react-semaphor 0.1.381 → 0.1.382
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/DATA_APP_SDK.md +238 -0
- package/README.md +7 -0
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +45 -41
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +6 -6
- package/dist/chunks/analyze-result-contract-CtXfp3nv.js +1 -0
- package/dist/chunks/analyze-result-contract-DuhlklhI.js +102 -0
- package/dist/chunks/{braces-BT-ZyB-g.js → braces-CGi-YFZp.js} +1 -1
- package/dist/chunks/{braces-DOxxfERN.js → braces-CP8BEzl3.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-Dsgs8WDv.js → calendar-preferences-dialog-CV4xF2Tp.js} +3 -3
- package/dist/chunks/{calendar-preferences-dialog-iZs8XqyH.js → calendar-preferences-dialog-rDDobeLo.js} +1 -1
- package/dist/chunks/catalog-field-grounding-Bnx-3tE0.js +1 -0
- package/dist/chunks/catalog-field-grounding-CJKAqtiC.js +100 -0
- package/dist/chunks/{dashboard-briefing-launcher-Coks66cV.js → dashboard-briefing-launcher-BT00MvGB.js} +5 -5
- package/dist/chunks/{dashboard-briefing-launcher-B5vPTl8P.js → dashboard-briefing-launcher-Dcbh-mjY.js} +1 -1
- package/dist/chunks/{dashboard-controls-BfkcnIdy.js → dashboard-controls-B6y7jkKO.js} +8 -8
- package/dist/chunks/{dashboard-controls-Dyqye6fh.js → dashboard-controls-CRqnPibB.js} +1 -1
- package/dist/chunks/{dashboard-json-DjXi4cI6.js → dashboard-json-CfIUG8k1.js} +3 -3
- package/dist/chunks/{dashboard-json-CV_LnO9x.js → dashboard-json-DEQqRR1x.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DOW1Ap1N.js → edit-dashboard-visual-DMbf89xa.js} +5 -5
- package/dist/chunks/{edit-dashboard-visual-yinO0yU-.js → edit-dashboard-visual-wDOcHak3.js} +1 -1
- package/dist/chunks/{index-DlprYjr6.js → index-BAsWLkZ8.js} +169 -168
- package/dist/chunks/{index-CkoRCh3g.js → index-CrKxP9uF.js} +5 -5
- package/dist/chunks/{layout-grid-DTbOIOsE.js → layout-grid-BsKH3TgY.js} +1 -1
- package/dist/chunks/{layout-grid-DccceHv4.js → layout-grid-jJQUqDN9.js} +1 -1
- package/dist/chunks/operators-C8TxpM4C.js +48 -0
- package/dist/chunks/operators-DrTQsJXv.js +1 -0
- package/dist/chunks/{palette-SimHJELn.js → palette-9zLPGlj2.js} +1 -1
- package/dist/chunks/{palette-DCzLwqIw.js → palette-xU9Qt6bE.js} +1 -1
- package/dist/chunks/{save-D2O96E5A.js → save-8A_q6K4E.js} +1 -1
- package/dist/chunks/{save-zNVYH02T.js → save-DzciESDh.js} +1 -1
- package/dist/chunks/{source-identity-Dj3dryN9.js → source-identity-CN4xiyKJ.js} +5 -5
- package/dist/chunks/{switch-DMPsMpHW.js → switch-DArtNJZh.js} +292 -291
- package/dist/chunks/{switch-Jhyl63RF.js → switch-k7kj6NRg.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-r5JKyXU8.js → use-create-flow-overlay-state-BdG1DiSx.js} +4 -4
- package/dist/chunks/{use-create-flow-overlay-state-NsqFPwdB.js → use-create-flow-overlay-state-ipeaE65_.js} +1 -1
- package/dist/chunks/{validators-CtNmgsvG.js → validators-CHPH6ORs.js} +641 -498
- package/dist/chunks/validators-lWo8m0Q7.js +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +105 -92
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +444 -380
- package/dist/data-app-sdk-adapters/index.cjs +1 -0
- package/dist/data-app-sdk-adapters/index.js +383 -0
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +1073 -6
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +58 -31
- package/dist/types/dashboard-assistant.d.ts +40 -15
- package/dist/types/dashboard-authoring.d.ts +36 -16
- package/dist/types/dashboard.d.ts +8 -8
- package/dist/types/data-app-builder.d.ts +35 -11
- package/dist/types/data-app-sdk-adapters.d.ts +733 -0
- package/dist/types/data-app-sdk-validation.d.ts +85 -25
- package/dist/types/data-app-sdk.d.ts +99 -155
- package/dist/types/main.d.ts +35 -11
- package/dist/types/shared.d.ts +8 -8
- package/dist/types/surfboard.d.ts +8 -8
- package/dist/types/types.d.ts +8 -8
- package/package.json +9 -2
- package/src/data-app-sdk/README.md +240 -0
- package/dist/chunks/catalog-field-grounding-8L9I0zdg.js +0 -1
- package/dist/chunks/catalog-field-grounding-BK4BX8sZ.js +0 -200
- package/dist/chunks/validation-BM3-ShHV.js +0 -1003
- package/dist/chunks/validation-BVpqRFar.js +0 -1
- package/dist/chunks/validators-jpoYhpHh.js +0 -1
|
@@ -1,8 +1,1075 @@
|
|
|
1
|
-
import "../chunks/validators-
|
|
2
|
-
import "../chunks/
|
|
3
|
-
import "../chunks/source-identity-
|
|
4
|
-
import {
|
|
1
|
+
import { b as O } from "../chunks/validators-CHPH6ORs.js";
|
|
2
|
+
import "../chunks/analyze-result-contract-DuhlklhI.js";
|
|
3
|
+
import { s as K, b as q } from "../chunks/source-identity-CN4xiyKJ.js";
|
|
4
|
+
import { toSemaphorMetricIntent as Q, toSemaphorAnalysisIntent as E, toSemaphorRecordsIntent as J, toSemaphorSqlIntent as U, toSemaphorMatrixIntent as W, toSemaphorInputOptionsIntent as L } from "../data-app-sdk-adapters/index.js";
|
|
5
|
+
import { n as A, b as V } from "../chunks/catalog-field-grounding-CJKAqtiC.js";
|
|
6
|
+
function G({
|
|
7
|
+
intent: e,
|
|
8
|
+
field: r,
|
|
9
|
+
catalogField: o,
|
|
10
|
+
relativePath: t
|
|
11
|
+
}) {
|
|
12
|
+
const i = Y({
|
|
13
|
+
intent: e,
|
|
14
|
+
field: r,
|
|
15
|
+
relativePath: t
|
|
16
|
+
});
|
|
17
|
+
if (!i || i.allowedRelatedRoles.length === 0)
|
|
18
|
+
return !1;
|
|
19
|
+
const a = m(
|
|
20
|
+
r,
|
|
21
|
+
i.selectedField
|
|
22
|
+
), s = H(o), n = f(a);
|
|
23
|
+
return X(
|
|
24
|
+
s,
|
|
25
|
+
i.allowedRelatedRoles
|
|
26
|
+
) ? n === s : !1;
|
|
27
|
+
}
|
|
28
|
+
function De(e) {
|
|
29
|
+
return e.kind === "records" ? oe(e) : e.kind === "metric" ? te(e) : ie(e);
|
|
30
|
+
}
|
|
31
|
+
function H(e) {
|
|
32
|
+
const r = A(e.role);
|
|
33
|
+
if (r === "measure")
|
|
34
|
+
return "measure";
|
|
35
|
+
if (r === "id")
|
|
36
|
+
return "id";
|
|
37
|
+
const o = V(e.dataType);
|
|
38
|
+
if (r === "date" || o === "date" || o === "datetime")
|
|
39
|
+
return "date";
|
|
40
|
+
if (r === "dimension")
|
|
41
|
+
return "dimension";
|
|
42
|
+
}
|
|
43
|
+
function X(e, r) {
|
|
44
|
+
return !!(e && r.includes(e));
|
|
45
|
+
}
|
|
46
|
+
function m(e, r) {
|
|
47
|
+
const o = f(e);
|
|
48
|
+
if (o)
|
|
49
|
+
return e.role === o ? e : {
|
|
50
|
+
...e,
|
|
51
|
+
role: o
|
|
52
|
+
};
|
|
53
|
+
const t = r ? f(r) : void 0;
|
|
54
|
+
return t ? {
|
|
55
|
+
...e,
|
|
56
|
+
role: t
|
|
57
|
+
} : e;
|
|
58
|
+
}
|
|
59
|
+
function u(e, r) {
|
|
60
|
+
return e.find(
|
|
61
|
+
(o) => B(o, r)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function k(e) {
|
|
65
|
+
return [
|
|
66
|
+
...e.rows.map((r) => r.field),
|
|
67
|
+
...(e.columns || []).map((r) => r.field)
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
function Y({
|
|
71
|
+
intent: e,
|
|
72
|
+
field: r,
|
|
73
|
+
relativePath: o
|
|
74
|
+
}) {
|
|
75
|
+
if (e.kind === "records")
|
|
76
|
+
return Z(e, r, o);
|
|
77
|
+
if (e.kind === "metric")
|
|
78
|
+
return ee(e, r, o);
|
|
79
|
+
if (e.kind === "matrix")
|
|
80
|
+
return re(e, r, o);
|
|
81
|
+
}
|
|
82
|
+
function Z(e, r, o) {
|
|
83
|
+
if (o.startsWith("spec.fields."))
|
|
84
|
+
return { allowedRelatedRoles: ["dimension", "date", "id"] };
|
|
85
|
+
if (o === "spec.dateField" && !e.timeWindow)
|
|
86
|
+
return { allowedRelatedRoles: ["date"] };
|
|
87
|
+
if (o === "spec.orderBy.field") {
|
|
88
|
+
const t = u(
|
|
89
|
+
M(e),
|
|
90
|
+
r
|
|
91
|
+
);
|
|
92
|
+
return {
|
|
93
|
+
selectedField: t,
|
|
94
|
+
allowedRelatedRoles: t ? F(t) : []
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function ee(e, r, o) {
|
|
99
|
+
if (o.startsWith("spec.dimensions."))
|
|
100
|
+
return { allowedRelatedRoles: ["dimension"] };
|
|
101
|
+
if (o === "spec.orderBy.field") {
|
|
102
|
+
const t = u(
|
|
103
|
+
e.dimensions || [],
|
|
104
|
+
r
|
|
105
|
+
);
|
|
106
|
+
return {
|
|
107
|
+
selectedField: t,
|
|
108
|
+
allowedRelatedRoles: t ? ["dimension"] : []
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function re(e, r, o) {
|
|
113
|
+
if (ne(o))
|
|
114
|
+
return { allowedRelatedRoles: ["dimension", "date"] };
|
|
115
|
+
if (de(o)) {
|
|
116
|
+
const t = u(
|
|
117
|
+
k(e),
|
|
118
|
+
r
|
|
119
|
+
);
|
|
120
|
+
return {
|
|
121
|
+
selectedField: t,
|
|
122
|
+
allowedRelatedRoles: g(t)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function oe(e) {
|
|
127
|
+
var t, i;
|
|
128
|
+
const r = M(e), o = (t = e.orderBy) != null && t.field ? u(r, e.orderBy.field) : void 0;
|
|
129
|
+
return R([
|
|
130
|
+
...r.map(
|
|
131
|
+
(a) => l(
|
|
132
|
+
a,
|
|
133
|
+
F(a)
|
|
134
|
+
)
|
|
135
|
+
),
|
|
136
|
+
...(i = e.orderBy) != null && i.field ? [
|
|
137
|
+
l(
|
|
138
|
+
m(
|
|
139
|
+
e.orderBy.field,
|
|
140
|
+
o
|
|
141
|
+
),
|
|
142
|
+
o ? F(o) : [],
|
|
143
|
+
{
|
|
144
|
+
unsupportedRelatedRoleMessage: "Joined records projections support related sort fields only when the same related field is included in spec.fields.",
|
|
145
|
+
recommendedNextStep: "Add the related sort field to spec.fields, or keep orderBy fields on the base source."
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
] : []
|
|
149
|
+
]);
|
|
150
|
+
}
|
|
151
|
+
function te(e) {
|
|
152
|
+
var o, t;
|
|
153
|
+
const r = (o = e.orderBy) != null && o.field ? u(
|
|
154
|
+
e.dimensions || [],
|
|
155
|
+
e.orderBy.field
|
|
156
|
+
) : void 0;
|
|
157
|
+
return R([
|
|
158
|
+
...e.measures.map((i) => l(i, [])),
|
|
159
|
+
...e.primaryMeasure ? [l(e.primaryMeasure, [])] : [],
|
|
160
|
+
...(e.dimensions || []).map(
|
|
161
|
+
(i) => l(i, ["dimension"])
|
|
162
|
+
),
|
|
163
|
+
...e.dateField ? [l({ ...e.dateField, role: "date" }, [])] : [],
|
|
164
|
+
...(t = e.orderBy) != null && t.field ? [
|
|
165
|
+
l(
|
|
166
|
+
m(
|
|
167
|
+
e.orderBy.field,
|
|
168
|
+
r
|
|
169
|
+
),
|
|
170
|
+
r ? ["dimension"] : [],
|
|
171
|
+
{
|
|
172
|
+
unsupportedRelatedRoleMessage: "Joined metric projections support related orderBy fields only when the same related field is declared in spec.dimensions.",
|
|
173
|
+
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."
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
] : []
|
|
177
|
+
]);
|
|
178
|
+
}
|
|
179
|
+
function ie(e) {
|
|
180
|
+
const r = [...e.rows, ...e.columns || []];
|
|
181
|
+
return R([
|
|
182
|
+
...r.map(
|
|
183
|
+
(o) => l(
|
|
184
|
+
o.field,
|
|
185
|
+
g(o.field)
|
|
186
|
+
)
|
|
187
|
+
),
|
|
188
|
+
...r.flatMap((o) => {
|
|
189
|
+
var a;
|
|
190
|
+
if (((a = o.sortBy) == null ? void 0 : a.by.kind) !== "field")
|
|
191
|
+
return [];
|
|
192
|
+
const t = o.sortBy.by.field, i = u(
|
|
193
|
+
k(e),
|
|
194
|
+
t
|
|
195
|
+
);
|
|
196
|
+
return [
|
|
197
|
+
l(
|
|
198
|
+
m(t, i),
|
|
199
|
+
g(i),
|
|
200
|
+
{
|
|
201
|
+
unsupportedRelatedRoleMessage: "Joined matrix projections support related axis sort fields only when the same related field is used as a row/column axis.",
|
|
202
|
+
recommendedNextStep: "Use a related field as a row or column axis, or keep axis sort fields on the base source."
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
];
|
|
206
|
+
}),
|
|
207
|
+
...e.values.map(
|
|
208
|
+
(o) => l(o.field, [], {
|
|
209
|
+
unsupportedRelatedRoleMessage: "Joined matrix projections support related row/column dimensions or dates only. Related value fields are not supported in this phase.",
|
|
210
|
+
recommendedNextStep: "Keep matrix values on the base source, or use governed SQL for unsupported aggregate-safe joined values."
|
|
211
|
+
})
|
|
212
|
+
),
|
|
213
|
+
...(e.sort || []).flatMap((o) => {
|
|
214
|
+
if (o.by.kind !== "field")
|
|
215
|
+
return [];
|
|
216
|
+
const t = o.by.field, i = u(
|
|
217
|
+
k(e),
|
|
218
|
+
t
|
|
219
|
+
);
|
|
220
|
+
return [
|
|
221
|
+
l(
|
|
222
|
+
m(t, i),
|
|
223
|
+
g(i),
|
|
224
|
+
{
|
|
225
|
+
unsupportedRelatedRoleMessage: "Joined matrix projections support related top-level sort fields only when the same related field is used as a row/column axis.",
|
|
226
|
+
recommendedNextStep: "Use a related field as a row or column axis, or keep matrix sort fields on the base source."
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
];
|
|
230
|
+
})
|
|
231
|
+
]);
|
|
232
|
+
}
|
|
233
|
+
function F(e) {
|
|
234
|
+
const r = e ? f(e) : void 0;
|
|
235
|
+
return r === "dimension" ? ["dimension"] : r === "date" ? ["date"] : r === "id" ? ["id"] : ["dimension", "date", "id"];
|
|
236
|
+
}
|
|
237
|
+
function g(e) {
|
|
238
|
+
const r = e ? f(e) : void 0;
|
|
239
|
+
return r === "date" ? ["date"] : r === "dimension" ? ["dimension"] : [];
|
|
240
|
+
}
|
|
241
|
+
function l(e, r, o = {}) {
|
|
242
|
+
return {
|
|
243
|
+
field: m(e),
|
|
244
|
+
allowedRelatedRoles: r,
|
|
245
|
+
...o
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function R(e) {
|
|
249
|
+
const r = [];
|
|
250
|
+
return e.forEach((o) => {
|
|
251
|
+
r.some(
|
|
252
|
+
(t) => ae(t, o)
|
|
253
|
+
) || r.push(o);
|
|
254
|
+
}), r;
|
|
255
|
+
}
|
|
256
|
+
function M(e) {
|
|
257
|
+
const r = [...e.fields];
|
|
258
|
+
return e.dateField && !r.some(
|
|
259
|
+
(o) => j(o, e.dateField)
|
|
260
|
+
) && r.push({ ...e.dateField, role: "date" }), r;
|
|
261
|
+
}
|
|
262
|
+
function ae(e, r) {
|
|
263
|
+
return B(e.field, r.field) && e.allowedRelatedRoles.join("|") === r.allowedRelatedRoles.join("|") && (e.unsupportedRelatedRoleMessage || "") === (r.unsupportedRelatedRoleMessage || "") && (e.recommendedNextStep || "") === (r.recommendedNextStep || "");
|
|
264
|
+
}
|
|
265
|
+
function j(e, r) {
|
|
266
|
+
return K(e, r);
|
|
267
|
+
}
|
|
268
|
+
function B(e, r) {
|
|
269
|
+
return j(e, r) && se(
|
|
270
|
+
f(e),
|
|
271
|
+
f(r)
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
function se(e, r) {
|
|
275
|
+
return !!(e && (!r || e === r));
|
|
276
|
+
}
|
|
277
|
+
function f(e) {
|
|
278
|
+
return H(e);
|
|
279
|
+
}
|
|
280
|
+
function ne(e) {
|
|
281
|
+
const r = e.split(".");
|
|
282
|
+
return r.length === 4 && r[0] === "spec" && (r[1] === "rows" || r[1] === "columns") && b(r[2]) && r[3] === "field";
|
|
283
|
+
}
|
|
284
|
+
function de(e) {
|
|
285
|
+
const r = e.split(".");
|
|
286
|
+
return r.length === 6 && r[0] === "spec" && (r[1] === "rows" || r[1] === "columns") && b(r[2]) && r[3] === "sortBy" && r[4] === "by" && r[5] === "field" || r.length === 5 && r[0] === "spec" && r[1] === "sort" && b(r[2]) && r[3] === "by" && r[4] === "field";
|
|
287
|
+
}
|
|
288
|
+
function b(e) {
|
|
289
|
+
return e === void 0 || e.trim() === "" ? !1 : Number.isInteger(Number(e)) && Number(e) >= 0;
|
|
290
|
+
}
|
|
291
|
+
function le({
|
|
292
|
+
intent: e,
|
|
293
|
+
field: r,
|
|
294
|
+
relativePath: o,
|
|
295
|
+
baseCatalog: t,
|
|
296
|
+
fieldCatalogs: i
|
|
297
|
+
}) {
|
|
298
|
+
const a = h(r, e.source), s = q(
|
|
299
|
+
a,
|
|
300
|
+
e.source
|
|
301
|
+
);
|
|
302
|
+
if (!s && !ue(e.source, a))
|
|
303
|
+
return {
|
|
304
|
+
ok: !1,
|
|
305
|
+
code: "invalid_source_ref",
|
|
306
|
+
message: `Field "${r.name}" references a related Semaphor source outside the query's semantic domain.`,
|
|
307
|
+
pathSuffix: ".source",
|
|
308
|
+
source: a
|
|
309
|
+
};
|
|
310
|
+
const n = s ? t : S(i, a);
|
|
311
|
+
if (!n)
|
|
312
|
+
return {
|
|
313
|
+
ok: !1,
|
|
314
|
+
code: "invalid_source_ref",
|
|
315
|
+
message: `Field "${r.name}" references a Semaphor source that is not present in the visible field catalog.`,
|
|
316
|
+
pathSuffix: ".source",
|
|
317
|
+
source: a
|
|
318
|
+
};
|
|
319
|
+
const d = v(n, r, e.source);
|
|
320
|
+
return d ? !s && !ce({
|
|
321
|
+
intent: e,
|
|
322
|
+
field: r,
|
|
323
|
+
catalogField: d,
|
|
324
|
+
relativePath: o
|
|
325
|
+
}) ? {
|
|
326
|
+
ok: !1,
|
|
327
|
+
code: "unsupported_joined_projection",
|
|
328
|
+
message: `Field "${r.name}" references a related Semaphor source, but this query kind does not support joined projections for that field yet.`,
|
|
329
|
+
pathSuffix: ".source",
|
|
330
|
+
source: a
|
|
331
|
+
} : {
|
|
332
|
+
ok: !0,
|
|
333
|
+
source: a,
|
|
334
|
+
catalogField: d,
|
|
335
|
+
usesBaseSource: s
|
|
336
|
+
} : {
|
|
337
|
+
ok: !1,
|
|
338
|
+
code: "missing_field",
|
|
339
|
+
message: `Field "${r.name}" is not visible on the selected Semaphor source.`,
|
|
340
|
+
source: a
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function ce({
|
|
344
|
+
intent: e,
|
|
345
|
+
field: r,
|
|
346
|
+
catalogField: o,
|
|
347
|
+
relativePath: t
|
|
348
|
+
}) {
|
|
349
|
+
return G({
|
|
350
|
+
intent: e,
|
|
351
|
+
field: r,
|
|
352
|
+
catalogField: o,
|
|
353
|
+
relativePath: t
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
function ue(e, r) {
|
|
357
|
+
return e.kind === "semantic" && r.kind === "semantic" && e.domainId === r.domainId;
|
|
358
|
+
}
|
|
359
|
+
function S(e, r) {
|
|
360
|
+
return e.find((o) => x(o, r));
|
|
361
|
+
}
|
|
362
|
+
function v(e, r, o) {
|
|
363
|
+
const t = h(r, o);
|
|
364
|
+
if (x(e, t))
|
|
365
|
+
return e.fields.find(
|
|
366
|
+
(i) => fe(i, r) && x(
|
|
367
|
+
e,
|
|
368
|
+
h(i, e.source)
|
|
369
|
+
)
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
function $(e) {
|
|
373
|
+
return A(e);
|
|
374
|
+
}
|
|
375
|
+
function h(e, r) {
|
|
376
|
+
return e.source || r;
|
|
377
|
+
}
|
|
378
|
+
function x(e, r) {
|
|
379
|
+
return [e.source, ...e.sourceAliases || []].some(
|
|
380
|
+
(o) => q(o, r)
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
function fe(e, r) {
|
|
384
|
+
return !!(e.name && r.name && e.name === r.name);
|
|
385
|
+
}
|
|
386
|
+
function pe(e, r = {}) {
|
|
387
|
+
const o = r.pathPrefix || "analysisOptions";
|
|
388
|
+
if (e === void 0)
|
|
389
|
+
return { ok: !0 };
|
|
390
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
391
|
+
return c(
|
|
392
|
+
o,
|
|
393
|
+
"Data App analysis options must be an object."
|
|
394
|
+
);
|
|
395
|
+
const t = e, i = {};
|
|
396
|
+
if (t.chartTitle !== void 0) {
|
|
397
|
+
if (typeof t.chartTitle != "string")
|
|
398
|
+
return c(
|
|
399
|
+
`${o}.chartTitle`,
|
|
400
|
+
'Data App analysis option "chartTitle" must be a string.'
|
|
401
|
+
);
|
|
402
|
+
i.chartTitle = t.chartTitle;
|
|
403
|
+
}
|
|
404
|
+
if (t.chartType !== void 0) {
|
|
405
|
+
if (typeof t.chartType != "string")
|
|
406
|
+
return c(
|
|
407
|
+
`${o}.chartType`,
|
|
408
|
+
'Data App analysis option "chartType" must be a string.'
|
|
409
|
+
);
|
|
410
|
+
i.chartType = t.chartType;
|
|
411
|
+
}
|
|
412
|
+
if (t.driverMode !== void 0) {
|
|
413
|
+
if (!ye(t.driverMode))
|
|
414
|
+
return c(
|
|
415
|
+
`${o}.driverMode`,
|
|
416
|
+
'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.'
|
|
417
|
+
);
|
|
418
|
+
i.driverMode = t.driverMode;
|
|
419
|
+
}
|
|
420
|
+
if (t.includePopulation !== void 0) {
|
|
421
|
+
if (typeof t.includePopulation != "boolean")
|
|
422
|
+
return c(
|
|
423
|
+
`${o}.includePopulation`,
|
|
424
|
+
'Data App analysis option "includePopulation" must be a boolean.'
|
|
425
|
+
);
|
|
426
|
+
i.includePopulation = t.includePopulation;
|
|
427
|
+
}
|
|
428
|
+
if (t.calendarContext !== void 0) {
|
|
429
|
+
const a = ge(
|
|
430
|
+
t.calendarContext,
|
|
431
|
+
{
|
|
432
|
+
pathPrefix: `${o}.calendarContext`,
|
|
433
|
+
validateTimezone: r.validateTimezone
|
|
434
|
+
}
|
|
435
|
+
);
|
|
436
|
+
if (!a.ok)
|
|
437
|
+
return a;
|
|
438
|
+
i.calendarContext = a.calendarContext;
|
|
439
|
+
}
|
|
440
|
+
return { ok: !0, analysisOptions: i };
|
|
441
|
+
}
|
|
442
|
+
function ze(e) {
|
|
443
|
+
const r = e.queries.map(
|
|
444
|
+
(i, a) => me(i, a, {
|
|
445
|
+
fieldCatalogs: e.fieldCatalogs || [],
|
|
446
|
+
requireFieldCatalog: !!e.requireFieldCatalog,
|
|
447
|
+
validateTimezone: e.validateTimezone
|
|
448
|
+
})
|
|
449
|
+
), o = r.flatMap((i) => i.diagnostics), t = r.map((i) => i.executionResult);
|
|
450
|
+
return {
|
|
451
|
+
ok: o.every((i) => i.severity !== "error"),
|
|
452
|
+
diagnostics: o,
|
|
453
|
+
queries: r,
|
|
454
|
+
intents: r.flatMap(
|
|
455
|
+
(i) => i.intent ? [i.intent] : []
|
|
456
|
+
),
|
|
457
|
+
executionResults: t
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function me(e, r, o) {
|
|
461
|
+
const t = `queries.${r}`;
|
|
462
|
+
try {
|
|
463
|
+
const i = ve(e), a = Ae(e, i), s = O(i), n = [
|
|
464
|
+
...$e({
|
|
465
|
+
querySpec: e,
|
|
466
|
+
queryId: a,
|
|
467
|
+
intent: i,
|
|
468
|
+
pathPrefix: t
|
|
469
|
+
}),
|
|
470
|
+
...s.errors.map(
|
|
471
|
+
(y) => w(y, {
|
|
472
|
+
queryHook: e.queryHook,
|
|
473
|
+
queryId: a,
|
|
474
|
+
pathPrefix: t,
|
|
475
|
+
severity: "error",
|
|
476
|
+
intent: i
|
|
477
|
+
})
|
|
478
|
+
),
|
|
479
|
+
...s.warnings.map(
|
|
480
|
+
(y) => w(y, {
|
|
481
|
+
queryHook: e.queryHook,
|
|
482
|
+
queryId: a,
|
|
483
|
+
pathPrefix: t,
|
|
484
|
+
severity: "warning",
|
|
485
|
+
intent: i
|
|
486
|
+
})
|
|
487
|
+
),
|
|
488
|
+
...Se({
|
|
489
|
+
querySpec: e,
|
|
490
|
+
queryId: a,
|
|
491
|
+
intent: i,
|
|
492
|
+
pathPrefix: t,
|
|
493
|
+
fieldCatalogs: o.fieldCatalogs,
|
|
494
|
+
requireFieldCatalog: o.requireFieldCatalog
|
|
495
|
+
}),
|
|
496
|
+
...Re({
|
|
497
|
+
querySpec: e,
|
|
498
|
+
queryId: a,
|
|
499
|
+
intent: i,
|
|
500
|
+
pathPrefix: t,
|
|
501
|
+
validateTimezone: o.validateTimezone
|
|
502
|
+
})
|
|
503
|
+
], d = Pe(s, n);
|
|
504
|
+
return {
|
|
505
|
+
queryHook: e.queryHook,
|
|
506
|
+
queryId: a,
|
|
507
|
+
intent: i,
|
|
508
|
+
diagnostics: n,
|
|
509
|
+
executionResult: P({
|
|
510
|
+
intent: i,
|
|
511
|
+
validation: d,
|
|
512
|
+
diagnostics: n
|
|
513
|
+
})
|
|
514
|
+
};
|
|
515
|
+
} catch (i) {
|
|
516
|
+
const a = {
|
|
517
|
+
severity: "error",
|
|
518
|
+
code: "invalid_query_spec",
|
|
519
|
+
message: i instanceof Error ? i.message : String(i),
|
|
520
|
+
path: t,
|
|
521
|
+
queryHook: e.queryHook,
|
|
522
|
+
queryId: N(e.spec)
|
|
523
|
+
}, s = z([a]);
|
|
524
|
+
return {
|
|
525
|
+
queryHook: e.queryHook,
|
|
526
|
+
queryId: a.queryId,
|
|
527
|
+
diagnostics: [a],
|
|
528
|
+
executionResult: P({
|
|
529
|
+
validation: s,
|
|
530
|
+
diagnostics: [a]
|
|
531
|
+
})
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function c(e, r) {
|
|
536
|
+
return {
|
|
537
|
+
ok: !1,
|
|
538
|
+
issues: [
|
|
539
|
+
{
|
|
540
|
+
code: "invalid_analysis_option",
|
|
541
|
+
message: r,
|
|
542
|
+
path: e
|
|
543
|
+
}
|
|
544
|
+
]
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function T(e) {
|
|
548
|
+
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
549
|
+
}
|
|
550
|
+
function ye(e) {
|
|
551
|
+
return e === "absolute_delta" || e === "largest_negative" || e === "largest_positive" || e === "positive_and_negative" || e === "all";
|
|
552
|
+
}
|
|
553
|
+
function he(e) {
|
|
554
|
+
return e.trim().length > 0 && !Number.isNaN(Date.parse(e));
|
|
555
|
+
}
|
|
556
|
+
function ge(e, r) {
|
|
557
|
+
var d;
|
|
558
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
559
|
+
return c(
|
|
560
|
+
r.pathPrefix,
|
|
561
|
+
'Data App analysis option "calendarContext" must be an object.'
|
|
562
|
+
);
|
|
563
|
+
const o = e, t = o.tz, i = o.weekStart, a = o.anchor, s = a && typeof a == "object" && !Array.isArray(a) ? a.iso : void 0, n = typeof t == "string" ? ((d = r.validateTimezone) == null ? void 0 : d.call(r, t)) ?? t : null;
|
|
564
|
+
return n ? typeof i != "number" || !Number.isInteger(i) || i < 0 || i > 6 ? c(
|
|
565
|
+
`${r.pathPrefix}.weekStart`,
|
|
566
|
+
'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'
|
|
567
|
+
) : a !== "now" && !(typeof s == "string" && he(s)) ? c(
|
|
568
|
+
`${r.pathPrefix}.anchor`,
|
|
569
|
+
'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'
|
|
570
|
+
) : {
|
|
571
|
+
ok: !0,
|
|
572
|
+
calendarContext: {
|
|
573
|
+
tz: n,
|
|
574
|
+
weekStart: i,
|
|
575
|
+
anchor: a
|
|
576
|
+
}
|
|
577
|
+
} : c(
|
|
578
|
+
`${r.pathPrefix}.tz`,
|
|
579
|
+
'Data App analysis option "calendarContext.tz" must be a valid timezone string.'
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
function ve(e) {
|
|
583
|
+
return qe(e.spec);
|
|
584
|
+
}
|
|
585
|
+
function qe(e) {
|
|
586
|
+
if (!T(e))
|
|
587
|
+
throw new Error("useSemaphorQuery spec must be an object.");
|
|
588
|
+
if (e.queryKind === "metric")
|
|
589
|
+
return Q(e);
|
|
590
|
+
if (e.queryKind === "analysis")
|
|
591
|
+
return E(e);
|
|
592
|
+
if (e.queryKind === "records")
|
|
593
|
+
return J(e);
|
|
594
|
+
if (e.queryKind === "sql")
|
|
595
|
+
return U(e);
|
|
596
|
+
if (e.queryKind === "matrix")
|
|
597
|
+
return W(e);
|
|
598
|
+
if (e.queryKind === "inputOptions")
|
|
599
|
+
return L(e);
|
|
600
|
+
throw new Error(
|
|
601
|
+
"useSemaphorQuery spec.queryKind must be metric, analysis, records, inputOptions, sql, or matrix."
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
function Se(e) {
|
|
605
|
+
if (e.intent.kind === "sql")
|
|
606
|
+
return [];
|
|
607
|
+
if (e.fieldCatalogs.length === 0 && !e.requireFieldCatalog)
|
|
608
|
+
return [];
|
|
609
|
+
const r = S(
|
|
610
|
+
e.fieldCatalogs,
|
|
611
|
+
e.intent.source
|
|
612
|
+
);
|
|
613
|
+
if (!r)
|
|
614
|
+
return [
|
|
615
|
+
{
|
|
616
|
+
severity: "error",
|
|
617
|
+
code: "invalid_source_ref",
|
|
618
|
+
message: `Source ref for ${e.querySpec.queryHook} does not match a visible Semaphor source.`,
|
|
619
|
+
path: `${e.pathPrefix}.spec.source`,
|
|
620
|
+
queryHook: e.querySpec.queryHook,
|
|
621
|
+
queryId: e.queryId,
|
|
622
|
+
intentId: e.intent.id,
|
|
623
|
+
source: e.intent.source
|
|
624
|
+
}
|
|
625
|
+
];
|
|
626
|
+
const o = ke({
|
|
627
|
+
...e,
|
|
628
|
+
catalog: r
|
|
629
|
+
}), t = {
|
|
630
|
+
...r,
|
|
631
|
+
fields: [
|
|
632
|
+
...r.fields,
|
|
633
|
+
..._e(e.intent, r, e.intent.source)
|
|
634
|
+
]
|
|
635
|
+
};
|
|
636
|
+
return [
|
|
637
|
+
...o,
|
|
638
|
+
...Ie({
|
|
639
|
+
...e,
|
|
640
|
+
fieldCatalogs: e.fieldCatalogs
|
|
641
|
+
}),
|
|
642
|
+
...Fe({
|
|
643
|
+
...e,
|
|
644
|
+
catalog: t,
|
|
645
|
+
fieldCatalogs: e.fieldCatalogs
|
|
646
|
+
}),
|
|
647
|
+
...be({
|
|
648
|
+
...e,
|
|
649
|
+
catalog: t,
|
|
650
|
+
fieldCatalogs: e.fieldCatalogs
|
|
651
|
+
})
|
|
652
|
+
];
|
|
653
|
+
}
|
|
654
|
+
function Ie(e) {
|
|
655
|
+
var o;
|
|
656
|
+
if (e.intent.kind !== "inputOptions" || ((o = e.intent.population) == null ? void 0 : o.kind) !== "related_population")
|
|
657
|
+
return [];
|
|
658
|
+
const r = e.intent.population.baseSource;
|
|
659
|
+
return S(e.fieldCatalogs, r) ? [] : [
|
|
660
|
+
{
|
|
661
|
+
severity: "error",
|
|
662
|
+
code: "invalid_source_ref",
|
|
663
|
+
message: "Input options related population baseSource does not match a visible Semaphor source.",
|
|
664
|
+
path: `${e.pathPrefix}.spec.population.baseSource`,
|
|
665
|
+
queryHook: e.querySpec.queryHook,
|
|
666
|
+
queryId: e.queryId,
|
|
667
|
+
intentId: e.intent.id,
|
|
668
|
+
source: r
|
|
669
|
+
}
|
|
670
|
+
];
|
|
671
|
+
}
|
|
672
|
+
function ke(e) {
|
|
673
|
+
const r = D(e.intent);
|
|
674
|
+
if (r.length === 0)
|
|
675
|
+
return [];
|
|
676
|
+
const o = [], t = /* @__PURE__ */ new Set();
|
|
677
|
+
return r.forEach((i, a) => {
|
|
678
|
+
const s = `${e.pathPrefix}.spec.derivedFields.${a}`, n = $(i.name);
|
|
679
|
+
n && (t.has(n) && o.push({
|
|
680
|
+
severity: "error",
|
|
681
|
+
code: "duplicate_derived_field",
|
|
682
|
+
message: `Derived field "${i.name}" is declared more than once.`,
|
|
683
|
+
path: `${s}.name`,
|
|
684
|
+
queryHook: e.querySpec.queryHook,
|
|
685
|
+
queryId: e.queryId,
|
|
686
|
+
intentId: e.intent.id,
|
|
687
|
+
source: e.intent.source
|
|
688
|
+
}), t.add(n), e.catalog.fields.some(
|
|
689
|
+
(d) => $(d.name) === n
|
|
690
|
+
) && o.push({
|
|
691
|
+
severity: "error",
|
|
692
|
+
code: "derived_field_name_collision",
|
|
693
|
+
message: `Derived field "${i.name}" conflicts with a field already visible on the selected Semaphor source.`,
|
|
694
|
+
path: `${s}.name`,
|
|
695
|
+
queryHook: e.querySpec.queryHook,
|
|
696
|
+
queryId: e.queryId,
|
|
697
|
+
intentId: e.intent.id,
|
|
698
|
+
source: e.intent.source
|
|
699
|
+
})), Object.entries(i.inputs || {}).forEach(([d, y]) => {
|
|
700
|
+
const p = Ce(y);
|
|
701
|
+
if (!p)
|
|
702
|
+
return;
|
|
703
|
+
const I = h(p, e.intent.source);
|
|
704
|
+
if (!q(I, e.intent.source)) {
|
|
705
|
+
o.push({
|
|
706
|
+
severity: "error",
|
|
707
|
+
code: "unsupported_derived_field_source",
|
|
708
|
+
message: `Derived field "${i.name}" input "${d}" references a different Semaphor source. App-local derived fields must use fields from the query source.`,
|
|
709
|
+
path: `${s}.inputs.${d}`,
|
|
710
|
+
queryHook: e.querySpec.queryHook,
|
|
711
|
+
queryId: e.queryId,
|
|
712
|
+
intentId: e.intent.id,
|
|
713
|
+
source: I,
|
|
714
|
+
field: p
|
|
715
|
+
});
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
v(e.catalog, p, e.intent.source) || o.push({
|
|
719
|
+
severity: "error",
|
|
720
|
+
code: "missing_field",
|
|
721
|
+
message: `Derived field "${i.name}" input "${d}" references field "${p.name}", which is not visible on the selected Semaphor source.`,
|
|
722
|
+
path: `${s}.inputs.${d}`,
|
|
723
|
+
queryHook: e.querySpec.queryHook,
|
|
724
|
+
queryId: e.queryId,
|
|
725
|
+
intentId: e.intent.id,
|
|
726
|
+
source: I,
|
|
727
|
+
field: p
|
|
728
|
+
});
|
|
729
|
+
});
|
|
730
|
+
}), o;
|
|
731
|
+
}
|
|
732
|
+
function Fe(e) {
|
|
733
|
+
return we(e.intent).flatMap(({ field: r, path: o }) => {
|
|
734
|
+
const t = le({
|
|
735
|
+
intent: e.intent,
|
|
736
|
+
field: r,
|
|
737
|
+
relativePath: o,
|
|
738
|
+
baseCatalog: e.catalog,
|
|
739
|
+
fieldCatalogs: e.fieldCatalogs
|
|
740
|
+
});
|
|
741
|
+
return t.ok ? [] : [
|
|
742
|
+
{
|
|
743
|
+
severity: "error",
|
|
744
|
+
code: t.code,
|
|
745
|
+
message: t.message,
|
|
746
|
+
path: `${e.pathPrefix}.${o}${t.pathSuffix || ""}`,
|
|
747
|
+
queryHook: e.querySpec.queryHook,
|
|
748
|
+
queryId: e.queryId,
|
|
749
|
+
intentId: e.intent.id,
|
|
750
|
+
source: t.source,
|
|
751
|
+
field: r
|
|
752
|
+
}
|
|
753
|
+
];
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
function be(e) {
|
|
757
|
+
return ("inputs" in e.intent ? e.intent.inputs || [] : []).flatMap((o, t) => {
|
|
758
|
+
if (!o.field)
|
|
759
|
+
return [];
|
|
760
|
+
const i = h(o.field, e.intent.source);
|
|
761
|
+
if (!q(i, e.intent.source)) {
|
|
762
|
+
if (xe(e.intent, i)) {
|
|
763
|
+
const a = S(e.fieldCatalogs, i);
|
|
764
|
+
return a ? v(a, o.field, i) ? [] : [
|
|
765
|
+
{
|
|
766
|
+
severity: "error",
|
|
767
|
+
code: "missing_field",
|
|
768
|
+
message: `Input "${o.inputId}" references field "${o.field.name}", which is not visible on the selected Semaphor source.`,
|
|
769
|
+
path: `${e.pathPrefix}.spec.inputs.${t}.field`,
|
|
770
|
+
queryHook: e.querySpec.queryHook,
|
|
771
|
+
queryId: e.queryId,
|
|
772
|
+
intentId: e.intent.id,
|
|
773
|
+
source: i,
|
|
774
|
+
field: o.field
|
|
775
|
+
}
|
|
776
|
+
] : [
|
|
777
|
+
{
|
|
778
|
+
severity: "error",
|
|
779
|
+
code: "invalid_source_ref",
|
|
780
|
+
message: `Input "${o.inputId}" references a Semaphor source that is not present in the visible field catalog.`,
|
|
781
|
+
path: `${e.pathPrefix}.spec.inputs.${t}.field.source`,
|
|
782
|
+
queryHook: e.querySpec.queryHook,
|
|
783
|
+
queryId: e.queryId,
|
|
784
|
+
intentId: e.intent.id,
|
|
785
|
+
source: i,
|
|
786
|
+
field: o.field
|
|
787
|
+
}
|
|
788
|
+
];
|
|
789
|
+
}
|
|
790
|
+
return [
|
|
791
|
+
{
|
|
792
|
+
severity: "error",
|
|
793
|
+
code: "unsupported_input_filter_composition",
|
|
794
|
+
message: `Input "${o.inputId}" filters a different Semaphor source than the query, and no relationship-aware semantic validation path is available for this query kind.`,
|
|
795
|
+
path: `${e.pathPrefix}.spec.inputs.${t}.field`,
|
|
796
|
+
queryHook: e.querySpec.queryHook,
|
|
797
|
+
queryId: e.queryId,
|
|
798
|
+
intentId: e.intent.id,
|
|
799
|
+
source: i,
|
|
800
|
+
field: o.field
|
|
801
|
+
}
|
|
802
|
+
];
|
|
803
|
+
}
|
|
804
|
+
return v(e.catalog, o.field, e.intent.source) ? [] : [
|
|
805
|
+
{
|
|
806
|
+
severity: "error",
|
|
807
|
+
code: "missing_field",
|
|
808
|
+
message: `Input "${o.inputId}" references field "${o.field.name}", which is not visible on the selected Semaphor source.`,
|
|
809
|
+
path: `${e.pathPrefix}.spec.inputs.${t}.field`,
|
|
810
|
+
queryHook: e.querySpec.queryHook,
|
|
811
|
+
queryId: e.queryId,
|
|
812
|
+
intentId: e.intent.id,
|
|
813
|
+
source: i,
|
|
814
|
+
field: o.field
|
|
815
|
+
}
|
|
816
|
+
];
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
function xe(e, r) {
|
|
820
|
+
return e.source.kind === "semantic" && r.kind === "semantic" && r.domainId === e.source.domainId;
|
|
821
|
+
}
|
|
822
|
+
function Re(e) {
|
|
823
|
+
if (e.querySpec.spec.queryKind !== "analysis")
|
|
824
|
+
return [];
|
|
825
|
+
const r = pe(
|
|
826
|
+
e.querySpec.spec,
|
|
827
|
+
{
|
|
828
|
+
pathPrefix: `${e.pathPrefix}.spec`,
|
|
829
|
+
validateTimezone: e.validateTimezone
|
|
830
|
+
}
|
|
831
|
+
);
|
|
832
|
+
return r.ok ? [] : r.issues.map((o) => ({
|
|
833
|
+
severity: "error",
|
|
834
|
+
code: o.code,
|
|
835
|
+
message: o.message,
|
|
836
|
+
path: o.path,
|
|
837
|
+
queryHook: e.querySpec.queryHook,
|
|
838
|
+
queryId: e.queryId,
|
|
839
|
+
intentId: e.intent.id,
|
|
840
|
+
source: e.intent.source
|
|
841
|
+
}));
|
|
842
|
+
}
|
|
843
|
+
function $e(e) {
|
|
844
|
+
return e.querySpec.spec.queryKind !== "sql" ? [] : T(e.querySpec.spec) ? Object.prototype.hasOwnProperty.call(e.querySpec.spec, "parameters") ? [
|
|
845
|
+
{
|
|
846
|
+
severity: "error",
|
|
847
|
+
code: "deprecated_sql_parameters",
|
|
848
|
+
message: "semaphor.sql uses defaultParameters for static SQL param(...) fallback values. The legacy parameters field is not supported.",
|
|
849
|
+
path: `${e.pathPrefix}.spec.parameters`,
|
|
850
|
+
queryHook: e.querySpec.queryHook,
|
|
851
|
+
queryId: e.queryId,
|
|
852
|
+
intentId: e.intent.id
|
|
853
|
+
}
|
|
854
|
+
] : [] : [];
|
|
855
|
+
}
|
|
856
|
+
function we(e) {
|
|
857
|
+
return e.kind === "metric" ? [
|
|
858
|
+
...e.measures.map((r, o) => ({
|
|
859
|
+
field: r,
|
|
860
|
+
path: `spec.measures.${o}`
|
|
861
|
+
})),
|
|
862
|
+
...e.primaryMeasure ? [{ field: e.primaryMeasure, path: "spec.primaryMeasure" }] : [],
|
|
863
|
+
...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
|
|
864
|
+
...(e.dimensions || []).map((r, o) => ({
|
|
865
|
+
field: r,
|
|
866
|
+
path: `spec.dimensions.${o}`
|
|
867
|
+
})),
|
|
868
|
+
...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : [],
|
|
869
|
+
...(e.filters || []).map((r, o) => ({
|
|
870
|
+
field: r.field,
|
|
871
|
+
path: `spec.filters.${o}.field`
|
|
872
|
+
}))
|
|
873
|
+
] : e.kind === "records" ? [
|
|
874
|
+
...e.fields.map((r, o) => ({
|
|
875
|
+
field: r,
|
|
876
|
+
path: `spec.fields.${o}`
|
|
877
|
+
})),
|
|
878
|
+
...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
|
|
879
|
+
...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : [],
|
|
880
|
+
...(e.filters || []).map((r, o) => ({
|
|
881
|
+
field: r.field,
|
|
882
|
+
path: `spec.filters.${o}.field`
|
|
883
|
+
}))
|
|
884
|
+
] : e.kind === "inputOptions" ? [
|
|
885
|
+
{ field: e.labelField, path: "spec.labelField" },
|
|
886
|
+
{ field: e.valueField, path: "spec.valueField" },
|
|
887
|
+
...e.searchField ? [{ field: e.searchField, path: "spec.searchField" }] : [],
|
|
888
|
+
...(e.disambiguationFields || []).map((r, o) => ({
|
|
889
|
+
field: r,
|
|
890
|
+
path: `spec.disambiguationFields.${o}`
|
|
891
|
+
}))
|
|
892
|
+
] : e.kind === "matrix" ? [
|
|
893
|
+
...e.rows.map((r, o) => ({
|
|
894
|
+
field: r.field,
|
|
895
|
+
path: `spec.rows.${o}.field`
|
|
896
|
+
})),
|
|
897
|
+
...e.rows.flatMap(
|
|
898
|
+
(r, o) => {
|
|
899
|
+
var t;
|
|
900
|
+
return ((t = r.sortBy) == null ? void 0 : t.by.kind) === "field" ? [
|
|
901
|
+
{
|
|
902
|
+
field: r.sortBy.by.field,
|
|
903
|
+
path: `spec.rows.${o}.sortBy.by.field`
|
|
904
|
+
}
|
|
905
|
+
] : [];
|
|
906
|
+
}
|
|
907
|
+
),
|
|
908
|
+
...(e.columns || []).map((r, o) => ({
|
|
909
|
+
field: r.field,
|
|
910
|
+
path: `spec.columns.${o}.field`
|
|
911
|
+
})),
|
|
912
|
+
...(e.columns || []).flatMap(
|
|
913
|
+
(r, o) => {
|
|
914
|
+
var t;
|
|
915
|
+
return ((t = r.sortBy) == null ? void 0 : t.by.kind) === "field" ? [
|
|
916
|
+
{
|
|
917
|
+
field: r.sortBy.by.field,
|
|
918
|
+
path: `spec.columns.${o}.sortBy.by.field`
|
|
919
|
+
}
|
|
920
|
+
] : [];
|
|
921
|
+
}
|
|
922
|
+
),
|
|
923
|
+
...e.values.map((r, o) => ({
|
|
924
|
+
field: r.field,
|
|
925
|
+
path: `spec.values.${o}.field`
|
|
926
|
+
})),
|
|
927
|
+
...(e.sort || []).flatMap(
|
|
928
|
+
(r, o) => r.by.kind === "field" ? [
|
|
929
|
+
{
|
|
930
|
+
field: r.by.field,
|
|
931
|
+
path: `spec.sort.${o}.by.field`
|
|
932
|
+
}
|
|
933
|
+
] : []
|
|
934
|
+
),
|
|
935
|
+
...(e.filters || []).map((r, o) => ({
|
|
936
|
+
field: r.field,
|
|
937
|
+
path: `spec.filters.${o}.field`
|
|
938
|
+
}))
|
|
939
|
+
] : [];
|
|
940
|
+
}
|
|
941
|
+
function D(e) {
|
|
942
|
+
return !("derivedFields" in e) || !Array.isArray(e.derivedFields) ? [] : e.derivedFields;
|
|
943
|
+
}
|
|
944
|
+
function _e(e, r, o) {
|
|
945
|
+
return D(e).map((t) => ({
|
|
946
|
+
name: t.name,
|
|
947
|
+
label: t.label,
|
|
948
|
+
role: t.resultRole,
|
|
949
|
+
dataType: t.dataType,
|
|
950
|
+
source: r.source || o,
|
|
951
|
+
...t.defaultAggregate ? { aggregate: t.defaultAggregate } : {}
|
|
952
|
+
}));
|
|
953
|
+
}
|
|
954
|
+
function Ce(e) {
|
|
955
|
+
if (!(!e || typeof e != "object"))
|
|
956
|
+
return e.field;
|
|
957
|
+
}
|
|
958
|
+
function w(e, r) {
|
|
959
|
+
return {
|
|
960
|
+
severity: r.severity,
|
|
961
|
+
code: e.code || "invalid_analytics_intent",
|
|
962
|
+
message: e.message,
|
|
963
|
+
path: e.path ? `${r.pathPrefix}.spec.${e.path}` : r.pathPrefix,
|
|
964
|
+
queryHook: r.queryHook,
|
|
965
|
+
queryId: r.queryId,
|
|
966
|
+
intentId: r.intent.id,
|
|
967
|
+
source: r.intent.source
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
function Pe(e, r) {
|
|
971
|
+
const o = z(r);
|
|
972
|
+
return {
|
|
973
|
+
ok: o.ok && e.ok,
|
|
974
|
+
errors: C([
|
|
975
|
+
...e.errors,
|
|
976
|
+
...o.errors
|
|
977
|
+
]),
|
|
978
|
+
warnings: C([
|
|
979
|
+
...e.warnings,
|
|
980
|
+
...o.warnings
|
|
981
|
+
]),
|
|
982
|
+
repairHints: [
|
|
983
|
+
...e.repairHints,
|
|
984
|
+
...o.repairHints
|
|
985
|
+
]
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
function z(e) {
|
|
989
|
+
const r = e.filter((t) => t.severity === "error").map(_), o = e.filter((t) => t.severity === "warning").map(_);
|
|
990
|
+
return {
|
|
991
|
+
ok: r.length === 0,
|
|
992
|
+
errors: r,
|
|
993
|
+
warnings: o,
|
|
994
|
+
repairHints: r.map((t) => {
|
|
995
|
+
var i, a;
|
|
996
|
+
return {
|
|
997
|
+
code: t.code,
|
|
998
|
+
message: t.message,
|
|
999
|
+
fieldRole: t.fieldRole,
|
|
1000
|
+
invalidField: (i = t.repairHint) == null ? void 0 : i.invalidField,
|
|
1001
|
+
recommendedNextStep: ((a = t.repairHint) == null ? void 0 : a.recommendedNextStep) || "Update the Data App SDK query spec to use visible Semaphor source and field refs."
|
|
1002
|
+
};
|
|
1003
|
+
})
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
function _(e) {
|
|
1007
|
+
var r;
|
|
1008
|
+
return {
|
|
1009
|
+
code: e.code,
|
|
1010
|
+
message: e.message,
|
|
1011
|
+
path: e.path,
|
|
1012
|
+
fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
|
|
1013
|
+
repairHint: {
|
|
1014
|
+
code: e.code,
|
|
1015
|
+
message: e.message,
|
|
1016
|
+
invalidField: (r = e.field) == null ? void 0 : r.name,
|
|
1017
|
+
fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
|
|
1018
|
+
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."
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
function C(e) {
|
|
1023
|
+
const r = /* @__PURE__ */ new Set();
|
|
1024
|
+
return e.filter((o) => {
|
|
1025
|
+
const t = `${o.code}:${o.path || ""}:${o.message}`;
|
|
1026
|
+
return r.has(t) ? !1 : (r.add(t), !0);
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
function P(e) {
|
|
1030
|
+
var o, t;
|
|
1031
|
+
const r = e.diagnostics.filter(
|
|
1032
|
+
(i) => i.severity === "error"
|
|
1033
|
+
);
|
|
1034
|
+
return {
|
|
1035
|
+
intentId: (o = e.intent) == null ? void 0 : o.id,
|
|
1036
|
+
status: r.length ? "failed" : "answered",
|
|
1037
|
+
resultShape: (t = e.intent) == null ? void 0 : t.kind,
|
|
1038
|
+
intent: e.intent,
|
|
1039
|
+
validation: e.validation,
|
|
1040
|
+
coverage: {
|
|
1041
|
+
answeredObligations: r.length ? [] : ["query_spec_validation"],
|
|
1042
|
+
missingObligations: r.length ? ["query_spec_validation"] : [],
|
|
1043
|
+
warnings: e.validation.warnings
|
|
1044
|
+
},
|
|
1045
|
+
missingFields: r.filter((i) => i.code === "missing_field").flatMap(
|
|
1046
|
+
(i) => {
|
|
1047
|
+
var a;
|
|
1048
|
+
return (a = i.field) != null && a.name ? [i.field.name] : [];
|
|
1049
|
+
}
|
|
1050
|
+
),
|
|
1051
|
+
warnings: e.diagnostics.filter((i) => i.severity === "warning").map((i) => i.message),
|
|
1052
|
+
metadata: {
|
|
1053
|
+
validationKind: "data_app_sdk_query_spec"
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
function Ae(e, r) {
|
|
1058
|
+
return r.id || N(e.spec);
|
|
1059
|
+
}
|
|
1060
|
+
function N(e) {
|
|
1061
|
+
if (!e || typeof e != "object" || !("id" in e))
|
|
1062
|
+
return;
|
|
1063
|
+
const r = e.id;
|
|
1064
|
+
return typeof r == "string" && r.trim() ? r : void 0;
|
|
1065
|
+
}
|
|
5
1066
|
export {
|
|
6
|
-
m as
|
|
7
|
-
|
|
1067
|
+
m as fieldWithSelectedProjectionRole,
|
|
1068
|
+
u as findMatchingRelatedProjectionField,
|
|
1069
|
+
X as isAllowedRelatedProjectionRole,
|
|
1070
|
+
k as matrixAxisFieldsForPolicy,
|
|
1071
|
+
pe as normalizeSemaphorAnalysisQueryOptions,
|
|
1072
|
+
H as normalizeSemaphorFieldRole,
|
|
1073
|
+
De as relatedProjectionFieldCandidatesForIntent,
|
|
1074
|
+
ze as validateSemaphorDataAppQuerySpecs
|
|
8
1075
|
};
|