@w6w/embed 0.2.24 → 0.2.26
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/dist/{ImportSpecModal-Cpzp8ndt.js → ImportSpecModal-VdYN1QeZ.js} +21 -20
- package/dist/{ImportSpecModal-Cpzp8ndt.js.map → ImportSpecModal-VdYN1QeZ.js.map} +1 -1
- package/dist/{WorkflowEditor-LesBKjb2.js → WorkflowEditor-CGKoeSG7.js} +6 -6
- package/dist/{WorkflowEditor-LesBKjb2.js.map → WorkflowEditor-CGKoeSG7.js.map} +1 -1
- package/dist/{apps-CYUgEfGf.js → apps-FMcQfyL2.js} +2 -2
- package/dist/{apps-CYUgEfGf.js.map → apps-FMcQfyL2.js.map} +1 -1
- package/dist/chrome/ImportSpecModal.d.ts +2 -0
- package/dist/{credentials-Cn92LGhJ.js → credentials-CMR_wEvx.js} +96 -71
- package/dist/credentials-CMR_wEvx.js.map +1 -0
- package/dist/editor-apps-HEOclsxL.js +152 -0
- package/dist/{editor-apps-LZmDWMqf.js.map → editor-apps-HEOclsxL.js.map} +1 -1
- package/dist/{editor-tools-DHyWiG21.js → editor-tools-Brw0cv2F.js} +4 -4
- package/dist/{editor-tools-DHyWiG21.js.map → editor-tools-Brw0cv2F.js.map} +1 -1
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +7 -7
- package/dist/index.mjs +15 -15
- package/dist/lists/ConnectionList.d.ts +3 -1
- package/dist/lists/CredentialCreate.d.ts +25 -0
- package/dist/lists/CredentialDetail.d.ts +5 -1
- package/dist/lists/CredentialList.d.ts +3 -1
- package/dist/lists.d.ts +2 -0
- package/dist/lists.mjs +1035 -862
- package/dist/lists.mjs.map +1 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/credentials.d.ts +16 -2
- package/dist/repos.mjs +157 -153
- package/dist/{spec-export-DGigBUsP.js → spec-export-DMMET5VM.js} +2 -2
- package/dist/{spec-export-DGigBUsP.js.map → spec-export-DMMET5VM.js.map} +1 -1
- package/dist/{workflows-BK6IM4if.js → workflows-Dz8LMjnt.js} +37 -34
- package/dist/workflows-Dz8LMjnt.js.map +1 -0
- package/package.json +2 -2
- package/dist/credentials-Cn92LGhJ.js.map +0 -1
- package/dist/editor-apps-LZmDWMqf.js +0 -152
- package/dist/workflows-BK6IM4if.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery as u, keepPreviousData as l, useQueryClient as p, useMutation as y } from "@tanstack/react-query";
|
|
2
2
|
import { u as i } from "./client-context-CX61Bgw-.js";
|
|
3
|
-
import { H as d, h as f, o as r, g as q, i as a, E, j as g, I as x, x as K } from "./workflows-
|
|
3
|
+
import { H as d, h as f, o as r, g as q, i as a, E, j as g, I as x, x as K } from "./workflows-Dz8LMjnt.js";
|
|
4
4
|
const c = { project: "" };
|
|
5
5
|
function b(e, t, n = d) {
|
|
6
6
|
const s = i();
|
|
@@ -89,4 +89,4 @@ export {
|
|
|
89
89
|
k,
|
|
90
90
|
b as u
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=apps-
|
|
92
|
+
//# sourceMappingURL=apps-FMcQfyL2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps-
|
|
1
|
+
{"version":3,"file":"apps-FMcQfyL2.js","sources":["../src/repos/history.ts","../src/repos/apps.ts"],"sourcesContent":["/**\n * The `history` domain repo (T2.3.1) — thin react-query hooks over\n * `lib/history-query.ts`'s pure fetchers, mirroring `./dashboard.ts`'s\n * shape exactly: the query keys ship from the pure module, not from here or\n * from a caller; every hook is `useEmbedClient()` + one `useQuery`.\n *\n * `lib/history-query.ts` carries every judgment call (URL⇄filter mapping,\n * request params, cache keys, fetchers, detail mapping) so it stays loadable\n * by `node --test`; this file adds nothing but React wiring on top of it.\n */\nimport { keepPreviousData, useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport {\n EMPTY_HISTORY_FILTERS,\n type ExecutionSummary,\n HISTORY_PAGE_SIZE,\n type HistoryFilters,\n type HistoryScope,\n findExecution,\n getExecutionDetail,\n getHistory,\n getHistoryStats,\n historyKeys,\n rerunExecution,\n} from \"../lib/history-query.ts\";\nimport { runsKey } from \"./workflows.ts\";\n\n/** A placeholder scope to key a disabled query by — never fetched, since\n * `enabled` gates on the real (possibly `null`) scope, matching\n * `repos/workflows.ts`'s `useLiveRunQuery(runId ?? \"\")` idiom. */\nconst NO_SCOPE: HistoryScope = { project: \"\" };\n\n/** The project-wide or per-callable execution list, one page at a time.\n * Disabled while `scope` is `null` (no project/callable selected yet).\n * `placeholderData: keepPreviousData` keeps the previous page's rows on\n * screen while a filter/page change is in flight, instead of flashing to\n * an empty list. */\nexport function useHistoryQuery(\n scope: HistoryScope | null,\n f: HistoryFilters,\n limit: number = HISTORY_PAGE_SIZE,\n) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: historyKeys.list(scope ?? NO_SCOPE, f, limit),\n queryFn: () => getHistory(apiClient, scope as HistoryScope, f, limit),\n enabled: scope !== null,\n placeholderData: keepPreviousData,\n });\n}\n\n/** The aggregate stats card above the list — same scope/filters, no paging.\n * Disabled while `scope` is `null`. */\nexport function useHistoryStatsQuery(scope: HistoryScope | null, f: HistoryFilters) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: historyKeys.stats(scope ?? NO_SCOPE, f),\n queryFn: () => getHistoryStats(apiClient, scope as HistoryScope, f),\n enabled: scope !== null,\n });\n}\n\n/** \"Has this callable ever been executed?\" — the cheap existence probe the\n * header's History button uses to decide its disabled state (one row,\n * every filter at its default). `hasExecuted` reads `false` while loading\n * or on error — never a false \"yes\". */\nexport function useHasExecutedQuery(callableId: string): {\n hasExecuted: boolean;\n isLoading: boolean;\n} {\n const apiClient = useEmbedClient();\n const query = useQuery({\n queryKey: historyKeys.exists(callableId),\n queryFn: () => getHistory(apiClient, { callable: callableId }, EMPTY_HISTORY_FILTERS, 1),\n });\n return {\n hasExecuted: (query.data?.executions?.length ?? 0) > 0,\n isLoading: query.isLoading,\n };\n}\n\n/** One execution's full detail, opened from a list row. Disabled while\n * `summary` is `null` (no row selected). */\nexport function useExecutionDetailQuery(summary: ExecutionSummary | null) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: historyKeys.detail(summary?.kind ?? \"function\", summary?.id ?? \"\"),\n queryFn: () => getExecutionDetail(apiClient, summary as ExecutionSummary),\n enabled: summary !== null,\n });\n}\n\n/** Run a listed execution again with the same input (`rerunExecution`),\n * resolving to the new execution's row (or `null` if not listed yet). Every\n * history list, stat and probe is invalidated once it settles — a failed\n * re-run is still a new execution — as is the workflow's own run list. */\nexport function useRerunExecutionMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (summary: ExecutionSummary) => rerunExecution(apiClient, summary),\n onSettled: (_res, _err, summary) => {\n qc.invalidateQueries({ queryKey: historyKeys.root });\n if (summary.kind === \"workflow\") {\n qc.invalidateQueries({ queryKey: runsKey(summary.callableId) });\n }\n },\n });\n}\n\n/** Look one execution of a callable up by id (`findExecution`) — what opens the original from a\n * re-run's \"Re-run of <id>\". A plain function over the embed client, not a query: it runs once per\n * click, and the opened detail has its own query. */\nexport function useFindExecution() {\n const apiClient = useEmbedClient();\n return (callableId: string, id: string) => findExecution(apiClient, callableId, id);\n}\n","/**\n * The per-app Actions repo — what the Target selector and the canvas's step pickers read.\n *\n * Moved from Studio's `repos/apps.ts` (B-3a); the Studio file re-exports these names. The client\n * comes from `useEmbedClient()`. `GET /apps/:id` through `client.console.apps.getActions` is the\n * same payload the W6WApi adapter serves the canvas, and the key is byte-identical to the one\n * the editor and `WorkflowsPage` compose by hand, so every reader shares one cache entry.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { W6WClient } from \"@w6w/sdk\";\nimport type { ActionDef, AppDetail } from \"@w6w/sdk/console\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport const appActionsKey = (id: string) => [\"app-actions\", id] as const;\n\nexport function getAppActions(client: W6WClient, id: string): Promise<ActionDef[]> {\n return client.console.apps.getActions(id);\n}\n\n/** `enabled` defaults to `true`; a selector passes `app !== \"\"` so an empty app issues nothing. */\nexport function useAppActionsQuery(id: string, enabled = true) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: appActionsKey(id),\n queryFn: () => getAppActions(client, id),\n enabled,\n });\n}\n\n// ── app (detail) ─────────────────────────────────────────────────────────\n\nexport const appKey = (id: string) => [\"app\", id] as const;\n\nexport function getApp(client: W6WClient, id: string): Promise<AppDetail> {\n return client.console.apps.get(id);\n}\n\n/**\n * `id` accepts `string | undefined`: a detail view's app id is `undefined` until its own\n * connection query resolves, so the caller passes `enabled` (its `!!id` guard) instead of\n * `!`-asserting.\n */\nexport function useAppQuery(id: string | undefined, enabled = true) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: appKey(id ?? \"\"),\n queryFn: () => getApp(client, id as string),\n enabled,\n });\n}\n"],"names":["NO_SCOPE","useHistoryQuery","scope","f","limit","HISTORY_PAGE_SIZE","apiClient","useEmbedClient","useQuery","historyKeys","getHistory","keepPreviousData","useHistoryStatsQuery","getHistoryStats","useHasExecutedQuery","callableId","query","EMPTY_HISTORY_FILTERS","_b","_a","useExecutionDetailQuery","summary","getExecutionDetail","useRerunExecutionMutation","qc","useQueryClient","useMutation","rerunExecution","_res","_err","runsKey","useFindExecution","id","findExecution","appActionsKey","getAppActions","client","useAppActionsQuery","enabled","appKey","getApp","useAppQuery"],"mappings":";;;AA8BA,MAAMA,IAAyB,EAAE,SAAS,GAAA;AAOnC,SAASC,EACdC,GACAC,GACAC,IAAgBC,GAChB;AACA,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUC,EAAY,KAAKP,KAASF,GAAUG,GAAGC,CAAK;AAAA,IACtD,SAAS,MAAMM,EAAWJ,GAAWJ,GAAuBC,GAAGC,CAAK;AAAA,IACpE,SAASF,MAAU;AAAA,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E;AAAA,EAAA,CACD;AACH;AAKO,SAASU,IAAmB;AACjC,QAAMzB,IAAYC,EAAA;AAClB,SAAO,CAACQ,GAAoBiB,MAAeC,EAAc3B,GAAWS,GAAYiB,CAAE;AACpF;ACvGO,MAAME,IAAgB,CAACF,MAAe,CAAC,eAAeA,CAAE;AAExD,SAASG,EAAcC,GAAmBJ,GAAkC;AACjF,SAAOI,EAAO,QAAQ,KAAK,WAAWJ,CAAE;AAC1C;AAGO,SAASK,EAAmBL,GAAYM,IAAU,IAAM;AAC7D,QAAMF,IAAS7B,EAAA;AACf,SAAOC,EAAS;AAAA,IACd,UAAU0B,EAAcF,CAAE;AAAA,IAC1B,SAAS,MAAMG,EAAcC,GAAQJ,CAAE;AAAA,IACvC,SAAAM;AAAA,EAAA,CACD;AACH;AAIO,MAAMC,IAAS,CAACP,MAAe,CAAC,OAAOA,CAAE;AAEzC,SAASQ,EAAOJ,GAAmBJ,GAAgC;AACxE,SAAOI,EAAO,QAAQ,KAAK,IAAIJ,CAAE;AACnC;AAOO,SAASS,EAAYT,GAAwBM,IAAU,IAAM;AAClE,QAAMF,IAAS7B,EAAA;AACf,SAAOC,EAAS;AAAA,IACd,UAAU+B,EAAOP,KAAM,EAAE;AAAA,IACzB,SAAS,MAAMQ,EAAOJ,GAAQJ,CAAY;AAAA,IAC1C,SAAAM;AAAA,EAAA,CACD;AACH;"}
|
|
@@ -36,5 +36,7 @@ export interface ImportSpecModalProps {
|
|
|
36
36
|
/** Navigate to the imported row; the modal closes itself first. */
|
|
37
37
|
onOpenImported: (kind: SpecImportKind, id: string) => void;
|
|
38
38
|
onClose: () => void;
|
|
39
|
+
/** Optional: where the connect form's Use existing empty state sends the user. */
|
|
40
|
+
onCreateSharedCredential?: () => void;
|
|
39
41
|
}
|
|
40
42
|
export declare function ImportSpecModal(props: ImportSpecModalProps): import("react").JSX.Element;
|
|
@@ -1,114 +1,135 @@
|
|
|
1
1
|
import { useQueryClient as c, useMutation as i, useQuery as l } from "@tanstack/react-query";
|
|
2
|
-
import { u as
|
|
2
|
+
import { u as s } from "./client-context-CX61Bgw-.js";
|
|
3
3
|
import { c as w } from "./connections-CzsCyIxY.js";
|
|
4
|
-
const u = ["credentials"], d = (e) => ["credential", e],
|
|
4
|
+
const u = ["credentials"], d = (e) => ["credential", e], Q = ["credential-types"], v = (e) => ["credential-dependents", e];
|
|
5
5
|
function y(e, t) {
|
|
6
6
|
e.invalidateQueries({ queryKey: u }), e.invalidateQueries({ queryKey: d(t) }), e.invalidateQueries({ queryKey: w }), e.invalidateQueries({ queryKey: ["connection"] }), e.invalidateQueries({ queryKey: ["app-connections"] });
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function f(e, t) {
|
|
9
9
|
return e.console.credentials.list(t);
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function T(e) {
|
|
12
|
+
return e.console.credentials.types();
|
|
13
|
+
}
|
|
14
|
+
function C(e, t) {
|
|
12
15
|
return e.console.credentials.get(t);
|
|
13
16
|
}
|
|
14
17
|
function p(e, t) {
|
|
15
18
|
return e.console.credentials.create(t);
|
|
16
19
|
}
|
|
17
|
-
function
|
|
20
|
+
function S(e, t, n) {
|
|
18
21
|
return e.console.credentials.update(t, n);
|
|
19
22
|
}
|
|
20
|
-
function
|
|
23
|
+
function m(e, t, n) {
|
|
21
24
|
return e.console.credentials.rotate(t, n);
|
|
22
25
|
}
|
|
23
|
-
function
|
|
26
|
+
function h(e, t, n) {
|
|
24
27
|
return n === "disabled" ? e.console.credentials.disable(t) : e.console.credentials.enable(t);
|
|
25
28
|
}
|
|
26
|
-
function
|
|
29
|
+
function q(e, t) {
|
|
27
30
|
return e.console.credentials.test(t);
|
|
28
31
|
}
|
|
29
|
-
function
|
|
32
|
+
function K(e, t) {
|
|
30
33
|
return e.console.credentials.dependents(t);
|
|
31
34
|
}
|
|
32
|
-
async function
|
|
35
|
+
async function F(e, t) {
|
|
33
36
|
var n, r;
|
|
34
37
|
try {
|
|
35
38
|
return await e.console.credentials.delete(t), { ok: !0 };
|
|
36
|
-
} catch (
|
|
37
|
-
const o =
|
|
39
|
+
} catch (a) {
|
|
40
|
+
const o = a;
|
|
38
41
|
if ((o == null ? void 0 : o.status) === 409 && o.code === "credential_in_use")
|
|
39
42
|
return {
|
|
40
43
|
ok: !1,
|
|
41
44
|
dependents: { connections: ((r = (n = (o.raw ?? {}).error) == null ? void 0 : n.dependents) == null ? void 0 : r.connections) ?? [] }
|
|
42
45
|
};
|
|
43
|
-
throw
|
|
46
|
+
throw a;
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
49
|
+
function k(e, t) {
|
|
50
|
+
const n = e ?? {}, r = t === "create" ? "create" : "rotate";
|
|
51
|
+
return n.status === 401 || n.status === 403 ? `You are not allowed to ${r} this credential.` : n.status === 409 ? "A credential with that name already exists." : n.status === 400 || n.status === 422 ? "The server rejected those values. Check them and try again." : n.status === 0 ? `Could not reach the server to ${r} the credential.` : `Could not ${r} the credential.`;
|
|
52
|
+
}
|
|
53
|
+
function x(e) {
|
|
54
|
+
const t = s();
|
|
48
55
|
return l({
|
|
49
56
|
queryKey: e ? [...u, e] : u,
|
|
50
|
-
queryFn: () =>
|
|
57
|
+
queryFn: () => f(t, e)
|
|
51
58
|
});
|
|
52
59
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
return l({
|
|
60
|
+
function A() {
|
|
61
|
+
const e = s();
|
|
62
|
+
return l({
|
|
63
|
+
queryKey: Q,
|
|
64
|
+
queryFn: () => T(e),
|
|
65
|
+
staleTime: Number.POSITIVE_INFINITY,
|
|
66
|
+
retry: !1
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function N(e) {
|
|
70
|
+
const t = s();
|
|
71
|
+
return l({ queryKey: d(e), queryFn: () => C(t, e) });
|
|
56
72
|
}
|
|
57
73
|
function _(e, t = !0) {
|
|
58
|
-
const n =
|
|
74
|
+
const n = s();
|
|
59
75
|
return l({
|
|
60
|
-
queryKey:
|
|
61
|
-
queryFn: () =>
|
|
76
|
+
queryKey: v(e),
|
|
77
|
+
queryFn: () => K(n, e),
|
|
62
78
|
enabled: t,
|
|
63
79
|
retry: !1
|
|
64
80
|
});
|
|
65
81
|
}
|
|
66
82
|
function j() {
|
|
67
|
-
const e =
|
|
83
|
+
const e = s(), t = c();
|
|
68
84
|
return i({
|
|
69
85
|
mutationFn: (n) => p(e, n),
|
|
86
|
+
// The variables carry the typed secret: do not keep a settled mutation (or its variables) in
|
|
87
|
+
// the cache once the form has reset it.
|
|
88
|
+
gcTime: 0,
|
|
70
89
|
onSuccess: () => t.invalidateQueries({ queryKey: u })
|
|
71
90
|
});
|
|
72
91
|
}
|
|
73
|
-
function
|
|
74
|
-
const t =
|
|
92
|
+
function $(e) {
|
|
93
|
+
const t = s(), n = c();
|
|
75
94
|
return i({
|
|
76
|
-
mutationFn: (r) =>
|
|
95
|
+
mutationFn: (r) => S(t, e, r),
|
|
77
96
|
onSuccess: () => {
|
|
78
97
|
n.invalidateQueries({ queryKey: u }), n.invalidateQueries({ queryKey: d(e) });
|
|
79
98
|
}
|
|
80
99
|
});
|
|
81
100
|
}
|
|
82
|
-
function
|
|
83
|
-
const t =
|
|
101
|
+
function O(e) {
|
|
102
|
+
const t = s(), n = c();
|
|
84
103
|
return i({
|
|
85
|
-
mutationFn: (r) =>
|
|
104
|
+
mutationFn: (r) => m(t, e, r),
|
|
105
|
+
gcTime: 0,
|
|
106
|
+
// the variables carry the typed secret
|
|
86
107
|
onSuccess: () => y(n, e)
|
|
87
108
|
});
|
|
88
109
|
}
|
|
89
110
|
function R(e) {
|
|
90
|
-
const t =
|
|
111
|
+
const t = s(), n = c();
|
|
91
112
|
return i({
|
|
92
|
-
mutationFn: (r) =>
|
|
113
|
+
mutationFn: (r) => h(t, e, r),
|
|
93
114
|
onSuccess: () => y(n, e)
|
|
94
115
|
});
|
|
95
116
|
}
|
|
96
117
|
function U(e) {
|
|
97
|
-
const t =
|
|
118
|
+
const t = s();
|
|
98
119
|
return i({
|
|
99
|
-
mutationFn: () =>
|
|
120
|
+
mutationFn: () => q(t, e)
|
|
100
121
|
});
|
|
101
122
|
}
|
|
102
|
-
function
|
|
103
|
-
const e =
|
|
123
|
+
function W() {
|
|
124
|
+
const e = s(), t = c();
|
|
104
125
|
return i({
|
|
105
|
-
mutationFn: (n) =>
|
|
126
|
+
mutationFn: (n) => F(e, n),
|
|
106
127
|
onSuccess: (n, r) => {
|
|
107
128
|
n.ok && y(t, r);
|
|
108
129
|
}
|
|
109
130
|
});
|
|
110
131
|
}
|
|
111
|
-
const
|
|
132
|
+
const g = [
|
|
112
133
|
"listCredentials",
|
|
113
134
|
"createCredential",
|
|
114
135
|
"getCredential",
|
|
@@ -118,15 +139,15 @@ const F = [
|
|
|
118
139
|
"credentialDependents",
|
|
119
140
|
"deleteCredential"
|
|
120
141
|
];
|
|
121
|
-
function
|
|
142
|
+
function M(e) {
|
|
122
143
|
return {
|
|
123
|
-
listCredentials: (t) =>
|
|
144
|
+
listCredentials: (t) => f(e, t),
|
|
124
145
|
createCredential: (t) => p(e, t),
|
|
125
|
-
getCredential: (t) =>
|
|
126
|
-
rotateCredential: (t, n) =>
|
|
127
|
-
setCredentialStatus: (t, n) =>
|
|
128
|
-
testCredential: (t) =>
|
|
129
|
-
credentialDependents: (t) =>
|
|
146
|
+
getCredential: (t) => C(e, t),
|
|
147
|
+
rotateCredential: (t, n) => m(e, t, n),
|
|
148
|
+
setCredentialStatus: (t, n) => h(e, t, n),
|
|
149
|
+
testCredential: (t) => q(e, t),
|
|
150
|
+
credentialDependents: (t) => K(e, t),
|
|
130
151
|
deleteCredential: async (t) => {
|
|
131
152
|
try {
|
|
132
153
|
await e.console.credentials.delete(t);
|
|
@@ -136,36 +157,40 @@ function h(e) {
|
|
|
136
157
|
}
|
|
137
158
|
};
|
|
138
159
|
}
|
|
139
|
-
function
|
|
140
|
-
const n =
|
|
141
|
-
for (const
|
|
142
|
-
typeof r[
|
|
160
|
+
function Y(e, t) {
|
|
161
|
+
const n = M(t), r = e;
|
|
162
|
+
for (const a of g)
|
|
163
|
+
typeof r[a] != "function" && (r[a] = n[a]);
|
|
143
164
|
return e;
|
|
144
165
|
}
|
|
145
166
|
export {
|
|
146
|
-
|
|
167
|
+
$ as A,
|
|
168
|
+
Y as B,
|
|
169
|
+
v as a,
|
|
147
170
|
d as b,
|
|
148
171
|
p as c,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
j,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
Q as d,
|
|
173
|
+
M as e,
|
|
174
|
+
k as f,
|
|
175
|
+
u as g,
|
|
176
|
+
F as h,
|
|
177
|
+
C as i,
|
|
178
|
+
K as j,
|
|
179
|
+
y as k,
|
|
180
|
+
T as l,
|
|
181
|
+
f as m,
|
|
182
|
+
j as n,
|
|
183
|
+
_ as o,
|
|
184
|
+
N as p,
|
|
185
|
+
A as q,
|
|
186
|
+
m as r,
|
|
187
|
+
h as s,
|
|
188
|
+
q as t,
|
|
189
|
+
S as u,
|
|
190
|
+
x as v,
|
|
191
|
+
W as w,
|
|
192
|
+
O as x,
|
|
193
|
+
R as y,
|
|
194
|
+
U as z
|
|
170
195
|
};
|
|
171
|
-
//# sourceMappingURL=credentials-
|
|
196
|
+
//# sourceMappingURL=credentials-CMR_wEvx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials-CMR_wEvx.js","sources":["../src/repos/credentials.ts"],"sourcesContent":["/**\n * The stored-credentials repo — list, single, create, rename, rotate, enable/disable, test,\n * dependents and delete, over `client.console.credentials.*`. Mirrors `connections.ts`.\n *\n * `invalidateAfterCredentialWrite` is the one place that knows a credential write can change what\n * a connection shows (its status, its untested flag), so it also stales every cached connection.\n * `credentialUiMethods` / `withCredentialMethods` are how both hosts (`W6WEmbedProvider` and\n * Studio's facade) supply the eight optional `W6WApi` credential methods from one implementation.\n */\nimport { type QueryClient, useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type { W6WClient } from \"@w6w/sdk\";\nimport type {\n CredentialDependents,\n CredentialListFilter,\n CredentialSummary,\n CredentialTestResult,\n CredentialTypeDescriptor,\n} from \"@w6w/sdk/console\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { connectionsKey } from \"./connections.ts\";\n\nexport type {\n CredentialDependents,\n CredentialListFilter,\n CredentialSummary,\n CredentialTestResult,\n CredentialTypeDescriptor,\n CredentialTypeField,\n} from \"@w6w/sdk/console\";\n\n// ── keys ──────────────────────────────────────────────────────────────\n\nexport const credentialsKey = [\"credentials\"] as const;\nexport const credentialKey = (id: string) => [\"credential\", id] as const;\nexport const credentialTypesKey = [\"credential-types\"] as const;\nexport const credentialDependentsKey = (id: string) => [\"credential-dependents\", id] as const;\n\n/**\n * A credential write (rotate, enable/disable, delete) changes what every connection on it\n * reports, so the credential keys AND every cached connection (single and per-app) go stale.\n */\nexport function invalidateAfterCredentialWrite(qc: QueryClient, id: string): void {\n qc.invalidateQueries({ queryKey: credentialsKey });\n qc.invalidateQueries({ queryKey: credentialKey(id) });\n qc.invalidateQueries({ queryKey: connectionsKey });\n qc.invalidateQueries({ queryKey: [\"connection\"] });\n qc.invalidateQueries({ queryKey: [\"app-connections\"] });\n}\n\n// ── fetchers ──────────────────────────────────────────────────────────\n\nexport function listCredentials(\n client: W6WClient,\n filter?: CredentialListFilter,\n): Promise<CredentialSummary[]> {\n return client.console.credentials.list(filter);\n}\n\n/** The credential types the server can store and the fields each collects, in server order. */\nexport function listCredentialTypes(client: W6WClient): Promise<CredentialTypeDescriptor[]> {\n return client.console.credentials.types();\n}\n\nexport function getCredential(client: W6WClient, id: string): Promise<CredentialSummary> {\n return client.console.credentials.get(id);\n}\n\nexport function createCredential(\n client: W6WClient,\n body: { name: string; contract: string; source: Record<string, unknown> },\n): Promise<CredentialSummary> {\n return client.console.credentials.create(body);\n}\n\n/** Rename. */\nexport function updateCredential(\n client: W6WClient,\n id: string,\n body: { name: string },\n): Promise<CredentialSummary> {\n return client.console.credentials.update(id, body);\n}\n\nexport function rotateCredential(\n client: W6WClient,\n id: string,\n body: { source: Record<string, unknown> },\n): Promise<CredentialSummary> {\n return client.console.credentials.rotate(id, body);\n}\n\nexport function setCredentialStatus(\n client: W6WClient,\n id: string,\n status: \"active\" | \"disabled\",\n): Promise<CredentialSummary> {\n return status === \"disabled\"\n ? client.console.credentials.disable(id)\n : client.console.credentials.enable(id);\n}\n\nexport function testCredential(client: W6WClient, id: string): Promise<CredentialTestResult> {\n return client.console.credentials.test(id);\n}\n\nexport function getCredentialDependents(\n client: W6WClient,\n id: string,\n): Promise<CredentialDependents> {\n return client.console.credentials.dependents(id);\n}\n\nexport type DeleteCredentialResult = { ok: true } | { ok: false; dependents: CredentialDependents };\n\n/**\n * Delete. A 409 `credential_in_use` is data — `{ ok: false, dependents }` — not a thrown error;\n * every other failure rejects. There is no `force`: a credential in use is never deleted.\n * Wire (RECONCILE R-11): `{ error: { code, message, dependents: { connections } } }`.\n */\nexport async function deleteCredential(\n client: W6WClient,\n id: string,\n): Promise<DeleteCredentialResult> {\n try {\n await client.console.credentials.delete(id);\n return { ok: true };\n } catch (e) {\n const err = e as { status?: unknown; code?: unknown; raw?: unknown };\n if (err?.status === 409 && err.code === \"credential_in_use\") {\n const raw = (err.raw ?? {}) as {\n error?: { dependents?: Partial<CredentialDependents> };\n };\n return {\n ok: false,\n dependents: { connections: raw.error?.dependents?.connections ?? [] },\n };\n }\n throw e;\n }\n}\n\n/**\n * Fixed, secret-free text for a failed credential write, chosen by the server's status / error\n * code. The server's own message is never shown: a value the user typed could be echoed in it.\n */\nexport function credentialWriteErrorText(e: unknown, verb: \"create\" | \"rotate\"): string {\n const err = (e ?? {}) as { status?: unknown; code?: unknown };\n const what = verb === \"create\" ? \"create\" : \"rotate\";\n if (err.status === 401 || err.status === 403)\n return `You are not allowed to ${what} this credential.`;\n if (err.status === 409) return \"A credential with that name already exists.\";\n if (err.status === 400 || err.status === 422)\n return \"The server rejected those values. Check them and try again.\";\n if (err.status === 0) return `Could not reach the server to ${what} the credential.`;\n return `Could not ${what} the credential.`;\n}\n\n// ── hooks ─────────────────────────────────────────────────────────────\n\nexport function useCredentialsQuery(filter?: CredentialListFilter) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: filter ? [...credentialsKey, filter] : credentialsKey,\n queryFn: () => listCredentials(client, filter),\n });\n}\n\n/**\n * The descriptors that drive the create form, the list's type label and the rotate fields. They\n * change only with a server release, so they are cached for the session; a failure is not retried\n * (the callers degrade to the contract id / the JSON rotate box).\n */\nexport function useCredentialTypesQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: credentialTypesKey,\n queryFn: () => listCredentialTypes(client),\n staleTime: Number.POSITIVE_INFINITY,\n retry: false,\n });\n}\n\nexport function useCredentialQuery(id: string) {\n const client = useEmbedClient();\n return useQuery({ queryKey: credentialKey(id), queryFn: () => getCredential(client, id) });\n}\n\nexport function useCredentialDependentsQuery(id: string, enabled = true) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: credentialDependentsKey(id),\n queryFn: () => getCredentialDependents(client, id),\n enabled,\n retry: false,\n });\n}\n\nexport function useCreateCredentialMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (body: { name: string; contract: string; source: Record<string, unknown> }) =>\n createCredential(client, body),\n // The variables carry the typed secret: do not keep a settled mutation (or its variables) in\n // the cache once the form has reset it.\n gcTime: 0,\n onSuccess: () => qc.invalidateQueries({ queryKey: credentialsKey }),\n });\n}\n\n/** Rename touches only the credential keys: no connection's state changes. */\nexport function useUpdateCredentialMutation(id: string) {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (body: { name: string }) => updateCredential(client, id, body),\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: credentialsKey });\n qc.invalidateQueries({ queryKey: credentialKey(id) });\n },\n });\n}\n\nexport function useRotateCredentialMutation(id: string) {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (body: { source: Record<string, unknown> }) => rotateCredential(client, id, body),\n gcTime: 0, // the variables carry the typed secret\n onSuccess: () => invalidateAfterCredentialWrite(qc, id),\n });\n}\n\nexport function useSetCredentialStatusMutation(id: string) {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (status: \"active\" | \"disabled\") => setCredentialStatus(client, id, status),\n onSuccess: () => invalidateAfterCredentialWrite(qc, id),\n });\n}\n\nexport function useTestCredentialMutation(id: string) {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (): Promise<CredentialTestResult> => testCredential(client, id),\n });\n}\n\nexport function useDeleteCredentialMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => deleteCredential(client, id),\n onSuccess: (r, id) => {\n if (r.ok) invalidateAfterCredentialWrite(qc, id);\n },\n });\n}\n\n// ── W6WApi bridge ─────────────────────────────────────────────────────\n\ntype CredentialMethodName =\n | \"listCredentials\"\n | \"createCredential\"\n | \"getCredential\"\n | \"rotateCredential\"\n | \"setCredentialStatus\"\n | \"testCredential\"\n | \"credentialDependents\"\n | \"deleteCredential\";\n\nconst CREDENTIAL_METHODS: readonly CredentialMethodName[] = [\n \"listCredentials\",\n \"createCredential\",\n \"getCredential\",\n \"rotateCredential\",\n \"setCredentialStatus\",\n \"testCredential\",\n \"credentialDependents\",\n \"deleteCredential\",\n];\n\n/**\n * The eight optional `W6WApi` credential methods over `client` (this module may not import\n * `@w6w/ui`, so the signatures are checked where they are spread into a `W6WApi`: Studio's\n * facade, and `W6WEmbedProvider`'s bridge). `deleteCredential` rejects on a\n * 409 with the response body attached as `.body` (as `withApiErrorBody` does in the react adapter).\n */\nexport function credentialUiMethods(client: W6WClient) {\n return {\n listCredentials: (filter?: CredentialListFilter) => listCredentials(client, filter),\n createCredential: (body: { name: string; contract: string; source: Record<string, unknown> }) =>\n createCredential(client, body),\n getCredential: (id: string) => getCredential(client, id),\n rotateCredential: (id: string, body: { source: Record<string, unknown> }) =>\n rotateCredential(client, id, body),\n setCredentialStatus: (id: string, status: \"active\" | \"disabled\") =>\n setCredentialStatus(client, id, status),\n testCredential: (id: string) => testCredential(client, id),\n credentialDependents: (id: string) => getCredentialDependents(client, id),\n deleteCredential: async (id: string) => {\n try {\n await client.console.credentials.delete(id);\n } catch (e) {\n if (e && typeof e === \"object\" && \"raw\" in e) {\n (e as { body?: unknown }).body = (e as { raw?: unknown }).raw;\n }\n throw e;\n }\n },\n };\n}\n\n/** Fills ONLY the credential methods that are not functions on `adapter`; keeps the rest. */\nexport function withCredentialMethods<T extends object>(adapter: T, client: W6WClient): T {\n const ours = credentialUiMethods(client);\n const target = adapter as Record<string, unknown>;\n for (const name of CREDENTIAL_METHODS) {\n if (typeof target[name] !== \"function\") target[name] = ours[name];\n }\n return adapter;\n}\n"],"names":["credentialsKey","credentialKey","id","credentialTypesKey","credentialDependentsKey","invalidateAfterCredentialWrite","qc","connectionsKey","listCredentials","client","filter","listCredentialTypes","getCredential","createCredential","body","updateCredential","rotateCredential","setCredentialStatus","status","testCredential","getCredentialDependents","deleteCredential","e","err","_b","_a","credentialWriteErrorText","verb","what","useCredentialsQuery","useEmbedClient","useQuery","useCredentialTypesQuery","useCredentialQuery","useCredentialDependentsQuery","enabled","useCreateCredentialMutation","useQueryClient","useMutation","useUpdateCredentialMutation","useRotateCredentialMutation","useSetCredentialStatusMutation","useTestCredentialMutation","useDeleteCredentialMutation","r","CREDENTIAL_METHODS","credentialUiMethods","withCredentialMethods","adapter","ours","target","name"],"mappings":";;;AAgCO,MAAMA,IAAiB,CAAC,aAAa,GAC/BC,IAAgB,CAACC,MAAe,CAAC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AASoB,GAAG;AACV,cAAIA,KAAK,OAAOA,KAAM,YAAY,SAASA,MACxCA,EAAyB,OAAQA,EAAwB,MAEtDA;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAEJ;AAGO,SAASyB,EAAwCC,GAAYvC,GAAsB;AACxF,QAAMwC,IAAOH,EAAoBrC,CAAM,GACjCyC,IAASF;AACf,aAAWG,KAAQN;AACjB,IAAI,OAAOK,EAAOC,CAAI,KAAM,eAAYD,EAAOC,CAAI,IAAIF,EAAKE,CAAI;AAElE,SAAOH;AACT;"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { jsxs as C, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { u as X, a as tt, b as et, c as nt, d as rt } from "./apps-FMcQfyL2.js";
|
|
3
|
+
import { H as _ } from "./workflows-Dz8LMjnt.js";
|
|
4
|
+
import { ExecutionDetail as ot, ExecutionStats as st, ExecutionFilters as it, ExecutionList as lt, useW6WApi as ct } from "@w6w/ui";
|
|
5
|
+
import { useRef as E, useState as R, useEffect as B, useLayoutEffect as ut, useCallback as L, useMemo as at } from "react";
|
|
6
|
+
import { useQuery as dt } from "@tanstack/react-query";
|
|
7
|
+
const ft = 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 xt(o) {
|
|
17
|
+
var Q, A, O;
|
|
18
|
+
const { scope: r, showKind: l, filters: n, onFiltersChange: m, onOpenInEditor: f } = 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 = X(r, n), j = tt(r, n), I = et(s), c = nt(), D = rt(), [T, y] = R(null), g = E(null), w = E(null), k = (s == null ? void 0 : s.id) ?? null;
|
|
30
|
+
ut(() => {
|
|
31
|
+
var e;
|
|
32
|
+
const t = g.current;
|
|
33
|
+
if (t) {
|
|
34
|
+
if (k !== null) {
|
|
35
|
+
const i = Y(t);
|
|
36
|
+
i ? i.scrollTop = 0 : t.getBoundingClientRect().top < 0 && ((e = t.scrollIntoView) == null || e.call(t, { block: "start" }));
|
|
37
|
+
} else if (w.current) {
|
|
38
|
+
const { parent: i, top: F } = w.current;
|
|
39
|
+
w.current = null, i ? i.scrollTop = F : window.scrollTo(0, F);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, [k]);
|
|
43
|
+
const H = E(s);
|
|
44
|
+
H.current = s;
|
|
45
|
+
const v = L((t) => {
|
|
46
|
+
if (H.current === null) {
|
|
47
|
+
const e = Y(g.current);
|
|
48
|
+
w.current = { parent: e, top: e ? e.scrollTop : window.scrollY };
|
|
49
|
+
}
|
|
50
|
+
b(t);
|
|
51
|
+
}, []), x = ((Q = h.data) == null ? void 0 : Q.executions) ?? [], q = n.offset, V = ((A = h.data) == null ? void 0 : A.hasMore) ?? !1, K = (t) => {
|
|
52
|
+
m({ ...t, offset: 0 });
|
|
53
|
+
}, W = (t) => {
|
|
54
|
+
if (t.q === u) {
|
|
55
|
+
K(t);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
a(t.q), p.current && clearTimeout(p.current), p.current = setTimeout(() => {
|
|
59
|
+
p.current = null, m({ ...S.current, q: t.q, offset: 0 });
|
|
60
|
+
}, ft);
|
|
61
|
+
}, $ = () => m({ ...n, q: u, offset: Math.max(0, q - _) }), G = () => m({ ...n, q: u, offset: q + _ }), U = L(
|
|
62
|
+
(t) => {
|
|
63
|
+
const e = x.find((i) => i.id === t);
|
|
64
|
+
e && v(e);
|
|
65
|
+
},
|
|
66
|
+
[x, v]
|
|
67
|
+
), M = (t) => {
|
|
68
|
+
c.mutate(t, {
|
|
69
|
+
onSuccess: (e) => {
|
|
70
|
+
e ? v(e) : b(null);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}, N = c.isPending ? ((O = c.variables) == null ? void 0 : O.id) ?? null : null, Z = (t, e) => {
|
|
74
|
+
y(null), D(t, e).then((i) => {
|
|
75
|
+
i ? v(i) : y(`${e} is no longer available.`);
|
|
76
|
+
}).catch(() => y(`Couldn't open ${e}.`));
|
|
77
|
+
}, P = 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" && f ? () => f(s) : void 0;
|
|
87
|
+
return s ? /* @__PURE__ */ C("div", { ref: g, children: [
|
|
88
|
+
P,
|
|
89
|
+
T && /* @__PURE__ */ d("p", { className: "error", "data-testid": "history-find-error", children: T }),
|
|
90
|
+
/* @__PURE__ */ d(
|
|
91
|
+
ot,
|
|
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: (t) => Z(s.callableId, t),
|
|
100
|
+
onRerun: () => M(s),
|
|
101
|
+
rerunning: N !== null,
|
|
102
|
+
onOpenInEditor: J
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }) : /* @__PURE__ */ C("div", { className: "w6w-card-stack", "data-testid": "history-view", children: [
|
|
106
|
+
/* @__PURE__ */ d(st, { stats: j.data ?? null }),
|
|
107
|
+
/* @__PURE__ */ d(it, { showKind: l, value: z, onChange: W }),
|
|
108
|
+
h.isError && /* @__PURE__ */ d("p", { className: "error", "data-testid": "history-error", children: "Couldn't load execution history." }),
|
|
109
|
+
P,
|
|
110
|
+
/* @__PURE__ */ d("div", { ref: g, children: /* @__PURE__ */ d(
|
|
111
|
+
lt,
|
|
112
|
+
{
|
|
113
|
+
items: x,
|
|
114
|
+
showCallable: l,
|
|
115
|
+
loading: h.isLoading,
|
|
116
|
+
hasPrev: q > 0,
|
|
117
|
+
hasNext: V,
|
|
118
|
+
onPrev: $,
|
|
119
|
+
onNext: G,
|
|
120
|
+
onSelect: U,
|
|
121
|
+
onRerun: (t) => {
|
|
122
|
+
const e = x.find((i) => i.id === t);
|
|
123
|
+
e && M(e);
|
|
124
|
+
},
|
|
125
|
+
rerunningId: N
|
|
126
|
+
}
|
|
127
|
+
) })
|
|
128
|
+
] });
|
|
129
|
+
}
|
|
130
|
+
const pt = /* @__PURE__ */ new Map();
|
|
131
|
+
function mt(o) {
|
|
132
|
+
var u;
|
|
133
|
+
const r = ct(), l = (u = r.listAppsByIds) == null ? void 0 : u.bind(r), n = [...o].sort().join(","), f = dt({
|
|
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: at(
|
|
139
|
+
() => f ? new Map(f.map((a) => [a.id, a])) : pt,
|
|
140
|
+
[f]
|
|
141
|
+
) };
|
|
142
|
+
}
|
|
143
|
+
function St(o) {
|
|
144
|
+
const { byId: r } = mt(o ? [o] : []);
|
|
145
|
+
return o ? r.get(o) : void 0;
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
xt as H,
|
|
149
|
+
mt as a,
|
|
150
|
+
St as u
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=editor-apps-HEOclsxL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-apps-LZmDWMqf.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,C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BK,IALIC,GAAS;AAAA,IACjB,UAAU,CAAC,eAAeF,CAAG;AAAA,IAC7B,SAAS,CAAC,EAAE,QAAAG,EAAA,MAAcJ,IAAOA,EAAKH,GAAK,EAAE,QAAAO,GAAQ,IAAI,QAAQ,QAAQ,CAAA,CAAkB;AAAA,IAC3F,SAASP,EAAI,SAAS,KAAK,OAAOG,KAAS;AAAA,EAAA,CAC5C,EACc;AAKf,SAAO,EAAE,MAJIK;AAAA,IACX,MAAOH,IAAO,IAAI,IAAIA,EAAK,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAU,CAAC,IAAIP;AAAA,IAC7D,CAACO,CAAI;AAAA,EAAA,EAEE;AACX;AAOO,SAASI,GAAatB,GAAoC;AAC/D,QAAM,EAAE,MAAAuB,MAASX,GAAcZ,IAAK,CAACA,CAAE,IAAI,EAAE;AAC7C,SAAOA,IAAKuB,EAAK,IAAIvB,CAAE,IAAI;AAC7B;"}
|
|
1
|
+
{"version":3,"file":"editor-apps-HEOclsxL.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 // `.w6w-card-stack` spaces stats → filters → list. A bare fragment left them touching: every host\n // wraps this view in one element (`RunHistory`'s embed root, `HistoryModal`'s body), so the\n // page's own flex gap never reached these siblings.\n return (\n <div className=\"w6w-card-stack\" data-testid=\"history-view\">\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 </div>\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","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,EAAAI,EAAU,MAAM;AACd,IAAAL,EAAKN,EAAQ,CAAC;AAAA,EAChB,GAAG,CAACA,EAAQ,CAAC,CAAC,GAGdW;AAAA,IACE,MAAM,MAAM;AACV,MAAIH,EAAY,WAAS,aAAaA,EAAY,OAAO;AAAA,IAC3D;AAAA,IACA,CAAA;AAAA,EAAC;AAGH,QAAMI,IAAYC,EAAgBf,GAAOE,CAAO,GAC1Cc,IAAaC,GAAqBjB,GAAOE,CAAO,GAChDgB,IAAcC,GAAwBR,CAAQ,GAC9CS,IAAQC,GAAA,GACRC,IAAgBC,GAAA,GAChB,CAACC,GAAWC,CAAY,IAAIhB,EAAwB,IAAI,GAMxDiB,IAAUpB,EAAuB,IAAI,GACrCqB,IAAarB,EAA2D,IAAI,GAC5EsB,KAAajB,KAAA,gBAAAA,EAAU,OAAM;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