react-semaphor 0.1.369 → 0.1.370
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/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +1 -1
- package/dist/chunks/validation-DYL3ArlL.js +1 -0
- package/dist/chunks/{validation-nOPr0mTk.js → validation-PPSpYtVf.js} +304 -207
- package/dist/chunks/validators-CgxWT8UX.js +1 -0
- package/dist/chunks/validators-DBNa-eb1.js +1799 -0
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +251 -180
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +451 -2
- package/dist/types/dashboard-assistant.d.ts +448 -2
- package/dist/types/dashboard-authoring.d.ts +159 -1
- package/dist/types/data-app-builder.d.ts +156 -1
- package/dist/types/data-app-sdk-validation.d.ts +470 -3
- package/dist/types/data-app-sdk.d.ts +490 -5
- package/dist/types/main.d.ts +156 -1
- package/package.json +1 -1
- package/dist/chunks/validation-Dsf7PydY.js +0 -1
- package/dist/chunks/validators-CVuWOHYv.js +0 -1032
- package/dist/chunks/validators-oc8qtP4q.js +0 -1
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { b
|
|
3
|
-
function
|
|
1
|
+
import { n as P, v as T } from "./validators-DBNa-eb1.js";
|
|
2
|
+
import { b, c as H, a as w } from "./source-identity-Dj3dryN9.js";
|
|
3
|
+
function A(e) {
|
|
4
4
|
var t;
|
|
5
|
-
const r =
|
|
5
|
+
const r = O(e);
|
|
6
6
|
return {
|
|
7
7
|
version: 1,
|
|
8
8
|
kind: "metric",
|
|
9
9
|
id: e.id,
|
|
10
10
|
label: e.label,
|
|
11
|
-
source:
|
|
11
|
+
source: y(e),
|
|
12
12
|
metrics: r,
|
|
13
13
|
primaryMetric: z(e, r),
|
|
14
14
|
dateField: e.dateField ? a(e.dateField, "date") : void 0,
|
|
15
15
|
timeGrain: e.timeGrain,
|
|
16
|
-
dimensions: (t = e.dimensions) == null ? void 0 : t.map((
|
|
17
|
-
comparison:
|
|
16
|
+
dimensions: (t = e.dimensions) == null ? void 0 : t.map((i) => a(i, "dimension")),
|
|
17
|
+
comparison: te(e.comparison),
|
|
18
18
|
orderBy: e.orderBy ? {
|
|
19
19
|
field: a(e.orderBy.field),
|
|
20
20
|
direction: e.orderBy.direction
|
|
21
21
|
} : void 0,
|
|
22
|
-
inputs:
|
|
22
|
+
inputs: u(e.inputs),
|
|
23
23
|
limit: e.limit
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function B(e) {
|
|
27
27
|
var t;
|
|
28
28
|
return {
|
|
29
|
-
...
|
|
29
|
+
...A(e),
|
|
30
30
|
...e.timeWindow ? { timeWindow: e.timeWindow } : {},
|
|
31
31
|
...(t = e.filters) != null && t.length ? { filters: e.filters } : {},
|
|
32
32
|
...e.analysis ? { analysis: e.analysis } : {}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Se(e) {
|
|
36
36
|
return {
|
|
37
37
|
...e.chartTitle ? { chartTitle: e.chartTitle } : {},
|
|
38
38
|
...e.chartType ? { chartType: e.chartType } : {},
|
|
@@ -44,49 +44,49 @@ function ge(e) {
|
|
|
44
44
|
function z(e, r) {
|
|
45
45
|
if (!e.primaryMetric)
|
|
46
46
|
return r[0] || { name: "", role: "measure" };
|
|
47
|
-
const t = a(e.primaryMetric, "measure"),
|
|
48
|
-
return
|
|
47
|
+
const t = a(e.primaryMetric, "measure"), i = Q(t, r), o = i.length === 1 ? i[0] : void 0;
|
|
48
|
+
return o ? M(t, o) : t;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function O(e) {
|
|
51
51
|
const r = [];
|
|
52
52
|
for (const t of e.metrics.map(
|
|
53
|
-
(
|
|
53
|
+
(i) => a(i, "measure")
|
|
54
54
|
)) {
|
|
55
55
|
if (!t.name)
|
|
56
56
|
continue;
|
|
57
|
-
const
|
|
58
|
-
(
|
|
57
|
+
const i = r.findIndex(
|
|
58
|
+
(o) => D(o, t)
|
|
59
59
|
);
|
|
60
|
-
if (
|
|
60
|
+
if (i === -1) {
|
|
61
61
|
r.push(t);
|
|
62
62
|
continue;
|
|
63
63
|
}
|
|
64
|
-
r[
|
|
65
|
-
r[
|
|
64
|
+
r[i] = M(
|
|
65
|
+
r[i],
|
|
66
66
|
t
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
return r;
|
|
70
70
|
}
|
|
71
|
-
function O(e, r) {
|
|
72
|
-
return S(e, r) && f(e) === f(r);
|
|
73
|
-
}
|
|
74
71
|
function D(e, r) {
|
|
75
|
-
return
|
|
72
|
+
return b(e, r) && c(e) === c(r);
|
|
76
73
|
}
|
|
77
74
|
function j(e, r) {
|
|
78
|
-
return
|
|
75
|
+
return c(r) === c(e);
|
|
79
76
|
}
|
|
80
77
|
function K(e, r) {
|
|
78
|
+
return r.name !== e.name || e.source && !b(r, e) ? !1 : j(e, r);
|
|
79
|
+
}
|
|
80
|
+
function Q(e, r) {
|
|
81
81
|
const t = r.filter(
|
|
82
|
-
(
|
|
82
|
+
(i) => K(e, i)
|
|
83
83
|
);
|
|
84
84
|
return e.aggregate !== void 0, t;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function c(e) {
|
|
87
87
|
return (e.aggregate || "SUM").toUpperCase();
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function M(e, r) {
|
|
90
90
|
if (e.aggregate && r.aggregate && e.aggregate !== r.aggregate)
|
|
91
91
|
throw new Error(
|
|
92
92
|
`Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${r.aggregate}.`
|
|
@@ -96,21 +96,21 @@ function A(e, r) {
|
|
|
96
96
|
aggregate: e.aggregate || r.aggregate
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function E(e) {
|
|
100
100
|
var t;
|
|
101
101
|
if ("sort" in e)
|
|
102
102
|
throw new Error(
|
|
103
103
|
"semaphor.records supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet."
|
|
104
104
|
);
|
|
105
|
-
if (!
|
|
105
|
+
if (!re(e))
|
|
106
106
|
throw new Error("semaphor.records needs at least one field.");
|
|
107
|
-
const r =
|
|
107
|
+
const r = N(e.fields);
|
|
108
108
|
return {
|
|
109
109
|
version: 1,
|
|
110
110
|
kind: "records",
|
|
111
111
|
id: e.id,
|
|
112
112
|
label: e.label,
|
|
113
|
-
source:
|
|
113
|
+
source: y(e),
|
|
114
114
|
fields: r,
|
|
115
115
|
dateField: e.dateField ? a(e.dateField, "date") : void 0,
|
|
116
116
|
timeGrain: e.timeGrain,
|
|
@@ -120,12 +120,12 @@ function Q(e) {
|
|
|
120
120
|
field: a(e.orderBy.field),
|
|
121
121
|
direction: e.orderBy.direction
|
|
122
122
|
} : void 0,
|
|
123
|
-
inputs:
|
|
123
|
+
inputs: u(e.inputs),
|
|
124
124
|
limit: e.limit,
|
|
125
125
|
...e.pagination ? { pagination: e.pagination } : {}
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function N(e) {
|
|
129
129
|
return e.map((r) => {
|
|
130
130
|
const t = a(r);
|
|
131
131
|
if (!t.role)
|
|
@@ -135,19 +135,19 @@ function E(e) {
|
|
|
135
135
|
return t;
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function V(e) {
|
|
139
139
|
return {
|
|
140
140
|
version: 1,
|
|
141
141
|
kind: "inputOptions",
|
|
142
142
|
id: e.id,
|
|
143
143
|
label: e.label,
|
|
144
|
-
source:
|
|
144
|
+
source: y(e),
|
|
145
145
|
field: a(e.field, "dimension"),
|
|
146
146
|
search: e.search,
|
|
147
147
|
limit: e.limit
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function L(e) {
|
|
151
151
|
var r;
|
|
152
152
|
return {
|
|
153
153
|
version: 1,
|
|
@@ -159,13 +159,60 @@ function W(e) {
|
|
|
159
159
|
...e.defaultParameters ? { defaultParameters: e.defaultParameters } : {},
|
|
160
160
|
...e.pythonCode ? { pythonCode: e.pythonCode } : {},
|
|
161
161
|
...(r = e.fields) != null && r.length ? { fields: e.fields.map((t) => a(t)) } : {},
|
|
162
|
-
inputs:
|
|
162
|
+
inputs: u(e.inputs),
|
|
163
163
|
limit: e.limit,
|
|
164
164
|
...e.pagination ? { pagination: e.pagination } : {},
|
|
165
165
|
rationale: e.rationale
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
+
function W(e) {
|
|
169
|
+
var r, t;
|
|
170
|
+
return {
|
|
171
|
+
version: 1,
|
|
172
|
+
kind: "matrix",
|
|
173
|
+
id: e.id,
|
|
174
|
+
label: e.label,
|
|
175
|
+
source: y(e),
|
|
176
|
+
rows: e.rows.map((i) => g(i, "dimension")),
|
|
177
|
+
...e.columns ? {
|
|
178
|
+
columns: e.columns.map(
|
|
179
|
+
(i) => g(i, "dimension")
|
|
180
|
+
)
|
|
181
|
+
} : {},
|
|
182
|
+
values: e.values.map(U),
|
|
183
|
+
...(r = e.filters) != null && r.length ? { filters: e.filters } : {},
|
|
184
|
+
inputs: u(e.inputs),
|
|
185
|
+
...e.totals ? { totals: e.totals } : {},
|
|
186
|
+
...(t = e.sort) != null && t.length ? { sort: e.sort } : {},
|
|
187
|
+
...e.expansion ? { expansion: e.expansion } : {},
|
|
188
|
+
...e.layout ? { layout: e.layout } : {},
|
|
189
|
+
...e.displayLimits ? { displayLimits: e.displayLimits } : {}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function g(e, r) {
|
|
193
|
+
return G(e) ? {
|
|
194
|
+
...e,
|
|
195
|
+
field: a(e.field, r)
|
|
196
|
+
} : {
|
|
197
|
+
field: a(e, r)
|
|
198
|
+
};
|
|
199
|
+
}
|
|
168
200
|
function U(e) {
|
|
201
|
+
return J(e) ? {
|
|
202
|
+
...e,
|
|
203
|
+
field: a(e.field, "measure")
|
|
204
|
+
} : {
|
|
205
|
+
field: a(e, "measure"),
|
|
206
|
+
aggregate: e.aggregate
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function G(e) {
|
|
210
|
+
return "field" in e;
|
|
211
|
+
}
|
|
212
|
+
function J(e) {
|
|
213
|
+
return "field" in e;
|
|
214
|
+
}
|
|
215
|
+
function X(e) {
|
|
169
216
|
if ("toAnalyticsInput" in e) {
|
|
170
217
|
const n = e.toAnalyticsInput();
|
|
171
218
|
return {
|
|
@@ -177,7 +224,7 @@ function U(e) {
|
|
|
177
224
|
};
|
|
178
225
|
}
|
|
179
226
|
if ("id" in e) {
|
|
180
|
-
const n =
|
|
227
|
+
const n = x(e);
|
|
181
228
|
return {
|
|
182
229
|
inputId: n.inputId,
|
|
183
230
|
kind: n.kind,
|
|
@@ -186,31 +233,31 @@ function U(e) {
|
|
|
186
233
|
...n.field ? { field: n.field } : {}
|
|
187
234
|
};
|
|
188
235
|
}
|
|
189
|
-
const r = "kind" in e ? e.kind : void 0, t = "operator" in e ?
|
|
236
|
+
const r = "kind" in e ? e.kind : void 0, t = "operator" in e ? $(e.operator, e.inputId) : void 0, i = "controlRole" in e ? e.controlRole : "role" in e ? e.role : void 0, o = Y(i) ? i : void 0;
|
|
190
237
|
return {
|
|
191
238
|
inputId: e.inputId,
|
|
192
239
|
...r ? { kind: r } : {},
|
|
193
|
-
...
|
|
240
|
+
...o ? { controlRole: o } : {},
|
|
194
241
|
...t ? { operator: t } : {},
|
|
195
242
|
...e.field ? { field: e.field } : {}
|
|
196
243
|
};
|
|
197
244
|
}
|
|
198
|
-
function
|
|
245
|
+
function Y(e) {
|
|
199
246
|
return e === "grain" || e === "metric" || e === "dimension" || e === "aggregation" || e === "sqlParam";
|
|
200
247
|
}
|
|
201
|
-
function
|
|
202
|
-
const r =
|
|
248
|
+
function be(e) {
|
|
249
|
+
const r = u(e);
|
|
203
250
|
return r.length > 0 ? r : void 0;
|
|
204
251
|
}
|
|
205
|
-
function
|
|
206
|
-
return (e || []).map(
|
|
252
|
+
function Z(e) {
|
|
253
|
+
return (e || []).map(ee);
|
|
207
254
|
}
|
|
208
|
-
function
|
|
209
|
-
return
|
|
255
|
+
function we(e) {
|
|
256
|
+
return Z(e).filter((r) => r.isActive);
|
|
210
257
|
}
|
|
211
|
-
function
|
|
258
|
+
function x(e) {
|
|
212
259
|
if (e.kind === "filter") {
|
|
213
|
-
const r =
|
|
260
|
+
const r = $(e.operator, e.id);
|
|
214
261
|
return {
|
|
215
262
|
inputId: e.id,
|
|
216
263
|
kind: e.kind,
|
|
@@ -226,7 +273,7 @@ function M(e) {
|
|
|
226
273
|
controlRole: e.role
|
|
227
274
|
};
|
|
228
275
|
}
|
|
229
|
-
function
|
|
276
|
+
function Ae(e = []) {
|
|
230
277
|
return e.map(
|
|
231
278
|
(r) => typeof r == "object" ? r : {
|
|
232
279
|
label: String(r),
|
|
@@ -234,16 +281,16 @@ function Ie(e = []) {
|
|
|
234
281
|
}
|
|
235
282
|
);
|
|
236
283
|
}
|
|
237
|
-
function
|
|
284
|
+
function v(e) {
|
|
238
285
|
return e == null ? !1 : Array.isArray(e) ? e.length > 0 : typeof e == "string" ? e.trim().length > 0 : !0;
|
|
239
286
|
}
|
|
240
|
-
function
|
|
287
|
+
function ee(e) {
|
|
241
288
|
if ("toAnalyticsInput" in e)
|
|
242
289
|
return e.toAnalyticsInput();
|
|
243
290
|
if ("kind" in e && "isActive" in e)
|
|
244
291
|
return e;
|
|
245
292
|
if ("id" in e) {
|
|
246
|
-
const r =
|
|
293
|
+
const r = x(e), t = Object.prototype.hasOwnProperty.call(e, "value") ? e.value : e.defaultValue;
|
|
247
294
|
return {
|
|
248
295
|
inputId: r.inputId,
|
|
249
296
|
kind: r.kind,
|
|
@@ -252,22 +299,22 @@ function L(e) {
|
|
|
252
299
|
...r.operator ? { operator: r.operator } : {},
|
|
253
300
|
...r.controlRole ? { controlRole: r.controlRole } : {},
|
|
254
301
|
value: t,
|
|
255
|
-
isActive:
|
|
302
|
+
isActive: v(t)
|
|
256
303
|
};
|
|
257
304
|
}
|
|
258
305
|
return {
|
|
259
306
|
...e,
|
|
260
307
|
kind: "filter",
|
|
261
|
-
isActive:
|
|
308
|
+
isActive: v(
|
|
262
309
|
e.value
|
|
263
310
|
),
|
|
264
311
|
value: e.value
|
|
265
312
|
};
|
|
266
313
|
}
|
|
267
|
-
function
|
|
314
|
+
function y(e) {
|
|
268
315
|
return e.source;
|
|
269
316
|
}
|
|
270
|
-
function
|
|
317
|
+
function re(e) {
|
|
271
318
|
var r;
|
|
272
319
|
return !!((r = e.fields) != null && r.length);
|
|
273
320
|
}
|
|
@@ -277,24 +324,24 @@ function a(e, r) {
|
|
|
277
324
|
role: e.role || r
|
|
278
325
|
};
|
|
279
326
|
}
|
|
280
|
-
function
|
|
281
|
-
return (e || []).map(
|
|
327
|
+
function u(e) {
|
|
328
|
+
return (e || []).map(X);
|
|
282
329
|
}
|
|
283
|
-
function
|
|
330
|
+
function te(e) {
|
|
284
331
|
if (e)
|
|
285
332
|
return e;
|
|
286
333
|
}
|
|
287
|
-
function
|
|
334
|
+
function $(e, r) {
|
|
288
335
|
if (e === void 0)
|
|
289
336
|
return;
|
|
290
|
-
const t =
|
|
337
|
+
const t = P(e);
|
|
291
338
|
if (!t)
|
|
292
339
|
throw new Error(
|
|
293
340
|
`useSemaphorInput "${r}" uses unsupported filter operator "${e}".`
|
|
294
341
|
);
|
|
295
342
|
return t;
|
|
296
343
|
}
|
|
297
|
-
function
|
|
344
|
+
function ie(e, r = {}) {
|
|
298
345
|
const t = r.pathPrefix || "analysisOptions";
|
|
299
346
|
if (e === void 0)
|
|
300
347
|
return { ok: !0 };
|
|
@@ -303,42 +350,42 @@ function Y(e, r = {}) {
|
|
|
303
350
|
t,
|
|
304
351
|
"Data App analysis options must be an object."
|
|
305
352
|
);
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
if (typeof
|
|
353
|
+
const i = e, o = {};
|
|
354
|
+
if (i.chartTitle !== void 0) {
|
|
355
|
+
if (typeof i.chartTitle != "string")
|
|
309
356
|
return s(
|
|
310
357
|
`${t}.chartTitle`,
|
|
311
358
|
'Data App analysis option "chartTitle" must be a string.'
|
|
312
359
|
);
|
|
313
|
-
|
|
360
|
+
o.chartTitle = i.chartTitle;
|
|
314
361
|
}
|
|
315
|
-
if (
|
|
316
|
-
if (typeof
|
|
362
|
+
if (i.chartType !== void 0) {
|
|
363
|
+
if (typeof i.chartType != "string")
|
|
317
364
|
return s(
|
|
318
365
|
`${t}.chartType`,
|
|
319
366
|
'Data App analysis option "chartType" must be a string.'
|
|
320
367
|
);
|
|
321
|
-
|
|
368
|
+
o.chartType = i.chartType;
|
|
322
369
|
}
|
|
323
|
-
if (
|
|
324
|
-
if (!
|
|
370
|
+
if (i.driverMode !== void 0) {
|
|
371
|
+
if (!ne(i.driverMode))
|
|
325
372
|
return s(
|
|
326
373
|
`${t}.driverMode`,
|
|
327
374
|
'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.'
|
|
328
375
|
);
|
|
329
|
-
|
|
376
|
+
o.driverMode = i.driverMode;
|
|
330
377
|
}
|
|
331
|
-
if (
|
|
332
|
-
if (typeof
|
|
378
|
+
if (i.includePopulation !== void 0) {
|
|
379
|
+
if (typeof i.includePopulation != "boolean")
|
|
333
380
|
return s(
|
|
334
381
|
`${t}.includePopulation`,
|
|
335
382
|
'Data App analysis option "includePopulation" must be a boolean.'
|
|
336
383
|
);
|
|
337
|
-
|
|
384
|
+
o.includePopulation = i.includePopulation;
|
|
338
385
|
}
|
|
339
|
-
if (
|
|
340
|
-
const n =
|
|
341
|
-
|
|
386
|
+
if (i.calendarContext !== void 0) {
|
|
387
|
+
const n = se(
|
|
388
|
+
i.calendarContext,
|
|
342
389
|
{
|
|
343
390
|
pathPrefix: `${t}.calendarContext`,
|
|
344
391
|
validateTimezone: r.validateTimezone
|
|
@@ -346,97 +393,97 @@ function Y(e, r = {}) {
|
|
|
346
393
|
);
|
|
347
394
|
if (!n.ok)
|
|
348
395
|
return n;
|
|
349
|
-
|
|
396
|
+
o.calendarContext = n.calendarContext;
|
|
350
397
|
}
|
|
351
|
-
return { ok: !0, analysisOptions:
|
|
398
|
+
return { ok: !0, analysisOptions: o };
|
|
352
399
|
}
|
|
353
|
-
function
|
|
400
|
+
function Me(e) {
|
|
354
401
|
const r = e.queries.map(
|
|
355
|
-
(
|
|
402
|
+
(o, n) => oe(o, n, {
|
|
356
403
|
fieldCatalogs: e.fieldCatalogs || [],
|
|
357
404
|
requireFieldCatalog: !!e.requireFieldCatalog,
|
|
358
405
|
validateTimezone: e.validateTimezone
|
|
359
406
|
})
|
|
360
|
-
), t = r.flatMap((
|
|
407
|
+
), t = r.flatMap((o) => o.diagnostics), i = r.map((o) => o.executionResult);
|
|
361
408
|
return {
|
|
362
|
-
ok: t.every((
|
|
409
|
+
ok: t.every((o) => o.severity !== "error"),
|
|
363
410
|
diagnostics: t,
|
|
364
411
|
queries: r,
|
|
365
412
|
intents: r.flatMap(
|
|
366
|
-
(
|
|
413
|
+
(o) => o.intent ? [o.intent] : []
|
|
367
414
|
),
|
|
368
|
-
executionResults:
|
|
415
|
+
executionResults: i
|
|
369
416
|
};
|
|
370
417
|
}
|
|
371
|
-
function
|
|
372
|
-
const
|
|
418
|
+
function oe(e, r, t) {
|
|
419
|
+
const i = `queries.${r}`;
|
|
373
420
|
try {
|
|
374
|
-
const
|
|
375
|
-
...
|
|
421
|
+
const o = de(e), n = qe(e, o), d = T(o), l = [
|
|
422
|
+
...ye({
|
|
376
423
|
querySpec: e,
|
|
377
424
|
queryId: n,
|
|
378
|
-
intent:
|
|
379
|
-
pathPrefix:
|
|
425
|
+
intent: o,
|
|
426
|
+
pathPrefix: i
|
|
380
427
|
}),
|
|
381
428
|
...d.errors.map(
|
|
382
|
-
(
|
|
429
|
+
(p) => q(p, {
|
|
383
430
|
queryHook: e.queryHook,
|
|
384
431
|
queryId: n,
|
|
385
|
-
pathPrefix:
|
|
432
|
+
pathPrefix: i,
|
|
386
433
|
severity: "error",
|
|
387
|
-
intent:
|
|
434
|
+
intent: o
|
|
388
435
|
})
|
|
389
436
|
),
|
|
390
437
|
...d.warnings.map(
|
|
391
|
-
(
|
|
438
|
+
(p) => q(p, {
|
|
392
439
|
queryHook: e.queryHook,
|
|
393
440
|
queryId: n,
|
|
394
|
-
pathPrefix:
|
|
441
|
+
pathPrefix: i,
|
|
395
442
|
severity: "warning",
|
|
396
|
-
intent:
|
|
443
|
+
intent: o
|
|
397
444
|
})
|
|
398
445
|
),
|
|
399
|
-
...
|
|
446
|
+
...ue({
|
|
400
447
|
querySpec: e,
|
|
401
448
|
queryId: n,
|
|
402
|
-
intent:
|
|
403
|
-
pathPrefix:
|
|
449
|
+
intent: o,
|
|
450
|
+
pathPrefix: i,
|
|
404
451
|
fieldCatalogs: t.fieldCatalogs,
|
|
405
452
|
requireFieldCatalog: t.requireFieldCatalog
|
|
406
453
|
}),
|
|
407
|
-
...
|
|
454
|
+
...me({
|
|
408
455
|
querySpec: e,
|
|
409
456
|
queryId: n,
|
|
410
|
-
intent:
|
|
411
|
-
pathPrefix:
|
|
457
|
+
intent: o,
|
|
458
|
+
pathPrefix: i,
|
|
412
459
|
validateTimezone: t.validateTimezone
|
|
413
460
|
})
|
|
414
|
-
],
|
|
461
|
+
], f = ve(d, l);
|
|
415
462
|
return {
|
|
416
463
|
queryHook: e.queryHook,
|
|
417
464
|
queryId: n,
|
|
418
|
-
intent:
|
|
465
|
+
intent: o,
|
|
419
466
|
diagnostics: l,
|
|
420
|
-
executionResult:
|
|
421
|
-
intent:
|
|
422
|
-
validation:
|
|
467
|
+
executionResult: S({
|
|
468
|
+
intent: o,
|
|
469
|
+
validation: f,
|
|
423
470
|
diagnostics: l
|
|
424
471
|
})
|
|
425
472
|
};
|
|
426
|
-
} catch (
|
|
473
|
+
} catch (o) {
|
|
427
474
|
const n = {
|
|
428
475
|
severity: "error",
|
|
429
476
|
code: "invalid_query_spec",
|
|
430
|
-
message:
|
|
431
|
-
path:
|
|
477
|
+
message: o instanceof Error ? o.message : String(o),
|
|
478
|
+
path: i,
|
|
432
479
|
queryHook: e.queryHook,
|
|
433
|
-
queryId:
|
|
480
|
+
queryId: F(e.spec)
|
|
434
481
|
}, d = R([n]);
|
|
435
482
|
return {
|
|
436
483
|
queryHook: e.queryHook,
|
|
437
484
|
queryId: n.queryId,
|
|
438
485
|
diagnostics: [n],
|
|
439
|
-
executionResult:
|
|
486
|
+
executionResult: S({
|
|
440
487
|
validation: d,
|
|
441
488
|
diagnostics: [n]
|
|
442
489
|
})
|
|
@@ -455,34 +502,34 @@ function s(e, r) {
|
|
|
455
502
|
]
|
|
456
503
|
};
|
|
457
504
|
}
|
|
458
|
-
function
|
|
505
|
+
function _(e) {
|
|
459
506
|
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
460
507
|
}
|
|
461
|
-
function
|
|
508
|
+
function ne(e) {
|
|
462
509
|
return e === "absolute_delta" || e === "largest_negative" || e === "largest_positive" || e === "positive_and_negative" || e === "all";
|
|
463
510
|
}
|
|
464
|
-
function
|
|
511
|
+
function ae(e) {
|
|
465
512
|
return e.trim().length > 0 && !Number.isNaN(Date.parse(e));
|
|
466
513
|
}
|
|
467
|
-
function
|
|
468
|
-
var
|
|
514
|
+
function se(e, r) {
|
|
515
|
+
var f;
|
|
469
516
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
470
517
|
return s(
|
|
471
518
|
r.pathPrefix,
|
|
472
519
|
'Data App analysis option "calendarContext" must be an object.'
|
|
473
520
|
);
|
|
474
|
-
const t = e,
|
|
475
|
-
return l ? typeof
|
|
521
|
+
const t = e, i = t.tz, o = t.weekStart, n = t.anchor, d = n && typeof n == "object" && !Array.isArray(n) ? n.iso : void 0, l = typeof i == "string" ? ((f = r.validateTimezone) == null ? void 0 : f.call(r, i)) ?? i : null;
|
|
522
|
+
return l ? typeof o != "number" || !Number.isInteger(o) || o < 0 || o > 6 ? s(
|
|
476
523
|
`${r.pathPrefix}.weekStart`,
|
|
477
524
|
'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'
|
|
478
|
-
) : n !== "now" && !(typeof d == "string" &&
|
|
525
|
+
) : n !== "now" && !(typeof d == "string" && ae(d)) ? s(
|
|
479
526
|
`${r.pathPrefix}.anchor`,
|
|
480
527
|
'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'
|
|
481
528
|
) : {
|
|
482
529
|
ok: !0,
|
|
483
530
|
calendarContext: {
|
|
484
531
|
tz: l,
|
|
485
|
-
weekStart:
|
|
532
|
+
weekStart: o,
|
|
486
533
|
anchor: n
|
|
487
534
|
}
|
|
488
535
|
} : s(
|
|
@@ -490,41 +537,43 @@ function te(e, r) {
|
|
|
490
537
|
'Data App analysis option "calendarContext.tz" must be a valid timezone string.'
|
|
491
538
|
);
|
|
492
539
|
}
|
|
493
|
-
function
|
|
494
|
-
return
|
|
540
|
+
function de(e) {
|
|
541
|
+
return le(e.spec);
|
|
495
542
|
}
|
|
496
|
-
function
|
|
497
|
-
if (!
|
|
543
|
+
function le(e) {
|
|
544
|
+
if (!_(e))
|
|
498
545
|
throw new Error("useSemaphorQuery spec must be an object.");
|
|
499
546
|
if (e.queryKind === "metric")
|
|
500
|
-
return
|
|
547
|
+
return A(e);
|
|
501
548
|
if (e.queryKind === "analysis")
|
|
502
|
-
return
|
|
549
|
+
return B(e);
|
|
503
550
|
if (e.queryKind === "records")
|
|
504
|
-
return
|
|
551
|
+
return E(e);
|
|
505
552
|
if (e.queryKind === "sql")
|
|
553
|
+
return L(e);
|
|
554
|
+
if (e.queryKind === "matrix")
|
|
506
555
|
return W(e);
|
|
507
556
|
if (e.queryKind === "inputOptions")
|
|
508
|
-
return
|
|
557
|
+
return V(e);
|
|
509
558
|
throw new Error(
|
|
510
|
-
"useSemaphorQuery spec.queryKind must be metric, analysis, records, inputOptions, or
|
|
559
|
+
"useSemaphorQuery spec.queryKind must be metric, analysis, records, inputOptions, sql, or matrix."
|
|
511
560
|
);
|
|
512
561
|
}
|
|
513
|
-
function
|
|
562
|
+
function ue(e) {
|
|
514
563
|
if (e.intent.kind === "sql")
|
|
515
564
|
return [];
|
|
516
565
|
if (e.fieldCatalogs.length === 0 && !e.requireFieldCatalog)
|
|
517
566
|
return [];
|
|
518
|
-
const r =
|
|
567
|
+
const r = he(
|
|
519
568
|
e.fieldCatalogs,
|
|
520
569
|
e.intent.source
|
|
521
570
|
);
|
|
522
571
|
return r ? [
|
|
523
|
-
...
|
|
572
|
+
...fe({
|
|
524
573
|
...e,
|
|
525
574
|
catalog: r
|
|
526
575
|
}),
|
|
527
|
-
...
|
|
576
|
+
...ce({
|
|
528
577
|
...e,
|
|
529
578
|
catalog: r
|
|
530
579
|
})
|
|
@@ -541,8 +590,8 @@ function ne(e) {
|
|
|
541
590
|
}
|
|
542
591
|
];
|
|
543
592
|
}
|
|
544
|
-
function
|
|
545
|
-
return
|
|
593
|
+
function fe(e) {
|
|
594
|
+
return pe(e.intent).flatMap(({ field: r, path: t }) => C(e.catalog, r, e.intent.source) ? [] : [
|
|
546
595
|
{
|
|
547
596
|
severity: "error",
|
|
548
597
|
code: "missing_field",
|
|
@@ -551,26 +600,26 @@ function ae(e) {
|
|
|
551
600
|
queryHook: e.querySpec.queryHook,
|
|
552
601
|
queryId: e.queryId,
|
|
553
602
|
intentId: e.intent.id,
|
|
554
|
-
source:
|
|
603
|
+
source: m(r, e.intent.source),
|
|
555
604
|
field: r
|
|
556
605
|
}
|
|
557
606
|
]);
|
|
558
607
|
}
|
|
559
|
-
function
|
|
560
|
-
return ("inputs" in e.intent ? e.intent.inputs || [] : []).flatMap((t,
|
|
608
|
+
function ce(e) {
|
|
609
|
+
return ("inputs" in e.intent ? e.intent.inputs || [] : []).flatMap((t, i) => {
|
|
561
610
|
if (!t.field)
|
|
562
611
|
return [];
|
|
563
|
-
const
|
|
564
|
-
return
|
|
612
|
+
const o = m(t.field, e.intent.source);
|
|
613
|
+
return w(o, e.intent.source) ? C(e.catalog, t.field, e.intent.source) ? [] : [
|
|
565
614
|
{
|
|
566
615
|
severity: "error",
|
|
567
616
|
code: "missing_field",
|
|
568
617
|
message: `Input "${t.inputId}" references field "${t.field.name}", which is not visible on the selected Semaphor source.`,
|
|
569
|
-
path: `${e.pathPrefix}.spec.inputs.${
|
|
618
|
+
path: `${e.pathPrefix}.spec.inputs.${i}.field`,
|
|
570
619
|
queryHook: e.querySpec.queryHook,
|
|
571
620
|
queryId: e.queryId,
|
|
572
621
|
intentId: e.intent.id,
|
|
573
|
-
source:
|
|
622
|
+
source: o,
|
|
574
623
|
field: t.field
|
|
575
624
|
}
|
|
576
625
|
] : [
|
|
@@ -578,20 +627,20 @@ function se(e) {
|
|
|
578
627
|
severity: "error",
|
|
579
628
|
code: "unsupported_input_filter_composition",
|
|
580
629
|
message: `Input "${t.inputId}" filters a different Semaphor source than the query. Cross-source Data App inputs are not supported yet.`,
|
|
581
|
-
path: `${e.pathPrefix}.spec.inputs.${
|
|
630
|
+
path: `${e.pathPrefix}.spec.inputs.${i}.field`,
|
|
582
631
|
queryHook: e.querySpec.queryHook,
|
|
583
632
|
queryId: e.queryId,
|
|
584
633
|
intentId: e.intent.id,
|
|
585
|
-
source:
|
|
634
|
+
source: o,
|
|
586
635
|
field: t.field
|
|
587
636
|
}
|
|
588
637
|
];
|
|
589
638
|
});
|
|
590
639
|
}
|
|
591
|
-
function
|
|
640
|
+
function me(e) {
|
|
592
641
|
if (e.querySpec.spec.queryKind !== "analysis")
|
|
593
642
|
return [];
|
|
594
|
-
const r =
|
|
643
|
+
const r = ie(
|
|
595
644
|
e.querySpec.spec,
|
|
596
645
|
{
|
|
597
646
|
pathPrefix: `${e.pathPrefix}.spec`,
|
|
@@ -609,8 +658,8 @@ function de(e) {
|
|
|
609
658
|
source: e.intent.source
|
|
610
659
|
}));
|
|
611
660
|
}
|
|
612
|
-
function
|
|
613
|
-
return e.querySpec.spec.queryKind !== "sql" ? [] :
|
|
661
|
+
function ye(e) {
|
|
662
|
+
return e.querySpec.spec.queryKind !== "sql" ? [] : _(e.querySpec.spec) ? Object.prototype.hasOwnProperty.call(e.querySpec.spec, "parameters") ? [
|
|
614
663
|
{
|
|
615
664
|
severity: "error",
|
|
616
665
|
code: "deprecated_sql_parameters",
|
|
@@ -622,7 +671,7 @@ function le(e) {
|
|
|
622
671
|
}
|
|
623
672
|
] : [] : [];
|
|
624
673
|
}
|
|
625
|
-
function
|
|
674
|
+
function pe(e) {
|
|
626
675
|
return e.kind === "metric" ? [
|
|
627
676
|
...e.metrics.map((r, t) => ({
|
|
628
677
|
field: r,
|
|
@@ -650,33 +699,80 @@ function ue(e) {
|
|
|
650
699
|
field: r.field,
|
|
651
700
|
path: `spec.filters.${t}.field`
|
|
652
701
|
}))
|
|
653
|
-
] : e.kind === "inputOptions" ? [{ field: e.field, path: "spec.field" }] : [
|
|
702
|
+
] : e.kind === "inputOptions" ? [{ field: e.field, path: "spec.field" }] : e.kind === "matrix" ? [
|
|
703
|
+
...e.rows.map((r, t) => ({
|
|
704
|
+
field: r.field,
|
|
705
|
+
path: `spec.rows.${t}.field`
|
|
706
|
+
})),
|
|
707
|
+
...e.rows.flatMap(
|
|
708
|
+
(r, t) => {
|
|
709
|
+
var i;
|
|
710
|
+
return ((i = r.sortBy) == null ? void 0 : i.by.kind) === "field" ? [
|
|
711
|
+
{
|
|
712
|
+
field: r.sortBy.by.field,
|
|
713
|
+
path: `spec.rows.${t}.sortBy.by.field`
|
|
714
|
+
}
|
|
715
|
+
] : [];
|
|
716
|
+
}
|
|
717
|
+
),
|
|
718
|
+
...(e.columns || []).map((r, t) => ({
|
|
719
|
+
field: r.field,
|
|
720
|
+
path: `spec.columns.${t}.field`
|
|
721
|
+
})),
|
|
722
|
+
...(e.columns || []).flatMap(
|
|
723
|
+
(r, t) => {
|
|
724
|
+
var i;
|
|
725
|
+
return ((i = r.sortBy) == null ? void 0 : i.by.kind) === "field" ? [
|
|
726
|
+
{
|
|
727
|
+
field: r.sortBy.by.field,
|
|
728
|
+
path: `spec.columns.${t}.sortBy.by.field`
|
|
729
|
+
}
|
|
730
|
+
] : [];
|
|
731
|
+
}
|
|
732
|
+
),
|
|
733
|
+
...e.values.map((r, t) => ({
|
|
734
|
+
field: r.field,
|
|
735
|
+
path: `spec.values.${t}.field`
|
|
736
|
+
})),
|
|
737
|
+
...(e.sort || []).flatMap(
|
|
738
|
+
(r, t) => r.by.kind === "field" ? [
|
|
739
|
+
{
|
|
740
|
+
field: r.by.field,
|
|
741
|
+
path: `spec.sort.${t}.by.field`
|
|
742
|
+
}
|
|
743
|
+
] : []
|
|
744
|
+
),
|
|
745
|
+
...(e.filters || []).map((r, t) => ({
|
|
746
|
+
field: r.field,
|
|
747
|
+
path: `spec.filters.${t}.field`
|
|
748
|
+
}))
|
|
749
|
+
] : [];
|
|
654
750
|
}
|
|
655
|
-
function
|
|
656
|
-
return e.find((t) =>
|
|
751
|
+
function he(e, r) {
|
|
752
|
+
return e.find((t) => h(t, r));
|
|
657
753
|
}
|
|
658
|
-
function
|
|
659
|
-
const
|
|
660
|
-
if (
|
|
754
|
+
function C(e, r, t) {
|
|
755
|
+
const i = m(r, t);
|
|
756
|
+
if (h(e, i))
|
|
661
757
|
return e.fields.find(
|
|
662
|
-
(
|
|
758
|
+
(o) => ge(o, r) && h(
|
|
663
759
|
e,
|
|
664
|
-
|
|
760
|
+
m(o, e.source)
|
|
665
761
|
)
|
|
666
762
|
);
|
|
667
763
|
}
|
|
668
|
-
function
|
|
764
|
+
function h(e, r) {
|
|
669
765
|
return [e.source, ...e.sourceAliases || []].some(
|
|
670
|
-
(t) =>
|
|
766
|
+
(t) => w(t, r)
|
|
671
767
|
);
|
|
672
768
|
}
|
|
673
|
-
function
|
|
769
|
+
function m(e, r) {
|
|
674
770
|
return e.source || r;
|
|
675
771
|
}
|
|
676
|
-
function
|
|
772
|
+
function ge(e, r) {
|
|
677
773
|
return !!(e.name && r.name && e.name === r.name);
|
|
678
774
|
}
|
|
679
|
-
function
|
|
775
|
+
function q(e, r) {
|
|
680
776
|
return {
|
|
681
777
|
severity: r.severity,
|
|
682
778
|
code: e.code || "invalid_analytics_intent",
|
|
@@ -688,15 +784,15 @@ function v(e, r) {
|
|
|
688
784
|
source: r.intent.source
|
|
689
785
|
};
|
|
690
786
|
}
|
|
691
|
-
function
|
|
787
|
+
function ve(e, r) {
|
|
692
788
|
const t = R(r);
|
|
693
789
|
return {
|
|
694
790
|
ok: t.ok && e.ok,
|
|
695
|
-
errors:
|
|
791
|
+
errors: k([
|
|
696
792
|
...e.errors,
|
|
697
793
|
...t.errors
|
|
698
794
|
]),
|
|
699
|
-
warnings:
|
|
795
|
+
warnings: k([
|
|
700
796
|
...e.warnings,
|
|
701
797
|
...t.warnings
|
|
702
798
|
]),
|
|
@@ -707,24 +803,24 @@ function me(e, r) {
|
|
|
707
803
|
};
|
|
708
804
|
}
|
|
709
805
|
function R(e) {
|
|
710
|
-
const r = e.filter((
|
|
806
|
+
const r = e.filter((i) => i.severity === "error").map(I), t = e.filter((i) => i.severity === "warning").map(I);
|
|
711
807
|
return {
|
|
712
808
|
ok: r.length === 0,
|
|
713
809
|
errors: r,
|
|
714
810
|
warnings: t,
|
|
715
|
-
repairHints: r.map((
|
|
716
|
-
var
|
|
811
|
+
repairHints: r.map((i) => {
|
|
812
|
+
var o, n;
|
|
717
813
|
return {
|
|
718
|
-
code:
|
|
719
|
-
message:
|
|
720
|
-
fieldRole:
|
|
721
|
-
invalidField: (
|
|
722
|
-
recommendedNextStep: ((n =
|
|
814
|
+
code: i.code,
|
|
815
|
+
message: i.message,
|
|
816
|
+
fieldRole: i.fieldRole,
|
|
817
|
+
invalidField: (o = i.repairHint) == null ? void 0 : o.invalidField,
|
|
818
|
+
recommendedNextStep: ((n = i.repairHint) == null ? void 0 : n.recommendedNextStep) || "Update the Data App SDK query spec to use visible Semaphor source and field refs."
|
|
723
819
|
};
|
|
724
820
|
})
|
|
725
821
|
};
|
|
726
822
|
}
|
|
727
|
-
function
|
|
823
|
+
function I(e) {
|
|
728
824
|
var r;
|
|
729
825
|
return {
|
|
730
826
|
code: e.code,
|
|
@@ -740,22 +836,22 @@ function q(e) {
|
|
|
740
836
|
}
|
|
741
837
|
};
|
|
742
838
|
}
|
|
743
|
-
function
|
|
839
|
+
function k(e) {
|
|
744
840
|
const r = /* @__PURE__ */ new Set();
|
|
745
841
|
return e.filter((t) => {
|
|
746
|
-
const
|
|
747
|
-
return r.has(
|
|
842
|
+
const i = `${t.code}:${t.path || ""}:${t.message}`;
|
|
843
|
+
return r.has(i) ? !1 : (r.add(i), !0);
|
|
748
844
|
});
|
|
749
845
|
}
|
|
750
|
-
function
|
|
751
|
-
var t,
|
|
846
|
+
function S(e) {
|
|
847
|
+
var t, i;
|
|
752
848
|
const r = e.diagnostics.filter(
|
|
753
|
-
(
|
|
849
|
+
(o) => o.severity === "error"
|
|
754
850
|
);
|
|
755
851
|
return {
|
|
756
852
|
intentId: (t = e.intent) == null ? void 0 : t.id,
|
|
757
853
|
status: r.length ? "failed" : "answered",
|
|
758
|
-
resultShape: (
|
|
854
|
+
resultShape: (i = e.intent) == null ? void 0 : i.kind,
|
|
759
855
|
intent: e.intent,
|
|
760
856
|
validation: e.validation,
|
|
761
857
|
coverage: {
|
|
@@ -763,22 +859,22 @@ function k(e) {
|
|
|
763
859
|
missingObligations: r.length ? ["query_spec_validation"] : [],
|
|
764
860
|
warnings: e.validation.warnings
|
|
765
861
|
},
|
|
766
|
-
missingFields: r.filter((
|
|
767
|
-
(
|
|
862
|
+
missingFields: r.filter((o) => o.code === "missing_field").flatMap(
|
|
863
|
+
(o) => {
|
|
768
864
|
var n;
|
|
769
|
-
return (n =
|
|
865
|
+
return (n = o.field) != null && n.name ? [o.field.name] : [];
|
|
770
866
|
}
|
|
771
867
|
),
|
|
772
|
-
warnings: e.diagnostics.filter((
|
|
868
|
+
warnings: e.diagnostics.filter((o) => o.severity === "warning").map((o) => o.message),
|
|
773
869
|
metadata: {
|
|
774
870
|
validationKind: "data_app_sdk_query_spec"
|
|
775
871
|
}
|
|
776
872
|
};
|
|
777
873
|
}
|
|
778
|
-
function
|
|
779
|
-
return r.id ||
|
|
874
|
+
function qe(e, r) {
|
|
875
|
+
return r.id || F(e.spec);
|
|
780
876
|
}
|
|
781
|
-
function
|
|
877
|
+
function F(e) {
|
|
782
878
|
if (!e || typeof e != "object" || !("id" in e))
|
|
783
879
|
return;
|
|
784
880
|
const r = e.id;
|
|
@@ -786,18 +882,19 @@ function P(e) {
|
|
|
786
882
|
}
|
|
787
883
|
export {
|
|
788
884
|
W as a,
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
885
|
+
L as b,
|
|
886
|
+
V as c,
|
|
887
|
+
E as d,
|
|
888
|
+
Se as e,
|
|
889
|
+
B as f,
|
|
890
|
+
A as g,
|
|
891
|
+
x as h,
|
|
892
|
+
v as i,
|
|
893
|
+
X as j,
|
|
894
|
+
be as k,
|
|
895
|
+
Z as l,
|
|
896
|
+
ie as m,
|
|
897
|
+
Ae as n,
|
|
898
|
+
we as t,
|
|
899
|
+
Me as v
|
|
803
900
|
};
|