react-semaphor 0.1.398 → 0.1.400

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 (59) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +2 -2
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +2 -2
  5. package/dist/chunks/analyze-result-contract-BUgK3759.js +1833 -0
  6. package/dist/chunks/analyze-result-contract-S8u7CcPL.js +1 -0
  7. package/dist/chunks/{calendar-preferences-dialog-DwLeBLy2.js → calendar-preferences-dialog-Ci3rHHgA.js} +1 -1
  8. package/dist/chunks/{calendar-preferences-dialog-49fcEPXS.js → calendar-preferences-dialog-i3-jBIYS.js} +3 -3
  9. package/dist/chunks/{dashboard-briefing-launcher-cgPKz1yX.js → dashboard-briefing-launcher-BpwjeJsQ.js} +4 -4
  10. package/dist/chunks/{dashboard-briefing-launcher-CgkSKkZR.js → dashboard-briefing-launcher-DiEpMS9E.js} +1 -1
  11. package/dist/chunks/{dashboard-controls-D12ZSUP_.js → dashboard-controls-BaUUrvSI.js} +1 -1
  12. package/dist/chunks/{dashboard-controls-VMFm3OP4.js → dashboard-controls-Bkjpgr3d.js} +5 -5
  13. package/dist/chunks/{dashboard-json-CvK0oI24.js → dashboard-json-CxNyExRm.js} +1 -1
  14. package/dist/chunks/{dashboard-json-C-GG5yC7.js → dashboard-json-DvULhhN2.js} +3 -3
  15. package/dist/chunks/{edit-dashboard-visual-B5KB7dx4.js → edit-dashboard-visual-DBrsgEtL.js} +4 -4
  16. package/dist/chunks/{edit-dashboard-visual-ql99faTz.js → edit-dashboard-visual-DJRPiKdY.js} +1 -1
  17. package/dist/chunks/{index-DXCBPLDu.js → index-BepF6hoa.js} +2 -2
  18. package/dist/chunks/{index-CQmKDEbe.js → index-Drz04wqE.js} +5 -5
  19. package/dist/chunks/{switch-B79Hn4Qh.js → switch-D2oOmorN.js} +1 -1
  20. package/dist/chunks/{switch-BXQAlSuW.js → switch-qUw8u-gU.js} +1 -1
  21. package/dist/chunks/update-policy-BmtOqvbf.js +3 -0
  22. package/dist/chunks/update-policy-KImUg4Od.js +831 -0
  23. package/dist/chunks/{use-create-flow-overlay-state-Bw5LRkf9.js → use-create-flow-overlay-state-CFJIHt5D.js} +3 -3
  24. package/dist/chunks/{use-create-flow-overlay-state-7MFN3PWX.js → use-create-flow-overlay-state-DrkYiyQz.js} +1 -1
  25. package/dist/chunks/{validators-4EGCWWga.js → validators-B1Mgdr3T.js} +279 -242
  26. package/dist/chunks/{validators-CPtkrola.js → validators-DFOX0tYY.js} +1 -1
  27. package/dist/dashboard/index.cjs +1 -1
  28. package/dist/dashboard/index.js +1 -1
  29. package/dist/dashboard-authoring/index.cjs +1 -1
  30. package/dist/dashboard-authoring/index.js +2 -2
  31. package/dist/data-app-builder/index.cjs +1 -1
  32. package/dist/data-app-builder/index.js +2 -2
  33. package/dist/data-app-codegen/index.cjs +1 -0
  34. package/dist/data-app-codegen/index.js +22 -0
  35. package/dist/data-app-codegen-node/index.cjs +462 -0
  36. package/dist/data-app-codegen-node/index.js +1424 -0
  37. package/dist/data-app-sdk/index.cjs +2 -2
  38. package/dist/data-app-sdk/index.js +3 -2
  39. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  40. package/dist/data-app-sdk-adapters/index.js +20 -12
  41. package/dist/data-app-sdk-validation/index.cjs +1 -1
  42. package/dist/data-app-sdk-validation/index.js +2 -2
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.js +7 -7
  45. package/dist/surfboard/index.cjs +1 -1
  46. package/dist/surfboard/index.js +2 -2
  47. package/dist/types/analytics-protocol.d.ts +101 -2
  48. package/dist/types/dashboard-assistant.d.ts +14 -0
  49. package/dist/types/dashboard-authoring.d.ts +6 -0
  50. package/dist/types/data-app-builder.d.ts +6 -0
  51. package/dist/types/data-app-codegen-node.d.ts +1165 -0
  52. package/dist/types/data-app-codegen.d.ts +1137 -0
  53. package/dist/types/data-app-sdk-adapters.d.ts +7 -0
  54. package/dist/types/data-app-sdk-validation.d.ts +15 -0
  55. package/dist/types/data-app-sdk.d.ts +18 -0
  56. package/dist/types/main.d.ts +6 -0
  57. package/package.json +9 -1
  58. package/dist/chunks/analyze-result-contract-C9Gv2_qW.js +0 -1585
  59. package/dist/chunks/analyze-result-contract-Zgg-Bbpj.js +0 -1
@@ -0,0 +1,1833 @@
1
+ import { z as e } from "zod";
2
+ const B = {
3
+ answerSummary: "string",
4
+ responseDetail: "responseDetail",
5
+ mode: "string",
6
+ comparisonType: "string",
7
+ executionResult: "executionResult",
8
+ compiledQuery: "unknown",
9
+ data: "unknown",
10
+ resultSets: "record",
11
+ analysisWarnings: "unknownArray",
12
+ columns: "unknownArray",
13
+ records: "recordArray",
14
+ rowCount: "number",
15
+ rowLimitExceeded: "boolean",
16
+ output: "string",
17
+ querySpec: "unknown",
18
+ metadata: "record",
19
+ validation: "validationResult",
20
+ coverage: "coverage",
21
+ diagnosticFeedback: "diagnosticFeedback",
22
+ missingFields: "stringArray",
23
+ warnings: "unknownArray",
24
+ comparison: "unknown",
25
+ population: "population",
26
+ comparisons: "recordArray",
27
+ fieldsUsed: "compactExecutionFieldArray",
28
+ primary: "recordArray",
29
+ contributors: "recordArray",
30
+ segments: "recordArray",
31
+ periodChanges: "recordArray",
32
+ changes: "recordArray",
33
+ largestNegativeChanges: "recordArray",
34
+ largestPositiveChanges: "recordArray",
35
+ drivers: "recordArray",
36
+ absoluteDeltaDrivers: "recordArray",
37
+ largestNegativeDrivers: "recordArray",
38
+ largestPositiveDrivers: "recordArray",
39
+ periodRows: "recordArray",
40
+ sql: "unknown",
41
+ omitted: "stringArray"
42
+ }, K = "semaphor-data-app-codegen-summary/v1", Ht = "semaphor-data-app-codegen-summary-validator/v2", ge = /* @__PURE__ */ new Set([
43
+ "metric",
44
+ "records",
45
+ "matrix",
46
+ "analysis",
47
+ "sql_fallback"
48
+ ]), he = /* @__PURE__ */ new Set([
49
+ "semaphor.metric",
50
+ "semaphor.records",
51
+ "semaphor.matrix",
52
+ "semaphor.analysis",
53
+ "semaphor.sql"
54
+ ]), fe = /* @__PURE__ */ new Set([
55
+ "absolute_delta",
56
+ "largest_negative",
57
+ "largest_positive",
58
+ "positive_and_negative",
59
+ "all"
60
+ ]), W = /* @__PURE__ */ new Set([
61
+ "source",
62
+ "id",
63
+ "label",
64
+ "measures",
65
+ "primaryMeasure",
66
+ "dateField",
67
+ "timeGrain",
68
+ "dimensions",
69
+ "comparison",
70
+ "orderBy",
71
+ "filters",
72
+ "relationshipHint",
73
+ "limit",
74
+ "derivedFields"
75
+ ]), be = /* @__PURE__ */ new Set([
76
+ ...W,
77
+ "analysis",
78
+ "timeWindow",
79
+ "filters",
80
+ "driverMode",
81
+ "includePopulation",
82
+ "calendarContext",
83
+ "chartTitle",
84
+ "chartType"
85
+ ]), ye = /* @__PURE__ */ new Set([
86
+ "source",
87
+ "id",
88
+ "label",
89
+ "fields",
90
+ "dateField",
91
+ "timeGrain",
92
+ "timeWindow",
93
+ "filters",
94
+ "orderBy",
95
+ "relationshipHint",
96
+ "limit",
97
+ "pagination",
98
+ "totals",
99
+ "derivedFields"
100
+ ]), ve = /* @__PURE__ */ new Set([
101
+ "source",
102
+ "id",
103
+ "label",
104
+ "filters",
105
+ "relationshipHint",
106
+ "rows",
107
+ "columns",
108
+ "values",
109
+ "totals",
110
+ "sort",
111
+ "expansion",
112
+ "layout",
113
+ "displayLimits"
114
+ ]), $e = /* @__PURE__ */ new Set([
115
+ "source",
116
+ "id",
117
+ "label",
118
+ "sql",
119
+ "defaultParameters",
120
+ "pythonCode",
121
+ "fields",
122
+ "limit",
123
+ "pagination",
124
+ "rationale"
125
+ ]), Se = /* @__PURE__ */ new Set([
126
+ "kpi",
127
+ "line_chart",
128
+ "bar_chart",
129
+ "stacked_bar_chart",
130
+ "pie_chart",
131
+ "donut_chart",
132
+ "area_chart",
133
+ "table",
134
+ "matrix",
135
+ "narrative",
136
+ "text_block",
137
+ "custom"
138
+ ]), we = /* @__PURE__ */ new Set([
139
+ "missing_measure",
140
+ "missing_dimension",
141
+ "missing_date",
142
+ "missing_relationship",
143
+ "missing_semantic_role",
144
+ "missing_current_app_state",
145
+ "unsupported_change_intent",
146
+ "ambiguous_field_grounding",
147
+ "invalid_ranker_output",
148
+ "latest_snapshot_selector_not_modeled",
149
+ "unsupported_grain",
150
+ "requires_sql_escape_hatch",
151
+ "unsupported_sdk_capability"
152
+ ]);
153
+ function Qt(i) {
154
+ return Z(i).ok;
155
+ }
156
+ function Z(i) {
157
+ const o = [];
158
+ if (!i || typeof i != "object")
159
+ return { ok: !1, issues: ["Summary must be an object."] };
160
+ const t = i;
161
+ return t.schemaVersion !== K && o.push(
162
+ `schemaVersion must be ${K}.`
163
+ ), (typeof t.title != "string" || !t.title.trim()) && o.push("title is required."), Array.isArray(t.sources) || o.push("sources must be an array."), Array.isArray(t.inputs) || o.push("inputs must be an array."), Array.isArray(t.views) || o.push("views must be an array."), Array.isArray(t.filterContracts) || o.push("filterContracts must be an array."), (!t.implementationChecklist || typeof t.implementationChecklist != "object") && o.push("implementationChecklist must be an object."), t.implementationChecklist && typeof t.implementationChecklist == "object" && o.push(
164
+ ...Ie(t.implementationChecklist)
165
+ ), Array.isArray(t.sources) && t.sources.forEach((s, n) => {
166
+ o.push(...w(s, `sources.${n}`));
167
+ }), Array.isArray(t.inputs) && t.inputs.forEach((s, n) => {
168
+ o.push(...Ae(s, `inputs.${n}`));
169
+ }), Array.isArray(t.views) && t.views.forEach((s, n) => {
170
+ o.push(..._e(s, `views.${n}`));
171
+ }), Array.isArray(t.filterContracts) && t.filterContracts.forEach((s, n) => {
172
+ o.push(
173
+ ...Ee(s, `filterContracts.${n}`)
174
+ );
175
+ }), t.unsupportedInsights !== void 0 && (Array.isArray(t.unsupportedInsights) ? t.unsupportedInsights.forEach((s, n) => {
176
+ o.push(
177
+ ...Ze(
178
+ s,
179
+ `unsupportedInsights.${n}`
180
+ )
181
+ );
182
+ }) : o.push("unsupportedInsights must be an array.")), o.push(...ke(t)), { ok: o.length === 0, issues: o };
183
+ }
184
+ function ke(i) {
185
+ const o = Array.isArray(i.unsupportedInsights) && i.unsupportedInsights.some(
186
+ (l) => {
187
+ var u;
188
+ return ((u = a(l)) == null ? void 0 : u.reason) === "missing_relationship";
189
+ }
190
+ ), t = Array.isArray(i.views) && i.views.some((l) => {
191
+ var c;
192
+ const u = a((c = a(l)) == null ? void 0 : c.computation);
193
+ return (u == null ? void 0 : u.kind) === "unsupported" && u.reason === "missing_relationship";
194
+ });
195
+ if (!o && !t)
196
+ return [];
197
+ const s = [], n = a(i.validation);
198
+ (n == null ? void 0 : n.status) !== "blocked" && s.push(
199
+ "validation.status must be blocked when missing_relationship gaps are present."
200
+ );
201
+ const r = a(i.nextRequiredTool);
202
+ return (r == null ? void 0 : r.name) !== "semaphor_propose_semantic_model_change" && s.push(
203
+ "nextRequiredTool.name must be semaphor_propose_semantic_model_change when missing_relationship gaps are present."
204
+ ), s;
205
+ }
206
+ function w(i, o) {
207
+ const t = a(i);
208
+ return t ? t.kind === "semantic" ? typeof t.domainId == "string" && t.domainId.trim() && typeof t.datasetName == "string" && t.datasetName.trim() ? [] : [`${o} must include sourceKey or a supported source identity.`] : typeof t.sourceKey == "string" && t.sourceKey.trim() ? [] : t.kind === "physical" && typeof t.tableName == "string" && t.tableName.trim() && typeof t.connectionId == "string" && t.connectionId.trim() ? [] : t.kind === "sql" && typeof t.connectionId == "string" && t.connectionId.trim() ? [] : [`${o} must include sourceKey or a supported source identity.`] : [`${o} must be an object.`];
209
+ }
210
+ function Ie(i) {
211
+ const o = a(i);
212
+ if (!o)
213
+ return ["implementationChecklist must be an object."];
214
+ const t = [], s = [
215
+ "requiredDevtools",
216
+ "requiredInputOptions",
217
+ "filterScopeByInput",
218
+ "bindingsByView",
219
+ "validationCommands",
220
+ "browserSmokeChecks"
221
+ ];
222
+ for (const r of s)
223
+ r in o || t.push(`implementationChecklist.${r} is required.`);
224
+ const n = a(o.requiredDevtools);
225
+ return n ? typeof n.mountRootDevtools != "boolean" && t.push(
226
+ "implementationChecklist.requiredDevtools.mountRootDevtools must be a boolean."
227
+ ) : t.push("implementationChecklist.requiredDevtools must be an object."), Array.isArray(o.requiredInputOptions) || t.push(
228
+ "implementationChecklist.requiredInputOptions must be an array."
229
+ ), Array.isArray(o.filterScopeByInput) || t.push("implementationChecklist.filterScopeByInput must be an array."), a(o.bindingsByView) || t.push("implementationChecklist.bindingsByView must be an object."), g(o.validationCommands) || t.push(
230
+ "implementationChecklist.validationCommands must be an array of strings."
231
+ ), g(o.browserSmokeChecks) || t.push(
232
+ "implementationChecklist.browserSmokeChecks must be an array of strings."
233
+ ), t;
234
+ }
235
+ function Ae(i, o) {
236
+ const t = a(i);
237
+ if (!t)
238
+ return [`${o} must be an object.`];
239
+ const s = [];
240
+ return (typeof t.id != "string" || !t.id.trim()) && s.push(`${o}.id is required.`), t.fieldRef && s.push(...p(t.fieldRef, `${o}.fieldRef`)), s.push(...X(t.optionQuery, `${o}.optionQuery`)), g(t.appliesToViewIds) || s.push(`${o}.appliesToViewIds must be an array of strings.`), t.bindings !== void 0 && !Array.isArray(t.bindings) && s.push(`${o}.bindings must be an array.`), Array.isArray(t.bindings) && t.bindings.forEach((n, r) => {
241
+ const l = a(n);
242
+ if (!l) {
243
+ s.push(`${o}.bindings.${r} must be an object.`);
244
+ return;
245
+ }
246
+ g(l.appliesToViewIds) || s.push(
247
+ `${o}.bindings.${r}.appliesToViewIds must be an array of strings.`
248
+ ), s.push(
249
+ ...p(
250
+ l.fieldRef,
251
+ `${o}.bindings.${r}.fieldRef`
252
+ )
253
+ );
254
+ }), s;
255
+ }
256
+ function _e(i, o) {
257
+ const t = a(i);
258
+ if (!t)
259
+ return [`${o} must be an object.`];
260
+ const s = [];
261
+ if ((typeof t.id != "string" || !t.id.trim()) && s.push(`${o}.id is required.`), t.visualSpec !== void 0 && s.push(...Ge(t.visualSpec, `${o}.visualSpec`)), t.computation !== void 0 && s.push(...We(t.computation, `${o}.computation`)), Le(t))
262
+ return s.push(...E(t, `${o}`)), t.fields !== void 0 && (Array.isArray(t.fields) ? t.fields.forEach((r, l) => {
263
+ s.push(...p(r, `${o}.fields.${l}`));
264
+ }) : s.push(`${o}.fields must be an array.`)), t.queryKind !== void 0 && s.push(`${o}.queryKind is not allowed for non-executable views.`), t.sdkBuilder !== void 0 && s.push(`${o}.sdkBuilder is not allowed for non-executable views.`), t.sdkSpec !== void 0 && s.push(`${o}.sdkSpec is not allowed for non-executable views.`), s;
265
+ if (!Array.isArray(t.fields))
266
+ return s.push(`${o}.fields must be an array.`), (t.sdkSpec !== void 0 || t.sdkBuilder !== void 0) && s.push(`${o}.fields must be an array for executable views.`), s.push(...E(t, `${o}`)), s;
267
+ t.fields.forEach((r, l) => {
268
+ s.push(...p(r, `${o}.fields.${l}`));
269
+ }), $(t.queryKind) || s.push(`${o}.queryKind must be a supported codegen query kind.`), t.sdkBuilder !== void 0 && !ee(t.sdkBuilder) && s.push(`${o}.sdkBuilder must be a supported SDK builder.`);
270
+ const n = a(t.computation);
271
+ return (n == null ? void 0 : n.kind) === "server_query" && $(t.queryKind) && $(n.queryKind) && n.queryKind !== t.queryKind && s.push(`${o}.computation.queryKind must match queryKind.`), s.push(
272
+ ...Fe({
273
+ value: t.sdkSpec,
274
+ path: `${o}.sdkSpec`,
275
+ queryKind: typeof t.queryKind == "string" ? t.queryKind : void 0,
276
+ sdkBuilder: typeof t.sdkBuilder == "string" ? t.sdkBuilder : void 0
277
+ }),
278
+ ...E(t, `${o}`)
279
+ ), s;
280
+ }
281
+ function E(i, o) {
282
+ var G;
283
+ const t = a((G = a(i.visualSpec)) == null ? void 0 : G.tableBehavior), s = a(i.sdkSpec), n = a(s == null ? void 0 : s.spec), r = typeof (s == null ? void 0 : s.builder) == "string" ? s.builder : void 0, l = r === "semaphor.records" ? a(n == null ? void 0 : n.totals) : void 0, u = [];
284
+ if (!t)
285
+ return l && u.push(
286
+ `${o}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`
287
+ ), u;
288
+ const c = a(t.totals);
289
+ return c ? (c.mode === "server" && (r !== "semaphor.records" && u.push(
290
+ `${o}.visualSpec.tableBehavior.totals.mode server is only supported for semaphor.records views.`
291
+ ), !l || l.mode !== "server" ? u.push(
292
+ `${o}.sdkSpec.spec.totals.mode must be server when tableBehavior.totals.mode is server.`
293
+ ) : u.push(
294
+ ...je({
295
+ left: c.measures,
296
+ right: l.measures,
297
+ leftPath: `${o}.visualSpec.tableBehavior.totals.measures`,
298
+ rightPath: `${o}.sdkSpec.spec.totals.measures`
299
+ })
300
+ )), c.mode !== "server" && l && u.push(
301
+ `${o}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`
302
+ ), r === "semaphor.sql" && c.mode !== "none" && u.push(
303
+ `${o}.visualSpec.tableBehavior.totals.mode must be none for semaphor.sql views.`
304
+ ), r === "semaphor.sql" && a(n == null ? void 0 : n.totals) && u.push(`${o}.sdkSpec.spec.totals is not supported for semaphor.sql.`), u) : (l && u.push(
305
+ `${o}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`
306
+ ), u);
307
+ }
308
+ function je({
309
+ left: i,
310
+ right: o,
311
+ leftPath: t,
312
+ rightPath: s
313
+ }) {
314
+ if (!Array.isArray(i) || !Array.isArray(o))
315
+ return [`${s} must match ${t}.`];
316
+ const n = [];
317
+ return i.length !== o.length ? (n.push(`${s} must match ${t}.`), n) : (i.forEach((r, l) => {
318
+ Re(
319
+ a(r),
320
+ a(o[l])
321
+ ) || n.push(`${s}.${l} must match ${t}.${l}.`);
322
+ }), n);
323
+ }
324
+ function Re(i, o) {
325
+ return !i || !o ? !1 : i.name === o.name && (i.role || "measure") === (o.role || "measure") && U(i) === U(o) && Ce(i, o);
326
+ }
327
+ function U(i) {
328
+ return typeof i.aggregate == "string" ? i.aggregate.toUpperCase() : "SUM";
329
+ }
330
+ function Ce(i, o) {
331
+ const t = a(i.source), s = a(o.source);
332
+ if (qe(t, s))
333
+ return !1;
334
+ const n = z(i), r = z(o);
335
+ if (n.size > 0 || r.size > 0) {
336
+ for (const l of n)
337
+ if (r.has(l))
338
+ return !0;
339
+ return !1;
340
+ }
341
+ return !t || !s || t.kind !== s.kind ? !1 : t.kind === "semantic" ? t.domainId === s.domainId && t.datasetName === s.datasetName && (t.datasetId === void 0 || s.datasetId === void 0 || t.datasetId === s.datasetId) : t.kind === "physical" ? t.connectionId === s.connectionId && t.tableName === s.tableName : t.kind === "sql" ? t.connectionId === s.connectionId : !1;
342
+ }
343
+ function qe(i, o) {
344
+ if (!i || !o || i.kind !== "semantic" || o.kind !== "semantic")
345
+ return !1;
346
+ const t = typeof i.datasetId == "string" ? i.datasetId.trim() : "", s = typeof o.datasetId == "string" ? o.datasetId.trim() : "";
347
+ return !!(t && s && t !== s);
348
+ }
349
+ function z(i) {
350
+ const o = typeof i.sourceKey == "string" ? i.sourceKey.trim() : "";
351
+ return o ? /* @__PURE__ */ new Set([o]) : xe(a(i.source));
352
+ }
353
+ function xe(i) {
354
+ const o = /* @__PURE__ */ new Set();
355
+ if (!i)
356
+ return o;
357
+ const t = typeof i.sourceKey == "string" ? i.sourceKey.trim() : "";
358
+ if (t && o.add(t), i.kind === "semantic") {
359
+ const s = typeof i.domainId == "string" ? i.domainId : "", n = typeof i.datasetName == "string" ? i.datasetName : "", r = typeof i.datasetId == "string" ? i.datasetId : "";
360
+ s && r && o.add(`semantic:${s}:datasetId:${r}`), s && n && o.add(`semantic:${s}:datasetName:${n}`);
361
+ }
362
+ if (i.kind === "physical") {
363
+ const s = typeof i.connectionId == "string" ? i.connectionId : "", n = typeof i.tableName == "string" ? i.tableName : "", r = typeof i.databaseName == "string" ? i.databaseName : "", l = typeof i.schemaName == "string" ? i.schemaName : "";
364
+ s && n && (o.add(
365
+ ["physical", s, r, l, n].join(":")
366
+ ), o.add(`physical:${s}:${n}`));
367
+ }
368
+ if (i.kind === "sql") {
369
+ const s = typeof i.connectionId == "string" ? i.connectionId : "", n = typeof i.dialect == "string" ? i.dialect : "", r = typeof i.label == "string" ? i.label : "";
370
+ s && (o.add(["sql", s, n, r].join(":")), o.add(`sql:${s}`));
371
+ }
372
+ return o;
373
+ }
374
+ function Ee(i, o) {
375
+ const t = a(i);
376
+ if (!t)
377
+ return [`${o} must be an object.`];
378
+ const s = [];
379
+ if (t.fieldRef && s.push(
380
+ ...p(t.fieldRef, `${o}.fieldRef`)
381
+ ), (typeof t.inputId != "string" || !t.inputId.trim()) && s.push(`${o}.inputId is required.`), s.push(
382
+ ...X(t.optionQuery, `${o}.optionQuery`)
383
+ ), g(t.appliesToViewIds) || s.push(`${o}.appliesToViewIds must be an array of strings.`), g(t.notAppliedToViewIds) || s.push(`${o}.notAppliedToViewIds must be an array of strings.`), !Array.isArray(t.bindings))
384
+ s.push(`${o}.bindings must be an array.`);
385
+ else {
386
+ const n = g(t.appliesToViewIds) ? new Set(t.appliesToViewIds) : void 0, r = g(
387
+ t.notAppliedToViewIds
388
+ ) ? new Set(t.notAppliedToViewIds) : void 0;
389
+ t.bindings.forEach((l, u) => {
390
+ const c = a(l);
391
+ if (!c) {
392
+ s.push(`${o}.bindings.${u} must be an object.`);
393
+ return;
394
+ }
395
+ typeof c.viewId != "string" || !c.viewId ? s.push(`${o}.bindings.${u}.viewId is required.`) : (n && !n.has(c.viewId) && s.push(
396
+ `${o}.bindings.${u}.viewId must be included in appliesToViewIds.`
397
+ ), r != null && r.has(c.viewId) && s.push(
398
+ `${o}.bindings.${u}.viewId must not be listed in notAppliedToViewIds.`
399
+ )), s.push(
400
+ ...p(
401
+ c.fieldRef,
402
+ `${o}.bindings.${u}.fieldRef`
403
+ )
404
+ );
405
+ });
406
+ }
407
+ return s;
408
+ }
409
+ function X(i, o) {
410
+ if (i === void 0)
411
+ return [];
412
+ const t = a(i);
413
+ if (!t)
414
+ return [`${o} must be an object.`];
415
+ const s = [
416
+ ...h(
417
+ t.valueFieldRef,
418
+ `${o}.valueFieldRef`
419
+ ),
420
+ ...h(
421
+ t.labelFieldRef,
422
+ `${o}.labelFieldRef`
423
+ ),
424
+ ...h(
425
+ t.filterFieldRef,
426
+ `${o}.filterFieldRef`
427
+ )
428
+ ];
429
+ return t.builder !== "semaphor.inputOptions" && s.push(`${o}.builder must be semaphor.inputOptions.`), typeof t.sourceKey != "string" && t.source === void 0 && s.push(`${o} must include source or sourceKey.`), t.source !== void 0 && s.push(...w(t.source, `${o}.source`)), a(t.valueFieldRef) || s.push(`${o}.valueFieldRef is required.`), a(t.labelFieldRef) || s.push(`${o}.labelFieldRef is required.`), t.limit !== void 0 && (typeof t.limit != "number" || !Number.isInteger(t.limit) || t.limit <= 0) && s.push(`${o}.limit must be a positive integer.`), s;
430
+ }
431
+ function Fe(i) {
432
+ var n;
433
+ const o = a(i.value);
434
+ if (!o)
435
+ return [`${i.path} is required for executable views.`];
436
+ const t = [];
437
+ if (!ee(o.builder))
438
+ return t.push(`${i.path}.builder must be a supported SDK builder.`), t;
439
+ i.sdkBuilder && o.builder !== i.sdkBuilder && t.push(`${i.path}.builder must match sdkBuilder.`), i.queryKind && $(i.queryKind) && o.builder !== Ve(i.queryKind) && t.push(`${i.path}.builder must match queryKind.`);
440
+ const s = a(o.spec);
441
+ if (!s)
442
+ return t.push(`${i.path}.spec must be an object.`), t;
443
+ switch (o.builder) {
444
+ case "semaphor.metric":
445
+ t.push(
446
+ ...v(s, W, `${i.path}.spec`),
447
+ ...A(s, i.path),
448
+ ...F(s.measures, `${i.path}.spec.measures`),
449
+ ...h(
450
+ s.primaryMeasure,
451
+ `${i.path}.spec.primaryMeasure`
452
+ ),
453
+ ...h(
454
+ s.dateField,
455
+ `${i.path}.spec.dateField`
456
+ ),
457
+ ...N(
458
+ s.dimensions,
459
+ `${i.path}.spec.dimensions`
460
+ ),
461
+ ...T(s.orderBy, `${i.path}.spec.orderBy`),
462
+ ..._(s.filters, `${i.path}.spec.filters`)
463
+ );
464
+ break;
465
+ case "semaphor.analysis":
466
+ t.push(
467
+ ...v(s, be, `${i.path}.spec`),
468
+ ...A(s, i.path),
469
+ ...F(s.measures, `${i.path}.spec.measures`),
470
+ ...h(
471
+ s.primaryMeasure,
472
+ `${i.path}.spec.primaryMeasure`
473
+ ),
474
+ ...h(
475
+ s.dateField,
476
+ `${i.path}.spec.dateField`
477
+ ),
478
+ ...N(
479
+ s.dimensions,
480
+ `${i.path}.spec.dimensions`
481
+ ),
482
+ ...T(s.orderBy, `${i.path}.spec.orderBy`),
483
+ ..._(s.filters, `${i.path}.spec.filters`),
484
+ ...Ne(s, `${i.path}.spec`)
485
+ );
486
+ break;
487
+ case "semaphor.records":
488
+ t.push(
489
+ ...v(s, ye, `${i.path}.spec`),
490
+ ...A(s, i.path),
491
+ ...F(s.fields, `${i.path}.spec.fields`),
492
+ ...h(
493
+ s.dateField,
494
+ `${i.path}.spec.dateField`
495
+ ),
496
+ ...T(s.orderBy, `${i.path}.spec.orderBy`),
497
+ ..._(s.filters, `${i.path}.spec.filters`),
498
+ ...Te(
499
+ s.totals,
500
+ `${i.path}.spec.totals`
501
+ )
502
+ );
503
+ break;
504
+ case "semaphor.matrix":
505
+ t.push(
506
+ ...v(s, ve, `${i.path}.spec`),
507
+ ...De(s, i.path),
508
+ ...Ke(s.rows, `${i.path}.spec.rows`),
509
+ ...Oe(
510
+ s.columns,
511
+ `${i.path}.spec.columns`
512
+ ),
513
+ ...Me(s.values, `${i.path}.spec.values`),
514
+ ...Be(s.sort, `${i.path}.spec.sort`),
515
+ ..._(s.filters, `${i.path}.spec.filters`)
516
+ );
517
+ break;
518
+ case "semaphor.sql":
519
+ t.push(
520
+ ...v(s, $e, `${i.path}.spec`),
521
+ ...A(s, i.path)
522
+ ), ((n = a(s.source)) == null ? void 0 : n.kind) !== "sql" && t.push(`${i.path}.spec.source.kind must be sql.`), (typeof s.sql != "string" || !s.sql.trim()) && t.push(`${i.path}.spec.sql is required.`), t.push(
523
+ ...N(
524
+ s.fields,
525
+ `${i.path}.spec.fields`
526
+ )
527
+ );
528
+ break;
529
+ }
530
+ return t;
531
+ }
532
+ function Ne(i, o) {
533
+ const t = [];
534
+ if (i.driverMode !== void 0 && !fe.has(i.driverMode) && t.push(`${o}.driverMode must be a supported analysis driver mode.`), i.includePopulation !== void 0 && typeof i.includePopulation != "boolean" && t.push(`${o}.includePopulation must be a boolean.`), i.calendarContext !== void 0) {
535
+ const s = a(i.calendarContext);
536
+ if (!s)
537
+ t.push(`${o}.calendarContext must be an object.`);
538
+ else {
539
+ s.tz !== void 0 && typeof s.tz != "string" && t.push(`${o}.calendarContext.tz must be a string.`), s.weekStart !== void 0 && (typeof s.weekStart != "number" || !Number.isInteger(s.weekStart) || s.weekStart < 0 || s.weekStart > 6) && t.push(
540
+ `${o}.calendarContext.weekStart must be an integer between 0 and 6.`
541
+ );
542
+ const n = s.anchor;
543
+ if (n !== void 0 && n !== "now") {
544
+ const r = a(n);
545
+ (!r || typeof r.iso != "string" || !r.iso.trim()) && t.push(`${o}.calendarContext.anchor must be now or { iso }.`);
546
+ }
547
+ }
548
+ }
549
+ return t;
550
+ }
551
+ function Te(i, o) {
552
+ if (i === void 0)
553
+ return [];
554
+ const t = a(i);
555
+ if (!t)
556
+ return [`${o} must be an object.`];
557
+ const s = [];
558
+ return t.mode !== "server" && s.push(`${o}.mode must be server.`), !Array.isArray(t.measures) || t.measures.length === 0 ? s.push(`${o}.measures must include at least one measure.`) : t.measures.forEach((n, r) => {
559
+ var l;
560
+ s.push(
561
+ ...te(
562
+ n,
563
+ `${o}.measures.${r}`
564
+ )
565
+ ), ((l = a(n)) == null ? void 0 : l.role) !== "measure" && s.push(`${o}.measures.${r}.role must be measure.`);
566
+ }), s;
567
+ }
568
+ function v(i, o, t) {
569
+ const s = [];
570
+ return Object.keys(i).forEach((n) => {
571
+ o.has(n) || s.push(`${t}.${n} is not supported for this SDK builder.`);
572
+ }), s;
573
+ }
574
+ function A(i, o) {
575
+ return a(i.source) ? w(i.source, `${o}.spec.source`) : [`${o}.spec.source must be an object.`];
576
+ }
577
+ function De(i, o) {
578
+ const t = a(i.source);
579
+ if (!t)
580
+ return [`${o}.spec.source must be an object.`];
581
+ const s = w(i.source, `${o}.spec.source`);
582
+ return t.kind !== "semantic" && t.kind !== "physical" && s.push(`${o}.spec.source.kind must be semantic or physical.`), s;
583
+ }
584
+ function F(i, o) {
585
+ const t = P(i, o);
586
+ return Array.isArray(i) && i.forEach((s, n) => {
587
+ t.push(...p(s, `${o}.${n}`));
588
+ }), t;
589
+ }
590
+ function N(i, o) {
591
+ if (i === void 0)
592
+ return [];
593
+ if (!Array.isArray(i))
594
+ return [`${o} must be an array.`];
595
+ const t = [];
596
+ return i.forEach((s, n) => {
597
+ t.push(...p(s, `${o}.${n}`));
598
+ }), t;
599
+ }
600
+ function T(i, o) {
601
+ if (i === void 0)
602
+ return [];
603
+ const t = a(i);
604
+ return t ? [
605
+ ...p(t.field, `${o}.field`),
606
+ ...J(t.direction, `${o}.direction`)
607
+ ] : [`${o} must be an object.`];
608
+ }
609
+ function Ke(i, o) {
610
+ const t = P(i, o);
611
+ return Array.isArray(i) && i.forEach((s, n) => {
612
+ const r = a(s);
613
+ if (!r) {
614
+ t.push(`${o}.${n} must be an object.`);
615
+ return;
616
+ }
617
+ t.push(
618
+ ...p(r.field, `${o}.${n}.field`)
619
+ );
620
+ }), t;
621
+ }
622
+ function Oe(i, o) {
623
+ if (i === void 0)
624
+ return [];
625
+ const t = [];
626
+ return Array.isArray(i) ? (i.forEach((s, n) => {
627
+ const r = a(s);
628
+ if (!r) {
629
+ t.push(`${o}.${n} must be an object.`);
630
+ return;
631
+ }
632
+ t.push(
633
+ ...p(r.field, `${o}.${n}.field`)
634
+ );
635
+ }), t) : [`${o} must be an array.`];
636
+ }
637
+ function Me(i, o) {
638
+ const t = P(i, o);
639
+ return Array.isArray(i) && i.forEach((s, n) => {
640
+ const r = a(s);
641
+ if (!r) {
642
+ t.push(`${o}.${n} must be an object.`);
643
+ return;
644
+ }
645
+ t.push(
646
+ ...p(r.field, `${o}.${n}.field`)
647
+ );
648
+ }), t;
649
+ }
650
+ function Be(i, o) {
651
+ if (i === void 0)
652
+ return [];
653
+ if (!Array.isArray(i))
654
+ return [`${o} must be an array.`];
655
+ const t = [];
656
+ return i.forEach((s, n) => {
657
+ const r = a(s);
658
+ if (!r) {
659
+ t.push(`${o}.${n} must be an object.`);
660
+ return;
661
+ }
662
+ r.axis !== "row" && r.axis !== "column" && t.push(`${o}.${n}.axis must be row or column.`), t.push(
663
+ ...J(r.direction, `${o}.${n}.direction`),
664
+ ...Pe(r.by, `${o}.${n}.by`)
665
+ );
666
+ }), t;
667
+ }
668
+ function Pe(i, o) {
669
+ const t = a(i);
670
+ if (!t)
671
+ return [`${o} must be an object.`];
672
+ switch (t.kind) {
673
+ case "label":
674
+ return [];
675
+ case "field":
676
+ return p(t.field, `${o}.field`);
677
+ case "value":
678
+ return typeof t.valueId != "string" || !t.valueId.trim() ? [`${o}.valueId is required.`] : [];
679
+ default:
680
+ return [`${o}.kind must be label, field, or value.`];
681
+ }
682
+ }
683
+ function J(i, o) {
684
+ return i === "asc" || i === "desc" ? [] : [`${o} must be asc or desc.`];
685
+ }
686
+ function _(i, o) {
687
+ if (i === void 0)
688
+ return [];
689
+ if (!Array.isArray(i))
690
+ return [`${o} must be an array.`];
691
+ const t = [];
692
+ return i.forEach((s, n) => {
693
+ const r = a(s);
694
+ if (!r) {
695
+ t.push(`${o}.${n} must be an object.`);
696
+ return;
697
+ }
698
+ t.push(...p(r.field, `${o}.${n}.field`));
699
+ }), t;
700
+ }
701
+ function P(i, o) {
702
+ return !Array.isArray(i) || i.length === 0 ? [`${o} must be a non-empty array.`] : [];
703
+ }
704
+ function Ve(i) {
705
+ switch (i) {
706
+ case "metric":
707
+ return "semaphor.metric";
708
+ case "records":
709
+ return "semaphor.records";
710
+ case "matrix":
711
+ return "semaphor.matrix";
712
+ case "analysis":
713
+ return "semaphor.analysis";
714
+ case "sql_fallback":
715
+ return "semaphor.sql";
716
+ }
717
+ }
718
+ function Le(i) {
719
+ const o = a(i.computation), t = a(i.visualSpec);
720
+ return (o == null ? void 0 : o.kind) === "presentation_only" || (o == null ? void 0 : o.kind) === "derived" || (o == null ? void 0 : o.kind) === "unsupported" || i.visual === "text_block" || (t == null ? void 0 : t.visualType) === "text_block";
721
+ }
722
+ function Ge(i, o) {
723
+ const t = a(i);
724
+ if (!t)
725
+ return [`${o} must be an object.`];
726
+ const s = [];
727
+ return Se.has(t.visualType) || s.push(`${o}.visualType must be a supported visual type.`), t.limit !== void 0 && (typeof t.limit != "number" || !Number.isInteger(t.limit) || t.limit <= 0) && s.push(`${o}.limit must be a positive integer.`), t.tableBehavior !== void 0 && s.push(
728
+ ...Ue(
729
+ t.tableBehavior,
730
+ `${o}.tableBehavior`
731
+ )
732
+ ), s;
733
+ }
734
+ function Ue(i, o) {
735
+ const t = a(i);
736
+ if (!t)
737
+ return [`${o} must be an object.`];
738
+ const s = [];
739
+ return t.tableMode !== "bounded" && t.tableMode !== "server_paginated" && t.tableMode !== "server_windowed" && s.push(`${o}.tableMode must be a supported table mode.`), s.push(
740
+ ...ze(t.height, `${o}.height`),
741
+ ...He(t.pagination, `${o}.pagination`),
742
+ ...Qe(t.sorting, `${o}.sorting`),
743
+ ...Ye(t.totals, `${o}.totals`)
744
+ ), typeof t.serverSideRequired != "boolean" && s.push(`${o}.serverSideRequired must be a boolean.`), s;
745
+ }
746
+ function ze(i, o) {
747
+ const t = a(i);
748
+ if (!t)
749
+ return [`${o} must be an object.`];
750
+ const s = [];
751
+ return (typeof t.maxPx != "number" || !Number.isInteger(t.maxPx) || t.maxPx <= 0) && s.push(`${o}.maxPx must be a positive integer.`), t.scroll !== "vertical" && t.scroll !== "both" && s.push(`${o}.scroll must be vertical or both.`), typeof t.stickyHeader != "boolean" && s.push(`${o}.stickyHeader must be a boolean.`), s;
752
+ }
753
+ function He(i, o) {
754
+ const t = a(i);
755
+ if (!t)
756
+ return [`${o} must be an object.`];
757
+ const s = [];
758
+ return t.mode !== "none" && t.mode !== "server" && t.mode !== "client_for_bounded_rows" && s.push(`${o}.mode must be a supported pagination mode.`), t.pageSize !== void 0 && (typeof t.pageSize != "number" || !Number.isInteger(t.pageSize) || t.pageSize <= 0) && s.push(`${o}.pageSize must be a positive integer.`), t.readsFrom !== void 0 && t.readsFrom !== "result.pagination" && s.push(`${o}.readsFrom must be result.pagination.`), s;
759
+ }
760
+ function Qe(i, o) {
761
+ const t = a(i);
762
+ if (!t)
763
+ return [`${o} must be an object.`];
764
+ const s = [];
765
+ return t.mode !== "server" && t.mode !== "client_for_bounded_rows" && s.push(`${o}.mode must be a supported sorting mode.`), t.defaultField !== void 0 && (typeof t.defaultField != "string" || !t.defaultField.trim()) && s.push(`${o}.defaultField must be a non-empty string.`), t.defaultDirection !== void 0 && t.defaultDirection !== "asc" && t.defaultDirection !== "desc" && s.push(`${o}.defaultDirection must be asc or desc.`), t.resetPageOnChange !== void 0 && typeof t.resetPageOnChange != "boolean" && s.push(`${o}.resetPageOnChange must be a boolean.`), s;
766
+ }
767
+ function Ye(i, o) {
768
+ const t = a(i);
769
+ if (!t)
770
+ return [`${o} must be an object.`];
771
+ const s = [];
772
+ return t.mode !== "none" && t.mode !== "server" && t.mode !== "local" ? (s.push(`${o}.mode must be none, server, or local.`), s) : t.mode === "none" ? (t.measures !== void 0 && s.push(`${o}.measures is not allowed when mode is none.`), t.label !== void 0 && s.push(`${o}.label is not allowed when mode is none.`), s) : t.mode === "server" ? (!Array.isArray(t.measures) || t.measures.length === 0 ? s.push(`${o}.measures must include at least one measure when mode is server.`) : t.measures.forEach((n, r) => {
773
+ var l;
774
+ s.push(
775
+ ...te(
776
+ n,
777
+ `${o}.measures.${r}`
778
+ )
779
+ ), ((l = a(n)) == null ? void 0 : l.role) !== "measure" && s.push(`${o}.measures.${r}.role must be measure.`);
780
+ }), t.label !== void 0 && s.push(`${o}.label is not allowed when mode is server.`), s) : (t.mode === "local" && (t.label !== "Displayed rows" && t.label !== "Current page" && s.push(`${o}.label must be Displayed rows or Current page when mode is local.`), t.measures !== void 0 && s.push(`${o}.measures is not allowed when mode is local.`)), s);
781
+ }
782
+ function We(i, o) {
783
+ const t = a(i);
784
+ if (!t)
785
+ return [`${o} must be an object.`];
786
+ const s = [];
787
+ switch (t.kind) {
788
+ case "server_query":
789
+ $(t.queryKind) || s.push(`${o}.queryKind must be a supported codegen query kind.`), t.queryOwnership !== void 0 && t.queryOwnership !== "view_owned" && t.queryOwnership !== "shared_query" && s.push(
790
+ `${o}.queryOwnership must be view_owned or shared_query.`
791
+ ), t.sourceKeys !== void 0 && !g(t.sourceKeys) && s.push(`${o}.sourceKeys must be an array of strings.`), t.fieldNames !== void 0 && !g(t.fieldNames) && s.push(`${o}.fieldNames must be an array of strings.`);
792
+ break;
793
+ case "derived":
794
+ (typeof t.upstreamViewId != "string" || !t.upstreamViewId.trim()) && s.push(`${o}.upstreamViewId is required.`), (typeof t.derivation != "string" || !t.derivation.trim()) && s.push(`${o}.derivation is required.`);
795
+ break;
796
+ case "presentation_only":
797
+ break;
798
+ case "unsupported":
799
+ (typeof t.reason != "string" || !t.reason.trim()) && s.push(`${o}.reason is required.`), (typeof t.suggestedModelingFix != "string" || !t.suggestedModelingFix.trim()) && s.push(`${o}.suggestedModelingFix is required.`);
800
+ break;
801
+ default:
802
+ s.push(`${o}.kind must be a supported computation kind.`);
803
+ }
804
+ return s;
805
+ }
806
+ function Ze(i, o) {
807
+ const t = a(i);
808
+ if (!t)
809
+ return [`${o} must be an object.`];
810
+ const s = [];
811
+ for (const r of ["title", "requestedQuestion", "suggestedModelingFix"])
812
+ (typeof t[r] != "string" || !t[r].trim()) && s.push(`${o}.${r} is required.`);
813
+ return we.has(t.reason) || s.push(`${o}.reason must be a supported unsupported insight reason.`), (t.relationshipCandidate !== void 0 || t.nextRepairAction !== void 0) && t.reason !== "missing_relationship" && s.push(
814
+ `${o} relationship repair metadata is only valid for missing_relationship unsupported insights.`
815
+ ), t.relationshipCandidate !== void 0 && s.push(
816
+ ...Je(
817
+ t.relationshipCandidate,
818
+ `${o}.relationshipCandidate`
819
+ )
820
+ ), t.nextRepairAction !== void 0 && s.push(
821
+ ...Xe(
822
+ t.nextRepairAction,
823
+ `${o}.nextRepairAction`
824
+ )
825
+ ), s;
826
+ }
827
+ function Xe(i, o) {
828
+ const t = a(i);
829
+ if (!t)
830
+ return [`${o} must be an object.`];
831
+ const s = [], n = /* @__PURE__ */ new Set(["tool", "reason"]);
832
+ return Object.keys(t).forEach((r) => {
833
+ n.has(r) || s.push(
834
+ `${o}.${r} is not supported; repair actions support only tool and reason.`
835
+ );
836
+ }), t.tool !== "semaphor_propose_semantic_model_change" && s.push(
837
+ `${o}.tool must be semaphor_propose_semantic_model_change.`
838
+ ), t.reason !== "missing_relationship" && s.push(`${o}.reason must be missing_relationship.`), s;
839
+ }
840
+ function Je(i, o) {
841
+ const t = a(i);
842
+ if (!t)
843
+ return [`${o} must be an object.`];
844
+ const s = [], n = /* @__PURE__ */ new Set(["source", "sourceFields", "target", "targetFields"]);
845
+ Object.keys(t).forEach((r) => {
846
+ n.has(r) || s.push(
847
+ `${o}.${r} is not supported; relationship candidates support only source, sourceFields, target, and targetFields.`
848
+ );
849
+ }), s.push(
850
+ ...H(t.source, `${o}.source`)
851
+ ), s.push(
852
+ ...H(t.target, `${o}.target`)
853
+ );
854
+ for (const r of ["sourceFields", "targetFields"]) {
855
+ const l = t[r];
856
+ if (!Array.isArray(l) || l.length === 0) {
857
+ s.push(`${o}.${r} must be a non-empty endpoint field array.`);
858
+ continue;
859
+ }
860
+ l.forEach((u, c) => {
861
+ s.push(
862
+ ...et(u, `${o}.${r}.${c}`)
863
+ );
864
+ });
865
+ }
866
+ return s;
867
+ }
868
+ function et(i, o) {
869
+ const t = a(i);
870
+ if (!t)
871
+ return [`${o} must be an object.`];
872
+ const s = [], n = /* @__PURE__ */ new Set(["name", "label", "role", "dataType"]);
873
+ return Object.keys(t).forEach((r) => {
874
+ n.has(r) || s.push(
875
+ `${o}.${r} is not supported; relationship candidate fields are scoped by their endpoint and support only name, label, role, and dataType.`
876
+ );
877
+ }), (typeof t.name != "string" || !t.name.trim()) && s.push(`${o}.name must be a non-empty string.`), t.role !== void 0 && (typeof t.role != "string" || !["dimension", "measure", "date", "id", "unknown"].includes(t.role)) && s.push(`${o}.role must be dimension, measure, date, id, or unknown.`), t.dataType !== void 0 && (typeof t.dataType != "string" || !["string", "number", "boolean", "date", "datetime", "unknown"].includes(
878
+ t.dataType
879
+ )) && s.push(
880
+ `${o}.dataType must be string, number, boolean, date, datetime, or unknown.`
881
+ ), s;
882
+ }
883
+ function H(i, o) {
884
+ const t = a(i);
885
+ if (!t)
886
+ return [`${o} must be an object.`];
887
+ const s = [], n = /* @__PURE__ */ new Set([
888
+ "kind",
889
+ "domainId",
890
+ "datasetName",
891
+ "datasetId",
892
+ "label",
893
+ "sourceKey"
894
+ ]);
895
+ return Object.keys(t).forEach((r) => {
896
+ n.has(r) || s.push(
897
+ `${o}.${r} is not supported; relationship candidate sources support only semantic identity fields.`
898
+ );
899
+ }), t.kind !== "semantic" && s.push(`${o} must use semantic source identity.`), (typeof t.domainId != "string" || !t.domainId.trim() || typeof t.datasetName != "string" || !t.datasetName.trim()) && s.push(`${o} must include semantic domainId and datasetName.`), s;
900
+ }
901
+ function $(i) {
902
+ return ge.has(i);
903
+ }
904
+ function ee(i) {
905
+ return he.has(i);
906
+ }
907
+ function h(i, o) {
908
+ return i === void 0 ? [] : p(i, o);
909
+ }
910
+ function p(i, o) {
911
+ const t = a(i);
912
+ if (!t)
913
+ return [`${o} must be an object.`];
914
+ const s = [];
915
+ return (typeof t.name != "string" || !t.name.trim()) && s.push(`${o}.name is required.`), !t.source && typeof t.sourceKey != "string" && s.push(`${o} must include source or sourceKey.`), s;
916
+ }
917
+ function te(i, o) {
918
+ const t = a(i), s = p(i, o);
919
+ if (!t || typeof t.sourceKey == "string" && t.sourceKey.trim())
920
+ return s;
921
+ if (t.source !== void 0) {
922
+ const r = w(t.source, `${o}.source`);
923
+ return r.length === 0 || s.push(...r), s;
924
+ }
925
+ return s.includes(`${o} must include source or sourceKey.`) || s.push(`${o} must include source or sourceKey.`), s;
926
+ }
927
+ function a(i) {
928
+ return i && typeof i == "object" && !Array.isArray(i) ? i : void 0;
929
+ }
930
+ function g(i) {
931
+ return Array.isArray(i) && i.every((o) => typeof o == "string");
932
+ }
933
+ const m = e.record(e.string(), e.unknown()), R = e.array(m), d = e.enum([
934
+ "SUM",
935
+ "COUNT",
936
+ "AVG",
937
+ "MIN",
938
+ "MAX",
939
+ "MEDIAN",
940
+ "DISTINCT"
941
+ ]), C = e.enum([
942
+ "postgres",
943
+ "mysql",
944
+ "mssql",
945
+ "snowflake",
946
+ "clickhouse",
947
+ "bigquery",
948
+ "redshift",
949
+ "duckdb",
950
+ "sqlite",
951
+ "unknown"
952
+ ]), oe = e.enum([
953
+ "hour",
954
+ "day",
955
+ "week",
956
+ "month",
957
+ "quarter",
958
+ "year"
959
+ ]), q = e.enum([
960
+ "dimension",
961
+ "measure",
962
+ "date",
963
+ "id",
964
+ "unknown"
965
+ ]), x = e.enum([
966
+ "string",
967
+ "number",
968
+ "boolean",
969
+ "date",
970
+ "datetime",
971
+ "unknown"
972
+ ]), se = e.enum([
973
+ "semantic_model",
974
+ "caller_override",
975
+ "default_sum"
976
+ ]), j = e.union([e.number(), e.string(), e.null()]), D = e.enum([
977
+ "millisecond",
978
+ "second",
979
+ "minute",
980
+ "hour",
981
+ "day"
982
+ ]), ie = e.union([
983
+ e.object({
984
+ type: e.enum(["number", "currency", "percent", "percentage", "scientific"]),
985
+ locale: e.string().optional(),
986
+ minimumFractionDigits: e.number().optional(),
987
+ maximumFractionDigits: e.number().optional(),
988
+ useGrouping: e.boolean().optional(),
989
+ prefix: e.string().optional(),
990
+ suffix: e.string().optional(),
991
+ negativeStyle: e.enum(["minus", "parentheses"]).optional(),
992
+ compact: e.boolean().optional(),
993
+ scale: e.number().optional(),
994
+ currency: e.string().optional(),
995
+ percentValueMode: e.enum(["fraction", "whole"]).optional()
996
+ }).passthrough(),
997
+ e.object({
998
+ type: e.enum(["date", "datetime"]),
999
+ locale: e.string().optional(),
1000
+ pattern: e.string().optional(),
1001
+ relative: e.boolean().optional(),
1002
+ timezone: e.string().optional(),
1003
+ sourceTimezone: e.string().optional(),
1004
+ prefix: e.string().optional(),
1005
+ suffix: e.string().optional()
1006
+ }).passthrough(),
1007
+ e.object({
1008
+ type: e.literal("duration"),
1009
+ inputUnit: D.optional(),
1010
+ outputStyle: e.enum(["compact", "digital", "long"]).optional(),
1011
+ largestUnit: D.optional(),
1012
+ smallestUnit: D.optional(),
1013
+ maxUnits: e.number().optional(),
1014
+ prefix: e.string().optional(),
1015
+ suffix: e.string().optional(),
1016
+ negativeStyle: e.enum(["minus", "parentheses"]).optional()
1017
+ }).passthrough(),
1018
+ e.object({
1019
+ type: e.literal("string"),
1020
+ prefix: e.string().optional(),
1021
+ suffix: e.string().optional()
1022
+ }).passthrough()
1023
+ ]), tt = e.union([
1024
+ e.object({ kind: e.literal("defaultAggregate") }).passthrough(),
1025
+ e.object({ kind: e.literal("blank") }).passthrough(),
1026
+ e.object({
1027
+ kind: e.literal("labelOnly"),
1028
+ label: e.string().optional()
1029
+ }).passthrough(),
1030
+ e.object({
1031
+ kind: e.literal("customAggregate"),
1032
+ aggregate: d
1033
+ }).passthrough(),
1034
+ e.object({ kind: e.literal("percentOfParent") }).passthrough(),
1035
+ e.object({ kind: e.literal("percentOfGrandTotal") }).passthrough(),
1036
+ e.object({
1037
+ kind: e.literal("customExpression"),
1038
+ expressionId: e.string()
1039
+ }).passthrough()
1040
+ ]);
1041
+ function k(i, o) {
1042
+ return e.object(i).passthrough().superRefine((t, s) => {
1043
+ for (const n of o)
1044
+ Object.prototype.hasOwnProperty.call(t, n) || s.addIssue({
1045
+ code: "custom",
1046
+ path: [n],
1047
+ message: `Required field "${n}" is missing.`
1048
+ });
1049
+ });
1050
+ }
1051
+ const ne = e.object({
1052
+ kind: e.literal("semantic"),
1053
+ domainId: e.string(),
1054
+ datasetName: e.string(),
1055
+ datasetId: e.string().optional(),
1056
+ label: e.string().optional(),
1057
+ connectionId: e.string().optional()
1058
+ }).passthrough(), ot = e.object({
1059
+ kind: e.literal("physical"),
1060
+ connectionId: e.string(),
1061
+ connectionType: e.string().optional(),
1062
+ tableName: e.string(),
1063
+ databaseName: e.string().optional(),
1064
+ schemaName: e.string().optional(),
1065
+ label: e.string().optional(),
1066
+ dialect: C.optional()
1067
+ }).passthrough(), st = e.object({
1068
+ kind: e.literal("sql"),
1069
+ connectionId: e.string(),
1070
+ dialect: C.optional(),
1071
+ label: e.string().optional()
1072
+ }).passthrough(), S = e.union([
1073
+ ne,
1074
+ ot,
1075
+ st
1076
+ ]), y = e.object({
1077
+ name: e.string(),
1078
+ label: e.string().optional(),
1079
+ role: q.optional(),
1080
+ dataType: x.optional(),
1081
+ source: S.optional(),
1082
+ aggregate: d.optional()
1083
+ }).passthrough(), it = e.object({
1084
+ kind: e.literal("field"),
1085
+ field: y,
1086
+ aggregate: d.optional()
1087
+ }).passthrough(), re = e.object({
1088
+ kind: e.literal("derived_field"),
1089
+ name: e.string(),
1090
+ label: e.string(),
1091
+ description: e.string().optional(),
1092
+ resultRole: q,
1093
+ dataType: x,
1094
+ computeStage: e.enum(["row", "aggregate"]),
1095
+ expression: e.string(),
1096
+ expressionLanguage: e.literal("semaphor_sql_template").optional(),
1097
+ inputs: e.record(it),
1098
+ defaultAggregate: d.optional(),
1099
+ aggregationBehavior: e.enum([
1100
+ "additive",
1101
+ "non_additive",
1102
+ "ratio_of_sums",
1103
+ "weighted",
1104
+ "pre_aggregated",
1105
+ "snapshot"
1106
+ ]).optional(),
1107
+ aggregationStrategy: e.enum([
1108
+ "default",
1109
+ "symmetric_aggregate",
1110
+ "aggregate_then_join",
1111
+ "weighted"
1112
+ ]).optional(),
1113
+ format: ie.optional(),
1114
+ tags: e.array(e.string()).optional()
1115
+ }).passthrough(), V = y.and(
1116
+ e.object({
1117
+ semanticAggregate: d.optional(),
1118
+ effectiveAggregate: d.optional(),
1119
+ aggregateSource: se.optional(),
1120
+ derivedField: re.optional()
1121
+ }).passthrough()
1122
+ ), nt = ne, rt = e.object({
1123
+ kind: e.literal("physical"),
1124
+ connectionId: e.string().optional(),
1125
+ connectionType: e.string().optional(),
1126
+ tableName: e.string(),
1127
+ databaseName: e.string().optional(),
1128
+ schemaName: e.string().optional(),
1129
+ label: e.string().optional(),
1130
+ dialect: C.optional()
1131
+ }).passthrough(), at = e.object({
1132
+ kind: e.literal("sql"),
1133
+ connectionId: e.string().optional(),
1134
+ dialect: C.optional(),
1135
+ label: e.string().optional()
1136
+ }).passthrough(), lt = e.union([
1137
+ nt,
1138
+ rt,
1139
+ at
1140
+ ]), ut = e.object({
1141
+ key: e.string().optional(),
1142
+ name: e.string(),
1143
+ label: e.string().optional(),
1144
+ role: q.optional(),
1145
+ dataType: x.optional(),
1146
+ source: lt.optional(),
1147
+ aggregate: d.optional(),
1148
+ semanticAggregate: d.optional(),
1149
+ effectiveAggregate: d.optional(),
1150
+ aggregateSource: se.optional(),
1151
+ derivedField: e.never().optional()
1152
+ }).passthrough(), O = e.object({
1153
+ key: e.string(),
1154
+ name: e.string(),
1155
+ label: e.string(),
1156
+ role: q.optional(),
1157
+ dataType: x.optional(),
1158
+ aggregate: d.optional(),
1159
+ source: S.optional(),
1160
+ derivedField: re.optional()
1161
+ }).passthrough(), ae = e.object({
1162
+ code: e.string(),
1163
+ message: e.string().optional(),
1164
+ invalidField: e.string().optional(),
1165
+ fieldRole: e.enum(["measure", "date", "dimension", "input", "source", "sql"]).optional(),
1166
+ validMeasureCandidates: e.array(e.string()).optional(),
1167
+ validDateCandidates: e.array(e.string()).optional(),
1168
+ validDimensionCandidates: e.array(e.string()).optional(),
1169
+ recommendedNextStep: e.string()
1170
+ }).passthrough(), M = e.object({
1171
+ code: e.string(),
1172
+ message: e.string(),
1173
+ path: e.string().optional(),
1174
+ fieldRole: e.enum(["measure", "date", "dimension", "input", "source", "sql"]).optional(),
1175
+ repairHint: ae.optional()
1176
+ }).passthrough(), le = e.object({
1177
+ ok: e.boolean(),
1178
+ errors: e.array(M),
1179
+ warnings: e.array(M),
1180
+ repairHints: e.array(ae)
1181
+ }).passthrough(), dt = e.object({
1182
+ page: e.number(),
1183
+ pageSize: e.number(),
1184
+ pageCount: e.number(),
1185
+ totalCount: e.number(),
1186
+ hasNextPage: e.boolean(),
1187
+ hasPrevPage: e.boolean()
1188
+ }).passthrough(), I = {
1189
+ intentId: e.string().optional(),
1190
+ queryPath: e.enum(["query_spec", "sql", "sql_python"]),
1191
+ warnings: e.array(e.string()).optional(),
1192
+ rowCount: e.number().optional(),
1193
+ rowLimitExceeded: e.boolean().optional(),
1194
+ limit: e.number().optional(),
1195
+ pagination: dt.optional()
1196
+ }, ct = e.object({
1197
+ ...I,
1198
+ kind: e.literal("metric"),
1199
+ value: j,
1200
+ measures: e.record(j).optional(),
1201
+ comparison: e.object({
1202
+ kind: e.enum(["previous_period", "previous_year", "target"]),
1203
+ value: j.optional(),
1204
+ delta: e.union([e.number(), e.null()]).optional(),
1205
+ deltaPercent: e.union([e.number(), e.null()]).optional()
1206
+ }).passthrough().optional(),
1207
+ records: R.optional()
1208
+ }).passthrough(), pt = e.object({
1209
+ ...I,
1210
+ kind: e.literal("records"),
1211
+ columns: e.array(O),
1212
+ records: R,
1213
+ totals: e.object({
1214
+ mode: e.literal("server"),
1215
+ scope: e.literal("filtered_result"),
1216
+ row: e.record(e.string(), e.unknown()),
1217
+ columns: e.array(O).optional()
1218
+ }).passthrough().optional()
1219
+ }).passthrough(), mt = e.object({
1220
+ ...I,
1221
+ kind: e.literal("inputOptions"),
1222
+ options: e.array(
1223
+ k(
1224
+ {
1225
+ label: e.string(),
1226
+ value: e.unknown(),
1227
+ count: e.number().optional(),
1228
+ disambiguation: e.array(e.string()).optional()
1229
+ },
1230
+ ["value"]
1231
+ )
1232
+ )
1233
+ }).passthrough(), gt = e.object({
1234
+ ...I,
1235
+ kind: e.literal("sql"),
1236
+ columns: e.array(O),
1237
+ records: R,
1238
+ sqlShape: e.object({
1239
+ statementType: e.string().optional(),
1240
+ explicitLimit: e.number().optional(),
1241
+ hasPythonCode: e.boolean().optional()
1242
+ }).passthrough().optional()
1243
+ }).passthrough(), ht = e.object({
1244
+ enabled: e.boolean().optional(),
1245
+ position: e.enum(["before", "after"]).optional(),
1246
+ label: e.string().optional()
1247
+ }).passthrough(), Q = e.object({
1248
+ id: e.enum(["rows", "columns"]),
1249
+ levels: e.array(
1250
+ e.object({
1251
+ instanceId: e.string(),
1252
+ fieldKey: e.string(),
1253
+ label: e.string(),
1254
+ field: y,
1255
+ grain: oe.optional(),
1256
+ subtotal: ht.optional()
1257
+ }).passthrough()
1258
+ ),
1259
+ nodeIds: e.array(e.string())
1260
+ }).passthrough(), b = k(
1261
+ {
1262
+ instanceId: e.string(),
1263
+ fieldKey: e.string(),
1264
+ value: e.unknown(),
1265
+ label: e.string()
1266
+ },
1267
+ ["value"]
1268
+ ), ft = e.union([
1269
+ e.object({ kind: e.literal("label") }).passthrough(),
1270
+ e.object({
1271
+ kind: e.literal("field"),
1272
+ field: y,
1273
+ aggregate: d.optional()
1274
+ }).passthrough(),
1275
+ e.object({
1276
+ kind: e.literal("value"),
1277
+ valueId: e.string(),
1278
+ rowPath: e.array(b).optional(),
1279
+ columnPath: e.array(b).optional()
1280
+ }).passthrough()
1281
+ ]), bt = e.enum([
1282
+ "present",
1283
+ "presentNull",
1284
+ "missing",
1285
+ "densified"
1286
+ ]), yt = e.enum([
1287
+ "value",
1288
+ "rowSubtotal",
1289
+ "columnSubtotal",
1290
+ "subtotalIntersection",
1291
+ "rowGrandTotal",
1292
+ "columnGrandTotal",
1293
+ "matrixGrandTotal"
1294
+ ]), vt = e.object({
1295
+ instanceId: e.string(),
1296
+ fieldKey: e.string(),
1297
+ field: y,
1298
+ role: e.enum(["row", "column", "measure", "sort", "filter"]),
1299
+ label: e.string().optional()
1300
+ }).passthrough(), $t = e.union([
1301
+ e.object({
1302
+ kind: e.literal("additive"),
1303
+ aggregate: d.optional()
1304
+ }).passthrough(),
1305
+ e.object({
1306
+ kind: e.literal("semiAdditive"),
1307
+ aggregate: d.optional(),
1308
+ grain: oe.optional()
1309
+ }).passthrough(),
1310
+ e.object({
1311
+ kind: e.literal("nonAdditive"),
1312
+ aggregate: d.optional()
1313
+ }).passthrough(),
1314
+ e.object({
1315
+ kind: e.literal("ratio"),
1316
+ numeratorMeasureInstanceId: e.string().optional(),
1317
+ denominatorMeasureInstanceId: e.string().optional()
1318
+ }).passthrough(),
1319
+ e.object({
1320
+ kind: e.literal("custom"),
1321
+ expressionId: e.string().optional()
1322
+ }).passthrough()
1323
+ ]), St = e.object({
1324
+ instanceId: e.string(),
1325
+ fieldKey: e.string(),
1326
+ label: e.string(),
1327
+ field: y,
1328
+ aggregate: d.optional(),
1329
+ format: ie.optional(),
1330
+ totalBehavior: tt.optional(),
1331
+ semantics: $t
1332
+ }).passthrough(), wt = e.object({
1333
+ id: e.string(),
1334
+ measureId: e.string(),
1335
+ aggregate: d.optional(),
1336
+ label: e.string().optional(),
1337
+ source: e.enum([
1338
+ "measureDefault",
1339
+ "rowSubtotal",
1340
+ "columnSubtotal",
1341
+ "subtotalIntersection",
1342
+ "rowGrandTotal",
1343
+ "columnGrandTotal",
1344
+ "matrixGrandTotal",
1345
+ "custom"
1346
+ ]),
1347
+ scope: e.object({
1348
+ rowLevelId: e.string().optional(),
1349
+ columnLevelId: e.string().optional(),
1350
+ rowNodeId: e.string().optional(),
1351
+ columnNodeId: e.string().optional()
1352
+ }).passthrough().optional()
1353
+ }).passthrough(), kt = e.object({
1354
+ kind: e.string(),
1355
+ label: e.string().optional(),
1356
+ payload: e.record(e.string(), e.unknown()).optional()
1357
+ }).passthrough(), It = k(
1358
+ {
1359
+ id: e.string(),
1360
+ axis: e.enum(["row", "column"]),
1361
+ path: e.array(b),
1362
+ level: e.number(),
1363
+ label: e.string(),
1364
+ value: e.unknown(),
1365
+ parentId: e.string().optional(),
1366
+ hasChildren: e.boolean(),
1367
+ isExpanded: e.boolean().optional(),
1368
+ isSubtotal: e.boolean().optional(),
1369
+ isGrandTotal: e.boolean().optional(),
1370
+ subtotalFunction: d.optional(),
1371
+ childCount: e.number().optional(),
1372
+ actions: e.array(kt).optional()
1373
+ },
1374
+ ["value"]
1375
+ ), At = e.object({
1376
+ rowHeaderLevels: e.array(
1377
+ e.object({
1378
+ id: e.string(),
1379
+ label: e.string(),
1380
+ fieldInstanceId: e.string()
1381
+ }).passthrough()
1382
+ ),
1383
+ columnHeaderRows: e.array(
1384
+ e.object({
1385
+ id: e.string(),
1386
+ cells: e.array(
1387
+ e.object({
1388
+ id: e.string(),
1389
+ label: e.string(),
1390
+ role: e.enum([
1391
+ "rowHeader",
1392
+ "columnHeader",
1393
+ "measureHeader",
1394
+ "subtotal",
1395
+ "grandTotal"
1396
+ ]),
1397
+ colSpan: e.number(),
1398
+ rowSpan: e.number(),
1399
+ columnPath: e.array(b),
1400
+ measureInstanceId: e.string().optional()
1401
+ }).passthrough()
1402
+ )
1403
+ }).passthrough()
1404
+ ),
1405
+ columns: e.array(
1406
+ e.object({
1407
+ id: e.string(),
1408
+ label: e.string(),
1409
+ columnNodeId: e.string().optional(),
1410
+ columnPath: e.array(b),
1411
+ measureInstanceId: e.string(),
1412
+ role: e.enum(["value", "columnSubtotal", "columnGrandTotal"])
1413
+ }).passthrough()
1414
+ )
1415
+ }).passthrough(), _t = k(
1416
+ {
1417
+ rowId: e.string(),
1418
+ columnId: e.string().optional(),
1419
+ measureId: e.string(),
1420
+ value: e.unknown(),
1421
+ formattedValue: e.string().optional(),
1422
+ presence: bt,
1423
+ role: yt,
1424
+ calculationId: e.string().optional()
1425
+ },
1426
+ ["value"]
1427
+ ), jt = e.object({
1428
+ rows: e.boolean().optional(),
1429
+ columns: e.boolean().optional(),
1430
+ grandTotal: e.union([
1431
+ e.boolean(),
1432
+ e.object({
1433
+ rows: e.boolean().optional(),
1434
+ columns: e.boolean().optional()
1435
+ }).passthrough()
1436
+ ]).optional()
1437
+ }).passthrough(), Rt = k(
1438
+ {
1439
+ id: e.string(),
1440
+ axis: e.enum(["row", "column"]),
1441
+ targetInstanceId: e.string().optional(),
1442
+ direction: e.enum(["asc", "desc"]),
1443
+ nulls: e.enum(["warehouseDefault", "first", "last"]).optional(),
1444
+ scope: e.enum(["global", "withinParent"]).optional(),
1445
+ by: ft
1446
+ },
1447
+ ["by"]
1448
+ ), Ct = e.object({
1449
+ rowOffset: e.number().optional(),
1450
+ rowLimit: e.number().optional(),
1451
+ columnOffset: e.number().optional(),
1452
+ columnLimit: e.number().optional(),
1453
+ hasMoreRows: e.boolean().optional(),
1454
+ hasMoreColumns: e.boolean().optional()
1455
+ }).passthrough(), qt = e.object({
1456
+ axis: e.enum(["row", "column"]),
1457
+ path: e.array(b),
1458
+ depth: e.number().optional()
1459
+ }).passthrough(), xt = e.object({
1460
+ rowLazyLoading: e.boolean().optional(),
1461
+ columnLazyLoading: e.boolean().optional(),
1462
+ expandableRowNodeIds: e.array(e.string()).optional(),
1463
+ expandableColumnNodeIds: e.array(e.string()).optional(),
1464
+ nextRequests: e.array(qt).optional()
1465
+ }).passthrough(), Et = e.object({
1466
+ domains: e.record(
1467
+ e.object({
1468
+ min: e.number().optional(),
1469
+ max: e.number().optional()
1470
+ }).passthrough()
1471
+ ).optional(),
1472
+ rules: e.array(e.record(e.string(), e.unknown())).optional()
1473
+ }).passthrough(), Ft = e.object({
1474
+ ...I,
1475
+ kind: e.literal("matrix"),
1476
+ schemaVersion: e.literal(1),
1477
+ shape: e.enum(["hierarchical", "pivot"]),
1478
+ capabilities: e.array(e.string()),
1479
+ executionMetadata: e.record(e.string(), e.unknown()),
1480
+ fieldsById: e.record(e.string(), vt),
1481
+ measuresById: e.record(e.string(), St),
1482
+ calculationsById: e.record(e.string(), wt).optional(),
1483
+ axes: e.object({
1484
+ rows: Q,
1485
+ columns: Q
1486
+ }).passthrough(),
1487
+ nodesById: e.record(e.string(), It),
1488
+ layout: At,
1489
+ cells: e.array(_t),
1490
+ totals: jt,
1491
+ sort: e.array(Rt),
1492
+ formattingContext: Et,
1493
+ pageInfo: Ct.optional(),
1494
+ expansion: xt.optional()
1495
+ }).passthrough(), Nt = e.union([
1496
+ ct,
1497
+ pt,
1498
+ mt,
1499
+ gt,
1500
+ Ft
1501
+ ]), Tt = e.object({
1502
+ status: e.enum([
1503
+ "not_required",
1504
+ "resolved",
1505
+ "missing",
1506
+ "ambiguous",
1507
+ "fanout_risk",
1508
+ "unknown"
1509
+ ]),
1510
+ requiredSources: e.array(S).optional(),
1511
+ relationshipsUsed: e.array(e.string()).optional(),
1512
+ missingSources: e.array(e.string()).optional(),
1513
+ warnings: e.array(e.string()).optional(),
1514
+ message: e.string().optional(),
1515
+ recommendedNextStep: e.string().optional(),
1516
+ joinPlanSummary: e.object({
1517
+ baseSource: S.optional(),
1518
+ joinedSources: e.array(S).optional(),
1519
+ joinCount: e.number().optional()
1520
+ }).passthrough().optional(),
1521
+ fanoutRisk: e.object({
1522
+ status: e.enum(["none", "warning", "error", "unknown"]),
1523
+ message: e.string().optional()
1524
+ }).passthrough().optional()
1525
+ }).passthrough(), Y = e.enum([
1526
+ "ambiguous_fields",
1527
+ "empty_result",
1528
+ "missing_grounded_fields",
1529
+ "missing_relationship",
1530
+ "no_grounded_query",
1531
+ "partial_result",
1532
+ "presentation_incomplete",
1533
+ "query_validation_failed",
1534
+ "unsafe_join"
1535
+ ]), ue = e.object({
1536
+ version: e.literal(1),
1537
+ status: e.enum(["answered", "partial", "blocked"]),
1538
+ summary: e.string(),
1539
+ answered: e.array(
1540
+ e.object({
1541
+ slotId: e.string().optional(),
1542
+ queryId: e.string().optional(),
1543
+ summary: e.string(),
1544
+ evidenceIds: e.array(e.string()).optional(),
1545
+ fieldsUsed: e.array(V).optional()
1546
+ }).passthrough()
1547
+ ),
1548
+ blocked: e.array(
1549
+ e.object({
1550
+ slotId: e.string().optional(),
1551
+ queryId: e.string().optional(),
1552
+ reasonCode: Y,
1553
+ message: e.string(),
1554
+ missingFields: e.array(e.string()).optional(),
1555
+ availableFields: e.array(e.string()).optional(),
1556
+ ambiguousFields: e.array(e.string()).optional(),
1557
+ missingRelationships: e.array(e.string()).optional(),
1558
+ evidenceIds: e.array(e.string()).optional(),
1559
+ neededFromUser: e.array(e.string()).optional(),
1560
+ recommendedNextStep: e.string().optional()
1561
+ }).passthrough()
1562
+ ),
1563
+ semanticModelRecommendations: e.array(
1564
+ e.object({
1565
+ reasonCode: Y,
1566
+ message: e.string(),
1567
+ recommendedNextStep: e.string().optional()
1568
+ }).passthrough()
1569
+ ).optional()
1570
+ }).passthrough(), de = e.object({
1571
+ scope: e.literal("filtered_query"),
1572
+ measures: e.record(j)
1573
+ }).passthrough(), ce = e.object({
1574
+ answeredObligations: e.array(e.string()),
1575
+ missingObligations: e.array(e.string()),
1576
+ warnings: e.array(M).optional()
1577
+ }).passthrough(), Dt = e.object({
1578
+ intentId: e.string().optional(),
1579
+ queryId: e.string().optional(),
1580
+ status: e.enum(["answered", "partial", "failed"]),
1581
+ resultShape: e.enum([
1582
+ "metric",
1583
+ "records",
1584
+ "inputOptions",
1585
+ "sql",
1586
+ "matrix",
1587
+ "period_change",
1588
+ "analysis"
1589
+ ]).optional(),
1590
+ intent: e.unknown().optional(),
1591
+ compiledQuery: e.unknown().optional(),
1592
+ fieldsUsed: e.array(V).optional(),
1593
+ result: Nt.optional(),
1594
+ validation: le,
1595
+ coverage: ce.optional(),
1596
+ missingFields: e.array(e.string()).optional(),
1597
+ warnings: e.array(e.string()).optional(),
1598
+ relationshipDiagnostics: Tt.optional(),
1599
+ diagnosticFeedback: ue.optional(),
1600
+ population: de.optional(),
1601
+ metadata: e.record(e.string(), e.unknown()).optional()
1602
+ }).passthrough();
1603
+ function Kt(i) {
1604
+ switch (i) {
1605
+ case "boolean":
1606
+ return e.boolean().optional();
1607
+ case "compactExecutionFieldArray":
1608
+ return e.array(ut).optional();
1609
+ case "coverage":
1610
+ return ce.optional();
1611
+ case "diagnosticFeedback":
1612
+ return ue.optional();
1613
+ case "executionFieldArray":
1614
+ return e.array(V).optional();
1615
+ case "executionResult":
1616
+ return Dt.optional();
1617
+ case "number":
1618
+ return e.number().finite().optional();
1619
+ case "population":
1620
+ return de.optional();
1621
+ case "record":
1622
+ return m.optional();
1623
+ case "recordArray":
1624
+ return R.optional();
1625
+ case "responseDetail":
1626
+ return e.enum(["compact", "standard", "debug"]).optional();
1627
+ case "string":
1628
+ return e.string().optional();
1629
+ case "stringArray":
1630
+ return e.array(e.string()).optional();
1631
+ case "unknown":
1632
+ return e.unknown().optional();
1633
+ case "unknownArray":
1634
+ return e.array(e.unknown()).optional();
1635
+ case "validationResult":
1636
+ return le.optional();
1637
+ }
1638
+ }
1639
+ const Ot = Object.fromEntries(
1640
+ Object.entries(B).map(
1641
+ ([i, o]) => [i, Kt(o)]
1642
+ )
1643
+ ), Mt = e.object(Ot).strict(), L = e.object({
1644
+ sourceKey: e.string().optional(),
1645
+ kind: e.enum(["semantic", "physical", "sql"]).optional(),
1646
+ domainId: e.string().optional(),
1647
+ datasetName: e.string().optional(),
1648
+ datasetId: e.string().optional(),
1649
+ connectionId: e.string().optional(),
1650
+ tableName: e.string().optional(),
1651
+ label: e.string().optional()
1652
+ }).passthrough(), f = e.object({
1653
+ name: e.string(),
1654
+ label: e.string().optional(),
1655
+ role: e.enum(["dimension", "measure", "date", "id", "unknown"]).optional(),
1656
+ dataType: e.enum(["string", "number", "boolean", "date", "datetime", "unknown"]).optional(),
1657
+ aggregate: d.optional(),
1658
+ sourceKey: e.string().optional(),
1659
+ source: L.optional()
1660
+ }).passthrough(), pe = e.object({
1661
+ id: e.string().optional(),
1662
+ builder: e.literal("semaphor.inputOptions"),
1663
+ source: L.optional(),
1664
+ sourceKey: e.string().optional(),
1665
+ valueFieldRef: f,
1666
+ labelFieldRef: f,
1667
+ filterFieldRef: f.optional(),
1668
+ population: e.unknown().optional(),
1669
+ dependencies: e.unknown().optional(),
1670
+ limit: e.number().int().positive().optional(),
1671
+ spec: m.optional()
1672
+ }).passthrough(), me = e.object({
1673
+ appliesToViewIds: e.array(e.string()).optional(),
1674
+ viewId: e.string().optional(),
1675
+ fieldRef: f,
1676
+ relationshipHint: e.unknown().optional(),
1677
+ relationshipsUsed: e.array(m).optional()
1678
+ }).passthrough(), Bt = e.object({
1679
+ id: e.string(),
1680
+ label: e.string().optional(),
1681
+ type: e.string().optional(),
1682
+ serverSide: e.boolean().optional(),
1683
+ fieldRef: f.optional(),
1684
+ optionQuery: pe.optional(),
1685
+ bindings: e.array(me).optional(),
1686
+ appliesToViewIds: e.array(e.string()),
1687
+ relationshipHint: e.unknown().optional(),
1688
+ relationshipsUsed: e.array(m).optional()
1689
+ }).passthrough(), Pt = e.object({
1690
+ builder: e.enum([
1691
+ "semaphor.metric",
1692
+ "semaphor.records",
1693
+ "semaphor.matrix",
1694
+ "semaphor.analysis",
1695
+ "semaphor.sql"
1696
+ ]),
1697
+ spec: m,
1698
+ fallbackReason: m.optional()
1699
+ }).passthrough(), Vt = e.object({
1700
+ id: e.string(),
1701
+ title: e.string().optional(),
1702
+ purpose: e.string().optional(),
1703
+ sourcePresentation: e.object({
1704
+ sourceKeys: e.array(e.string()).optional(),
1705
+ sourceLabels: e.array(e.string()).optional()
1706
+ }).passthrough().optional(),
1707
+ visual: e.string().optional(),
1708
+ visualSpec: m.optional(),
1709
+ queryKind: e.enum(["metric", "records", "matrix", "analysis", "sql_fallback"]).optional(),
1710
+ sdkBuilder: e.enum([
1711
+ "semaphor.metric",
1712
+ "semaphor.records",
1713
+ "semaphor.matrix",
1714
+ "semaphor.analysis",
1715
+ "semaphor.sql"
1716
+ ]).optional(),
1717
+ sdkSpec: Pt.optional(),
1718
+ fields: e.array(f).optional(),
1719
+ computation: m.optional(),
1720
+ uxExpectations: e.array(e.string()).optional(),
1721
+ validation: m.optional()
1722
+ }).passthrough(), Lt = e.object({
1723
+ inputId: e.string(),
1724
+ label: e.string().optional(),
1725
+ type: e.string().optional(),
1726
+ serverSide: e.boolean().optional(),
1727
+ fieldRef: f.optional(),
1728
+ optionQuery: pe.optional(),
1729
+ bindings: e.array(me),
1730
+ appliesToViewIds: e.array(e.string()),
1731
+ notAppliedToViewIds: e.array(e.string())
1732
+ }).passthrough(), Yt = e.object({
1733
+ schemaVersion: e.literal(K),
1734
+ title: e.string(),
1735
+ purpose: e.string().optional(),
1736
+ userGoal: e.string().optional(),
1737
+ nextStep: e.string().optional(),
1738
+ sources: e.array(L),
1739
+ inputs: e.array(Bt),
1740
+ views: e.array(Vt),
1741
+ filterContracts: e.array(Lt),
1742
+ implementationChecklist: e.object({
1743
+ schemaVersion: e.string().optional(),
1744
+ requiredDevtools: e.object({
1745
+ mountRootDevtools: e.boolean(),
1746
+ providerDebugBridge: e.string().optional(),
1747
+ panelPosition: e.string().optional(),
1748
+ forbidden: e.array(e.string()).optional()
1749
+ }).passthrough(),
1750
+ requiredInputOptions: e.array(m),
1751
+ filterScopeByInput: e.array(m),
1752
+ bindingsByView: e.record(e.string(), e.array(m)),
1753
+ validationCommands: e.array(e.string()),
1754
+ browserSmokeChecks: e.array(e.string())
1755
+ }).passthrough(),
1756
+ nextRequiredTool: e.object({
1757
+ name: e.string(),
1758
+ reason: e.string().optional()
1759
+ }).optional(),
1760
+ unsupportedInsights: e.array(
1761
+ e.object({
1762
+ title: e.string(),
1763
+ requestedQuestion: e.string(),
1764
+ reason: e.string(),
1765
+ suggestedModelingFix: e.string()
1766
+ }).passthrough()
1767
+ ).optional(),
1768
+ assumptions: e.array(e.string()).optional(),
1769
+ validation: m.optional()
1770
+ }).passthrough().superRefine((i, o) => {
1771
+ const t = Z(i);
1772
+ for (const s of t.issues)
1773
+ o.addIssue({
1774
+ code: e.ZodIssueCode.custom,
1775
+ message: s
1776
+ });
1777
+ }), Gt = new Set(
1778
+ Object.keys(B)
1779
+ );
1780
+ function Wt() {
1781
+ return Object.keys(
1782
+ B
1783
+ );
1784
+ }
1785
+ function Ut(i) {
1786
+ return Gt.has(i);
1787
+ }
1788
+ function Zt(i) {
1789
+ if (!i || typeof i != "object" || Array.isArray(i))
1790
+ throw new Error("Semaphor analyze result must be an object.");
1791
+ const t = Object.keys(i).filter(
1792
+ (s) => !Ut(s)
1793
+ );
1794
+ if (t.length)
1795
+ throw new Error(
1796
+ `Semaphor analyze result contains unsupported top-level field(s): ${t.join(", ")}.`
1797
+ );
1798
+ return Mt.parse(i);
1799
+ }
1800
+ export {
1801
+ ce as A,
1802
+ Dt as B,
1803
+ Ot as C,
1804
+ Mt as D,
1805
+ Yt as E,
1806
+ K as S,
1807
+ Ht as a,
1808
+ Ut as b,
1809
+ B as c,
1810
+ ot as d,
1811
+ st as e,
1812
+ S as f,
1813
+ Wt as g,
1814
+ y as h,
1815
+ Qt as i,
1816
+ re as j,
1817
+ V as k,
1818
+ O as l,
1819
+ M as m,
1820
+ le as n,
1821
+ ct as o,
1822
+ Zt as p,
1823
+ pt as q,
1824
+ mt as r,
1825
+ ne as s,
1826
+ gt as t,
1827
+ Ft as u,
1828
+ Z as v,
1829
+ Nt as w,
1830
+ Tt as x,
1831
+ ue as y,
1832
+ de as z
1833
+ };