@lace-cloud/canvas 0.31.0 → 0.31.2

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.
@@ -28,9 +28,11 @@ __export(engine_exports, {
28
28
  CommandExitError: () => CommandExitError,
29
29
  CommandUnobservedError: () => CommandUnobservedError,
30
30
  ConnectError: () => ConnectError,
31
+ DID_NOT_LOCK: () => DID_NOT_LOCK,
31
32
  EMPTY_REPORT_FOLD: () => EMPTY_REPORT_FOLD,
32
33
  GENERATE_STAGES: () => GENERATE_STAGES,
33
34
  InputMode: () => InputMode,
35
+ LOCK_LABEL: () => LOCK_LABEL,
34
36
  Reason: () => Reason,
35
37
  SCHEMAS: () => SCHEMAS,
36
38
  answering: () => answering,
@@ -51,6 +53,10 @@ __export(engine_exports, {
51
53
  generatedTree: () => generatedTree,
52
54
  isBoundPath: () => isBoundPath,
53
55
  liveSlots: () => liveSlots,
56
+ lockFailed: () => lockFailed,
57
+ lockNotice: () => lockNotice,
58
+ lockedIn: () => lockedIn,
59
+ lockfileOf: () => lockfileOf,
54
60
  openEngineCommands: () => openEngineCommands,
55
61
  openEngineSession: () => openEngineSession,
56
62
  parseBound: () => parseBound,
@@ -13641,6 +13647,36 @@ function withStage(stages, name) {
13641
13647
  function closeStages(stages) {
13642
13648
  return stages.map((s) => s.status === "done" ? s : { ...s, status: "done" });
13643
13649
  }
13650
+ var RECORDED_ENDS = /* @__PURE__ */ new Map([
13651
+ ["apply_succeeded", "succeeded"],
13652
+ ["apply_failed", "failed"],
13653
+ ["policy_blocked", "blocked"],
13654
+ ["cancelled", "cancelled"]
13655
+ ]);
13656
+ function runKind(run, ending) {
13657
+ const recorded = run ? RECORDED_ENDS.get(run.status) : void 0;
13658
+ if (recorded) return recorded;
13659
+ if ("result" in ending) return ending.result.error ? "running" : "succeeded";
13660
+ const { error } = ending;
13661
+ if (error instanceof CommandDetachedError || error instanceof CommandUnobservedError)
13662
+ return "detached";
13663
+ if (error instanceof CommandExitError) {
13664
+ if (error.code === 130) return run ? "detached" : "cancelled";
13665
+ if (error.code === 143) return "detached";
13666
+ if (error.code === 7) return "blocked";
13667
+ }
13668
+ return "failed";
13669
+ }
13670
+ function endSays(ending) {
13671
+ if ("error" in ending) return failureSays(ending.error);
13672
+ const { run, error } = ending.result;
13673
+ return { message: run.errorMessage ?? error ?? run.status };
13674
+ }
13675
+ function outcomeOf(end, ending, submitted) {
13676
+ if (end === "blocked" || end === "failed") return { kind: end, ...endSays(ending) };
13677
+ if (end === "detached") return { kind: end, submitted };
13678
+ return { kind: end };
13679
+ }
13644
13680
  function reduceRun(prev, token, event) {
13645
13681
  const carried = prev && prev.token === token ? prev : null;
13646
13682
  const run = event.type === "result" ? event.run : carried?.run ?? null;
@@ -13668,10 +13704,12 @@ function reduceRun(prev, token, event) {
13668
13704
  stages
13669
13705
  };
13670
13706
  }
13671
- if (!event.error)
13707
+ const ending = { result: event };
13708
+ const kind = runKind(run, ending);
13709
+ if (kind !== "running")
13672
13710
  return {
13673
13711
  token,
13674
- outcome: { kind: "succeeded" },
13712
+ outcome: outcomeOf(kind, ending, submitted),
13675
13713
  run,
13676
13714
  lastLog,
13677
13715
  submitted,
@@ -13703,31 +13741,9 @@ function settleRun(prev, token, error) {
13703
13741
  const lastLog = carried?.lastLog ?? null;
13704
13742
  const submitted = carried?.submitted ?? false;
13705
13743
  const stages = closeStages(carried?.stages ?? []);
13706
- if (error instanceof CommandDetachedError || error instanceof CommandUnobservedError)
13707
- return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13708
- if (error instanceof CommandExitError) {
13709
- if (error.code === 130)
13710
- return { token, outcome: { kind: "cancelled" }, run, lastLog, submitted, stages };
13711
- if (error.code === 143)
13712
- return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13713
- if (error.code === 7)
13714
- return {
13715
- token,
13716
- outcome: { kind: "blocked", ...failureSays(error) },
13717
- run,
13718
- lastLog,
13719
- submitted,
13720
- stages
13721
- };
13722
- }
13723
- return {
13724
- token,
13725
- outcome: { kind: "failed", ...failureSays(error) },
13726
- run,
13727
- lastLog,
13728
- submitted,
13729
- stages
13730
- };
13744
+ const ending = { error };
13745
+ const outcome = outcomeOf(runKind(run, ending), ending, submitted);
13746
+ return { token, outcome, run, lastLog, submitted, stages };
13731
13747
  }
13732
13748
  function reducePreview(_prev, token, event) {
13733
13749
  return { token, outcome: { kind: "succeeded", data: event } };
@@ -13928,6 +13944,10 @@ function lockfileOf(lock2) {
13928
13944
  function lockedIn(lock2) {
13929
13945
  return `${counted(lock2.providers.length, "provider")} in ${lockfileOf(lock2)}`;
13930
13946
  }
13947
+ function lockNotice(lock2) {
13948
+ return `Locked ${lockedIn(lock2)}. Commit it beside the tree.`;
13949
+ }
13950
+ var LOCK_LABEL = "Lock providers";
13931
13951
  function listed(parts) {
13932
13952
  return parts.length < 2 ? parts.join("") : `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}`;
13933
13953
  }
@@ -14092,10 +14112,7 @@ var lock = defineCommand({
14092
14112
  args: () => ({}),
14093
14113
  result: {
14094
14114
  kind: "notify",
14095
- consume: (rt, e) => rt.ports.presenter.notify(
14096
- "info",
14097
- `Locked ${lockedIn(e)}. Commit it beside the tree, then run the command again.`
14098
- )
14115
+ consume: (rt, e) => rt.ports.presenter.notify("info", `${lockNotice(e)} Then run the refused command again.`)
14099
14116
  }
14100
14117
  });
14101
14118
  var preview = defineCommand({
@@ -14220,7 +14237,7 @@ var STACK_COMMAND_ACTIONS = [
14220
14237
  // writes it.
14221
14238
  {
14222
14239
  id: "lock-missing",
14223
- label: "Lock providers",
14240
+ label: LOCK_LABEL,
14224
14241
  placement: { row: "failure" },
14225
14242
  requiredPorts: ["commands"],
14226
14243
  requiredContext: ["root"],
@@ -14824,9 +14841,11 @@ function autosave(source, save, policy, report) {
14824
14841
  CommandExitError,
14825
14842
  CommandUnobservedError,
14826
14843
  ConnectError,
14844
+ DID_NOT_LOCK,
14827
14845
  EMPTY_REPORT_FOLD,
14828
14846
  GENERATE_STAGES,
14829
14847
  InputMode,
14848
+ LOCK_LABEL,
14830
14849
  Reason,
14831
14850
  SCHEMAS,
14832
14851
  answering,
@@ -14847,6 +14866,10 @@ function autosave(source, save, policy, report) {
14847
14866
  generatedTree,
14848
14867
  isBoundPath,
14849
14868
  liveSlots,
14869
+ lockFailed,
14870
+ lockNotice,
14871
+ lockedIn,
14872
+ lockfileOf,
14850
14873
  openEngineCommands,
14851
14874
  openEngineSession,
14852
14875
  parseBound,