react-semaphor 0.1.359 → 0.1.360

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 (38) hide show
  1. package/dist/chunks/{calendar-preferences-dialog-BeZvsJV0.js → calendar-preferences-dialog-BEKBpwMY.js} +1 -1
  2. package/dist/chunks/{calendar-preferences-dialog-BHq3bPkF.js → calendar-preferences-dialog-GwtaSN53.js} +1 -1
  3. package/dist/chunks/{dashboard-briefing-launcher-gm3YPxOh.js → dashboard-briefing-launcher-D6gGO5wz.js} +3 -3
  4. package/dist/chunks/{dashboard-briefing-launcher-Dr6trdJw.js → dashboard-briefing-launcher-DYxd4856.js} +1 -1
  5. package/dist/chunks/{dashboard-controls-BZljC-GB.js → dashboard-controls-B4u5RsKl.js} +3 -3
  6. package/dist/chunks/{dashboard-controls-4a3fKtuD.js → dashboard-controls-C_rExqPw.js} +1 -1
  7. package/dist/chunks/{dashboard-json-wTRw_VIn.js → dashboard-json-BWWU6a7V.js} +1 -1
  8. package/dist/chunks/{dashboard-json-4uDp0D6Y.js → dashboard-json-CPGTofhm.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-CqnMxF8h.js → edit-dashboard-visual-D_jZ-iix.js} +1 -1
  10. package/dist/chunks/{edit-dashboard-visual-BztJSdkR.js → edit-dashboard-visual-biMO829J.js} +3 -3
  11. package/dist/chunks/{index-DZ3lq1Pk.js → index-CJ2IEuKz.js} +31368 -31127
  12. package/dist/chunks/index-Db1XVmfU.js +1411 -0
  13. package/dist/chunks/{resource-management-panel-CEVKKwSW.js → resource-management-panel-B9-5VHYe.js} +2 -2
  14. package/dist/chunks/{resource-management-panel-BajPY5IU.js → resource-management-panel-Bam-yvnt.js} +1 -1
  15. package/dist/chunks/{use-create-flow-overlay-state-CT1BlsPJ.js → use-create-flow-overlay-state-DAvEqaJV.js} +2 -2
  16. package/dist/chunks/{use-create-flow-overlay-state-D010FtSh.js → use-create-flow-overlay-state-dhxgdLYo.js} +1 -1
  17. package/dist/chunks/{use-visual-utils-CIHFvxpt.js → use-visual-utils-CAKdXsr5.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-H2FXMsGo.js → use-visual-utils-FoHNPwpu.js} +1 -1
  19. package/dist/chunks/validation-C_WDLZdp.js +1 -0
  20. package/dist/chunks/validation-McK0uXpV.js +669 -0
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/data-app-builder/index.cjs +1 -1
  24. package/dist/data-app-builder/index.js +1 -1
  25. package/dist/data-app-sdk/index.cjs +1 -1
  26. package/dist/data-app-sdk/index.js +308 -440
  27. package/dist/data-app-sdk-validation/index.cjs +1 -0
  28. package/dist/data-app-sdk-validation/index.js +7 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +5 -5
  31. package/dist/style.css +1 -1
  32. package/dist/surfboard/index.cjs +1 -1
  33. package/dist/surfboard/index.js +2 -2
  34. package/dist/types/data-app-builder.d.ts +68 -9
  35. package/dist/types/data-app-sdk-validation.d.ts +595 -0
  36. package/dist/types/data-app-sdk.d.ts +333 -0
  37. package/package.json +6 -1
  38. package/dist/chunks/index-YZnHD2NF.js +0 -1410
@@ -1,9 +1,9 @@
1
1
  import { jsx as e, jsxs as n, Fragment as oe } from "react/jsx-runtime";
2
2
  import { c as He, u as se, G as Ge, a as Z, B as O, f as te, N as be, V as $e, L as ie, a2 as de, X as ke, Z as We, _ as Xe, $ as Ye, a1 as Ze, az as Je } from "./switch-xcWLtWs0.js";
3
3
  import Qe, { useState as b, useEffect as ee, useRef as qe } from "react";
4
- import { ah as ue, aL as et, aM as tt, aI as ce, aN as nt, aO as at, aP as st, aQ as it, aR as Y, aS as ot, aT as rt, aU as lt, aV as xe, az as he, aW as dt, aX as ct, aY as Ne, aZ as we, a_ as ut, J as ye, A as Ce, a$ as ve, b0 as Se, b1 as Ee, b2 as Ve, b3 as Le, b4 as Ae, b5 as Oe, b6 as Te, b7 as Re, b8 as ht, b9 as pe, ba as pt, y as ae, u as mt, bb as Ue, c as Ie, d as ze, e as Me, f as Pe, g as Fe, bc as ft, o as je, bd as gt, be as De, bf as xt } from "./index-DZ3lq1Pk.js";
4
+ import { ah as ue, aL as et, aM as tt, aI as ce, aN as nt, aO as at, aP as st, aQ as it, aR as Y, aS as ot, aT as rt, aU as lt, aV as xe, az as he, aW as dt, aX as ct, aY as Ne, aZ as we, a_ as ut, J as ye, A as Ce, a$ as ve, b0 as Se, b1 as Ee, b2 as Ve, b3 as Le, b4 as Ae, b5 as Oe, b6 as Te, b7 as Re, b8 as ht, b9 as pe, ba as pt, y as ae, u as mt, bb as Ue, c as Ie, d as ze, e as Me, f as Pe, g as Fe, bc as ft, o as je, bd as gt, be as De, bf as xt } from "./index-CJ2IEuKz.js";
5
5
  import "./index-CuHybtft.js";
6
- import { u as Be } from "./use-visual-utils-H2FXMsGo.js";
6
+ import { u as Be } from "./use-visual-utils-FoHNPwpu.js";
7
7
  /**
8
8
  * @license lucide-react v0.453.0 - ISC
9
9
  *
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./switch-C0S63HAv.js"),x=require("react"),t=require("./index-YZnHD2NF.js");require("./index-BxM99sFL.js");const oe=require("./use-visual-utils-CIHFvxpt.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./switch-C0S63HAv.js"),x=require("react"),t=require("./index-Db1XVmfU.js");require("./index-BxM99sFL.js");const oe=require("./use-visual-utils-CAKdXsr5.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,9 +1,9 @@
1
1
  import { c as te, G as L, H as ne, u as oe, Z as ft, _ as ht, $ as gt, a as ie, a1 as bt, a9 as yt, B as V, e as xt, X as Ke, E as Pe, f as Ye, S as Ge, aa as vt, ab as Ct, ac as se, ad as Ae, ae as ze, af as be, ag as ye, ah as kt, ai as Me, aj as Nt, ak as St, al as le, am as Dt, an as Oe, g as Be, ao as Xe, ap as Je, aq as Ze, L as P, a2 as We, a3 as xe, a4 as ve, a5 as Ce, a6 as ke, a7 as Ne, ar as et, as as wt, at as It, au as Re, av as Et, aw as Qe, ax as Tt, ay as Se } from "./switch-xcWLtWs0.js";
2
2
  import { useEffect as de, useMemo as z, useState as Q, useRef as De, useCallback as O, Fragment as Vt } from "react";
3
- import { al as _t, am as tt, an as qt, ao as Ft, ap as Lt, aq as At, ar as zt, y as Mt, as as Ot, ae as ue, at, ag as rt, au as st, av as Bt, p as R, aw as Rt, ax as Qt, ay as je, az as jt, aA as Ut, aB as lt, aC as nt, aD as Ht, aE as $t, aF as Kt, aG as Pt, aH as Yt, aI as Gt, aJ as Xt, aK as Jt } from "./index-DZ3lq1Pk.js";
3
+ import { al as _t, am as tt, an as qt, ao as Ft, ap as Lt, aq as At, ar as zt, y as Mt, as as Ot, ae as ue, at, ag as rt, au as st, av as Bt, p as R, aw as Rt, ax as Qt, ay as je, az as jt, aA as Ut, aB as lt, aC as nt, aD as Ht, aE as $t, aF as Kt, aG as Pt, aH as Yt, aI as Gt, aJ as Xt, aK as Jt } from "./index-CJ2IEuKz.js";
4
4
  import { jsx as t, jsxs as d, Fragment as $ } from "react/jsx-runtime";
5
5
  import "./index-CuHybtft.js";
6
- import { u as we } from "./use-visual-utils-H2FXMsGo.js";
6
+ import { u as we } from "./use-visual-utils-FoHNPwpu.js";
7
7
  /**
8
8
  * @license lucide-react v0.453.0 - ISC
9
9
  *
@@ -1,4 +1,4 @@
1
- "use strict";const s=require("./switch-C0S63HAv.js"),v=require("react"),p=require("./index-YZnHD2NF.js"),e=require("react/jsx-runtime");require("./index-BxM99sFL.js");const re=require("./use-visual-utils-CIHFvxpt.js");/**
1
+ "use strict";const s=require("./switch-C0S63HAv.js"),v=require("react"),p=require("./index-Db1XVmfU.js"),e=require("react/jsx-runtime");require("./index-BxM99sFL.js");const re=require("./use-visual-utils-CAKdXsr5.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- "use strict";const u=require("./index-YZnHD2NF.js"),f=require("./switch-C0S63HAv.js"),S=require("react");function K(e){const[a,s]=S.useState(null),[r,t]=S.useState(null),o=u.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!o)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 i=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(i,{method:"HEAD"})).ok)throw new Error(`Module not found at ${i}`)}catch{}const m=await import(i);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>m.useChartStore),t(null)}catch(n){const i=n instanceof Error?n.message:"Unknown error";console.error("Failed to load remote chart store:",i),t(i),s(null)}})()},[e,o]),a}function X(e,a){if(e.length===0)return"";const s=e.find(r=>{var t,o;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((o=r.customCardPreferences)!=null&&o.dataInputCardIds)});if(s)return s.id;if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const l=t.split("__")[0],n=e.find(i=>i.tabTitle===l);return n?n.id:e[0].id}return a}}return e[0].id}const A=new Set;function Y(e){return A.add(e),()=>{A.delete(e)}}function z(){A.forEach(e=>{e()})}const Z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:a,...s}=e;return s};async function B(e,a,s,r){if(!a||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],o=r.getQueryData(t);if(o)return console.log("Using cached visual data for:",s),{data:o,fromCache:!0};console.log("Fetching visual data from network for:",s);const l=u.ue.loading("Loading visual...",{position:"top-center"});try{const n=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${a}`}});if(!n.ok)throw new Error("Failed to load visual");const i=await n.json();return r.setQueryData(t,i),u.ue.dismiss(l),{data:i,fromCache:!1}}catch(n){throw u.ue.dismiss(l),n}}function H(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function ee(e,a){var o,l;const s=(e==null?void 0:e.frameObject)??((o=e==null?void 0:e.visual)==null?void 0:o.frameObject);if(!s)return!1;const r=H(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(l=r.cards)==null?void 0:l.find(n=>n.id===r.activeCardId);return t?(u.setupEditorWithCard({...a,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function te(){const e=f.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),a=K(e);return{getUpdatedFrame:S.useCallback(()=>{var b;z();const{frame:r,card:t,isDevMode:o,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y}=f.useEditorStore.getState(),I=t.sql,U=(b=a==null?void 0:a.getState())==null?void 0:b.settings,V=f.buildSavedEditorCard(t,{isDevMode:o,cardSql:I,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y,remoteChartSettings:U,stripConfig:Z}),g=r.cards.map(E=>E.id===t.id?V:E);return{...r,cards:g,activeCardId:X(g,r.activeCardId)}},[a])}}function re(){const{authToken:e,tokenProps:a}=u.useSemaphorContext(),s=u.useQueryClient(),r=u.useAddFrameWithFreshSemanticExecutionPayload(),t=u.useSelectedVisual(),{selectVisual:o}=u.useManagementActions(),{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,clearEditorContext:L}=f.useEditorActions(),{setIsDashboardEditing:v,setIsVisualEditing:T,setSelectedFrameId:j,clearSelectedFrameId:N,setIsDashboardPanelOpen:R}=f.useDashboardActions(),w=f.useDashboardStore(c=>c.selectedSheetId),W=f.useDashboardStore(c=>c.selectedFrameId),$=f.useDashboardStore(c=>c.dashboard),_=f.useDashboardStore(c=>c.filterValues),x=f.useDashboardStore(c=>c.inlineFilterValuesMap),F=u.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),Q=S.useCallback(async c=>{try{o(c),N(),L();const{data:h,fromCache:D}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s);if(!ee(h,{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,setIsDashboardEditing:v,setIsVisualEditing:T,dashboard:$,selectedSheetId:w,selectedFrameId:W,filterValues:_,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:D}}catch(h){return console.error("Error editing visual:",h),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,l,n,v,T,i,m,p,y,I,U,V,g,b,E,P,M,k,L,N,$,w,W,_,x]),G=S.useCallback(async c=>{var D;const h=d=>(u.ue.error(d),{success:!1,error:d});try{if(o(c),!w)return h("No sheet selected. Please select a sheet first.");const{data:d,fromCache:J}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s),O=(d==null?void 0:d.frameObject)??((D=d==null?void 0:d.visual)==null?void 0:D.frameObject);if(!O)return h("Visual has no frame data");const C=H(O);if(!(C!=null&&C.cards)||C.cards.length===0)return h("Visual frame is malformed");const q={...u.cloneLinkedFrameWithSourceMapping(C),visualId:c.id};return await r(w,q,"end"),v(!0),j(q.id),R(!1),{success:!0,fromCache:J}}catch(d){return console.error("Error adding visual:",d),h(d instanceof Error?d.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,w,v,j,R,r]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:Q,handleAddLibraryVisual:G,getUpdatedFrame:te().getUpdatedFrame,refetch:F.refetch}}exports.flushPendingEditorDrafts=z;exports.registerPendingEditorDraftFlusher=Y;exports.useVisualUtils=re;
1
+ "use strict";const u=require("./index-Db1XVmfU.js"),f=require("./switch-C0S63HAv.js"),S=require("react");function K(e){const[a,s]=S.useState(null),[r,t]=S.useState(null),o=u.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!o)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 i=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(i,{method:"HEAD"})).ok)throw new Error(`Module not found at ${i}`)}catch{}const m=await import(i);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>m.useChartStore),t(null)}catch(n){const i=n instanceof Error?n.message:"Unknown error";console.error("Failed to load remote chart store:",i),t(i),s(null)}})()},[e,o]),a}function X(e,a){if(e.length===0)return"";const s=e.find(r=>{var t,o;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((o=r.customCardPreferences)!=null&&o.dataInputCardIds)});if(s)return s.id;if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const l=t.split("__")[0],n=e.find(i=>i.tabTitle===l);return n?n.id:e[0].id}return a}}return e[0].id}const A=new Set;function Y(e){return A.add(e),()=>{A.delete(e)}}function z(){A.forEach(e=>{e()})}const Z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:a,...s}=e;return s};async function B(e,a,s,r){if(!a||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],o=r.getQueryData(t);if(o)return console.log("Using cached visual data for:",s),{data:o,fromCache:!0};console.log("Fetching visual data from network for:",s);const l=u.ue.loading("Loading visual...",{position:"top-center"});try{const n=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${a}`}});if(!n.ok)throw new Error("Failed to load visual");const i=await n.json();return r.setQueryData(t,i),u.ue.dismiss(l),{data:i,fromCache:!1}}catch(n){throw u.ue.dismiss(l),n}}function H(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function ee(e,a){var o,l;const s=(e==null?void 0:e.frameObject)??((o=e==null?void 0:e.visual)==null?void 0:o.frameObject);if(!s)return!1;const r=H(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(l=r.cards)==null?void 0:l.find(n=>n.id===r.activeCardId);return t?(u.setupEditorWithCard({...a,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function te(){const e=f.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),a=K(e);return{getUpdatedFrame:S.useCallback(()=>{var b;z();const{frame:r,card:t,isDevMode:o,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y}=f.useEditorStore.getState(),I=t.sql,U=(b=a==null?void 0:a.getState())==null?void 0:b.settings,V=f.buildSavedEditorCard(t,{isDevMode:o,cardSql:I,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y,remoteChartSettings:U,stripConfig:Z}),g=r.cards.map(E=>E.id===t.id?V:E);return{...r,cards:g,activeCardId:X(g,r.activeCardId)}},[a])}}function re(){const{authToken:e,tokenProps:a}=u.useSemaphorContext(),s=u.useQueryClient(),r=u.useAddFrameWithFreshSemanticExecutionPayload(),t=u.useSelectedVisual(),{selectVisual:o}=u.useManagementActions(),{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,clearEditorContext:L}=f.useEditorActions(),{setIsDashboardEditing:v,setIsVisualEditing:T,setSelectedFrameId:j,clearSelectedFrameId:N,setIsDashboardPanelOpen:R}=f.useDashboardActions(),w=f.useDashboardStore(c=>c.selectedSheetId),W=f.useDashboardStore(c=>c.selectedFrameId),$=f.useDashboardStore(c=>c.dashboard),_=f.useDashboardStore(c=>c.filterValues),x=f.useDashboardStore(c=>c.inlineFilterValuesMap),F=u.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),Q=S.useCallback(async c=>{try{o(c),N(),L();const{data:h,fromCache:D}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s);if(!ee(h,{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,setIsDashboardEditing:v,setIsVisualEditing:T,dashboard:$,selectedSheetId:w,selectedFrameId:W,filterValues:_,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:D}}catch(h){return console.error("Error editing visual:",h),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,l,n,v,T,i,m,p,y,I,U,V,g,b,E,P,M,k,L,N,$,w,W,_,x]),G=S.useCallback(async c=>{var D;const h=d=>(u.ue.error(d),{success:!1,error:d});try{if(o(c),!w)return h("No sheet selected. Please select a sheet first.");const{data:d,fromCache:J}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s),O=(d==null?void 0:d.frameObject)??((D=d==null?void 0:d.visual)==null?void 0:D.frameObject);if(!O)return h("Visual has no frame data");const C=H(O);if(!(C!=null&&C.cards)||C.cards.length===0)return h("Visual frame is malformed");const q={...u.cloneLinkedFrameWithSourceMapping(C),visualId:c.id};return await r(w,q,"end"),v(!0),j(q.id),R(!1),{success:!0,fromCache:J}}catch(d){return console.error("Error adding visual:",d),h(d instanceof Error?d.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,w,v,j,R,r]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:Q,handleAddLibraryVisual:G,getUpdatedFrame:te().getUpdatedFrame,refetch:F.refetch}}exports.flushPendingEditorDrafts=z;exports.registerPendingEditorDraftFlusher=Y;exports.useVisualUtils=re;
@@ -1,4 +1,4 @@
1
- import { ad as X, u as Y, ae as Z, af as ee, ag as te, ah as re, ai as se, aj as ae, p as V, ak as oe } from "./index-DZ3lq1Pk.js";
1
+ import { ad as X, u as Y, ae as Z, af as ee, ag as te, ah as re, ai as se, aj as ae, p as V, ak as oe } from "./index-CJ2IEuKz.js";
2
2
  import { H as ne, E as ie, u as b, G as H, I as ce } from "./switch-xcWLtWs0.js";
3
3
  import { useState as z, useEffect as de, useCallback as A } from "react";
4
4
  function le(e) {
@@ -0,0 +1 @@
1
+ "use strict";const B=require("./validators-Cu_w8ZEP.js"),c=require("./source-identity-C-xaeE_I.js");function p(e){var r;const t=H(e);return{version:1,kind:"metric",id:e.id,label:e.label,source:g(e),metrics:t,primaryMetric:O(e,t),dateField:e.dateField?a(e.dateField,"date"):void 0,timeGrain:e.timeGrain,dimensions:(r=e.dimensions)==null?void 0:r.map(i=>a(i,"dimension")),comparison:J(e.comparison),orderBy:e.orderBy?{field:a(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:y(e.inputs),limit:e.limit}}function M(e){var r;return{...p(e),...e.timeWindow?{timeWindow:e.timeWindow}:{},...(r=e.filters)!=null&&r.length?{filters:e.filters}:{},...e.analysis?{analysis:e.analysis}:{}}}function D(e){return{...e.chartTitle?{chartTitle:e.chartTitle}:{},...e.chartType?{chartType:e.chartType}:{},...e.driverMode?{driverMode:e.driverMode}:{},...e.includePopulation!==void 0?{includePopulation:e.includePopulation}:{},...e.calendarContext?{calendarContext:e.calendarContext}:{}}}function O(e,t){if(!e.primaryMetric)return t[0]||{name:"",role:"measure"};const r=a(e.primaryMetric,"measure"),i=E(r,t),o=i.length===1?i[0]:void 0;return o?b(r,o):r}function H(e){const t=[];for(const r of e.metrics.map(i=>a(i,"measure"))){if(!r.name)continue;const i=t.findIndex(o=>j(o,r));if(i===-1){t.push(r);continue}t[i]=b(t[i],r)}return t}function j(e,t){return c.semaphorFieldRefsMatch(e,t)&&f(e)===f(t)}function q(e,t){return f(t)===f(e)}function N(e,t){return t.name!==e.name||e.source&&!c.semaphorFieldRefsMatch(t,e)?!1:q(e,t)}function E(e,t){const r=t.filter(i=>N(e,i));return e.aggregate!==void 0,r}function f(e){return(e.aggregate||"SUM").toUpperCase()}function b(e,t){if(e.aggregate&&t.aggregate&&e.aggregate!==t.aggregate)throw new Error(`Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${t.aggregate}.`);return{...c.preferSemaphorFieldRefMetadata(e,t),aggregate:e.aggregate||t.aggregate}}function _(e){if("sort"in e)throw new Error("useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!L(e))throw new Error("useSemaphorRecords needs at least one field.");const t=U(e.fields);return{version:1,kind:"records",id:e.id,label:e.label,source:g(e),fields:t,dateField:e.dateField?a(e.dateField,"date"):void 0,timeGrain:e.timeGrain,orderBy:e.orderBy?{field:a(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:y(e.inputs),limit:e.limit}}function U(e){return e.map(t=>{const r=a(t);if(!r.role)throw new Error(`useSemaphorRecords field "${r.name}" needs an explicit role.`);return r})}function w(e){return{version:1,kind:"inputOptions",id:e.id,label:e.label,source:g(e),field:a(e.field,"dimension"),search:e.search,limit:e.limit}}function C(e){if("toAnalyticsInput"in e){const t=e.toAnalyticsInput();return{inputId:t.inputId,...t.field?{field:t.field}:{}}}return{inputId:e.inputId,...e.field?{field:e.field}:{}}}function G(e){const t=y(e);return t.length>0?t:void 0}function $(e){return(e||[]).map(K)}function Q(e){return $(e).filter(t=>t.isActive)}function V(e){return e.kind==="filter"?{inputId:e.id,kind:e.kind,label:e.label,field:a(e.field,"dimension"),operator:e.operator||"in"}:{inputId:e.id,kind:e.kind,label:e.label}}function W(e=[]){return e.map(t=>typeof t=="object"?t:{label:String(t),value:t})}function F(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!0}function K(e){return"toAnalyticsInput"in e?e.toAnalyticsInput():"kind"in e&&"isActive"in e?e:{...e,kind:"filter",isActive:F(e.value),value:e.value}}function g(e){return e.source}function L(e){var t;return!!((t=e.fields)!=null&&t.length)}function a(e,t){return{...e,role:e.role||t}}function y(e){return(e||[]).map(C)}function J(e){if(e)return e}function T(e,t={}){const r=t.pathPrefix||"analysisOptions";if(e===void 0)return{ok:!0};if(!e||typeof e!="object"||Array.isArray(e))return s(r,"Data App analysis options must be an object.");const i=e,o={};if(i.chartTitle!==void 0){if(typeof i.chartTitle!="string")return s(`${r}.chartTitle`,'Data App analysis option "chartTitle" must be a string.');o.chartTitle=i.chartTitle}if(i.chartType!==void 0){if(typeof i.chartType!="string")return s(`${r}.chartType`,'Data App analysis option "chartType" must be a string.');o.chartType=i.chartType}if(i.driverMode!==void 0){if(!Z(i.driverMode))return s(`${r}.driverMode`,'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.');o.driverMode=i.driverMode}if(i.includePopulation!==void 0){if(typeof i.includePopulation!="boolean")return s(`${r}.includePopulation`,'Data App analysis option "includePopulation" must be a boolean.');o.includePopulation=i.includePopulation}if(i.calendarContext!==void 0){const n=ee(i.calendarContext,{pathPrefix:`${r}.calendarContext`,validateTimezone:t.validateTimezone});if(!n.ok)return n;o.calendarContext=n.calendarContext}return{ok:!0,analysisOptions:o}}function X(e){const t=e.hooks.map((o,n)=>Y(o,n,{fieldCatalogs:e.fieldCatalogs||[],requireFieldCatalog:!!e.requireFieldCatalog,validateTimezone:e.validateTimezone})),r=t.flatMap(o=>o.diagnostics),i=t.map(o=>o.executionResult);return{ok:r.every(o=>o.severity!=="error"),diagnostics:r,hooks:t,intents:t.flatMap(o=>o.intent?[o.intent]:[]),executionResults:i}}function Y(e,t,r){const i=`hooks.${t}`;try{const o=te(e),n=ce(e,o),d=B.validateSemaphorAnalyticsIntent(o),l=[...d.errors.map(h=>k(h,{hook:e.hook,hookId:n,pathPrefix:i,severity:"error",intent:o})),...d.warnings.map(h=>k(h,{hook:e.hook,hookId:n,pathPrefix:i,severity:"warning",intent:o})),...re({hookSpec:e,hookId:n,intent:o,pathPrefix:i,fieldCatalogs:r.fieldCatalogs,requireFieldCatalog:r.requireFieldCatalog}),...ne({hookSpec:e,hookId:n,intent:o,pathPrefix:i,validateTimezone:r.validateTimezone})],z=le(d,l);return{hook:e.hook,hookId:n,intent:o,diagnostics:l,executionResult:A({intent:o,validation:z,diagnostics:l})}}catch(o){const n={severity:"error",code:"invalid_hook_spec",message:o instanceof Error?o.message:String(o),path:i,hook:e.hook,hookId:P(e.spec)},d=R([n]);return{hook:e.hook,hookId:n.hookId,diagnostics:[n],executionResult:A({validation:d,diagnostics:[n]})}}}function s(e,t){return{ok:!1,issues:[{code:"invalid_analysis_option",message:t,path:e}]}}function Z(e){return e==="absolute_delta"||e==="largest_negative"||e==="largest_positive"||e==="positive_and_negative"||e==="all"}function ee(e,t){var l;if(!e||typeof e!="object"||Array.isArray(e))return s(t.pathPrefix,'Data App analysis option "calendarContext" must be an object.');const r=e,i=r.tz,o=r.weekStart,n=r.anchor,d=typeof i=="string"?((l=t.validateTimezone)==null?void 0:l.call(t,i))??i:null;return d?typeof o!="number"||!Number.isInteger(o)||o<0||o>6?s(`${t.pathPrefix}.weekStart`,'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'):n!=="now"&&!(n&&typeof n=="object"&&!Array.isArray(n)&&typeof n.iso=="string")?s(`${t.pathPrefix}.anchor`,'Data App analysis option "calendarContext.anchor" must be "now" or an object with an iso string.'):{ok:!0,calendarContext:{tz:d,weekStart:o,anchor:n}}:s(`${t.pathPrefix}.tz`,'Data App analysis option "calendarContext.tz" must be a valid timezone string.')}function te(e){return e.hook==="useSemaphorMetric"?p(e.spec):e.hook==="useSemaphorAnalysis"?M(e.spec):e.hook==="useSemaphorRecords"?_(e.spec):w(e.spec)}function re(e){if(e.fieldCatalogs.length===0&&!e.requireFieldCatalog)return[];const t=se(e.fieldCatalogs,e.intent.source);return t?[...ie({...e,catalog:t}),...oe({...e,catalog:t})]:[{severity:"error",code:"invalid_source_ref",message:`Source ref for ${e.hookSpec.hook} does not match a visible Semaphor source.`,path:`${e.pathPrefix}.spec.source`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:e.intent.source}]}function ie(e){return ae(e.intent).flatMap(({field:t,path:r})=>x(e.catalog,t,e.intent.source)?[]:[{severity:"error",code:"missing_field",message:`Field "${t.name}" is not visible on the selected Semaphor source.`,path:`${e.pathPrefix}.${r}`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:u(t,e.intent.source),field:t}])}function oe(e){return("inputs"in e.intent?e.intent.inputs||[]:[]).flatMap((r,i)=>{if(!r.field)return[];const o=u(r.field,e.intent.source);return c.semaphorSourcesReferToSameDataset(o,e.intent.source)?x(e.catalog,r.field,e.intent.source)?[]:[{severity:"error",code:"missing_field",message:`Input "${r.inputId}" references field "${r.field.name}", which is not visible on the selected Semaphor source.`,path:`${e.pathPrefix}.spec.inputs.${i}.field`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:o,field:r.field}]:[{severity:"error",code:"unsupported_input_filter_composition",message:`Input "${r.inputId}" filters a different Semaphor source than the query. Cross-source Data App inputs are not supported yet.`,path:`${e.pathPrefix}.spec.inputs.${i}.field`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:o,field:r.field}]})}function ne(e){if(e.hookSpec.hook!=="useSemaphorAnalysis")return[];const t=T(e.hookSpec.spec,{pathPrefix:`${e.pathPrefix}.spec`,validateTimezone:e.validateTimezone});return t.ok?[]:t.issues.map(r=>({severity:"error",code:r.code,message:r.message,path:r.path,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:e.intent.source}))}function ae(e){return e.kind==="metric"?[...e.metrics.map((t,r)=>({field:t,path:`spec.metrics.${r}`})),...e.primaryMetric?[{field:e.primaryMetric,path:"spec.primaryMetric"}]:[],...e.dateField?[{field:e.dateField,path:"spec.dateField"}]:[],...(e.dimensions||[]).map((t,r)=>({field:t,path:`spec.dimensions.${r}`})),...e.orderBy?[{field:e.orderBy.field,path:"spec.orderBy.field"}]:[],...(e.filters||[]).map((t,r)=>({field:t.field,path:`spec.filters.${r}.field`}))]:e.kind==="records"?[...e.fields.map((t,r)=>({field:t,path:`spec.fields.${r}`})),...e.dateField?[{field:e.dateField,path:"spec.dateField"}]:[],...e.orderBy?[{field:e.orderBy.field,path:"spec.orderBy.field"}]:[]]:e.kind==="inputOptions"?[{field:e.field,path:"spec.field"}]:[]}function se(e,t){return e.find(r=>m(r,t))}function x(e,t,r){const i=u(t,r);if(m(e,i))return e.fields.find(o=>de(o,t)&&m(e,u(o,e.source)))}function m(e,t){return[e.source,...e.sourceAliases||[]].some(r=>c.semaphorSourcesReferToSameDataset(r,t))}function u(e,t){return e.source||t}function de(e,t){const r=v(e.name),i=v(t.name);return!!(r&&i&&r===i)}function v(e){return(e||"").trim().toLowerCase()}function k(e,t){return{severity:t.severity,code:e.code||"invalid_analytics_intent",message:e.message,path:e.path?`${t.pathPrefix}.spec.${e.path}`:t.pathPrefix,hook:t.hook,hookId:t.hookId,intentId:t.intent.id,source:t.intent.source}}function le(e,t){const r=R(t);return{ok:r.ok&&e.ok,errors:S([...e.errors,...r.errors]),warnings:S([...e.warnings,...r.warnings]),repairHints:[...e.repairHints,...r.repairHints]}}function R(e){const t=e.filter(i=>i.severity==="error").map(I),r=e.filter(i=>i.severity==="warning").map(I);return{ok:t.length===0,errors:t,warnings:r,repairHints:t.map(i=>{var o,n;return{code:i.code,message:i.message,fieldRole:i.fieldRole,invalidField:(o=i.repairHint)==null?void 0:o.invalidField,recommendedNextStep:((n=i.repairHint)==null?void 0:n.recommendedNextStep)||"Update the Data App SDK hook spec to use visible Semaphor source and field refs."}})}}function I(e){var t;return{code:e.code,message:e.message,path:e.path,fieldRole:e.code==="invalid_source_ref"?"source":void 0,repairHint:{code:e.code,message:e.message,invalidField:(t=e.field)==null?void 0:t.name,fieldRole:e.code==="invalid_source_ref"?"source":void 0,recommendedNextStep:e.code==="unsupported_input_filter_composition"?"Use an input field from the same Semaphor source as the query, or split the query into separate source-scoped hooks.":"Update the hook spec to use a visible Semaphor source and field ref."}}}function S(e){const t=new Set;return e.filter(r=>{const i=`${r.code}:${r.path||""}:${r.message}`;return t.has(i)?!1:(t.add(i),!0)})}function A(e){var r,i;const t=e.diagnostics.filter(o=>o.severity==="error");return{intentId:(r=e.intent)==null?void 0:r.id,status:t.length?"failed":"answered",resultShape:(i=e.intent)==null?void 0:i.kind,intent:e.intent,validation:e.validation,coverage:{answeredObligations:t.length?[]:["hook_spec_validation"],missingObligations:t.length?["hook_spec_validation"]:[],warnings:e.validation.warnings},missingFields:t.filter(o=>o.code==="missing_field").flatMap(o=>{var n;return(n=o.field)!=null&&n.name?[o.field.name]:[]}),warnings:e.diagnostics.filter(o=>o.severity==="warning").map(o=>o.message),metadata:{validationKind:"data_app_sdk_hook_spec"}}}function ce(e,t){return t.id||P(e.spec)}function P(e){if(!e||typeof e!="object"||!("id"in e))return;const t=e.id;return typeof t=="string"&&t.trim()?t:void 0}exports.hasSemaphorInputValue=F;exports.normalizeSemaphorAnalysisQueryOptions=T;exports.normalizeSemaphorInputOptions=W;exports.toSemaphorActiveInputSnapshots=Q;exports.toSemaphorAnalysisIntent=M;exports.toSemaphorAnalysisQueryOptions=D;exports.toSemaphorInputBinding=C;exports.toSemaphorInputBindings=G;exports.toSemaphorInputOptionsIntent=w;exports.toSemaphorInputSnapshots=$;exports.toSemaphorInputSpec=V;exports.toSemaphorMetricIntent=p;exports.toSemaphorRecordsIntent=_;exports.validateSemaphorDataAppHookSpecs=X;