react-semaphor 0.1.368 → 0.1.369

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 (64) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +1 -1
  3. package/dist/brand-studio/index.cjs +5 -5
  4. package/dist/brand-studio/index.js +24 -23
  5. package/dist/chunks/{braces-Cc86y9Ov.js → braces-C3-w6xDL.js} +1 -1
  6. package/dist/chunks/{braces-CXvY9MwQ.js → braces-C8QqW4wu.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog-BOFlzOJg.js → calendar-preferences-dialog-6q51A6XC.js} +3 -3
  8. package/dist/chunks/{calendar-preferences-dialog-ZzwfJv2J.js → calendar-preferences-dialog-CUGzkNcE.js} +1 -1
  9. package/dist/chunks/{chevrons-up-down-CUZL1zaU.js → chevrons-up-down-CnCSGY02.js} +1 -1
  10. package/dist/chunks/{chevrons-up-down-qQMadOWA.js → chevrons-up-down-DSvLu4Ye.js} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-9-PCYMjR.js → dashboard-briefing-launcher-BEZnvIla.js} +1 -1
  12. package/dist/chunks/{dashboard-briefing-launcher-D2lBFqAd.js → dashboard-briefing-launcher-ptERmNJr.js} +176 -177
  13. package/dist/chunks/{dashboard-controls-D4bUHAjX.js → dashboard-controls-CGt6_hMf.js} +11 -11
  14. package/dist/chunks/{dashboard-controls-BIk094Ah.js → dashboard-controls-CqKC5oEk.js} +77 -77
  15. package/dist/chunks/{dashboard-json-DImOf512.js → dashboard-json-6SgPm_QW.js} +13 -14
  16. package/dist/chunks/dashboard-json-CYSbOdmE.js +1 -0
  17. package/dist/chunks/{edit-dashboard-visual-DTxkV6Fl.js → edit-dashboard-visual-ByQx_M2i.js} +8 -9
  18. package/dist/chunks/{edit-dashboard-visual-BHKlcqQR.js → edit-dashboard-visual-w6hKbjlw.js} +1 -1
  19. package/dist/chunks/index-BtqYNH_S.js +1361 -0
  20. package/dist/chunks/{index-BVEIk-rB.js → index-CPyEi9gS.js} +72498 -76193
  21. package/dist/chunks/{palette-DPuAc82h.js → palette-D-f4-82S.js} +1 -1
  22. package/dist/chunks/{palette-C1k347Tb.js → palette-DUGktM-M.js} +1 -1
  23. package/dist/chunks/{resource-management-panel-BeHceP2D.js → resource-management-panel-Bf8-3eUf.js} +1 -1
  24. package/dist/chunks/{resource-management-panel-BOfbSf48.js → resource-management-panel-mJ84NxzC.js} +152 -152
  25. package/dist/chunks/save-D3YYinDz.js +6 -0
  26. package/dist/chunks/save-kkBEBeLg.js +21 -0
  27. package/dist/chunks/{switch-xcWLtWs0.js → switch-Dkx2qEOr.js} +758 -776
  28. package/dist/chunks/{switch-C0S63HAv.js → switch-fIkmwzUt.js} +27 -32
  29. package/dist/chunks/{use-create-flow-overlay-state-B5FygfQL.js → use-create-flow-overlay-state-BfoXDDrd.js} +190 -189
  30. package/dist/chunks/use-create-flow-overlay-state-c6rCm36x.js +26 -0
  31. package/dist/chunks/{use-visual-utils-DxDE8S8M.js → use-visual-utils-C_c-aiqi.js} +1 -1
  32. package/dist/chunks/{use-visual-utils-CszWnFBW.js → use-visual-utils-NN0e3fBP.js} +13 -13
  33. package/dist/chunks/validation-Dsf7PydY.js +1 -0
  34. package/dist/chunks/validation-nOPr0mTk.js +803 -0
  35. package/dist/chunks/{validators-L0xEXtjf.js → validators-CVuWOHYv.js} +225 -158
  36. package/dist/chunks/validators-oc8qtP4q.js +1 -0
  37. package/dist/dashboard/index.cjs +1 -1
  38. package/dist/dashboard/index.js +1 -1
  39. package/dist/dashboard-authoring/index.cjs +1 -1
  40. package/dist/dashboard-authoring/index.js +1 -1
  41. package/dist/data-app-builder/index.cjs +51 -1
  42. package/dist/data-app-builder/index.js +3666 -2
  43. package/dist/data-app-sdk/index.cjs +1 -1
  44. package/dist/data-app-sdk/index.js +589 -388
  45. package/dist/data-app-sdk-validation/index.cjs +1 -1
  46. package/dist/data-app-sdk-validation/index.js +4 -4
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.js +14 -14
  49. package/dist/surfboard/index.cjs +1 -1
  50. package/dist/surfboard/index.js +2 -2
  51. package/dist/types/analytics-protocol.d.ts +21 -1
  52. package/dist/types/dashboard-assistant.d.ts +21 -1
  53. package/dist/types/dashboard-authoring.d.ts +11 -1
  54. package/dist/types/data-app-builder.d.ts +11 -1
  55. package/dist/types/data-app-sdk-validation.d.ts +107 -23
  56. package/dist/types/data-app-sdk.d.ts +168 -35
  57. package/dist/types/main.d.ts +11 -1
  58. package/package.json +1 -1
  59. package/dist/chunks/dashboard-json-Bo1kX6W1.js +0 -1
  60. package/dist/chunks/index-HjDeEytV.js +0 -1411
  61. package/dist/chunks/use-create-flow-overlay-state-DOXTbTcQ.js +0 -26
  62. package/dist/chunks/validation-CrUjNWby.js +0 -689
  63. package/dist/chunks/validation-DGl8wnTt.js +0 -1
  64. package/dist/chunks/validators-Dq5X4mp0.js +0 -1
@@ -0,0 +1,803 @@
1
+ import { n as T, v as x } from "./validators-CVuWOHYv.js";
2
+ import { b as S, c as H, a as b } from "./source-identity-Dj3dryN9.js";
3
+ function w(e) {
4
+ var t;
5
+ const r = B(e);
6
+ return {
7
+ version: 1,
8
+ kind: "metric",
9
+ id: e.id,
10
+ label: e.label,
11
+ source: h(e),
12
+ metrics: r,
13
+ primaryMetric: z(e, r),
14
+ dateField: e.dateField ? a(e.dateField, "date") : void 0,
15
+ timeGrain: e.timeGrain,
16
+ dimensions: (t = e.dimensions) == null ? void 0 : t.map((o) => a(o, "dimension")),
17
+ comparison: X(e.comparison),
18
+ orderBy: e.orderBy ? {
19
+ field: a(e.orderBy.field),
20
+ direction: e.orderBy.direction
21
+ } : void 0,
22
+ inputs: m(e.inputs),
23
+ limit: e.limit
24
+ };
25
+ }
26
+ function F(e) {
27
+ var t;
28
+ return {
29
+ ...w(e),
30
+ ...e.timeWindow ? { timeWindow: e.timeWindow } : {},
31
+ ...(t = e.filters) != null && t.length ? { filters: e.filters } : {},
32
+ ...e.analysis ? { analysis: e.analysis } : {}
33
+ };
34
+ }
35
+ function ge(e) {
36
+ return {
37
+ ...e.chartTitle ? { chartTitle: e.chartTitle } : {},
38
+ ...e.chartType ? { chartType: e.chartType } : {},
39
+ ...e.driverMode ? { driverMode: e.driverMode } : {},
40
+ ...e.includePopulation !== void 0 ? { includePopulation: e.includePopulation } : {},
41
+ ...e.calendarContext ? { calendarContext: e.calendarContext } : {}
42
+ };
43
+ }
44
+ function z(e, r) {
45
+ if (!e.primaryMetric)
46
+ return r[0] || { name: "", role: "measure" };
47
+ const t = a(e.primaryMetric, "measure"), o = K(t, r), i = o.length === 1 ? o[0] : void 0;
48
+ return i ? A(t, i) : t;
49
+ }
50
+ function B(e) {
51
+ const r = [];
52
+ for (const t of e.metrics.map(
53
+ (o) => a(o, "measure")
54
+ )) {
55
+ if (!t.name)
56
+ continue;
57
+ const o = r.findIndex(
58
+ (i) => O(i, t)
59
+ );
60
+ if (o === -1) {
61
+ r.push(t);
62
+ continue;
63
+ }
64
+ r[o] = A(
65
+ r[o],
66
+ t
67
+ );
68
+ }
69
+ return r;
70
+ }
71
+ function O(e, r) {
72
+ return S(e, r) && f(e) === f(r);
73
+ }
74
+ function D(e, r) {
75
+ return f(r) === f(e);
76
+ }
77
+ function j(e, r) {
78
+ return r.name !== e.name || e.source && !S(r, e) ? !1 : D(e, r);
79
+ }
80
+ function K(e, r) {
81
+ const t = r.filter(
82
+ (o) => j(e, o)
83
+ );
84
+ return e.aggregate !== void 0, t;
85
+ }
86
+ function f(e) {
87
+ return (e.aggregate || "SUM").toUpperCase();
88
+ }
89
+ function A(e, r) {
90
+ if (e.aggregate && r.aggregate && e.aggregate !== r.aggregate)
91
+ throw new Error(
92
+ `Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${r.aggregate}.`
93
+ );
94
+ return {
95
+ ...H(e, r),
96
+ aggregate: e.aggregate || r.aggregate
97
+ };
98
+ }
99
+ function Q(e) {
100
+ var t;
101
+ if ("sort" in e)
102
+ throw new Error(
103
+ "semaphor.records supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet."
104
+ );
105
+ if (!J(e))
106
+ throw new Error("semaphor.records needs at least one field.");
107
+ const r = E(e.fields);
108
+ return {
109
+ version: 1,
110
+ kind: "records",
111
+ id: e.id,
112
+ label: e.label,
113
+ source: h(e),
114
+ fields: r,
115
+ dateField: e.dateField ? a(e.dateField, "date") : void 0,
116
+ timeGrain: e.timeGrain,
117
+ ...e.timeWindow ? { timeWindow: e.timeWindow } : {},
118
+ ...(t = e.filters) != null && t.length ? { filters: e.filters } : {},
119
+ orderBy: e.orderBy ? {
120
+ field: a(e.orderBy.field),
121
+ direction: e.orderBy.direction
122
+ } : void 0,
123
+ inputs: m(e.inputs),
124
+ limit: e.limit,
125
+ ...e.pagination ? { pagination: e.pagination } : {}
126
+ };
127
+ }
128
+ function E(e) {
129
+ return e.map((r) => {
130
+ const t = a(r);
131
+ if (!t.role)
132
+ throw new Error(
133
+ `semaphor.records field "${t.name}" needs an explicit role.`
134
+ );
135
+ return t;
136
+ });
137
+ }
138
+ function N(e) {
139
+ return {
140
+ version: 1,
141
+ kind: "inputOptions",
142
+ id: e.id,
143
+ label: e.label,
144
+ source: h(e),
145
+ field: a(e.field, "dimension"),
146
+ search: e.search,
147
+ limit: e.limit
148
+ };
149
+ }
150
+ function W(e) {
151
+ var r;
152
+ return {
153
+ version: 1,
154
+ kind: "sql",
155
+ id: e.id,
156
+ label: e.label,
157
+ source: e.source,
158
+ sql: e.sql,
159
+ ...e.defaultParameters ? { defaultParameters: e.defaultParameters } : {},
160
+ ...e.pythonCode ? { pythonCode: e.pythonCode } : {},
161
+ ...(r = e.fields) != null && r.length ? { fields: e.fields.map((t) => a(t)) } : {},
162
+ inputs: m(e.inputs),
163
+ limit: e.limit,
164
+ ...e.pagination ? { pagination: e.pagination } : {},
165
+ rationale: e.rationale
166
+ };
167
+ }
168
+ function U(e) {
169
+ if ("toAnalyticsInput" in e) {
170
+ const n = e.toAnalyticsInput();
171
+ return {
172
+ inputId: n.inputId,
173
+ kind: n.kind,
174
+ ...n.controlRole ? { controlRole: n.controlRole } : {},
175
+ ...n.operator ? { operator: n.operator } : {},
176
+ ...n.field ? { field: n.field } : {}
177
+ };
178
+ }
179
+ if ("id" in e) {
180
+ const n = M(e);
181
+ return {
182
+ inputId: n.inputId,
183
+ kind: n.kind,
184
+ ...n.controlRole ? { controlRole: n.controlRole } : {},
185
+ ...n.operator ? { operator: n.operator } : {},
186
+ ...n.field ? { field: n.field } : {}
187
+ };
188
+ }
189
+ const r = "kind" in e ? e.kind : void 0, t = "operator" in e ? _(e.operator, e.inputId) : void 0, o = "controlRole" in e ? e.controlRole : "role" in e ? e.role : void 0, i = V(o) ? o : void 0;
190
+ return {
191
+ inputId: e.inputId,
192
+ ...r ? { kind: r } : {},
193
+ ...i ? { controlRole: i } : {},
194
+ ...t ? { operator: t } : {},
195
+ ...e.field ? { field: e.field } : {}
196
+ };
197
+ }
198
+ function V(e) {
199
+ return e === "grain" || e === "metric" || e === "dimension" || e === "aggregation" || e === "sqlParam";
200
+ }
201
+ function ve(e) {
202
+ const r = m(e);
203
+ return r.length > 0 ? r : void 0;
204
+ }
205
+ function G(e) {
206
+ return (e || []).map(L);
207
+ }
208
+ function qe(e) {
209
+ return G(e).filter((r) => r.isActive);
210
+ }
211
+ function M(e) {
212
+ if (e.kind === "filter") {
213
+ const r = _(e.operator, e.id);
214
+ return {
215
+ inputId: e.id,
216
+ kind: e.kind,
217
+ label: e.label,
218
+ field: a(e.field, "dimension"),
219
+ operator: r || "in"
220
+ };
221
+ }
222
+ return {
223
+ inputId: e.id,
224
+ kind: e.kind,
225
+ label: e.label,
226
+ controlRole: e.role
227
+ };
228
+ }
229
+ function Ie(e = []) {
230
+ return e.map(
231
+ (r) => typeof r == "object" ? r : {
232
+ label: String(r),
233
+ value: r
234
+ }
235
+ );
236
+ }
237
+ function g(e) {
238
+ return e == null ? !1 : Array.isArray(e) ? e.length > 0 : typeof e == "string" ? e.trim().length > 0 : !0;
239
+ }
240
+ function L(e) {
241
+ if ("toAnalyticsInput" in e)
242
+ return e.toAnalyticsInput();
243
+ if ("kind" in e && "isActive" in e)
244
+ return e;
245
+ if ("id" in e) {
246
+ const r = M(e), t = Object.prototype.hasOwnProperty.call(e, "value") ? e.value : e.defaultValue;
247
+ return {
248
+ inputId: r.inputId,
249
+ kind: r.kind,
250
+ label: r.label,
251
+ ...r.field ? { field: r.field } : {},
252
+ ...r.operator ? { operator: r.operator } : {},
253
+ ...r.controlRole ? { controlRole: r.controlRole } : {},
254
+ value: t,
255
+ isActive: g(t)
256
+ };
257
+ }
258
+ return {
259
+ ...e,
260
+ kind: "filter",
261
+ isActive: g(
262
+ e.value
263
+ ),
264
+ value: e.value
265
+ };
266
+ }
267
+ function h(e) {
268
+ return e.source;
269
+ }
270
+ function J(e) {
271
+ var r;
272
+ return !!((r = e.fields) != null && r.length);
273
+ }
274
+ function a(e, r) {
275
+ return {
276
+ ...e,
277
+ role: e.role || r
278
+ };
279
+ }
280
+ function m(e) {
281
+ return (e || []).map(U);
282
+ }
283
+ function X(e) {
284
+ if (e)
285
+ return e;
286
+ }
287
+ function _(e, r) {
288
+ if (e === void 0)
289
+ return;
290
+ const t = T(e);
291
+ if (!t)
292
+ throw new Error(
293
+ `useSemaphorInput "${r}" uses unsupported filter operator "${e}".`
294
+ );
295
+ return t;
296
+ }
297
+ function Y(e, r = {}) {
298
+ const t = r.pathPrefix || "analysisOptions";
299
+ if (e === void 0)
300
+ return { ok: !0 };
301
+ if (!e || typeof e != "object" || Array.isArray(e))
302
+ return s(
303
+ t,
304
+ "Data App analysis options must be an object."
305
+ );
306
+ const o = e, i = {};
307
+ if (o.chartTitle !== void 0) {
308
+ if (typeof o.chartTitle != "string")
309
+ return s(
310
+ `${t}.chartTitle`,
311
+ 'Data App analysis option "chartTitle" must be a string.'
312
+ );
313
+ i.chartTitle = o.chartTitle;
314
+ }
315
+ if (o.chartType !== void 0) {
316
+ if (typeof o.chartType != "string")
317
+ return s(
318
+ `${t}.chartType`,
319
+ 'Data App analysis option "chartType" must be a string.'
320
+ );
321
+ i.chartType = o.chartType;
322
+ }
323
+ if (o.driverMode !== void 0) {
324
+ if (!ee(o.driverMode))
325
+ return s(
326
+ `${t}.driverMode`,
327
+ 'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.'
328
+ );
329
+ i.driverMode = o.driverMode;
330
+ }
331
+ if (o.includePopulation !== void 0) {
332
+ if (typeof o.includePopulation != "boolean")
333
+ return s(
334
+ `${t}.includePopulation`,
335
+ 'Data App analysis option "includePopulation" must be a boolean.'
336
+ );
337
+ i.includePopulation = o.includePopulation;
338
+ }
339
+ if (o.calendarContext !== void 0) {
340
+ const n = te(
341
+ o.calendarContext,
342
+ {
343
+ pathPrefix: `${t}.calendarContext`,
344
+ validateTimezone: r.validateTimezone
345
+ }
346
+ );
347
+ if (!n.ok)
348
+ return n;
349
+ i.calendarContext = n.calendarContext;
350
+ }
351
+ return { ok: !0, analysisOptions: i };
352
+ }
353
+ function ke(e) {
354
+ const r = e.queries.map(
355
+ (i, n) => Z(i, n, {
356
+ fieldCatalogs: e.fieldCatalogs || [],
357
+ requireFieldCatalog: !!e.requireFieldCatalog,
358
+ validateTimezone: e.validateTimezone
359
+ })
360
+ ), t = r.flatMap((i) => i.diagnostics), o = r.map((i) => i.executionResult);
361
+ return {
362
+ ok: t.every((i) => i.severity !== "error"),
363
+ diagnostics: t,
364
+ queries: r,
365
+ intents: r.flatMap(
366
+ (i) => i.intent ? [i.intent] : []
367
+ ),
368
+ executionResults: o
369
+ };
370
+ }
371
+ function Z(e, r, t) {
372
+ const o = `queries.${r}`;
373
+ try {
374
+ const i = ie(e), n = ye(e, i), d = x(i), l = [
375
+ ...le({
376
+ querySpec: e,
377
+ queryId: n,
378
+ intent: i,
379
+ pathPrefix: o
380
+ }),
381
+ ...d.errors.map(
382
+ (y) => v(y, {
383
+ queryHook: e.queryHook,
384
+ queryId: n,
385
+ pathPrefix: o,
386
+ severity: "error",
387
+ intent: i
388
+ })
389
+ ),
390
+ ...d.warnings.map(
391
+ (y) => v(y, {
392
+ queryHook: e.queryHook,
393
+ queryId: n,
394
+ pathPrefix: o,
395
+ severity: "warning",
396
+ intent: i
397
+ })
398
+ ),
399
+ ...ne({
400
+ querySpec: e,
401
+ queryId: n,
402
+ intent: i,
403
+ pathPrefix: o,
404
+ fieldCatalogs: t.fieldCatalogs,
405
+ requireFieldCatalog: t.requireFieldCatalog
406
+ }),
407
+ ...de({
408
+ querySpec: e,
409
+ queryId: n,
410
+ intent: i,
411
+ pathPrefix: o,
412
+ validateTimezone: t.validateTimezone
413
+ })
414
+ ], u = me(d, l);
415
+ return {
416
+ queryHook: e.queryHook,
417
+ queryId: n,
418
+ intent: i,
419
+ diagnostics: l,
420
+ executionResult: k({
421
+ intent: i,
422
+ validation: u,
423
+ diagnostics: l
424
+ })
425
+ };
426
+ } catch (i) {
427
+ const n = {
428
+ severity: "error",
429
+ code: "invalid_query_spec",
430
+ message: i instanceof Error ? i.message : String(i),
431
+ path: o,
432
+ queryHook: e.queryHook,
433
+ queryId: P(e.spec)
434
+ }, d = R([n]);
435
+ return {
436
+ queryHook: e.queryHook,
437
+ queryId: n.queryId,
438
+ diagnostics: [n],
439
+ executionResult: k({
440
+ validation: d,
441
+ diagnostics: [n]
442
+ })
443
+ };
444
+ }
445
+ }
446
+ function s(e, r) {
447
+ return {
448
+ ok: !1,
449
+ issues: [
450
+ {
451
+ code: "invalid_analysis_option",
452
+ message: r,
453
+ path: e
454
+ }
455
+ ]
456
+ };
457
+ }
458
+ function C(e) {
459
+ return !!(e && typeof e == "object" && !Array.isArray(e));
460
+ }
461
+ function ee(e) {
462
+ return e === "absolute_delta" || e === "largest_negative" || e === "largest_positive" || e === "positive_and_negative" || e === "all";
463
+ }
464
+ function re(e) {
465
+ return e.trim().length > 0 && !Number.isNaN(Date.parse(e));
466
+ }
467
+ function te(e, r) {
468
+ var u;
469
+ if (!e || typeof e != "object" || Array.isArray(e))
470
+ return s(
471
+ r.pathPrefix,
472
+ 'Data App analysis option "calendarContext" must be an object.'
473
+ );
474
+ const t = e, o = t.tz, i = t.weekStart, n = t.anchor, d = n && typeof n == "object" && !Array.isArray(n) ? n.iso : void 0, l = typeof o == "string" ? ((u = r.validateTimezone) == null ? void 0 : u.call(r, o)) ?? o : null;
475
+ return l ? typeof i != "number" || !Number.isInteger(i) || i < 0 || i > 6 ? s(
476
+ `${r.pathPrefix}.weekStart`,
477
+ 'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'
478
+ ) : n !== "now" && !(typeof d == "string" && re(d)) ? s(
479
+ `${r.pathPrefix}.anchor`,
480
+ 'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'
481
+ ) : {
482
+ ok: !0,
483
+ calendarContext: {
484
+ tz: l,
485
+ weekStart: i,
486
+ anchor: n
487
+ }
488
+ } : s(
489
+ `${r.pathPrefix}.tz`,
490
+ 'Data App analysis option "calendarContext.tz" must be a valid timezone string.'
491
+ );
492
+ }
493
+ function ie(e) {
494
+ return oe(e.spec);
495
+ }
496
+ function oe(e) {
497
+ if (!C(e))
498
+ throw new Error("useSemaphorQuery spec must be an object.");
499
+ if (e.queryKind === "metric")
500
+ return w(e);
501
+ if (e.queryKind === "analysis")
502
+ return F(e);
503
+ if (e.queryKind === "records")
504
+ return Q(e);
505
+ if (e.queryKind === "sql")
506
+ return W(e);
507
+ if (e.queryKind === "inputOptions")
508
+ return N(e);
509
+ throw new Error(
510
+ "useSemaphorQuery spec.queryKind must be metric, analysis, records, inputOptions, or sql."
511
+ );
512
+ }
513
+ function ne(e) {
514
+ if (e.intent.kind === "sql")
515
+ return [];
516
+ if (e.fieldCatalogs.length === 0 && !e.requireFieldCatalog)
517
+ return [];
518
+ const r = fe(
519
+ e.fieldCatalogs,
520
+ e.intent.source
521
+ );
522
+ return r ? [
523
+ ...ae({
524
+ ...e,
525
+ catalog: r
526
+ }),
527
+ ...se({
528
+ ...e,
529
+ catalog: r
530
+ })
531
+ ] : [
532
+ {
533
+ severity: "error",
534
+ code: "invalid_source_ref",
535
+ message: `Source ref for ${e.querySpec.queryHook} does not match a visible Semaphor source.`,
536
+ path: `${e.pathPrefix}.spec.source`,
537
+ queryHook: e.querySpec.queryHook,
538
+ queryId: e.queryId,
539
+ intentId: e.intent.id,
540
+ source: e.intent.source
541
+ }
542
+ ];
543
+ }
544
+ function ae(e) {
545
+ return ue(e.intent).flatMap(({ field: r, path: t }) => $(e.catalog, r, e.intent.source) ? [] : [
546
+ {
547
+ severity: "error",
548
+ code: "missing_field",
549
+ message: `Field "${r.name}" is not visible on the selected Semaphor source.`,
550
+ path: `${e.pathPrefix}.${t}`,
551
+ queryHook: e.querySpec.queryHook,
552
+ queryId: e.queryId,
553
+ intentId: e.intent.id,
554
+ source: c(r, e.intent.source),
555
+ field: r
556
+ }
557
+ ]);
558
+ }
559
+ function se(e) {
560
+ return ("inputs" in e.intent ? e.intent.inputs || [] : []).flatMap((t, o) => {
561
+ if (!t.field)
562
+ return [];
563
+ const i = c(t.field, e.intent.source);
564
+ return b(i, e.intent.source) ? $(e.catalog, t.field, e.intent.source) ? [] : [
565
+ {
566
+ severity: "error",
567
+ code: "missing_field",
568
+ message: `Input "${t.inputId}" references field "${t.field.name}", which is not visible on the selected Semaphor source.`,
569
+ path: `${e.pathPrefix}.spec.inputs.${o}.field`,
570
+ queryHook: e.querySpec.queryHook,
571
+ queryId: e.queryId,
572
+ intentId: e.intent.id,
573
+ source: i,
574
+ field: t.field
575
+ }
576
+ ] : [
577
+ {
578
+ severity: "error",
579
+ code: "unsupported_input_filter_composition",
580
+ message: `Input "${t.inputId}" filters a different Semaphor source than the query. Cross-source Data App inputs are not supported yet.`,
581
+ path: `${e.pathPrefix}.spec.inputs.${o}.field`,
582
+ queryHook: e.querySpec.queryHook,
583
+ queryId: e.queryId,
584
+ intentId: e.intent.id,
585
+ source: i,
586
+ field: t.field
587
+ }
588
+ ];
589
+ });
590
+ }
591
+ function de(e) {
592
+ if (e.querySpec.spec.queryKind !== "analysis")
593
+ return [];
594
+ const r = Y(
595
+ e.querySpec.spec,
596
+ {
597
+ pathPrefix: `${e.pathPrefix}.spec`,
598
+ validateTimezone: e.validateTimezone
599
+ }
600
+ );
601
+ return r.ok ? [] : r.issues.map((t) => ({
602
+ severity: "error",
603
+ code: t.code,
604
+ message: t.message,
605
+ path: t.path,
606
+ queryHook: e.querySpec.queryHook,
607
+ queryId: e.queryId,
608
+ intentId: e.intent.id,
609
+ source: e.intent.source
610
+ }));
611
+ }
612
+ function le(e) {
613
+ return e.querySpec.spec.queryKind !== "sql" ? [] : C(e.querySpec.spec) ? Object.prototype.hasOwnProperty.call(e.querySpec.spec, "parameters") ? [
614
+ {
615
+ severity: "error",
616
+ code: "deprecated_sql_parameters",
617
+ message: "semaphor.sql uses defaultParameters for static SQL param(...) fallback values. The legacy parameters field is not supported.",
618
+ path: `${e.pathPrefix}.spec.parameters`,
619
+ queryHook: e.querySpec.queryHook,
620
+ queryId: e.queryId,
621
+ intentId: e.intent.id
622
+ }
623
+ ] : [] : [];
624
+ }
625
+ function ue(e) {
626
+ return e.kind === "metric" ? [
627
+ ...e.metrics.map((r, t) => ({
628
+ field: r,
629
+ path: `spec.metrics.${t}`
630
+ })),
631
+ ...e.primaryMetric ? [{ field: e.primaryMetric, path: "spec.primaryMetric" }] : [],
632
+ ...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
633
+ ...(e.dimensions || []).map((r, t) => ({
634
+ field: r,
635
+ path: `spec.dimensions.${t}`
636
+ })),
637
+ ...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : [],
638
+ ...(e.filters || []).map((r, t) => ({
639
+ field: r.field,
640
+ path: `spec.filters.${t}.field`
641
+ }))
642
+ ] : e.kind === "records" ? [
643
+ ...e.fields.map((r, t) => ({
644
+ field: r,
645
+ path: `spec.fields.${t}`
646
+ })),
647
+ ...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
648
+ ...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : [],
649
+ ...(e.filters || []).map((r, t) => ({
650
+ field: r.field,
651
+ path: `spec.filters.${t}.field`
652
+ }))
653
+ ] : e.kind === "inputOptions" ? [{ field: e.field, path: "spec.field" }] : [];
654
+ }
655
+ function fe(e, r) {
656
+ return e.find((t) => p(t, r));
657
+ }
658
+ function $(e, r, t) {
659
+ const o = c(r, t);
660
+ if (p(e, o))
661
+ return e.fields.find(
662
+ (i) => ce(i, r) && p(
663
+ e,
664
+ c(i, e.source)
665
+ )
666
+ );
667
+ }
668
+ function p(e, r) {
669
+ return [e.source, ...e.sourceAliases || []].some(
670
+ (t) => b(t, r)
671
+ );
672
+ }
673
+ function c(e, r) {
674
+ return e.source || r;
675
+ }
676
+ function ce(e, r) {
677
+ return !!(e.name && r.name && e.name === r.name);
678
+ }
679
+ function v(e, r) {
680
+ return {
681
+ severity: r.severity,
682
+ code: e.code || "invalid_analytics_intent",
683
+ message: e.message,
684
+ path: e.path ? `${r.pathPrefix}.spec.${e.path}` : r.pathPrefix,
685
+ queryHook: r.queryHook,
686
+ queryId: r.queryId,
687
+ intentId: r.intent.id,
688
+ source: r.intent.source
689
+ };
690
+ }
691
+ function me(e, r) {
692
+ const t = R(r);
693
+ return {
694
+ ok: t.ok && e.ok,
695
+ errors: I([
696
+ ...e.errors,
697
+ ...t.errors
698
+ ]),
699
+ warnings: I([
700
+ ...e.warnings,
701
+ ...t.warnings
702
+ ]),
703
+ repairHints: [
704
+ ...e.repairHints,
705
+ ...t.repairHints
706
+ ]
707
+ };
708
+ }
709
+ function R(e) {
710
+ const r = e.filter((o) => o.severity === "error").map(q), t = e.filter((o) => o.severity === "warning").map(q);
711
+ return {
712
+ ok: r.length === 0,
713
+ errors: r,
714
+ warnings: t,
715
+ repairHints: r.map((o) => {
716
+ var i, n;
717
+ return {
718
+ code: o.code,
719
+ message: o.message,
720
+ fieldRole: o.fieldRole,
721
+ invalidField: (i = o.repairHint) == null ? void 0 : i.invalidField,
722
+ recommendedNextStep: ((n = o.repairHint) == null ? void 0 : n.recommendedNextStep) || "Update the Data App SDK query spec to use visible Semaphor source and field refs."
723
+ };
724
+ })
725
+ };
726
+ }
727
+ function q(e) {
728
+ var r;
729
+ return {
730
+ code: e.code,
731
+ message: e.message,
732
+ path: e.path,
733
+ fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
734
+ repairHint: {
735
+ code: e.code,
736
+ message: e.message,
737
+ invalidField: (r = e.field) == null ? void 0 : r.name,
738
+ fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
739
+ recommendedNextStep: e.code === "unsupported_input_filter_composition" ? "Use an input field from the same Semaphor source as the query, or split the query into separate source-scoped queries." : "Update the query spec to use a visible Semaphor source and field ref."
740
+ }
741
+ };
742
+ }
743
+ function I(e) {
744
+ const r = /* @__PURE__ */ new Set();
745
+ return e.filter((t) => {
746
+ const o = `${t.code}:${t.path || ""}:${t.message}`;
747
+ return r.has(o) ? !1 : (r.add(o), !0);
748
+ });
749
+ }
750
+ function k(e) {
751
+ var t, o;
752
+ const r = e.diagnostics.filter(
753
+ (i) => i.severity === "error"
754
+ );
755
+ return {
756
+ intentId: (t = e.intent) == null ? void 0 : t.id,
757
+ status: r.length ? "failed" : "answered",
758
+ resultShape: (o = e.intent) == null ? void 0 : o.kind,
759
+ intent: e.intent,
760
+ validation: e.validation,
761
+ coverage: {
762
+ answeredObligations: r.length ? [] : ["query_spec_validation"],
763
+ missingObligations: r.length ? ["query_spec_validation"] : [],
764
+ warnings: e.validation.warnings
765
+ },
766
+ missingFields: r.filter((i) => i.code === "missing_field").flatMap(
767
+ (i) => {
768
+ var n;
769
+ return (n = i.field) != null && n.name ? [i.field.name] : [];
770
+ }
771
+ ),
772
+ warnings: e.diagnostics.filter((i) => i.severity === "warning").map((i) => i.message),
773
+ metadata: {
774
+ validationKind: "data_app_sdk_query_spec"
775
+ }
776
+ };
777
+ }
778
+ function ye(e, r) {
779
+ return r.id || P(e.spec);
780
+ }
781
+ function P(e) {
782
+ if (!e || typeof e != "object" || !("id" in e))
783
+ return;
784
+ const r = e.id;
785
+ return typeof r == "string" && r.trim() ? r : void 0;
786
+ }
787
+ export {
788
+ W as a,
789
+ N as b,
790
+ Q as c,
791
+ ge as d,
792
+ F as e,
793
+ w as f,
794
+ M as g,
795
+ g as h,
796
+ U as i,
797
+ ve as j,
798
+ G as k,
799
+ Y as l,
800
+ Ie as n,
801
+ qe as t,
802
+ ke as v
803
+ };