react-semaphor 0.1.365 → 0.1.366

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 (36) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +26 -24
  3. package/dist/chunks/{calendar-preferences-dialog-CgBwWqfY.js → calendar-preferences-dialog-BOFlzOJg.js} +1 -1
  4. package/dist/chunks/{dashboard-briefing-launcher-CK_6KGFV.js → dashboard-briefing-launcher-D2lBFqAd.js} +3 -3
  5. package/dist/chunks/{dashboard-controls-CsIEj0Vm.js → dashboard-controls-BIk094Ah.js} +3 -3
  6. package/dist/chunks/{dashboard-json-OhYs9GOx.js → dashboard-json-DImOf512.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-q_XG4oWg.js → edit-dashboard-visual-DTxkV6Fl.js} +3 -3
  8. package/dist/chunks/{index-Ds3_EAla.js → index-BVEIk-rB.js} +5 -5
  9. package/dist/chunks/{resource-management-panel-CYXyE2js.js → resource-management-panel-BOfbSf48.js} +2 -2
  10. package/dist/chunks/{source-identity-qAmkNtEK.js → source-identity-Dj3dryN9.js} +3 -3
  11. package/dist/chunks/{use-create-flow-overlay-state-CRQcqLs3.js → use-create-flow-overlay-state-B5FygfQL.js} +2 -2
  12. package/dist/chunks/{use-visual-utils-CpZplRpR.js → use-visual-utils-CszWnFBW.js} +1 -1
  13. package/dist/chunks/validation-DiCE3_4O.js +1 -0
  14. package/dist/chunks/{validation-B4_hBuYu.js → validation-WGWJOQsV.js} +115 -94
  15. package/dist/chunks/{validators-BnLhuIhd.js → validators-Bxc1OmZK.js} +296 -237
  16. package/dist/chunks/validators-BxhJ_NtM.js +1 -0
  17. package/dist/dashboard/index.js +1 -1
  18. package/dist/dashboard-authoring/index.cjs +3 -3
  19. package/dist/dashboard-authoring/index.js +135 -134
  20. package/dist/data-app-builder/index.js +1 -1
  21. package/dist/data-app-sdk/index.cjs +1 -1
  22. package/dist/data-app-sdk/index.js +3 -3
  23. package/dist/data-app-sdk-validation/index.cjs +1 -1
  24. package/dist/data-app-sdk-validation/index.js +3 -3
  25. package/dist/index.js +5 -5
  26. package/dist/surfboard/index.js +2 -2
  27. package/dist/types/analytics-protocol.d.ts +11 -1
  28. package/dist/types/dashboard-assistant.d.ts +2 -0
  29. package/dist/types/dashboard-authoring.d.ts +7 -1
  30. package/dist/types/data-app-builder.d.ts +2 -0
  31. package/dist/types/data-app-sdk-validation.d.ts +4 -0
  32. package/dist/types/data-app-sdk.d.ts +21 -6
  33. package/dist/types/main.d.ts +2 -0
  34. package/package.json +1 -1
  35. package/dist/chunks/validation-CsK42Vbq.js +0 -1
  36. package/dist/chunks/validators-Cu_w8ZEP.js +0 -1
@@ -1,8 +1,8 @@
1
- import { v as C } from "./validators-BnLhuIhd.js";
2
- import { s as S, c as x, b as A } from "./source-identity-qAmkNtEK.js";
1
+ import { n as C, v as x } from "./validators-Bxc1OmZK.js";
2
+ import { b as S, c as F, a as A } from "./source-identity-Dj3dryN9.js";
3
3
  function b(e) {
4
4
  var r;
5
- const t = P(e);
5
+ const t = z(e);
6
6
  return {
7
7
  version: 1,
8
8
  kind: "metric",
@@ -10,7 +10,7 @@ function b(e) {
10
10
  label: e.label,
11
11
  source: p(e),
12
12
  metrics: t,
13
- primaryMetric: T(e, t),
13
+ primaryMetric: P(e, t),
14
14
  dateField: e.dateField ? a(e.dateField, "date") : void 0,
15
15
  timeGrain: e.timeGrain,
16
16
  dimensions: (r = e.dimensions) == null ? void 0 : r.map((o) => a(o, "dimension")),
@@ -23,7 +23,7 @@ function b(e) {
23
23
  limit: e.limit
24
24
  };
25
25
  }
26
- function F(e) {
26
+ function T(e) {
27
27
  var r;
28
28
  return {
29
29
  ...b(e),
@@ -32,7 +32,7 @@ function F(e) {
32
32
  ...e.analysis ? { analysis: e.analysis } : {}
33
33
  };
34
34
  }
35
- function le(e) {
35
+ function ce(e) {
36
36
  return {
37
37
  ...e.chartTitle ? { chartTitle: e.chartTitle } : {},
38
38
  ...e.chartType ? { chartType: e.chartType } : {},
@@ -41,13 +41,13 @@ function le(e) {
41
41
  ...e.calendarContext ? { calendarContext: e.calendarContext } : {}
42
42
  };
43
43
  }
44
- function T(e, t) {
44
+ function P(e, t) {
45
45
  if (!e.primaryMetric)
46
46
  return t[0] || { name: "", role: "measure" };
47
- const r = a(e.primaryMetric, "measure"), o = D(r, t), i = o.length === 1 ? o[0] : void 0;
48
- return i ? M(r, i) : r;
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
49
  }
50
- function P(e) {
50
+ function z(e) {
51
51
  const t = [];
52
52
  for (const r of e.metrics.map((o) => a(o, "measure"))) {
53
53
  if (!r.name)
@@ -59,39 +59,40 @@ function P(e) {
59
59
  t.push(r);
60
60
  continue;
61
61
  }
62
- t[o] = M(t[o], r);
62
+ t[o] = w(t[o], r);
63
63
  }
64
64
  return t;
65
65
  }
66
66
  function R(e, t) {
67
- return S(e, t) && f(e) === f(t);
68
- }
69
- function z(e, t) {
70
- return f(t) === f(e);
67
+ return S(e, t) && c(e) === c(t);
71
68
  }
72
69
  function B(e, t) {
73
- return t.name !== e.name || e.source && !S(t, e) ? !1 : z(e, t);
70
+ return c(t) === c(e);
74
71
  }
75
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
76
  const r = t.filter(
77
- (o) => B(e, o)
77
+ (o) => D(e, o)
78
78
  );
79
79
  return e.aggregate !== void 0, r;
80
80
  }
81
- function f(e) {
81
+ function c(e) {
82
82
  return (e.aggregate || "SUM").toUpperCase();
83
83
  }
84
- function M(e, t) {
84
+ function w(e, t) {
85
85
  if (e.aggregate && t.aggregate && e.aggregate !== t.aggregate)
86
86
  throw new Error(
87
87
  `Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${t.aggregate}.`
88
88
  );
89
89
  return {
90
- ...x(e, t),
90
+ ...F(e, t),
91
91
  aggregate: e.aggregate || t.aggregate
92
92
  };
93
93
  }
94
94
  function H(e) {
95
+ var r;
95
96
  if ("sort" in e)
96
97
  throw new Error(
97
98
  "useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet."
@@ -100,7 +101,7 @@ function H(e) {
100
101
  throw new Error(
101
102
  "useSemaphorRecords needs at least one field."
102
103
  );
103
- const t = O(e.fields);
104
+ const t = j(e.fields);
104
105
  return {
105
106
  version: 1,
106
107
  kind: "records",
@@ -110,6 +111,8 @@ function H(e) {
110
111
  fields: t,
111
112
  dateField: e.dateField ? a(e.dateField, "date") : void 0,
112
113
  timeGrain: e.timeGrain,
114
+ ...e.timeWindow ? { timeWindow: e.timeWindow } : {},
115
+ ...(r = e.filters) != null && r.length ? { filters: e.filters } : {},
113
116
  orderBy: e.orderBy ? {
114
117
  field: a(e.orderBy.field),
115
118
  direction: e.orderBy.direction
@@ -118,7 +121,7 @@ function H(e) {
118
121
  limit: e.limit
119
122
  };
120
123
  }
121
- function O(e) {
124
+ function j(e) {
122
125
  return e.map((t) => {
123
126
  const r = a(t);
124
127
  if (!r.role)
@@ -128,7 +131,7 @@ function O(e) {
128
131
  return r;
129
132
  });
130
133
  }
131
- function j(e) {
134
+ function N(e) {
132
135
  return {
133
136
  version: 1,
134
137
  kind: "inputOptions",
@@ -140,7 +143,7 @@ function j(e) {
140
143
  limit: e.limit
141
144
  };
142
145
  }
143
- function N(e) {
146
+ function E(e) {
144
147
  if ("toAnalyticsInput" in e) {
145
148
  const t = e.toAnalyticsInput();
146
149
  return {
@@ -153,30 +156,34 @@ function N(e) {
153
156
  ...e.field ? { field: e.field } : {}
154
157
  };
155
158
  }
156
- function ce(e) {
159
+ function ue(e) {
157
160
  const t = g(e);
158
161
  return t.length > 0 ? t : void 0;
159
162
  }
160
163
  function q(e) {
161
164
  return (e || []).map(U);
162
165
  }
163
- function fe(e) {
166
+ function me(e) {
164
167
  return q(e).filter((t) => t.isActive);
165
168
  }
166
- function ue(e) {
167
- return e.kind === "filter" ? {
168
- inputId: e.id,
169
- kind: e.kind,
170
- label: e.label,
171
- field: a(e.field, "dimension"),
172
- operator: e.operator || "in"
173
- } : {
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 {
174
181
  inputId: e.id,
175
182
  kind: e.kind,
176
183
  label: e.label
177
184
  };
178
185
  }
179
- function he(e = []) {
186
+ function pe(e = []) {
180
187
  return e.map(
181
188
  (t) => typeof t == "object" ? t : {
182
189
  label: String(t),
@@ -184,14 +191,14 @@ function he(e = []) {
184
191
  }
185
192
  );
186
193
  }
187
- function E(e) {
194
+ function W(e) {
188
195
  return e == null ? !1 : Array.isArray(e) ? e.length > 0 : typeof e == "string" ? e.trim().length > 0 : !0;
189
196
  }
190
197
  function U(e) {
191
198
  return "toAnalyticsInput" in e ? e.toAnalyticsInput() : "kind" in e && "isActive" in e ? e : {
192
199
  ...e,
193
200
  kind: "filter",
194
- isActive: E(
201
+ isActive: W(
195
202
  e.value
196
203
  ),
197
204
  value: e.value
@@ -211,13 +218,23 @@ function a(e, t) {
211
218
  };
212
219
  }
213
220
  function g(e) {
214
- return (e || []).map(N);
221
+ return (e || []).map(E);
215
222
  }
216
223
  function V(e) {
217
224
  if (e)
218
225
  return e;
219
226
  }
220
- function W(e, t = {}) {
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 = {}) {
221
238
  const r = t.pathPrefix || "analysisOptions";
222
239
  if (e === void 0)
223
240
  return { ok: !0 };
@@ -244,7 +261,7 @@ function W(e, t = {}) {
244
261
  i.chartType = o.chartType;
245
262
  }
246
263
  if (o.driverMode !== void 0) {
247
- if (!Q(o.driverMode))
264
+ if (!L(o.driverMode))
248
265
  return s(
249
266
  `${r}.driverMode`,
250
267
  'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.'
@@ -260,7 +277,7 @@ function W(e, t = {}) {
260
277
  i.includePopulation = o.includePopulation;
261
278
  }
262
279
  if (o.calendarContext !== void 0) {
263
- const n = L(
280
+ const n = Y(
264
281
  o.calendarContext,
265
282
  {
266
283
  pathPrefix: `${r}.calendarContext`,
@@ -273,9 +290,9 @@ function W(e, t = {}) {
273
290
  }
274
291
  return { ok: !0, analysisOptions: i };
275
292
  }
276
- function me(e) {
293
+ function ge(e) {
277
294
  const t = e.hooks.map(
278
- (i, n) => K(i, n, {
295
+ (i, n) => J(i, n, {
279
296
  fieldCatalogs: e.fieldCatalogs || [],
280
297
  requireFieldCatalog: !!e.requireFieldCatalog,
281
298
  validateTimezone: e.validateTimezone
@@ -289,12 +306,12 @@ function me(e) {
289
306
  executionResults: o
290
307
  };
291
308
  }
292
- function K(e, t, r) {
309
+ function J(e, t, r) {
293
310
  const o = `hooks.${t}`;
294
311
  try {
295
- const i = X(e), n = ae(e, i), d = C(i), l = [
312
+ const i = Z(e), n = de(e, i), d = x(i), l = [
296
313
  ...d.errors.map(
297
- (h) => y(h, {
314
+ (m) => y(m, {
298
315
  hook: e.hook,
299
316
  hookId: n,
300
317
  pathPrefix: o,
@@ -303,7 +320,7 @@ function K(e, t, r) {
303
320
  })
304
321
  ),
305
322
  ...d.warnings.map(
306
- (h) => y(h, {
323
+ (m) => y(m, {
307
324
  hook: e.hook,
308
325
  hookId: n,
309
326
  pathPrefix: o,
@@ -311,7 +328,7 @@ function K(e, t, r) {
311
328
  intent: i
312
329
  })
313
330
  ),
314
- ...Y({
331
+ ...ee({
315
332
  hookSpec: e,
316
333
  hookId: n,
317
334
  intent: i,
@@ -319,14 +336,14 @@ function K(e, t, r) {
319
336
  fieldCatalogs: r.fieldCatalogs,
320
337
  requireFieldCatalog: r.requireFieldCatalog
321
338
  }),
322
- ...te({
339
+ ...ie({
323
340
  hookSpec: e,
324
341
  hookId: n,
325
342
  intent: i,
326
343
  pathPrefix: o,
327
344
  validateTimezone: r.validateTimezone
328
345
  })
329
- ], c = ne(d, l);
346
+ ], f = se(d, l);
330
347
  return {
331
348
  hook: e.hook,
332
349
  hookId: n,
@@ -334,7 +351,7 @@ function K(e, t, r) {
334
351
  diagnostics: l,
335
352
  executionResult: I({
336
353
  intent: i,
337
- validation: c,
354
+ validation: f,
338
355
  diagnostics: l
339
356
  })
340
357
  };
@@ -346,7 +363,7 @@ function K(e, t, r) {
346
363
  path: o,
347
364
  hook: e.hook,
348
365
  hookId: $(e.spec)
349
- }, d = w([n]);
366
+ }, d = _([n]);
350
367
  return {
351
368
  hook: e.hook,
352
369
  hookId: n.hookId,
@@ -370,24 +387,24 @@ function s(e, t) {
370
387
  ]
371
388
  };
372
389
  }
373
- function Q(e) {
390
+ function L(e) {
374
391
  return e === "absolute_delta" || e === "largest_negative" || e === "largest_positive" || e === "positive_and_negative" || e === "all";
375
392
  }
376
- function J(e) {
393
+ function X(e) {
377
394
  return e.trim().length > 0 && !Number.isNaN(Date.parse(e));
378
395
  }
379
- function L(e, t) {
380
- var c;
396
+ function Y(e, t) {
397
+ var f;
381
398
  if (!e || typeof e != "object" || Array.isArray(e))
382
399
  return s(
383
400
  t.pathPrefix,
384
401
  'Data App analysis option "calendarContext" must be an object.'
385
402
  );
386
- 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" ? ((c = t.validateTimezone) == null ? void 0 : c.call(t, o)) ?? o : null;
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;
387
404
  return l ? typeof i != "number" || !Number.isInteger(i) || i < 0 || i > 6 ? s(
388
405
  `${t.pathPrefix}.weekStart`,
389
406
  'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'
390
- ) : n !== "now" && !(typeof d == "string" && J(d)) ? s(
407
+ ) : n !== "now" && !(typeof d == "string" && X(d)) ? s(
391
408
  `${t.pathPrefix}.anchor`,
392
409
  'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'
393
410
  ) : {
@@ -402,19 +419,19 @@ function L(e, t) {
402
419
  'Data App analysis option "calendarContext.tz" must be a valid timezone string.'
403
420
  );
404
421
  }
405
- function X(e) {
406
- return e.hook === "useSemaphorMetric" ? b(e.spec) : e.hook === "useSemaphorAnalysis" ? F(e.spec) : e.hook === "useSemaphorRecords" ? H(e.spec) : j(e.spec);
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);
407
424
  }
408
- function Y(e) {
425
+ function ee(e) {
409
426
  if (e.fieldCatalogs.length === 0 && !e.requireFieldCatalog)
410
427
  return [];
411
- const t = ie(e.fieldCatalogs, e.intent.source);
428
+ const t = ne(e.fieldCatalogs, e.intent.source);
412
429
  return t ? [
413
- ...Z({
430
+ ...te({
414
431
  ...e,
415
432
  catalog: t
416
433
  }),
417
- ...ee({
434
+ ...re({
418
435
  ...e,
419
436
  catalog: t
420
437
  })
@@ -431,8 +448,8 @@ function Y(e) {
431
448
  }
432
449
  ];
433
450
  }
434
- function Z(e) {
435
- return re(e.intent).flatMap(({ field: t, path: r }) => _(e.catalog, t, e.intent.source) ? [] : [
451
+ function te(e) {
452
+ return oe(e.intent).flatMap(({ field: t, path: r }) => M(e.catalog, t, e.intent.source) ? [] : [
436
453
  {
437
454
  severity: "error",
438
455
  code: "missing_field",
@@ -446,12 +463,12 @@ function Z(e) {
446
463
  }
447
464
  ]);
448
465
  }
449
- function ee(e) {
466
+ function re(e) {
450
467
  return ("inputs" in e.intent ? e.intent.inputs || [] : []).flatMap((r, o) => {
451
468
  if (!r.field)
452
469
  return [];
453
470
  const i = u(r.field, e.intent.source);
454
- return A(i, e.intent.source) ? _(e.catalog, r.field, e.intent.source) ? [] : [
471
+ return A(i, e.intent.source) ? M(e.catalog, r.field, e.intent.source) ? [] : [
455
472
  {
456
473
  severity: "error",
457
474
  code: "missing_field",
@@ -478,10 +495,10 @@ function ee(e) {
478
495
  ];
479
496
  });
480
497
  }
481
- function te(e) {
498
+ function ie(e) {
482
499
  if (e.hookSpec.hook !== "useSemaphorAnalysis")
483
500
  return [];
484
- const t = W(e.hookSpec.spec, {
501
+ const t = Q(e.hookSpec.spec, {
485
502
  pathPrefix: `${e.pathPrefix}.spec`,
486
503
  validateTimezone: e.validateTimezone
487
504
  });
@@ -496,7 +513,7 @@ function te(e) {
496
513
  source: e.intent.source
497
514
  }));
498
515
  }
499
- function re(e) {
516
+ function oe(e) {
500
517
  return e.kind === "metric" ? [
501
518
  ...e.metrics.map((t, r) => ({
502
519
  field: t,
@@ -519,23 +536,27 @@ function re(e) {
519
536
  path: `spec.fields.${r}`
520
537
  })),
521
538
  ...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
522
- ...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : []
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
+ }))
523
544
  ] : e.kind === "inputOptions" ? [{ field: e.field, path: "spec.field" }] : [];
524
545
  }
525
- function ie(e, t) {
526
- return e.find((r) => m(r, t));
546
+ function ne(e, t) {
547
+ return e.find((r) => h(r, t));
527
548
  }
528
- function _(e, t, r) {
549
+ function M(e, t, r) {
529
550
  const o = u(t, r);
530
- if (m(e, o))
551
+ if (h(e, o))
531
552
  return e.fields.find(
532
- (i) => oe(i, t) && m(
553
+ (i) => ae(i, t) && h(
533
554
  e,
534
555
  u(i, e.source)
535
556
  )
536
557
  );
537
558
  }
538
- function m(e, t) {
559
+ function h(e, t) {
539
560
  return [e.source, ...e.sourceAliases || []].some(
540
561
  (r) => A(r, t)
541
562
  );
@@ -543,7 +564,7 @@ function m(e, t) {
543
564
  function u(e, t) {
544
565
  return e.source || t;
545
566
  }
546
- function oe(e, t) {
567
+ function ae(e, t) {
547
568
  return !!(e.name && t.name && e.name === t.name);
548
569
  }
549
570
  function y(e, t) {
@@ -558,8 +579,8 @@ function y(e, t) {
558
579
  source: t.intent.source
559
580
  };
560
581
  }
561
- function ne(e, t) {
562
- const r = w(t);
582
+ function se(e, t) {
583
+ const r = _(t);
563
584
  return {
564
585
  ok: r.ok && e.ok,
565
586
  errors: k([
@@ -576,7 +597,7 @@ function ne(e, t) {
576
597
  ]
577
598
  };
578
599
  }
579
- function w(e) {
600
+ function _(e) {
580
601
  const t = e.filter((o) => o.severity === "error").map(v), r = e.filter((o) => o.severity === "warning").map(v);
581
602
  return {
582
603
  ok: t.length === 0,
@@ -641,7 +662,7 @@ function I(e) {
641
662
  }
642
663
  };
643
664
  }
644
- function ae(e, t) {
665
+ function de(e, t) {
645
666
  return t.id || $(e.spec);
646
667
  }
647
668
  function $(e) {
@@ -651,18 +672,18 @@ function $(e) {
651
672
  return typeof t == "string" && t.trim() ? t : void 0;
652
673
  }
653
674
  export {
654
- le as a,
655
- F as b,
675
+ ce as a,
676
+ T as b,
656
677
  b as c,
657
678
  H as d,
658
- j as e,
659
- ue as f,
660
- N as g,
661
- E as h,
662
- ce as i,
679
+ N as e,
680
+ he as f,
681
+ E as g,
682
+ W as h,
683
+ ue as i,
663
684
  q as j,
664
- W as k,
665
- he as n,
666
- fe as t,
667
- me as v
685
+ Q as k,
686
+ pe as n,
687
+ me as t,
688
+ ge as v
668
689
  };