@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.
Files changed (111) hide show
  1. package/README.md +33 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +2 -1
  4. package/dist/semanticfed/components/AskQuestionPanel.d.ts +0 -14
  5. package/dist/semanticfed/components/AskQuestionPanel.js +198 -160
  6. package/dist/semanticfed/components/AskQuestionPanel.js.map +1 -1
  7. package/dist/semanticfed/components/NlAssistSettings.js +4 -4
  8. package/dist/semanticfed/components/NlAssistSettings.js.map +1 -1
  9. package/dist/semanticfed/components/OnboardingChecklist.js +172 -128
  10. package/dist/semanticfed/components/OnboardingChecklist.js.map +1 -1
  11. package/dist/semanticfed/components/PageHeader.d.ts +11 -0
  12. package/dist/semanticfed/components/PageHeader.js +21 -0
  13. package/dist/semanticfed/components/PageHeader.js.map +1 -0
  14. package/dist/semanticfed/components/SavedQueryRunsPanel.js +224 -200
  15. package/dist/semanticfed/components/SavedQueryRunsPanel.js.map +1 -1
  16. package/dist/semanticfed/components/SummaryCard.d.ts +10 -0
  17. package/dist/semanticfed/components/SummaryCard.js +21 -0
  18. package/dist/semanticfed/components/SummaryCard.js.map +1 -0
  19. package/dist/semanticfed/components/TableHeaders.d.ts +16 -0
  20. package/dist/semanticfed/components/TableHeaders.js +21 -0
  21. package/dist/semanticfed/components/TableHeaders.js.map +1 -0
  22. package/dist/semanticfed/components/askConversation.d.ts +16 -0
  23. package/dist/semanticfed/components/askConversation.js +7 -0
  24. package/dist/semanticfed/components/askConversation.js.map +1 -0
  25. package/dist/semanticfed/components/lineage/LineageDetails.d.ts +15 -0
  26. package/dist/semanticfed/components/lineage/LineageDetails.js +155 -0
  27. package/dist/semanticfed/components/lineage/LineageDetails.js.map +1 -0
  28. package/dist/semanticfed/components/lineage/LineageLanes.d.ts +11 -0
  29. package/dist/semanticfed/components/lineage/LineageLanes.js +78 -0
  30. package/dist/semanticfed/components/lineage/LineageLanes.js.map +1 -0
  31. package/dist/semanticfed/components/lineage/LineageToolbar.d.ts +14 -0
  32. package/dist/semanticfed/components/lineage/LineageToolbar.js +69 -0
  33. package/dist/semanticfed/components/lineage/LineageToolbar.js.map +1 -0
  34. package/dist/semanticfed/components/lineage/LineageWarnings.d.ts +13 -0
  35. package/dist/semanticfed/components/lineage/LineageWarnings.js +43 -0
  36. package/dist/semanticfed/components/lineage/LineageWarnings.js.map +1 -0
  37. package/dist/semanticfed/components/lineage/lineageModel.d.ts +30 -0
  38. package/dist/semanticfed/components/lineage/lineageModel.js +110 -0
  39. package/dist/semanticfed/components/lineage/lineageModel.js.map +1 -0
  40. package/dist/semanticfed/components/lineage/useLineageTrace.d.ts +17 -0
  41. package/dist/semanticfed/components/lineage/useLineageTrace.js +34 -0
  42. package/dist/semanticfed/components/lineage/useLineageTrace.js.map +1 -0
  43. package/dist/semanticfed/components/queryConsole/QueryHistoryCard.d.ts +10 -0
  44. package/dist/semanticfed/components/queryConsole/QueryHistoryCard.js +47 -0
  45. package/dist/semanticfed/components/queryConsole/QueryHistoryCard.js.map +1 -0
  46. package/dist/semanticfed/components/queryConsole/SchemaBrowser.d.ts +13 -0
  47. package/dist/semanticfed/components/queryConsole/SchemaBrowser.js +89 -0
  48. package/dist/semanticfed/components/queryConsole/SchemaBrowser.js.map +1 -0
  49. package/dist/semanticfed/components/queryConsole/SqlEditorCard.d.ts +14 -0
  50. package/dist/semanticfed/components/queryConsole/SqlEditorCard.js +69 -0
  51. package/dist/semanticfed/components/queryConsole/SqlEditorCard.js.map +1 -0
  52. package/dist/semanticfed/components/queryConsole/SqlResultCard.d.ts +14 -0
  53. package/dist/semanticfed/components/queryConsole/SqlResultCard.js +71 -0
  54. package/dist/semanticfed/components/queryConsole/SqlResultCard.js.map +1 -0
  55. package/dist/semanticfed/components/queryConsole/consoleHistory.d.ts +23 -0
  56. package/dist/semanticfed/components/queryConsole/consoleHistory.js +19 -0
  57. package/dist/semanticfed/components/queryConsole/consoleHistory.js.map +1 -0
  58. package/dist/semanticfed/hooks/useLineage.d.ts +2 -1
  59. package/dist/semanticfed/hooks/useLineage.js +24 -23
  60. package/dist/semanticfed/hooks/useLineage.js.map +1 -1
  61. package/dist/semanticfed/hooks/useNlQuery.js +13 -10
  62. package/dist/semanticfed/hooks/useNlQuery.js.map +1 -1
  63. package/dist/semanticfed/hooks/useSqlConsole.d.ts +2 -1
  64. package/dist/semanticfed/hooks/useSqlConsole.js +28 -27
  65. package/dist/semanticfed/hooks/useSqlConsole.js.map +1 -1
  66. package/dist/semanticfed/pages/AgentsPage.js +119 -148
  67. package/dist/semanticfed/pages/AgentsPage.js.map +1 -1
  68. package/dist/semanticfed/pages/AuditPage.js +95 -76
  69. package/dist/semanticfed/pages/AuditPage.js.map +1 -1
  70. package/dist/semanticfed/pages/CollaborationPage.js +60 -64
  71. package/dist/semanticfed/pages/CollaborationPage.js.map +1 -1
  72. package/dist/semanticfed/pages/ConfigurationPage.js +86 -67
  73. package/dist/semanticfed/pages/ConfigurationPage.js.map +1 -1
  74. package/dist/semanticfed/pages/DashboardPage.js +1 -1
  75. package/dist/semanticfed/pages/DashboardPage.js.map +1 -1
  76. package/dist/semanticfed/pages/HelpPage.js +1 -1
  77. package/dist/semanticfed/pages/HelpPage.js.map +1 -1
  78. package/dist/semanticfed/pages/KnowledgeGraphPage.js +129 -128
  79. package/dist/semanticfed/pages/KnowledgeGraphPage.js.map +1 -1
  80. package/dist/semanticfed/pages/LineagePage.js +110 -424
  81. package/dist/semanticfed/pages/LineagePage.js.map +1 -1
  82. package/dist/semanticfed/pages/MonitoringPage.js +76 -76
  83. package/dist/semanticfed/pages/MonitoringPage.js.map +1 -1
  84. package/dist/semanticfed/pages/OntologyPage.js +71 -98
  85. package/dist/semanticfed/pages/OntologyPage.js.map +1 -1
  86. package/dist/semanticfed/pages/PerformancePage.js +2 -2
  87. package/dist/semanticfed/pages/PerformancePage.js.map +1 -1
  88. package/dist/semanticfed/pages/PoliciesPage.js +112 -141
  89. package/dist/semanticfed/pages/PoliciesPage.js.map +1 -1
  90. package/dist/semanticfed/pages/ProtocolPage.js +93 -94
  91. package/dist/semanticfed/pages/ProtocolPage.js.map +1 -1
  92. package/dist/semanticfed/pages/QueryConsolePage.js +160 -327
  93. package/dist/semanticfed/pages/QueryConsolePage.js.map +1 -1
  94. package/dist/semanticfed/pages/RegistryPage.js +94 -105
  95. package/dist/semanticfed/pages/RegistryPage.js.map +1 -1
  96. package/dist/semanticfed/pages/TechStackPage.js +1 -1
  97. package/dist/semanticfed/pages/TechStackPage.js.map +1 -1
  98. package/dist/semanticfed/pages/TopologyPage.js +68 -99
  99. package/dist/semanticfed/pages/TopologyPage.js.map +1 -1
  100. package/dist/semanticfed/pages/VisualizationPage.js +7 -7
  101. package/dist/semanticfed/pages/VisualizationPage.js.map +1 -1
  102. package/dist/semanticfed/translations/english.js +514 -0
  103. package/dist/semanticfed/translations/english.js.map +1 -0
  104. package/dist/semanticfed/translations/english.json.d.ts +513 -0
  105. package/dist/semanticfed/utils/contentKeys.d.ts +16 -0
  106. package/dist/semanticfed/utils/contentKeys.js +14 -0
  107. package/dist/semanticfed/utils/contentKeys.js.map +1 -0
  108. package/dist/semanticfed/utils/requestErrorI18n.d.ts +3 -0
  109. package/dist/semanticfed/utils/requestErrorI18n.js +15 -0
  110. package/dist/semanticfed/utils/requestErrorI18n.js.map +1 -0
  111. package/package.json +9 -3
package/README.md CHANGED
@@ -34,3 +34,36 @@ commit tests with browser fetch disabled. Native context changes reset local
34
34
  result/history/editor state and query data; ordinary bearer renewal in the same
35
35
  context preserves that state. The tests are protocol and state fixtures, separate
36
36
  from deployed doctor and Playwright acceptance. They are part of `sanity`.
37
+
38
+ ## Product translations and RTL
39
+
40
+ `bun run i18n:extract` statically extracts the literal translation calls and the
41
+ finite onboarding, guide, lineage and label maps into
42
+ `src/semanticfed/translations/english.json`. It never imports or executes product
43
+ source. An unclassified dynamic call or conflicting English fallback fails the
44
+ command. `bun run i18n:check` verifies the checked-in catalog and extraction
45
+ regressions; `sanity` runs it after generating the GraphQL artifacts required by
46
+ the client tests.
47
+
48
+ The package exports `semanticfedEnglishCatalog`, a flat map of dot-notated keys
49
+ to their current English fallback values. The dedicated
50
+ `@burdenoff/microfe-semanticfed/translations/english` default export lets shells
51
+ load this data without eagerly importing the product component entry.
52
+ App shells can reconcile their bundled
53
+ fallbacks against the catalog of the exact package they pin. This catalog is
54
+ English source extraction, not a complete translation-seed bundle or proof that
55
+ online dictionaries or non-English translations are complete. Online changes
56
+ belong to the global i18n service's in-place seeder and reviewed plan, preserving
57
+ existing values and history.
58
+
59
+ Product spacing and text alignment use logical utilities. Pagination chevrons
60
+ mirror under the platform RTL mode; source/target graph direction and technical
61
+ SQL identifiers retain their meaning. The platform owns document direction:
62
+ use its supported `?dir=rtl` preview for browser acceptance rather than setting
63
+ `document.dir` in product components. Actual locale and RTL browser receipts are
64
+ separate from successful extraction and build checks.
65
+
66
+ Known fixed client request messages also use product translation keys. SQL parser
67
+ and service-provided diagnostic text remain verbatim; unknown messages are not
68
+ translated by guessing. The extraction gate rejects nonliteral metadata labels,
69
+ conflicting or duplicate fields, unsafe paths and unclassified dynamic calls.
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './semanticfed';
2
+ export { default as semanticfedEnglishCatalog } from './semanticfed/translations/english.json';
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@ import { useSemanticFed as e } from "./semanticfed/providers/SemanticFedProvider
2
2
  import { SemanticFedRoot as t } from "./semanticfed/SemanticFedRoot.js";
3
3
  import { useSemanticFedStore as n } from "./semanticfed/store/semanticfedStore.js";
4
4
  import "./semanticfed/index.js";
5
- export { t as SemanticFedRoot, e as useSemanticFed, n as useSemanticFedStore };
5
+ import r from "./semanticfed/translations/english.js";
6
+ export { t as SemanticFedRoot, r as semanticfedEnglishCatalog, e as useSemanticFed, n as useSemanticFedStore };
@@ -1,17 +1,4 @@
1
1
  import { SemNlAnswer } from '../hooks/useNlQuery';
2
- /** One question of the conversation and what it got back. */
3
- interface Turn {
4
- id: number;
5
- question: string;
6
- answer: SemNlAnswer | null;
7
- error: string | null;
8
- }
9
- /**
10
- * The questions a follow-up refines: the answered ones, oldest first. A turn
11
- * the AI provider reworded is carried as its rewrite, which uses the model's
12
- * own names.
13
- */
14
- export declare function conversationHistory(turns: Turn[]): string[];
15
2
  export interface AskQuestionPanelProps {
16
3
  modelId: string | null;
17
4
  maxRows: number;
@@ -32,4 +19,3 @@ export interface AskQuestionPanelProps {
32
19
  * the answer can be checked, and opened in the SQL editor.
33
20
  */
34
21
  export declare function AskQuestionPanel({ modelId, maxRows, onAnswer, onError, onOpenInEditor, }: AskQuestionPanelProps): import('react').JSX.Element;
35
- export {};
@@ -1,31 +1,30 @@
1
1
  import { useSemAskQuestion as e, useSemNlSuggestions as t } from "../hooks/useNlQuery.js";
2
2
  import { NlAssistSettings as n } from "./NlAssistSettings.js";
3
- import { sqlErrorMessage as r } from "../hooks/useSqlConsole.js";
4
- import { useTr as i } from "../hooks/useTr.js";
5
- import { useRef as a, useState as o } from "react";
6
- import { CornerDownRight as s, HelpCircle as c, Loader2 as l, MessageSquareText as u, PencilLine as d, RotateCcw as f, Send as p, Sparkles as m } from "lucide-react";
7
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
- import { Badge as _, Button as v, Card as y, CardContent as b, CardHeader as x, CardTitle as S } from "@burdenoff/fe-libs/ui";
3
+ import { conversationHistory as r } from "./askConversation.js";
4
+ import { withContentKeys as i } from "../utils/contentKeys.js";
5
+ import { sqlErrorMessage as a } from "../hooks/useSqlConsole.js";
6
+ import { useTr as o } from "../hooks/useTr.js";
7
+ import { useRef as s, useState as c } from "react";
8
+ import { CornerDownRight as l, HelpCircle as u, Loader2 as d, MessageSquareText as f, PencilLine as p, RotateCcw as m, Send as h, Sparkles as g } from "lucide-react";
9
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
10
+ import { Badge as y, Button as b, Card as x, CardContent as S, CardHeader as C, CardTitle as w } from "@burdenoff/fe-libs/ui";
9
11
  // src/semanticfed/components/AskQuestionPanel.tsx
10
- var C = 1e3, w = 6;
11
- function T(e) {
12
- return e.filter((e) => e.answer?.translation.status === "TRANSLATED").map((e) => e.answer?.translation.rephrasedQuestion ?? e.question).slice(-10);
13
- }
14
- function E(e) {
12
+ var T = 1e3, E = 6;
13
+ function D(e) {
15
14
  return e == null ? "NULL" : typeof e == "string" ? `'${e}'` : typeof e == "object" ? JSON.stringify(e) : String(e);
16
15
  }
17
- function D(e, t) {
16
+ function O(e, t) {
18
17
  let n = [e.entity, e.field].filter(Boolean).join(".");
19
18
  switch (e.kind) {
20
19
  case "MEASURE": return `${e.aggregation ?? ""}(${n})${e.governed ? ` ${t}` : ""}`;
21
- case "FILTER": return `${n} ${e.operator ?? "="} ${E(e.value)}`;
20
+ case "FILTER": return `${n} ${e.operator ?? "="} ${D(e.value)}`;
22
21
  case "ORDER": return `${n} ${e.direction ?? ""}`.trim();
23
22
  case "LIMIT": return String(e.count ?? "");
24
23
  case "JOIN": return e.relationship ? `${n} (${e.relationship})` : n;
25
24
  default: return n;
26
25
  }
27
26
  }
28
- function O(e, t) {
27
+ function k(e, t) {
29
28
  return {
30
29
  REPHRASED: {
31
30
  text: t("semanticfed.queryConsole.ask.assist.rephrased", "Reworded by your AI provider ({provider}) as: “{question}”", {
@@ -56,216 +55,255 @@ function O(e, t) {
56
55
  }
57
56
  }[e.assist] ?? null;
58
57
  }
59
- function k({ translation: e, governedLabel: t, onOpenInEditor: n, latest: r }) {
60
- let a = i(), o = /* @__PURE__ */ h("pre", {
58
+ function A({ translation: e, governedLabel: t, onOpenInEditor: n, latest: r }) {
59
+ let a = o(), s = /* @__PURE__ */ _("pre", {
61
60
  className: "overflow-x-auto rounded bg-muted p-3 font-mono text-xs text-foreground",
62
61
  "data-testid": r ? "nl-ask-sql" : void 0,
63
62
  children: e.sql
64
63
  });
65
- return /* @__PURE__ */ g("div", {
64
+ return /* @__PURE__ */ v("div", {
66
65
  className: "space-y-2 rounded border p-3",
67
66
  "data-testid": r ? "nl-ask-interpretation" : void 0,
68
67
  children: [
69
- /* @__PURE__ */ g("div", {
68
+ /* @__PURE__ */ v("div", {
70
69
  className: "flex flex-wrap items-center justify-between gap-2",
71
- children: [/* @__PURE__ */ g("div", {
70
+ children: [/* @__PURE__ */ v("div", {
72
71
  className: "flex flex-wrap items-center gap-2 text-xs",
73
72
  children: [
74
- /* @__PURE__ */ h("span", {
73
+ /* @__PURE__ */ _("span", {
75
74
  className: "font-medium",
76
75
  children: a("semanticfed.queryConsole.ask.interpretation", "Interpretation")
77
76
  }),
78
- e.followUp && /* @__PURE__ */ g(_, {
77
+ e.followUp && /* @__PURE__ */ v(y, {
79
78
  variant: "outline",
80
79
  "data-testid": r ? "nl-ask-followup" : void 0,
81
- children: [/* @__PURE__ */ h(s, { className: "mr-1 h-3 w-3" }), a("semanticfed.queryConsole.ask.followUp", "Follow-up")]
80
+ children: [/* @__PURE__ */ _(l, { className: "me-1 h-3 w-3 rtl:-scale-x-100" }), a("semanticfed.queryConsole.ask.followUp", "Follow-up")]
82
81
  }),
83
- /* @__PURE__ */ h(_, {
82
+ /* @__PURE__ */ _(y, {
84
83
  variant: "outline",
85
84
  "data-testid": r ? "nl-ask-confidence" : void 0,
86
85
  children: a("semanticfed.queryConsole.ask.confidence", "Confidence {value}%", { value: Math.round(e.confidence * 100) })
87
86
  }),
88
- e.steps.map((e, n) => /* @__PURE__ */ g(_, {
87
+ i(e.steps, (e) => `${e.kind}:${O(e, t)}`).map(({ key: e, item: n }) => /* @__PURE__ */ v(y, {
89
88
  variant: "secondary",
90
89
  className: "font-mono",
91
90
  children: [
92
- e.kind.replace("_", " "),
91
+ n.kind.replace("_", " "),
93
92
  ": ",
94
- D(e, t)
93
+ O(n, t)
95
94
  ]
96
- }, `${e.kind}-${n}`))
95
+ }, e))
97
96
  ]
98
- }), /* @__PURE__ */ g(v, {
97
+ }), /* @__PURE__ */ v(b, {
99
98
  size: "sm",
100
99
  variant: "outline",
101
100
  onClick: () => n(e.sql ?? ""),
102
101
  "data-testid": r ? "nl-ask-open-editor" : void 0,
103
- children: [/* @__PURE__ */ h(d, { className: "mr-2 h-4 w-4" }), a("semanticfed.queryConsole.ask.openInEditor", "Edit as SQL")]
102
+ children: [/* @__PURE__ */ _(p, { className: "me-2 h-4 w-4" }), a("semanticfed.queryConsole.ask.openInEditor", "Edit as SQL")]
104
103
  })]
105
104
  }),
106
- r ? o : /* @__PURE__ */ g("details", { children: [/* @__PURE__ */ h("summary", {
105
+ r ? s : /* @__PURE__ */ v("details", { children: [/* @__PURE__ */ _("summary", {
107
106
  className: "cursor-pointer text-xs text-muted-foreground",
108
107
  children: a("semanticfed.queryConsole.ask.showSql", "Show SQL")
109
- }), o] }),
110
- e.unmatchedTerms.length > 0 && /* @__PURE__ */ h("p", {
108
+ }), s] }),
109
+ e.unmatchedTerms.length > 0 && /* @__PURE__ */ _("p", {
111
110
  className: "text-xs text-muted-foreground",
112
111
  children: a("semanticfed.queryConsole.ask.ignored", "Ignored words: {terms}", { terms: e.unmatchedTerms.join(", ") })
113
112
  })
114
113
  ]
115
114
  });
116
115
  }
117
- function A({ modelId: s, maxRows: d, onAnswer: _, onError: E, onOpenInEditor: D }) {
118
- let A = i(), [j, M] = o(""), [N, P] = o([]), [F, I] = o(s), [L, R] = o(!1), z = a(0), B = t(s), V = e();
119
- F !== s && (I(s), P([]));
120
- let H = async (e) => {
116
+ function j({ translation: e, latest: t, tr: n }) {
117
+ return /* @__PURE__ */ v("div", {
118
+ className: "flex items-start gap-2 rounded border border-dashed p-3 text-sm",
119
+ "data-testid": t ? "nl-ask-clarification" : void 0,
120
+ children: [/* @__PURE__ */ _(u, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" }), /* @__PURE__ */ v("div", {
121
+ className: "min-w-0 space-y-1",
122
+ children: [/* @__PURE__ */ _("p", { children: e.clarification }), e.unmatchedTerms.length > 0 && /* @__PURE__ */ _("p", {
123
+ className: "text-xs text-muted-foreground",
124
+ children: n("semanticfed.queryConsole.ask.unmatched", "Not found in the model: {terms}", { terms: e.unmatchedTerms.join(", ") })
125
+ })]
126
+ })]
127
+ });
128
+ }
129
+ function M({ turn: e, latest: t, governedLabel: n, onOpenInEditor: r, tr: i }) {
130
+ let a = e.answer?.translation ?? null, o = a ? k(a, i) : null;
131
+ return /* @__PURE__ */ v("li", {
132
+ className: "space-y-2",
133
+ "data-testid": "nl-ask-turn",
134
+ children: [
135
+ /* @__PURE__ */ _("p", {
136
+ className: "w-fit max-w-full rounded-lg bg-muted px-3 py-2 text-sm",
137
+ children: e.question
138
+ }),
139
+ e.error && /* @__PURE__ */ _("p", {
140
+ className: "text-xs text-destructive",
141
+ children: e.error
142
+ }),
143
+ o && /* @__PURE__ */ v("p", {
144
+ className: `flex items-start gap-1 text-xs ${o.tone === "warn" ? "text-muted-foreground" : "text-primary"}`,
145
+ "data-testid": t ? "nl-ask-assist-note" : void 0,
146
+ children: [/* @__PURE__ */ _(g, { className: "mt-0.5 h-3 w-3 shrink-0" }), o.text]
147
+ }),
148
+ a?.status === "NEEDS_CLARIFICATION" && /* @__PURE__ */ _(j, {
149
+ translation: a,
150
+ latest: t,
151
+ tr: i
152
+ }),
153
+ a?.status === "TRANSLATED" && a.sql && /* @__PURE__ */ _(A, {
154
+ translation: a,
155
+ governedLabel: n,
156
+ onOpenInEditor: r,
157
+ latest: t
158
+ })
159
+ ]
160
+ });
161
+ }
162
+ function N({ hasTurns: e, busy: t, showSettings: n, onNewConversation: r, onToggleSettings: i, tr: a }) {
163
+ return /* @__PURE__ */ v(C, {
164
+ className: "pb-3",
165
+ children: [/* @__PURE__ */ v("div", {
166
+ className: "flex flex-wrap items-center justify-between gap-2",
167
+ children: [/* @__PURE__ */ v(w, {
168
+ className: "flex items-center gap-2 text-base",
169
+ children: [/* @__PURE__ */ _(f, { className: "h-4 w-4" }), a("semanticfed.queryConsole.ask.title", "Ask a question")]
170
+ }), /* @__PURE__ */ v("div", {
171
+ className: "flex flex-wrap gap-2",
172
+ children: [e && /* @__PURE__ */ v(b, {
173
+ size: "sm",
174
+ variant: "ghost",
175
+ onClick: r,
176
+ disabled: t,
177
+ "data-testid": "nl-ask-new-conversation",
178
+ children: [/* @__PURE__ */ _(m, { className: "me-2 h-4 w-4" }), a("semanticfed.queryConsole.ask.newConversation", "New conversation")]
179
+ }), /* @__PURE__ */ v(b, {
180
+ size: "sm",
181
+ variant: n ? "secondary" : "ghost",
182
+ onClick: i,
183
+ "aria-expanded": n,
184
+ "data-testid": "nl-assist-toggle",
185
+ children: [/* @__PURE__ */ _(g, { className: "me-2 h-4 w-4" }), a("semanticfed.queryConsole.ask.assistSettings", "AI assistance")]
186
+ })]
187
+ })]
188
+ }), /* @__PURE__ */ _("p", {
189
+ className: "text-xs text-muted-foreground",
190
+ children: a("semanticfed.queryConsole.ask.conversationDescription", "Ask in plain English, then refine with follow-ups such as “and by status?”, “only EU” or “top 3 instead”. Answers come from the model’s governed metrics and dimensions, with your access policies applied, and the SQL that ran is shown.")
191
+ })]
192
+ });
193
+ }
194
+ function P({ question: e, onQuestionChange: t, onSubmit: n, isFollowUp: r, disabled: i, busy: a, tr: o }) {
195
+ return /* @__PURE__ */ v("form", {
196
+ className: "flex flex-col gap-2 sm:flex-row",
197
+ onSubmit: (e) => {
198
+ e.preventDefault(), n();
199
+ },
200
+ children: [
201
+ /* @__PURE__ */ _("label", {
202
+ className: "sr-only",
203
+ htmlFor: "nl-ask-input",
204
+ children: o("semanticfed.queryConsole.ask.inputLabel", "Your question")
205
+ }),
206
+ /* @__PURE__ */ _("input", {
207
+ id: "nl-ask-input",
208
+ "data-testid": "nl-ask-input",
209
+ className: "min-w-0 flex-1 rounded border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary",
210
+ value: e,
211
+ maxLength: T,
212
+ onChange: (e) => t(e.target.value),
213
+ placeholder: r ? o("semanticfed.queryConsole.ask.followUpPlaceholder", "Ask a follow-up, e.g. and by status?") : o("semanticfed.queryConsole.ask.placeholder", "e.g. top 5 regions by revenue"),
214
+ disabled: i
215
+ }),
216
+ /* @__PURE__ */ v(b, {
217
+ type: "submit",
218
+ size: "sm",
219
+ className: "sm:self-stretch",
220
+ disabled: i || e.trim() === "" || a,
221
+ "data-testid": "nl-ask-submit",
222
+ children: [a ? /* @__PURE__ */ _(d, { className: "me-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ _(h, { className: "me-2 h-4 w-4" }), o("semanticfed.queryConsole.ask.submit", "Ask")]
223
+ })
224
+ ]
225
+ });
226
+ }
227
+ function F(e, t) {
228
+ let n = e.at(-1)?.answer?.translation ?? null;
229
+ return n?.status === "NEEDS_CLARIFICATION" ? n.suggestions.slice(0, E) : e.length === 0 ? (t ?? []).slice(0, E) : [];
230
+ }
231
+ function I({ modelId: i, maxRows: l, onAnswer: u, onError: d, onOpenInEditor: f }) {
232
+ let p = o(), [m, h] = c(""), [g, y] = c([]), [b, C] = c(i), [w, T] = c(!1), E = s(0), D = t(i), O = e();
233
+ b !== i && (C(i), y([]));
234
+ let k = async (e) => {
121
235
  let t = e.trim();
122
- if (!s || t === "" || V.isPending) return;
123
- let n = T(N);
124
- z.current += 1;
125
- let i = z.current;
236
+ if (!i || t === "" || O.isPending) return;
237
+ let n = r(g);
238
+ E.current += 1;
239
+ let o = E.current;
126
240
  try {
127
- let e = await V.mutateAsync({
241
+ let e = await O.mutateAsync({
128
242
  question: t,
129
- modelId: s,
130
- maxRows: d,
243
+ modelId: i,
244
+ maxRows: l,
131
245
  ...n.length > 0 ? { history: n } : {}
132
246
  });
133
- P((n) => [...n, {
134
- id: i,
247
+ y((n) => [...n, {
248
+ id: o,
135
249
  question: t,
136
250
  answer: e,
137
251
  error: null
138
- }]), M(""), _(e);
252
+ }]), h(""), u(e);
139
253
  } catch (e) {
140
- let n = r(e);
141
- P((e) => [...e, {
142
- id: i,
254
+ let n = a(e, p);
255
+ y((e) => [...e, {
256
+ id: o,
143
257
  question: t,
144
258
  answer: null,
145
259
  error: n
146
- }]), E(n);
260
+ }]), d(n);
147
261
  }
148
- }, U = (e) => {
149
- M(e), H(e);
150
- }, W = (N.at(-1) ?? null)?.answer?.translation ?? null, G = (W?.status === "NEEDS_CLARIFICATION" ? W.suggestions : N.length === 0 ? B.data ?? [] : []).slice(0, w), K = A("semanticfed.queryConsole.ask.governed", "(governed)");
151
- return /* @__PURE__ */ g(y, {
262
+ }, A = (e) => {
263
+ h(e), k(e);
264
+ }, j = F(g, D.data), I = p("semanticfed.queryConsole.ask.governed", "(governed)");
265
+ return /* @__PURE__ */ v(x, {
152
266
  "data-testid": "nl-ask-panel",
153
- children: [/* @__PURE__ */ g(x, {
154
- className: "pb-3",
155
- children: [/* @__PURE__ */ g("div", {
156
- className: "flex flex-wrap items-center justify-between gap-2",
157
- children: [/* @__PURE__ */ g(S, {
158
- className: "flex items-center gap-2 text-base",
159
- children: [/* @__PURE__ */ h(u, { className: "h-4 w-4" }), A("semanticfed.queryConsole.ask.title", "Ask a question")]
160
- }), /* @__PURE__ */ g("div", {
161
- className: "flex flex-wrap gap-2",
162
- children: [N.length > 0 && /* @__PURE__ */ g(v, {
163
- size: "sm",
164
- variant: "ghost",
165
- onClick: () => P([]),
166
- disabled: V.isPending,
167
- "data-testid": "nl-ask-new-conversation",
168
- children: [/* @__PURE__ */ h(f, { className: "mr-2 h-4 w-4" }), A("semanticfed.queryConsole.ask.newConversation", "New conversation")]
169
- }), /* @__PURE__ */ g(v, {
170
- size: "sm",
171
- variant: L ? "secondary" : "ghost",
172
- onClick: () => R((e) => !e),
173
- "aria-expanded": L,
174
- "data-testid": "nl-assist-toggle",
175
- children: [/* @__PURE__ */ h(m, { className: "mr-2 h-4 w-4" }), A("semanticfed.queryConsole.ask.assistSettings", "AI assistance")]
176
- })]
177
- })]
178
- }), /* @__PURE__ */ h("p", {
179
- className: "text-xs text-muted-foreground",
180
- children: A("semanticfed.queryConsole.ask.conversationDescription", "Ask in plain English, then refine with follow-ups such as “and by status?”, “only EU” or “top 3 instead”. Answers come from the model’s governed metrics and dimensions, with your access policies applied, and the SQL that ran is shown.")
181
- })]
182
- }), /* @__PURE__ */ g(b, {
267
+ children: [/* @__PURE__ */ _(N, {
268
+ hasTurns: g.length > 0,
269
+ busy: O.isPending,
270
+ showSettings: w,
271
+ onNewConversation: () => y([]),
272
+ onToggleSettings: () => T((e) => !e),
273
+ tr: p
274
+ }), /* @__PURE__ */ v(S, {
183
275
  className: "space-y-3",
184
276
  children: [
185
- L && /* @__PURE__ */ h(n, {}),
186
- N.length > 0 && /* @__PURE__ */ h("ol", {
277
+ w && /* @__PURE__ */ _(n, {}),
278
+ g.length > 0 && /* @__PURE__ */ _("ol", {
187
279
  className: "space-y-3",
188
280
  "data-testid": "nl-ask-thread",
189
281
  "aria-live": "polite",
190
- children: N.map((e, t) => {
191
- let n = t === N.length - 1, r = e.answer?.translation ?? null, i = r ? O(r, A) : null;
192
- return /* @__PURE__ */ g("li", {
193
- className: "space-y-2",
194
- "data-testid": "nl-ask-turn",
195
- children: [
196
- /* @__PURE__ */ h("p", {
197
- className: "w-fit max-w-full rounded-lg bg-muted px-3 py-2 text-sm",
198
- children: e.question
199
- }),
200
- e.error && /* @__PURE__ */ h("p", {
201
- className: "text-xs text-destructive",
202
- children: e.error
203
- }),
204
- i && /* @__PURE__ */ g("p", {
205
- className: `flex items-start gap-1 text-xs ${i.tone === "warn" ? "text-muted-foreground" : "text-primary"}`,
206
- "data-testid": n ? "nl-ask-assist-note" : void 0,
207
- children: [/* @__PURE__ */ h(m, { className: "mt-0.5 h-3 w-3 shrink-0" }), i.text]
208
- }),
209
- r?.status === "NEEDS_CLARIFICATION" && /* @__PURE__ */ g("div", {
210
- className: "flex items-start gap-2 rounded border border-dashed p-3 text-sm",
211
- "data-testid": n ? "nl-ask-clarification" : void 0,
212
- children: [/* @__PURE__ */ h(c, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" }), /* @__PURE__ */ g("div", {
213
- className: "min-w-0 space-y-1",
214
- children: [/* @__PURE__ */ h("p", { children: r.clarification }), r.unmatchedTerms.length > 0 && /* @__PURE__ */ h("p", {
215
- className: "text-xs text-muted-foreground",
216
- children: A("semanticfed.queryConsole.ask.unmatched", "Not found in the model: {terms}", { terms: r.unmatchedTerms.join(", ") })
217
- })]
218
- })]
219
- }),
220
- r?.status === "TRANSLATED" && r.sql && /* @__PURE__ */ h(k, {
221
- translation: r,
222
- governedLabel: K,
223
- onOpenInEditor: D,
224
- latest: n
225
- })
226
- ]
227
- }, e.id);
228
- })
282
+ children: g.map((e, t) => /* @__PURE__ */ _(M, {
283
+ turn: e,
284
+ latest: t === g.length - 1,
285
+ governedLabel: I,
286
+ onOpenInEditor: f,
287
+ tr: p
288
+ }, e.id))
229
289
  }),
230
- /* @__PURE__ */ g("form", {
231
- className: "flex flex-col gap-2 sm:flex-row",
232
- onSubmit: (e) => {
233
- e.preventDefault(), H(j);
234
- },
235
- children: [
236
- /* @__PURE__ */ h("label", {
237
- className: "sr-only",
238
- htmlFor: "nl-ask-input",
239
- children: A("semanticfed.queryConsole.ask.inputLabel", "Your question")
240
- }),
241
- /* @__PURE__ */ h("input", {
242
- id: "nl-ask-input",
243
- "data-testid": "nl-ask-input",
244
- className: "min-w-0 flex-1 rounded border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary",
245
- value: j,
246
- maxLength: C,
247
- onChange: (e) => M(e.target.value),
248
- placeholder: N.length > 0 ? A("semanticfed.queryConsole.ask.followUpPlaceholder", "Ask a follow-up, e.g. and by status?") : A("semanticfed.queryConsole.ask.placeholder", "e.g. top 5 regions by revenue"),
249
- disabled: !s
250
- }),
251
- /* @__PURE__ */ g(v, {
252
- type: "submit",
253
- size: "sm",
254
- className: "sm:self-stretch",
255
- disabled: !s || j.trim() === "" || V.isPending,
256
- "data-testid": "nl-ask-submit",
257
- children: [V.isPending ? /* @__PURE__ */ h(l, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ h(p, { className: "mr-2 h-4 w-4" }), A("semanticfed.queryConsole.ask.submit", "Ask")]
258
- })
259
- ]
290
+ /* @__PURE__ */ _(P, {
291
+ question: m,
292
+ onQuestionChange: h,
293
+ onSubmit: () => void k(m),
294
+ isFollowUp: g.length > 0,
295
+ disabled: !i,
296
+ busy: O.isPending,
297
+ tr: p
260
298
  }),
261
- G.length > 0 && /* @__PURE__ */ h("div", {
299
+ j.length > 0 && /* @__PURE__ */ _("div", {
262
300
  className: "flex flex-wrap gap-2",
263
301
  "data-testid": "nl-ask-suggestions",
264
- children: G.map((e) => /* @__PURE__ */ h("button", {
302
+ children: j.map((e) => /* @__PURE__ */ _("button", {
265
303
  type: "button",
266
304
  className: "rounded-full border px-3 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground",
267
- onClick: () => U(e),
268
- disabled: V.isPending,
305
+ onClick: () => A(e),
306
+ disabled: O.isPending,
269
307
  children: e
270
308
  }, e))
271
309
  })
@@ -273,6 +311,6 @@ function A({ modelId: s, maxRows: d, onAnswer: _, onError: E, onOpenInEditor: D
273
311
  })]
274
312
  });
275
313
  }
276
- export { A as AskQuestionPanel, T as conversationHistory };
314
+ export { I as AskQuestionPanel };
277
315
 
278
316
  //# sourceMappingURL=AskQuestionPanel.js.map