@seamapi/cli 0.0.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -3
- package/bin/cli.d.ts +2 -0
- package/bin/cli.js +233 -0
- package/bin/cli.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +5 -0
- package/index.js.map +1 -0
- package/lib/get-api-blueprint.d.ts +3 -0
- package/lib/get-api-blueprint.js +11 -0
- package/lib/get-api-blueprint.js.map +1 -0
- package/lib/get-command-blueprint-def.d.ts +2 -0
- package/lib/get-command-blueprint-def.js +11 -0
- package/lib/get-command-blueprint-def.js.map +1 -0
- package/lib/get-config-store.d.ts +2 -0
- package/lib/get-config-store.js +5 -0
- package/lib/get-config-store.js.map +1 -0
- package/lib/get-current-workspace-id.d.ts +1 -0
- package/lib/get-current-workspace-id.js +10 -0
- package/lib/get-current-workspace-id.js.map +1 -0
- package/lib/get-seam.d.ts +3 -0
- package/lib/get-seam.js +26 -0
- package/lib/get-seam.js.map +1 -0
- package/lib/get-server.d.ts +1 -0
- package/lib/get-server.js +7 -0
- package/lib/get-server.js.map +1 -0
- package/lib/interact-for-access-code.d.ts +3 -0
- package/lib/interact-for-access-code.js +19 -0
- package/lib/interact-for-access-code.js.map +1 -0
- package/lib/interact-for-acs-entrance.d.ts +1 -0
- package/lib/interact-for-acs-entrance.js +15 -0
- package/lib/interact-for-acs-entrance.js.map +1 -0
- package/lib/interact-for-acs-system.d.ts +1 -0
- package/lib/interact-for-acs-system.js +16 -0
- package/lib/interact-for-acs-system.js.map +1 -0
- package/lib/interact-for-acs-user.d.ts +1 -0
- package/lib/interact-for-acs-user.js +17 -0
- package/lib/interact-for-acs-user.js.map +1 -0
- package/lib/interact-for-action-attempt-poll.d.ts +2 -0
- package/lib/interact-for-action-attempt-poll.js +22 -0
- package/lib/interact-for-action-attempt-poll.js.map +1 -0
- package/lib/interact-for-array.d.ts +1 -0
- package/lib/interact-for-array.js +53 -0
- package/lib/interact-for-array.js.map +1 -0
- package/lib/interact-for-blueprint-object.d.ts +9 -0
- package/lib/interact-for-blueprint-object.js +235 -0
- package/lib/interact-for-blueprint-object.js.map +1 -0
- package/lib/interact-for-command-params.d.ts +5 -0
- package/lib/interact-for-command-params.js +11 -0
- package/lib/interact-for-command-params.js.map +1 -0
- package/lib/interact-for-command-selection.d.ts +2 -0
- package/lib/interact-for-command-selection.js +76 -0
- package/lib/interact-for-command-selection.js.map +1 -0
- package/lib/interact-for-connected-account.d.ts +1 -0
- package/lib/interact-for-connected-account.js +20 -0
- package/lib/interact-for-connected-account.js.map +1 -0
- package/lib/interact-for-custom-metadata.d.ts +6 -0
- package/lib/interact-for-custom-metadata.js +71 -0
- package/lib/interact-for-custom-metadata.js.map +1 -0
- package/lib/interact-for-device.d.ts +1 -0
- package/lib/interact-for-device.js +15 -0
- package/lib/interact-for-device.js.map +1 -0
- package/lib/interact-for-login.d.ts +1 -0
- package/lib/interact-for-login.js +39 -0
- package/lib/interact-for-login.js.map +1 -0
- package/lib/interact-for-resource.d.ts +11 -0
- package/lib/interact-for-resource.js +13 -0
- package/lib/interact-for-resource.js.map +1 -0
- package/lib/interact-for-server-selection.d.ts +1 -0
- package/lib/interact-for-server-selection.js +41 -0
- package/lib/interact-for-server-selection.js.map +1 -0
- package/lib/interact-for-timestamp.d.ts +1 -0
- package/lib/interact-for-timestamp.js +10 -0
- package/lib/interact-for-timestamp.js.map +1 -0
- package/lib/interact-for-use-remote-api-defs.d.ts +1 -0
- package/lib/interact-for-use-remote-api-defs.js +25 -0
- package/lib/interact-for-use-remote-api-defs.js.map +1 -0
- package/lib/interact-for-user-identity.d.ts +1 -0
- package/lib/interact-for-user-identity.js +15 -0
- package/lib/interact-for-user-identity.js.map +1 -0
- package/lib/interact-for-workspace-id.d.ts +1 -0
- package/lib/interact-for-workspace-id.js +31 -0
- package/lib/interact-for-workspace-id.js.map +1 -0
- package/lib/types.d.ts +5 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/util/ellipsis.d.ts +1 -0
- package/lib/util/ellipsis.js +6 -0
- package/lib/util/ellipsis.js.map +1 -0
- package/lib/util/request-seam-api.d.ts +4 -0
- package/lib/util/request-seam-api.js +28 -0
- package/lib/util/request-seam-api.js.map +1 -0
- package/lib/util/with-loading.d.ts +1 -0
- package/lib/util/with-loading.js +14 -0
- package/lib/util/with-loading.js.map +1 -0
- package/lib/validate-token.d.ts +1 -0
- package/lib/validate-token.js +19 -0
- package/lib/validate-token.js.map +1 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.js +3 -0
- package/lib/version.js.map +1 -0
- package/package.json +44 -18
- package/src/bin/cli.ts +265 -0
- package/src/index.ts +4 -1
- package/src/lib/get-api-blueprint.ts +17 -0
- package/src/lib/get-command-blueprint-def.ts +15 -0
- package/src/lib/get-config-store.ts +5 -0
- package/src/lib/get-current-workspace-id.ts +11 -0
- package/src/lib/get-seam.ts +43 -0
- package/src/lib/get-server.ts +9 -0
- package/src/lib/interact-for-access-code.ts +25 -0
- package/src/lib/interact-for-acs-entrance.ts +16 -0
- package/src/lib/interact-for-acs-system.ts +17 -0
- package/src/lib/interact-for-acs-user.ts +21 -0
- package/src/lib/interact-for-action-attempt-poll.ts +35 -0
- package/src/lib/interact-for-array.ts +61 -0
- package/src/lib/interact-for-blueprint-object.ts +274 -0
- package/src/lib/interact-for-command-params.ts +22 -0
- package/src/lib/interact-for-command-selection.ts +107 -0
- package/src/lib/interact-for-connected-account.ts +24 -0
- package/src/lib/interact-for-custom-metadata.ts +86 -0
- package/src/lib/interact-for-device.ts +15 -0
- package/src/lib/interact-for-login.ts +53 -0
- package/src/lib/interact-for-resource.ts +34 -0
- package/src/lib/interact-for-server-selection.ts +46 -0
- package/src/lib/interact-for-timestamp.ts +10 -0
- package/src/lib/interact-for-use-remote-api-defs.ts +27 -0
- package/src/lib/interact-for-user-identity.ts +16 -0
- package/src/lib/interact-for-workspace-id.ts +37 -0
- package/src/lib/types.ts +6 -0
- package/src/lib/util/ellipsis.ts +4 -0
- package/src/lib/util/request-seam-api.ts +43 -0
- package/src/lib/util/with-loading.ts +16 -0
- package/src/lib/validate-token.ts +28 -0
- package/src/lib/version.ts +3 -0
- package/src/lib/index.ts +0 -1
- package/src/lib/todo.ts +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
import { withLoading } from './util/with-loading.js';
|
|
3
|
+
export const interactForResource = async ({ resourceName, fetchResources, toChoice, message = `Select a ${resourceName}:`, }) => {
|
|
4
|
+
const resources = await withLoading(`Fetching ${resourceName.replace(/_/g, ' ')}s...`, fetchResources);
|
|
5
|
+
const { resourceId } = await prompts({
|
|
6
|
+
name: 'resourceId',
|
|
7
|
+
type: 'autocomplete',
|
|
8
|
+
message,
|
|
9
|
+
choices: resources.map(toChoice),
|
|
10
|
+
});
|
|
11
|
+
return resourceId;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=interact-for-resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interact-for-resource.js","sourceRoot":"","sources":["../src/lib/interact-for-resource.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAQpD,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAY,EAClD,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,OAAO,GAAG,YAAY,YAAY,GAAG,GAMtC,EAAE,EAAE;IACH,MAAM,SAAS,GAAG,MAAM,WAAW,CACjC,YAAY,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EACjD,cAAc,CACf,CAAA;IACD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,OAAO,CAAC;QACnC,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,cAAc;QACpB,OAAO;QACP,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;KACjC,CAAC,CAAA;IAEF,OAAO,UAAoB,CAAA;AAC7B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function interactForServerSelection(): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import prompts from 'prompts';
|
|
3
|
+
import { getConfigStore } from './get-config-store.js';
|
|
4
|
+
import { getServer } from './get-server.js';
|
|
5
|
+
export async function interactForServerSelection() {
|
|
6
|
+
const servers = [
|
|
7
|
+
'http://localhost:3020',
|
|
8
|
+
'https://connect.getseam.com',
|
|
9
|
+
'https://fakeseamconnect.seam.vc',
|
|
10
|
+
];
|
|
11
|
+
const { server } = await prompts([
|
|
12
|
+
{
|
|
13
|
+
type: 'select',
|
|
14
|
+
name: 'server',
|
|
15
|
+
message: 'Select a server:',
|
|
16
|
+
choices: servers.map((server) => ({ title: server, value: server })),
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
const config = getConfigStore();
|
|
20
|
+
if (server === servers[2]) {
|
|
21
|
+
let { userUrlSeed } = await prompts([
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
name: 'userUrlSeed',
|
|
25
|
+
message: 'You can input a custom server URL or leave this field empty to use a new fakeserver.',
|
|
26
|
+
},
|
|
27
|
+
]);
|
|
28
|
+
if (userUrlSeed.trim().length === 0) {
|
|
29
|
+
userUrlSeed = randomBytes(5).toString('hex');
|
|
30
|
+
}
|
|
31
|
+
config.set('server', `https://${userUrlSeed}.fakeseamconnect.seam.vc`);
|
|
32
|
+
config.set(`${getServer()}.pat`, `seam_apikey1_token`);
|
|
33
|
+
console.log(`PAT set to use fakeseamconnect with "seam_apikey1_token"`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
config.set('server', server);
|
|
37
|
+
}
|
|
38
|
+
config.delete('current_workspace_id');
|
|
39
|
+
console.log(`Server set to ${server}`);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=interact-for-server-selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interact-for-server-selection.js","sourceRoot":"","sources":["../src/lib/interact-for-server-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,MAAM,OAAO,GAAG;QACd,uBAAuB;QACvB,6BAA6B;QAC7B,iCAAiC;KAClC,CAAA;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC;QAC/B;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,kBAAkB;YAC3B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;SACrE;KACF,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,cAAc,EAAE,CAAA;IAC/B,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1B,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,CAAC;YAClC;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,aAAa;gBACnB,OAAO,EACL,sFAAsF;aACzF;SACF,CAAC,CAAA;QAEF,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC9C,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,WAAW,0BAA0B,CAAC,CAAA;QACtE,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,oBAAoB,CAAC,CAAA;QACtD,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAA;IACzE,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC9B,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAA;IACrC,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAAM,EAAE,CAAC,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const interactForTimestamp: () => Promise<any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
export const interactForTimestamp = async () => {
|
|
3
|
+
const { timestamp } = await prompts({
|
|
4
|
+
name: 'timestamp',
|
|
5
|
+
type: 'date',
|
|
6
|
+
message: 'Enter a timestamp:',
|
|
7
|
+
});
|
|
8
|
+
return timestamp.toISOString();
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=interact-for-timestamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interact-for-timestamp.js","sourceRoot":"","sources":["../src/lib/interact-for-timestamp.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,IAAI,EAAE;IAC7C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,OAAO,CAAC;QAClC,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,oBAAoB;KAC9B,CAAC,CAAA;IAEF,OAAO,SAAS,CAAC,WAAW,EAAE,CAAA;AAChC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function interactForUseRemoteApiDefs(): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
import { getConfigStore } from './get-config-store.js';
|
|
3
|
+
export async function interactForUseRemoteApiDefs() {
|
|
4
|
+
const { use_remote_api_defs } = await prompts([
|
|
5
|
+
{
|
|
6
|
+
type: 'select',
|
|
7
|
+
name: 'use_remote_api_defs',
|
|
8
|
+
message: 'Always use remote API Definitions?',
|
|
9
|
+
choices: [
|
|
10
|
+
{
|
|
11
|
+
title: 'Yes',
|
|
12
|
+
value: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
title: 'No',
|
|
16
|
+
value: false,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
const config = getConfigStore();
|
|
22
|
+
config.set('use_remote_api_defs', use_remote_api_defs);
|
|
23
|
+
console.log(`Use remote API Definitions: ${use_remote_api_defs}`);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=interact-for-use-remote-api-defs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interact-for-use-remote-api-defs.js","sourceRoot":"","sources":["../src/lib/interact-for-use-remote-api-defs.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,CAAC,KAAK,UAAU,2BAA2B;IAC/C,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,OAAO,CAAC;QAC5C;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE,oCAAoC;YAC7C,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,IAAI;iBACZ;gBACD;oBACE,KAAK,EAAE,IAAI;oBACX,KAAK,EAAE,KAAK;iBACb;aACF;SACF;KACF,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,cAAc,EAAE,CAAA;IAC/B,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAA;IACtD,OAAO,CAAC,GAAG,CAAC,+BAA+B,mBAAmB,EAAE,CAAC,CAAA;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const interactForUserIdentity: () => Promise<string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getSeam } from './get-seam.js';
|
|
2
|
+
import { interactForResource } from './interact-for-resource.js';
|
|
3
|
+
export const interactForUserIdentity = async () => {
|
|
4
|
+
const seam = await getSeam();
|
|
5
|
+
return interactForResource({
|
|
6
|
+
resourceName: 'user_identity',
|
|
7
|
+
fetchResources: () => seam.userIdentities.list(),
|
|
8
|
+
toChoice: (userIdentity) => ({
|
|
9
|
+
title: `${userIdentity.email_address} "${userIdentity.full_name}: ${userIdentity.user_identity_key}`,
|
|
10
|
+
value: userIdentity.user_identity_id,
|
|
11
|
+
description: userIdentity.user_identity_id,
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=interact-for-user-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interact-for-user-identity.js","sourceRoot":"","sources":["../src/lib/interact-for-user-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,IAAI,EAAE;IAChD,MAAM,IAAI,GAAG,MAAM,OAAO,EAAE,CAAA;IAE5B,OAAO,mBAAmB,CAAC;QACzB,YAAY,EAAE,eAAe;QAC7B,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE;QAChD,QAAQ,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YAC3B,KAAK,EAAE,GAAG,YAAY,CAAC,aAAa,KAAK,YAAY,CAAC,SAAS,KAAK,YAAY,CAAC,iBAAiB,EAAE;YACpG,KAAK,EAAE,YAAY,CAAC,gBAAgB;YACpC,WAAW,EAAE,YAAY,CAAC,gBAAgB;SAC3C,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const interactForWorkspaceId: (personalAccessToken?: string) => Promise<any>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SeamHttpWithoutWorkspace } from '@seamapi/http/connect';
|
|
2
|
+
import prompts from 'prompts';
|
|
3
|
+
import { getConfigStore } from './get-config-store.js';
|
|
4
|
+
import { getSeamMultiWorkspace } from './get-seam.js';
|
|
5
|
+
import { getServer } from './get-server.js';
|
|
6
|
+
import { withLoading } from './util/with-loading.js';
|
|
7
|
+
export const interactForWorkspaceId = async (personalAccessToken) => {
|
|
8
|
+
const config = getConfigStore();
|
|
9
|
+
const seam = personalAccessToken
|
|
10
|
+
? SeamHttpWithoutWorkspace.fromPersonalAccessToken(personalAccessToken, {
|
|
11
|
+
endpoint: getServer(),
|
|
12
|
+
})
|
|
13
|
+
: await getSeamMultiWorkspace();
|
|
14
|
+
const workspaces = await withLoading('Fetching workspaces...', () => seam.workspaces.list());
|
|
15
|
+
const { workspaceId } = await prompts({
|
|
16
|
+
name: 'workspaceId',
|
|
17
|
+
type: 'select',
|
|
18
|
+
message: 'Select a workspace:',
|
|
19
|
+
choices: workspaces.map((workspace) => ({
|
|
20
|
+
title: workspace.name,
|
|
21
|
+
value: workspace.workspace_id,
|
|
22
|
+
description: workspace.workspace_id,
|
|
23
|
+
})),
|
|
24
|
+
});
|
|
25
|
+
if (workspaceId) {
|
|
26
|
+
config.set('current_workspace_id', workspaceId);
|
|
27
|
+
return workspaceId;
|
|
28
|
+
}
|
|
29
|
+
throw new Error('Bailed');
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=interact-for-workspace-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interact-for-workspace-id.js","sourceRoot":"","sources":["../src/lib/interact-for-workspace-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,mBAA4B,EAAE,EAAE;IAC3E,MAAM,MAAM,GAAG,cAAc,EAAE,CAAA;IAC/B,MAAM,IAAI,GAAG,mBAAmB;QAC9B,CAAC,CAAC,wBAAwB,CAAC,uBAAuB,CAAC,mBAAmB,EAAE;YACpE,QAAQ,EAAE,SAAS,EAAE;SACtB,CAAC;QACJ,CAAC,CAAC,MAAM,qBAAqB,EAAE,CAAA;IAEjC,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,wBAAwB,EAAE,GAAG,EAAE,CAClE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CACvB,CAAA;IACD,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,CAAC;QACpC,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,qBAAqB;QAC9B,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAc,EAAE,EAAE,CAAC,CAAC;YAC3C,KAAK,EAAE,SAAS,CAAC,IAAI;YACrB,KAAK,EAAE,SAAS,CAAC,YAAY;YAC7B,WAAW,EAAE,SAAS,CAAC,YAAY;SACpC,CAAC,CAAC;KACJ,CAAC,CAAA;IAEF,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAA;QAC/C,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAA;AAC3B,CAAC,CAAA"}
|
package/lib/types.d.ts
ADDED
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/lib/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ellipsis: (str: string, len: number) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ellipsis.js","sourceRoot":"","sources":["../../src/lib/util/ellipsis.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE;IACnD,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,GAAG,CAAA;IACjC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,KAAK,CAAA;AACtC,CAAC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { getSeam } from '../get-seam.js';
|
|
3
|
+
import { withLoading } from './with-loading.js';
|
|
4
|
+
export const RequestSeamApi = async ({ path, params, }) => {
|
|
5
|
+
const seam = await getSeam();
|
|
6
|
+
logRequest(path, params);
|
|
7
|
+
const response = await withLoading('Making request...', () => seam.client.post(path, params, {
|
|
8
|
+
validateStatus: () => true,
|
|
9
|
+
}));
|
|
10
|
+
logResponse(response);
|
|
11
|
+
return response;
|
|
12
|
+
};
|
|
13
|
+
const logResponse = (response) => {
|
|
14
|
+
if (response.status >= 400) {
|
|
15
|
+
console.log(chalk.red(`\n\n[${response.status}]\n`));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.log(chalk.green(`\n\n[${response.status}]`));
|
|
19
|
+
}
|
|
20
|
+
console.dir(response.data, { depth: null });
|
|
21
|
+
console.log('\n');
|
|
22
|
+
};
|
|
23
|
+
const logRequest = (apiPath, params) => {
|
|
24
|
+
console.log(`\n\n${chalk.green(apiPath)}`);
|
|
25
|
+
console.log(`Request Params:`);
|
|
26
|
+
console.log(params);
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=request-seam-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-seam-api.js","sourceRoot":"","sources":["../../src/lib/util/request-seam-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,EACnC,IAAI,EACJ,MAAM,GAIP,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,MAAM,OAAO,EAAE,CAAA;IAE5B,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAExB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE;QAC7B,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI;KAC3B,CAAC,CACH,CAAA;IAED,WAAW,CAAC,QAAQ,CAAC,CAAA;IAErB,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,QAA2C,EAAE,EAAE;IAClE,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;IACtD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACnB,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,MAA2B,EAAE,EAAE;IAClE,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC1C,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;IAC9B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACrB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const withLoading: <T>(message: string, fn: () => Promise<T>) => Promise<T>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createSpinner } from 'nanospinner';
|
|
2
|
+
export const withLoading = async (message, fn) => {
|
|
3
|
+
const spinner = createSpinner(message).start();
|
|
4
|
+
try {
|
|
5
|
+
const result = await fn();
|
|
6
|
+
spinner.success();
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
spinner.error();
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=with-loading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-loading.js","sourceRoot":"","sources":["../../src/lib/util/with-loading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC9B,OAAe,EACf,EAAoB,EACR,EAAE;IACd,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAA;IAC9C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;QACzB,OAAO,CAAC,OAAO,EAAE,CAAA;QACjB,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,EAAE,CAAA;QACf,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateToken: (token: string, workspaceId?: string) => Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isApiKey, isPersonalAccessToken, SeamHttp, SeamHttpWithoutWorkspace, } from '@seamapi/http/connect';
|
|
2
|
+
import { getServer } from './get-server.js';
|
|
3
|
+
export const validateToken = async (token, workspaceId) => {
|
|
4
|
+
const options = { endpoint: getServer() };
|
|
5
|
+
if (isPersonalAccessToken(token)) {
|
|
6
|
+
const seam = workspaceId
|
|
7
|
+
? SeamHttp.fromPersonalAccessToken(token, workspaceId, options)
|
|
8
|
+
: SeamHttpWithoutWorkspace.fromPersonalAccessToken(token, options);
|
|
9
|
+
await seam.workspaces.list();
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (isApiKey(token)) {
|
|
13
|
+
const seam = SeamHttp.fromApiKey(token, options);
|
|
14
|
+
await seam.workspaces.list();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
throw new Error('Invalid token: expected a Personal Access Token or API Key');
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=validate-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-token.js","sourceRoot":"","sources":["../src/lib/validate-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,QAAQ,EACR,wBAAwB,GACzB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,KAAa,EAAE,WAAoB,EAAE,EAAE;IACzE,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,CAAA;IAEzC,IAAI,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,WAAW;YACtB,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC;YAC/D,CAAC,CAAC,wBAAwB,CAAC,uBAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QACpE,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QAC5B,OAAM;IACR,CAAC;IAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAChD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QAC5B,OAAM;IACR,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAA;AAC/E,CAAC,CAAA"}
|
package/lib/version.d.ts
ADDED
package/lib/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/lib/version.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,OAAO,CAAA;AAEjC,eAAe,iBAAiB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamapi/cli",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A command line interface (CLI) for interacting with the Seam API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -14,9 +14,17 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"module": "index.js",
|
|
17
|
-
"
|
|
17
|
+
"bin": {
|
|
18
|
+
"seam": "./bin/cli.js"
|
|
19
|
+
},
|
|
20
|
+
"sideEffects": [
|
|
21
|
+
"./bin/cli.js",
|
|
22
|
+
"./src/bin/cli.ts"
|
|
23
|
+
],
|
|
18
24
|
"keywords": [
|
|
19
|
-
"
|
|
25
|
+
"cli",
|
|
26
|
+
"node",
|
|
27
|
+
"seam"
|
|
20
28
|
],
|
|
21
29
|
"homepage": "https://github.com/seamapi/cli",
|
|
22
30
|
"bugs": "https://github.com/seamapi/cli/issues",
|
|
@@ -30,6 +38,7 @@
|
|
|
30
38
|
"index.js",
|
|
31
39
|
"index.js.map",
|
|
32
40
|
"index.d.ts",
|
|
41
|
+
"bin",
|
|
33
42
|
"lib",
|
|
34
43
|
"src",
|
|
35
44
|
"!test",
|
|
@@ -38,29 +47,30 @@
|
|
|
38
47
|
"scripts": {
|
|
39
48
|
"build": "npm run build:entrypoints",
|
|
40
49
|
"prebuild": "tsx src/index.ts",
|
|
41
|
-
"postbuild": "node ./index.js",
|
|
50
|
+
"postbuild": "concurrently --raw --group 'node ./index.js' 'node ./bin/cli.js --version'",
|
|
42
51
|
"build:entrypoints": "npm run build:ts",
|
|
43
52
|
"build:ts": "tsc --project tsconfig.build.json",
|
|
44
|
-
"prebuild:ts": "del 'index.*' lib",
|
|
53
|
+
"prebuild:ts": "del 'index.*' bin lib",
|
|
45
54
|
"postbuild:ts": "tsc-alias --project tsconfig.build.json",
|
|
46
55
|
"typecheck": "tsc",
|
|
47
|
-
"test": "
|
|
56
|
+
"test": "vitest run --coverage",
|
|
48
57
|
"pretest": "tsx src/index.ts",
|
|
49
|
-
"test:update": "
|
|
50
|
-
"test:watch": "
|
|
51
|
-
"test:debug": "
|
|
58
|
+
"test:update": "vitest run --update",
|
|
59
|
+
"test:watch": "vitest",
|
|
60
|
+
"test:debug": "vitest --inspect-brk --no-file-parallelism",
|
|
52
61
|
"lint": "eslint .",
|
|
53
62
|
"postlint": "prettier --check --ignore-path .gitignore .",
|
|
63
|
+
"prepack": "tsx ./prepack.ts",
|
|
54
64
|
"postversion": "git push --follow-tags",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
65
|
+
"seam": "tsx src/bin/cli.ts",
|
|
66
|
+
"inspect": "tsx --inspect src/bin/cli.ts",
|
|
57
67
|
"format": "prettier --write --ignore-path .gitignore .",
|
|
58
68
|
"preformat": "eslint --fix .",
|
|
59
|
-
"report": "
|
|
69
|
+
"report": "vitest run --coverage"
|
|
60
70
|
},
|
|
61
71
|
"engines": {
|
|
62
72
|
"node": ">=22.11.0",
|
|
63
|
-
"npm": ">=10.
|
|
73
|
+
"npm": ">=10.0.0"
|
|
64
74
|
},
|
|
65
75
|
"devEngines": {
|
|
66
76
|
"runtime": {
|
|
@@ -69,24 +79,40 @@
|
|
|
69
79
|
},
|
|
70
80
|
"packageManager": {
|
|
71
81
|
"name": "npm",
|
|
72
|
-
"version": "^11.
|
|
82
|
+
"version": "^11.0.0 || ^10.0.0"
|
|
73
83
|
}
|
|
74
84
|
},
|
|
85
|
+
"dependencies": {
|
|
86
|
+
"@seamapi/blueprint": "^1.1.0",
|
|
87
|
+
"@seamapi/http": "^2.2.0",
|
|
88
|
+
"@seamapi/types": "^1.983.0",
|
|
89
|
+
"chalk": "^6.0.0",
|
|
90
|
+
"command-line-usage": "^7.0.4",
|
|
91
|
+
"configstore": "^8.0.0",
|
|
92
|
+
"minimist": "^1.2.8",
|
|
93
|
+
"nanospinner": "^1.2.2",
|
|
94
|
+
"open": "^11.0.0",
|
|
95
|
+
"prompts": "^2.4.2"
|
|
96
|
+
},
|
|
75
97
|
"devDependencies": {
|
|
98
|
+
"@types/command-line-usage": "^5.0.4",
|
|
99
|
+
"@types/minimist": "^1.2.5",
|
|
76
100
|
"@types/node": "^24.10.9",
|
|
77
|
-
"
|
|
78
|
-
"
|
|
101
|
+
"@types/prompts": "^2.4.9",
|
|
102
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
103
|
+
"concurrently": "^10.0.4",
|
|
79
104
|
"del-cli": "^7.0.0",
|
|
80
105
|
"eslint": "^9.31.0",
|
|
81
106
|
"eslint-plugin-import": "^2.32.0",
|
|
82
107
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
83
108
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
109
|
+
"execa": "^10.0.0",
|
|
84
110
|
"jiti": "^2.4.2",
|
|
85
|
-
"landlubber": "^2.0.0",
|
|
86
111
|
"neostandard": "^0.13.0",
|
|
87
112
|
"prettier": "^3.0.0",
|
|
88
113
|
"tsc-alias": "^1.8.2",
|
|
89
114
|
"tsx": "^4.6.2",
|
|
90
|
-
"typescript": "^6.0.3"
|
|
115
|
+
"typescript": "^6.0.3",
|
|
116
|
+
"vitest": "^4.1.10"
|
|
91
117
|
}
|
|
92
118
|
}
|