react-semaphor 0.1.347 → 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.
@@ -1,4 +1,4 @@
1
- function h(e) {
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 $(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 : h(e) === h(i);
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 N(e, i) {
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 B(e, i) {
32
- return e.name === i.name && $(e.source, i.source);
31
+ function x(e, i) {
32
+ return e.name === i.name && F(e.source, i.source);
33
33
  }
34
- function L(e, i) {
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 ? N(e.source, i.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 a(e, i, n) {
44
- return n ? { code: e, message: i, path: n } : { code: e, message: i };
43
+ function n(e, i, a) {
44
+ return a ? { code: e, message: i, path: a } : { code: e, message: i };
45
45
  }
46
- function R(e) {
46
+ function j(e) {
47
47
  for (let i = 0; i < e.length; i += 1) {
48
- const n = e[i];
48
+ const a = e[i];
49
49
  if (e.some(
50
- (o, r) => r !== i && b(o, n)
50
+ (r, o) => o !== i && $(r, a)
51
51
  ))
52
52
  return !1;
53
53
  }
54
54
  return !0;
55
55
  }
56
- function g(e, i) {
57
- return B(e, i);
56
+ function S(e, i) {
57
+ return x(e, i);
58
58
  }
59
- function b(e, i) {
60
- return g(e, i) && y(e) === y(i);
59
+ function $(e, i) {
60
+ return S(e, i) && y(e) === y(i);
61
61
  }
62
- function F(e) {
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 j(e, i) {
66
- return _(e, i).length === 1;
65
+ function C(e, i) {
66
+ return b(e, i).length === 1;
67
67
  }
68
- function x(e, i) {
69
- return _(e, i).length === 1;
68
+ function E(e, i) {
69
+ return b(e, i).length === 1;
70
70
  }
71
- function _(e, i) {
71
+ function b(e, i) {
72
72
  return i.filter(
73
- (o) => T(e, o)
73
+ (r) => q(e, r)
74
74
  );
75
75
  }
76
- function T(e, i) {
77
- return D(e, i) ? e.source ? g(i, e) : !0 : !1;
76
+ function q(e, i) {
77
+ return U(e, i) ? e.source ? S(i, e) : !0 : !1;
78
78
  }
79
- function D(e, i) {
80
- return !(i.name !== e.name || e.role !== void 0 && i.role !== void 0 && i.role !== e.role || q(e, i) && y(i) !== y(e));
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 q(e, i) {
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 c(e) {
128
+ function u(e) {
92
129
  return !!(e && typeof e == "object" && !Array.isArray(e));
93
130
  }
94
- function v(e) {
131
+ function M(e) {
95
132
  const i = /* @__PURE__ */ new Set();
96
- for (const n of e) {
97
- if (i.has(n))
98
- return n;
99
- i.add(n);
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 C = /* @__PURE__ */ new Set([
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 A(e, i, n) {
149
+ function N(e, i, a) {
113
150
  if (!e || typeof e != "object") {
114
- n.push(a("missing_source", "Analytics intent needs a source.", i));
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) || n.push(
119
- a(
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) || n.push(
125
- a(
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, n) {
131
168
  return;
132
169
  }
133
170
  if (e.kind === "physical") {
134
- d(e.connectionId) || n.push(
135
- a(
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) || n.push(
141
- a(
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, n) {
147
184
  return;
148
185
  }
149
186
  if (e.kind === "sql") {
150
- d(e.connectionId) || n.push(
151
- a(
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, n) {
156
193
  );
157
194
  return;
158
195
  }
159
- n.push(a("invalid_source_kind", "Source kind is not supported.", i));
196
+ a.push(n("invalid_source_kind", "Source kind is not supported.", i));
160
197
  }
161
- function f(e, i, n, o = {}) {
162
- if (!e || !c(e)) {
163
- o.required && n.push(
164
- a("missing_field_ref", "Field reference needs a name.", i)
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) || n.push(
169
- a("missing_field_ref", "Field reference needs a name.", `${i}.name`)
170
- ), e.source !== void 0 && A(e.source, `${i}.source`, n), E(e.aggregate, `${i}.aggregate`, n);
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 E(e, i, n) {
173
- e !== void 0 && (typeof e != "string" || !C.has(e)) && n.push(
174
- a(
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 P(e, i) {
218
+ function X(e, i) {
182
219
  if (e.analysis === void 0)
183
220
  return;
184
- if (!c(e.analysis)) {
221
+ if (!u(e.analysis)) {
185
222
  i.push(
186
- a(
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
- a(
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
- a(
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
- a(
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
- a(
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: n } = e.analysis;
224
- n !== void 0 && w(n, "analysis.timeWindow", i);
260
+ const { timeWindow: a } = e.analysis;
261
+ a !== void 0 && B(a, "analysis.timeWindow", i);
225
262
  }
226
- function w(e, i, n) {
227
- if (!c(e)) {
228
- n.push(
229
- a(
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 w(e, i, n) {
234
271
  );
235
272
  return;
236
273
  }
237
- 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(
238
- a(
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) && n.push(
244
- a(
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" && n.push(
250
- a(
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" && n.push(
256
- a(
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 O(e, i, n) {
343
+ function Y(e, i, a) {
264
344
  if (e !== void 0) {
265
345
  if (!Array.isArray(e)) {
266
- n.push(
267
- a(
346
+ a.push(
347
+ n(
268
348
  "invalid_analytics_filters",
269
349
  "Analytics filters must be an array.",
270
350
  i
@@ -272,91 +352,91 @@ function O(e, i, n) {
272
352
  );
273
353
  return;
274
354
  }
275
- e.forEach((o, r) => {
276
- const t = `${i}.${r}`;
277
- if (!c(o)) {
278
- n.push(
279
- a(
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
- t
362
+ s
283
363
  )
284
364
  );
285
365
  return;
286
366
  }
287
- const s = o;
288
- f(s.field, `${t}.field`, n, {
367
+ const t = r;
368
+ m(t.field, `${s}.field`, a, {
289
369
  required: !0
290
370
  });
291
- const m = s.operator === "is_null" || s.operator === "is_not_null";
292
- 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(
293
- a(
371
+ const p = t.operator === "is_null" || t.operator === "is_not_null";
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
- `${t}.operator`
376
+ `${s}.operator`
297
377
  )
298
- ), s.values === void 0 && !m && n.push(
299
- a(
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
- t
382
+ s
303
383
  )
304
- ), m && s.values !== void 0) {
305
- n.push(
306
- a(
384
+ ), p && t.values !== void 0) {
385
+ a.push(
386
+ n(
307
387
  "invalid_analytics_filter_values",
308
388
  "Null-check analytics filters must not include values.",
309
- `${t}.values`
389
+ `${s}.values`
310
390
  )
311
391
  );
312
392
  return;
313
393
  }
314
- if (s.values !== void 0 && !Array.isArray(s.values)) {
315
- n.push(
316
- a(
394
+ if (t.values !== void 0 && !Array.isArray(t.values)) {
395
+ a.push(
396
+ n(
317
397
  "invalid_analytics_filter_values",
318
398
  "Analytics filter values must be an array when provided.",
319
- `${t}.values`
399
+ `${s}.values`
320
400
  )
321
401
  );
322
402
  return;
323
403
  }
324
- if (s.values !== void 0) {
325
- const u = s.values.length;
326
- if (s.operator === "between" || s.operator === "not_between") {
327
- u !== 2 && n.push(
328
- a(
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(
329
409
  "invalid_analytics_filter_values",
330
410
  "Between analytics filters must include exactly two values.",
331
- `${t}.values`
411
+ `${s}.values`
332
412
  )
333
413
  );
334
414
  return;
335
415
  }
336
- (s.operator === "contains" || s.operator === "not_contains" || s.operator === "=" || s.operator === "!=" || s.operator === ">" || s.operator === ">=" || s.operator === "<" || s.operator === "<=" || s.operator === void 0) && u !== 1 && n.push(
337
- a(
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(
338
418
  "invalid_analytics_filter_values",
339
419
  "Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",
340
- `${t}.values`
420
+ `${s}.values`
341
421
  )
342
422
  );
343
423
  }
344
424
  });
345
425
  }
346
426
  }
347
- function k(e) {
348
- var o;
349
- const i = [], n = [];
427
+ function T(e) {
428
+ var r;
429
+ const i = [], a = [];
350
430
  if (!e || typeof e != "object")
351
431
  return {
352
432
  ok: !1,
353
433
  errors: [
354
- a(
434
+ n(
355
435
  "invalid_analytics_intent",
356
436
  "Analytics intent must be a structured object."
357
437
  )
358
438
  ],
359
- warnings: n,
439
+ warnings: a,
360
440
  repairHints: [
361
441
  {
362
442
  code: "invalid_analytics_intent",
@@ -365,111 +445,111 @@ function k(e) {
365
445
  ]
366
446
  };
367
447
  if (e.version !== void 0 && e.version !== 1 && i.push(
368
- a("invalid_version", "Analytics intent version must be 1.", "version")
369
- ), A(e.source, "source", i), e.kind === "metric") {
370
- const r = Array.isArray(e.metrics) ? e.metrics.filter(
371
- (t) => c(t) && d(t.name)
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)
372
452
  ) : [];
373
453
  if (!Array.isArray(e.metrics) || e.metrics.length === 0 ? i.push(
374
- a("missing_metric", "Metric intent needs at least one metric.", "metrics")
454
+ n("missing_metric", "Metric intent needs at least one metric.", "metrics")
375
455
  ) : e.metrics.some(
376
- (t) => !c(t) || !d(t.name)
456
+ (s) => !u(s) || !d(s.name)
377
457
  ) && i.push(
378
- a(
458
+ n(
379
459
  "invalid_metric_list",
380
460
  "Metric intent metrics must be an array of field references with names.",
381
461
  "metrics"
382
462
  )
383
- ), r.forEach((t, s) => {
384
- f(t, `metrics.${s}`, i, {
463
+ ), o.forEach((s, t) => {
464
+ m(s, `metrics.${t}`, i, {
385
465
  required: !0
386
466
  });
387
- }), r.length > 0 && !R(r)) {
388
- const t = r.find(
389
- (s, m) => r.some(
390
- (u, l) => l !== m && b(u, s)
467
+ }), o.length > 0 && !j(o)) {
468
+ const s = o.find(
469
+ (t, p) => o.some(
470
+ (c, l) => l !== p && $(c, t)
391
471
  )
392
472
  );
393
- t && i.push(
394
- a(
473
+ s && i.push(
474
+ n(
395
475
  "duplicate_metric",
396
- F(t),
476
+ O(s),
397
477
  "metrics"
398
478
  )
399
479
  );
400
480
  }
401
- if (c(e.primaryMetric) && d(e.primaryMetric.name) && _(
481
+ if (u(e.primaryMetric) && d(e.primaryMetric.name) && b(
402
482
  e.primaryMetric,
403
- r
483
+ o
404
484
  ).length > 1 && i.push(
405
- a(
485
+ n(
406
486
  "ambiguous_primary_metric",
407
487
  "Metric intent primaryMetric must identify exactly one selected metric.",
408
488
  "primaryMetric"
409
489
  )
410
- ), e.primaryMetric !== void 0 && (f(e.primaryMetric, "primaryMetric", i, {
490
+ ), e.primaryMetric !== void 0 && (m(e.primaryMetric, "primaryMetric", i, {
411
491
  required: !0
412
- }), c(e.primaryMetric) && d(e.primaryMetric.name) && r.length > 0 && !j(
492
+ }), u(e.primaryMetric) && d(e.primaryMetric.name) && o.length > 0 && !C(
413
493
  e.primaryMetric,
414
- r
494
+ o
415
495
  ) && i.push(
416
- a(
496
+ n(
417
497
  "invalid_primary_metric",
418
498
  "Metric intent primaryMetric must match one metric field reference.",
419
499
  "primaryMetric"
420
500
  )
421
501
  )), e.dimensions !== void 0 && !Array.isArray(e.dimensions) ? i.push(
422
- a(
502
+ n(
423
503
  "invalid_metric_dimensions",
424
504
  "Metric intent dimensions must be an array of field references.",
425
505
  "dimensions"
426
506
  )
427
507
  ) : Array.isArray(e.dimensions) && e.dimensions.some(
428
- (t) => !c(t) || !d(t.name)
508
+ (s) => !u(s) || !d(s.name)
429
509
  ) && i.push(
430
- a(
510
+ n(
431
511
  "invalid_metric_dimensions",
432
512
  "Metric intent dimensions must be an array of field references with names.",
433
513
  "dimensions"
434
514
  )
435
- ), e.dateField !== void 0 && f(e.dateField, "dateField", i), e.timeWindow !== void 0 && (w(e.timeWindow, "timeWindow", i), e.dateField || i.push(
436
- a(
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(
437
517
  "missing_time_window_date_field",
438
518
  "Metric timeWindow needs a dateField.",
439
519
  "dateField"
440
520
  )
441
- )), O(e.filters, "filters", i), Array.isArray(e.dimensions) && e.dimensions.forEach((t, s) => {
442
- f(t, `dimensions.${s}`, i);
521
+ )), Y(e.filters, "filters", i), Array.isArray(e.dimensions) && e.dimensions.forEach((s, t) => {
522
+ m(s, `dimensions.${t}`, i);
443
523
  }), e.orderBy !== void 0) {
444
- if (!c(e.orderBy))
524
+ if (!u(e.orderBy))
445
525
  i.push(
446
- a(
526
+ n(
447
527
  "invalid_metric_order_by",
448
528
  "Metric intent orderBy must be a structured object.",
449
529
  "orderBy"
450
530
  )
451
531
  );
452
- else if (f(e.orderBy.field, "orderBy.field", i, {
532
+ else if (m(e.orderBy.field, "orderBy.field", i, {
453
533
  required: !0
454
534
  }), e.orderBy.direction !== "asc" && e.orderBy.direction !== "desc" && i.push(
455
- a(
535
+ n(
456
536
  "invalid_metric_order_direction",
457
537
  "Metric intent orderBy direction must be asc or desc.",
458
538
  "orderBy.direction"
459
539
  )
460
- ), c(e.orderBy.field) && d(e.orderBy.field.name)) {
461
- const t = [
462
- ...r,
463
- ...e.timeGrain && e.dateField && c(e.dateField) ? [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] : [],
464
544
  ...Array.isArray(e.dimensions) ? e.dimensions.filter(
465
- (s) => c(s) && d(s.name)
545
+ (t) => u(t) && d(t.name)
466
546
  ) : []
467
547
  ];
468
- t.length > 0 && !x(
548
+ s.length > 0 && !E(
469
549
  e.orderBy.field,
470
- t
550
+ s
471
551
  ) && i.push(
472
- a(
552
+ n(
473
553
  "invalid_metric_order_by",
474
554
  "Metric intent orderBy.field must match one selected metric, grouped dateField, or dimension.",
475
555
  "orderBy.field"
@@ -477,73 +557,73 @@ function k(e) {
477
557
  );
478
558
  }
479
559
  }
480
- P(e, i);
560
+ X(e, i);
481
561
  } else e.kind === "records" ? (!Array.isArray(e.fields) || e.fields.length === 0 ? i.push(
482
- a(
562
+ n(
483
563
  "missing_record_fields",
484
564
  "Records intent needs at least one field.",
485
565
  "fields"
486
566
  )
487
567
  ) : e.fields.some(
488
- (r) => !c(r) || !d(r.name)
568
+ (o) => !u(o) || !d(o.name)
489
569
  ) && i.push(
490
- a(
570
+ n(
491
571
  "invalid_record_fields",
492
572
  "Records intent fields must be field references with names.",
493
573
  "fields"
494
574
  )
495
- ), Array.isArray(e.fields) && e.fields.forEach((r, t) => {
496
- f(r, `fields.${t}`, i);
497
- }), e.dateField !== void 0 && f(e.dateField, "dateField", i), e.orderBy !== void 0 && (c(e.orderBy) ? (f(e.orderBy.field, "orderBy.field", i, {
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, {
498
578
  required: !0
499
579
  }), e.orderBy.direction !== "asc" && e.orderBy.direction !== "desc" && i.push(
500
- a(
580
+ n(
501
581
  "invalid_record_order_direction",
502
582
  "Records intent orderBy direction must be asc or desc.",
503
583
  "orderBy.direction"
504
584
  )
505
585
  )) : i.push(
506
- a(
586
+ n(
507
587
  "invalid_record_order_by",
508
588
  "Records intent orderBy must be a structured object.",
509
589
  "orderBy"
510
590
  )
511
591
  ))) : e.kind === "inputOptions" ? ((!e.field || !d(e.field.name)) && i.push(
512
- a(
592
+ n(
513
593
  "missing_input_options_field",
514
594
  "Input options intent needs a field.",
515
595
  "field"
516
596
  )
517
- ), f(e.field, "field", i, { required: !0 })) : e.kind === "sql" ? (((o = e.source) == null ? void 0 : o.kind) !== "sql" && i.push(
518
- a(
597
+ ), m(e.field, "field", i, { required: !0 })) : e.kind === "sql" ? (((r = e.source) == null ? void 0 : r.kind) !== "sql" && i.push(
598
+ n(
519
599
  "invalid_sql_source",
520
600
  "SQL analytics intent must use a SQL execution source.",
521
601
  "source"
522
602
  )
523
- ), d(e.sql) || i.push(a("missing_sql", "SQL analytics intent needs SQL text.", "sql")), Array.isArray(e.fields) && e.fields.forEach((r, t) => {
524
- f(r, `fields.${t}`, i);
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);
525
605
  })) : i.push(
526
- a("invalid_analytics_kind", "Analytics kind is not supported.", "kind")
606
+ n("invalid_analytics_kind", "Analytics kind is not supported.", "kind")
527
607
  );
528
608
  return {
529
609
  ok: i.length === 0,
530
610
  errors: i,
531
- warnings: n,
532
- repairHints: H(i)
611
+ warnings: a,
612
+ repairHints: z(i)
533
613
  };
534
614
  }
535
- function U(e) {
536
- const i = [], n = [];
615
+ function Z(e) {
616
+ const i = [], a = [];
537
617
  if (!e || typeof e != "object")
538
618
  return {
539
619
  ok: !1,
540
620
  errors: [
541
- a(
621
+ n(
542
622
  "invalid_operation_intent",
543
623
  "Operation intent must be a structured object."
544
624
  )
545
625
  ],
546
- warnings: n,
626
+ warnings: a,
547
627
  repairHints: [
548
628
  {
549
629
  code: "invalid_operation_intent",
@@ -552,45 +632,45 @@ function U(e) {
552
632
  ]
553
633
  };
554
634
  if (e.version !== 1 && i.push(
555
- a("invalid_version", "Operation intent version must be 1.", "version")
635
+ n("invalid_version", "Operation intent version must be 1.", "version")
556
636
  ), e.kind === "answer_obligations")
557
637
  !Array.isArray(e.obligations) || e.obligations.length === 0 ? i.push(
558
- a(
638
+ n(
559
639
  "missing_obligations",
560
640
  "Answer-obligations operation intent needs at least one obligation.",
561
641
  "obligations"
562
642
  )
563
- ) : e.obligations.forEach((o, r) => {
564
- d(o.id) || i.push(
565
- a(
643
+ ) : e.obligations.forEach((r, o) => {
644
+ d(r.id) || i.push(
645
+ n(
566
646
  "missing_obligation_id",
567
647
  "Each analytics obligation needs an id.",
568
- `obligations.${r}.id`
648
+ `obligations.${o}.id`
569
649
  )
570
- ), d(o.prompt) || i.push(
571
- a(
650
+ ), d(r.prompt) || i.push(
651
+ n(
572
652
  "missing_obligation_prompt",
573
653
  "Each analytics obligation needs a prompt.",
574
- `obligations.${r}.prompt`
654
+ `obligations.${o}.prompt`
575
655
  )
576
656
  );
577
657
  });
578
658
  else if (e.kind === "dashboard_change" || e.kind === "data_app_change") {
579
659
  if (d(e.instruction) || i.push(
580
- a(
660
+ n(
581
661
  "missing_instruction",
582
662
  "Change operation intent needs an instruction.",
583
663
  "instruction"
584
664
  )
585
665
  ), e.analyticsIntent) {
586
- const o = k(
666
+ const r = T(
587
667
  e.analyticsIntent
588
668
  );
589
- i.push(...o.errors), n.push(...o.warnings);
669
+ i.push(...r.errors), a.push(...r.warnings);
590
670
  }
591
671
  } else
592
672
  i.push(
593
- a(
673
+ n(
594
674
  "invalid_operation_kind",
595
675
  "Operation intent kind is not supported.",
596
676
  "kind"
@@ -599,22 +679,22 @@ function U(e) {
599
679
  return {
600
680
  ok: i.length === 0,
601
681
  errors: i,
602
- warnings: n,
603
- repairHints: I(i)
682
+ warnings: a,
683
+ repairHints: R(i)
604
684
  };
605
685
  }
606
- function Q(e) {
607
- const i = [], n = [];
686
+ function W(e) {
687
+ const i = [], a = [];
608
688
  if (!e || typeof e != "object")
609
689
  return {
610
690
  ok: !1,
611
691
  errors: [
612
- a(
692
+ n(
613
693
  "invalid_recovery_plan",
614
694
  "Analytics recovery plan must be a structured object."
615
695
  )
616
696
  ],
617
- warnings: n,
697
+ warnings: a,
618
698
  repairHints: [
619
699
  {
620
700
  code: "invalid_recovery_plan",
@@ -623,17 +703,17 @@ function Q(e) {
623
703
  ]
624
704
  };
625
705
  e.version !== 1 && i.push(
626
- a("invalid_version", "Recovery plan version must be 1.", "version")
706
+ n("invalid_version", "Recovery plan version must be 1.", "version")
627
707
  ), e.kind !== "analytics_recovery_plan" && i.push(
628
- a(
708
+ n(
629
709
  "invalid_recovery_plan_kind",
630
710
  "Recovery plan kind must be analytics_recovery_plan.",
631
711
  "kind"
632
712
  )
633
713
  );
634
- const o = U(e.operationIntent);
635
- return i.push(...o.errors), n.push(...o.warnings), Array.isArray(e.plannedToolCalls) || i.push(
636
- a(
714
+ const r = Z(e.operationIntent);
715
+ return i.push(...r.errors), a.push(...r.warnings), Array.isArray(e.plannedToolCalls) || i.push(
716
+ n(
637
717
  "invalid_planned_tool_calls",
638
718
  "Recovery plan plannedToolCalls must be an array.",
639
719
  "plannedToolCalls"
@@ -641,17 +721,17 @@ function Q(e) {
641
721
  ), {
642
722
  ok: i.length === 0,
643
723
  errors: i,
644
- warnings: n,
645
- repairHints: I(i)
724
+ warnings: a,
725
+ repairHints: R(i)
646
726
  };
647
727
  }
648
- function I(e) {
728
+ function R(e) {
649
729
  return e.map((i) => ({
650
730
  code: i.code,
651
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."
652
732
  }));
653
733
  }
654
- function H(e) {
734
+ function z(e) {
655
735
  return e.map((i) => {
656
736
  switch (i.code) {
657
737
  case "missing_source":
@@ -704,14 +784,14 @@ function H(e) {
704
784
  }
705
785
  }).filter((i) => !!i);
706
786
  }
707
- function G(e, i, n, o) {
787
+ function K(e, i, a, r) {
708
788
  if (!e || typeof e != "object") {
709
- n.push(a("invalid_view", "Dashboard view must be an object.", i));
789
+ a.push(n("invalid_view", "Dashboard view must be an object.", i));
710
790
  return;
711
791
  }
712
- if (d(e.title) || n.push(a("missing_view_title", "Dashboard view needs a title.", i)), !e.presentation || typeof e.presentation != "object") {
713
- n.push(
714
- a(
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(
715
795
  "missing_presentation",
716
796
  "Dashboard view needs a presentation.",
717
797
  `${i}.presentation`
@@ -720,8 +800,8 @@ function G(e, i, n, o) {
720
800
  return;
721
801
  }
722
802
  if (e.presentation.kind === "text") {
723
- d(e.text) || o.push(
724
- a(
803
+ d(e.text) || r.push(
804
+ n(
725
805
  "missing_text_content",
726
806
  "Text views should include text content.",
727
807
  `${i}.text`
@@ -730,8 +810,8 @@ function G(e, i, n, o) {
730
810
  return;
731
811
  }
732
812
  if (!e.analytics) {
733
- n.push(
734
- a(
813
+ a.push(
814
+ n(
735
815
  "missing_view_analytics",
736
816
  "Non-text dashboard views need analytics intent.",
737
817
  `${i}.analytics`
@@ -739,112 +819,113 @@ function G(e, i, n, o) {
739
819
  );
740
820
  return;
741
821
  }
742
- const r = k(e.analytics);
743
- for (const t of r.errors)
744
- n.push(
745
- a(t.code, t.message, `${i}.analytics${t.path ? `.${t.path}` : ""}`)
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}` : ""}`)
746
826
  );
747
- for (const t of r.warnings)
748
- o.push(
749
- a(
750
- t.code,
751
- t.message,
752
- `${i}.analytics${t.path ? `.${t.path}` : ""}`
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}` : ""}`
753
833
  )
754
834
  );
755
835
  }
756
- function V(e) {
757
- const i = [], n = [];
836
+ function ee(e) {
837
+ const i = [], a = [];
758
838
  if (!e || typeof e != "object")
759
839
  return {
760
840
  ok: !1,
761
841
  errors: [
762
- a(
842
+ n(
763
843
  "invalid_dashboard_intent",
764
844
  "Dashboard intent must be a structured object."
765
845
  )
766
846
  ],
767
- warnings: n
847
+ warnings: a
768
848
  };
769
- 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"));
770
- const o = Array.isArray(e.inputs) ? e.inputs : [], r = v(
771
- o.filter(c).map((u) => u.id).filter((u) => typeof u == "string")
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")
772
852
  );
773
- r && i.push(
774
- a(
853
+ o && i.push(
854
+ n(
775
855
  "duplicate_input_id",
776
- `Duplicate input id: ${r}.`,
856
+ `Duplicate input id: ${o}.`,
777
857
  "inputs"
778
858
  )
779
859
  );
780
- for (const [u, l] of o.entries()) {
781
- const p = `inputs.${u}`;
782
- if (!c(l)) {
783
- i.push(a("invalid_input", "Dashboard input must be an object.", p));
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));
784
864
  continue;
785
865
  }
786
- d(l.id) || i.push(a("missing_input_id", "Input needs an id.", `${p}.id`)), d(l.label) || i.push(
787
- a("missing_input_label", "Input needs a label.", `${p}.label`)
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`)
788
868
  ), !l.field || !d(l.field.name) ? i.push(
789
- a("missing_input_field", "Input needs a field.", `${p}.field`)
790
- ) : f(l.field, `${p}.field`, i);
869
+ n("missing_input_field", "Input needs a field.", `${f}.field`)
870
+ ) : m(l.field, `${f}.field`, i);
791
871
  }
792
- const t = Array.isArray(e.sections) ? e.sections : [];
793
- t.length === 0 && i.push(
794
- a(
872
+ const s = Array.isArray(e.sections) ? e.sections : [];
873
+ s.length === 0 && i.push(
874
+ n(
795
875
  "missing_sections",
796
876
  "Dashboard intent needs at least one section.",
797
877
  "sections"
798
878
  )
799
879
  );
800
- const s = t.flatMap(
801
- (u) => u && typeof u == "object" && Array.isArray(u.views) ? u.views.filter(c).map((l) => l.id).filter((l) => !!l) : []
802
- ), m = v(s);
803
- m && i.push(
804
- a(
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);
883
+ p && i.push(
884
+ n(
805
885
  "duplicate_view_id",
806
- `Duplicate dashboard view id: ${m}.`,
886
+ `Duplicate dashboard view id: ${p}.`,
807
887
  "sections"
808
888
  )
809
889
  );
810
- for (const [u, l] of t.entries()) {
811
- const p = `sections.${u}`;
890
+ for (const [c, l] of s.entries()) {
891
+ const f = `sections.${c}`;
812
892
  if (!l || typeof l != "object") {
813
893
  i.push(
814
- a("invalid_section", "Dashboard section must be an object.", p)
894
+ n("invalid_section", "Dashboard section must be an object.", f)
815
895
  );
816
896
  continue;
817
897
  }
818
898
  if (d(l.title) || i.push(
819
- a("missing_section_title", "Dashboard section needs a title.", p)
899
+ n("missing_section_title", "Dashboard section needs a title.", f)
820
900
  ), !Array.isArray(l.views) || l.views.length === 0) {
821
901
  i.push(
822
- a(
902
+ n(
823
903
  "missing_section_views",
824
904
  "Dashboard section needs at least one view.",
825
- `${p}.views`
905
+ `${f}.views`
826
906
  )
827
907
  );
828
908
  continue;
829
909
  }
830
- for (const [M, S] of l.views.entries())
831
- G(
832
- S,
833
- `${p}.views.${M}`,
910
+ for (const [h, v] of l.views.entries())
911
+ K(
912
+ v,
913
+ `${f}.views.${h}`,
834
914
  i,
835
- n
915
+ a
836
916
  );
837
917
  }
838
- return { ok: i.length === 0, errors: i, warnings: n };
918
+ return { ok: i.length === 0, errors: i, warnings: a };
839
919
  }
840
920
  export {
841
- U as a,
842
- Q as b,
843
- V as c,
844
- $ as d,
845
- B as e,
846
- L as f,
847
- N as p,
848
- h as s,
849
- k as v
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
850
931
  };