@w6w/embed 0.2.11 → 0.2.19

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 (132) hide show
  1. package/README.md +22 -5
  2. package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
  3. package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
  4. package/dist/{CreateFunctionModal-D6CQLpa_.js → CreateFunctionModal-DScxp_LN.js} +2 -2
  5. package/dist/{CreateFunctionModal-D6CQLpa_.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
  6. package/dist/{DocumentFormModal-YauVdolr.js → DocumentFormModal-Br4s8wmi.js} +3 -3
  7. package/dist/{DocumentFormModal-YauVdolr.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
  8. package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
  9. package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
  10. package/dist/{ModelRoutesManager-BGESQahw.js → ModelRoutesManager-1Ac5wcas.js} +3 -3
  11. package/dist/{ModelRoutesManager-BGESQahw.js.map → ModelRoutesManager-1Ac5wcas.js.map} +1 -1
  12. package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
  13. package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
  14. package/dist/apps-ItBvnWX3.js +92 -0
  15. package/dist/apps-ItBvnWX3.js.map +1 -0
  16. package/dist/chrome/DangerZone.d.ts +4 -3
  17. package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
  18. package/dist/chrome/JsonToggle.d.ts +29 -20
  19. package/dist/chrome/Modal.d.ts +3 -1
  20. package/dist/chrome/RightRail.d.ts +6 -1
  21. package/dist/chrome/VersionHistoryModal.d.ts +2 -0
  22. package/dist/chrome/index.d.ts +1 -0
  23. package/dist/chrome/workspace.d.ts +32 -1
  24. package/dist/{coerce-input-DttlcSdO.js → coerce-input-DFJ4n_wc.js} +68 -69
  25. package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
  26. package/dist/{connections-D7cgXhDS.js → connections-CzsCyIxY.js} +10 -10
  27. package/dist/{connections-D7cgXhDS.js.map → connections-CzsCyIxY.js.map} +1 -1
  28. package/dist/{credentials-DaQU3Ca_.js → credentials-Cn92LGhJ.js} +4 -4
  29. package/dist/{credentials-DaQU3Ca_.js.map → credentials-Cn92LGhJ.js.map} +1 -1
  30. package/dist/data-stores-UeQvwVCa.js +170 -0
  31. package/dist/data-stores-UeQvwVCa.js.map +1 -0
  32. package/dist/document-sources-DNmBojx6.js +169 -0
  33. package/dist/document-sources-DNmBojx6.js.map +1 -0
  34. package/dist/draft/use-workflow-draft.d.ts +2 -0
  35. package/dist/draft.mjs +2 -2
  36. package/dist/editor/PublishTooltip.d.ts +7 -0
  37. package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
  38. package/dist/editor/StartingStateModal.d.ts +14 -0
  39. package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
  40. package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
  41. package/dist/editor/definition.d.ts +4 -0
  42. package/dist/editor/json-apply.d.ts +29 -0
  43. package/dist/editor/step-problems-feed.d.ts +5 -0
  44. package/dist/editor/types.d.ts +2 -2
  45. package/dist/editor-apps-DkkC7wOQ.js +152 -0
  46. package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
  47. package/dist/editor-tools-BR27RGto.js +1683 -0
  48. package/dist/editor-tools-BR27RGto.js.map +1 -0
  49. package/dist/editor.mjs +1 -1
  50. package/dist/editors.mjs +536 -478
  51. package/dist/editors.mjs.map +1 -1
  52. package/dist/forms.mjs +3 -3
  53. package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
  54. package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
  55. package/dist/index.mjs +138 -108
  56. package/dist/index.mjs.map +1 -1
  57. package/dist/lib/binding-problems.d.ts +5 -1
  58. package/dist/lib/history-query.d.ts +45 -0
  59. package/dist/lib/import-bindings.d.ts +89 -0
  60. package/dist/lib/index.d.ts +3 -0
  61. package/dist/lib/rail-settings.d.ts +1 -1
  62. package/dist/lib/setup-incomplete.d.ts +22 -0
  63. package/dist/lib/starting-data.d.ts +31 -0
  64. package/dist/lib/state-panel.d.ts +29 -0
  65. package/dist/lib/target-fields.d.ts +3 -15
  66. package/dist/lib/workflow-live-run.d.ts +84 -6
  67. package/dist/lib/workflow-validity.d.ts +64 -16
  68. package/dist/lib/workflow-variables.d.ts +1 -1
  69. package/dist/lib/workflow-version.d.ts +2 -0
  70. package/dist/lib.mjs +87 -72
  71. package/dist/lists/DataStoreList.d.ts +17 -0
  72. package/dist/lists/DataStoreView.d.ts +19 -0
  73. package/dist/lists/Logs.d.ts +19 -0
  74. package/dist/lists.d.ts +6 -0
  75. package/dist/lists.mjs +1255 -816
  76. package/dist/lists.mjs.map +1 -1
  77. package/dist/rail/ConnectionsTool.d.ts +2 -0
  78. package/dist/rail/HistoryTool.d.ts +2 -0
  79. package/dist/rail/StartingStateTool.d.ts +2 -0
  80. package/dist/rail/settings-sections.d.ts +4 -1
  81. package/dist/rail.mjs +1 -1
  82. package/dist/repos/constants.d.ts +12 -0
  83. package/dist/repos/data-stores.d.ts +84 -0
  84. package/dist/repos/history.d.ts +9 -0
  85. package/dist/repos/index.d.ts +2 -0
  86. package/dist/repos/spec-export.d.ts +3 -3
  87. package/dist/repos/spec-import.d.ts +30 -1
  88. package/dist/repos/step-tests.d.ts +2 -0
  89. package/dist/repos/webhook-listen.d.ts +35 -0
  90. package/dist/repos/workflows.d.ts +105 -2
  91. package/dist/repos.mjs +370 -328
  92. package/dist/repos.mjs.map +1 -1
  93. package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
  94. package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
  95. package/dist/{spec-export-CBbloO_n.js → spec-export-DGy5ijps.js} +72 -59
  96. package/dist/spec-export-DGy5ijps.js.map +1 -0
  97. package/dist/spec-import-SWOonsNr.js +116 -0
  98. package/dist/spec-import-SWOonsNr.js.map +1 -0
  99. package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
  100. package/dist/step-tests-B4E4W3ly.js.map +1 -0
  101. package/dist/{use-callable-draft-DsALnSfF.js → use-callable-draft-DCauHt5o.js} +2 -2
  102. package/dist/{use-callable-draft-DsALnSfF.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
  103. package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
  104. package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
  105. package/dist/workflows-BZN4Hyz1.js +623 -0
  106. package/dist/workflows-BZN4Hyz1.js.map +1 -0
  107. package/package.json +3 -2
  108. package/src/styles.css +153 -1
  109. package/dist/ConfirmModal-BE-SdX-O.js +0 -185
  110. package/dist/ConfirmModal-BE-SdX-O.js.map +0 -1
  111. package/dist/ImportSpecModal-B7qd1Km2.js +0 -136
  112. package/dist/ImportSpecModal-B7qd1Km2.js.map +0 -1
  113. package/dist/WorkflowEditor-CwvmAGp2.js +0 -925
  114. package/dist/WorkflowEditor-CwvmAGp2.js.map +0 -1
  115. package/dist/apps-CboASBKr.js +0 -77
  116. package/dist/apps-CboASBKr.js.map +0 -1
  117. package/dist/coerce-input-DttlcSdO.js.map +0 -1
  118. package/dist/document-sources-UCwe8x77.js +0 -91
  119. package/dist/document-sources-UCwe8x77.js.map +0 -1
  120. package/dist/editor-apps-BUZWld-m.js +0 -95
  121. package/dist/editor-apps-BUZWld-m.js.map +0 -1
  122. package/dist/editor-tools-B_Lfx3kw.js +0 -1279
  123. package/dist/editor-tools-B_Lfx3kw.js.map +0 -1
  124. package/dist/rail-settings-XYGToh00.js.map +0 -1
  125. package/dist/spec-export-CBbloO_n.js.map +0 -1
  126. package/dist/spec-import-CW6R_Wk1.js +0 -469
  127. package/dist/spec-import-CW6R_Wk1.js.map +0 -1
  128. package/dist/step-tests-CivICmTq.js.map +0 -1
  129. package/dist/trigger-preview-DKxfjzUY.js +0 -145
  130. package/dist/trigger-preview-DKxfjzUY.js.map +0 -1
  131. package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
  132. package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
@@ -0,0 +1,152 @@
1
+ import { jsxs as C, jsx as f, Fragment as X } from "react/jsx-runtime";
2
+ import { u as ee, a as te, b as ne, c as re, d as oe } from "./apps-ItBvnWX3.js";
3
+ import { H as _ } from "./workflows-BZN4Hyz1.js";
4
+ import { ExecutionDetail as se, ExecutionStats as ie, ExecutionFilters as le, ExecutionList as ce, useW6WApi as ue } from "@w6w/ui";
5
+ import { useRef as E, useState as R, useEffect as B, useLayoutEffect as ae, useCallback as L, useMemo as fe } from "react";
6
+ import { useQuery as de } from "@tanstack/react-query";
7
+ const pe = 300;
8
+ function Y(o) {
9
+ for (let r = (o == null ? void 0 : o.parentElement) ?? null; r; r = r.parentElement) {
10
+ const l = getComputedStyle(r).overflowY;
11
+ if ((l === "auto" || l === "scroll") && r.scrollHeight > r.clientHeight)
12
+ return r;
13
+ }
14
+ return null;
15
+ }
16
+ function Se(o) {
17
+ var A, F, N;
18
+ const { scope: r, showKind: l, filters: n, onFiltersChange: m, onOpenInEditor: d } = o, S = E(n);
19
+ S.current = n;
20
+ const [u, a] = R(n.q), p = E(null), [s, b] = R(null);
21
+ B(() => {
22
+ a(n.q);
23
+ }, [n.q]), B(
24
+ () => () => {
25
+ p.current && clearTimeout(p.current);
26
+ },
27
+ []
28
+ );
29
+ const h = ee(r, n), j = te(r, n), I = ne(s), c = re(), D = oe(), [T, y] = R(null), g = E(null), w = E(null), H = (s == null ? void 0 : s.id) ?? null;
30
+ ae(() => {
31
+ var t;
32
+ const e = g.current;
33
+ if (e) {
34
+ if (H !== null) {
35
+ const i = Y(e);
36
+ i ? i.scrollTop = 0 : e.getBoundingClientRect().top < 0 && ((t = e.scrollIntoView) == null || t.call(e, { block: "start" }));
37
+ } else if (w.current) {
38
+ const { parent: i, top: O } = w.current;
39
+ w.current = null, i ? i.scrollTop = O : window.scrollTo(0, O);
40
+ }
41
+ }
42
+ }, [H]);
43
+ const M = E(s);
44
+ M.current = s;
45
+ const x = L((e) => {
46
+ if (M.current === null) {
47
+ const t = Y(g.current);
48
+ w.current = { parent: t, top: t ? t.scrollTop : window.scrollY };
49
+ }
50
+ b(e);
51
+ }, []), v = ((A = h.data) == null ? void 0 : A.executions) ?? [], q = n.offset, V = ((F = h.data) == null ? void 0 : F.hasMore) ?? !1, K = (e) => {
52
+ m({ ...e, offset: 0 });
53
+ }, W = (e) => {
54
+ if (e.q === u) {
55
+ K(e);
56
+ return;
57
+ }
58
+ a(e.q), p.current && clearTimeout(p.current), p.current = setTimeout(() => {
59
+ p.current = null, m({ ...S.current, q: e.q, offset: 0 });
60
+ }, pe);
61
+ }, $ = () => m({ ...n, q: u, offset: Math.max(0, q - _) }), G = () => m({ ...n, q: u, offset: q + _ }), U = L(
62
+ (e) => {
63
+ const t = v.find((i) => i.id === e);
64
+ t && x(t);
65
+ },
66
+ [v, x]
67
+ ), k = (e) => {
68
+ c.mutate(e, {
69
+ onSuccess: (t) => {
70
+ t ? x(t) : b(null);
71
+ }
72
+ });
73
+ }, P = c.isPending ? ((N = c.variables) == null ? void 0 : N.id) ?? null : null, Z = (e, t) => {
74
+ y(null), D(e, t).then((i) => {
75
+ i ? x(i) : y(`${t} is no longer available.`);
76
+ }).catch(() => y(`Couldn't open ${t}.`));
77
+ }, Q = c.isError ? /* @__PURE__ */ C("p", { className: "error", "data-testid": "history-rerun-error", children: [
78
+ "Couldn't re-run: ",
79
+ c.error instanceof Error ? c.error.message : String(c.error)
80
+ ] }) : null, z = {
81
+ status: n.status,
82
+ kind: n.kind,
83
+ from: n.from,
84
+ to: n.to,
85
+ q: u
86
+ }, J = (s == null ? void 0 : s.kind) === "workflow" && d ? () => d(s) : void 0;
87
+ return s ? /* @__PURE__ */ C("div", { ref: g, children: [
88
+ Q,
89
+ T && /* @__PURE__ */ f("p", { className: "error", "data-testid": "history-find-error", children: T }),
90
+ /* @__PURE__ */ f(
91
+ se,
92
+ {
93
+ execution: I.data ?? null,
94
+ loading: I.isLoading,
95
+ errorMessage: I.isError ? "This execution is no longer available." : void 0,
96
+ onBack: () => {
97
+ c.reset(), y(null), b(null);
98
+ },
99
+ onOpenExecution: (e) => Z(s.callableId, e),
100
+ onRerun: () => k(s),
101
+ rerunning: P !== null,
102
+ onOpenInEditor: J
103
+ }
104
+ )
105
+ ] }) : /* @__PURE__ */ C(X, { children: [
106
+ /* @__PURE__ */ f(ie, { stats: j.data ?? null }),
107
+ /* @__PURE__ */ f(le, { showKind: l, value: z, onChange: W }),
108
+ h.isError && /* @__PURE__ */ f("p", { className: "error", "data-testid": "history-error", children: "Couldn't load execution history." }),
109
+ Q,
110
+ /* @__PURE__ */ f("div", { ref: g, children: /* @__PURE__ */ f(
111
+ ce,
112
+ {
113
+ items: v,
114
+ showCallable: l,
115
+ loading: h.isLoading,
116
+ hasPrev: q > 0,
117
+ hasNext: V,
118
+ onPrev: $,
119
+ onNext: G,
120
+ onSelect: U,
121
+ onRerun: (e) => {
122
+ const t = v.find((i) => i.id === e);
123
+ t && k(t);
124
+ },
125
+ rerunningId: P
126
+ }
127
+ ) })
128
+ ] });
129
+ }
130
+ const me = /* @__PURE__ */ new Map();
131
+ function Ee(o) {
132
+ var u;
133
+ const r = ue(), l = (u = r.listAppsByIds) == null ? void 0 : u.bind(r), n = [...o].sort().join(","), d = de({
134
+ queryKey: ["editor-apps", n],
135
+ queryFn: ({ signal: a }) => l ? l(o, { signal: a }) : Promise.resolve([]),
136
+ enabled: o.length > 0 && typeof l == "function"
137
+ }).data;
138
+ return { byId: fe(
139
+ () => d ? new Map(d.map((a) => [a.id, a])) : me,
140
+ [d]
141
+ ) };
142
+ }
143
+ function be(o) {
144
+ const { byId: r } = Ee(o ? [o] : []);
145
+ return o ? r.get(o) : void 0;
146
+ }
147
+ export {
148
+ Se as H,
149
+ Ee as a,
150
+ be as u
151
+ };
152
+ //# sourceMappingURL=editor-apps-DkkC7wOQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-apps-DkkC7wOQ.js","sources":["../src/chrome/HistoryView.tsx","../src/editor/editor-apps.ts"],"sourcesContent":["/**\n * `HistoryView` — the execution-history view body (T3.2.1, extracted from\n * `HistoryPage.tsx`'s T2.4.1 shape): stats + filters + paged list, OR the\n * selected execution's detail — never both. Opening a row swaps the list for\n * that execution (with a Back control to return to the list where it was\n * left); it does not stack the detail under a long list, where it lands\n * off-screen. Two hosts mount it — `HistoryPage` (the\n * project-wide and per-callable routes, filters URL-backed) and\n * `HistoryModal` (R-2's in-place modal, filters kept in local state) — so\n * this component owns every judgment call about HOW the view behaves, and\n * takes no position on WHERE its filters live: the host hands down\n * `filters` and gets every change back through `onFiltersChange`, exactly\n * the controlled-value shape `filtersToSearch`/`filtersFromSearch` already\n * assume on the URL-backed side.\n *\n * What stays here, same as it was in `HistoryPage` before the extraction:\n * - the search box's text, debounced, so a keystroke does not re-key and\n * re-issue both queries on every character (`onFiltersChange` — and so\n * the host's own write, URL or local state — fires only once typing\n * settles);\n * - which list row is selected, which is not shareable state and resets on\n * every mount;\n * - re-running an execution (a control on every row and in the detail): the\n * same input, against the callable's current definition. The view then\n * opens the NEW execution, so the outcome is what the author sees next;\n * - every filter change but paging snapping the page back to the first\n * (`offset` 0), because a narrowed result set has no meaningful \"page 3\".\n *\n * `onOpenInEditor`, when given, is called with the selected execution ONLY\n * while it is a workflow run (a function/endpoint invocation has no visual\n * editor to open) — the same gate `HistoryPage.tsx` applied inline before\n * this extraction. A host that never passes it (none of today's two do)\n * simply never sees the call.\n */\nimport {\n type ExecutionSummary,\n HISTORY_PAGE_SIZE,\n type HistoryFilters,\n type HistoryScope,\n useExecutionDetailQuery,\n useFindExecution,\n useHistoryQuery,\n useHistoryStatsQuery,\n useRerunExecutionMutation,\n} from \"@w6w/embed/repos\";\nimport {\n ExecutionDetail,\n type ExecutionFilterValue,\n ExecutionFilters,\n ExecutionList,\n ExecutionStats,\n} from \"@w6w/ui\";\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from \"react\";\n\n/** How long to wait after the last keystroke before `onFiltersChange` fires\n * with the new `q` (and so before either query re-issues with it). */\nconst SEARCH_DEBOUNCE_MS = 300;\n\n/** The nearest ancestor that actually scrolls (the modal body, the app's main\n * pane), or `null` when the document itself does. */\nfunction scrollParent(el: HTMLElement | null): HTMLElement | null {\n for (let p = el?.parentElement ?? null; p; p = p.parentElement) {\n const overflowY = getComputedStyle(p).overflowY;\n if ((overflowY === \"auto\" || overflowY === \"scroll\") && p.scrollHeight > p.clientHeight) {\n return p;\n }\n }\n return null;\n}\n\nexport interface HistoryViewProps {\n /** `null` ⇒ no scope known yet (the project-wide host, before its project\n * resolves) — both queries stay disabled, mirroring `repos/history.ts`'s\n * own `enabled: scope !== null`. */\n scope: HistoryScope | null;\n /** Project-wide chrome: the Kind filter, and the Callable column on every\n * row. A per-callable host (every callable already knows its own kind)\n * passes `false`. */\n showKind: boolean;\n filters: HistoryFilters;\n onFiltersChange: (next: HistoryFilters) => void;\n onOpenInEditor?: (execution: ExecutionSummary) => void;\n}\n\nexport function HistoryView(props: HistoryViewProps) {\n const { scope, showKind, filters, onFiltersChange, onOpenInEditor } = props;\n\n // The debounce below fires outside any render, so it needs the LATEST\n // filters (a status picked while a `q` write was still pending must\n // survive it) rather than the ones captured when typing started.\n const filtersRef = useRef(filters);\n filtersRef.current = filters;\n\n const [q, setQ] = useState(filters.q);\n const searchTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const [selected, setSelected] = useState<ExecutionSummary | null>(null);\n\n // Keep the search box in step with `filters.q` when IT moves from outside\n // (Back/Forward or a shared link on the URL-backed host). This never\n // fights a keystroke: an outside `q` only changes once typing has\n // settled, by which point `q` already equals it.\n useEffect(() => {\n setQ(filters.q);\n }, [filters.q]);\n\n // Drop a pending debounce on unmount.\n useEffect(\n () => () => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n },\n [],\n );\n\n const listQuery = useHistoryQuery(scope, filters);\n const statsQuery = useHistoryStatsQuery(scope, filters);\n const detailQuery = useExecutionDetailQuery(selected);\n const rerun = useRerunExecutionMutation();\n const findExecution = useFindExecution();\n const [findError, setFindError] = useState<string | null>(null);\n\n // Swapping list ⇄ detail keeps the scroll offset of whatever scrolls around\n // this view, which would open a detail scrolled past its own top (the row\n // was clicked far down the list). So: remember the list's offset on the\n // way in, show the detail from its top, and put the list back on the way out.\n const viewRef = useRef<HTMLDivElement>(null);\n const listScroll = useRef<{ parent: HTMLElement | null; top: number } | null>(null);\n const selectedId = selected?.id ?? null;\n useLayoutEffect(() => {\n const el = viewRef.current;\n if (!el) return;\n if (selectedId !== null) {\n const parent = scrollParent(el);\n if (parent) parent.scrollTop = 0;\n else if (el.getBoundingClientRect().top < 0) el.scrollIntoView?.({ block: \"start\" });\n } else if (listScroll.current) {\n const { parent, top } = listScroll.current;\n listScroll.current = null;\n if (parent) parent.scrollTop = top;\n else window.scrollTo(0, top);\n }\n }, [selectedId]);\n\n const selectedRef = useRef(selected);\n selectedRef.current = selected;\n const open = useCallback((next: ExecutionSummary) => {\n // Leaving the LIST (not one detail for another, as a re-run from the detail does).\n if (selectedRef.current === null) {\n const parent = scrollParent(viewRef.current);\n listScroll.current = { parent, top: parent ? parent.scrollTop : window.scrollY };\n }\n setSelected(next);\n }, []);\n\n const executions = listQuery.data?.executions ?? [];\n const offset = filters.offset;\n const hasMore = listQuery.data?.hasMore ?? false;\n\n /** Every filter change but paging reports a fresh filter set and resets\n * the page to the first. */\n const applyFilters = (next: ExecutionFilterValue) => {\n onFiltersChange({ ...next, offset: 0 });\n };\n\n const onChange = (next: ExecutionFilterValue) => {\n if (next.q === q) {\n applyFilters(next);\n return;\n }\n setQ(next.q);\n if (searchTimer.current) clearTimeout(searchTimer.current);\n searchTimer.current = setTimeout(() => {\n searchTimer.current = null;\n onFiltersChange({ ...filtersRef.current, q: next.q, offset: 0 });\n }, SEARCH_DEBOUNCE_MS);\n };\n\n const onPrev = () =>\n onFiltersChange({ ...filters, q, offset: Math.max(0, offset - HISTORY_PAGE_SIZE) });\n const onNext = () => onFiltersChange({ ...filters, q, offset: offset + HISTORY_PAGE_SIZE });\n\n const onSelect = useCallback(\n (executionId: string) => {\n const row = executions.find((r) => r.id === executionId);\n if (row) open(row);\n },\n [executions, open],\n );\n\n /** Re-run one execution, then open the new one — or, when it is not listed\n * yet, fall back to the (refreshed) list. */\n const startRerun = (summary: ExecutionSummary) => {\n rerun.mutate(summary, {\n onSuccess: (next) => {\n if (next) open(next);\n else setSelected(null);\n },\n });\n };\n const rerunningId = rerun.isPending ? (rerun.variables?.id ?? null) : null;\n\n /** \"Re-run of <id>\": open the original, from the callable this one belongs to. */\n const openOriginal = (callableId: string, id: string) => {\n setFindError(null);\n findExecution(callableId, id)\n .then((row) => {\n if (row) open(row);\n else setFindError(`${id} is no longer available.`);\n })\n .catch(() => setFindError(`Couldn't open ${id}.`));\n };\n const rerunError = rerun.isError ? (\n <p className=\"error\" data-testid=\"history-rerun-error\">\n Couldn't re-run: {rerun.error instanceof Error ? rerun.error.message : String(rerun.error)}\n </p>\n ) : null;\n\n const filterValue: ExecutionFilterValue = {\n status: filters.status,\n kind: filters.kind,\n from: filters.from,\n to: filters.to,\n q,\n };\n\n // A workflow run is the only execution with a visual editor to jump into\n // — a function/endpoint invocation has no such surface.\n const openInEditor =\n selected?.kind === \"workflow\" && onOpenInEditor ? () => onOpenInEditor(selected) : undefined;\n\n if (selected) {\n return (\n <div ref={viewRef}>\n {rerunError}\n {findError && (\n <p className=\"error\" data-testid=\"history-find-error\">\n {findError}\n </p>\n )}\n <ExecutionDetail\n execution={detailQuery.data ?? null}\n loading={detailQuery.isLoading}\n errorMessage={detailQuery.isError ? \"This execution is no longer available.\" : undefined}\n onBack={() => {\n rerun.reset();\n setFindError(null);\n setSelected(null);\n }}\n onOpenExecution={(id) => openOriginal(selected.callableId, id)}\n onRerun={() => startRerun(selected)}\n rerunning={rerunningId !== null}\n onOpenInEditor={openInEditor}\n />\n </div>\n );\n }\n\n return (\n <>\n <ExecutionStats stats={statsQuery.data ?? null} />\n\n <ExecutionFilters showKind={showKind} value={filterValue} onChange={onChange} />\n\n {listQuery.isError && (\n <p className=\"error\" data-testid=\"history-error\">\n Couldn't load execution history.\n </p>\n )}\n\n {rerunError}\n\n <div ref={viewRef}>\n <ExecutionList\n items={executions}\n showCallable={showKind}\n loading={listQuery.isLoading}\n hasPrev={offset > 0}\n hasNext={hasMore}\n onPrev={onPrev}\n onNext={onNext}\n onSelect={onSelect}\n onRerun={(id) => {\n const row = executions.find((r) => r.id === id);\n if (row) startRerun(row);\n }}\n rerunningId={rerunningId}\n />\n </div>\n </>\n );\n}\n","/**\n * The canvas's app lookups, through the host-provided `W6WApi` (`useW6WApi()` — in an embed that\n * is `createW6WUiAdapter`'s, in Studio the facade, which delegates to the same store/repo).\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { type AppSummary, useW6WApi } from \"@w6w/ui\";\nimport { useMemo } from \"react\";\n\n/** The per-app actions query key — the repos export itself (one declaration, no copy). */\nexport { appActionsKey } from \"../repos/apps.ts\";\n\nconst NO_APPS: ReadonlyMap<string, AppSummary> = new Map();\n\n/** A bounded set of app records by id. Empty when the host's API has no `listAppsByIds`. */\nexport function useEditorApps(ids: readonly string[]): { byId: ReadonlyMap<string, AppSummary> } {\n const api = useW6WApi();\n const list = api.listAppsByIds?.bind(api);\n const key = [...ids].sort().join(\",\");\n const q = useQuery({\n queryKey: [\"editor-apps\", key],\n queryFn: ({ signal }) => (list ? list(ids, { signal }) : Promise.resolve([] as AppSummary[])),\n enabled: ids.length > 0 && typeof list === \"function\",\n });\n const data = q.data;\n const byId = useMemo(\n () => (data ? new Map(data.map((a) => [a.id, a] as const)) : NO_APPS),\n [data],\n );\n return { byId };\n}\n\n/**\n * One app record by id, over {@link useEditorApps} (same `/apps` request, same cache entry as the\n * canvas's batch lookup). `undefined` while loading, for an empty id (which issues no request),\n * or when the host's API cannot look apps up by id.\n */\nexport function useEditorApp(id: string): AppSummary | undefined {\n const { byId } = useEditorApps(id ? [id] : []);\n return id ? byId.get(id) : undefined;\n}\n"],"names":["SEARCH_DEBOUNCE_MS","scrollParent","el","p","overflowY","HistoryView","props","scope","showKind","filters","onFiltersChange","onOpenInEditor","filtersRef","useRef","q","setQ","useState","searchTimer","selected","setSelected","useEffect","listQuery","useHistoryQuery","statsQuery","useHistoryStatsQuery","detailQuery","useExecutionDetailQuery","rerun","useRerunExecutionMutation","findExecution","useFindExecution","findError","setFindError","viewRef","listScroll","selectedId","useLayoutEffect","parent","top","selectedRef","open","useCallback","next","executions","_a","offset","hasMore","_b","applyFilters","onChange","onPrev","HISTORY_PAGE_SIZE","onNext","onSelect","executionId","row","r","startRerun","summary","rerunningId","_c","openOriginal","callableId","id","rerunError","jsxs","filterValue","openInEditor","jsx","ExecutionDetail","Fragment","ExecutionStats","ExecutionFilters","ExecutionList","NO_APPS","useEditorApps","ids","api","useW6WApi","list","key","data","useQuery","signal","useMemo","useEditorApp","byId"],"mappings":";;;;;;AAwDA,MAAMA,KAAqB;AAI3B,SAASC,EAAaC,GAA4C;AAChE,WAASC,KAAID,KAAA,gBAAAA,EAAI,kBAAiB,MAAMC,GAAGA,IAAIA,EAAE,eAAe;AAC9D,UAAMC,IAAY,iBAAiBD,CAAC,EAAE;AACtC,SAAKC,MAAc,UAAUA,MAAc,aAAaD,EAAE,eAAeA,EAAE;AACzE,aAAOA;AAAA,EAEX;AACA,SAAO;AACT;AAgBO,SAASE,GAAYC,GAAyB;;AACnD,QAAM,EAAE,OAAAC,GAAO,UAAAC,GAAU,SAAAC,GAAS,iBAAAC,GAAiB,gBAAAC,MAAmBL,GAKhEM,IAAaC,EAAOJ,CAAO;AACjC,EAAAG,EAAW,UAAUH;AAErB,QAAM,CAACK,GAAGC,CAAI,IAAIC,EAASP,EAAQ,CAAC,GAC9BQ,IAAcJ,EAA6C,IAAI,GAC/D,CAACK,GAAUC,CAAW,IAAIH,EAAkC,IAAI;AAMtE,EAAA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