react-semaphor 0.1.444 → 0.1.445

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