@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.
Files changed (136) hide show
  1. package/README.md +59 -3
  2. package/bin/cli.d.ts +2 -0
  3. package/bin/cli.js +233 -0
  4. package/bin/cli.js.map +1 -0
  5. package/index.d.ts +2 -0
  6. package/index.js +5 -0
  7. package/index.js.map +1 -0
  8. package/lib/get-api-blueprint.d.ts +3 -0
  9. package/lib/get-api-blueprint.js +11 -0
  10. package/lib/get-api-blueprint.js.map +1 -0
  11. package/lib/get-command-blueprint-def.d.ts +2 -0
  12. package/lib/get-command-blueprint-def.js +11 -0
  13. package/lib/get-command-blueprint-def.js.map +1 -0
  14. package/lib/get-config-store.d.ts +2 -0
  15. package/lib/get-config-store.js +5 -0
  16. package/lib/get-config-store.js.map +1 -0
  17. package/lib/get-current-workspace-id.d.ts +1 -0
  18. package/lib/get-current-workspace-id.js +10 -0
  19. package/lib/get-current-workspace-id.js.map +1 -0
  20. package/lib/get-seam.d.ts +3 -0
  21. package/lib/get-seam.js +26 -0
  22. package/lib/get-seam.js.map +1 -0
  23. package/lib/get-server.d.ts +1 -0
  24. package/lib/get-server.js +7 -0
  25. package/lib/get-server.js.map +1 -0
  26. package/lib/interact-for-access-code.d.ts +3 -0
  27. package/lib/interact-for-access-code.js +19 -0
  28. package/lib/interact-for-access-code.js.map +1 -0
  29. package/lib/interact-for-acs-entrance.d.ts +1 -0
  30. package/lib/interact-for-acs-entrance.js +15 -0
  31. package/lib/interact-for-acs-entrance.js.map +1 -0
  32. package/lib/interact-for-acs-system.d.ts +1 -0
  33. package/lib/interact-for-acs-system.js +16 -0
  34. package/lib/interact-for-acs-system.js.map +1 -0
  35. package/lib/interact-for-acs-user.d.ts +1 -0
  36. package/lib/interact-for-acs-user.js +17 -0
  37. package/lib/interact-for-acs-user.js.map +1 -0
  38. package/lib/interact-for-action-attempt-poll.d.ts +2 -0
  39. package/lib/interact-for-action-attempt-poll.js +22 -0
  40. package/lib/interact-for-action-attempt-poll.js.map +1 -0
  41. package/lib/interact-for-array.d.ts +1 -0
  42. package/lib/interact-for-array.js +53 -0
  43. package/lib/interact-for-array.js.map +1 -0
  44. package/lib/interact-for-blueprint-object.d.ts +9 -0
  45. package/lib/interact-for-blueprint-object.js +235 -0
  46. package/lib/interact-for-blueprint-object.js.map +1 -0
  47. package/lib/interact-for-command-params.d.ts +5 -0
  48. package/lib/interact-for-command-params.js +11 -0
  49. package/lib/interact-for-command-params.js.map +1 -0
  50. package/lib/interact-for-command-selection.d.ts +2 -0
  51. package/lib/interact-for-command-selection.js +76 -0
  52. package/lib/interact-for-command-selection.js.map +1 -0
  53. package/lib/interact-for-connected-account.d.ts +1 -0
  54. package/lib/interact-for-connected-account.js +20 -0
  55. package/lib/interact-for-connected-account.js.map +1 -0
  56. package/lib/interact-for-custom-metadata.d.ts +6 -0
  57. package/lib/interact-for-custom-metadata.js +71 -0
  58. package/lib/interact-for-custom-metadata.js.map +1 -0
  59. package/lib/interact-for-device.d.ts +1 -0
  60. package/lib/interact-for-device.js +15 -0
  61. package/lib/interact-for-device.js.map +1 -0
  62. package/lib/interact-for-login.d.ts +1 -0
  63. package/lib/interact-for-login.js +39 -0
  64. package/lib/interact-for-login.js.map +1 -0
  65. package/lib/interact-for-resource.d.ts +11 -0
  66. package/lib/interact-for-resource.js +13 -0
  67. package/lib/interact-for-resource.js.map +1 -0
  68. package/lib/interact-for-server-selection.d.ts +1 -0
  69. package/lib/interact-for-server-selection.js +41 -0
  70. package/lib/interact-for-server-selection.js.map +1 -0
  71. package/lib/interact-for-timestamp.d.ts +1 -0
  72. package/lib/interact-for-timestamp.js +10 -0
  73. package/lib/interact-for-timestamp.js.map +1 -0
  74. package/lib/interact-for-use-remote-api-defs.d.ts +1 -0
  75. package/lib/interact-for-use-remote-api-defs.js +25 -0
  76. package/lib/interact-for-use-remote-api-defs.js.map +1 -0
  77. package/lib/interact-for-user-identity.d.ts +1 -0
  78. package/lib/interact-for-user-identity.js +15 -0
  79. package/lib/interact-for-user-identity.js.map +1 -0
  80. package/lib/interact-for-workspace-id.d.ts +1 -0
  81. package/lib/interact-for-workspace-id.js +31 -0
  82. package/lib/interact-for-workspace-id.js.map +1 -0
  83. package/lib/types.d.ts +5 -0
  84. package/lib/types.js +2 -0
  85. package/lib/types.js.map +1 -0
  86. package/lib/util/ellipsis.d.ts +1 -0
  87. package/lib/util/ellipsis.js +6 -0
  88. package/lib/util/ellipsis.js.map +1 -0
  89. package/lib/util/request-seam-api.d.ts +4 -0
  90. package/lib/util/request-seam-api.js +28 -0
  91. package/lib/util/request-seam-api.js.map +1 -0
  92. package/lib/util/with-loading.d.ts +1 -0
  93. package/lib/util/with-loading.js +14 -0
  94. package/lib/util/with-loading.js.map +1 -0
  95. package/lib/validate-token.d.ts +1 -0
  96. package/lib/validate-token.js +19 -0
  97. package/lib/validate-token.js.map +1 -0
  98. package/lib/version.d.ts +2 -0
  99. package/lib/version.js +3 -0
  100. package/lib/version.js.map +1 -0
  101. package/package.json +44 -18
  102. package/src/bin/cli.ts +265 -0
  103. package/src/index.ts +4 -1
  104. package/src/lib/get-api-blueprint.ts +17 -0
  105. package/src/lib/get-command-blueprint-def.ts +15 -0
  106. package/src/lib/get-config-store.ts +5 -0
  107. package/src/lib/get-current-workspace-id.ts +11 -0
  108. package/src/lib/get-seam.ts +43 -0
  109. package/src/lib/get-server.ts +9 -0
  110. package/src/lib/interact-for-access-code.ts +25 -0
  111. package/src/lib/interact-for-acs-entrance.ts +16 -0
  112. package/src/lib/interact-for-acs-system.ts +17 -0
  113. package/src/lib/interact-for-acs-user.ts +21 -0
  114. package/src/lib/interact-for-action-attempt-poll.ts +35 -0
  115. package/src/lib/interact-for-array.ts +61 -0
  116. package/src/lib/interact-for-blueprint-object.ts +274 -0
  117. package/src/lib/interact-for-command-params.ts +22 -0
  118. package/src/lib/interact-for-command-selection.ts +107 -0
  119. package/src/lib/interact-for-connected-account.ts +24 -0
  120. package/src/lib/interact-for-custom-metadata.ts +86 -0
  121. package/src/lib/interact-for-device.ts +15 -0
  122. package/src/lib/interact-for-login.ts +53 -0
  123. package/src/lib/interact-for-resource.ts +34 -0
  124. package/src/lib/interact-for-server-selection.ts +46 -0
  125. package/src/lib/interact-for-timestamp.ts +10 -0
  126. package/src/lib/interact-for-use-remote-api-defs.ts +27 -0
  127. package/src/lib/interact-for-user-identity.ts +16 -0
  128. package/src/lib/interact-for-workspace-id.ts +37 -0
  129. package/src/lib/types.ts +6 -0
  130. package/src/lib/util/ellipsis.ts +4 -0
  131. package/src/lib/util/request-seam-api.ts +43 -0
  132. package/src/lib/util/with-loading.ts +16 -0
  133. package/src/lib/validate-token.ts +28 -0
  134. package/src/lib/version.ts +3 -0
  135. package/src/lib/index.ts +0 -1
  136. 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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AAM,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
@@ -0,0 +1,5 @@
1
+ import type { ApiBlueprint } from './get-api-blueprint.js';
2
+ export interface ContextHelpers {
3
+ blueprint: ApiBlueprint;
4
+ is_interactive: boolean;
5
+ }
package/lib/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -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,6 @@
1
+ export const ellipsis = (str, len) => {
2
+ if (str.length <= len)
3
+ return str;
4
+ return str.slice(0, len - 3) + '...';
5
+ };
6
+ //# sourceMappingURL=ellipsis.js.map
@@ -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,4 @@
1
+ export declare const RequestSeamApi: ({ path, params, }: {
2
+ path: string;
3
+ params: Record<string, any>;
4
+ }) => Promise<import("axios").AxiosResponse<any, any, {}>>;
@@ -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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ospinner';
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"}
@@ -0,0 +1,2 @@
1
+ declare const seamapiCliVersion = "0.4.0";
2
+ export default seamapiCliVersion;
package/lib/version.js ADDED
@@ -0,0 +1,3 @@
1
+ const seamapiCliVersion = '0.4.0';
2
+ export default seamapiCliVersion;
3
+ //# sourceMappingURL=version.js.map
@@ -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.1",
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
- "sideEffects": false,
17
+ "bin": {
18
+ "seam": "./bin/cli.js"
19
+ },
20
+ "sideEffects": [
21
+ "./bin/cli.js",
22
+ "./src/bin/cli.ts"
23
+ ],
18
24
  "keywords": [
19
- "node"
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": "c8 ava",
56
+ "test": "vitest run --coverage",
48
57
  "pretest": "tsx src/index.ts",
49
- "test:update": "ava --update-snapshots",
50
- "test:watch": "ava --watch",
51
- "test:debug": "ava debug --break",
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
- "example": "tsx examples",
56
- "example:inspect": "tsx --inspect examples",
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": "c8 report"
69
+ "report": "vitest run --coverage"
60
70
  },
61
71
  "engines": {
62
72
  "node": ">=22.11.0",
63
- "npm": ">=10.9.4"
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.16.0 || ^10.9.4"
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
- "ava": "^8.0.1",
78
- "c8": "^12.0.0",
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
  }