New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

seamapi

Package Overview
Dependencies
Maintainers
1
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seamapi - npm Package Compare versions

Comparing version 2.1.0 to 2.3.0

dist/chunk-XBD7HWBY.mjs

582

dist/cli/entry.js

@@ -9,2 +9,6 @@ #!/usr/bin/env node

var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, copyDefault, desc) => {

@@ -22,8 +26,561 @@ if (module2 && typeof module2 === "object" || typeof module2 === "function") {

// src/cli/global-options.ts
var import_yargs = __toESM(require("yargs"));
// src/cli/entry.ts
var import_yargs = __toESM(require("yargs/yargs"));
var import_helpers = require("yargs/helpers");
var parser = (0, import_yargs.default)((0, import_helpers.hideBin)(process.argv));
var parserWithOptions = parser.option("api-key", {
describe: "Seam API key (the environment variable SEAM_API_KEY is used if not provided)"
// src/cli/commands/index.ts
var commands_exports = {};
__export(commands_exports, {
accessCodes: () => access_codes_exports,
actionAttempts: () => action_attempts_exports,
connectWebviews: () => connect_webviews_exports,
connectedAccounts: () => connected_accounts_exports,
devices: () => devices_exports,
locks: () => locks_exports,
workspaces: () => workspaces_exports
});
// src/cli/commands/access-codes.ts
var access_codes_exports = {};
__export(access_codes_exports, {
default: () => access_codes_default
});
// src/cli/lib/execute-command.ts
var import_node_inspect_extracted = require("node-inspect-extracted");
var import_change_case = require("change-case");
// src/index.ts
var import_axios = __toESM(require("axios"));
// src/lib/api-error.ts
var SeamAPIError = class extends Error {
constructor(status, metadata) {
super((_a = metadata == null ? void 0 : metadata.message) != null ? _a : "Unknown Error");
this.status = status;
this.metadata = metadata;
var _a;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
toString() {
var _a, _b;
return `SeamAPIError: ${this.status}, ${(_a = this.metadata) == null ? void 0 : _a.message} (${(_b = this.metadata) == null ? void 0 : _b.type})`;
}
};
var SeamActionAttemptError = class extends Error {
constructor(type, message, action_type) {
super(`${type} performing ${action_type}: ${message}`);
this.type = type;
this.message = message;
this.action_type = action_type;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
toString() {
return `SeamActionAttemptError: ${this.type} performing ${this.action_type}: ${this.message}`;
}
};
// src/routes.ts
var Routes = class {
constructor() {
this.workspaces = {
list: () => this.makeRequestAndFormat("workspaces", {
url: "/workspaces/list"
}),
get: () => this.makeRequestAndFormat("workspace", {
url: "/workspaces/get"
}),
resetSandbox: () => this.makeRequest({
url: "/workspaces/reset_sandbox",
method: "POST"
})
};
this.locks = {
list: (connectedAccountId) => this.makeRequestAndFormat("locks", {
url: "/locks/list",
params: connectedAccountId ? {
connected_account_id: connectedAccountId
} : {}
}),
get: (deviceId) => this.makeRequestAndFormat("lock", {
url: "/locks/get",
params: {
device_id: deviceId
}
}),
lockDoor: (deviceId) => this.makeActionAttemptRequest(null, {
url: "/locks/lock_door",
data: {
device_id: deviceId
},
method: "POST"
}),
unlockDoor: (deviceId) => this.makeActionAttemptRequest(null, {
url: "/locks/unlock_door",
data: {
device_id: deviceId
},
method: "POST"
})
};
this.devices = {
list: (connectedAccountId) => this.makeRequestAndFormat("devices", {
url: "/devices/list",
params: connectedAccountId ? {
connected_account_id: connectedAccountId
} : {}
}),
get: (deviceId) => this.makeRequestAndFormat("device", {
url: "/devices/get",
params: {
device_id: deviceId
}
})
};
this.connectWebviews = {
list: () => this.makeRequestAndFormat("connect_webviews", {
url: "/connect_webviews/list"
}),
get: (connectWebviewId) => this.makeRequestAndFormat("connect_webview", {
url: "/connect_webviews/get",
params: {
connect_webview_id: connectWebviewId
}
}),
create: (params) => this.makeRequestAndFormat("connect_webview", {
url: "/connect_webviews/create",
method: "POST",
data: params
})
};
this.accessCodes = {
list: (params) => this.makeRequestAndFormat("access_codes", {
url: "/access_codes/list",
params
}),
create: async (params) => {
const parsedParams = Object.assign({}, params);
if (params.starts_at === "object" && params.starts_at !== null) {
parsedParams.starts_at = params.starts_at.toISOString();
}
if (typeof params.ends_at === "object" && params.starts_at !== null) {
parsedParams.ends_at = params.ends_at.toISOString();
}
return await this.makeActionAttemptRequest("access_code", {
url: "/access_codes/create",
method: "POST",
data: parsedParams
});
},
delete: (params) => this.makeActionAttemptRequest(null, {
url: "/access_codes/delete",
method: "POST",
data: params
})
};
this.connectedAccounts = {
list: () => this.makeRequestAndFormat("connected_accounts", {
url: "/connected_accounts/list"
}),
get: (connectedAccountId) => this.makeRequestAndFormat("connected_account", {
url: "/connected_accounts/get",
params: {
connected_account_id: connectedAccountId
}
})
};
this.actionAttempts = {
get: (actionAttemptId) => this.makeRequestAndFormat("action_attempt", {
url: "/action_attempts/get",
params: {
action_attempt_id: actionAttemptId
}
})
};
}
async formatResponse(innerObjectName, response) {
return response[innerObjectName];
}
async awaitActionAttempt(actionAttempt) {
while (actionAttempt.status === "pending") {
actionAttempt = await this.actionAttempts.get(actionAttempt.action_attempt_id);
if (actionAttempt.status !== "pending")
break;
await new Promise((resolve) => setTimeout(resolve, 250));
}
if (actionAttempt.status === "error") {
throw new SeamActionAttemptError(actionAttempt.error.type, actionAttempt.error.message, actionAttempt.action_type);
}
return actionAttempt;
}
async makeRequestAndFormat(innerObjectName, request) {
const res = await this.makeRequest(request);
return this.formatResponse(innerObjectName, res);
}
async makeActionAttemptRequest(innerObjectName, request) {
const pendingActionAttempt = await this.makeRequestAndFormat("action_attempt", request);
const actionAttempt = await this.awaitActionAttempt(pendingActionAttempt);
if (innerObjectName === null)
return actionAttempt.result;
return actionAttempt.result[innerObjectName];
}
};
// src/types/models.ts
var Provider = /* @__PURE__ */ ((Provider2) => {
Provider2["AUGUST"] = "august";
Provider2["SCHLAGE"] = "schlage";
Provider2["YALE"] = "yale";
Provider2["NOISEAWARE"] = "noiseaware";
Provider2["SMARTTHINGS"] = "smartthings";
return Provider2;
})(Provider || {});
// src/index.ts
var Seam = class extends Routes {
constructor(apiKey, endpoint = "https://connect.getseam.com") {
super();
if (!apiKey) {
apiKey = process.env.SEAM_API_KEY;
}
if (!apiKey) {
throw new Error("SEAM_API_KEY not found in environment, and apiKey not provided");
}
this.client = import_axios.default.create({
baseURL: endpoint,
headers: {
Authorization: `Bearer ${apiKey}`
}
});
}
async makeRequest(request) {
try {
const response = await this.client.request(request);
return response.data;
} catch (error) {
if (import_axios.default.isAxiosError(error) && error.response) {
throw new SeamAPIError(error.response.status, error.response.data.error);
}
throw error;
}
}
};
var src_default = Seam;
// src/cli/lib/execute-command.ts
var executeCommand = async (methodName, args, executeArgs) => {
let spinner = void 0;
const displaySpinner = typeof window === "undefined" && !(executeArgs.quiet || executeArgs.json);
if (displaySpinner) {
const ora = await Promise.resolve().then(() => __toESM(require("ora")));
spinner = ora.default(methodName.split(".").map((v) => (0, import_change_case.paramCase)(v)).join(".")).start();
}
const seam = new src_default(executeArgs["api-key"]);
let method = seam;
for (const path of methodName.split(".")) {
method = method[path];
}
try {
const result = await method(...args);
spinner == null ? void 0 : spinner.succeed();
if (executeArgs.json) {
process.stdout.write(JSON.stringify(result, null, 2));
} else {
process.stdout.write((0, import_node_inspect_extracted.inspect)(result, { depth: 2, colors: true, compact: false }));
}
process.stdout.write("\n");
} catch (error) {
let message = "Unknown error";
if (error instanceof SeamAPIError) {
message = `${error.name} (HTTP ${error.status}): ${error.message}`;
} else if (error instanceof Error) {
message = error.message;
}
spinner == null ? void 0 : spinner.fail(message);
process.exit(1);
}
};
var execute_command_default = executeCommand;
// src/cli/commands/access-codes.ts
var command = {
command: "access-codes",
aliases: ["access-code", "ac"],
describe: "interact with access codes",
builder: (yargs2) => {
return yargs2.demandCommand().command("list", "list access codes", (yargs3) => {
return yargs3.option("device-id", {
describe: "filter by device ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("accessCodes.list", [
{
device_id: argv.deviceId
}
], argv);
}).command("create", "create an access code", (yargs3) => {
return yargs3.option("device-id", {
describe: "the device ID",
demandOption: true,
type: "string"
}).option("name", {
describe: "the name of the access code",
type: "string"
}).option("code", {
describe: "the code",
defaultDescription: "generate a random code",
type: "string"
}).option("starts-at", {
describe: "the start datetime of the access code",
coerce: (v) => v ? new Date(v) : void 0,
implies: "ends-at"
}).option("ends-at", {
describe: "the end datetime of the access code",
coerce: (v) => v ? new Date(v) : void 0,
implies: "starts-at"
});
}, async (argv) => {
await execute_command_default("accessCodes.create", [
{
device_id: argv.deviceId,
name: argv.name,
code: argv.code,
starts_at: argv.startsAt,
ends_at: argv.endsAt
}
], argv);
}).command("delete <id>", "delete an access code", (yargs3) => {
return yargs3.positional("id", {
describe: "the access code ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("accessCodes.delete", [
{
access_code_id: argv.id
}
], argv);
});
},
handler: () => {
}
};
var access_codes_default = command;
// src/cli/commands/action-attempts.ts
var action_attempts_exports = {};
__export(action_attempts_exports, {
default: () => action_attempts_default
});
var command2 = {
command: "action-attempts",
aliases: ["action-attempt", "aa"],
describe: "interact with action attempts",
builder: (yargs2) => {
return yargs2.demandCommand().command("get <id>", "get an action attempt", (yargs3) => {
return yargs3.positional("id", {
describe: "the action attempt ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("actionAttempts.get", [argv.id], argv);
});
},
handler: () => {
}
};
var action_attempts_default = command2;
// src/cli/commands/connect-webviews.ts
var connect_webviews_exports = {};
__export(connect_webviews_exports, {
default: () => connect_webviews_default
});
var command3 = {
command: "connect-webviews",
aliases: ["connect-webview", "cw"],
describe: "interact with connect webviews",
builder: (yargs2) => {
return yargs2.demandCommand().command("list", "list connect webviews", () => {
}, async (yargs3) => {
await execute_command_default("connectWebviews.list", [], yargs3);
}).command("get <id>", "get a connect webview", (yargs3) => {
return yargs3.positional("id", {
describe: "the connect webview ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("connectWebviews.get", [argv.id], argv);
}).command("create", "create a connect webview", (yargs3) => {
return yargs3.option("accepted-providers", {
describe: "providers to accept",
demandOption: true,
type: "array",
choices: Object.values(Provider),
alias: "ap"
}).check((argv) => {
if (argv["accepted-providers"].length === 0) {
throw new Error("You must specify at least one accepted provider");
}
return true;
});
}, async (argv) => {
await execute_command_default("connectWebviews.create", [
{
accepted_providers: argv["accepted-providers"]
}
], argv);
});
},
handler: () => {
}
};
var connect_webviews_default = command3;
// src/cli/commands/connected-accounts.ts
var connected_accounts_exports = {};
__export(connected_accounts_exports, {
default: () => connected_accounts_default
});
var command4 = {
command: "connected-accounts",
aliases: ["connected-account", "ca"],
describe: "interact with connected accounts",
builder: (yargs2) => {
return yargs2.demandCommand().command("list", "list connected accounts", () => {
}, async (argv) => {
await execute_command_default("connectedAccounts.list", [], argv);
}).command("get <id>", "get a connected account", (yargs3) => {
return yargs3.positional("id", {
describe: "the connected account ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("connectedAccounts.get", [argv.id], argv);
});
},
handler: () => {
}
};
var connected_accounts_default = command4;
// src/cli/commands/devices.ts
var devices_exports = {};
__export(devices_exports, {
default: () => devices_default
});
var command5 = {
command: "devices",
aliases: ["device"],
describe: "interact with devices",
builder: (yargs2) => {
return yargs2.demandCommand().command("get <id>", "get a device", (yargs3) => {
return yargs3.positional("id", {
describe: "the device ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("devices.get", [argv.id], argv);
}).command("list", "list devices", (yargs3) => {
return yargs3.option("connected-account-id", {
describe: "filter by connected account ID",
type: "string",
alias: "ca"
});
}, async (argv) => {
await execute_command_default("devices.list", [argv.connectedAccountId], argv);
});
},
handler: () => {
}
};
var devices_default = command5;
// src/cli/commands/locks.ts
var locks_exports = {};
__export(locks_exports, {
default: () => locks_default
});
var command6 = {
command: "locks",
aliases: ["lock"],
describe: "interact with locks",
builder: (yargs2) => {
return yargs2.demandCommand().command("get <id>", "get a lock", (yargs3) => {
return yargs3.positional("id", {
describe: "the lock ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("locks.get", [argv.id], argv);
}).command("list", "list locks", (yargs3) => {
return yargs3.option("connected-account-id", {
describe: "filter by connected account ID",
type: "string",
alias: "ca"
});
}, async (argv) => {
await execute_command_default("locks.list", [argv.connectedAccountId], argv);
}).command("lock-door <id>", "lock a door", (yargs3) => {
return yargs3.positional("id", {
describe: "the lock ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("locks.lockDoor", [argv.id], argv);
}).command("unlock-door <id>", "unlock a door", (yargs3) => {
return yargs3.positional("id", {
describe: "the lock ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("locks.unlockDoor", [argv.id], argv);
});
},
handler: () => {
}
};
var locks_default = command6;
// src/cli/commands/workspaces.ts
var workspaces_exports = {};
__export(workspaces_exports, {
default: () => workspaces_default
});
var command7 = {
command: "workspaces",
aliases: ["workspace"],
describe: "interact with workspaces",
builder: (yargs2) => {
return yargs2.demandCommand().command("get", "get the workspace associated with the current API key", (yargs3) => yargs3, async (argv) => {
await execute_command_default("workspaces.get", [], argv);
}).command("list", "list workspaces", (yargs3) => yargs3, async (argv) => {
await execute_command_default("workspaces.list", [], argv);
}).command("reset-sandbox", "reset the sandbox associated with the current API key", (yargs3) => yargs3, async (argv) => {
await execute_command_default("workspaces.resetSandbox", [], argv);
});
},
handler: () => {
}
};
var workspaces_default = command7;
// src/cli/lib/global-options.ts
var getParserWithOptions = (yargsInstance) => yargsInstance.option("api-key", {
describe: "Seam API key (the environment variable SEAM_API_KEY is used if not provided)",
type: "string"
}).option("quiet", {

@@ -36,14 +593,15 @@ describe: "Hide progress indicators",

}).group(["api-key", "quiet", "json", "help", "version"], "Global Options:");
var global_options_default = parserWithOptions;
// src/cli/index.ts
var cli = global_options_default.commandDir("./commands", {
extensions: [true ? "js" : "ts"],
visit: (command) => {
return command.default;
var getCLI = (yargs2) => {
let builder = getParserWithOptions(yargs2);
for (const command8 of Object.values(commands_exports)) {
builder = builder.command(command8.default);
}
}).demandCommand().strict();
builder = builder.demandCommand().strict().usage("Control locks, lights and other internet of things devices with Seam's simple API.");
return builder;
};
// src/cli/entry.ts
cli.parse();
getCLI((0, import_yargs.default)()).parse((0, import_helpers.hideBin)(process.argv));
//# sourceMappingURL=entry.js.map

8

dist/cli/index.d.ts

@@ -1,5 +0,5 @@

import * as yargs from 'yargs';
import { Argv } from 'yargs';
declare const cli: yargs.Argv<{
"api-key": unknown;
declare const getCLI: (yargs: Argv) => Argv<{
"api-key": string | undefined;
} & {

@@ -11,2 +11,2 @@ quiet: boolean | undefined;

export { cli };
export { getCLI };

@@ -32,11 +32,560 @@ var __create = Object.create;

__export(cli_exports, {
cli: () => cli
getCLI: () => getCLI
});
// src/cli/global-options.ts
var import_yargs = __toESM(require("yargs"));
var import_helpers = require("yargs/helpers");
var parser = (0, import_yargs.default)((0, import_helpers.hideBin)(process.argv));
var parserWithOptions = parser.option("api-key", {
describe: "Seam API key (the environment variable SEAM_API_KEY is used if not provided)"
// src/cli/commands/index.ts
var commands_exports = {};
__export(commands_exports, {
accessCodes: () => access_codes_exports,
actionAttempts: () => action_attempts_exports,
connectWebviews: () => connect_webviews_exports,
connectedAccounts: () => connected_accounts_exports,
devices: () => devices_exports,
locks: () => locks_exports,
workspaces: () => workspaces_exports
});
// src/cli/commands/access-codes.ts
var access_codes_exports = {};
__export(access_codes_exports, {
default: () => access_codes_default
});
// src/cli/lib/execute-command.ts
var import_node_inspect_extracted = require("node-inspect-extracted");
var import_change_case = require("change-case");
// src/index.ts
var import_axios = __toESM(require("axios"));
// src/lib/api-error.ts
var SeamAPIError = class extends Error {
constructor(status, metadata) {
super((_a = metadata == null ? void 0 : metadata.message) != null ? _a : "Unknown Error");
this.status = status;
this.metadata = metadata;
var _a;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
toString() {
var _a, _b;
return `SeamAPIError: ${this.status}, ${(_a = this.metadata) == null ? void 0 : _a.message} (${(_b = this.metadata) == null ? void 0 : _b.type})`;
}
};
var SeamActionAttemptError = class extends Error {
constructor(type, message, action_type) {
super(`${type} performing ${action_type}: ${message}`);
this.type = type;
this.message = message;
this.action_type = action_type;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
toString() {
return `SeamActionAttemptError: ${this.type} performing ${this.action_type}: ${this.message}`;
}
};
// src/routes.ts
var Routes = class {
constructor() {
this.workspaces = {
list: () => this.makeRequestAndFormat("workspaces", {
url: "/workspaces/list"
}),
get: () => this.makeRequestAndFormat("workspace", {
url: "/workspaces/get"
}),
resetSandbox: () => this.makeRequest({
url: "/workspaces/reset_sandbox",
method: "POST"
})
};
this.locks = {
list: (connectedAccountId) => this.makeRequestAndFormat("locks", {
url: "/locks/list",
params: connectedAccountId ? {
connected_account_id: connectedAccountId
} : {}
}),
get: (deviceId) => this.makeRequestAndFormat("lock", {
url: "/locks/get",
params: {
device_id: deviceId
}
}),
lockDoor: (deviceId) => this.makeActionAttemptRequest(null, {
url: "/locks/lock_door",
data: {
device_id: deviceId
},
method: "POST"
}),
unlockDoor: (deviceId) => this.makeActionAttemptRequest(null, {
url: "/locks/unlock_door",
data: {
device_id: deviceId
},
method: "POST"
})
};
this.devices = {
list: (connectedAccountId) => this.makeRequestAndFormat("devices", {
url: "/devices/list",
params: connectedAccountId ? {
connected_account_id: connectedAccountId
} : {}
}),
get: (deviceId) => this.makeRequestAndFormat("device", {
url: "/devices/get",
params: {
device_id: deviceId
}
})
};
this.connectWebviews = {
list: () => this.makeRequestAndFormat("connect_webviews", {
url: "/connect_webviews/list"
}),
get: (connectWebviewId) => this.makeRequestAndFormat("connect_webview", {
url: "/connect_webviews/get",
params: {
connect_webview_id: connectWebviewId
}
}),
create: (params) => this.makeRequestAndFormat("connect_webview", {
url: "/connect_webviews/create",
method: "POST",
data: params
})
};
this.accessCodes = {
list: (params) => this.makeRequestAndFormat("access_codes", {
url: "/access_codes/list",
params
}),
create: async (params) => {
const parsedParams = Object.assign({}, params);
if (params.starts_at === "object" && params.starts_at !== null) {
parsedParams.starts_at = params.starts_at.toISOString();
}
if (typeof params.ends_at === "object" && params.starts_at !== null) {
parsedParams.ends_at = params.ends_at.toISOString();
}
return await this.makeActionAttemptRequest("access_code", {
url: "/access_codes/create",
method: "POST",
data: parsedParams
});
},
delete: (params) => this.makeActionAttemptRequest(null, {
url: "/access_codes/delete",
method: "POST",
data: params
})
};
this.connectedAccounts = {
list: () => this.makeRequestAndFormat("connected_accounts", {
url: "/connected_accounts/list"
}),
get: (connectedAccountId) => this.makeRequestAndFormat("connected_account", {
url: "/connected_accounts/get",
params: {
connected_account_id: connectedAccountId
}
})
};
this.actionAttempts = {
get: (actionAttemptId) => this.makeRequestAndFormat("action_attempt", {
url: "/action_attempts/get",
params: {
action_attempt_id: actionAttemptId
}
})
};
}
async formatResponse(innerObjectName, response) {
return response[innerObjectName];
}
async awaitActionAttempt(actionAttempt) {
while (actionAttempt.status === "pending") {
actionAttempt = await this.actionAttempts.get(actionAttempt.action_attempt_id);
if (actionAttempt.status !== "pending")
break;
await new Promise((resolve) => setTimeout(resolve, 250));
}
if (actionAttempt.status === "error") {
throw new SeamActionAttemptError(actionAttempt.error.type, actionAttempt.error.message, actionAttempt.action_type);
}
return actionAttempt;
}
async makeRequestAndFormat(innerObjectName, request) {
const res = await this.makeRequest(request);
return this.formatResponse(innerObjectName, res);
}
async makeActionAttemptRequest(innerObjectName, request) {
const pendingActionAttempt = await this.makeRequestAndFormat("action_attempt", request);
const actionAttempt = await this.awaitActionAttempt(pendingActionAttempt);
if (innerObjectName === null)
return actionAttempt.result;
return actionAttempt.result[innerObjectName];
}
};
// src/types/models.ts
var Provider = /* @__PURE__ */ ((Provider2) => {
Provider2["AUGUST"] = "august";
Provider2["SCHLAGE"] = "schlage";
Provider2["YALE"] = "yale";
Provider2["NOISEAWARE"] = "noiseaware";
Provider2["SMARTTHINGS"] = "smartthings";
return Provider2;
})(Provider || {});
// src/index.ts
var Seam = class extends Routes {
constructor(apiKey, endpoint = "https://connect.getseam.com") {
super();
if (!apiKey) {
apiKey = process.env.SEAM_API_KEY;
}
if (!apiKey) {
throw new Error("SEAM_API_KEY not found in environment, and apiKey not provided");
}
this.client = import_axios.default.create({
baseURL: endpoint,
headers: {
Authorization: `Bearer ${apiKey}`
}
});
}
async makeRequest(request) {
try {
const response = await this.client.request(request);
return response.data;
} catch (error) {
if (import_axios.default.isAxiosError(error) && error.response) {
throw new SeamAPIError(error.response.status, error.response.data.error);
}
throw error;
}
}
};
var src_default = Seam;
// src/cli/lib/execute-command.ts
var executeCommand = async (methodName, args, executeArgs) => {
let spinner = void 0;
const displaySpinner = typeof window === "undefined" && !(executeArgs.quiet || executeArgs.json);
if (displaySpinner) {
const ora = await Promise.resolve().then(() => __toESM(require("ora")));
spinner = ora.default(methodName.split(".").map((v) => (0, import_change_case.paramCase)(v)).join(".")).start();
}
const seam = new src_default(executeArgs["api-key"]);
let method = seam;
for (const path of methodName.split(".")) {
method = method[path];
}
try {
const result = await method(...args);
spinner == null ? void 0 : spinner.succeed();
if (executeArgs.json) {
process.stdout.write(JSON.stringify(result, null, 2));
} else {
process.stdout.write((0, import_node_inspect_extracted.inspect)(result, { depth: 2, colors: true, compact: false }));
}
process.stdout.write("\n");
} catch (error) {
let message = "Unknown error";
if (error instanceof SeamAPIError) {
message = `${error.name} (HTTP ${error.status}): ${error.message}`;
} else if (error instanceof Error) {
message = error.message;
}
spinner == null ? void 0 : spinner.fail(message);
process.exit(1);
}
};
var execute_command_default = executeCommand;
// src/cli/commands/access-codes.ts
var command = {
command: "access-codes",
aliases: ["access-code", "ac"],
describe: "interact with access codes",
builder: (yargs) => {
return yargs.demandCommand().command("list", "list access codes", (yargs2) => {
return yargs2.option("device-id", {
describe: "filter by device ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("accessCodes.list", [
{
device_id: argv.deviceId
}
], argv);
}).command("create", "create an access code", (yargs2) => {
return yargs2.option("device-id", {
describe: "the device ID",
demandOption: true,
type: "string"
}).option("name", {
describe: "the name of the access code",
type: "string"
}).option("code", {
describe: "the code",
defaultDescription: "generate a random code",
type: "string"
}).option("starts-at", {
describe: "the start datetime of the access code",
coerce: (v) => v ? new Date(v) : void 0,
implies: "ends-at"
}).option("ends-at", {
describe: "the end datetime of the access code",
coerce: (v) => v ? new Date(v) : void 0,
implies: "starts-at"
});
}, async (argv) => {
await execute_command_default("accessCodes.create", [
{
device_id: argv.deviceId,
name: argv.name,
code: argv.code,
starts_at: argv.startsAt,
ends_at: argv.endsAt
}
], argv);
}).command("delete <id>", "delete an access code", (yargs2) => {
return yargs2.positional("id", {
describe: "the access code ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("accessCodes.delete", [
{
access_code_id: argv.id
}
], argv);
});
},
handler: () => {
}
};
var access_codes_default = command;
// src/cli/commands/action-attempts.ts
var action_attempts_exports = {};
__export(action_attempts_exports, {
default: () => action_attempts_default
});
var command2 = {
command: "action-attempts",
aliases: ["action-attempt", "aa"],
describe: "interact with action attempts",
builder: (yargs) => {
return yargs.demandCommand().command("get <id>", "get an action attempt", (yargs2) => {
return yargs2.positional("id", {
describe: "the action attempt ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("actionAttempts.get", [argv.id], argv);
});
},
handler: () => {
}
};
var action_attempts_default = command2;
// src/cli/commands/connect-webviews.ts
var connect_webviews_exports = {};
__export(connect_webviews_exports, {
default: () => connect_webviews_default
});
var command3 = {
command: "connect-webviews",
aliases: ["connect-webview", "cw"],
describe: "interact with connect webviews",
builder: (yargs) => {
return yargs.demandCommand().command("list", "list connect webviews", () => {
}, async (yargs2) => {
await execute_command_default("connectWebviews.list", [], yargs2);
}).command("get <id>", "get a connect webview", (yargs2) => {
return yargs2.positional("id", {
describe: "the connect webview ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("connectWebviews.get", [argv.id], argv);
}).command("create", "create a connect webview", (yargs2) => {
return yargs2.option("accepted-providers", {
describe: "providers to accept",
demandOption: true,
type: "array",
choices: Object.values(Provider),
alias: "ap"
}).check((argv) => {
if (argv["accepted-providers"].length === 0) {
throw new Error("You must specify at least one accepted provider");
}
return true;
});
}, async (argv) => {
await execute_command_default("connectWebviews.create", [
{
accepted_providers: argv["accepted-providers"]
}
], argv);
});
},
handler: () => {
}
};
var connect_webviews_default = command3;
// src/cli/commands/connected-accounts.ts
var connected_accounts_exports = {};
__export(connected_accounts_exports, {
default: () => connected_accounts_default
});
var command4 = {
command: "connected-accounts",
aliases: ["connected-account", "ca"],
describe: "interact with connected accounts",
builder: (yargs) => {
return yargs.demandCommand().command("list", "list connected accounts", () => {
}, async (argv) => {
await execute_command_default("connectedAccounts.list", [], argv);
}).command("get <id>", "get a connected account", (yargs2) => {
return yargs2.positional("id", {
describe: "the connected account ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("connectedAccounts.get", [argv.id], argv);
});
},
handler: () => {
}
};
var connected_accounts_default = command4;
// src/cli/commands/devices.ts
var devices_exports = {};
__export(devices_exports, {
default: () => devices_default
});
var command5 = {
command: "devices",
aliases: ["device"],
describe: "interact with devices",
builder: (yargs) => {
return yargs.demandCommand().command("get <id>", "get a device", (yargs2) => {
return yargs2.positional("id", {
describe: "the device ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("devices.get", [argv.id], argv);
}).command("list", "list devices", (yargs2) => {
return yargs2.option("connected-account-id", {
describe: "filter by connected account ID",
type: "string",
alias: "ca"
});
}, async (argv) => {
await execute_command_default("devices.list", [argv.connectedAccountId], argv);
});
},
handler: () => {
}
};
var devices_default = command5;
// src/cli/commands/locks.ts
var locks_exports = {};
__export(locks_exports, {
default: () => locks_default
});
var command6 = {
command: "locks",
aliases: ["lock"],
describe: "interact with locks",
builder: (yargs) => {
return yargs.demandCommand().command("get <id>", "get a lock", (yargs2) => {
return yargs2.positional("id", {
describe: "the lock ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("locks.get", [argv.id], argv);
}).command("list", "list locks", (yargs2) => {
return yargs2.option("connected-account-id", {
describe: "filter by connected account ID",
type: "string",
alias: "ca"
});
}, async (argv) => {
await execute_command_default("locks.list", [argv.connectedAccountId], argv);
}).command("lock-door <id>", "lock a door", (yargs2) => {
return yargs2.positional("id", {
describe: "the lock ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("locks.lockDoor", [argv.id], argv);
}).command("unlock-door <id>", "unlock a door", (yargs2) => {
return yargs2.positional("id", {
describe: "the lock ID",
demandOption: true,
type: "string"
});
}, async (argv) => {
await execute_command_default("locks.unlockDoor", [argv.id], argv);
});
},
handler: () => {
}
};
var locks_default = command6;
// src/cli/commands/workspaces.ts
var workspaces_exports = {};
__export(workspaces_exports, {
default: () => workspaces_default
});
var command7 = {
command: "workspaces",
aliases: ["workspace"],
describe: "interact with workspaces",
builder: (yargs) => {
return yargs.demandCommand().command("get", "get the workspace associated with the current API key", (yargs2) => yargs2, async (argv) => {
await execute_command_default("workspaces.get", [], argv);
}).command("list", "list workspaces", (yargs2) => yargs2, async (argv) => {
await execute_command_default("workspaces.list", [], argv);
}).command("reset-sandbox", "reset the sandbox associated with the current API key", (yargs2) => yargs2, async (argv) => {
await execute_command_default("workspaces.resetSandbox", [], argv);
});
},
handler: () => {
}
};
var workspaces_default = command7;
// src/cli/lib/global-options.ts
var getParserWithOptions = (yargsInstance) => yargsInstance.option("api-key", {
describe: "Seam API key (the environment variable SEAM_API_KEY is used if not provided)",
type: "string"
}).option("quiet", {

@@ -49,16 +598,17 @@ describe: "Hide progress indicators",

}).group(["api-key", "quiet", "json", "help", "version"], "Global Options:");
var global_options_default = parserWithOptions;
// src/cli/index.ts
var cli = global_options_default.commandDir("./commands", {
extensions: [true ? "js" : "ts"],
visit: (command) => {
return command.default;
var getCLI = (yargs) => {
let builder = getParserWithOptions(yargs);
for (const command8 of Object.values(commands_exports)) {
builder = builder.command(command8.default);
}
}).demandCommand().strict();
builder = builder.demandCommand().strict().usage("Control locks, lights and other internet of things devices with Seam's simple API.");
return builder;
};
module.exports = __toCommonJS(cli_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
cli
getCLI
});
//# sourceMappingURL=index.js.map

@@ -10,3 +10,3 @@ {

],
"version": "2.1.0",
"version": "2.3.0",
"license": "MIT",

@@ -23,6 +23,11 @@ "sideEffects": false,

},
"./cli": {
"require": "./dist/cli/index.js",
"import": "./dist/cli/index.js",
"types": "./dist/cli/index.d.ts"
"./cli/browser": {
"require": "./dist/cli/browser.js",
"import": "./dist/cli/browser.mjs",
"types": "./dist/cli/browser.d.ts"
},
"./dist/cli/browser": {
"require": "./dist/cli/browser.js",
"import": "./dist/cli/browser.mjs",
"types": "./dist/cli/browser.d.ts"
}

@@ -37,2 +42,4 @@ },

"change-case": "4.1.2",
"eventemitter3": "4.0.7",
"node-inspect-extracted": "1.1.0",
"ora": "5.4.1",

@@ -52,2 +59,3 @@ "yargs": "17.3.1"

"esbuild": "0.14.18",
"esbuild-plugin-cache": "0.2.9",
"esbuild-runner": "2.2.1",

@@ -65,2 +73,3 @@ "husky": ">=6",

"type-fest": "2.11.1",
"typed-emitter": "2.1.0",
"typedoc": "0.22.12",

@@ -71,7 +80,6 @@ "typedoc-plugin-markdown": "3.11.12",

"lint-staged": {
"*.{ts,css,md}": "prettier --write"
"*.{ts,css,md,js}": "prettier --write"
},
"pkg": {
"outputPath": "cli-binaries",
"assets": "./dist/cli/commands/**/*"
"outputPath": "cli-binaries"
},

@@ -83,2 +91,3 @@ "scripts": {

"build:docs": "typedoc",
"build:json-response-schemas": "ts-json-schema-generator --path src/types/route-responses.ts -o src/types/route-responses.generated.json && ts-json-schema-generator --path src/types/models.ts -o src/types/models.generated.json",
"build": "npm run build:package && npm run build:docs",

@@ -88,3 +97,2 @@ "pack:cli": "pkg -c package.json dist/cli/entry.js",

"format:check": "prettier --check .",
"build:json-response-schemas": "ts-json-schema-generator --path src/types/route-responses.ts -o src/types/route-responses.generated.json && ts-json-schema-generator --path src/types/models.ts -o src/types/models.generated.json",
"test": "npm run build:json-response-schemas && ava",

@@ -91,0 +99,0 @@ "test:watch": "npm run build:json-response-schemas && ava --watch",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc