react-semaphor 0.1.368 → 0.1.370

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 (65) 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-DYL3ArlL.js +1 -0
  34. package/dist/chunks/validation-PPSpYtVf.js +900 -0
  35. package/dist/chunks/validators-CgxWT8UX.js +1 -0
  36. package/dist/chunks/validators-DBNa-eb1.js +1799 -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 +661 -389
  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 +472 -3
  52. package/dist/types/dashboard-assistant.d.ts +469 -3
  53. package/dist/types/dashboard-authoring.d.ts +170 -2
  54. package/dist/types/data-app-builder.d.ts +167 -2
  55. package/dist/types/data-app-sdk-validation.d.ts +576 -25
  56. package/dist/types/data-app-sdk.d.ts +655 -37
  57. package/dist/types/main.d.ts +167 -2
  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
  65. package/dist/chunks/validators-L0xEXtjf.js +0 -965
@@ -1,10 +1,10 @@
1
- import { t as k, a as q, b as C, c as w, d as _, e as T, n as K, f as P, h as E } from "../chunks/validation-CrUjNWby.js";
2
- import { k as Ie, g as Ee, i as xe, j as Re, v as Oe } from "../chunks/validation-CrUjNWby.js";
3
- import { j as $ } from "../chunks/index-CuHybtft.js";
4
- import { createContext as j, useContext as N, useMemo as d, useState as R, useCallback as y, useRef as x, useEffect as U } from "react";
5
- import { jsx as B } from "react/jsx-runtime";
6
- import { v as L } from "../chunks/validators-L0xEXtjf.js";
7
- const z = [
1
+ import { t as y, a as M, b as B, c as Q, d as J, e as Y, f as H, g as W, n as V, h as $, i as I } from "../chunks/validation-PPSpYtVf.js";
2
+ import { m as Le, j as Me, k as Be, l as Qe, v as Je } from "../chunks/validation-PPSpYtVf.js";
3
+ import { j as F } from "../chunks/index-CuHybtft.js";
4
+ import { createContext as X, useContext as G, useMemo as m, useState as O, useCallback as R, useEffect as N, useRef as j } from "react";
5
+ import { jsx as Z } from "react/jsx-runtime";
6
+ import { v as ee } from "../chunks/validators-DBNa-eb1.js";
7
+ const te = [
8
8
  "records",
9
9
  "changes",
10
10
  "drivers",
@@ -12,7 +12,7 @@ const z = [
12
12
  "largestPositiveChanges",
13
13
  "largestNegativeDrivers",
14
14
  "largestPositiveDrivers"
15
- ], M = [
15
+ ], re = [
16
16
  "records",
17
17
  "changes",
18
18
  "drivers",
@@ -21,542 +21,814 @@ const z = [
21
21
  "largestNegativeDrivers",
22
22
  "largestPositiveDrivers"
23
23
  ];
24
- function O(t) {
25
- var r, s;
26
- if (!t)
24
+ function U(e) {
25
+ if (!e)
27
26
  return {};
28
- const e = H(t.executionResult), n = V(t, e), o = J(n);
27
+ const t = se(e.executionResult), n = ne(e, t), r = ie(n);
29
28
  return {
30
- ...t,
29
+ ...e,
31
30
  ...Object.keys(n).length ? { resultSets: n } : {},
32
- ...o && !((r = t.columns) != null && r.length) ? { columns: o.columns } : {},
33
- ...o && !((s = t.records) != null && s.length) ? { records: o.records } : {},
34
- ...o && t.rowCount === void 0 ? { rowCount: o.rowCount } : {}
31
+ ...r ? {
32
+ columns: r.columns,
33
+ records: r.records,
34
+ rowCount: r.rowCount
35
+ } : {}
35
36
  };
36
37
  }
37
- function V(t, e) {
38
- const n = {
39
- ...t.resultSets || {}
40
- };
41
- for (const r of z) {
42
- if (n[r]) {
43
- n[r] = Q(n[r]);
38
+ function ne(e, t) {
39
+ const n = oe(e.resultSets);
40
+ for (const i of te) {
41
+ if (n[i]) {
42
+ n[i] = z(n[i]);
44
43
  continue;
45
44
  }
46
- const s = W(t[r]);
47
- if (!s.length)
45
+ const u = ae(e[i]);
46
+ if (!u.length)
48
47
  continue;
49
- const a = e.length ? e : F(s);
50
- n[r] = {
51
- records: I(s, a),
52
- columns: a,
53
- rowCount: s.length
48
+ const s = t.length ? t : ce(u);
49
+ n[i] = {
50
+ records: b(u, s),
51
+ columns: s,
52
+ rowCount: u.length
54
53
  };
55
54
  }
56
- const o = Y(t.executionResult);
57
- return o && o.records.length > 0 && !n.records && (n.records = o), n;
55
+ const r = ue(e.executionResult);
56
+ return r && r.records.length > 0 && !n.records && (n.records = r), n;
57
+ }
58
+ function oe(e) {
59
+ return Object.fromEntries(
60
+ Object.entries(e || {}).map(([t, n]) => [
61
+ t,
62
+ z(n)
63
+ ])
64
+ );
58
65
  }
59
- function Q(t) {
60
- var e;
66
+ function z(e) {
67
+ var t;
61
68
  return {
62
- ...t,
63
- records: I(
64
- t.records || [],
65
- t.columns || []
69
+ ...e,
70
+ records: b(
71
+ e.records || [],
72
+ e.columns || []
66
73
  ),
67
- rowCount: t.rowCount ?? ((e = t.records) == null ? void 0 : e.length) ?? 0
74
+ rowCount: e.rowCount ?? ((t = e.records) == null ? void 0 : t.length) ?? 0
68
75
  };
69
76
  }
70
- function J(t) {
71
- var e;
72
- for (const n of M)
73
- if ((e = t[n]) != null && e.records.length)
74
- return t[n];
75
- return Object.values(t).find((n) => n.records.length) || Object.values(t)[0];
77
+ function ie(e) {
78
+ var t;
79
+ for (const n of re)
80
+ if ((t = e[n]) != null && t.records.length)
81
+ return e[n];
82
+ return Object.values(e).find((n) => n.records.length) || Object.values(e)[0];
76
83
  }
77
- function Y(t) {
78
- const e = t == null ? void 0 : t.result;
79
- if (!(!e || e.kind !== "records" && e.kind !== "sql"))
84
+ function ue(e) {
85
+ const t = e == null ? void 0 : e.result;
86
+ if (!(!t || t.kind !== "records" && t.kind !== "sql"))
80
87
  return {
81
- records: I(e.records, e.columns),
82
- columns: e.columns,
83
- rowCount: e.rowCount ?? e.records.length
88
+ records: b(t.records, t.columns),
89
+ columns: t.columns,
90
+ rowCount: t.rowCount ?? t.records.length
84
91
  };
85
92
  }
86
- function H(t) {
87
- const e = t == null ? void 0 : t.result;
88
- return !e || e.kind !== "records" && e.kind !== "sql" ? [] : e.columns;
93
+ function se(e) {
94
+ const t = e == null ? void 0 : e.result;
95
+ return !t || t.kind !== "records" && t.kind !== "sql" ? [] : t.columns;
89
96
  }
90
- function W(t) {
91
- return Array.isArray(t) ? t.filter(
92
- (e) => !!(e && typeof e == "object" && !Array.isArray(e))
97
+ function ae(e) {
98
+ return Array.isArray(e) ? e.filter(
99
+ (t) => !!(t && typeof t == "object" && !Array.isArray(t))
93
100
  ) : [];
94
101
  }
95
- function I(t, e) {
96
- return e.length ? t.map((n) => {
97
- const o = {};
98
- return e.forEach((r, s) => {
99
- const a = G(n, {
100
- name: r.key,
101
- label: r.label,
102
- fallbackNames: [r.name, Object.keys(n)[s]]
102
+ function b(e, t) {
103
+ return t.length ? e.map((n) => {
104
+ const r = {};
105
+ return t.forEach((i, u) => {
106
+ const s = le(n, {
107
+ name: i.key,
108
+ label: i.label,
109
+ fallbackNames: [i.name, Object.keys(n)[u]]
103
110
  });
104
- a !== void 0 && (o[r.key] = a);
105
- }), Object.keys(o).length ? o : n;
106
- }) : t;
111
+ s !== void 0 && (r[i.key] = s);
112
+ }), Object.keys(r).length ? r : n;
113
+ }) : e;
107
114
  }
108
- function F(t) {
115
+ function ce(e) {
109
116
  return Array.from(
110
- new Set(t.flatMap((n) => Object.keys(n)))
117
+ new Set(e.flatMap((n) => Object.keys(n)))
111
118
  ).map((n) => ({
112
119
  key: n,
113
120
  name: n,
114
121
  label: n
115
122
  }));
116
123
  }
117
- function G(t, e) {
124
+ function le(e, t) {
118
125
  const n = [
119
- e.name,
120
- e.label,
121
- ...e.fallbackNames || []
122
- ].filter((o) => !!o);
123
- for (const o of n)
124
- if (Object.prototype.hasOwnProperty.call(t, o))
125
- return t[o];
126
- }
127
- function X() {
126
+ t.name,
127
+ t.label,
128
+ ...t.fallbackNames || []
129
+ ].filter((r) => !!r);
130
+ for (const r of n)
131
+ if (Object.prototype.hasOwnProperty.call(e, r))
132
+ return e[r];
133
+ }
134
+ function _e(e) {
135
+ return e;
136
+ }
137
+ function Te(e) {
138
+ return e;
139
+ }
140
+ const Pe = {
141
+ filter(e) {
142
+ return {
143
+ ...e,
144
+ kind: "filter"
145
+ };
146
+ },
147
+ control(e) {
148
+ return {
149
+ ...e,
150
+ kind: "control"
151
+ };
152
+ },
153
+ sqlParam(e) {
154
+ return {
155
+ ...e,
156
+ kind: "control",
157
+ role: "sqlParam"
158
+ };
159
+ },
160
+ metric(e) {
161
+ return {
162
+ ...e,
163
+ queryKind: "metric"
164
+ };
165
+ },
166
+ analysis(e) {
167
+ return {
168
+ ...e,
169
+ queryKind: "analysis"
170
+ };
171
+ },
172
+ records(e) {
173
+ return {
174
+ ...e,
175
+ queryKind: "records"
176
+ };
177
+ },
178
+ inputOptions(e) {
179
+ return {
180
+ ...e,
181
+ queryKind: "inputOptions"
182
+ };
183
+ },
184
+ sql(e) {
185
+ return {
186
+ ...e,
187
+ queryKind: "sql"
188
+ };
189
+ },
190
+ matrix(e) {
191
+ return {
192
+ ...e,
193
+ queryKind: "matrix"
194
+ };
195
+ }
196
+ };
197
+ function de() {
128
198
  return {
129
- executeAnalysis: (t, e, n) => h(
130
- t,
199
+ executeAnalysis: (e, t, n) => h(
131
200
  e,
201
+ t,
132
202
  n ?? {}
133
- ).then(O),
134
- executeMetric: (t, e) => h(t, e),
135
- executeRecords: (t, e) => h(t, e),
136
- executeInputOptions: (t, e) => h(t, e)
203
+ ).then(U),
204
+ executeMetric: (e, t) => h(e, t),
205
+ executeRecords: (e, t) => h(e, t),
206
+ executeInputOptions: (e, t) => h(e, t),
207
+ executeSql: (e, t) => h(e, t),
208
+ executeMatrix: (e, t) => h(e, t)
137
209
  };
138
210
  }
139
- async function h(t, e, n) {
140
- if (!e.token)
141
- throw new Error("SemaphorDataAppProvider needs a token to execute queries.");
142
- const o = await fetch(te(e), {
211
+ async function h(e, t, n) {
212
+ if (!t.token)
213
+ throw new Error(
214
+ "SemaphorDataAppProvider needs a token to execute queries."
215
+ );
216
+ const r = await fetch(me(t), {
143
217
  method: "POST",
144
218
  headers: {
145
219
  "Content-Type": "application/json",
146
- Authorization: `Bearer ${e.token}`
220
+ Authorization: `Bearer ${t.token}`
147
221
  },
148
222
  body: JSON.stringify({
149
- intent: t,
150
- activeInputs: e.activeInputs,
223
+ intent: e,
224
+ activeInputs: t.activeInputs,
151
225
  ...n ? { analysisOptions: n } : {},
152
- resultShape: t.kind
226
+ resultShape: e.kind
153
227
  })
154
- }), r = await Z(o);
155
- if (!o.ok || r.error)
228
+ }), i = await fe(r);
229
+ if (!r.ok || i.error)
156
230
  throw new Error(
157
- r.error || `Semaphor Data App execution failed with status ${o.status}.`
231
+ i.error || `Semaphor Data App execution failed with status ${r.status}.`
158
232
  );
159
- return r;
233
+ return i;
160
234
  }
161
- async function Z(t) {
162
- const e = await t.text().catch(() => "");
163
- if (!e.trim())
164
- return t.ok ? {
235
+ async function fe(e) {
236
+ const t = await e.text().catch(() => "");
237
+ if (!t.trim())
238
+ return e.ok ? {
165
239
  error: "Semaphor Data App execution returned an empty response."
166
240
  } : {};
167
241
  try {
168
- return JSON.parse(e);
242
+ return JSON.parse(t);
169
243
  } catch {
170
- return t.ok ? {
244
+ return e.ok ? {
171
245
  error: "Semaphor Data App execution returned invalid JSON.",
172
- details: e
246
+ details: t
173
247
  } : {
174
- error: ee(t, e),
175
- details: e
248
+ error: pe(e, t),
249
+ details: t
176
250
  };
177
251
  }
178
252
  }
179
- function ee(t, e) {
180
- const n = t.statusText ? ` ${t.statusText}` : "", o = e.replace(/\s+/g, " ").trim();
181
- return o ? `Semaphor Data App execution failed with status ${t.status}${n}: ${o.slice(0, 240)}` : `Semaphor Data App execution failed with status ${t.status}${n}.`;
253
+ function pe(e, t) {
254
+ const n = e.statusText ? ` ${e.statusText}` : "", r = t.replace(/\s+/g, " ").trim();
255
+ return r ? `Semaphor Data App execution failed with status ${e.status}${n}: ${r.slice(0, 240)}` : `Semaphor Data App execution failed with status ${e.status}${n}.`;
182
256
  }
183
- function te(t) {
184
- const e = re(t).replace(/\/+$/, "");
185
- return e ? e.endsWith("/api") ? `${e}/v1/data-app/execute` : `${e}/api/v1/data-app/execute` : "/api/v1/data-app/execute";
257
+ function me(e) {
258
+ const t = he(e).replace(/\/+$/, "");
259
+ return t ? t.endsWith("/api") ? `${t}/v1/data-app/execute` : `${t}/api/v1/data-app/execute` : "/api/v1/data-app/execute";
186
260
  }
187
- function re(t) {
188
- if (t.apiBaseUrl)
189
- return t.apiBaseUrl;
190
- if (!t.token)
261
+ function he(e) {
262
+ if (e.apiBaseUrl)
263
+ return e.apiBaseUrl;
264
+ if (!e.token)
191
265
  return "";
192
266
  try {
193
- return $(t.token).apiServiceUrl || "";
267
+ return F(e.token).apiServiceUrl || "";
194
268
  } catch {
195
269
  return "";
196
270
  }
197
271
  }
198
- const b = j({});
199
- function ne() {
272
+ const L = X({});
273
+ function ve() {
200
274
  if (!(typeof window > "u"))
201
275
  return window.__SEMAPHOR_DATA_APP_RUNTIME__;
202
276
  }
203
- function oe() {
204
- return N(b);
277
+ function ye() {
278
+ return G(L);
205
279
  }
206
- function me({
207
- token: t,
208
- apiBaseUrl: e,
280
+ function je({
281
+ token: e,
282
+ apiBaseUrl: t,
209
283
  executor: n,
210
- children: o
284
+ children: r
211
285
  }) {
212
- var l;
213
- const r = ne(), s = ((l = r == null ? void 0 : r.authToken) == null ? void 0 : l.accessToken) || t, a = (r == null ? void 0 : r.dataApiBaseUrl) || (r == null ? void 0 : r.apiBaseUrl) || e, c = d(() => X(), []), i = n || c, p = d(
286
+ var o;
287
+ const i = ve(), u = ((o = i == null ? void 0 : i.authToken) == null ? void 0 : o.accessToken) || e, s = (i == null ? void 0 : i.dataApiBaseUrl) || (i == null ? void 0 : i.apiBaseUrl) || t, f = m(() => de(), []), a = n || f, c = m(
214
288
  () => ({
215
- token: s,
216
- apiBaseUrl: a,
217
- executor: i
289
+ token: u,
290
+ apiBaseUrl: s,
291
+ executor: a
218
292
  }),
219
- [a, i, s]
293
+ [s, a, u]
220
294
  );
221
- return /* @__PURE__ */ B(b.Provider, { value: p, children: o });
295
+ return /* @__PURE__ */ Z(L.Provider, { value: c, children: r });
222
296
  }
223
- const A = { value: null }, g = {}, se = { records: [] }, D = { options: [] };
224
- function ae(t) {
225
- const e = k(t.inputs), n = q(t);
297
+ const k = { value: null }, D = {}, qe = { records: [] }, x = { options: [] }, Se = { records: [] }, E = {};
298
+ function Ae(e) {
299
+ const t = y(e.inputs), n = Y(e);
226
300
  try {
227
- const o = C(t), r = v(o);
228
- return r ? {
229
- error: r,
230
- activeInputs: e,
301
+ const r = H(e), i = v(r);
302
+ return i ? {
303
+ error: i,
304
+ activeInputs: t,
231
305
  analysisOptions: n,
232
- queryKey: u(void 0, e, r, n),
233
- idleData: g
306
+ queryKey: d(
307
+ void 0,
308
+ t,
309
+ i,
310
+ n
311
+ ),
312
+ idleData: D
234
313
  } : {
235
- intent: o,
314
+ intent: r,
236
315
  error: null,
237
- activeInputs: e,
316
+ activeInputs: t,
238
317
  analysisOptions: n,
239
- queryKey: u(o, e, void 0, n),
240
- idleData: g
318
+ queryKey: d(r, t, void 0, n),
319
+ idleData: D
241
320
  };
242
- } catch (o) {
243
- const r = m(o);
321
+ } catch (r) {
322
+ const i = p(r);
244
323
  return {
245
- error: r,
246
- activeInputs: e,
324
+ error: i,
325
+ activeInputs: t,
247
326
  analysisOptions: n,
248
- queryKey: u(void 0, e, r, n),
249
- idleData: g
327
+ queryKey: d(
328
+ void 0,
329
+ t,
330
+ i,
331
+ n
332
+ ),
333
+ idleData: D
250
334
  };
251
335
  }
252
336
  }
253
- function ie(t) {
254
- const e = k(t.inputs);
337
+ function ge(e) {
338
+ const t = y(e.inputs);
255
339
  try {
256
- const n = w(t), o = v(n);
257
- return o ? {
258
- error: o,
259
- activeInputs: e,
260
- queryKey: u(void 0, e, o),
261
- idleData: A
340
+ const n = W(e), r = v(n);
341
+ return r ? {
342
+ error: r,
343
+ activeInputs: t,
344
+ queryKey: d(void 0, t, r),
345
+ idleData: k
262
346
  } : {
263
347
  intent: n,
264
348
  error: null,
265
- activeInputs: e,
266
- queryKey: u(n, e),
267
- idleData: A
349
+ activeInputs: t,
350
+ queryKey: d(n, t),
351
+ idleData: k
268
352
  };
269
353
  } catch (n) {
270
- const o = m(n);
354
+ const r = p(n);
271
355
  return {
272
- error: o,
273
- activeInputs: e,
274
- queryKey: u(void 0, e, o),
275
- idleData: A
356
+ error: r,
357
+ activeInputs: t,
358
+ queryKey: d(void 0, t, r),
359
+ idleData: k
276
360
  };
277
361
  }
278
362
  }
279
- function ue(t) {
280
- const e = k(t.inputs), n = se;
363
+ function Ie(e) {
364
+ const t = y(e.inputs), n = qe;
281
365
  try {
282
- const o = _(t), r = v(o);
283
- return r ? {
284
- error: r,
285
- activeInputs: e,
286
- queryKey: u(void 0, e, r),
366
+ const r = J(e), i = v(r);
367
+ return i ? {
368
+ error: i,
369
+ activeInputs: t,
370
+ queryKey: d(void 0, t, i),
287
371
  idleData: n
288
372
  } : {
289
- intent: o,
373
+ intent: r,
290
374
  error: null,
291
- activeInputs: e,
292
- queryKey: u(o, e),
375
+ activeInputs: t,
376
+ queryKey: d(r, t),
293
377
  idleData: n
294
378
  };
295
- } catch (o) {
296
- const r = m(o);
379
+ } catch (r) {
380
+ const i = p(r);
297
381
  return {
298
- error: r,
299
- activeInputs: e,
300
- queryKey: u(void 0, e, r),
382
+ error: i,
383
+ activeInputs: t,
384
+ queryKey: d(void 0, t, i),
301
385
  idleData: n
302
386
  };
303
387
  }
304
388
  }
305
- function ce(t) {
389
+ function ke(e) {
306
390
  try {
307
- const e = T(t), n = v(e);
391
+ const t = Q(e), n = v(t);
308
392
  return n ? {
309
393
  error: n,
310
- queryKey: u(void 0, void 0, n),
311
- idleData: D
394
+ queryKey: d(void 0, void 0, n),
395
+ idleData: x
312
396
  } : {
313
- intent: e,
397
+ intent: t,
314
398
  error: null,
315
- queryKey: u(e),
316
- idleData: D
399
+ queryKey: d(t),
400
+ idleData: x
317
401
  };
318
- } catch (e) {
319
- const n = m(e);
402
+ } catch (t) {
403
+ const n = p(t);
320
404
  return {
321
405
  error: n,
322
- queryKey: u(void 0, void 0, n),
323
- idleData: D
406
+ queryKey: d(void 0, void 0, n),
407
+ idleData: x
324
408
  };
325
409
  }
326
410
  }
327
- function m(t) {
328
- return t instanceof Error ? t : new Error(String(t));
411
+ function De(e) {
412
+ const t = y(e.inputs), n = Se;
413
+ try {
414
+ const r = B(e), i = v(r);
415
+ return i ? {
416
+ error: i,
417
+ activeInputs: t,
418
+ queryKey: d(void 0, t, i),
419
+ idleData: n
420
+ } : {
421
+ intent: r,
422
+ error: null,
423
+ activeInputs: t,
424
+ queryKey: d(r, t),
425
+ idleData: n
426
+ };
427
+ } catch (r) {
428
+ const i = p(r);
429
+ return {
430
+ error: i,
431
+ activeInputs: t,
432
+ queryKey: d(void 0, t, i),
433
+ idleData: n
434
+ };
435
+ }
436
+ }
437
+ function xe(e) {
438
+ const t = y(e.inputs);
439
+ try {
440
+ const n = M(e), r = v(n);
441
+ return r ? {
442
+ error: r,
443
+ activeInputs: t,
444
+ queryKey: d(void 0, t, r),
445
+ idleData: E
446
+ } : {
447
+ intent: n,
448
+ error: null,
449
+ activeInputs: t,
450
+ queryKey: d(n, t),
451
+ idleData: E
452
+ };
453
+ } catch (n) {
454
+ const r = p(n);
455
+ return {
456
+ error: r,
457
+ activeInputs: t,
458
+ queryKey: d(void 0, t, r),
459
+ idleData: E
460
+ };
461
+ }
329
462
  }
330
- function v(t) {
331
- const e = L(t);
332
- if (e.ok)
463
+ function p(e) {
464
+ return e instanceof Error ? e : new Error(String(e));
465
+ }
466
+ function v(e) {
467
+ const t = ee(e);
468
+ if (t.ok)
333
469
  return null;
334
- const n = e.errors.map(
335
- (o) => o.path ? `${o.code} at ${o.path}: ${o.message}` : `${o.code}: ${o.message}`
470
+ const n = t.errors.map(
471
+ (r) => r.path ? `${r.code} at ${r.path}: ${r.message}` : `${r.code}: ${r.message}`
336
472
  ).join("; ");
337
473
  return new Error(`Invalid Semaphor analytics intent. ${n}`);
338
474
  }
339
- function u(t, e, n, o) {
475
+ function d(e, t, n, r) {
340
476
  return JSON.stringify({
341
- intent: t,
342
- activeInputs: e,
343
- analysisOptions: o,
477
+ intent: e,
478
+ activeInputs: t,
479
+ analysisOptions: r,
344
480
  error: n == null ? void 0 : n.message
345
481
  });
346
482
  }
347
- function he(t) {
348
- const [e, n] = R(t.defaultValue), o = Object.prototype.hasOwnProperty.call(t, "value"), r = o ? t.value : e, s = d(
349
- () => K(t.options),
350
- [t.options]
351
- ), a = y(
352
- (i) => {
353
- var l;
354
- const p = i;
355
- (l = t.onValueChange) == null || l.call(t, p), o || n(p);
483
+ function Ve(e) {
484
+ const [t, n] = O(e.defaultValue), r = Object.prototype.hasOwnProperty.call(e, "value"), i = r ? e.value : t, u = m(
485
+ () => V(e.options),
486
+ [e.options]
487
+ ), s = R(
488
+ (a) => {
489
+ var o;
490
+ const c = a;
491
+ (o = e.onValueChange) == null || o.call(e, c), r || n(c);
356
492
  },
357
- [o, t]
358
- ), c = y(() => a(void 0), [a]);
359
- return d(() => {
360
- const i = P(t);
493
+ [r, e]
494
+ ), f = R(() => s(void 0), [s]);
495
+ return m(() => {
496
+ const a = $(e);
361
497
  return {
362
- id: t.id,
363
- kind: t.kind,
364
- label: t.label,
365
- field: i.field,
366
- operator: i.operator,
367
- controlRole: t.kind === "control" ? t.role : void 0,
368
- value: r,
369
- options: s,
370
- isActive: E(r),
371
- setValue: a,
372
- clear: c,
498
+ id: e.id,
499
+ kind: e.kind,
500
+ label: e.label,
501
+ field: a.field,
502
+ operator: a.operator,
503
+ controlRole: e.kind === "control" ? e.role : void 0,
504
+ value: i,
505
+ options: u,
506
+ isActive: I(i),
507
+ setValue: s,
508
+ clear: f,
373
509
  toAnalyticsInput: () => ({
374
- inputId: i.inputId,
375
- field: i.field,
376
- kind: t.kind,
377
- label: t.label,
378
- value: r,
379
- isActive: E(r),
380
- operator: i.operator,
381
- controlRole: t.kind === "control" ? t.role : void 0
510
+ inputId: a.inputId,
511
+ field: a.field,
512
+ kind: e.kind,
513
+ label: e.label,
514
+ value: i,
515
+ isActive: I(i),
516
+ operator: a.operator,
517
+ controlRole: e.kind === "control" ? e.role : void 0
382
518
  })
383
519
  };
384
- }, [c, s, a, t, r]);
385
- }
386
- function ve(t) {
387
- const e = d(() => ae(t), [t]), n = y(
388
- (s) => {
389
- var a, c;
390
- return e.intent ? (c = (a = s.executor) == null ? void 0 : a.executeAnalysis) == null ? void 0 : c.call(
391
- a,
392
- e.intent,
393
- s,
394
- e.analysisOptions
395
- ) : void 0;
396
- },
397
- [e.analysisOptions, e.intent]
398
- ), o = S(
399
- e.queryKey,
400
- n,
401
- e.idleData,
402
- e.activeInputs
403
- ), r = d(
404
- () => O(
405
- e.error ? e.idleData : o.data
406
- ),
407
- [e.error, e.idleData, o.data]
520
+ }, [f, u, s, e, i]);
521
+ }
522
+ function $e(e) {
523
+ const [t, n] = O(() => Ke(e));
524
+ return N(() => {
525
+ n((r) => {
526
+ let i = r;
527
+ for (const u of e)
528
+ !Object.prototype.hasOwnProperty.call(i, u.id) && u.defaultValue !== void 0 && (i = { ...i, [u.id]: u.defaultValue });
529
+ return i;
530
+ });
531
+ }, [e]), m(
532
+ () => e.map((r) => {
533
+ const i = Object.prototype.hasOwnProperty.call(
534
+ r,
535
+ "value"
536
+ ), u = i ? r.value : t[r.id], s = V(r.options), f = (o) => {
537
+ var l;
538
+ (l = r.onValueChange) == null || l.call(r, o), i || n((q) => ({
539
+ ...q,
540
+ [r.id]: o
541
+ }));
542
+ }, a = () => f(void 0), c = $(r);
543
+ return {
544
+ id: r.id,
545
+ kind: r.kind,
546
+ label: r.label,
547
+ field: c.field,
548
+ operator: c.operator,
549
+ controlRole: r.kind === "control" ? r.role : void 0,
550
+ value: u,
551
+ options: s,
552
+ isActive: I(u),
553
+ setValue: f,
554
+ clear: a,
555
+ toAnalyticsInput: () => ({
556
+ inputId: c.inputId,
557
+ field: c.field,
558
+ kind: r.kind,
559
+ label: r.label,
560
+ value: u,
561
+ isActive: I(u),
562
+ operator: c.operator,
563
+ controlRole: r.kind === "control" ? r.role : void 0
564
+ })
565
+ };
566
+ }),
567
+ [e, t]
408
568
  );
409
- return {
410
- id: t.id,
411
- intent: e.intent,
412
- ...r || {},
413
- status: e.error ? "error" : o.status,
414
- isLoading: !e.error && o.status === "loading",
415
- error: e.error || o.error
416
- };
417
569
  }
418
- function Se(t) {
419
- const e = d(() => ie(t), [t]), n = y(
420
- (s) => {
421
- var a;
422
- return e.intent ? (a = s.executor) == null ? void 0 : a.executeMetric(e.intent, s) : void 0;
423
- },
424
- [e.intent]
425
- ), o = S(
426
- e.queryKey,
427
- n,
428
- e.idleData,
429
- e.activeInputs
430
- ), r = e.error ? e.idleData : o.data;
431
- return {
432
- id: t.id,
433
- intent: e.intent,
434
- value: (r == null ? void 0 : r.value) ?? null,
435
- metrics: r == null ? void 0 : r.metrics,
436
- comparisonValue: r == null ? void 0 : r.comparisonValue,
437
- delta: r == null ? void 0 : r.delta,
438
- deltaPercent: r == null ? void 0 : r.deltaPercent,
439
- records: r == null ? void 0 : r.records,
440
- executionResult: r == null ? void 0 : r.executionResult,
441
- status: e.error ? "error" : o.status,
442
- isLoading: !e.error && o.status === "loading",
443
- error: e.error || o.error
444
- };
445
- }
446
- function Ae(t) {
447
- const e = d(() => ue(t), [t]), n = y(
448
- (s) => {
449
- var a;
450
- return e.intent ? (a = s.executor) == null ? void 0 : a.executeRecords(e.intent, s) : void 0;
451
- },
452
- [e.intent]
453
- ), o = S(
454
- e.queryKey,
455
- n,
456
- e.idleData,
457
- e.activeInputs
458
- ), r = e.error ? e.idleData : o.data;
459
- return {
460
- id: t.id,
461
- intent: e.intent,
462
- records: (r == null ? void 0 : r.records) || [],
463
- columns: r == null ? void 0 : r.columns,
464
- rowCount: r == null ? void 0 : r.rowCount,
465
- executionResult: r == null ? void 0 : r.executionResult,
466
- status: e.error ? "error" : o.status,
467
- isLoading: !e.error && o.status === "loading",
468
- error: e.error || o.error
469
- };
470
- }
471
- function ge(t) {
472
- const e = d(() => ce(t), [t]), n = y(
473
- (s) => {
474
- var a;
475
- return e.intent ? (a = s.executor) == null ? void 0 : a.executeInputOptions(e.intent, s) : void 0;
570
+ function Ne(e, t = {}) {
571
+ const n = m(
572
+ () => t.inputs ? {
573
+ ...e,
574
+ inputs: t.inputs
575
+ } : e,
576
+ [t.inputs, e]
577
+ ), r = m(() => {
578
+ switch (n.queryKind) {
579
+ case "metric":
580
+ return {
581
+ queryKind: n.queryKind,
582
+ request: ge(n)
583
+ };
584
+ case "analysis":
585
+ return {
586
+ queryKind: n.queryKind,
587
+ request: Ae(n)
588
+ };
589
+ case "records":
590
+ return {
591
+ queryKind: n.queryKind,
592
+ request: Ie(n)
593
+ };
594
+ case "inputOptions":
595
+ return {
596
+ queryKind: n.queryKind,
597
+ request: ke(n)
598
+ };
599
+ case "sql":
600
+ return {
601
+ queryKind: n.queryKind,
602
+ request: De(n)
603
+ };
604
+ case "matrix":
605
+ return {
606
+ queryKind: n.queryKind,
607
+ request: xe(n)
608
+ };
609
+ default:
610
+ return K(n);
611
+ }
612
+ }, [n]), i = R(
613
+ (o) => {
614
+ var q, S, w, C, _, A, T, g, P;
615
+ const l = r.request;
616
+ if (l.intent)
617
+ switch (r.queryKind) {
618
+ case "metric":
619
+ return (q = o.executor) == null ? void 0 : q.executeMetric(
620
+ l.intent,
621
+ o
622
+ );
623
+ case "analysis":
624
+ return (w = (S = o.executor) == null ? void 0 : S.executeAnalysis) == null ? void 0 : w.call(
625
+ S,
626
+ l.intent,
627
+ o,
628
+ l.analysisOptions
629
+ );
630
+ case "records":
631
+ return (C = o.executor) == null ? void 0 : C.executeRecords(
632
+ l.intent,
633
+ o
634
+ );
635
+ case "inputOptions":
636
+ return (_ = o.executor) == null ? void 0 : _.executeInputOptions(
637
+ l.intent,
638
+ o
639
+ );
640
+ case "sql":
641
+ return (T = (A = o.executor) == null ? void 0 : A.executeSql) == null ? void 0 : T.call(
642
+ A,
643
+ l.intent,
644
+ o
645
+ );
646
+ case "matrix":
647
+ return (P = (g = o.executor) == null ? void 0 : g.executeMatrix) == null ? void 0 : P.call(
648
+ g,
649
+ l.intent,
650
+ o
651
+ );
652
+ default:
653
+ return K(r);
654
+ }
476
655
  },
477
- [e.intent]
478
- ), o = S(
479
- e.queryKey,
480
- n,
481
- e.idleData
482
- ), r = e.error ? e.idleData : o.data;
483
- return {
484
- id: t.id,
485
- intent: e.intent,
486
- options: (r == null ? void 0 : r.options) || [],
487
- executionResult: r == null ? void 0 : r.executionResult,
488
- status: e.error ? "error" : o.status,
489
- isLoading: !e.error && o.status === "loading",
490
- error: e.error || o.error
491
- };
656
+ [r]
657
+ ), u = Ee(
658
+ r.request.queryKey,
659
+ i,
660
+ r.request.idleData,
661
+ r.request.activeInputs
662
+ ), s = r.request.error ? r.request.idleData : u.data, f = r.request.error ? "error" : u.status, a = !r.request.error && u.status === "loading", c = r.request.error || u.error;
663
+ switch (r.queryKind) {
664
+ case "metric": {
665
+ const o = s;
666
+ return {
667
+ id: n.id,
668
+ intent: r.request.intent,
669
+ value: (o == null ? void 0 : o.value) ?? null,
670
+ metrics: o == null ? void 0 : o.metrics,
671
+ comparisonValue: o == null ? void 0 : o.comparisonValue,
672
+ delta: o == null ? void 0 : o.delta,
673
+ deltaPercent: o == null ? void 0 : o.deltaPercent,
674
+ records: o == null ? void 0 : o.records,
675
+ executionResult: o == null ? void 0 : o.executionResult,
676
+ status: f,
677
+ isLoading: a,
678
+ error: c
679
+ };
680
+ }
681
+ case "analysis": {
682
+ const o = U(s);
683
+ return {
684
+ id: n.id,
685
+ intent: r.request.intent,
686
+ ...o || {},
687
+ status: f,
688
+ isLoading: a,
689
+ error: c
690
+ };
691
+ }
692
+ case "records": {
693
+ const o = s;
694
+ return {
695
+ id: n.id,
696
+ intent: r.request.intent,
697
+ records: (o == null ? void 0 : o.records) || [],
698
+ columns: o == null ? void 0 : o.columns,
699
+ rowCount: o == null ? void 0 : o.rowCount,
700
+ pagination: o == null ? void 0 : o.pagination,
701
+ executionResult: o == null ? void 0 : o.executionResult,
702
+ status: f,
703
+ isLoading: a,
704
+ error: c
705
+ };
706
+ }
707
+ case "inputOptions": {
708
+ const o = s;
709
+ return {
710
+ id: n.id,
711
+ intent: r.request.intent,
712
+ options: (o == null ? void 0 : o.options) || [],
713
+ executionResult: o == null ? void 0 : o.executionResult,
714
+ status: f,
715
+ isLoading: a,
716
+ error: c
717
+ };
718
+ }
719
+ case "sql": {
720
+ const o = s;
721
+ return {
722
+ id: n.id,
723
+ intent: r.request.intent,
724
+ records: (o == null ? void 0 : o.records) || [],
725
+ columns: o == null ? void 0 : o.columns,
726
+ rowCount: o == null ? void 0 : o.rowCount,
727
+ pagination: o == null ? void 0 : o.pagination,
728
+ output: o == null ? void 0 : o.output,
729
+ rowLimitExceeded: o == null ? void 0 : o.rowLimitExceeded,
730
+ executionResult: o == null ? void 0 : o.executionResult,
731
+ status: f,
732
+ isLoading: a,
733
+ error: c
734
+ };
735
+ }
736
+ case "matrix": {
737
+ const o = s;
738
+ return {
739
+ id: n.id,
740
+ intent: r.request.intent,
741
+ payload: o == null ? void 0 : o.payload,
742
+ grid: o == null ? void 0 : o.grid,
743
+ expansion: o == null ? void 0 : o.expansion,
744
+ executionResult: o == null ? void 0 : o.executionResult,
745
+ status: f,
746
+ isLoading: a,
747
+ error: c
748
+ };
749
+ }
750
+ default:
751
+ return K(r);
752
+ }
492
753
  }
493
- function S(t, e, n, o) {
494
- const r = oe(), s = x(e), a = x(o), [c, i] = R({
754
+ function Ee(e, t, n, r) {
755
+ const i = ye(), u = j(t), s = j(r), [f, a] = O({
495
756
  status: "idle",
496
757
  data: n,
497
758
  error: null
498
759
  });
499
- return s.current = e, a.current = o, U(() => {
500
- let p;
760
+ return u.current = t, s.current = r, N(() => {
761
+ let c;
501
762
  try {
502
- p = s.current({
503
- ...r,
504
- activeInputs: a.current
763
+ c = u.current({
764
+ ...i,
765
+ activeInputs: s.current
505
766
  });
506
- } catch (f) {
507
- i({
767
+ } catch (l) {
768
+ a({
508
769
  status: "error",
509
770
  data: n,
510
- error: m(f)
771
+ error: p(l)
511
772
  });
512
773
  return;
513
774
  }
514
- if (!p) {
515
- i({ status: "idle", data: n, error: null });
775
+ if (!c) {
776
+ a({ status: "idle", data: n, error: null });
516
777
  return;
517
778
  }
518
- let l = !1;
519
- return i((f) => ({
779
+ let o = !1;
780
+ return a((l) => ({
520
781
  status: "loading",
521
- data: f.data,
782
+ data: l.data,
522
783
  error: null
523
- })), p.then((f) => {
524
- l || i({ status: "success", data: f, error: null });
525
- }).catch((f) => {
526
- l || i({
784
+ })), c.then((l) => {
785
+ o || a({ status: "success", data: l, error: null });
786
+ }).catch((l) => {
787
+ o || a({
527
788
  status: "error",
528
789
  data: n,
529
- error: m(f)
790
+ error: p(l)
530
791
  });
531
792
  }), () => {
532
- l = !0;
793
+ o = !0;
533
794
  };
534
- }, [n, t, r]), c;
795
+ }, [n, e, i]), f;
796
+ }
797
+ function Ke(e) {
798
+ return Object.fromEntries(
799
+ e.filter((t) => t.defaultValue !== void 0).map((t) => [t.id, t.defaultValue])
800
+ );
801
+ }
802
+ function K(e) {
803
+ throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`);
535
804
  }
536
805
  export {
537
- b as SemaphorDataAppContext,
538
- me as SemaphorDataAppProvider,
539
- X as createSemaphorQueryExecutor,
540
- E as hasSemaphorInputValue,
541
- O as normalizeSemaphorAnalysisPayload,
542
- Ie as normalizeSemaphorAnalysisQueryOptions,
543
- K as normalizeSemaphorInputOptions,
544
- ne as readWindowRuntime,
545
- k as toSemaphorActiveInputSnapshots,
546
- C as toSemaphorAnalysisIntent,
547
- q as toSemaphorAnalysisQueryOptions,
548
- Ee as toSemaphorInputBinding,
549
- xe as toSemaphorInputBindings,
550
- T as toSemaphorInputOptionsIntent,
551
- Re as toSemaphorInputSnapshots,
552
- P as toSemaphorInputSpec,
553
- w as toSemaphorMetricIntent,
554
- _ as toSemaphorRecordsIntent,
555
- ve as useSemaphorAnalysis,
556
- oe as useSemaphorDataAppRuntime,
557
- he as useSemaphorInput,
558
- ge as useSemaphorInputOptions,
559
- Se as useSemaphorMetric,
560
- Ae as useSemaphorRecords,
561
- Oe as validateSemaphorDataAppHookSpecs
806
+ L as SemaphorDataAppContext,
807
+ je as SemaphorDataAppProvider,
808
+ de as createSemaphorQueryExecutor,
809
+ _e as defineSemaphorDataApp,
810
+ Te as defineSemaphorInput,
811
+ I as hasSemaphorInputValue,
812
+ U as normalizeSemaphorAnalysisPayload,
813
+ Le as normalizeSemaphorAnalysisQueryOptions,
814
+ V as normalizeSemaphorInputOptions,
815
+ ve as readWindowRuntime,
816
+ Pe as semaphor,
817
+ y as toSemaphorActiveInputSnapshots,
818
+ H as toSemaphorAnalysisIntent,
819
+ Y as toSemaphorAnalysisQueryOptions,
820
+ Me as toSemaphorInputBinding,
821
+ Be as toSemaphorInputBindings,
822
+ Q as toSemaphorInputOptionsIntent,
823
+ Qe as toSemaphorInputSnapshots,
824
+ $ as toSemaphorInputSpec,
825
+ M as toSemaphorMatrixIntent,
826
+ W as toSemaphorMetricIntent,
827
+ J as toSemaphorRecordsIntent,
828
+ B as toSemaphorSqlIntent,
829
+ ye as useSemaphorDataAppRuntime,
830
+ Ve as useSemaphorInput,
831
+ $e as useSemaphorInputs,
832
+ Ne as useSemaphorQuery,
833
+ Je as validateSemaphorDataAppQuerySpecs
562
834
  };