sim 2.2.19 → 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/generated/v2-api.d.ts +3 -3
- package/dist/index.js +31 -6
- package/dist/runtime/request.d.ts +2 -0
- package/dist/runtime.js +31 -6
- 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 `@`. */
|
|
@@ -13753,7 +13753,7 @@ export declare const V2_OPERATIONS: {
|
|
|
13753
13753
|
readonly path: '/api/v2/files/[fileId]';
|
|
13754
13754
|
readonly pathParams: readonly ['fileId'];
|
|
13755
13755
|
readonly pathParamDocs: {
|
|
13756
|
-
readonly fileId: 'File identifier
|
|
13756
|
+
readonly fileId: 'File identifier, or the file’s VFS path: `files/<folder>/<name>`.';
|
|
13757
13757
|
};
|
|
13758
13758
|
readonly responseMode: 'json';
|
|
13759
13759
|
readonly summary: 'Delete file';
|
|
@@ -14796,7 +14796,7 @@ export declare const V2_OPERATIONS: {
|
|
|
14796
14796
|
readonly path: '/api/v2/files/[fileId]/metadata';
|
|
14797
14797
|
readonly pathParams: readonly ['fileId'];
|
|
14798
14798
|
readonly pathParamDocs: {
|
|
14799
|
-
readonly fileId: 'File identifier
|
|
14799
|
+
readonly fileId: 'File identifier, or the file’s VFS path: `files/<folder>/<name>`.';
|
|
14800
14800
|
};
|
|
14801
14801
|
readonly responseMode: 'json';
|
|
14802
14802
|
readonly summary: 'Get file metadata';
|
|
@@ -18837,7 +18837,7 @@ export declare const V2_OPERATIONS: {
|
|
|
18837
18837
|
readonly path: '/api/v2/files/[fileId]';
|
|
18838
18838
|
readonly pathParams: readonly ['fileId'];
|
|
18839
18839
|
readonly pathParamDocs: {
|
|
18840
|
-
readonly fileId: 'File identifier
|
|
18840
|
+
readonly fileId: 'File identifier, or the file’s VFS path: `files/<folder>/<name>`.';
|
|
18841
18841
|
};
|
|
18842
18842
|
readonly responseMode: 'json';
|
|
18843
18843
|
readonly summary: 'Rename file';
|
package/dist/index.js
CHANGED
|
@@ -11208,7 +11208,7 @@ var V2_OPERATIONS = {
|
|
|
11208
11208
|
method: "DELETE",
|
|
11209
11209
|
path: "/api/v2/files/[fileId]",
|
|
11210
11210
|
pathParams: ["fileId"],
|
|
11211
|
-
pathParamDocs: { fileId: "File identifier
|
|
11211
|
+
pathParamDocs: { fileId: "File identifier, or the file’s VFS path: `files/<folder>/<name>`." },
|
|
11212
11212
|
responseMode: "json",
|
|
11213
11213
|
summary: "Delete file",
|
|
11214
11214
|
query: {
|
|
@@ -12153,7 +12153,7 @@ var V2_OPERATIONS = {
|
|
|
12153
12153
|
method: "GET",
|
|
12154
12154
|
path: "/api/v2/files/[fileId]/metadata",
|
|
12155
12155
|
pathParams: ["fileId"],
|
|
12156
|
-
pathParamDocs: { fileId: "File identifier
|
|
12156
|
+
pathParamDocs: { fileId: "File identifier, or the file’s VFS path: `files/<folder>/<name>`." },
|
|
12157
12157
|
responseMode: "json",
|
|
12158
12158
|
summary: "Get file metadata",
|
|
12159
12159
|
query: {
|
|
@@ -16182,7 +16182,7 @@ var V2_OPERATIONS = {
|
|
|
16182
16182
|
method: "PATCH",
|
|
16183
16183
|
path: "/api/v2/files/[fileId]",
|
|
16184
16184
|
pathParams: ["fileId"],
|
|
16185
|
-
pathParamDocs: { fileId: "File identifier
|
|
16185
|
+
pathParamDocs: { fileId: "File identifier, or the file’s VFS path: `files/<folder>/<name>`." },
|
|
16186
16186
|
responseMode: "json",
|
|
16187
16187
|
summary: "Rename file",
|
|
16188
16188
|
body: {
|
|
@@ -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
|
@@ -11257,7 +11257,7 @@ var V2_OPERATIONS = {
|
|
|
11257
11257
|
method: "DELETE",
|
|
11258
11258
|
path: "/api/v2/files/[fileId]",
|
|
11259
11259
|
pathParams: ["fileId"],
|
|
11260
|
-
pathParamDocs: { fileId: "File identifier
|
|
11260
|
+
pathParamDocs: { fileId: "File identifier, or the file’s VFS path: `files/<folder>/<name>`." },
|
|
11261
11261
|
responseMode: "json",
|
|
11262
11262
|
summary: "Delete file",
|
|
11263
11263
|
query: {
|
|
@@ -12202,7 +12202,7 @@ var V2_OPERATIONS = {
|
|
|
12202
12202
|
method: "GET",
|
|
12203
12203
|
path: "/api/v2/files/[fileId]/metadata",
|
|
12204
12204
|
pathParams: ["fileId"],
|
|
12205
|
-
pathParamDocs: { fileId: "File identifier
|
|
12205
|
+
pathParamDocs: { fileId: "File identifier, or the file’s VFS path: `files/<folder>/<name>`." },
|
|
12206
12206
|
responseMode: "json",
|
|
12207
12207
|
summary: "Get file metadata",
|
|
12208
12208
|
query: {
|
|
@@ -16231,7 +16231,7 @@ var V2_OPERATIONS = {
|
|
|
16231
16231
|
method: "PATCH",
|
|
16232
16232
|
path: "/api/v2/files/[fileId]",
|
|
16233
16233
|
pathParams: ["fileId"],
|
|
16234
|
-
pathParamDocs: { fileId: "File identifier
|
|
16234
|
+
pathParamDocs: { fileId: "File identifier, or the file’s VFS path: `files/<folder>/<name>`." },
|
|
16235
16235
|
responseMode: "json",
|
|
16236
16236
|
summary: "Rename file",
|
|
16237
16237
|
body: {
|
|
@@ -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]) {
|