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