@seamapi/cli 0.13.0 → 0.14.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 +26 -2
- package/bin/cli.js +86 -30
- package/bin/cli.js.map +1 -1
- package/lib/command-spec.d.ts +8 -0
- package/lib/command-spec.js +8 -0
- package/lib/command-spec.js.map +1 -1
- package/lib/completion/render-fish.js +2 -2
- package/lib/interact-for-access-code.d.ts +1 -1
- package/lib/interact-for-access-code.js +7 -4
- package/lib/interact-for-access-code.js.map +1 -1
- package/lib/interact-for-acs-user.js +2 -2
- package/lib/interact-for-acs-user.js.map +1 -1
- package/lib/interact-for-action-attempt-poll.d.ts +1 -1
- package/lib/interact-for-action-attempt-poll.js +8 -8
- package/lib/interact-for-action-attempt-poll.js.map +1 -1
- package/lib/interact-for-blueprint-object.js +6 -8
- package/lib/interact-for-blueprint-object.js.map +1 -1
- package/lib/interact-for-custom-metadata.d.ts +1 -1
- package/lib/interact-for-custom-metadata.js +15 -15
- package/lib/interact-for-custom-metadata.js.map +1 -1
- package/lib/interact-for-use-remote-api-defs.js +4 -4
- package/lib/interact-for-use-remote-api-defs.js.map +1 -1
- package/lib/render-help.js +4 -0
- package/lib/render-help.js.map +1 -1
- package/lib/util/cli-args.d.ts +21 -0
- package/lib/util/cli-args.js +26 -1
- package/lib/util/cli-args.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +6 -4
- package/src/bin/cli.ts +111 -29
- package/src/lib/command-spec.ts +12 -0
- package/src/lib/completion/render-fish.ts +2 -2
- package/src/lib/interact-for-access-code.ts +6 -4
- package/src/lib/interact-for-acs-user.ts +2 -2
- package/src/lib/interact-for-action-attempt-poll.ts +9 -9
- package/src/lib/interact-for-blueprint-object.ts +6 -8
- package/src/lib/interact-for-custom-metadata.ts +18 -20
- package/src/lib/interact-for-use-remote-api-defs.ts +4 -4
- package/src/lib/render-help.ts +4 -0
- package/src/lib/util/cli-args.ts +33 -1
- package/src/lib/version.ts +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { getOutput } from './output/get-output.js';
|
|
2
2
|
import { prompt } from './util/prompt.js';
|
|
3
|
-
export const interactForCustomMetadata = async (
|
|
4
|
-
const
|
|
3
|
+
export const interactForCustomMetadata = async (customMetadata) => {
|
|
4
|
+
const updatedCustomMetadata = { ...customMetadata };
|
|
5
5
|
const output = getOutput();
|
|
6
6
|
const displayCurrentCustomMetadata = () => {
|
|
7
7
|
output.info('custom_metadata:');
|
|
8
|
-
if (Object.keys(
|
|
9
|
-
Object.keys(
|
|
10
|
-
output.info(`${index + 1}: ${key}: ${
|
|
8
|
+
if (Object.keys(updatedCustomMetadata).length > 0) {
|
|
9
|
+
Object.keys(updatedCustomMetadata).forEach((key, index) => {
|
|
10
|
+
output.info(`${index + 1}: ${key}: ${updatedCustomMetadata[key]}`);
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
@@ -44,30 +44,30 @@ export const interactForCustomMetadata = async (custom_metadata) => {
|
|
|
44
44
|
newValue = Boolean(newValue);
|
|
45
45
|
}
|
|
46
46
|
if (newValue === 'null') {
|
|
47
|
-
|
|
47
|
+
updatedCustomMetadata[newKey] = null;
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
|
|
50
|
+
updatedCustomMetadata[newKey] = newValue;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
else if (action === 'remove') {
|
|
55
|
-
const {
|
|
55
|
+
const { customKeyToRemove } = await prompt({
|
|
56
56
|
type: 'select',
|
|
57
|
-
name: '
|
|
57
|
+
name: 'customKeyToRemove',
|
|
58
58
|
message: 'Choose a key-value pair to remove from params:',
|
|
59
|
-
choices: Object.keys(
|
|
59
|
+
choices: Object.keys(updatedCustomMetadata).map((customMetadataKey) => {
|
|
60
60
|
return {
|
|
61
|
-
title: `${
|
|
62
|
-
value:
|
|
61
|
+
title: `${customMetadataKey}: ${updatedCustomMetadata[customMetadataKey]}`,
|
|
62
|
+
value: customMetadataKey,
|
|
63
63
|
};
|
|
64
64
|
}),
|
|
65
65
|
});
|
|
66
|
-
if (
|
|
67
|
-
delete
|
|
66
|
+
if (customKeyToRemove) {
|
|
67
|
+
delete customMetadata[customKeyToRemove];
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
} while (action !== 'done');
|
|
71
|
-
return
|
|
71
|
+
return updatedCustomMetadata;
|
|
72
72
|
};
|
|
73
73
|
//# sourceMappingURL=interact-for-custom-metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interact-for-custom-metadata.js","sourceRoot":"","sources":["../src/lib/interact-for-custom-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAUzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAC5C,
|
|
1
|
+
{"version":3,"file":"interact-for-custom-metadata.js","sourceRoot":"","sources":["../src/lib/interact-for-custom-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAUzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAC5C,cAA8B,EAC9B,EAAE;IACF,MAAM,qBAAqB,GAA0B,EAAE,GAAG,cAAc,EAAE,CAAA;IAC1E,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,MAAM,4BAA4B,GAAG,GAAG,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAC/B,IAAI,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClD,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,C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CAAA;gBAC9B,CAAC;gBACD,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;oBACxB,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;gBACtC,CAAC;qBAAM,CAAC;oBACN,qBAAqB,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAA;gBAC1C,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC;gBACzC,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EAAE,gDAAgD;gBACzD,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE;oBACpE,OAAO;wBACL,KAAK,EAAE,GAAG,iBAAiB,KAAK,qBAAqB,CAAC,iBAAiB,CAAC,EAAE;wBAC1E,KAAK,EAAE,iBAAiB;qBACzB,CAAA;gBACH,CAAC,CAAC;aACH,CAAC,CAAA;YAEF,IAAI,iBAAiB,EAAE,CAAC;gBACtB,OAAO,cAAc,CAAC,iBAAiB,CAAC,CAAA;YAC1C,CAAC;QACH,CAAC;IACH,CAAC,QAAQ,MAAM,KAAK,MAAM,EAAC;IAE3B,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA"}
|
|
@@ -2,10 +2,10 @@ import { getConfigStore } from './config/index.js';
|
|
|
2
2
|
import { getOutput } from './output/get-output.js';
|
|
3
3
|
import { prompt } from './util/prompt.js';
|
|
4
4
|
export async function interactForUseRemoteApiDefs() {
|
|
5
|
-
const {
|
|
5
|
+
const { useRemoteApiDefs } = await prompt([
|
|
6
6
|
{
|
|
7
7
|
type: 'select',
|
|
8
|
-
name: '
|
|
8
|
+
name: 'useRemoteApiDefs',
|
|
9
9
|
message: 'Always use remote API Definitions?',
|
|
10
10
|
choices: [
|
|
11
11
|
{
|
|
@@ -20,7 +20,7 @@ export async function interactForUseRemoteApiDefs() {
|
|
|
20
20
|
},
|
|
21
21
|
]);
|
|
22
22
|
const config = getConfigStore();
|
|
23
|
-
config.set('use_remote_api_defs',
|
|
24
|
-
getOutput().info(`Use remote API Definitions: ${
|
|
23
|
+
config.set('use_remote_api_defs', useRemoteApiDefs);
|
|
24
|
+
getOutput().info(`Use remote API Definitions: ${useRemoteApiDefs}`);
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=interact-for-use-remote-api-defs.js.map
|
|
@@ -1 +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,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,2BAA2B;IAC/C,MAAM,EAAE,
|
|
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,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,2BAA2B;IAC/C,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,kBAAkB;YACxB,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,gBAAgB,CAAC,CAAA;IACnD,SAAS,EAAE,CAAC,IAAI,CAAC,+BAA+B,gBAAgB,EAAE,CAAC,CAAA;AACrE,CAAC"}
|
package/lib/render-help.js
CHANGED
|
@@ -50,6 +50,10 @@ const examples = [
|
|
|
50
50
|
name: "seam access-codes create {bold --code} '1234' {bold --name} 'My Code'",
|
|
51
51
|
summary: 'Create an access code.',
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
name: 'seam devices list {bold --page-cursor} $NEXT_PAGE_CURSOR',
|
|
55
|
+
summary: 'List the next page of devices.',
|
|
56
|
+
},
|
|
53
57
|
{
|
|
54
58
|
name: 'seam devices list > devices.json',
|
|
55
59
|
summary: 'Write the response to a file as JSON.',
|
package/lib/render-help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-help.js","sourceRoot":"","sources":["../src/lib/render-help.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,EAAE,EAAgB,MAAM,oBAAoB,CAAA;AAEnE,OAAO,EAKL,WAAW,EACX,SAAS,GACV,MAAM,mBAAmB,CAAA;AAE1B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,IAAc,EACd,IAAiB,EACF,EAAE;IACjB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACnC,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,gBAAgB,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;IAEtE,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACvC,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,gBAAgB,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CA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CAAA;IAErD,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,KAAK,GAAG,CAAA;AAC/E,CAAC,CAAA"}
|
package/lib/util/cli-args.d.ts
CHANGED
|
@@ -26,6 +26,17 @@ export declare const cliFlags: string[];
|
|
|
26
26
|
export declare class NonInteractiveError extends Error {
|
|
27
27
|
name: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Thrown when the arguments do not name something the CLI can run.
|
|
31
|
+
*/
|
|
32
|
+
export declare class UsageError extends Error {
|
|
33
|
+
name: string;
|
|
34
|
+
/** What to run instead, reported after the message. */
|
|
35
|
+
readonly hint: string;
|
|
36
|
+
constructor(message: string, { hint }?: {
|
|
37
|
+
hint?: string;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
29
40
|
export declare const parseCliArgs: (argv: string[]) => ParsedArgs;
|
|
30
41
|
export interface GetInteractivityOptions {
|
|
31
42
|
/**
|
|
@@ -43,3 +54,13 @@ export declare const getInteractivity: (args: ParsedArgs, { canPrompt }?: GetInt
|
|
|
43
54
|
* e.g., `device_id` as `--device-id`.
|
|
44
55
|
*/
|
|
45
56
|
export declare const toArgName: (parameterName: string) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Read an argument key as the parameter it names, e.g., `--page-cursor`,
|
|
59
|
+
* `--page_cursor`, and `--PAGE-CURSOR` all name `page_cursor`.
|
|
60
|
+
*/
|
|
61
|
+
export declare const toParameterName: (argKey: string) => string;
|
|
62
|
+
/**
|
|
63
|
+
* Render an argument key as the argument it was given as, naming a one letter
|
|
64
|
+
* key as the short form it can only have been written as, e.g., `-n`.
|
|
65
|
+
*/
|
|
66
|
+
export declare const toGivenArgName: (argKey: string) => string;
|
package/lib/util/cli-args.js
CHANGED
|
@@ -28,8 +28,23 @@ export const cliFlags = [
|
|
|
28
28
|
export class NonInteractiveError extends Error {
|
|
29
29
|
name = 'NonInteractiveError';
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Thrown when the arguments do not name something the CLI can run.
|
|
33
|
+
*/
|
|
34
|
+
export class UsageError extends Error {
|
|
35
|
+
name = 'UsageError';
|
|
36
|
+
/** What to run instead, reported after the message. */
|
|
37
|
+
hint;
|
|
38
|
+
constructor(message, { hint = '' } = {}) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.hint = hint;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
31
43
|
export const parseCliArgs = (argv) => parseArgs(argv, {
|
|
32
|
-
|
|
44
|
+
// A page cursor is opaque, so keep it exactly as given: read as a number
|
|
45
|
+
// it would lose leading zeroes and turn exponent notation into a digit
|
|
46
|
+
// string, naming a page the API never issued.
|
|
47
|
+
string: ['code', 'page-cursor', 'page_cursor'],
|
|
33
48
|
boolean: ['non-interactive', 'interactive', 'json'],
|
|
34
49
|
// Deliberately not aliased to -n, which is reserved for a future
|
|
35
50
|
// --dry-run flag.
|
|
@@ -55,4 +70,14 @@ export const getInteractivity = (args, { canPrompt = true } = {}) => {
|
|
|
55
70
|
* e.g., `device_id` as `--device-id`.
|
|
56
71
|
*/
|
|
57
72
|
export const toArgName = (parameterName) => `--${parameterName.replace(/_/g, '-')}`;
|
|
73
|
+
/**
|
|
74
|
+
* Read an argument key as the parameter it names, e.g., `--page-cursor`,
|
|
75
|
+
* `--page_cursor`, and `--PAGE-CURSOR` all name `page_cursor`.
|
|
76
|
+
*/
|
|
77
|
+
export const toParameterName = (argKey) => argKey.toLowerCase().replace(/-/g, '_');
|
|
78
|
+
/**
|
|
79
|
+
* Render an argument key as the argument it was given as, naming a one letter
|
|
80
|
+
* key as the short form it can only have been written as, e.g., `-n`.
|
|
81
|
+
*/
|
|
82
|
+
export const toGivenArgName = (argKey) => argKey.length === 1 ? `-${argKey}` : toArgName(argKey);
|
|
58
83
|
//# sourceMappingURL=cli-args.js.map
|
package/lib/util/cli-args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../../src/lib/util/cli-args.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAmB,MAAM,UAAU,CAAA;AAcrD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAa;IAC1C,iBAAiB;IACjB,GAAG;IACH,aAAa;IACb,GAAG;CACJ,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,GAAG,kBAAkB;IACrB,GAAG;IACH,MAAM;IACN,MAAM;IACN,iBAAiB;IACjB,QAAQ;IACR,SAAS;CACV,CAAA;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,GAAG,qBAAqB,CAAA;CACtC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAc,EAAc,EAAE,CACzD,SAAS,CAAC,IAAI,EAAE;IACd,MAAM,EAAE,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../../src/lib/util/cli-args.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAmB,MAAM,UAAU,CAAA;AAcrD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAa;IAC1C,iBAAiB;IACjB,GAAG;IACH,aAAa;IACb,GAAG;CACJ,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,GAAG,kBAAkB;IACrB,GAAG;IACH,MAAM;IACN,MAAM;IACN,iBAAiB;IACjB,QAAQ;IACR,SAAS;CACV,CAAA;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,GAAG,qBAAqB,CAAA;CACtC;AAED;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,GAAG,YAAY,CAAA;IAE5B,uDAAuD;IAC9C,IAAI,CAAQ;IAErB,YAAY,OAAe,EAAE,EA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C,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAU,EAAE,CACxD,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAU,EAAE,CACvD,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA"}
|
package/lib/version.d.ts
CHANGED
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamapi/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A command
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"description": "A command-line interface (CLI) for interacting with the Seam API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
@@ -82,11 +82,13 @@
|
|
|
82
82
|
"devEngines": {
|
|
83
83
|
"runtime": {
|
|
84
84
|
"name": "node",
|
|
85
|
-
"version": "^24.11.0 || ^22.11.0"
|
|
85
|
+
"version": "^24.11.0 || ^22.11.0",
|
|
86
|
+
"onFail": "warn"
|
|
86
87
|
},
|
|
87
88
|
"packageManager": {
|
|
88
89
|
"name": "npm",
|
|
89
|
-
"version": "^11.0.0 || ^10.0.0"
|
|
90
|
+
"version": "^11.0.0 || ^10.0.0",
|
|
91
|
+
"onFail": "warn"
|
|
90
92
|
}
|
|
91
93
|
},
|
|
92
94
|
"dependencies": {
|
package/src/bin/cli.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { isDeepStrictEqual as isEqual } from 'node:util'
|
|
|
5
5
|
import chalk from 'chalk'
|
|
6
6
|
import type { ParsedArgs } from 'minimist'
|
|
7
7
|
|
|
8
|
-
import { getCommandSpec } from 'lib/command-spec.js'
|
|
8
|
+
import { findLocalCommand, getCommandSpec } from 'lib/command-spec.js'
|
|
9
9
|
import {
|
|
10
10
|
completionShells,
|
|
11
11
|
isCompletionShell,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from 'lib/completion/index.js'
|
|
14
14
|
import { getConfigStore } from 'lib/config/index.js'
|
|
15
15
|
import { getApiBlueprint } from 'lib/get-api-blueprint.js'
|
|
16
|
+
import { getCommandBlueprintDef } from 'lib/get-command-blueprint-def.js'
|
|
16
17
|
import { getResponseKey } from 'lib/get-response-key.js'
|
|
17
18
|
import { getServer } from 'lib/get-server.js'
|
|
18
19
|
import { interactForActionAttemptPoll } from 'lib/interact-for-action-attempt-poll.js'
|
|
@@ -33,6 +34,9 @@ import {
|
|
|
33
34
|
type Interactivity,
|
|
34
35
|
NonInteractiveError,
|
|
35
36
|
parseCliArgs,
|
|
37
|
+
toGivenArgName,
|
|
38
|
+
toParameterName,
|
|
39
|
+
UsageError,
|
|
36
40
|
} from 'lib/util/cli-args.js'
|
|
37
41
|
import { canPrompt, prompt } from 'lib/util/prompt.js'
|
|
38
42
|
import { readStdinJson } from 'lib/util/read-stdin-json.js'
|
|
@@ -77,6 +81,29 @@ async function cli(args: ParsedArgs) {
|
|
|
77
81
|
return
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
args._ = args._.map(toCommandWord)
|
|
85
|
+
|
|
86
|
+
// Argument keys name parameters however they are written, so normalize each
|
|
87
|
+
// one to the name the API gives it. Replace the key rather than adding the
|
|
88
|
+
// normalized form alongside it, or an argument would be sent twice: once as
|
|
89
|
+
// written and once as the API names it.
|
|
90
|
+
for (const key of Object.keys(args)) {
|
|
91
|
+
if (key === '_') continue
|
|
92
|
+
const name = toParameterName(key)
|
|
93
|
+
if (name === key) continue
|
|
94
|
+
args[name] = args[key]
|
|
95
|
+
delete args[key]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Params given as arguments, kept apart from the params read from stdin so
|
|
99
|
+
// that only the arguments are held to what the command accepts.
|
|
100
|
+
const argParams: Record<string, any> = {}
|
|
101
|
+
for (const [key, value] of Object.entries(args)) {
|
|
102
|
+
if (key === '_') continue
|
|
103
|
+
if (cliFlags.includes(key)) continue
|
|
104
|
+
argParams[key] = value
|
|
105
|
+
}
|
|
106
|
+
|
|
80
107
|
if (args._[0] === 'completion') {
|
|
81
108
|
const shell = args._[1]
|
|
82
109
|
|
|
@@ -86,6 +113,8 @@ async function cli(args: ParsedArgs) {
|
|
|
86
113
|
return
|
|
87
114
|
}
|
|
88
115
|
|
|
116
|
+
assertKnownArgs(argParams, ['completion', shell])
|
|
117
|
+
|
|
89
118
|
// Completions always come from the cached API definitions so that they
|
|
90
119
|
// can be generated without logging in. They may lag the definitions
|
|
91
120
|
// served by Seam when config use-remote-api-defs is enabled.
|
|
@@ -121,15 +150,10 @@ async function cli(args: ParsedArgs) {
|
|
|
121
150
|
return
|
|
122
151
|
}
|
|
123
152
|
|
|
124
|
-
|
|
125
|
-
for (const k in args) {
|
|
126
|
-
args[k.toLowerCase().replace(/-/g, '_')] = args[k]
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const use_remote_api_defs =
|
|
153
|
+
const useRemoteApiDefs =
|
|
130
154
|
args['remote_api_defs'] ?? config.get('use_remote_api_defs')
|
|
131
155
|
|
|
132
|
-
const blueprint = await getApiBlueprint(
|
|
156
|
+
const blueprint = await getApiBlueprint(useRemoteApiDefs ?? false, {
|
|
133
157
|
update,
|
|
134
158
|
})
|
|
135
159
|
|
|
@@ -144,17 +168,22 @@ async function cli(args: ParsedArgs) {
|
|
|
144
168
|
|
|
145
169
|
const isNonInteractive = ctx.interactivity === 'non-interactive'
|
|
146
170
|
|
|
147
|
-
|
|
148
|
-
if (k === '_') continue
|
|
149
|
-
const v = args[k]
|
|
150
|
-
delete args[k]
|
|
151
|
-
const key = k.replace(/-/g, '_')
|
|
152
|
-
args[key] = v
|
|
153
|
-
if (cliFlags.includes(key)) continue
|
|
154
|
-
commandParams[key] = v
|
|
155
|
-
}
|
|
171
|
+
Object.assign(commandParams, argParams)
|
|
156
172
|
|
|
157
173
|
const selectedCommand = await interactForCommandSelection(args._, ctx)
|
|
174
|
+
|
|
175
|
+
// Hit 'back' on a top-level command path, so we start again
|
|
176
|
+
if (selectedCommand.slice(-1)[0] === '[Back]') {
|
|
177
|
+
return await cli({
|
|
178
|
+
...args,
|
|
179
|
+
_: [],
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Check the arguments before the command acts on any of them, so a mistake
|
|
184
|
+
// is reported rather than half applied.
|
|
185
|
+
assertKnownArgs(argParams, selectedCommand, ctx)
|
|
186
|
+
|
|
158
187
|
if (isEqual(selectedCommand, ['login'])) {
|
|
159
188
|
if (args['server']) {
|
|
160
189
|
config.set('server', args['server'])
|
|
@@ -236,14 +265,7 @@ async function cli(args: ParsedArgs) {
|
|
|
236
265
|
commandParams['accepted_providers'].split(',')
|
|
237
266
|
}
|
|
238
267
|
|
|
239
|
-
|
|
240
|
-
const lastCommandPath = selectedCommand.slice(-1)[0]
|
|
241
|
-
if (lastCommandPath === '[Back]') {
|
|
242
|
-
return await cli({
|
|
243
|
-
...args,
|
|
244
|
-
_: [],
|
|
245
|
-
})
|
|
246
|
-
}
|
|
268
|
+
const apiPath = `/${selectedCommand.join('/').replace(/-/g, '_')}`
|
|
247
269
|
|
|
248
270
|
const params = await interactForCommandParams(
|
|
249
271
|
{ command: selectedCommand, params: commandParams },
|
|
@@ -259,8 +281,6 @@ async function cli(args: ParsedArgs) {
|
|
|
259
281
|
})
|
|
260
282
|
}
|
|
261
283
|
|
|
262
|
-
const apiPath = `/${selectedCommand.join('/').replace(/-/g, '_')}`
|
|
263
|
-
|
|
264
284
|
if (apiPath.includes('/events/list') && params.between) {
|
|
265
285
|
delete params.since
|
|
266
286
|
}
|
|
@@ -286,11 +306,67 @@ async function cli(args: ParsedArgs) {
|
|
|
286
306
|
const toCommandWord = (arg: string): string =>
|
|
287
307
|
arg.toLowerCase().replace(/_/g, '-')
|
|
288
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Report any argument the command does not accept, rather than acting on it.
|
|
311
|
+
* An unrecognized argument is a mistake: forwarded to the API it would fail
|
|
312
|
+
* somewhere less obvious or be quietly ignored, and on a command the CLI
|
|
313
|
+
* handles itself it would go nowhere at all.
|
|
314
|
+
*
|
|
315
|
+
* Only arguments are checked. Params read from stdin are passed through as
|
|
316
|
+
* given, so a caller may send whatever the API itself accepts.
|
|
317
|
+
*
|
|
318
|
+
* `ctx` is only needed to look up an endpoint's parameters, so commands the
|
|
319
|
+
* CLI declares itself can be checked before any blueprint is loaded.
|
|
320
|
+
*/
|
|
321
|
+
const assertKnownArgs = (
|
|
322
|
+
argParams: Record<string, any>,
|
|
323
|
+
command: string[],
|
|
324
|
+
ctx?: ContextHelpers,
|
|
325
|
+
): void => {
|
|
326
|
+
const local = findLocalCommand(command)
|
|
327
|
+
|
|
328
|
+
let accepted: Set<string>
|
|
329
|
+
if (local != null) {
|
|
330
|
+
accepted = new Set(
|
|
331
|
+
local.flags.flatMap(({ long }) =>
|
|
332
|
+
long == null ? [] : [toParameterName(long)],
|
|
333
|
+
),
|
|
334
|
+
)
|
|
335
|
+
} else if (ctx != null) {
|
|
336
|
+
accepted = new Set(
|
|
337
|
+
getCommandBlueprintDef(command, ctx).request.parameters.map(
|
|
338
|
+
({ name }) => name,
|
|
339
|
+
),
|
|
340
|
+
)
|
|
341
|
+
} else {
|
|
342
|
+
throw new Error(`No definition for command seam ${command.join(' ')}`)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const unknown = Object.keys(argParams).filter((key) => !accepted.has(key))
|
|
346
|
+
if (unknown.length === 0) return
|
|
347
|
+
|
|
348
|
+
// Name an endpoint command by its path, as missing params are named, and a
|
|
349
|
+
// command the CLI handles itself by the words that run it.
|
|
350
|
+
const target =
|
|
351
|
+
local == null
|
|
352
|
+
? `/${command.join('/').replace(/-/g, '_')}`
|
|
353
|
+
: command.join(' ')
|
|
354
|
+
|
|
355
|
+
throw new UsageError(
|
|
356
|
+
`Unknown ${
|
|
357
|
+
unknown.length === 1 ? 'parameter' : 'parameters'
|
|
358
|
+
} for ${target}: ${unknown.map(toGivenArgName).join(' ')}`,
|
|
359
|
+
{
|
|
360
|
+
hint: `Run 'seam ${command.join(' ')} --help' to see what it accepts.`,
|
|
361
|
+
},
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
|
|
289
365
|
const handleConnectWebviewResponse = async (
|
|
290
|
-
|
|
366
|
+
connectWebview: any,
|
|
291
367
|
interactivity: Interactivity,
|
|
292
368
|
) => {
|
|
293
|
-
const url =
|
|
369
|
+
const url = connectWebview.url
|
|
294
370
|
|
|
295
371
|
if (
|
|
296
372
|
interactivity !== 'non-interactive' &&
|
|
@@ -337,6 +413,12 @@ run(process.argv.slice(2)).catch((e: unknown) => {
|
|
|
337
413
|
const output = getOutput()
|
|
338
414
|
process.exitCode = 1
|
|
339
415
|
|
|
416
|
+
if (e instanceof UsageError) {
|
|
417
|
+
output.error(chalk.red(e.message))
|
|
418
|
+
if (e.hint !== '') output.error(e.hint)
|
|
419
|
+
return
|
|
420
|
+
}
|
|
421
|
+
|
|
340
422
|
if (e instanceof NonInteractiveError) {
|
|
341
423
|
output.error(chalk.red(e.message))
|
|
342
424
|
return
|
package/src/lib/command-spec.ts
CHANGED
|
@@ -151,6 +151,18 @@ export const findGroup = (
|
|
|
151
151
|
): CommandGroup | undefined =>
|
|
152
152
|
spec.groups.find((group) => isSamePath(group.path, path))
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* The definition of a command the CLI handles itself, or `undefined` when the
|
|
156
|
+
* path is an endpoint or no command at all.
|
|
157
|
+
*
|
|
158
|
+
* Unlike {@link findCommand} this needs no blueprint, since these commands are
|
|
159
|
+
* declared by the CLI rather than derived from the API definitions.
|
|
160
|
+
*/
|
|
161
|
+
export const findLocalCommand = (
|
|
162
|
+
path: string[],
|
|
163
|
+
): CommandDefinition | undefined =>
|
|
164
|
+
localCommands.find((command) => isSamePath(command.path, path))
|
|
165
|
+
|
|
154
166
|
const isSamePath = (a: string[], b: string[]): boolean =>
|
|
155
167
|
a.length === b.length && a.every((word, index) => word === b[index])
|
|
156
168
|
|
|
@@ -19,7 +19,7 @@ const header = `# fish completion for the seam command.
|
|
|
19
19
|
#
|
|
20
20
|
# seam completion fish > ~/.config/fish/completions/seam.fish`
|
|
21
21
|
|
|
22
|
-
const helpers = `function __seam_command --description 'Print the seam command path on the command
|
|
22
|
+
const helpers = `function __seam_command --description 'Print the seam command path on the command-line'
|
|
23
23
|
set -l tokens (commandline -opc)
|
|
24
24
|
set -l command
|
|
25
25
|
if test (count $tokens) -gt 1
|
|
@@ -34,7 +34,7 @@ const helpers = `function __seam_command --description 'Print the seam command p
|
|
|
34
34
|
string join ' ' -- $command
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
function __seam_using --description 'Test whether the command
|
|
37
|
+
function __seam_using --description 'Test whether the command-line names the given seam command'
|
|
38
38
|
set -l command (__seam_command)
|
|
39
39
|
test "$command" = "$argv[1]"
|
|
40
40
|
end`
|
|
@@ -3,19 +3,21 @@ import { interactForDevice } from './interact-for-device.js'
|
|
|
3
3
|
import { interactForResource } from './interact-for-resource.js'
|
|
4
4
|
|
|
5
5
|
export const interactForAccessCode = async ({
|
|
6
|
-
|
|
6
|
+
// The key is a Seam API parameter name: callers pass the blueprint params
|
|
7
|
+
// bag through as-is, so only the binding may be camelCase.
|
|
8
|
+
device_id: deviceId,
|
|
7
9
|
}: {
|
|
8
10
|
device_id?: string
|
|
9
11
|
}) => {
|
|
10
12
|
const seam = await getSeam()
|
|
11
13
|
|
|
12
|
-
if (!
|
|
13
|
-
|
|
14
|
+
if (!deviceId) {
|
|
15
|
+
deviceId = await interactForDevice()
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
return interactForResource({
|
|
17
19
|
resourceName: 'access_code',
|
|
18
|
-
fetchResources: () => seam.accessCodes.list({ device_id }),
|
|
20
|
+
fetchResources: () => seam.accessCodes.list({ device_id: deviceId }),
|
|
19
21
|
toChoice: (accessCode) => ({
|
|
20
22
|
title: accessCode.name ?? '<No Name>',
|
|
21
23
|
value: accessCode.access_code_id,
|
|
@@ -5,13 +5,13 @@ import { interactForResource } from './interact-for-resource.js'
|
|
|
5
5
|
export const interactForAcsUser = async () => {
|
|
6
6
|
const seam = await getSeam()
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const acsSystemId = await interactForAcsSystem(
|
|
9
9
|
'What acs_system does the acs_user belong to?',
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
return interactForResource({
|
|
13
13
|
resourceName: 'ACS user',
|
|
14
|
-
fetchResources: () => seam.acs.users.list({ acs_system_id }),
|
|
14
|
+
fetchResources: () => seam.acs.users.list({ acs_system_id: acsSystemId }),
|
|
15
15
|
toChoice: (user) => ({
|
|
16
16
|
title: `${user.display_name} ${user.email_address}`,
|
|
17
17
|
value: user.acs_user_id,
|
|
@@ -6,11 +6,11 @@ import { prompt } from './util/prompt.js'
|
|
|
6
6
|
import { withLoading } from './util/with-loading.js'
|
|
7
7
|
|
|
8
8
|
export const interactForActionAttemptPoll = async (
|
|
9
|
-
|
|
9
|
+
actionAttempt: ActionAttemptsGetResponse['action_attempt'],
|
|
10
10
|
) => {
|
|
11
|
-
if (
|
|
12
|
-
const {
|
|
13
|
-
name: '
|
|
11
|
+
if (actionAttempt.status === 'pending') {
|
|
12
|
+
const { pollForActionAttempt } = await prompt({
|
|
13
|
+
name: 'pollForActionAttempt',
|
|
14
14
|
message: "Would you like to poll the action attempt until it's ready?",
|
|
15
15
|
type: 'toggle',
|
|
16
16
|
initial: true,
|
|
@@ -18,19 +18,19 @@ export const interactForActionAttemptPoll = async (
|
|
|
18
18
|
inactive: 'no',
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
if (
|
|
21
|
+
if (pollForActionAttempt) {
|
|
22
22
|
const seam = await getSeam()
|
|
23
|
-
const { action_attempt_id } =
|
|
23
|
+
const { action_attempt_id: actionAttemptId } = actionAttempt
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const updatedActionAttempt = await withLoading(
|
|
26
26
|
'Polling action attempt...',
|
|
27
27
|
() =>
|
|
28
28
|
seam.actionAttempts.get(
|
|
29
|
-
{ action_attempt_id },
|
|
29
|
+
{ action_attempt_id: actionAttemptId },
|
|
30
30
|
{ waitForActionAttempt: { pollingInterval: 240, timeout: 10_000 } },
|
|
31
31
|
),
|
|
32
32
|
)
|
|
33
|
-
getOutput().data({ action_attempt:
|
|
33
|
+
getOutput().data({ action_attempt: updatedActionAttempt })
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -51,11 +51,11 @@ export const interactForBlueprintObject = async (
|
|
|
51
51
|
|
|
52
52
|
const cmdPath = `/${args.command.join('/').replace(/-/g, '_')}`
|
|
53
53
|
|
|
54
|
-
const
|
|
54
|
+
const shouldAutoSubmit =
|
|
55
55
|
ctx.interactivity !== 'interactive' &&
|
|
56
56
|
haveAllRequiredParams &&
|
|
57
57
|
!args.isSubProperty
|
|
58
|
-
if (
|
|
58
|
+
if (shouldAutoSubmit) {
|
|
59
59
|
return args.params
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -160,18 +160,16 @@ export const interactForBlueprintObject = async (
|
|
|
160
160
|
args.params[paramToEdit] = await interactForAccessCode(args.params as any)
|
|
161
161
|
return interactForBlueprintObject(args, ctx)
|
|
162
162
|
} else if (paramToEdit === 'connected_account_id') {
|
|
163
|
-
const
|
|
164
|
-
args.params[paramToEdit] =
|
|
163
|
+
const connectedAccountId = await interactForConnectedAccount()
|
|
164
|
+
args.params[paramToEdit] = connectedAccountId
|
|
165
165
|
return interactForBlueprintObject(args, ctx)
|
|
166
166
|
} else if (
|
|
167
167
|
paramToEdit === 'user_identity_id' ||
|
|
168
168
|
paramToEdit === 'user_identity_ids'
|
|
169
169
|
) {
|
|
170
|
-
const
|
|
170
|
+
const userIdentityId = await interactForUserIdentity()
|
|
171
171
|
args.params[paramToEdit] =
|
|
172
|
-
paramToEdit === 'user_identity_ids'
|
|
173
|
-
? [user_identity_id]
|
|
174
|
-
: user_identity_id
|
|
172
|
+
paramToEdit === 'user_identity_ids' ? [userIdentityId] : userIdentityId
|
|
175
173
|
return interactForBlueprintObject(args, ctx)
|
|
176
174
|
} else if (paramToEdit.endsWith('acs_system_id')) {
|
|
177
175
|
args.params[paramToEdit] = await interactForAcsSystem()
|