sim 2.1.21 → 2.1.22-preview.142.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.
Files changed (2) hide show
  1. package/dist/index.js +182 -31
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10645,6 +10645,17 @@ var V2_OPERATIONS = {
10645
10645
  }
10646
10646
  }
10647
10647
  },
10648
+ deleteFileVersion: {
10649
+ method: "DELETE",
10650
+ path: "/api/v2/files/[fileId]/versions/[version]",
10651
+ pathParams: ["fileId", "version"],
10652
+ pathParamDocs: { fileId: "File identifier.", version: "Version number." },
10653
+ responseMode: "json",
10654
+ summary: "Delete File Version",
10655
+ query: {
10656
+ workspaceId: { kind: "string", required: true, describe: "Workspace that owns the file." }
10657
+ }
10658
+ },
10648
10659
  deleteKnowledgeBase: {
10649
10660
  method: "DELETE",
10650
10661
  path: "/api/v2/knowledge/[knowledgeBaseId]",
@@ -11068,6 +11079,17 @@ var V2_OPERATIONS = {
11068
11079
  workspaceId: { kind: "string", required: true, describe: "Workspace that owns the file." }
11069
11080
  }
11070
11081
  },
11082
+ downloadFileVersion: {
11083
+ method: "GET",
11084
+ path: "/api/v2/files/[fileId]/versions/[version]/content",
11085
+ pathParams: ["fileId", "version"],
11086
+ pathParamDocs: { fileId: "File identifier.", version: "Version number." },
11087
+ responseMode: "binary",
11088
+ summary: "Download File Version",
11089
+ query: {
11090
+ workspaceId: { kind: "string", required: true, describe: "Workspace that owns the file." }
11091
+ }
11092
+ },
11071
11093
  downloadRunFile: {
11072
11094
  method: "GET",
11073
11095
  path: "/api/v2/workflows/[workflowId]/runs/[runId]/files/[fileId]",
@@ -11378,6 +11400,17 @@ var V2_OPERATIONS = {
11378
11400
  }
11379
11401
  }
11380
11402
  },
11403
+ getFileVersion: {
11404
+ method: "GET",
11405
+ path: "/api/v2/files/[fileId]/versions/[version]",
11406
+ pathParams: ["fileId", "version"],
11407
+ pathParamDocs: { fileId: "File identifier.", version: "Version number." },
11408
+ responseMode: "json",
11409
+ summary: "Get File Version",
11410
+ query: {
11411
+ workspaceId: { kind: "string", required: true, describe: "Workspace that owns the file." }
11412
+ }
11413
+ },
11381
11414
  getKnowledgeBase: {
11382
11415
  method: "GET",
11383
11416
  path: "/api/v2/knowledge/[knowledgeBaseId]",
@@ -12489,6 +12522,38 @@ var V2_OPERATIONS = {
12489
12522
  }
12490
12523
  }
12491
12524
  },
12525
+ listFileVersions: {
12526
+ method: "GET",
12527
+ path: "/api/v2/files/[fileId]/versions",
12528
+ pathParams: ["fileId"],
12529
+ pathParamDocs: { fileId: "File identifier." },
12530
+ responseMode: "json",
12531
+ summary: "List File Versions",
12532
+ query: {
12533
+ workspaceId: { kind: "string", required: true, describe: "Workspace that owns the file." },
12534
+ sortBy: {
12535
+ kind: "enum",
12536
+ values: ["version"],
12537
+ default: "version",
12538
+ describe: "Field used to sort the result."
12539
+ },
12540
+ sortOrder: {
12541
+ kind: "enum",
12542
+ values: ["asc", "desc"],
12543
+ default: "desc",
12544
+ describe: "Sort direction."
12545
+ },
12546
+ limit: {
12547
+ kind: "integer",
12548
+ default: 50,
12549
+ describe: "Maximum versions to return per page. Must be a whole number from 1 to 100. Defaults to 50."
12550
+ },
12551
+ cursor: {
12552
+ kind: "string",
12553
+ describe: "Opaque cursor from the previous page. Send it back with the same sort and filters; only `limit` may change. Change anything else and pagination must restart without a cursor."
12554
+ }
12555
+ }
12556
+ },
12492
12557
  listKnowledgeBases: {
12493
12558
  method: "GET",
12494
12559
  path: "/api/v2/knowledge",
@@ -14108,6 +14173,29 @@ var V2_OPERATIONS = {
14108
14173
  }
14109
14174
  }
14110
14175
  },
14176
+ readFileVersionText: {
14177
+ method: "GET",
14178
+ path: "/api/v2/files/[fileId]/versions/[version]/text",
14179
+ pathParams: ["fileId", "version"],
14180
+ pathParamDocs: { fileId: "File identifier.", version: "Version number." },
14181
+ responseMode: "json",
14182
+ summary: "Read File Version Text",
14183
+ query: {
14184
+ workspaceId: { kind: "string", required: true, describe: "Workspace that owns the file." },
14185
+ maxBytes: {
14186
+ kind: "integer",
14187
+ describe: "Optional ceiling on the source bytes fed to the parser, lowering but never raising the server limit."
14188
+ },
14189
+ offset: {
14190
+ kind: "integer",
14191
+ describe: "First line to return, 1-based. Absent starts at the first line."
14192
+ },
14193
+ limit: {
14194
+ kind: "integer",
14195
+ describe: "How many lines to return from `offset`. Absent reads to the end."
14196
+ }
14197
+ }
14198
+ },
14111
14199
  relocateFileFolder: {
14112
14200
  method: "PATCH",
14113
14201
  path: "/api/v2/files/folders",
@@ -14374,6 +14462,21 @@ var V2_OPERATIONS = {
14374
14462
  input: { kind: "unknown", describe: "Input supplied to the paused workflow block." }
14375
14463
  }
14376
14464
  },
14465
+ revertFileVersion: {
14466
+ method: "POST",
14467
+ path: "/api/v2/files/[fileId]/versions/[version]/revert",
14468
+ pathParams: ["fileId", "version"],
14469
+ pathParamDocs: { fileId: "File identifier.", version: "Version number." },
14470
+ responseMode: "json",
14471
+ summary: "Revert File Version",
14472
+ body: {
14473
+ workspaceId: { kind: "string", required: true, describe: "Workspace that owns the file." },
14474
+ expectedCurrentVersion: {
14475
+ kind: "integer",
14476
+ describe: "Revert only while this is still the current version; otherwise the request fails with `409`. Omit to revert whatever is current. Collaborative edits and repeated workflow writes that fold into the current version keep its number."
14477
+ }
14478
+ }
14479
+ },
14377
14480
  revertWorkflowVersion: {
14378
14481
  method: "POST",
14379
14482
  path: "/api/v2/workflows/[workflowId]/versions/[version]/revert",
@@ -16889,6 +16992,7 @@ var CLI_CONTRACT = {
16889
16992
  { header: "uploaded by", path: "uploadedByEmail" },
16890
16993
  { header: "uploaded", path: "uploadedAt", format: "timestamp" },
16891
16994
  { header: "updated", path: "updatedAt", format: "timestamp" },
16995
+ { header: "version", path: "currentVersion" },
16892
16996
  { header: "shared", path: "share.isActive", format: "bool" },
16893
16997
  { header: "share URL", path: "share.url" },
16894
16998
  { header: "share auth", path: "share.authType" },
@@ -16913,6 +17017,49 @@ var CLI_CONTRACT = {
16913
17017
  renamedFrom: ["files restore create"],
16914
17018
  describe: "Restore an archived file"
16915
17019
  },
17020
+ listFileVersions: {
17021
+ command: "files versions list",
17022
+ describe: "List the recorded versions of a file",
17023
+ columns: [
17024
+ { header: "version" },
17025
+ { header: "current", path: "isCurrent", format: "bool" },
17026
+ { header: "source" },
17027
+ { header: "size", format: "bytes" },
17028
+ { header: "authors", format: "count" },
17029
+ { header: "created", path: "createdAt", format: "timestamp" },
17030
+ { header: "superseded", path: "supersededAt", format: "timestamp" }
17031
+ ]
17032
+ },
17033
+ getFileVersion: {
17034
+ command: "files versions describe",
17035
+ describe: "Show the metadata of one version of a file",
17036
+ fields: [
17037
+ { header: "file", path: "fileId" },
17038
+ { header: "version" },
17039
+ { header: "current", path: "isCurrent", format: "bool" },
17040
+ { header: "source" },
17041
+ { header: "restored from", path: "restoredFromVersion" },
17042
+ { header: "size", format: "bytes" },
17043
+ { header: "type", path: "contentType" },
17044
+ { header: "authors", format: "count" },
17045
+ { header: "created", path: "createdAt", format: "timestamp" },
17046
+ { header: "updated", path: "updatedAt", format: "timestamp" },
17047
+ { header: "superseded", path: "supersededAt", format: "timestamp" }
17048
+ ]
17049
+ },
17050
+ readFileVersionText: {
17051
+ command: "files versions read",
17052
+ describe: "Read the text content of one version of a file"
17053
+ },
17054
+ revertFileVersion: {
17055
+ command: "files versions revert",
17056
+ describe: "Make a previous version of a file current again"
17057
+ },
17058
+ deleteFileVersion: {
17059
+ command: "files versions delete",
17060
+ describe: "Permanently delete a previous version of a file",
17061
+ confirm: "This permanently deletes the version and its stored content."
17062
+ },
16916
17063
  restoreFileFolder: {
16917
17064
  command: "files folders restore",
16918
17065
  positionals: ["path"],
@@ -19403,40 +19550,43 @@ function isTerminalSafeContentType(contentType) {
19403
19550
  "image/svg+xml"
19404
19551
  ].includes(mediaType);
19405
19552
  }
19406
- function attachFileGet(files) {
19407
- files.command("get").argument("<fileId>", "File whose content to read").allowExcessArguments(false).description("Get a file’s content").option("-o, --output-file <path>", "Write content to a file instead of stdout").option("--force", "Overwrite --output-file if it already exists").action(async (fileId, options, command) => {
19408
- const writesToStdout = options.outputFile === undefined || options.outputFile === "-";
19409
- if (writesToStdout && options.force) {
19410
- throw new SimApiError("--force requires --output-file <path>", 0);
19411
- }
19412
- const { client, profile } = clientFrom(command);
19413
- const workspaceId = client.requireWorkspace();
19414
- const operation = V2_OPERATIONS.downloadFile;
19415
- const response = await client.requestRaw(resolvePath(operation.path, { fileId }), {
19416
- method: operation.method,
19417
- query: { workspaceId }
19418
- });
19419
- if (!response.body) {
19420
- throw new SimApiError("File content response was empty.", response.status);
19421
- }
19422
- if (options.outputFile === undefined || options.outputFile === "-") {
19423
- const contentType = response.headers.get("content-type");
19424
- if (process.stdout.isTTY && !isTerminalSafeContentType(contentType)) {
19425
- await response.body.cancel();
19426
- throw new SimApiError(`Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
19427
- }
19428
- await streamToStdout(response.body);
19429
- return;
19553
+ async function downloadToOutput(command, operation, pathParams, options) {
19554
+ const target = options.outputFile;
19555
+ const writesToStdout = target === undefined || target === "-";
19556
+ if (writesToStdout && options.force) {
19557
+ throw new SimApiError("--force requires --output-file <path>", 0);
19558
+ }
19559
+ const { client, profile } = clientFrom(command);
19560
+ const workspaceId = client.requireWorkspace();
19561
+ const response = await client.requestRaw(resolvePath(operation.path, pathParams), {
19562
+ method: operation.method,
19563
+ query: { workspaceId }
19564
+ });
19565
+ if (!response.body) {
19566
+ throw new SimApiError("File content response was empty.", response.status);
19567
+ }
19568
+ if (writesToStdout) {
19569
+ const contentType = response.headers.get("content-type");
19570
+ if (process.stdout.isTTY && !isTerminalSafeContentType(contentType)) {
19571
+ await response.body.cancel();
19572
+ throw new SimApiError(`Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
19430
19573
  }
19431
- const target = options.outputFile;
19432
- await saveToFile(response.body, target, Boolean(options.force));
19433
- printProtocolResult(profile.output, {
19434
- id: fileId,
19435
- path: target,
19436
- status: "saved"
19437
- });
19574
+ await streamToStdout(response.body);
19575
+ return;
19576
+ }
19577
+ await saveToFile(response.body, target, Boolean(options.force));
19578
+ printProtocolResult(profile.output, {
19579
+ id: pathParams.fileId,
19580
+ path: target,
19581
+ status: "saved"
19438
19582
  });
19439
19583
  }
19584
+ function attachFileGet(files) {
19585
+ files.command("get").argument("<fileId>", "File whose content to read").allowExcessArguments(false).description("Get a file’s content").option("-o, --output-file <path>", "Write content to a file instead of stdout").option("--force", "Overwrite --output-file if it already exists").action((fileId, options, command) => downloadToOutput(command, V2_OPERATIONS.downloadFile, { fileId }, options));
19586
+ }
19587
+ function attachFileVersionDownload(versions) {
19588
+ versions.command("download").argument("<fileId>", "File identifier.").argument("<version>", "Version number.").allowExcessArguments(false).description("Download the content of one version of a file").option("-o, --output-file <path>", "Write content to a file instead of stdout").option("--force", "Overwrite --output-file if it already exists").action((fileId, version, options, command) => downloadToOutput(command, V2_OPERATIONS.downloadFileVersion, { fileId, version }, options));
19589
+ }
19440
19590
 
19441
19591
  // src/transfer/local-file.ts
19442
19592
  import { constants as constants2 } from "node:fs";
@@ -20645,6 +20795,7 @@ function attachProtocolCommands(program) {
20645
20795
  const files = group(program, "files");
20646
20796
  attachFileUpload(files);
20647
20797
  attachFileGet(files);
20798
+ attachFileVersionDownload(group(files, "versions"));
20648
20799
  attachResourceDirectoryCommands(files, {
20649
20800
  kind: "file",
20650
20801
  resources: "listFiles",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim",
3
- "version": "2.1.21",
3
+ "version": "2.1.22-preview.142.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "imports": {