sim 2.2.20-preview.254.1 → 2.2.20-preview.255.1
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/dist/contract/types.d.ts +5 -0
- package/dist/index.js +28 -3
- package/dist/runtime/request.d.ts +2 -0
- package/dist/runtime.js +28 -3
- package/package.json +1 -1
package/dist/contract/types.d.ts
CHANGED
|
@@ -67,6 +67,11 @@ export interface FlagSpec {
|
|
|
67
67
|
* error, and a literal `#` value can still be passed.
|
|
68
68
|
*/
|
|
69
69
|
manifest?: true;
|
|
70
|
+
/**
|
|
71
|
+
* The list's values may also follow the command as arguments, so `files batch-delete <id>...`
|
|
72
|
+
* reads like `rm`. Passing both forms is refused. At most one field per command.
|
|
73
|
+
*/
|
|
74
|
+
trailing?: true;
|
|
70
75
|
/** Take a JSON string. Implied for object/array/unknown fields. */
|
|
71
76
|
json?: boolean;
|
|
72
77
|
/** Read a scalar string verbatim from `@path` / `@-`; `@@` escapes a literal leading `@`. */
|
package/dist/index.js
CHANGED
|
@@ -20211,7 +20211,7 @@ var CLI_CONTRACT = {
|
|
|
20211
20211
|
command: "files batch-delete",
|
|
20212
20212
|
describe: "Delete several files at once",
|
|
20213
20213
|
flags: {
|
|
20214
|
-
fileIds: { list: true }
|
|
20214
|
+
fileIds: { list: true, trailing: true }
|
|
20215
20215
|
},
|
|
20216
20216
|
confirm: "This archives the listed files; restore them with `files restore`."
|
|
20217
20217
|
},
|
|
@@ -21352,6 +21352,9 @@ var NUMERIC_KINDS = new Set(["number", "integer"]);
|
|
|
21352
21352
|
function flagSpecFor(operation, field) {
|
|
21353
21353
|
return CLI_CONTRACT[operation]?.flags?.[field] ?? {};
|
|
21354
21354
|
}
|
|
21355
|
+
function trailingListField(commandSpec) {
|
|
21356
|
+
return Object.entries(commandSpec.flags ?? {}).find(([, flag]) => flag.trailing)?.[0];
|
|
21357
|
+
}
|
|
21355
21358
|
var RESERVED_PROGRAM_FLAGS = new Set([
|
|
21356
21359
|
"--version",
|
|
21357
21360
|
"-V",
|
|
@@ -21799,7 +21802,7 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
|
|
|
21799
21802
|
const placeholder = takesList ? "<value...>" : flag.rowCap ? "<n>" : wantsJson ? "<json|@file>" : flag.textSource ? "<value|@file>" : descriptor.nullable ? "<number|null>" : "<value>";
|
|
21800
21803
|
const choices = flag.choices ?? descriptor.values;
|
|
21801
21804
|
const literalNull = slot === "body" && !takesList && !wantsJson && !descriptor.nullable;
|
|
21802
|
-
const describe = `${documented}${takesList ? flag.manifest ? " (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @)" : " (space-separated, or @path / @- with one value per line; @@value for a literal leading @)" : wantsJson ? " (JSON, or @path / @- to read a file or stdin)" : flag.textSource ? " (@path / @- reads a file or stdin verbatim, including trailing newlines; @@value for a literal leading @)" : ""}${descriptor.required ? " (required)" : ""}${literalNull ? literalNullHint(documented, name) : ""}`;
|
|
21805
|
+
const describe = `${documented}${takesList ? flag.manifest ? " (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @)" : " (space-separated, or @path / @- with one value per line; @@value for a literal leading @)" : wantsJson ? " (JSON, or @path / @- to read a file or stdin)" : flag.textSource ? " (@path / @- reads a file or stdin verbatim, including trailing newlines; @@value for a literal leading @)" : ""}${descriptor.required ? flag.trailing ? " (required, or pass the values as arguments)" : " (required)" : ""}${literalNull ? literalNullHint(documented, name) : ""}`;
|
|
21803
21806
|
const renamedFrom = flag.renamedFrom ?? [];
|
|
21804
21807
|
const option = new Option(`${short}--${name} ${placeholder}`, describe);
|
|
21805
21808
|
if (flag.hidden)
|
|
@@ -21809,8 +21812,9 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
|
|
|
21809
21812
|
if (descriptor.default !== undefined && field !== "limit") {
|
|
21810
21813
|
option.default(undefined, String(descriptor.default));
|
|
21811
21814
|
}
|
|
21812
|
-
if (descriptor.required && renamedFrom.length === 0)
|
|
21815
|
+
if (descriptor.required && renamedFrom.length === 0 && !flag.trailing) {
|
|
21813
21816
|
option.makeOptionMandatory();
|
|
21817
|
+
}
|
|
21814
21818
|
command.addOption(option);
|
|
21815
21819
|
for (const previous of renamedFrom) {
|
|
21816
21820
|
const retired = new Option(`--${previous} ${placeholder}`).hideHelp();
|
|
@@ -22083,6 +22087,15 @@ async function executeOperation(operation, commandSpec, operationSpec, invocatio
|
|
|
22083
22087
|
for (const [index, field] of (commandSpec.positionals ?? []).entries()) {
|
|
22084
22088
|
requestFlags[camel(flagNameFor(operation, field))] = invocation[pathPositionalCount + index];
|
|
22085
22089
|
}
|
|
22090
|
+
const trailing = trailingListField(commandSpec);
|
|
22091
|
+
const trailingValues = trailing ? invocation[pathPositionalCount + (commandSpec.positionals?.length ?? 0)] : undefined;
|
|
22092
|
+
if (trailing && Array.isArray(trailingValues) && trailingValues.length > 0) {
|
|
22093
|
+
const name = flagNameFor(operation, trailing);
|
|
22094
|
+
if (requestFlags[camel(name)] !== undefined) {
|
|
22095
|
+
throw new SimApiError(`Pass the ${name} as arguments or with --${name}, not both`, 0);
|
|
22096
|
+
}
|
|
22097
|
+
requestFlags[camel(name)] = trailingValues;
|
|
22098
|
+
}
|
|
22086
22099
|
foldRenamedFlags(operation, commandSpec, requestFlags);
|
|
22087
22100
|
assertCapIsUsable(operation, requestFlags);
|
|
22088
22101
|
assertSelectorIsUsable(operation, requestFlags);
|
|
@@ -22448,6 +22461,18 @@ function configureOperation(command, operation, spec) {
|
|
|
22448
22461
|
}
|
|
22449
22462
|
command.argument(`<${flagNameFor(operation, field)}>`, flagSpecFor(operation, field).describe ?? descriptor.describe);
|
|
22450
22463
|
}
|
|
22464
|
+
const trailing = trailingListField(spec);
|
|
22465
|
+
if (trailing) {
|
|
22466
|
+
const trailingFlags = Object.values(spec.flags ?? {}).filter((flag) => flag.trailing);
|
|
22467
|
+
const descriptor = operationSpec.query?.[trailing] ?? operationSpec.body?.[trailing];
|
|
22468
|
+
if (trailingFlags.length > 1)
|
|
22469
|
+
throw new Error(`${operation} declares more than one trailing list`);
|
|
22470
|
+
if (!descriptor || !flagSpecFor(operation, trailing).list) {
|
|
22471
|
+
throw new Error(`${operation}.${trailing} is trailing but not a list request field`);
|
|
22472
|
+
}
|
|
22473
|
+
const name = flagNameFor(operation, trailing);
|
|
22474
|
+
command.argument(`[${name}...]`, `${flagSpecFor(operation, trailing).describe ?? descriptor.describe} Same as --${name}.`);
|
|
22475
|
+
}
|
|
22451
22476
|
if (spec.requestFields) {
|
|
22452
22477
|
for (const field of spec.requestFields) {
|
|
22453
22478
|
if (!operationSpec.query?.[field] && !operationSpec.body?.[field] && !operationSpec.headers?.[field]) {
|
|
@@ -34,6 +34,8 @@ export declare function isProfileWorkspacePath(commandSpec: CommandSpec, param:
|
|
|
34
34
|
*/
|
|
35
35
|
export declare function cursorSlot(operationSpec: Pick<OperationSpec, 'query' | 'body'>): 'query' | 'body' | null;
|
|
36
36
|
export declare function flagSpecFor(operation: V2OperationName, field: string): FlagSpec;
|
|
37
|
+
/** The list field whose values may also follow the command as arguments, if any. */
|
|
38
|
+
export declare function trailingListField(commandSpec: CommandSpec): string | undefined;
|
|
37
39
|
/**
|
|
38
40
|
* Long and short flags the root program has already claimed.
|
|
39
41
|
*
|
package/dist/runtime.js
CHANGED
|
@@ -20260,7 +20260,7 @@ var CLI_CONTRACT = {
|
|
|
20260
20260
|
command: "files batch-delete",
|
|
20261
20261
|
describe: "Delete several files at once",
|
|
20262
20262
|
flags: {
|
|
20263
|
-
fileIds: { list: true }
|
|
20263
|
+
fileIds: { list: true, trailing: true }
|
|
20264
20264
|
},
|
|
20265
20265
|
confirm: "This archives the listed files; restore them with `files restore`."
|
|
20266
20266
|
},
|
|
@@ -21401,6 +21401,9 @@ var NUMERIC_KINDS = new Set(["number", "integer"]);
|
|
|
21401
21401
|
function flagSpecFor(operation, field) {
|
|
21402
21402
|
return CLI_CONTRACT[operation]?.flags?.[field] ?? {};
|
|
21403
21403
|
}
|
|
21404
|
+
function trailingListField(commandSpec) {
|
|
21405
|
+
return Object.entries(commandSpec.flags ?? {}).find(([, flag]) => flag.trailing)?.[0];
|
|
21406
|
+
}
|
|
21404
21407
|
var RESERVED_PROGRAM_FLAGS = new Set([
|
|
21405
21408
|
"--version",
|
|
21406
21409
|
"-V",
|
|
@@ -21848,7 +21851,7 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
|
|
|
21848
21851
|
const placeholder = takesList ? "<value...>" : flag.rowCap ? "<n>" : wantsJson ? "<json|@file>" : flag.textSource ? "<value|@file>" : descriptor.nullable ? "<number|null>" : "<value>";
|
|
21849
21852
|
const choices = flag.choices ?? descriptor.values;
|
|
21850
21853
|
const literalNull = slot === "body" && !takesList && !wantsJson && !descriptor.nullable;
|
|
21851
|
-
const describe = `${documented}${takesList ? flag.manifest ? " (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @)" : " (space-separated, or @path / @- with one value per line; @@value for a literal leading @)" : wantsJson ? " (JSON, or @path / @- to read a file or stdin)" : flag.textSource ? " (@path / @- reads a file or stdin verbatim, including trailing newlines; @@value for a literal leading @)" : ""}${descriptor.required ? " (required)" : ""}${literalNull ? literalNullHint(documented, name) : ""}`;
|
|
21854
|
+
const describe = `${documented}${takesList ? flag.manifest ? " (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @)" : " (space-separated, or @path / @- with one value per line; @@value for a literal leading @)" : wantsJson ? " (JSON, or @path / @- to read a file or stdin)" : flag.textSource ? " (@path / @- reads a file or stdin verbatim, including trailing newlines; @@value for a literal leading @)" : ""}${descriptor.required ? flag.trailing ? " (required, or pass the values as arguments)" : " (required)" : ""}${literalNull ? literalNullHint(documented, name) : ""}`;
|
|
21852
21855
|
const renamedFrom = flag.renamedFrom ?? [];
|
|
21853
21856
|
const option = new Option(`${short}--${name} ${placeholder}`, describe);
|
|
21854
21857
|
if (flag.hidden)
|
|
@@ -21858,8 +21861,9 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
|
|
|
21858
21861
|
if (descriptor.default !== undefined && field !== "limit") {
|
|
21859
21862
|
option.default(undefined, String(descriptor.default));
|
|
21860
21863
|
}
|
|
21861
|
-
if (descriptor.required && renamedFrom.length === 0)
|
|
21864
|
+
if (descriptor.required && renamedFrom.length === 0 && !flag.trailing) {
|
|
21862
21865
|
option.makeOptionMandatory();
|
|
21866
|
+
}
|
|
21863
21867
|
command.addOption(option);
|
|
21864
21868
|
for (const previous of renamedFrom) {
|
|
21865
21869
|
const retired = new Option(`--${previous} ${placeholder}`).hideHelp();
|
|
@@ -22132,6 +22136,15 @@ async function executeOperation(operation, commandSpec, operationSpec, invocatio
|
|
|
22132
22136
|
for (const [index, field] of (commandSpec.positionals ?? []).entries()) {
|
|
22133
22137
|
requestFlags[camel(flagNameFor(operation, field))] = invocation[pathPositionalCount + index];
|
|
22134
22138
|
}
|
|
22139
|
+
const trailing = trailingListField(commandSpec);
|
|
22140
|
+
const trailingValues = trailing ? invocation[pathPositionalCount + (commandSpec.positionals?.length ?? 0)] : undefined;
|
|
22141
|
+
if (trailing && Array.isArray(trailingValues) && trailingValues.length > 0) {
|
|
22142
|
+
const name = flagNameFor(operation, trailing);
|
|
22143
|
+
if (requestFlags[camel(name)] !== undefined) {
|
|
22144
|
+
throw new SimApiError(`Pass the ${name} as arguments or with --${name}, not both`, 0);
|
|
22145
|
+
}
|
|
22146
|
+
requestFlags[camel(name)] = trailingValues;
|
|
22147
|
+
}
|
|
22135
22148
|
foldRenamedFlags(operation, commandSpec, requestFlags);
|
|
22136
22149
|
assertCapIsUsable(operation, requestFlags);
|
|
22137
22150
|
assertSelectorIsUsable(operation, requestFlags);
|
|
@@ -22497,6 +22510,18 @@ function configureOperation(command, operation, spec) {
|
|
|
22497
22510
|
}
|
|
22498
22511
|
command.argument(`<${flagNameFor(operation, field)}>`, flagSpecFor(operation, field).describe ?? descriptor.describe);
|
|
22499
22512
|
}
|
|
22513
|
+
const trailing = trailingListField(spec);
|
|
22514
|
+
if (trailing) {
|
|
22515
|
+
const trailingFlags = Object.values(spec.flags ?? {}).filter((flag) => flag.trailing);
|
|
22516
|
+
const descriptor = operationSpec.query?.[trailing] ?? operationSpec.body?.[trailing];
|
|
22517
|
+
if (trailingFlags.length > 1)
|
|
22518
|
+
throw new Error(`${operation} declares more than one trailing list`);
|
|
22519
|
+
if (!descriptor || !flagSpecFor(operation, trailing).list) {
|
|
22520
|
+
throw new Error(`${operation}.${trailing} is trailing but not a list request field`);
|
|
22521
|
+
}
|
|
22522
|
+
const name = flagNameFor(operation, trailing);
|
|
22523
|
+
command.argument(`[${name}...]`, `${flagSpecFor(operation, trailing).describe ?? descriptor.describe} Same as --${name}.`);
|
|
22524
|
+
}
|
|
22500
22525
|
if (spec.requestFields) {
|
|
22501
22526
|
for (const field of spec.requestFields) {
|
|
22502
22527
|
if (!operationSpec.query?.[field] && !operationSpec.body?.[field] && !operationSpec.headers?.[field]) {
|