react-semaphor 0.1.603 → 0.1.605
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.
- package/dist/activity/index.js +1 -73
- package/dist/analytics-protocol/index.js +1 -1491
- package/dist/appearance/index.js +1 -12
- package/dist/appearance-runtime/index.js +1 -5
- package/dist/assistant-context/index.js +1 -11
- package/dist/assistant-protocol/index.js +1 -152
- package/dist/brand-studio/index.js +3 -1598
- package/dist/briefings/index.js +1 -70
- package/dist/chunks/add-to-dashboard-CEmZUf9o.js +12 -0
- package/dist/chunks/analytics-base-schemas-DMFrDqn_.js +1 -0
- package/dist/chunks/appearance-provider-CfoAVQuG.js +608 -0
- package/dist/chunks/appearance-runtime-provider-Bx8H-moR.js +1 -0
- package/dist/chunks/applied-constraints-CinevlKD.js +1 -0
- package/dist/chunks/assistant-chat-DgUaCE9k.js +51 -0
- package/dist/chunks/attachment-filter-line-C_zHMhGh.js +1 -0
- package/dist/chunks/attribution-BEFSsbNn.js +1 -0
- package/dist/chunks/availability-3AIOf6Z-.js +1 -0
- package/dist/chunks/bookmark-impact-BAtemeyK.js +1 -0
- package/dist/chunks/bookmark-state-DScd31KT.js +1 -0
- package/dist/chunks/brand-C9APUFaP.js +1 -0
- package/dist/chunks/card-filter-builder-ClWrXB7P.js +11 -0
- package/dist/chunks/column-bands-DwxbZ6UI.js +1 -0
- package/dist/chunks/comparison-window-caption-tguyN24S.js +1 -0
- package/dist/chunks/context-CntvtZwC.js +2 -0
- package/dist/chunks/conversation-JMK2kyTK.js +1 -0
- package/dist/chunks/dashboard-ChIcbVTx.js +1 -0
- package/dist/chunks/dashboard-briefing-launcher-CwMlhkxV.js +42 -0
- package/dist/chunks/dashboard-controls-UCSAFCGA.js +42 -0
- package/dist/chunks/dashboard-json-B120hYDa.js +1 -0
- package/dist/chunks/dashboard-temporal-snapshot-BFJKbp_6.js +1 -0
- package/dist/chunks/edit-dashboard-visual-DvHp03h_.js +73 -0
- package/dist/chunks/export-file-format-B-wQNHIn.js +4 -0
- package/dist/chunks/filter-line-WwUV5JzN.js +1 -0
- package/dist/chunks/filter-reach-preview-C5M5_hf_.js +1 -0
- package/dist/chunks/filter-value-text-DqTHe_vu.js +1 -0
- package/dist/chunks/index-DViPGDFj.js +1 -0
- package/dist/chunks/index-bkP6SnYu.js +1 -0
- package/dist/chunks/kpi-trend-rule-B87LNzcz.js +1 -0
- package/dist/chunks/layout-grid-CFzqJ7GC.js +6 -0
- package/dist/chunks/matrix-analytical-definition-5T-2euHZ.js +1 -0
- package/dist/chunks/matrix-member-presentation-vVAv-aqg.js +1 -0
- package/dist/chunks/matrix-operation-contract-CWvcEsQ0.js +1 -0
- package/dist/chunks/normalize-dashboard-for-dirty-check-ILKfqgL3.js +1 -0
- package/dist/chunks/numeric-range-options-C8tr-Bls.js +1 -0
- package/dist/chunks/palette-NvEIuXHN.js +6 -0
- package/dist/chunks/pivot-result-contract-expectations-BNWhS8mv.js +1 -0
- package/dist/chunks/pivot-result-identity-B0eWVMXg.js +1 -0
- package/dist/chunks/raw-temporal-value-BHQ-ldpW.js +1 -0
- package/dist/chunks/rendered-file-BbvwaU6z.js +1 -0
- package/dist/chunks/report-preferences-dialog-Bseb2Rlg.js +1 -0
- package/dist/chunks/report-runtime-context-Cd1b5pku.js +1 -0
- package/dist/chunks/resolve-dashboard-input-context-BDY7KwRe.js +8 -0
- package/dist/chunks/resolver-CjsW8Rz0.js +1 -0
- package/dist/chunks/saved-dashboard-context-C3lWc4Dx.js +1 -0
- package/dist/chunks/schema-O1Y3WTGF.js +4 -0
- package/dist/chunks/selection-filter-compiler-kYsRugss.js +1 -0
- package/dist/chunks/semaphor-ready-indicator-BQarSo6S.js +612 -0
- package/dist/chunks/set-6mOnfQeH.js +1 -0
- package/dist/chunks/slider-BPnHdMGq.js +4 -0
- package/dist/chunks/stored-dashboard-DfrxDLhR.js +1 -0
- package/dist/chunks/table-export-sheet-xaczzWZF.js +2 -0
- package/dist/chunks/token-types-1vzMWjI-.js +1 -0
- package/dist/chunks/validators-Dg2kyF4_.js +1 -0
- package/dist/chunks/variable-draft-B4_xqr4Y.js +1 -0
- package/dist/chunks/visual-choice-DgEFfkE-.js +1 -0
- package/dist/dashboard/index.js +1 -7
- package/dist/dashboard-authoring/index.js +1 -4614
- package/dist/format-utils/index.js +1 -425
- package/dist/index.js +1 -554
- package/dist/layouts/index.js +1 -7
- package/dist/live-channel/index.js +1 -124
- package/dist/pdf-export-policy/index.js +1 -92
- package/dist/pdf-table-layout/index.js +1 -993
- package/dist/report-runtime-context/index.js +1 -9
- package/dist/shared/index.js +1 -6
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +1 -9
- package/dist/types/brand-studio/brand-studio-draft.d.ts +45 -13
- package/dist/types/brand-studio/brand-studio-editor.d.ts +13 -2
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +17 -6
- package/dist/types/components/visual/data-table/types/data-table.d.ts +52 -42
- package/dist/types/index.js +1 -88
- package/dist/types/lib/appearance/aliases.d.ts +3 -0
- package/dist/types/lib/appearance/index.d.ts +1 -0
- package/dist/types/lib/appearance/table-density.d.ts +18 -0
- package/dist/types/lib/appearance/types.d.ts +39 -1
- package/dist/types/lib/dashboard-viewer/column-header-actions.d.ts +100 -0
- package/dist/types/lib/dashboard-viewer/table-view-edit.d.ts +0 -27
- package/dist/types/lib/dashboard-viewer/table-view.d.ts +26 -2
- package/dist/types/lib/dashboard-viewer/use-table-view.d.ts +2 -0
- package/dist/types/lib/filter-values/build-card-filter-definition.d.ts +32 -0
- package/dist/types/lib/hooks/use-add-new-frame.d.ts +7 -0
- package/dist/types/lib/hooks/use-dashboard-card.d.ts +4 -0
- package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +8 -0
- package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +9 -0
- package/dist/types/lib/stores/dashboard-store.d.ts +14 -2
- package/dist/types/lib/stores/explorer-actions.d.ts +7 -10
- package/dist/types/lib/types/common-types.d.ts +1 -2
- package/dist/types/lib/types/semantic-types.d.ts +6 -10
- package/dist/types/lib/utils/card-config-utils.d.ts +13 -0
- package/dist/types/lib/utils/field-placement.d.ts +17 -0
- package/dist/types/lib/utils/field-state-calculator.d.ts +7 -19
- package/dist/types/shared/analytics-protocol/analytics-refusal.d.ts +21 -1
- package/dist/types/shared/analytics-protocol/field-provenance.d.ts +7 -4
- package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +13 -0
- package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +125 -0
- package/dist/types/shared/dashboard-authoring/card-data-source/card-field-folders.d.ts +55 -0
- package/dist/types/shared/dashboard-authoring/card-data-source/card-joins.d.ts +114 -0
- package/dist/types/shared/dashboard-authoring/card-data-source/card-prune.d.ts +12 -0
- package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-catalog.d.ts +60 -0
- package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +180 -0
- package/dist/types/shared/dashboard-authoring/card-data-source/index.d.ts +7 -0
- package/dist/types/shared/dashboard-authoring/card-data-source/join-reach.d.ts +42 -0
- package/dist/types/shared/dashboard-authoring/card-field-places.d.ts +28 -0
- package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +2 -8
- package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
- package/dist/types/shared/dashboard-authoring/card-settings/column-display-values.d.ts +5 -0
- package/dist/types/shared/dashboard-authoring/card-settings/column-display.d.ts +52 -0
- package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +9 -0
- package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +4 -0
- package/dist/types/shared/dashboard-authoring/card-settings/table-viewer-switches.d.ts +15 -0
- package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +5 -0
- package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
- package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +132 -3
- package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +3 -1
- package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
- package/dist/types/shared/dashboard-authoring/conditional-formatting/store.d.ts +10 -1
- package/dist/types/shared/dashboard-authoring/field-aggregations.d.ts +9 -2
- package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +116 -0
- package/dist/types/shared/dashboard-authoring/field-folders/index.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/filter-reach-decision.d.ts +11 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +7 -1
- package/dist/types/shared/dashboard-authoring/operations/card-operations.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +7 -2
- package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +6 -2
- package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/see-records/result.d.ts +7 -22
- package/dist/types/shared/dashboard-authoring/sheet-kinds.d.ts +36 -0
- package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +140 -0
- package/dist/types/shared/dashboard-viewer/table-column-move.d.ts +15 -0
- package/dist/types/shared/dashboard-viewer/table-settings.d.ts +8 -2
- package/dist/types/shared/format-utils/types/format-types.d.ts +1 -1
- package/dist/usage-events/index.js +1 -285
- package/dist/value-format-preferences/index.js +1 -635
- package/package.json +5 -2
- package/dist/chunks/add-to-dashboard-CFF-wFU-.js +0 -291
- package/dist/chunks/analytics-base-schemas-DsUh5Q3C.js +0 -680
- package/dist/chunks/appearance-context-BwBp25ZG.js +0 -162
- package/dist/chunks/appearance-runtime-provider-BRHYELkC.js +0 -80
- package/dist/chunks/applied-constraints-DU-wndZ7.js +0 -47
- package/dist/chunks/assistant-chat-B6hNQI1t.js +0 -6115
- package/dist/chunks/attribution-BvoKvhcj.js +0 -32
- package/dist/chunks/availability-Bp5Gfu1I.js +0 -44
- package/dist/chunks/bookmark-impact-Ba2PLcGp.js +0 -76
- package/dist/chunks/bookmark-state-n7AaNzR_.js +0 -1667
- package/dist/chunks/brand-BoUV0iHF.js +0 -54
- package/dist/chunks/card-filter-builder-Y22HizVx.js +0 -4069
- package/dist/chunks/column-bands-RdM-kjDe.js +0 -47
- package/dist/chunks/comparison-window-caption-Ck2TIbnR.js +0 -741
- package/dist/chunks/context-UCQ7sere.js +0 -369
- package/dist/chunks/conversation-sQiWYUOb.js +0 -16
- package/dist/chunks/dashboard-BghI99oY.js +0 -14
- package/dist/chunks/dashboard-briefing-launcher-DtBAnGiH.js +0 -4875
- package/dist/chunks/dashboard-controls-CtFXlyjV.js +0 -2290
- package/dist/chunks/dashboard-json-DfGBUtCd.js +0 -66
- package/dist/chunks/dates-BnrXF4bb.js +0 -185
- package/dist/chunks/edit-9df1zOWe.js +0 -226
- package/dist/chunks/edit-dashboard-visual-oxt3x1wb.js +0 -18397
- package/dist/chunks/export-file-format-C-tJsxsf.js +0 -111
- package/dist/chunks/filter-line-Cy5YYqRL.js +0 -703
- package/dist/chunks/filter-reach-copy-CE_ZX147.js +0 -5111
- package/dist/chunks/filter-value-text-fWvSDwkl.js +0 -153
- package/dist/chunks/index-BVKzKl5d.js +0 -90
- package/dist/chunks/index-CV_Kzou0.js +0 -595
- package/dist/chunks/index-D5rxbtS4.js +0 -2795
- package/dist/chunks/layout-grid-9LndRoLa.js +0 -16
- package/dist/chunks/matrix-analytical-definition-CCp48UCw.js +0 -1233
- package/dist/chunks/matrix-member-presentation-zNehruXR.js +0 -391
- package/dist/chunks/matrix-operation-contract-DPBj69D8.js +0 -1413
- package/dist/chunks/metric-comparison-B0FR-Q8I.js +0 -600
- package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +0 -119
- package/dist/chunks/paintbrush-58FQYY-y.js +0 -27
- package/dist/chunks/palette-Be62Tkoa.js +0 -23
- package/dist/chunks/pickers-DkqmtnTL.js +0 -2403
- package/dist/chunks/pivot-result-contract-expectations-BYqAmG9n.js +0 -5092
- package/dist/chunks/pivot-result-identity-CAP4--iq.js +0 -77
- package/dist/chunks/raw-temporal-value-Dg_MTFF7.js +0 -3778
- package/dist/chunks/rendered-file-D8xEuVVx.js +0 -108
- package/dist/chunks/report-preferences-dialog-uJp9GBTM.js +0 -1651
- package/dist/chunks/report-runtime-context-c77_KF9v.js +0 -388
- package/dist/chunks/resolve-dashboard-input-context-Rtl1ffmE.js +0 -25324
- package/dist/chunks/resolver-DG_tfEpt.js +0 -156
- package/dist/chunks/save-C5A0JnEV.js +0 -21
- package/dist/chunks/saved-dashboard-context-tcyTU8jm.js +0 -618
- package/dist/chunks/schema-C9NPiIru.js +0 -2568
- package/dist/chunks/selection-filter-compiler-DNijjI5y.js +0 -150
- package/dist/chunks/semaphor-ready-indicator-FBvunj6S.js +0 -145603
- package/dist/chunks/shelf-drop-preview-context-QKStrcK9.js +0 -2466
- package/dist/chunks/stored-dashboard-CHozcAY9.js +0 -4075
- package/dist/chunks/style-sheet-parts-CDCG-8Ej.js +0 -8681
- package/dist/chunks/table-export-sheet-ZFIvs6Sj.js +0 -949
- package/dist/chunks/token-types-XbM6QByy.js +0 -8
- package/dist/chunks/upload-H15d7uHK.js +0 -15
- package/dist/chunks/validators-Baf3VIf5.js +0 -3686
- package/dist/chunks/variable-draft-C2y8Jp6Z.js +0 -242
- package/dist/chunks/visual-choice-DDfHfHvY.js +0 -172
|
@@ -1,1413 +0,0 @@
|
|
|
1
|
-
import { z as t } from "zod";
|
|
2
|
-
import { z as Ue, P as De, X as qe, Y as Me, a0 as Be, a1 as Ge, s as U, L as $, n as ze, V as Ve, W as le, g as We, r as Ke, N as Xe, E as $e, F as Ze, o as ue, b as de, I as Ye } from "./analytics-base-schemas-DsUh5Q3C.js";
|
|
3
|
-
import { B as v, v as me, K as G, b0 as te, m as _, E as He, aV as Z, w as Qe, o as Je, q as pe, a3 as et, p as tt, a6 as nt, a$ as at } from "./validators-Baf3VIf5.js";
|
|
4
|
-
const Y = {
|
|
5
|
-
answerSummary: "string",
|
|
6
|
-
responseDetail: "responseDetail",
|
|
7
|
-
mode: "string",
|
|
8
|
-
comparisonKind: "string",
|
|
9
|
-
comparisonWords: "string",
|
|
10
|
-
executionResult: "executionResult",
|
|
11
|
-
compiledQuery: "unknown",
|
|
12
|
-
data: "unknown",
|
|
13
|
-
resultSets: "record",
|
|
14
|
-
analysisWarnings: "unknownArray",
|
|
15
|
-
columns: "unknownArray",
|
|
16
|
-
records: "recordArray",
|
|
17
|
-
rowCount: "number",
|
|
18
|
-
rowLimitExceeded: "boolean",
|
|
19
|
-
output: "string",
|
|
20
|
-
querySpec: "unknown",
|
|
21
|
-
metadata: "record",
|
|
22
|
-
validation: "validationResult",
|
|
23
|
-
coverage: "coverage",
|
|
24
|
-
diagnosticFeedback: "diagnosticFeedback",
|
|
25
|
-
missingFields: "stringArray",
|
|
26
|
-
warnings: "unknownArray",
|
|
27
|
-
comparison: "unknown",
|
|
28
|
-
population: "population",
|
|
29
|
-
comparisons: "recordArray",
|
|
30
|
-
fieldsUsed: "compactExecutionFieldArray",
|
|
31
|
-
primary: "recordArray",
|
|
32
|
-
contributors: "recordArray",
|
|
33
|
-
segments: "recordArray",
|
|
34
|
-
periodChanges: "recordArray",
|
|
35
|
-
changes: "recordArray",
|
|
36
|
-
largestNegativeChanges: "recordArray",
|
|
37
|
-
largestPositiveChanges: "recordArray",
|
|
38
|
-
drivers: "recordArray",
|
|
39
|
-
absoluteDeltaDrivers: "recordArray",
|
|
40
|
-
largestNegativeDrivers: "recordArray",
|
|
41
|
-
largestPositiveDrivers: "recordArray",
|
|
42
|
-
periodRows: "recordArray",
|
|
43
|
-
sql: "unknown",
|
|
44
|
-
omitted: "stringArray"
|
|
45
|
-
}, he = [
|
|
46
|
-
/** The request can't run as asked (no specific validation code applies). */
|
|
47
|
-
"invalid_request",
|
|
48
|
-
/** No authored relationship connects the requested datasets. */
|
|
49
|
-
"missing_relationship",
|
|
50
|
-
/** More than one relationship path fits and none is preferred. */
|
|
51
|
-
"ambiguous_relationship",
|
|
52
|
-
/** The join would repeat measure rows (fan-out, chasm, unknown cardinality). */
|
|
53
|
-
"unsafe_join",
|
|
54
|
-
/** The request needs something this surface doesn't support yet. */
|
|
55
|
-
"unsupported_capability",
|
|
56
|
-
/** The caller lacks a capability (for example raw SQL). */
|
|
57
|
-
"capability_required",
|
|
58
|
-
"forbidden",
|
|
59
|
-
"not_found",
|
|
60
|
-
/** The warehouse or driver failed while the query ran; the message is its own. */
|
|
61
|
-
"execution_failed",
|
|
62
|
-
"timeout",
|
|
63
|
-
"budget_exceeded",
|
|
64
|
-
"cancelled"
|
|
65
|
-
], rt = {
|
|
66
|
-
invalid_request: 400,
|
|
67
|
-
missing_relationship: 400,
|
|
68
|
-
ambiguous_relationship: 400,
|
|
69
|
-
unsafe_join: 400,
|
|
70
|
-
unsupported_capability: 400,
|
|
71
|
-
capability_required: 403,
|
|
72
|
-
forbidden: 403,
|
|
73
|
-
not_found: 404,
|
|
74
|
-
execution_failed: 502,
|
|
75
|
-
timeout: 504,
|
|
76
|
-
budget_exceeded: 413,
|
|
77
|
-
cancelled: 499
|
|
78
|
-
}, st = /* @__PURE__ */ new Set(["execution_failed", "timeout"]);
|
|
79
|
-
function ot(e) {
|
|
80
|
-
return typeof e == "string" && he.includes(e);
|
|
81
|
-
}
|
|
82
|
-
function it(e, n, a = {}) {
|
|
83
|
-
return {
|
|
84
|
-
code: e,
|
|
85
|
-
message: n,
|
|
86
|
-
...a.details ? { details: a.details } : {},
|
|
87
|
-
...a.nextStep ? { nextStep: a.nextStep } : {},
|
|
88
|
-
retryable: st.has(e),
|
|
89
|
-
status: a.status ?? rt[e]
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
function dn(e) {
|
|
93
|
-
if (!e || typeof e != "object") return;
|
|
94
|
-
const n = e.refusal ?? e;
|
|
95
|
-
if (!n || typeof n != "object") return;
|
|
96
|
-
const { code: a, message: r } = n;
|
|
97
|
-
if (!(!ot(a) || typeof r != "string"))
|
|
98
|
-
return n;
|
|
99
|
-
}
|
|
100
|
-
const ct = {
|
|
101
|
-
invalid_request: { message: "This query configuration cannot run.", nextStep: "Check the selected fields, filters and parameters." },
|
|
102
|
-
missing_relationship: { message: "The selected data is not connected.", nextStep: "Choose related datasets or ask the owner to add a relationship." },
|
|
103
|
-
ambiguous_relationship: { message: "The selected data has more than one relationship path.", nextStep: "Choose the relationship to use." },
|
|
104
|
-
unsafe_join: { message: "This query could count values more than once.", nextStep: "Group by shared fields or query the measures separately." },
|
|
105
|
-
unsupported_capability: { message: "This query needs a capability this view does not support.", nextStep: "Change the query configuration." },
|
|
106
|
-
capability_required: { message: "You do not have access to this capability.", nextStep: "Ask the owner for access." },
|
|
107
|
-
forbidden: { message: "You do not have access to this data.", nextStep: "Ask the owner for access." },
|
|
108
|
-
not_found: { message: "The requested data is no longer available.", nextStep: "Ask the owner to check the data source." },
|
|
109
|
-
execution_failed: { message: "The query could not complete.", nextStep: "Try again. If it keeps failing, contact the owner." },
|
|
110
|
-
timeout: { message: "The query took too long to complete.", nextStep: "Try again or narrow the query." },
|
|
111
|
-
budget_exceeded: { message: "The query exceeds this view’s limits.", nextStep: "Request fewer rows, columns or measures." },
|
|
112
|
-
cancelled: { message: "The query was cancelled.", nextStep: "Reload the view when ready." }
|
|
113
|
-
};
|
|
114
|
-
function mn(e) {
|
|
115
|
-
const n = ct[e.code], a = it(e.code, n.message, { nextStep: n.nextStep, status: e.status }), r = e.retryable ?? a.retryable;
|
|
116
|
-
return {
|
|
117
|
-
...a,
|
|
118
|
-
retryable: r,
|
|
119
|
-
...!r && a.retryable ? { nextStep: "Ask the owner to check the query." } : {}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
const lt = [
|
|
123
|
-
...he,
|
|
124
|
-
"stale_cursor",
|
|
125
|
-
"source_truncated"
|
|
126
|
-
], pn = Object.freeze({
|
|
127
|
-
coordinates: 2e4,
|
|
128
|
-
responseBytes: 5 * 1024 * 1024
|
|
129
|
-
}), P = t.string().uuid(), b = t.string().min(1), ut = t.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
130
|
-
function f(e, n, a) {
|
|
131
|
-
e.addIssue({ code: "custom", path: n, message: a });
|
|
132
|
-
}
|
|
133
|
-
function T(e, n, a) {
|
|
134
|
-
new Set(e).size !== e.length && f(n, a, "Duplicate identity.");
|
|
135
|
-
}
|
|
136
|
-
const dt = t.object({
|
|
137
|
-
id: b,
|
|
138
|
-
axis: me,
|
|
139
|
-
parent: v,
|
|
140
|
-
position: t.union([
|
|
141
|
-
t.object({ kind: t.literal("first") }).strict(),
|
|
142
|
-
t.object({ kind: t.enum(["after", "before"]), cursor: b }).strict()
|
|
143
|
-
]),
|
|
144
|
-
size: ut
|
|
145
|
-
}).strict(), ne = t.object({
|
|
146
|
-
paths: t.array(v).readonly(),
|
|
147
|
-
pageIds: t.array(b).readonly()
|
|
148
|
-
}).strict(), mt = t.object({
|
|
149
|
-
id: b,
|
|
150
|
-
rows: ne,
|
|
151
|
-
columns: ne,
|
|
152
|
-
measureIds: t.array(P).min(1).readonly()
|
|
153
|
-
}).strict(), fe = t.object({
|
|
154
|
-
pages: t.array(dt).readonly(),
|
|
155
|
-
blocks: t.array(mt).readonly()
|
|
156
|
-
}).strict().superRefine((e, n) => {
|
|
157
|
-
!e.pages.length && !e.blocks.length && f(n, [], "Request at least one page or block."), T(
|
|
158
|
-
[...e.pages, ...e.blocks].map((a) => a.id),
|
|
159
|
-
n,
|
|
160
|
-
[]
|
|
161
|
-
);
|
|
162
|
-
for (const a of e.blocks) {
|
|
163
|
-
T(a.measureIds, n, ["blocks", a.id, "measureIds"]);
|
|
164
|
-
for (const r of ["rows", "columns"])
|
|
165
|
-
for (const s of a[r].pageIds)
|
|
166
|
-
e.pages.some(
|
|
167
|
-
(c) => c.id === s && c.axis === r
|
|
168
|
-
) || f(
|
|
169
|
-
n,
|
|
170
|
-
["blocks", a.id, r],
|
|
171
|
-
"Page reference must name a page on this axis in this operation."
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
}), hn = t.object({ spec: G, request: fe }).strict().superRefine(({ spec: e, request: n }, a) => {
|
|
175
|
-
for (const r of n.pages)
|
|
176
|
-
te(
|
|
177
|
-
e,
|
|
178
|
-
r.axis,
|
|
179
|
-
r.parent,
|
|
180
|
-
a,
|
|
181
|
-
["pages", r.id],
|
|
182
|
-
!0
|
|
183
|
-
), r.parent.length >= e[r.axis].length && f(
|
|
184
|
-
a,
|
|
185
|
-
["pages", r.id],
|
|
186
|
-
"Cannot request children of a leaf or empty axis."
|
|
187
|
-
);
|
|
188
|
-
for (const r of n.blocks) {
|
|
189
|
-
r.measureIds.some((s) => !e.measures.some((c) => c.id === s)) && f(a, ["blocks", r.id], "Unknown block measure.");
|
|
190
|
-
for (const s of ["rows", "columns"])
|
|
191
|
-
for (const c of r[s].paths)
|
|
192
|
-
te(e, s, c, a, ["blocks", r.id, s]);
|
|
193
|
-
}
|
|
194
|
-
}), pt = t.object({
|
|
195
|
-
requestId: b,
|
|
196
|
-
axis: me,
|
|
197
|
-
parent: v,
|
|
198
|
-
members: t.array(t.object({ path: v }).strict()).readonly(),
|
|
199
|
-
before: b.nullable(),
|
|
200
|
-
after: b.nullable(),
|
|
201
|
-
exactCount: t.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()
|
|
202
|
-
}).strict().superRefine((e, n) => {
|
|
203
|
-
e.parent.some((r) => r.member.kind === "others") && f(n, ["parent"], "Others has no children.");
|
|
204
|
-
const a = e.members.filter(
|
|
205
|
-
({ path: r }) => {
|
|
206
|
-
var s;
|
|
207
|
-
return ((s = r[r.length - 1]) == null ? void 0 : s.member.kind) === "others";
|
|
208
|
-
}
|
|
209
|
-
);
|
|
210
|
-
a.length > 1 && f(n, ["members"], "A page may contain Others only once."), a.length && (e.members[e.members.length - 1] !== a[0] && f(n, ["members"], "Others must be the last page member."), e.after !== null && f(n, ["after"], "Others must end the branch.")), new Set(
|
|
211
|
-
e.members.map(
|
|
212
|
-
(r) => {
|
|
213
|
-
var s;
|
|
214
|
-
return (s = r.path[r.path.length - 1]) == null ? void 0 : s.levelId;
|
|
215
|
-
}
|
|
216
|
-
)
|
|
217
|
-
).size > 1 && f(n, ["members"], "One page must contain one child level."), T(
|
|
218
|
-
e.members.map((r) => _(r.path)),
|
|
219
|
-
n,
|
|
220
|
-
["members"]
|
|
221
|
-
);
|
|
222
|
-
for (const r of e.members)
|
|
223
|
-
(r.path.length !== e.parent.length + 1 || _(r.path.slice(0, -1)) !== _(e.parent)) && f(n, ["members"], "Page members must be immediate children.");
|
|
224
|
-
}), ge = t.object({
|
|
225
|
-
rowPaths: t.array(v).readonly(),
|
|
226
|
-
columnPaths: t.array(v).readonly(),
|
|
227
|
-
measureIds: t.array(P).readonly()
|
|
228
|
-
}).strict();
|
|
229
|
-
function ye(e, n) {
|
|
230
|
-
const a = e.rowPaths.map(_), r = e.columnPaths.map(_);
|
|
231
|
-
return T(a, n, ["coverage", "rowPaths"]), T(r, n, ["coverage", "columnPaths"]), T(e.measureIds, n, ["coverage", "measureIds"]), { rows: a, columns: r };
|
|
232
|
-
}
|
|
233
|
-
const ht = t.object({
|
|
234
|
-
requestId: b,
|
|
235
|
-
coverage: ge,
|
|
236
|
-
cells: t.array(
|
|
237
|
-
He.extend({ value: Z }).strict()
|
|
238
|
-
).readonly()
|
|
239
|
-
}).strict().superRefine((e, n) => {
|
|
240
|
-
const { rows: a, columns: r } = ye(e.coverage, n), s = new Set(a), c = new Set(r), o = new Set(e.coverage.measureIds);
|
|
241
|
-
T(
|
|
242
|
-
e.cells.map(
|
|
243
|
-
(m) => JSON.stringify([
|
|
244
|
-
_(m.rowPath),
|
|
245
|
-
_(m.columnPath),
|
|
246
|
-
m.measureId
|
|
247
|
-
])
|
|
248
|
-
),
|
|
249
|
-
n,
|
|
250
|
-
["cells"]
|
|
251
|
-
);
|
|
252
|
-
for (const m of e.cells)
|
|
253
|
-
(!s.has(_(m.rowPath)) || !c.has(_(m.columnPath)) || !o.has(m.measureId)) && f(n, ["cells"], "Cell is outside certified coverage.");
|
|
254
|
-
}), D = t.number().int().nonnegative(), ft = t.object({
|
|
255
|
-
requestId: b,
|
|
256
|
-
coverage: ge,
|
|
257
|
-
values: t.array(
|
|
258
|
-
t.tuple([D, D, D, Z]).readonly()
|
|
259
|
-
).readonly()
|
|
260
|
-
}).strict().superRefine((e, n) => {
|
|
261
|
-
ye(e.coverage, n);
|
|
262
|
-
const { rowPaths: a, columnPaths: r, measureIds: s } = e.coverage, c = /* @__PURE__ */ new Set();
|
|
263
|
-
for (const [o, m, d] of e.values) {
|
|
264
|
-
if (o >= a.length || m >= r.length || d >= s.length) {
|
|
265
|
-
f(n, ["values"], "Cell is outside certified coverage.");
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
|
-
const i = `${o},${m},${d}`;
|
|
269
|
-
c.has(i) && f(n, ["values"], "Duplicate identity."), c.add(i);
|
|
270
|
-
}
|
|
271
|
-
}), ae = t.object({
|
|
272
|
-
id: P,
|
|
273
|
-
column: De,
|
|
274
|
-
nativeDataType: b,
|
|
275
|
-
semanticFormat: Ue.optional()
|
|
276
|
-
}).strict(), Se = t.object({
|
|
277
|
-
levels: t.array(ae).readonly(),
|
|
278
|
-
measures: t.array(ae).readonly()
|
|
279
|
-
}).strict(), H = t.object({
|
|
280
|
-
code: t.enum(lt),
|
|
281
|
-
message: b,
|
|
282
|
-
/** Technical cause for dashboard owners; never shown as the primary copy. */
|
|
283
|
-
detail: b.optional(),
|
|
284
|
-
details: t.record(t.unknown()).optional(),
|
|
285
|
-
nextStep: b.optional(),
|
|
286
|
-
status: t.number().int().optional(),
|
|
287
|
-
retryable: t.boolean(),
|
|
288
|
-
scope: t.union([
|
|
289
|
-
t.object({ kind: t.literal("operation") }).strict(),
|
|
290
|
-
t.object({ kind: t.enum(["page", "block"]), requestId: b }).strict()
|
|
291
|
-
])
|
|
292
|
-
}).strict(), gt = t.object({
|
|
293
|
-
dialect: t.enum(["postgres", "clickhouse", "duckdb", "snowflake"]),
|
|
294
|
-
aggregates: t.array(Qe).readonly()
|
|
295
|
-
}).strict();
|
|
296
|
-
function be(e) {
|
|
297
|
-
return t.object({
|
|
298
|
-
queryIdentity: b,
|
|
299
|
-
descriptors: Se,
|
|
300
|
-
capabilities: gt,
|
|
301
|
-
pages: t.array(pt).readonly(),
|
|
302
|
-
blocks: t.array(e).readonly(),
|
|
303
|
-
failures: t.array(H).readonly()
|
|
304
|
-
}).strict().superRefine((n, a) => {
|
|
305
|
-
const r = new Set(
|
|
306
|
-
n.descriptors.levels.map((o) => o.id)
|
|
307
|
-
), s = new Set(
|
|
308
|
-
n.descriptors.measures.map((o) => o.id)
|
|
309
|
-
), c = n.pages.flatMap((o) => [
|
|
310
|
-
o.parent,
|
|
311
|
-
...o.members.map((m) => m.path)
|
|
312
|
-
]);
|
|
313
|
-
for (const o of n.blocks)
|
|
314
|
-
c.push(...o.coverage.rowPaths, ...o.coverage.columnPaths), o.coverage.measureIds.some((m) => !s.has(m)) && f(
|
|
315
|
-
a,
|
|
316
|
-
["blocks", o.requestId],
|
|
317
|
-
"Coverage references an unknown measure descriptor."
|
|
318
|
-
);
|
|
319
|
-
c.some((o) => o.some((m) => !r.has(m.levelId))) && f(
|
|
320
|
-
a,
|
|
321
|
-
["descriptors"],
|
|
322
|
-
"Acquired paths require level descriptors."
|
|
323
|
-
), T(
|
|
324
|
-
[...n.descriptors.levels, ...n.descriptors.measures].map(
|
|
325
|
-
(o) => o.id
|
|
326
|
-
),
|
|
327
|
-
a,
|
|
328
|
-
["descriptors"]
|
|
329
|
-
), T(
|
|
330
|
-
[...n.pages, ...n.blocks].map((o) => o.requestId),
|
|
331
|
-
a,
|
|
332
|
-
[]
|
|
333
|
-
), T(
|
|
334
|
-
n.failures.map(
|
|
335
|
-
(o) => o.scope.kind === "operation" ? "operation" : o.scope.requestId
|
|
336
|
-
),
|
|
337
|
-
a,
|
|
338
|
-
["failures"]
|
|
339
|
-
);
|
|
340
|
-
for (const o of n.failures)
|
|
341
|
-
if (o.scope.kind === "operation")
|
|
342
|
-
f(
|
|
343
|
-
a,
|
|
344
|
-
["failures"],
|
|
345
|
-
"Operation failure cannot accompany acquired data."
|
|
346
|
-
);
|
|
347
|
-
else {
|
|
348
|
-
const m = o.scope.requestId;
|
|
349
|
-
[...n.pages, ...n.blocks].some(
|
|
350
|
-
(d) => d.requestId === m
|
|
351
|
-
) && f(
|
|
352
|
-
a,
|
|
353
|
-
["failures"],
|
|
354
|
-
"A requested unit cannot both succeed and fail."
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
const Ae = be(
|
|
360
|
-
ht
|
|
361
|
-
), yt = be(
|
|
362
|
-
ft
|
|
363
|
-
);
|
|
364
|
-
function Ie(e) {
|
|
365
|
-
return t.union([
|
|
366
|
-
t.object({
|
|
367
|
-
status: t.enum(["success", "partial"]),
|
|
368
|
-
window: e
|
|
369
|
-
}).strict(),
|
|
370
|
-
t.object({ status: t.literal("failed"), failure: H }).strict()
|
|
371
|
-
]).superRefine((n, a) => {
|
|
372
|
-
const r = n;
|
|
373
|
-
if (r.status === "failed") return;
|
|
374
|
-
const { window: s } = r;
|
|
375
|
-
!s.pages.length && !s.blocks.length && f(
|
|
376
|
-
a,
|
|
377
|
-
["window"],
|
|
378
|
-
"A window outcome requires successful acquired work."
|
|
379
|
-
), r.status === "success" != (s.failures.length === 0) && f(a, ["status"], "Status must match failure coverage.");
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
const fn = Ie(
|
|
383
|
-
Ae
|
|
384
|
-
), gn = Ie(
|
|
385
|
-
yt
|
|
386
|
-
);
|
|
387
|
-
function St(e) {
|
|
388
|
-
const { rowPaths: n, columnPaths: a, measureIds: r } = e.coverage, s = (d) => new Map(d.map((i, l) => [i, l])), c = s(n.map(_)), o = s(a.map(_)), m = s(r);
|
|
389
|
-
return {
|
|
390
|
-
requestId: e.requestId,
|
|
391
|
-
coverage: e.coverage,
|
|
392
|
-
values: e.cells.map((d) => {
|
|
393
|
-
const i = c.get(_(d.rowPath)), l = o.get(_(d.columnPath)), p = m.get(d.measureId);
|
|
394
|
-
if (i === void 0 || l === void 0 || p === void 0)
|
|
395
|
-
throw new Error("Cell is outside certified coverage.");
|
|
396
|
-
return [i, l, p, d.value];
|
|
397
|
-
})
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
function bt(e) {
|
|
401
|
-
const { rowPaths: n, columnPaths: a, measureIds: r } = e.coverage;
|
|
402
|
-
return {
|
|
403
|
-
requestId: e.requestId,
|
|
404
|
-
coverage: e.coverage,
|
|
405
|
-
cells: e.values.map(([s, c, o, m]) => ({
|
|
406
|
-
rowPath: n[s],
|
|
407
|
-
columnPath: a[c],
|
|
408
|
-
measureId: r[o],
|
|
409
|
-
value: m
|
|
410
|
-
}))
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
function At(e) {
|
|
414
|
-
return { ...e, blocks: e.blocks.map(St) };
|
|
415
|
-
}
|
|
416
|
-
function yn(e) {
|
|
417
|
-
return { ...e, blocks: e.blocks.map(bt) };
|
|
418
|
-
}
|
|
419
|
-
function Sn(e) {
|
|
420
|
-
return e.status === "failed" ? e : { status: e.status, window: At(e.window) };
|
|
421
|
-
}
|
|
422
|
-
const _e = t.object({
|
|
423
|
-
kind: t.literal("matrix"),
|
|
424
|
-
window: Ae
|
|
425
|
-
}).strict(), we = t.enum(["member", "subtotal", "grand_total"]), It = t.discriminatedUnion("kind", [
|
|
426
|
-
t.object({ kind: t.literal("hierarchy"), label: t.string() }).strict(),
|
|
427
|
-
t.object({ kind: t.literal("level"), levelId: P, label: t.string() }).strict(),
|
|
428
|
-
t.object({
|
|
429
|
-
kind: t.literal("measure"),
|
|
430
|
-
measureId: P,
|
|
431
|
-
columnPath: v,
|
|
432
|
-
role: we,
|
|
433
|
-
label: t.string()
|
|
434
|
-
}).strict()
|
|
435
|
-
]), _t = t.object({
|
|
436
|
-
columns: t.array(It).readonly(),
|
|
437
|
-
descriptors: Se
|
|
438
|
-
}).strict(), re = t.union([
|
|
439
|
-
t.object({
|
|
440
|
-
kind: t.literal("value"),
|
|
441
|
-
value: Z.refine(
|
|
442
|
-
(e) => e !== null
|
|
443
|
-
)
|
|
444
|
-
}).strict(),
|
|
445
|
-
t.object({ kind: t.enum(["null", "empty"]) }).strict()
|
|
446
|
-
]), wt = t.discriminatedUnion("kind", [
|
|
447
|
-
t.object({
|
|
448
|
-
kind: t.literal("layout"),
|
|
449
|
-
rowPath: v,
|
|
450
|
-
role: we,
|
|
451
|
-
values: t.array(re).readonly()
|
|
452
|
-
}).strict(),
|
|
453
|
-
t.object({
|
|
454
|
-
kind: t.literal("flat"),
|
|
455
|
-
rowPath: v,
|
|
456
|
-
columnPath: v,
|
|
457
|
-
values: t.array(re).readonly()
|
|
458
|
-
}).strict()
|
|
459
|
-
]), bn = t.discriminatedUnion("kind", [
|
|
460
|
-
t.object({
|
|
461
|
-
kind: t.literal("layout"),
|
|
462
|
-
layout: _t,
|
|
463
|
-
next: b
|
|
464
|
-
}).strict(),
|
|
465
|
-
t.object({
|
|
466
|
-
kind: t.literal("rows"),
|
|
467
|
-
rows: t.array(wt).readonly(),
|
|
468
|
-
next: b.nullable()
|
|
469
|
-
}).strict()
|
|
470
|
-
]), kt = t.union([
|
|
471
|
-
qe,
|
|
472
|
-
Me,
|
|
473
|
-
Be,
|
|
474
|
-
Ge,
|
|
475
|
-
_e
|
|
476
|
-
]), vt = t.object({
|
|
477
|
-
status: t.enum([
|
|
478
|
-
"not_required",
|
|
479
|
-
"resolved",
|
|
480
|
-
"missing",
|
|
481
|
-
"ambiguous",
|
|
482
|
-
"fanout_risk",
|
|
483
|
-
"unknown"
|
|
484
|
-
]),
|
|
485
|
-
requiredSources: t.array(U).optional(),
|
|
486
|
-
relationshipsUsed: t.array(t.string()).optional(),
|
|
487
|
-
missingSources: t.array(t.string()).optional(),
|
|
488
|
-
warnings: t.array(t.string()).optional(),
|
|
489
|
-
message: t.string().optional(),
|
|
490
|
-
recommendedNextStep: t.string().optional(),
|
|
491
|
-
joinPlanSummary: t.object({
|
|
492
|
-
baseSource: U.optional(),
|
|
493
|
-
joinedSources: t.array(U).optional(),
|
|
494
|
-
joinCount: t.number().optional()
|
|
495
|
-
}).passthrough().optional(),
|
|
496
|
-
fanoutRisk: t.object({
|
|
497
|
-
status: t.enum(["none", "warning", "error", "unknown"]),
|
|
498
|
-
message: t.string().optional()
|
|
499
|
-
}).passthrough().optional()
|
|
500
|
-
}).passthrough(), se = t.enum([
|
|
501
|
-
"ambiguous_fields",
|
|
502
|
-
"empty_result",
|
|
503
|
-
"missing_grounded_fields",
|
|
504
|
-
"missing_relationship",
|
|
505
|
-
"no_grounded_query",
|
|
506
|
-
"partial_result",
|
|
507
|
-
"presentation_incomplete",
|
|
508
|
-
"query_validation_failed",
|
|
509
|
-
"unsafe_join"
|
|
510
|
-
]), ke = t.object({
|
|
511
|
-
version: t.literal(1),
|
|
512
|
-
status: t.enum(["answered", "partial", "blocked"]),
|
|
513
|
-
summary: t.string(),
|
|
514
|
-
answered: t.array(
|
|
515
|
-
t.object({
|
|
516
|
-
slotId: t.string().optional(),
|
|
517
|
-
queryId: t.string().optional(),
|
|
518
|
-
summary: t.string(),
|
|
519
|
-
evidenceIds: t.array(t.string()).optional(),
|
|
520
|
-
fieldsUsed: t.array($).optional()
|
|
521
|
-
}).passthrough()
|
|
522
|
-
),
|
|
523
|
-
blocked: t.array(
|
|
524
|
-
t.object({
|
|
525
|
-
slotId: t.string().optional(),
|
|
526
|
-
queryId: t.string().optional(),
|
|
527
|
-
reasonCode: se,
|
|
528
|
-
message: t.string(),
|
|
529
|
-
missingFields: t.array(t.string()).optional(),
|
|
530
|
-
availableFields: t.array(t.string()).optional(),
|
|
531
|
-
ambiguousFields: t.array(t.string()).optional(),
|
|
532
|
-
missingRelationships: t.array(t.string()).optional(),
|
|
533
|
-
evidenceIds: t.array(t.string()).optional(),
|
|
534
|
-
neededFromUser: t.array(t.string()).optional(),
|
|
535
|
-
recommendedNextStep: t.string().optional()
|
|
536
|
-
}).passthrough()
|
|
537
|
-
),
|
|
538
|
-
semanticModelRecommendations: t.array(
|
|
539
|
-
t.object({
|
|
540
|
-
reasonCode: se,
|
|
541
|
-
message: t.string(),
|
|
542
|
-
recommendedNextStep: t.string().optional()
|
|
543
|
-
}).passthrough()
|
|
544
|
-
).optional()
|
|
545
|
-
}).passthrough(), ve = t.object({
|
|
546
|
-
scope: t.literal("filtered_query"),
|
|
547
|
-
measures: t.record(ze)
|
|
548
|
-
}).passthrough(), Te = t.object({
|
|
549
|
-
answeredObligations: t.array(t.string()),
|
|
550
|
-
missingObligations: t.array(t.string()),
|
|
551
|
-
warnings: t.array(Ve).optional()
|
|
552
|
-
}).passthrough(), Ee = t.object({
|
|
553
|
-
intentId: t.string().optional(),
|
|
554
|
-
queryId: t.string().optional(),
|
|
555
|
-
status: t.enum(["answered", "partial", "failed"]),
|
|
556
|
-
resultShape: t.enum([
|
|
557
|
-
"metric",
|
|
558
|
-
"records",
|
|
559
|
-
"inputOptions",
|
|
560
|
-
"sql",
|
|
561
|
-
"matrix",
|
|
562
|
-
"period_change",
|
|
563
|
-
"analysis"
|
|
564
|
-
]).optional(),
|
|
565
|
-
intent: t.unknown().optional(),
|
|
566
|
-
compiledQuery: t.unknown().optional(),
|
|
567
|
-
fieldsUsed: t.array($).optional(),
|
|
568
|
-
result: kt.optional(),
|
|
569
|
-
validation: le,
|
|
570
|
-
coverage: Te.optional(),
|
|
571
|
-
missingFields: t.array(t.string()).optional(),
|
|
572
|
-
warnings: t.array(t.string()).optional(),
|
|
573
|
-
relationshipDiagnostics: vt.optional(),
|
|
574
|
-
diagnosticFeedback: ke.optional(),
|
|
575
|
-
population: ve.optional(),
|
|
576
|
-
metadata: t.record(t.string(), t.unknown()).optional()
|
|
577
|
-
}).passthrough(), Tt = Ee;
|
|
578
|
-
function Et(e) {
|
|
579
|
-
switch (e) {
|
|
580
|
-
case "boolean":
|
|
581
|
-
return t.boolean().optional();
|
|
582
|
-
case "compactExecutionFieldArray":
|
|
583
|
-
return t.array(Xe).optional();
|
|
584
|
-
case "coverage":
|
|
585
|
-
return Te.optional();
|
|
586
|
-
case "diagnosticFeedback":
|
|
587
|
-
return ke.optional();
|
|
588
|
-
case "executionFieldArray":
|
|
589
|
-
return t.array($).optional();
|
|
590
|
-
case "executionResult":
|
|
591
|
-
return Tt.optional();
|
|
592
|
-
case "number":
|
|
593
|
-
return t.number().finite().optional();
|
|
594
|
-
case "population":
|
|
595
|
-
return ve.optional();
|
|
596
|
-
case "record":
|
|
597
|
-
return Ke.optional();
|
|
598
|
-
case "recordArray":
|
|
599
|
-
return We.optional();
|
|
600
|
-
case "responseDetail":
|
|
601
|
-
return t.enum(["compact", "standard", "debug"]).optional();
|
|
602
|
-
case "string":
|
|
603
|
-
return t.string().optional();
|
|
604
|
-
case "stringArray":
|
|
605
|
-
return t.array(t.string()).optional();
|
|
606
|
-
case "unknown":
|
|
607
|
-
return t.unknown().optional();
|
|
608
|
-
case "unknownArray":
|
|
609
|
-
return t.array(t.unknown()).optional();
|
|
610
|
-
case "validationResult":
|
|
611
|
-
return le.optional();
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
const Rt = Object.fromEntries(
|
|
615
|
-
Object.entries(Y).map(
|
|
616
|
-
([e, n]) => [e, Et(n)]
|
|
617
|
-
)
|
|
618
|
-
), Ct = t.object(Rt).strict(), Nt = new Set(
|
|
619
|
-
Object.keys(Y)
|
|
620
|
-
);
|
|
621
|
-
function An() {
|
|
622
|
-
return Object.keys(
|
|
623
|
-
Y
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
function Ot(e) {
|
|
627
|
-
return Nt.has(e);
|
|
628
|
-
}
|
|
629
|
-
function In(e) {
|
|
630
|
-
if (!e || typeof e != "object" || Array.isArray(e))
|
|
631
|
-
throw new Error("Semaphor analyze result must be an object.");
|
|
632
|
-
const a = Object.keys(e).filter(
|
|
633
|
-
(r) => !Ot(r)
|
|
634
|
-
);
|
|
635
|
-
if (a.length)
|
|
636
|
-
throw new Error(
|
|
637
|
-
`Semaphor analyze result contains unsupported top-level field(s): ${a.join(", ")}.`
|
|
638
|
-
);
|
|
639
|
-
return Ct.parse(e);
|
|
640
|
-
}
|
|
641
|
-
const Re = 100, L = "selection:";
|
|
642
|
-
function Ce(e) {
|
|
643
|
-
return [
|
|
644
|
-
pe(e.source),
|
|
645
|
-
et(e.name),
|
|
646
|
-
e.sourceField ?? ""
|
|
647
|
-
].join("::");
|
|
648
|
-
}
|
|
649
|
-
function _n(e) {
|
|
650
|
-
return `${L}${e}`;
|
|
651
|
-
}
|
|
652
|
-
function xt(e) {
|
|
653
|
-
return e.startsWith(L) && e.length > L.length;
|
|
654
|
-
}
|
|
655
|
-
function wn(e) {
|
|
656
|
-
return xt(e) ? e.slice(L.length) : void 0;
|
|
657
|
-
}
|
|
658
|
-
function Ne(e) {
|
|
659
|
-
if (!e) return "";
|
|
660
|
-
const n = e.calendar.fiscalCalendar;
|
|
661
|
-
return JSON.stringify([
|
|
662
|
-
e.granularity,
|
|
663
|
-
e.calendar.tz,
|
|
664
|
-
e.calendar.weekStart,
|
|
665
|
-
n ? [n.kind, n.yearStartMonth] : null
|
|
666
|
-
]);
|
|
667
|
-
}
|
|
668
|
-
function Oe(e) {
|
|
669
|
-
return e ? JSON.stringify([e.valueKind, e.tz]) : "";
|
|
670
|
-
}
|
|
671
|
-
function Pt(e) {
|
|
672
|
-
return JSON.stringify([
|
|
673
|
-
Ce(e.field),
|
|
674
|
-
e.operator,
|
|
675
|
-
e.operator === "isNull" ? null : e.value,
|
|
676
|
-
Ne(e.temporalBucket),
|
|
677
|
-
Oe(e.rawTemporal)
|
|
678
|
-
]);
|
|
679
|
-
}
|
|
680
|
-
function oe(e) {
|
|
681
|
-
return JSON.stringify(e.conditions.map(Pt).sort());
|
|
682
|
-
}
|
|
683
|
-
function z(e) {
|
|
684
|
-
return JSON.stringify([
|
|
685
|
-
pe(e.field.source),
|
|
686
|
-
e.field.name,
|
|
687
|
-
e.operator,
|
|
688
|
-
e.operator === "isNull" ? null : e.value,
|
|
689
|
-
Ne(e.temporalBucket),
|
|
690
|
-
Oe(e.rawTemporal)
|
|
691
|
-
]);
|
|
692
|
-
}
|
|
693
|
-
function ie(e) {
|
|
694
|
-
return JSON.stringify(
|
|
695
|
-
e.conditions.map(z).sort()
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
-
function kn(e) {
|
|
699
|
-
const n = e.map((a) => a.id);
|
|
700
|
-
if (new Set(n).size !== n.length)
|
|
701
|
-
throw new Error("Data App selections require one active selection per id.");
|
|
702
|
-
return e.map((a) => ({
|
|
703
|
-
...a,
|
|
704
|
-
tuples: a.tuples.map((r) => ({
|
|
705
|
-
...r,
|
|
706
|
-
conditions: [...r.conditions].sort(
|
|
707
|
-
(s, c) => q(
|
|
708
|
-
z(s),
|
|
709
|
-
z(c)
|
|
710
|
-
)
|
|
711
|
-
)
|
|
712
|
-
})).sort(
|
|
713
|
-
(r, s) => q(
|
|
714
|
-
ie(r),
|
|
715
|
-
ie(s)
|
|
716
|
-
)
|
|
717
|
-
)
|
|
718
|
-
})).sort((a, r) => q(a.id, r.id));
|
|
719
|
-
}
|
|
720
|
-
function q(e, n) {
|
|
721
|
-
return e < n ? -1 : e > n ? 1 : 0;
|
|
722
|
-
}
|
|
723
|
-
function vn(e, n) {
|
|
724
|
-
return oe(e) === oe(n);
|
|
725
|
-
}
|
|
726
|
-
const jt = "(Blank)";
|
|
727
|
-
function Tn(e) {
|
|
728
|
-
return e.conditions.map((n) => n.label ? n.label : n.operator === "isNull" || n.value === null ? jt : String(n.value)).join(" · ");
|
|
729
|
-
}
|
|
730
|
-
const Ft = t.union([
|
|
731
|
-
$e,
|
|
732
|
-
Ze
|
|
733
|
-
]), Lt = t.object({
|
|
734
|
-
name: t.string().min(1),
|
|
735
|
-
source: Ft,
|
|
736
|
-
dataType: t.enum(["string", "number", "boolean", "date", "datetime"]),
|
|
737
|
-
sourceField: t.string().min(1).optional(),
|
|
738
|
-
nativeDataType: t.string().min(1).optional()
|
|
739
|
-
}).strict(), Ut = t.object({
|
|
740
|
-
field: Lt,
|
|
741
|
-
operator: t.enum(["=", "isNull"]),
|
|
742
|
-
value: t.union([t.string(), t.number().finite(), t.null()]),
|
|
743
|
-
label: t.string().optional(),
|
|
744
|
-
temporalBucket: de.optional(),
|
|
745
|
-
rawTemporal: ue.optional()
|
|
746
|
-
}).strict().superRefine((e, n) => {
|
|
747
|
-
e.operator === "isNull" != (e.value === null) && n.addIssue({
|
|
748
|
-
code: t.ZodIssueCode.custom,
|
|
749
|
-
message: "isNull carries a null value, and only isNull does.",
|
|
750
|
-
path: ["value"]
|
|
751
|
-
});
|
|
752
|
-
}), Dt = t.object({
|
|
753
|
-
conditions: t.array(Ut).min(1)
|
|
754
|
-
}).strict().superRefine((e, n) => {
|
|
755
|
-
const a = e.conditions.map((r) => Ce(r.field));
|
|
756
|
-
new Set(a).size !== a.length && n.addIssue({
|
|
757
|
-
code: t.ZodIssueCode.custom,
|
|
758
|
-
message: "A tuple holds one condition per field.",
|
|
759
|
-
path: ["conditions"]
|
|
760
|
-
});
|
|
761
|
-
}), En = t.object({
|
|
762
|
-
kind: t.literal("selection"),
|
|
763
|
-
sourceCardId: t.string().min(1),
|
|
764
|
-
tuples: t.array(Dt).min(1).max(Re)
|
|
765
|
-
}).strict(), qt = t.object({
|
|
766
|
-
field: Ye,
|
|
767
|
-
operator: t.enum(["=", "isNull"]),
|
|
768
|
-
value: t.union([t.string(), t.number().finite(), t.null()]),
|
|
769
|
-
temporalBucket: de.optional(),
|
|
770
|
-
rawTemporal: ue.optional()
|
|
771
|
-
}).strict().superRefine((e, n) => {
|
|
772
|
-
e.operator === "isNull" != (e.value === null) && n.addIssue({
|
|
773
|
-
code: t.ZodIssueCode.custom,
|
|
774
|
-
message: "isNull carries a null value, and only isNull does.",
|
|
775
|
-
path: ["value"]
|
|
776
|
-
});
|
|
777
|
-
}), Mt = t.object({
|
|
778
|
-
conditions: t.array(qt).min(1)
|
|
779
|
-
}).strict().superRefine((e, n) => {
|
|
780
|
-
for (let a = 0; a < e.conditions.length; a += 1) {
|
|
781
|
-
const r = e.conditions[a];
|
|
782
|
-
e.conditions.findIndex(
|
|
783
|
-
(c, o) => o < a && Je(c.field, r.field)
|
|
784
|
-
) !== -1 && n.addIssue({
|
|
785
|
-
code: t.ZodIssueCode.custom,
|
|
786
|
-
message: "A selection tuple can contain only one condition per field.",
|
|
787
|
-
path: ["conditions", a, "field"]
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
}), Rn = t.object({
|
|
791
|
-
id: t.string().min(1),
|
|
792
|
-
tuples: t.array(Mt).min(1).max(Re)
|
|
793
|
-
}).strict(), xe = {
|
|
794
|
-
COUNT: "count",
|
|
795
|
-
COUNTIF: "count",
|
|
796
|
-
COUNT_IF: "count",
|
|
797
|
-
COUNTIFS: "count",
|
|
798
|
-
SUM: "sum",
|
|
799
|
-
SUM_IF: "sum",
|
|
800
|
-
SUMIF: "sum",
|
|
801
|
-
AVG: "avg",
|
|
802
|
-
AVG_IF: "avg",
|
|
803
|
-
AVERAGE: "avg",
|
|
804
|
-
MEAN: "avg",
|
|
805
|
-
MIN: "min",
|
|
806
|
-
MIN_IF: "min",
|
|
807
|
-
MAX: "max",
|
|
808
|
-
MAX_IF: "max",
|
|
809
|
-
MEDIAN: "median",
|
|
810
|
-
DISTINCT: "count_distinct",
|
|
811
|
-
COUNT_DISTINCT: "count_distinct",
|
|
812
|
-
APPROX_COUNT_DISTINCT: "count_distinct",
|
|
813
|
-
APPROX_DISTINCT: "count_distinct",
|
|
814
|
-
NDV: "count_distinct",
|
|
815
|
-
UNIQ: "count_distinct",
|
|
816
|
-
UNIQEXACT: "count_distinct",
|
|
817
|
-
UNIQCOMBINED: "count_distinct",
|
|
818
|
-
UNIQHLL12: "count_distinct",
|
|
819
|
-
HLL_COUNT: "count_distinct",
|
|
820
|
-
HLL_ESTIMATE: "count_distinct",
|
|
821
|
-
BOOL_AND: "repeat_safe_other",
|
|
822
|
-
BOOL_OR: "repeat_safe_other",
|
|
823
|
-
BIT_AND: "repeat_safe_other",
|
|
824
|
-
BIT_OR: "repeat_safe_other",
|
|
825
|
-
EVERY: "repeat_safe_other",
|
|
826
|
-
ANY_VALUE: "repeat_safe_other",
|
|
827
|
-
MODE: "other",
|
|
828
|
-
// Ordered-set percentiles; PostgreSQL's MEDIAN is PERCENTILE_CONT(0.5).
|
|
829
|
-
PERCENTILE_CONT: "other",
|
|
830
|
-
PERCENTILE_DISC: "other",
|
|
831
|
-
APPROX_QUANTILES: "other",
|
|
832
|
-
APPROX_QUANTILE: "other",
|
|
833
|
-
APPROX_TOP_COUNT: "other",
|
|
834
|
-
APPROX_TOP_SUM: "other",
|
|
835
|
-
STDDEV: "other",
|
|
836
|
-
STDDEV_POP: "other",
|
|
837
|
-
STDDEV_SAMP: "other",
|
|
838
|
-
VARIANCE: "other",
|
|
839
|
-
VAR_POP: "other",
|
|
840
|
-
VAR_SAMP: "other",
|
|
841
|
-
BIT_XOR: "other",
|
|
842
|
-
CORR: "other",
|
|
843
|
-
COVAR_POP: "other",
|
|
844
|
-
COVAR_SAMP: "other",
|
|
845
|
-
STRING_AGG: "other",
|
|
846
|
-
ARRAY_AGG: "other",
|
|
847
|
-
JSON_AGG: "other",
|
|
848
|
-
JSONB_AGG: "other",
|
|
849
|
-
OBJECT_AGG: "other",
|
|
850
|
-
MAP_AGG: "other",
|
|
851
|
-
LISTAGG: "other",
|
|
852
|
-
GROUP_CONCAT: "other",
|
|
853
|
-
COLLECT_LIST: "other",
|
|
854
|
-
COLLECT_SET: "other",
|
|
855
|
-
FIRST: "other",
|
|
856
|
-
LAST: "other"
|
|
857
|
-
}, Bt = /(?:_AGG$|^APPROX_[A-Z0-9_]+$|^COUNT_DISTINCT$|^HLL_(?:COUNT|ESTIMATE)$|^REGR_[A-Z_]+$)/;
|
|
858
|
-
function Gt(e) {
|
|
859
|
-
const n = e.toUpperCase();
|
|
860
|
-
return n in xe || Bt.test(n);
|
|
861
|
-
}
|
|
862
|
-
function Pe(e, n = !1) {
|
|
863
|
-
const a = xe[e.toUpperCase()] ?? "other";
|
|
864
|
-
return n ? a === "count" || a === "count_distinct" ? "count_distinct" : a === "min" || a === "max" ? a : "repeat_safe_other" : a;
|
|
865
|
-
}
|
|
866
|
-
const zt = /* @__PURE__ */ new Set([
|
|
867
|
-
"NULLIF",
|
|
868
|
-
"COALESCE",
|
|
869
|
-
"IFNULL",
|
|
870
|
-
"ISNULL",
|
|
871
|
-
"ROUND",
|
|
872
|
-
"FLOOR",
|
|
873
|
-
"CEIL",
|
|
874
|
-
"CEILING",
|
|
875
|
-
"ABS",
|
|
876
|
-
"POWER",
|
|
877
|
-
"SQRT",
|
|
878
|
-
"CAST",
|
|
879
|
-
"TRY_CAST",
|
|
880
|
-
"SAFE_CAST"
|
|
881
|
-
]), Vt = /* @__PURE__ */ new Set(["DECIMAL", "NUMERIC", "INTEGER", "INT", "BIGINT", "FLOAT", "DOUBLE", "REAL", "VARCHAR", "TEXT"]), ce = /[A-Za-z_]/, Wt = /[A-Za-z0-9_]/;
|
|
882
|
-
function V(e, n) {
|
|
883
|
-
const a = e[n];
|
|
884
|
-
let r = n + 1;
|
|
885
|
-
for (; r < e.length; ) {
|
|
886
|
-
if (e[r] === a) {
|
|
887
|
-
if (e[r + 1] === a) {
|
|
888
|
-
r += 2;
|
|
889
|
-
continue;
|
|
890
|
-
}
|
|
891
|
-
return r + 1;
|
|
892
|
-
}
|
|
893
|
-
r += 1;
|
|
894
|
-
}
|
|
895
|
-
return r;
|
|
896
|
-
}
|
|
897
|
-
function x(e, n) {
|
|
898
|
-
let a = 0, r = n;
|
|
899
|
-
for (; r < e.length; ) {
|
|
900
|
-
const s = e[r];
|
|
901
|
-
if (s === "'" || s === '"') {
|
|
902
|
-
r = V(e, r);
|
|
903
|
-
continue;
|
|
904
|
-
}
|
|
905
|
-
if (s === "(" && (a += 1), s === ")" && (a -= 1, a === 0))
|
|
906
|
-
return r + 1;
|
|
907
|
-
r += 1;
|
|
908
|
-
}
|
|
909
|
-
return e.length;
|
|
910
|
-
}
|
|
911
|
-
function F(e, n) {
|
|
912
|
-
let a = n;
|
|
913
|
-
for (; a < e.length && /\s/.test(e[a]); ) a += 1;
|
|
914
|
-
return a;
|
|
915
|
-
}
|
|
916
|
-
function M(e, n) {
|
|
917
|
-
let a = n + 1;
|
|
918
|
-
for (; a < e.length && Wt.test(e[a]); ) a += 1;
|
|
919
|
-
return a;
|
|
920
|
-
}
|
|
921
|
-
const Kt = /\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
922
|
-
function Xt(e) {
|
|
923
|
-
return Array.from(e.matchAll(Kt), (n) => n[1]);
|
|
924
|
-
}
|
|
925
|
-
function W(e, n = /* @__PURE__ */ new Set()) {
|
|
926
|
-
const a = [], r = [], s = [];
|
|
927
|
-
let c = !1, o = "", m = !0, d = 0;
|
|
928
|
-
for (; d < e.length; ) {
|
|
929
|
-
const i = e[d];
|
|
930
|
-
if (i === "'" || i === '"') {
|
|
931
|
-
const l = V(e, d);
|
|
932
|
-
o += "'s'", i !== "'" && (m = !1), d = l;
|
|
933
|
-
continue;
|
|
934
|
-
}
|
|
935
|
-
if (i === "{") {
|
|
936
|
-
const l = e.indexOf("}", d);
|
|
937
|
-
if (l > d) {
|
|
938
|
-
const p = e.slice(d + 1, l);
|
|
939
|
-
r.push(p), n.has(p) || (m = !1), o += `#${p}`, d = l + 1;
|
|
940
|
-
continue;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
if (ce.test(i)) {
|
|
944
|
-
const l = M(e, d), p = e.slice(d, l), y = F(e, l);
|
|
945
|
-
if (e[y] === "(" && Gt(p)) {
|
|
946
|
-
let g = x(e, y);
|
|
947
|
-
const j = g - 1;
|
|
948
|
-
let E = g;
|
|
949
|
-
const R = e.slice(y + 1, g - 1);
|
|
950
|
-
let O = R.trim() ? 1 : 0;
|
|
951
|
-
for (let S = y + 1; S < E - 1; S++)
|
|
952
|
-
e[S] === "'" || e[S] === '"' ? S = V(e, S) - 1 : e[S] === "(" ? S = x(e, S) - 1 : e[S] === "," && O++;
|
|
953
|
-
const A = /^\s*DISTINCT\b/i.test(R);
|
|
954
|
-
W(A ? R.replace(/^\s*DISTINCT\b/i, "") : R).calls.length > 0 && (c = !0);
|
|
955
|
-
let k = !1, w = !1;
|
|
956
|
-
const C = [];
|
|
957
|
-
for (; ; ) {
|
|
958
|
-
const S = F(e, g);
|
|
959
|
-
if (!ce.test(e[S] || "")) break;
|
|
960
|
-
const u = M(e, S), h = e.slice(S, u).toUpperCase(), I = F(e, u);
|
|
961
|
-
if (h === "WITHIN") {
|
|
962
|
-
const N = M(e, I), ee = F(e, N);
|
|
963
|
-
if (e.slice(I, N).toUpperCase() === "GROUP" && e[ee] === "(") {
|
|
964
|
-
g = x(e, ee), E = g;
|
|
965
|
-
continue;
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
if ((h === "FILTER" || h === "OVER") && e[I] === "(") {
|
|
969
|
-
k = k || h === "OVER", w = w || h === "FILTER", g = x(e, I), C.push({ kind: h === "OVER" ? "over" : "filter", start: I + 1, end: g - 1 });
|
|
970
|
-
continue;
|
|
971
|
-
}
|
|
972
|
-
break;
|
|
973
|
-
}
|
|
974
|
-
a.push({
|
|
975
|
-
name: p.toUpperCase(),
|
|
976
|
-
kind: Pe(p, A),
|
|
977
|
-
distinct: A,
|
|
978
|
-
windowed: k,
|
|
979
|
-
tokens: Xt(e.slice(y, g)),
|
|
980
|
-
span: { start: d, end: E, argumentStart: y + 1, argumentEnd: j },
|
|
981
|
-
argumentCount: O,
|
|
982
|
-
filtered: w,
|
|
983
|
-
suffixes: C
|
|
984
|
-
}), o += `@${a.length - 1}`, d = g;
|
|
985
|
-
continue;
|
|
986
|
-
}
|
|
987
|
-
p.toUpperCase() === "OVER" && e[y] === "(" && s.push({ start: y + 1, end: x(e, y) - 1 }), o += e.slice(d, l), d = l;
|
|
988
|
-
continue;
|
|
989
|
-
}
|
|
990
|
-
/[\s0-9.,()+*/%<>=!|&^-]/.test(i) || (m = !1), o += i, d += 1;
|
|
991
|
-
}
|
|
992
|
-
return {
|
|
993
|
-
calls: a,
|
|
994
|
-
nestedAggregate: c,
|
|
995
|
-
windowed: a.some((i) => i.windowed),
|
|
996
|
-
tokensOutsideAggregates: r,
|
|
997
|
-
windowClauses: s,
|
|
998
|
-
aggregateInputsComplete: m && $t(o, n),
|
|
999
|
-
skeleton: o
|
|
1000
|
-
};
|
|
1001
|
-
}
|
|
1002
|
-
function $t(e, n) {
|
|
1003
|
-
var d;
|
|
1004
|
-
const a = [];
|
|
1005
|
-
let r = 0;
|
|
1006
|
-
for (; r < e.length; ) {
|
|
1007
|
-
const i = e.slice(r), l = (d = /^(\s+|@\d+|#field_\d+|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|'s'|[A-Za-z_][A-Za-z0-9_]*|<>|!=|<=|>=|[()+*/%,<>=-])/.exec(i)) == null ? void 0 : d[0];
|
|
1008
|
-
if (!l) return !1;
|
|
1009
|
-
if (r += l.length, l.startsWith("#")) {
|
|
1010
|
-
if (!n.has(l.slice(1))) return !1;
|
|
1011
|
-
a.push("@input");
|
|
1012
|
-
} else l.trim() && a.push(l.toUpperCase());
|
|
1013
|
-
}
|
|
1014
|
-
let s = 0;
|
|
1015
|
-
const c = (i) => a[s] === i && ++s > 0, o = () => {
|
|
1016
|
-
if (!m()) return !1;
|
|
1017
|
-
for (; ["+", "-", "*", "/", "%", "<", ">", "<=", ">=", "=", "<>", "!=", "AND", "OR", "IS"].includes(a[s]); )
|
|
1018
|
-
if (a[s++] === "IS" && c("NOT"), !m()) return !1;
|
|
1019
|
-
return !0;
|
|
1020
|
-
}, m = () => {
|
|
1021
|
-
const i = a[s];
|
|
1022
|
-
if (!i) return !1;
|
|
1023
|
-
if (["+", "-", "NOT"].includes(i))
|
|
1024
|
-
return s++, m();
|
|
1025
|
-
if (c("(")) return o() && c(")");
|
|
1026
|
-
if (c("CASE")) {
|
|
1027
|
-
if (a[s] !== "WHEN" && !o()) return !1;
|
|
1028
|
-
let l = 0;
|
|
1029
|
-
for (; c("WHEN"); ) {
|
|
1030
|
-
if (!o() || !c("THEN") || !o()) return !1;
|
|
1031
|
-
l++;
|
|
1032
|
-
}
|
|
1033
|
-
return c("ELSE") && !o() ? !1 : l > 0 && c("END");
|
|
1034
|
-
}
|
|
1035
|
-
if (i.startsWith("@") || i === "'S'" || ["NULL", "TRUE", "FALSE"].includes(i) || /^[0-9.]/.test(i))
|
|
1036
|
-
return s++, !0;
|
|
1037
|
-
if (!zt.has(i) || (s++, !c("(") || !o())) return !1;
|
|
1038
|
-
if (["CAST", "TRY_CAST", "SAFE_CAST"].includes(i)) {
|
|
1039
|
-
if (!c("AS") || !Vt.has(a[s++]) || (c("PRECISION"), c("(") && (!/^\d+$/.test(a[s++] || "") || c(",") && !/^\d+$/.test(a[s++] || "") || !c(")"))))
|
|
1040
|
-
return !1;
|
|
1041
|
-
} else
|
|
1042
|
-
for (; c(","); ) if (!o()) return !1;
|
|
1043
|
-
return c(")");
|
|
1044
|
-
};
|
|
1045
|
-
return o() && s === a.length;
|
|
1046
|
-
}
|
|
1047
|
-
function Cn(e, n) {
|
|
1048
|
-
if (n.argumentCount !== 1 || n.windowed || n.filtered) return;
|
|
1049
|
-
const a = e.slice(n.span.argumentStart, n.span.argumentEnd).trim();
|
|
1050
|
-
return n.distinct ? a.replace(/^DISTINCT\s*/i, "") : a;
|
|
1051
|
-
}
|
|
1052
|
-
function Zt(e) {
|
|
1053
|
-
const n = [];
|
|
1054
|
-
let a = 0;
|
|
1055
|
-
for (; a < e.length; ) {
|
|
1056
|
-
const r = e[a];
|
|
1057
|
-
if (/\s/.test(r)) {
|
|
1058
|
-
a += 1;
|
|
1059
|
-
continue;
|
|
1060
|
-
}
|
|
1061
|
-
if (r === "@") {
|
|
1062
|
-
const s = /^@(\d+)/.exec(e.slice(a));
|
|
1063
|
-
n.push({ type: "unit", unit: { kind: "call", index: Number(s[1]) } }), a += s[0].length;
|
|
1064
|
-
continue;
|
|
1065
|
-
}
|
|
1066
|
-
if (r === "#") {
|
|
1067
|
-
const s = /^#([A-Za-z_][A-Za-z0-9_]*)/.exec(e.slice(a));
|
|
1068
|
-
if (s) {
|
|
1069
|
-
n.push({ type: "unit", unit: { kind: "token", token: s[1] } }), a += s[0].length;
|
|
1070
|
-
continue;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
if (/[0-9.]/.test(r)) {
|
|
1074
|
-
const s = /^[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?/.exec(e.slice(a));
|
|
1075
|
-
if (s) {
|
|
1076
|
-
n.push({ type: "number" }), a += s[0].length;
|
|
1077
|
-
continue;
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
if (r === "+" || r === "-" || r === "*" || r === "/") {
|
|
1081
|
-
n.push({ type: "op", value: r }), a += 1;
|
|
1082
|
-
continue;
|
|
1083
|
-
}
|
|
1084
|
-
if (r === "(") {
|
|
1085
|
-
n.push({ type: "open" }), a += 1;
|
|
1086
|
-
continue;
|
|
1087
|
-
}
|
|
1088
|
-
if (r === ")") {
|
|
1089
|
-
n.push({ type: "close" }), a += 1;
|
|
1090
|
-
continue;
|
|
1091
|
-
}
|
|
1092
|
-
n.push({ type: "other" }), a += 1;
|
|
1093
|
-
}
|
|
1094
|
-
return n;
|
|
1095
|
-
}
|
|
1096
|
-
function Yt(e) {
|
|
1097
|
-
const n = Zt(e), a = n.some((i) => i.type === "op" && i.value === "/");
|
|
1098
|
-
if (n.some((i) => i.type === "other"))
|
|
1099
|
-
return { kind: "other", hasDivision: a };
|
|
1100
|
-
let r = 0, s = !0;
|
|
1101
|
-
const c = () => {
|
|
1102
|
-
let i = [], l, p = !0;
|
|
1103
|
-
for (; ; ) {
|
|
1104
|
-
if (!p) {
|
|
1105
|
-
const g = n[r];
|
|
1106
|
-
if (!(g && g.type === "op" && (g.value === "+" || g.value === "-"))) break;
|
|
1107
|
-
r += 1;
|
|
1108
|
-
}
|
|
1109
|
-
const y = o();
|
|
1110
|
-
if (!y) return null;
|
|
1111
|
-
l === void 0 ? l = y.degree : l !== y.degree && (s = !1), i = i.concat(y.units), p = !1;
|
|
1112
|
-
}
|
|
1113
|
-
return { degree: l ?? 0, units: i };
|
|
1114
|
-
}, o = () => {
|
|
1115
|
-
let i = m();
|
|
1116
|
-
if (!i) return null;
|
|
1117
|
-
for (; ; ) {
|
|
1118
|
-
const l = n[r];
|
|
1119
|
-
if (!(l && l.type === "op" && (l.value === "*" || l.value === "/"))) break;
|
|
1120
|
-
r += 1;
|
|
1121
|
-
const p = m();
|
|
1122
|
-
if (!p) return null;
|
|
1123
|
-
l.value === "/" && p.degree > 0 && (s = !1), i.degree + p.degree > 1 && (s = !1), i = { degree: i.degree + p.degree, units: i.units.concat(p.units) };
|
|
1124
|
-
}
|
|
1125
|
-
return i;
|
|
1126
|
-
}, m = () => {
|
|
1127
|
-
var l;
|
|
1128
|
-
const i = n[r];
|
|
1129
|
-
if (!i) return null;
|
|
1130
|
-
if (i.type === "op" && i.value === "-")
|
|
1131
|
-
return r += 1, m();
|
|
1132
|
-
if (i.type === "unit")
|
|
1133
|
-
return r += 1, { degree: 1, units: [i.unit] };
|
|
1134
|
-
if (i.type === "number")
|
|
1135
|
-
return r += 1, { degree: 0, units: [] };
|
|
1136
|
-
if (i.type === "open") {
|
|
1137
|
-
r += 1;
|
|
1138
|
-
const p = c();
|
|
1139
|
-
return !p || ((l = n[r]) == null ? void 0 : l.type) !== "close" ? null : (r += 1, p);
|
|
1140
|
-
}
|
|
1141
|
-
return null;
|
|
1142
|
-
}, d = c();
|
|
1143
|
-
return !d || r !== n.length ? { kind: "other", hasDivision: a } : d.units.length === 1 && d.degree === 1 && s && !a && n.filter((l) => l.type !== "open" && l.type !== "close").length === 1 ? { kind: "single", unit: d.units[0] } : s && d.degree === 1 ? { kind: "linear", units: d.units } : { kind: "other", hasDivision: a };
|
|
1144
|
-
}
|
|
1145
|
-
const Ht = t.object({ key: t.string().min(1), nativeText: t.string().nullable() }).strict(), Qt = t.object({
|
|
1146
|
-
executionInstant: t.string().refine((e) => tt(e) !== null, {
|
|
1147
|
-
message: "executionInstant must be an ISO instant"
|
|
1148
|
-
}),
|
|
1149
|
-
dataAnchors: t.array(Ht).default([])
|
|
1150
|
-
}).strict().refine(
|
|
1151
|
-
(e) => new Set(e.dataAnchors.map((n) => n.key)).size === e.dataAnchors.length,
|
|
1152
|
-
{ message: "dataAnchors keys must be unique", path: ["dataAnchors"] }
|
|
1153
|
-
);
|
|
1154
|
-
function Nn(e) {
|
|
1155
|
-
if (e == null) return;
|
|
1156
|
-
const n = Qt.safeParse(e);
|
|
1157
|
-
return n.success ? n.data : void 0;
|
|
1158
|
-
}
|
|
1159
|
-
const je = /* @__PURE__ */ new Set([
|
|
1160
|
-
"min",
|
|
1161
|
-
"max",
|
|
1162
|
-
"count_distinct",
|
|
1163
|
-
"repeat_safe_other"
|
|
1164
|
-
]);
|
|
1165
|
-
function K(e) {
|
|
1166
|
-
if (!(!e || !e.trim()))
|
|
1167
|
-
return Pe(e);
|
|
1168
|
-
}
|
|
1169
|
-
function Fe(e) {
|
|
1170
|
-
switch (e) {
|
|
1171
|
-
case "count":
|
|
1172
|
-
case "sum":
|
|
1173
|
-
return { kind: "additive" };
|
|
1174
|
-
case "avg":
|
|
1175
|
-
return { kind: "decomposable_avg" };
|
|
1176
|
-
case "min":
|
|
1177
|
-
case "max":
|
|
1178
|
-
return { kind: "idempotent", fn: e };
|
|
1179
|
-
case "count_distinct":
|
|
1180
|
-
return { kind: "none", reason: "distinct" };
|
|
1181
|
-
case "median":
|
|
1182
|
-
return { kind: "none", reason: "median" };
|
|
1183
|
-
default:
|
|
1184
|
-
return { kind: "none", reason: "other" };
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
function Jt(e) {
|
|
1188
|
-
var n, a;
|
|
1189
|
-
return ((n = e.derivedField) == null ? void 0 : n.computeStage) || ((a = e.calculatedFormula) == null ? void 0 : a.computeStage);
|
|
1190
|
-
}
|
|
1191
|
-
const Q = {
|
|
1192
|
-
stage: "aggregate",
|
|
1193
|
-
calls: [],
|
|
1194
|
-
windowed: !1,
|
|
1195
|
-
repeatSafe: !1,
|
|
1196
|
-
reaggregation: { kind: "none", reason: "unresolved" },
|
|
1197
|
-
outputType: "numeric",
|
|
1198
|
-
identity: "unresolved",
|
|
1199
|
-
unresolved: !0
|
|
1200
|
-
}, Le = { ...Q, stage: "row" };
|
|
1201
|
-
function X(e) {
|
|
1202
|
-
return {
|
|
1203
|
-
stage: "row",
|
|
1204
|
-
outer: e,
|
|
1205
|
-
calls: [{ kind: e, distinct: e === "count_distinct" }],
|
|
1206
|
-
windowed: !1,
|
|
1207
|
-
repeatSafe: je.has(e),
|
|
1208
|
-
reaggregation: Fe(e),
|
|
1209
|
-
outputType: e === "min" || e === "max" ? "input" : "numeric",
|
|
1210
|
-
identity: e,
|
|
1211
|
-
unresolved: !1
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
1214
|
-
function B(e, n) {
|
|
1215
|
-
var r;
|
|
1216
|
-
const a = (r = n.derivedField) == null ? void 0 : r.aggregationBehavior;
|
|
1217
|
-
return !a || e.unresolved ? e : a === "additive" ? e.reaggregation.kind === "additive" ? e : { ...e, reaggregation: { kind: "additive" } } : { ...e, reaggregation: { kind: "none", reason: "declared" } };
|
|
1218
|
-
}
|
|
1219
|
-
function en(e, n) {
|
|
1220
|
-
if (!e) return Q;
|
|
1221
|
-
if (typeof e.expression == "string" && e.expression.trim()) {
|
|
1222
|
-
const r = J(e, n + 1);
|
|
1223
|
-
return r === "row_input" ? "raw" : r.unresolved || r.stage === "aggregate" || r.outer ? r : "raw";
|
|
1224
|
-
}
|
|
1225
|
-
const a = K(e.aggregate);
|
|
1226
|
-
return a ? X(a) : "raw";
|
|
1227
|
-
}
|
|
1228
|
-
const tn = 12;
|
|
1229
|
-
function J(e, n) {
|
|
1230
|
-
var S;
|
|
1231
|
-
if (n > tn) return Q;
|
|
1232
|
-
const a = typeof e.expression == "string" ? e.expression.trim() : "";
|
|
1233
|
-
if (!a)
|
|
1234
|
-
return B(
|
|
1235
|
-
X(K(e.aggregate) ?? "sum"),
|
|
1236
|
-
e
|
|
1237
|
-
);
|
|
1238
|
-
const r = W(a), s = ((S = e.calculatedFormula) == null ? void 0 : S.inputFields) || [], c = (u) => {
|
|
1239
|
-
const h = /^field_(\d+)$/.exec(u);
|
|
1240
|
-
return h ? s[Number(h[1])] : void 0;
|
|
1241
|
-
}, o = /* @__PURE__ */ new Map();
|
|
1242
|
-
for (const u of r.tokensOutsideAggregates)
|
|
1243
|
-
o.has(u) || o.set(u, en(c(u), n));
|
|
1244
|
-
const m = r.calls.some(
|
|
1245
|
-
(u) => u.tokens.some((h) => {
|
|
1246
|
-
const I = c(h);
|
|
1247
|
-
if (!(I != null && I.expression)) return !1;
|
|
1248
|
-
const N = J(I, n + 1);
|
|
1249
|
-
return N !== "row_input" && (N.unresolved || N.stage === "aggregate");
|
|
1250
|
-
})
|
|
1251
|
-
), d = Array.from(o.values()).filter(
|
|
1252
|
-
(u) => u !== "raw"
|
|
1253
|
-
), i = Array.from(o.values()).some((u) => u === "raw"), l = r.calls.length > 0 || d.length > 0 || Jt(e) === "aggregate" || !!e.isPreAggregated, p = new Set(
|
|
1254
|
-
[...o].filter(
|
|
1255
|
-
([u, h]) => h === "raw" ? !l && !!c(u) : !h.unresolved
|
|
1256
|
-
).map(([u]) => u)
|
|
1257
|
-
), y = W(a, p).aggregateInputsComplete;
|
|
1258
|
-
if (!l) {
|
|
1259
|
-
if (!y) return Le;
|
|
1260
|
-
const u = K(e.aggregate);
|
|
1261
|
-
return u ? B(X(u), e) : "row_input";
|
|
1262
|
-
}
|
|
1263
|
-
const g = !y || i || r.nestedAggregate || m || d.some((u) => u.unresolved) || r.calls.length === 0 && d.length === 0, j = [
|
|
1264
|
-
...r.calls.map((u) => ({ kind: u.kind, distinct: u.distinct })),
|
|
1265
|
-
...d.flatMap((u) => u.calls)
|
|
1266
|
-
], E = r.windowed || d.some((u) => u.windowed), R = !g && !E && j.every((u) => je.has(u.kind)), O = (u) => {
|
|
1267
|
-
if (u.kind === "call") {
|
|
1268
|
-
const I = r.calls[u.index];
|
|
1269
|
-
return I ? Fe(I.kind) : { kind: "none", reason: "unresolved" };
|
|
1270
|
-
}
|
|
1271
|
-
const h = o.get(u.token);
|
|
1272
|
-
return h && h !== "raw" ? h.reaggregation : { kind: "none", reason: "unresolved" };
|
|
1273
|
-
}, A = Yt(r.skeleton);
|
|
1274
|
-
let k, w, C = "numeric";
|
|
1275
|
-
if (g)
|
|
1276
|
-
k = { kind: "none", reason: "unresolved" }, w = "unresolved";
|
|
1277
|
-
else if (E)
|
|
1278
|
-
k = { kind: "none", reason: "window" }, w = "expression";
|
|
1279
|
-
else if (A.kind === "single")
|
|
1280
|
-
if (k = O(A.unit), A.unit.kind === "call") {
|
|
1281
|
-
const u = r.calls[A.unit.index];
|
|
1282
|
-
w = u.kind, (u.kind === "min" || u.kind === "max") && (C = "input");
|
|
1283
|
-
} else {
|
|
1284
|
-
const u = o.get(A.unit.token);
|
|
1285
|
-
w = u.identity, C = u.outputType;
|
|
1286
|
-
}
|
|
1287
|
-
else A.kind === "linear" ? (k = A.units.every((h) => O(h).kind === "additive") ? { kind: "additive" } : { kind: "none", reason: "other" }, w = "linear") : (k = { kind: "none", reason: A.hasDivision ? "ratio" : "other" }, w = A.hasDivision ? "ratio" : "expression");
|
|
1288
|
-
return B(
|
|
1289
|
-
{
|
|
1290
|
-
stage: "aggregate",
|
|
1291
|
-
calls: j,
|
|
1292
|
-
windowed: E,
|
|
1293
|
-
repeatSafe: R,
|
|
1294
|
-
reaggregation: k,
|
|
1295
|
-
outputType: C,
|
|
1296
|
-
identity: w,
|
|
1297
|
-
unresolved: g
|
|
1298
|
-
},
|
|
1299
|
-
e
|
|
1300
|
-
);
|
|
1301
|
-
}
|
|
1302
|
-
function nn(e) {
|
|
1303
|
-
const n = J(e, 0);
|
|
1304
|
-
return n === "row_input" ? Le : n;
|
|
1305
|
-
}
|
|
1306
|
-
function On(e) {
|
|
1307
|
-
const n = nt((e == null ? void 0 : e.dataType) || "number");
|
|
1308
|
-
if (!e) return n;
|
|
1309
|
-
const a = nn(e);
|
|
1310
|
-
return a.unresolved || a.outputType === "input" ? n : "number";
|
|
1311
|
-
}
|
|
1312
|
-
const an = t.object({
|
|
1313
|
-
intent: at,
|
|
1314
|
-
matrixWindowRequest: fe
|
|
1315
|
-
}).strict(), rn = t.object({
|
|
1316
|
-
runtimeFilters: G.innerType().shape.filters,
|
|
1317
|
-
runtimeSorts: G.innerType().shape.sorts.optional()
|
|
1318
|
-
});
|
|
1319
|
-
function xn(e) {
|
|
1320
|
-
return rn.parse(e);
|
|
1321
|
-
}
|
|
1322
|
-
const sn = {
|
|
1323
|
-
// A window executes a governed statement set, not one compiled query.
|
|
1324
|
-
compiledQuery: t.never().optional(),
|
|
1325
|
-
intent: an.shape.intent,
|
|
1326
|
-
resultShape: t.literal("matrix"),
|
|
1327
|
-
result: _e.optional(),
|
|
1328
|
-
metadata: t.object({ rowLimitExceeded: t.boolean(), matrixFailure: H.optional() }).passthrough()
|
|
1329
|
-
}, on = Ee.extend(sn), Pn = on.superRefine((e, n) => {
|
|
1330
|
-
e.status === "failed" == !!e.result && n.addIssue({ code: "custom", message: "Only answered or partial Matrix execution carries a window." }), e.result && e.status === "partial" != e.result.window.failures.length > 0 && n.addIssue({ code: "custom", message: "Matrix execution status must match acquired window failures." });
|
|
1331
|
-
});
|
|
1332
|
-
export {
|
|
1333
|
-
mt as $,
|
|
1334
|
-
Tn as A,
|
|
1335
|
-
Lt as B,
|
|
1336
|
-
Ut as C,
|
|
1337
|
-
Dt as D,
|
|
1338
|
-
En as E,
|
|
1339
|
-
qt as F,
|
|
1340
|
-
Mt as G,
|
|
1341
|
-
Rn as H,
|
|
1342
|
-
Qt as I,
|
|
1343
|
-
Nn as J,
|
|
1344
|
-
Gt as K,
|
|
1345
|
-
Pe as L,
|
|
1346
|
-
W as M,
|
|
1347
|
-
Cn as N,
|
|
1348
|
-
Yt as O,
|
|
1349
|
-
nn as P,
|
|
1350
|
-
On as Q,
|
|
1351
|
-
he as R,
|
|
1352
|
-
Y as S,
|
|
1353
|
-
ot as T,
|
|
1354
|
-
it as U,
|
|
1355
|
-
dn as V,
|
|
1356
|
-
mn as W,
|
|
1357
|
-
lt as X,
|
|
1358
|
-
pn as Y,
|
|
1359
|
-
dt as Z,
|
|
1360
|
-
ne as _,
|
|
1361
|
-
vt as a,
|
|
1362
|
-
fe as a0,
|
|
1363
|
-
hn as a1,
|
|
1364
|
-
pt as a2,
|
|
1365
|
-
ht as a3,
|
|
1366
|
-
ft as a4,
|
|
1367
|
-
ae as a5,
|
|
1368
|
-
H as a6,
|
|
1369
|
-
gt as a7,
|
|
1370
|
-
Ae as a8,
|
|
1371
|
-
yt as a9,
|
|
1372
|
-
fn as aa,
|
|
1373
|
-
gn as ab,
|
|
1374
|
-
St as ac,
|
|
1375
|
-
bt as ad,
|
|
1376
|
-
At as ae,
|
|
1377
|
-
yn as af,
|
|
1378
|
-
Sn as ag,
|
|
1379
|
-
It as ah,
|
|
1380
|
-
_t as ai,
|
|
1381
|
-
re as aj,
|
|
1382
|
-
wt as ak,
|
|
1383
|
-
bn as al,
|
|
1384
|
-
rn as am,
|
|
1385
|
-
xn as an,
|
|
1386
|
-
Pn as ao,
|
|
1387
|
-
an as ap,
|
|
1388
|
-
ke as b,
|
|
1389
|
-
ve as c,
|
|
1390
|
-
Te as d,
|
|
1391
|
-
Ee as e,
|
|
1392
|
-
Tt as f,
|
|
1393
|
-
An as g,
|
|
1394
|
-
Rt as h,
|
|
1395
|
-
Ot as i,
|
|
1396
|
-
Ct as j,
|
|
1397
|
-
Re as k,
|
|
1398
|
-
Ce as l,
|
|
1399
|
-
_e as m,
|
|
1400
|
-
_n as n,
|
|
1401
|
-
xt as o,
|
|
1402
|
-
In as p,
|
|
1403
|
-
wn as q,
|
|
1404
|
-
Oe as r,
|
|
1405
|
-
kt as s,
|
|
1406
|
-
Ne as t,
|
|
1407
|
-
Pt as u,
|
|
1408
|
-
oe as v,
|
|
1409
|
-
z as w,
|
|
1410
|
-
ie as x,
|
|
1411
|
-
kn as y,
|
|
1412
|
-
vn as z
|
|
1413
|
-
};
|