@burdenoff/microfe-semanticfed 2026.1109.14 → 2026.1109.16
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/README.md +33 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/semanticfed/components/AskQuestionPanel.d.ts +0 -14
- package/dist/semanticfed/components/AskQuestionPanel.js +198 -160
- package/dist/semanticfed/components/AskQuestionPanel.js.map +1 -1
- package/dist/semanticfed/components/NlAssistSettings.js +4 -4
- package/dist/semanticfed/components/NlAssistSettings.js.map +1 -1
- package/dist/semanticfed/components/OnboardingChecklist.js +172 -128
- package/dist/semanticfed/components/OnboardingChecklist.js.map +1 -1
- package/dist/semanticfed/components/PageHeader.d.ts +11 -0
- package/dist/semanticfed/components/PageHeader.js +21 -0
- package/dist/semanticfed/components/PageHeader.js.map +1 -0
- package/dist/semanticfed/components/SavedQueryRunsPanel.js +224 -200
- package/dist/semanticfed/components/SavedQueryRunsPanel.js.map +1 -1
- package/dist/semanticfed/components/SummaryCard.d.ts +10 -0
- package/dist/semanticfed/components/SummaryCard.js +21 -0
- package/dist/semanticfed/components/SummaryCard.js.map +1 -0
- package/dist/semanticfed/components/TableHeaders.d.ts +16 -0
- package/dist/semanticfed/components/TableHeaders.js +21 -0
- package/dist/semanticfed/components/TableHeaders.js.map +1 -0
- package/dist/semanticfed/components/askConversation.d.ts +16 -0
- package/dist/semanticfed/components/askConversation.js +7 -0
- package/dist/semanticfed/components/askConversation.js.map +1 -0
- package/dist/semanticfed/components/lineage/LineageDetails.d.ts +15 -0
- package/dist/semanticfed/components/lineage/LineageDetails.js +155 -0
- package/dist/semanticfed/components/lineage/LineageDetails.js.map +1 -0
- package/dist/semanticfed/components/lineage/LineageLanes.d.ts +11 -0
- package/dist/semanticfed/components/lineage/LineageLanes.js +78 -0
- package/dist/semanticfed/components/lineage/LineageLanes.js.map +1 -0
- package/dist/semanticfed/components/lineage/LineageToolbar.d.ts +14 -0
- package/dist/semanticfed/components/lineage/LineageToolbar.js +69 -0
- package/dist/semanticfed/components/lineage/LineageToolbar.js.map +1 -0
- package/dist/semanticfed/components/lineage/LineageWarnings.d.ts +13 -0
- package/dist/semanticfed/components/lineage/LineageWarnings.js +43 -0
- package/dist/semanticfed/components/lineage/LineageWarnings.js.map +1 -0
- package/dist/semanticfed/components/lineage/lineageModel.d.ts +30 -0
- package/dist/semanticfed/components/lineage/lineageModel.js +110 -0
- package/dist/semanticfed/components/lineage/lineageModel.js.map +1 -0
- package/dist/semanticfed/components/lineage/useLineageTrace.d.ts +17 -0
- package/dist/semanticfed/components/lineage/useLineageTrace.js +34 -0
- package/dist/semanticfed/components/lineage/useLineageTrace.js.map +1 -0
- package/dist/semanticfed/components/queryConsole/QueryHistoryCard.d.ts +10 -0
- package/dist/semanticfed/components/queryConsole/QueryHistoryCard.js +47 -0
- package/dist/semanticfed/components/queryConsole/QueryHistoryCard.js.map +1 -0
- package/dist/semanticfed/components/queryConsole/SchemaBrowser.d.ts +13 -0
- package/dist/semanticfed/components/queryConsole/SchemaBrowser.js +89 -0
- package/dist/semanticfed/components/queryConsole/SchemaBrowser.js.map +1 -0
- package/dist/semanticfed/components/queryConsole/SqlEditorCard.d.ts +14 -0
- package/dist/semanticfed/components/queryConsole/SqlEditorCard.js +69 -0
- package/dist/semanticfed/components/queryConsole/SqlEditorCard.js.map +1 -0
- package/dist/semanticfed/components/queryConsole/SqlResultCard.d.ts +14 -0
- package/dist/semanticfed/components/queryConsole/SqlResultCard.js +71 -0
- package/dist/semanticfed/components/queryConsole/SqlResultCard.js.map +1 -0
- package/dist/semanticfed/components/queryConsole/consoleHistory.d.ts +23 -0
- package/dist/semanticfed/components/queryConsole/consoleHistory.js +19 -0
- package/dist/semanticfed/components/queryConsole/consoleHistory.js.map +1 -0
- package/dist/semanticfed/hooks/useLineage.d.ts +2 -1
- package/dist/semanticfed/hooks/useLineage.js +24 -23
- package/dist/semanticfed/hooks/useLineage.js.map +1 -1
- package/dist/semanticfed/hooks/useNlQuery.js +13 -10
- package/dist/semanticfed/hooks/useNlQuery.js.map +1 -1
- package/dist/semanticfed/hooks/useSqlConsole.d.ts +2 -1
- package/dist/semanticfed/hooks/useSqlConsole.js +28 -27
- package/dist/semanticfed/hooks/useSqlConsole.js.map +1 -1
- package/dist/semanticfed/pages/AgentsPage.js +119 -148
- package/dist/semanticfed/pages/AgentsPage.js.map +1 -1
- package/dist/semanticfed/pages/AuditPage.js +95 -76
- package/dist/semanticfed/pages/AuditPage.js.map +1 -1
- package/dist/semanticfed/pages/CollaborationPage.js +60 -64
- package/dist/semanticfed/pages/CollaborationPage.js.map +1 -1
- package/dist/semanticfed/pages/ConfigurationPage.js +86 -67
- package/dist/semanticfed/pages/ConfigurationPage.js.map +1 -1
- package/dist/semanticfed/pages/DashboardPage.js +1 -1
- package/dist/semanticfed/pages/DashboardPage.js.map +1 -1
- package/dist/semanticfed/pages/HelpPage.js +1 -1
- package/dist/semanticfed/pages/HelpPage.js.map +1 -1
- package/dist/semanticfed/pages/KnowledgeGraphPage.js +129 -128
- package/dist/semanticfed/pages/KnowledgeGraphPage.js.map +1 -1
- package/dist/semanticfed/pages/LineagePage.js +110 -424
- package/dist/semanticfed/pages/LineagePage.js.map +1 -1
- package/dist/semanticfed/pages/MonitoringPage.js +76 -76
- package/dist/semanticfed/pages/MonitoringPage.js.map +1 -1
- package/dist/semanticfed/pages/OntologyPage.js +71 -98
- package/dist/semanticfed/pages/OntologyPage.js.map +1 -1
- package/dist/semanticfed/pages/PerformancePage.js +2 -2
- package/dist/semanticfed/pages/PerformancePage.js.map +1 -1
- package/dist/semanticfed/pages/PoliciesPage.js +112 -141
- package/dist/semanticfed/pages/PoliciesPage.js.map +1 -1
- package/dist/semanticfed/pages/ProtocolPage.js +93 -94
- package/dist/semanticfed/pages/ProtocolPage.js.map +1 -1
- package/dist/semanticfed/pages/QueryConsolePage.js +160 -327
- package/dist/semanticfed/pages/QueryConsolePage.js.map +1 -1
- package/dist/semanticfed/pages/RegistryPage.js +94 -105
- package/dist/semanticfed/pages/RegistryPage.js.map +1 -1
- package/dist/semanticfed/pages/TechStackPage.js +1 -1
- package/dist/semanticfed/pages/TechStackPage.js.map +1 -1
- package/dist/semanticfed/pages/TopologyPage.js +68 -99
- package/dist/semanticfed/pages/TopologyPage.js.map +1 -1
- package/dist/semanticfed/pages/VisualizationPage.js +7 -7
- package/dist/semanticfed/pages/VisualizationPage.js.map +1 -1
- package/dist/semanticfed/translations/english.js +514 -0
- package/dist/semanticfed/translations/english.js.map +1 -0
- package/dist/semanticfed/translations/english.json.d.ts +513 -0
- package/dist/semanticfed/utils/contentKeys.d.ts +16 -0
- package/dist/semanticfed/utils/contentKeys.js +14 -0
- package/dist/semanticfed/utils/contentKeys.js.map +1 -0
- package/dist/semanticfed/utils/requestErrorI18n.d.ts +3 -0
- package/dist/semanticfed/utils/requestErrorI18n.js +15 -0
- package/dist/semanticfed/utils/requestErrorI18n.js.map +1 -0
- package/package.json +9 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Loader2 as e, Play as t } from "lucide-react";
|
|
2
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
|
+
import { Button as i, Card as a, CardContent as o, CardHeader as s, CardTitle as c } from "@burdenoff/fe-libs/ui";
|
|
4
|
+
// src/semanticfed/components/queryConsole/SqlEditorCard.tsx
|
|
5
|
+
var l = [
|
|
6
|
+
100,
|
|
7
|
+
1e3,
|
|
8
|
+
1e4
|
|
9
|
+
];
|
|
10
|
+
function u({ sql: u, onSqlChange: d, maxRows: f, onMaxRowsChange: p, canRun: m, running: h, onRun: g, tr: _ }) {
|
|
11
|
+
return /* @__PURE__ */ r(a, { children: [/* @__PURE__ */ n(s, {
|
|
12
|
+
className: "pb-3",
|
|
13
|
+
children: /* @__PURE__ */ r("div", {
|
|
14
|
+
className: "flex flex-wrap items-center justify-between gap-2",
|
|
15
|
+
children: [/* @__PURE__ */ n(c, {
|
|
16
|
+
className: "text-base",
|
|
17
|
+
children: _("semanticfed.queryConsole.editor.title", "Query Editor")
|
|
18
|
+
}), /* @__PURE__ */ r("div", {
|
|
19
|
+
className: "flex items-center gap-2",
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ n("label", {
|
|
22
|
+
className: "sr-only",
|
|
23
|
+
htmlFor: "sql-console-max-rows",
|
|
24
|
+
children: _("semanticfed.queryConsole.editor.maxRowsLabel", "Maximum rows")
|
|
25
|
+
}),
|
|
26
|
+
/* @__PURE__ */ n("select", {
|
|
27
|
+
id: "sql-console-max-rows",
|
|
28
|
+
className: "rounded border bg-background p-1 text-xs",
|
|
29
|
+
value: f,
|
|
30
|
+
onChange: (e) => p(Number(e.target.value)),
|
|
31
|
+
children: l.map((e) => /* @__PURE__ */ n("option", {
|
|
32
|
+
value: e,
|
|
33
|
+
children: _("semanticfed.queryConsole.editor.maxRowsOption", "Max {count} rows", { count: e.toLocaleString() })
|
|
34
|
+
}, e))
|
|
35
|
+
}),
|
|
36
|
+
/* @__PURE__ */ r(i, {
|
|
37
|
+
size: "sm",
|
|
38
|
+
onClick: g,
|
|
39
|
+
disabled: !m || h,
|
|
40
|
+
"data-testid": "sql-console-run",
|
|
41
|
+
children: [h ? /* @__PURE__ */ n(e, { className: "me-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ n(t, { className: "me-2 h-4 w-4" }), _("semanticfed.queryConsole.actions.execute", "Execute")]
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
})]
|
|
45
|
+
})
|
|
46
|
+
}), /* @__PURE__ */ r(o, { children: [/* @__PURE__ */ n("textarea", {
|
|
47
|
+
"aria-label": _("semanticfed.queryConsole.editor.ariaLabel", "SQL statement"),
|
|
48
|
+
"data-testid": "sql-console-editor",
|
|
49
|
+
className: "w-full rounded border bg-muted/30 p-4 font-mono text-sm leading-relaxed focus:outline-none focus:ring-2 focus:ring-primary",
|
|
50
|
+
rows: 8,
|
|
51
|
+
value: u,
|
|
52
|
+
onChange: (e) => d(e.target.value),
|
|
53
|
+
onKeyDown: (e) => {
|
|
54
|
+
(e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), g());
|
|
55
|
+
},
|
|
56
|
+
spellCheck: !1,
|
|
57
|
+
placeholder: "SELECT region, SUM(revenue) FROM orders GROUP BY region"
|
|
58
|
+
}), /* @__PURE__ */ r("div", {
|
|
59
|
+
className: "mt-2 flex flex-wrap items-center gap-4 text-xs text-muted-foreground",
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ n("span", { children: _("semanticfed.queryConsole.editor.shortcut", "Ctrl/Cmd + Enter to run") }),
|
|
62
|
+
/* @__PURE__ */ n("span", { children: _("semanticfed.queryConsole.editor.timeout", "Timeout: 30s") }),
|
|
63
|
+
/* @__PURE__ */ n("span", { children: _("semanticfed.queryConsole.editor.supported", "SELECT, JOIN … ON, WHERE … AND, GROUP BY, ORDER BY, LIMIT/OFFSET") })
|
|
64
|
+
]
|
|
65
|
+
})] })] });
|
|
66
|
+
}
|
|
67
|
+
export { u as SqlEditorCard };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=SqlEditorCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlEditorCard.js","names":["ROW_LIMIT_OPTIONS","SqlEditorCard","Card","CardHeader","CardTitle","tr","maxRows","onMaxRowsChange","n","Button","onRun","canRun","running","Loader2","Play","CardContent","sql","onSqlChange"],"sources":["../../../../src/semanticfed/components/queryConsole/SqlEditorCard.tsx"],"sourcesContent":["import { Button, Card, CardContent, CardHeader, CardTitle } from '@burdenoff/fe-libs/ui';\nimport { Loader2, Play } from 'lucide-react';\n\nimport type { useTr } from '../../hooks/useTr';\n\ntype Tr = ReturnType<typeof useTr>;\n\n/** Row caps offered in the console (the endpoint allows up to 10,000). */\nconst ROW_LIMIT_OPTIONS = [100, 1000, 10000] as const;\n\n/** The SQL editor with its row cap and Execute button (Ctrl/Cmd + Enter runs it too). */\nexport function SqlEditorCard({\n sql,\n onSqlChange,\n maxRows,\n onMaxRowsChange,\n canRun,\n running,\n onRun,\n tr,\n}: {\n sql: string;\n onSqlChange: (sql: string) => void;\n maxRows: number;\n onMaxRowsChange: (maxRows: number) => void;\n canRun: boolean;\n running: boolean;\n onRun: () => void;\n tr: Tr;\n}) {\n return (\n <Card>\n <CardHeader className=\"pb-3\">\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <CardTitle className=\"text-base\">\n {tr('semanticfed.queryConsole.editor.title', 'Query Editor')}\n </CardTitle>\n <div className=\"flex items-center gap-2\">\n <label className=\"sr-only\" htmlFor=\"sql-console-max-rows\">\n {tr('semanticfed.queryConsole.editor.maxRowsLabel', 'Maximum rows')}\n </label>\n <select\n id=\"sql-console-max-rows\"\n className=\"rounded border bg-background p-1 text-xs\"\n value={maxRows}\n onChange={(e) => onMaxRowsChange(Number(e.target.value))}\n >\n {ROW_LIMIT_OPTIONS.map((n) => (\n <option key={n} value={n}>\n {tr('semanticfed.queryConsole.editor.maxRowsOption', 'Max {count} rows', {\n count: n.toLocaleString(),\n })}\n </option>\n ))}\n </select>\n <Button\n size=\"sm\"\n onClick={onRun}\n disabled={!canRun || running}\n data-testid=\"sql-console-run\"\n >\n {running ? (\n <Loader2 className=\"me-2 h-4 w-4 animate-spin\" />\n ) : (\n <Play className=\"me-2 h-4 w-4\" />\n )}\n {tr('semanticfed.queryConsole.actions.execute', 'Execute')}\n </Button>\n </div>\n </div>\n </CardHeader>\n <CardContent>\n <textarea\n aria-label={tr('semanticfed.queryConsole.editor.ariaLabel', 'SQL statement')}\n data-testid=\"sql-console-editor\"\n className=\"w-full rounded border bg-muted/30 p-4 font-mono text-sm leading-relaxed focus:outline-none focus:ring-2 focus:ring-primary\"\n rows={8}\n value={sql}\n onChange={(e) => onSqlChange(e.target.value)}\n onKeyDown={(e) => {\n if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {\n e.preventDefault();\n onRun();\n }\n }}\n spellCheck={false}\n placeholder=\"SELECT region, SUM(revenue) FROM orders GROUP BY region\"\n />\n <div className=\"mt-2 flex flex-wrap items-center gap-4 text-xs text-muted-foreground\">\n <span>{tr('semanticfed.queryConsole.editor.shortcut', 'Ctrl/Cmd + Enter to run')}</span>\n <span>{tr('semanticfed.queryConsole.editor.timeout', 'Timeout: 30s')}</span>\n <span>\n {tr(\n 'semanticfed.queryConsole.editor.supported',\n 'SELECT, JOIN … ON, WHERE … AND, GROUP BY, ORDER BY, LIMIT/OFFSET'\n )}\n </span>\n </div>\n </CardContent>\n </Card>\n );\n}\n"],"mappings":";;;;AAQA,IAAMA,IAAoB;CAAC;CAAK;CAAM;AAAK;AAG3C,SAAgBC,EAAc,EAC5B,QACA,gBACA,YACA,oBACA,WACA,YACA,UACA,SAUC;CACD,OACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;EAAY,WAAU;EACpB,UAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACC,GAAD;IAAW,WAAU;IAClB,UAAAC,EAAG,yCAAyC,cAAc;GAClD,CAAA,GACX,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,kBAAC,SAAD;MAAO,WAAU;MAAU,SAAQ;MAChC,UAAAA,EAAG,gDAAgD,cAAc;KAC7D,CAAA;KACP,kBAAC,UAAD;MACE,IAAG;MACH,WAAU;MACV,OAAOC;MACP,WAAW,MAAMC,EAAgB,OAAO,EAAE,OAAO,KAAK,CAAC;MAEtD,UAAAP,EAAkB,KAAK,MACtB,kBAAC,UAAD;OAAgB,OAAOQ;OACpB,UAAAH,EAAG,iDAAiD,oBAAoB,EACvE,OAAOG,EAAE,eAAe,EAC1B,CAAC;MACK,GAJKA,CAIL,CACT;KACK,CAAA;KACR,kBAACC,GAAD;MACE,MAAK;MACL,SAASC;MACT,UAAU,CAACC,KAAUC;MACrB,eAAY;MAJd,UAAA,CAMGA,IACC,kBAACC,GAAD,EAAS,WAAU,4BAA6B,CAAA,IAEhD,kBAACC,GAAD,EAAM,WAAU,eAAgB,CAAA,GAEjCT,EAAG,4CAA4C,SAAS,CACnD;;IACL;GACF,CAAA,CAAA;;CACK,CAAA,GACZ,kBAACU,GAAD,EAAA,UAAA,CACE,kBAAC,YAAD;EACE,cAAYV,EAAG,6CAA6C,eAAe;EAC3E,eAAY;EACZ,WAAU;EACV,MAAM;EACN,OAAOW;EACP,WAAW,MAAMC,EAAY,EAAE,OAAO,KAAK;EAC3C,YAAY,MAAM;GAChB,CAAK,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,YACxC,EAAE,eAAe,GACjBP,EAAM;EAEV;EACA,YAAY;EACZ,aAAY;CACb,CAAA,GACD,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACE,kBAAC,QAAD,EAAA,UAAOL,EAAG,4CAA4C,yBAAyB,EAAQ,CAAA;GACvF,kBAAC,QAAD,EAAA,UAAOA,EAAG,2CAA2C,cAAc,EAAQ,CAAA;GAC3E,kBAAC,QAAD,EAAA,UACGA,EACC,6CACA,kEACF,EACI,CAAA;EACH;CACM,CAAA,CAAA,EAAA,CAAA,CACT,EAAA,CAAA;AAEV"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SemSqlResult } from '../../hooks/useSqlConsole';
|
|
2
|
+
import { useTr } from '../../hooks/useTr';
|
|
3
|
+
type Tr = ReturnType<typeof useTr>;
|
|
4
|
+
/**
|
|
5
|
+
* The rows of the last statement or answered question. A result is an
|
|
6
|
+
* immutable snapshot that is replaced as a whole, and its rows have no
|
|
7
|
+
* identity of their own (two rows may be identical), so a row is keyed by
|
|
8
|
+
* its position in the snapshot.
|
|
9
|
+
*/
|
|
10
|
+
export declare function SqlResultCard({ result, tr }: {
|
|
11
|
+
result: SemSqlResult;
|
|
12
|
+
tr: Tr;
|
|
13
|
+
}): import('react').JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { formatCell as e } from "../../utils/format.js";
|
|
2
|
+
import { AlertTriangle as t, CheckCircle2 as n, EyeOff as r } from "lucide-react";
|
|
3
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
|
+
import { Badge as o, Card as s, CardContent as c, CardHeader as l } from "@burdenoff/fe-libs/ui";
|
|
5
|
+
// src/semanticfed/components/queryConsole/SqlResultCard.tsx
|
|
6
|
+
function u({ result: u, tr: d }) {
|
|
7
|
+
return /* @__PURE__ */ a(s, {
|
|
8
|
+
"data-testid": "sql-console-result",
|
|
9
|
+
children: [/* @__PURE__ */ i(l, {
|
|
10
|
+
className: "pb-3",
|
|
11
|
+
children: /* @__PURE__ */ a("div", {
|
|
12
|
+
className: "flex flex-wrap items-center gap-3 text-sm",
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ i(n, { className: "h-4 w-4 text-primary" }),
|
|
15
|
+
/* @__PURE__ */ i("span", {
|
|
16
|
+
className: "font-medium",
|
|
17
|
+
"data-testid": "sql-console-row-count",
|
|
18
|
+
children: d("semanticfed.queryConsole.result.rows", "{count} rows", { count: u.rowCount.toLocaleString() })
|
|
19
|
+
}),
|
|
20
|
+
/* @__PURE__ */ a("span", {
|
|
21
|
+
className: "text-muted-foreground",
|
|
22
|
+
children: [Math.round(u.durationMs), "ms"]
|
|
23
|
+
}),
|
|
24
|
+
/* @__PURE__ */ i("span", {
|
|
25
|
+
className: "text-muted-foreground",
|
|
26
|
+
children: d("semanticfed.queryConsole.result.sources", "{count} sources", { count: u.sourcesTouched })
|
|
27
|
+
}),
|
|
28
|
+
u.truncated && /* @__PURE__ */ a(o, {
|
|
29
|
+
variant: "outline",
|
|
30
|
+
className: "gap-1",
|
|
31
|
+
children: [/* @__PURE__ */ i(t, { className: "h-3 w-3" }), d("semanticfed.queryConsole.result.truncated", "Truncated — more rows matched")]
|
|
32
|
+
})
|
|
33
|
+
]
|
|
34
|
+
})
|
|
35
|
+
}), /* @__PURE__ */ i(c, { children: /* @__PURE__ */ i("div", {
|
|
36
|
+
className: "max-h-[28rem] overflow-auto rounded border",
|
|
37
|
+
children: /* @__PURE__ */ a("table", {
|
|
38
|
+
className: "w-max min-w-full max-w-none table-auto text-start text-xs",
|
|
39
|
+
children: [/* @__PURE__ */ i("thead", {
|
|
40
|
+
className: "sticky top-0 bg-muted",
|
|
41
|
+
children: /* @__PURE__ */ i("tr", { children: u.columns.map((e) => /* @__PURE__ */ a("th", {
|
|
42
|
+
className: "whitespace-nowrap px-3 py-2 font-medium",
|
|
43
|
+
children: [/* @__PURE__ */ a("span", {
|
|
44
|
+
className: "inline-flex items-center gap-1",
|
|
45
|
+
children: [e.name, e.masked && /* @__PURE__ */ i(r, {
|
|
46
|
+
className: "h-3 w-3 text-muted-foreground",
|
|
47
|
+
"aria-label": d("semanticfed.queryConsole.result.masked", "Masked by policy ({mask})", { mask: e.mask ?? "" })
|
|
48
|
+
})]
|
|
49
|
+
}), /* @__PURE__ */ i("span", {
|
|
50
|
+
className: "block text-[10px] font-normal text-muted-foreground",
|
|
51
|
+
children: e.aggregation ?? e.dataType
|
|
52
|
+
})]
|
|
53
|
+
}, e.name)) })
|
|
54
|
+
}), /* @__PURE__ */ a("tbody", { children: [u.rows.map((t, n) => /* @__PURE__ */ i("tr", {
|
|
55
|
+
className: "border-t",
|
|
56
|
+
children: u.columns.map((n) => /* @__PURE__ */ i("td", {
|
|
57
|
+
className: "whitespace-nowrap px-3 py-1.5 font-mono",
|
|
58
|
+
children: e(t[n.name])
|
|
59
|
+
}, n.name))
|
|
60
|
+
}, n)), u.rows.length === 0 && /* @__PURE__ */ i("tr", { children: /* @__PURE__ */ i("td", {
|
|
61
|
+
colSpan: u.columns.length,
|
|
62
|
+
className: "px-3 py-4 text-center text-muted-foreground",
|
|
63
|
+
children: d("semanticfed.queryConsole.result.empty", "No rows matched")
|
|
64
|
+
}) })] })]
|
|
65
|
+
})
|
|
66
|
+
}) })]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export { u as SqlResultCard };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=SqlResultCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlResultCard.js","names":["SqlResultCard","Card","CardHeader","CheckCircle2","tr","result","Badge","AlertTriangle","CardContent","column","EyeOff","formatCell","row","index"],"sources":["../../../../src/semanticfed/components/queryConsole/SqlResultCard.tsx"],"sourcesContent":["import { Badge, Card, CardContent, CardHeader } from '@burdenoff/fe-libs/ui';\nimport { AlertTriangle, CheckCircle2, EyeOff } from 'lucide-react';\n\nimport type { SemSqlResult } from '../../hooks/useSqlConsole';\nimport type { useTr } from '../../hooks/useTr';\nimport { formatCell } from '../../utils/format';\n\ntype Tr = ReturnType<typeof useTr>;\n\n/**\n * The rows of the last statement or answered question. A result is an\n * immutable snapshot that is replaced as a whole, and its rows have no\n * identity of their own (two rows may be identical), so a row is keyed by\n * its position in the snapshot.\n */\nexport function SqlResultCard({ result, tr }: { result: SemSqlResult; tr: Tr }) {\n return (\n <Card data-testid=\"sql-console-result\">\n <CardHeader className=\"pb-3\">\n <div className=\"flex flex-wrap items-center gap-3 text-sm\">\n <CheckCircle2 className=\"h-4 w-4 text-primary\" />\n <span className=\"font-medium\" data-testid=\"sql-console-row-count\">\n {tr('semanticfed.queryConsole.result.rows', '{count} rows', {\n count: result.rowCount.toLocaleString(),\n })}\n </span>\n <span className=\"text-muted-foreground\">{Math.round(result.durationMs)}ms</span>\n <span className=\"text-muted-foreground\">\n {tr('semanticfed.queryConsole.result.sources', '{count} sources', {\n count: result.sourcesTouched,\n })}\n </span>\n {result.truncated && (\n <Badge variant=\"outline\" className=\"gap-1\">\n <AlertTriangle className=\"h-3 w-3\" />\n {tr('semanticfed.queryConsole.result.truncated', 'Truncated — more rows matched')}\n </Badge>\n )}\n </div>\n </CardHeader>\n <CardContent>\n <div className=\"max-h-[28rem] overflow-auto rounded border\">\n {/* The shell's base styles give tables a fixed layout capped at 100% width,\n which lets long values spill into the next column. Size the grid to its\n content instead and let the wrapper scroll sideways. */}\n <table className=\"w-max min-w-full max-w-none table-auto text-start text-xs\">\n <thead className=\"sticky top-0 bg-muted\">\n <tr>\n {result.columns.map((column) => (\n <th key={column.name} className=\"whitespace-nowrap px-3 py-2 font-medium\">\n <span className=\"inline-flex items-center gap-1\">\n {column.name}\n {column.masked && (\n <EyeOff\n className=\"h-3 w-3 text-muted-foreground\"\n aria-label={tr(\n 'semanticfed.queryConsole.result.masked',\n 'Masked by policy ({mask})',\n { mask: column.mask ?? '' }\n )}\n />\n )}\n </span>\n <span className=\"block text-[10px] font-normal text-muted-foreground\">\n {column.aggregation ?? column.dataType}\n </span>\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {result.rows.map((row, index) => (\n <tr key={index} className=\"border-t\">\n {result.columns.map((column) => (\n <td key={column.name} className=\"whitespace-nowrap px-3 py-1.5 font-mono\">\n {formatCell(row[column.name])}\n </td>\n ))}\n </tr>\n ))}\n {result.rows.length === 0 && (\n <tr>\n <td\n colSpan={result.columns.length}\n className=\"px-3 py-4 text-center text-muted-foreground\"\n >\n {tr('semanticfed.queryConsole.result.empty', 'No rows matched')}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n </CardContent>\n </Card>\n );\n}\n"],"mappings":";;;;;AAeA,SAAgBA,EAAc,EAAE,WAAQ,SAAwC;CAC9E,OACE,kBAACC,GAAD;EAAM,eAAY;EAAlB,UAAA,CACE,kBAACC,GAAD;GAAY,WAAU;GACpB,UAAA,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,kBAACC,GAAD,EAAc,WAAU,uBAAwB,CAAA;KAChD,kBAAC,QAAD;MAAM,WAAU;MAAc,eAAY;MACvC,UAAAC,EAAG,wCAAwC,gBAAgB,EAC1D,OAAOC,EAAO,SAAS,eAAe,EACxC,CAAC;KACG,CAAA;KACN,kBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CAAyC,KAAK,MAAMA,EAAO,UAAU,GAAE,IAAQ;;KAC/E,kBAAC,QAAD;MAAM,WAAU;MACb,UAAAD,EAAG,2CAA2C,mBAAmB,EAChE,OAAOC,EAAO,eAChB,CAAC;KACG,CAAA;KACLA,EAAO,aACN,kBAACC,GAAD;MAAO,SAAQ;MAAU,WAAU;MAAnC,UAAA,CACE,kBAACC,GAAD,EAAe,WAAU,UAAW,CAAA,GACnCH,EAAG,6CAA6C,+BAA+B,CAC3E;;IAEN;;EACK,CAAA,GACZ,kBAACI,GAAD,EAAA,UACE,kBAAC,OAAD;GAAK,WAAU;GAIb,UAAA,kBAAC,SAAD;IAAO,WAAU;IAAjB,UAAA,CACE,kBAAC,SAAD;KAAO,WAAU;KACf,UAAA,kBAAC,MAAD,EAAA,UACGH,EAAO,QAAQ,KAAK,MACnB,kBAAC,MAAD;MAAsB,WAAU;MAAhC,UAAA,CACE,kBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA,CACGI,EAAO,MACPA,EAAO,UACN,kBAACC,GAAD;QACE,WAAU;QACV,cAAYN,EACV,0CACA,6BACA,EAAE,MAAMK,EAAO,QAAQ,GAAG,CAC5B;OACD,CAAA,CAEC;MACN,CAAA,GAAA,kBAAC,QAAD;OAAM,WAAU;OACb,UAAAA,EAAO,eAAeA,EAAO;MAC1B,CAAA,CACJ;KAjBK,GAAAA,EAAO,IAiBZ,CACL,EACC,CAAA;IACC,CAAA,GACP,kBAAC,SAAD,EAAA,UAAA,CACGJ,EAAO,KAAK,KAAK,GAAK,MACrB,kBAAC,MAAD;KAAgB,WAAU;KACvB,UAAAA,EAAO,QAAQ,KAAK,MACnB,kBAAC,MAAD;MAAsB,WAAU;MAC7B,UAAAM,EAAWC,EAAIH,EAAO,KAAK;KAC1B,GAFKA,EAAO,IAEZ,CACL;IACC,GANKI,CAML,CACL,GACAR,EAAO,KAAK,WAAW,KACtB,kBAAC,MAAD,EAAA,UACE,kBAAC,MAAD;KACE,SAASA,EAAO,QAAQ;KACxB,WAAU;KAET,UAAAD,EAAG,yCAAyC,iBAAiB;IAC5D,CAAA,EACF,CAAA,CAED,EAAA,CAAA,CACF;;EACJ,CAAA,EACM,CAAA,CACT;;AAEV"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Session history entries kept on the page. */
|
|
2
|
+
export declare const HISTORY_LIMIT = 10;
|
|
3
|
+
/** One statement run from this page in the current session. */
|
|
4
|
+
export interface HistoryEntry {
|
|
5
|
+
id: number;
|
|
6
|
+
sql: string;
|
|
7
|
+
modelName: string;
|
|
8
|
+
ok: boolean;
|
|
9
|
+
rowCount: number;
|
|
10
|
+
durationMs: number;
|
|
11
|
+
message: string | null;
|
|
12
|
+
executedAt: string;
|
|
13
|
+
}
|
|
14
|
+
export type HistoryRecord = Omit<HistoryEntry, 'id' | 'executedAt'>;
|
|
15
|
+
/**
|
|
16
|
+
* The console's session history, newest first. Entry ids come from a
|
|
17
|
+
* per-page counter, so two statements finishing in the same millisecond
|
|
18
|
+
* still get distinct ids.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useConsoleHistory(): {
|
|
21
|
+
history: HistoryEntry[];
|
|
22
|
+
record: (entry: HistoryRecord) => void;
|
|
23
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useCallback as e, useRef as t, useState as n } from "react";
|
|
2
|
+
function r() {
|
|
3
|
+
let [r, i] = n([]), a = t(0);
|
|
4
|
+
return {
|
|
5
|
+
history: r,
|
|
6
|
+
record: e((e) => {
|
|
7
|
+
a.current += 1;
|
|
8
|
+
let t = a.current, n = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
9
|
+
i((r) => [{
|
|
10
|
+
...e,
|
|
11
|
+
id: t,
|
|
12
|
+
executedAt: n
|
|
13
|
+
}, ...r].slice(0, 10));
|
|
14
|
+
}, [])
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export { r as useConsoleHistory };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=consoleHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleHistory.js","names":["useConsoleHistory","history","setHistory","useState","nextId","useRef","useCallback","id","executedAt","entry","h"],"sources":["../../../../src/semanticfed/components/queryConsole/consoleHistory.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\n/** Session history entries kept on the page. */\nexport const HISTORY_LIMIT = 10;\n\n/** One statement run from this page in the current session. */\nexport interface HistoryEntry {\n id: number;\n sql: string;\n modelName: string;\n ok: boolean;\n rowCount: number;\n durationMs: number;\n message: string | null;\n executedAt: string;\n}\n\nexport type HistoryRecord = Omit<HistoryEntry, 'id' | 'executedAt'>;\n\n/**\n * The console's session history, newest first. Entry ids come from a\n * per-page counter, so two statements finishing in the same millisecond\n * still get distinct ids.\n */\nexport function useConsoleHistory() {\n const [history, setHistory] = useState<HistoryEntry[]>([]);\n const nextId = useRef(0);\n const record = useCallback((entry: HistoryRecord) => {\n nextId.current += 1;\n const id = nextId.current;\n const executedAt = new Date().toLocaleTimeString();\n setHistory((h) => [{ ...entry, id, executedAt }, ...h].slice(0, HISTORY_LIMIT));\n }, []);\n return { history, record };\n}\n"],"mappings":";AAwBA,SAAgBA,IAAoB;CAClC,IAAM,CAACC,GAASC,KAAcC,EAAyB,CAAC,CAAC,GACnDC,IAASC,EAAO,CAAC;CAOvB,OAAO;EAAE;EAAS,QANHC,GAAa,MAAyB;GACnD,EAAO,WAAW;GAClB,IAAMC,IAAKH,EAAO,SACZI,qBAAa,IAAI,KAAK,EAAA,CAAE,mBAAmB;GACjD,GAAY,MAAM,CAAC;IAAE,GAAGC;IAAO;IAAI;GAAW,GAAG,GAAGC,CAAC,CAAC,CAAC,MAAM,GAAA,EAAgB,CAAC;EAChF,GAAG,CAAC,CACc;CAAO;AAC3B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorTranslator } from '../utils/requestErrorI18n';
|
|
1
2
|
export type SemLineageNodeKind = 'CONNECTOR' | 'DATA_SOURCE' | 'TABLE' | 'ENTITY' | 'DIMENSION' | 'METRIC' | 'COLUMN' | 'MODEL' | 'QUERY';
|
|
2
3
|
export type SemLineageRootKind = Exclude<SemLineageNodeKind, 'TABLE' | 'COLUMN'>;
|
|
3
4
|
export type SemLineageEdgeKind = 'PROVIDES' | 'HOSTS' | 'MAPS_TO' | 'DEFINES' | 'MEMBER_OF' | 'JOINS' | 'SERVES' | 'READ_BY' | 'EXECUTED_ON';
|
|
@@ -42,4 +43,4 @@ export declare function useSemWorkspaceLineage(): import('@tanstack/react-query'
|
|
|
42
43
|
/** The upstream / downstream lineage of one record; idle until a root is chosen. */
|
|
43
44
|
export declare function useSemRecordLineage(root: SemLineageRoot | null, direction: SemLineageDirection, depth: number | null): import('@tanstack/react-query').UseQueryResult<SemLineageGraph, Error>;
|
|
44
45
|
/** The text to show for a failed lineage request, preferring the service's own explanation. */
|
|
45
|
-
export declare function lineageErrorMessage(error: unknown): string;
|
|
46
|
+
export declare function lineageErrorMessage(error: unknown, tr?: ErrorTranslator): string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { translateRequestError as e } from "../utils/requestErrorI18n.js";
|
|
2
|
+
import { SemRequestError as t, semRequest as n } from "../api/semanticfedGraphql.js";
|
|
3
|
+
import { useSemanticFed as r } from "../providers/SemanticFedProvider.js";
|
|
4
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
4
5
|
// src/semanticfed/hooks/useLineage.ts
|
|
5
|
-
var
|
|
6
|
+
var a = [
|
|
6
7
|
"CONNECTOR",
|
|
7
8
|
"DATA_SOURCE",
|
|
8
9
|
"ENTITY",
|
|
@@ -11,29 +12,29 @@ var i = [
|
|
|
11
12
|
"MODEL",
|
|
12
13
|
"QUERY"
|
|
13
14
|
];
|
|
14
|
-
function
|
|
15
|
-
return !e.refId || !
|
|
15
|
+
function o(e) {
|
|
16
|
+
return !e.refId || !a.includes(e.kind) ? null : {
|
|
16
17
|
kind: e.kind,
|
|
17
18
|
id: e.refId
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
var
|
|
21
|
-
function
|
|
22
|
-
let { apiGatewayUrl: e, workspaceId:
|
|
23
|
-
return
|
|
21
|
+
var s = "query SemLineage(\n $rootKind: SemLineageRootKind\n $rootId: ID\n $direction: SemLineageDirection\n $depth: Int\n) {\n semLineage(rootKind: $rootKind, rootId: $rootId, direction: $direction, depth: $depth) {\n rootId\n direction\n truncated\n nodes {\n id\n kind\n refId\n label\n detail\n status\n parentId\n }\n edges {\n id\n kind\n from\n to\n detail\n observedAt\n }\n warnings {\n nodeId\n message\n }\n }\n}";
|
|
22
|
+
function c() {
|
|
23
|
+
let { apiGatewayUrl: e, workspaceId: t } = r();
|
|
24
|
+
return i({
|
|
24
25
|
queryKey: [
|
|
25
26
|
"semanticfed",
|
|
26
27
|
"lineage",
|
|
27
|
-
|
|
28
|
+
t ?? "no-workspace",
|
|
28
29
|
"workspace"
|
|
29
30
|
],
|
|
30
|
-
enabled: !!
|
|
31
|
-
queryFn: async () => (await
|
|
31
|
+
enabled: !!t,
|
|
32
|
+
queryFn: async () => (await n(s, {}, e)).semLineage
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
-
let { apiGatewayUrl:
|
|
36
|
-
return
|
|
35
|
+
function l(e, t, a) {
|
|
36
|
+
let { apiGatewayUrl: o, workspaceId: c } = r();
|
|
37
|
+
return i({
|
|
37
38
|
queryKey: [
|
|
38
39
|
"semanticfed",
|
|
39
40
|
"lineage",
|
|
@@ -41,21 +42,21 @@ function c(e, i, a) {
|
|
|
41
42
|
"record",
|
|
42
43
|
e?.kind ?? null,
|
|
43
44
|
e?.id ?? null,
|
|
44
|
-
|
|
45
|
+
t,
|
|
45
46
|
a
|
|
46
47
|
],
|
|
47
48
|
enabled: !!(c && e),
|
|
48
|
-
queryFn: async () => (await
|
|
49
|
+
queryFn: async () => (await n(s, {
|
|
49
50
|
rootKind: e?.kind,
|
|
50
51
|
rootId: e?.id,
|
|
51
|
-
direction:
|
|
52
|
+
direction: t,
|
|
52
53
|
depth: a
|
|
53
|
-
},
|
|
54
|
+
}, o)).semLineage
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
57
|
+
function u(n, r) {
|
|
58
|
+
return n instanceof t && n.detail && n.code !== "INTERNAL_SERVER_ERROR" ? e(n.detail, r) : e(n instanceof Error ? n.message : String(n), r);
|
|
58
59
|
}
|
|
59
|
-
export {
|
|
60
|
+
export { u as lineageErrorMessage, o as lineageRootFor, l as useSemRecordLineage, c as useSemWorkspaceLineage };
|
|
60
61
|
|
|
61
62
|
//# sourceMappingURL=useLineage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLineage.js","names":["ROOT_KINDS","lineageRootFor","node","LINEAGE_QUERY","useSemWorkspaceLineage","useSemanticFed","useQuery","workspaceId","semRequest","apiGatewayUrl","useSemRecordLineage","root","direction","depth","lineageErrorMessage","error","SemRequestError"],"sources":["../../../src/semanticfed/hooks/useLineage.ts"],"sourcesContent":["/**\n * Lineage hooks, wired to the `wspace-semanticfed-svc` lineage API\n * (BOFF-4279). `semLineage` computes end-to-end lineage on read from the\n * semantic layer: connector → data source → physical table → entity →\n * dimension / metric → saved query, plus model membership and the data\n * sources each query's latest successful run actually read.\n */\nimport { useQuery } from '@tanstack/react-query';\n\nimport { SemRequestError, semRequest } from '../api/semanticfedGraphql';\nimport { useSemanticFed } from '../providers/SemanticFedProvider';\n\nexport type SemLineageNodeKind =\n | 'CONNECTOR'\n | 'DATA_SOURCE'\n | 'TABLE'\n | 'ENTITY'\n | 'DIMENSION'\n | 'METRIC'\n | 'COLUMN'\n | 'MODEL'\n | 'QUERY';\n\nexport type SemLineageRootKind = Exclude<SemLineageNodeKind, 'TABLE' | 'COLUMN'>;\n\nexport type SemLineageEdgeKind =\n | 'PROVIDES'\n | 'HOSTS'\n | 'MAPS_TO'\n | 'DEFINES'\n | 'MEMBER_OF'\n | 'JOINS'\n | 'SERVES'\n | 'READ_BY'\n | 'EXECUTED_ON';\n\nexport type SemLineageDirection = 'UPSTREAM' | 'DOWNSTREAM' | 'BOTH';\n\nexport interface SemLineageNode {\n id: string;\n kind: SemLineageNodeKind;\n refId: string | null;\n label: string;\n detail: string | null;\n status: string | null;\n parentId: string | null;\n}\n\nexport interface SemLineageEdge {\n id: string;\n kind: SemLineageEdgeKind;\n from: string;\n to: string;\n detail: string | null;\n observedAt: string | null;\n}\n\nexport interface SemLineageWarning {\n nodeId: string | null;\n message: string;\n}\n\nexport interface SemLineageGraph {\n rootId: string | null;\n direction: SemLineageDirection;\n nodes: SemLineageNode[];\n edges: SemLineageEdge[];\n warnings: SemLineageWarning[];\n truncated: boolean;\n}\n\nexport interface SemLineageRoot {\n kind: SemLineageRootKind;\n id: string;\n}\n\nconst ROOT_KINDS: readonly SemLineageNodeKind[] = [\n 'CONNECTOR',\n 'DATA_SOURCE',\n 'ENTITY',\n 'DIMENSION',\n 'METRIC',\n 'MODEL',\n 'QUERY',\n];\n\n/** The traversal root for a node, or null for node kinds the API cannot start from. */\nexport function lineageRootFor(node: SemLineageNode): SemLineageRoot | null {\n if (!node.refId || !ROOT_KINDS.includes(node.kind)) return null;\n return { kind: node.kind as SemLineageRootKind, id: node.refId };\n}\n\nconst LINEAGE_QUERY = `query SemLineage(\n $rootKind: SemLineageRootKind\n $rootId: ID\n $direction: SemLineageDirection\n $depth: Int\n) {\n semLineage(rootKind: $rootKind, rootId: $rootId, direction: $direction, depth: $depth) {\n rootId\n direction\n truncated\n nodes {\n id\n kind\n refId\n label\n detail\n status\n parentId\n }\n edges {\n id\n kind\n from\n to\n detail\n observedAt\n }\n warnings {\n nodeId\n message\n }\n }\n}`;\n\n/** The whole-workspace lineage graph. */\nexport function useSemWorkspaceLineage() {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: ['semanticfed', 'lineage', workspaceId ?? 'no-workspace', 'workspace'] as const,\n enabled: Boolean(workspaceId),\n queryFn: async () => {\n const data = await semRequest<{ semLineage: SemLineageGraph }>(\n LINEAGE_QUERY,\n {},\n apiGatewayUrl\n );\n return data.semLineage;\n },\n });\n}\n\n/** The upstream / downstream lineage of one record; idle until a root is chosen. */\nexport function useSemRecordLineage(\n root: SemLineageRoot | null,\n direction: SemLineageDirection,\n depth: number | null\n) {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: [\n 'semanticfed',\n 'lineage',\n workspaceId ?? 'no-workspace',\n 'record',\n root?.kind ?? null,\n root?.id ?? null,\n direction,\n depth,\n ] as const,\n enabled: Boolean(workspaceId && root),\n queryFn: async () => {\n const data = await semRequest<{ semLineage: SemLineageGraph }>(\n LINEAGE_QUERY,\n { rootKind: root?.kind, rootId: root?.id, direction, depth },\n apiGatewayUrl\n );\n return data.semLineage;\n },\n });\n}\n\n/** The text to show for a failed lineage request, preferring the service's own explanation. */\nexport function lineageErrorMessage(error: unknown): string {\n if (error instanceof SemRequestError && error.detail && error.code !== 'INTERNAL_SERVER_ERROR') {\n return error.detail;\n }\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLineage.js","names":["ROOT_KINDS","lineageRootFor","node","LINEAGE_QUERY","useSemWorkspaceLineage","useSemanticFed","useQuery","workspaceId","semRequest","apiGatewayUrl","useSemRecordLineage","root","direction","depth","lineageErrorMessage","error","SemRequestError","translateRequestError","tr"],"sources":["../../../src/semanticfed/hooks/useLineage.ts"],"sourcesContent":["import { translateRequestError, type ErrorTranslator } from '../utils/requestErrorI18n';\n/**\n * Lineage hooks, wired to the `wspace-semanticfed-svc` lineage API\n * (BOFF-4279). `semLineage` computes end-to-end lineage on read from the\n * semantic layer: connector → data source → physical table → entity →\n * dimension / metric → saved query, plus model membership and the data\n * sources each query's latest successful run actually read.\n */\nimport { useQuery } from '@tanstack/react-query';\n\nimport { SemRequestError, semRequest } from '../api/semanticfedGraphql';\nimport { useSemanticFed } from '../providers/SemanticFedProvider';\n\nexport type SemLineageNodeKind =\n | 'CONNECTOR'\n | 'DATA_SOURCE'\n | 'TABLE'\n | 'ENTITY'\n | 'DIMENSION'\n | 'METRIC'\n | 'COLUMN'\n | 'MODEL'\n | 'QUERY';\n\nexport type SemLineageRootKind = Exclude<SemLineageNodeKind, 'TABLE' | 'COLUMN'>;\n\nexport type SemLineageEdgeKind =\n | 'PROVIDES'\n | 'HOSTS'\n | 'MAPS_TO'\n | 'DEFINES'\n | 'MEMBER_OF'\n | 'JOINS'\n | 'SERVES'\n | 'READ_BY'\n | 'EXECUTED_ON';\n\nexport type SemLineageDirection = 'UPSTREAM' | 'DOWNSTREAM' | 'BOTH';\n\nexport interface SemLineageNode {\n id: string;\n kind: SemLineageNodeKind;\n refId: string | null;\n label: string;\n detail: string | null;\n status: string | null;\n parentId: string | null;\n}\n\nexport interface SemLineageEdge {\n id: string;\n kind: SemLineageEdgeKind;\n from: string;\n to: string;\n detail: string | null;\n observedAt: string | null;\n}\n\nexport interface SemLineageWarning {\n nodeId: string | null;\n message: string;\n}\n\nexport interface SemLineageGraph {\n rootId: string | null;\n direction: SemLineageDirection;\n nodes: SemLineageNode[];\n edges: SemLineageEdge[];\n warnings: SemLineageWarning[];\n truncated: boolean;\n}\n\nexport interface SemLineageRoot {\n kind: SemLineageRootKind;\n id: string;\n}\n\nconst ROOT_KINDS: readonly SemLineageNodeKind[] = [\n 'CONNECTOR',\n 'DATA_SOURCE',\n 'ENTITY',\n 'DIMENSION',\n 'METRIC',\n 'MODEL',\n 'QUERY',\n];\n\n/** The traversal root for a node, or null for node kinds the API cannot start from. */\nexport function lineageRootFor(node: SemLineageNode): SemLineageRoot | null {\n if (!node.refId || !ROOT_KINDS.includes(node.kind)) return null;\n return { kind: node.kind as SemLineageRootKind, id: node.refId };\n}\n\nconst LINEAGE_QUERY = `query SemLineage(\n $rootKind: SemLineageRootKind\n $rootId: ID\n $direction: SemLineageDirection\n $depth: Int\n) {\n semLineage(rootKind: $rootKind, rootId: $rootId, direction: $direction, depth: $depth) {\n rootId\n direction\n truncated\n nodes {\n id\n kind\n refId\n label\n detail\n status\n parentId\n }\n edges {\n id\n kind\n from\n to\n detail\n observedAt\n }\n warnings {\n nodeId\n message\n }\n }\n}`;\n\n/** The whole-workspace lineage graph. */\nexport function useSemWorkspaceLineage() {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: ['semanticfed', 'lineage', workspaceId ?? 'no-workspace', 'workspace'] as const,\n enabled: Boolean(workspaceId),\n queryFn: async () => {\n const data = await semRequest<{ semLineage: SemLineageGraph }>(\n LINEAGE_QUERY,\n {},\n apiGatewayUrl\n );\n return data.semLineage;\n },\n });\n}\n\n/** The upstream / downstream lineage of one record; idle until a root is chosen. */\nexport function useSemRecordLineage(\n root: SemLineageRoot | null,\n direction: SemLineageDirection,\n depth: number | null\n) {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: [\n 'semanticfed',\n 'lineage',\n workspaceId ?? 'no-workspace',\n 'record',\n root?.kind ?? null,\n root?.id ?? null,\n direction,\n depth,\n ] as const,\n enabled: Boolean(workspaceId && root),\n queryFn: async () => {\n const data = await semRequest<{ semLineage: SemLineageGraph }>(\n LINEAGE_QUERY,\n { rootKind: root?.kind, rootId: root?.id, direction, depth },\n apiGatewayUrl\n );\n return data.semLineage;\n },\n });\n}\n\n/** The text to show for a failed lineage request, preferring the service's own explanation. */\nexport function lineageErrorMessage(error: unknown, tr?: ErrorTranslator): string {\n if (error instanceof SemRequestError && error.detail && error.code !== 'INTERNAL_SERVER_ERROR') {\n return translateRequestError(error.detail, tr);\n }\n return translateRequestError(error instanceof Error ? error.message : String(error), tr);\n}\n"],"mappings":";;;;;AA6EA,IAAMA,IAA4C;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,SAAgBC,EAAe,GAA6C;CAE1E,OADI,CAACC,EAAK,SAAS,CAACF,EAAW,SAASE,EAAK,IAAI,IAAU,OACpD;EAAE,MAAMA,EAAK;EAA4B,IAAIA,EAAK;CAAM;AACjE;AAEA,IAAMC,IAAgB;AAmCtB,SAAgBC,IAAyB;CACvC,IAAM,EAAE,kBAAe,mBAAgBC,EAAe;CACtD,OAAOC,EAAS;EACd,UAAU;GAAC;GAAe;GAAWC,KAAe;GAAgB;EAAW;EAC/E,SAAS,EAAQA;EACjB,SAAS,aAMA,MALYC,EACjBL,GACA,CAAC,GACDM,CACF,EAAA,CACY;CAEhB,CAAC;AACH;AAGA,SAAgBC,EACd,GACA,GACA,GACA;CACA,IAAM,EAAE,kBAAe,mBAAgBL,EAAe;CACtD,OAAOC,EAAS;EACd,UAAU;GACR;GACA;GACAC,KAAe;GACf;GACAI,GAAM,QAAQ;GACdA,GAAM,MAAM;GACZC;GACAC;EACF;EACA,SAAS,GAAQN,KAAeI;EAChC,SAAS,aAMA,MALYH,EACjBL,GACA;GAAE,UAAUQ,GAAM;GAAM,QAAQA,GAAM;GAAI;GAAW;EAAM,GAC3DF,CACF,EAAA,CACY;CAEhB,CAAC;AACH;AAGA,SAAgBK,EAAoB,GAAgB,GAA8B;CAIhF,OAHIC,aAAiBC,KAAmBD,EAAM,UAAUA,EAAM,SAAS,0BAC9DE,EAAsBF,EAAM,QAAQG,CAAE,IAExCD,EAAsBF,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK,GAAGG,CAAE;AACzF"}
|
|
@@ -86,16 +86,19 @@ function _(n, i) {
|
|
|
86
86
|
i.join(",")
|
|
87
87
|
],
|
|
88
88
|
enabled: !!o && n,
|
|
89
|
-
queryFn: async () =>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
89
|
+
queryFn: async () => {
|
|
90
|
+
let t = await e(l, {
|
|
91
|
+
filter: { status: "ACTIVE" },
|
|
92
|
+
pagination: { limit: 100 }
|
|
93
|
+
}, a), n = new Set(i);
|
|
94
|
+
return t.getConnections.items.filter((e) => e.provider && n.has(e.provider.key)).map((e) => ({
|
|
95
|
+
id: e.id,
|
|
96
|
+
name: e.name,
|
|
97
|
+
status: e.status,
|
|
98
|
+
providerKey: e.provider?.key ?? "",
|
|
99
|
+
providerName: e.provider?.name ?? ""
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
104
|
export { _ as useSemAiConnections, p as useSemAskQuestion, h as useSemNlSettings, f as useSemNlSuggestions, g as useSemUpdateNlSettings };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNlQuery.js","names":["TRANSLATION_FIELDS","SETTINGS_FIELDS","NL_SETTINGS_QUERY","UPDATE_NL_SETTINGS_MUTATION","AI_CONNECTIONS_QUERY","SUGGESTIONS_QUERY","ASK_QUESTION_MUTATION","useSemNlSuggestions","useSemanticFed","useQuery","workspaceId","modelId","semRequest","apiGatewayUrl","useSemAskQuestion","useMutation","nlSettingsKey","useSemNlSettings","useSemUpdateNlSettings","queryClient","useQueryClient","settings","useSemAiConnections","supportedProviders","enabled","c"],"sources":["../../../src/semanticfed/hooks/useNlQuery.ts"],"sourcesContent":["/**\n * Natural-language question hooks (BOFF-4276), wired to the\n * `wspace-semanticfed-svc` NL module:\n *\n * - `semTranslateQuestion` translates a question into SQL over the model's\n * governed entities, dimensions and metrics without running it. Asked with\n * an empty question it returns only the example questions the model can\n * answer, which the console offers as starting points.\n * - `semAskQuestion` translates the question and runs the generated SQL\n * through the SQL endpoint with the caller's access policies applied. It is\n * metered as one query run.\n * - Follow-ups (BOFF-10533): the earlier questions of the conversation are\n * sent as `history`, so \"and by status?\" or \"only EU\" refine the previous\n * interpretation.\n * - LLM-assisted phrasing (BOFF-10533): `semNlSettings` /\n * `semUpdateNlSettings` turn on rewording by the workspace's own AI\n * provider (an OpenAI or Anthropic connection from Integrations).\n */\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport { semRequest } from '../api/semanticfedGraphql';\nimport { useSemanticFed } from '../providers/SemanticFedProvider';\nimport type { SemSqlResult } from './useSqlConsole';\n\nexport type SemNlStatus = 'TRANSLATED' | 'NEEDS_CLARIFICATION';\n\nexport type SemNlClarificationReason =\n | 'EMPTY_QUESTION'\n | 'TOO_LONG'\n | 'NO_MATCH'\n | 'NO_JOIN_PATH'\n | 'UNSUPPORTED_AGGREGATION'\n | 'INVALID_FILTER'\n | 'LOW_CONFIDENCE'\n | 'INVALID_QUERY'\n | 'UNPLACED_VALUE';\n\nexport type SemNlAssistStatus =\n | 'NOT_NEEDED'\n | 'SKIPPED'\n | 'DISABLED'\n | 'NOT_CONFIGURED'\n | 'QUOTA_EXHAUSTED'\n | 'QUOTA_UNAVAILABLE'\n | 'PROVIDER_ERROR'\n | 'NO_IMPROVEMENT'\n | 'REPHRASED';\n\nexport type SemNlStepKind =\n 'ENTITY' | 'JOIN' | 'COLUMN' | 'MEASURE' | 'GROUP_BY' | 'FILTER' | 'ORDER' | 'LIMIT';\n\nexport interface SemNlStep {\n kind: SemNlStepKind;\n entity: string | null;\n field: string | null;\n aggregation: string | null;\n governed: boolean;\n operator: string | null;\n value: unknown;\n direction: string | null;\n count: number | null;\n relationship: string | null;\n}\n\nexport interface SemNlTranslation {\n modelId: string;\n modelName: string;\n question: string;\n status: SemNlStatus;\n sql: string | null;\n confidence: number;\n steps: SemNlStep[];\n unmatchedTerms: string[];\n clarificationReason: SemNlClarificationReason | null;\n clarification: string | null;\n suggestions: string[];\n engine: string;\n followUp: boolean;\n assist: SemNlAssistStatus;\n rephrasedQuestion: string | null;\n assistProvider: string | null;\n}\n\nexport interface SemNlAnswer {\n translation: SemNlTranslation;\n result: SemSqlResult | null;\n}\n\nexport interface SemNlQuestionInput {\n question: string;\n modelId: string;\n maxRows?: number;\n /** Earlier questions of the conversation, oldest first. */\n history?: string[];\n}\n\nexport interface SemNlSettings {\n llmAssistEnabled: boolean;\n aiConnectionId: string | null;\n aiProviderKey: string | null;\n aiModel: string | null;\n defaultAiModel: string | null;\n supportedProviders: string[];\n updatedAt: string | null;\n updatedBy: string | null;\n}\n\nexport interface SemUpdateNlSettingsInput {\n llmAssistEnabled: boolean;\n aiConnectionId: string | null;\n aiModel: string | null;\n}\n\n/** An integration connection that can hold the workspace's AI provider key. */\nexport interface SemAiConnection {\n id: string;\n name: string;\n status: string;\n providerKey: string;\n providerName: string;\n}\n\nconst TRANSLATION_FIELDS = `\n modelId\n modelName\n question\n status\n sql\n confidence\n steps {\n kind\n entity\n field\n aggregation\n governed\n operator\n value\n direction\n count\n relationship\n }\n unmatchedTerms\n clarificationReason\n clarification\n suggestions\n engine\n followUp\n assist\n rephrasedQuestion\n assistProvider`;\n\nconst SETTINGS_FIELDS = `\n llmAssistEnabled\n aiConnectionId\n aiProviderKey\n aiModel\n defaultAiModel\n supportedProviders\n updatedAt\n updatedBy`;\n\nconst NL_SETTINGS_QUERY = `query SemNlSettings {\n semNlSettings {${SETTINGS_FIELDS}\n }\n}`;\n\nconst UPDATE_NL_SETTINGS_MUTATION = `mutation SemUpdateNlSettings($input: SemUpdateNlSettingsInput!) {\n semUpdateNlSettings(input: $input) {${SETTINGS_FIELDS}\n }\n}`;\n\nconst AI_CONNECTIONS_QUERY = `query SemAiConnections($filter: ConnectionFilterInput, $pagination: IntegrationsPaginationInput) {\n getConnections(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n status\n provider {\n key\n name\n }\n }\n }\n}`;\n\nconst SUGGESTIONS_QUERY = `query SemNlSuggestions($input: SemNlQuestionInput!) {\n semTranslateQuestion(input: $input) {\n modelId\n suggestions\n }\n}`;\n\nconst ASK_QUESTION_MUTATION = `mutation SemAskQuestion($input: SemNlQuestionInput!) {\n semAskQuestion(input: $input) {\n translation {${TRANSLATION_FIELDS}\n }\n result {\n modelId\n columns {\n name\n entity\n field\n aggregation\n dataType\n masked\n mask\n }\n rows\n rowCount\n truncated\n durationMs\n sourcesTouched\n }\n }\n}`;\n\n/** Example questions the model can answer (translation only: reads no data, not metered). */\nexport function useSemNlSuggestions(modelId: string | null) {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: ['semanticfed', 'nl', 'suggestions', workspaceId ?? 'no-workspace', modelId] as const,\n enabled: Boolean(workspaceId && modelId),\n queryFn: async () => {\n const data = await semRequest<{\n semTranslateQuestion: Pick<SemNlTranslation, 'modelId' | 'suggestions'>;\n }>(SUGGESTIONS_QUERY, { input: { question: '', modelId } }, apiGatewayUrl);\n return data.semTranslateQuestion.suggestions;\n },\n });\n}\n\n/** Translate a question and run it with the caller's access policies (one metered query run). */\nexport function useSemAskQuestion() {\n const { apiGatewayUrl } = useSemanticFed();\n return useMutation({\n mutationFn: async (input: SemNlQuestionInput) => {\n const data = await semRequest<{ semAskQuestion: SemNlAnswer }>(\n ASK_QUESTION_MUTATION,\n { input },\n apiGatewayUrl\n );\n return data.semAskQuestion;\n },\n });\n}\n\nconst nlSettingsKey = (workspaceId: string | null | undefined) =>\n ['semanticfed', 'nl', 'settings', workspaceId ?? 'no-workspace'] as const;\n\n/** The workspace's natural-language settings (LLM-assisted phrasing is off until enabled). */\nexport function useSemNlSettings() {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: nlSettingsKey(workspaceId),\n enabled: Boolean(workspaceId),\n queryFn: async () => {\n const data = await semRequest<{ semNlSettings: SemNlSettings }>(\n NL_SETTINGS_QUERY,\n {},\n apiGatewayUrl\n );\n return data.semNlSettings;\n },\n });\n}\n\n/** Save the workspace's natural-language settings (governance permission). */\nexport function useSemUpdateNlSettings() {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: SemUpdateNlSettingsInput) => {\n const data = await semRequest<{ semUpdateNlSettings: SemNlSettings }>(\n UPDATE_NL_SETTINGS_MUTATION,\n { input },\n apiGatewayUrl\n );\n return data.semUpdateNlSettings;\n },\n onSuccess: (settings) => {\n queryClient.setQueryData(nlSettingsKey(workspaceId), settings);\n },\n });\n}\n\ninterface ConnectionsData {\n getConnections: {\n items: Array<{\n id: string;\n name: string;\n status: string;\n provider: { key: string; name: string } | null;\n }>;\n };\n}\n\n/** Active integration connections to a supported AI provider (OpenAI, Anthropic). */\nexport function useSemAiConnections(enabled: boolean, supportedProviders: string[]) {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: [\n 'semanticfed',\n 'nl',\n 'ai-connections',\n workspaceId ?? 'no-workspace',\n supportedProviders.join(','),\n ] as const,\n enabled: Boolean(workspaceId) && enabled,\n queryFn: async (): Promise<SemAiConnection[]> => {\n const data = await semRequest<ConnectionsData>(\n AI_CONNECTIONS_QUERY,\n { filter: { status: 'ACTIVE' }, pagination: { limit: 100 } },\n apiGatewayUrl\n );\n return data.getConnections.items\n .filter((c) => c.provider && supportedProviders.includes(c.provider.key))\n .map((c) => ({\n id: c.id,\n name: c.name,\n status: c.status,\n providerKey: c.provider?.key ?? '',\n providerName: c.provider?.name ?? '',\n }));\n },\n });\n}\n"],"mappings":";;;;AA0HA,IAAMA,IAAqB,kaA6BrBC,IAAkB,wJAUlBC,IAAoB;mBACPD,EAAgB;;IAI7BE,IAA8B;wCACIF,EAAgB;;IAIlDG,IAAuB,0RAcvBC,IAAoB,wIAOpBC,IAAwB;;mBAEXN,EAAmB;;;;;;;;;;;;;;;;;;;;;AAuBtC,SAAgBO,EAAoB,GAAwB;CAC1D,IAAM,EAAE,kBAAe,mBAAgBC,EAAe;CACtD,OAAOC,EAAS;EACd,UAAU;GAAC;GAAe;GAAM;GAAeC,KAAe;GAAgBC;EAAO;EACrF,SAAS,GAAQD,KAAeC;EAChC,SAAS,aAIA,MAHYC,EAEhBP,GAAmB,EAAE,OAAO;GAAE,UAAU;GAAI;EAAQ,EAAE,GAAGQ,CAAa,EAAA,CAC7D,qBAAqB;CAErC,CAAC;AACH;AAGA,SAAgBC,IAAoB;CAClC,IAAM,EAAE,qBAAkBN,EAAe;CACzC,OAAOO,EAAY,EACjB,YAAY,OAAO,OAMV,MALYH,EACjBN,GACA,EAAE,SAAM,GACRO,CACF,EAAA,CACY,eAEhB,CAAC;AACH;AAEA,IAAMG,KAAiB,MACrB;CAAC;CAAe;CAAM;CAAYN,KAAe;AAAc;AAGjE,SAAgBO,IAAmB;CACjC,IAAM,EAAE,kBAAe,mBAAgBT,EAAe;CACtD,OAAOC,EAAS;EACd,UAAUO,EAAcN,CAAW;EACnC,SAAS,EAAQA;EACjB,SAAS,aAMA,MALYE,EACjBV,GACA,CAAC,GACDW,CACF,EAAA,CACY;CAEhB,CAAC;AACH;AAGA,SAAgBK,IAAyB;CACvC,IAAM,EAAE,kBAAe,mBAAgBV,EAAe,GAChDW,IAAcC,EAAe;CACnC,OAAOL,EAAY;EACjB,YAAY,OAAO,OAMV,MALYH,EACjBT,GACA,EAAE,SAAM,GACRU,CACF,EAAA,CACY;EAEd,YAAY,MAAa;GACvB,EAAY,aAAaG,EAAcN,CAAW,GAAGW,CAAQ;EAC/D;CACF,CAAC;AACH;AAcA,SAAgBC,EAAoB,GAAkB,GAA8B;CAClF,IAAM,EAAE,kBAAe,mBAAgBd,EAAe;CACtD,OAAOC,EAAS;EACd,UAAU;GACR;GACA;GACA;GACAC,KAAe;GACfa,EAAmB,KAAK,GAAG;EAC7B;EACA,SAAS,EAAQb,KAAgBc;EACjC,SAAS,aAMA,MALYZ,EACjBR,GACA;GAAE,QAAQ,EAAE,QAAQ,SAAS;GAAG,YAAY,EAAE,OAAO,IAAI;EAAE,GAC3DS,CACF,EAAA,CACY,eAAe,MACxB,QAAQ,MAAMY,EAAE,YAAYF,EAAmB,SAASE,EAAE,SAAS,GAAG,CAAC,CAAC,CACxE,KAAK,OAAO;GACX,IAAIA,EAAE;GACN,MAAMA,EAAE;GACR,QAAQA,EAAE;GACV,aAAaA,EAAE,UAAU,OAAO;GAChC,cAAcA,EAAE,UAAU,QAAQ;EACpC,EAAE;CAER,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"useNlQuery.js","names":["TRANSLATION_FIELDS","SETTINGS_FIELDS","NL_SETTINGS_QUERY","UPDATE_NL_SETTINGS_MUTATION","AI_CONNECTIONS_QUERY","SUGGESTIONS_QUERY","ASK_QUESTION_MUTATION","useSemNlSuggestions","useSemanticFed","useQuery","workspaceId","modelId","semRequest","apiGatewayUrl","useSemAskQuestion","useMutation","nlSettingsKey","useSemNlSettings","useSemUpdateNlSettings","queryClient","useQueryClient","settings","useSemAiConnections","supportedProviders","enabled","data","supported","c"],"sources":["../../../src/semanticfed/hooks/useNlQuery.ts"],"sourcesContent":["/**\n * Natural-language question hooks (BOFF-4276), wired to the\n * `wspace-semanticfed-svc` NL module:\n *\n * - `semTranslateQuestion` translates a question into SQL over the model's\n * governed entities, dimensions and metrics without running it. Asked with\n * an empty question it returns only the example questions the model can\n * answer, which the console offers as starting points.\n * - `semAskQuestion` translates the question and runs the generated SQL\n * through the SQL endpoint with the caller's access policies applied. It is\n * metered as one query run.\n * - Follow-ups (BOFF-10533): the earlier questions of the conversation are\n * sent as `history`, so \"and by status?\" or \"only EU\" refine the previous\n * interpretation.\n * - LLM-assisted phrasing (BOFF-10533): `semNlSettings` /\n * `semUpdateNlSettings` turn on rewording by the workspace's own AI\n * provider (an OpenAI or Anthropic connection from Integrations).\n */\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport { semRequest } from '../api/semanticfedGraphql';\nimport { useSemanticFed } from '../providers/SemanticFedProvider';\nimport type { SemSqlResult } from './useSqlConsole';\n\nexport type SemNlStatus = 'TRANSLATED' | 'NEEDS_CLARIFICATION';\n\nexport type SemNlClarificationReason =\n | 'EMPTY_QUESTION'\n | 'TOO_LONG'\n | 'NO_MATCH'\n | 'NO_JOIN_PATH'\n | 'UNSUPPORTED_AGGREGATION'\n | 'INVALID_FILTER'\n | 'LOW_CONFIDENCE'\n | 'INVALID_QUERY'\n | 'UNPLACED_VALUE';\n\nexport type SemNlAssistStatus =\n | 'NOT_NEEDED'\n | 'SKIPPED'\n | 'DISABLED'\n | 'NOT_CONFIGURED'\n | 'QUOTA_EXHAUSTED'\n | 'QUOTA_UNAVAILABLE'\n | 'PROVIDER_ERROR'\n | 'NO_IMPROVEMENT'\n | 'REPHRASED';\n\nexport type SemNlStepKind =\n 'ENTITY' | 'JOIN' | 'COLUMN' | 'MEASURE' | 'GROUP_BY' | 'FILTER' | 'ORDER' | 'LIMIT';\n\nexport interface SemNlStep {\n kind: SemNlStepKind;\n entity: string | null;\n field: string | null;\n aggregation: string | null;\n governed: boolean;\n operator: string | null;\n value: unknown;\n direction: string | null;\n count: number | null;\n relationship: string | null;\n}\n\nexport interface SemNlTranslation {\n modelId: string;\n modelName: string;\n question: string;\n status: SemNlStatus;\n sql: string | null;\n confidence: number;\n steps: SemNlStep[];\n unmatchedTerms: string[];\n clarificationReason: SemNlClarificationReason | null;\n clarification: string | null;\n suggestions: string[];\n engine: string;\n followUp: boolean;\n assist: SemNlAssistStatus;\n rephrasedQuestion: string | null;\n assistProvider: string | null;\n}\n\nexport interface SemNlAnswer {\n translation: SemNlTranslation;\n result: SemSqlResult | null;\n}\n\nexport interface SemNlQuestionInput {\n question: string;\n modelId: string;\n maxRows?: number;\n /** Earlier questions of the conversation, oldest first. */\n history?: string[];\n}\n\nexport interface SemNlSettings {\n llmAssistEnabled: boolean;\n aiConnectionId: string | null;\n aiProviderKey: string | null;\n aiModel: string | null;\n defaultAiModel: string | null;\n supportedProviders: string[];\n updatedAt: string | null;\n updatedBy: string | null;\n}\n\nexport interface SemUpdateNlSettingsInput {\n llmAssistEnabled: boolean;\n aiConnectionId: string | null;\n aiModel: string | null;\n}\n\n/** An integration connection that can hold the workspace's AI provider key. */\nexport interface SemAiConnection {\n id: string;\n name: string;\n status: string;\n providerKey: string;\n providerName: string;\n}\n\nconst TRANSLATION_FIELDS = `\n modelId\n modelName\n question\n status\n sql\n confidence\n steps {\n kind\n entity\n field\n aggregation\n governed\n operator\n value\n direction\n count\n relationship\n }\n unmatchedTerms\n clarificationReason\n clarification\n suggestions\n engine\n followUp\n assist\n rephrasedQuestion\n assistProvider`;\n\nconst SETTINGS_FIELDS = `\n llmAssistEnabled\n aiConnectionId\n aiProviderKey\n aiModel\n defaultAiModel\n supportedProviders\n updatedAt\n updatedBy`;\n\nconst NL_SETTINGS_QUERY = `query SemNlSettings {\n semNlSettings {${SETTINGS_FIELDS}\n }\n}`;\n\nconst UPDATE_NL_SETTINGS_MUTATION = `mutation SemUpdateNlSettings($input: SemUpdateNlSettingsInput!) {\n semUpdateNlSettings(input: $input) {${SETTINGS_FIELDS}\n }\n}`;\n\nconst AI_CONNECTIONS_QUERY = `query SemAiConnections($filter: ConnectionFilterInput, $pagination: IntegrationsPaginationInput) {\n getConnections(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n status\n provider {\n key\n name\n }\n }\n }\n}`;\n\nconst SUGGESTIONS_QUERY = `query SemNlSuggestions($input: SemNlQuestionInput!) {\n semTranslateQuestion(input: $input) {\n modelId\n suggestions\n }\n}`;\n\nconst ASK_QUESTION_MUTATION = `mutation SemAskQuestion($input: SemNlQuestionInput!) {\n semAskQuestion(input: $input) {\n translation {${TRANSLATION_FIELDS}\n }\n result {\n modelId\n columns {\n name\n entity\n field\n aggregation\n dataType\n masked\n mask\n }\n rows\n rowCount\n truncated\n durationMs\n sourcesTouched\n }\n }\n}`;\n\n/** Example questions the model can answer (translation only: reads no data, not metered). */\nexport function useSemNlSuggestions(modelId: string | null) {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: ['semanticfed', 'nl', 'suggestions', workspaceId ?? 'no-workspace', modelId] as const,\n enabled: Boolean(workspaceId && modelId),\n queryFn: async () => {\n const data = await semRequest<{\n semTranslateQuestion: Pick<SemNlTranslation, 'modelId' | 'suggestions'>;\n }>(SUGGESTIONS_QUERY, { input: { question: '', modelId } }, apiGatewayUrl);\n return data.semTranslateQuestion.suggestions;\n },\n });\n}\n\n/** Translate a question and run it with the caller's access policies (one metered query run). */\nexport function useSemAskQuestion() {\n const { apiGatewayUrl } = useSemanticFed();\n return useMutation({\n mutationFn: async (input: SemNlQuestionInput) => {\n const data = await semRequest<{ semAskQuestion: SemNlAnswer }>(\n ASK_QUESTION_MUTATION,\n { input },\n apiGatewayUrl\n );\n return data.semAskQuestion;\n },\n });\n}\n\nconst nlSettingsKey = (workspaceId: string | null | undefined) =>\n ['semanticfed', 'nl', 'settings', workspaceId ?? 'no-workspace'] as const;\n\n/** The workspace's natural-language settings (LLM-assisted phrasing is off until enabled). */\nexport function useSemNlSettings() {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: nlSettingsKey(workspaceId),\n enabled: Boolean(workspaceId),\n queryFn: async () => {\n const data = await semRequest<{ semNlSettings: SemNlSettings }>(\n NL_SETTINGS_QUERY,\n {},\n apiGatewayUrl\n );\n return data.semNlSettings;\n },\n });\n}\n\n/** Save the workspace's natural-language settings (governance permission). */\nexport function useSemUpdateNlSettings() {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: SemUpdateNlSettingsInput) => {\n const data = await semRequest<{ semUpdateNlSettings: SemNlSettings }>(\n UPDATE_NL_SETTINGS_MUTATION,\n { input },\n apiGatewayUrl\n );\n return data.semUpdateNlSettings;\n },\n onSuccess: (settings) => {\n queryClient.setQueryData(nlSettingsKey(workspaceId), settings);\n },\n });\n}\n\ninterface ConnectionsData {\n getConnections: {\n items: Array<{\n id: string;\n name: string;\n status: string;\n provider: { key: string; name: string } | null;\n }>;\n };\n}\n\n/** Active integration connections to a supported AI provider (OpenAI, Anthropic). */\nexport function useSemAiConnections(enabled: boolean, supportedProviders: string[]) {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: [\n 'semanticfed',\n 'nl',\n 'ai-connections',\n workspaceId ?? 'no-workspace',\n supportedProviders.join(','),\n ] as const,\n enabled: Boolean(workspaceId) && enabled,\n queryFn: async (): Promise<SemAiConnection[]> => {\n const data = await semRequest<ConnectionsData>(\n AI_CONNECTIONS_QUERY,\n { filter: { status: 'ACTIVE' }, pagination: { limit: 100 } },\n apiGatewayUrl\n );\n const supported = new Set(supportedProviders);\n return data.getConnections.items\n .filter((c) => c.provider && supported.has(c.provider.key))\n .map((c) => ({\n id: c.id,\n name: c.name,\n status: c.status,\n providerKey: c.provider?.key ?? '',\n providerName: c.provider?.name ?? '',\n }));\n },\n });\n}\n"],"mappings":";;;;AA0HA,IAAMA,IAAqB,kaA6BrBC,IAAkB,wJAUlBC,IAAoB;mBACPD,EAAgB;;IAI7BE,IAA8B;wCACIF,EAAgB;;IAIlDG,IAAuB,0RAcvBC,IAAoB,wIAOpBC,IAAwB;;mBAEXN,EAAmB;;;;;;;;;;;;;;;;;;;;;AAuBtC,SAAgBO,EAAoB,GAAwB;CAC1D,IAAM,EAAE,kBAAe,mBAAgBC,EAAe;CACtD,OAAOC,EAAS;EACd,UAAU;GAAC;GAAe;GAAM;GAAeC,KAAe;GAAgBC;EAAO;EACrF,SAAS,GAAQD,KAAeC;EAChC,SAAS,aAIA,MAHYC,EAEhBP,GAAmB,EAAE,OAAO;GAAE,UAAU;GAAI;EAAQ,EAAE,GAAGQ,CAAa,EAAA,CAC7D,qBAAqB;CAErC,CAAC;AACH;AAGA,SAAgBC,IAAoB;CAClC,IAAM,EAAE,qBAAkBN,EAAe;CACzC,OAAOO,EAAY,EACjB,YAAY,OAAO,OAMV,MALYH,EACjBN,GACA,EAAE,SAAM,GACRO,CACF,EAAA,CACY,eAEhB,CAAC;AACH;AAEA,IAAMG,KAAiB,MACrB;CAAC;CAAe;CAAM;CAAYN,KAAe;AAAc;AAGjE,SAAgBO,IAAmB;CACjC,IAAM,EAAE,kBAAe,mBAAgBT,EAAe;CACtD,OAAOC,EAAS;EACd,UAAUO,EAAcN,CAAW;EACnC,SAAS,EAAQA;EACjB,SAAS,aAMA,MALYE,EACjBV,GACA,CAAC,GACDW,CACF,EAAA,CACY;CAEhB,CAAC;AACH;AAGA,SAAgBK,IAAyB;CACvC,IAAM,EAAE,kBAAe,mBAAgBV,EAAe,GAChDW,IAAcC,EAAe;CACnC,OAAOL,EAAY;EACjB,YAAY,OAAO,OAMV,MALYH,EACjBT,GACA,EAAE,SAAM,GACRU,CACF,EAAA,CACY;EAEd,YAAY,MAAa;GACvB,EAAY,aAAaG,EAAcN,CAAW,GAAGW,CAAQ;EAC/D;CACF,CAAC;AACH;AAcA,SAAgBC,EAAoB,GAAkB,GAA8B;CAClF,IAAM,EAAE,kBAAe,mBAAgBd,EAAe;CACtD,OAAOC,EAAS;EACd,UAAU;GACR;GACA;GACA;GACAC,KAAe;GACfa,EAAmB,KAAK,GAAG;EAC7B;EACA,SAAS,EAAQb,KAAgBc;EACjC,SAAS,YAAwC;GAC/C,IAAMC,IAAO,MAAMb,EACjBR,GACA;IAAE,QAAQ,EAAE,QAAQ,SAAS;IAAG,YAAY,EAAE,OAAO,IAAI;GAAE,GAC3DS,CACF,GACMa,IAAY,IAAI,IAAIH,CAAkB;GAC5C,OAAOE,EAAK,eAAe,MACxB,QAAQ,MAAME,EAAE,YAAYD,EAAU,IAAIC,EAAE,SAAS,GAAG,CAAC,CAAC,CAC1D,KAAK,OAAO;IACX,IAAIA,EAAE;IACN,MAAMA,EAAE;IACR,QAAQA,EAAE;IACV,aAAaA,EAAE,UAAU,OAAO;IAChC,cAAcA,EAAE,UAAU,QAAQ;GACpC,EAAE;EACN;CACF,CAAC;AACH"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorTranslator } from '../utils/requestErrorI18n';
|
|
1
2
|
export type SemSqlDataType = 'STRING' | 'INTEGER' | 'DECIMAL' | 'BOOLEAN' | 'DATE' | 'TIMESTAMP' | 'JSON' | 'GEO' | 'UNKNOWN';
|
|
2
3
|
export interface SemModelSummary {
|
|
3
4
|
id: string;
|
|
@@ -55,4 +56,4 @@ export declare function useSemExecuteSql(): import('@tanstack/react-query').UseM
|
|
|
55
56
|
* errors, so the service's own explanation (syntax position, unknown column,
|
|
56
57
|
* policy denial) is preferred whenever the service sent one.
|
|
57
58
|
*/
|
|
58
|
-
export declare function sqlErrorMessage(error: unknown): string;
|
|
59
|
+
export declare function sqlErrorMessage(error: unknown, tr?: ErrorTranslator): string;
|
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { translateRequestError as e } from "../utils/requestErrorI18n.js";
|
|
2
|
+
import { useSemRequest as t } from "./useSemRequest.js";
|
|
3
|
+
import { useClientAnalytics as n } from "./useClientAnalytics.js";
|
|
4
|
+
import { SemRequestError as r } from "../api/semanticfedGraphql.js";
|
|
5
|
+
import { useSemanticFed as i } from "../providers/SemanticFedProvider.js";
|
|
6
|
+
import { useMutation as a, useQuery as o } from "@tanstack/react-query";
|
|
6
7
|
// src/semanticfed/hooks/useSqlConsole.ts
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
let { workspaceId:
|
|
10
|
-
return
|
|
8
|
+
var s = "query SemSqlConsoleModels($pagination: PaginationInput) {\n semListModels(pagination: $pagination) {\n items {\n id\n name\n status\n }\n }\n}", c = "query SemSqlCatalog($modelId: ID) {\n semSqlCatalog(modelId: $modelId) {\n modelId\n modelName\n tables {\n name\n kind\n description\n primaryKey\n columns {\n name\n kind\n dataType\n aggregation\n description\n isPrimary\n }\n }\n }\n}", l = "mutation SemExecuteSql($input: SemExecuteSqlInput!) {\n semExecuteSql(input: $input) {\n modelId\n columns {\n name\n entity\n field\n aggregation\n dataType\n masked\n mask\n }\n rows\n rowCount\n truncated\n durationMs\n sourcesTouched\n }\n}", u = 100;
|
|
9
|
+
function d() {
|
|
10
|
+
let { workspaceId: e } = i(), { request: n, ready: r } = t();
|
|
11
|
+
return o({
|
|
11
12
|
queryKey: [
|
|
12
13
|
"semanticfed",
|
|
13
14
|
"sql",
|
|
14
15
|
"models",
|
|
15
|
-
|
|
16
|
+
e ?? "no-workspace"
|
|
16
17
|
],
|
|
17
|
-
enabled:
|
|
18
|
-
queryFn: async ({ signal: e }) => (await n(
|
|
18
|
+
enabled: r && !!e,
|
|
19
|
+
queryFn: async ({ signal: e }) => (await n(s, { pagination: { limit: u } }, e)).semListModels.items
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
let { workspaceId: n } =
|
|
23
|
-
return
|
|
22
|
+
function f(e) {
|
|
23
|
+
let { workspaceId: n } = i(), { request: r, ready: a } = t();
|
|
24
|
+
return o({
|
|
24
25
|
queryKey: [
|
|
25
26
|
"semanticfed",
|
|
26
27
|
"sql",
|
|
27
28
|
"catalog",
|
|
28
29
|
n ?? "no-workspace",
|
|
29
|
-
|
|
30
|
+
e
|
|
30
31
|
],
|
|
31
|
-
enabled:
|
|
32
|
-
queryFn: async ({ signal:
|
|
32
|
+
enabled: a && !!(n && e),
|
|
33
|
+
queryFn: async ({ signal: t }) => (await r(c, { modelId: e }, t)).semSqlCatalog
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
-
let { request:
|
|
37
|
-
return
|
|
36
|
+
function p() {
|
|
37
|
+
let { request: e } = t(), r = n();
|
|
38
|
+
return a({
|
|
38
39
|
retry: !1,
|
|
39
|
-
mutationFn: async (
|
|
40
|
+
mutationFn: async (t) => {
|
|
40
41
|
try {
|
|
41
|
-
let
|
|
42
|
-
return r.sqlExecuted(
|
|
42
|
+
let n = await e(l, { input: t });
|
|
43
|
+
return r.sqlExecuted(n.semExecuteSql.rowCount, n.semExecuteSql.truncated), n.semExecuteSql;
|
|
43
44
|
} catch (e) {
|
|
44
45
|
throw r.sqlFailed(e), e;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
-
return
|
|
50
|
+
function m(t, n) {
|
|
51
|
+
return t instanceof r && t.detail && t.code !== "INTERNAL_SERVER_ERROR" ? e(t.detail, n) : e(t instanceof Error ? t.message : String(t), n);
|
|
51
52
|
}
|
|
52
|
-
export {
|
|
53
|
+
export { m as sqlErrorMessage, p as useSemExecuteSql, f as useSemSqlCatalog, d as useSemSqlModels };
|
|
53
54
|
|
|
54
55
|
//# sourceMappingURL=useSqlConsole.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSqlConsole.js","names":["LIST_MODELS_QUERY","SQL_CATALOG_QUERY","EXECUTE_SQL_MUTATION","MODEL_PICKER_LIMIT","useSemSqlModels","useSemanticFed","useSemRequest","useQuery","workspaceId","ready","request","signal","useSemSqlCatalog","modelId","useSemExecuteSql","analytics","useClientAnalytics","useMutation","data","error","sqlErrorMessage","SemRequestError"],"sources":["../../../src/semanticfed/hooks/useSqlConsole.ts"],"sourcesContent":["import { useSemRequest } from './useSemRequest';\nimport { useClientAnalytics } from './useClientAnalytics';\n/**\n * SQL console hooks, wired to the real `wspace-semanticfed-svc` SQL endpoint\n * (BOFF-4271): `semListModels` to pick a semantic model, `semSqlCatalog` for\n * the table/column browser and `semExecuteSql` to run a read-only SELECT\n * through the federated query engine with the caller's access policies.\n */\nimport { useMutation, useQuery } from '@tanstack/react-query';\n\nimport { SemRequestError } from '../api/semanticfedGraphql';\nimport { useSemanticFed } from '../providers/SemanticFedProvider';\n\nexport type SemSqlDataType =\n 'STRING' | 'INTEGER' | 'DECIMAL' | 'BOOLEAN' | 'DATE' | 'TIMESTAMP' | 'JSON' | 'GEO' | 'UNKNOWN';\n\nexport interface SemModelSummary {\n id: string;\n name: string;\n status: string;\n}\n\nexport interface SemSqlCatalogColumn {\n name: string;\n kind: 'DIMENSION' | 'METRIC';\n dataType: SemSqlDataType;\n aggregation: string | null;\n description: string | null;\n isPrimary: boolean;\n}\n\nexport interface SemSqlCatalogTable {\n name: string;\n kind: string;\n description: string | null;\n primaryKey: string | null;\n columns: SemSqlCatalogColumn[];\n}\n\nexport interface SemSqlCatalog {\n modelId: string;\n modelName: string;\n tables: SemSqlCatalogTable[];\n}\n\nexport interface SemSqlResultColumn {\n name: string;\n entity: string;\n field: string;\n aggregation: string | null;\n dataType: SemSqlDataType;\n masked: boolean;\n mask: string | null;\n}\n\nexport interface SemSqlResult {\n modelId: string;\n columns: SemSqlResultColumn[];\n rows: Array<Record<string, unknown>>;\n rowCount: number;\n truncated: boolean;\n durationMs: number;\n sourcesTouched: number;\n}\n\nexport interface SemExecuteSqlInput {\n sql: string;\n modelId: string;\n maxRows?: number;\n}\n\nconst LIST_MODELS_QUERY = `query SemSqlConsoleModels($pagination: PaginationInput) {\n semListModels(pagination: $pagination) {\n items {\n id\n name\n status\n }\n }\n}`;\n\nconst SQL_CATALOG_QUERY = `query SemSqlCatalog($modelId: ID) {\n semSqlCatalog(modelId: $modelId) {\n modelId\n modelName\n tables {\n name\n kind\n description\n primaryKey\n columns {\n name\n kind\n dataType\n aggregation\n description\n isPrimary\n }\n }\n }\n}`;\n\nconst EXECUTE_SQL_MUTATION = `mutation SemExecuteSql($input: SemExecuteSqlInput!) {\n semExecuteSql(input: $input) {\n modelId\n columns {\n name\n entity\n field\n aggregation\n dataType\n masked\n mask\n }\n rows\n rowCount\n truncated\n durationMs\n sourcesTouched\n }\n}`;\n\n/** Largest model list the console offers (the picker is not paginated). */\nconst MODEL_PICKER_LIMIT = 100;\n\nexport function useSemSqlModels() {\n const { workspaceId } = useSemanticFed();\n const { request, ready } = useSemRequest();\n return useQuery({\n queryKey: ['semanticfed', 'sql', 'models', workspaceId ?? 'no-workspace'] as const,\n enabled: ready && Boolean(workspaceId),\n queryFn: async ({ signal }) => {\n const data = await request<{ semListModels: { items: SemModelSummary[] } }>(\n LIST_MODELS_QUERY,\n { pagination: { limit: MODEL_PICKER_LIMIT } },\n signal\n );\n return data.semListModels.items;\n },\n });\n}\n\nexport function useSemSqlCatalog(modelId: string | null) {\n const { workspaceId } = useSemanticFed();\n const { request, ready } = useSemRequest();\n return useQuery({\n queryKey: ['semanticfed', 'sql', 'catalog', workspaceId ?? 'no-workspace', modelId] as const,\n enabled: ready && Boolean(workspaceId && modelId),\n queryFn: async ({ signal }) => {\n const data = await request<{ semSqlCatalog: SemSqlCatalog }>(\n SQL_CATALOG_QUERY,\n { modelId },\n signal\n );\n return data.semSqlCatalog;\n },\n });\n}\n\nexport function useSemExecuteSql() {\n const { request } = useSemRequest();\n const analytics = useClientAnalytics();\n return useMutation({\n retry: false,\n mutationFn: async (input: SemExecuteSqlInput) => {\n try {\n const data = await request<{ semExecuteSql: SemSqlResult }>(EXECUTE_SQL_MUTATION, {\n input,\n });\n analytics.sqlExecuted(data.semExecuteSql.rowCount, data.semExecuteSql.truncated);\n return data.semExecuteSql;\n } catch (error: unknown) {\n analytics.sqlFailed(error);\n throw error;\n }\n },\n });\n}\n\n/**\n * The text to show for a failed SQL statement. The gateway generalises client\n * errors, so the service's own explanation (syntax position, unknown column,\n * policy denial) is preferred whenever the service sent one.\n */\nexport function sqlErrorMessage(error: unknown): string {\n if (error instanceof SemRequestError && error.detail && error.code !== 'INTERNAL_SERVER_ERROR') {\n return error.detail;\n }\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSqlConsole.js","names":["LIST_MODELS_QUERY","SQL_CATALOG_QUERY","EXECUTE_SQL_MUTATION","MODEL_PICKER_LIMIT","useSemSqlModels","useSemanticFed","useSemRequest","useQuery","workspaceId","ready","request","signal","useSemSqlCatalog","modelId","useSemExecuteSql","analytics","useClientAnalytics","useMutation","data","error","sqlErrorMessage","SemRequestError","translateRequestError","tr"],"sources":["../../../src/semanticfed/hooks/useSqlConsole.ts"],"sourcesContent":["import { translateRequestError, type ErrorTranslator } from '../utils/requestErrorI18n';\nimport { useSemRequest } from './useSemRequest';\nimport { useClientAnalytics } from './useClientAnalytics';\n/**\n * SQL console hooks, wired to the real `wspace-semanticfed-svc` SQL endpoint\n * (BOFF-4271): `semListModels` to pick a semantic model, `semSqlCatalog` for\n * the table/column browser and `semExecuteSql` to run a read-only SELECT\n * through the federated query engine with the caller's access policies.\n */\nimport { useMutation, useQuery } from '@tanstack/react-query';\n\nimport { SemRequestError } from '../api/semanticfedGraphql';\nimport { useSemanticFed } from '../providers/SemanticFedProvider';\n\nexport type SemSqlDataType =\n 'STRING' | 'INTEGER' | 'DECIMAL' | 'BOOLEAN' | 'DATE' | 'TIMESTAMP' | 'JSON' | 'GEO' | 'UNKNOWN';\n\nexport interface SemModelSummary {\n id: string;\n name: string;\n status: string;\n}\n\nexport interface SemSqlCatalogColumn {\n name: string;\n kind: 'DIMENSION' | 'METRIC';\n dataType: SemSqlDataType;\n aggregation: string | null;\n description: string | null;\n isPrimary: boolean;\n}\n\nexport interface SemSqlCatalogTable {\n name: string;\n kind: string;\n description: string | null;\n primaryKey: string | null;\n columns: SemSqlCatalogColumn[];\n}\n\nexport interface SemSqlCatalog {\n modelId: string;\n modelName: string;\n tables: SemSqlCatalogTable[];\n}\n\nexport interface SemSqlResultColumn {\n name: string;\n entity: string;\n field: string;\n aggregation: string | null;\n dataType: SemSqlDataType;\n masked: boolean;\n mask: string | null;\n}\n\nexport interface SemSqlResult {\n modelId: string;\n columns: SemSqlResultColumn[];\n rows: Array<Record<string, unknown>>;\n rowCount: number;\n truncated: boolean;\n durationMs: number;\n sourcesTouched: number;\n}\n\nexport interface SemExecuteSqlInput {\n sql: string;\n modelId: string;\n maxRows?: number;\n}\n\nconst LIST_MODELS_QUERY = `query SemSqlConsoleModels($pagination: PaginationInput) {\n semListModels(pagination: $pagination) {\n items {\n id\n name\n status\n }\n }\n}`;\n\nconst SQL_CATALOG_QUERY = `query SemSqlCatalog($modelId: ID) {\n semSqlCatalog(modelId: $modelId) {\n modelId\n modelName\n tables {\n name\n kind\n description\n primaryKey\n columns {\n name\n kind\n dataType\n aggregation\n description\n isPrimary\n }\n }\n }\n}`;\n\nconst EXECUTE_SQL_MUTATION = `mutation SemExecuteSql($input: SemExecuteSqlInput!) {\n semExecuteSql(input: $input) {\n modelId\n columns {\n name\n entity\n field\n aggregation\n dataType\n masked\n mask\n }\n rows\n rowCount\n truncated\n durationMs\n sourcesTouched\n }\n}`;\n\n/** Largest model list the console offers (the picker is not paginated). */\nconst MODEL_PICKER_LIMIT = 100;\n\nexport function useSemSqlModels() {\n const { workspaceId } = useSemanticFed();\n const { request, ready } = useSemRequest();\n return useQuery({\n queryKey: ['semanticfed', 'sql', 'models', workspaceId ?? 'no-workspace'] as const,\n enabled: ready && Boolean(workspaceId),\n queryFn: async ({ signal }) => {\n const data = await request<{ semListModels: { items: SemModelSummary[] } }>(\n LIST_MODELS_QUERY,\n { pagination: { limit: MODEL_PICKER_LIMIT } },\n signal\n );\n return data.semListModels.items;\n },\n });\n}\n\nexport function useSemSqlCatalog(modelId: string | null) {\n const { workspaceId } = useSemanticFed();\n const { request, ready } = useSemRequest();\n return useQuery({\n queryKey: ['semanticfed', 'sql', 'catalog', workspaceId ?? 'no-workspace', modelId] as const,\n enabled: ready && Boolean(workspaceId && modelId),\n queryFn: async ({ signal }) => {\n const data = await request<{ semSqlCatalog: SemSqlCatalog }>(\n SQL_CATALOG_QUERY,\n { modelId },\n signal\n );\n return data.semSqlCatalog;\n },\n });\n}\n\nexport function useSemExecuteSql() {\n const { request } = useSemRequest();\n const analytics = useClientAnalytics();\n return useMutation({\n retry: false,\n mutationFn: async (input: SemExecuteSqlInput) => {\n try {\n const data = await request<{ semExecuteSql: SemSqlResult }>(EXECUTE_SQL_MUTATION, {\n input,\n });\n analytics.sqlExecuted(data.semExecuteSql.rowCount, data.semExecuteSql.truncated);\n return data.semExecuteSql;\n } catch (error: unknown) {\n analytics.sqlFailed(error);\n throw error;\n }\n },\n });\n}\n\n/**\n * The text to show for a failed SQL statement. The gateway generalises client\n * errors, so the service's own explanation (syntax position, unknown column,\n * policy denial) is preferred whenever the service sent one.\n */\nexport function sqlErrorMessage(error: unknown, tr?: ErrorTranslator): string {\n if (error instanceof SemRequestError && error.detail && error.code !== 'INTERNAL_SERVER_ERROR') {\n return translateRequestError(error.detail, tr);\n }\n return translateRequestError(error instanceof Error ? error.message : String(error), tr);\n}\n"],"mappings":";;;;;;;AAwEA,IAAMA,IAAoB,yKAUpBC,IAAoB,wUAqBpBC,IAAuB,qTAqBvBC,IAAqB;AAE3B,SAAgBC,IAAkB;CAChC,IAAM,EAAE,mBAAgBC,EAAe,GACjC,EAAE,YAAS,aAAUC,EAAc;CACzC,OAAOC,EAAS;EACd,UAAU;GAAC;GAAe;GAAO;GAAUC,KAAe;EAAc;EACxE,SAASC,KAAS,EAAQD;EAC1B,SAAS,OAAO,EAAE,iBAMT,MALYE,EACjBV,GACA,EAAE,YAAY,EAAE,OAAOG,EAAmB,EAAE,GAC5CQ,CACF,EAAA,CACY,cAAc;CAE9B,CAAC;AACH;AAEA,SAAgBC,EAAiB,GAAwB;CACvD,IAAM,EAAE,mBAAgBP,EAAe,GACjC,EAAE,YAAS,aAAUC,EAAc;CACzC,OAAOC,EAAS;EACd,UAAU;GAAC;GAAe;GAAO;GAAWC,KAAe;GAAgBK;EAAO;EAClF,SAASJ,KAAS,GAAQD,KAAeK;EACzC,SAAS,OAAO,EAAE,iBAMT,MALYH,EACjBT,GACA,EAAE,WAAQ,GACVU,CACF,EAAA,CACY;CAEhB,CAAC;AACH;AAEA,SAAgBG,IAAmB;CACjC,IAAM,EAAE,eAAYR,EAAc,GAC5BS,IAAYC,EAAmB;CACrC,OAAOC,EAAY;EACjB,OAAO;EACP,YAAY,OAAO,MAA8B;GAC/C,IAAI;IACF,IAAMC,IAAO,MAAMR,EAAyCR,GAAsB,EAChF,SACF,CAAC;IAED,OADAa,EAAU,YAAYG,EAAK,cAAc,UAAUA,EAAK,cAAc,SAAS,GACxEA,EAAK;GACd,SAASC,GAAgB;IAEvB,MADAJ,EAAU,UAAUI,CAAK,GACnBA;GACR;EACF;CACF,CAAC;AACH;AAOA,SAAgBC,EAAgB,GAAgB,GAA8B;CAI5E,OAHID,aAAiBE,KAAmBF,EAAM,UAAUA,EAAM,SAAS,0BAC9DG,EAAsBH,EAAM,QAAQI,CAAE,IAExCD,EAAsBH,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK,GAAGI,CAAE;AACzF"}
|