sim 2.1.22-preview.142.1 → 2.1.22-preview.145.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 +34 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6970,6 +6970,9 @@ function omit(obj, keys) {
6970
6970
  }
6971
6971
  return result;
6972
6972
  }
6973
+ function isRecordLike(value) {
6974
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6975
+ }
6973
6976
 
6974
6977
  // src/update/install.ts
6975
6978
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
@@ -17025,7 +17028,7 @@ var CLI_CONTRACT = {
17025
17028
  { header: "current", path: "isCurrent", format: "bool" },
17026
17029
  { header: "source" },
17027
17030
  { header: "size", format: "bytes" },
17028
- { header: "authors", format: "count" },
17031
+ { header: "authors", format: "people" },
17029
17032
  { header: "created", path: "createdAt", format: "timestamp" },
17030
17033
  { header: "superseded", path: "supersededAt", format: "timestamp" }
17031
17034
  ]
@@ -17041,7 +17044,7 @@ var CLI_CONTRACT = {
17041
17044
  { header: "restored from", path: "restoredFromVersion" },
17042
17045
  { header: "size", format: "bytes" },
17043
17046
  { header: "type", path: "contentType" },
17044
- { header: "authors", format: "count" },
17047
+ { header: "authors", format: "people" },
17045
17048
  { header: "created", path: "createdAt", format: "timestamp" },
17046
17049
  { header: "updated", path: "updatedAt", format: "timestamp" },
17047
17050
  { header: "superseded", path: "supersededAt", format: "timestamp" }
@@ -17053,7 +17056,18 @@ var CLI_CONTRACT = {
17053
17056
  },
17054
17057
  revertFileVersion: {
17055
17058
  command: "files versions revert",
17056
- describe: "Make a previous version of a file current again"
17059
+ describe: "Make a previous version of a file current again",
17060
+ fields: [
17061
+ { header: "reverted", format: "bool" },
17062
+ { header: "file", path: "file.id" },
17063
+ { header: "name", path: "file.name" },
17064
+ { header: "version", path: "version.version" },
17065
+ { header: "source", path: "version.source" },
17066
+ { header: "restored from", path: "version.restoredFromVersion" },
17067
+ { header: "size", path: "version.size", format: "bytes" },
17068
+ { header: "authors", path: "version.authors", format: "people" },
17069
+ { header: "created", path: "version.createdAt", format: "timestamp" }
17070
+ ]
17057
17071
  },
17058
17072
  deleteFileVersion: {
17059
17073
  command: "files versions delete",
@@ -17679,6 +17693,12 @@ function decodeFolderPath(value) {
17679
17693
  }
17680
17694
  }).join("/");
17681
17695
  }
17696
+ function personLabel(person) {
17697
+ const { id, email } = person ?? {};
17698
+ if (typeof email === "string" && email)
17699
+ return email;
17700
+ return typeof id === "string" && id ? id : JSON.stringify(person);
17701
+ }
17682
17702
  function renderCell(value, format, options = {}) {
17683
17703
  switch (format) {
17684
17704
  case "timestamp":
@@ -17695,6 +17715,8 @@ function renderCell(value, format, options = {}) {
17695
17715
  return typeof value === "number" ? value.toFixed(4) : text(null);
17696
17716
  case "count":
17697
17717
  return Array.isArray(value) ? String(value.length) : text(null);
17718
+ case "people":
17719
+ return Array.isArray(value) && value.length > 0 ? sanitize(value.map(personLabel).join(", ")) : text(null);
17698
17720
  case "folder-path":
17699
17721
  return typeof value === "string" ? text(decodeFolderPath(value)) : text(value);
17700
17722
  case "trace-count": {
@@ -20408,9 +20430,6 @@ function resolveWorkflowRunSelection(flags) {
20408
20430
  }
20409
20431
  };
20410
20432
  }
20411
- function isRecord(value) {
20412
- return typeof value === "object" && value !== null && !Array.isArray(value);
20413
- }
20414
20433
  function stringField(frame, key) {
20415
20434
  const value = frame[key];
20416
20435
  return typeof value === "string" ? value : null;
@@ -20424,13 +20443,13 @@ async function readWorkflowResult(response) {
20424
20443
  } catch {
20425
20444
  throw new SimApiError(`Workflow run returned malformed JSON${contentType ? ` as ${contentType}` : ""}`, response.status);
20426
20445
  }
20427
- if (!isRecord(envelope)) {
20446
+ if (!isRecordLike(envelope)) {
20428
20447
  throw new SimApiError("Workflow run returned an invalid result envelope", response.status);
20429
20448
  }
20430
- return isRecord(envelope.data) ? envelope.data : envelope;
20449
+ return isRecordLike(envelope.data) ? envelope.data : envelope;
20431
20450
  }
20432
20451
  for await (const value of readNdjson(response.body, "Workflow result stream")) {
20433
- if (!isRecord(value) || typeof value.type !== "string") {
20452
+ if (!isRecordLike(value) || typeof value.type !== "string") {
20434
20453
  throw new SimApiError("Workflow result stream returned an unknown event", response.status);
20435
20454
  }
20436
20455
  if (value.type === "heartbeat")
@@ -20438,7 +20457,7 @@ async function readWorkflowResult(response) {
20438
20457
  if (value.type === "error") {
20439
20458
  throw new SimApiError(safeOneLine(typeof value.error === "string" ? value.error : "Workflow run failed"), typeof value.status === "number" ? value.status : 0, typeof value.code === "string" ? value.code : null);
20440
20459
  }
20441
- if (value.type === "final" && isRecord(value.data))
20460
+ if (value.type === "final" && isRecordLike(value.data))
20442
20461
  return value.data;
20443
20462
  throw new SimApiError("Workflow result stream returned an unknown event", response.status);
20444
20463
  }
@@ -20543,7 +20562,7 @@ async function renderRunStream(body, options) {
20543
20562
  }
20544
20563
  if (frame === DONE_SENTINEL)
20545
20564
  break;
20546
- if (!isRecord(frame))
20565
+ if (!isRecordLike(frame))
20547
20566
  continue;
20548
20567
  if (frame.event === undefined && typeof frame.chunk === "string") {
20549
20568
  commentary.inline(sanitize(frame.chunk));
@@ -20569,7 +20588,7 @@ async function renderRunStream(body, options) {
20569
20588
  commentary.endLine();
20570
20589
  throw new SimApiError(safeOneLine(stringField(frame, "error") ?? "The workflow run failed."), 0);
20571
20590
  case "final":
20572
- if (isRecord(frame.data))
20591
+ if (isRecordLike(frame.data))
20573
20592
  final = frame.data;
20574
20593
  break;
20575
20594
  default:
@@ -20677,18 +20696,15 @@ var MAX_POLL_DELAY_MS = 15000;
20677
20696
  var POLL_BACKOFF_FACTOR = 2;
20678
20697
  var DEFAULT_WAIT_TIMEOUT_SECONDS = 3600;
20679
20698
  var WAIT_TIMEOUT_FLAG = "--wait-timeout <seconds>";
20680
- function isRecord2(value) {
20681
- return typeof value === "object" && value !== null && !Array.isArray(value);
20682
- }
20683
20699
  function optionalString(value) {
20684
20700
  return typeof value === "string" && value !== "" ? value : null;
20685
20701
  }
20686
20702
  function readRun(raw) {
20687
- const run = isRecord2(raw) && isRecord2(raw.data) ? raw.data : raw;
20688
- if (!isRecord2(run) || typeof run.status !== "string") {
20703
+ const run = isRecordLike(raw) && isRecordLike(raw.data) ? raw.data : raw;
20704
+ if (!isRecordLike(run) || typeof run.status !== "string") {
20689
20705
  throw new SimApiError("Run status response carried no status.", 0);
20690
20706
  }
20691
- const paused = isRecord2(run.paused) ? run.paused : null;
20707
+ const paused = isRecordLike(run.paused) ? run.paused : null;
20692
20708
  return {
20693
20709
  status: run.status,
20694
20710
  pauseKind: paused ? optionalString(paused.pauseKind) : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim",
3
- "version": "2.1.22-preview.142.1",
3
+ "version": "2.1.22-preview.145.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "imports": {