react-semaphor 0.1.507 → 0.1.509

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 (254) hide show
  1. package/DATA_APP_SDK.md +56 -0
  2. package/dist/analytics-protocol/index.cjs +1 -1
  3. package/dist/analytics-protocol/index.js +194 -172
  4. package/dist/appearance/index.cjs +1 -1
  5. package/dist/appearance/index.js +1 -1
  6. package/dist/appearance-runtime/index.cjs +1 -1
  7. package/dist/appearance-runtime/index.js +1 -1
  8. package/dist/brand-studio/index.cjs +2 -2
  9. package/dist/brand-studio/index.js +279 -250
  10. package/dist/briefings/index.cjs +1 -1
  11. package/dist/briefings/index.js +3 -3
  12. package/dist/chunks/appearance-context-DzqCdhB4.cjs +1 -0
  13. package/dist/chunks/{appearance-context-XviHOhWJ.js → appearance-context-VJdrKi7r.js} +2 -1
  14. package/dist/chunks/{appearance-runtime-provider-D0xVQWnH.js → appearance-runtime-provider-CC4HT2Gi.js} +2 -2
  15. package/dist/chunks/{appearance-runtime-provider-Ca8rxO86.cjs → appearance-runtime-provider-D5pkvgE4.cjs} +1 -1
  16. package/dist/chunks/calculated-field-identity-BiTGmnST.cjs +1 -0
  17. package/dist/chunks/calculated-field-identity-CJL54uFx.js +1373 -0
  18. package/dist/chunks/{constants-NUleP4DY.js → card-config-utils-Bq1enstT.js} +260 -260
  19. package/dist/chunks/card-config-utils-CMO4_zVs.cjs +1 -0
  20. package/dist/chunks/{dashboard-briefing-launcher-DXTpU85p.js → dashboard-briefing-launcher-B5AQu-Vb.js} +12 -12
  21. package/dist/chunks/{dashboard-briefing-launcher-C8nDSDnV.cjs → dashboard-briefing-launcher-BoXFrqq0.cjs} +1 -1
  22. package/dist/chunks/{dashboard-controls-CyL0yimg.js → dashboard-controls-CKKkSXEX.js} +16 -14
  23. package/dist/chunks/dashboard-controls-gUVkQm8o.cjs +52 -0
  24. package/dist/chunks/dashboard-json-B7fSi6_b.cjs +1 -0
  25. package/dist/chunks/{dashboard-json-5Jr3RudV.js → dashboard-json-CAJJquVx.js} +9 -9
  26. package/dist/chunks/edit-dashboard-visual-AZetLUv1.cjs +172 -0
  27. package/dist/chunks/{edit-dashboard-visual-C7X-um9g.js → edit-dashboard-visual-DCnbqRRn.js} +1986 -1990
  28. package/dist/chunks/{editor-action-buttons-CcDm8nA5.cjs → editor-action-buttons-CBQsVYdt.cjs} +2 -2
  29. package/dist/chunks/{editor-action-buttons-C5Wja_J4.js → editor-action-buttons-DDA5JGwO.js} +6 -6
  30. package/dist/chunks/field-aggregations-DUb0NU6c.js +1229 -0
  31. package/dist/chunks/field-aggregations-jSi77h9Z.cjs +1 -0
  32. package/dist/chunks/{field-dependencies-DVl2p1Nm.js → field-dependencies-Cl97kkHy.js} +30 -34
  33. package/dist/chunks/{field-dependencies-r_U0CGQ-.cjs → field-dependencies-DIab72rQ.cjs} +1 -1
  34. package/dist/chunks/{index-BVr4fcCB.js → index-0pdaQ9e1.js} +5 -5
  35. package/dist/chunks/{index-De2QNsqV.js → index-CL2lvhwk.js} +47783 -46019
  36. package/dist/chunks/{index-C9KXfCkC.js → index-CLIro-EG.js} +3 -0
  37. package/dist/chunks/index-Cx3qmRUB.cjs +1 -0
  38. package/dist/chunks/{index-BlYf8gNa.cjs → index-DhlVxvyI.cjs} +1 -1
  39. package/dist/chunks/index-DkEAikW8.cjs +1420 -0
  40. package/dist/chunks/{matrix-card-DACDwdTq.js → matrix-card-CnKQpnsj.js} +1 -1
  41. package/dist/chunks/{matrix-card-CRXcmAjp.cjs → matrix-card-U4c72doZ.cjs} +1 -1
  42. package/dist/chunks/{matrix-control-sources-ClQzIk7E.js → matrix-control-sources-CRRdP03Q.js} +165 -134
  43. package/dist/chunks/matrix-control-sources-FjxGIbqk.cjs +1 -0
  44. package/dist/chunks/{matrix-formatter-7GLTcBuy.cjs → matrix-formatter-CveLJo6S.cjs} +1 -1
  45. package/dist/chunks/{matrix-formatter-xsq7n_e6.js → matrix-formatter-ZVS5QOuq.js} +2 -2
  46. package/dist/chunks/matrix-member-presentation-CFHjdrxT.cjs +1 -0
  47. package/dist/chunks/matrix-member-presentation-CzGZJd3a.js +182 -0
  48. package/dist/chunks/matrix-operation-contract-DoiWTUbT.cjs +1 -0
  49. package/dist/chunks/matrix-operation-contract-xL8IhFzp.js +1802 -0
  50. package/dist/chunks/{pivot-header-presentation-3wqWChFd.cjs → pivot-header-presentation-Cxz8-06f.cjs} +1 -1
  51. package/dist/chunks/{pivot-header-presentation-D44ODZGn.js → pivot-header-presentation-DVylCBHB.js} +2 -2
  52. package/dist/chunks/{pivot-result-lifecycle-DZ0ZSMoM.cjs → pivot-result-lifecycle-BiERyXnS.cjs} +1 -1
  53. package/dist/chunks/{pivot-result-lifecycle-BSmqVkVG.js → pivot-result-lifecycle-CmjpW7qG.js} +1 -1
  54. package/dist/chunks/{report-preferences-dialog-xADifRXs.js → report-preferences-dialog-Bv2VIOKc.js} +4 -4
  55. package/dist/chunks/report-preferences-dialog-Wg9g9fIj.cjs +1 -0
  56. package/dist/chunks/{search-BHsQIWBV.js → selection-reducer-B94WgZ9V.js} +55 -11
  57. package/dist/chunks/selection-reducer-CGKKsaPa.cjs +26 -0
  58. package/dist/chunks/{semantic-format-BhIL1PXP.cjs → semantic-format-BzH69TRq.cjs} +1 -1
  59. package/dist/chunks/{semantic-format-C3amkGmY.js → semantic-format-CBlRO8Aw.js} +1 -1
  60. package/dist/chunks/{switch-DHGiC0aU.js → switch-CD4uGTZI.js} +7450 -7694
  61. package/dist/chunks/switch-iC1x2dcE.cjs +134 -0
  62. package/dist/chunks/token-types-Ahh5u4iT.cjs +1 -0
  63. package/dist/chunks/token-types-CPde8_LG.js +8 -0
  64. package/dist/chunks/{update-policy-Cc9h57pA.cjs → update-policy-COjFudhl.cjs} +1 -1
  65. package/dist/chunks/{update-policy-eTcz52jO.js → update-policy-D9q1Tz8k.js} +1 -1
  66. package/dist/dashboard/index.cjs +1 -1
  67. package/dist/dashboard/index.js +1 -1
  68. package/dist/dashboard-authoring/index.cjs +3 -3
  69. package/dist/dashboard-authoring/index.js +734 -622
  70. package/dist/data-app-builder/index.cjs +1 -1
  71. package/dist/data-app-builder/index.js +3 -3
  72. package/dist/data-app-codegen/index.cjs +1 -1
  73. package/dist/data-app-codegen/index.js +2 -2
  74. package/dist/data-app-codegen-node/index.cjs +94 -92
  75. package/dist/data-app-codegen-node/index.js +337 -333
  76. package/dist/data-app-sdk/index.cjs +9 -9
  77. package/dist/data-app-sdk/index.js +1091 -969
  78. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  79. package/dist/data-app-sdk-adapters/index.js +104 -96
  80. package/dist/data-app-sdk-validation/index.cjs +1 -1
  81. package/dist/data-app-sdk-validation/index.js +2 -2
  82. package/dist/format-utils/index.cjs +1 -1
  83. package/dist/format-utils/index.js +8 -8
  84. package/dist/index.cjs +1 -1
  85. package/dist/index.js +15 -15
  86. package/dist/style.css +1 -1
  87. package/dist/surfboard/index.cjs +1 -1
  88. package/dist/surfboard/index.js +2 -2
  89. package/dist/types/brand-studio/brand-studio-draft.d.ts +3 -1
  90. package/dist/types/components/dashboard/card-selection-pill.d.ts +5 -0
  91. package/dist/types/components/dashboard/dashboard-container.d.ts +1 -1
  92. package/dist/types/components/dashboard/drill-breadcrumb.d.ts +1 -0
  93. package/dist/types/components/dashboard/drill-navigation-controls.d.ts +3 -3
  94. package/dist/types/components/interactions/applied-filters-display.d.ts +6 -1
  95. package/dist/types/components/interactions/click-to-filter-review-dialog.d.ts +21 -0
  96. package/dist/types/components/interactions/dashboard-drill-host.d.ts +13 -0
  97. package/dist/types/components/interactions/filter-badge-tooltip.d.ts +4 -4
  98. package/dist/types/components/interactions/insight-modal.d.ts +4 -14
  99. package/dist/types/components/interactions/insight-viewer.d.ts +7 -19
  100. package/dist/types/components/interactions/interactions-sheet.d.ts +6 -0
  101. package/dist/types/components/interactions/panels/click-to-filter-panel.d.ts +20 -0
  102. package/dist/types/components/interactions/reusable/interaction-selection-popover.d.ts +2 -2
  103. package/dist/types/components/interactions/sheet/action-editor.d.ts +17 -0
  104. package/dist/types/components/interactions/sheet/action-meta.d.ts +45 -0
  105. package/dist/types/components/interactions/sheet/action-picker.d.ts +7 -0
  106. package/dist/types/components/interactions/sheet/click-outcome-preview.d.ts +10 -0
  107. package/dist/types/components/interactions/sheet/interactions-home.d.ts +28 -0
  108. package/dist/types/components/interactions/sheet/sheet-parts.d.ts +37 -0
  109. package/dist/types/components/surfboard/filter/dashboard-filter-mapping-panel.d.ts +28 -1
  110. package/dist/types/components/surfboard/filter/selection-chip.d.ts +11 -0
  111. package/dist/types/components/surfboard/filter/selection-filter-section.d.ts +4 -0
  112. package/dist/types/components/surfboard/filter/use-dashboard-filter-mapping-popover.d.ts +3 -0
  113. package/dist/types/components/ui/resizable.d.ts +1 -1
  114. package/dist/types/components/visual/matrix-table/matrix-interaction-actions.d.ts +24 -3
  115. package/dist/types/components/visual/matrix-table/matrix-selection-click.d.ts +6 -0
  116. package/dist/types/components/visual/matrix-table/matrix-window-viewer.d.ts +1 -1
  117. package/dist/types/data-app-sdk/adapters.d.ts +3 -2
  118. package/dist/types/data-app-sdk/builders.d.ts +2 -1
  119. package/dist/types/data-app-sdk/contracts.d.ts +44 -2
  120. package/dist/types/data-app-sdk/index.d.ts +1 -0
  121. package/dist/types/data-app-sdk/query-request.d.ts +7 -2
  122. package/dist/types/data-app-sdk/selection.d.ts +2 -0
  123. package/dist/types/index.cjs +1 -1
  124. package/dist/types/index.js +24 -23
  125. package/dist/types/lib/appearance/types.d.ts +3 -1
  126. package/dist/types/lib/briefings/briefing-attachment-model.d.ts +0 -2
  127. package/dist/types/lib/contexts/interactions-popover-context.d.ts +1 -8
  128. package/dist/types/lib/dashboard/click-to-filter-card-references.d.ts +23 -0
  129. package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +16 -2
  130. package/dist/types/lib/dashboard-inputs/build-selection-dashboard-inputs.d.ts +31 -0
  131. package/dist/types/lib/dashboard-inputs/click-to-filter-emitted-fields.d.ts +17 -0
  132. package/dist/types/lib/dashboard-inputs/click-to-filter-mapping-draft.d.ts +99 -0
  133. package/dist/types/lib/dashboard-inputs/click-to-filter-sheet-reach.d.ts +12 -0
  134. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +18 -1
  135. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-candidate-metadata.d.ts +4 -1
  136. package/dist/types/lib/dashboard-inputs/dashboard-input-scope.d.ts +10 -0
  137. package/dist/types/lib/dashboard-inputs/dashboard-input-snapshot.d.ts +8 -1
  138. package/dist/types/lib/dashboard-inputs/index.d.ts +1 -0
  139. package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +18 -7
  140. package/dist/types/lib/dashboard-inputs/resolve-field-date-comparison-coverage.d.ts +5 -2
  141. package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +77 -0
  142. package/dist/types/lib/dashboard-inputs/selection-targets.d.ts +26 -0
  143. package/dist/types/lib/dashboard-inputs/transient-input-context.d.ts +102 -0
  144. package/dist/types/lib/dashboard-navigation/build-carried-click-context.d.ts +50 -0
  145. package/dist/types/lib/dashboard-navigation/describe-carried-context.d.ts +11 -0
  146. package/dist/types/lib/dashboard-navigation/index.d.ts +1 -0
  147. package/dist/types/lib/dashboard-navigation/navigation-state.d.ts +120 -0
  148. package/dist/types/lib/dashboard-navigation/run-one-off-drill.d.ts +11 -0
  149. package/dist/types/lib/dashboard-navigation/use-transient-contexts.d.ts +17 -0
  150. package/dist/types/lib/dashboard-view-state/card-view-state.d.ts +48 -0
  151. package/dist/types/lib/dashboard-view-state/drill-path.d.ts +20 -0
  152. package/dist/types/lib/dashboard-view-state/index.d.ts +2 -0
  153. package/dist/types/lib/download-pdf.d.ts +0 -3
  154. package/dist/types/lib/formatters/metric-formatting.d.ts +1 -1
  155. package/dist/types/lib/hooks/ai/dashboard-context.d.ts +15 -8
  156. package/dist/types/lib/hooks/chartjs/use-chart-blur.d.ts +10 -2
  157. package/dist/types/lib/hooks/interactions/{use-event-engine.d.ts → use-drill-actions.d.ts} +28 -7
  158. package/dist/types/lib/hooks/selection/use-active-selections.d.ts +15 -0
  159. package/dist/types/lib/hooks/selection/use-click-to-filter-mapping-draft.d.ts +20 -0
  160. package/dist/types/lib/hooks/selection/use-selection-click.d.ts +34 -0
  161. package/dist/types/lib/hooks/selection/use-selection-gestures.d.ts +38 -0
  162. package/dist/types/lib/hooks/selection/use-table-row-selection.d.ts +46 -0
  163. package/dist/types/lib/hooks/use-dashboard-card.d.ts +0 -2
  164. package/dist/types/lib/hooks/use-dashboard-filter-mapping-candidates.d.ts +18 -0
  165. package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +0 -1
  166. package/dist/types/lib/hooks/use-dashboard.d.ts +1 -3
  167. package/dist/types/lib/hooks/use-interactions-popover.d.ts +1 -8
  168. package/dist/types/lib/hooks/use-resolved-card-config.d.ts +6 -0
  169. package/dist/types/lib/interactions/click-outcome.d.ts +25 -0
  170. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +3 -1
  171. package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +1 -1
  172. package/dist/types/lib/interactions/get-click-context-from-table.d.ts +7 -0
  173. package/dist/types/lib/interactions/interaction-utils.d.ts +17 -1
  174. package/dist/types/lib/matrix-table/build-matrix-drill-to-detail.d.ts +15 -0
  175. package/dist/types/lib/matrix-table/matrix-card-interactions.d.ts +14 -3
  176. package/dist/types/lib/matrix-table/matrix-runtime-types.d.ts +0 -3
  177. package/dist/types/lib/matrix-table/matrix-runtime.d.ts +0 -4
  178. package/dist/types/lib/matrix-table/{use-matrix-selection.d.ts → use-matrix-cell-focus.d.ts} +13 -17
  179. package/dist/types/lib/matrix-table/use-matrix.d.ts +0 -1
  180. package/dist/types/lib/query-context/build-card-query-context.d.ts +19 -8
  181. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +5 -3
  182. package/dist/types/lib/query-context/build-dashboard-frame-base-query-contexts.d.ts +12 -4
  183. package/dist/types/lib/query-context/compile-selection-filters.d.ts +5 -0
  184. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +46 -0
  185. package/dist/types/lib/query-context/filter-group-utils.d.ts +3 -0
  186. package/dist/types/lib/query-context/resolve-runtime-card-filters.d.ts +29 -0
  187. package/dist/types/lib/selection/click-to-filter-authoring-support.d.ts +9 -0
  188. package/dist/types/lib/selection/selection-from-click-context.d.ts +41 -0
  189. package/dist/types/lib/selection/selection-labels.d.ts +3 -0
  190. package/dist/types/lib/selection/selection-notices.d.ts +9 -0
  191. package/dist/types/lib/selection/selection-reducer.d.ts +46 -0
  192. package/dist/types/lib/stores/dashboard-store.d.ts +62 -17
  193. package/dist/types/lib/stores/editor-store.d.ts +1 -2
  194. package/dist/types/lib/stores/index.d.ts +0 -2
  195. package/dist/types/lib/types/common-types.d.ts +60 -6
  196. package/dist/types/lib/types/explorer-types.d.ts +1 -22
  197. package/dist/types/lib/types/interaction-types.d.ts +6 -198
  198. package/dist/types/lib/utils/calculate-context-aware-filters.d.ts +21 -12
  199. package/dist/types/lib/utils/card-utils.d.ts +11 -0
  200. package/dist/types/lib/utils/date-hierarchy-utils.d.ts +3 -1
  201. package/dist/types/lib/utils/drag-and-drop-utils.d.ts +1 -1
  202. package/dist/types/lib/utils/interaction-icons.d.ts +1 -1
  203. package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +32 -32
  204. package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
  205. package/dist/types/shared/analytics-protocol/selection-contract.d.ts +100 -0
  206. package/dist/types/shared/analytics-protocol/selection-filter-compiler.d.ts +12 -0
  207. package/dist/types/shared/dashboard-authoring/apply-group-by-override.d.ts +19 -0
  208. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +88 -0
  209. package/dist/types/shared/dashboard-authoring/contracts.d.ts +8 -0
  210. package/dist/types/shared/dashboard-authoring/index.d.ts +3 -0
  211. package/dist/types/shared/dashboard-authoring/linked-click-to-filter-overrides.d.ts +32 -0
  212. package/dist/types/shared/format-utils/matrix-continuation.d.ts +3 -3
  213. package/package.json +1 -1
  214. package/src/data-app-sdk/README.md +58 -1
  215. package/dist/chunks/appearance-context-tNjvTJj3.cjs +0 -1
  216. package/dist/chunks/calculated-field-identity-BTpUqfEu.js +0 -1276
  217. package/dist/chunks/calculated-field-identity-rMuXuzEY.cjs +0 -1
  218. package/dist/chunks/constants-vtu7_IUo.cjs +0 -1
  219. package/dist/chunks/dashboard-controls-DlxeddZN.cjs +0 -52
  220. package/dist/chunks/dashboard-json-DhS4yJfc.cjs +0 -1
  221. package/dist/chunks/edit-dashboard-visual-X3OCnivL.cjs +0 -172
  222. package/dist/chunks/field-aggregations-BU_3gHKR.js +0 -957
  223. package/dist/chunks/field-aggregations-CDCamEsQ.cjs +0 -1
  224. package/dist/chunks/index-C8XCKzB6.cjs +0 -1
  225. package/dist/chunks/index-DSa6RSdg.cjs +0 -1417
  226. package/dist/chunks/matrix-control-sources-CeC5EMyq.cjs +0 -1
  227. package/dist/chunks/matrix-member-presentation-E2B4k3ws.cjs +0 -1
  228. package/dist/chunks/matrix-member-presentation-qiHxv67e.js +0 -105
  229. package/dist/chunks/matrix-operation-contract-Cqy4EW2H.js +0 -1638
  230. package/dist/chunks/matrix-operation-contract-D9dLX-Wr.cjs +0 -1
  231. package/dist/chunks/report-preferences-dialog-7Vsc_fsG.cjs +0 -1
  232. package/dist/chunks/search-BqqhaMx9.cjs +0 -26
  233. package/dist/chunks/switch-BytP6QY8.cjs +0 -139
  234. package/dist/types/components/interactions/configuration-popover.d.ts +0 -1
  235. package/dist/types/components/interactions/interaction-card.d.ts +0 -59
  236. package/dist/types/components/interactions/interaction-event-handler.d.ts +0 -11
  237. package/dist/types/components/interactions/interactions-list.d.ts +0 -50
  238. package/dist/types/components/interactions/panels/cross-filter-panel.d.ts +0 -24
  239. package/dist/types/components/interactions/panels/inline-drill-panel.d.ts +0 -24
  240. package/dist/types/components/interactions/selectors/action-selector.d.ts +0 -31
  241. package/dist/types/components/interactions/selectors/trigger-selector.d.ts +0 -38
  242. package/dist/types/components/surfboard/filter/click-filter-section.d.ts +0 -5
  243. package/dist/types/lib/interactions/build-interaction-event.d.ts +0 -25
  244. package/dist/types/lib/interactions/convert-click-filters-to-filter-group.d.ts +0 -10
  245. package/dist/types/lib/interactions/execute-interaction-event.d.ts +0 -80
  246. package/dist/types/lib/interactions/field-utils.d.ts +0 -11
  247. package/dist/types/lib/interactions/handle-chart-click.d.ts +0 -75
  248. package/dist/types/lib/interactions/linked-interaction-utils.d.ts +0 -14
  249. package/dist/types/lib/interactions/source-card-filter-utils.d.ts +0 -9
  250. package/dist/types/lib/matrix-table/matrix-clipboard.d.ts +0 -45
  251. package/dist/types/lib/matrix-table/matrix-selection.d.ts +0 -20
  252. package/dist/types/lib/stores/drill-actions.d.ts +0 -139
  253. package/dist/types/lib/stores/interaction-store.d.ts +0 -113
  254. package/dist/types/lib/stores/pointer-interaction-store.d.ts +0 -18
@@ -1,1638 +0,0 @@
1
- import { z as r } from "zod";
2
- import { K as g, E as W, U as N, ba as V, S as v, M as be, b2 as J, bb as ve, aL as $e, F as Se, m as we, l as ke, b0 as Ie, aQ as Ae, aR as _e, aU as Re, aV as qe, aE as C, aJ as D, ax as Ce, aO as je, aP as X, av as Ee, at as m, au as xe, aK as Fe } from "./validators-BDYzZFgs.js";
3
- const T = {
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
- }, Qs = Object.freeze({ coordinates: 2e4 }), k = r.string().uuid(), p = r.string().min(1), Ke = r.number().int().positive().max(Number.MAX_SAFE_INTEGER);
44
- function c(i, s, e) {
45
- i.addIssue({ code: "custom", path: s, message: e });
46
- }
47
- function y(i, s, e) {
48
- new Set(i).size !== i.length && c(s, e, "Duplicate identity.");
49
- }
50
- const Ne = r.object({
51
- id: p,
52
- axis: W,
53
- parent: g,
54
- position: r.union([
55
- r.object({ kind: r.literal("first") }).strict(),
56
- r.object({ kind: r.enum(["after", "before"]), cursor: p }).strict()
57
- ]),
58
- size: Ke
59
- }).strict(), U = r.object({
60
- paths: r.array(g).readonly(),
61
- pageIds: r.array(p).readonly()
62
- }).strict(), Oe = r.object({
63
- id: p,
64
- rows: U,
65
- columns: U,
66
- measureIds: r.array(k).min(1).readonly()
67
- }).strict(), Z = r.object({
68
- pages: r.array(Ne).readonly(),
69
- blocks: r.array(Oe).readonly()
70
- }).strict().superRefine((i, s) => {
71
- !i.pages.length && !i.blocks.length && c(s, [], "Request at least one page or block."), y(
72
- [...i.pages, ...i.blocks].map((e) => e.id),
73
- s,
74
- []
75
- );
76
- for (const e of i.blocks) {
77
- y(e.measureIds, s, ["blocks", e.id, "measureIds"]);
78
- for (const t of ["rows", "columns"])
79
- for (const n of e[t].pageIds)
80
- i.pages.some(
81
- (o) => o.id === n && o.axis === t
82
- ) || c(
83
- s,
84
- ["blocks", e.id, t],
85
- "Page reference must name a page on this axis in this operation."
86
- );
87
- }
88
- }), Hs = r.object({ spec: N, request: Z }).strict().superRefine(({ spec: i, request: s }, e) => {
89
- for (const t of s.pages)
90
- V(
91
- i,
92
- t.axis,
93
- t.parent,
94
- e,
95
- ["pages", t.id],
96
- !0
97
- ), t.parent.length >= i[t.axis].length && c(
98
- e,
99
- ["pages", t.id],
100
- "Cannot request children of a leaf or empty axis."
101
- );
102
- for (const t of s.blocks) {
103
- t.measureIds.some((n) => !i.measures.some((o) => o.id === n)) && c(e, ["blocks", t.id], "Unknown block measure.");
104
- for (const n of ["rows", "columns"])
105
- for (const o of t[n].paths)
106
- V(i, n, o, e, ["blocks", t.id, n]);
107
- }
108
- }), Be = r.object({
109
- requestId: p,
110
- axis: W,
111
- parent: g,
112
- members: r.array(r.object({ path: g }).strict()).readonly(),
113
- before: p.nullable(),
114
- after: p.nullable(),
115
- exactCount: r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()
116
- }).strict().superRefine((i, s) => {
117
- i.parent.some((t) => t.member.kind === "others") && c(s, ["parent"], "Others has no children.");
118
- const e = i.members.filter(
119
- ({ path: t }) => {
120
- var n;
121
- return ((n = t[t.length - 1]) == null ? void 0 : n.member.kind) === "others";
122
- }
123
- );
124
- e.length > 1 && c(s, ["members"], "A page may contain Others only once."), e.length && (i.members[i.members.length - 1] !== e[0] && c(s, ["members"], "Others must be the last page member."), i.after !== null && c(s, ["after"], "Others must end the branch.")), new Set(
125
- i.members.map(
126
- (t) => {
127
- var n;
128
- return (n = t.path[t.path.length - 1]) == null ? void 0 : n.levelId;
129
- }
130
- )
131
- ).size > 1 && c(s, ["members"], "One page must contain one child level."), y(
132
- i.members.map((t) => v(t.path)),
133
- s,
134
- ["members"]
135
- );
136
- for (const t of i.members)
137
- (t.path.length !== i.parent.length + 1 || v(t.path.slice(0, -1)) !== v(i.parent)) && c(s, ["members"], "Page members must be immediate children.");
138
- }), De = r.object({
139
- requestId: p,
140
- coverage: r.object({
141
- rowPaths: r.array(g).readonly(),
142
- columnPaths: r.array(g).readonly(),
143
- measureIds: r.array(k).readonly()
144
- }).strict(),
145
- cells: r.array(
146
- be.extend({ value: J }).strict()
147
- ).readonly()
148
- }).strict().superRefine((i, s) => {
149
- const e = i.coverage.rowPaths.map(v), t = i.coverage.columnPaths.map(v);
150
- y(e, s, ["coverage", "rowPaths"]), y(t, s, ["coverage", "columnPaths"]), y(i.coverage.measureIds, s, ["coverage", "measureIds"]);
151
- const n = new Set(e), o = new Set(t), d = new Set(i.coverage.measureIds);
152
- y(
153
- i.cells.map(
154
- (u) => JSON.stringify([
155
- v(u.rowPath),
156
- v(u.columnPath),
157
- u.measureId
158
- ])
159
- ),
160
- s,
161
- ["cells"]
162
- );
163
- for (const u of i.cells)
164
- (!n.has(v(u.rowPath)) || !o.has(v(u.columnPath)) || !d.has(u.measureId)) && c(s, ["cells"], "Cell is outside certified coverage.");
165
- }), z = r.object({
166
- id: k,
167
- column: $e,
168
- nativeDataType: p,
169
- semanticFormat: ve.optional()
170
- }).strict(), ee = r.object({
171
- levels: r.array(z).readonly(),
172
- measures: r.array(z).readonly()
173
- }).strict(), M = r.object({
174
- code: r.enum([
175
- "invalid_request",
176
- "unsupported_capability",
177
- "stale_cursor",
178
- "forbidden",
179
- "budget_exceeded",
180
- "source_truncated",
181
- "execution_failed",
182
- "cancelled"
183
- ]),
184
- message: p,
185
- /** Technical cause for dashboard owners; never shown as the primary copy. */
186
- detail: p.optional(),
187
- retryable: r.boolean(),
188
- scope: r.union([
189
- r.object({ kind: r.literal("operation") }).strict(),
190
- r.object({ kind: r.enum(["page", "block"]), requestId: p }).strict()
191
- ])
192
- }).strict(), Te = r.object({
193
- dialect: r.enum(["postgres", "clickhouse", "duckdb"]),
194
- aggregates: r.array(Se).readonly()
195
- }).strict(), se = r.object({
196
- queryIdentity: p,
197
- descriptors: ee,
198
- capabilities: Te,
199
- pages: r.array(Be).readonly(),
200
- blocks: r.array(De).readonly(),
201
- failures: r.array(M).readonly()
202
- }).strict().superRefine((i, s) => {
203
- const e = new Set(
204
- i.descriptors.levels.map((o) => o.id)
205
- ), t = new Set(
206
- i.descriptors.measures.map((o) => o.id)
207
- ), n = i.pages.flatMap((o) => [
208
- o.parent,
209
- ...o.members.map((d) => d.path)
210
- ]);
211
- for (const o of i.blocks)
212
- n.push(...o.coverage.rowPaths, ...o.coverage.columnPaths), o.coverage.measureIds.some((d) => !t.has(d)) && c(
213
- s,
214
- ["blocks", o.requestId],
215
- "Coverage references an unknown measure descriptor."
216
- );
217
- n.some((o) => o.some((d) => !e.has(d.levelId))) && c(s, ["descriptors"], "Acquired paths require level descriptors."), y(
218
- [...i.descriptors.levels, ...i.descriptors.measures].map(
219
- (o) => o.id
220
- ),
221
- s,
222
- ["descriptors"]
223
- ), y(
224
- [...i.pages, ...i.blocks].map((o) => o.requestId),
225
- s,
226
- []
227
- ), y(
228
- i.failures.map(
229
- (o) => o.scope.kind === "operation" ? "operation" : o.scope.requestId
230
- ),
231
- s,
232
- ["failures"]
233
- );
234
- for (const o of i.failures)
235
- if (o.scope.kind === "operation")
236
- c(
237
- s,
238
- ["failures"],
239
- "Operation failure cannot accompany acquired data."
240
- );
241
- else {
242
- const d = o.scope.requestId;
243
- [...i.pages, ...i.blocks].some(
244
- (u) => u.requestId === d
245
- ) && c(
246
- s,
247
- ["failures"],
248
- "A requested unit cannot both succeed and fail."
249
- );
250
- }
251
- }), Ys = r.union([
252
- r.object({
253
- status: r.enum(["success", "partial"]),
254
- window: se
255
- }).strict(),
256
- r.object({ status: r.literal("failed"), failure: M }).strict()
257
- ]).superRefine((i, s) => {
258
- if (i.status === "failed") return;
259
- const { window: e } = i;
260
- !e.pages.length && !e.blocks.length && c(
261
- s,
262
- ["window"],
263
- "A window outcome requires successful acquired work."
264
- ), i.status === "success" != (e.failures.length === 0) && c(s, ["status"], "Status must match failure coverage.");
265
- }), te = r.object({
266
- kind: r.literal("matrix"),
267
- window: se
268
- }).strict(), ie = r.enum(["member", "subtotal", "grand_total"]), Me = r.discriminatedUnion("kind", [
269
- r.object({ kind: r.literal("hierarchy"), label: r.string() }).strict(),
270
- r.object({ kind: r.literal("level"), levelId: k, label: r.string() }).strict(),
271
- r.object({
272
- kind: r.literal("measure"),
273
- measureId: k,
274
- columnPath: g,
275
- role: ie,
276
- label: r.string()
277
- }).strict()
278
- ]), Pe = r.object({
279
- columns: r.array(Me).readonly(),
280
- descriptors: ee
281
- }).strict(), G = r.union([
282
- r.object({
283
- kind: r.literal("value"),
284
- value: J.refine(
285
- (i) => i !== null
286
- )
287
- }).strict(),
288
- r.object({ kind: r.enum(["null", "empty"]) }).strict()
289
- ]), Ve = r.discriminatedUnion("kind", [
290
- r.object({
291
- kind: r.literal("layout"),
292
- rowPath: g,
293
- role: ie,
294
- values: r.array(G).readonly()
295
- }).strict(),
296
- r.object({
297
- kind: r.literal("flat"),
298
- rowPath: g,
299
- columnPath: g,
300
- values: r.array(G).readonly()
301
- }).strict()
302
- ]), Ws = r.discriminatedUnion("kind", [
303
- r.object({
304
- kind: r.literal("layout"),
305
- layout: Pe,
306
- next: p
307
- }).strict(),
308
- r.object({
309
- kind: r.literal("rows"),
310
- rows: r.array(Ve).readonly(),
311
- next: p.nullable()
312
- }).strict()
313
- ]), re = r.object({
314
- intent: we,
315
- matrixWindowRequest: Z
316
- }).strict(), O = "semaphor-data-app-codegen-summary/v1", Js = "semaphor-data-app-codegen-summary-validator/v2", Ue = /* @__PURE__ */ new Set([
317
- "metric",
318
- "records",
319
- "matrix",
320
- "analysis",
321
- "sql_fallback"
322
- ]), ze = /* @__PURE__ */ new Set([
323
- "semaphor.metric",
324
- "semaphor.records",
325
- "semaphor.matrix",
326
- "semaphor.analysis",
327
- "semaphor.sql"
328
- ]), Ge = /* @__PURE__ */ new Set([
329
- "SUM",
330
- "COUNT",
331
- "AVG",
332
- "MIN",
333
- "MAX",
334
- "MEDIAN",
335
- "DISTINCT"
336
- ]), Le = /* @__PURE__ */ new Set([
337
- "absolute_delta",
338
- "largest_negative",
339
- "largest_positive",
340
- "positive_and_negative",
341
- "all"
342
- ]), ne = /* @__PURE__ */ new Set([
343
- "source",
344
- "id",
345
- "label",
346
- "measures",
347
- "primaryMeasure",
348
- "dateField",
349
- "timeGrain",
350
- "dimensions",
351
- "comparison",
352
- "orderBy",
353
- "filters",
354
- "relationshipHint",
355
- "limit",
356
- "derivedFields"
357
- ]), Qe = /* @__PURE__ */ new Set([
358
- ...ne,
359
- "analysis",
360
- "timeWindow",
361
- "filters",
362
- "driverMode",
363
- "includePopulation",
364
- "calendarContext",
365
- "chartTitle",
366
- "chartType"
367
- ]), He = /* @__PURE__ */ new Set([
368
- "source",
369
- "id",
370
- "label",
371
- "fields",
372
- "dateField",
373
- "timeGrain",
374
- "timeWindow",
375
- "filters",
376
- "orderBy",
377
- "relationshipHint",
378
- "limit",
379
- "pagination",
380
- "totals",
381
- "derivedFields"
382
- ]), Ye = /* @__PURE__ */ new Set([
383
- "source",
384
- "id",
385
- "label",
386
- "sql",
387
- "defaultParameters",
388
- "pythonCode",
389
- "fields",
390
- "limit",
391
- "pagination",
392
- "rationale"
393
- ]), We = /* @__PURE__ */ new Set([
394
- "kpi",
395
- "line_chart",
396
- "bar_chart",
397
- "stacked_bar_chart",
398
- "pie_chart",
399
- "donut_chart",
400
- "area_chart",
401
- "table",
402
- "matrix",
403
- "narrative",
404
- "text_block",
405
- "custom"
406
- ]), Je = /* @__PURE__ */ new Set([
407
- "missing_measure",
408
- "missing_dimension",
409
- "missing_date",
410
- "missing_relationship",
411
- "missing_semantic_role",
412
- "missing_current_app_state",
413
- "raw_identifier_filter_options",
414
- "unsupported_change_intent",
415
- "ambiguous_field_grounding",
416
- "bounded_intent_unavailable",
417
- "invalid_bounded_intent_output",
418
- "latest_snapshot_selector_not_modeled",
419
- "unsupported_grain",
420
- "requires_sql_escape_hatch",
421
- "unsupported_sdk_capability"
422
- ]);
423
- function Xs(i) {
424
- return oe(i).ok;
425
- }
426
- function oe(i) {
427
- const s = [];
428
- if (!i || typeof i != "object")
429
- return { ok: !1, issues: ["Summary must be an object."] };
430
- const e = i;
431
- return e.schemaVersion !== O && s.push(
432
- `schemaVersion must be ${O}.`
433
- ), (typeof e.title != "string" || !e.title.trim()) && s.push("title is required."), Array.isArray(e.sources) || s.push("sources must be an array."), Array.isArray(e.inputs) || s.push("inputs must be an array."), Array.isArray(e.views) || s.push("views must be an array."), Array.isArray(e.filterContracts) || s.push("filterContracts must be an array."), (!e.implementationChecklist || typeof e.implementationChecklist != "object") && s.push("implementationChecklist must be an object."), e.implementationChecklist && typeof e.implementationChecklist == "object" && s.push(
434
- ...Ze(e.implementationChecklist)
435
- ), Array.isArray(e.sources) && e.sources.forEach((t, n) => {
436
- s.push(...R(t, `sources.${n}`));
437
- }), Array.isArray(e.inputs) && e.inputs.forEach((t, n) => {
438
- s.push(...es(t, `inputs.${n}`));
439
- }), Array.isArray(e.views) && e.views.forEach((t, n) => {
440
- s.push(...ss(t, `views.${n}`));
441
- }), Array.isArray(e.filterContracts) && e.filterContracts.forEach((t, n) => {
442
- s.push(
443
- ...cs(t, `filterContracts.${n}`)
444
- );
445
- }), e.unsupportedInsights !== void 0 && (Array.isArray(e.unsupportedInsights) ? e.unsupportedInsights.forEach((t, n) => {
446
- s.push(
447
- ..._s(
448
- t,
449
- `unsupportedInsights.${n}`
450
- )
451
- );
452
- }) : s.push("unsupportedInsights must be an array.")), s.push(...Xe(e)), { ok: s.length === 0, issues: s };
453
- }
454
- function Xe(i) {
455
- const s = Array.isArray(i.unsupportedInsights) && i.unsupportedInsights.some(
456
- (d) => {
457
- var u;
458
- return L.has((u = a(d)) == null ? void 0 : u.reason);
459
- }
460
- ), e = Array.isArray(i.views) && i.views.some((d) => {
461
- var l;
462
- const u = a((l = a(d)) == null ? void 0 : l.computation);
463
- return (u == null ? void 0 : u.kind) === "unsupported" && L.has(u.reason);
464
- });
465
- if (!s && !e)
466
- return [];
467
- const t = [], n = a(i.validation);
468
- (n == null ? void 0 : n.status) !== "blocked" && t.push(
469
- "validation.status must be blocked when semantic model repair gaps are present."
470
- );
471
- const o = a(i.nextRequiredTool);
472
- return (o == null ? void 0 : o.name) !== "semaphor_propose_semantic_model_change" && t.push(
473
- "nextRequiredTool.name must be semaphor_propose_semantic_model_change when semantic model repair gaps are present."
474
- ), t;
475
- }
476
- const L = /* @__PURE__ */ new Set([
477
- "missing_relationship",
478
- "raw_identifier_filter_options"
479
- ]);
480
- function R(i, s) {
481
- const e = a(i);
482
- return e ? e.kind === "semantic" ? typeof e.domainId == "string" && e.domainId.trim() && typeof e.datasetName == "string" && e.datasetName.trim() ? [] : [`${s} must include sourceKey or a supported source identity.`] : typeof e.sourceKey == "string" && e.sourceKey.trim() ? [] : e.kind === "physical" && typeof e.tableName == "string" && e.tableName.trim() && typeof e.connectionId == "string" && e.connectionId.trim() ? [] : e.kind === "sql" && typeof e.connectionId == "string" && e.connectionId.trim() ? [] : [`${s} must include sourceKey or a supported source identity.`] : [`${s} must be an object.`];
483
- }
484
- function Ze(i) {
485
- const s = a(i);
486
- if (!s)
487
- return ["implementationChecklist must be an object."];
488
- const e = [], t = [
489
- "requiredDevtools",
490
- "requiredInputOptions",
491
- "filterScopeByInput",
492
- "bindingsByView",
493
- "validationCommands",
494
- "browserSmokeChecks"
495
- ];
496
- for (const o of t)
497
- o in s || e.push(`implementationChecklist.${o} is required.`);
498
- const n = a(s.requiredDevtools);
499
- return n ? typeof n.mountRootDevtools != "boolean" && e.push(
500
- "implementationChecklist.requiredDevtools.mountRootDevtools must be a boolean."
501
- ) : e.push("implementationChecklist.requiredDevtools must be an object."), Array.isArray(s.requiredInputOptions) || e.push(
502
- "implementationChecklist.requiredInputOptions must be an array."
503
- ), Array.isArray(s.filterScopeByInput) || e.push("implementationChecklist.filterScopeByInput must be an array."), a(s.bindingsByView) || e.push("implementationChecklist.bindingsByView must be an object."), h(s.validationCommands) || e.push(
504
- "implementationChecklist.validationCommands must be an array of strings."
505
- ), h(s.browserSmokeChecks) || e.push(
506
- "implementationChecklist.browserSmokeChecks must be an array of strings."
507
- ), e;
508
- }
509
- function es(i, s) {
510
- const e = a(i);
511
- if (!e)
512
- return [`${s} must be an object.`];
513
- const t = [];
514
- return (typeof e.id != "string" || !e.id.trim()) && t.push(`${s}.id is required.`), e.fieldRef && t.push(...f(e.fieldRef, `${s}.fieldRef`)), t.push(...ue(e.optionQuery, `${s}.optionQuery`)), h(e.appliesToViewIds) || t.push(`${s}.appliesToViewIds must be an array of strings.`), e.bindings !== void 0 && !Array.isArray(e.bindings) && t.push(`${s}.bindings must be an array.`), Array.isArray(e.bindings) && e.bindings.forEach((n, o) => {
515
- const d = a(n);
516
- if (!d) {
517
- t.push(`${s}.bindings.${o} must be an object.`);
518
- return;
519
- }
520
- h(d.appliesToViewIds) || t.push(
521
- `${s}.bindings.${o}.appliesToViewIds must be an array of strings.`
522
- ), t.push(
523
- ...f(
524
- d.fieldRef,
525
- `${s}.bindings.${o}.fieldRef`
526
- )
527
- );
528
- }), t;
529
- }
530
- function ss(i, s) {
531
- const e = a(i);
532
- if (!e)
533
- return [`${s} must be an object.`];
534
- const t = [];
535
- if ((typeof e.id != "string" || !e.id.trim()) && t.push(`${s}.id is required.`), e.visualSpec !== void 0 && t.push(...vs(e.visualSpec, `${s}.visualSpec`)), e.computation !== void 0 && t.push(
536
- ...As(e.computation, `${s}.computation`)
537
- ), bs(e))
538
- return t.push(...j(e, `${s}`)), e.fields !== void 0 && (Array.isArray(e.fields) ? e.fields.forEach((l, b) => {
539
- t.push(
540
- ...f(l, `${s}.fields.${b}`)
541
- );
542
- }) : t.push(`${s}.fields must be an array.`)), e.queryKind !== void 0 && t.push(`${s}.queryKind is not allowed for non-executable views.`), e.sdkBuilder !== void 0 && t.push(
543
- `${s}.sdkBuilder is not allowed for non-executable views.`
544
- ), e.sdkSpec !== void 0 && t.push(`${s}.sdkSpec is not allowed for non-executable views.`), t;
545
- if (!Array.isArray(e.fields))
546
- return t.push(`${s}.fields must be an array.`), (e.sdkSpec !== void 0 || e.sdkBuilder !== void 0) && t.push(`${s}.fields must be an array for executable views.`), t.push(...j(e, `${s}`)), t;
547
- e.fields.forEach((l, b) => {
548
- t.push(...f(l, `${s}.fields.${b}`));
549
- }), w(e.queryKind) || t.push(`${s}.queryKind must be a supported codegen query kind.`), e.sdkBuilder !== void 0 && !le(e.sdkBuilder) && t.push(`${s}.sdkBuilder must be a supported SDK builder.`), e.metricBindingKeys !== void 0 && (Array.isArray(e.metricBindingKeys) ? e.metricBindingKeys.some(
550
- (l) => typeof l != "string" || l.trim().length === 0
551
- ) && t.push(`${s}.metricBindingKeys must be an array of strings.`) : t.push(`${s}.metricBindingKeys must be an array of strings.`));
552
- const n = a(e.sdkSpec), o = (n == null ? void 0 : n.builder) === "semaphor.metric";
553
- o && (!Array.isArray(e.metricBindingKeys) || e.metricBindingKeys.length === 0) && t.push(`${s}.metricBindingKeys is required for metric views.`);
554
- const d = ts(e);
555
- o && Array.isArray(e.metricBindingKeys) && d && JSON.stringify(e.metricBindingKeys) !== JSON.stringify(d) && t.push(
556
- `${s}.metricBindingKeys must match the generated metric field binding keys in order.`
557
- );
558
- const u = a(e.computation);
559
- return (u == null ? void 0 : u.kind) === "server_query" && w(e.queryKind) && w(u.queryKind) && u.queryKind !== e.queryKind && t.push(`${s}.computation.queryKind must match queryKind.`), t.push(
560
- ...ps({
561
- value: e.sdkSpec,
562
- path: `${s}.sdkSpec`,
563
- queryKind: typeof e.queryKind == "string" ? e.queryKind : void 0,
564
- sdkBuilder: typeof e.sdkBuilder == "string" ? e.sdkBuilder : void 0
565
- }),
566
- ...j(e, `${s}`)
567
- ), t;
568
- }
569
- function ts(i) {
570
- const s = a(i.sdkSpec);
571
- if ((s == null ? void 0 : s.builder) !== "semaphor.metric")
572
- return;
573
- const e = a(s.spec);
574
- if (!e)
575
- return;
576
- const n = [
577
- e.primaryMeasure,
578
- ...Array.isArray(e.measures) ? e.measures : []
579
- ].map(is).filter(
580
- (o) => !!o
581
- );
582
- return Array.from(
583
- new Map(n.map((o) => [o.identity, o.bindingKey])).values()
584
- );
585
- }
586
- function is(i) {
587
- const s = a(i);
588
- if (!s || typeof s.name != "string" || !s.name.trim())
589
- return;
590
- const e = rs(s);
591
- return e ? {
592
- identity: JSON.stringify({
593
- source: e,
594
- name: s.name,
595
- aggregate: ae(s)
596
- }),
597
- bindingKey: ns(s)
598
- } : void 0;
599
- }
600
- function rs(i) {
601
- if (typeof i.sourceKey == "string" && i.sourceKey.trim())
602
- return { sourceKey: i.sourceKey };
603
- const s = a(i.source);
604
- if (s)
605
- return {
606
- kind: s.kind,
607
- domainId: s.domainId,
608
- datasetId: s.datasetId,
609
- datasetName: s.datasetName,
610
- name: s.name
611
- };
612
- }
613
- function ns(i) {
614
- return typeof i.sourceKey == "string" && i.sourceKey.trim() ? [i.sourceKey, ae(i), i.name].filter(Boolean).join(":") : Ie(i);
615
- }
616
- function ae(i) {
617
- return ke(i);
618
- }
619
- function j(i, s) {
620
- var b;
621
- const e = a((b = a(i.visualSpec)) == null ? void 0 : b.tableBehavior), t = a(i.sdkSpec), n = a(t == null ? void 0 : t.spec), o = typeof (t == null ? void 0 : t.builder) == "string" ? t.builder : void 0, d = o === "semaphor.records" ? a(n == null ? void 0 : n.totals) : void 0, u = [];
622
- if (!e)
623
- return d && u.push(
624
- `${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`
625
- ), u;
626
- const l = a(e.totals);
627
- return l ? (l.mode === "server" && (o !== "semaphor.records" && u.push(
628
- `${s}.visualSpec.tableBehavior.totals.mode server is only supported for semaphor.records views.`
629
- ), !d || d.mode !== "server" ? u.push(
630
- `${s}.sdkSpec.spec.totals.mode must be server when tableBehavior.totals.mode is server.`
631
- ) : u.push(
632
- ...os({
633
- left: l.measures,
634
- right: d.measures,
635
- leftPath: `${s}.visualSpec.tableBehavior.totals.measures`,
636
- rightPath: `${s}.sdkSpec.spec.totals.measures`
637
- })
638
- )), l.mode !== "server" && d && u.push(
639
- `${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`
640
- ), o === "semaphor.sql" && l.mode !== "none" && u.push(
641
- `${s}.visualSpec.tableBehavior.totals.mode must be none for semaphor.sql views.`
642
- ), o === "semaphor.sql" && a(n == null ? void 0 : n.totals) && u.push(
643
- `${s}.sdkSpec.spec.totals is not supported for semaphor.sql.`
644
- ), u) : (d && u.push(
645
- `${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`
646
- ), u);
647
- }
648
- function os({
649
- left: i,
650
- right: s,
651
- leftPath: e,
652
- rightPath: t
653
- }) {
654
- if (!Array.isArray(i) || !Array.isArray(s))
655
- return [`${t} must match ${e}.`];
656
- const n = [];
657
- return i.length !== s.length ? (n.push(`${t} must match ${e}.`), n) : (i.forEach((o, d) => {
658
- as(a(o), a(s[d])) || n.push(`${t}.${d} must match ${e}.${d}.`);
659
- }), n);
660
- }
661
- function as(i, s) {
662
- return !i || !s ? !1 : i.name === s.name && (i.role || "measure") === (s.role || "measure") && Q(i) === Q(s) && us(i, s);
663
- }
664
- function Q(i) {
665
- return typeof i.aggregate == "string" ? i.aggregate.toUpperCase() : "SUM";
666
- }
667
- function us(i, s) {
668
- const e = a(i.source), t = a(s.source);
669
- if (ds(e, t))
670
- return !1;
671
- const n = H(i), o = H(s);
672
- if (n.size > 0 || o.size > 0) {
673
- for (const d of n)
674
- if (o.has(d))
675
- return !0;
676
- return !1;
677
- }
678
- return !e || !t || e.kind !== t.kind ? !1 : e.kind === "semantic" ? e.domainId === t.domainId && e.datasetName === t.datasetName && (e.datasetId === void 0 || t.datasetId === void 0 || e.datasetId === t.datasetId) : e.kind === "physical" ? e.connectionId === t.connectionId && e.tableName === t.tableName : e.kind === "sql" ? e.connectionId === t.connectionId : !1;
679
- }
680
- function ds(i, s) {
681
- if (!i || !s || i.kind !== "semantic" || s.kind !== "semantic")
682
- return !1;
683
- const e = typeof i.datasetId == "string" ? i.datasetId.trim() : "", t = typeof s.datasetId == "string" ? s.datasetId.trim() : "";
684
- return !!(e && t && e !== t);
685
- }
686
- function H(i) {
687
- const s = typeof i.sourceKey == "string" ? i.sourceKey.trim() : "";
688
- return s ? /* @__PURE__ */ new Set([s]) : ls(a(i.source));
689
- }
690
- function ls(i) {
691
- const s = /* @__PURE__ */ new Set();
692
- if (!i)
693
- return s;
694
- const e = typeof i.sourceKey == "string" ? i.sourceKey.trim() : "";
695
- if (e && s.add(e), i.kind === "semantic") {
696
- const t = typeof i.domainId == "string" ? i.domainId : "", n = typeof i.datasetName == "string" ? i.datasetName : "", o = typeof i.datasetId == "string" ? i.datasetId : "";
697
- t && o && s.add(`semantic:${t}:datasetId:${o}`), t && n && s.add(`semantic:${t}:datasetName:${n}`);
698
- }
699
- if (i.kind === "physical") {
700
- const t = typeof i.connectionId == "string" ? i.connectionId : "", n = typeof i.tableName == "string" ? i.tableName : "", o = typeof i.databaseName == "string" ? i.databaseName : "", d = typeof i.schemaName == "string" ? i.schemaName : "";
701
- t && n && (s.add(
702
- ["physical", t, o, d, n].join(
703
- ":"
704
- )
705
- ), s.add(`physical:${t}:${n}`));
706
- }
707
- if (i.kind === "sql") {
708
- const t = typeof i.connectionId == "string" ? i.connectionId : "", n = typeof i.dialect == "string" ? i.dialect : "", o = typeof i.label == "string" ? i.label : "";
709
- t && (s.add(["sql", t, n, o].join(":")), s.add(`sql:${t}`));
710
- }
711
- return s;
712
- }
713
- function cs(i, s) {
714
- const e = a(i);
715
- if (!e)
716
- return [`${s} must be an object.`];
717
- const t = [];
718
- if (e.fieldRef && t.push(
719
- ...f(e.fieldRef, `${s}.fieldRef`)
720
- ), (typeof e.inputId != "string" || !e.inputId.trim()) && t.push(`${s}.inputId is required.`), t.push(
721
- ...ue(e.optionQuery, `${s}.optionQuery`)
722
- ), h(e.appliesToViewIds) || t.push(`${s}.appliesToViewIds must be an array of strings.`), h(e.notAppliedToViewIds) || t.push(`${s}.notAppliedToViewIds must be an array of strings.`), !Array.isArray(e.bindings))
723
- t.push(`${s}.bindings must be an array.`);
724
- else {
725
- const n = h(e.appliesToViewIds) ? new Set(e.appliesToViewIds) : void 0, o = h(
726
- e.notAppliedToViewIds
727
- ) ? new Set(e.notAppliedToViewIds) : void 0;
728
- e.bindings.forEach((d, u) => {
729
- const l = a(d);
730
- if (!l) {
731
- t.push(`${s}.bindings.${u} must be an object.`);
732
- return;
733
- }
734
- typeof l.viewId != "string" || !l.viewId ? t.push(`${s}.bindings.${u}.viewId is required.`) : (n && !n.has(l.viewId) && t.push(
735
- `${s}.bindings.${u}.viewId must be included in appliesToViewIds.`
736
- ), o != null && o.has(l.viewId) && t.push(
737
- `${s}.bindings.${u}.viewId must not be listed in notAppliedToViewIds.`
738
- )), t.push(
739
- ...f(
740
- l.fieldRef,
741
- `${s}.bindings.${u}.fieldRef`
742
- )
743
- );
744
- });
745
- }
746
- return t;
747
- }
748
- function ue(i, s) {
749
- if (i === void 0)
750
- return [];
751
- const e = a(i);
752
- if (!e)
753
- return [`${s} must be an object.`];
754
- const t = [
755
- ...$(
756
- e.valueFieldRef,
757
- `${s}.valueFieldRef`
758
- ),
759
- ...$(
760
- e.labelFieldRef,
761
- `${s}.labelFieldRef`
762
- ),
763
- ...$(
764
- e.filterFieldRef,
765
- `${s}.filterFieldRef`
766
- )
767
- ];
768
- if (e.builder !== "semaphor.inputOptions" && t.push(`${s}.builder must be semaphor.inputOptions.`), typeof e.sourceKey != "string" && e.source === void 0 && t.push(`${s} must include source or sourceKey.`), e.source !== void 0) {
769
- const n = a(e.source);
770
- !n || n.kind !== "semantic" && n.kind !== "physical" ? t.push(`${s}.source.kind must be semantic or physical.`) : t.push(...R(e.source, `${s}.source`));
771
- }
772
- return a(e.valueFieldRef) || t.push(`${s}.valueFieldRef is required.`), a(e.labelFieldRef) || t.push(`${s}.labelFieldRef is required.`), e.limit !== void 0 && (typeof e.limit != "number" || !Number.isInteger(e.limit) || e.limit <= 0) && t.push(`${s}.limit must be a positive integer.`), t;
773
- }
774
- function ps(i) {
775
- var n;
776
- const s = a(i.value);
777
- if (!s)
778
- return [`${i.path} is required for executable views.`];
779
- const e = [];
780
- if (!le(s.builder))
781
- return e.push(`${i.path}.builder must be a supported SDK builder.`), e;
782
- i.sdkBuilder && s.builder !== i.sdkBuilder && e.push(`${i.path}.builder must match sdkBuilder.`), i.queryKind && w(i.queryKind) && s.builder !== gs(i.queryKind) && e.push(`${i.path}.builder must match queryKind.`);
783
- const t = a(s.spec);
784
- if (!t)
785
- return e.push(`${i.path}.spec must be an object.`), e;
786
- switch (s.builder) {
787
- case "semaphor.metric":
788
- e.push(
789
- ...A(
790
- t,
791
- ne,
792
- `${i.path}.spec`
793
- ),
794
- ..._(t, i.path),
795
- ...E(t.measures, `${i.path}.spec.measures`),
796
- ...$(
797
- t.primaryMeasure,
798
- `${i.path}.spec.primaryMeasure`
799
- ),
800
- ...$(
801
- t.dateField,
802
- `${i.path}.spec.dateField`
803
- ),
804
- ...x(
805
- t.dimensions,
806
- `${i.path}.spec.dimensions`
807
- ),
808
- ...F(t.orderBy, `${i.path}.spec.orderBy`),
809
- ...K(t.filters, `${i.path}.spec.filters`)
810
- );
811
- break;
812
- case "semaphor.analysis":
813
- e.push(
814
- ...A(
815
- t,
816
- Qe,
817
- `${i.path}.spec`
818
- ),
819
- ..._(t, i.path),
820
- ...E(t.measures, `${i.path}.spec.measures`),
821
- ...$(
822
- t.primaryMeasure,
823
- `${i.path}.spec.primaryMeasure`
824
- ),
825
- ...$(
826
- t.dateField,
827
- `${i.path}.spec.dateField`
828
- ),
829
- ...x(
830
- t.dimensions,
831
- `${i.path}.spec.dimensions`
832
- ),
833
- ...F(t.orderBy, `${i.path}.spec.orderBy`),
834
- ...K(t.filters, `${i.path}.spec.filters`),
835
- ...ms(t, `${i.path}.spec`)
836
- );
837
- break;
838
- case "semaphor.records":
839
- e.push(
840
- ...A(
841
- t,
842
- He,
843
- `${i.path}.spec`
844
- ),
845
- ..._(t, i.path),
846
- ...E(t.fields, `${i.path}.spec.fields`),
847
- ...$(
848
- t.dateField,
849
- `${i.path}.spec.dateField`
850
- ),
851
- ...F(t.orderBy, `${i.path}.spec.orderBy`),
852
- ...K(t.filters, `${i.path}.spec.filters`),
853
- ...fs(
854
- t.totals,
855
- `${i.path}.spec.totals`
856
- )
857
- );
858
- break;
859
- case "semaphor.matrix": {
860
- const { id: o, label: d, matrixWindowRequest: u, ...l } = t;
861
- for (const [I, q] of Object.entries({ id: o, label: d }))
862
- q !== void 0 && (typeof q != "string" || !q.trim()) && e.push(`${i.path}.spec.${I} must be a nonempty string.`);
863
- const b = re.safeParse({
864
- intent: { ...l, kind: "matrix" },
865
- matrixWindowRequest: u
866
- });
867
- b.success || e.push(...b.error.issues.map((I) => `${i.path}.spec.${I.path.join(".")}: ${I.message}`));
868
- break;
869
- }
870
- case "semaphor.sql":
871
- e.push(
872
- ...A(
873
- t,
874
- Ye,
875
- `${i.path}.spec`
876
- ),
877
- ..._(t, i.path)
878
- ), ((n = a(t.source)) == null ? void 0 : n.kind) !== "sql" && e.push(`${i.path}.spec.source.kind must be sql.`), (typeof t.sql != "string" || !t.sql.trim()) && e.push(`${i.path}.spec.sql is required.`), e.push(
879
- ...x(
880
- t.fields,
881
- `${i.path}.spec.fields`
882
- )
883
- );
884
- break;
885
- }
886
- return e;
887
- }
888
- function ms(i, s) {
889
- const e = [];
890
- if (i.driverMode !== void 0 && !Le.has(i.driverMode) && e.push(`${s}.driverMode must be a supported analysis driver mode.`), i.includePopulation !== void 0 && typeof i.includePopulation != "boolean" && e.push(`${s}.includePopulation must be a boolean.`), i.calendarContext !== void 0) {
891
- const t = a(i.calendarContext);
892
- if (!t)
893
- e.push(`${s}.calendarContext must be an object.`);
894
- else {
895
- t.tz !== void 0 && typeof t.tz != "string" && e.push(`${s}.calendarContext.tz must be a string.`), t.weekStart !== void 0 && (typeof t.weekStart != "number" || !Number.isInteger(t.weekStart) || t.weekStart < 0 || t.weekStart > 6) && e.push(
896
- `${s}.calendarContext.weekStart must be an integer between 0 and 6.`
897
- );
898
- const n = t.anchor;
899
- if (n !== void 0 && n !== "now") {
900
- const o = a(n);
901
- (!o || typeof o.iso != "string" || !o.iso.trim()) && e.push(`${s}.calendarContext.anchor must be now or { iso }.`);
902
- }
903
- }
904
- }
905
- return e;
906
- }
907
- function fs(i, s) {
908
- if (i === void 0)
909
- return [];
910
- const e = a(i);
911
- if (!e)
912
- return [`${s} must be an object.`];
913
- const t = [];
914
- return e.mode !== "server" && t.push(`${s}.mode must be server.`), !Array.isArray(e.measures) || e.measures.length === 0 ? t.push(`${s}.measures must include at least one measure.`) : e.measures.forEach((n, o) => {
915
- var d;
916
- t.push(
917
- ...ce(
918
- n,
919
- `${s}.measures.${o}`
920
- )
921
- ), ((d = a(n)) == null ? void 0 : d.role) !== "measure" && t.push(`${s}.measures.${o}.role must be measure.`);
922
- }), t;
923
- }
924
- function A(i, s, e) {
925
- const t = [];
926
- return Object.keys(i).forEach((n) => {
927
- s.has(n) || t.push(`${e}.${n} is not supported for this SDK builder.`);
928
- }), t;
929
- }
930
- function _(i, s) {
931
- return a(i.source) ? R(i.source, `${s}.spec.source`) : [`${s}.spec.source must be an object.`];
932
- }
933
- function E(i, s) {
934
- const e = hs(i, s);
935
- return Array.isArray(i) && i.forEach((t, n) => {
936
- e.push(...f(t, `${s}.${n}`));
937
- }), e;
938
- }
939
- function x(i, s) {
940
- if (i === void 0)
941
- return [];
942
- if (!Array.isArray(i))
943
- return [`${s} must be an array.`];
944
- const e = [];
945
- return i.forEach((t, n) => {
946
- e.push(...f(t, `${s}.${n}`));
947
- }), e;
948
- }
949
- function F(i, s) {
950
- if (i === void 0)
951
- return [];
952
- const e = a(i);
953
- return e ? [
954
- ...f(e.field, `${s}.field`),
955
- ...ys(e.direction, `${s}.direction`)
956
- ] : [`${s} must be an object.`];
957
- }
958
- function ys(i, s) {
959
- return i === "asc" || i === "desc" ? [] : [`${s} must be asc or desc.`];
960
- }
961
- function K(i, s) {
962
- if (i === void 0)
963
- return [];
964
- if (!Array.isArray(i))
965
- return [`${s} must be an array.`];
966
- const e = [];
967
- return i.forEach((t, n) => {
968
- const o = a(t);
969
- if (!o) {
970
- e.push(`${s}.${n} must be an object.`);
971
- return;
972
- }
973
- e.push(
974
- ...f(o.field, `${s}.${n}.field`)
975
- );
976
- }), e;
977
- }
978
- function hs(i, s) {
979
- return !Array.isArray(i) || i.length === 0 ? [`${s} must be a non-empty array.`] : [];
980
- }
981
- function gs(i) {
982
- switch (i) {
983
- case "metric":
984
- return "semaphor.metric";
985
- case "records":
986
- return "semaphor.records";
987
- case "matrix":
988
- return "semaphor.matrix";
989
- case "analysis":
990
- return "semaphor.analysis";
991
- case "sql_fallback":
992
- return "semaphor.sql";
993
- }
994
- }
995
- function bs(i) {
996
- const s = a(i.computation), e = a(i.visualSpec);
997
- return (s == null ? void 0 : s.kind) === "presentation_only" || (s == null ? void 0 : s.kind) === "derived" || (s == null ? void 0 : s.kind) === "unsupported" || i.visual === "text_block" || (e == null ? void 0 : e.visualType) === "text_block";
998
- }
999
- function vs(i, s) {
1000
- const e = a(i);
1001
- if (!e)
1002
- return [`${s} must be an object.`];
1003
- const t = [];
1004
- return We.has(e.visualType) || t.push(`${s}.visualType must be a supported visual type.`), e.limit !== void 0 && (typeof e.limit != "number" || !Number.isInteger(e.limit) || e.limit <= 0) && t.push(`${s}.limit must be a positive integer.`), e.tableBehavior !== void 0 && t.push(
1005
- ...$s(
1006
- e.tableBehavior,
1007
- `${s}.tableBehavior`
1008
- )
1009
- ), t;
1010
- }
1011
- function $s(i, s) {
1012
- const e = a(i);
1013
- if (!e)
1014
- return [`${s} must be an object.`];
1015
- const t = [];
1016
- return e.tableMode !== "bounded" && e.tableMode !== "server_paginated" && e.tableMode !== "server_windowed" && t.push(`${s}.tableMode must be a supported table mode.`), t.push(
1017
- ...Ss(e.height, `${s}.height`),
1018
- ...ws(e.pagination, `${s}.pagination`),
1019
- ...ks(e.sorting, `${s}.sorting`),
1020
- ...Is(e.totals, `${s}.totals`)
1021
- ), typeof e.serverSideRequired != "boolean" && t.push(`${s}.serverSideRequired must be a boolean.`), t;
1022
- }
1023
- function Ss(i, s) {
1024
- const e = a(i);
1025
- if (!e)
1026
- return [`${s} must be an object.`];
1027
- const t = [];
1028
- return (typeof e.maxPx != "number" || !Number.isInteger(e.maxPx) || e.maxPx <= 0) && t.push(`${s}.maxPx must be a positive integer.`), e.scroll !== "vertical" && e.scroll !== "both" && t.push(`${s}.scroll must be vertical or both.`), typeof e.stickyHeader != "boolean" && t.push(`${s}.stickyHeader must be a boolean.`), t;
1029
- }
1030
- function ws(i, s) {
1031
- const e = a(i);
1032
- if (!e)
1033
- return [`${s} must be an object.`];
1034
- const t = [];
1035
- return e.mode !== "none" && e.mode !== "server" && e.mode !== "client_for_bounded_rows" && t.push(`${s}.mode must be a supported pagination mode.`), e.pageSize !== void 0 && (typeof e.pageSize != "number" || !Number.isInteger(e.pageSize) || e.pageSize <= 0) && t.push(`${s}.pageSize must be a positive integer.`), e.readsFrom !== void 0 && e.readsFrom !== "result.pagination" && t.push(`${s}.readsFrom must be result.pagination.`), t;
1036
- }
1037
- function ks(i, s) {
1038
- const e = a(i);
1039
- if (!e)
1040
- return [`${s} must be an object.`];
1041
- const t = [];
1042
- return e.mode !== "server" && e.mode !== "client_for_bounded_rows" && t.push(`${s}.mode must be a supported sorting mode.`), e.defaultField !== void 0 && (typeof e.defaultField != "string" || !e.defaultField.trim()) && t.push(`${s}.defaultField must be a non-empty string.`), e.defaultDirection !== void 0 && e.defaultDirection !== "asc" && e.defaultDirection !== "desc" && t.push(`${s}.defaultDirection must be asc or desc.`), e.resetPageOnChange !== void 0 && typeof e.resetPageOnChange != "boolean" && t.push(`${s}.resetPageOnChange must be a boolean.`), t;
1043
- }
1044
- function Is(i, s) {
1045
- const e = a(i);
1046
- if (!e)
1047
- return [`${s} must be an object.`];
1048
- const t = [];
1049
- return e.mode !== "none" && e.mode !== "server" && e.mode !== "local" ? (t.push(`${s}.mode must be none, server, or local.`), t) : e.mode === "none" ? (e.measures !== void 0 && t.push(`${s}.measures is not allowed when mode is none.`), e.label !== void 0 && t.push(`${s}.label is not allowed when mode is none.`), t) : e.mode === "server" ? (!Array.isArray(e.measures) || e.measures.length === 0 ? t.push(
1050
- `${s}.measures must include at least one measure when mode is server.`
1051
- ) : e.measures.forEach((n, o) => {
1052
- var d;
1053
- t.push(
1054
- ...ce(
1055
- n,
1056
- `${s}.measures.${o}`
1057
- )
1058
- ), ((d = a(n)) == null ? void 0 : d.role) !== "measure" && t.push(`${s}.measures.${o}.role must be measure.`);
1059
- }), e.label !== void 0 && t.push(`${s}.label is not allowed when mode is server.`), t) : (e.mode === "local" && (e.label !== "Displayed rows" && e.label !== "Current page" && t.push(
1060
- `${s}.label must be Displayed rows or Current page when mode is local.`
1061
- ), e.measures !== void 0 && t.push(`${s}.measures is not allowed when mode is local.`)), t);
1062
- }
1063
- function As(i, s) {
1064
- const e = a(i);
1065
- if (!e)
1066
- return [`${s} must be an object.`];
1067
- const t = [];
1068
- switch (e.kind) {
1069
- case "server_query":
1070
- w(e.queryKind) || t.push(
1071
- `${s}.queryKind must be a supported codegen query kind.`
1072
- ), e.queryOwnership !== void 0 && e.queryOwnership !== "view_owned" && e.queryOwnership !== "shared_query" && t.push(
1073
- `${s}.queryOwnership must be view_owned or shared_query.`
1074
- ), e.sourceKeys !== void 0 && !h(e.sourceKeys) && t.push(`${s}.sourceKeys must be an array of strings.`), e.fieldNames !== void 0 && !h(e.fieldNames) && t.push(`${s}.fieldNames must be an array of strings.`);
1075
- break;
1076
- case "derived":
1077
- (typeof e.upstreamViewId != "string" || !e.upstreamViewId.trim()) && t.push(`${s}.upstreamViewId is required.`), (typeof e.derivation != "string" || !e.derivation.trim()) && t.push(`${s}.derivation is required.`);
1078
- break;
1079
- case "presentation_only":
1080
- break;
1081
- case "unsupported":
1082
- (typeof e.reason != "string" || !e.reason.trim()) && t.push(`${s}.reason is required.`), (typeof e.suggestedModelingFix != "string" || !e.suggestedModelingFix.trim()) && t.push(`${s}.suggestedModelingFix is required.`);
1083
- break;
1084
- default:
1085
- t.push(`${s}.kind must be a supported computation kind.`);
1086
- }
1087
- return t;
1088
- }
1089
- function _s(i, s) {
1090
- const e = a(i);
1091
- if (!e)
1092
- return [`${s} must be an object.`];
1093
- const t = [];
1094
- for (const o of ["title", "requestedQuestion", "suggestedModelingFix"])
1095
- (typeof e[o] != "string" || !e[o].trim()) && t.push(`${s}.${o} is required.`);
1096
- return Je.has(e.reason) || t.push(
1097
- `${s}.reason must be a supported unsupported insight reason.`
1098
- ), (e.relationshipCandidate !== void 0 || e.nextRepairAction !== void 0) && e.reason !== "missing_relationship" && t.push(
1099
- `${s} relationship repair metadata is only valid for missing_relationship unsupported insights.`
1100
- ), e.diagnostic !== void 0 && t.push(
1101
- ...Rs(
1102
- e.diagnostic,
1103
- `${s}.diagnostic`,
1104
- e.reason
1105
- )
1106
- ), e.relationshipCandidate !== void 0 && t.push(
1107
- ...Cs(
1108
- e.relationshipCandidate,
1109
- `${s}.relationshipCandidate`
1110
- )
1111
- ), e.nextRepairAction !== void 0 && t.push(
1112
- ...qs(
1113
- e.nextRepairAction,
1114
- `${s}.nextRepairAction`
1115
- )
1116
- ), t;
1117
- }
1118
- function Rs(i, s, e) {
1119
- const t = a(i);
1120
- if (!t)
1121
- return [`${s} must be an object.`];
1122
- const n = [], o = /* @__PURE__ */ new Set([
1123
- "kind",
1124
- "inputId",
1125
- "inputLabel",
1126
- "optionSource",
1127
- "optionField",
1128
- "missingEvidence"
1129
- ]);
1130
- Object.keys(t).forEach((u) => {
1131
- o.has(u) || n.push(
1132
- `${s}.${u} is not supported; raw identifier diagnostics support only kind, inputId, inputLabel, optionSource, optionField, and missingEvidence.`
1133
- );
1134
- }), e !== "raw_identifier_filter_options" && n.push(
1135
- `${s} is only valid for raw_identifier_filter_options unsupported insights.`
1136
- ), t.kind !== "raw_identifier_filter_options" && n.push(`${s}.kind must be raw_identifier_filter_options.`);
1137
- for (const u of ["inputId", "inputLabel"])
1138
- (typeof t[u] != "string" || !t[u].trim()) && n.push(`${s}.${u} must be a non-empty string.`);
1139
- n.push(
1140
- ...B(
1141
- t.optionSource,
1142
- `${s}.optionSource`
1143
- )
1144
- ), n.push(
1145
- ...de(
1146
- t.optionField,
1147
- `${s}.optionField`
1148
- )
1149
- );
1150
- const d = /* @__PURE__ */ new Set([
1151
- "display_field",
1152
- "relationship_display_path"
1153
- ]);
1154
- return !Array.isArray(t.missingEvidence) || t.missingEvidence.length === 0 ? n.push(`${s}.missingEvidence must be a non-empty evidence array.`) : t.missingEvidence.forEach((u, l) => {
1155
- d.has(u) || n.push(
1156
- `${s}.missingEvidence.${l} must be display_field or relationship_display_path.`
1157
- );
1158
- }), n;
1159
- }
1160
- function qs(i, s) {
1161
- const e = a(i);
1162
- if (!e)
1163
- return [`${s} must be an object.`];
1164
- const t = [], n = /* @__PURE__ */ new Set(["tool", "reason"]);
1165
- return Object.keys(e).forEach((o) => {
1166
- n.has(o) || t.push(
1167
- `${s}.${o} is not supported; repair actions support only tool and reason.`
1168
- );
1169
- }), e.tool !== "semaphor_propose_semantic_model_change" && t.push(`${s}.tool must be semaphor_propose_semantic_model_change.`), e.reason !== "missing_relationship" && t.push(`${s}.reason must be missing_relationship.`), t;
1170
- }
1171
- function Cs(i, s) {
1172
- const e = a(i);
1173
- if (!e)
1174
- return [`${s} must be an object.`];
1175
- const t = [], n = /* @__PURE__ */ new Set([
1176
- "source",
1177
- "sourceFields",
1178
- "target",
1179
- "targetFields"
1180
- ]);
1181
- Object.keys(e).forEach((o) => {
1182
- n.has(o) || t.push(
1183
- `${s}.${o} is not supported; relationship candidates support only source, sourceFields, target, and targetFields.`
1184
- );
1185
- }), t.push(
1186
- ...B(e.source, `${s}.source`)
1187
- ), t.push(
1188
- ...B(e.target, `${s}.target`)
1189
- );
1190
- for (const o of ["sourceFields", "targetFields"]) {
1191
- const d = e[o];
1192
- if (!Array.isArray(d) || d.length === 0) {
1193
- t.push(`${s}.${o} must be a non-empty endpoint field array.`);
1194
- continue;
1195
- }
1196
- d.forEach((u, l) => {
1197
- t.push(
1198
- ...de(u, `${s}.${o}.${l}`)
1199
- );
1200
- });
1201
- }
1202
- return t;
1203
- }
1204
- function de(i, s) {
1205
- const e = a(i);
1206
- if (!e)
1207
- return [`${s} must be an object.`];
1208
- const t = [], n = /* @__PURE__ */ new Set(["name", "label", "role", "dataType"]);
1209
- return Object.keys(e).forEach((o) => {
1210
- n.has(o) || t.push(
1211
- `${s}.${o} is not supported; relationship candidate fields are scoped by their endpoint and support only name, label, role, and dataType.`
1212
- );
1213
- }), (typeof e.name != "string" || !e.name.trim()) && t.push(`${s}.name must be a non-empty string.`), e.role !== void 0 && (typeof e.role != "string" || !["dimension", "measure", "date", "id", "unknown"].includes(e.role)) && t.push(
1214
- `${s}.role must be dimension, measure, date, id, or unknown.`
1215
- ), e.dataType !== void 0 && (typeof e.dataType != "string" || !["string", "number", "boolean", "date", "datetime", "unknown"].includes(
1216
- e.dataType
1217
- )) && t.push(
1218
- `${s}.dataType must be string, number, boolean, date, datetime, or unknown.`
1219
- ), t;
1220
- }
1221
- function B(i, s) {
1222
- const e = a(i);
1223
- if (!e)
1224
- return [`${s} must be an object.`];
1225
- const t = [], n = /* @__PURE__ */ new Set([
1226
- "kind",
1227
- "domainId",
1228
- "datasetName",
1229
- "datasetId",
1230
- "label",
1231
- "sourceKey"
1232
- ]);
1233
- return Object.keys(e).forEach((o) => {
1234
- n.has(o) || t.push(
1235
- `${s}.${o} is not supported; relationship candidate sources support only semantic identity fields.`
1236
- );
1237
- }), e.kind !== "semantic" && t.push(`${s} must use semantic source identity.`), (typeof e.domainId != "string" || !e.domainId.trim() || typeof e.datasetName != "string" || !e.datasetName.trim()) && t.push(`${s} must include semantic domainId and datasetName.`), t;
1238
- }
1239
- function w(i) {
1240
- return Ue.has(i);
1241
- }
1242
- function le(i) {
1243
- return ze.has(i);
1244
- }
1245
- function $(i, s) {
1246
- return i === void 0 ? [] : f(i, s);
1247
- }
1248
- function f(i, s) {
1249
- const e = a(i);
1250
- if (!e)
1251
- return [`${s} must be an object.`];
1252
- const t = [];
1253
- return (typeof e.name != "string" || !e.name.trim()) && t.push(`${s}.name is required.`), !e.source && typeof e.sourceKey != "string" && t.push(`${s} must include source or sourceKey.`), e.aggregate !== void 0 && !Ge.has(e.aggregate) && t.push(`${s}.aggregate must be a supported aggregate function.`), t;
1254
- }
1255
- function ce(i, s) {
1256
- const e = a(i), t = f(i, s);
1257
- if (!e || typeof e.sourceKey == "string" && e.sourceKey.trim())
1258
- return t;
1259
- if (e.source !== void 0) {
1260
- const o = R(
1261
- e.source,
1262
- `${s}.source`
1263
- );
1264
- return o.length === 0 || t.push(...o), t;
1265
- }
1266
- return t.includes(`${s} must include source or sourceKey.`) || t.push(`${s} must include source or sourceKey.`), t;
1267
- }
1268
- function a(i) {
1269
- return i && typeof i == "object" && !Array.isArray(i) ? i : void 0;
1270
- }
1271
- function h(i) {
1272
- return Array.isArray(i) && i.every((s) => typeof s == "string");
1273
- }
1274
- const js = r.union([
1275
- Ae,
1276
- _e,
1277
- Re,
1278
- qe,
1279
- te
1280
- ]), Es = r.object({
1281
- status: r.enum([
1282
- "not_required",
1283
- "resolved",
1284
- "missing",
1285
- "ambiguous",
1286
- "fanout_risk",
1287
- "unknown"
1288
- ]),
1289
- requiredSources: r.array(C).optional(),
1290
- relationshipsUsed: r.array(r.string()).optional(),
1291
- missingSources: r.array(r.string()).optional(),
1292
- warnings: r.array(r.string()).optional(),
1293
- message: r.string().optional(),
1294
- recommendedNextStep: r.string().optional(),
1295
- joinPlanSummary: r.object({
1296
- baseSource: C.optional(),
1297
- joinedSources: r.array(C).optional(),
1298
- joinCount: r.number().optional()
1299
- }).passthrough().optional(),
1300
- fanoutRisk: r.object({
1301
- status: r.enum(["none", "warning", "error", "unknown"]),
1302
- message: r.string().optional()
1303
- }).passthrough().optional()
1304
- }).passthrough(), Y = r.enum([
1305
- "ambiguous_fields",
1306
- "empty_result",
1307
- "missing_grounded_fields",
1308
- "missing_relationship",
1309
- "no_grounded_query",
1310
- "partial_result",
1311
- "presentation_incomplete",
1312
- "query_validation_failed",
1313
- "unsafe_join"
1314
- ]), pe = r.object({
1315
- version: r.literal(1),
1316
- status: r.enum(["answered", "partial", "blocked"]),
1317
- summary: r.string(),
1318
- answered: r.array(
1319
- r.object({
1320
- slotId: r.string().optional(),
1321
- queryId: r.string().optional(),
1322
- summary: r.string(),
1323
- evidenceIds: r.array(r.string()).optional(),
1324
- fieldsUsed: r.array(D).optional()
1325
- }).passthrough()
1326
- ),
1327
- blocked: r.array(
1328
- r.object({
1329
- slotId: r.string().optional(),
1330
- queryId: r.string().optional(),
1331
- reasonCode: Y,
1332
- message: r.string(),
1333
- missingFields: r.array(r.string()).optional(),
1334
- availableFields: r.array(r.string()).optional(),
1335
- ambiguousFields: r.array(r.string()).optional(),
1336
- missingRelationships: r.array(r.string()).optional(),
1337
- evidenceIds: r.array(r.string()).optional(),
1338
- neededFromUser: r.array(r.string()).optional(),
1339
- recommendedNextStep: r.string().optional()
1340
- }).passthrough()
1341
- ),
1342
- semanticModelRecommendations: r.array(
1343
- r.object({
1344
- reasonCode: Y,
1345
- message: r.string(),
1346
- recommendedNextStep: r.string().optional()
1347
- }).passthrough()
1348
- ).optional()
1349
- }).passthrough(), me = r.object({
1350
- scope: r.literal("filtered_query"),
1351
- measures: r.record(Ce)
1352
- }).passthrough(), fe = r.object({
1353
- answeredObligations: r.array(r.string()),
1354
- missingObligations: r.array(r.string()),
1355
- warnings: r.array(je).optional()
1356
- }).passthrough(), ye = r.object({
1357
- intentId: r.string().optional(),
1358
- queryId: r.string().optional(),
1359
- status: r.enum(["answered", "partial", "failed"]),
1360
- resultShape: r.enum([
1361
- "metric",
1362
- "records",
1363
- "inputOptions",
1364
- "sql",
1365
- "matrix",
1366
- "period_change",
1367
- "analysis"
1368
- ]).optional(),
1369
- intent: r.unknown().optional(),
1370
- compiledQuery: r.unknown().optional(),
1371
- fieldsUsed: r.array(D).optional(),
1372
- result: js.optional(),
1373
- validation: X,
1374
- coverage: fe.optional(),
1375
- missingFields: r.array(r.string()).optional(),
1376
- warnings: r.array(r.string()).optional(),
1377
- relationshipDiagnostics: Es.optional(),
1378
- diagnosticFeedback: pe.optional(),
1379
- population: me.optional(),
1380
- metadata: r.record(r.string(), r.unknown()).optional()
1381
- }).passthrough(), xs = ye;
1382
- function Fs(i) {
1383
- switch (i) {
1384
- case "boolean":
1385
- return r.boolean().optional();
1386
- case "compactExecutionFieldArray":
1387
- return r.array(Fe).optional();
1388
- case "coverage":
1389
- return fe.optional();
1390
- case "diagnosticFeedback":
1391
- return pe.optional();
1392
- case "executionFieldArray":
1393
- return r.array(D).optional();
1394
- case "executionResult":
1395
- return xs.optional();
1396
- case "number":
1397
- return r.number().finite().optional();
1398
- case "population":
1399
- return me.optional();
1400
- case "record":
1401
- return m.optional();
1402
- case "recordArray":
1403
- return xe.optional();
1404
- case "responseDetail":
1405
- return r.enum(["compact", "standard", "debug"]).optional();
1406
- case "string":
1407
- return r.string().optional();
1408
- case "stringArray":
1409
- return r.array(r.string()).optional();
1410
- case "unknown":
1411
- return r.unknown().optional();
1412
- case "unknownArray":
1413
- return r.array(r.unknown()).optional();
1414
- case "validationResult":
1415
- return X.optional();
1416
- }
1417
- }
1418
- const Ks = Object.fromEntries(
1419
- Object.entries(T).map(
1420
- ([i, s]) => [i, Fs(s)]
1421
- )
1422
- ), Ns = r.object(Ks).strict(), P = r.object({
1423
- sourceKey: r.string().optional(),
1424
- kind: r.enum(["semantic", "physical", "sql"]).optional(),
1425
- domainId: r.string().optional(),
1426
- datasetName: r.string().optional(),
1427
- datasetId: r.string().optional(),
1428
- connectionId: r.string().optional(),
1429
- tableName: r.string().optional(),
1430
- label: r.string().optional()
1431
- }).passthrough(), S = r.object({
1432
- name: r.string(),
1433
- label: r.string().optional(),
1434
- role: r.enum(["dimension", "measure", "date", "id", "unknown"]).optional(),
1435
- dataType: r.enum(["string", "number", "boolean", "date", "datetime", "unknown"]).optional(),
1436
- aggregate: Ee.optional(),
1437
- sourceKey: r.string().optional(),
1438
- source: P.optional()
1439
- }).passthrough(), he = r.object({
1440
- id: r.string().optional(),
1441
- builder: r.literal("semaphor.inputOptions"),
1442
- source: P.optional(),
1443
- sourceKey: r.string().optional(),
1444
- valueFieldRef: S,
1445
- labelFieldRef: S,
1446
- filterFieldRef: S.optional(),
1447
- population: r.unknown().optional(),
1448
- dependencies: r.unknown().optional(),
1449
- limit: r.number().int().positive().optional(),
1450
- spec: m.optional()
1451
- }).passthrough(), ge = r.object({
1452
- appliesToViewIds: r.array(r.string()).optional(),
1453
- viewId: r.string().optional(),
1454
- fieldRef: S,
1455
- relationshipHint: r.unknown().optional(),
1456
- relationshipsUsed: r.array(m).optional()
1457
- }).passthrough(), Os = r.object({
1458
- id: r.string(),
1459
- label: r.string().optional(),
1460
- type: r.string().optional(),
1461
- serverSide: r.boolean().optional(),
1462
- fieldRef: S.optional(),
1463
- optionQuery: he.optional(),
1464
- bindings: r.array(ge).optional(),
1465
- appliesToViewIds: r.array(r.string()),
1466
- relationshipHint: r.unknown().optional(),
1467
- relationshipsUsed: r.array(m).optional()
1468
- }).passthrough(), Bs = r.object({
1469
- builder: r.enum([
1470
- "semaphor.metric",
1471
- "semaphor.records",
1472
- "semaphor.matrix",
1473
- "semaphor.analysis",
1474
- "semaphor.sql"
1475
- ]),
1476
- spec: m,
1477
- fallbackReason: m.optional()
1478
- }).passthrough(), Ds = r.object({
1479
- id: r.string(),
1480
- title: r.string().optional(),
1481
- purpose: r.string().optional(),
1482
- sourcePresentation: r.object({
1483
- sourceKeys: r.array(r.string()).optional(),
1484
- sourceLabels: r.array(r.string()).optional()
1485
- }).passthrough().optional(),
1486
- visual: r.string().optional(),
1487
- visualSpec: m.optional(),
1488
- queryKind: r.enum(["metric", "records", "matrix", "analysis", "sql_fallback"]).optional(),
1489
- sdkBuilder: r.enum([
1490
- "semaphor.metric",
1491
- "semaphor.records",
1492
- "semaphor.matrix",
1493
- "semaphor.analysis",
1494
- "semaphor.sql"
1495
- ]).optional(),
1496
- sdkSpec: Bs.optional(),
1497
- fields: r.array(S).optional(),
1498
- computation: m.optional(),
1499
- uxExpectations: r.array(r.string()).optional(),
1500
- validation: m.optional()
1501
- }).passthrough(), Ts = r.object({
1502
- inputId: r.string(),
1503
- label: r.string().optional(),
1504
- type: r.string().optional(),
1505
- serverSide: r.boolean().optional(),
1506
- fieldRef: S.optional(),
1507
- optionQuery: he.optional(),
1508
- bindings: r.array(ge),
1509
- appliesToViewIds: r.array(r.string()),
1510
- notAppliedToViewIds: r.array(r.string())
1511
- }).passthrough(), Zs = r.object({
1512
- schemaVersion: r.literal(O),
1513
- title: r.string(),
1514
- purpose: r.string().optional(),
1515
- userGoal: r.string().optional(),
1516
- nextStep: r.string().optional(),
1517
- sources: r.array(P),
1518
- inputs: r.array(Os),
1519
- views: r.array(Ds),
1520
- filterContracts: r.array(Ts),
1521
- implementationChecklist: r.object({
1522
- schemaVersion: r.string().optional(),
1523
- requiredDevtools: r.object({
1524
- mountRootDevtools: r.boolean(),
1525
- providerDebugBridge: r.string().optional(),
1526
- panelPosition: r.string().optional(),
1527
- forbidden: r.array(r.string()).optional()
1528
- }).passthrough(),
1529
- requiredInputOptions: r.array(m),
1530
- filterScopeByInput: r.array(m),
1531
- bindingsByView: r.record(r.string(), r.array(m)),
1532
- validationCommands: r.array(r.string()),
1533
- browserSmokeChecks: r.array(r.string())
1534
- }).passthrough(),
1535
- nextRequiredTool: r.object({
1536
- name: r.string(),
1537
- reason: r.string().optional()
1538
- }).optional(),
1539
- unsupportedInsights: r.array(
1540
- r.object({
1541
- title: r.string(),
1542
- requestedQuestion: r.string(),
1543
- reason: r.string(),
1544
- suggestedModelingFix: r.string()
1545
- }).passthrough()
1546
- ).optional(),
1547
- assumptions: r.array(r.string()).optional(),
1548
- validation: m.optional()
1549
- }).passthrough().superRefine((i, s) => {
1550
- const e = oe(i);
1551
- for (const t of e.issues)
1552
- s.addIssue({
1553
- code: r.ZodIssueCode.custom,
1554
- message: t
1555
- });
1556
- }), Ms = new Set(
1557
- Object.keys(T)
1558
- );
1559
- function et() {
1560
- return Object.keys(
1561
- T
1562
- );
1563
- }
1564
- function Ps(i) {
1565
- return Ms.has(i);
1566
- }
1567
- function st(i) {
1568
- if (!i || typeof i != "object" || Array.isArray(i))
1569
- throw new Error("Semaphor analyze result must be an object.");
1570
- const e = Object.keys(i).filter(
1571
- (t) => !Ps(t)
1572
- );
1573
- if (e.length)
1574
- throw new Error(
1575
- `Semaphor analyze result contains unsupported top-level field(s): ${e.join(", ")}.`
1576
- );
1577
- return Ns.parse(i);
1578
- }
1579
- const Vs = r.object({
1580
- runtimeFilters: N.innerType().shape.filters,
1581
- runtimeSorts: N.innerType().shape.sorts.optional()
1582
- });
1583
- function tt(i) {
1584
- return Vs.parse(i);
1585
- }
1586
- const Us = {
1587
- // A window executes a governed statement set, not one compiled query.
1588
- compiledQuery: r.never().optional(),
1589
- intent: re.shape.intent,
1590
- resultShape: r.literal("matrix"),
1591
- result: te.optional(),
1592
- metadata: r.object({ rowLimitExceeded: r.boolean(), matrixFailure: M.optional() }).passthrough()
1593
- }, zs = ye.extend(Us), it = zs.superRefine((i, s) => {
1594
- i.status === "failed" == !!i.result && s.addIssue({ code: "custom", message: "Only answered or partial Matrix execution carries a window." }), i.result && i.status === "partial" != i.result.window.failures.length > 0 && s.addIssue({ code: "custom", message: "Matrix execution status must match acquired window failures." });
1595
- });
1596
- export {
1597
- M as A,
1598
- Te as B,
1599
- se as C,
1600
- Ys as D,
1601
- Me as E,
1602
- Pe as F,
1603
- G,
1604
- Ve as H,
1605
- Ws as I,
1606
- Vs as J,
1607
- tt as K,
1608
- it as L,
1609
- Qs as M,
1610
- re as N,
1611
- O as S,
1612
- Js as a,
1613
- Ps as b,
1614
- T as c,
1615
- Es as d,
1616
- pe as e,
1617
- me as f,
1618
- et as g,
1619
- fe as h,
1620
- Xs as i,
1621
- ye as j,
1622
- xs as k,
1623
- Ks as l,
1624
- Ns as m,
1625
- Zs as n,
1626
- te as o,
1627
- st as p,
1628
- Ne as q,
1629
- U as r,
1630
- js as s,
1631
- Oe as t,
1632
- Z as u,
1633
- oe as v,
1634
- Hs as w,
1635
- Be as x,
1636
- De as y,
1637
- z
1638
- };