react-semaphor 0.1.333 → 0.1.335

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 (60) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +68 -232
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +3 -3
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +435 -391
  7. package/dist/chunks/{braces-BxHNQOYk.js → braces-BLa_lORs.js} +1 -1
  8. package/dist/chunks/{braces-4vZnfI1o.js → braces-Q86XHDaD.js} +1 -1
  9. package/dist/chunks/{calendar-preferences-dialog-mY0L4X0S.js → calendar-preferences-dialog-Bm7ji3k9.js} +1 -1
  10. package/dist/chunks/{calendar-preferences-dialog-Cxj1zuet.js → calendar-preferences-dialog-Cocogo9H.js} +3 -3
  11. package/dist/chunks/catalog-field-grounding-DmT7aGUA.js +191 -0
  12. package/dist/chunks/catalog-field-grounding-VgVzDd25.js +1 -0
  13. package/dist/chunks/{chevrons-up-down-CIlNtntj.js → chevrons-up-down-BBTZ5pAY.js} +1 -1
  14. package/dist/chunks/{chevrons-up-down-oh0-U32g.js → chevrons-up-down-CYuWasy_.js} +1 -1
  15. package/dist/chunks/{dashboard-briefing-launcher-ih3HDp3Q.js → dashboard-briefing-launcher-BtqtLx1-.js} +1 -1
  16. package/dist/chunks/{dashboard-briefing-launcher-BQXscUvQ.js → dashboard-briefing-launcher-DF4CoaRn.js} +4 -4
  17. package/dist/chunks/{dashboard-controls-Dje4oqXJ.js → dashboard-controls-0VMAeMoa.js} +1 -1
  18. package/dist/chunks/{dashboard-controls-UN6XyI0w.js → dashboard-controls-B5U-VUxs.js} +6 -6
  19. package/dist/chunks/{dashboard-json-CahEbpAw.js → dashboard-json-CqbLOfnr.js} +1 -1
  20. package/dist/chunks/{dashboard-json-BB2frqlS.js → dashboard-json-Hmc0Ri5z.js} +2 -2
  21. package/dist/chunks/{edit-dashboard-visual-B9QNMn1k.js → edit-dashboard-visual-C0EDM0QB.js} +3 -3
  22. package/dist/chunks/{edit-dashboard-visual-2xDuubCd.js → edit-dashboard-visual-D4VVu-QQ.js} +1302 -1302
  23. package/dist/chunks/{index-DMilTFOG.js → index-DE0vIuYG.js} +238 -238
  24. package/dist/chunks/{index-zqZLz4DH.js → index-DzyUhzV3.js} +30507 -30454
  25. package/dist/chunks/{palette-B78b9bL_.js → palette-B9AbDw0n.js} +1 -1
  26. package/dist/chunks/{palette-BzcTKXSo.js → palette-DalASD28.js} +1 -1
  27. package/dist/chunks/{resource-management-panel-CR87UhdL.js → resource-management-panel-C4YydU9I.js} +3 -3
  28. package/dist/chunks/{resource-management-panel-BiDjNUl9.js → resource-management-panel-P9iNqBM1.js} +1 -1
  29. package/dist/chunks/{switch-DionLwdI.js → switch-BAYfpAEb.js} +1968 -2009
  30. package/dist/chunks/switch-CyRoZr5T.js +173 -0
  31. package/dist/chunks/{use-create-flow-overlay-state-UWfoDonf.js → use-create-flow-overlay-state-CbhjxI3W.js} +1 -1
  32. package/dist/chunks/{use-create-flow-overlay-state-BYZywwZQ.js → use-create-flow-overlay-state-P1LMwQ89.js} +3 -3
  33. package/dist/chunks/{use-visual-utils-Ce_aCega.js → use-visual-utils-CV6_-y4p.js} +1 -1
  34. package/dist/chunks/{use-visual-utils-rqBoCLlu.js → use-visual-utils-lB-3Zk0b.js} +2 -2
  35. package/dist/chunks/validators-BuaRUBQI.js +561 -0
  36. package/dist/chunks/validators-x74uYpnG.js +2 -0
  37. package/dist/dashboard/index.cjs +1 -1
  38. package/dist/dashboard/index.js +1 -1
  39. package/dist/dashboard-authoring/index.cjs +3 -3
  40. package/dist/dashboard-authoring/index.js +378 -377
  41. package/dist/data-app-builder/index.cjs +1 -1
  42. package/dist/data-app-builder/index.js +1 -1
  43. package/dist/data-app-builder-browser-runtime/index.cjs +1 -1
  44. package/dist/data-app-builder-browser-runtime/index.js +4 -9
  45. package/dist/data-app-sdk/index.cjs +1 -1
  46. package/dist/data-app-sdk/index.js +1 -1
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.js +7 -7
  49. package/dist/surfboard/index.cjs +1 -1
  50. package/dist/surfboard/index.js +2 -2
  51. package/dist/types/analytics-protocol.d.ts +90 -0
  52. package/dist/types/briefings.d.ts +12 -0
  53. package/dist/types/dashboard-authoring.d.ts +14 -0
  54. package/dist/types/data-app-builder.d.ts +14 -0
  55. package/dist/types/data-app-sdk.d.ts +14 -0
  56. package/dist/types/main.d.ts +16 -0
  57. package/package.json +1 -1
  58. package/dist/chunks/switch-aSDkK5PS.js +0 -173
  59. package/dist/chunks/validators-DDAweCzB.js +0 -371
  60. package/dist/chunks/validators-odlRJblR.js +0 -2
@@ -1,4 +1,4 @@
1
- "use strict";const s=require("./switch-aSDkK5PS.js"),v=require("react"),p=require("./index-DMilTFOG.js"),e=require("react/jsx-runtime");require("./index-BxM99sFL.js");const re=require("./use-visual-utils-Ce_aCega.js");/**
1
+ "use strict";const s=require("./switch-CyRoZr5T.js"),v=require("react"),p=require("./index-DE0vIuYG.js"),e=require("react/jsx-runtime");require("./index-BxM99sFL.js");const re=require("./use-visual-utils-CV6_-y4p.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
- 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-DionLwdI.js";
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-BAYfpAEb.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-zqZLz4DH.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-DzyUhzV3.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-rqBoCLlu.js";
6
+ import { u as we } from "./use-visual-utils-lB-3Zk0b.js";
7
7
  /**
8
8
  * @license lucide-react v0.453.0 - ISC
9
9
  *
@@ -1 +1 @@
1
- "use strict";const u=require("./index-DMilTFOG.js"),f=require("./switch-aSDkK5PS.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-DE0vIuYG.js"),f=require("./switch-CyRoZr5T.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,5 +1,5 @@
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-zqZLz4DH.js";
2
- import { H as ne, E as ie, u as b, G as H, I as ce } from "./switch-DionLwdI.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-DzyUhzV3.js";
2
+ import { H as ne, E as ie, u as b, G as H, I as ce } from "./switch-BAYfpAEb.js";
3
3
  import { useState as z, useEffect as de, useCallback as A } from "react";
4
4
  function le(e) {
5
5
  const [a, s] = z(null), [r, t] = z(null), o = X();
@@ -0,0 +1,561 @@
1
+ function s(e, i, n) {
2
+ return n ? { code: e, message: i, path: n } : { code: e, message: i };
3
+ }
4
+ function h(e) {
5
+ const i = /* @__PURE__ */ new Set();
6
+ for (const n of e) {
7
+ if (i.has(n))
8
+ return n;
9
+ i.add(n);
10
+ }
11
+ return null;
12
+ }
13
+ function a(e) {
14
+ return typeof e == "string" && e.trim().length > 0;
15
+ }
16
+ function f(e) {
17
+ return !!(e && typeof e == "object" && !Array.isArray(e));
18
+ }
19
+ function _(e, i, n, t = {}) {
20
+ if (!e || typeof e != "object") {
21
+ n.push(s("missing_source", "Analytics intent needs a source.", i));
22
+ return;
23
+ }
24
+ if (e.kind === "semantic") {
25
+ a(e.domainId) || n.push(
26
+ s(
27
+ "missing_semantic_domain",
28
+ "Semantic source needs a domainId.",
29
+ `${i}.domainId`
30
+ )
31
+ ), a(e.datasetName) || n.push(
32
+ s(
33
+ "missing_dataset_name",
34
+ "Semantic source needs a datasetName.",
35
+ `${i}.datasetName`
36
+ )
37
+ );
38
+ return;
39
+ }
40
+ if (e.kind === "physical") {
41
+ a(e.connectionId) || n.push(
42
+ s(
43
+ "missing_connection_id",
44
+ "Physical source needs a connectionId.",
45
+ `${i}.connectionId`
46
+ )
47
+ ), a(e.tableName) || n.push(
48
+ s(
49
+ "missing_table_name",
50
+ "Physical source needs a tableName.",
51
+ `${i}.tableName`
52
+ )
53
+ );
54
+ return;
55
+ }
56
+ if (e.kind === "sql") {
57
+ a(e.connectionId) || n.push(
58
+ s(
59
+ "missing_connection_id",
60
+ "SQL source needs a connectionId.",
61
+ `${i}.connectionId`
62
+ )
63
+ ), t.requireSqlText !== !1 && !a(e.sql) && n.push(s("missing_sql", "SQL source needs SQL text.", `${i}.sql`));
64
+ return;
65
+ }
66
+ n.push(s("invalid_source_kind", "Source kind is not supported.", i));
67
+ }
68
+ function m(e, i, n, t = {}) {
69
+ if (!e || !f(e)) {
70
+ t.required && n.push(
71
+ s("missing_field_ref", "Field reference needs a name.", i)
72
+ );
73
+ return;
74
+ }
75
+ a(e.name) || n.push(
76
+ s("missing_field_ref", "Field reference needs a name.", `${i}.name`)
77
+ ), e.source !== void 0 && _(e.source, `${i}.source`, n, {
78
+ requireSqlText: !1
79
+ });
80
+ }
81
+ function k(e, i) {
82
+ if (e.analysis === void 0)
83
+ return;
84
+ if (!f(e.analysis)) {
85
+ i.push(
86
+ s(
87
+ "invalid_metric_analysis",
88
+ "Metric analysis must be a structured object.",
89
+ "analysis"
90
+ )
91
+ );
92
+ return;
93
+ }
94
+ if (e.analysis.kind !== "period_change") {
95
+ i.push(
96
+ s(
97
+ "invalid_metric_analysis",
98
+ "Metric analysis kind is not supported.",
99
+ "analysis.kind"
100
+ )
101
+ );
102
+ return;
103
+ }
104
+ e.dateField || i.push(
105
+ s(
106
+ "missing_analysis_date_field",
107
+ "Period-change analysis needs a dateField.",
108
+ "dateField"
109
+ )
110
+ ), e.timeGrain || i.push(
111
+ s(
112
+ "missing_analysis_time_grain",
113
+ "Period-change analysis needs a timeGrain.",
114
+ "timeGrain"
115
+ )
116
+ );
117
+ const { timeWindow: n } = e.analysis;
118
+ if (n !== void 0) {
119
+ if (!f(n)) {
120
+ i.push(
121
+ s(
122
+ "invalid_time_window",
123
+ "Analysis timeWindow must be a structured object.",
124
+ "analysis.timeWindow"
125
+ )
126
+ );
127
+ return;
128
+ }
129
+ n.unit !== "day" && n.unit !== "month" && i.push(
130
+ s(
131
+ "invalid_time_window",
132
+ "Analysis timeWindow unit must be day or month.",
133
+ "analysis.timeWindow.unit"
134
+ )
135
+ ), (typeof n.value != "number" || !Number.isFinite(n.value) || n.value <= 0) && i.push(
136
+ s(
137
+ "invalid_time_window",
138
+ "Analysis timeWindow value must be a positive number.",
139
+ "analysis.timeWindow.value"
140
+ )
141
+ ), n.anchor !== void 0 && n.anchor !== "now" && n.anchor !== "latest_available" && i.push(
142
+ s(
143
+ "invalid_time_window",
144
+ "Analysis timeWindow anchor must be now or latest_available.",
145
+ "analysis.timeWindow.anchor"
146
+ )
147
+ );
148
+ }
149
+ }
150
+ function v(e) {
151
+ var t, c, d, p;
152
+ const i = [], n = [];
153
+ return !e || typeof e != "object" ? {
154
+ ok: !1,
155
+ errors: [
156
+ s(
157
+ "invalid_analytics_intent",
158
+ "Analytics intent must be a structured object."
159
+ )
160
+ ],
161
+ warnings: n,
162
+ repairHints: [
163
+ {
164
+ code: "invalid_analytics_intent",
165
+ recommendedNextStep: "Send one structured analytics intent object with kind, source, and required fields."
166
+ }
167
+ ]
168
+ } : (e.version !== void 0 && e.version !== 1 && i.push(
169
+ s("invalid_version", "Analytics intent version must be 1.", "version")
170
+ ), _(e.source, "source", i, {
171
+ requireSqlText: e.kind !== "sql" || !a(e.sql)
172
+ }), e.kind === "metric" ? (a(e.metric) || i.push(
173
+ s("missing_metric", "Metric intent needs a metric.", "metric")
174
+ ), e.metrics !== void 0 && !Array.isArray(e.metrics) ? i.push(
175
+ s(
176
+ "invalid_metric_list",
177
+ "Metric intent metrics must be an array of metric names.",
178
+ "metrics"
179
+ )
180
+ ) : Array.isArray(e.metrics) && e.metrics.some((l) => !a(l)) && i.push(
181
+ s(
182
+ "invalid_metric_list",
183
+ "Metric intent metrics must be an array of non-empty metric names.",
184
+ "metrics"
185
+ )
186
+ ), e.dimensions !== void 0 && !Array.isArray(e.dimensions) ? i.push(
187
+ s(
188
+ "invalid_metric_dimensions",
189
+ "Metric intent dimensions must be an array of field references.",
190
+ "dimensions"
191
+ )
192
+ ) : Array.isArray(e.dimensions) && e.dimensions.some(
193
+ (l) => !f(l) || !a(l.name)
194
+ ) && i.push(
195
+ s(
196
+ "invalid_metric_dimensions",
197
+ "Metric intent dimensions must be an array of field references with names.",
198
+ "dimensions"
199
+ )
200
+ ), e.dateField !== void 0 && m(e.dateField, "dateField", i), Array.isArray(e.dimensions) && e.dimensions.forEach((l, r) => {
201
+ m(l, `dimensions.${r}`, i);
202
+ }), k(e, i)) : e.kind === "records" ? (!Array.isArray(e.fields) || e.fields.length === 0 ? i.push(
203
+ s(
204
+ "missing_record_fields",
205
+ "Records intent needs at least one field.",
206
+ "fields"
207
+ )
208
+ ) : e.fields.some(
209
+ (l) => !f(l) || !a(l.name)
210
+ ) && i.push(
211
+ s(
212
+ "invalid_record_fields",
213
+ "Records intent fields must be field references with names.",
214
+ "fields"
215
+ )
216
+ ), Array.isArray(e.fields) && e.fields.forEach((l, r) => {
217
+ m(l, `fields.${r}`, i);
218
+ }), e.dateField !== void 0 && m(e.dateField, "dateField", i)) : e.kind === "inputOptions" ? ((!e.field || !a(e.field.name)) && i.push(
219
+ s(
220
+ "missing_input_options_field",
221
+ "Input options intent needs a field.",
222
+ "field"
223
+ )
224
+ ), m(e.field, "field", i, { required: !0 })) : e.kind === "sql" ? (((t = e.source) == null ? void 0 : t.kind) !== "sql" && ((c = e.source) == null ? void 0 : c.kind) !== "physical" && i.push(
225
+ s(
226
+ "invalid_sql_source",
227
+ "SQL analytics intent must use a SQL or physical source.",
228
+ "source"
229
+ )
230
+ ), a(e.sql) && ((d = e.source) == null ? void 0 : d.kind) === "sql" && a(e.source.sql) && y(e.sql) !== y(e.source.sql) && i.push(
231
+ s(
232
+ "conflicting_sql",
233
+ "SQL analytics intent cannot define different SQL text in source.sql and sql.",
234
+ "sql"
235
+ )
236
+ ), !a(e.sql) && !(((p = e.source) == null ? void 0 : p.kind) === "sql" && a(e.source.sql)) && i.push(s("missing_sql", "SQL analytics intent needs SQL text.", "sql")), Array.isArray(e.fields) && e.fields.forEach((l, r) => {
237
+ m(l, `fields.${r}`, i);
238
+ })) : i.push(
239
+ s("invalid_analytics_kind", "Analytics kind is not supported.", "kind")
240
+ ), {
241
+ ok: i.length === 0,
242
+ errors: i,
243
+ warnings: n,
244
+ repairHints: q(i)
245
+ });
246
+ }
247
+ function y(e) {
248
+ return e.replace(/\r\n/g, `
249
+ `).trim();
250
+ }
251
+ function A(e) {
252
+ const i = [], n = [];
253
+ if (!e || typeof e != "object")
254
+ return {
255
+ ok: !1,
256
+ errors: [
257
+ s(
258
+ "invalid_operation_intent",
259
+ "Operation intent must be a structured object."
260
+ )
261
+ ],
262
+ warnings: n,
263
+ repairHints: [
264
+ {
265
+ code: "invalid_operation_intent",
266
+ recommendedNextStep: "Send one typed operation intent with version, kind, and required operation fields."
267
+ }
268
+ ]
269
+ };
270
+ if (e.version !== 1 && i.push(
271
+ s("invalid_version", "Operation intent version must be 1.", "version")
272
+ ), e.kind === "answer_obligations")
273
+ !Array.isArray(e.obligations) || e.obligations.length === 0 ? i.push(
274
+ s(
275
+ "missing_obligations",
276
+ "Answer-obligations operation intent needs at least one obligation.",
277
+ "obligations"
278
+ )
279
+ ) : e.obligations.forEach((t, c) => {
280
+ a(t.id) || i.push(
281
+ s(
282
+ "missing_obligation_id",
283
+ "Each analytics obligation needs an id.",
284
+ `obligations.${c}.id`
285
+ )
286
+ ), a(t.prompt) || i.push(
287
+ s(
288
+ "missing_obligation_prompt",
289
+ "Each analytics obligation needs a prompt.",
290
+ `obligations.${c}.prompt`
291
+ )
292
+ );
293
+ });
294
+ else if (e.kind === "dashboard_change" || e.kind === "data_app_change") {
295
+ if (a(e.instruction) || i.push(
296
+ s(
297
+ "missing_instruction",
298
+ "Change operation intent needs an instruction.",
299
+ "instruction"
300
+ )
301
+ ), e.analyticsIntent) {
302
+ const t = v(
303
+ e.analyticsIntent
304
+ );
305
+ i.push(...t.errors), n.push(...t.warnings);
306
+ }
307
+ } else
308
+ i.push(
309
+ s(
310
+ "invalid_operation_kind",
311
+ "Operation intent kind is not supported.",
312
+ "kind"
313
+ )
314
+ );
315
+ return {
316
+ ok: i.length === 0,
317
+ errors: i,
318
+ warnings: n,
319
+ repairHints: b(i)
320
+ };
321
+ }
322
+ function x(e) {
323
+ const i = [], n = [];
324
+ if (!e || typeof e != "object")
325
+ return {
326
+ ok: !1,
327
+ errors: [
328
+ s(
329
+ "invalid_recovery_plan",
330
+ "Analytics recovery plan must be a structured object."
331
+ )
332
+ ],
333
+ warnings: n,
334
+ repairHints: [
335
+ {
336
+ code: "invalid_recovery_plan",
337
+ recommendedNextStep: "Return a typed recovery plan with operationIntent and plannedToolCalls."
338
+ }
339
+ ]
340
+ };
341
+ e.version !== 1 && i.push(
342
+ s("invalid_version", "Recovery plan version must be 1.", "version")
343
+ ), e.kind !== "analytics_recovery_plan" && i.push(
344
+ s(
345
+ "invalid_recovery_plan_kind",
346
+ "Recovery plan kind must be analytics_recovery_plan.",
347
+ "kind"
348
+ )
349
+ );
350
+ const t = A(e.operationIntent);
351
+ return i.push(...t.errors), n.push(...t.warnings), Array.isArray(e.plannedToolCalls) || i.push(
352
+ s(
353
+ "invalid_planned_tool_calls",
354
+ "Recovery plan plannedToolCalls must be an array.",
355
+ "plannedToolCalls"
356
+ )
357
+ ), {
358
+ ok: i.length === 0,
359
+ errors: i,
360
+ warnings: n,
361
+ repairHints: b(i)
362
+ };
363
+ }
364
+ function b(e) {
365
+ return e.map((i) => ({
366
+ code: i.code,
367
+ recommendedNextStep: i.code === "missing_obligations" ? "Normalize the user request into one or more typed analytics obligations before recovery planning." : "Correct the operation/recovery contract shape before planning execution."
368
+ }));
369
+ }
370
+ function q(e) {
371
+ return e.map((i) => {
372
+ switch (i.code) {
373
+ case "missing_source":
374
+ return {
375
+ code: i.code,
376
+ fieldRole: "source",
377
+ recommendedNextStep: "Provide a semantic, physical, or SQL source before executing analytics."
378
+ };
379
+ case "missing_metric":
380
+ return {
381
+ code: i.code,
382
+ fieldRole: "metric",
383
+ recommendedNextStep: "Choose one exact metric from the grounded schema candidates."
384
+ };
385
+ case "missing_record_fields":
386
+ return {
387
+ code: i.code,
388
+ fieldRole: "dimension",
389
+ recommendedNextStep: "Provide at least one field for the records intent."
390
+ };
391
+ case "missing_input_options_field":
392
+ return {
393
+ code: i.code,
394
+ fieldRole: "input",
395
+ recommendedNextStep: "Provide the exact field whose option values should be listed."
396
+ };
397
+ case "missing_sql":
398
+ return {
399
+ code: i.code,
400
+ fieldRole: "sql",
401
+ recommendedNextStep: "Provide bounded read-only SQL with an explicit outer LIMIT."
402
+ };
403
+ case "conflicting_sql":
404
+ return {
405
+ code: i.code,
406
+ fieldRole: "sql",
407
+ recommendedNextStep: "Use one canonical SQL text location for the intent; prefer top-level sql."
408
+ };
409
+ case "missing_semantic_domain":
410
+ case "missing_dataset_name":
411
+ case "missing_connection_id":
412
+ case "missing_table_name":
413
+ return {
414
+ code: i.code,
415
+ fieldRole: "source",
416
+ recommendedNextStep: "Use grounded catalog metadata to fill the missing source reference."
417
+ };
418
+ default:
419
+ return;
420
+ }
421
+ }).filter((i) => !!i);
422
+ }
423
+ function S(e, i, n, t) {
424
+ if (!e || typeof e != "object") {
425
+ n.push(s("invalid_view", "Dashboard view must be an object.", i));
426
+ return;
427
+ }
428
+ if (a(e.title) || n.push(s("missing_view_title", "Dashboard view needs a title.", i)), !e.presentation || typeof e.presentation != "object") {
429
+ n.push(
430
+ s(
431
+ "missing_presentation",
432
+ "Dashboard view needs a presentation.",
433
+ `${i}.presentation`
434
+ )
435
+ );
436
+ return;
437
+ }
438
+ if (e.presentation.kind === "text") {
439
+ a(e.text) || t.push(
440
+ s(
441
+ "missing_text_content",
442
+ "Text views should include text content.",
443
+ `${i}.text`
444
+ )
445
+ );
446
+ return;
447
+ }
448
+ if (!e.analytics) {
449
+ n.push(
450
+ s(
451
+ "missing_view_analytics",
452
+ "Non-text dashboard views need analytics intent.",
453
+ `${i}.analytics`
454
+ )
455
+ );
456
+ return;
457
+ }
458
+ const c = v(e.analytics);
459
+ for (const d of c.errors)
460
+ n.push(
461
+ s(d.code, d.message, `${i}.analytics${d.path ? `.${d.path}` : ""}`)
462
+ );
463
+ for (const d of c.warnings)
464
+ t.push(
465
+ s(
466
+ d.code,
467
+ d.message,
468
+ `${i}.analytics${d.path ? `.${d.path}` : ""}`
469
+ )
470
+ );
471
+ }
472
+ function $(e) {
473
+ const i = [], n = [];
474
+ if (!e || typeof e != "object")
475
+ return {
476
+ ok: !1,
477
+ errors: [
478
+ s(
479
+ "invalid_dashboard_intent",
480
+ "Dashboard intent must be a structured object."
481
+ )
482
+ ],
483
+ warnings: n
484
+ };
485
+ e.version !== 1 && i.push(s("invalid_version", "Dashboard intent version must be 1.")), e.kind !== "dashboard" && i.push(s("invalid_kind", "Experience intent kind must be dashboard.")), a(e.title) || i.push(s("missing_title", "Dashboard intent needs a title.", "title"));
486
+ const t = Array.isArray(e.inputs) ? e.inputs : [], c = h(
487
+ t.filter(f).map((r) => r.id).filter((r) => typeof r == "string")
488
+ );
489
+ c && i.push(
490
+ s(
491
+ "duplicate_input_id",
492
+ `Duplicate input id: ${c}.`,
493
+ "inputs"
494
+ )
495
+ );
496
+ for (const [r, o] of t.entries()) {
497
+ const u = `inputs.${r}`;
498
+ if (!f(o)) {
499
+ i.push(s("invalid_input", "Dashboard input must be an object.", u));
500
+ continue;
501
+ }
502
+ a(o.id) || i.push(s("missing_input_id", "Input needs an id.", `${u}.id`)), a(o.label) || i.push(
503
+ s("missing_input_label", "Input needs a label.", `${u}.label`)
504
+ ), !o.field || !a(o.field.name) ? i.push(
505
+ s("missing_input_field", "Input needs a field.", `${u}.field`)
506
+ ) : m(o.field, `${u}.field`, i), o.source && _(o.source, `${u}.source`, i);
507
+ }
508
+ const d = Array.isArray(e.sections) ? e.sections : [];
509
+ d.length === 0 && i.push(
510
+ s(
511
+ "missing_sections",
512
+ "Dashboard intent needs at least one section.",
513
+ "sections"
514
+ )
515
+ );
516
+ const p = d.flatMap(
517
+ (r) => r && typeof r == "object" && Array.isArray(r.views) ? r.views.filter(f).map((o) => o.id).filter((o) => !!o) : []
518
+ ), l = h(p);
519
+ l && i.push(
520
+ s(
521
+ "duplicate_view_id",
522
+ `Duplicate dashboard view id: ${l}.`,
523
+ "sections"
524
+ )
525
+ );
526
+ for (const [r, o] of d.entries()) {
527
+ const u = `sections.${r}`;
528
+ if (!o || typeof o != "object") {
529
+ i.push(
530
+ s("invalid_section", "Dashboard section must be an object.", u)
531
+ );
532
+ continue;
533
+ }
534
+ if (a(o.title) || i.push(
535
+ s("missing_section_title", "Dashboard section needs a title.", u)
536
+ ), !Array.isArray(o.views) || o.views.length === 0) {
537
+ i.push(
538
+ s(
539
+ "missing_section_views",
540
+ "Dashboard section needs at least one view.",
541
+ `${u}.views`
542
+ )
543
+ );
544
+ continue;
545
+ }
546
+ for (const [g, w] of o.views.entries())
547
+ S(
548
+ w,
549
+ `${u}.views.${g}`,
550
+ i,
551
+ n
552
+ );
553
+ }
554
+ return { ok: i.length === 0, errors: i, warnings: n };
555
+ }
556
+ export {
557
+ A as a,
558
+ x as b,
559
+ $ as c,
560
+ v
561
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";function s(e,i,n){return n?{code:e,message:i,path:n}:{code:e,message:i}}function y(e){const i=new Set;for(const n of e){if(i.has(n))return n;i.add(n)}return null}function a(e){return typeof e=="string"&&e.trim().length>0}function m(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function _(e,i,n,t={}){if(!e||typeof e!="object"){n.push(s("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){a(e.domainId)||n.push(s("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),a(e.datasetName)||n.push(s("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){a(e.connectionId)||n.push(s("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),a(e.tableName)||n.push(s("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){a(e.connectionId)||n.push(s("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`)),t.requireSqlText!==!1&&!a(e.sql)&&n.push(s("missing_sql","SQL source needs SQL text.",`${i}.sql`));return}n.push(s("invalid_source_kind","Source kind is not supported.",i))}function f(e,i,n,t={}){if(!e||!m(e)){t.required&&n.push(s("missing_field_ref","Field reference needs a name.",i));return}a(e.name)||n.push(s("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&_(e.source,`${i}.source`,n,{requireSqlText:!1})}function k(e,i){if(e.analysis===void 0)return;if(!m(e.analysis)){i.push(s("invalid_metric_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(s("invalid_metric_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(s("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(s("missing_analysis_time_grain","Period-change analysis needs a timeGrain.","timeGrain"));const{timeWindow:n}=e.analysis;if(n!==void 0){if(!m(n)){i.push(s("invalid_time_window","Analysis timeWindow must be a structured object.","analysis.timeWindow"));return}n.unit!=="day"&&n.unit!=="month"&&i.push(s("invalid_time_window","Analysis timeWindow unit must be day or month.","analysis.timeWindow.unit")),(typeof n.value!="number"||!Number.isFinite(n.value)||n.value<=0)&&i.push(s("invalid_time_window","Analysis timeWindow value must be a positive number.","analysis.timeWindow.value")),n.anchor!==void 0&&n.anchor!=="now"&&n.anchor!=="latest_available"&&i.push(s("invalid_time_window","Analysis timeWindow anchor must be now or latest_available.","analysis.timeWindow.anchor"))}}function h(e){var t,c,d,p;const i=[],n=[];return!e||typeof e!="object"?{ok:!1,errors:[s("invalid_analytics_intent","Analytics intent must be a structured object.")],warnings:n,repairHints:[{code:"invalid_analytics_intent",recommendedNextStep:"Send one structured analytics intent object with kind, source, and required fields."}]}:(e.version!==void 0&&e.version!==1&&i.push(s("invalid_version","Analytics intent version must be 1.","version")),_(e.source,"source",i,{requireSqlText:e.kind!=="sql"||!a(e.sql)}),e.kind==="metric"?(a(e.metric)||i.push(s("missing_metric","Metric intent needs a metric.","metric")),e.metrics!==void 0&&!Array.isArray(e.metrics)?i.push(s("invalid_metric_list","Metric intent metrics must be an array of metric names.","metrics")):Array.isArray(e.metrics)&&e.metrics.some(l=>!a(l))&&i.push(s("invalid_metric_list","Metric intent metrics must be an array of non-empty metric names.","metrics")),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(s("invalid_metric_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(l=>!m(l)||!a(l.name))&&i.push(s("invalid_metric_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions")),e.dateField!==void 0&&f(e.dateField,"dateField",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((l,r)=>{f(l,`dimensions.${r}`,i)}),k(e,i)):e.kind==="records"?(!Array.isArray(e.fields)||e.fields.length===0?i.push(s("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(l=>!m(l)||!a(l.name))&&i.push(s("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((l,r)=>{f(l,`fields.${r}`,i)}),e.dateField!==void 0&&f(e.dateField,"dateField",i)):e.kind==="inputOptions"?((!e.field||!a(e.field.name))&&i.push(s("missing_input_options_field","Input options intent needs a field.","field")),f(e.field,"field",i,{required:!0})):e.kind==="sql"?(((t=e.source)==null?void 0:t.kind)!=="sql"&&((c=e.source)==null?void 0:c.kind)!=="physical"&&i.push(s("invalid_sql_source","SQL analytics intent must use a SQL or physical source.","source")),a(e.sql)&&((d=e.source)==null?void 0:d.kind)==="sql"&&a(e.source.sql)&&v(e.sql)!==v(e.source.sql)&&i.push(s("conflicting_sql","SQL analytics intent cannot define different SQL text in source.sql and sql.","sql")),!a(e.sql)&&!(((p=e.source)==null?void 0:p.kind)==="sql"&&a(e.source.sql))&&i.push(s("missing_sql","SQL analytics intent needs SQL text.","sql")),Array.isArray(e.fields)&&e.fields.forEach((l,r)=>{f(l,`fields.${r}`,i)})):i.push(s("invalid_analytics_kind","Analytics kind is not supported.","kind")),{ok:i.length===0,errors:i,warnings:n,repairHints:q(i)})}function v(e){return e.replace(/\r\n/g,`
2
+ `).trim()}function b(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_operation_intent","Operation intent must be a structured object.")],warnings:n,repairHints:[{code:"invalid_operation_intent",recommendedNextStep:"Send one typed operation intent with version, kind, and required operation fields."}]};if(e.version!==1&&i.push(s("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(s("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((t,c)=>{a(t.id)||i.push(s("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${c}.id`)),a(t.prompt)||i.push(s("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${c}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(a(e.instruction)||i.push(s("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const t=h(e.analyticsIntent);i.push(...t.errors),n.push(...t.warnings)}}else i.push(s("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:g(i)}}function S(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_recovery_plan","Analytics recovery plan must be a structured object.")],warnings:n,repairHints:[{code:"invalid_recovery_plan",recommendedNextStep:"Return a typed recovery plan with operationIntent and plannedToolCalls."}]};e.version!==1&&i.push(s("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(s("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const t=b(e.operationIntent);return i.push(...t.errors),n.push(...t.warnings),Array.isArray(e.plannedToolCalls)||i.push(s("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:n,repairHints:g(i)}}function g(e){return e.map(i=>({code:i.code,recommendedNextStep:i.code==="missing_obligations"?"Normalize the user request into one or more typed analytics obligations before recovery planning.":"Correct the operation/recovery contract shape before planning execution."}))}function q(e){return e.map(i=>{switch(i.code){case"missing_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Provide a semantic, physical, or SQL source before executing analytics."};case"missing_metric":return{code:i.code,fieldRole:"metric",recommendedNextStep:"Choose one exact metric from the grounded schema candidates."};case"missing_record_fields":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide at least one field for the records intent."};case"missing_input_options_field":return{code:i.code,fieldRole:"input",recommendedNextStep:"Provide the exact field whose option values should be listed."};case"missing_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Provide bounded read-only SQL with an explicit outer LIMIT."};case"conflicting_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Use one canonical SQL text location for the intent; prefer top-level sql."};case"missing_semantic_domain":case"missing_dataset_name":case"missing_connection_id":case"missing_table_name":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use grounded catalog metadata to fill the missing source reference."};default:return}}).filter(i=>!!i)}function x(e,i,n,t){if(!e||typeof e!="object"){n.push(s("invalid_view","Dashboard view must be an object.",i));return}if(a(e.title)||n.push(s("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){n.push(s("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){a(e.text)||t.push(s("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){n.push(s("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}const c=h(e.analytics);for(const d of c.errors)n.push(s(d.code,d.message,`${i}.analytics${d.path?`.${d.path}`:""}`));for(const d of c.warnings)t.push(s(d.code,d.message,`${i}.analytics${d.path?`.${d.path}`:""}`))}function $(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:n};e.version!==1&&i.push(s("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(s("invalid_kind","Experience intent kind must be dashboard.")),a(e.title)||i.push(s("missing_title","Dashboard intent needs a title.","title"));const t=Array.isArray(e.inputs)?e.inputs:[],c=y(t.filter(m).map(r=>r.id).filter(r=>typeof r=="string"));c&&i.push(s("duplicate_input_id",`Duplicate input id: ${c}.`,"inputs"));for(const[r,o]of t.entries()){const u=`inputs.${r}`;if(!m(o)){i.push(s("invalid_input","Dashboard input must be an object.",u));continue}a(o.id)||i.push(s("missing_input_id","Input needs an id.",`${u}.id`)),a(o.label)||i.push(s("missing_input_label","Input needs a label.",`${u}.label`)),!o.field||!a(o.field.name)?i.push(s("missing_input_field","Input needs a field.",`${u}.field`)):f(o.field,`${u}.field`,i),o.source&&_(o.source,`${u}.source`,i)}const d=Array.isArray(e.sections)?e.sections:[];d.length===0&&i.push(s("missing_sections","Dashboard intent needs at least one section.","sections"));const p=d.flatMap(r=>r&&typeof r=="object"&&Array.isArray(r.views)?r.views.filter(m).map(o=>o.id).filter(o=>!!o):[]),l=y(p);l&&i.push(s("duplicate_view_id",`Duplicate dashboard view id: ${l}.`,"sections"));for(const[r,o]of d.entries()){const u=`sections.${r}`;if(!o||typeof o!="object"){i.push(s("invalid_section","Dashboard section must be an object.",u));continue}if(a(o.title)||i.push(s("missing_section_title","Dashboard section needs a title.",u)),!Array.isArray(o.views)||o.views.length===0){i.push(s("missing_section_views","Dashboard section needs at least one view.",`${u}.views`));continue}for(const[w,A]of o.views.entries())x(A,`${u}.views.${w}`,i,n)}return{ok:i.length===0,errors:i,warnings:n}}exports.validateSemaphorAnalyticsIntent=h;exports.validateSemaphorAnalyticsRecoveryPlan=S;exports.validateSemaphorDashboardIntent=$;exports.validateSemaphorOperationIntent=b;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-DMilTFOG.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-DE0vIuYG.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as o } from "../chunks/index-zqZLz4DH.js";
1
+ import { D as o } from "../chunks/index-DzyUhzV3.js";
2
2
  import { C as s, E as C } from "../chunks/common-types-4bjoIgvm.js";
3
3
  export {
4
4
  s as CONTROL_CARD_DEFAULT_VALUE,