react-semaphor 0.1.370 → 0.1.372

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.
Files changed (52) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +40 -38
  3. package/dist/chunks/{calendar-preferences-dialog-6q51A6XC.js → calendar-preferences-dialog-ClBAkMmF.js} +1 -1
  4. package/dist/chunks/{calendar-preferences-dialog-CUGzkNcE.js → calendar-preferences-dialog-Dn6o2r2Y.js} +1 -1
  5. package/dist/chunks/{dashboard-briefing-launcher-BEZnvIla.js → dashboard-briefing-launcher-BO-kXtEd.js} +1 -1
  6. package/dist/chunks/{dashboard-briefing-launcher-ptERmNJr.js → dashboard-briefing-launcher-D3Xfc_26.js} +3 -3
  7. package/dist/chunks/{dashboard-controls-CqKC5oEk.js → dashboard-controls-B3sdy_Zx.js} +3 -3
  8. package/dist/chunks/{dashboard-controls-CGt6_hMf.js → dashboard-controls-DcXMFgGR.js} +1 -1
  9. package/dist/chunks/{dashboard-json-6SgPm_QW.js → dashboard-json-BWfkEy48.js} +1 -1
  10. package/dist/chunks/{dashboard-json-CYSbOdmE.js → dashboard-json-CFURS_OR.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-w6hKbjlw.js → edit-dashboard-visual-BD2AJLiT.js} +1 -1
  12. package/dist/chunks/{edit-dashboard-visual-ByQx_M2i.js → edit-dashboard-visual-DjdhKiP2.js} +3 -3
  13. package/dist/chunks/{index-CPyEi9gS.js → index-C0Qnfr_7.js} +5 -4
  14. package/dist/chunks/{index-BtqYNH_S.js → index-DlLvzmJF.js} +2 -2
  15. package/dist/chunks/{resource-management-panel-Bf8-3eUf.js → resource-management-panel-DytUMSGA.js} +1 -1
  16. package/dist/chunks/{resource-management-panel-mJ84NxzC.js → resource-management-panel-YvIfaphX.js} +2 -2
  17. package/dist/chunks/{use-create-flow-overlay-state-BfoXDDrd.js → use-create-flow-overlay-state-BETXykC9.js} +2 -2
  18. package/dist/chunks/{use-create-flow-overlay-state-c6rCm36x.js → use-create-flow-overlay-state-CwIG1Ekp.js} +1 -1
  19. package/dist/chunks/{use-visual-utils-NN0e3fBP.js → use-visual-utils-Bk135OgA.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-C_c-aiqi.js → use-visual-utils-BzFjIykb.js} +1 -1
  21. package/dist/chunks/{validation-PPSpYtVf.js → validation-CQFpcSSP.js} +295 -192
  22. package/dist/chunks/validation-D4Zz6WPD.js +1 -0
  23. package/dist/chunks/{validators-DBNa-eb1.js → validators-CuKnUZFO.js} +717 -345
  24. package/dist/chunks/validators-DHee9kM2.js +1 -0
  25. package/dist/dashboard/index.cjs +1 -1
  26. package/dist/dashboard/index.js +1 -1
  27. package/dist/dashboard-authoring/index.cjs +1 -1
  28. package/dist/dashboard-authoring/index.js +1 -1
  29. package/dist/data-app-builder/index.cjs +1 -1
  30. package/dist/data-app-builder/index.js +1 -1
  31. package/dist/data-app-sdk/index.cjs +1 -1
  32. package/dist/data-app-sdk/index.js +56 -49
  33. package/dist/data-app-sdk-validation/index.cjs +1 -1
  34. package/dist/data-app-sdk-validation/index.js +5 -4
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.js +5 -5
  37. package/dist/surfboard/index.cjs +1 -1
  38. package/dist/surfboard/index.js +2 -2
  39. package/dist/types/analytics-protocol.d.ts +91 -0
  40. package/dist/types/dashboard-assistant.d.ts +60 -2
  41. package/dist/types/dashboard-authoring.d.ts +58 -2
  42. package/dist/types/dashboard.d.ts +67 -2
  43. package/dist/types/data-app-builder.d.ts +41 -0
  44. package/dist/types/data-app-sdk-validation.d.ts +50 -3
  45. package/dist/types/data-app-sdk.d.ts +53 -3
  46. package/dist/types/main.d.ts +59 -2
  47. package/dist/types/shared.d.ts +66 -2
  48. package/dist/types/surfboard.d.ts +67 -2
  49. package/dist/types/types.d.ts +67 -2
  50. package/package.json +1 -1
  51. package/dist/chunks/validation-DYL3ArlL.js +0 -1
  52. package/dist/chunks/validators-CgxWT8UX.js +0 -1
@@ -1,38 +1,40 @@
1
- import { n as P, v as T } from "./validators-DBNa-eb1.js";
2
- import { b, c as H, a as w } from "./source-identity-Dj3dryN9.js";
3
- function A(e) {
4
- var t;
5
- const r = O(e);
1
+ import { n as z, c as D } from "./validators-CuKnUZFO.js";
2
+ import { n as O } from "./catalog-field-grounding-DoEBOXQd.js";
3
+ import { b as M, c as j, a as q } from "./source-identity-Dj3dryN9.js";
4
+ function x(e) {
5
+ var t, i;
6
+ const r = Q(e);
6
7
  return {
7
8
  version: 1,
8
9
  kind: "metric",
9
10
  id: e.id,
10
11
  label: e.label,
11
- source: y(e),
12
+ source: p(e),
12
13
  metrics: r,
13
- primaryMetric: z(e, r),
14
+ primaryMetric: K(e, r),
14
15
  dateField: e.dateField ? a(e.dateField, "date") : void 0,
15
16
  timeGrain: e.timeGrain,
16
- dimensions: (t = e.dimensions) == null ? void 0 : t.map((i) => a(i, "dimension")),
17
- comparison: te(e.comparison),
17
+ dimensions: (t = e.dimensions) == null ? void 0 : t.map((o) => a(o, "dimension")),
18
+ comparison: se(e.comparison),
18
19
  orderBy: e.orderBy ? {
19
20
  field: a(e.orderBy.field),
20
21
  direction: e.orderBy.direction
21
22
  } : void 0,
22
- inputs: u(e.inputs),
23
- limit: e.limit
23
+ inputs: y(e.inputs),
24
+ limit: e.limit,
25
+ ...(i = e.derivedFields) != null && i.length ? { derivedFields: e.derivedFields } : {}
24
26
  };
25
27
  }
26
- function B(e) {
28
+ function E(e) {
27
29
  var t;
28
30
  return {
29
- ...A(e),
31
+ ...x(e),
30
32
  ...e.timeWindow ? { timeWindow: e.timeWindow } : {},
31
33
  ...(t = e.filters) != null && t.length ? { filters: e.filters } : {},
32
34
  ...e.analysis ? { analysis: e.analysis } : {}
33
35
  };
34
36
  }
35
- function Se(e) {
37
+ function Re(e) {
36
38
  return {
37
39
  ...e.chartTitle ? { chartTitle: e.chartTitle } : {},
38
40
  ...e.chartType ? { chartType: e.chartType } : {},
@@ -41,13 +43,13 @@ function Se(e) {
41
43
  ...e.calendarContext ? { calendarContext: e.calendarContext } : {}
42
44
  };
43
45
  }
44
- function z(e, r) {
46
+ function K(e, r) {
45
47
  if (!e.primaryMetric)
46
48
  return r[0] || { name: "", role: "measure" };
47
- const t = a(e.primaryMetric, "measure"), i = Q(t, r), o = i.length === 1 ? i[0] : void 0;
48
- return o ? M(t, o) : t;
49
+ const t = a(e.primaryMetric, "measure"), i = L(t, r), o = i.length === 1 ? i[0] : void 0;
50
+ return o ? F(t, o) : t;
49
51
  }
50
- function O(e) {
52
+ function Q(e) {
51
53
  const r = [];
52
54
  for (const t of e.metrics.map(
53
55
  (i) => a(i, "measure")
@@ -55,62 +57,62 @@ function O(e) {
55
57
  if (!t.name)
56
58
  continue;
57
59
  const i = r.findIndex(
58
- (o) => D(o, t)
60
+ (o) => N(o, t)
59
61
  );
60
62
  if (i === -1) {
61
63
  r.push(t);
62
64
  continue;
63
65
  }
64
- r[i] = M(
66
+ r[i] = F(
65
67
  r[i],
66
68
  t
67
69
  );
68
70
  }
69
71
  return r;
70
72
  }
71
- function D(e, r) {
72
- return b(e, r) && c(e) === c(r);
73
+ function N(e, r) {
74
+ return M(e, r) && h(e) === h(r);
73
75
  }
74
- function j(e, r) {
75
- return c(r) === c(e);
76
+ function V(e, r) {
77
+ return h(r) === h(e);
76
78
  }
77
- function K(e, r) {
78
- return r.name !== e.name || e.source && !b(r, e) ? !1 : j(e, r);
79
+ function W(e, r) {
80
+ return r.name !== e.name || e.source && !M(r, e) ? !1 : V(e, r);
79
81
  }
80
- function Q(e, r) {
82
+ function L(e, r) {
81
83
  const t = r.filter(
82
- (i) => K(e, i)
84
+ (i) => W(e, i)
83
85
  );
84
86
  return e.aggregate !== void 0, t;
85
87
  }
86
- function c(e) {
88
+ function h(e) {
87
89
  return (e.aggregate || "SUM").toUpperCase();
88
90
  }
89
- function M(e, r) {
91
+ function F(e, r) {
90
92
  if (e.aggregate && r.aggregate && e.aggregate !== r.aggregate)
91
93
  throw new Error(
92
94
  `Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${r.aggregate}.`
93
95
  );
94
96
  return {
95
- ...H(e, r),
97
+ ...j(e, r),
96
98
  aggregate: e.aggregate || r.aggregate
97
99
  };
98
100
  }
99
- function E(e) {
100
- var t;
101
+ function U(e) {
102
+ var t, i;
101
103
  if ("sort" in e)
102
104
  throw new Error(
103
105
  "semaphor.records supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet."
104
106
  );
105
- if (!re(e))
107
+ if (!ae(e))
106
108
  throw new Error("semaphor.records needs at least one field.");
107
- const r = N(e.fields);
109
+ const r = G(e.fields);
108
110
  return {
109
111
  version: 1,
110
112
  kind: "records",
111
113
  id: e.id,
112
114
  label: e.label,
113
- source: y(e),
115
+ source: p(e),
114
116
  fields: r,
115
117
  dateField: e.dateField ? a(e.dateField, "date") : void 0,
116
118
  timeGrain: e.timeGrain,
@@ -120,12 +122,13 @@ function E(e) {
120
122
  field: a(e.orderBy.field),
121
123
  direction: e.orderBy.direction
122
124
  } : void 0,
123
- inputs: u(e.inputs),
125
+ inputs: y(e.inputs),
124
126
  limit: e.limit,
125
- ...e.pagination ? { pagination: e.pagination } : {}
127
+ ...e.pagination ? { pagination: e.pagination } : {},
128
+ ...(i = e.derivedFields) != null && i.length ? { derivedFields: e.derivedFields } : {}
126
129
  };
127
130
  }
128
- function N(e) {
131
+ function G(e) {
129
132
  return e.map((r) => {
130
133
  const t = a(r);
131
134
  if (!t.role)
@@ -135,19 +138,21 @@ function N(e) {
135
138
  return t;
136
139
  });
137
140
  }
138
- function V(e) {
141
+ function J(e) {
142
+ var r;
139
143
  return {
140
144
  version: 1,
141
145
  kind: "inputOptions",
142
146
  id: e.id,
143
147
  label: e.label,
144
- source: y(e),
148
+ source: p(e),
145
149
  field: a(e.field, "dimension"),
146
150
  search: e.search,
147
- limit: e.limit
151
+ limit: e.limit,
152
+ ...(r = e.derivedFields) != null && r.length ? { derivedFields: e.derivedFields } : {}
148
153
  };
149
154
  }
150
- function L(e) {
155
+ function X(e) {
151
156
  var r;
152
157
  return {
153
158
  version: 1,
@@ -159,29 +164,29 @@ function L(e) {
159
164
  ...e.defaultParameters ? { defaultParameters: e.defaultParameters } : {},
160
165
  ...e.pythonCode ? { pythonCode: e.pythonCode } : {},
161
166
  ...(r = e.fields) != null && r.length ? { fields: e.fields.map((t) => a(t)) } : {},
162
- inputs: u(e.inputs),
167
+ inputs: y(e.inputs),
163
168
  limit: e.limit,
164
169
  ...e.pagination ? { pagination: e.pagination } : {},
165
170
  rationale: e.rationale
166
171
  };
167
172
  }
168
- function W(e) {
173
+ function Y(e) {
169
174
  var r, t;
170
175
  return {
171
176
  version: 1,
172
177
  kind: "matrix",
173
178
  id: e.id,
174
179
  label: e.label,
175
- source: y(e),
176
- rows: e.rows.map((i) => g(i, "dimension")),
180
+ source: p(e),
181
+ rows: e.rows.map((i) => k(i, "dimension")),
177
182
  ...e.columns ? {
178
183
  columns: e.columns.map(
179
- (i) => g(i, "dimension")
184
+ (i) => k(i, "dimension")
180
185
  )
181
186
  } : {},
182
- values: e.values.map(U),
187
+ values: e.values.map(Z),
183
188
  ...(r = e.filters) != null && r.length ? { filters: e.filters } : {},
184
- inputs: u(e.inputs),
189
+ inputs: y(e.inputs),
185
190
  ...e.totals ? { totals: e.totals } : {},
186
191
  ...(t = e.sort) != null && t.length ? { sort: e.sort } : {},
187
192
  ...e.expansion ? { expansion: e.expansion } : {},
@@ -189,16 +194,16 @@ function W(e) {
189
194
  ...e.displayLimits ? { displayLimits: e.displayLimits } : {}
190
195
  };
191
196
  }
192
- function g(e, r) {
193
- return G(e) ? {
197
+ function k(e, r) {
198
+ return ee(e) ? {
194
199
  ...e,
195
200
  field: a(e.field, r)
196
201
  } : {
197
202
  field: a(e, r)
198
203
  };
199
204
  }
200
- function U(e) {
201
- return J(e) ? {
205
+ function Z(e) {
206
+ return re(e) ? {
202
207
  ...e,
203
208
  field: a(e.field, "measure")
204
209
  } : {
@@ -206,13 +211,13 @@ function U(e) {
206
211
  aggregate: e.aggregate
207
212
  };
208
213
  }
209
- function G(e) {
214
+ function ee(e) {
210
215
  return "field" in e;
211
216
  }
212
- function J(e) {
217
+ function re(e) {
213
218
  return "field" in e;
214
219
  }
215
- function X(e) {
220
+ function te(e) {
216
221
  if ("toAnalyticsInput" in e) {
217
222
  const n = e.toAnalyticsInput();
218
223
  return {
@@ -224,7 +229,7 @@ function X(e) {
224
229
  };
225
230
  }
226
231
  if ("id" in e) {
227
- const n = x(e);
232
+ const n = C(e);
228
233
  return {
229
234
  inputId: n.inputId,
230
235
  kind: n.kind,
@@ -233,7 +238,7 @@ function X(e) {
233
238
  ...n.field ? { field: n.field } : {}
234
239
  };
235
240
  }
236
- const r = "kind" in e ? e.kind : void 0, t = "operator" in e ? $(e.operator, e.inputId) : void 0, i = "controlRole" in e ? e.controlRole : "role" in e ? e.role : void 0, o = Y(i) ? i : void 0;
241
+ const r = "kind" in e ? e.kind : void 0, t = "operator" in e ? R(e.operator, e.inputId) : void 0, i = "controlRole" in e ? e.controlRole : "role" in e ? e.role : void 0, o = ie(i) ? i : void 0;
237
242
  return {
238
243
  inputId: e.inputId,
239
244
  ...r ? { kind: r } : {},
@@ -242,22 +247,22 @@ function X(e) {
242
247
  ...e.field ? { field: e.field } : {}
243
248
  };
244
249
  }
245
- function Y(e) {
250
+ function ie(e) {
246
251
  return e === "grain" || e === "metric" || e === "dimension" || e === "aggregation" || e === "sqlParam";
247
252
  }
248
- function be(e) {
249
- const r = u(e);
253
+ function He(e) {
254
+ const r = y(e);
250
255
  return r.length > 0 ? r : void 0;
251
256
  }
252
- function Z(e) {
253
- return (e || []).map(ee);
257
+ function oe(e) {
258
+ return (e || []).map(ne);
254
259
  }
255
- function we(e) {
256
- return Z(e).filter((r) => r.isActive);
260
+ function Te(e) {
261
+ return oe(e).filter((r) => r.isActive);
257
262
  }
258
- function x(e) {
263
+ function C(e) {
259
264
  if (e.kind === "filter") {
260
- const r = $(e.operator, e.id);
265
+ const r = R(e.operator, e.id);
261
266
  return {
262
267
  inputId: e.id,
263
268
  kind: e.kind,
@@ -273,7 +278,7 @@ function x(e) {
273
278
  controlRole: e.role
274
279
  };
275
280
  }
276
- function Ae(e = []) {
281
+ function Pe(e = []) {
277
282
  return e.map(
278
283
  (r) => typeof r == "object" ? r : {
279
284
  label: String(r),
@@ -281,16 +286,16 @@ function Ae(e = []) {
281
286
  }
282
287
  );
283
288
  }
284
- function v(e) {
289
+ function S(e) {
285
290
  return e == null ? !1 : Array.isArray(e) ? e.length > 0 : typeof e == "string" ? e.trim().length > 0 : !0;
286
291
  }
287
- function ee(e) {
292
+ function ne(e) {
288
293
  if ("toAnalyticsInput" in e)
289
294
  return e.toAnalyticsInput();
290
295
  if ("kind" in e && "isActive" in e)
291
296
  return e;
292
297
  if ("id" in e) {
293
- const r = x(e), t = Object.prototype.hasOwnProperty.call(e, "value") ? e.value : e.defaultValue;
298
+ const r = C(e), t = Object.prototype.hasOwnProperty.call(e, "value") ? e.value : e.defaultValue;
294
299
  return {
295
300
  inputId: r.inputId,
296
301
  kind: r.kind,
@@ -299,22 +304,22 @@ function ee(e) {
299
304
  ...r.operator ? { operator: r.operator } : {},
300
305
  ...r.controlRole ? { controlRole: r.controlRole } : {},
301
306
  value: t,
302
- isActive: v(t)
307
+ isActive: S(t)
303
308
  };
304
309
  }
305
310
  return {
306
311
  ...e,
307
312
  kind: "filter",
308
- isActive: v(
313
+ isActive: S(
309
314
  e.value
310
315
  ),
311
316
  value: e.value
312
317
  };
313
318
  }
314
- function y(e) {
319
+ function p(e) {
315
320
  return e.source;
316
321
  }
317
- function re(e) {
322
+ function ae(e) {
318
323
  var r;
319
324
  return !!((r = e.fields) != null && r.length);
320
325
  }
@@ -324,36 +329,36 @@ function a(e, r) {
324
329
  role: e.role || r
325
330
  };
326
331
  }
327
- function u(e) {
328
- return (e || []).map(X);
332
+ function y(e) {
333
+ return (e || []).map(te);
329
334
  }
330
- function te(e) {
335
+ function se(e) {
331
336
  if (e)
332
337
  return e;
333
338
  }
334
- function $(e, r) {
339
+ function R(e, r) {
335
340
  if (e === void 0)
336
341
  return;
337
- const t = P(e);
342
+ const t = z(e);
338
343
  if (!t)
339
344
  throw new Error(
340
345
  `useSemaphorInput "${r}" uses unsupported filter operator "${e}".`
341
346
  );
342
347
  return t;
343
348
  }
344
- function ie(e, r = {}) {
349
+ function de(e, r = {}) {
345
350
  const t = r.pathPrefix || "analysisOptions";
346
351
  if (e === void 0)
347
352
  return { ok: !0 };
348
353
  if (!e || typeof e != "object" || Array.isArray(e))
349
- return s(
354
+ return u(
350
355
  t,
351
356
  "Data App analysis options must be an object."
352
357
  );
353
358
  const i = e, o = {};
354
359
  if (i.chartTitle !== void 0) {
355
360
  if (typeof i.chartTitle != "string")
356
- return s(
361
+ return u(
357
362
  `${t}.chartTitle`,
358
363
  'Data App analysis option "chartTitle" must be a string.'
359
364
  );
@@ -361,15 +366,15 @@ function ie(e, r = {}) {
361
366
  }
362
367
  if (i.chartType !== void 0) {
363
368
  if (typeof i.chartType != "string")
364
- return s(
369
+ return u(
365
370
  `${t}.chartType`,
366
371
  'Data App analysis option "chartType" must be a string.'
367
372
  );
368
373
  o.chartType = i.chartType;
369
374
  }
370
375
  if (i.driverMode !== void 0) {
371
- if (!ne(i.driverMode))
372
- return s(
376
+ if (!ue(i.driverMode))
377
+ return u(
373
378
  `${t}.driverMode`,
374
379
  'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.'
375
380
  );
@@ -377,14 +382,14 @@ function ie(e, r = {}) {
377
382
  }
378
383
  if (i.includePopulation !== void 0) {
379
384
  if (typeof i.includePopulation != "boolean")
380
- return s(
385
+ return u(
381
386
  `${t}.includePopulation`,
382
387
  'Data App analysis option "includePopulation" must be a boolean.'
383
388
  );
384
389
  o.includePopulation = i.includePopulation;
385
390
  }
386
391
  if (i.calendarContext !== void 0) {
387
- const n = se(
392
+ const n = ce(
388
393
  i.calendarContext,
389
394
  {
390
395
  pathPrefix: `${t}.calendarContext`,
@@ -397,9 +402,9 @@ function ie(e, r = {}) {
397
402
  }
398
403
  return { ok: !0, analysisOptions: o };
399
404
  }
400
- function Me(e) {
405
+ function Be(e) {
401
406
  const r = e.queries.map(
402
- (o, n) => oe(o, n, {
407
+ (o, n) => le(o, n, {
403
408
  fieldCatalogs: e.fieldCatalogs || [],
404
409
  requireFieldCatalog: !!e.requireFieldCatalog,
405
410
  validateTimezone: e.validateTimezone
@@ -415,18 +420,18 @@ function Me(e) {
415
420
  executionResults: i
416
421
  };
417
422
  }
418
- function oe(e, r, t) {
423
+ function le(e, r, t) {
419
424
  const i = `queries.${r}`;
420
425
  try {
421
- const o = de(e), n = qe(e, o), d = T(o), l = [
422
- ...ye({
426
+ const o = me(e), n = Me(e, o), s = D(o), d = [
427
+ ...Ie({
423
428
  querySpec: e,
424
429
  queryId: n,
425
430
  intent: o,
426
431
  pathPrefix: i
427
432
  }),
428
- ...d.errors.map(
429
- (p) => q(p, {
433
+ ...s.errors.map(
434
+ (c) => $(c, {
430
435
  queryHook: e.queryHook,
431
436
  queryId: n,
432
437
  pathPrefix: i,
@@ -434,8 +439,8 @@ function oe(e, r, t) {
434
439
  intent: o
435
440
  })
436
441
  ),
437
- ...d.warnings.map(
438
- (p) => q(p, {
442
+ ...s.warnings.map(
443
+ (c) => $(c, {
439
444
  queryHook: e.queryHook,
440
445
  queryId: n,
441
446
  pathPrefix: i,
@@ -443,7 +448,7 @@ function oe(e, r, t) {
443
448
  intent: o
444
449
  })
445
450
  ),
446
- ...ue({
451
+ ...he({
447
452
  querySpec: e,
448
453
  queryId: n,
449
454
  intent: o,
@@ -451,23 +456,23 @@ function oe(e, r, t) {
451
456
  fieldCatalogs: t.fieldCatalogs,
452
457
  requireFieldCatalog: t.requireFieldCatalog
453
458
  }),
454
- ...me({
459
+ ...qe({
455
460
  querySpec: e,
456
461
  queryId: n,
457
462
  intent: o,
458
463
  pathPrefix: i,
459
464
  validateTimezone: t.validateTimezone
460
465
  })
461
- ], f = ve(d, l);
466
+ ], l = _e(s, d);
462
467
  return {
463
468
  queryHook: e.queryHook,
464
469
  queryId: n,
465
470
  intent: o,
466
- diagnostics: l,
467
- executionResult: S({
471
+ diagnostics: d,
472
+ executionResult: _({
468
473
  intent: o,
469
- validation: f,
470
- diagnostics: l
474
+ validation: l,
475
+ diagnostics: d
471
476
  })
472
477
  };
473
478
  } catch (o) {
@@ -477,20 +482,20 @@ function oe(e, r, t) {
477
482
  message: o instanceof Error ? o.message : String(o),
478
483
  path: i,
479
484
  queryHook: e.queryHook,
480
- queryId: F(e.spec)
481
- }, d = R([n]);
485
+ queryId: B(e.spec)
486
+ }, s = P([n]);
482
487
  return {
483
488
  queryHook: e.queryHook,
484
489
  queryId: n.queryId,
485
490
  diagnostics: [n],
486
- executionResult: S({
487
- validation: d,
491
+ executionResult: _({
492
+ validation: s,
488
493
  diagnostics: [n]
489
494
  })
490
495
  };
491
496
  }
492
497
  }
493
- function s(e, r) {
498
+ function u(e, r) {
494
499
  return {
495
500
  ok: !1,
496
501
  issues: [
@@ -502,96 +507,169 @@ function s(e, r) {
502
507
  ]
503
508
  };
504
509
  }
505
- function _(e) {
510
+ function H(e) {
506
511
  return !!(e && typeof e == "object" && !Array.isArray(e));
507
512
  }
508
- function ne(e) {
513
+ function ue(e) {
509
514
  return e === "absolute_delta" || e === "largest_negative" || e === "largest_positive" || e === "positive_and_negative" || e === "all";
510
515
  }
511
- function ae(e) {
516
+ function fe(e) {
512
517
  return e.trim().length > 0 && !Number.isNaN(Date.parse(e));
513
518
  }
514
- function se(e, r) {
515
- var f;
519
+ function ce(e, r) {
520
+ var l;
516
521
  if (!e || typeof e != "object" || Array.isArray(e))
517
- return s(
522
+ return u(
518
523
  r.pathPrefix,
519
524
  'Data App analysis option "calendarContext" must be an object.'
520
525
  );
521
- const t = e, i = t.tz, o = t.weekStart, n = t.anchor, d = n && typeof n == "object" && !Array.isArray(n) ? n.iso : void 0, l = typeof i == "string" ? ((f = r.validateTimezone) == null ? void 0 : f.call(r, i)) ?? i : null;
522
- return l ? typeof o != "number" || !Number.isInteger(o) || o < 0 || o > 6 ? s(
526
+ const t = e, i = t.tz, o = t.weekStart, n = t.anchor, s = n && typeof n == "object" && !Array.isArray(n) ? n.iso : void 0, d = typeof i == "string" ? ((l = r.validateTimezone) == null ? void 0 : l.call(r, i)) ?? i : null;
527
+ return d ? typeof o != "number" || !Number.isInteger(o) || o < 0 || o > 6 ? u(
523
528
  `${r.pathPrefix}.weekStart`,
524
529
  'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'
525
- ) : n !== "now" && !(typeof d == "string" && ae(d)) ? s(
530
+ ) : n !== "now" && !(typeof s == "string" && fe(s)) ? u(
526
531
  `${r.pathPrefix}.anchor`,
527
532
  'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'
528
533
  ) : {
529
534
  ok: !0,
530
535
  calendarContext: {
531
- tz: l,
536
+ tz: d,
532
537
  weekStart: o,
533
538
  anchor: n
534
539
  }
535
- } : s(
540
+ } : u(
536
541
  `${r.pathPrefix}.tz`,
537
542
  'Data App analysis option "calendarContext.tz" must be a valid timezone string.'
538
543
  );
539
544
  }
540
- function de(e) {
541
- return le(e.spec);
545
+ function me(e) {
546
+ return ye(e.spec);
542
547
  }
543
- function le(e) {
544
- if (!_(e))
548
+ function ye(e) {
549
+ if (!H(e))
545
550
  throw new Error("useSemaphorQuery spec must be an object.");
546
551
  if (e.queryKind === "metric")
547
- return A(e);
552
+ return x(e);
548
553
  if (e.queryKind === "analysis")
549
- return B(e);
550
- if (e.queryKind === "records")
551
554
  return E(e);
555
+ if (e.queryKind === "records")
556
+ return U(e);
552
557
  if (e.queryKind === "sql")
553
- return L(e);
558
+ return X(e);
554
559
  if (e.queryKind === "matrix")
555
- return W(e);
560
+ return Y(e);
556
561
  if (e.queryKind === "inputOptions")
557
- return V(e);
562
+ return J(e);
558
563
  throw new Error(
559
564
  "useSemaphorQuery spec.queryKind must be metric, analysis, records, inputOptions, sql, or matrix."
560
565
  );
561
566
  }
562
- function ue(e) {
567
+ function he(e) {
563
568
  if (e.intent.kind === "sql")
564
569
  return [];
565
570
  if (e.fieldCatalogs.length === 0 && !e.requireFieldCatalog)
566
571
  return [];
567
- const r = he(
572
+ const r = Se(
568
573
  e.fieldCatalogs,
569
574
  e.intent.source
570
575
  );
571
- return r ? [
572
- ...fe({
576
+ if (!r)
577
+ return [
578
+ {
579
+ severity: "error",
580
+ code: "invalid_source_ref",
581
+ message: `Source ref for ${e.querySpec.queryHook} does not match a visible Semaphor source.`,
582
+ path: `${e.pathPrefix}.spec.source`,
583
+ queryHook: e.querySpec.queryHook,
584
+ queryId: e.queryId,
585
+ intentId: e.intent.id,
586
+ source: e.intent.source
587
+ }
588
+ ];
589
+ const t = pe({
590
+ ...e,
591
+ catalog: r
592
+ }), i = {
593
+ ...r,
594
+ fields: [
595
+ ...r.fields,
596
+ ...be(e.intent, r, e.intent.source)
597
+ ]
598
+ };
599
+ return [
600
+ ...t,
601
+ ...ge({
573
602
  ...e,
574
- catalog: r
603
+ catalog: i
575
604
  }),
576
- ...ce({
605
+ ...ve({
577
606
  ...e,
578
- catalog: r
607
+ catalog: i
579
608
  })
580
- ] : [
581
- {
609
+ ];
610
+ }
611
+ function pe(e) {
612
+ const r = T(e.intent);
613
+ if (r.length === 0)
614
+ return [];
615
+ const t = [], i = /* @__PURE__ */ new Set();
616
+ return r.forEach((o, n) => {
617
+ const s = `${e.pathPrefix}.spec.derivedFields.${n}`, d = b(o.name);
618
+ d && (i.has(d) && t.push({
582
619
  severity: "error",
583
- code: "invalid_source_ref",
584
- message: `Source ref for ${e.querySpec.queryHook} does not match a visible Semaphor source.`,
585
- path: `${e.pathPrefix}.spec.source`,
620
+ code: "duplicate_derived_field",
621
+ message: `Derived field "${o.name}" is declared more than once.`,
622
+ path: `${s}.name`,
586
623
  queryHook: e.querySpec.queryHook,
587
624
  queryId: e.queryId,
588
625
  intentId: e.intent.id,
589
626
  source: e.intent.source
590
- }
591
- ];
592
- }
593
- function fe(e) {
594
- return pe(e.intent).flatMap(({ field: r, path: t }) => C(e.catalog, r, e.intent.source) ? [] : [
627
+ }), i.add(d), e.catalog.fields.some(
628
+ (l) => b(l.name) === d
629
+ ) && t.push({
630
+ severity: "error",
631
+ code: "derived_field_name_collision",
632
+ message: `Derived field "${o.name}" conflicts with a field already visible on the selected Semaphor source.`,
633
+ path: `${s}.name`,
634
+ queryHook: e.querySpec.queryHook,
635
+ queryId: e.queryId,
636
+ intentId: e.intent.id,
637
+ source: e.intent.source
638
+ })), Object.entries(o.inputs || {}).forEach(([l, c]) => {
639
+ const f = we(c);
640
+ if (!f)
641
+ return;
642
+ const g = m(f, e.intent.source);
643
+ if (!q(g, e.intent.source)) {
644
+ t.push({
645
+ severity: "error",
646
+ code: "unsupported_derived_field_source",
647
+ message: `Derived field "${o.name}" input "${l}" references a different Semaphor source. App-local derived fields must use fields from the query source.`,
648
+ path: `${s}.inputs.${l}`,
649
+ queryHook: e.querySpec.queryHook,
650
+ queryId: e.queryId,
651
+ intentId: e.intent.id,
652
+ source: g,
653
+ field: f
654
+ });
655
+ return;
656
+ }
657
+ I(e.catalog, f, e.intent.source) || t.push({
658
+ severity: "error",
659
+ code: "missing_field",
660
+ message: `Derived field "${o.name}" input "${l}" references field "${f.name}", which is not visible on the selected Semaphor source.`,
661
+ path: `${s}.inputs.${l}`,
662
+ queryHook: e.querySpec.queryHook,
663
+ queryId: e.queryId,
664
+ intentId: e.intent.id,
665
+ source: g,
666
+ field: f
667
+ });
668
+ });
669
+ }), t;
670
+ }
671
+ function ge(e) {
672
+ return ke(e.intent).flatMap(({ field: r, path: t }) => I(e.catalog, r, e.intent.source) ? [] : [
595
673
  {
596
674
  severity: "error",
597
675
  code: "missing_field",
@@ -605,12 +683,12 @@ function fe(e) {
605
683
  }
606
684
  ]);
607
685
  }
608
- function ce(e) {
686
+ function ve(e) {
609
687
  return ("inputs" in e.intent ? e.intent.inputs || [] : []).flatMap((t, i) => {
610
688
  if (!t.field)
611
689
  return [];
612
690
  const o = m(t.field, e.intent.source);
613
- return w(o, e.intent.source) ? C(e.catalog, t.field, e.intent.source) ? [] : [
691
+ return q(o, e.intent.source) ? I(e.catalog, t.field, e.intent.source) ? [] : [
614
692
  {
615
693
  severity: "error",
616
694
  code: "missing_field",
@@ -637,10 +715,10 @@ function ce(e) {
637
715
  ];
638
716
  });
639
717
  }
640
- function me(e) {
718
+ function qe(e) {
641
719
  if (e.querySpec.spec.queryKind !== "analysis")
642
720
  return [];
643
- const r = ie(
721
+ const r = de(
644
722
  e.querySpec.spec,
645
723
  {
646
724
  pathPrefix: `${e.pathPrefix}.spec`,
@@ -658,8 +736,8 @@ function me(e) {
658
736
  source: e.intent.source
659
737
  }));
660
738
  }
661
- function ye(e) {
662
- return e.querySpec.spec.queryKind !== "sql" ? [] : _(e.querySpec.spec) ? Object.prototype.hasOwnProperty.call(e.querySpec.spec, "parameters") ? [
739
+ function Ie(e) {
740
+ return e.querySpec.spec.queryKind !== "sql" ? [] : H(e.querySpec.spec) ? Object.prototype.hasOwnProperty.call(e.querySpec.spec, "parameters") ? [
663
741
  {
664
742
  severity: "error",
665
743
  code: "deprecated_sql_parameters",
@@ -671,7 +749,7 @@ function ye(e) {
671
749
  }
672
750
  ] : [] : [];
673
751
  }
674
- function pe(e) {
752
+ function ke(e) {
675
753
  return e.kind === "metric" ? [
676
754
  ...e.metrics.map((r, t) => ({
677
755
  field: r,
@@ -748,31 +826,56 @@ function pe(e) {
748
826
  }))
749
827
  ] : [];
750
828
  }
751
- function he(e, r) {
752
- return e.find((t) => h(t, r));
829
+ function Se(e, r) {
830
+ return e.find((t) => v(t, r));
753
831
  }
754
- function C(e, r, t) {
832
+ function I(e, r, t) {
755
833
  const i = m(r, t);
756
- if (h(e, i))
834
+ if (v(e, i))
757
835
  return e.fields.find(
758
- (o) => ge(o, r) && h(
836
+ (o) => Ae(o, r) && v(
759
837
  e,
760
838
  m(o, e.source)
761
839
  )
762
840
  );
763
841
  }
764
- function h(e, r) {
842
+ function T(e) {
843
+ return !("derivedFields" in e) || !Array.isArray(e.derivedFields) ? [] : e.derivedFields;
844
+ }
845
+ function be(e, r, t) {
846
+ return T(e).map((i) => ({
847
+ name: i.name,
848
+ label: i.label,
849
+ role: $e(i.resultRole),
850
+ dataType: i.dataType,
851
+ source: r.source || t,
852
+ ...i.defaultAggregate ? { aggregate: i.defaultAggregate } : {}
853
+ }));
854
+ }
855
+ function $e(e) {
856
+ return e === "measure" ? "measure" : e === "date" ? "date" : e === "id" ? "id" : "dimension";
857
+ }
858
+ function we(e) {
859
+ if (!e || typeof e != "object")
860
+ return;
861
+ const r = e;
862
+ return r.field || r.metric || r.dimension;
863
+ }
864
+ function b(e) {
865
+ return O(e);
866
+ }
867
+ function v(e, r) {
765
868
  return [e.source, ...e.sourceAliases || []].some(
766
- (t) => w(t, r)
869
+ (t) => q(t, r)
767
870
  );
768
871
  }
769
872
  function m(e, r) {
770
873
  return e.source || r;
771
874
  }
772
- function ge(e, r) {
875
+ function Ae(e, r) {
773
876
  return !!(e.name && r.name && e.name === r.name);
774
877
  }
775
- function q(e, r) {
878
+ function $(e, r) {
776
879
  return {
777
880
  severity: r.severity,
778
881
  code: e.code || "invalid_analytics_intent",
@@ -784,15 +887,15 @@ function q(e, r) {
784
887
  source: r.intent.source
785
888
  };
786
889
  }
787
- function ve(e, r) {
788
- const t = R(r);
890
+ function _e(e, r) {
891
+ const t = P(r);
789
892
  return {
790
893
  ok: t.ok && e.ok,
791
- errors: k([
894
+ errors: A([
792
895
  ...e.errors,
793
896
  ...t.errors
794
897
  ]),
795
- warnings: k([
898
+ warnings: A([
796
899
  ...e.warnings,
797
900
  ...t.warnings
798
901
  ]),
@@ -802,8 +905,8 @@ function ve(e, r) {
802
905
  ]
803
906
  };
804
907
  }
805
- function R(e) {
806
- const r = e.filter((i) => i.severity === "error").map(I), t = e.filter((i) => i.severity === "warning").map(I);
908
+ function P(e) {
909
+ const r = e.filter((i) => i.severity === "error").map(w), t = e.filter((i) => i.severity === "warning").map(w);
807
910
  return {
808
911
  ok: r.length === 0,
809
912
  errors: r,
@@ -820,7 +923,7 @@ function R(e) {
820
923
  })
821
924
  };
822
925
  }
823
- function I(e) {
926
+ function w(e) {
824
927
  var r;
825
928
  return {
826
929
  code: e.code,
@@ -836,14 +939,14 @@ function I(e) {
836
939
  }
837
940
  };
838
941
  }
839
- function k(e) {
942
+ function A(e) {
840
943
  const r = /* @__PURE__ */ new Set();
841
944
  return e.filter((t) => {
842
945
  const i = `${t.code}:${t.path || ""}:${t.message}`;
843
946
  return r.has(i) ? !1 : (r.add(i), !0);
844
947
  });
845
948
  }
846
- function S(e) {
949
+ function _(e) {
847
950
  var t, i;
848
951
  const r = e.diagnostics.filter(
849
952
  (o) => o.severity === "error"
@@ -871,30 +974,30 @@ function S(e) {
871
974
  }
872
975
  };
873
976
  }
874
- function qe(e, r) {
875
- return r.id || F(e.spec);
977
+ function Me(e, r) {
978
+ return r.id || B(e.spec);
876
979
  }
877
- function F(e) {
980
+ function B(e) {
878
981
  if (!e || typeof e != "object" || !("id" in e))
879
982
  return;
880
983
  const r = e.id;
881
984
  return typeof r == "string" && r.trim() ? r : void 0;
882
985
  }
883
986
  export {
884
- W as a,
885
- L as b,
886
- V as c,
887
- E as d,
888
- Se as e,
889
- B as f,
890
- A as g,
891
- x as h,
892
- v as i,
893
- X as j,
894
- be as k,
895
- Z as l,
896
- ie as m,
897
- Ae as n,
898
- we as t,
899
- Me as v
987
+ Y as a,
988
+ X as b,
989
+ J as c,
990
+ U as d,
991
+ Re as e,
992
+ E as f,
993
+ x as g,
994
+ C as h,
995
+ S as i,
996
+ te as j,
997
+ He as k,
998
+ oe as l,
999
+ de as m,
1000
+ Pe as n,
1001
+ Te as t,
1002
+ Be as v
900
1003
  };