sim 2.1.22-preview.143.1 → 2.1.22-preview.146.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 +15 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6970,6 +6970,12 @@ 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
+ }
6976
+ function toRecordOrNull(value) {
6977
+ return isRecordLike(value) ? value : null;
6978
+ }
6973
6979
 
6974
6980
  // src/update/install.ts
6975
6981
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
@@ -20427,9 +20433,6 @@ function resolveWorkflowRunSelection(flags) {
20427
20433
  }
20428
20434
  };
20429
20435
  }
20430
- function isRecord(value) {
20431
- return typeof value === "object" && value !== null && !Array.isArray(value);
20432
- }
20433
20436
  function stringField(frame, key) {
20434
20437
  const value = frame[key];
20435
20438
  return typeof value === "string" ? value : null;
@@ -20443,13 +20446,13 @@ async function readWorkflowResult(response) {
20443
20446
  } catch {
20444
20447
  throw new SimApiError(`Workflow run returned malformed JSON${contentType ? ` as ${contentType}` : ""}`, response.status);
20445
20448
  }
20446
- if (!isRecord(envelope)) {
20449
+ if (!isRecordLike(envelope)) {
20447
20450
  throw new SimApiError("Workflow run returned an invalid result envelope", response.status);
20448
20451
  }
20449
- return isRecord(envelope.data) ? envelope.data : envelope;
20452
+ return isRecordLike(envelope.data) ? envelope.data : envelope;
20450
20453
  }
20451
20454
  for await (const value of readNdjson(response.body, "Workflow result stream")) {
20452
- if (!isRecord(value) || typeof value.type !== "string") {
20455
+ if (!isRecordLike(value) || typeof value.type !== "string") {
20453
20456
  throw new SimApiError("Workflow result stream returned an unknown event", response.status);
20454
20457
  }
20455
20458
  if (value.type === "heartbeat")
@@ -20457,7 +20460,7 @@ async function readWorkflowResult(response) {
20457
20460
  if (value.type === "error") {
20458
20461
  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);
20459
20462
  }
20460
- if (value.type === "final" && isRecord(value.data))
20463
+ if (value.type === "final" && isRecordLike(value.data))
20461
20464
  return value.data;
20462
20465
  throw new SimApiError("Workflow result stream returned an unknown event", response.status);
20463
20466
  }
@@ -20562,7 +20565,7 @@ async function renderRunStream(body, options) {
20562
20565
  }
20563
20566
  if (frame === DONE_SENTINEL)
20564
20567
  break;
20565
- if (!isRecord(frame))
20568
+ if (!isRecordLike(frame))
20566
20569
  continue;
20567
20570
  if (frame.event === undefined && typeof frame.chunk === "string") {
20568
20571
  commentary.inline(sanitize(frame.chunk));
@@ -20588,7 +20591,7 @@ async function renderRunStream(body, options) {
20588
20591
  commentary.endLine();
20589
20592
  throw new SimApiError(safeOneLine(stringField(frame, "error") ?? "The workflow run failed."), 0);
20590
20593
  case "final":
20591
- if (isRecord(frame.data))
20594
+ if (isRecordLike(frame.data))
20592
20595
  final = frame.data;
20593
20596
  break;
20594
20597
  default:
@@ -20696,18 +20699,15 @@ var MAX_POLL_DELAY_MS = 15000;
20696
20699
  var POLL_BACKOFF_FACTOR = 2;
20697
20700
  var DEFAULT_WAIT_TIMEOUT_SECONDS = 3600;
20698
20701
  var WAIT_TIMEOUT_FLAG = "--wait-timeout <seconds>";
20699
- function isRecord2(value) {
20700
- return typeof value === "object" && value !== null && !Array.isArray(value);
20701
- }
20702
20702
  function optionalString(value) {
20703
20703
  return typeof value === "string" && value !== "" ? value : null;
20704
20704
  }
20705
20705
  function readRun(raw) {
20706
- const run = isRecord2(raw) && isRecord2(raw.data) ? raw.data : raw;
20707
- if (!isRecord2(run) || typeof run.status !== "string") {
20706
+ const run = isRecordLike(raw) && isRecordLike(raw.data) ? raw.data : raw;
20707
+ if (!isRecordLike(run) || typeof run.status !== "string") {
20708
20708
  throw new SimApiError("Run status response carried no status.", 0);
20709
20709
  }
20710
- const paused = isRecord2(run.paused) ? run.paused : null;
20710
+ const paused = toRecordOrNull(run.paused);
20711
20711
  return {
20712
20712
  status: run.status,
20713
20713
  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.143.1",
3
+ "version": "2.1.22-preview.146.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "imports": {