react-semaphor 0.1.283 → 0.1.284

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 (31) hide show
  1. package/dist/chunks/{dashboard-controls-wfMo3T6T.js → dashboard-controls-4pDdG3me.js} +1 -1
  2. package/dist/chunks/{dashboard-controls-DN8jYCON.js → dashboard-controls-Dhry2k8x.js} +4 -4
  3. package/dist/chunks/{dashboard-filter-controls-button-zeiatmo1.js → dashboard-filter-controls-button-BZXrmJP2.js} +11 -11
  4. package/dist/chunks/{dashboard-filter-controls-button-DKc_6T_O.js → dashboard-filter-controls-button-DEUvxIWD.js} +1 -1
  5. package/dist/chunks/dashboard-json-CYnf5rdp.js +1 -0
  6. package/dist/chunks/dashboard-json-D-KsLEGl.js +61 -0
  7. package/dist/chunks/{dashboard-summary-settings-dialog-CWtlFDFP.js → dashboard-summary-settings-dialog-B4jsBFro.js} +15 -15
  8. package/dist/chunks/{dashboard-summary-settings-dialog-BPyawgMV.js → dashboard-summary-settings-dialog-Cn4-fB2h.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-4nQV1U_c.js → edit-dashboard-visual-BDIt_S2F.js} +4782 -4853
  10. package/dist/chunks/edit-dashboard-visual-BQnApBvr.js +193 -0
  11. package/dist/chunks/{index-BHWWNpG6.js → index-DBuN9Zf6.js} +281 -250
  12. package/dist/chunks/{index-B7kUtCgG.js → index-y1uW2fuZ.js} +30193 -28860
  13. package/dist/chunks/{resource-management-panel-Dpin6Ffw.js → resource-management-panel-BC-cvjI9.js} +2 -2
  14. package/dist/chunks/{resource-management-panel-D8xvqypt.js → resource-management-panel-PSvKnmq5.js} +1 -1
  15. package/dist/chunks/{use-create-flow-overlay-state-XkHgf9f3.js → use-create-flow-overlay-state-COe7Ekru.js} +1 -1
  16. package/dist/chunks/{use-create-flow-overlay-state-VwKDgVAy.js → use-create-flow-overlay-state-Cr9AFdXx.js} +4 -4
  17. package/dist/chunks/use-visual-utils-Ccmzx7-m.js +353 -0
  18. package/dist/chunks/use-visual-utils-DNp8XO6G.js +1 -0
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/package.json +3 -2
  27. package/dist/chunks/dashboard-json-DK_hQ4vs.js +0 -66
  28. package/dist/chunks/dashboard-json-DyJBSpIU.js +0 -1
  29. package/dist/chunks/edit-dashboard-visual-0lBlwTCM.js +0 -193
  30. package/dist/chunks/use-visual-utils-C8YSTPfX.js +0 -1
  31. package/dist/chunks/use-visual-utils-CBocWNV1.js +0 -347
@@ -1 +0,0 @@
1
- "use strict";const o=require("./index-BHWWNpG6.js"),S=require("react");function Q(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let i=e.length;if(s!==-1&&(i=s),r!==-1&&r<i&&(i=r),n!==-1){const d=e.substring(0,n),a=e.substring(n);return`${d} {{ filters | where }} AND ${a.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),a=e.substring(t);return`${d} {{ filters | where }} ${a}`}else{const d=e.substring(0,i),a=e.substring(i);return console.log("beforeClause",d),console.log("afterClause",a),a?`${d} {{ filters | where }} ${a}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function z(e){const[n,t]=S.useState(null),[r,s]=S.useState(null),i=o.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!i)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(a){const l=a instanceof Error?a.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,i]),n}function G(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,i;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((i=r.customCardPreferences)!=null&&i.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],a=e.find(l=>l.tabTitle===d);return a?a.id:e[0].id}return n}}return e[0].id}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function P(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],i=r.getQueryData(s);if(i)return console.log("Using cached visual data for:",t),{data:i,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=o.ue.loading("Loading visual...",{position:"top-center"});try{const a=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!a.ok)throw new Error("Failed to load visual");const l=await a.json();return r.setQueryData(s,l),o.ue.dismiss(d),{data:l,fromCache:!1}}catch(a){throw o.ue.dismiss(d),a}}function j(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function J(e,n){var i,d;const t=(e==null?void 0:e.frameObject)??((i=e==null?void 0:e.visual)==null?void 0:i.frameObject);if(!t)return!1;const r=j(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(a=>a.id===r.activeCardId);return s?(o.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function K(){var g;const{setCardSql:e}=o.useEditorActions(),n=o.useEditorStore(c=>c.frame),t=o.useEditorStore(c=>c.card),r=o.useEditorStore(c=>c.isDevMode),s=z(((g=t.customCardPreferences)==null?void 0:g.url)||""),i=o.useEditorStore(c=>c.selectedSchemaName),d=o.useEditorStore(c=>c.selectedDatamodelId),a=o.useEditorStore(c=>c.selectedDatabaseName),l=o.useEditorStore(c=>c.selectedTableName),h=o.useEditorStore(c=>c.selectedConnectionId),m=o.useEditorStore(c=>c.isShowingVisual),p=t.sql;return{getUpdatedFrame:S.useCallback(()=>{var E;let c=p;p&&!p.includes("{{")&&(c=Q(p),e(c));const U=(E=s==null?void 0:s.getState())==null?void 0:E.settings,v=o.buildSavedEditorCard(t,{isDevMode:r,cardSql:c,isShowingVisual:m,selectedSchemaName:i,selectedDatamodelId:d,selectedDatabaseName:a,selectedTableName:l,selectedConnectionId:h,remoteChartSettings:U,stripConfig:Y}),C=n.cards.map(w=>w.id===t.id?v:w);return{...n,cards:C,activeCardId:G(C,n.activeCardId)}},[t,n,r,m,i,d,a,l,h,e,s,p])}}function X(){const{authToken:e,tokenProps:n}=o.useSemaphorContext(),t=o.useQueryClient(),r=o.useSelectedVisual(),{selectVisual:s}=o.useManagementActions(),{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w}=o.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:D,setSelectedFrameId:M,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:O}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),R=o.useDashboardStore(u=>u.selectedFrameId),x=o.useDashboardStore(u=>u.dashboard),B=o.useDashboardStore(u=>u.filterValues),T=o.useDashboardStore(u=>u.inlineFilterValuesMap),y=o.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),_=S.useCallback(async u=>{try{s(u),A();const{data:b,fromCache:f}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!J(b,{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w,setIsDashboardEditing:V,setIsVisualEditing:D,dashboard:x,selectedSheetId:I,selectedFrameId:R,filterValues:B,inlineFilterValuesMap:T}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,i,d,V,D,a,l,h,m,p,$,g,c,U,v,C,E,w,A,x,I,R,B,T]),H=S.useCallback(async u=>{var b;try{if(s(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:W}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),k=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!k)return{success:!1,error:"Visual has no frame data"};const F=j(k);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const L={...o.cloneLinkedFrameWithSourceMapping(F),visualId:u.id};return N(I,L,"end"),V(!0),M(L.id),O(!1),{success:!0,fromCache:W}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,I,N,V,M,O]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:_,handleAddLibraryVisual:H,getUpdatedFrame:K().getUpdatedFrame,refetch:y.refetch}}exports.useVisualUtils=X;
@@ -1,347 +0,0 @@
1
- import { G as K, b as Y, H as X, J as Z, K as q, M as _, N as ee, u as F, O as te, Q as re, x as M, T as se, U as f, V as oe } from "./index-B7kUtCgG.js";
2
- import { useState as H, useEffect as ae, useCallback as N } from "react";
3
- function ne(e) {
4
- const a = e.toUpperCase().indexOf("WHERE"), t = e.toUpperCase().indexOf("GROUP BY"), r = e.toUpperCase().indexOf("LIMIT"), s = e.toUpperCase().indexOf("ORDER BY");
5
- let n = e.length;
6
- if (s !== -1 && (n = s), r !== -1 && r < n && (n = r), a !== -1) {
7
- const c = e.substring(0, a), o = e.substring(a);
8
- return `${c} {{ filters | where }} AND ${o.substring(
9
- 6
10
- )}`;
11
- } else if (t !== -1) {
12
- const c = e.substring(0, t), o = e.substring(t);
13
- return `${c} {{ filters | where }} ${o}`;
14
- } else {
15
- const c = e.substring(0, n), o = e.substring(n);
16
- return console.log("beforeClause", c), console.log("afterClause", o), o ? `${c} {{ filters | where }} ${o}` : `${c.replace(/;$/, "")} {{ filters | where }}`;
17
- }
18
- }
19
- function ie(e) {
20
- const [a, t] = H(null), [r, s] = H(null), n = K();
21
- return ae(() => {
22
- if (!e || e.trim() === "") {
23
- t(null), s(null);
24
- return;
25
- }
26
- if (!n)
27
- return;
28
- (async () => {
29
- try {
30
- if (!e.startsWith("http://") && !e.startsWith("https://"))
31
- throw new Error(`Invalid URL format: ${e}`);
32
- try {
33
- new URL(e);
34
- } catch {
35
- throw new Error(`Invalid URL: ${e}`);
36
- }
37
- const d = `${e.endsWith("/") ? e : `${e}/`}index.js`;
38
- try {
39
- if (!(await fetch(d, { method: "HEAD" })).ok)
40
- throw new Error(`Module not found at ${d}`);
41
- } catch {
42
- }
43
- const h = await import(
44
- /* @vite-ignore */
45
- /* webpackIgnore: true */
46
- d
47
- );
48
- if (typeof h.useChartStore != "function")
49
- throw new Error("useChartStore is not a function");
50
- t(() => h.useChartStore), s(null);
51
- } catch (o) {
52
- const d = o instanceof Error ? o.message : "Unknown error";
53
- console.error("Failed to load remote chart store:", d), s(d), t(null);
54
- }
55
- })();
56
- }, [e, n]), a;
57
- }
58
- function ce(e, a) {
59
- if (e.length === 0)
60
- return "";
61
- const t = e.find(
62
- (r) => {
63
- var s, n;
64
- return ((s = r.customCardPreferences) == null ? void 0 : s.visualType) === "multiple" || !!((n = r.customCardPreferences) != null && n.dataInputCardIds);
65
- }
66
- );
67
- if (t)
68
- return t.id;
69
- if (a) {
70
- const r = e.find((s) => s.id === a);
71
- if (r) {
72
- const s = r.tabTitle;
73
- if (s == "All__Header")
74
- return e[0].id;
75
- if (s && s.endsWith("__Header")) {
76
- const c = s.split("__")[0], o = e.find(
77
- (d) => d.tabTitle === c
78
- );
79
- return o ? o.id : e[0].id;
80
- }
81
- return a;
82
- }
83
- }
84
- return e[0].id;
85
- }
86
- const de = (e) => {
87
- if (!e || !("detailTableBackup" in e))
88
- return e;
89
- const { detailTableBackup: a, ...t } = e;
90
- return t;
91
- };
92
- async function Q(e, a, t, r) {
93
- if (!a || !t)
94
- throw new Error("Missing auth token or visual ID");
95
- const s = ["resource-by-id", "visual", t], n = r.getQueryData(s);
96
- if (n)
97
- return console.log("Using cached visual data for:", t), { data: n, fromCache: !0 };
98
- console.log("Fetching visual data from network for:", t);
99
- const c = M.loading("Loading visual...", {
100
- position: "top-center"
101
- });
102
- try {
103
- const o = await fetch(
104
- `${e}/management/v1/visuals/${t}`,
105
- {
106
- headers: {
107
- Authorization: `Bearer ${a}`
108
- }
109
- }
110
- );
111
- if (!o.ok)
112
- throw new Error("Failed to load visual");
113
- const d = await o.json();
114
- return r.setQueryData(s, d), M.dismiss(c), { data: d, fromCache: !1 };
115
- } catch (o) {
116
- throw M.dismiss(c), o;
117
- }
118
- }
119
- function G(e) {
120
- if (typeof e == "string")
121
- return JSON.parse(e);
122
- if (typeof e == "object")
123
- return e;
124
- throw new Error("Invalid frame object format");
125
- }
126
- function le(e, a) {
127
- var n, c;
128
- const t = (e == null ? void 0 : e.frameObject) ?? ((n = e == null ? void 0 : e.visual) == null ? void 0 : n.frameObject);
129
- if (!t)
130
- return !1;
131
- const r = G(t);
132
- if (!(r != null && r.cards) || r.cards.length === 0)
133
- return !1;
134
- const s = (c = r.cards) == null ? void 0 : c.find(
135
- (o) => o.id === r.activeCardId
136
- );
137
- return s ? (se({
138
- ...a,
139
- frame: r,
140
- card: s,
141
- visualId: (e == null ? void 0 : e.id) || r.visualId
142
- }), !0) : !1;
143
- }
144
- function ue() {
145
- var g;
146
- const { setCardSql: e } = _(), a = f((i) => i.frame), t = f((i) => i.card), r = f((i) => i.isDevMode), s = ie(
147
- ((g = t.customCardPreferences) == null ? void 0 : g.url) || ""
148
- ), n = f(
149
- (i) => i.selectedSchemaName
150
- ), c = f(
151
- (i) => i.selectedDatamodelId
152
- ), o = f(
153
- (i) => i.selectedDatabaseName
154
- ), d = f((i) => i.selectedTableName), h = f(
155
- (i) => i.selectedConnectionId
156
- ), m = f((i) => i.isShowingVisual), p = t.sql;
157
- return { getUpdatedFrame: N(() => {
158
- var S;
159
- let i = p;
160
- p && !p.includes("{{") && (i = ne(p), e(i));
161
- const U = (S = s == null ? void 0 : s.getState()) == null ? void 0 : S.settings, v = oe(t, {
162
- isDevMode: r,
163
- cardSql: i,
164
- isShowingVisual: m,
165
- selectedSchemaName: n,
166
- selectedDatamodelId: c,
167
- selectedDatabaseName: o,
168
- selectedTableName: d,
169
- selectedConnectionId: h,
170
- remoteChartSettings: U,
171
- stripConfig: de
172
- }), C = a.cards.map(
173
- (w) => w.id === t.id ? v : w
174
- );
175
- return {
176
- ...a,
177
- cards: C,
178
- activeCardId: ce(C, a.activeCardId)
179
- };
180
- }, [
181
- t,
182
- a,
183
- r,
184
- m,
185
- n,
186
- c,
187
- o,
188
- d,
189
- h,
190
- e,
191
- s,
192
- p
193
- ]) };
194
- }
195
- function me() {
196
- const { authToken: e, tokenProps: a } = Y(), t = X(), r = Z(), { selectVisual: s } = q(), {
197
- setFrame: n,
198
- setCard: c,
199
- setIsDevMode: o,
200
- initializeModeDrafts: d,
201
- setActiveTabCardId: h,
202
- updateDataSource: m,
203
- setQueryResultColumns: p,
204
- setSelectedConnectionId: $,
205
- setSelectedDatabaseName: g,
206
- setSelectedSchemaName: i,
207
- setSelectedTableName: U,
208
- setSelectedDatamodelId: v,
209
- setFilterValues: C,
210
- setInlineFilterValuesMap: S,
211
- setApplyFilters: w
212
- } = _(), {
213
- setIsDashboardEditing: V,
214
- setIsVisualEditing: O,
215
- setSelectedFrameId: x,
216
- clearSelectedFrameId: A,
217
- addFrame: T,
218
- setIsDashboardPanelOpen: B
219
- } = ee(), I = F((l) => l.selectedSheetId), D = F((l) => l.selectedFrameId), R = F((l) => l.dashboard), W = F((l) => l.filterValues), L = F(
220
- (l) => l.inlineFilterValuesMap
221
- ), y = te((r == null ? void 0 : r.id) || "", {
222
- enabled: !!(r != null && r.id) && !!(e != null && e.accessToken)
223
- }), z = N(
224
- async (l) => {
225
- try {
226
- s(l), A();
227
- const { data: b, fromCache: u } = await Q(
228
- a.apiServiceUrl,
229
- (e == null ? void 0 : e.accessToken) || "",
230
- l.id,
231
- t
232
- );
233
- if (!le(b, {
234
- setFrame: n,
235
- setCard: c,
236
- setIsDevMode: o,
237
- initializeModeDrafts: d,
238
- setActiveTabCardId: h,
239
- updateDataSource: m,
240
- setQueryResultColumns: p,
241
- setSelectedConnectionId: $,
242
- setSelectedDatabaseName: g,
243
- setSelectedSchemaName: i,
244
- setSelectedTableName: U,
245
- setSelectedDatamodelId: v,
246
- setFilterValues: C,
247
- setInlineFilterValuesMap: S,
248
- setApplyFilters: w,
249
- setIsDashboardEditing: V,
250
- setIsVisualEditing: O,
251
- dashboard: R,
252
- selectedSheetId: I,
253
- selectedFrameId: D,
254
- filterValues: W,
255
- inlineFilterValuesMap: L
256
- }))
257
- throw new Error("Failed to setup editor with visual data");
258
- return { success: !0, fromCache: u };
259
- } catch (b) {
260
- return console.error("Error editing visual:", b), { success: !1, error: "Failed to load visual for editing" };
261
- }
262
- },
263
- [
264
- e == null ? void 0 : e.accessToken,
265
- a.apiServiceUrl,
266
- t,
267
- s,
268
- n,
269
- c,
270
- V,
271
- O,
272
- o,
273
- d,
274
- h,
275
- m,
276
- p,
277
- $,
278
- g,
279
- i,
280
- U,
281
- v,
282
- C,
283
- S,
284
- w,
285
- A,
286
- R,
287
- I,
288
- D,
289
- W,
290
- L
291
- ]
292
- ), J = N(
293
- async (l) => {
294
- var b;
295
- try {
296
- if (s(l), !I)
297
- return {
298
- success: !1,
299
- error: "No sheet selected. Please select a sheet first."
300
- };
301
- const { data: u, fromCache: P } = await Q(
302
- a.apiServiceUrl,
303
- (e == null ? void 0 : e.accessToken) || "",
304
- l.id,
305
- t
306
- ), j = (u == null ? void 0 : u.frameObject) ?? ((b = u == null ? void 0 : u.visual) == null ? void 0 : b.frameObject);
307
- if (!j)
308
- return { success: !1, error: "Visual has no frame data" };
309
- const E = G(j);
310
- if (!(E != null && E.cards) || E.cards.length === 0)
311
- return { success: !1, error: "Visual frame is malformed" };
312
- const k = {
313
- ...re(E),
314
- visualId: l.id
315
- // Link this frame to the library visual
316
- };
317
- return T(I, k, "end"), V(!0), x(k.id), B(!1), { success: !0, fromCache: P };
318
- } catch (u) {
319
- return console.error("Error adding visual:", u), { success: !1, error: "Failed to add visual to dashboard" };
320
- }
321
- },
322
- [
323
- e == null ? void 0 : e.accessToken,
324
- a.apiServiceUrl,
325
- t,
326
- s,
327
- I,
328
- T,
329
- V,
330
- x,
331
- B
332
- ]
333
- );
334
- return {
335
- visual: y.data,
336
- isLoading: y.isLoading,
337
- isError: y.isError,
338
- error: y.error,
339
- handleEditLibraryVisual: z,
340
- handleAddLibraryVisual: J,
341
- getUpdatedFrame: ue().getUpdatedFrame,
342
- refetch: y.refetch
343
- };
344
- }
345
- export {
346
- me as u
347
- };