react-semaphor 0.1.419 → 0.1.421

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 (57) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +28 -27
  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-B5Eeu7vD.js +1 -0
  6. package/dist/chunks/analyze-result-contract-sWcmvBOA.js +2070 -0
  7. package/dist/chunks/{calendar-preferences-dialog-f0Z7Kf-U.js → calendar-preferences-dialog-CscmhyuZ.js} +1 -1
  8. package/dist/chunks/{calendar-preferences-dialog-DIfAbE_y.js → calendar-preferences-dialog-cN3_2C-u.js} +3 -3
  9. package/dist/chunks/{dashboard-briefing-launcher-anh-Jy5v.js → dashboard-briefing-launcher-BYTBNetR.js} +4 -4
  10. package/dist/chunks/{dashboard-briefing-launcher-C3tNkGFG.js → dashboard-briefing-launcher-DmZkzIC3.js} +1 -1
  11. package/dist/chunks/{dashboard-controls-DQxlOxzy.js → dashboard-controls-9DFeKIP4.js} +1 -1
  12. package/dist/chunks/{dashboard-controls-8dCQaPaq.js → dashboard-controls-PhzuaTBj.js} +5 -5
  13. package/dist/chunks/{dashboard-json-i7Ae9KGD.js → dashboard-json-Cxhw2TZc.js} +3 -3
  14. package/dist/chunks/{dashboard-json-B309EInF.js → dashboard-json-DyRHI3mL.js} +1 -1
  15. package/dist/chunks/{edit-dashboard-visual-4HycwBHR.js → edit-dashboard-visual-3_jiBXsu.js} +1 -1
  16. package/dist/chunks/{edit-dashboard-visual-z3IqzYnj.js → edit-dashboard-visual-BigSJ3-x.js} +4 -4
  17. package/dist/chunks/{index-yxKWKFdr.js → index-BKDQw0aK.js} +2 -2
  18. package/dist/chunks/{index-B6DLEXRX.js → index-CH2ZzQo4.js} +5 -5
  19. package/dist/chunks/{switch-D6Ygf3wA.js → switch-CiOjVyVI.js} +1 -1
  20. package/dist/chunks/{switch-COWQU8aK.js → switch-TbCsyhv9.js} +1 -1
  21. package/dist/chunks/{update-policy-BzT2k4n6.js → update-policy-2MZ-Vf7v.js} +211 -187
  22. package/dist/chunks/update-policy-qpyAkOyO.js +3 -0
  23. package/dist/chunks/{use-create-flow-overlay-state-CX0D-6HM.js → use-create-flow-overlay-state-BzcJWNzh.js} +3 -3
  24. package/dist/chunks/{use-create-flow-overlay-state-DENfd7sW.js → use-create-flow-overlay-state-DUQmgb9H.js} +1 -1
  25. package/dist/chunks/{validators-Cxr9qbrR.js → validators-D0pfj3jJ.js} +93 -93
  26. package/dist/chunks/validators-Dj1Y-46V.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 +1 -1
  30. package/dist/dashboard-authoring/index.js +14 -14
  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 +251 -139
  36. package/dist/data-app-codegen-node/index.js +806 -657
  37. package/dist/data-app-sdk/index.cjs +2 -2
  38. package/dist/data-app-sdk/index.js +743 -693
  39. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  40. package/dist/data-app-sdk-adapters/index.js +51 -51
  41. package/dist/data-app-sdk-validation/index.cjs +1 -1
  42. package/dist/data-app-sdk-validation/index.js +2 -2
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.js +7 -7
  45. package/dist/surfboard/index.cjs +1 -1
  46. package/dist/surfboard/index.js +2 -2
  47. package/dist/types/analytics-protocol.d.ts +12 -5
  48. package/dist/types/dashboard-assistant.d.ts +0 -5
  49. package/dist/types/data-app-codegen-node.d.ts +12 -2
  50. package/dist/types/data-app-codegen.d.ts +12 -2
  51. package/dist/types/data-app-sdk-validation.d.ts +0 -5
  52. package/dist/types/data-app-sdk.d.ts +17 -5
  53. package/package.json +1 -1
  54. package/dist/chunks/analyze-result-contract-DdhEt99q.js +0 -2004
  55. package/dist/chunks/analyze-result-contract-DwRzl7yJ.js +0 -1
  56. package/dist/chunks/update-policy-VloD-0YM.js +0 -3
  57. package/dist/chunks/validators-BMQo93Y0.js +0 -1
@@ -1,2004 +0,0 @@
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(...I(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 I(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
- }), w(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" && w(t.queryKind) && w(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(...I(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 && w(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
- ...j(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
- ...R(i.filters, `${o.path}.spec.filters`)
589
- );
590
- break;
591
- case "semaphor.analysis":
592
- t.push(
593
- ...$(i, we, `${o.path}.spec`),
594
- ...j(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
- ...R(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
- ...j(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
- ...R(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
- ...R(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
- ...j(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 j(o, s) {
737
- return a(o.source) ? I(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 = I(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 R(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
- w(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 w(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 = I(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
- ]), S = 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 A(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(), k = 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: k.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: k.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(), _ = {
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
- ..._,
1360
- kind: e.literal("metric"),
1361
- value: S,
1362
- primaryValue: S,
1363
- measures: e.record(S).optional(),
1364
- missingMeasures: e.array(e.string()).optional(),
1365
- comparison: e.object({
1366
- kind: e.enum(["previous_period", "previous_year", "target"]),
1367
- value: S.optional(),
1368
- delta: e.union([e.number(), e.null()]).optional(),
1369
- deltaPercent: e.union([e.number(), e.null()]).optional()
1370
- }).passthrough().optional(),
1371
- records: C.optional()
1372
- }).passthrough(), wt = e.object({
1373
- ..._,
1374
- kind: e.literal("records"),
1375
- columns: e.array(O),
1376
- records: C,
1377
- totals: e.object({
1378
- mode: e.literal("server"),
1379
- scope: e.literal("filtered_result"),
1380
- row: e.record(e.string(), e.unknown()),
1381
- columns: e.array(O).optional()
1382
- }).passthrough().optional()
1383
- }).passthrough(), kt = e.object({
1384
- ..._,
1385
- kind: e.literal("inputOptions"),
1386
- options: e.array(
1387
- A(
1388
- {
1389
- label: e.string(),
1390
- value: e.unknown(),
1391
- count: e.number().optional(),
1392
- disambiguation: e.array(e.string()).optional()
1393
- },
1394
- ["value"]
1395
- )
1396
- )
1397
- }).passthrough(), It = e.object({
1398
- ..._,
1399
- kind: e.literal("sql"),
1400
- columns: e.array(O),
1401
- records: C,
1402
- sqlShape: e.object({
1403
- statementType: e.string().optional(),
1404
- explicitLimit: e.number().optional(),
1405
- hasPythonCode: e.boolean().optional()
1406
- }).passthrough().optional()
1407
- }).passthrough(), At = e.object({
1408
- enabled: e.boolean().optional(),
1409
- position: e.enum(["before", "after"]).optional(),
1410
- label: e.string().optional()
1411
- }).passthrough(), J = e.object({
1412
- id: e.enum(["rows", "columns"]),
1413
- levels: e.array(
1414
- e.object({
1415
- instanceId: e.string(),
1416
- fieldKey: e.string(),
1417
- label: e.string(),
1418
- field: v,
1419
- grain: re.optional(),
1420
- subtotal: At.optional()
1421
- }).passthrough()
1422
- ),
1423
- nodeIds: e.array(e.string())
1424
- }).passthrough(), b = A(
1425
- {
1426
- instanceId: e.string(),
1427
- fieldKey: e.string(),
1428
- value: e.unknown(),
1429
- label: e.string()
1430
- },
1431
- ["value"]
1432
- ), _t = e.union([
1433
- e.object({ kind: e.literal("label") }).passthrough(),
1434
- e.object({
1435
- kind: e.literal("field"),
1436
- field: v,
1437
- aggregate: c.optional()
1438
- }).passthrough(),
1439
- e.object({
1440
- kind: e.literal("value"),
1441
- valueId: e.string(),
1442
- rowPath: e.array(b).optional(),
1443
- columnPath: e.array(b).optional()
1444
- }).passthrough()
1445
- ]), jt = e.enum([
1446
- "present",
1447
- "presentNull",
1448
- "missing",
1449
- "densified"
1450
- ]), Rt = e.enum([
1451
- "value",
1452
- "rowSubtotal",
1453
- "columnSubtotal",
1454
- "subtotalIntersection",
1455
- "rowGrandTotal",
1456
- "columnGrandTotal",
1457
- "matrixGrandTotal"
1458
- ]), Ct = e.object({
1459
- instanceId: e.string(),
1460
- fieldKey: e.string(),
1461
- field: v,
1462
- role: e.enum(["row", "column", "measure", "sort", "filter"]),
1463
- label: e.string().optional()
1464
- }).passthrough(), qt = e.union([
1465
- e.object({
1466
- kind: e.literal("additive"),
1467
- aggregate: c.optional()
1468
- }).passthrough(),
1469
- e.object({
1470
- kind: e.literal("semiAdditive"),
1471
- aggregate: c.optional(),
1472
- grain: re.optional()
1473
- }).passthrough(),
1474
- e.object({
1475
- kind: e.literal("nonAdditive"),
1476
- aggregate: c.optional()
1477
- }).passthrough(),
1478
- e.object({
1479
- kind: e.literal("ratio"),
1480
- numeratorMeasureInstanceId: e.string().optional(),
1481
- denominatorMeasureInstanceId: e.string().optional()
1482
- }).passthrough(),
1483
- e.object({
1484
- kind: e.literal("custom"),
1485
- expressionId: e.string().optional()
1486
- }).passthrough()
1487
- ]), xt = e.object({
1488
- instanceId: e.string(),
1489
- fieldKey: e.string(),
1490
- label: e.string(),
1491
- field: v,
1492
- aggregate: c.optional(),
1493
- format: le.optional(),
1494
- totalBehavior: ct.optional(),
1495
- semantics: qt
1496
- }).passthrough(), Ft = e.object({
1497
- id: e.string(),
1498
- measureId: e.string(),
1499
- aggregate: c.optional(),
1500
- label: e.string().optional(),
1501
- source: e.enum([
1502
- "measureDefault",
1503
- "rowSubtotal",
1504
- "columnSubtotal",
1505
- "subtotalIntersection",
1506
- "rowGrandTotal",
1507
- "columnGrandTotal",
1508
- "matrixGrandTotal",
1509
- "custom"
1510
- ]),
1511
- scope: e.object({
1512
- rowLevelId: e.string().optional(),
1513
- columnLevelId: e.string().optional(),
1514
- rowNodeId: e.string().optional(),
1515
- columnNodeId: e.string().optional()
1516
- }).passthrough().optional()
1517
- }).passthrough(), Nt = e.object({
1518
- kind: e.string(),
1519
- label: e.string().optional(),
1520
- payload: e.record(e.string(), e.unknown()).optional()
1521
- }).passthrough(), Kt = A(
1522
- {
1523
- id: e.string(),
1524
- axis: e.enum(["row", "column"]),
1525
- path: e.array(b),
1526
- level: e.number(),
1527
- label: e.string(),
1528
- value: e.unknown(),
1529
- parentId: e.string().optional(),
1530
- hasChildren: e.boolean(),
1531
- isExpanded: e.boolean().optional(),
1532
- isSubtotal: e.boolean().optional(),
1533
- isGrandTotal: e.boolean().optional(),
1534
- subtotalFunction: c.optional(),
1535
- childCount: e.number().optional(),
1536
- actions: e.array(Nt).optional()
1537
- },
1538
- ["value"]
1539
- ), Et = e.object({
1540
- rowHeaderLevels: e.array(
1541
- e.object({
1542
- id: e.string(),
1543
- label: e.string(),
1544
- fieldInstanceId: e.string()
1545
- }).passthrough()
1546
- ),
1547
- columnHeaderRows: e.array(
1548
- e.object({
1549
- id: e.string(),
1550
- cells: e.array(
1551
- e.object({
1552
- id: e.string(),
1553
- label: e.string(),
1554
- role: e.enum([
1555
- "rowHeader",
1556
- "columnHeader",
1557
- "measureHeader",
1558
- "subtotal",
1559
- "grandTotal"
1560
- ]),
1561
- colSpan: e.number(),
1562
- rowSpan: e.number(),
1563
- columnPath: e.array(b),
1564
- measureInstanceId: e.string().optional()
1565
- }).passthrough()
1566
- )
1567
- }).passthrough()
1568
- ),
1569
- columns: e.array(
1570
- e.object({
1571
- id: e.string(),
1572
- label: e.string(),
1573
- columnNodeId: e.string().optional(),
1574
- columnPath: e.array(b),
1575
- measureInstanceId: e.string(),
1576
- role: e.enum(["value", "columnSubtotal", "columnGrandTotal"])
1577
- }).passthrough()
1578
- )
1579
- }).passthrough(), Tt = A(
1580
- {
1581
- rowId: e.string(),
1582
- columnId: e.string().optional(),
1583
- measureId: e.string(),
1584
- value: e.unknown(),
1585
- formattedValue: e.string().optional(),
1586
- presence: jt,
1587
- role: Rt,
1588
- calculationId: e.string().optional()
1589
- },
1590
- ["value"]
1591
- ), Bt = e.object({
1592
- rows: e.boolean().optional(),
1593
- columns: e.boolean().optional(),
1594
- grandTotal: e.union([
1595
- e.boolean(),
1596
- e.object({
1597
- rows: e.boolean().optional(),
1598
- columns: e.boolean().optional()
1599
- }).passthrough()
1600
- ]).optional()
1601
- }).passthrough(), Dt = A(
1602
- {
1603
- id: e.string(),
1604
- axis: e.enum(["row", "column"]),
1605
- targetInstanceId: e.string().optional(),
1606
- direction: e.enum(["asc", "desc"]),
1607
- nulls: e.enum(["warehouseDefault", "first", "last"]).optional(),
1608
- scope: e.enum(["global", "withinParent"]).optional(),
1609
- by: _t
1610
- },
1611
- ["by"]
1612
- ), Mt = e.object({
1613
- rowOffset: e.number().optional(),
1614
- rowLimit: e.number().optional(),
1615
- columnOffset: e.number().optional(),
1616
- columnLimit: e.number().optional(),
1617
- hasMoreRows: e.boolean().optional(),
1618
- hasMoreColumns: e.boolean().optional()
1619
- }).passthrough(), Ot = e.object({
1620
- axis: e.enum(["row", "column"]),
1621
- path: e.array(b),
1622
- depth: e.number().optional()
1623
- }).passthrough(), Pt = e.object({
1624
- rowLazyLoading: e.boolean().optional(),
1625
- columnLazyLoading: e.boolean().optional(),
1626
- expandableRowNodeIds: e.array(e.string()).optional(),
1627
- expandableColumnNodeIds: e.array(e.string()).optional(),
1628
- nextRequests: e.array(Ot).optional()
1629
- }).passthrough(), Vt = e.object({
1630
- domains: e.record(
1631
- e.object({
1632
- min: e.number().optional(),
1633
- max: e.number().optional()
1634
- }).passthrough()
1635
- ).optional(),
1636
- rules: e.array(e.record(e.string(), e.unknown())).optional()
1637
- }).passthrough(), Lt = e.object({
1638
- ..._,
1639
- kind: e.literal("matrix"),
1640
- schemaVersion: e.literal(1),
1641
- shape: e.enum(["hierarchical", "pivot"]),
1642
- capabilities: e.array(e.string()),
1643
- executionMetadata: e.record(e.string(), e.unknown()),
1644
- fieldsById: e.record(e.string(), Ct),
1645
- measuresById: e.record(e.string(), xt),
1646
- calculationsById: e.record(e.string(), Ft).optional(),
1647
- axes: e.object({
1648
- rows: J,
1649
- columns: J
1650
- }).passthrough(),
1651
- nodesById: e.record(e.string(), Kt),
1652
- layout: Et,
1653
- cells: e.array(Tt),
1654
- totals: Bt,
1655
- sort: e.array(Dt),
1656
- formattingContext: Vt,
1657
- pageInfo: Mt.optional(),
1658
- expansion: Pt.optional()
1659
- }).passthrough(), Ut = e.union([
1660
- St,
1661
- wt,
1662
- kt,
1663
- It,
1664
- Lt
1665
- ]), Gt = e.object({
1666
- status: e.enum([
1667
- "not_required",
1668
- "resolved",
1669
- "missing",
1670
- "ambiguous",
1671
- "fanout_risk",
1672
- "unknown"
1673
- ]),
1674
- requiredSources: e.array(k).optional(),
1675
- relationshipsUsed: e.array(e.string()).optional(),
1676
- missingSources: e.array(e.string()).optional(),
1677
- warnings: e.array(e.string()).optional(),
1678
- message: e.string().optional(),
1679
- recommendedNextStep: e.string().optional(),
1680
- joinPlanSummary: e.object({
1681
- baseSource: k.optional(),
1682
- joinedSources: e.array(k).optional(),
1683
- joinCount: e.number().optional()
1684
- }).passthrough().optional(),
1685
- fanoutRisk: e.object({
1686
- status: e.enum(["none", "warning", "error", "unknown"]),
1687
- message: e.string().optional()
1688
- }).passthrough().optional()
1689
- }).passthrough(), W = e.enum([
1690
- "ambiguous_fields",
1691
- "empty_result",
1692
- "missing_grounded_fields",
1693
- "missing_relationship",
1694
- "no_grounded_query",
1695
- "partial_result",
1696
- "presentation_incomplete",
1697
- "query_validation_failed",
1698
- "unsafe_join"
1699
- ]), me = e.object({
1700
- version: e.literal(1),
1701
- status: e.enum(["answered", "partial", "blocked"]),
1702
- summary: e.string(),
1703
- answered: e.array(
1704
- e.object({
1705
- slotId: e.string().optional(),
1706
- queryId: e.string().optional(),
1707
- summary: e.string(),
1708
- evidenceIds: e.array(e.string()).optional(),
1709
- fieldsUsed: e.array(U).optional()
1710
- }).passthrough()
1711
- ),
1712
- blocked: e.array(
1713
- e.object({
1714
- slotId: e.string().optional(),
1715
- queryId: e.string().optional(),
1716
- reasonCode: W,
1717
- message: e.string(),
1718
- missingFields: e.array(e.string()).optional(),
1719
- availableFields: e.array(e.string()).optional(),
1720
- ambiguousFields: e.array(e.string()).optional(),
1721
- missingRelationships: e.array(e.string()).optional(),
1722
- evidenceIds: e.array(e.string()).optional(),
1723
- neededFromUser: e.array(e.string()).optional(),
1724
- recommendedNextStep: e.string().optional()
1725
- }).passthrough()
1726
- ),
1727
- semanticModelRecommendations: e.array(
1728
- e.object({
1729
- reasonCode: W,
1730
- message: e.string(),
1731
- recommendedNextStep: e.string().optional()
1732
- }).passthrough()
1733
- ).optional()
1734
- }).passthrough(), ge = e.object({
1735
- scope: e.literal("filtered_query"),
1736
- measures: e.record(S)
1737
- }).passthrough(), fe = e.object({
1738
- answeredObligations: e.array(e.string()),
1739
- missingObligations: e.array(e.string()),
1740
- warnings: e.array(P).optional()
1741
- }).passthrough(), zt = e.object({
1742
- intentId: e.string().optional(),
1743
- queryId: e.string().optional(),
1744
- status: e.enum(["answered", "partial", "failed"]),
1745
- resultShape: e.enum([
1746
- "metric",
1747
- "records",
1748
- "inputOptions",
1749
- "sql",
1750
- "matrix",
1751
- "period_change",
1752
- "analysis"
1753
- ]).optional(),
1754
- intent: e.unknown().optional(),
1755
- compiledQuery: e.unknown().optional(),
1756
- fieldsUsed: e.array(U).optional(),
1757
- result: Ut.optional(),
1758
- validation: pe,
1759
- coverage: fe.optional(),
1760
- missingFields: e.array(e.string()).optional(),
1761
- warnings: e.array(e.string()).optional(),
1762
- relationshipDiagnostics: Gt.optional(),
1763
- diagnosticFeedback: me.optional(),
1764
- population: ge.optional(),
1765
- metadata: e.record(e.string(), e.unknown()).optional()
1766
- }).passthrough();
1767
- function Ht(o) {
1768
- switch (o) {
1769
- case "boolean":
1770
- return e.boolean().optional();
1771
- case "compactExecutionFieldArray":
1772
- return e.array(vt).optional();
1773
- case "coverage":
1774
- return fe.optional();
1775
- case "diagnosticFeedback":
1776
- return me.optional();
1777
- case "executionFieldArray":
1778
- return e.array(U).optional();
1779
- case "executionResult":
1780
- return zt.optional();
1781
- case "number":
1782
- return e.number().finite().optional();
1783
- case "population":
1784
- return ge.optional();
1785
- case "record":
1786
- return m.optional();
1787
- case "recordArray":
1788
- return C.optional();
1789
- case "responseDetail":
1790
- return e.enum(["compact", "standard", "debug"]).optional();
1791
- case "string":
1792
- return e.string().optional();
1793
- case "stringArray":
1794
- return e.array(e.string()).optional();
1795
- case "unknown":
1796
- return e.unknown().optional();
1797
- case "unknownArray":
1798
- return e.array(e.unknown()).optional();
1799
- case "validationResult":
1800
- return pe.optional();
1801
- }
1802
- }
1803
- const Qt = Object.fromEntries(
1804
- Object.entries(V).map(
1805
- ([o, s]) => [o, Ht(s)]
1806
- )
1807
- ), Yt = e.object(Qt).strict(), G = e.object({
1808
- sourceKey: e.string().optional(),
1809
- kind: e.enum(["semantic", "physical", "sql"]).optional(),
1810
- domainId: e.string().optional(),
1811
- datasetName: e.string().optional(),
1812
- datasetId: e.string().optional(),
1813
- connectionId: e.string().optional(),
1814
- tableName: e.string().optional(),
1815
- label: e.string().optional()
1816
- }).passthrough(), h = e.object({
1817
- name: e.string(),
1818
- label: e.string().optional(),
1819
- role: e.enum(["dimension", "measure", "date", "id", "unknown"]).optional(),
1820
- dataType: e.enum(["string", "number", "boolean", "date", "datetime", "unknown"]).optional(),
1821
- aggregate: c.optional(),
1822
- sourceKey: e.string().optional(),
1823
- source: G.optional()
1824
- }).passthrough(), he = e.object({
1825
- id: e.string().optional(),
1826
- builder: e.literal("semaphor.inputOptions"),
1827
- source: G.optional(),
1828
- sourceKey: e.string().optional(),
1829
- valueFieldRef: h,
1830
- labelFieldRef: h,
1831
- filterFieldRef: h.optional(),
1832
- population: e.unknown().optional(),
1833
- dependencies: e.unknown().optional(),
1834
- limit: e.number().int().positive().optional(),
1835
- spec: m.optional()
1836
- }).passthrough(), ye = e.object({
1837
- appliesToViewIds: e.array(e.string()).optional(),
1838
- viewId: e.string().optional(),
1839
- fieldRef: h,
1840
- relationshipHint: e.unknown().optional(),
1841
- relationshipsUsed: e.array(m).optional()
1842
- }).passthrough(), Jt = e.object({
1843
- id: e.string(),
1844
- label: e.string().optional(),
1845
- type: e.string().optional(),
1846
- serverSide: e.boolean().optional(),
1847
- fieldRef: h.optional(),
1848
- optionQuery: he.optional(),
1849
- bindings: e.array(ye).optional(),
1850
- appliesToViewIds: e.array(e.string()),
1851
- relationshipHint: e.unknown().optional(),
1852
- relationshipsUsed: e.array(m).optional()
1853
- }).passthrough(), Wt = e.object({
1854
- builder: e.enum([
1855
- "semaphor.metric",
1856
- "semaphor.records",
1857
- "semaphor.matrix",
1858
- "semaphor.analysis",
1859
- "semaphor.sql"
1860
- ]),
1861
- spec: m,
1862
- fallbackReason: m.optional()
1863
- }).passthrough(), Zt = e.object({
1864
- id: e.string(),
1865
- title: e.string().optional(),
1866
- purpose: e.string().optional(),
1867
- sourcePresentation: e.object({
1868
- sourceKeys: e.array(e.string()).optional(),
1869
- sourceLabels: e.array(e.string()).optional()
1870
- }).passthrough().optional(),
1871
- visual: e.string().optional(),
1872
- visualSpec: m.optional(),
1873
- queryKind: e.enum(["metric", "records", "matrix", "analysis", "sql_fallback"]).optional(),
1874
- sdkBuilder: e.enum([
1875
- "semaphor.metric",
1876
- "semaphor.records",
1877
- "semaphor.matrix",
1878
- "semaphor.analysis",
1879
- "semaphor.sql"
1880
- ]).optional(),
1881
- sdkSpec: Wt.optional(),
1882
- fields: e.array(h).optional(),
1883
- computation: m.optional(),
1884
- uxExpectations: e.array(e.string()).optional(),
1885
- validation: m.optional()
1886
- }).passthrough(), Xt = e.object({
1887
- inputId: e.string(),
1888
- label: e.string().optional(),
1889
- type: e.string().optional(),
1890
- serverSide: e.boolean().optional(),
1891
- fieldRef: h.optional(),
1892
- optionQuery: he.optional(),
1893
- bindings: e.array(ye),
1894
- appliesToViewIds: e.array(e.string()),
1895
- notAppliedToViewIds: e.array(e.string())
1896
- }).passthrough(), ls = e.object({
1897
- schemaVersion: e.literal(M),
1898
- title: e.string(),
1899
- purpose: e.string().optional(),
1900
- userGoal: e.string().optional(),
1901
- nextStep: e.string().optional(),
1902
- sources: e.array(G),
1903
- inputs: e.array(Jt),
1904
- views: e.array(Zt),
1905
- filterContracts: e.array(Xt),
1906
- implementationChecklist: e.object({
1907
- schemaVersion: e.string().optional(),
1908
- requiredDevtools: e.object({
1909
- mountRootDevtools: e.boolean(),
1910
- providerDebugBridge: e.string().optional(),
1911
- panelPosition: e.string().optional(),
1912
- forbidden: e.array(e.string()).optional()
1913
- }).passthrough(),
1914
- requiredInputOptions: e.array(m),
1915
- filterScopeByInput: e.array(m),
1916
- bindingsByView: e.record(e.string(), e.array(m)),
1917
- validationCommands: e.array(e.string()),
1918
- browserSmokeChecks: e.array(e.string())
1919
- }).passthrough(),
1920
- nextRequiredTool: e.object({
1921
- name: e.string(),
1922
- reason: e.string().optional()
1923
- }).optional(),
1924
- unsupportedInsights: e.array(
1925
- e.object({
1926
- title: e.string(),
1927
- requestedQuestion: e.string(),
1928
- reason: e.string(),
1929
- suggestedModelingFix: e.string()
1930
- }).passthrough()
1931
- ).optional(),
1932
- assumptions: e.array(e.string()).optional(),
1933
- validation: m.optional()
1934
- }).passthrough().superRefine((o, s) => {
1935
- const t = te(o);
1936
- for (const i of t.issues)
1937
- s.addIssue({
1938
- code: e.ZodIssueCode.custom,
1939
- message: i
1940
- });
1941
- }), es = new Set(
1942
- Object.keys(V)
1943
- );
1944
- function us() {
1945
- return Object.keys(
1946
- V
1947
- );
1948
- }
1949
- function ts(o) {
1950
- return es.has(o);
1951
- }
1952
- function ds(o) {
1953
- if (!o || typeof o != "object" || Array.isArray(o))
1954
- throw new Error("Semaphor analyze result must be an object.");
1955
- const t = Object.keys(o).filter(
1956
- (i) => !ts(i)
1957
- );
1958
- if (t.length)
1959
- throw new Error(
1960
- `Semaphor analyze result contains unsupported top-level field(s): ${t.join(", ")}.`
1961
- );
1962
- return Yt.parse(o);
1963
- }
1964
- export {
1965
- me as A,
1966
- ge as B,
1967
- fe as C,
1968
- zt as D,
1969
- Qt as E,
1970
- Yt as F,
1971
- ls as G,
1972
- D as H,
1973
- Z as I,
1974
- X as J,
1975
- os as K,
1976
- be as L,
1977
- M as S,
1978
- rs as a,
1979
- ts as b,
1980
- ds as c,
1981
- V as d,
1982
- ue as e,
1983
- pt as f,
1984
- us as g,
1985
- mt as h,
1986
- as as i,
1987
- k as j,
1988
- v as k,
1989
- de as l,
1990
- U as m,
1991
- O as n,
1992
- P as o,
1993
- ns as p,
1994
- pe as q,
1995
- St as r,
1996
- is as s,
1997
- wt as t,
1998
- kt as u,
1999
- te as v,
2000
- It as w,
2001
- Lt as x,
2002
- Ut as y,
2003
- Gt as z
2004
- };