react-semaphor 0.1.368 → 0.1.369

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +1 -1
  3. package/dist/brand-studio/index.cjs +5 -5
  4. package/dist/brand-studio/index.js +24 -23
  5. package/dist/chunks/{braces-Cc86y9Ov.js → braces-C3-w6xDL.js} +1 -1
  6. package/dist/chunks/{braces-CXvY9MwQ.js → braces-C8QqW4wu.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog-BOFlzOJg.js → calendar-preferences-dialog-6q51A6XC.js} +3 -3
  8. package/dist/chunks/{calendar-preferences-dialog-ZzwfJv2J.js → calendar-preferences-dialog-CUGzkNcE.js} +1 -1
  9. package/dist/chunks/{chevrons-up-down-CUZL1zaU.js → chevrons-up-down-CnCSGY02.js} +1 -1
  10. package/dist/chunks/{chevrons-up-down-qQMadOWA.js → chevrons-up-down-DSvLu4Ye.js} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-9-PCYMjR.js → dashboard-briefing-launcher-BEZnvIla.js} +1 -1
  12. package/dist/chunks/{dashboard-briefing-launcher-D2lBFqAd.js → dashboard-briefing-launcher-ptERmNJr.js} +176 -177
  13. package/dist/chunks/{dashboard-controls-D4bUHAjX.js → dashboard-controls-CGt6_hMf.js} +11 -11
  14. package/dist/chunks/{dashboard-controls-BIk094Ah.js → dashboard-controls-CqKC5oEk.js} +77 -77
  15. package/dist/chunks/{dashboard-json-DImOf512.js → dashboard-json-6SgPm_QW.js} +13 -14
  16. package/dist/chunks/dashboard-json-CYSbOdmE.js +1 -0
  17. package/dist/chunks/{edit-dashboard-visual-DTxkV6Fl.js → edit-dashboard-visual-ByQx_M2i.js} +8 -9
  18. package/dist/chunks/{edit-dashboard-visual-BHKlcqQR.js → edit-dashboard-visual-w6hKbjlw.js} +1 -1
  19. package/dist/chunks/index-BtqYNH_S.js +1361 -0
  20. package/dist/chunks/{index-BVEIk-rB.js → index-CPyEi9gS.js} +72498 -76193
  21. package/dist/chunks/{palette-DPuAc82h.js → palette-D-f4-82S.js} +1 -1
  22. package/dist/chunks/{palette-C1k347Tb.js → palette-DUGktM-M.js} +1 -1
  23. package/dist/chunks/{resource-management-panel-BeHceP2D.js → resource-management-panel-Bf8-3eUf.js} +1 -1
  24. package/dist/chunks/{resource-management-panel-BOfbSf48.js → resource-management-panel-mJ84NxzC.js} +152 -152
  25. package/dist/chunks/save-D3YYinDz.js +6 -0
  26. package/dist/chunks/save-kkBEBeLg.js +21 -0
  27. package/dist/chunks/{switch-xcWLtWs0.js → switch-Dkx2qEOr.js} +758 -776
  28. package/dist/chunks/{switch-C0S63HAv.js → switch-fIkmwzUt.js} +27 -32
  29. package/dist/chunks/{use-create-flow-overlay-state-B5FygfQL.js → use-create-flow-overlay-state-BfoXDDrd.js} +190 -189
  30. package/dist/chunks/use-create-flow-overlay-state-c6rCm36x.js +26 -0
  31. package/dist/chunks/{use-visual-utils-DxDE8S8M.js → use-visual-utils-C_c-aiqi.js} +1 -1
  32. package/dist/chunks/{use-visual-utils-CszWnFBW.js → use-visual-utils-NN0e3fBP.js} +13 -13
  33. package/dist/chunks/validation-Dsf7PydY.js +1 -0
  34. package/dist/chunks/validation-nOPr0mTk.js +803 -0
  35. package/dist/chunks/{validators-L0xEXtjf.js → validators-CVuWOHYv.js} +225 -158
  36. package/dist/chunks/validators-oc8qtP4q.js +1 -0
  37. package/dist/dashboard/index.cjs +1 -1
  38. package/dist/dashboard/index.js +1 -1
  39. package/dist/dashboard-authoring/index.cjs +1 -1
  40. package/dist/dashboard-authoring/index.js +1 -1
  41. package/dist/data-app-builder/index.cjs +51 -1
  42. package/dist/data-app-builder/index.js +3666 -2
  43. package/dist/data-app-sdk/index.cjs +1 -1
  44. package/dist/data-app-sdk/index.js +589 -388
  45. package/dist/data-app-sdk-validation/index.cjs +1 -1
  46. package/dist/data-app-sdk-validation/index.js +4 -4
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.js +14 -14
  49. package/dist/surfboard/index.cjs +1 -1
  50. package/dist/surfboard/index.js +2 -2
  51. package/dist/types/analytics-protocol.d.ts +21 -1
  52. package/dist/types/dashboard-assistant.d.ts +21 -1
  53. package/dist/types/dashboard-authoring.d.ts +11 -1
  54. package/dist/types/data-app-builder.d.ts +11 -1
  55. package/dist/types/data-app-sdk-validation.d.ts +107 -23
  56. package/dist/types/data-app-sdk.d.ts +168 -35
  57. package/dist/types/main.d.ts +11 -1
  58. package/package.json +1 -1
  59. package/dist/chunks/dashboard-json-Bo1kX6W1.js +0 -1
  60. package/dist/chunks/index-HjDeEytV.js +0 -1411
  61. package/dist/chunks/use-create-flow-overlay-state-DOXTbTcQ.js +0 -26
  62. package/dist/chunks/validation-CrUjNWby.js +0 -689
  63. package/dist/chunks/validation-DGl8wnTt.js +0 -1
  64. package/dist/chunks/validators-Dq5X4mp0.js +0 -1
@@ -1,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,542 +21,743 @@ const z = [
21
21
  "largestNegativeDrivers",
22
22
  "largestPositiveDrivers"
23
23
  ];
24
- function O(t) {
25
- var r, s;
26
- if (!t)
24
+ function V(e) {
25
+ if (!e)
27
26
  return {};
28
- 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);
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 Z(e, t) {
39
+ const n = ee(e.resultSets);
40
+ for (const i of G) {
41
+ if (n[i]) {
42
+ n[i] = $(n[i]);
44
43
  continue;
45
44
  }
46
- const s = W(t[r]);
47
- if (!s.length)
45
+ const u = oe(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 : ie(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 = re(e.executionResult);
56
+ return r && r.records.length > 0 && !n.records && (n.records = r), n;
58
57
  }
59
- function Q(t) {
60
- var e;
58
+ function ee(e) {
59
+ return Object.fromEntries(
60
+ Object.entries(e || {}).map(([t, n]) => [
61
+ t,
62
+ $(n)
63
+ ])
64
+ );
65
+ }
66
+ function $(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 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];
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 re(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 ne(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 oe(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 = ue(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 ie(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 ue(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 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() {
128
192
  return {
129
- executeAnalysis: (t, e, n) => h(
130
- t,
193
+ executeAnalysis: (e, t, n) => h(
131
194
  e,
195
+ t,
132
196
  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)
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)
137
202
  };
138
203
  }
139
- async function h(t, e, n) {
140
- if (!e.token)
204
+ async function h(e, t, n) {
205
+ if (!t.token)
141
206
  throw new Error("SemaphorDataAppProvider needs a token to execute queries.");
142
- const o = await fetch(te(e), {
207
+ const r = await fetch(le(t), {
143
208
  method: "POST",
144
209
  headers: {
145
210
  "Content-Type": "application/json",
146
- Authorization: `Bearer ${e.token}`
211
+ Authorization: `Bearer ${t.token}`
147
212
  },
148
213
  body: JSON.stringify({
149
- intent: t,
150
- activeInputs: e.activeInputs,
214
+ intent: e,
215
+ activeInputs: t.activeInputs,
151
216
  ...n ? { analysisOptions: n } : {},
152
- resultShape: t.kind
217
+ resultShape: e.kind
153
218
  })
154
- }), r = await Z(o);
155
- if (!o.ok || r.error)
219
+ }), i = await ae(r);
220
+ if (!r.ok || i.error)
156
221
  throw new Error(
157
- r.error || `Semaphor Data App execution failed with status ${o.status}.`
222
+ i.error || `Semaphor Data App execution failed with status ${r.status}.`
158
223
  );
159
- return r;
224
+ return i;
160
225
  }
161
- async function Z(t) {
162
- const e = await t.text().catch(() => "");
163
- if (!e.trim())
164
- return t.ok ? {
226
+ async function ae(e) {
227
+ const t = await e.text().catch(() => "");
228
+ if (!t.trim())
229
+ return e.ok ? {
165
230
  error: "Semaphor Data App execution returned an empty response."
166
231
  } : {};
167
232
  try {
168
- return JSON.parse(e);
233
+ return JSON.parse(t);
169
234
  } catch {
170
- return t.ok ? {
235
+ return e.ok ? {
171
236
  error: "Semaphor Data App execution returned invalid JSON.",
172
- details: e
237
+ details: t
173
238
  } : {
174
- error: ee(t, e),
175
- details: e
239
+ error: ce(e, t),
240
+ details: t
176
241
  };
177
242
  }
178
243
  }
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}.`;
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}.`;
182
247
  }
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";
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";
186
251
  }
187
- function re(t) {
188
- if (t.apiBaseUrl)
189
- return t.apiBaseUrl;
190
- if (!t.token)
252
+ function de(e) {
253
+ if (e.apiBaseUrl)
254
+ return e.apiBaseUrl;
255
+ if (!e.token)
191
256
  return "";
192
257
  try {
193
- return $(t.token).apiServiceUrl || "";
258
+ return J(e.token).apiServiceUrl || "";
194
259
  } catch {
195
260
  return "";
196
261
  }
197
262
  }
198
- const b = j({});
199
- function ne() {
263
+ const N = Y({});
264
+ function fe() {
200
265
  if (!(typeof window > "u"))
201
266
  return window.__SEMAPHOR_DATA_APP_RUNTIME__;
202
267
  }
203
- function oe() {
204
- return N(b);
268
+ function pe() {
269
+ return H(N);
205
270
  }
206
- function me({
207
- token: t,
208
- apiBaseUrl: e,
271
+ function we({
272
+ token: e,
273
+ apiBaseUrl: t,
209
274
  executor: n,
210
- children: o
275
+ children: r
211
276
  }) {
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(
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(
214
279
  () => ({
215
- token: s,
216
- apiBaseUrl: a,
217
- executor: i
280
+ token: u,
281
+ apiBaseUrl: s,
282
+ executor: a
218
283
  }),
219
- [a, i, s]
284
+ [s, a, u]
220
285
  );
221
- return /* @__PURE__ */ B(b.Provider, { value: p, children: o });
286
+ return /* @__PURE__ */ W(N.Provider, { value: c, children: r });
222
287
  }
223
- const A = { value: null }, g = {}, se = { records: [] }, D = { options: [] };
224
- function ae(t) {
225
- 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);
226
291
  try {
227
- const o = C(t), r = v(o);
228
- return r ? {
229
- error: r,
230
- activeInputs: e,
292
+ const r = Q(e), i = v(r);
293
+ return i ? {
294
+ error: i,
295
+ activeInputs: t,
231
296
  analysisOptions: n,
232
- queryKey: u(void 0, e, r, n),
233
- idleData: g
297
+ queryKey: f(void 0, t, i, n),
298
+ idleData: I
234
299
  } : {
235
- intent: o,
300
+ intent: r,
236
301
  error: null,
237
- activeInputs: e,
302
+ activeInputs: t,
238
303
  analysisOptions: n,
239
- queryKey: u(o, e, void 0, n),
240
- idleData: g
304
+ queryKey: f(r, t, void 0, n),
305
+ idleData: I
241
306
  };
242
- } catch (o) {
243
- const r = m(o);
307
+ } catch (r) {
308
+ const i = m(r);
244
309
  return {
245
- error: r,
246
- activeInputs: e,
310
+ error: i,
311
+ activeInputs: t,
247
312
  analysisOptions: n,
248
- queryKey: u(void 0, e, r, n),
249
- idleData: g
313
+ queryKey: f(void 0, t, i, n),
314
+ idleData: I
250
315
  };
251
316
  }
252
317
  }
253
- function ie(t) {
254
- const e = k(t.inputs);
318
+ function ye(e) {
319
+ const t = g(e.inputs);
255
320
  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
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
262
327
  } : {
263
328
  intent: n,
264
329
  error: null,
265
- activeInputs: e,
266
- queryKey: u(n, e),
267
- idleData: A
330
+ activeInputs: t,
331
+ queryKey: f(n, t),
332
+ idleData: k
268
333
  };
269
334
  } catch (n) {
270
- const o = m(n);
335
+ const r = m(n);
271
336
  return {
272
- error: o,
273
- activeInputs: e,
274
- queryKey: u(void 0, e, o),
275
- idleData: A
337
+ error: r,
338
+ activeInputs: t,
339
+ queryKey: f(void 0, t, r),
340
+ idleData: k
276
341
  };
277
342
  }
278
343
  }
279
- function ue(t) {
280
- const e = k(t.inputs), n = se;
344
+ function qe(e) {
345
+ const t = g(e.inputs), n = me;
281
346
  try {
282
- const o = _(t), r = v(o);
283
- return r ? {
284
- error: r,
285
- activeInputs: e,
286
- 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),
287
352
  idleData: n
288
353
  } : {
289
- intent: o,
354
+ intent: r,
290
355
  error: null,
291
- activeInputs: e,
292
- queryKey: u(o, e),
356
+ activeInputs: t,
357
+ queryKey: f(r, t),
293
358
  idleData: n
294
359
  };
295
- } catch (o) {
296
- const r = m(o);
360
+ } catch (r) {
361
+ const i = m(r);
297
362
  return {
298
- error: r,
299
- activeInputs: e,
300
- queryKey: u(void 0, e, r),
363
+ error: i,
364
+ activeInputs: t,
365
+ queryKey: f(void 0, t, i),
301
366
  idleData: n
302
367
  };
303
368
  }
304
369
  }
305
- function ce(t) {
370
+ function Se(e) {
306
371
  try {
307
- const e = T(t), n = v(e);
372
+ const t = z(e), n = v(t);
308
373
  return n ? {
309
374
  error: n,
310
- queryKey: u(void 0, void 0, n),
311
- idleData: D
375
+ queryKey: f(void 0, void 0, n),
376
+ idleData: E
312
377
  } : {
313
- intent: e,
378
+ intent: t,
314
379
  error: null,
315
- queryKey: u(e),
316
- idleData: D
380
+ queryKey: f(t),
381
+ idleData: E
317
382
  };
318
- } catch (e) {
319
- const n = m(e);
383
+ } catch (t) {
384
+ const n = m(t);
320
385
  return {
321
386
  error: n,
322
- queryKey: u(void 0, void 0, n),
323
- idleData: D
387
+ queryKey: f(void 0, void 0, n),
388
+ idleData: E
389
+ };
390
+ }
391
+ }
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
324
415
  };
325
416
  }
326
417
  }
327
- function m(t) {
328
- return t instanceof Error ? t : new Error(String(t));
418
+ function m(e) {
419
+ return e instanceof Error ? e : new Error(String(e));
329
420
  }
330
- function v(t) {
331
- const e = L(t);
332
- if (e.ok)
421
+ function v(e) {
422
+ const t = F(e);
423
+ if (t.ok)
333
424
  return null;
334
- const n = e.errors.map(
335
- (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}`
336
427
  ).join("; ");
337
428
  return new Error(`Invalid Semaphor analytics intent. ${n}`);
338
429
  }
339
- function u(t, e, n, o) {
430
+ function f(e, t, n, r) {
340
431
  return JSON.stringify({
341
- intent: t,
342
- activeInputs: e,
343
- analysisOptions: o,
432
+ intent: e,
433
+ activeInputs: t,
434
+ analysisOptions: r,
344
435
  error: n == null ? void 0 : n.message
345
436
  });
346
437
  }
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);
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);
356
447
  },
357
- [o, t]
358
- ), c = y(() => a(void 0), [a]);
359
- return d(() => {
360
- const i = P(t);
448
+ [r, e]
449
+ ), d = O(() => s(void 0), [s]);
450
+ return p(() => {
451
+ const a = T(e);
361
452
  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,
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),
462
+ setValue: s,
463
+ clear: d,
373
464
  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
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
382
473
  })
383
474
  };
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]
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]
408
523
  );
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
524
  }
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;
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
+ }
476
599
  },
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
- };
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
+ }
492
683
  }
493
- function S(t, e, n, o) {
494
- const r = oe(), s = x(e), a = x(o), [c, i] = R({
684
+ function ge(e, t, n, r) {
685
+ const i = pe(), u = _(t), s = _(r), [d, a] = R({
495
686
  status: "idle",
496
687
  data: n,
497
688
  error: null
498
689
  });
499
- return s.current = e, a.current = o, U(() => {
500
- let p;
690
+ return u.current = t, s.current = r, j(() => {
691
+ let c;
501
692
  try {
502
- p = s.current({
503
- ...r,
504
- activeInputs: a.current
693
+ c = u.current({
694
+ ...i,
695
+ activeInputs: s.current
505
696
  });
506
- } catch (f) {
507
- i({
697
+ } catch (l) {
698
+ a({
508
699
  status: "error",
509
700
  data: n,
510
- error: m(f)
701
+ error: m(l)
511
702
  });
512
703
  return;
513
704
  }
514
- if (!p) {
515
- i({ status: "idle", data: n, error: null });
705
+ if (!c) {
706
+ a({ status: "idle", data: n, error: null });
516
707
  return;
517
708
  }
518
- let l = !1;
519
- return i((f) => ({
709
+ let o = !1;
710
+ return a((l) => ({
520
711
  status: "loading",
521
- data: f.data,
712
+ data: l.data,
522
713
  error: null
523
- })), p.then((f) => {
524
- l || i({ status: "success", data: f, error: null });
525
- }).catch((f) => {
526
- l || i({
714
+ })), c.then((l) => {
715
+ o || a({ status: "success", data: l, error: null });
716
+ }).catch((l) => {
717
+ o || a({
527
718
  status: "error",
528
719
  data: n,
529
- error: m(f)
720
+ error: m(l)
530
721
  });
531
722
  }), () => {
532
- l = !0;
723
+ o = !0;
533
724
  };
534
- }, [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)}`);
535
734
  }
536
735
  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
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
562
763
  };