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