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
@@ -1,689 +0,0 @@
1
- import { n as C, v as x } from "./validators-L0xEXtjf.js";
2
- import { b as S, c as F, a as A } from "./source-identity-Dj3dryN9.js";
3
- function b(e) {
4
- var r;
5
- const t = z(e);
6
- return {
7
- version: 1,
8
- kind: "metric",
9
- id: e.id,
10
- label: e.label,
11
- source: p(e),
12
- metrics: t,
13
- primaryMetric: P(e, t),
14
- dateField: e.dateField ? a(e.dateField, "date") : void 0,
15
- timeGrain: e.timeGrain,
16
- dimensions: (r = e.dimensions) == null ? void 0 : r.map((o) => a(o, "dimension")),
17
- comparison: V(e.comparison),
18
- orderBy: e.orderBy ? {
19
- field: a(e.orderBy.field),
20
- direction: e.orderBy.direction
21
- } : void 0,
22
- inputs: g(e.inputs),
23
- limit: e.limit
24
- };
25
- }
26
- function T(e) {
27
- var r;
28
- return {
29
- ...b(e),
30
- ...e.timeWindow ? { timeWindow: e.timeWindow } : {},
31
- ...(r = e.filters) != null && r.length ? { filters: e.filters } : {},
32
- ...e.analysis ? { analysis: e.analysis } : {}
33
- };
34
- }
35
- function ce(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 P(e, t) {
45
- if (!e.primaryMetric)
46
- return t[0] || { name: "", role: "measure" };
47
- const r = a(e.primaryMetric, "measure"), o = O(r, t), i = o.length === 1 ? o[0] : void 0;
48
- return i ? w(r, i) : r;
49
- }
50
- function z(e) {
51
- const t = [];
52
- for (const r of e.metrics.map((o) => a(o, "measure"))) {
53
- if (!r.name)
54
- continue;
55
- const o = t.findIndex(
56
- (i) => R(i, r)
57
- );
58
- if (o === -1) {
59
- t.push(r);
60
- continue;
61
- }
62
- t[o] = w(t[o], r);
63
- }
64
- return t;
65
- }
66
- function R(e, t) {
67
- return S(e, t) && c(e) === c(t);
68
- }
69
- function B(e, t) {
70
- return c(t) === c(e);
71
- }
72
- function D(e, t) {
73
- return t.name !== e.name || e.source && !S(t, e) ? !1 : B(e, t);
74
- }
75
- function O(e, t) {
76
- const r = t.filter(
77
- (o) => D(e, o)
78
- );
79
- return e.aggregate !== void 0, r;
80
- }
81
- function c(e) {
82
- return (e.aggregate || "SUM").toUpperCase();
83
- }
84
- function w(e, t) {
85
- if (e.aggregate && t.aggregate && e.aggregate !== t.aggregate)
86
- throw new Error(
87
- `Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${t.aggregate}.`
88
- );
89
- return {
90
- ...F(e, t),
91
- aggregate: e.aggregate || t.aggregate
92
- };
93
- }
94
- function H(e) {
95
- var r;
96
- if ("sort" in e)
97
- throw new Error(
98
- "useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet."
99
- );
100
- if (!G(e))
101
- throw new Error(
102
- "useSemaphorRecords needs at least one field."
103
- );
104
- const t = j(e.fields);
105
- return {
106
- version: 1,
107
- kind: "records",
108
- id: e.id,
109
- label: e.label,
110
- source: p(e),
111
- fields: t,
112
- dateField: e.dateField ? a(e.dateField, "date") : void 0,
113
- timeGrain: e.timeGrain,
114
- ...e.timeWindow ? { timeWindow: e.timeWindow } : {},
115
- ...(r = e.filters) != null && r.length ? { filters: e.filters } : {},
116
- orderBy: e.orderBy ? {
117
- field: a(e.orderBy.field),
118
- direction: e.orderBy.direction
119
- } : void 0,
120
- inputs: g(e.inputs),
121
- limit: e.limit
122
- };
123
- }
124
- function j(e) {
125
- return e.map((t) => {
126
- const r = a(t);
127
- if (!r.role)
128
- throw new Error(
129
- `useSemaphorRecords field "${r.name}" needs an explicit role.`
130
- );
131
- return r;
132
- });
133
- }
134
- function N(e) {
135
- return {
136
- version: 1,
137
- kind: "inputOptions",
138
- id: e.id,
139
- label: e.label,
140
- source: p(e),
141
- field: a(e.field, "dimension"),
142
- search: e.search,
143
- limit: e.limit
144
- };
145
- }
146
- function E(e) {
147
- if ("toAnalyticsInput" in e) {
148
- const t = e.toAnalyticsInput();
149
- return {
150
- inputId: t.inputId,
151
- ...t.field ? { field: t.field } : {}
152
- };
153
- }
154
- return {
155
- inputId: e.inputId,
156
- ...e.field ? { field: e.field } : {}
157
- };
158
- }
159
- function ue(e) {
160
- const t = g(e);
161
- return t.length > 0 ? t : void 0;
162
- }
163
- function q(e) {
164
- return (e || []).map(U);
165
- }
166
- function me(e) {
167
- return q(e).filter((t) => t.isActive);
168
- }
169
- function he(e) {
170
- if (e.kind === "filter") {
171
- const t = K(e.operator, e.id);
172
- return {
173
- inputId: e.id,
174
- kind: e.kind,
175
- label: e.label,
176
- field: a(e.field, "dimension"),
177
- operator: t || "in"
178
- };
179
- }
180
- return {
181
- inputId: e.id,
182
- kind: e.kind,
183
- label: e.label
184
- };
185
- }
186
- function pe(e = []) {
187
- return e.map(
188
- (t) => typeof t == "object" ? t : {
189
- label: String(t),
190
- value: t
191
- }
192
- );
193
- }
194
- function W(e) {
195
- return e == null ? !1 : Array.isArray(e) ? e.length > 0 : typeof e == "string" ? e.trim().length > 0 : !0;
196
- }
197
- function U(e) {
198
- return "toAnalyticsInput" in e ? e.toAnalyticsInput() : "kind" in e && "isActive" in e ? e : {
199
- ...e,
200
- kind: "filter",
201
- isActive: W(
202
- e.value
203
- ),
204
- value: e.value
205
- };
206
- }
207
- function p(e) {
208
- return e.source;
209
- }
210
- function G(e) {
211
- var t;
212
- return !!((t = e.fields) != null && t.length);
213
- }
214
- function a(e, t) {
215
- return {
216
- ...e,
217
- role: e.role || t
218
- };
219
- }
220
- function g(e) {
221
- return (e || []).map(E);
222
- }
223
- function V(e) {
224
- if (e)
225
- return e;
226
- }
227
- function K(e, t) {
228
- if (e === void 0)
229
- return;
230
- const r = C(e);
231
- if (!r)
232
- throw new Error(
233
- `useSemaphorInput "${t}" uses unsupported filter operator "${e}".`
234
- );
235
- return r;
236
- }
237
- function Q(e, t = {}) {
238
- const r = t.pathPrefix || "analysisOptions";
239
- if (e === void 0)
240
- return { ok: !0 };
241
- if (!e || typeof e != "object" || Array.isArray(e))
242
- return s(
243
- r,
244
- "Data App analysis options must be an object."
245
- );
246
- const o = e, i = {};
247
- if (o.chartTitle !== void 0) {
248
- if (typeof o.chartTitle != "string")
249
- return s(
250
- `${r}.chartTitle`,
251
- 'Data App analysis option "chartTitle" must be a string.'
252
- );
253
- i.chartTitle = o.chartTitle;
254
- }
255
- if (o.chartType !== void 0) {
256
- if (typeof o.chartType != "string")
257
- return s(
258
- `${r}.chartType`,
259
- 'Data App analysis option "chartType" must be a string.'
260
- );
261
- i.chartType = o.chartType;
262
- }
263
- if (o.driverMode !== void 0) {
264
- if (!L(o.driverMode))
265
- return s(
266
- `${r}.driverMode`,
267
- 'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.'
268
- );
269
- i.driverMode = o.driverMode;
270
- }
271
- if (o.includePopulation !== void 0) {
272
- if (typeof o.includePopulation != "boolean")
273
- return s(
274
- `${r}.includePopulation`,
275
- 'Data App analysis option "includePopulation" must be a boolean.'
276
- );
277
- i.includePopulation = o.includePopulation;
278
- }
279
- if (o.calendarContext !== void 0) {
280
- const n = Y(
281
- o.calendarContext,
282
- {
283
- pathPrefix: `${r}.calendarContext`,
284
- validateTimezone: t.validateTimezone
285
- }
286
- );
287
- if (!n.ok)
288
- return n;
289
- i.calendarContext = n.calendarContext;
290
- }
291
- return { ok: !0, analysisOptions: i };
292
- }
293
- function ge(e) {
294
- const t = e.hooks.map(
295
- (i, n) => J(i, n, {
296
- fieldCatalogs: e.fieldCatalogs || [],
297
- requireFieldCatalog: !!e.requireFieldCatalog,
298
- validateTimezone: e.validateTimezone
299
- })
300
- ), r = t.flatMap((i) => i.diagnostics), o = t.map((i) => i.executionResult);
301
- return {
302
- ok: r.every((i) => i.severity !== "error"),
303
- diagnostics: r,
304
- hooks: t,
305
- intents: t.flatMap((i) => i.intent ? [i.intent] : []),
306
- executionResults: o
307
- };
308
- }
309
- function J(e, t, r) {
310
- const o = `hooks.${t}`;
311
- try {
312
- const i = Z(e), n = de(e, i), d = x(i), l = [
313
- ...d.errors.map(
314
- (m) => y(m, {
315
- hook: e.hook,
316
- hookId: n,
317
- pathPrefix: o,
318
- severity: "error",
319
- intent: i
320
- })
321
- ),
322
- ...d.warnings.map(
323
- (m) => y(m, {
324
- hook: e.hook,
325
- hookId: n,
326
- pathPrefix: o,
327
- severity: "warning",
328
- intent: i
329
- })
330
- ),
331
- ...ee({
332
- hookSpec: e,
333
- hookId: n,
334
- intent: i,
335
- pathPrefix: o,
336
- fieldCatalogs: r.fieldCatalogs,
337
- requireFieldCatalog: r.requireFieldCatalog
338
- }),
339
- ...ie({
340
- hookSpec: e,
341
- hookId: n,
342
- intent: i,
343
- pathPrefix: o,
344
- validateTimezone: r.validateTimezone
345
- })
346
- ], f = se(d, l);
347
- return {
348
- hook: e.hook,
349
- hookId: n,
350
- intent: i,
351
- diagnostics: l,
352
- executionResult: I({
353
- intent: i,
354
- validation: f,
355
- diagnostics: l
356
- })
357
- };
358
- } catch (i) {
359
- const n = {
360
- severity: "error",
361
- code: "invalid_hook_spec",
362
- message: i instanceof Error ? i.message : String(i),
363
- path: o,
364
- hook: e.hook,
365
- hookId: $(e.spec)
366
- }, d = _([n]);
367
- return {
368
- hook: e.hook,
369
- hookId: n.hookId,
370
- diagnostics: [n],
371
- executionResult: I({
372
- validation: d,
373
- diagnostics: [n]
374
- })
375
- };
376
- }
377
- }
378
- function s(e, t) {
379
- return {
380
- ok: !1,
381
- issues: [
382
- {
383
- code: "invalid_analysis_option",
384
- message: t,
385
- path: e
386
- }
387
- ]
388
- };
389
- }
390
- function L(e) {
391
- return e === "absolute_delta" || e === "largest_negative" || e === "largest_positive" || e === "positive_and_negative" || e === "all";
392
- }
393
- function X(e) {
394
- return e.trim().length > 0 && !Number.isNaN(Date.parse(e));
395
- }
396
- function Y(e, t) {
397
- var f;
398
- if (!e || typeof e != "object" || Array.isArray(e))
399
- return s(
400
- t.pathPrefix,
401
- 'Data App analysis option "calendarContext" must be an object.'
402
- );
403
- const r = e, o = r.tz, i = r.weekStart, n = r.anchor, d = n && typeof n == "object" && !Array.isArray(n) ? n.iso : void 0, l = typeof o == "string" ? ((f = t.validateTimezone) == null ? void 0 : f.call(t, o)) ?? o : null;
404
- return l ? typeof i != "number" || !Number.isInteger(i) || i < 0 || i > 6 ? s(
405
- `${t.pathPrefix}.weekStart`,
406
- 'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'
407
- ) : n !== "now" && !(typeof d == "string" && X(d)) ? s(
408
- `${t.pathPrefix}.anchor`,
409
- 'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'
410
- ) : {
411
- ok: !0,
412
- calendarContext: {
413
- tz: l,
414
- weekStart: i,
415
- anchor: n
416
- }
417
- } : s(
418
- `${t.pathPrefix}.tz`,
419
- 'Data App analysis option "calendarContext.tz" must be a valid timezone string.'
420
- );
421
- }
422
- function Z(e) {
423
- return e.hook === "useSemaphorMetric" ? b(e.spec) : e.hook === "useSemaphorAnalysis" ? T(e.spec) : e.hook === "useSemaphorRecords" ? H(e.spec) : N(e.spec);
424
- }
425
- function ee(e) {
426
- if (e.fieldCatalogs.length === 0 && !e.requireFieldCatalog)
427
- return [];
428
- const t = ne(e.fieldCatalogs, e.intent.source);
429
- return t ? [
430
- ...te({
431
- ...e,
432
- catalog: t
433
- }),
434
- ...re({
435
- ...e,
436
- catalog: t
437
- })
438
- ] : [
439
- {
440
- severity: "error",
441
- code: "invalid_source_ref",
442
- message: `Source ref for ${e.hookSpec.hook} does not match a visible Semaphor source.`,
443
- path: `${e.pathPrefix}.spec.source`,
444
- hook: e.hookSpec.hook,
445
- hookId: e.hookId,
446
- intentId: e.intent.id,
447
- source: e.intent.source
448
- }
449
- ];
450
- }
451
- function te(e) {
452
- return oe(e.intent).flatMap(({ field: t, path: r }) => M(e.catalog, t, e.intent.source) ? [] : [
453
- {
454
- severity: "error",
455
- code: "missing_field",
456
- message: `Field "${t.name}" is not visible on the selected Semaphor source.`,
457
- path: `${e.pathPrefix}.${r}`,
458
- hook: e.hookSpec.hook,
459
- hookId: e.hookId,
460
- intentId: e.intent.id,
461
- source: u(t, e.intent.source),
462
- field: t
463
- }
464
- ]);
465
- }
466
- function re(e) {
467
- return ("inputs" in e.intent ? e.intent.inputs || [] : []).flatMap((r, o) => {
468
- if (!r.field)
469
- return [];
470
- const i = u(r.field, e.intent.source);
471
- return A(i, e.intent.source) ? M(e.catalog, r.field, e.intent.source) ? [] : [
472
- {
473
- severity: "error",
474
- code: "missing_field",
475
- message: `Input "${r.inputId}" references field "${r.field.name}", which is not visible on the selected Semaphor source.`,
476
- path: `${e.pathPrefix}.spec.inputs.${o}.field`,
477
- hook: e.hookSpec.hook,
478
- hookId: e.hookId,
479
- intentId: e.intent.id,
480
- source: i,
481
- field: r.field
482
- }
483
- ] : [
484
- {
485
- severity: "error",
486
- code: "unsupported_input_filter_composition",
487
- message: `Input "${r.inputId}" filters a different Semaphor source than the query. Cross-source Data App inputs are not supported yet.`,
488
- path: `${e.pathPrefix}.spec.inputs.${o}.field`,
489
- hook: e.hookSpec.hook,
490
- hookId: e.hookId,
491
- intentId: e.intent.id,
492
- source: i,
493
- field: r.field
494
- }
495
- ];
496
- });
497
- }
498
- function ie(e) {
499
- if (e.hookSpec.hook !== "useSemaphorAnalysis")
500
- return [];
501
- const t = Q(e.hookSpec.spec, {
502
- pathPrefix: `${e.pathPrefix}.spec`,
503
- validateTimezone: e.validateTimezone
504
- });
505
- return t.ok ? [] : t.issues.map((r) => ({
506
- severity: "error",
507
- code: r.code,
508
- message: r.message,
509
- path: r.path,
510
- hook: e.hookSpec.hook,
511
- hookId: e.hookId,
512
- intentId: e.intent.id,
513
- source: e.intent.source
514
- }));
515
- }
516
- function oe(e) {
517
- return e.kind === "metric" ? [
518
- ...e.metrics.map((t, r) => ({
519
- field: t,
520
- path: `spec.metrics.${r}`
521
- })),
522
- ...e.primaryMetric ? [{ field: e.primaryMetric, path: "spec.primaryMetric" }] : [],
523
- ...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
524
- ...(e.dimensions || []).map((t, r) => ({
525
- field: t,
526
- path: `spec.dimensions.${r}`
527
- })),
528
- ...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : [],
529
- ...(e.filters || []).map((t, r) => ({
530
- field: t.field,
531
- path: `spec.filters.${r}.field`
532
- }))
533
- ] : e.kind === "records" ? [
534
- ...e.fields.map((t, r) => ({
535
- field: t,
536
- path: `spec.fields.${r}`
537
- })),
538
- ...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
539
- ...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : [],
540
- ...(e.filters || []).map((t, r) => ({
541
- field: t.field,
542
- path: `spec.filters.${r}.field`
543
- }))
544
- ] : e.kind === "inputOptions" ? [{ field: e.field, path: "spec.field" }] : [];
545
- }
546
- function ne(e, t) {
547
- return e.find((r) => h(r, t));
548
- }
549
- function M(e, t, r) {
550
- const o = u(t, r);
551
- if (h(e, o))
552
- return e.fields.find(
553
- (i) => ae(i, t) && h(
554
- e,
555
- u(i, e.source)
556
- )
557
- );
558
- }
559
- function h(e, t) {
560
- return [e.source, ...e.sourceAliases || []].some(
561
- (r) => A(r, t)
562
- );
563
- }
564
- function u(e, t) {
565
- return e.source || t;
566
- }
567
- function ae(e, t) {
568
- return !!(e.name && t.name && e.name === t.name);
569
- }
570
- function y(e, t) {
571
- return {
572
- severity: t.severity,
573
- code: e.code || "invalid_analytics_intent",
574
- message: e.message,
575
- path: e.path ? `${t.pathPrefix}.spec.${e.path}` : t.pathPrefix,
576
- hook: t.hook,
577
- hookId: t.hookId,
578
- intentId: t.intent.id,
579
- source: t.intent.source
580
- };
581
- }
582
- function se(e, t) {
583
- const r = _(t);
584
- return {
585
- ok: r.ok && e.ok,
586
- errors: k([
587
- ...e.errors,
588
- ...r.errors
589
- ]),
590
- warnings: k([
591
- ...e.warnings,
592
- ...r.warnings
593
- ]),
594
- repairHints: [
595
- ...e.repairHints,
596
- ...r.repairHints
597
- ]
598
- };
599
- }
600
- function _(e) {
601
- const t = e.filter((o) => o.severity === "error").map(v), r = e.filter((o) => o.severity === "warning").map(v);
602
- return {
603
- ok: t.length === 0,
604
- errors: t,
605
- warnings: r,
606
- repairHints: t.map((o) => {
607
- var i, n;
608
- return {
609
- code: o.code,
610
- message: o.message,
611
- fieldRole: o.fieldRole,
612
- invalidField: (i = o.repairHint) == null ? void 0 : i.invalidField,
613
- recommendedNextStep: ((n = o.repairHint) == null ? void 0 : n.recommendedNextStep) || "Update the Data App SDK hook spec to use visible Semaphor source and field refs."
614
- };
615
- })
616
- };
617
- }
618
- function v(e) {
619
- var t;
620
- return {
621
- code: e.code,
622
- message: e.message,
623
- path: e.path,
624
- fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
625
- repairHint: {
626
- code: e.code,
627
- message: e.message,
628
- invalidField: (t = e.field) == null ? void 0 : t.name,
629
- fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
630
- 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 hooks." : "Update the hook spec to use a visible Semaphor source and field ref."
631
- }
632
- };
633
- }
634
- function k(e) {
635
- const t = /* @__PURE__ */ new Set();
636
- return e.filter((r) => {
637
- const o = `${r.code}:${r.path || ""}:${r.message}`;
638
- return t.has(o) ? !1 : (t.add(o), !0);
639
- });
640
- }
641
- function I(e) {
642
- var r, o;
643
- const t = e.diagnostics.filter((i) => i.severity === "error");
644
- return {
645
- intentId: (r = e.intent) == null ? void 0 : r.id,
646
- status: t.length ? "failed" : "answered",
647
- resultShape: (o = e.intent) == null ? void 0 : o.kind,
648
- intent: e.intent,
649
- validation: e.validation,
650
- coverage: {
651
- answeredObligations: t.length ? [] : ["hook_spec_validation"],
652
- missingObligations: t.length ? ["hook_spec_validation"] : [],
653
- warnings: e.validation.warnings
654
- },
655
- missingFields: t.filter((i) => i.code === "missing_field").flatMap((i) => {
656
- var n;
657
- return (n = i.field) != null && n.name ? [i.field.name] : [];
658
- }),
659
- warnings: e.diagnostics.filter((i) => i.severity === "warning").map((i) => i.message),
660
- metadata: {
661
- validationKind: "data_app_sdk_hook_spec"
662
- }
663
- };
664
- }
665
- function de(e, t) {
666
- return t.id || $(e.spec);
667
- }
668
- function $(e) {
669
- if (!e || typeof e != "object" || !("id" in e))
670
- return;
671
- const t = e.id;
672
- return typeof t == "string" && t.trim() ? t : void 0;
673
- }
674
- export {
675
- ce as a,
676
- T as b,
677
- b as c,
678
- H as d,
679
- N as e,
680
- he as f,
681
- E as g,
682
- W as h,
683
- ue as i,
684
- q as j,
685
- Q as k,
686
- pe as n,
687
- me as t,
688
- ge as v
689
- };