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