@seamapi/cli 0.24.1 → 0.25.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 +8 -4
- package/bin/cli.js +8 -2
- package/bin/cli.js.map +1 -1
- package/lib/args/parse.js +1 -0
- package/lib/args/parse.js.map +1 -1
- package/lib/auth/validate-token.js +1 -1
- package/lib/auth/validate-token.js.map +1 -1
- package/lib/blueprint/source-remote.js +1 -1
- package/lib/blueprint/source-remote.js.map +1 -1
- package/lib/commands/local/wizard.js +1 -1
- package/lib/commands/local/wizard.js.map +1 -1
- package/lib/commands/spec.js +8 -0
- package/lib/commands/spec.js.map +1 -1
- package/lib/http/api.d.ts +1 -1
- package/lib/http/api.js +1 -1
- package/lib/http/api.js.map +1 -1
- package/lib/http/client.d.ts +1 -1
- package/lib/http/client.js +1 -1
- package/lib/http/client.js.map +1 -1
- package/lib/http/memory-seam-api.js +1 -1
- package/lib/http/memory-seam-api.js.map +1 -1
- package/lib/http/request.js +1 -1
- package/lib/http/request.js.map +1 -1
- package/lib/interactions/access-code.d.ts +1 -1
- package/lib/interactions/access-code.js +2 -1
- package/lib/interactions/access-code.js.map +1 -1
- package/lib/interactions/acs-entrance.d.ts +1 -1
- package/lib/interactions/acs-entrance.js +2 -1
- package/lib/interactions/acs-entrance.js.map +1 -1
- package/lib/interactions/acs-system.d.ts +4 -1
- package/lib/interactions/acs-system.js +2 -1
- package/lib/interactions/acs-system.js.map +1 -1
- package/lib/interactions/acs-user.d.ts +1 -1
- package/lib/interactions/acs-user.js +5 -2
- package/lib/interactions/acs-user.js.map +1 -1
- package/lib/interactions/action-attempt-poll.d.ts +1 -1
- package/lib/interactions/blueprint-object.js +41 -13
- package/lib/interactions/blueprint-object.js.map +1 -1
- package/lib/interactions/connected-account.d.ts +1 -1
- package/lib/interactions/connected-account.js +2 -1
- package/lib/interactions/connected-account.js.map +1 -1
- package/lib/interactions/custom-metadata.js +4 -0
- package/lib/interactions/custom-metadata.js.map +1 -1
- package/lib/interactions/device.d.ts +1 -1
- package/lib/interactions/device.js +2 -1
- package/lib/interactions/device.js.map +1 -1
- package/lib/interactions/login.js +1 -1
- package/lib/interactions/login.js.map +1 -1
- package/lib/interactions/resource.d.ts +3 -1
- package/lib/interactions/resource.js +2 -1
- package/lib/interactions/resource.js.map +1 -1
- package/lib/interactions/timestamp.d.ts +1 -1
- package/lib/interactions/timestamp.js +4 -1
- package/lib/interactions/timestamp.js.map +1 -1
- package/lib/interactions/user-identity.d.ts +1 -1
- package/lib/interactions/user-identity.js +2 -1
- package/lib/interactions/user-identity.js.map +1 -1
- package/lib/interactions/workspace-id.js +1 -1
- package/lib/interactions/workspace-id.js.map +1 -1
- package/lib/memory-prompt.d.ts +10 -7
- package/lib/memory-prompt.js +12 -6
- package/lib/memory-prompt.js.map +1 -1
- package/lib/prompt.d.ts +27 -3
- package/lib/prompt.js +26 -1
- package/lib/prompt.js.map +1 -1
- package/lib/render/help.js +1 -1
- package/lib/render/help.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +8 -12
- package/src/bin/cli.ts +9 -2
- package/src/lib/args/parse.ts +1 -0
- package/src/lib/auth/validate-token.ts +1 -1
- package/src/lib/blueprint/source-remote.ts +1 -1
- package/src/lib/commands/local/wizard.ts +1 -1
- package/src/lib/commands/spec.ts +8 -0
- package/src/lib/http/api.ts +1 -1
- package/src/lib/http/client.ts +1 -1
- package/src/lib/http/memory-seam-api.ts +1 -4
- package/src/lib/http/request.ts +1 -4
- package/src/lib/interactions/access-code.ts +11 -7
- package/src/lib/interactions/acs-entrance.ts +2 -1
- package/src/lib/interactions/acs-system.ts +8 -1
- package/src/lib/interactions/acs-user.ts +5 -4
- package/src/lib/interactions/action-attempt-poll.ts +1 -1
- package/src/lib/interactions/blueprint-object.ts +62 -13
- package/src/lib/interactions/connected-account.ts +2 -1
- package/src/lib/interactions/custom-metadata.ts +6 -0
- package/src/lib/interactions/device.ts +2 -1
- package/src/lib/interactions/login.ts +1 -1
- package/src/lib/interactions/resource.ts +4 -0
- package/src/lib/interactions/timestamp.ts +4 -1
- package/src/lib/interactions/user-identity.ts +2 -1
- package/src/lib/interactions/workspace-id.ts +1 -1
- package/src/lib/memory-prompt.ts +31 -9
- package/src/lib/prompt.ts +65 -4
- package/src/lib/render/help.ts +1 -1
- package/src/lib/version.ts +1 -1
package/src/lib/prompt.ts
CHANGED
|
@@ -24,11 +24,15 @@ export interface PromptTextOptions {
|
|
|
24
24
|
message: string
|
|
25
25
|
placeholder?: string
|
|
26
26
|
defaultValue?: string
|
|
27
|
+
/** Editable text the prompt opens with, for editing a value in place. */
|
|
28
|
+
initialValue?: string | undefined
|
|
27
29
|
validate?: (value: string | undefined) => string | undefined
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export interface PromptNumberOptions {
|
|
31
33
|
message: string
|
|
34
|
+
/** Editable text the prompt opens with, for editing a value in place. */
|
|
35
|
+
initialValue?: number | undefined
|
|
32
36
|
validate?: (value: number) => string | undefined
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -42,6 +46,15 @@ export interface PromptConfirmOptions {
|
|
|
42
46
|
export interface PromptSelectOptions<Value> {
|
|
43
47
|
message: string
|
|
44
48
|
choices: Array<PromptChoice<Value>>
|
|
49
|
+
/** The choice to open on, for editing a value in place. */
|
|
50
|
+
initialValue?: Value | undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface PromptMultiselectOptions<Value> {
|
|
54
|
+
message: string
|
|
55
|
+
choices: Array<PromptChoice<Value>>
|
|
56
|
+
/** The choices to open selected, for editing a value in place. */
|
|
57
|
+
initialValues?: Value[] | undefined
|
|
45
58
|
}
|
|
46
59
|
|
|
47
60
|
/**
|
|
@@ -60,7 +73,7 @@ export interface PromptClient {
|
|
|
60
73
|
select: <Value>(options: PromptSelectOptions<Value>) => Promise<Value>
|
|
61
74
|
autocomplete: <Value>(options: PromptSelectOptions<Value>) => Promise<Value>
|
|
62
75
|
autocompleteMultiselect: <Value>(
|
|
63
|
-
options:
|
|
76
|
+
options: PromptMultiselectOptions<Value>,
|
|
64
77
|
) => Promise<Value[]>
|
|
65
78
|
}
|
|
66
79
|
|
|
@@ -133,6 +146,37 @@ const toOptions = <Value>(
|
|
|
133
146
|
: { label, value, hint }) as Option<Value>,
|
|
134
147
|
)
|
|
135
148
|
|
|
149
|
+
/**
|
|
150
|
+
* A value as the choice a list prompt opens on: the value when the list
|
|
151
|
+
* offers it, and otherwise nothing.
|
|
152
|
+
*
|
|
153
|
+
* A value the list does not offer, such as an id passed as an argument that
|
|
154
|
+
* is not among the resources fetched, would leave clack holding a selection
|
|
155
|
+
* with no choice behind it — so the prompt opens on its first choice, the
|
|
156
|
+
* same as one with no value to start from.
|
|
157
|
+
*/
|
|
158
|
+
export const offeredValue = <Value>(
|
|
159
|
+
choices: Array<PromptChoice<Value>>,
|
|
160
|
+
value: Value | undefined,
|
|
161
|
+
): Value | undefined =>
|
|
162
|
+
choices.some((choice) => choice.value === value) ? value : undefined
|
|
163
|
+
|
|
164
|
+
/** Every one of the values a list prompt offers, in the order given. */
|
|
165
|
+
export const offeredValues = <Value>(
|
|
166
|
+
choices: Array<PromptChoice<Value>>,
|
|
167
|
+
values: Value[] | undefined,
|
|
168
|
+
): Value[] =>
|
|
169
|
+
(values ?? []).filter((value) => offeredValue(choices, value) !== undefined)
|
|
170
|
+
|
|
171
|
+
// Options a clack prompt is given cannot carry an explicit undefined: it
|
|
172
|
+
// declares each optional field without it, and the CLI type-checks with
|
|
173
|
+
// exactOptionalPropertyTypes.
|
|
174
|
+
const optional = <Key extends string, Value>(
|
|
175
|
+
key: Key,
|
|
176
|
+
value: Value | undefined,
|
|
177
|
+
): Partial<Record<Key, Value>> =>
|
|
178
|
+
value === undefined ? {} : ({ [key]: value } as Record<Key, Value>)
|
|
179
|
+
|
|
136
180
|
export class TerminalPromptClient implements PromptClient {
|
|
137
181
|
/**
|
|
138
182
|
* Prompts read raw keypresses and render an interface, so they need a
|
|
@@ -145,7 +189,14 @@ export class TerminalPromptClient implements PromptClient {
|
|
|
145
189
|
|
|
146
190
|
text = async (options: PromptTextOptions): Promise<string> => {
|
|
147
191
|
installArrowKeyAliases()
|
|
148
|
-
|
|
192
|
+
const { initialValue, ...rest } = options
|
|
193
|
+
return unwrap(
|
|
194
|
+
await text({
|
|
195
|
+
...rest,
|
|
196
|
+
...optional('initialValue', initialValue),
|
|
197
|
+
output,
|
|
198
|
+
}),
|
|
199
|
+
)
|
|
149
200
|
}
|
|
150
201
|
|
|
151
202
|
number = async (options: PromptNumberOptions): Promise<number> => {
|
|
@@ -153,6 +204,7 @@ export class TerminalPromptClient implements PromptClient {
|
|
|
153
204
|
const value = unwrap(
|
|
154
205
|
await text({
|
|
155
206
|
message: options.message,
|
|
207
|
+
...optional('initialValue', options.initialValue?.toString()),
|
|
156
208
|
validate: (value) => {
|
|
157
209
|
if (value == null || value.trim() === '') return 'Enter a number'
|
|
158
210
|
const parsed = Number(value)
|
|
@@ -178,6 +230,10 @@ export class TerminalPromptClient implements PromptClient {
|
|
|
178
230
|
await select<Value>({
|
|
179
231
|
message: options.message,
|
|
180
232
|
options: toOptions(options.choices),
|
|
233
|
+
...optional(
|
|
234
|
+
'initialValue',
|
|
235
|
+
offeredValue(options.choices, options.initialValue),
|
|
236
|
+
),
|
|
181
237
|
output,
|
|
182
238
|
}),
|
|
183
239
|
)
|
|
@@ -191,6 +247,10 @@ export class TerminalPromptClient implements PromptClient {
|
|
|
191
247
|
await autocomplete<Value>({
|
|
192
248
|
message: options.message,
|
|
193
249
|
options: toOptions(options.choices),
|
|
250
|
+
...optional(
|
|
251
|
+
'initialValue',
|
|
252
|
+
offeredValue(options.choices, options.initialValue),
|
|
253
|
+
),
|
|
194
254
|
// Search a list by any part of a name or hint, rather than only by
|
|
195
255
|
// the label, which is all clack matches for itself.
|
|
196
256
|
filter: searchChoices,
|
|
@@ -200,13 +260,14 @@ export class TerminalPromptClient implements PromptClient {
|
|
|
200
260
|
}
|
|
201
261
|
|
|
202
262
|
autocompleteMultiselect = async <Value>(
|
|
203
|
-
options:
|
|
263
|
+
options: PromptMultiselectOptions<Value>,
|
|
204
264
|
): Promise<Value[]> => {
|
|
205
265
|
installArrowKeyAliases()
|
|
206
266
|
return unwrap(
|
|
207
267
|
await autocompleteMultiselect<Value>({
|
|
208
268
|
message: options.message,
|
|
209
269
|
options: toOptions(options.choices),
|
|
270
|
+
initialValues: offeredValues(options.choices, options.initialValues),
|
|
210
271
|
filter: searchChoices,
|
|
211
272
|
output,
|
|
212
273
|
}),
|
|
@@ -273,7 +334,7 @@ export const promptAutocomplete = async <Value>(
|
|
|
273
334
|
}
|
|
274
335
|
|
|
275
336
|
export const promptAutocompleteMultiselect = async <Value>(
|
|
276
|
-
options:
|
|
337
|
+
options: PromptMultiselectOptions<Value>,
|
|
277
338
|
): Promise<Value[]> => {
|
|
278
339
|
ensureInteractive()
|
|
279
340
|
return await client.autocompleteMultiselect(options)
|
package/src/lib/render/help.ts
CHANGED
|
@@ -36,7 +36,7 @@ const outputSection = {
|
|
|
36
36
|
content: [
|
|
37
37
|
'Only the response is written to stdout, so it is safe to pipe. Prompts, progress, and other information are written to stderr.',
|
|
38
38
|
'The response is trimmed to the response key and pagination.',
|
|
39
|
-
'Request params may be piped or redirected in as a JSON object. Params given as arguments win over
|
|
39
|
+
'Request params may be piped or redirected in as a JSON object, or passed inline with --raw. Params given as arguments win over raw or stdin params.',
|
|
40
40
|
],
|
|
41
41
|
}
|
|
42
42
|
|
package/src/lib/version.ts
CHANGED