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