react-semaphor 0.1.567 → 0.1.569
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/README.md +0 -7
- package/dist/analytics-protocol/index.js +434 -454
- package/dist/assistant-context/index.js +1 -1
- package/dist/brand-studio/index.js +10 -12
- package/dist/briefings/index.js +4 -4
- package/dist/chunks/{_commonjsHelpers-DimLPMtv.js → _commonjsHelpers-Bid1ZNYj.js} +271 -222
- package/dist/chunks/{assistant-chat-D-IuHHwh.js → assistant-chat-Dzf2Mbph.js} +107 -109
- package/dist/chunks/{bookmark-impact-B0estCHn.js → bookmark-impact-Czg6FGt5.js} +2 -2
- package/dist/chunks/{bookmark-state-Du3s13_V.js → bookmark-state-CflS88gq.js} +251 -250
- package/dist/chunks/{card-filter-builder-DbSmzvem.js → card-filter-builder-BS982X7x.js} +1001 -1000
- package/dist/chunks/{code-editor-DJNOsgJH.js → code-editor-BsxHzm9u.js} +43 -45
- package/dist/chunks/{comparison-window-caption-CMLb3mut.js → comparison-window-caption-lLTgzOkM.js} +252 -253
- package/dist/chunks/{dashboard-f8J9DHh5.js → dashboard-BiYSbxZv.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DunvZYsU.js → dashboard-briefing-launcher-Bdj7luOr.js} +119 -120
- package/dist/chunks/{dashboard-controls-B09cN2Dz.js → dashboard-controls-TViDsnb8.js} +17 -19
- package/dist/chunks/dashboard-json-Dg9dQd9U.js +66 -0
- package/dist/chunks/{dates-BsJcyoC_.js → dates-BsPrWZIP.js} +8 -8
- package/dist/chunks/{edit-dashboard-visual-Cwzbpty8.js → edit-dashboard-visual-C6hoIeEJ.js} +20 -21
- package/dist/chunks/{filter-reach-copy-P-kDwUpY.js → filter-reach-copy-hcQ4os0u.js} +862 -852
- package/dist/chunks/filter-value-text-CVxEEDVl.js +146 -0
- package/dist/chunks/{index-BcXw0CpM.js → index-G4q89J6O.js} +74 -76
- package/dist/chunks/{layout-grid-0hIlqEtk.js → layout-grid-BIcoFfdS.js} +1 -1
- package/dist/chunks/{list-filter-DkgoCeBm.js → list-filter-C6tYkHyv.js} +1 -1
- package/dist/chunks/matrix-analytical-definition-dkS8szLM.js +1253 -0
- package/dist/chunks/matrix-member-presentation-DRa-9e6Q.js +169 -0
- package/dist/chunks/{matrix-operation-contract-Eb6elidS.js → matrix-operation-contract-DCVinw1o.js} +122 -122
- package/dist/chunks/{metric-comparison-ChXUFaZu.js → metric-comparison-n9NsIa-2.js} +175 -128
- package/dist/chunks/{palette-4vf2BEEg.js → palette-NjHOE_6B.js} +1 -1
- package/dist/chunks/pivot-result-contract-expectations-DkmueDTW.js +55 -0
- package/dist/chunks/{pivot-result-identity-BlbLrqaC.js → pivot-result-identity-B89X5xjb.js} +1 -1
- package/dist/chunks/raw-temporal-value-DdT0s47W.js +159 -0
- package/dist/chunks/{report-preferences-dialog-CbgmdWeZ.js → report-preferences-dialog-Xc8_GFju.js} +26 -28
- package/dist/chunks/{report-runtime-context-DnA_PiKo.js → report-runtime-context-BhPzLTbS.js} +1 -1
- package/dist/chunks/{resolve-dashboard-input-context-DPKSF3qj.js → resolve-dashboard-input-context-KqvcLcTM.js} +5956 -5880
- package/dist/chunks/{save-D6pHmSSP.js → save-C6VmEJTA.js} +1 -1
- package/dist/chunks/{saved-dashboard-context-CNudmm9U.js → saved-dashboard-context-BeXXyoD4.js} +6 -6
- package/dist/chunks/{semaphor-ready-indicator-CQd-PCCZ.js → semaphor-ready-indicator-BNkaANsG.js} +31011 -30850
- package/dist/chunks/{shelf-drop-preview-context-CWS3e20y.js → shelf-drop-preview-context-C_issPBA.js} +18 -20
- package/dist/chunks/{stored-dashboard-CrQFT27O.js → stored-dashboard-B6_StAty.js} +232 -234
- package/dist/chunks/{table-export-sheet--DUKWk6o.js → table-export-sheet-BWP2joD1.js} +1 -1
- package/dist/chunks/{temporal-input-presentation--2r9BLr0.js → temporal-input-presentation-scSWQXAB.js} +4 -4
- package/dist/chunks/{token-types-C8JymO8s.js → token-types-iKMplaBL.js} +1 -1
- package/dist/chunks/{upload-Cf3wXZT8.js → upload-BRW4Mwrd.js} +1 -1
- package/dist/chunks/validators-B8fpdinG.js +3651 -0
- package/dist/chunks/{variable-draft-BDxlD0dM.js → variable-draft-BQ3OMjvy.js} +4 -4
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.js +1778 -1741
- package/dist/format-utils/index.js +230 -231
- package/dist/index.js +236 -237
- package/dist/report-runtime-context/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/components/surfboard/filter/types.d.ts +5 -4
- package/dist/types/components/ui-custom/date-range-presets.d.ts +1 -17
- package/dist/types/index.js +9 -9
- package/dist/types/lib/document/document-edits.d.ts +8 -3
- package/dist/types/lib/document/document-text-style.d.ts +54 -0
- package/dist/types/lib/hooks/use-date-filter.d.ts +3 -3
- package/dist/types/lib/matrix-table/matrix-card-adapter.d.ts +1 -1
- package/dist/types/lib/types/explorer-types.d.ts +2 -2
- package/dist/types/lib/types/index.d.ts +1 -1
- package/dist/types/lib/utils/card-definition.d.ts +7 -7
- package/dist/types/shared/analytics-protocol/agent-time-window.d.ts +84 -0
- package/dist/types/shared/analytics-protocol/applied-constraints.d.ts +2 -2
- package/dist/types/shared/analytics-protocol/contracts.d.ts +8 -17
- package/dist/types/shared/analytics-protocol/fixtures.d.ts +3 -2
- package/dist/types/shared/analytics-protocol/index.d.ts +2 -4
- package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +4 -4
- package/dist/types/shared/analytics-protocol/relative-date/describe.d.ts +18 -0
- package/dist/types/shared/analytics-protocol/relative-date/index.d.ts +7 -0
- package/dist/types/shared/analytics-protocol/relative-date/limits.d.ts +3 -0
- package/dist/types/shared/analytics-protocol/relative-date/presets.d.ts +11 -0
- package/dist/types/shared/analytics-protocol/relative-date/resolve.d.ts +49 -0
- package/dist/types/shared/analytics-protocol/relative-date/schemas.d.ts +76 -0
- package/dist/types/shared/analytics-protocol/relative-date/traits.d.ts +51 -0
- package/dist/types/shared/analytics-protocol/relative-date/window.d.ts +111 -0
- package/dist/types/shared/analytics-protocol/selection-contract.d.ts +1 -1
- package/dist/types/shared/assistant-protocol/context.d.ts +12 -12
- package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +0 -2
- package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +176 -1756
- package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +8 -4
- package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +74 -74
- package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +20 -20
- package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +8 -2
- package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +10 -2
- package/dist/types/shared/format-utils/filter-detail.d.ts +2 -8
- package/dist/types/shared/format-utils/filter-line.d.ts +2 -2
- package/dist/types/shared/format-utils/matrix-continuation.d.ts +3 -3
- package/dist/types/shared/temporal/index.d.ts +0 -2
- package/dist/types/shared/temporal/temporal-parity-fixtures.d.ts +2 -2
- package/package.json +2 -24
- package/DATA_APP_SDK.md +0 -339
- package/dist/chunks/dashboard-json-BNNCaKEc.js +0 -68
- package/dist/chunks/filter-value-text-7zhmth1S.js +0 -163
- package/dist/chunks/index-CuHybtft.js +0 -51
- package/dist/chunks/matrix-analytical-definition-C9xB_T84.js +0 -717
- package/dist/chunks/matrix-card-BSUeSXpD.js +0 -42
- package/dist/chunks/matrix-member-presentation-DZNgQpUq.js +0 -105
- package/dist/chunks/operators-B3zZoskU.js +0 -66
- package/dist/chunks/pivot-result-contract-expectations-Ddh1rNz5.js +0 -56
- package/dist/chunks/raw-temporal-value-Bqz8wc7L.js +0 -242
- package/dist/chunks/selection-reducer-OaJ-N5uN.js +0 -46
- package/dist/chunks/source-entity-resolution-DF6GulDn.js +0 -607
- package/dist/chunks/validators-wtjw0aw6.js +0 -3332
- package/dist/data-app-sdk/index.js +0 -1412
- package/dist/data-app-sdk-adapters/index.js +0 -361
- package/dist/data-app-sdk-validation/index.js +0 -1031
- package/dist/types/data-app-sdk/adapters.d.ts +0 -35
- package/dist/types/data-app-sdk/builders.d.ts +0 -62
- package/dist/types/data-app-sdk/contracts.d.ts +0 -419
- package/dist/types/data-app-sdk/executor.d.ts +0 -5
- package/dist/types/data-app-sdk/field-catalog-validation.d.ts +0 -29
- package/dist/types/data-app-sdk/hooks.d.ts +0 -11
- package/dist/types/data-app-sdk/index.d.ts +0 -9
- package/dist/types/data-app-sdk/provider.d.ts +0 -8
- package/dist/types/data-app-sdk/relationship-aware-field-policy.d.ts +0 -21
- package/dist/types/data-app-sdk/selection.d.ts +0 -2
- package/dist/types/data-app-sdk/validation.d.ts +0 -58
- package/dist/types/data-app-sdk-adapters.d.ts +0 -2
- package/dist/types/data-app-sdk-validation.d.ts +0 -2
- package/dist/types/data-app-sdk.d.ts +0 -2
- package/dist/types/shared/analytics-protocol/relative-date-filter.d.ts +0 -68
- package/dist/types/shared/analytics-protocol/relative-date-label.d.ts +0 -20
- package/dist/types/shared/analytics-protocol/time-window-schema.d.ts +0 -314
- package/dist/types/shared/analytics-protocol/time-window.d.ts +0 -52
- package/dist/types/shared/temporal/relative-date.d.ts +0 -21
- package/dist/types/shared/temporal/time-window-periods.d.ts +0 -21
- package/src/data-app-sdk/README.md +0 -402
|
@@ -1,1031 +0,0 @@
|
|
|
1
|
-
import { G as b, H as N, s as O, I as v, q as E, J as K, K as l } from "../chunks/validators-wtjw0aw6.js";
|
|
2
|
-
import { m as Q } from "../chunks/matrix-operation-contract-Eb6elidS.js";
|
|
3
|
-
import "../chunks/analytics-base-schemas-BaIQrEzX.js";
|
|
4
|
-
import "zod";
|
|
5
|
-
import { p as W } from "../chunks/report-runtime-context-DnA_PiKo.js";
|
|
6
|
-
import { r as J } from "../chunks/source-entity-resolution-DF6GulDn.js";
|
|
7
|
-
import { toSemaphorMetricIntent as U, toSemaphorAnalysisIntent as G, toSemaphorRecordsIntent as V, toSemaphorSqlIntent as L, toSemaphorMatrixIntent as X, toSemaphorInputOptionsIntent as Y } from "../data-app-sdk-adapters/index.js";
|
|
8
|
-
import { m as Z } from "../chunks/matrix-card-BSUeSXpD.js";
|
|
9
|
-
function ee({
|
|
10
|
-
intent: e,
|
|
11
|
-
field: r,
|
|
12
|
-
catalogField: t,
|
|
13
|
-
relativePath: o
|
|
14
|
-
}) {
|
|
15
|
-
const i = te({
|
|
16
|
-
intent: e,
|
|
17
|
-
field: r,
|
|
18
|
-
relativePath: o
|
|
19
|
-
});
|
|
20
|
-
if (!i || i.allowedRelatedRoles.length === 0)
|
|
21
|
-
return !1;
|
|
22
|
-
const n = q(
|
|
23
|
-
r,
|
|
24
|
-
i.selectedField
|
|
25
|
-
), s = H(t), c = y(n);
|
|
26
|
-
return re(
|
|
27
|
-
s,
|
|
28
|
-
i.allowedRelatedRoles
|
|
29
|
-
) ? c === s : !1;
|
|
30
|
-
}
|
|
31
|
-
function Ne(e) {
|
|
32
|
-
return e.kind === "records" ? ae(e) : e.kind === "metric" ? ne(e) : [];
|
|
33
|
-
}
|
|
34
|
-
function H(e) {
|
|
35
|
-
const r = b(e.role);
|
|
36
|
-
if (r === "measure")
|
|
37
|
-
return "measure";
|
|
38
|
-
if (r === "id")
|
|
39
|
-
return "id";
|
|
40
|
-
const t = N(e.dataType);
|
|
41
|
-
if (r === "date" || t === "date" || t === "datetime")
|
|
42
|
-
return "date";
|
|
43
|
-
if (r === "dimension")
|
|
44
|
-
return "dimension";
|
|
45
|
-
}
|
|
46
|
-
function re(e, r) {
|
|
47
|
-
return !!(e && r.includes(e));
|
|
48
|
-
}
|
|
49
|
-
function q(e, r) {
|
|
50
|
-
const t = y(e);
|
|
51
|
-
if (t)
|
|
52
|
-
return e.role === t ? e : {
|
|
53
|
-
...e,
|
|
54
|
-
role: t
|
|
55
|
-
};
|
|
56
|
-
const o = r ? y(r) : void 0;
|
|
57
|
-
return o ? {
|
|
58
|
-
...e,
|
|
59
|
-
role: o
|
|
60
|
-
} : e;
|
|
61
|
-
}
|
|
62
|
-
function I(e, r) {
|
|
63
|
-
return e.find(
|
|
64
|
-
(t) => T(t, r)
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
function te({
|
|
68
|
-
intent: e,
|
|
69
|
-
field: r,
|
|
70
|
-
relativePath: t
|
|
71
|
-
}) {
|
|
72
|
-
if (e.kind === "records")
|
|
73
|
-
return oe(e, r, t);
|
|
74
|
-
if (e.kind === "metric")
|
|
75
|
-
return ie(e, r, t);
|
|
76
|
-
}
|
|
77
|
-
function oe(e, r, t) {
|
|
78
|
-
if (t.startsWith("spec.fields."))
|
|
79
|
-
return { allowedRelatedRoles: ["dimension", "date", "id"] };
|
|
80
|
-
if (t === "spec.dateField" && !e.timeWindow)
|
|
81
|
-
return { allowedRelatedRoles: ["date"] };
|
|
82
|
-
if (t === "spec.orderBy.field") {
|
|
83
|
-
const o = I(
|
|
84
|
-
w(e),
|
|
85
|
-
r
|
|
86
|
-
);
|
|
87
|
-
return {
|
|
88
|
-
selectedField: o,
|
|
89
|
-
allowedRelatedRoles: o ? S(o) : []
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function ie(e, r, t) {
|
|
94
|
-
if (t.startsWith("spec.dimensions."))
|
|
95
|
-
return { allowedRelatedRoles: ["dimension"] };
|
|
96
|
-
if (t === "spec.orderBy.field") {
|
|
97
|
-
const o = I(
|
|
98
|
-
e.dimensions || [],
|
|
99
|
-
r
|
|
100
|
-
);
|
|
101
|
-
return {
|
|
102
|
-
selectedField: o,
|
|
103
|
-
allowedRelatedRoles: o ? ["dimension"] : []
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function ae(e) {
|
|
108
|
-
var o, i;
|
|
109
|
-
const r = w(e), t = (o = e.orderBy) != null && o.field ? I(r, e.orderBy.field) : void 0;
|
|
110
|
-
return P([
|
|
111
|
-
...r.map(
|
|
112
|
-
(n) => p(
|
|
113
|
-
n,
|
|
114
|
-
S(n)
|
|
115
|
-
)
|
|
116
|
-
),
|
|
117
|
-
...(i = e.orderBy) != null && i.field ? [
|
|
118
|
-
p(
|
|
119
|
-
q(
|
|
120
|
-
e.orderBy.field,
|
|
121
|
-
t
|
|
122
|
-
),
|
|
123
|
-
t ? S(t) : [],
|
|
124
|
-
{
|
|
125
|
-
unsupportedRelatedRoleMessage: "Joined records projections support related sort fields only when the same related field is included in spec.fields.",
|
|
126
|
-
recommendedNextStep: "Add the related sort field to spec.fields, or keep orderBy fields on the base source."
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
] : []
|
|
130
|
-
]);
|
|
131
|
-
}
|
|
132
|
-
function ne(e) {
|
|
133
|
-
var t, o;
|
|
134
|
-
const r = (t = e.orderBy) != null && t.field ? I(
|
|
135
|
-
e.dimensions || [],
|
|
136
|
-
e.orderBy.field
|
|
137
|
-
) : void 0;
|
|
138
|
-
return P([
|
|
139
|
-
...e.measures.map((i) => p(i, [])),
|
|
140
|
-
...e.primaryMeasure ? [p(e.primaryMeasure, [])] : [],
|
|
141
|
-
...(e.dimensions || []).map(
|
|
142
|
-
(i) => p(i, ["dimension"])
|
|
143
|
-
),
|
|
144
|
-
...e.dateField ? [p({ ...e.dateField, role: "date" }, [])] : [],
|
|
145
|
-
...(o = e.orderBy) != null && o.field ? [
|
|
146
|
-
p(
|
|
147
|
-
q(
|
|
148
|
-
e.orderBy.field,
|
|
149
|
-
r
|
|
150
|
-
),
|
|
151
|
-
r ? ["dimension"] : [],
|
|
152
|
-
{
|
|
153
|
-
unsupportedRelatedRoleMessage: "Joined metric projections support related orderBy fields only when the same related field is declared in spec.dimensions.",
|
|
154
|
-
recommendedNextStep: "Add the related field as a metric dimension when it should participate in the grouped result, or keep orderBy fields on the base source."
|
|
155
|
-
}
|
|
156
|
-
)
|
|
157
|
-
] : []
|
|
158
|
-
]);
|
|
159
|
-
}
|
|
160
|
-
function S(e) {
|
|
161
|
-
const r = e ? y(e) : void 0;
|
|
162
|
-
return r === "dimension" ? ["dimension"] : r === "date" ? ["date"] : r === "id" ? ["id"] : ["dimension", "date", "id"];
|
|
163
|
-
}
|
|
164
|
-
function p(e, r, t = {}) {
|
|
165
|
-
return {
|
|
166
|
-
field: q(e),
|
|
167
|
-
allowedRelatedRoles: r,
|
|
168
|
-
...t
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function P(e) {
|
|
172
|
-
const r = [];
|
|
173
|
-
return e.forEach((t) => {
|
|
174
|
-
r.some(
|
|
175
|
-
(o) => se(o, t)
|
|
176
|
-
) || r.push(t);
|
|
177
|
-
}), r;
|
|
178
|
-
}
|
|
179
|
-
function w(e) {
|
|
180
|
-
const r = [...e.fields];
|
|
181
|
-
return e.dateField && !r.some(
|
|
182
|
-
(t) => A(t, e.dateField)
|
|
183
|
-
) && r.push({ ...e.dateField, role: "date" }), r;
|
|
184
|
-
}
|
|
185
|
-
function se(e, r) {
|
|
186
|
-
return T(e.field, r.field) && e.allowedRelatedRoles.join("|") === r.allowedRelatedRoles.join("|") && (e.unsupportedRelatedRoleMessage || "") === (r.unsupportedRelatedRoleMessage || "") && (e.recommendedNextStep || "") === (r.recommendedNextStep || "");
|
|
187
|
-
}
|
|
188
|
-
function A(e, r) {
|
|
189
|
-
return O(e, r);
|
|
190
|
-
}
|
|
191
|
-
function T(e, r) {
|
|
192
|
-
return A(e, r) && de(
|
|
193
|
-
y(e),
|
|
194
|
-
y(r)
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
function de(e, r) {
|
|
198
|
-
return !!(e && (!r || e === r));
|
|
199
|
-
}
|
|
200
|
-
function y(e) {
|
|
201
|
-
return H(e);
|
|
202
|
-
}
|
|
203
|
-
function j({
|
|
204
|
-
intent: e,
|
|
205
|
-
field: r,
|
|
206
|
-
relativePath: t,
|
|
207
|
-
baseCatalog: o,
|
|
208
|
-
fieldCatalogs: i
|
|
209
|
-
}) {
|
|
210
|
-
const n = h(r, e.source), s = v(
|
|
211
|
-
n,
|
|
212
|
-
e.source
|
|
213
|
-
);
|
|
214
|
-
if (e.kind !== "matrix" && !s && !ce(e.source, n))
|
|
215
|
-
return {
|
|
216
|
-
ok: !1,
|
|
217
|
-
code: "invalid_source_ref",
|
|
218
|
-
message: `Field "${r.name}" references a related Semaphor source outside the query's semantic domain.`,
|
|
219
|
-
pathSuffix: ".source",
|
|
220
|
-
source: n
|
|
221
|
-
};
|
|
222
|
-
const c = s ? o : k(i, n);
|
|
223
|
-
if (!c)
|
|
224
|
-
return {
|
|
225
|
-
ok: !1,
|
|
226
|
-
code: "invalid_source_ref",
|
|
227
|
-
message: `Field "${r.name}" references a Semaphor source that is not present in the visible field catalog.`,
|
|
228
|
-
pathSuffix: ".source",
|
|
229
|
-
source: n
|
|
230
|
-
};
|
|
231
|
-
const a = g(c, r, e.source);
|
|
232
|
-
return a ? e.kind !== "matrix" && !s && !le({
|
|
233
|
-
intent: e,
|
|
234
|
-
field: r,
|
|
235
|
-
catalogField: a,
|
|
236
|
-
relativePath: t
|
|
237
|
-
}) ? {
|
|
238
|
-
ok: !1,
|
|
239
|
-
code: "unsupported_joined_projection",
|
|
240
|
-
message: `Field "${r.name}" references a related Semaphor source, but this query kind does not support joined projections for that field yet.`,
|
|
241
|
-
pathSuffix: ".source",
|
|
242
|
-
source: n
|
|
243
|
-
} : {
|
|
244
|
-
ok: !0,
|
|
245
|
-
source: n,
|
|
246
|
-
catalogField: a,
|
|
247
|
-
usesBaseSource: s
|
|
248
|
-
} : {
|
|
249
|
-
ok: !1,
|
|
250
|
-
code: "missing_field",
|
|
251
|
-
message: `Field "${r.name}" is not visible on the selected Semaphor source.`,
|
|
252
|
-
source: n
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
function le({
|
|
256
|
-
intent: e,
|
|
257
|
-
field: r,
|
|
258
|
-
catalogField: t,
|
|
259
|
-
relativePath: o
|
|
260
|
-
}) {
|
|
261
|
-
return ee({
|
|
262
|
-
intent: e,
|
|
263
|
-
field: r,
|
|
264
|
-
catalogField: t,
|
|
265
|
-
relativePath: o
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
function ce(e, r) {
|
|
269
|
-
return e.kind === "semantic" && r.kind === "semantic" && e.domainId === r.domainId;
|
|
270
|
-
}
|
|
271
|
-
function k(e, r) {
|
|
272
|
-
return e.find((t) => F(t, r));
|
|
273
|
-
}
|
|
274
|
-
function g(e, r, t) {
|
|
275
|
-
const o = h(r, t);
|
|
276
|
-
if (F(e, o))
|
|
277
|
-
return e.fields.find(
|
|
278
|
-
(i) => ue(i, r) && F(
|
|
279
|
-
e,
|
|
280
|
-
h(i, e.source)
|
|
281
|
-
)
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
function $(e) {
|
|
285
|
-
return b(e);
|
|
286
|
-
}
|
|
287
|
-
function h(e, r) {
|
|
288
|
-
return e.source || r;
|
|
289
|
-
}
|
|
290
|
-
function F(e, r) {
|
|
291
|
-
return [e.source, ...e.sourceAliases || []].some(
|
|
292
|
-
(t) => v(t, r)
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
function ue(e, r) {
|
|
296
|
-
return !!(e.name && r.name && e.name === r.name);
|
|
297
|
-
}
|
|
298
|
-
function fe(e) {
|
|
299
|
-
const r = [];
|
|
300
|
-
if (!e.intent.filters) return r;
|
|
301
|
-
const t = e.intent.source, i = E(
|
|
302
|
-
e.fieldCatalogs.flatMap((a) => [
|
|
303
|
-
a.source,
|
|
304
|
-
...a.sourceAliases ?? []
|
|
305
|
-
])
|
|
306
|
-
).filter(
|
|
307
|
-
(a) => t.kind === "semantic" ? a.kind === "semantic" && a.domainId === t.domainId : a.kind === "physical" && a.connectionId === t.connectionId
|
|
308
|
-
).map((a) => a.kind === "semantic" ? {
|
|
309
|
-
type: "dataset",
|
|
310
|
-
name: a.datasetName,
|
|
311
|
-
id: a.datasetId,
|
|
312
|
-
domainId: a.domainId,
|
|
313
|
-
connectionId: a.connectionId
|
|
314
|
-
} : {
|
|
315
|
-
type: "table",
|
|
316
|
-
name: a.tableName,
|
|
317
|
-
database: a.databaseName,
|
|
318
|
-
schema: a.schemaName,
|
|
319
|
-
connectionId: a.connectionId,
|
|
320
|
-
connectionType: a.connectionType,
|
|
321
|
-
dialect: a.dialect
|
|
322
|
-
}), n = (a, u) => {
|
|
323
|
-
r.push({
|
|
324
|
-
field: a,
|
|
325
|
-
path: u,
|
|
326
|
-
validation: j({
|
|
327
|
-
...e,
|
|
328
|
-
field: a,
|
|
329
|
-
relativePath: u
|
|
330
|
-
})
|
|
331
|
-
});
|
|
332
|
-
}, s = (a, u) => {
|
|
333
|
-
if (a.derivedField)
|
|
334
|
-
Object.entries(a.derivedField.inputs).forEach(
|
|
335
|
-
([d, f]) => n(f.field, `${u}.derivedField.inputs.${d}.field`)
|
|
336
|
-
);
|
|
337
|
-
else if (a.calculatedFormula)
|
|
338
|
-
a.calculatedFormula.inputFields.forEach(
|
|
339
|
-
(d, f) => s(
|
|
340
|
-
d,
|
|
341
|
-
`${u}.calculatedFormula.inputFields.${f}`
|
|
342
|
-
)
|
|
343
|
-
);
|
|
344
|
-
else {
|
|
345
|
-
const d = J({
|
|
346
|
-
entities: i,
|
|
347
|
-
semanticDomainId: t.kind === "semantic" ? t.domainId : void 0,
|
|
348
|
-
connectionId: t.connectionId,
|
|
349
|
-
connectionType: t.kind === "physical" ? t.connectionType : void 0,
|
|
350
|
-
dialect: t.kind === "physical" ? t.dialect : void 0,
|
|
351
|
-
fieldEntityType: a.entityType,
|
|
352
|
-
entityId: a.entityId,
|
|
353
|
-
entityName: a.entityName,
|
|
354
|
-
qualifiedHints: [a.qualifiedEntityName]
|
|
355
|
-
});
|
|
356
|
-
d.kind === "resolved" ? n({ name: a.name, source: d.source }, u) : r.push({
|
|
357
|
-
field: { name: a.name },
|
|
358
|
-
path: u,
|
|
359
|
-
validation: {
|
|
360
|
-
ok: !1,
|
|
361
|
-
code: "invalid_source_ref",
|
|
362
|
-
source: t,
|
|
363
|
-
message: `Filter field "${a.name}" has no unambiguous source in the visible field catalog (${d.kind}).`
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
}, c = (a, u) => {
|
|
368
|
-
a.conditions.forEach(
|
|
369
|
-
(d, f) => s(d.field, `${u}.conditions.${f}.field`)
|
|
370
|
-
), a.groups.forEach(
|
|
371
|
-
(d, f) => c(d, `${u}.groups.${f}`)
|
|
372
|
-
);
|
|
373
|
-
};
|
|
374
|
-
return c(e.intent.filters, "spec.filters"), r;
|
|
375
|
-
}
|
|
376
|
-
function me(e, r = {}) {
|
|
377
|
-
const t = r.pathPrefix || "analysisOptions";
|
|
378
|
-
if (e === void 0)
|
|
379
|
-
return { ok: !0 };
|
|
380
|
-
if (!e || typeof e != "object" || Array.isArray(e))
|
|
381
|
-
return m(
|
|
382
|
-
t,
|
|
383
|
-
"Data App analysis options must be an object."
|
|
384
|
-
);
|
|
385
|
-
const o = e, i = {};
|
|
386
|
-
if (o.chartTitle !== void 0) {
|
|
387
|
-
if (typeof o.chartTitle != "string")
|
|
388
|
-
return m(
|
|
389
|
-
`${t}.chartTitle`,
|
|
390
|
-
'Data App analysis option "chartTitle" must be a string.'
|
|
391
|
-
);
|
|
392
|
-
i.chartTitle = o.chartTitle;
|
|
393
|
-
}
|
|
394
|
-
if (o.chartType !== void 0) {
|
|
395
|
-
if (typeof o.chartType != "string")
|
|
396
|
-
return m(
|
|
397
|
-
`${t}.chartType`,
|
|
398
|
-
'Data App analysis option "chartType" must be a string.'
|
|
399
|
-
);
|
|
400
|
-
i.chartType = o.chartType;
|
|
401
|
-
}
|
|
402
|
-
if (o.driverMode !== void 0) {
|
|
403
|
-
if (!ye(o.driverMode))
|
|
404
|
-
return m(
|
|
405
|
-
`${t}.driverMode`,
|
|
406
|
-
'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.'
|
|
407
|
-
);
|
|
408
|
-
i.driverMode = o.driverMode;
|
|
409
|
-
}
|
|
410
|
-
if (o.includePopulation !== void 0) {
|
|
411
|
-
if (typeof o.includePopulation != "boolean")
|
|
412
|
-
return m(
|
|
413
|
-
`${t}.includePopulation`,
|
|
414
|
-
'Data App analysis option "includePopulation" must be a boolean.'
|
|
415
|
-
);
|
|
416
|
-
i.includePopulation = o.includePopulation;
|
|
417
|
-
}
|
|
418
|
-
if (o.calendarContext !== void 0) {
|
|
419
|
-
const n = he(
|
|
420
|
-
o.calendarContext,
|
|
421
|
-
{
|
|
422
|
-
pathPrefix: `${t}.calendarContext`,
|
|
423
|
-
validateTimezone: r.validateTimezone
|
|
424
|
-
}
|
|
425
|
-
);
|
|
426
|
-
if (!n.ok)
|
|
427
|
-
return n;
|
|
428
|
-
i.calendarContext = n.calendarContext;
|
|
429
|
-
}
|
|
430
|
-
return { ok: !0, analysisOptions: i };
|
|
431
|
-
}
|
|
432
|
-
function Oe(e) {
|
|
433
|
-
const r = e.queries.map(
|
|
434
|
-
(i, n) => pe(i, n, {
|
|
435
|
-
fieldCatalogs: e.fieldCatalogs || [],
|
|
436
|
-
requireFieldCatalog: !!e.requireFieldCatalog,
|
|
437
|
-
validateTimezone: e.validateTimezone
|
|
438
|
-
})
|
|
439
|
-
), t = r.flatMap((i) => i.diagnostics), o = r.map((i) => i.executionResult);
|
|
440
|
-
return {
|
|
441
|
-
ok: t.every((i) => i.severity !== "error"),
|
|
442
|
-
diagnostics: t,
|
|
443
|
-
queries: r,
|
|
444
|
-
intents: r.flatMap(
|
|
445
|
-
(i) => i.intent ? [i.intent] : []
|
|
446
|
-
),
|
|
447
|
-
executionResults: o
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
function pe(e, r, t) {
|
|
451
|
-
const o = `queries.${r}`;
|
|
452
|
-
try {
|
|
453
|
-
const i = ge(e), n = Pe(e, i), s = K(i), c = [
|
|
454
|
-
...Re({
|
|
455
|
-
querySpec: e,
|
|
456
|
-
queryId: n,
|
|
457
|
-
intent: i,
|
|
458
|
-
pathPrefix: o
|
|
459
|
-
}),
|
|
460
|
-
...s.errors.map(
|
|
461
|
-
(u) => _(u, {
|
|
462
|
-
queryHook: e.queryHook,
|
|
463
|
-
queryId: n,
|
|
464
|
-
pathPrefix: o,
|
|
465
|
-
severity: "error",
|
|
466
|
-
intent: i
|
|
467
|
-
})
|
|
468
|
-
),
|
|
469
|
-
...s.warnings.map(
|
|
470
|
-
(u) => _(u, {
|
|
471
|
-
queryHook: e.queryHook,
|
|
472
|
-
queryId: n,
|
|
473
|
-
pathPrefix: o,
|
|
474
|
-
severity: "warning",
|
|
475
|
-
intent: i
|
|
476
|
-
})
|
|
477
|
-
),
|
|
478
|
-
...qe({
|
|
479
|
-
querySpec: e,
|
|
480
|
-
queryId: n,
|
|
481
|
-
intent: i,
|
|
482
|
-
pathPrefix: o,
|
|
483
|
-
fieldCatalogs: t.fieldCatalogs,
|
|
484
|
-
requireFieldCatalog: t.requireFieldCatalog
|
|
485
|
-
}),
|
|
486
|
-
..._e({
|
|
487
|
-
querySpec: e,
|
|
488
|
-
queryId: n,
|
|
489
|
-
intent: i,
|
|
490
|
-
pathPrefix: o,
|
|
491
|
-
validateTimezone: t.validateTimezone
|
|
492
|
-
})
|
|
493
|
-
], a = He(s, c);
|
|
494
|
-
return {
|
|
495
|
-
queryHook: e.queryHook,
|
|
496
|
-
queryId: n,
|
|
497
|
-
intent: i,
|
|
498
|
-
diagnostics: c,
|
|
499
|
-
executionResult: x({
|
|
500
|
-
intent: i,
|
|
501
|
-
validation: a,
|
|
502
|
-
diagnostics: c
|
|
503
|
-
})
|
|
504
|
-
};
|
|
505
|
-
} catch (i) {
|
|
506
|
-
const n = {
|
|
507
|
-
severity: "error",
|
|
508
|
-
code: "invalid_query_spec",
|
|
509
|
-
message: i instanceof Error ? i.message : String(i),
|
|
510
|
-
path: o,
|
|
511
|
-
queryHook: e.queryHook,
|
|
512
|
-
queryId: z(e.spec)
|
|
513
|
-
}, s = D([n]);
|
|
514
|
-
return {
|
|
515
|
-
queryHook: e.queryHook,
|
|
516
|
-
queryId: n.queryId,
|
|
517
|
-
diagnostics: [n],
|
|
518
|
-
executionResult: x({
|
|
519
|
-
validation: s,
|
|
520
|
-
diagnostics: [n]
|
|
521
|
-
})
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
function m(e, r) {
|
|
526
|
-
return {
|
|
527
|
-
ok: !1,
|
|
528
|
-
issues: [
|
|
529
|
-
{
|
|
530
|
-
code: "invalid_analysis_option",
|
|
531
|
-
message: r,
|
|
532
|
-
path: e
|
|
533
|
-
}
|
|
534
|
-
]
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
function M(e) {
|
|
538
|
-
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
539
|
-
}
|
|
540
|
-
function ye(e) {
|
|
541
|
-
return e === "absolute_delta" || e === "largest_negative" || e === "largest_positive" || e === "positive_and_negative" || e === "all";
|
|
542
|
-
}
|
|
543
|
-
function he(e, r) {
|
|
544
|
-
if (!e || typeof e != "object" || Array.isArray(e))
|
|
545
|
-
return m(
|
|
546
|
-
r.pathPrefix,
|
|
547
|
-
'Data App analysis option "calendarContext" must be an object.'
|
|
548
|
-
);
|
|
549
|
-
const t = e, o = t.tz;
|
|
550
|
-
let i = o;
|
|
551
|
-
if (typeof o == "string" && r.validateTimezone && (i = r.validateTimezone(o)), i === null)
|
|
552
|
-
return m(
|
|
553
|
-
`${r.pathPrefix}.tz`,
|
|
554
|
-
'Data App analysis option "calendarContext.tz" must be a valid timezone string.'
|
|
555
|
-
);
|
|
556
|
-
const n = W({
|
|
557
|
-
...t,
|
|
558
|
-
tz: i
|
|
559
|
-
});
|
|
560
|
-
if (!n.ok) {
|
|
561
|
-
const s = n.issues[0];
|
|
562
|
-
return m(
|
|
563
|
-
s != null && s.path ? `${r.pathPrefix}.${s.path}` : r.pathPrefix,
|
|
564
|
-
`Data App analysis option "calendarContext" is invalid: ${(s == null ? void 0 : s.message) ?? "invalid value"}.`
|
|
565
|
-
);
|
|
566
|
-
}
|
|
567
|
-
return { ok: !0, calendarContext: n.value };
|
|
568
|
-
}
|
|
569
|
-
function ge(e) {
|
|
570
|
-
return ve(e.spec);
|
|
571
|
-
}
|
|
572
|
-
function ve(e) {
|
|
573
|
-
if (!M(e))
|
|
574
|
-
throw new Error("useSemaphorQuery spec must be an object.");
|
|
575
|
-
if (e.queryKind === "metric")
|
|
576
|
-
return U(e);
|
|
577
|
-
if (e.queryKind === "analysis")
|
|
578
|
-
return G(e);
|
|
579
|
-
if (e.queryKind === "records")
|
|
580
|
-
return V(e);
|
|
581
|
-
if (e.queryKind === "sql")
|
|
582
|
-
return L(e);
|
|
583
|
-
if (e.queryKind === "matrix")
|
|
584
|
-
return X(e);
|
|
585
|
-
if (e.queryKind === "inputOptions")
|
|
586
|
-
return Y(e);
|
|
587
|
-
throw new Error(
|
|
588
|
-
"useSemaphorQuery spec.queryKind must be metric, analysis, records, inputOptions, sql, or matrix."
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
|
-
function qe(e) {
|
|
592
|
-
if (e.intent.kind === "sql")
|
|
593
|
-
return [];
|
|
594
|
-
if (e.fieldCatalogs.length === 0 && !e.requireFieldCatalog)
|
|
595
|
-
return [];
|
|
596
|
-
const r = k(
|
|
597
|
-
e.fieldCatalogs,
|
|
598
|
-
e.intent.source
|
|
599
|
-
);
|
|
600
|
-
if (!r)
|
|
601
|
-
return [
|
|
602
|
-
{
|
|
603
|
-
severity: "error",
|
|
604
|
-
code: "invalid_source_ref",
|
|
605
|
-
message: `Source ref for ${e.querySpec.queryHook} does not match a visible Semaphor source.`,
|
|
606
|
-
path: `${e.pathPrefix}.spec.source`,
|
|
607
|
-
queryHook: e.querySpec.queryHook,
|
|
608
|
-
queryId: e.queryId,
|
|
609
|
-
intentId: l(e.intent),
|
|
610
|
-
source: e.intent.source
|
|
611
|
-
}
|
|
612
|
-
];
|
|
613
|
-
const t = ke({
|
|
614
|
-
...e,
|
|
615
|
-
catalog: r
|
|
616
|
-
}), o = {
|
|
617
|
-
...r,
|
|
618
|
-
fields: [
|
|
619
|
-
...r.fields,
|
|
620
|
-
...xe(e.intent, r, e.intent.source)
|
|
621
|
-
]
|
|
622
|
-
};
|
|
623
|
-
return [
|
|
624
|
-
...t,
|
|
625
|
-
...Ie({
|
|
626
|
-
...e,
|
|
627
|
-
fieldCatalogs: e.fieldCatalogs
|
|
628
|
-
}),
|
|
629
|
-
...Se({
|
|
630
|
-
...e,
|
|
631
|
-
catalog: o,
|
|
632
|
-
fieldCatalogs: e.fieldCatalogs
|
|
633
|
-
}),
|
|
634
|
-
...Fe({
|
|
635
|
-
...e,
|
|
636
|
-
catalog: o,
|
|
637
|
-
fieldCatalogs: e.fieldCatalogs
|
|
638
|
-
})
|
|
639
|
-
];
|
|
640
|
-
}
|
|
641
|
-
function Ie(e) {
|
|
642
|
-
var t;
|
|
643
|
-
if (e.intent.kind !== "inputOptions" || ((t = e.intent.population) == null ? void 0 : t.kind) !== "related_population")
|
|
644
|
-
return [];
|
|
645
|
-
const r = e.intent.population.baseSource;
|
|
646
|
-
return k(e.fieldCatalogs, r) ? [] : [
|
|
647
|
-
{
|
|
648
|
-
severity: "error",
|
|
649
|
-
code: "invalid_source_ref",
|
|
650
|
-
message: "Input options related population baseSource does not match a visible Semaphor source.",
|
|
651
|
-
path: `${e.pathPrefix}.spec.population.baseSource`,
|
|
652
|
-
queryHook: e.querySpec.queryHook,
|
|
653
|
-
queryId: e.queryId,
|
|
654
|
-
intentId: l(e.intent),
|
|
655
|
-
source: r
|
|
656
|
-
}
|
|
657
|
-
];
|
|
658
|
-
}
|
|
659
|
-
function ke(e) {
|
|
660
|
-
const r = B(e.intent);
|
|
661
|
-
if (r.length === 0)
|
|
662
|
-
return [];
|
|
663
|
-
const t = [], o = /* @__PURE__ */ new Set();
|
|
664
|
-
return r.forEach((i, n) => {
|
|
665
|
-
const s = `${e.pathPrefix}.spec.derivedFields.${n}`, c = $(i.name);
|
|
666
|
-
c && (o.has(c) && t.push({
|
|
667
|
-
severity: "error",
|
|
668
|
-
code: "duplicate_derived_field",
|
|
669
|
-
message: `Derived field "${i.name}" is declared more than once.`,
|
|
670
|
-
path: `${s}.name`,
|
|
671
|
-
queryHook: e.querySpec.queryHook,
|
|
672
|
-
queryId: e.queryId,
|
|
673
|
-
intentId: l(e.intent),
|
|
674
|
-
source: e.intent.source
|
|
675
|
-
}), o.add(c), e.catalog.fields.some(
|
|
676
|
-
(a) => $(a.name) === c
|
|
677
|
-
) && t.push({
|
|
678
|
-
severity: "error",
|
|
679
|
-
code: "derived_field_name_collision",
|
|
680
|
-
message: `Derived field "${i.name}" conflicts with a field already visible on the selected Semaphor source.`,
|
|
681
|
-
path: `${s}.name`,
|
|
682
|
-
queryHook: e.querySpec.queryHook,
|
|
683
|
-
queryId: e.queryId,
|
|
684
|
-
intentId: l(e.intent),
|
|
685
|
-
source: e.intent.source
|
|
686
|
-
})), Object.entries(i.inputs || {}).forEach(([a, u]) => {
|
|
687
|
-
const d = be(u);
|
|
688
|
-
if (!d)
|
|
689
|
-
return;
|
|
690
|
-
const f = h(d, e.intent.source);
|
|
691
|
-
if (!v(f, e.intent.source)) {
|
|
692
|
-
t.push({
|
|
693
|
-
severity: "error",
|
|
694
|
-
code: "unsupported_derived_field_source",
|
|
695
|
-
message: `Derived field "${i.name}" input "${a}" references a different Semaphor source. App-local derived fields must use fields from the query source.`,
|
|
696
|
-
path: `${s}.inputs.${a}`,
|
|
697
|
-
queryHook: e.querySpec.queryHook,
|
|
698
|
-
queryId: e.queryId,
|
|
699
|
-
intentId: l(e.intent),
|
|
700
|
-
source: f,
|
|
701
|
-
field: d
|
|
702
|
-
});
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
g(e.catalog, d, e.intent.source) || t.push({
|
|
706
|
-
severity: "error",
|
|
707
|
-
code: "missing_field",
|
|
708
|
-
message: `Derived field "${i.name}" input "${a}" references field "${d.name}", which is not visible on the selected Semaphor source.`,
|
|
709
|
-
path: `${s}.inputs.${a}`,
|
|
710
|
-
queryHook: e.querySpec.queryHook,
|
|
711
|
-
queryId: e.queryId,
|
|
712
|
-
intentId: l(e.intent),
|
|
713
|
-
source: f,
|
|
714
|
-
field: d
|
|
715
|
-
});
|
|
716
|
-
});
|
|
717
|
-
}), t;
|
|
718
|
-
}
|
|
719
|
-
function Se(e) {
|
|
720
|
-
const r = Ce(e.intent).map(({ field: t, path: o }) => {
|
|
721
|
-
const i = j({
|
|
722
|
-
intent: e.intent,
|
|
723
|
-
field: t,
|
|
724
|
-
relativePath: o,
|
|
725
|
-
baseCatalog: e.catalog,
|
|
726
|
-
fieldCatalogs: e.fieldCatalogs
|
|
727
|
-
});
|
|
728
|
-
return { field: t, path: o, validation: i };
|
|
729
|
-
});
|
|
730
|
-
return e.intent.kind === "matrix" && r.push(...fe({
|
|
731
|
-
intent: e.intent,
|
|
732
|
-
baseCatalog: e.catalog,
|
|
733
|
-
fieldCatalogs: e.fieldCatalogs
|
|
734
|
-
})), r.flatMap(({ field: t, path: o, validation: i }) => i.ok ? [] : [
|
|
735
|
-
{
|
|
736
|
-
severity: "error",
|
|
737
|
-
code: i.code,
|
|
738
|
-
message: i.message,
|
|
739
|
-
path: `${e.pathPrefix}.${o}${i.pathSuffix || ""}`,
|
|
740
|
-
queryHook: e.querySpec.queryHook,
|
|
741
|
-
queryId: e.queryId,
|
|
742
|
-
intentId: l(e.intent),
|
|
743
|
-
source: i.source,
|
|
744
|
-
field: t
|
|
745
|
-
}
|
|
746
|
-
]);
|
|
747
|
-
}
|
|
748
|
-
function Fe(e) {
|
|
749
|
-
return ("inputs" in e.intent ? e.intent.inputs || [] : []).flatMap((t, o) => {
|
|
750
|
-
if (!t.field)
|
|
751
|
-
return [];
|
|
752
|
-
const i = h(t.field, e.intent.source);
|
|
753
|
-
if (!v(i, e.intent.source)) {
|
|
754
|
-
if ($e(e.intent, i)) {
|
|
755
|
-
const n = k(e.fieldCatalogs, i);
|
|
756
|
-
return n ? g(n, t.field, i) ? [] : [
|
|
757
|
-
{
|
|
758
|
-
severity: "error",
|
|
759
|
-
code: "missing_field",
|
|
760
|
-
message: `Input "${t.inputId}" references field "${t.field.name}", which is not visible on the selected Semaphor source.`,
|
|
761
|
-
path: `${e.pathPrefix}.spec.inputs.${o}.field`,
|
|
762
|
-
queryHook: e.querySpec.queryHook,
|
|
763
|
-
queryId: e.queryId,
|
|
764
|
-
intentId: l(e.intent),
|
|
765
|
-
source: i,
|
|
766
|
-
field: t.field
|
|
767
|
-
}
|
|
768
|
-
] : [
|
|
769
|
-
{
|
|
770
|
-
severity: "error",
|
|
771
|
-
code: "invalid_source_ref",
|
|
772
|
-
message: `Input "${t.inputId}" references a Semaphor source that is not present in the visible field catalog.`,
|
|
773
|
-
path: `${e.pathPrefix}.spec.inputs.${o}.field.source`,
|
|
774
|
-
queryHook: e.querySpec.queryHook,
|
|
775
|
-
queryId: e.queryId,
|
|
776
|
-
intentId: l(e.intent),
|
|
777
|
-
source: i,
|
|
778
|
-
field: t.field
|
|
779
|
-
}
|
|
780
|
-
];
|
|
781
|
-
}
|
|
782
|
-
return [
|
|
783
|
-
{
|
|
784
|
-
severity: "error",
|
|
785
|
-
code: "unsupported_input_filter_composition",
|
|
786
|
-
message: `Input "${t.inputId}" filters a different Semaphor source than the query, and no relationship-aware semantic validation path is available for this query kind.`,
|
|
787
|
-
path: `${e.pathPrefix}.spec.inputs.${o}.field`,
|
|
788
|
-
queryHook: e.querySpec.queryHook,
|
|
789
|
-
queryId: e.queryId,
|
|
790
|
-
intentId: l(e.intent),
|
|
791
|
-
source: i,
|
|
792
|
-
field: t.field
|
|
793
|
-
}
|
|
794
|
-
];
|
|
795
|
-
}
|
|
796
|
-
return g(e.catalog, t.field, e.intent.source) ? [] : [
|
|
797
|
-
{
|
|
798
|
-
severity: "error",
|
|
799
|
-
code: "missing_field",
|
|
800
|
-
message: `Input "${t.inputId}" references field "${t.field.name}", which is not visible on the selected Semaphor source.`,
|
|
801
|
-
path: `${e.pathPrefix}.spec.inputs.${o}.field`,
|
|
802
|
-
queryHook: e.querySpec.queryHook,
|
|
803
|
-
queryId: e.queryId,
|
|
804
|
-
intentId: l(e.intent),
|
|
805
|
-
source: i,
|
|
806
|
-
field: t.field
|
|
807
|
-
}
|
|
808
|
-
];
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
function $e(e, r) {
|
|
812
|
-
return e.source.kind === "semantic" && r.kind === "semantic" && r.domainId === e.source.domainId;
|
|
813
|
-
}
|
|
814
|
-
function _e(e) {
|
|
815
|
-
if (e.querySpec.spec.queryKind !== "analysis")
|
|
816
|
-
return [];
|
|
817
|
-
const r = me(
|
|
818
|
-
e.querySpec.spec,
|
|
819
|
-
{
|
|
820
|
-
pathPrefix: `${e.pathPrefix}.spec`,
|
|
821
|
-
validateTimezone: e.validateTimezone
|
|
822
|
-
}
|
|
823
|
-
);
|
|
824
|
-
return r.ok ? [] : r.issues.map((t) => ({
|
|
825
|
-
severity: "error",
|
|
826
|
-
code: t.code,
|
|
827
|
-
message: t.message,
|
|
828
|
-
path: t.path,
|
|
829
|
-
queryHook: e.querySpec.queryHook,
|
|
830
|
-
queryId: e.queryId,
|
|
831
|
-
intentId: l(e.intent),
|
|
832
|
-
source: e.intent.source
|
|
833
|
-
}));
|
|
834
|
-
}
|
|
835
|
-
function Re(e) {
|
|
836
|
-
if (e.querySpec.spec.queryKind === "matrix") {
|
|
837
|
-
const r = Q.safeParse(e.querySpec.spec.matrixWindowRequest);
|
|
838
|
-
return r.success ? [] : r.error.issues.map((t) => ({
|
|
839
|
-
severity: "error",
|
|
840
|
-
code: "invalid_query_spec",
|
|
841
|
-
message: t.message,
|
|
842
|
-
path: [e.pathPrefix, "spec", "matrixWindowRequest", ...t.path].join("."),
|
|
843
|
-
queryHook: e.querySpec.queryHook,
|
|
844
|
-
queryId: e.queryId,
|
|
845
|
-
intentId: l(e.intent)
|
|
846
|
-
}));
|
|
847
|
-
}
|
|
848
|
-
return e.querySpec.spec.queryKind !== "sql" ? [] : M(e.querySpec.spec) ? Object.prototype.hasOwnProperty.call(e.querySpec.spec, "parameters") ? [
|
|
849
|
-
{
|
|
850
|
-
severity: "error",
|
|
851
|
-
code: "deprecated_sql_parameters",
|
|
852
|
-
message: "semaphor.sql uses defaultParameters for static SQL param(...) fallback values. The legacy parameters field is not supported.",
|
|
853
|
-
path: `${e.pathPrefix}.spec.parameters`,
|
|
854
|
-
queryHook: e.querySpec.queryHook,
|
|
855
|
-
queryId: e.queryId,
|
|
856
|
-
intentId: l(e.intent)
|
|
857
|
-
}
|
|
858
|
-
] : [] : [];
|
|
859
|
-
}
|
|
860
|
-
function Ce(e) {
|
|
861
|
-
return e.kind === "metric" ? [
|
|
862
|
-
...e.measures.map((r, t) => ({
|
|
863
|
-
field: r,
|
|
864
|
-
path: `spec.measures.${t}`
|
|
865
|
-
})),
|
|
866
|
-
...e.primaryMeasure ? [{ field: e.primaryMeasure, path: "spec.primaryMeasure" }] : [],
|
|
867
|
-
...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
|
|
868
|
-
...(e.dimensions || []).map((r, t) => ({
|
|
869
|
-
field: r,
|
|
870
|
-
path: `spec.dimensions.${t}`
|
|
871
|
-
})),
|
|
872
|
-
...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : [],
|
|
873
|
-
...(e.filters || []).map((r, t) => ({
|
|
874
|
-
field: r.field,
|
|
875
|
-
path: `spec.filters.${t}.field`
|
|
876
|
-
}))
|
|
877
|
-
] : e.kind === "records" ? [
|
|
878
|
-
...e.fields.map((r, t) => ({
|
|
879
|
-
field: r,
|
|
880
|
-
path: `spec.fields.${t}`
|
|
881
|
-
})),
|
|
882
|
-
...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
|
|
883
|
-
...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : [],
|
|
884
|
-
...(e.filters || []).map((r, t) => ({
|
|
885
|
-
field: r.field,
|
|
886
|
-
path: `spec.filters.${t}.field`
|
|
887
|
-
}))
|
|
888
|
-
] : e.kind === "inputOptions" ? [
|
|
889
|
-
{ field: e.labelField, path: "spec.labelField" },
|
|
890
|
-
{ field: e.valueField, path: "spec.valueField" },
|
|
891
|
-
...e.searchField ? [{ field: e.searchField, path: "spec.searchField" }] : [],
|
|
892
|
-
...(e.disambiguationFields || []).map((r, t) => ({
|
|
893
|
-
field: r,
|
|
894
|
-
path: `spec.disambiguationFields.${t}`
|
|
895
|
-
}))
|
|
896
|
-
] : e.kind === "matrix" ? Z(e).flatMap((r, t) => r.derivedField || r.name === "*" ? [] : [{ field: r, path: `spec.fields.${t}` }]) : [];
|
|
897
|
-
}
|
|
898
|
-
function B(e) {
|
|
899
|
-
return !("derivedFields" in e) || !Array.isArray(e.derivedFields) ? [] : e.derivedFields;
|
|
900
|
-
}
|
|
901
|
-
function xe(e, r, t) {
|
|
902
|
-
return B(e).map((o) => ({
|
|
903
|
-
name: o.name,
|
|
904
|
-
label: o.label,
|
|
905
|
-
role: o.resultRole,
|
|
906
|
-
dataType: o.dataType,
|
|
907
|
-
source: r.source || t,
|
|
908
|
-
...o.defaultAggregate ? { aggregate: o.defaultAggregate } : {}
|
|
909
|
-
}));
|
|
910
|
-
}
|
|
911
|
-
function be(e) {
|
|
912
|
-
if (!(!e || typeof e != "object"))
|
|
913
|
-
return e.field;
|
|
914
|
-
}
|
|
915
|
-
function _(e, r) {
|
|
916
|
-
return {
|
|
917
|
-
severity: r.severity,
|
|
918
|
-
code: e.code || "invalid_analytics_intent",
|
|
919
|
-
message: e.message,
|
|
920
|
-
path: e.path ? `${r.pathPrefix}.spec.${e.path}` : r.pathPrefix,
|
|
921
|
-
queryHook: r.queryHook,
|
|
922
|
-
queryId: r.queryId,
|
|
923
|
-
intentId: l(r.intent),
|
|
924
|
-
source: r.intent.source
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
function He(e, r) {
|
|
928
|
-
const t = D(r);
|
|
929
|
-
return {
|
|
930
|
-
ok: t.ok && e.ok,
|
|
931
|
-
errors: C([
|
|
932
|
-
...e.errors,
|
|
933
|
-
...t.errors
|
|
934
|
-
]),
|
|
935
|
-
warnings: C([
|
|
936
|
-
...e.warnings,
|
|
937
|
-
...t.warnings
|
|
938
|
-
]),
|
|
939
|
-
repairHints: [
|
|
940
|
-
...e.repairHints,
|
|
941
|
-
...t.repairHints
|
|
942
|
-
]
|
|
943
|
-
};
|
|
944
|
-
}
|
|
945
|
-
function D(e) {
|
|
946
|
-
const r = e.filter((o) => o.severity === "error").map(R), t = e.filter((o) => o.severity === "warning").map(R);
|
|
947
|
-
return {
|
|
948
|
-
ok: r.length === 0,
|
|
949
|
-
errors: r,
|
|
950
|
-
warnings: t,
|
|
951
|
-
repairHints: r.map((o) => {
|
|
952
|
-
var i, n;
|
|
953
|
-
return {
|
|
954
|
-
code: o.code,
|
|
955
|
-
message: o.message,
|
|
956
|
-
fieldRole: o.fieldRole,
|
|
957
|
-
invalidField: (i = o.repairHint) == null ? void 0 : i.invalidField,
|
|
958
|
-
recommendedNextStep: ((n = o.repairHint) == null ? void 0 : n.recommendedNextStep) || "Update the Data App SDK query spec to use visible Semaphor source and field refs."
|
|
959
|
-
};
|
|
960
|
-
})
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
function R(e) {
|
|
964
|
-
var r;
|
|
965
|
-
return {
|
|
966
|
-
code: e.code,
|
|
967
|
-
message: e.message,
|
|
968
|
-
path: e.path,
|
|
969
|
-
fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
|
|
970
|
-
repairHint: {
|
|
971
|
-
code: e.code,
|
|
972
|
-
message: e.message,
|
|
973
|
-
invalidField: (r = e.field) == null ? void 0 : r.name,
|
|
974
|
-
fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
|
|
975
|
-
recommendedNextStep: e.code === "unsupported_input_filter_composition" ? "Use an input field from the same Semaphor source as the query, or split the query into separate source-scoped queries." : "Update the query spec to use a visible Semaphor source and field ref."
|
|
976
|
-
}
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
function C(e) {
|
|
980
|
-
const r = /* @__PURE__ */ new Set();
|
|
981
|
-
return e.filter((t) => {
|
|
982
|
-
const o = `${t.code}:${t.path || ""}:${t.message}`;
|
|
983
|
-
return r.has(o) ? !1 : (r.add(o), !0);
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
function x(e) {
|
|
987
|
-
var t;
|
|
988
|
-
const r = e.diagnostics.filter(
|
|
989
|
-
(o) => o.severity === "error"
|
|
990
|
-
);
|
|
991
|
-
return {
|
|
992
|
-
intentId: l(e.intent),
|
|
993
|
-
status: r.length ? "failed" : "answered",
|
|
994
|
-
resultShape: (t = e.intent) == null ? void 0 : t.kind,
|
|
995
|
-
intent: e.intent,
|
|
996
|
-
validation: e.validation,
|
|
997
|
-
coverage: {
|
|
998
|
-
answeredObligations: r.length ? [] : ["query_spec_validation"],
|
|
999
|
-
missingObligations: r.length ? ["query_spec_validation"] : [],
|
|
1000
|
-
warnings: e.validation.warnings
|
|
1001
|
-
},
|
|
1002
|
-
missingFields: r.filter((o) => o.code === "missing_field").flatMap(
|
|
1003
|
-
(o) => {
|
|
1004
|
-
var i;
|
|
1005
|
-
return (i = o.field) != null && i.name ? [o.field.name] : [];
|
|
1006
|
-
}
|
|
1007
|
-
),
|
|
1008
|
-
warnings: e.diagnostics.filter((o) => o.severity === "warning").map((o) => o.message),
|
|
1009
|
-
metadata: {
|
|
1010
|
-
validationKind: "data_app_sdk_query_spec"
|
|
1011
|
-
}
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
|
-
function Pe(e, r) {
|
|
1015
|
-
return l(r) || z(e.spec);
|
|
1016
|
-
}
|
|
1017
|
-
function z(e) {
|
|
1018
|
-
if (!e || typeof e != "object" || !("id" in e))
|
|
1019
|
-
return;
|
|
1020
|
-
const r = e.id;
|
|
1021
|
-
return typeof r == "string" && r.trim() ? r : void 0;
|
|
1022
|
-
}
|
|
1023
|
-
export {
|
|
1024
|
-
q as fieldWithSelectedProjectionRole,
|
|
1025
|
-
I as findMatchingRelatedProjectionField,
|
|
1026
|
-
re as isAllowedRelatedProjectionRole,
|
|
1027
|
-
me as normalizeSemaphorAnalysisQueryOptions,
|
|
1028
|
-
H as normalizeSemaphorFieldRole,
|
|
1029
|
-
Ne as relatedProjectionFieldCandidatesForIntent,
|
|
1030
|
-
Oe as validateSemaphorDataAppQuerySpecs
|
|
1031
|
-
};
|