react-semaphor 0.1.346 → 0.1.348
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 +42 -41
- package/dist/chunks/validators-BNvNf_tO.js +1 -0
- package/dist/chunks/{validators-yMB7Tm4j.js → validators-C2eI8fHy.js} +372 -268
- 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 +12 -12
- package/dist/types/analytics-protocol.d.ts +17 -6
- package/dist/types/dashboard-authoring.d.ts +15 -6
- package/dist/types/data-app-builder.d.ts +15 -6
- package/dist/types/data-app-sdk.d.ts +15 -6
- package/dist/types/main.d.ts +15 -6
- package/package.json +1 -1
- package/dist/chunks/validators-8R9pr2K9.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function A(e) {
|
|
2
2
|
return e ? e.kind === "semantic" ? [
|
|
3
3
|
e.kind,
|
|
4
4
|
e.domainId,
|
|
@@ -17,10 +17,10 @@ function h(e) {
|
|
|
17
17
|
e.label || ""
|
|
18
18
|
].join(":") : "";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return !e || !i ? e === i : e.kind !== i.kind ? !1 : e.kind === "semantic" && i.kind === "semantic" ? e.domainId !== i.domainId ? !1 : e.datasetId && i.datasetId ? e.datasetId === i.datasetId : e.datasetName === i.datasetName :
|
|
20
|
+
function F(e, i) {
|
|
21
|
+
return !e || !i ? e === i : e.kind !== i.kind ? !1 : e.kind === "semantic" && i.kind === "semantic" ? e.domainId !== i.domainId ? !1 : e.datasetId && i.datasetId ? e.datasetId === i.datasetId : e.datasetName === i.datasetName : A(e) === A(i);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function D(e, i) {
|
|
24
24
|
return e.kind !== "semantic" || i.kind !== "semantic" ? e : {
|
|
25
25
|
...e,
|
|
26
26
|
datasetId: e.datasetId || i.datasetId,
|
|
@@ -28,79 +28,116 @@ function N(e, i) {
|
|
|
28
28
|
connectionId: e.connectionId || i.connectionId
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return e.name === i.name &&
|
|
31
|
+
function x(e, i) {
|
|
32
|
+
return e.name === i.name && F(e.source, i.source);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function J(e, i) {
|
|
35
35
|
return {
|
|
36
36
|
...e,
|
|
37
37
|
label: e.label || i.label,
|
|
38
38
|
role: e.role || i.role,
|
|
39
39
|
dataType: e.dataType || i.dataType,
|
|
40
|
-
source: e.source && i.source ?
|
|
40
|
+
source: e.source && i.source ? D(e.source, i.source) : e.source || i.source
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
43
|
+
function n(e, i, a) {
|
|
44
|
+
return a ? { code: e, message: i, path: a } : { code: e, message: i };
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function j(e) {
|
|
47
47
|
for (let i = 0; i < e.length; i += 1) {
|
|
48
|
-
const
|
|
48
|
+
const a = e[i];
|
|
49
49
|
if (e.some(
|
|
50
|
-
(
|
|
50
|
+
(r, o) => o !== i && $(r, a)
|
|
51
51
|
))
|
|
52
52
|
return !1;
|
|
53
53
|
}
|
|
54
54
|
return !0;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
56
|
+
function S(e, i) {
|
|
57
|
+
return x(e, i);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return
|
|
59
|
+
function $(e, i) {
|
|
60
|
+
return S(e, i) && y(e) === y(i);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function O(e) {
|
|
63
63
|
return `Metric intent has duplicate metric "${e.name}" with the same aggregate (${y(e)}). Use different aggregates to request both, or remove one entry.`;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
65
|
+
function C(e, i) {
|
|
66
|
+
return b(e, i).length === 1;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
68
|
+
function E(e, i) {
|
|
69
|
+
return b(e, i).length === 1;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function b(e, i) {
|
|
72
72
|
return i.filter(
|
|
73
|
-
(
|
|
73
|
+
(r) => q(e, r)
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
76
|
+
function q(e, i) {
|
|
77
|
+
return U(e, i) ? e.source ? S(i, e) : !0 : !1;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return !(i.name !== e.name || e.role !== void 0 && i.role !== void 0 && i.role !== e.role ||
|
|
79
|
+
function U(e, i) {
|
|
80
|
+
return !(i.name !== e.name || e.role !== void 0 && i.role !== void 0 && i.role !== e.role || P(e, i) && y(i) !== y(e));
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function P(e, i) {
|
|
83
83
|
return e.role === "measure" || i.role === "measure" || e.aggregate !== void 0 || i.aggregate !== void 0;
|
|
84
84
|
}
|
|
85
85
|
function y(e) {
|
|
86
86
|
return (e.aggregate || "SUM").toUpperCase();
|
|
87
87
|
}
|
|
88
|
+
const G = /^(\d{4})-(\d{2})-(\d{2})$/, H = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})$/;
|
|
89
|
+
function I(e) {
|
|
90
|
+
if (typeof e != "string")
|
|
91
|
+
return null;
|
|
92
|
+
const i = e.trim(), a = G.exec(i);
|
|
93
|
+
if (a) {
|
|
94
|
+
const [, v, g, w] = a;
|
|
95
|
+
return k(v, g, w) ? new Date(
|
|
96
|
+
Date.UTC(Number(v), Number(g) - 1, Number(w))
|
|
97
|
+
) : null;
|
|
98
|
+
}
|
|
99
|
+
const r = H.exec(i);
|
|
100
|
+
if (!r)
|
|
101
|
+
return null;
|
|
102
|
+
const [, o, s, t, p, c, l = "00", , f] = r;
|
|
103
|
+
if (!k(o, s, t) || !_(p, 0, 23) || !_(c, 0, 59) || !_(l, 0, 59) || !L(f))
|
|
104
|
+
return null;
|
|
105
|
+
const h = new Date(i);
|
|
106
|
+
return Number.isFinite(h.getTime()) ? h : null;
|
|
107
|
+
}
|
|
108
|
+
function k(e, i, a) {
|
|
109
|
+
const r = Number(e), o = Number(i), s = Number(a);
|
|
110
|
+
if (!Number.isInteger(r) || !Number.isInteger(o) || !Number.isInteger(s) || o < 1 || o > 12)
|
|
111
|
+
return !1;
|
|
112
|
+
const t = new Date(Date.UTC(r, o - 1, s));
|
|
113
|
+
return t.getUTCFullYear() === r && t.getUTCMonth() === o - 1 && t.getUTCDate() === s;
|
|
114
|
+
}
|
|
115
|
+
function _(e, i, a) {
|
|
116
|
+
const r = Number(e);
|
|
117
|
+
return Number.isInteger(r) && r >= i && r <= a;
|
|
118
|
+
}
|
|
119
|
+
function L(e) {
|
|
120
|
+
if (e === "Z")
|
|
121
|
+
return !0;
|
|
122
|
+
const i = /^([+-])(\d{2}):(\d{2})$/.exec(e);
|
|
123
|
+
return !!(i && _(i[2], 0, 23) && _(i[3], 0, 59));
|
|
124
|
+
}
|
|
88
125
|
function d(e) {
|
|
89
126
|
return typeof e == "string" && e.trim().length > 0;
|
|
90
127
|
}
|
|
91
|
-
function
|
|
128
|
+
function u(e) {
|
|
92
129
|
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
93
130
|
}
|
|
94
|
-
function
|
|
131
|
+
function M(e) {
|
|
95
132
|
const i = /* @__PURE__ */ new Set();
|
|
96
|
-
for (const
|
|
97
|
-
if (i.has(
|
|
98
|
-
return
|
|
99
|
-
i.add(
|
|
133
|
+
for (const a of e) {
|
|
134
|
+
if (i.has(a))
|
|
135
|
+
return a;
|
|
136
|
+
i.add(a);
|
|
100
137
|
}
|
|
101
138
|
return null;
|
|
102
139
|
}
|
|
103
|
-
const
|
|
140
|
+
const V = /* @__PURE__ */ new Set([
|
|
104
141
|
"SUM",
|
|
105
142
|
"COUNT",
|
|
106
143
|
"AVG",
|
|
@@ -109,20 +146,20 @@ const C = /* @__PURE__ */ new Set([
|
|
|
109
146
|
"MEDIAN",
|
|
110
147
|
"DISTINCT"
|
|
111
148
|
]);
|
|
112
|
-
function
|
|
149
|
+
function N(e, i, a) {
|
|
113
150
|
if (!e || typeof e != "object") {
|
|
114
|
-
|
|
151
|
+
a.push(n("missing_source", "Analytics intent needs a source.", i));
|
|
115
152
|
return;
|
|
116
153
|
}
|
|
117
154
|
if (e.kind === "semantic") {
|
|
118
|
-
d(e.domainId) ||
|
|
119
|
-
|
|
155
|
+
d(e.domainId) || a.push(
|
|
156
|
+
n(
|
|
120
157
|
"missing_semantic_domain",
|
|
121
158
|
"Semantic source needs a domainId.",
|
|
122
159
|
`${i}.domainId`
|
|
123
160
|
)
|
|
124
|
-
), d(e.datasetName) ||
|
|
125
|
-
|
|
161
|
+
), d(e.datasetName) || a.push(
|
|
162
|
+
n(
|
|
126
163
|
"missing_dataset_name",
|
|
127
164
|
"Semantic source needs a datasetName.",
|
|
128
165
|
`${i}.datasetName`
|
|
@@ -131,14 +168,14 @@ function A(e, i, s) {
|
|
|
131
168
|
return;
|
|
132
169
|
}
|
|
133
170
|
if (e.kind === "physical") {
|
|
134
|
-
d(e.connectionId) ||
|
|
135
|
-
|
|
171
|
+
d(e.connectionId) || a.push(
|
|
172
|
+
n(
|
|
136
173
|
"missing_connection_id",
|
|
137
174
|
"Physical source needs a connectionId.",
|
|
138
175
|
`${i}.connectionId`
|
|
139
176
|
)
|
|
140
|
-
), d(e.tableName) ||
|
|
141
|
-
|
|
177
|
+
), d(e.tableName) || a.push(
|
|
178
|
+
n(
|
|
142
179
|
"missing_table_name",
|
|
143
180
|
"Physical source needs a tableName.",
|
|
144
181
|
`${i}.tableName`
|
|
@@ -147,8 +184,8 @@ function A(e, i, s) {
|
|
|
147
184
|
return;
|
|
148
185
|
}
|
|
149
186
|
if (e.kind === "sql") {
|
|
150
|
-
d(e.connectionId) ||
|
|
151
|
-
|
|
187
|
+
d(e.connectionId) || a.push(
|
|
188
|
+
n(
|
|
152
189
|
"missing_connection_id",
|
|
153
190
|
"SQL source needs a connectionId.",
|
|
154
191
|
`${i}.connectionId`
|
|
@@ -156,34 +193,34 @@ function A(e, i, s) {
|
|
|
156
193
|
);
|
|
157
194
|
return;
|
|
158
195
|
}
|
|
159
|
-
|
|
196
|
+
a.push(n("invalid_source_kind", "Source kind is not supported.", i));
|
|
160
197
|
}
|
|
161
|
-
function
|
|
162
|
-
if (!e || !
|
|
163
|
-
|
|
164
|
-
|
|
198
|
+
function m(e, i, a, r = {}) {
|
|
199
|
+
if (!e || !u(e)) {
|
|
200
|
+
r.required && a.push(
|
|
201
|
+
n("missing_field_ref", "Field reference needs a name.", i)
|
|
165
202
|
);
|
|
166
203
|
return;
|
|
167
204
|
}
|
|
168
|
-
d(e.name) ||
|
|
169
|
-
|
|
170
|
-
), e.source !== void 0 &&
|
|
205
|
+
d(e.name) || a.push(
|
|
206
|
+
n("missing_field_ref", "Field reference needs a name.", `${i}.name`)
|
|
207
|
+
), e.source !== void 0 && N(e.source, `${i}.source`, a), Q(e.aggregate, `${i}.aggregate`, a);
|
|
171
208
|
}
|
|
172
|
-
function
|
|
173
|
-
e !== void 0 && (typeof e != "string" || !
|
|
174
|
-
|
|
209
|
+
function Q(e, i, a) {
|
|
210
|
+
e !== void 0 && (typeof e != "string" || !V.has(e)) && a.push(
|
|
211
|
+
n(
|
|
175
212
|
"invalid_aggregate",
|
|
176
213
|
"Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",
|
|
177
214
|
i
|
|
178
215
|
)
|
|
179
216
|
);
|
|
180
217
|
}
|
|
181
|
-
function
|
|
218
|
+
function X(e, i) {
|
|
182
219
|
if (e.analysis === void 0)
|
|
183
220
|
return;
|
|
184
|
-
if (!
|
|
221
|
+
if (!u(e.analysis)) {
|
|
185
222
|
i.push(
|
|
186
|
-
|
|
223
|
+
n(
|
|
187
224
|
"invalid_metric_analysis",
|
|
188
225
|
"Metric analysis must be a structured object.",
|
|
189
226
|
"analysis"
|
|
@@ -193,7 +230,7 @@ function P(e, i) {
|
|
|
193
230
|
}
|
|
194
231
|
if (e.analysis.kind !== "period_change") {
|
|
195
232
|
i.push(
|
|
196
|
-
|
|
233
|
+
n(
|
|
197
234
|
"invalid_metric_analysis",
|
|
198
235
|
"Metric analysis kind is not supported.",
|
|
199
236
|
"analysis.kind"
|
|
@@ -202,31 +239,31 @@ function P(e, i) {
|
|
|
202
239
|
return;
|
|
203
240
|
}
|
|
204
241
|
e.dateField || i.push(
|
|
205
|
-
|
|
242
|
+
n(
|
|
206
243
|
"missing_analysis_date_field",
|
|
207
244
|
"Period-change analysis needs a dateField.",
|
|
208
245
|
"dateField"
|
|
209
246
|
)
|
|
210
247
|
), e.timeGrain || i.push(
|
|
211
|
-
|
|
248
|
+
n(
|
|
212
249
|
"missing_analysis_time_grain",
|
|
213
250
|
"Period-change analysis needs a timeGrain.",
|
|
214
251
|
"timeGrain"
|
|
215
252
|
)
|
|
216
253
|
), e.analysis.orderBy !== void 0 && e.analysis.orderBy !== "absolute_change" && e.analysis.orderBy !== "positive_change" && e.analysis.orderBy !== "negative_change" && e.analysis.orderBy !== "period" && i.push(
|
|
217
|
-
|
|
254
|
+
n(
|
|
218
255
|
"invalid_metric_analysis",
|
|
219
256
|
"Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.",
|
|
220
257
|
"analysis.orderBy"
|
|
221
258
|
)
|
|
222
259
|
);
|
|
223
|
-
const { timeWindow:
|
|
224
|
-
|
|
260
|
+
const { timeWindow: a } = e.analysis;
|
|
261
|
+
a !== void 0 && B(a, "analysis.timeWindow", i);
|
|
225
262
|
}
|
|
226
|
-
function
|
|
227
|
-
if (!
|
|
228
|
-
|
|
229
|
-
|
|
263
|
+
function B(e, i, a) {
|
|
264
|
+
if (!u(e)) {
|
|
265
|
+
a.push(
|
|
266
|
+
n(
|
|
230
267
|
"invalid_time_window",
|
|
231
268
|
"Time window must be a structured object.",
|
|
232
269
|
i
|
|
@@ -234,37 +271,80 @@ function k(e, i, s) {
|
|
|
234
271
|
);
|
|
235
272
|
return;
|
|
236
273
|
}
|
|
237
|
-
|
|
238
|
-
|
|
274
|
+
if (e.kind !== void 0 && e.kind !== "relative" && e.kind !== "absolute" && a.push(
|
|
275
|
+
n(
|
|
276
|
+
"invalid_time_window",
|
|
277
|
+
"Time window kind must be relative or absolute.",
|
|
278
|
+
`${i}.kind`
|
|
279
|
+
)
|
|
280
|
+
), e.kind === "absolute") {
|
|
281
|
+
if (d(e.start) || a.push(
|
|
282
|
+
n(
|
|
283
|
+
"invalid_time_window",
|
|
284
|
+
"Absolute time window start must be a non-empty ISO date or timestamp string.",
|
|
285
|
+
`${i}.start`
|
|
286
|
+
)
|
|
287
|
+
), d(e.end) || a.push(
|
|
288
|
+
n(
|
|
289
|
+
"invalid_time_window",
|
|
290
|
+
"Absolute time window end must be a non-empty ISO date or timestamp string.",
|
|
291
|
+
`${i}.end`
|
|
292
|
+
)
|
|
293
|
+
), d(e.start) && d(e.end)) {
|
|
294
|
+
const r = I(e.start), o = I(e.end);
|
|
295
|
+
r || a.push(
|
|
296
|
+
n(
|
|
297
|
+
"invalid_time_window",
|
|
298
|
+
"Absolute time window start must be a valid ISO date or timestamp.",
|
|
299
|
+
`${i}.start`
|
|
300
|
+
)
|
|
301
|
+
), o || a.push(
|
|
302
|
+
n(
|
|
303
|
+
"invalid_time_window",
|
|
304
|
+
"Absolute time window end must be a valid ISO date or timestamp.",
|
|
305
|
+
`${i}.end`
|
|
306
|
+
)
|
|
307
|
+
), r && o && r.getTime() > o.getTime() && a.push(
|
|
308
|
+
n(
|
|
309
|
+
"invalid_time_window",
|
|
310
|
+
"Absolute time window start must be before or equal to end.",
|
|
311
|
+
i
|
|
312
|
+
)
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
e.unit !== "second" && e.unit !== "minute" && e.unit !== "hour" && e.unit !== "day" && e.unit !== "week" && e.unit !== "month" && e.unit !== "quarter" && e.unit !== "year" && a.push(
|
|
318
|
+
n(
|
|
239
319
|
"invalid_time_window",
|
|
240
320
|
"Time window unit must be second, minute, hour, day, week, month, quarter, or year.",
|
|
241
321
|
`${i}.unit`
|
|
242
322
|
)
|
|
243
|
-
), (typeof e.value != "number" || !Number.isFinite(e.value) || e.value <= 0) &&
|
|
244
|
-
|
|
323
|
+
), (typeof e.value != "number" || !Number.isFinite(e.value) || e.value <= 0) && a.push(
|
|
324
|
+
n(
|
|
245
325
|
"invalid_time_window",
|
|
246
326
|
"Time window value must be a positive number.",
|
|
247
327
|
`${i}.value`
|
|
248
328
|
)
|
|
249
|
-
), e.anchor !== void 0 && e.anchor !== "now" && e.anchor !== "latest_available" &&
|
|
250
|
-
|
|
329
|
+
), e.anchor !== void 0 && e.anchor !== "now" && e.anchor !== "latest_available" && a.push(
|
|
330
|
+
n(
|
|
251
331
|
"invalid_time_window",
|
|
252
332
|
"Time window anchor must be now or latest_available.",
|
|
253
333
|
`${i}.anchor`
|
|
254
334
|
)
|
|
255
|
-
), e.completeness !== void 0 && e.completeness !== "include_partial" && e.completeness !== "complete_periods" &&
|
|
256
|
-
|
|
335
|
+
), e.completeness !== void 0 && e.completeness !== "include_partial" && e.completeness !== "complete_periods" && a.push(
|
|
336
|
+
n(
|
|
257
337
|
"invalid_time_window",
|
|
258
338
|
"Time window completeness must be include_partial or complete_periods.",
|
|
259
339
|
`${i}.completeness`
|
|
260
340
|
)
|
|
261
341
|
);
|
|
262
342
|
}
|
|
263
|
-
function
|
|
343
|
+
function Y(e, i, a) {
|
|
264
344
|
if (e !== void 0) {
|
|
265
345
|
if (!Array.isArray(e)) {
|
|
266
|
-
|
|
267
|
-
|
|
346
|
+
a.push(
|
|
347
|
+
n(
|
|
268
348
|
"invalid_analytics_filters",
|
|
269
349
|
"Analytics filters must be an array.",
|
|
270
350
|
i
|
|
@@ -272,68 +352,91 @@ function O(e, i, s) {
|
|
|
272
352
|
);
|
|
273
353
|
return;
|
|
274
354
|
}
|
|
275
|
-
e.forEach((
|
|
276
|
-
const
|
|
277
|
-
if (!
|
|
278
|
-
|
|
279
|
-
|
|
355
|
+
e.forEach((r, o) => {
|
|
356
|
+
const s = `${i}.${o}`;
|
|
357
|
+
if (!u(r)) {
|
|
358
|
+
a.push(
|
|
359
|
+
n(
|
|
280
360
|
"invalid_analytics_filter",
|
|
281
361
|
"Analytics filter must be a structured object.",
|
|
282
|
-
|
|
362
|
+
s
|
|
283
363
|
)
|
|
284
364
|
);
|
|
285
365
|
return;
|
|
286
366
|
}
|
|
287
|
-
const t =
|
|
288
|
-
|
|
367
|
+
const t = r;
|
|
368
|
+
m(t.field, `${s}.field`, a, {
|
|
289
369
|
required: !0
|
|
290
370
|
});
|
|
291
371
|
const p = t.operator === "is_null" || t.operator === "is_not_null";
|
|
292
|
-
if (t.operator !== void 0 && t.operator !== "=" && t.operator !== "!=" && t.operator !== "in" && t.operator !== "not_in" && t.operator !== "contains" && t.operator !== "not_contains" && t.operator !== "between" && t.operator !== "not_between" && t.operator !== ">" && t.operator !== ">=" && t.operator !== "<" && t.operator !== "<=" && t.operator !== "is_null" && t.operator !== "is_not_null" &&
|
|
293
|
-
|
|
372
|
+
if (t.operator !== void 0 && t.operator !== "=" && t.operator !== "!=" && t.operator !== "in" && t.operator !== "not_in" && t.operator !== "contains" && t.operator !== "not_contains" && t.operator !== "between" && t.operator !== "not_between" && t.operator !== ">" && t.operator !== ">=" && t.operator !== "<" && t.operator !== "<=" && t.operator !== "is_null" && t.operator !== "is_not_null" && a.push(
|
|
373
|
+
n(
|
|
294
374
|
"invalid_analytics_filter_operator",
|
|
295
375
|
"Analytics filter operator is not supported.",
|
|
296
|
-
`${
|
|
376
|
+
`${s}.operator`
|
|
297
377
|
)
|
|
298
|
-
), t.values === void 0 && !p &&
|
|
299
|
-
|
|
378
|
+
), t.values === void 0 && !p && a.push(
|
|
379
|
+
n(
|
|
300
380
|
"missing_analytics_filter_value",
|
|
301
381
|
"Analytics filter needs values unless it is a null check.",
|
|
302
|
-
|
|
382
|
+
s
|
|
303
383
|
)
|
|
304
384
|
), p && t.values !== void 0) {
|
|
305
|
-
|
|
306
|
-
|
|
385
|
+
a.push(
|
|
386
|
+
n(
|
|
307
387
|
"invalid_analytics_filter_values",
|
|
308
388
|
"Null-check analytics filters must not include values.",
|
|
309
|
-
`${
|
|
389
|
+
`${s}.values`
|
|
310
390
|
)
|
|
311
391
|
);
|
|
312
392
|
return;
|
|
313
393
|
}
|
|
314
|
-
t.values !== void 0 && !Array.isArray(t.values)
|
|
315
|
-
a(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
394
|
+
if (t.values !== void 0 && !Array.isArray(t.values)) {
|
|
395
|
+
a.push(
|
|
396
|
+
n(
|
|
397
|
+
"invalid_analytics_filter_values",
|
|
398
|
+
"Analytics filter values must be an array when provided.",
|
|
399
|
+
`${s}.values`
|
|
400
|
+
)
|
|
401
|
+
);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (t.values !== void 0) {
|
|
405
|
+
const c = t.values.length;
|
|
406
|
+
if (t.operator === "between" || t.operator === "not_between") {
|
|
407
|
+
c !== 2 && a.push(
|
|
408
|
+
n(
|
|
409
|
+
"invalid_analytics_filter_values",
|
|
410
|
+
"Between analytics filters must include exactly two values.",
|
|
411
|
+
`${s}.values`
|
|
412
|
+
)
|
|
413
|
+
);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
(t.operator === "contains" || t.operator === "not_contains" || t.operator === "=" || t.operator === "!=" || t.operator === ">" || t.operator === ">=" || t.operator === "<" || t.operator === "<=" || t.operator === void 0) && c !== 1 && a.push(
|
|
417
|
+
n(
|
|
418
|
+
"invalid_analytics_filter_values",
|
|
419
|
+
"Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",
|
|
420
|
+
`${s}.values`
|
|
421
|
+
)
|
|
422
|
+
);
|
|
423
|
+
}
|
|
321
424
|
});
|
|
322
425
|
}
|
|
323
426
|
}
|
|
324
|
-
function
|
|
325
|
-
var
|
|
326
|
-
const i = [],
|
|
427
|
+
function T(e) {
|
|
428
|
+
var r;
|
|
429
|
+
const i = [], a = [];
|
|
327
430
|
if (!e || typeof e != "object")
|
|
328
431
|
return {
|
|
329
432
|
ok: !1,
|
|
330
433
|
errors: [
|
|
331
|
-
|
|
434
|
+
n(
|
|
332
435
|
"invalid_analytics_intent",
|
|
333
436
|
"Analytics intent must be a structured object."
|
|
334
437
|
)
|
|
335
438
|
],
|
|
336
|
-
warnings:
|
|
439
|
+
warnings: a,
|
|
337
440
|
repairHints: [
|
|
338
441
|
{
|
|
339
442
|
code: "invalid_analytics_intent",
|
|
@@ -342,111 +445,111 @@ function w(e) {
|
|
|
342
445
|
]
|
|
343
446
|
};
|
|
344
447
|
if (e.version !== void 0 && e.version !== 1 && i.push(
|
|
345
|
-
|
|
346
|
-
),
|
|
347
|
-
const
|
|
348
|
-
(
|
|
448
|
+
n("invalid_version", "Analytics intent version must be 1.", "version")
|
|
449
|
+
), N(e.source, "source", i), e.kind === "metric") {
|
|
450
|
+
const o = Array.isArray(e.metrics) ? e.metrics.filter(
|
|
451
|
+
(s) => u(s) && d(s.name)
|
|
349
452
|
) : [];
|
|
350
453
|
if (!Array.isArray(e.metrics) || e.metrics.length === 0 ? i.push(
|
|
351
|
-
|
|
454
|
+
n("missing_metric", "Metric intent needs at least one metric.", "metrics")
|
|
352
455
|
) : e.metrics.some(
|
|
353
|
-
(
|
|
456
|
+
(s) => !u(s) || !d(s.name)
|
|
354
457
|
) && i.push(
|
|
355
|
-
|
|
458
|
+
n(
|
|
356
459
|
"invalid_metric_list",
|
|
357
460
|
"Metric intent metrics must be an array of field references with names.",
|
|
358
461
|
"metrics"
|
|
359
462
|
)
|
|
360
|
-
),
|
|
361
|
-
|
|
463
|
+
), o.forEach((s, t) => {
|
|
464
|
+
m(s, `metrics.${t}`, i, {
|
|
362
465
|
required: !0
|
|
363
466
|
});
|
|
364
|
-
}),
|
|
365
|
-
const
|
|
366
|
-
(t, p) =>
|
|
367
|
-
(
|
|
467
|
+
}), o.length > 0 && !j(o)) {
|
|
468
|
+
const s = o.find(
|
|
469
|
+
(t, p) => o.some(
|
|
470
|
+
(c, l) => l !== p && $(c, t)
|
|
368
471
|
)
|
|
369
472
|
);
|
|
370
|
-
|
|
371
|
-
|
|
473
|
+
s && i.push(
|
|
474
|
+
n(
|
|
372
475
|
"duplicate_metric",
|
|
373
|
-
|
|
476
|
+
O(s),
|
|
374
477
|
"metrics"
|
|
375
478
|
)
|
|
376
479
|
);
|
|
377
480
|
}
|
|
378
|
-
if (
|
|
481
|
+
if (u(e.primaryMetric) && d(e.primaryMetric.name) && b(
|
|
379
482
|
e.primaryMetric,
|
|
380
|
-
|
|
483
|
+
o
|
|
381
484
|
).length > 1 && i.push(
|
|
382
|
-
|
|
485
|
+
n(
|
|
383
486
|
"ambiguous_primary_metric",
|
|
384
487
|
"Metric intent primaryMetric must identify exactly one selected metric.",
|
|
385
488
|
"primaryMetric"
|
|
386
489
|
)
|
|
387
|
-
), e.primaryMetric !== void 0 && (
|
|
490
|
+
), e.primaryMetric !== void 0 && (m(e.primaryMetric, "primaryMetric", i, {
|
|
388
491
|
required: !0
|
|
389
|
-
}),
|
|
492
|
+
}), u(e.primaryMetric) && d(e.primaryMetric.name) && o.length > 0 && !C(
|
|
390
493
|
e.primaryMetric,
|
|
391
|
-
|
|
494
|
+
o
|
|
392
495
|
) && i.push(
|
|
393
|
-
|
|
496
|
+
n(
|
|
394
497
|
"invalid_primary_metric",
|
|
395
498
|
"Metric intent primaryMetric must match one metric field reference.",
|
|
396
499
|
"primaryMetric"
|
|
397
500
|
)
|
|
398
501
|
)), e.dimensions !== void 0 && !Array.isArray(e.dimensions) ? i.push(
|
|
399
|
-
|
|
502
|
+
n(
|
|
400
503
|
"invalid_metric_dimensions",
|
|
401
504
|
"Metric intent dimensions must be an array of field references.",
|
|
402
505
|
"dimensions"
|
|
403
506
|
)
|
|
404
507
|
) : Array.isArray(e.dimensions) && e.dimensions.some(
|
|
405
|
-
(
|
|
508
|
+
(s) => !u(s) || !d(s.name)
|
|
406
509
|
) && i.push(
|
|
407
|
-
|
|
510
|
+
n(
|
|
408
511
|
"invalid_metric_dimensions",
|
|
409
512
|
"Metric intent dimensions must be an array of field references with names.",
|
|
410
513
|
"dimensions"
|
|
411
514
|
)
|
|
412
|
-
), e.dateField !== void 0 &&
|
|
413
|
-
|
|
515
|
+
), e.dateField !== void 0 && m(e.dateField, "dateField", i), e.timeWindow !== void 0 && (B(e.timeWindow, "timeWindow", i), e.dateField || i.push(
|
|
516
|
+
n(
|
|
414
517
|
"missing_time_window_date_field",
|
|
415
518
|
"Metric timeWindow needs a dateField.",
|
|
416
519
|
"dateField"
|
|
417
520
|
)
|
|
418
|
-
)),
|
|
419
|
-
|
|
521
|
+
)), Y(e.filters, "filters", i), Array.isArray(e.dimensions) && e.dimensions.forEach((s, t) => {
|
|
522
|
+
m(s, `dimensions.${t}`, i);
|
|
420
523
|
}), e.orderBy !== void 0) {
|
|
421
|
-
if (!
|
|
524
|
+
if (!u(e.orderBy))
|
|
422
525
|
i.push(
|
|
423
|
-
|
|
526
|
+
n(
|
|
424
527
|
"invalid_metric_order_by",
|
|
425
528
|
"Metric intent orderBy must be a structured object.",
|
|
426
529
|
"orderBy"
|
|
427
530
|
)
|
|
428
531
|
);
|
|
429
|
-
else if (
|
|
532
|
+
else if (m(e.orderBy.field, "orderBy.field", i, {
|
|
430
533
|
required: !0
|
|
431
534
|
}), e.orderBy.direction !== "asc" && e.orderBy.direction !== "desc" && i.push(
|
|
432
|
-
|
|
535
|
+
n(
|
|
433
536
|
"invalid_metric_order_direction",
|
|
434
537
|
"Metric intent orderBy direction must be asc or desc.",
|
|
435
538
|
"orderBy.direction"
|
|
436
539
|
)
|
|
437
|
-
),
|
|
438
|
-
const
|
|
439
|
-
...
|
|
440
|
-
...e.timeGrain && e.dateField &&
|
|
540
|
+
), u(e.orderBy.field) && d(e.orderBy.field.name)) {
|
|
541
|
+
const s = [
|
|
542
|
+
...o,
|
|
543
|
+
...e.timeGrain && e.dateField && u(e.dateField) ? [e.dateField] : [],
|
|
441
544
|
...Array.isArray(e.dimensions) ? e.dimensions.filter(
|
|
442
|
-
(t) =>
|
|
545
|
+
(t) => u(t) && d(t.name)
|
|
443
546
|
) : []
|
|
444
547
|
];
|
|
445
|
-
|
|
548
|
+
s.length > 0 && !E(
|
|
446
549
|
e.orderBy.field,
|
|
447
|
-
|
|
550
|
+
s
|
|
448
551
|
) && i.push(
|
|
449
|
-
|
|
552
|
+
n(
|
|
450
553
|
"invalid_metric_order_by",
|
|
451
554
|
"Metric intent orderBy.field must match one selected metric, grouped dateField, or dimension.",
|
|
452
555
|
"orderBy.field"
|
|
@@ -454,73 +557,73 @@ function w(e) {
|
|
|
454
557
|
);
|
|
455
558
|
}
|
|
456
559
|
}
|
|
457
|
-
|
|
560
|
+
X(e, i);
|
|
458
561
|
} else e.kind === "records" ? (!Array.isArray(e.fields) || e.fields.length === 0 ? i.push(
|
|
459
|
-
|
|
562
|
+
n(
|
|
460
563
|
"missing_record_fields",
|
|
461
564
|
"Records intent needs at least one field.",
|
|
462
565
|
"fields"
|
|
463
566
|
)
|
|
464
567
|
) : e.fields.some(
|
|
465
|
-
(
|
|
568
|
+
(o) => !u(o) || !d(o.name)
|
|
466
569
|
) && i.push(
|
|
467
|
-
|
|
570
|
+
n(
|
|
468
571
|
"invalid_record_fields",
|
|
469
572
|
"Records intent fields must be field references with names.",
|
|
470
573
|
"fields"
|
|
471
574
|
)
|
|
472
|
-
), Array.isArray(e.fields) && e.fields.forEach((
|
|
473
|
-
|
|
474
|
-
}), e.dateField !== void 0 &&
|
|
575
|
+
), Array.isArray(e.fields) && e.fields.forEach((o, s) => {
|
|
576
|
+
m(o, `fields.${s}`, i);
|
|
577
|
+
}), e.dateField !== void 0 && m(e.dateField, "dateField", i), e.orderBy !== void 0 && (u(e.orderBy) ? (m(e.orderBy.field, "orderBy.field", i, {
|
|
475
578
|
required: !0
|
|
476
579
|
}), e.orderBy.direction !== "asc" && e.orderBy.direction !== "desc" && i.push(
|
|
477
|
-
|
|
580
|
+
n(
|
|
478
581
|
"invalid_record_order_direction",
|
|
479
582
|
"Records intent orderBy direction must be asc or desc.",
|
|
480
583
|
"orderBy.direction"
|
|
481
584
|
)
|
|
482
585
|
)) : i.push(
|
|
483
|
-
|
|
586
|
+
n(
|
|
484
587
|
"invalid_record_order_by",
|
|
485
588
|
"Records intent orderBy must be a structured object.",
|
|
486
589
|
"orderBy"
|
|
487
590
|
)
|
|
488
591
|
))) : e.kind === "inputOptions" ? ((!e.field || !d(e.field.name)) && i.push(
|
|
489
|
-
|
|
592
|
+
n(
|
|
490
593
|
"missing_input_options_field",
|
|
491
594
|
"Input options intent needs a field.",
|
|
492
595
|
"field"
|
|
493
596
|
)
|
|
494
|
-
),
|
|
495
|
-
|
|
597
|
+
), m(e.field, "field", i, { required: !0 })) : e.kind === "sql" ? (((r = e.source) == null ? void 0 : r.kind) !== "sql" && i.push(
|
|
598
|
+
n(
|
|
496
599
|
"invalid_sql_source",
|
|
497
600
|
"SQL analytics intent must use a SQL execution source.",
|
|
498
601
|
"source"
|
|
499
602
|
)
|
|
500
|
-
), d(e.sql) || i.push(
|
|
501
|
-
|
|
603
|
+
), d(e.sql) || i.push(n("missing_sql", "SQL analytics intent needs SQL text.", "sql")), Array.isArray(e.fields) && e.fields.forEach((o, s) => {
|
|
604
|
+
m(o, `fields.${s}`, i);
|
|
502
605
|
})) : i.push(
|
|
503
|
-
|
|
606
|
+
n("invalid_analytics_kind", "Analytics kind is not supported.", "kind")
|
|
504
607
|
);
|
|
505
608
|
return {
|
|
506
609
|
ok: i.length === 0,
|
|
507
610
|
errors: i,
|
|
508
|
-
warnings:
|
|
509
|
-
repairHints:
|
|
611
|
+
warnings: a,
|
|
612
|
+
repairHints: z(i)
|
|
510
613
|
};
|
|
511
614
|
}
|
|
512
|
-
function
|
|
513
|
-
const i = [],
|
|
615
|
+
function Z(e) {
|
|
616
|
+
const i = [], a = [];
|
|
514
617
|
if (!e || typeof e != "object")
|
|
515
618
|
return {
|
|
516
619
|
ok: !1,
|
|
517
620
|
errors: [
|
|
518
|
-
|
|
621
|
+
n(
|
|
519
622
|
"invalid_operation_intent",
|
|
520
623
|
"Operation intent must be a structured object."
|
|
521
624
|
)
|
|
522
625
|
],
|
|
523
|
-
warnings:
|
|
626
|
+
warnings: a,
|
|
524
627
|
repairHints: [
|
|
525
628
|
{
|
|
526
629
|
code: "invalid_operation_intent",
|
|
@@ -529,45 +632,45 @@ function H(e) {
|
|
|
529
632
|
]
|
|
530
633
|
};
|
|
531
634
|
if (e.version !== 1 && i.push(
|
|
532
|
-
|
|
635
|
+
n("invalid_version", "Operation intent version must be 1.", "version")
|
|
533
636
|
), e.kind === "answer_obligations")
|
|
534
637
|
!Array.isArray(e.obligations) || e.obligations.length === 0 ? i.push(
|
|
535
|
-
|
|
638
|
+
n(
|
|
536
639
|
"missing_obligations",
|
|
537
640
|
"Answer-obligations operation intent needs at least one obligation.",
|
|
538
641
|
"obligations"
|
|
539
642
|
)
|
|
540
|
-
) : e.obligations.forEach((
|
|
541
|
-
d(
|
|
542
|
-
|
|
643
|
+
) : e.obligations.forEach((r, o) => {
|
|
644
|
+
d(r.id) || i.push(
|
|
645
|
+
n(
|
|
543
646
|
"missing_obligation_id",
|
|
544
647
|
"Each analytics obligation needs an id.",
|
|
545
|
-
`obligations.${
|
|
648
|
+
`obligations.${o}.id`
|
|
546
649
|
)
|
|
547
|
-
), d(
|
|
548
|
-
|
|
650
|
+
), d(r.prompt) || i.push(
|
|
651
|
+
n(
|
|
549
652
|
"missing_obligation_prompt",
|
|
550
653
|
"Each analytics obligation needs a prompt.",
|
|
551
|
-
`obligations.${
|
|
654
|
+
`obligations.${o}.prompt`
|
|
552
655
|
)
|
|
553
656
|
);
|
|
554
657
|
});
|
|
555
658
|
else if (e.kind === "dashboard_change" || e.kind === "data_app_change") {
|
|
556
659
|
if (d(e.instruction) || i.push(
|
|
557
|
-
|
|
660
|
+
n(
|
|
558
661
|
"missing_instruction",
|
|
559
662
|
"Change operation intent needs an instruction.",
|
|
560
663
|
"instruction"
|
|
561
664
|
)
|
|
562
665
|
), e.analyticsIntent) {
|
|
563
|
-
const
|
|
666
|
+
const r = T(
|
|
564
667
|
e.analyticsIntent
|
|
565
668
|
);
|
|
566
|
-
i.push(...
|
|
669
|
+
i.push(...r.errors), a.push(...r.warnings);
|
|
567
670
|
}
|
|
568
671
|
} else
|
|
569
672
|
i.push(
|
|
570
|
-
|
|
673
|
+
n(
|
|
571
674
|
"invalid_operation_kind",
|
|
572
675
|
"Operation intent kind is not supported.",
|
|
573
676
|
"kind"
|
|
@@ -576,22 +679,22 @@ function H(e) {
|
|
|
576
679
|
return {
|
|
577
680
|
ok: i.length === 0,
|
|
578
681
|
errors: i,
|
|
579
|
-
warnings:
|
|
580
|
-
repairHints:
|
|
682
|
+
warnings: a,
|
|
683
|
+
repairHints: R(i)
|
|
581
684
|
};
|
|
582
685
|
}
|
|
583
|
-
function
|
|
584
|
-
const i = [],
|
|
686
|
+
function W(e) {
|
|
687
|
+
const i = [], a = [];
|
|
585
688
|
if (!e || typeof e != "object")
|
|
586
689
|
return {
|
|
587
690
|
ok: !1,
|
|
588
691
|
errors: [
|
|
589
|
-
|
|
692
|
+
n(
|
|
590
693
|
"invalid_recovery_plan",
|
|
591
694
|
"Analytics recovery plan must be a structured object."
|
|
592
695
|
)
|
|
593
696
|
],
|
|
594
|
-
warnings:
|
|
697
|
+
warnings: a,
|
|
595
698
|
repairHints: [
|
|
596
699
|
{
|
|
597
700
|
code: "invalid_recovery_plan",
|
|
@@ -600,17 +703,17 @@ function Q(e) {
|
|
|
600
703
|
]
|
|
601
704
|
};
|
|
602
705
|
e.version !== 1 && i.push(
|
|
603
|
-
|
|
706
|
+
n("invalid_version", "Recovery plan version must be 1.", "version")
|
|
604
707
|
), e.kind !== "analytics_recovery_plan" && i.push(
|
|
605
|
-
|
|
708
|
+
n(
|
|
606
709
|
"invalid_recovery_plan_kind",
|
|
607
710
|
"Recovery plan kind must be analytics_recovery_plan.",
|
|
608
711
|
"kind"
|
|
609
712
|
)
|
|
610
713
|
);
|
|
611
|
-
const
|
|
612
|
-
return i.push(...
|
|
613
|
-
|
|
714
|
+
const r = Z(e.operationIntent);
|
|
715
|
+
return i.push(...r.errors), a.push(...r.warnings), Array.isArray(e.plannedToolCalls) || i.push(
|
|
716
|
+
n(
|
|
614
717
|
"invalid_planned_tool_calls",
|
|
615
718
|
"Recovery plan plannedToolCalls must be an array.",
|
|
616
719
|
"plannedToolCalls"
|
|
@@ -618,17 +721,17 @@ function Q(e) {
|
|
|
618
721
|
), {
|
|
619
722
|
ok: i.length === 0,
|
|
620
723
|
errors: i,
|
|
621
|
-
warnings:
|
|
622
|
-
repairHints:
|
|
724
|
+
warnings: a,
|
|
725
|
+
repairHints: R(i)
|
|
623
726
|
};
|
|
624
727
|
}
|
|
625
|
-
function
|
|
728
|
+
function R(e) {
|
|
626
729
|
return e.map((i) => ({
|
|
627
730
|
code: i.code,
|
|
628
731
|
recommendedNextStep: i.code === "missing_obligations" ? "Normalize the user request into one or more typed analytics obligations before recovery planning." : "Correct the operation/recovery contract shape before planning execution."
|
|
629
732
|
}));
|
|
630
733
|
}
|
|
631
|
-
function
|
|
734
|
+
function z(e) {
|
|
632
735
|
return e.map((i) => {
|
|
633
736
|
switch (i.code) {
|
|
634
737
|
case "missing_source":
|
|
@@ -681,14 +784,14 @@ function U(e) {
|
|
|
681
784
|
}
|
|
682
785
|
}).filter((i) => !!i);
|
|
683
786
|
}
|
|
684
|
-
function
|
|
787
|
+
function K(e, i, a, r) {
|
|
685
788
|
if (!e || typeof e != "object") {
|
|
686
|
-
|
|
789
|
+
a.push(n("invalid_view", "Dashboard view must be an object.", i));
|
|
687
790
|
return;
|
|
688
791
|
}
|
|
689
|
-
if (d(e.title) ||
|
|
690
|
-
|
|
691
|
-
|
|
792
|
+
if (d(e.title) || a.push(n("missing_view_title", "Dashboard view needs a title.", i)), !e.presentation || typeof e.presentation != "object") {
|
|
793
|
+
a.push(
|
|
794
|
+
n(
|
|
692
795
|
"missing_presentation",
|
|
693
796
|
"Dashboard view needs a presentation.",
|
|
694
797
|
`${i}.presentation`
|
|
@@ -697,8 +800,8 @@ function G(e, i, s, o) {
|
|
|
697
800
|
return;
|
|
698
801
|
}
|
|
699
802
|
if (e.presentation.kind === "text") {
|
|
700
|
-
d(e.text) ||
|
|
701
|
-
|
|
803
|
+
d(e.text) || r.push(
|
|
804
|
+
n(
|
|
702
805
|
"missing_text_content",
|
|
703
806
|
"Text views should include text content.",
|
|
704
807
|
`${i}.text`
|
|
@@ -707,8 +810,8 @@ function G(e, i, s, o) {
|
|
|
707
810
|
return;
|
|
708
811
|
}
|
|
709
812
|
if (!e.analytics) {
|
|
710
|
-
|
|
711
|
-
|
|
813
|
+
a.push(
|
|
814
|
+
n(
|
|
712
815
|
"missing_view_analytics",
|
|
713
816
|
"Non-text dashboard views need analytics intent.",
|
|
714
817
|
`${i}.analytics`
|
|
@@ -716,112 +819,113 @@ function G(e, i, s, o) {
|
|
|
716
819
|
);
|
|
717
820
|
return;
|
|
718
821
|
}
|
|
719
|
-
const
|
|
720
|
-
for (const
|
|
721
|
-
|
|
722
|
-
|
|
822
|
+
const o = T(e.analytics);
|
|
823
|
+
for (const s of o.errors)
|
|
824
|
+
a.push(
|
|
825
|
+
n(s.code, s.message, `${i}.analytics${s.path ? `.${s.path}` : ""}`)
|
|
723
826
|
);
|
|
724
|
-
for (const
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
`${i}.analytics${
|
|
827
|
+
for (const s of o.warnings)
|
|
828
|
+
r.push(
|
|
829
|
+
n(
|
|
830
|
+
s.code,
|
|
831
|
+
s.message,
|
|
832
|
+
`${i}.analytics${s.path ? `.${s.path}` : ""}`
|
|
730
833
|
)
|
|
731
834
|
);
|
|
732
835
|
}
|
|
733
|
-
function
|
|
734
|
-
const i = [],
|
|
836
|
+
function ee(e) {
|
|
837
|
+
const i = [], a = [];
|
|
735
838
|
if (!e || typeof e != "object")
|
|
736
839
|
return {
|
|
737
840
|
ok: !1,
|
|
738
841
|
errors: [
|
|
739
|
-
|
|
842
|
+
n(
|
|
740
843
|
"invalid_dashboard_intent",
|
|
741
844
|
"Dashboard intent must be a structured object."
|
|
742
845
|
)
|
|
743
846
|
],
|
|
744
|
-
warnings:
|
|
847
|
+
warnings: a
|
|
745
848
|
};
|
|
746
|
-
e.version !== 1 && i.push(
|
|
747
|
-
const
|
|
748
|
-
|
|
849
|
+
e.version !== 1 && i.push(n("invalid_version", "Dashboard intent version must be 1.")), e.kind !== "dashboard" && i.push(n("invalid_kind", "Experience intent kind must be dashboard.")), d(e.title) || i.push(n("missing_title", "Dashboard intent needs a title.", "title"));
|
|
850
|
+
const r = Array.isArray(e.inputs) ? e.inputs : [], o = M(
|
|
851
|
+
r.filter(u).map((c) => c.id).filter((c) => typeof c == "string")
|
|
749
852
|
);
|
|
750
|
-
|
|
751
|
-
|
|
853
|
+
o && i.push(
|
|
854
|
+
n(
|
|
752
855
|
"duplicate_input_id",
|
|
753
|
-
`Duplicate input id: ${
|
|
856
|
+
`Duplicate input id: ${o}.`,
|
|
754
857
|
"inputs"
|
|
755
858
|
)
|
|
756
859
|
);
|
|
757
|
-
for (const [
|
|
758
|
-
const
|
|
759
|
-
if (!
|
|
760
|
-
i.push(
|
|
860
|
+
for (const [c, l] of r.entries()) {
|
|
861
|
+
const f = `inputs.${c}`;
|
|
862
|
+
if (!u(l)) {
|
|
863
|
+
i.push(n("invalid_input", "Dashboard input must be an object.", f));
|
|
761
864
|
continue;
|
|
762
865
|
}
|
|
763
|
-
d(l.id) || i.push(
|
|
764
|
-
|
|
866
|
+
d(l.id) || i.push(n("missing_input_id", "Input needs an id.", `${f}.id`)), d(l.label) || i.push(
|
|
867
|
+
n("missing_input_label", "Input needs a label.", `${f}.label`)
|
|
765
868
|
), !l.field || !d(l.field.name) ? i.push(
|
|
766
|
-
|
|
767
|
-
) :
|
|
869
|
+
n("missing_input_field", "Input needs a field.", `${f}.field`)
|
|
870
|
+
) : m(l.field, `${f}.field`, i);
|
|
768
871
|
}
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
|
|
872
|
+
const s = Array.isArray(e.sections) ? e.sections : [];
|
|
873
|
+
s.length === 0 && i.push(
|
|
874
|
+
n(
|
|
772
875
|
"missing_sections",
|
|
773
876
|
"Dashboard intent needs at least one section.",
|
|
774
877
|
"sections"
|
|
775
878
|
)
|
|
776
879
|
);
|
|
777
|
-
const t =
|
|
778
|
-
(
|
|
779
|
-
), p =
|
|
880
|
+
const t = s.flatMap(
|
|
881
|
+
(c) => c && typeof c == "object" && Array.isArray(c.views) ? c.views.filter(u).map((l) => l.id).filter((l) => !!l) : []
|
|
882
|
+
), p = M(t);
|
|
780
883
|
p && i.push(
|
|
781
|
-
|
|
884
|
+
n(
|
|
782
885
|
"duplicate_view_id",
|
|
783
886
|
`Duplicate dashboard view id: ${p}.`,
|
|
784
887
|
"sections"
|
|
785
888
|
)
|
|
786
889
|
);
|
|
787
|
-
for (const [
|
|
788
|
-
const
|
|
890
|
+
for (const [c, l] of s.entries()) {
|
|
891
|
+
const f = `sections.${c}`;
|
|
789
892
|
if (!l || typeof l != "object") {
|
|
790
893
|
i.push(
|
|
791
|
-
|
|
894
|
+
n("invalid_section", "Dashboard section must be an object.", f)
|
|
792
895
|
);
|
|
793
896
|
continue;
|
|
794
897
|
}
|
|
795
898
|
if (d(l.title) || i.push(
|
|
796
|
-
|
|
899
|
+
n("missing_section_title", "Dashboard section needs a title.", f)
|
|
797
900
|
), !Array.isArray(l.views) || l.views.length === 0) {
|
|
798
901
|
i.push(
|
|
799
|
-
|
|
902
|
+
n(
|
|
800
903
|
"missing_section_views",
|
|
801
904
|
"Dashboard section needs at least one view.",
|
|
802
|
-
`${
|
|
905
|
+
`${f}.views`
|
|
803
906
|
)
|
|
804
907
|
);
|
|
805
908
|
continue;
|
|
806
909
|
}
|
|
807
|
-
for (const [
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
`${
|
|
910
|
+
for (const [h, v] of l.views.entries())
|
|
911
|
+
K(
|
|
912
|
+
v,
|
|
913
|
+
`${f}.views.${h}`,
|
|
811
914
|
i,
|
|
812
|
-
|
|
915
|
+
a
|
|
813
916
|
);
|
|
814
917
|
}
|
|
815
|
-
return { ok: i.length === 0, errors: i, warnings:
|
|
918
|
+
return { ok: i.length === 0, errors: i, warnings: a };
|
|
816
919
|
}
|
|
817
920
|
export {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
921
|
+
Z as a,
|
|
922
|
+
W as b,
|
|
923
|
+
ee as c,
|
|
924
|
+
F as d,
|
|
925
|
+
D as e,
|
|
926
|
+
x as f,
|
|
927
|
+
J as g,
|
|
928
|
+
I as p,
|
|
929
|
+
A as s,
|
|
930
|
+
T as v
|
|
827
931
|
};
|