@plitzi/sdk-shared 0.35.8 → 0.35.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.35.10
4
+
5
+ ### Patch Changes
6
+
7
+ - **Breaking:** the space setting that lets a published site open the dev tools is now `settings.debugMode`, and
8
+ `settings.devTools` is gone.
9
+
10
+ It was always the same decision the SDK and the page server call `debugMode` — whether the dev-tools panel is
11
+ authorized — and having a third name for it invited confusing it with `devMode`, which is a different thing: it turns a
12
+ deployment into a development server (the unminified bundles, request timings, and the full action trace with every
13
+ step's results). A space can authorize debugging for its own site; it can never make its server a development one.
14
+
15
+ A space that stored `settings.devTools` needs it moved to `settings.debugMode`; nothing reads the old key.
16
+
17
+ ## 0.35.9
18
+
19
+ ### Patch Changes
20
+
21
+ - Debug a server action's whole flow from the dev-tools, not just its answer.
22
+
23
+ A run now reports an OUTLINE of what it did: every step in order, with its task, how it ended, how long it took, and
24
+ the redacted error of the one that broke the flow — the compensation steps `flow.onFailure` ran included. It carries
25
+ nothing a step was given or returned, so it goes to any page whose debugging the deployment authorized (`devMode`, or
26
+ a space that switched dev tools on for its published site) and to no other. The full trace, with each step's results,
27
+ still reaches only an authoring request or a development server.
28
+
29
+ Runs the SERVER started while rendering a page — the ones feeding `runtime: 'server'` elements — reach the dev-tools
30
+ too, seeded into the page and added to by every `/_rsc` refresh, under the same authorization: a page nobody
31
+ authorized is not told they happened. A response carrying them is never cached. A run that died on its deadline now
32
+ reports the step it was on rather than nothing at all.
33
+
34
+ The Actions tab was rebuilt around it: filters and search over the log, a run list that names the step that broke,
35
+ and a detail panel with the flow's timeline, its compensation shown apart, and what the run carried in and out.
36
+
3
37
  ## 0.35.8
4
38
 
5
39
  ### Patch Changes
@@ -1,34 +1,35 @@
1
1
  import { authFailureFromResponse as e, reportAuthFailure as t } from "../../auth/failureChannel.mjs";
2
2
  import { hasServerElements as n } from "../../schema/serverElements.mjs";
3
- import { getPaths as r, matchRoutePath as i } from "../../navigation/routes.mjs";
3
+ import { recordRenderActionRuns as r } from "../../store/actionRuns/actionRunsRecorder.mjs";
4
+ import { getPaths as i, matchRoutePath as a } from "../../navigation/routes.mjs";
4
5
  //#region src/server/rsc/refreshRsc.ts
5
- var a = (e, t, n) => {
6
+ var o = (e, t, n) => {
6
7
  if (!e) return;
7
- let a = e.pages.reduce((t, n) => (n in e.flat && (t[n] = e.flat[n]), t), {});
8
- return i(r(a, e.pageFolders, n), t.split("?")[0], n).pageId;
9
- }, o = (e) => `rsc.data.${e}`, s = () => typeof window > "u" ? "" : `${window.location.pathname}${window.location.search}`, c = async (r, i, c, l) => {
10
- let { enabled: u, endpoint: d } = r.get("rsc") ?? {};
11
- if (!u || !d || typeof window > "u") return;
12
- let f = l ?? s(), p = r.get("schema"), m = r.get("runtime.sources.auth"), h = l ? a(p, l, !!m?.details) : r.get("navigation.currentPageId");
13
- if (p && n(p, h)) try {
14
- let n = new URLSearchParams({ location: f });
15
- i?.length && n.set("ids", i.join(",")), Object.entries(c ?? {}).forEach(([e, t]) => n.set(e, t));
16
- let a = await fetch(`${d}?${n.toString()}`, { headers: { Accept: "application/json" } });
17
- if (!a.ok) {
18
- let n = e(a.status, await a.json().catch(() => void 0));
8
+ let r = e.pages.reduce((t, n) => (n in e.flat && (t[n] = e.flat[n]), t), {});
9
+ return a(i(r, e.pageFolders, n), t.split("?")[0], n).pageId;
10
+ }, s = (e) => `rsc.data.${e}`, c = () => typeof window > "u" ? "" : `${window.location.pathname}${window.location.search}`, l = async (i, a, l, u) => {
11
+ let { enabled: d, endpoint: f } = i.get("rsc") ?? {};
12
+ if (!d || !f || typeof window > "u") return;
13
+ let p = u ?? c(), m = i.get("schema"), h = i.get("runtime.sources.auth"), g = u ? o(m, u, !!h?.details) : i.get("navigation.currentPageId");
14
+ if (m && n(m, g)) try {
15
+ let n = new URLSearchParams({ location: p });
16
+ a?.length && n.set("ids", a.join(",")), Object.entries(l ?? {}).forEach(([e, t]) => n.set(e, t));
17
+ let o = await fetch(`${f}?${n.toString()}`, { headers: { Accept: "application/json" } });
18
+ if (!o.ok) {
19
+ let n = e(o.status, await o.json().catch(() => void 0));
19
20
  n && t({
20
21
  reason: n,
21
- url: d
22
- }), r.set("rsc.stale", !0);
22
+ url: f
23
+ }), i.set("rsc.stale", !0);
23
24
  return;
24
25
  }
25
- let { serverData: s } = await a.json();
26
- r.batch(() => {
27
- i?.length ? Object.entries(s ?? {}).forEach(([e, t]) => r.set(o(e), t)) : r.set("rsc.data", s ?? {}), r.set("rsc.loaded", !0), r.set("rsc.stale", !1), r.set("rsc.location", f);
26
+ let { serverData: c, actionRuns: u } = await o.json();
27
+ u?.length && r(u), i.batch(() => {
28
+ a?.length ? Object.entries(c ?? {}).forEach(([e, t]) => i.set(s(e), t)) : i.set("rsc.data", c ?? {}), i.set("rsc.loaded", !0), i.set("rsc.stale", !1), i.set("rsc.location", p);
28
29
  });
29
30
  } catch {
30
- r.set("rsc.stale", !0);
31
+ i.set("rsc.stale", !0);
31
32
  }
32
33
  };
33
34
  //#endregion
34
- export { s as currentRscLocation, c as default, c as refreshRsc, o as rscDataPath };
35
+ export { c as currentRscLocation, l as default, l as refreshRsc, s as rscDataPath };
@@ -1,4 +1,4 @@
1
- import { ActionRunEntry } from '../../types';
1
+ import { ActionRunEntry, ActionRunSummary } from '../../types';
2
2
  /** Registered by whatever started the run, for as long as stopping it means anything. */
3
3
  export declare const registerActionCanceller: (id: string, cancel: () => void) => void;
4
4
  export declare const releaseActionCanceller: (id: string) => void;
@@ -18,6 +18,15 @@ export declare const cancelActionRun: (id: string) => void;
18
18
  * A record that only appeared on success would be missing exactly the runs somebody is looking for.
19
19
  */
20
20
  export declare const recordActionRun: (entry: Omit<ActionRunEntry, "id" | "startedAt" | "status" | "progress">) => string;
21
+ /**
22
+ * Records the runs the SERVER did while building this page, or while answering a refresh of part of it.
23
+ *
24
+ * Nobody here started them, so without this they are the one kind of run a page cannot see at all — an empty
25
+ * section and no way to learn why. Deduped by the server's own run id, because a section refreshing itself
26
+ * re-reports a run that was joined or reused rather than started again: the same run twice would leave a person
27
+ * comparing two entries that are one.
28
+ */
29
+ export declare const recordRenderActionRuns: (summaries: ActionRunSummary[]) => void;
21
30
  /** How it ended, or what it reported on the way. Unknown ids are ignored: a swept-out run is not an error. */
22
31
  export declare const updateActionRun: (id: string, patch: Partial<Omit<ActionRunEntry, "id">>) => void;
23
32
  /**
@@ -17,23 +17,38 @@ var t = 0, n = (t) => e.setState("runs", t), r = /* @__PURE__ */ new Map(), i =
17
17
  progress: [],
18
18
  cancellable: !0
19
19
  }, ...e.getState().runs].slice(0, 100)), i;
20
- }, c = (t, r) => {
20
+ }, c = (e) => ({
21
+ id: `render-${e.runId}`,
22
+ actionId: e.actionId,
23
+ mode: "render",
24
+ runId: e.runId,
25
+ status: e.status,
26
+ steps: e.steps,
27
+ progress: [],
28
+ startedAt: e.startedAt,
29
+ endedAt: e.endedAt,
30
+ ...e.error === void 0 ? {} : { error: e.error },
31
+ ...e.elementId === void 0 ? {} : { elementId: e.elementId }
32
+ }), l = (t) => {
33
+ let { runs: r } = e.getState(), i = new Set(r.map((e) => e.runId)), a = t.filter((e) => !i.has(e.runId)).map(c);
34
+ a.length !== 0 && n([...a.reverse(), ...r].slice(0, 100));
35
+ }, u = (t, r) => {
21
36
  let { runs: i } = e.getState();
22
37
  i.some((e) => e.id === t) && n(i.map((e) => e.id === t ? {
23
38
  ...e,
24
39
  ...r
25
40
  } : e));
26
- }, l = (t, r) => {
41
+ }, d = (t, r) => {
27
42
  let { runs: i } = e.getState();
28
43
  n(i.map((e) => e.id === t ? {
29
44
  ...e,
30
45
  progress: [...e.progress, r].slice(-500)
31
46
  } : e));
32
- }, u = () => {
47
+ }, f = () => {
33
48
  let t = new Set(e.getState().runs.filter((e) => e.cancellable).map((e) => e.id));
34
49
  [...r.keys()].forEach((e) => {
35
50
  t.has(e) || r.delete(e);
36
51
  }), n([]);
37
52
  };
38
53
  //#endregion
39
- export { o as cancelActionRun, u as clearActionRuns, l as recordActionProgress, s as recordActionRun, i as registerActionCanceller, a as releaseActionCanceller, c as updateActionRun };
54
+ export { o as cancelActionRun, f as clearActionRuns, d as recordActionProgress, s as recordActionRun, l as recordRenderActionRuns, i as registerActionCanceller, a as releaseActionCanceller, u as updateActionRun };
@@ -1,6 +1,6 @@
1
1
  import { default as actionRunsStore } from './actionRunsStore';
2
2
  import { default as useActionRuns } from './useActionRuns';
3
3
  export { MAX_RUNS, createActionRunsState } from './actionRunsStore';
4
- export { cancelActionRun, clearActionRuns, recordActionProgress, recordActionRun, registerActionCanceller, releaseActionCanceller, updateActionRun } from './actionRunsRecorder';
4
+ export { cancelActionRun, clearActionRuns, recordActionProgress, recordActionRun, recordRenderActionRuns, registerActionCanceller, releaseActionCanceller, updateActionRun } from './actionRunsRecorder';
5
5
  export type { UseActionRunsReturn } from './useActionRuns';
6
6
  export { actionRunsStore, useActionRuns };
@@ -1,4 +1,4 @@
1
1
  import e, { MAX_RUNS as t, createActionRunsState as n } from "./actionRunsStore.mjs";
2
- import { cancelActionRun as r, clearActionRuns as i, recordActionProgress as a, recordActionRun as o, registerActionCanceller as s, releaseActionCanceller as c, updateActionRun as l } from "./actionRunsRecorder.mjs";
3
- import u from "./useActionRuns.mjs";
4
- export { t as MAX_RUNS, e as actionRunsStore, r as cancelActionRun, i as clearActionRuns, n as createActionRunsState, a as recordActionProgress, o as recordActionRun, s as registerActionCanceller, c as releaseActionCanceller, l as updateActionRun, u as useActionRuns };
2
+ import { cancelActionRun as r, clearActionRuns as i, recordActionProgress as a, recordActionRun as o, recordRenderActionRuns as s, registerActionCanceller as c, releaseActionCanceller as l, updateActionRun as u } from "./actionRunsRecorder.mjs";
3
+ import d from "./useActionRuns.mjs";
4
+ export { t as MAX_RUNS, e as actionRunsStore, r as cancelActionRun, i as clearActionRuns, n as createActionRunsState, a as recordActionProgress, o as recordActionRun, s as recordRenderActionRuns, c as registerActionCanceller, l as releaseActionCanceller, u as updateActionRun, d as useActionRuns };