react-semaphor 0.1.416 → 0.1.418

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 +49 -50
  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-Akysi2ML.js +2003 -0
  6. package/dist/chunks/analyze-result-contract-COjyJzYm.js +1 -0
  7. package/dist/chunks/{calendar-preferences-dialog-B8FmFRHX.js → calendar-preferences-dialog-BbuLgela.js} +3 -3
  8. package/dist/chunks/{calendar-preferences-dialog-ck4AU-to.js → calendar-preferences-dialog-CInkkhl_.js} +1 -1
  9. package/dist/chunks/{dashboard-briefing-launcher-Br_1IK1z.js → dashboard-briefing-launcher-B4OWNsVD.js} +1 -1
  10. package/dist/chunks/{dashboard-briefing-launcher-Tr2SqDMK.js → dashboard-briefing-launcher-D7FNuDuc.js} +4 -4
  11. package/dist/chunks/{dashboard-controls-B7OObDNl.js → dashboard-controls-DTC1eCz0.js} +1 -1
  12. package/dist/chunks/{dashboard-controls-B2bEv8uG.js → dashboard-controls-DcX7Mid4.js} +5 -5
  13. package/dist/chunks/{dashboard-json-DAB8WVyb.js → dashboard-json-BHWbQS6I.js} +3 -3
  14. package/dist/chunks/{dashboard-json-DNixjalS.js → dashboard-json-vu38P5pV.js} +1 -1
  15. package/dist/chunks/{edit-dashboard-visual-DWygSAp3.js → edit-dashboard-visual-CkBhJBhp.js} +1 -1
  16. package/dist/chunks/{edit-dashboard-visual-Dh8Ge3-B.js → edit-dashboard-visual-DsCr90_3.js} +4 -4
  17. package/dist/chunks/{index-BkTLAfKy.js → index-C56DuHI8.js} +163 -164
  18. package/dist/chunks/{index-CQIMj-FF.js → index-C8thRvkW.js} +4 -4
  19. package/dist/chunks/{switch-DMlqgIx_.js → switch-BXuyni6l.js} +1 -1
  20. package/dist/chunks/{switch-DgiogS4X.js → switch-Dsx-IwBE.js} +1 -1
  21. package/dist/chunks/{update-policy-BnEbPhHW.js → update-policy-B5S_LfEu.js} +347 -314
  22. package/dist/chunks/update-policy-BqBKUk3Q.js +3 -0
  23. package/dist/chunks/{use-create-flow-overlay-state-CZA-dSns.js → use-create-flow-overlay-state-BDv_VpL6.js} +1 -1
  24. package/dist/chunks/{use-create-flow-overlay-state-uujasvbD.js → use-create-flow-overlay-state-CzftV84t.js} +3 -3
  25. package/dist/chunks/{validators-UqQI3Cg_.js → validators-CLzrE2N_.js} +1 -1
  26. package/dist/chunks/validators-CPFcUMrV.js +1 -0
  27. package/dist/dashboard/index.cjs +1 -1
  28. package/dist/dashboard/index.js +1 -1
  29. package/dist/dashboard-authoring/index.cjs +3 -3
  30. package/dist/dashboard-authoring/index.js +28 -29
  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 -1
  34. package/dist/data-app-codegen/index.js +2 -2
  35. package/dist/data-app-codegen-node/index.cjs +154 -125
  36. package/dist/data-app-codegen-node/index.js +691 -609
  37. package/dist/data-app-sdk/index.cjs +2 -2
  38. package/dist/data-app-sdk/index.js +171 -157
  39. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  40. package/dist/data-app-sdk-adapters/index.js +26 -27
  41. package/dist/data-app-sdk-validation/index.cjs +1 -1
  42. package/dist/data-app-sdk-validation/index.js +17 -18
  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 +6 -1
  48. package/dist/types/dashboard-assistant.d.ts +1 -0
  49. package/dist/types/data-app-codegen-node.d.ts +5 -3
  50. package/dist/types/data-app-codegen.d.ts +5 -3
  51. package/dist/types/data-app-sdk-validation.d.ts +1 -0
  52. package/dist/types/data-app-sdk.d.ts +6 -0
  53. package/package.json +1 -1
  54. package/dist/chunks/analyze-result-contract-8nxUOWp8.js +0 -1
  55. package/dist/chunks/analyze-result-contract-DPjm6btg.js +0 -1869
  56. package/dist/chunks/source-identity-BM2FvJDP.js +0 -1
  57. package/dist/chunks/source-identity-Cv4Nm3TM.js +0 -75
  58. package/dist/chunks/update-policy-CWg9c08k.js +0 -3
  59. package/dist/chunks/validators-JzI7olk4.js +0 -1
@@ -1,1869 +0,0 @@
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
- }, O = "semaphor-data-app-codegen-summary/v1", Yt = "semaphor-data-app-codegen-summary-validator/v2", he = /* @__PURE__ */ new Set([
43
- "metric",
44
- "records",
45
- "matrix",
46
- "analysis",
47
- "sql_fallback"
48
- ]), fe = /* @__PURE__ */ new Set([
49
- "semaphor.metric",
50
- "semaphor.records",
51
- "semaphor.matrix",
52
- "semaphor.analysis",
53
- "semaphor.sql"
54
- ]), be = /* @__PURE__ */ new Set([
55
- "absolute_delta",
56
- "largest_negative",
57
- "largest_positive",
58
- "positive_and_negative",
59
- "all"
60
- ]), Z = /* @__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
- ]), ye = /* @__PURE__ */ new Set([
76
- ...Z,
77
- "analysis",
78
- "timeWindow",
79
- "filters",
80
- "driverMode",
81
- "includePopulation",
82
- "calendarContext",
83
- "chartTitle",
84
- "chartType"
85
- ]), ve = /* @__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
- ]), $e = /* @__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
- ]), Se = /* @__PURE__ */ new Set([
115
- "source",
116
- "id",
117
- "label",
118
- "sql",
119
- "defaultParameters",
120
- "pythonCode",
121
- "fields",
122
- "limit",
123
- "pagination",
124
- "rationale"
125
- ]), we = /* @__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
- ]), ke = /* @__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 Wt(i) {
154
- return X(i).ok;
155
- }
156
- function X(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 !== O && o.push(
162
- `schemaVersion must be ${O}.`
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
- ...Ae(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(..._e(s, `inputs.${n}`));
169
- }), Array.isArray(t.views) && t.views.forEach((s, n) => {
170
- o.push(...je(s, `views.${n}`));
171
- }), Array.isArray(t.filterContracts) && t.filterContracts.forEach((s, n) => {
172
- o.push(
173
- ...Fe(s, `filterContracts.${n}`)
174
- );
175
- }), t.unsupportedInsights !== void 0 && (Array.isArray(t.unsupportedInsights) ? t.unsupportedInsights.forEach((s, n) => {
176
- o.push(
177
- ...Je(
178
- s,
179
- `unsupportedInsights.${n}`
180
- )
181
- );
182
- }) : o.push("unsupportedInsights must be an array.")), o.push(...Ie(t)), { ok: o.length === 0, issues: o };
183
- }
184
- function Ie(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 Ae(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 _e(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(...J(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 je(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(...ze(t.visualSpec, `${o}.visualSpec`)), t.computation !== void 0 && s.push(...Xe(t.computation, `${o}.computation`)), Ue(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 && !te(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
- ...Ne({
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
- ...Re({
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 Re({
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
- Ce(
319
- a(r),
320
- a(o[l])
321
- ) || n.push(`${s}.${l} must match ${t}.${l}.`);
322
- }), n);
323
- }
324
- function Ce(i, o) {
325
- return !i || !o ? !1 : i.name === o.name && (i.role || "measure") === (o.role || "measure") && U(i) === U(o) && qe(i, o);
326
- }
327
- function U(i) {
328
- return typeof i.aggregate == "string" ? i.aggregate.toUpperCase() : "SUM";
329
- }
330
- function qe(i, o) {
331
- const t = a(i.source), s = a(o.source);
332
- if (xe(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 xe(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]) : Ee(a(i.source));
352
- }
353
- function Ee(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 Fe(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
- ...J(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 J(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 Ne(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 (!te(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 !== Ge(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, Z, `${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, ye, `${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
- ...De(s, `${i.path}.spec`)
485
- );
486
- break;
487
- case "semaphor.records":
488
- t.push(
489
- ...v(s, ve, `${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
- ...Oe(
499
- s.totals,
500
- `${i.path}.spec.totals`
501
- )
502
- );
503
- break;
504
- case "semaphor.matrix":
505
- t.push(
506
- ...v(s, $e, `${i.path}.spec`),
507
- ...Ke(s, i.path),
508
- ...Me(s.rows, `${i.path}.spec.rows`),
509
- ...Be(
510
- s.columns,
511
- `${i.path}.spec.columns`
512
- ),
513
- ...Pe(s.values, `${i.path}.spec.values`),
514
- ...Ve(s.sort, `${i.path}.spec.sort`),
515
- ..._(s.filters, `${i.path}.spec.filters`),
516
- ...Te(
517
- s.displayLimits,
518
- `${i.path}.spec.displayLimits`
519
- )
520
- );
521
- break;
522
- case "semaphor.sql":
523
- t.push(
524
- ...v(s, Se, `${i.path}.spec`),
525
- ...A(s, i.path)
526
- ), ((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(
527
- ...N(
528
- s.fields,
529
- `${i.path}.spec.fields`
530
- )
531
- );
532
- break;
533
- }
534
- return t;
535
- }
536
- function Te(i, o) {
537
- if (i === void 0)
538
- return [];
539
- const t = a(i);
540
- if (!t)
541
- return [`${o} must be an object.`];
542
- const s = [];
543
- s.push(
544
- ...H(t.rows, `${o}.rows`),
545
- ...H(
546
- t.columns,
547
- `${o}.columns`
548
- )
549
- );
550
- for (const n of Object.keys(t))
551
- n === "rows" || n === "columns" || s.push(`${o}.${n} is not supported.`);
552
- return s;
553
- }
554
- function H(i, o) {
555
- if (i === void 0)
556
- return [];
557
- const t = a(i);
558
- if (!t)
559
- return [`${o} must be an object.`];
560
- const s = [];
561
- (typeof t.limit != "number" || !Number.isInteger(t.limit) || t.limit < 1) && s.push(`${o}.limit must be a positive integer.`);
562
- for (const n of Object.keys(t))
563
- n !== "limit" && s.push(
564
- `${o}.${n} is not supported; matrix display limits are count-only in v1.`
565
- );
566
- return s;
567
- }
568
- function De(i, o) {
569
- const t = [];
570
- if (i.driverMode !== void 0 && !be.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) {
571
- const s = a(i.calendarContext);
572
- if (!s)
573
- t.push(`${o}.calendarContext must be an object.`);
574
- else {
575
- 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(
576
- `${o}.calendarContext.weekStart must be an integer between 0 and 6.`
577
- );
578
- const n = s.anchor;
579
- if (n !== void 0 && n !== "now") {
580
- const r = a(n);
581
- (!r || typeof r.iso != "string" || !r.iso.trim()) && t.push(`${o}.calendarContext.anchor must be now or { iso }.`);
582
- }
583
- }
584
- }
585
- return t;
586
- }
587
- function Oe(i, o) {
588
- if (i === void 0)
589
- return [];
590
- const t = a(i);
591
- if (!t)
592
- return [`${o} must be an object.`];
593
- const s = [];
594
- 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) => {
595
- var l;
596
- s.push(
597
- ...oe(
598
- n,
599
- `${o}.measures.${r}`
600
- )
601
- ), ((l = a(n)) == null ? void 0 : l.role) !== "measure" && s.push(`${o}.measures.${r}.role must be measure.`);
602
- }), s;
603
- }
604
- function v(i, o, t) {
605
- const s = [];
606
- return Object.keys(i).forEach((n) => {
607
- o.has(n) || s.push(`${t}.${n} is not supported for this SDK builder.`);
608
- }), s;
609
- }
610
- function A(i, o) {
611
- return a(i.source) ? w(i.source, `${o}.spec.source`) : [`${o}.spec.source must be an object.`];
612
- }
613
- function Ke(i, o) {
614
- const t = a(i.source);
615
- if (!t)
616
- return [`${o}.spec.source must be an object.`];
617
- const s = w(i.source, `${o}.spec.source`);
618
- return t.kind !== "semantic" && t.kind !== "physical" && s.push(`${o}.spec.source.kind must be semantic or physical.`), s;
619
- }
620
- function F(i, o) {
621
- const t = P(i, o);
622
- return Array.isArray(i) && i.forEach((s, n) => {
623
- t.push(...p(s, `${o}.${n}`));
624
- }), t;
625
- }
626
- function N(i, o) {
627
- if (i === void 0)
628
- return [];
629
- if (!Array.isArray(i))
630
- return [`${o} must be an array.`];
631
- const t = [];
632
- return i.forEach((s, n) => {
633
- t.push(...p(s, `${o}.${n}`));
634
- }), t;
635
- }
636
- function T(i, o) {
637
- if (i === void 0)
638
- return [];
639
- const t = a(i);
640
- return t ? [
641
- ...p(t.field, `${o}.field`),
642
- ...ee(t.direction, `${o}.direction`)
643
- ] : [`${o} must be an object.`];
644
- }
645
- function Me(i, o) {
646
- const t = P(i, o);
647
- return Array.isArray(i) && i.forEach((s, n) => {
648
- const r = a(s);
649
- if (!r) {
650
- t.push(`${o}.${n} must be an object.`);
651
- return;
652
- }
653
- t.push(
654
- ...p(r.field, `${o}.${n}.field`)
655
- );
656
- }), t;
657
- }
658
- function Be(i, o) {
659
- if (i === void 0)
660
- return [];
661
- const t = [];
662
- return Array.isArray(i) ? (i.forEach((s, n) => {
663
- const r = a(s);
664
- if (!r) {
665
- t.push(`${o}.${n} must be an object.`);
666
- return;
667
- }
668
- t.push(
669
- ...p(r.field, `${o}.${n}.field`)
670
- );
671
- }), t) : [`${o} must be an array.`];
672
- }
673
- function Pe(i, o) {
674
- const t = P(i, o);
675
- return Array.isArray(i) && i.forEach((s, n) => {
676
- const r = a(s);
677
- if (!r) {
678
- t.push(`${o}.${n} must be an object.`);
679
- return;
680
- }
681
- t.push(
682
- ...p(r.field, `${o}.${n}.field`)
683
- );
684
- }), t;
685
- }
686
- function Ve(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
- r.axis !== "row" && r.axis !== "column" && t.push(`${o}.${n}.axis must be row or column.`), t.push(
699
- ...ee(r.direction, `${o}.${n}.direction`),
700
- ...Le(r.by, `${o}.${n}.by`)
701
- );
702
- }), t;
703
- }
704
- function Le(i, o) {
705
- const t = a(i);
706
- if (!t)
707
- return [`${o} must be an object.`];
708
- switch (t.kind) {
709
- case "label":
710
- return [];
711
- case "field":
712
- return p(t.field, `${o}.field`);
713
- case "value":
714
- return typeof t.valueId != "string" || !t.valueId.trim() ? [`${o}.valueId is required.`] : [];
715
- default:
716
- return [`${o}.kind must be label, field, or value.`];
717
- }
718
- }
719
- function ee(i, o) {
720
- return i === "asc" || i === "desc" ? [] : [`${o} must be asc or desc.`];
721
- }
722
- function _(i, o) {
723
- if (i === void 0)
724
- return [];
725
- if (!Array.isArray(i))
726
- return [`${o} must be an array.`];
727
- const t = [];
728
- return i.forEach((s, n) => {
729
- const r = a(s);
730
- if (!r) {
731
- t.push(`${o}.${n} must be an object.`);
732
- return;
733
- }
734
- t.push(...p(r.field, `${o}.${n}.field`));
735
- }), t;
736
- }
737
- function P(i, o) {
738
- return !Array.isArray(i) || i.length === 0 ? [`${o} must be a non-empty array.`] : [];
739
- }
740
- function Ge(i) {
741
- switch (i) {
742
- case "metric":
743
- return "semaphor.metric";
744
- case "records":
745
- return "semaphor.records";
746
- case "matrix":
747
- return "semaphor.matrix";
748
- case "analysis":
749
- return "semaphor.analysis";
750
- case "sql_fallback":
751
- return "semaphor.sql";
752
- }
753
- }
754
- function Ue(i) {
755
- const o = a(i.computation), t = a(i.visualSpec);
756
- 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";
757
- }
758
- function ze(i, o) {
759
- const t = a(i);
760
- if (!t)
761
- return [`${o} must be an object.`];
762
- const s = [];
763
- return we.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(
764
- ...He(
765
- t.tableBehavior,
766
- `${o}.tableBehavior`
767
- )
768
- ), s;
769
- }
770
- function He(i, o) {
771
- const t = a(i);
772
- if (!t)
773
- return [`${o} must be an object.`];
774
- const s = [];
775
- return t.tableMode !== "bounded" && t.tableMode !== "server_paginated" && t.tableMode !== "server_windowed" && s.push(`${o}.tableMode must be a supported table mode.`), s.push(
776
- ...Qe(t.height, `${o}.height`),
777
- ...Ye(t.pagination, `${o}.pagination`),
778
- ...We(t.sorting, `${o}.sorting`),
779
- ...Ze(t.totals, `${o}.totals`)
780
- ), typeof t.serverSideRequired != "boolean" && s.push(`${o}.serverSideRequired must be a boolean.`), s;
781
- }
782
- function Qe(i, o) {
783
- const t = a(i);
784
- if (!t)
785
- return [`${o} must be an object.`];
786
- const s = [];
787
- 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;
788
- }
789
- function Ye(i, o) {
790
- const t = a(i);
791
- if (!t)
792
- return [`${o} must be an object.`];
793
- const s = [];
794
- 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;
795
- }
796
- function We(i, o) {
797
- const t = a(i);
798
- if (!t)
799
- return [`${o} must be an object.`];
800
- const s = [];
801
- 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;
802
- }
803
- function Ze(i, o) {
804
- const t = a(i);
805
- if (!t)
806
- return [`${o} must be an object.`];
807
- const s = [];
808
- 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) => {
809
- var l;
810
- s.push(
811
- ...oe(
812
- n,
813
- `${o}.measures.${r}`
814
- )
815
- ), ((l = a(n)) == null ? void 0 : l.role) !== "measure" && s.push(`${o}.measures.${r}.role must be measure.`);
816
- }), 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);
817
- }
818
- function Xe(i, o) {
819
- const t = a(i);
820
- if (!t)
821
- return [`${o} must be an object.`];
822
- const s = [];
823
- switch (t.kind) {
824
- case "server_query":
825
- $(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(
826
- `${o}.queryOwnership must be view_owned or shared_query.`
827
- ), 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.`);
828
- break;
829
- case "derived":
830
- (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.`);
831
- break;
832
- case "presentation_only":
833
- break;
834
- case "unsupported":
835
- (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.`);
836
- break;
837
- default:
838
- s.push(`${o}.kind must be a supported computation kind.`);
839
- }
840
- return s;
841
- }
842
- function Je(i, o) {
843
- const t = a(i);
844
- if (!t)
845
- return [`${o} must be an object.`];
846
- const s = [];
847
- for (const r of ["title", "requestedQuestion", "suggestedModelingFix"])
848
- (typeof t[r] != "string" || !t[r].trim()) && s.push(`${o}.${r} is required.`);
849
- return ke.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(
850
- `${o} relationship repair metadata is only valid for missing_relationship unsupported insights.`
851
- ), t.relationshipCandidate !== void 0 && s.push(
852
- ...tt(
853
- t.relationshipCandidate,
854
- `${o}.relationshipCandidate`
855
- )
856
- ), t.nextRepairAction !== void 0 && s.push(
857
- ...et(
858
- t.nextRepairAction,
859
- `${o}.nextRepairAction`
860
- )
861
- ), s;
862
- }
863
- function et(i, o) {
864
- const t = a(i);
865
- if (!t)
866
- return [`${o} must be an object.`];
867
- const s = [], n = /* @__PURE__ */ new Set(["tool", "reason"]);
868
- return Object.keys(t).forEach((r) => {
869
- n.has(r) || s.push(
870
- `${o}.${r} is not supported; repair actions support only tool and reason.`
871
- );
872
- }), t.tool !== "semaphor_propose_semantic_model_change" && s.push(
873
- `${o}.tool must be semaphor_propose_semantic_model_change.`
874
- ), t.reason !== "missing_relationship" && s.push(`${o}.reason must be missing_relationship.`), s;
875
- }
876
- function tt(i, o) {
877
- const t = a(i);
878
- if (!t)
879
- return [`${o} must be an object.`];
880
- const s = [], n = /* @__PURE__ */ new Set(["source", "sourceFields", "target", "targetFields"]);
881
- Object.keys(t).forEach((r) => {
882
- n.has(r) || s.push(
883
- `${o}.${r} is not supported; relationship candidates support only source, sourceFields, target, and targetFields.`
884
- );
885
- }), s.push(
886
- ...Q(t.source, `${o}.source`)
887
- ), s.push(
888
- ...Q(t.target, `${o}.target`)
889
- );
890
- for (const r of ["sourceFields", "targetFields"]) {
891
- const l = t[r];
892
- if (!Array.isArray(l) || l.length === 0) {
893
- s.push(`${o}.${r} must be a non-empty endpoint field array.`);
894
- continue;
895
- }
896
- l.forEach((u, c) => {
897
- s.push(
898
- ...ot(u, `${o}.${r}.${c}`)
899
- );
900
- });
901
- }
902
- return s;
903
- }
904
- function ot(i, o) {
905
- const t = a(i);
906
- if (!t)
907
- return [`${o} must be an object.`];
908
- const s = [], n = /* @__PURE__ */ new Set(["name", "label", "role", "dataType"]);
909
- return Object.keys(t).forEach((r) => {
910
- n.has(r) || s.push(
911
- `${o}.${r} is not supported; relationship candidate fields are scoped by their endpoint and support only name, label, role, and dataType.`
912
- );
913
- }), (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(
914
- t.dataType
915
- )) && s.push(
916
- `${o}.dataType must be string, number, boolean, date, datetime, or unknown.`
917
- ), s;
918
- }
919
- function Q(i, o) {
920
- const t = a(i);
921
- if (!t)
922
- return [`${o} must be an object.`];
923
- const s = [], n = /* @__PURE__ */ new Set([
924
- "kind",
925
- "domainId",
926
- "datasetName",
927
- "datasetId",
928
- "label",
929
- "sourceKey"
930
- ]);
931
- return Object.keys(t).forEach((r) => {
932
- n.has(r) || s.push(
933
- `${o}.${r} is not supported; relationship candidate sources support only semantic identity fields.`
934
- );
935
- }), 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;
936
- }
937
- function $(i) {
938
- return he.has(i);
939
- }
940
- function te(i) {
941
- return fe.has(i);
942
- }
943
- function h(i, o) {
944
- return i === void 0 ? [] : p(i, o);
945
- }
946
- function p(i, o) {
947
- const t = a(i);
948
- if (!t)
949
- return [`${o} must be an object.`];
950
- const s = [];
951
- 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;
952
- }
953
- function oe(i, o) {
954
- const t = a(i), s = p(i, o);
955
- if (!t || typeof t.sourceKey == "string" && t.sourceKey.trim())
956
- return s;
957
- if (t.source !== void 0) {
958
- const r = w(t.source, `${o}.source`);
959
- return r.length === 0 || s.push(...r), s;
960
- }
961
- return s.includes(`${o} must include source or sourceKey.`) || s.push(`${o} must include source or sourceKey.`), s;
962
- }
963
- function a(i) {
964
- return i && typeof i == "object" && !Array.isArray(i) ? i : void 0;
965
- }
966
- function g(i) {
967
- return Array.isArray(i) && i.every((o) => typeof o == "string");
968
- }
969
- const m = e.record(e.string(), e.unknown()), R = e.array(m), d = e.enum([
970
- "SUM",
971
- "COUNT",
972
- "AVG",
973
- "MIN",
974
- "MAX",
975
- "MEDIAN",
976
- "DISTINCT"
977
- ]), C = e.enum([
978
- "postgres",
979
- "mysql",
980
- "mssql",
981
- "snowflake",
982
- "clickhouse",
983
- "bigquery",
984
- "redshift",
985
- "duckdb",
986
- "sqlite",
987
- "unknown"
988
- ]), se = e.enum([
989
- "hour",
990
- "day",
991
- "week",
992
- "month",
993
- "quarter",
994
- "year"
995
- ]), q = e.enum([
996
- "dimension",
997
- "measure",
998
- "date",
999
- "id",
1000
- "unknown"
1001
- ]), x = e.enum([
1002
- "string",
1003
- "number",
1004
- "boolean",
1005
- "date",
1006
- "datetime",
1007
- "unknown"
1008
- ]), ie = e.enum([
1009
- "semantic_model",
1010
- "caller_override",
1011
- "default_sum"
1012
- ]), j = e.union([e.number(), e.string(), e.null()]), D = e.enum([
1013
- "millisecond",
1014
- "second",
1015
- "minute",
1016
- "hour",
1017
- "day"
1018
- ]), ne = e.union([
1019
- e.object({
1020
- type: e.enum(["number", "currency", "percent", "percentage", "scientific"]),
1021
- locale: e.string().optional(),
1022
- minimumFractionDigits: e.number().optional(),
1023
- maximumFractionDigits: e.number().optional(),
1024
- useGrouping: e.boolean().optional(),
1025
- prefix: e.string().optional(),
1026
- suffix: e.string().optional(),
1027
- negativeStyle: e.enum(["minus", "parentheses"]).optional(),
1028
- compact: e.boolean().optional(),
1029
- scale: e.number().optional(),
1030
- currency: e.string().optional(),
1031
- percentValueMode: e.enum(["fraction", "whole"]).optional()
1032
- }).passthrough(),
1033
- e.object({
1034
- type: e.enum(["date", "datetime"]),
1035
- locale: e.string().optional(),
1036
- pattern: e.string().optional(),
1037
- relative: e.boolean().optional(),
1038
- timezone: e.string().optional(),
1039
- sourceTimezone: e.string().optional(),
1040
- prefix: e.string().optional(),
1041
- suffix: e.string().optional()
1042
- }).passthrough(),
1043
- e.object({
1044
- type: e.literal("duration"),
1045
- inputUnit: D.optional(),
1046
- outputStyle: e.enum(["compact", "digital", "long"]).optional(),
1047
- largestUnit: D.optional(),
1048
- smallestUnit: D.optional(),
1049
- maxUnits: e.number().optional(),
1050
- prefix: e.string().optional(),
1051
- suffix: e.string().optional(),
1052
- negativeStyle: e.enum(["minus", "parentheses"]).optional()
1053
- }).passthrough(),
1054
- e.object({
1055
- type: e.literal("string"),
1056
- prefix: e.string().optional(),
1057
- suffix: e.string().optional()
1058
- }).passthrough()
1059
- ]), st = e.union([
1060
- e.object({ kind: e.literal("defaultAggregate") }).passthrough(),
1061
- e.object({ kind: e.literal("blank") }).passthrough(),
1062
- e.object({
1063
- kind: e.literal("labelOnly"),
1064
- label: e.string().optional()
1065
- }).passthrough(),
1066
- e.object({
1067
- kind: e.literal("customAggregate"),
1068
- aggregate: d
1069
- }).passthrough(),
1070
- e.object({ kind: e.literal("percentOfParent") }).passthrough(),
1071
- e.object({ kind: e.literal("percentOfGrandTotal") }).passthrough(),
1072
- e.object({
1073
- kind: e.literal("customExpression"),
1074
- expressionId: e.string()
1075
- }).passthrough()
1076
- ]);
1077
- function k(i, o) {
1078
- return e.object(i).passthrough().superRefine((t, s) => {
1079
- for (const n of o)
1080
- Object.prototype.hasOwnProperty.call(t, n) || s.addIssue({
1081
- code: "custom",
1082
- path: [n],
1083
- message: `Required field "${n}" is missing.`
1084
- });
1085
- });
1086
- }
1087
- const re = e.object({
1088
- kind: e.literal("semantic"),
1089
- domainId: e.string(),
1090
- datasetName: e.string(),
1091
- datasetId: e.string().optional(),
1092
- label: e.string().optional(),
1093
- connectionId: e.string().optional()
1094
- }).passthrough(), it = e.object({
1095
- kind: e.literal("physical"),
1096
- connectionId: e.string(),
1097
- connectionType: e.string().optional(),
1098
- tableName: e.string(),
1099
- databaseName: e.string().optional(),
1100
- schemaName: e.string().optional(),
1101
- label: e.string().optional(),
1102
- dialect: C.optional()
1103
- }).passthrough(), nt = e.object({
1104
- kind: e.literal("sql"),
1105
- connectionId: e.string(),
1106
- dialect: C.optional(),
1107
- label: e.string().optional()
1108
- }).passthrough(), S = e.union([
1109
- re,
1110
- it,
1111
- nt
1112
- ]), y = e.object({
1113
- name: e.string(),
1114
- label: e.string().optional(),
1115
- role: q.optional(),
1116
- dataType: x.optional(),
1117
- source: S.optional(),
1118
- aggregate: d.optional()
1119
- }).passthrough(), rt = e.object({
1120
- kind: e.literal("field"),
1121
- field: y,
1122
- aggregate: d.optional()
1123
- }).passthrough(), ae = e.object({
1124
- kind: e.literal("derived_field"),
1125
- name: e.string(),
1126
- label: e.string(),
1127
- description: e.string().optional(),
1128
- resultRole: q,
1129
- dataType: x,
1130
- computeStage: e.enum(["row", "aggregate"]),
1131
- expression: e.string(),
1132
- expressionLanguage: e.literal("semaphor_sql_template").optional(),
1133
- inputs: e.record(rt),
1134
- defaultAggregate: d.optional(),
1135
- aggregationBehavior: e.enum([
1136
- "additive",
1137
- "non_additive",
1138
- "ratio_of_sums",
1139
- "weighted",
1140
- "pre_aggregated",
1141
- "snapshot"
1142
- ]).optional(),
1143
- aggregationStrategy: e.enum([
1144
- "default",
1145
- "symmetric_aggregate",
1146
- "aggregate_then_join",
1147
- "weighted"
1148
- ]).optional(),
1149
- format: ne.optional(),
1150
- tags: e.array(e.string()).optional()
1151
- }).passthrough(), V = y.and(
1152
- e.object({
1153
- semanticAggregate: d.optional(),
1154
- effectiveAggregate: d.optional(),
1155
- aggregateSource: ie.optional(),
1156
- derivedField: ae.optional()
1157
- }).passthrough()
1158
- ), at = re, lt = e.object({
1159
- kind: e.literal("physical"),
1160
- connectionId: e.string().optional(),
1161
- connectionType: e.string().optional(),
1162
- tableName: e.string(),
1163
- databaseName: e.string().optional(),
1164
- schemaName: e.string().optional(),
1165
- label: e.string().optional(),
1166
- dialect: C.optional()
1167
- }).passthrough(), ut = e.object({
1168
- kind: e.literal("sql"),
1169
- connectionId: e.string().optional(),
1170
- dialect: C.optional(),
1171
- label: e.string().optional()
1172
- }).passthrough(), dt = e.union([
1173
- at,
1174
- lt,
1175
- ut
1176
- ]), ct = e.object({
1177
- key: e.string().optional(),
1178
- name: e.string(),
1179
- label: e.string().optional(),
1180
- role: q.optional(),
1181
- dataType: x.optional(),
1182
- source: dt.optional(),
1183
- aggregate: d.optional(),
1184
- semanticAggregate: d.optional(),
1185
- effectiveAggregate: d.optional(),
1186
- aggregateSource: ie.optional(),
1187
- derivedField: e.never().optional()
1188
- }).passthrough(), K = e.object({
1189
- key: e.string(),
1190
- name: e.string(),
1191
- label: e.string(),
1192
- role: q.optional(),
1193
- dataType: x.optional(),
1194
- aggregate: d.optional(),
1195
- source: S.optional(),
1196
- derivedField: ae.optional()
1197
- }).passthrough(), le = e.object({
1198
- code: e.string(),
1199
- message: e.string().optional(),
1200
- invalidField: e.string().optional(),
1201
- fieldRole: e.enum(["measure", "date", "dimension", "input", "source", "sql"]).optional(),
1202
- validMeasureCandidates: e.array(e.string()).optional(),
1203
- validDateCandidates: e.array(e.string()).optional(),
1204
- validDimensionCandidates: e.array(e.string()).optional(),
1205
- recommendedNextStep: e.string()
1206
- }).passthrough(), M = e.object({
1207
- code: e.string(),
1208
- message: e.string(),
1209
- path: e.string().optional(),
1210
- fieldRole: e.enum(["measure", "date", "dimension", "input", "source", "sql"]).optional(),
1211
- repairHint: le.optional()
1212
- }).passthrough(), ue = e.object({
1213
- ok: e.boolean(),
1214
- errors: e.array(M),
1215
- warnings: e.array(M),
1216
- repairHints: e.array(le)
1217
- }).passthrough(), pt = e.object({
1218
- page: e.number(),
1219
- pageSize: e.number(),
1220
- pageCount: e.number(),
1221
- totalCount: e.number(),
1222
- hasNextPage: e.boolean(),
1223
- hasPrevPage: e.boolean()
1224
- }).passthrough(), I = {
1225
- intentId: e.string().optional(),
1226
- queryPath: e.enum(["query_spec", "sql", "sql_python"]),
1227
- warnings: e.array(e.string()).optional(),
1228
- rowCount: e.number().optional(),
1229
- rowLimitExceeded: e.boolean().optional(),
1230
- limit: e.number().optional(),
1231
- pagination: pt.optional()
1232
- }, mt = e.object({
1233
- ...I,
1234
- kind: e.literal("metric"),
1235
- value: j,
1236
- measures: e.record(j).optional(),
1237
- comparison: e.object({
1238
- kind: e.enum(["previous_period", "previous_year", "target"]),
1239
- value: j.optional(),
1240
- delta: e.union([e.number(), e.null()]).optional(),
1241
- deltaPercent: e.union([e.number(), e.null()]).optional()
1242
- }).passthrough().optional(),
1243
- records: R.optional()
1244
- }).passthrough(), gt = e.object({
1245
- ...I,
1246
- kind: e.literal("records"),
1247
- columns: e.array(K),
1248
- records: R,
1249
- totals: e.object({
1250
- mode: e.literal("server"),
1251
- scope: e.literal("filtered_result"),
1252
- row: e.record(e.string(), e.unknown()),
1253
- columns: e.array(K).optional()
1254
- }).passthrough().optional()
1255
- }).passthrough(), ht = e.object({
1256
- ...I,
1257
- kind: e.literal("inputOptions"),
1258
- options: e.array(
1259
- k(
1260
- {
1261
- label: e.string(),
1262
- value: e.unknown(),
1263
- count: e.number().optional(),
1264
- disambiguation: e.array(e.string()).optional()
1265
- },
1266
- ["value"]
1267
- )
1268
- )
1269
- }).passthrough(), ft = e.object({
1270
- ...I,
1271
- kind: e.literal("sql"),
1272
- columns: e.array(K),
1273
- records: R,
1274
- sqlShape: e.object({
1275
- statementType: e.string().optional(),
1276
- explicitLimit: e.number().optional(),
1277
- hasPythonCode: e.boolean().optional()
1278
- }).passthrough().optional()
1279
- }).passthrough(), bt = e.object({
1280
- enabled: e.boolean().optional(),
1281
- position: e.enum(["before", "after"]).optional(),
1282
- label: e.string().optional()
1283
- }).passthrough(), Y = e.object({
1284
- id: e.enum(["rows", "columns"]),
1285
- levels: e.array(
1286
- e.object({
1287
- instanceId: e.string(),
1288
- fieldKey: e.string(),
1289
- label: e.string(),
1290
- field: y,
1291
- grain: se.optional(),
1292
- subtotal: bt.optional()
1293
- }).passthrough()
1294
- ),
1295
- nodeIds: e.array(e.string())
1296
- }).passthrough(), b = k(
1297
- {
1298
- instanceId: e.string(),
1299
- fieldKey: e.string(),
1300
- value: e.unknown(),
1301
- label: e.string()
1302
- },
1303
- ["value"]
1304
- ), yt = e.union([
1305
- e.object({ kind: e.literal("label") }).passthrough(),
1306
- e.object({
1307
- kind: e.literal("field"),
1308
- field: y,
1309
- aggregate: d.optional()
1310
- }).passthrough(),
1311
- e.object({
1312
- kind: e.literal("value"),
1313
- valueId: e.string(),
1314
- rowPath: e.array(b).optional(),
1315
- columnPath: e.array(b).optional()
1316
- }).passthrough()
1317
- ]), vt = e.enum([
1318
- "present",
1319
- "presentNull",
1320
- "missing",
1321
- "densified"
1322
- ]), $t = e.enum([
1323
- "value",
1324
- "rowSubtotal",
1325
- "columnSubtotal",
1326
- "subtotalIntersection",
1327
- "rowGrandTotal",
1328
- "columnGrandTotal",
1329
- "matrixGrandTotal"
1330
- ]), St = e.object({
1331
- instanceId: e.string(),
1332
- fieldKey: e.string(),
1333
- field: y,
1334
- role: e.enum(["row", "column", "measure", "sort", "filter"]),
1335
- label: e.string().optional()
1336
- }).passthrough(), wt = e.union([
1337
- e.object({
1338
- kind: e.literal("additive"),
1339
- aggregate: d.optional()
1340
- }).passthrough(),
1341
- e.object({
1342
- kind: e.literal("semiAdditive"),
1343
- aggregate: d.optional(),
1344
- grain: se.optional()
1345
- }).passthrough(),
1346
- e.object({
1347
- kind: e.literal("nonAdditive"),
1348
- aggregate: d.optional()
1349
- }).passthrough(),
1350
- e.object({
1351
- kind: e.literal("ratio"),
1352
- numeratorMeasureInstanceId: e.string().optional(),
1353
- denominatorMeasureInstanceId: e.string().optional()
1354
- }).passthrough(),
1355
- e.object({
1356
- kind: e.literal("custom"),
1357
- expressionId: e.string().optional()
1358
- }).passthrough()
1359
- ]), kt = e.object({
1360
- instanceId: e.string(),
1361
- fieldKey: e.string(),
1362
- label: e.string(),
1363
- field: y,
1364
- aggregate: d.optional(),
1365
- format: ne.optional(),
1366
- totalBehavior: st.optional(),
1367
- semantics: wt
1368
- }).passthrough(), It = e.object({
1369
- id: e.string(),
1370
- measureId: e.string(),
1371
- aggregate: d.optional(),
1372
- label: e.string().optional(),
1373
- source: e.enum([
1374
- "measureDefault",
1375
- "rowSubtotal",
1376
- "columnSubtotal",
1377
- "subtotalIntersection",
1378
- "rowGrandTotal",
1379
- "columnGrandTotal",
1380
- "matrixGrandTotal",
1381
- "custom"
1382
- ]),
1383
- scope: e.object({
1384
- rowLevelId: e.string().optional(),
1385
- columnLevelId: e.string().optional(),
1386
- rowNodeId: e.string().optional(),
1387
- columnNodeId: e.string().optional()
1388
- }).passthrough().optional()
1389
- }).passthrough(), At = e.object({
1390
- kind: e.string(),
1391
- label: e.string().optional(),
1392
- payload: e.record(e.string(), e.unknown()).optional()
1393
- }).passthrough(), _t = k(
1394
- {
1395
- id: e.string(),
1396
- axis: e.enum(["row", "column"]),
1397
- path: e.array(b),
1398
- level: e.number(),
1399
- label: e.string(),
1400
- value: e.unknown(),
1401
- parentId: e.string().optional(),
1402
- hasChildren: e.boolean(),
1403
- isExpanded: e.boolean().optional(),
1404
- isSubtotal: e.boolean().optional(),
1405
- isGrandTotal: e.boolean().optional(),
1406
- subtotalFunction: d.optional(),
1407
- childCount: e.number().optional(),
1408
- actions: e.array(At).optional()
1409
- },
1410
- ["value"]
1411
- ), jt = e.object({
1412
- rowHeaderLevels: e.array(
1413
- e.object({
1414
- id: e.string(),
1415
- label: e.string(),
1416
- fieldInstanceId: e.string()
1417
- }).passthrough()
1418
- ),
1419
- columnHeaderRows: e.array(
1420
- e.object({
1421
- id: e.string(),
1422
- cells: e.array(
1423
- e.object({
1424
- id: e.string(),
1425
- label: e.string(),
1426
- role: e.enum([
1427
- "rowHeader",
1428
- "columnHeader",
1429
- "measureHeader",
1430
- "subtotal",
1431
- "grandTotal"
1432
- ]),
1433
- colSpan: e.number(),
1434
- rowSpan: e.number(),
1435
- columnPath: e.array(b),
1436
- measureInstanceId: e.string().optional()
1437
- }).passthrough()
1438
- )
1439
- }).passthrough()
1440
- ),
1441
- columns: e.array(
1442
- e.object({
1443
- id: e.string(),
1444
- label: e.string(),
1445
- columnNodeId: e.string().optional(),
1446
- columnPath: e.array(b),
1447
- measureInstanceId: e.string(),
1448
- role: e.enum(["value", "columnSubtotal", "columnGrandTotal"])
1449
- }).passthrough()
1450
- )
1451
- }).passthrough(), Rt = k(
1452
- {
1453
- rowId: e.string(),
1454
- columnId: e.string().optional(),
1455
- measureId: e.string(),
1456
- value: e.unknown(),
1457
- formattedValue: e.string().optional(),
1458
- presence: vt,
1459
- role: $t,
1460
- calculationId: e.string().optional()
1461
- },
1462
- ["value"]
1463
- ), Ct = e.object({
1464
- rows: e.boolean().optional(),
1465
- columns: e.boolean().optional(),
1466
- grandTotal: e.union([
1467
- e.boolean(),
1468
- e.object({
1469
- rows: e.boolean().optional(),
1470
- columns: e.boolean().optional()
1471
- }).passthrough()
1472
- ]).optional()
1473
- }).passthrough(), qt = k(
1474
- {
1475
- id: e.string(),
1476
- axis: e.enum(["row", "column"]),
1477
- targetInstanceId: e.string().optional(),
1478
- direction: e.enum(["asc", "desc"]),
1479
- nulls: e.enum(["warehouseDefault", "first", "last"]).optional(),
1480
- scope: e.enum(["global", "withinParent"]).optional(),
1481
- by: yt
1482
- },
1483
- ["by"]
1484
- ), xt = e.object({
1485
- rowOffset: e.number().optional(),
1486
- rowLimit: e.number().optional(),
1487
- columnOffset: e.number().optional(),
1488
- columnLimit: e.number().optional(),
1489
- hasMoreRows: e.boolean().optional(),
1490
- hasMoreColumns: e.boolean().optional()
1491
- }).passthrough(), Et = e.object({
1492
- axis: e.enum(["row", "column"]),
1493
- path: e.array(b),
1494
- depth: e.number().optional()
1495
- }).passthrough(), Ft = e.object({
1496
- rowLazyLoading: e.boolean().optional(),
1497
- columnLazyLoading: e.boolean().optional(),
1498
- expandableRowNodeIds: e.array(e.string()).optional(),
1499
- expandableColumnNodeIds: e.array(e.string()).optional(),
1500
- nextRequests: e.array(Et).optional()
1501
- }).passthrough(), Nt = e.object({
1502
- domains: e.record(
1503
- e.object({
1504
- min: e.number().optional(),
1505
- max: e.number().optional()
1506
- }).passthrough()
1507
- ).optional(),
1508
- rules: e.array(e.record(e.string(), e.unknown())).optional()
1509
- }).passthrough(), Tt = e.object({
1510
- ...I,
1511
- kind: e.literal("matrix"),
1512
- schemaVersion: e.literal(1),
1513
- shape: e.enum(["hierarchical", "pivot"]),
1514
- capabilities: e.array(e.string()),
1515
- executionMetadata: e.record(e.string(), e.unknown()),
1516
- fieldsById: e.record(e.string(), St),
1517
- measuresById: e.record(e.string(), kt),
1518
- calculationsById: e.record(e.string(), It).optional(),
1519
- axes: e.object({
1520
- rows: Y,
1521
- columns: Y
1522
- }).passthrough(),
1523
- nodesById: e.record(e.string(), _t),
1524
- layout: jt,
1525
- cells: e.array(Rt),
1526
- totals: Ct,
1527
- sort: e.array(qt),
1528
- formattingContext: Nt,
1529
- pageInfo: xt.optional(),
1530
- expansion: Ft.optional()
1531
- }).passthrough(), Dt = e.union([
1532
- mt,
1533
- gt,
1534
- ht,
1535
- ft,
1536
- Tt
1537
- ]), Ot = e.object({
1538
- status: e.enum([
1539
- "not_required",
1540
- "resolved",
1541
- "missing",
1542
- "ambiguous",
1543
- "fanout_risk",
1544
- "unknown"
1545
- ]),
1546
- requiredSources: e.array(S).optional(),
1547
- relationshipsUsed: e.array(e.string()).optional(),
1548
- missingSources: e.array(e.string()).optional(),
1549
- warnings: e.array(e.string()).optional(),
1550
- message: e.string().optional(),
1551
- recommendedNextStep: e.string().optional(),
1552
- joinPlanSummary: e.object({
1553
- baseSource: S.optional(),
1554
- joinedSources: e.array(S).optional(),
1555
- joinCount: e.number().optional()
1556
- }).passthrough().optional(),
1557
- fanoutRisk: e.object({
1558
- status: e.enum(["none", "warning", "error", "unknown"]),
1559
- message: e.string().optional()
1560
- }).passthrough().optional()
1561
- }).passthrough(), W = e.enum([
1562
- "ambiguous_fields",
1563
- "empty_result",
1564
- "missing_grounded_fields",
1565
- "missing_relationship",
1566
- "no_grounded_query",
1567
- "partial_result",
1568
- "presentation_incomplete",
1569
- "query_validation_failed",
1570
- "unsafe_join"
1571
- ]), de = e.object({
1572
- version: e.literal(1),
1573
- status: e.enum(["answered", "partial", "blocked"]),
1574
- summary: e.string(),
1575
- answered: e.array(
1576
- e.object({
1577
- slotId: e.string().optional(),
1578
- queryId: e.string().optional(),
1579
- summary: e.string(),
1580
- evidenceIds: e.array(e.string()).optional(),
1581
- fieldsUsed: e.array(V).optional()
1582
- }).passthrough()
1583
- ),
1584
- blocked: e.array(
1585
- e.object({
1586
- slotId: e.string().optional(),
1587
- queryId: e.string().optional(),
1588
- reasonCode: W,
1589
- message: e.string(),
1590
- missingFields: e.array(e.string()).optional(),
1591
- availableFields: e.array(e.string()).optional(),
1592
- ambiguousFields: e.array(e.string()).optional(),
1593
- missingRelationships: e.array(e.string()).optional(),
1594
- evidenceIds: e.array(e.string()).optional(),
1595
- neededFromUser: e.array(e.string()).optional(),
1596
- recommendedNextStep: e.string().optional()
1597
- }).passthrough()
1598
- ),
1599
- semanticModelRecommendations: e.array(
1600
- e.object({
1601
- reasonCode: W,
1602
- message: e.string(),
1603
- recommendedNextStep: e.string().optional()
1604
- }).passthrough()
1605
- ).optional()
1606
- }).passthrough(), ce = e.object({
1607
- scope: e.literal("filtered_query"),
1608
- measures: e.record(j)
1609
- }).passthrough(), pe = e.object({
1610
- answeredObligations: e.array(e.string()),
1611
- missingObligations: e.array(e.string()),
1612
- warnings: e.array(M).optional()
1613
- }).passthrough(), Kt = e.object({
1614
- intentId: e.string().optional(),
1615
- queryId: e.string().optional(),
1616
- status: e.enum(["answered", "partial", "failed"]),
1617
- resultShape: e.enum([
1618
- "metric",
1619
- "records",
1620
- "inputOptions",
1621
- "sql",
1622
- "matrix",
1623
- "period_change",
1624
- "analysis"
1625
- ]).optional(),
1626
- intent: e.unknown().optional(),
1627
- compiledQuery: e.unknown().optional(),
1628
- fieldsUsed: e.array(V).optional(),
1629
- result: Dt.optional(),
1630
- validation: ue,
1631
- coverage: pe.optional(),
1632
- missingFields: e.array(e.string()).optional(),
1633
- warnings: e.array(e.string()).optional(),
1634
- relationshipDiagnostics: Ot.optional(),
1635
- diagnosticFeedback: de.optional(),
1636
- population: ce.optional(),
1637
- metadata: e.record(e.string(), e.unknown()).optional()
1638
- }).passthrough();
1639
- function Mt(i) {
1640
- switch (i) {
1641
- case "boolean":
1642
- return e.boolean().optional();
1643
- case "compactExecutionFieldArray":
1644
- return e.array(ct).optional();
1645
- case "coverage":
1646
- return pe.optional();
1647
- case "diagnosticFeedback":
1648
- return de.optional();
1649
- case "executionFieldArray":
1650
- return e.array(V).optional();
1651
- case "executionResult":
1652
- return Kt.optional();
1653
- case "number":
1654
- return e.number().finite().optional();
1655
- case "population":
1656
- return ce.optional();
1657
- case "record":
1658
- return m.optional();
1659
- case "recordArray":
1660
- return R.optional();
1661
- case "responseDetail":
1662
- return e.enum(["compact", "standard", "debug"]).optional();
1663
- case "string":
1664
- return e.string().optional();
1665
- case "stringArray":
1666
- return e.array(e.string()).optional();
1667
- case "unknown":
1668
- return e.unknown().optional();
1669
- case "unknownArray":
1670
- return e.array(e.unknown()).optional();
1671
- case "validationResult":
1672
- return ue.optional();
1673
- }
1674
- }
1675
- const Bt = Object.fromEntries(
1676
- Object.entries(B).map(
1677
- ([i, o]) => [i, Mt(o)]
1678
- )
1679
- ), Pt = e.object(Bt).strict(), L = e.object({
1680
- sourceKey: e.string().optional(),
1681
- kind: e.enum(["semantic", "physical", "sql"]).optional(),
1682
- domainId: e.string().optional(),
1683
- datasetName: e.string().optional(),
1684
- datasetId: e.string().optional(),
1685
- connectionId: e.string().optional(),
1686
- tableName: e.string().optional(),
1687
- label: e.string().optional()
1688
- }).passthrough(), f = e.object({
1689
- name: e.string(),
1690
- label: e.string().optional(),
1691
- role: e.enum(["dimension", "measure", "date", "id", "unknown"]).optional(),
1692
- dataType: e.enum(["string", "number", "boolean", "date", "datetime", "unknown"]).optional(),
1693
- aggregate: d.optional(),
1694
- sourceKey: e.string().optional(),
1695
- source: L.optional()
1696
- }).passthrough(), me = e.object({
1697
- id: e.string().optional(),
1698
- builder: e.literal("semaphor.inputOptions"),
1699
- source: L.optional(),
1700
- sourceKey: e.string().optional(),
1701
- valueFieldRef: f,
1702
- labelFieldRef: f,
1703
- filterFieldRef: f.optional(),
1704
- population: e.unknown().optional(),
1705
- dependencies: e.unknown().optional(),
1706
- limit: e.number().int().positive().optional(),
1707
- spec: m.optional()
1708
- }).passthrough(), ge = e.object({
1709
- appliesToViewIds: e.array(e.string()).optional(),
1710
- viewId: e.string().optional(),
1711
- fieldRef: f,
1712
- relationshipHint: e.unknown().optional(),
1713
- relationshipsUsed: e.array(m).optional()
1714
- }).passthrough(), Vt = e.object({
1715
- id: e.string(),
1716
- label: e.string().optional(),
1717
- type: e.string().optional(),
1718
- serverSide: e.boolean().optional(),
1719
- fieldRef: f.optional(),
1720
- optionQuery: me.optional(),
1721
- bindings: e.array(ge).optional(),
1722
- appliesToViewIds: e.array(e.string()),
1723
- relationshipHint: e.unknown().optional(),
1724
- relationshipsUsed: e.array(m).optional()
1725
- }).passthrough(), Lt = e.object({
1726
- builder: e.enum([
1727
- "semaphor.metric",
1728
- "semaphor.records",
1729
- "semaphor.matrix",
1730
- "semaphor.analysis",
1731
- "semaphor.sql"
1732
- ]),
1733
- spec: m,
1734
- fallbackReason: m.optional()
1735
- }).passthrough(), Gt = e.object({
1736
- id: e.string(),
1737
- title: e.string().optional(),
1738
- purpose: e.string().optional(),
1739
- sourcePresentation: e.object({
1740
- sourceKeys: e.array(e.string()).optional(),
1741
- sourceLabels: e.array(e.string()).optional()
1742
- }).passthrough().optional(),
1743
- visual: e.string().optional(),
1744
- visualSpec: m.optional(),
1745
- queryKind: e.enum(["metric", "records", "matrix", "analysis", "sql_fallback"]).optional(),
1746
- sdkBuilder: e.enum([
1747
- "semaphor.metric",
1748
- "semaphor.records",
1749
- "semaphor.matrix",
1750
- "semaphor.analysis",
1751
- "semaphor.sql"
1752
- ]).optional(),
1753
- sdkSpec: Lt.optional(),
1754
- fields: e.array(f).optional(),
1755
- computation: m.optional(),
1756
- uxExpectations: e.array(e.string()).optional(),
1757
- validation: m.optional()
1758
- }).passthrough(), Ut = e.object({
1759
- inputId: e.string(),
1760
- label: e.string().optional(),
1761
- type: e.string().optional(),
1762
- serverSide: e.boolean().optional(),
1763
- fieldRef: f.optional(),
1764
- optionQuery: me.optional(),
1765
- bindings: e.array(ge),
1766
- appliesToViewIds: e.array(e.string()),
1767
- notAppliedToViewIds: e.array(e.string())
1768
- }).passthrough(), Zt = e.object({
1769
- schemaVersion: e.literal(O),
1770
- title: e.string(),
1771
- purpose: e.string().optional(),
1772
- userGoal: e.string().optional(),
1773
- nextStep: e.string().optional(),
1774
- sources: e.array(L),
1775
- inputs: e.array(Vt),
1776
- views: e.array(Gt),
1777
- filterContracts: e.array(Ut),
1778
- implementationChecklist: e.object({
1779
- schemaVersion: e.string().optional(),
1780
- requiredDevtools: e.object({
1781
- mountRootDevtools: e.boolean(),
1782
- providerDebugBridge: e.string().optional(),
1783
- panelPosition: e.string().optional(),
1784
- forbidden: e.array(e.string()).optional()
1785
- }).passthrough(),
1786
- requiredInputOptions: e.array(m),
1787
- filterScopeByInput: e.array(m),
1788
- bindingsByView: e.record(e.string(), e.array(m)),
1789
- validationCommands: e.array(e.string()),
1790
- browserSmokeChecks: e.array(e.string())
1791
- }).passthrough(),
1792
- nextRequiredTool: e.object({
1793
- name: e.string(),
1794
- reason: e.string().optional()
1795
- }).optional(),
1796
- unsupportedInsights: e.array(
1797
- e.object({
1798
- title: e.string(),
1799
- requestedQuestion: e.string(),
1800
- reason: e.string(),
1801
- suggestedModelingFix: e.string()
1802
- }).passthrough()
1803
- ).optional(),
1804
- assumptions: e.array(e.string()).optional(),
1805
- validation: m.optional()
1806
- }).passthrough().superRefine((i, o) => {
1807
- const t = X(i);
1808
- for (const s of t.issues)
1809
- o.addIssue({
1810
- code: e.ZodIssueCode.custom,
1811
- message: s
1812
- });
1813
- }), zt = new Set(
1814
- Object.keys(B)
1815
- );
1816
- function Xt() {
1817
- return Object.keys(
1818
- B
1819
- );
1820
- }
1821
- function Ht(i) {
1822
- return zt.has(i);
1823
- }
1824
- function Jt(i) {
1825
- if (!i || typeof i != "object" || Array.isArray(i))
1826
- throw new Error("Semaphor analyze result must be an object.");
1827
- const t = Object.keys(i).filter(
1828
- (s) => !Ht(s)
1829
- );
1830
- if (t.length)
1831
- throw new Error(
1832
- `Semaphor analyze result contains unsupported top-level field(s): ${t.join(", ")}.`
1833
- );
1834
- return Pt.parse(i);
1835
- }
1836
- export {
1837
- pe as A,
1838
- Kt as B,
1839
- Bt as C,
1840
- Pt as D,
1841
- Zt as E,
1842
- O as S,
1843
- Yt as a,
1844
- Ht as b,
1845
- B as c,
1846
- it as d,
1847
- nt as e,
1848
- S as f,
1849
- Xt as g,
1850
- y as h,
1851
- Wt as i,
1852
- ae as j,
1853
- V as k,
1854
- K as l,
1855
- M as m,
1856
- ue as n,
1857
- mt as o,
1858
- Jt as p,
1859
- gt as q,
1860
- ht as r,
1861
- re as s,
1862
- ft as t,
1863
- Tt as u,
1864
- X as v,
1865
- Dt as w,
1866
- Ot as x,
1867
- de as y,
1868
- ce as z
1869
- };