@burdenoff/microfe-semanticfed 2026.1031.7 → 2026.1031.8
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/semanticfed/api/semanticfedGraphql.js +1 -1
- package/dist/semanticfed/components/SavedQueryRunsPanel.js +407 -0
- package/dist/semanticfed/components/SavedQueryRunsPanel.js.map +1 -0
- package/dist/semanticfed/hooks/useQueryRuns.js +171 -0
- package/dist/semanticfed/hooks/useQueryRuns.js.map +1 -0
- package/dist/semanticfed/pages/QueryConsolePage.js +138 -138
- package/dist/semanticfed/pages/QueryConsolePage.js.map +1 -1
- package/dist/semanticfed/providers/SemanticFedProvider.js +22 -10
- package/dist/semanticfed/providers/SemanticFedProvider.js.map +1 -1
- package/dist/semanticfed/utils/format.js +8 -0
- package/dist/semanticfed/utils/format.js.map +1 -0
- package/package.json +1 -1
|
@@ -30,6 +30,6 @@ async function o(o, s = {}, c) {
|
|
|
30
30
|
return /^\s*mutation\b/.test(o) && i(), l.data;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
|
-
export { a as SemRequestError, o as semRequest };
|
|
33
|
+
export { a as SemRequestError, i as clearGraphqlReadCaches, o as semRequest };
|
|
34
34
|
|
|
35
35
|
//# sourceMappingURL=semanticfedGraphql.js.map
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { useTr as e } from "../hooks/useTr.js";
|
|
2
|
+
import { sqlErrorMessage as t } from "../hooks/useSqlConsole.js";
|
|
3
|
+
import { isRunPollExpired as n, isTerminalRunStatus as r, restrictiveDecisions as i, runGovernance as a, useSemQueryRun as o, useSemQueryRunResult as s, useSemQueryRuns as c, useSemRunSavedQuery as l, useSemSavedQueries as u } from "../hooks/useQueryRuns.js";
|
|
4
|
+
import { formatCell as d } from "../utils/format.js";
|
|
5
|
+
import { useState as f } from "react";
|
|
6
|
+
import { AlertTriangle as p, BookMarked as m, CheckCircle2 as h, ChevronLeft as g, ChevronRight as _, Clock as v, EyeOff as y, History as b, Loader2 as x, Play as S, ShieldAlert as C, XCircle as w } from "lucide-react";
|
|
7
|
+
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
8
|
+
import { Badge as O, Button as k, Card as A, CardContent as j, CardHeader as M, CardTitle as N } from "@burdenoff/fe-libs/ui";
|
|
9
|
+
//#region src/semanticfed/components/SavedQueryRunsPanel.tsx
|
|
10
|
+
function P(e) {
|
|
11
|
+
if (!e) return "";
|
|
12
|
+
let t = new Date(e);
|
|
13
|
+
return Number.isNaN(t.getTime()) ? e : t.toLocaleString();
|
|
14
|
+
}
|
|
15
|
+
function F(e, t) {
|
|
16
|
+
switch (t) {
|
|
17
|
+
case "QUEUED": return e("semanticfed.queryConsole.saved.status.queued", "Queued");
|
|
18
|
+
case "PLANNING": return e("semanticfed.queryConsole.saved.status.planning", "Planning");
|
|
19
|
+
case "RUNNING": return e("semanticfed.queryConsole.saved.status.running", "Running");
|
|
20
|
+
case "SUCCEEDED": return e("semanticfed.queryConsole.saved.status.succeeded", "Succeeded");
|
|
21
|
+
case "FAILED": return e("semanticfed.queryConsole.saved.status.failed", "Failed");
|
|
22
|
+
case "CANCELLED": return e("semanticfed.queryConsole.saved.status.cancelled", "Cancelled");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function I({ status: e }) {
|
|
26
|
+
return e === "SUCCEEDED" ? /* @__PURE__ */ E(h, { className: "h-4 w-4 shrink-0 text-primary" }) : e === "FAILED" || e === "CANCELLED" ? /* @__PURE__ */ E(w, { className: "h-4 w-4 shrink-0 text-destructive" }) : /* @__PURE__ */ E(x, { className: "h-4 w-4 shrink-0 animate-spin text-muted-foreground" });
|
|
27
|
+
}
|
|
28
|
+
function L(e, t) {
|
|
29
|
+
switch (t) {
|
|
30
|
+
case "NULL": return e("semanticfed.queryConsole.saved.mask.null", "Hidden (NULL)");
|
|
31
|
+
case "REDACT": return e("semanticfed.queryConsole.saved.mask.redact", "Redacted");
|
|
32
|
+
case "HASH": return e("semanticfed.queryConsole.saved.mask.hash", "Hashed");
|
|
33
|
+
default: return e("semanticfed.queryConsole.saved.mask.other", "Masked");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function R({ run: e, tr: t }) {
|
|
37
|
+
let n = a(e.planSummary), r = n?.outcome === "DENIED", o = n ? i(n) : [];
|
|
38
|
+
return /* @__PURE__ */ D("div", {
|
|
39
|
+
className: "space-y-2 rounded border border-destructive/40 p-3 text-sm",
|
|
40
|
+
"data-testid": "saved-query-run-error",
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ D("div", {
|
|
43
|
+
className: "flex items-start gap-2 text-destructive",
|
|
44
|
+
children: [E(r ? C : w, { className: "mt-0.5 h-4 w-4 shrink-0" }), /* @__PURE__ */ D("span", {
|
|
45
|
+
className: "break-words",
|
|
46
|
+
children: [r ? t("semanticfed.queryConsole.saved.denied", "Denied by access policy") : t("semanticfed.queryConsole.saved.failed", "The run failed"), e.errorMessage ? `: ${e.errorMessage}` : ""]
|
|
47
|
+
})]
|
|
48
|
+
}),
|
|
49
|
+
r && n?.reason && n.reason !== e.errorMessage && /* @__PURE__ */ E("p", {
|
|
50
|
+
className: "text-xs text-muted-foreground",
|
|
51
|
+
children: n.reason
|
|
52
|
+
}),
|
|
53
|
+
o.length > 0 && /* @__PURE__ */ E("ul", {
|
|
54
|
+
className: "space-y-1 text-xs text-muted-foreground",
|
|
55
|
+
"data-testid": "saved-query-denials",
|
|
56
|
+
children: o.map((e, t) => /* @__PURE__ */ D("li", { children: [
|
|
57
|
+
/* @__PURE__ */ D("span", {
|
|
58
|
+
className: "font-mono",
|
|
59
|
+
children: [e.entity, e.field ? `.${e.field}` : ""]
|
|
60
|
+
}),
|
|
61
|
+
" ",
|
|
62
|
+
"— ",
|
|
63
|
+
e.action,
|
|
64
|
+
e.policyName ? ` (${e.policyName})` : "",
|
|
65
|
+
e.detail ? `: ${e.detail}` : ""
|
|
66
|
+
] }, `${e.action}-${e.entity}-${e.field ?? ""}-${t}`))
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function z({ runId: e, tr: n }) {
|
|
72
|
+
let [r, i] = f([0]), a = s(e, r[r.length - 1] ?? 0);
|
|
73
|
+
if (a.isLoading) return /* @__PURE__ */ E(x, { className: "h-4 w-4 animate-spin text-muted-foreground" });
|
|
74
|
+
if (a.isError) return /* @__PURE__ */ E("p", {
|
|
75
|
+
className: "text-sm text-destructive",
|
|
76
|
+
"data-testid": "saved-query-result-error",
|
|
77
|
+
children: n("semanticfed.queryConsole.saved.resultUnavailable", "The rows of this run are not available: {message}. Results are kept for a limited time and only for the person who ran the query; run it again to see current rows.", { message: t(a.error) })
|
|
78
|
+
});
|
|
79
|
+
let o = a.data;
|
|
80
|
+
if (!o) return null;
|
|
81
|
+
let c = o.columns.filter((e) => e.masked), l = o.rows.length === 0 ? 0 : o.offset + 1, u = o.offset + o.rows.length;
|
|
82
|
+
return /* @__PURE__ */ D("div", {
|
|
83
|
+
className: "space-y-2",
|
|
84
|
+
"data-testid": "saved-query-result",
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ D("div", {
|
|
87
|
+
className: "flex flex-wrap items-center gap-3 text-xs text-muted-foreground",
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ E("span", {
|
|
90
|
+
className: "font-medium text-foreground",
|
|
91
|
+
"data-testid": "saved-query-result-range",
|
|
92
|
+
children: n("semanticfed.queryConsole.saved.rowsRange", "Rows {first}–{last} of {count}", {
|
|
93
|
+
first: l.toLocaleString(),
|
|
94
|
+
last: u.toLocaleString(),
|
|
95
|
+
count: o.rowCount.toLocaleString()
|
|
96
|
+
})
|
|
97
|
+
}),
|
|
98
|
+
o.truncated && /* @__PURE__ */ D(O, {
|
|
99
|
+
variant: "outline",
|
|
100
|
+
className: "gap-1",
|
|
101
|
+
"data-testid": "saved-query-truncated",
|
|
102
|
+
children: [/* @__PURE__ */ E(p, { className: "h-3 w-3" }), n("semanticfed.queryConsole.saved.truncated", "Stored the first {count} of {total} rows", {
|
|
103
|
+
count: o.rowCount.toLocaleString(),
|
|
104
|
+
total: o.totalRowCount.toLocaleString()
|
|
105
|
+
})]
|
|
106
|
+
}),
|
|
107
|
+
c.length > 0 && /* @__PURE__ */ D(O, {
|
|
108
|
+
variant: "outline",
|
|
109
|
+
className: "gap-1",
|
|
110
|
+
"data-testid": "saved-query-masked-note",
|
|
111
|
+
children: [/* @__PURE__ */ E(y, { className: "h-3 w-3" }), n("semanticfed.queryConsole.saved.maskedNote", "{count} column(s) masked by access policy", { count: c.length })]
|
|
112
|
+
}),
|
|
113
|
+
/* @__PURE__ */ E("span", { children: n("semanticfed.queryConsole.saved.expires", "Result kept until {time}", { time: P(o.expiresAt) }) })
|
|
114
|
+
]
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ E("div", {
|
|
117
|
+
className: "max-h-[28rem] overflow-auto rounded border",
|
|
118
|
+
children: /* @__PURE__ */ D("table", {
|
|
119
|
+
className: "w-full text-left text-xs",
|
|
120
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
121
|
+
className: "sticky top-0 bg-muted",
|
|
122
|
+
children: /* @__PURE__ */ E("tr", { children: o.columns.map((e) => /* @__PURE__ */ D("th", {
|
|
123
|
+
className: "whitespace-nowrap px-3 py-2 font-medium",
|
|
124
|
+
"data-masked": e.masked ? e.mask ?? "MASKED" : void 0,
|
|
125
|
+
children: [/* @__PURE__ */ D("span", {
|
|
126
|
+
className: "inline-flex items-center gap-1",
|
|
127
|
+
children: [e.name, e.masked && /* @__PURE__ */ D(O, {
|
|
128
|
+
variant: "outline",
|
|
129
|
+
className: "gap-1 px-1 py-0 text-[10px] font-normal",
|
|
130
|
+
title: n("semanticfed.queryConsole.saved.maskedTitle", "Masked by access policy ({mask})", { mask: e.mask ?? "" }),
|
|
131
|
+
children: [/* @__PURE__ */ E(y, { className: "h-3 w-3" }), L(n, e.mask)]
|
|
132
|
+
})]
|
|
133
|
+
}), /* @__PURE__ */ E("span", {
|
|
134
|
+
className: "block text-[10px] font-normal text-muted-foreground",
|
|
135
|
+
children: e.aggregation ? `${e.aggregation}(${e.entity}.${e.field})` : `${e.entity}.${e.field}`
|
|
136
|
+
})]
|
|
137
|
+
}, e.name)) })
|
|
138
|
+
}), /* @__PURE__ */ D("tbody", { children: [o.rows.map((e, t) => /* @__PURE__ */ E("tr", {
|
|
139
|
+
className: "border-t",
|
|
140
|
+
children: o.columns.map((t) => /* @__PURE__ */ E("td", {
|
|
141
|
+
className: t.masked ? "whitespace-nowrap bg-muted/40 px-3 py-1.5 font-mono text-muted-foreground" : "whitespace-nowrap px-3 py-1.5 font-mono",
|
|
142
|
+
children: d(e[t.name])
|
|
143
|
+
}, t.name))
|
|
144
|
+
}, o.offset + t)), o.rows.length === 0 && /* @__PURE__ */ E("tr", { children: /* @__PURE__ */ E("td", {
|
|
145
|
+
colSpan: Math.max(o.columns.length, 1),
|
|
146
|
+
className: "px-3 py-4 text-center text-muted-foreground",
|
|
147
|
+
children: n("semanticfed.queryConsole.saved.noRows", "No rows matched, or none you are allowed to see")
|
|
148
|
+
}) })] })]
|
|
149
|
+
})
|
|
150
|
+
}),
|
|
151
|
+
(r.length > 1 || o.nextOffset !== null) && /* @__PURE__ */ D("div", {
|
|
152
|
+
className: "flex items-center justify-end gap-2",
|
|
153
|
+
children: [/* @__PURE__ */ D(k, {
|
|
154
|
+
size: "sm",
|
|
155
|
+
variant: "outline",
|
|
156
|
+
disabled: r.length <= 1 || a.isFetching,
|
|
157
|
+
onClick: () => i((e) => e.slice(0, -1)),
|
|
158
|
+
"data-testid": "saved-query-prev-page",
|
|
159
|
+
children: [/* @__PURE__ */ E(g, { className: "mr-1 h-4 w-4" }), n("semanticfed.queryConsole.saved.previous", "Previous")]
|
|
160
|
+
}), /* @__PURE__ */ D(k, {
|
|
161
|
+
size: "sm",
|
|
162
|
+
variant: "outline",
|
|
163
|
+
disabled: o.nextOffset === null || a.isFetching,
|
|
164
|
+
onClick: () => {
|
|
165
|
+
let e = o.nextOffset;
|
|
166
|
+
e !== null && i((t) => [...t, e]);
|
|
167
|
+
},
|
|
168
|
+
"data-testid": "saved-query-next-page",
|
|
169
|
+
children: [n("semanticfed.queryConsole.saved.next", "Next {count}", { count: 100 }), /* @__PURE__ */ E(_, { className: "ml-1 h-4 w-4" })]
|
|
170
|
+
})]
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function B({ runId: e, tr: i }) {
|
|
176
|
+
let s = o(e), c = s.data;
|
|
177
|
+
if (s.isError) return /* @__PURE__ */ E("p", {
|
|
178
|
+
className: "text-sm text-destructive",
|
|
179
|
+
children: t(s.error)
|
|
180
|
+
});
|
|
181
|
+
if (!c) return s.isLoading ? /* @__PURE__ */ E(x, { className: "h-4 w-4 animate-spin text-muted-foreground" }) : /* @__PURE__ */ E("p", {
|
|
182
|
+
className: "text-sm text-muted-foreground",
|
|
183
|
+
children: i("semanticfed.queryConsole.saved.runMissing", "This run no longer exists.")
|
|
184
|
+
});
|
|
185
|
+
let l = a(c.planSummary);
|
|
186
|
+
return /* @__PURE__ */ D("div", {
|
|
187
|
+
className: "space-y-3",
|
|
188
|
+
"data-testid": "saved-query-run",
|
|
189
|
+
"data-status": c.status,
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ D("div", {
|
|
192
|
+
className: "flex flex-wrap items-center gap-3 text-sm",
|
|
193
|
+
children: [
|
|
194
|
+
/* @__PURE__ */ E(I, { status: c.status }),
|
|
195
|
+
/* @__PURE__ */ E("span", {
|
|
196
|
+
className: "font-medium",
|
|
197
|
+
"data-testid": "saved-query-run-status",
|
|
198
|
+
children: F(i, c.status)
|
|
199
|
+
}),
|
|
200
|
+
c.durationMs !== null && /* @__PURE__ */ D("span", {
|
|
201
|
+
className: "text-muted-foreground",
|
|
202
|
+
children: [c.durationMs, "ms"]
|
|
203
|
+
}),
|
|
204
|
+
r(c.status) && /* @__PURE__ */ E("span", {
|
|
205
|
+
className: "text-muted-foreground",
|
|
206
|
+
children: i("semanticfed.queryConsole.result.sources", "{count} sources", { count: c.sourcesTouched })
|
|
207
|
+
}),
|
|
208
|
+
c.fromCache && /* @__PURE__ */ E(O, {
|
|
209
|
+
variant: "outline",
|
|
210
|
+
children: i("semanticfed.queryConsole.saved.fromCache", "From cache")
|
|
211
|
+
}),
|
|
212
|
+
l && l.policiesEvaluated > 0 && /* @__PURE__ */ D(O, {
|
|
213
|
+
variant: "outline",
|
|
214
|
+
className: "gap-1",
|
|
215
|
+
children: [/* @__PURE__ */ E(C, { className: "h-3 w-3" }), i("semanticfed.queryConsole.saved.policies", "{count} access policies applied", { count: l.policiesEvaluated })]
|
|
216
|
+
})
|
|
217
|
+
]
|
|
218
|
+
}),
|
|
219
|
+
!r(c.status) && !n(c) && /* @__PURE__ */ E("p", {
|
|
220
|
+
className: "text-xs text-muted-foreground",
|
|
221
|
+
children: i("semanticfed.queryConsole.saved.waiting", "The query runs in the background across its data sources; this updates when it finishes.")
|
|
222
|
+
}),
|
|
223
|
+
!r(c.status) && n(c) && /* @__PURE__ */ D("div", {
|
|
224
|
+
className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground",
|
|
225
|
+
"data-testid": "saved-query-run-stalled",
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ E(p, { className: "h-3 w-3" }),
|
|
228
|
+
/* @__PURE__ */ E("span", { children: i("semanticfed.queryConsole.saved.stalled", "This run is taking longer than expected, so it is no longer checked automatically.") }),
|
|
229
|
+
/* @__PURE__ */ E(k, {
|
|
230
|
+
size: "sm",
|
|
231
|
+
variant: "outline",
|
|
232
|
+
disabled: s.isFetching,
|
|
233
|
+
onClick: () => void s.refetch(),
|
|
234
|
+
children: i("semanticfed.queryConsole.saved.checkAgain", "Check again")
|
|
235
|
+
})
|
|
236
|
+
]
|
|
237
|
+
}),
|
|
238
|
+
c.status === "SUCCEEDED" && /* @__PURE__ */ E(z, {
|
|
239
|
+
runId: c.id,
|
|
240
|
+
tr: i
|
|
241
|
+
}, c.id),
|
|
242
|
+
(c.status === "FAILED" || c.status === "CANCELLED") && /* @__PURE__ */ E(R, {
|
|
243
|
+
run: c,
|
|
244
|
+
tr: i
|
|
245
|
+
})
|
|
246
|
+
]
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function V({ queryId: e, selectedRunId: n, onSelect: r, tr: i }) {
|
|
250
|
+
let a = c(e);
|
|
251
|
+
return /* @__PURE__ */ D("div", {
|
|
252
|
+
className: "space-y-2",
|
|
253
|
+
children: [
|
|
254
|
+
/* @__PURE__ */ D("h3", {
|
|
255
|
+
className: "flex items-center gap-2 text-sm font-medium",
|
|
256
|
+
children: [/* @__PURE__ */ E(b, { className: "h-4 w-4" }), i("semanticfed.queryConsole.saved.history", "Run history")]
|
|
257
|
+
}),
|
|
258
|
+
a.isLoading && /* @__PURE__ */ E(x, { className: "h-4 w-4 animate-spin text-muted-foreground" }),
|
|
259
|
+
a.isError && /* @__PURE__ */ E("p", {
|
|
260
|
+
className: "text-xs text-destructive",
|
|
261
|
+
children: t(a.error)
|
|
262
|
+
}),
|
|
263
|
+
a.isSuccess && a.data.length === 0 && /* @__PURE__ */ E("p", {
|
|
264
|
+
className: "text-xs text-muted-foreground",
|
|
265
|
+
children: i("semanticfed.queryConsole.saved.noRuns", "This query has not been run yet.")
|
|
266
|
+
}),
|
|
267
|
+
/* @__PURE__ */ E("div", {
|
|
268
|
+
className: "space-y-1",
|
|
269
|
+
"data-testid": "saved-query-history",
|
|
270
|
+
children: (a.data ?? []).map((e) => /* @__PURE__ */ D("button", {
|
|
271
|
+
type: "button",
|
|
272
|
+
onClick: () => r(e.id),
|
|
273
|
+
"aria-pressed": e.id === n,
|
|
274
|
+
className: e.id === n ? "flex w-full items-center gap-3 rounded border border-primary bg-muted p-2 text-left text-xs" : "flex w-full items-center gap-3 rounded border p-2 text-left text-xs hover:bg-muted",
|
|
275
|
+
children: [
|
|
276
|
+
/* @__PURE__ */ E(I, { status: e.status }),
|
|
277
|
+
/* @__PURE__ */ E("span", {
|
|
278
|
+
className: "font-medium",
|
|
279
|
+
children: F(i, e.status)
|
|
280
|
+
}),
|
|
281
|
+
e.rowCount !== null && /* @__PURE__ */ E("span", {
|
|
282
|
+
className: "text-muted-foreground",
|
|
283
|
+
children: i("semanticfed.queryConsole.history.results", "{count} results", { count: e.rowCount.toLocaleString() })
|
|
284
|
+
}),
|
|
285
|
+
e.durationMs !== null && /* @__PURE__ */ D("span", {
|
|
286
|
+
className: "text-muted-foreground",
|
|
287
|
+
children: [e.durationMs, "ms"]
|
|
288
|
+
}),
|
|
289
|
+
/* @__PURE__ */ D("span", {
|
|
290
|
+
className: "ml-auto flex items-center gap-1 text-muted-foreground",
|
|
291
|
+
children: [/* @__PURE__ */ E(v, { className: "h-3 w-3" }), P(e.createdAt)]
|
|
292
|
+
})
|
|
293
|
+
]
|
|
294
|
+
}, e.id))
|
|
295
|
+
})
|
|
296
|
+
]
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function H({ modelId: n }) {
|
|
300
|
+
let r = e(), i = u(n), a = l(), [o, s] = f(null), [c, d] = f(null), [p, h] = f(null), g = i.data ?? [], _ = g.find((e) => e.id === o) ?? g[0] ?? null, v = _ && c?.queryId === _.id ? c.runId : null, y = (e) => {
|
|
301
|
+
s(e || null), d(null), h(null);
|
|
302
|
+
}, b = async () => {
|
|
303
|
+
if (!(!_ || a.isPending)) {
|
|
304
|
+
h(null);
|
|
305
|
+
try {
|
|
306
|
+
let e = await a.mutateAsync(_.id);
|
|
307
|
+
d({
|
|
308
|
+
queryId: e.queryId,
|
|
309
|
+
runId: e.id
|
|
310
|
+
});
|
|
311
|
+
} catch (e) {
|
|
312
|
+
h(t(e));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
return /* @__PURE__ */ D(A, {
|
|
317
|
+
"data-testid": "saved-queries-panel",
|
|
318
|
+
children: [/* @__PURE__ */ D(M, {
|
|
319
|
+
className: "pb-3",
|
|
320
|
+
children: [/* @__PURE__ */ D(N, {
|
|
321
|
+
className: "flex items-center gap-2 text-base",
|
|
322
|
+
children: [/* @__PURE__ */ E(m, { className: "h-4 w-4" }), r("semanticfed.queryConsole.saved.title", "Saved queries")]
|
|
323
|
+
}), /* @__PURE__ */ E("p", {
|
|
324
|
+
className: "text-xs text-muted-foreground",
|
|
325
|
+
children: r("semanticfed.queryConsole.saved.description", "Run a saved federated query in the background and read its governed result: only the rows you may see, with masked columns marked.")
|
|
326
|
+
})]
|
|
327
|
+
}), /* @__PURE__ */ D(j, {
|
|
328
|
+
className: "space-y-4",
|
|
329
|
+
children: [
|
|
330
|
+
i.isLoading && /* @__PURE__ */ E(x, { className: "h-4 w-4 animate-spin text-muted-foreground" }),
|
|
331
|
+
i.isError && /* @__PURE__ */ E("p", {
|
|
332
|
+
className: "text-sm text-destructive",
|
|
333
|
+
children: t(i.error)
|
|
334
|
+
}),
|
|
335
|
+
i.isSuccess && g.length === 0 && /* @__PURE__ */ E("p", {
|
|
336
|
+
className: "text-sm text-muted-foreground",
|
|
337
|
+
"data-testid": "saved-queries-empty",
|
|
338
|
+
children: r("semanticfed.queryConsole.saved.empty", "No saved queries for this model yet. Save a federated query with the API, SDK or CLI and it appears here.")
|
|
339
|
+
}),
|
|
340
|
+
_ && /* @__PURE__ */ D(T, { children: [
|
|
341
|
+
/* @__PURE__ */ D("div", {
|
|
342
|
+
className: "flex flex-wrap items-end gap-2",
|
|
343
|
+
children: [/* @__PURE__ */ D("div", {
|
|
344
|
+
className: "min-w-0 flex-1",
|
|
345
|
+
children: [/* @__PURE__ */ E("label", {
|
|
346
|
+
className: "mb-1 block text-xs font-medium text-muted-foreground",
|
|
347
|
+
htmlFor: "saved-query-select",
|
|
348
|
+
children: r("semanticfed.queryConsole.saved.pick", "Saved query")
|
|
349
|
+
}), /* @__PURE__ */ E("select", {
|
|
350
|
+
id: "saved-query-select",
|
|
351
|
+
"data-testid": "saved-query-select",
|
|
352
|
+
className: "w-full rounded border bg-background p-2 text-sm",
|
|
353
|
+
value: _.id,
|
|
354
|
+
onChange: (e) => y(e.target.value),
|
|
355
|
+
children: g.map((e) => /* @__PURE__ */ E("option", {
|
|
356
|
+
value: e.id,
|
|
357
|
+
children: e.status === "DRAFT" ? r("semanticfed.queryConsole.saved.draftOption", "{name} (draft)", { name: e.name }) : e.name
|
|
358
|
+
}, e.id))
|
|
359
|
+
})]
|
|
360
|
+
}), /* @__PURE__ */ D(k, {
|
|
361
|
+
size: "sm",
|
|
362
|
+
onClick: () => void b(),
|
|
363
|
+
disabled: a.isPending || !_.modelId,
|
|
364
|
+
"data-testid": "saved-query-run-button",
|
|
365
|
+
children: [a.isPending ? /* @__PURE__ */ E(x, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ E(S, { className: "mr-2 h-4 w-4" }), r("semanticfed.queryConsole.saved.run", "Run query")]
|
|
366
|
+
})]
|
|
367
|
+
}),
|
|
368
|
+
_.description && /* @__PURE__ */ E("p", {
|
|
369
|
+
className: "text-xs text-muted-foreground",
|
|
370
|
+
children: _.description
|
|
371
|
+
}),
|
|
372
|
+
!_.modelId && /* @__PURE__ */ E("p", {
|
|
373
|
+
className: "text-xs text-destructive",
|
|
374
|
+
children: r("semanticfed.queryConsole.saved.noModel", "This query is not linked to a semantic model, so it cannot run.")
|
|
375
|
+
}),
|
|
376
|
+
/* @__PURE__ */ E("pre", {
|
|
377
|
+
className: "max-h-40 overflow-auto rounded bg-muted p-3 font-mono text-[11px] text-foreground",
|
|
378
|
+
"data-testid": "saved-query-text",
|
|
379
|
+
children: _.queryText
|
|
380
|
+
}),
|
|
381
|
+
p && /* @__PURE__ */ E("p", {
|
|
382
|
+
className: "text-sm text-destructive",
|
|
383
|
+
"data-testid": "saved-query-run-start-error",
|
|
384
|
+
children: p
|
|
385
|
+
}),
|
|
386
|
+
v && /* @__PURE__ */ E(B, {
|
|
387
|
+
runId: v,
|
|
388
|
+
tr: r
|
|
389
|
+
}, v),
|
|
390
|
+
/* @__PURE__ */ E(V, {
|
|
391
|
+
queryId: _.id,
|
|
392
|
+
selectedRunId: v,
|
|
393
|
+
onSelect: (e) => d({
|
|
394
|
+
queryId: _.id,
|
|
395
|
+
runId: e
|
|
396
|
+
}),
|
|
397
|
+
tr: r
|
|
398
|
+
})
|
|
399
|
+
] })
|
|
400
|
+
]
|
|
401
|
+
})]
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
export { H as SavedQueryRunsPanel };
|
|
406
|
+
|
|
407
|
+
//# sourceMappingURL=SavedQueryRunsPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SavedQueryRunsPanel.js","names":[],"sources":["../../../src/semanticfed/components/SavedQueryRunsPanel.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Badge, Button, Card, CardContent, CardHeader, CardTitle } from '@burdenoff/fe-libs/ui';\nimport {\n AlertTriangle,\n BookMarked,\n CheckCircle2,\n ChevronLeft,\n ChevronRight,\n Clock,\n EyeOff,\n History,\n Loader2,\n Play,\n ShieldAlert,\n XCircle,\n} from 'lucide-react';\n\nimport {\n isRunPollExpired,\n isTerminalRunStatus,\n restrictiveDecisions,\n RUN_RESULT_PAGE_SIZE,\n runGovernance,\n type SemQueryRun,\n type SemQueryRunStatus,\n type SemSavedQuery,\n useSemQueryRun,\n useSemQueryRunResult,\n useSemQueryRuns,\n useSemRunSavedQuery,\n useSemSavedQueries,\n} from '../hooks/useQueryRuns';\nimport { sqlErrorMessage } from '../hooks/useSqlConsole';\nimport { useTr } from '../hooks/useTr';\nimport { formatCell } from '../utils/format';\n\ntype Tr = ReturnType<typeof useTr>;\n\nfunction formatTime(iso: string | null): string {\n if (!iso) return '';\n const date = new Date(iso);\n return Number.isNaN(date.getTime()) ? iso : date.toLocaleString();\n}\n\nfunction statusLabel(tr: Tr, status: SemQueryRunStatus): string {\n switch (status) {\n case 'QUEUED':\n return tr('semanticfed.queryConsole.saved.status.queued', 'Queued');\n case 'PLANNING':\n return tr('semanticfed.queryConsole.saved.status.planning', 'Planning');\n case 'RUNNING':\n return tr('semanticfed.queryConsole.saved.status.running', 'Running');\n case 'SUCCEEDED':\n return tr('semanticfed.queryConsole.saved.status.succeeded', 'Succeeded');\n case 'FAILED':\n return tr('semanticfed.queryConsole.saved.status.failed', 'Failed');\n case 'CANCELLED':\n return tr('semanticfed.queryConsole.saved.status.cancelled', 'Cancelled');\n }\n}\n\nfunction StatusIcon({ status }: { status: SemQueryRunStatus }) {\n if (status === 'SUCCEEDED') return <CheckCircle2 className=\"h-4 w-4 shrink-0 text-primary\" />;\n if (status === 'FAILED' || status === 'CANCELLED') {\n return <XCircle className=\"h-4 w-4 shrink-0 text-destructive\" />;\n }\n return <Loader2 className=\"h-4 w-4 shrink-0 animate-spin text-muted-foreground\" />;\n}\n\nfunction maskLabel(tr: Tr, mask: string | null): string {\n switch (mask) {\n case 'NULL':\n return tr('semanticfed.queryConsole.saved.mask.null', 'Hidden (NULL)');\n case 'REDACT':\n return tr('semanticfed.queryConsole.saved.mask.redact', 'Redacted');\n case 'HASH':\n return tr('semanticfed.queryConsole.saved.mask.hash', 'Hashed');\n default:\n return tr('semanticfed.queryConsole.saved.mask.other', 'Masked');\n }\n}\n\n/** Why a failed run failed, with the access-policy decisions that denied it. */\nfunction RunFailure({ run, tr }: { run: SemQueryRun; tr: Tr }) {\n const governance = runGovernance(run.planSummary);\n const denied = governance?.outcome === 'DENIED';\n const decisions = governance ? restrictiveDecisions(governance) : [];\n return (\n <div\n className=\"space-y-2 rounded border border-destructive/40 p-3 text-sm\"\n data-testid=\"saved-query-run-error\"\n >\n <div className=\"flex items-start gap-2 text-destructive\">\n {denied ? (\n <ShieldAlert className=\"mt-0.5 h-4 w-4 shrink-0\" />\n ) : (\n <XCircle className=\"mt-0.5 h-4 w-4 shrink-0\" />\n )}\n <span className=\"break-words\">\n {denied\n ? tr('semanticfed.queryConsole.saved.denied', 'Denied by access policy')\n : tr('semanticfed.queryConsole.saved.failed', 'The run failed')}\n {run.errorMessage ? `: ${run.errorMessage}` : ''}\n </span>\n </div>\n {denied && governance?.reason && governance.reason !== run.errorMessage && (\n <p className=\"text-xs text-muted-foreground\">{governance.reason}</p>\n )}\n {decisions.length > 0 && (\n <ul className=\"space-y-1 text-xs text-muted-foreground\" data-testid=\"saved-query-denials\">\n {decisions.map((d, index) => (\n <li key={`${d.action}-${d.entity}-${d.field ?? ''}-${index}`}>\n <span className=\"font-mono\">\n {d.entity}\n {d.field ? `.${d.field}` : ''}\n </span>{' '}\n — {d.action}\n {d.policyName ? ` (${d.policyName})` : ''}\n {d.detail ? `: ${d.detail}` : ''}\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n}\n\n/** Paginated governed rows of a SUCCEEDED run. */\nfunction RunResultGrid({ runId, tr }: { runId: string; tr: Tr }) {\n const [offsets, setOffsets] = useState<number[]>([0]);\n const offset = offsets[offsets.length - 1] ?? 0;\n const result = useSemQueryRunResult(runId, offset);\n\n if (result.isLoading) {\n return <Loader2 className=\"h-4 w-4 animate-spin text-muted-foreground\" />;\n }\n if (result.isError) {\n return (\n <p className=\"text-sm text-destructive\" data-testid=\"saved-query-result-error\">\n {tr(\n 'semanticfed.queryConsole.saved.resultUnavailable',\n 'The rows of this run are not available: {message}. Results are kept for a limited time and only for the person who ran the query; run it again to see current rows.',\n { message: sqlErrorMessage(result.error) }\n )}\n </p>\n );\n }\n const page = result.data;\n if (!page) return null;\n const maskedColumns = page.columns.filter((c) => c.masked);\n const firstRow = page.rows.length === 0 ? 0 : page.offset + 1;\n const lastRow = page.offset + page.rows.length;\n\n return (\n <div className=\"space-y-2\" data-testid=\"saved-query-result\">\n <div className=\"flex flex-wrap items-center gap-3 text-xs text-muted-foreground\">\n <span className=\"font-medium text-foreground\" data-testid=\"saved-query-result-range\">\n {tr('semanticfed.queryConsole.saved.rowsRange', 'Rows {first}–{last} of {count}', {\n first: firstRow.toLocaleString(),\n last: lastRow.toLocaleString(),\n count: page.rowCount.toLocaleString(),\n })}\n </span>\n {page.truncated && (\n <Badge variant=\"outline\" className=\"gap-1\" data-testid=\"saved-query-truncated\">\n <AlertTriangle className=\"h-3 w-3\" />\n {tr(\n 'semanticfed.queryConsole.saved.truncated',\n 'Stored the first {count} of {total} rows',\n {\n count: page.rowCount.toLocaleString(),\n total: page.totalRowCount.toLocaleString(),\n }\n )}\n </Badge>\n )}\n {maskedColumns.length > 0 && (\n <Badge variant=\"outline\" className=\"gap-1\" data-testid=\"saved-query-masked-note\">\n <EyeOff className=\"h-3 w-3\" />\n {tr(\n 'semanticfed.queryConsole.saved.maskedNote',\n '{count} column(s) masked by access policy',\n { count: maskedColumns.length }\n )}\n </Badge>\n )}\n <span>\n {tr('semanticfed.queryConsole.saved.expires', 'Result kept until {time}', {\n time: formatTime(page.expiresAt),\n })}\n </span>\n </div>\n <div className=\"max-h-[28rem] overflow-auto rounded border\">\n <table className=\"w-full text-left text-xs\">\n <thead className=\"sticky top-0 bg-muted\">\n <tr>\n {page.columns.map((column) => (\n <th\n key={column.name}\n className=\"whitespace-nowrap px-3 py-2 font-medium\"\n data-masked={column.masked ? (column.mask ?? 'MASKED') : undefined}\n >\n <span className=\"inline-flex items-center gap-1\">\n {column.name}\n {column.masked && (\n <Badge\n variant=\"outline\"\n className=\"gap-1 px-1 py-0 text-[10px] font-normal\"\n title={tr(\n 'semanticfed.queryConsole.saved.maskedTitle',\n 'Masked by access policy ({mask})',\n { mask: column.mask ?? '' }\n )}\n >\n <EyeOff className=\"h-3 w-3\" />\n {maskLabel(tr, column.mask)}\n </Badge>\n )}\n </span>\n <span className=\"block text-[10px] font-normal text-muted-foreground\">\n {column.aggregation\n ? `${column.aggregation}(${column.entity}.${column.field})`\n : `${column.entity}.${column.field}`}\n </span>\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {page.rows.map((row, index) => (\n <tr key={page.offset + index} className=\"border-t\">\n {page.columns.map((column) => (\n <td\n key={column.name}\n className={\n column.masked\n ? 'whitespace-nowrap bg-muted/40 px-3 py-1.5 font-mono text-muted-foreground'\n : 'whitespace-nowrap px-3 py-1.5 font-mono'\n }\n >\n {formatCell(row[column.name])}\n </td>\n ))}\n </tr>\n ))}\n {page.rows.length === 0 && (\n <tr>\n <td\n colSpan={Math.max(page.columns.length, 1)}\n className=\"px-3 py-4 text-center text-muted-foreground\"\n >\n {tr(\n 'semanticfed.queryConsole.saved.noRows',\n 'No rows matched, or none you are allowed to see'\n )}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n {(offsets.length > 1 || page.nextOffset !== null) && (\n <div className=\"flex items-center justify-end gap-2\">\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={offsets.length <= 1 || result.isFetching}\n onClick={() => setOffsets((o) => o.slice(0, -1))}\n data-testid=\"saved-query-prev-page\"\n >\n <ChevronLeft className=\"mr-1 h-4 w-4\" />\n {tr('semanticfed.queryConsole.saved.previous', 'Previous')}\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={page.nextOffset === null || result.isFetching}\n onClick={() => {\n const next = page.nextOffset;\n if (next !== null) setOffsets((o) => [...o, next]);\n }}\n data-testid=\"saved-query-next-page\"\n >\n {tr('semanticfed.queryConsole.saved.next', 'Next {count}', {\n count: RUN_RESULT_PAGE_SIZE,\n })}\n <ChevronRight className=\"ml-1 h-4 w-4\" />\n </Button>\n </div>\n )}\n </div>\n );\n}\n\n/** The selected run: live status while it executes, then its rows or its error. */\nfunction RunDetail({ runId, tr }: { runId: string; tr: Tr }) {\n const runQuery = useSemQueryRun(runId);\n const run = runQuery.data;\n if (runQuery.isError) {\n return <p className=\"text-sm text-destructive\">{sqlErrorMessage(runQuery.error)}</p>;\n }\n if (!run) {\n return runQuery.isLoading ? (\n <Loader2 className=\"h-4 w-4 animate-spin text-muted-foreground\" />\n ) : (\n <p className=\"text-sm text-muted-foreground\">\n {tr('semanticfed.queryConsole.saved.runMissing', 'This run no longer exists.')}\n </p>\n );\n }\n const governance = runGovernance(run.planSummary);\n return (\n <div className=\"space-y-3\" data-testid=\"saved-query-run\" data-status={run.status}>\n <div className=\"flex flex-wrap items-center gap-3 text-sm\">\n <StatusIcon status={run.status} />\n <span className=\"font-medium\" data-testid=\"saved-query-run-status\">\n {statusLabel(tr, run.status)}\n </span>\n {run.durationMs !== null && (\n <span className=\"text-muted-foreground\">{run.durationMs}ms</span>\n )}\n {isTerminalRunStatus(run.status) && (\n <span className=\"text-muted-foreground\">\n {tr('semanticfed.queryConsole.result.sources', '{count} sources', {\n count: run.sourcesTouched,\n })}\n </span>\n )}\n {run.fromCache && (\n <Badge variant=\"outline\">\n {tr('semanticfed.queryConsole.saved.fromCache', 'From cache')}\n </Badge>\n )}\n {governance && governance.policiesEvaluated > 0 && (\n <Badge variant=\"outline\" className=\"gap-1\">\n <ShieldAlert className=\"h-3 w-3\" />\n {tr('semanticfed.queryConsole.saved.policies', '{count} access policies applied', {\n count: governance.policiesEvaluated,\n })}\n </Badge>\n )}\n </div>\n {!isTerminalRunStatus(run.status) && !isRunPollExpired(run) && (\n <p className=\"text-xs text-muted-foreground\">\n {tr(\n 'semanticfed.queryConsole.saved.waiting',\n 'The query runs in the background across its data sources; this updates when it finishes.'\n )}\n </p>\n )}\n {!isTerminalRunStatus(run.status) && isRunPollExpired(run) && (\n <div\n className=\"flex flex-wrap items-center gap-2 text-xs text-muted-foreground\"\n data-testid=\"saved-query-run-stalled\"\n >\n <AlertTriangle className=\"h-3 w-3\" />\n <span>\n {tr(\n 'semanticfed.queryConsole.saved.stalled',\n 'This run is taking longer than expected, so it is no longer checked automatically.'\n )}\n </span>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={runQuery.isFetching}\n onClick={() => void runQuery.refetch()}\n >\n {tr('semanticfed.queryConsole.saved.checkAgain', 'Check again')}\n </Button>\n </div>\n )}\n {run.status === 'SUCCEEDED' && <RunResultGrid key={run.id} runId={run.id} tr={tr} />}\n {(run.status === 'FAILED' || run.status === 'CANCELLED') && <RunFailure run={run} tr={tr} />}\n </div>\n );\n}\n\nfunction RunHistory({\n queryId,\n selectedRunId,\n onSelect,\n tr,\n}: {\n queryId: string;\n selectedRunId: string | null;\n onSelect: (runId: string) => void;\n tr: Tr;\n}) {\n const runs = useSemQueryRuns(queryId);\n return (\n <div className=\"space-y-2\">\n <h3 className=\"flex items-center gap-2 text-sm font-medium\">\n <History className=\"h-4 w-4\" />\n {tr('semanticfed.queryConsole.saved.history', 'Run history')}\n </h3>\n {runs.isLoading && <Loader2 className=\"h-4 w-4 animate-spin text-muted-foreground\" />}\n {runs.isError && <p className=\"text-xs text-destructive\">{sqlErrorMessage(runs.error)}</p>}\n {runs.isSuccess && runs.data.length === 0 && (\n <p className=\"text-xs text-muted-foreground\">\n {tr('semanticfed.queryConsole.saved.noRuns', 'This query has not been run yet.')}\n </p>\n )}\n <div className=\"space-y-1\" data-testid=\"saved-query-history\">\n {(runs.data ?? []).map((run) => (\n <button\n type=\"button\"\n key={run.id}\n onClick={() => onSelect(run.id)}\n aria-pressed={run.id === selectedRunId}\n className={\n run.id === selectedRunId\n ? 'flex w-full items-center gap-3 rounded border border-primary bg-muted p-2 text-left text-xs'\n : 'flex w-full items-center gap-3 rounded border p-2 text-left text-xs hover:bg-muted'\n }\n >\n <StatusIcon status={run.status} />\n <span className=\"font-medium\">{statusLabel(tr, run.status)}</span>\n {run.rowCount !== null && (\n <span className=\"text-muted-foreground\">\n {tr('semanticfed.queryConsole.history.results', '{count} results', {\n count: run.rowCount.toLocaleString(),\n })}\n </span>\n )}\n {run.durationMs !== null && (\n <span className=\"text-muted-foreground\">{run.durationMs}ms</span>\n )}\n <span className=\"ml-auto flex items-center gap-1 text-muted-foreground\">\n <Clock className=\"h-3 w-3\" />\n {formatTime(run.createdAt)}\n </span>\n </button>\n ))}\n </div>\n </div>\n );\n}\n\nexport interface SavedQueryRunsPanelProps {\n /** The console's selected semantic model; saved queries are listed for it. */\n modelId: string | null;\n}\n\n/**\n * Saved federated queries (BOFF-9754): pick one, run it asynchronously, follow\n * the run to completion and page through its governed result rows, with\n * masked columns marked and policy denials explained. The run history comes\n * from the service, so it is shared across sessions and devices.\n */\nexport function SavedQueryRunsPanel({ modelId }: SavedQueryRunsPanelProps) {\n const tr = useTr();\n const queries = useSemSavedQueries(modelId);\n const runQuery = useSemRunSavedQuery();\n const [chosenQueryId, setChosenQueryId] = useState<string | null>(null);\n // The opened run is remembered together with the saved query it belongs to,\n // so it is never shown under another query (for example when the chosen\n // query is archived and the picker falls back to the first one).\n const [selection, setSelection] = useState<{ queryId: string; runId: string } | null>(null);\n const [runError, setRunError] = useState<string | null>(null);\n\n const list: SemSavedQuery[] = queries.data ?? [];\n const query = list.find((q) => q.id === chosenQueryId) ?? list[0] ?? null;\n const selectedRunId = query && selection?.queryId === query.id ? selection.runId : null;\n\n const choose = (id: string) => {\n setChosenQueryId(id || null);\n setSelection(null);\n setRunError(null);\n };\n\n const run = async () => {\n if (!query || runQuery.isPending) return;\n setRunError(null);\n try {\n const started = await runQuery.mutateAsync(query.id);\n setSelection({ queryId: started.queryId, runId: started.id });\n } catch (e) {\n setRunError(sqlErrorMessage(e));\n }\n };\n\n return (\n <Card data-testid=\"saved-queries-panel\">\n <CardHeader className=\"pb-3\">\n <CardTitle className=\"flex items-center gap-2 text-base\">\n <BookMarked className=\"h-4 w-4\" />\n {tr('semanticfed.queryConsole.saved.title', 'Saved queries')}\n </CardTitle>\n <p className=\"text-xs text-muted-foreground\">\n {tr(\n 'semanticfed.queryConsole.saved.description',\n 'Run a saved federated query in the background and read its governed result: only the rows you may see, with masked columns marked.'\n )}\n </p>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {queries.isLoading && <Loader2 className=\"h-4 w-4 animate-spin text-muted-foreground\" />}\n {queries.isError && (\n <p className=\"text-sm text-destructive\">{sqlErrorMessage(queries.error)}</p>\n )}\n {queries.isSuccess && list.length === 0 && (\n <p className=\"text-sm text-muted-foreground\" data-testid=\"saved-queries-empty\">\n {tr(\n 'semanticfed.queryConsole.saved.empty',\n 'No saved queries for this model yet. Save a federated query with the API, SDK or CLI and it appears here.'\n )}\n </p>\n )}\n {query && (\n <>\n <div className=\"flex flex-wrap items-end gap-2\">\n <div className=\"min-w-0 flex-1\">\n <label\n className=\"mb-1 block text-xs font-medium text-muted-foreground\"\n htmlFor=\"saved-query-select\"\n >\n {tr('semanticfed.queryConsole.saved.pick', 'Saved query')}\n </label>\n <select\n id=\"saved-query-select\"\n data-testid=\"saved-query-select\"\n className=\"w-full rounded border bg-background p-2 text-sm\"\n value={query.id}\n onChange={(e) => choose(e.target.value)}\n >\n {list.map((q) => (\n <option key={q.id} value={q.id}>\n {q.status === 'DRAFT'\n ? tr('semanticfed.queryConsole.saved.draftOption', '{name} (draft)', {\n name: q.name,\n })\n : q.name}\n </option>\n ))}\n </select>\n </div>\n <Button\n size=\"sm\"\n onClick={() => void run()}\n disabled={runQuery.isPending || !query.modelId}\n data-testid=\"saved-query-run-button\"\n >\n {runQuery.isPending ? (\n <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" />\n ) : (\n <Play className=\"mr-2 h-4 w-4\" />\n )}\n {tr('semanticfed.queryConsole.saved.run', 'Run query')}\n </Button>\n </div>\n {query.description && (\n <p className=\"text-xs text-muted-foreground\">{query.description}</p>\n )}\n {!query.modelId && (\n <p className=\"text-xs text-destructive\">\n {tr(\n 'semanticfed.queryConsole.saved.noModel',\n 'This query is not linked to a semantic model, so it cannot run.'\n )}\n </p>\n )}\n <pre\n className=\"max-h-40 overflow-auto rounded bg-muted p-3 font-mono text-[11px] text-foreground\"\n data-testid=\"saved-query-text\"\n >\n {query.queryText}\n </pre>\n {runError && (\n <p className=\"text-sm text-destructive\" data-testid=\"saved-query-run-start-error\">\n {runError}\n </p>\n )}\n {selectedRunId && <RunDetail key={selectedRunId} runId={selectedRunId} tr={tr} />}\n <RunHistory\n queryId={query.id}\n selectedRunId={selectedRunId}\n onSelect={(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,UAAU,EAAS,aAAa,CAAC,EAAM;OACvC,eAAY;iBAJd,CAMG,EAAS,YACR,kBAAC,GAAD,EAAS,WAAU,6BAA8B,CAAA,GAEjD,kBAAC,GAAD,EAAM,WAAU,gBAAiB,CAAA,EAElC,EAAG,sCAAsC,YAAY,CAC/C;SACL;;KACL,EAAM,eACL,kBAAC,KAAD;MAAG,WAAU;gBAAiC,EAAM;MAAgB,CAAA;KAErE,CAAC,EAAM,WACN,kBAAC,KAAD;MAAG,WAAU;gBACV,EACC,0CACA,kEACD;MACC,CAAA;KAEN,kBAAC,OAAD;MACE,WAAU;MACV,eAAY;gBAEX,EAAM;MACH,CAAA;KACL,KACC,kBAAC,KAAD;MAAG,WAAU;MAA2B,eAAY;gBACjD;MACC,CAAA;KAEL,KAAiB,kBAAC,GAAD;MAA+B,OAAO;MAAmB;MAAM,EAA/C,EAA+C;KACjF,kBAAC,GAAD;MACE,SAAS,EAAM;MACA;MACf,WAAW,MAAU,EAAa;OAAE,SAAS,EAAM;OAAI;OAAO,CAAC;MAC3D;MACJ,CAAA;KACD,EAAA,CAAA;IAEO;KACT"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { useSemanticFed as e } from "../providers/SemanticFedProvider.js";
|
|
2
|
+
import { clearGraphqlReadCaches as t, semRequest as n } from "../api/semanticfedGraphql.js";
|
|
3
|
+
import { useMutation as r, useQuery as i, useQueryClient as a } from "@tanstack/react-query";
|
|
4
|
+
var o = 100, s = 20, c = 1500, l = new Set([
|
|
5
|
+
"SUCCEEDED",
|
|
6
|
+
"FAILED",
|
|
7
|
+
"CANCELLED"
|
|
8
|
+
]);
|
|
9
|
+
function u(e) {
|
|
10
|
+
return l.has(e);
|
|
11
|
+
}
|
|
12
|
+
function d(e, t = Date.now()) {
|
|
13
|
+
if (u(e.status)) return !1;
|
|
14
|
+
let n = Date.parse(e.createdAt);
|
|
15
|
+
return Number.isFinite(n) && t - n > 6e5;
|
|
16
|
+
}
|
|
17
|
+
var f = "id\n queryId\n status\n errorMessage\n planSummary\n rowCount\n durationMs\n sourcesTouched\n fromCache\n runById\n createdAt\n startedAt\n finishedAt", p = "query SemConsoleSavedQueries($modelId: ID, $pagination: PaginationInput) {\n semListQueries(modelId: $modelId, pagination: $pagination) {\n items {\n id\n name\n description\n modelId\n queryText\n status\n tags\n updatedAt\n }\n }\n}", m = `mutation SemConsoleRunQuery($id: ID!) {
|
|
18
|
+
semRunQuery(id: $id) {
|
|
19
|
+
${f}
|
|
20
|
+
}
|
|
21
|
+
}`, h = `query SemConsoleQueryRun($id: ID!) {
|
|
22
|
+
semQueryRun(id: $id) {
|
|
23
|
+
${f}
|
|
24
|
+
}
|
|
25
|
+
}`, g = `query SemConsoleQueryRuns($queryId: ID!, $pagination: PaginationInput) {
|
|
26
|
+
semListQueryRuns(queryId: $queryId, pagination: $pagination) {
|
|
27
|
+
items {
|
|
28
|
+
${f}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}`, _ = "query SemConsoleQueryRunResult($runId: ID!, $pagination: PaginationInput) {\n semQueryRunResult(runId: $runId, pagination: $pagination) {\n runId\n queryId\n columns {\n name\n entity\n field\n aggregation\n masked\n mask\n }\n rows\n rowCount\n totalRowCount\n truncated\n offset\n limit\n nextOffset\n expiresAt\n }\n}";
|
|
32
|
+
function v(t) {
|
|
33
|
+
let { apiGatewayUrl: r, workspaceId: a } = e();
|
|
34
|
+
return i({
|
|
35
|
+
queryKey: [
|
|
36
|
+
"semanticfed",
|
|
37
|
+
"savedQueries",
|
|
38
|
+
a ?? "no-workspace",
|
|
39
|
+
t
|
|
40
|
+
],
|
|
41
|
+
enabled: !!a,
|
|
42
|
+
queryFn: async () => (await n(p, {
|
|
43
|
+
modelId: t,
|
|
44
|
+
pagination: { limit: o }
|
|
45
|
+
}, r)).semListQueries.items.filter((e) => e.status !== "ARCHIVED")
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function y() {
|
|
49
|
+
let { apiGatewayUrl: t, workspaceId: i } = e(), o = a();
|
|
50
|
+
return r({
|
|
51
|
+
mutationFn: async (e) => (await n(m, { id: e }, t)).semRunQuery,
|
|
52
|
+
onSuccess: (e) => {
|
|
53
|
+
o.setQueryData([
|
|
54
|
+
"semanticfed",
|
|
55
|
+
"queryRun",
|
|
56
|
+
i ?? "no-workspace",
|
|
57
|
+
e.id
|
|
58
|
+
], e), o.invalidateQueries({ queryKey: [
|
|
59
|
+
"semanticfed",
|
|
60
|
+
"queryRuns",
|
|
61
|
+
i ?? "no-workspace",
|
|
62
|
+
e.queryId
|
|
63
|
+
] });
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function b(r) {
|
|
68
|
+
let { apiGatewayUrl: o, workspaceId: s } = e(), l = a();
|
|
69
|
+
return i({
|
|
70
|
+
queryKey: [
|
|
71
|
+
"semanticfed",
|
|
72
|
+
"queryRun",
|
|
73
|
+
s ?? "no-workspace",
|
|
74
|
+
r
|
|
75
|
+
],
|
|
76
|
+
enabled: !!(s && r),
|
|
77
|
+
staleTime: 0,
|
|
78
|
+
queryFn: async () => {
|
|
79
|
+
t();
|
|
80
|
+
let e = (await n(h, { id: r }, o)).semQueryRun;
|
|
81
|
+
return e && u(e.status) && l.invalidateQueries({ queryKey: [
|
|
82
|
+
"semanticfed",
|
|
83
|
+
"queryRuns",
|
|
84
|
+
s ?? "no-workspace",
|
|
85
|
+
e.queryId
|
|
86
|
+
] }), e;
|
|
87
|
+
},
|
|
88
|
+
refetchInterval: (e) => {
|
|
89
|
+
let t = e.state.data;
|
|
90
|
+
return t === null || t && (u(t.status) || d(t)) ? !1 : c;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function x(r) {
|
|
95
|
+
let { apiGatewayUrl: a, workspaceId: o } = e();
|
|
96
|
+
return i({
|
|
97
|
+
queryKey: [
|
|
98
|
+
"semanticfed",
|
|
99
|
+
"queryRuns",
|
|
100
|
+
o ?? "no-workspace",
|
|
101
|
+
r
|
|
102
|
+
],
|
|
103
|
+
enabled: !!(o && r),
|
|
104
|
+
staleTime: 0,
|
|
105
|
+
queryFn: async () => (t(), (await n(g, {
|
|
106
|
+
queryId: r,
|
|
107
|
+
pagination: { limit: s }
|
|
108
|
+
}, a)).semListQueryRuns.items)
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function S(t, r) {
|
|
112
|
+
let { apiGatewayUrl: a, workspaceId: o } = e();
|
|
113
|
+
return i({
|
|
114
|
+
queryKey: [
|
|
115
|
+
"semanticfed",
|
|
116
|
+
"queryRunResult",
|
|
117
|
+
o ?? "no-workspace",
|
|
118
|
+
t,
|
|
119
|
+
r
|
|
120
|
+
],
|
|
121
|
+
enabled: !!(o && t),
|
|
122
|
+
retry: !1,
|
|
123
|
+
queryFn: async () => (await n(_, {
|
|
124
|
+
runId: t,
|
|
125
|
+
pagination: {
|
|
126
|
+
limit: 100,
|
|
127
|
+
offset: r
|
|
128
|
+
}
|
|
129
|
+
}, a)).semQueryRunResult
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function C(e) {
|
|
133
|
+
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
134
|
+
}
|
|
135
|
+
function w(e) {
|
|
136
|
+
return typeof e == "string" && e !== "" ? e : null;
|
|
137
|
+
}
|
|
138
|
+
function T(e) {
|
|
139
|
+
let t = C(C(e)?.governance);
|
|
140
|
+
if (!t) return null;
|
|
141
|
+
let n = t.outcome === "ALLOWED" ? "ALLOWED" : "DENIED", r = Array.isArray(t.decisions) ? t.decisions : [];
|
|
142
|
+
return {
|
|
143
|
+
outcome: n,
|
|
144
|
+
policiesEvaluated: typeof t.policiesEvaluated == "number" ? t.policiesEvaluated : 0,
|
|
145
|
+
reason: w(t.reason),
|
|
146
|
+
decisions: r.flatMap((e) => {
|
|
147
|
+
let t = C(e);
|
|
148
|
+
return !t || typeof t.action != "string" ? [] : [{
|
|
149
|
+
action: t.action,
|
|
150
|
+
entity: w(t.entity) ?? "",
|
|
151
|
+
field: w(t.field),
|
|
152
|
+
policyName: w(t.policyName),
|
|
153
|
+
mask: w(t.mask),
|
|
154
|
+
detail: w(t.detail)
|
|
155
|
+
}];
|
|
156
|
+
})
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
var E = new Set([
|
|
160
|
+
"ENTITY_DENIED",
|
|
161
|
+
"ROWS_BLOCKED",
|
|
162
|
+
"COLUMN_DENIED",
|
|
163
|
+
"EVALUATION_FAILED"
|
|
164
|
+
]);
|
|
165
|
+
function D(e) {
|
|
166
|
+
return e.decisions.filter((e) => E.has(e.action));
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
169
|
+
export { d as isRunPollExpired, u as isTerminalRunStatus, D as restrictiveDecisions, T as runGovernance, b as useSemQueryRun, S as useSemQueryRunResult, x as useSemQueryRuns, y as useSemRunSavedQuery, v as useSemSavedQueries };
|
|
170
|
+
|
|
171
|
+
//# sourceMappingURL=useQueryRuns.js.map
|