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