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.
@@ -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 n(e, i, t) {
54
- return t ? { code: e, message: i, path: t } : { code: e, message: i };
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 t = e[i];
58
+ const n = e[i];
59
59
  if (e.some(
60
- (r, o) => o !== i && B(r, t)
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
- (r) => U(e, r)
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 M(e) {
99
+ function $(e) {
100
100
  if (typeof e != "string")
101
101
  return null;
102
- const i = e.trim(), t = L.exec(i);
103
- if (t) {
104
- const [, g, w, A] = t;
105
- return $(g, w, A) ? new Date(
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 r = H.exec(i);
110
- if (!r)
109
+ const o = H.exec(i);
110
+ if (!o)
111
111
  return null;
112
- const [, o, a, s, p, c, l = "00", , f] = r;
113
- if (!$(o, a, s) || !_(p, 0, 23) || !_(c, 0, 59) || !_(l, 0, 59) || !V(f))
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 $(e, i, t) {
119
- const r = Number(e), o = Number(i), a = Number(t);
120
- if (!Number.isInteger(r) || !Number.isInteger(o) || !Number.isInteger(a) || o < 1 || o > 12)
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(r, o - 1, a));
123
- return s.getUTCFullYear() === r && s.getUTCMonth() === o - 1 && s.getUTCDate() === a;
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, t) {
126
- const r = Number(e);
127
- return Number.isInteger(r) && r >= i && r <= t;
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 t of e) {
144
- if (i.has(t))
145
- return t;
146
- i.add(t);
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, t) {
159
+ function x(e, i, n) {
160
160
  if (!e || typeof e != "object") {
161
- t.push(n("missing_source", "Analytics intent needs a source.", i));
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) || t.push(
166
- n(
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) || t.push(
172
- n(
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) || t.push(
182
- n(
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) || t.push(
188
- n(
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) || t.push(
198
- n(
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
- t.push(n("invalid_source_kind", "Source kind is not supported.", i));
206
+ n.push(t("invalid_source_kind", "Source kind is not supported.", i));
207
207
  }
208
- function m(e, i, t, r = {}) {
208
+ function p(e, i, n, o = {}) {
209
209
  if (!e || !u(e)) {
210
- r.required && t.push(
211
- n("missing_field_ref", "Field reference needs a name.", i)
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) || t.push(
216
- n("missing_field_ref", "Field reference needs a name.", `${i}.name`)
217
- ), e.source !== void 0 && x(e.source, `${i}.source`, t), z(e.aggregate, `${i}.aggregate`, t);
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, t) {
220
- e !== void 0 && (typeof e != "string" || !Q.has(e)) && t.push(
221
- n(
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
- n(
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
- n(
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
- n(
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
- n(
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
- n(
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: t } = e.analysis;
271
- t !== void 0 && v(t, "analysis.timeWindow", i);
270
+ const { timeWindow: n } = e.analysis;
271
+ n !== void 0 && v(n, "analysis.timeWindow", i);
272
272
  }
273
- function v(e, i, t) {
273
+ function v(e, i, n) {
274
274
  if (!u(e)) {
275
- t.push(
276
- n(
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" && t.push(
285
- n(
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) || t.push(
292
- n(
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) || t.push(
298
- n(
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 r = M(e.start), o = M(e.end);
305
- r || t.push(
306
- n(
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
- ), o || t.push(
312
- n(
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
- ), r && o && r.getTime() > o.getTime() && t.push(
318
- n(
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" && t.push(
328
- n(
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) && t.push(
334
- n(
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" && t.push(
340
- n(
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" && t.push(
346
- n(
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, t) {
353
+ function S(e, i, n) {
354
354
  if (e !== void 0) {
355
355
  if (!Array.isArray(e)) {
356
- t.push(
357
- n(
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((r, o) => {
365
+ e.forEach((o, a) => {
366
366
  var c;
367
- const a = `${i}.${o}`;
368
- if (!u(r)) {
369
- t.push(
370
- n(
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
- a
373
+ r
374
374
  )
375
375
  );
376
376
  return;
377
377
  }
378
- const s = r;
379
- m(s.field, `${a}.field`, t, {
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" && t.push(
382
- n(
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
- `${a}.scope`
385
+ `${r}.scope`
386
386
  )
387
- ), s.scope === "aggregate" && ((c = s.field) == null ? void 0 : c.role) !== void 0 && s.field.role !== "measure" && t.push(
388
- n(
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
- `${a}.scope`
391
+ `${r}.scope`
392
392
  )
393
393
  );
394
- const p = 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" && t.push(
396
- n(
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
- `${a}.operator`
399
+ `${r}.operator`
400
400
  )
401
- ), s.values === void 0 && !p && t.push(
402
- n(
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
- a
405
+ r
406
406
  )
407
- ), p && s.values !== void 0) {
408
- t.push(
409
- n(
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
- `${a}.values`
412
+ `${r}.values`
413
413
  )
414
414
  );
415
415
  return;
416
416
  }
417
417
  if (s.values !== void 0 && !Array.isArray(s.values)) {
418
- t.push(
419
- n(
418
+ n.push(
419
+ t(
420
420
  "invalid_analytics_filter_values",
421
421
  "Analytics filter values must be an array when provided.",
422
- `${a}.values`
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 && t.push(
431
- n(
430
+ l !== 2 && n.push(
431
+ t(
432
432
  "invalid_analytics_filter_values",
433
433
  "Between analytics filters must include exactly two values.",
434
- `${a}.values`
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 && t.push(
440
- n(
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
- `${a}.values`
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 r;
452
- const i = [], t = [];
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
- n(
457
+ t(
458
458
  "invalid_analytics_intent",
459
459
  "Analytics intent must be a structured object."
460
460
  )
461
461
  ],
462
- warnings: t,
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
- n("invalid_version", "Analytics intent version must be 1.", "version")
471
+ t("invalid_version", "Analytics intent version must be 1.", "version")
472
472
  ), x(e.source, "source", i), e.kind === "metric") {
473
- const o = Array.isArray(e.metrics) ? e.metrics.filter(
474
- (a) => u(a) && d(a.name)
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
- n("missing_metric", "Metric intent needs at least one metric.", "metrics")
477
+ t("missing_metric", "Metric intent needs at least one metric.", "metrics")
478
478
  ) : e.metrics.some(
479
- (a) => !u(a) || !d(a.name)
479
+ (r) => !u(r) || !d(r.name)
480
480
  ) && i.push(
481
- n(
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
- ), o.forEach((a, s) => {
487
- m(a, `metrics.${s}`, i, {
486
+ ), a.forEach((r, s) => {
487
+ p(r, `metrics.${s}`, i, {
488
488
  required: !0
489
489
  });
490
- }), o.length > 0 && !q(o)) {
491
- const a = o.find(
492
- (s, p) => o.some(
493
- (c, l) => l !== p && B(c, s)
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
- a && i.push(
497
- n(
496
+ r && i.push(
497
+ t(
498
498
  "duplicate_metric",
499
- j(a),
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
- o
506
+ a
507
507
  ).length > 1 && i.push(
508
- n(
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 && (m(e.primaryMetric, "primaryMetric", i, {
513
+ ), e.primaryMetric !== void 0 && (p(e.primaryMetric, "primaryMetric", i, {
514
514
  required: !0
515
- }), u(e.primaryMetric) && d(e.primaryMetric.name) && o.length > 0 && !C(
515
+ }), u(e.primaryMetric) && d(e.primaryMetric.name) && a.length > 0 && !C(
516
516
  e.primaryMetric,
517
- o
517
+ a
518
518
  ) && i.push(
519
- n(
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
- n(
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
- (a) => !u(a) || !d(a.name)
531
+ (r) => !u(r) || !d(r.name)
532
532
  ) && i.push(
533
- n(
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 && m(e.dateField, "dateField", i), e.timeWindow !== void 0 && (v(e.timeWindow, "timeWindow", i), e.dateField || i.push(
539
- n(
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((a, s) => {
545
- m(a, `dimensions.${s}`, i);
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
- n(
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 (m(e.orderBy.field, "orderBy.field", i, {
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
- n(
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 a = [
565
- ...o,
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
- a.length > 0 && !E(
571
+ r.length > 0 && !E(
572
572
  e.orderBy.field,
573
- a
573
+ r
574
574
  ) && i.push(
575
- n(
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
- n(
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
- (o) => !u(o) || !d(o.name)
591
+ (a) => !u(a) || !d(a.name)
592
592
  ) && i.push(
593
- n(
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((o, a) => {
599
- m(o, `fields.${a}`, i);
600
- }), e.dateField !== void 0 && m(e.dateField, "dateField", i), e.timeWindow !== void 0 && (v(e.timeWindow, "timeWindow", i), e.dateField || i.push(
601
- n(
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), e.orderBy !== void 0 && (u(e.orderBy) ? (m(e.orderBy.field, "orderBy.field", 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
- n(
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
- n(
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
- n(
629
+ t(
622
630
  "missing_input_options_field",
623
631
  "Input options intent needs a field.",
624
632
  "field"
625
633
  )
626
- ), m(e.field, "field", i, { required: !0 })) : e.kind === "sql" ? (((r = e.source) == null ? void 0 : r.kind) !== "sql" && i.push(
627
- n(
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(n("missing_sql", "SQL analytics intent needs SQL text.", "sql")), Array.isArray(e.fields) && e.fields.forEach((o, a) => {
633
- m(o, `fields.${a}`, i);
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
- n("invalid_analytics_kind", "Analytics kind is not supported.", "kind")
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: t,
648
+ warnings: n,
641
649
  repairHints: Z(i)
642
650
  };
643
651
  }
644
652
  function Y(e) {
645
- const i = [], t = [];
653
+ const i = [], n = [];
646
654
  if (!e || typeof e != "object")
647
655
  return {
648
656
  ok: !1,
649
657
  errors: [
650
- n(
658
+ t(
651
659
  "invalid_operation_intent",
652
660
  "Operation intent must be a structured object."
653
661
  )
654
662
  ],
655
- warnings: t,
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
- n("invalid_version", "Operation intent version must be 1.", "version")
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
- n(
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((r, o) => {
673
- d(r.id) || i.push(
674
- n(
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.${o}.id`
685
+ `obligations.${a}.id`
678
686
  )
679
- ), d(r.prompt) || i.push(
680
- n(
687
+ ), d(o.prompt) || i.push(
688
+ t(
681
689
  "missing_obligation_prompt",
682
690
  "Each analytics obligation needs a prompt.",
683
- `obligations.${o}.prompt`
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
- n(
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 r = F(
703
+ const o = F(
696
704
  e.analyticsIntent
697
705
  );
698
- i.push(...r.errors), t.push(...r.warnings);
706
+ i.push(...o.errors), n.push(...o.warnings);
699
707
  }
700
708
  } else
701
709
  i.push(
702
- n(
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: t,
719
+ warnings: n,
712
720
  repairHints: R(i)
713
721
  };
714
722
  }
715
723
  function ee(e) {
716
- const i = [], t = [];
724
+ const i = [], n = [];
717
725
  if (!e || typeof e != "object")
718
726
  return {
719
727
  ok: !1,
720
728
  errors: [
721
- n(
729
+ t(
722
730
  "invalid_recovery_plan",
723
731
  "Analytics recovery plan must be a structured object."
724
732
  )
725
733
  ],
726
- warnings: t,
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
- n("invalid_version", "Recovery plan version must be 1.", "version")
743
+ t("invalid_version", "Recovery plan version must be 1.", "version")
736
744
  ), e.kind !== "analytics_recovery_plan" && i.push(
737
- n(
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 r = Y(e.operationIntent);
744
- return i.push(...r.errors), t.push(...r.warnings), Array.isArray(e.plannedToolCalls) || i.push(
745
- n(
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: t,
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, t, r) {
824
+ function J(e, i, n, o) {
817
825
  if (!e || typeof e != "object") {
818
- t.push(n("invalid_view", "Dashboard view must be an object.", i));
826
+ n.push(t("invalid_view", "Dashboard view must be an object.", i));
819
827
  return;
820
828
  }
821
- if (d(e.title) || t.push(n("missing_view_title", "Dashboard view needs a title.", i)), !e.presentation || typeof e.presentation != "object") {
822
- t.push(
823
- n(
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) || r.push(
833
- n(
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
- t.push(
843
- n(
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 o = F(e.analytics);
852
- for (const a of o.errors)
853
- t.push(
854
- n(a.code, a.message, `${i}.analytics${a.path ? `.${a.path}` : ""}`)
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 a of o.warnings)
857
- r.push(
858
- n(
859
- a.code,
860
- a.message,
861
- `${i}.analytics${a.path ? `.${a.path}` : ""}`
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 = [], t = [];
874
+ const i = [], n = [];
867
875
  if (!e || typeof e != "object")
868
876
  return {
869
877
  ok: !1,
870
878
  errors: [
871
- n(
879
+ t(
872
880
  "invalid_dashboard_intent",
873
881
  "Dashboard intent must be a structured object."
874
882
  )
875
883
  ],
876
- warnings: t
884
+ warnings: n
877
885
  };
878
- 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"));
879
- const r = Array.isArray(e.inputs) ? e.inputs : [], o = I(
880
- r.filter(u).map((c) => c.id).filter((c) => typeof c == "string")
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
- o && i.push(
883
- n(
890
+ a && i.push(
891
+ t(
884
892
  "duplicate_input_id",
885
- `Duplicate input id: ${o}.`,
893
+ `Duplicate input id: ${a}.`,
886
894
  "inputs"
887
895
  )
888
896
  );
889
- for (const [c, l] of r.entries()) {
897
+ for (const [c, l] of o.entries()) {
890
898
  const f = `inputs.${c}`;
891
899
  if (!u(l)) {
892
- i.push(n("invalid_input", "Dashboard input must be an object.", f));
900
+ i.push(t("invalid_input", "Dashboard input must be an object.", f));
893
901
  continue;
894
902
  }
895
- d(l.id) || i.push(n("missing_input_id", "Input needs an id.", `${f}.id`)), d(l.label) || i.push(
896
- n("missing_input_label", "Input needs a label.", `${f}.label`)
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
- n("missing_input_field", "Input needs a field.", `${f}.field`)
899
- ) : m(l.field, `${f}.field`, i);
906
+ t("missing_input_field", "Input needs a field.", `${f}.field`)
907
+ ) : p(l.field, `${f}.field`, i);
900
908
  }
901
- const a = Array.isArray(e.sections) ? e.sections : [];
902
- a.length === 0 && i.push(
903
- n(
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 = a.flatMap(
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
- ), p = I(s);
912
- p && i.push(
913
- n(
919
+ ), m = I(s);
920
+ m && i.push(
921
+ t(
914
922
  "duplicate_view_id",
915
- `Duplicate dashboard view id: ${p}.`,
923
+ `Duplicate dashboard view id: ${m}.`,
916
924
  "sections"
917
925
  )
918
926
  );
919
- for (const [c, l] of a.entries()) {
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
- n("invalid_section", "Dashboard section must be an object.", f)
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
- n("missing_section_title", "Dashboard section needs a title.", f)
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
- n(
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
- t
952
+ n
945
953
  );
946
954
  }
947
- return { ok: i.length === 0, errors: i, warnings: t };
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
- M as p,
963
+ $ as p,
956
964
  F as v
957
965
  };