react-semaphor 0.1.325 → 0.1.327

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 (68) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +260 -226
  3. package/dist/brand-studio/index.cjs +2 -2
  4. package/dist/brand-studio/index.js +7 -6
  5. package/dist/chunks/{braces-ZjRH2Kl7.js → braces-B6qRDu1H.js} +1 -1
  6. package/dist/chunks/{braces-C7BeIXvM.js → braces-BGWZEnQJ.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog-DHhT6Sja.js → calendar-preferences-dialog-CjwbE_82.js} +6 -5
  8. package/dist/chunks/calendar-preferences-dialog-fkLUMJyR.js +1 -0
  9. package/dist/chunks/{chevrons-up-down-CA-XvN1o.js → chevrons-up-down-BpsogQvv.js} +1 -1
  10. package/dist/chunks/{chevrons-up-down-Cuilz9aY.js → chevrons-up-down-xG-bVFD9.js} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-DZiFMK8I.js → dashboard-briefing-launcher-Co57xBfS.js} +2 -2
  12. package/dist/chunks/{dashboard-briefing-launcher-BzIxRlzW.js → dashboard-briefing-launcher-Cy1nWZRW.js} +714 -719
  13. package/dist/chunks/{dashboard-controls-DVwsWny9.js → dashboard-controls-BWnVEFJq.js} +10 -9
  14. package/dist/chunks/{dashboard-controls-BX693lE0.js → dashboard-controls-C7rOGZO-.js} +1 -1
  15. package/dist/chunks/{dashboard-json-D15C_I9e.js → dashboard-json-BpRNSsF3.js} +7 -6
  16. package/dist/chunks/dashboard-json-DBPMknGo.js +1 -0
  17. package/dist/chunks/date-formatter-B4EBSe9C.js +1 -0
  18. package/dist/chunks/date-formatter-CzcPZx39.js +416 -0
  19. package/dist/chunks/edit-dashboard-visual-B2vkIKEa.js +178 -0
  20. package/dist/chunks/{edit-dashboard-visual-wQyJEcVH.js → edit-dashboard-visual-CYf26co_.js} +8243 -7784
  21. package/dist/chunks/index-BD90s-wf.js +1309 -0
  22. package/dist/chunks/index-BxM99sFL.js +1 -0
  23. package/dist/chunks/index-CuHybtft.js +51 -0
  24. package/dist/chunks/{index-CffvIaZO.js → index-DTlbYpxd.js} +29440 -28968
  25. package/dist/chunks/{palette-D96DOM7E.js → palette-CSF7IVJn.js} +1 -1
  26. package/dist/chunks/{palette-CanPG11m.js → palette-CWgEPBoG.js} +1 -1
  27. package/dist/chunks/{resource-management-panel-DlnrD0y-.js → resource-management-panel-D6nbfJY3.js} +1 -1
  28. package/dist/chunks/{resource-management-panel-CLoO2DL3.js → resource-management-panel-D893Onv8.js} +6 -5
  29. package/dist/chunks/{save-CqrBQKG6.js → save-CtQbSub2.js} +1 -1
  30. package/dist/chunks/{save-DxkSzUTZ.js → save-DRdFKF57.js} +1 -1
  31. package/dist/chunks/switch-DJJJD_g1.js +168 -0
  32. package/dist/chunks/{switch-Deo2Ltmj.js → switch-DKf6vHfP.js} +2222 -2228
  33. package/dist/chunks/{use-create-flow-overlay-state-DocFanjO.js → use-create-flow-overlay-state-C4LgoK8q.js} +1 -1
  34. package/dist/chunks/{use-create-flow-overlay-state-DsPoCfMu.js → use-create-flow-overlay-state-p21zs2p6.js} +29 -28
  35. package/dist/chunks/{use-visual-utils-BdO22fQZ.js → use-visual-utils-BKBua6o4.js} +2 -2
  36. package/dist/chunks/{use-visual-utils-DSbXQQD1.js → use-visual-utils-BqWm0QeW.js} +1 -1
  37. package/dist/chunks/validators-DDAweCzB.js +371 -0
  38. package/dist/chunks/validators-odlRJblR.js +2 -0
  39. package/dist/dashboard/index.cjs +1 -1
  40. package/dist/dashboard/index.js +1 -1
  41. package/dist/dashboard-authoring/index.cjs +3 -3
  42. package/dist/dashboard-authoring/index.js +919 -507
  43. package/dist/data-app-sdk/index.cjs +1 -0
  44. package/dist/data-app-sdk/index.js +512 -0
  45. package/dist/format-utils/index.cjs +4 -4
  46. package/dist/format-utils/index.js +22 -21
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.js +141 -140
  49. package/dist/style.css +1 -1
  50. package/dist/surfboard/index.cjs +1 -1
  51. package/dist/surfboard/index.js +2 -2
  52. package/dist/types/analytics-protocol.d.ts +326 -2
  53. package/dist/types/dashboard-authoring.d.ts +102 -3
  54. package/dist/types/dashboard.d.ts +23 -3
  55. package/dist/types/data-app-sdk.d.ts +379 -0
  56. package/dist/types/format-utils.d.ts +25 -0
  57. package/dist/types/main.d.ts +182 -12
  58. package/dist/types/shared.d.ts +18 -2
  59. package/dist/types/surfboard.d.ts +23 -3
  60. package/dist/types/types.d.ts +38 -4
  61. package/package.json +6 -1
  62. package/dist/chunks/calendar-preferences-dialog-BxeROxyq.js +0 -1
  63. package/dist/chunks/dashboard-json-DxNEFM-p.js +0 -1
  64. package/dist/chunks/date-formatter-D9Bvw5Qk.js +0 -1
  65. package/dist/chunks/date-formatter-DyIOb6uC.js +0 -333
  66. package/dist/chunks/edit-dashboard-visual-90_qEgRc.js +0 -178
  67. package/dist/chunks/index-YTk9Hab2.js +0 -1303
  68. package/dist/chunks/switch-BXICAlvS.js +0 -168
@@ -1,4 +1,4 @@
1
- "use strict";const s=require("./switch-BXICAlvS.js"),v=require("react"),p=require("./index-YTk9Hab2.js"),e=require("react/jsx-runtime"),re=require("./use-visual-utils-DSbXQQD1.js"),he=require("./save-CqrBQKG6.js");/**
1
+ "use strict";const s=require("./switch-DJJJD_g1.js"),v=require("react"),p=require("./index-BD90s-wf.js"),e=require("react/jsx-runtime");require("./index-BxM99sFL.js");const re=require("./use-visual-utils-BqWm0QeW.js"),he=require("./save-CtQbSub2.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,16 +1,17 @@
1
- import { c as te, G as L, H as ne, u as oe, Y as ft, Z as ht, _ as bt, a as ie, a0 as gt, a8 as yt, B as V, e as xt, X as $e, E as Ke, f as Ye, a9 as vt, aa as Ct, ab as se, ac as Ae, ad as ze, ae as ge, af as ye, ag as kt, ah as Me, ai as Nt, aj as St, ak as le, al as Dt, am as Oe, g as Be, an as Ge, ao as Xe, ap as Je, L as K, a1 as Ze, a2 as xe, a3 as ve, a4 as Ce, a5 as ke, a6 as Ne, aq as We, ar as wt, as as It, at as Re, au as Et, av as Qe, aw as Tt, ax as Se } from "./switch-Deo2Ltmj.js";
1
+ import { c as te, G as L, H as ne, u as oe, Y as ft, Z as ht, _ as bt, a as ie, a0 as gt, a8 as yt, B as V, e as xt, X as $e, E as Ke, f as Ye, a9 as vt, aa as Ct, ab as se, ac as Ae, ad as ze, ae as ge, af as ye, ag as kt, ah as Me, ai as Nt, aj as St, ak as le, al as Dt, am as Oe, g as Be, an as Ge, ao as Xe, ap as Je, L as K, a1 as Ze, a2 as xe, a3 as ve, a4 as Ce, a5 as ke, a6 as Ne, aq as We, ar as wt, as as It, at as Re, au as Et, av as Qe, aw as Tt, ax as Se } from "./switch-DKf6vHfP.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 { ak as _t, al as et, am as qt, an as Ft, ao as Lt, ap as At, aq as zt, x as Mt, ar as Ot, ad as ue, as as tt, af as at, at as rt, au as Bt, o as R, av as Rt, aw as Qt, ax as je, ay as jt, az as Ut, aA as st, aB as lt, aC as Ht, aD as Pt, aE as $t, aF as Kt, aG as Yt, aH as Gt, aI as Xt, aJ as Jt } from "./index-CffvIaZO.js";
3
+ import { ak as _t, al as et, am as qt, an as Ft, ao as Lt, ap as At, aq as zt, x as Mt, ar as Ot, ad as ue, as as tt, af as at, at as rt, au as Bt, o as R, av as Rt, aw as Qt, ax as je, ay as jt, az as Ut, aA as st, aB as lt, aC as Ht, aD as Pt, aE as $t, aF as Kt, aG as Yt, aH as Gt, aI as Xt, aJ as Jt } from "./index-DTlbYpxd.js";
4
4
  import { jsx as t, jsxs as d, Fragment as P } from "react/jsx-runtime";
5
- import { u as we } from "./use-visual-utils-BdO22fQZ.js";
6
- import { S as nt } from "./save-DxkSzUTZ.js";
5
+ import "./index-CuHybtft.js";
6
+ import { u as we } from "./use-visual-utils-BKBua6o4.js";
7
+ import { S as nt } from "./save-DRdFKF57.js";
7
8
  /**
8
9
  * @license lucide-react v0.453.0 - ISC
9
10
  *
10
11
  * This source code is licensed under the ISC license.
11
12
  * See the LICENSE file in the root directory of this source tree.
12
13
  */
13
- const ua = te("CircleX", [
14
+ const pa = te("CircleX", [
14
15
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
15
16
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
16
17
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
@@ -44,7 +45,7 @@ const Wt = te("Link2", [
44
45
  * This source code is licensed under the ISC license.
45
46
  * See the LICENSE file in the root directory of this source tree.
46
47
  */
47
- const pa = te("Rows3", [
48
+ const ma = te("Rows3", [
48
49
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
49
50
  ["path", { d: "M21 9H3", key: "1338ky" }],
50
51
  ["path", { d: "M21 15H3", key: "9uk58r" }]
@@ -55,7 +56,7 @@ const pa = te("Rows3", [
55
56
  * This source code is licensed under the ISC license.
56
57
  * See the LICENSE file in the root directory of this source tree.
57
58
  */
58
- const ma = te("SendHorizontal", [
59
+ const fa = te("SendHorizontal", [
59
60
  [
60
61
  "path",
61
62
  {
@@ -65,7 +66,7 @@ const ma = te("SendHorizontal", [
65
66
  ],
66
67
  ["path", { d: "M6 12h16", key: "s4cdu5" }]
67
68
  ]);
68
- function fa() {
69
+ function ha() {
69
70
  const s = L((h) => h.card.dataSource), {
70
71
  setSelectedConnectionId: r,
71
72
  setSelectedDatabaseName: o,
@@ -124,7 +125,7 @@ function ot() {
124
125
  p == null ? void 0 : p.slots
125
126
  ) ?? s.type, [o, u, y, s, p == null ? void 0 : p.slots]);
126
127
  }
127
- function ha({
128
+ function ba({
128
129
  type: s,
129
130
  isLinked: r,
130
131
  className: o,
@@ -223,7 +224,7 @@ function Ie(s) {
223
224
  const r = vt(s);
224
225
  return r ? (R.error(r), !1) : !0;
225
226
  }
226
- function ba({
227
+ function ga({
227
228
  className: s,
228
229
  variant: r = "outline"
229
230
  }) {
@@ -246,7 +247,7 @@ function ba({
246
247
  }
247
248
  );
248
249
  }
249
- function ga({
250
+ function ya({
250
251
  className: s,
251
252
  variant: r = "default"
252
253
  }) {
@@ -298,7 +299,7 @@ function ga({
298
299
  }
299
300
  );
300
301
  }
301
- function ya({
302
+ function xa({
302
303
  className: s
303
304
  }) {
304
305
  const r = ue(), [o, i] = Q(!1), p = at(), u = L((N) => N.frame), h = oe((N) => N.selectedSheetId), y = oe((N) => N.dashboard), { updateFrame: b, setIsVisualEditing: v } = Ke(), { getUpdatedFrame: g } = we(), m = rt(), x = Bt();
@@ -361,7 +362,7 @@ function ya({
361
362
  }
362
363
  );
363
364
  }
364
- function xa({ className: s }) {
365
+ function va({ className: s }) {
365
366
  const { setTempQueryData: r, setSqlGen: o } = ne(), i = ue(), p = L((m) => m.tempQueryData), u = L((m) => m.onClose), h = L((m) => m.card), y = ot(), b = z(() => y !== h.type ? { ...h, type: y } : h, [h, y]), { queryKey: v } = tt(b);
366
367
  function g() {
367
368
  if (p) {
@@ -384,7 +385,7 @@ function xa({ className: s }) {
384
385
  }
385
386
  );
386
387
  }
387
- function va({
388
+ function Ca({
388
389
  label: s = "Clear",
389
390
  variant: r = "secondary",
390
391
  className: o
@@ -697,7 +698,7 @@ function sa(s) {
697
698
  defaultValue: le(o, void 0)
698
699
  };
699
700
  }
700
- function Ca({
701
+ function ka({
701
702
  scope: s,
702
703
  controls: r,
703
704
  reservedControlIds: o,
@@ -1593,7 +1594,7 @@ function Ca({
1593
1594
  )
1594
1595
  ] });
1595
1596
  }
1596
- function ka(s) {
1597
+ function Na(s) {
1597
1598
  const {
1598
1599
  open: r,
1599
1600
  onOpenChange: o,
@@ -1628,19 +1629,19 @@ function ka(s) {
1628
1629
  };
1629
1630
  }
1630
1631
  export {
1631
- ua as C,
1632
- ba as E,
1632
+ pa as C,
1633
+ ga as E,
1633
1634
  Zt as L,
1634
- pa as R,
1635
- ma as S,
1636
- ha as V,
1637
- xa as a,
1638
- ga as b,
1639
- ya as c,
1635
+ ma as R,
1636
+ fa as S,
1637
+ ba as V,
1638
+ va as a,
1639
+ ya as b,
1640
+ xa as c,
1640
1641
  Wt as d,
1641
- Ca as e,
1642
- fa as f,
1642
+ ka as e,
1643
+ ha as f,
1643
1644
  ot as g,
1644
- va as h,
1645
- ka as u
1645
+ Ca as h,
1646
+ Na as u
1646
1647
  };
@@ -1,5 +1,5 @@
1
- import { ac as X, u as Y, ad as Z, ae as ee, af as te, ag as re, ah as se, ai as ae, o as V, aj as oe } from "./index-CffvIaZO.js";
2
- import { H as ne, E as ie, u as b, G as H, I as ce } from "./switch-Deo2Ltmj.js";
1
+ import { ac as X, u as Y, ad as Z, ae as ee, af as te, ag as re, ah as se, ai as ae, o as V, aj as oe } from "./index-DTlbYpxd.js";
2
+ import { H as ne, E as ie, u as b, G as H, I as ce } from "./switch-DKf6vHfP.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();
@@ -1 +1 @@
1
- "use strict";const u=require("./index-YTk9Hab2.js"),f=require("./switch-BXICAlvS.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-BD90s-wf.js"),f=require("./switch-DJJJD_g1.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;
@@ -0,0 +1,371 @@
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 t(e) {
14
+ return typeof e == "string" && e.trim().length > 0;
15
+ }
16
+ function m(e) {
17
+ return !!(e && typeof e == "object" && !Array.isArray(e));
18
+ }
19
+ function _(e, i, n, c = {}) {
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
+ t(e.domainId) || n.push(
26
+ s(
27
+ "missing_semantic_domain",
28
+ "Semantic source needs a domainId.",
29
+ `${i}.domainId`
30
+ )
31
+ ), t(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
+ t(e.connectionId) || n.push(
42
+ s(
43
+ "missing_connection_id",
44
+ "Physical source needs a connectionId.",
45
+ `${i}.connectionId`
46
+ )
47
+ ), t(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
+ t(e.connectionId) || n.push(
58
+ s(
59
+ "missing_connection_id",
60
+ "SQL source needs a connectionId.",
61
+ `${i}.connectionId`
62
+ )
63
+ ), c.requireSqlText !== !1 && !t(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 f(e, i, n, c = {}) {
69
+ if (!e || !m(e)) {
70
+ c.required && n.push(
71
+ s("missing_field_ref", "Field reference needs a name.", i)
72
+ );
73
+ return;
74
+ }
75
+ t(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 g(e) {
82
+ var c, u, d, p;
83
+ const i = [], n = [];
84
+ return !e || typeof e != "object" ? {
85
+ ok: !1,
86
+ errors: [
87
+ s(
88
+ "invalid_analytics_intent",
89
+ "Analytics intent must be a structured object."
90
+ )
91
+ ],
92
+ warnings: n,
93
+ repairHints: [
94
+ {
95
+ code: "invalid_analytics_intent",
96
+ recommendedNextStep: "Send one structured analytics intent object with kind, source, and required fields."
97
+ }
98
+ ]
99
+ } : (e.version !== void 0 && e.version !== 1 && i.push(
100
+ s("invalid_version", "Analytics intent version must be 1.", "version")
101
+ ), _(e.source, "source", i, {
102
+ requireSqlText: e.kind !== "sql" || !t(e.sql)
103
+ }), e.kind === "metric" ? (t(e.metric) || i.push(
104
+ s("missing_metric", "Metric intent needs a metric.", "metric")
105
+ ), e.metrics !== void 0 && !Array.isArray(e.metrics) ? i.push(
106
+ s(
107
+ "invalid_metric_list",
108
+ "Metric intent metrics must be an array of metric names.",
109
+ "metrics"
110
+ )
111
+ ) : Array.isArray(e.metrics) && e.metrics.some((r) => !t(r)) && i.push(
112
+ s(
113
+ "invalid_metric_list",
114
+ "Metric intent metrics must be an array of non-empty metric names.",
115
+ "metrics"
116
+ )
117
+ ), e.dimensions !== void 0 && !Array.isArray(e.dimensions) ? i.push(
118
+ s(
119
+ "invalid_metric_dimensions",
120
+ "Metric intent dimensions must be an array of field references.",
121
+ "dimensions"
122
+ )
123
+ ) : Array.isArray(e.dimensions) && e.dimensions.some(
124
+ (r) => !m(r) || !t(r.name)
125
+ ) && i.push(
126
+ s(
127
+ "invalid_metric_dimensions",
128
+ "Metric intent dimensions must be an array of field references with names.",
129
+ "dimensions"
130
+ )
131
+ ), e.dateField !== void 0 && f(e.dateField, "dateField", i), Array.isArray(e.dimensions) && e.dimensions.forEach((r, o) => {
132
+ f(r, `dimensions.${o}`, i);
133
+ })) : e.kind === "records" ? (!Array.isArray(e.fields) || e.fields.length === 0 ? i.push(
134
+ s(
135
+ "missing_record_fields",
136
+ "Records intent needs at least one field.",
137
+ "fields"
138
+ )
139
+ ) : e.fields.some(
140
+ (r) => !m(r) || !t(r.name)
141
+ ) && i.push(
142
+ s(
143
+ "invalid_record_fields",
144
+ "Records intent fields must be field references with names.",
145
+ "fields"
146
+ )
147
+ ), Array.isArray(e.fields) && e.fields.forEach((r, o) => {
148
+ f(r, `fields.${o}`, i);
149
+ }), e.dateField !== void 0 && f(e.dateField, "dateField", i)) : e.kind === "inputOptions" ? ((!e.field || !t(e.field.name)) && i.push(
150
+ s(
151
+ "missing_input_options_field",
152
+ "Input options intent needs a field.",
153
+ "field"
154
+ )
155
+ ), f(e.field, "field", i, { required: !0 })) : e.kind === "sql" ? (((c = e.source) == null ? void 0 : c.kind) !== "sql" && ((u = e.source) == null ? void 0 : u.kind) !== "physical" && i.push(
156
+ s(
157
+ "invalid_sql_source",
158
+ "SQL analytics intent must use a SQL or physical source.",
159
+ "source"
160
+ )
161
+ ), t(e.sql) && ((d = e.source) == null ? void 0 : d.kind) === "sql" && t(e.source.sql) && y(e.sql) !== y(e.source.sql) && i.push(
162
+ s(
163
+ "conflicting_sql",
164
+ "SQL analytics intent cannot define different SQL text in source.sql and sql.",
165
+ "sql"
166
+ )
167
+ ), !t(e.sql) && !(((p = e.source) == null ? void 0 : p.kind) === "sql" && t(e.source.sql)) && i.push(s("missing_sql", "SQL analytics intent needs SQL text.", "sql")), Array.isArray(e.fields) && e.fields.forEach((r, o) => {
168
+ f(r, `fields.${o}`, i);
169
+ })) : i.push(
170
+ s("invalid_analytics_kind", "Analytics kind is not supported.", "kind")
171
+ ), {
172
+ ok: i.length === 0,
173
+ errors: i,
174
+ warnings: n,
175
+ repairHints: q(i)
176
+ });
177
+ }
178
+ function y(e) {
179
+ return e.replace(/\r\n/g, `
180
+ `).trim();
181
+ }
182
+ function q(e) {
183
+ return e.map((i) => {
184
+ switch (i.code) {
185
+ case "missing_source":
186
+ return {
187
+ code: i.code,
188
+ fieldRole: "source",
189
+ recommendedNextStep: "Provide a semantic, physical, or SQL source before executing analytics."
190
+ };
191
+ case "missing_metric":
192
+ return {
193
+ code: i.code,
194
+ fieldRole: "metric",
195
+ recommendedNextStep: "Choose one exact metric from the grounded schema candidates."
196
+ };
197
+ case "missing_record_fields":
198
+ return {
199
+ code: i.code,
200
+ fieldRole: "dimension",
201
+ recommendedNextStep: "Provide at least one field for the records intent."
202
+ };
203
+ case "missing_input_options_field":
204
+ return {
205
+ code: i.code,
206
+ fieldRole: "input",
207
+ recommendedNextStep: "Provide the exact field whose option values should be listed."
208
+ };
209
+ case "missing_sql":
210
+ return {
211
+ code: i.code,
212
+ fieldRole: "sql",
213
+ recommendedNextStep: "Provide bounded read-only SQL with an explicit outer LIMIT."
214
+ };
215
+ case "conflicting_sql":
216
+ return {
217
+ code: i.code,
218
+ fieldRole: "sql",
219
+ recommendedNextStep: "Use one canonical SQL text location for the intent; prefer top-level sql."
220
+ };
221
+ case "missing_semantic_domain":
222
+ case "missing_dataset_name":
223
+ case "missing_connection_id":
224
+ case "missing_table_name":
225
+ return {
226
+ code: i.code,
227
+ fieldRole: "source",
228
+ recommendedNextStep: "Use grounded catalog metadata to fill the missing source reference."
229
+ };
230
+ default:
231
+ return;
232
+ }
233
+ }).filter((i) => !!i);
234
+ }
235
+ function S(e, i, n, c) {
236
+ if (!e || typeof e != "object") {
237
+ n.push(s("invalid_view", "Dashboard view must be an object.", i));
238
+ return;
239
+ }
240
+ if (t(e.title) || n.push(s("missing_view_title", "Dashboard view needs a title.", i)), !e.presentation || typeof e.presentation != "object") {
241
+ n.push(
242
+ s(
243
+ "missing_presentation",
244
+ "Dashboard view needs a presentation.",
245
+ `${i}.presentation`
246
+ )
247
+ );
248
+ return;
249
+ }
250
+ if (e.presentation.kind === "text") {
251
+ t(e.text) || c.push(
252
+ s(
253
+ "missing_text_content",
254
+ "Text views should include text content.",
255
+ `${i}.text`
256
+ )
257
+ );
258
+ return;
259
+ }
260
+ if (!e.analytics) {
261
+ n.push(
262
+ s(
263
+ "missing_view_analytics",
264
+ "Non-text dashboard views need analytics intent.",
265
+ `${i}.analytics`
266
+ )
267
+ );
268
+ return;
269
+ }
270
+ const u = g(e.analytics);
271
+ for (const d of u.errors)
272
+ n.push(
273
+ s(d.code, d.message, `${i}.analytics${d.path ? `.${d.path}` : ""}`)
274
+ );
275
+ for (const d of u.warnings)
276
+ c.push(
277
+ s(
278
+ d.code,
279
+ d.message,
280
+ `${i}.analytics${d.path ? `.${d.path}` : ""}`
281
+ )
282
+ );
283
+ }
284
+ function x(e) {
285
+ const i = [], n = [];
286
+ if (!e || typeof e != "object")
287
+ return {
288
+ ok: !1,
289
+ errors: [
290
+ s(
291
+ "invalid_dashboard_intent",
292
+ "Dashboard intent must be a structured object."
293
+ )
294
+ ],
295
+ warnings: n
296
+ };
297
+ 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.")), t(e.title) || i.push(s("missing_title", "Dashboard intent needs a title.", "title"));
298
+ const c = Array.isArray(e.inputs) ? e.inputs : [], u = h(
299
+ c.filter(m).map((o) => o.id).filter((o) => typeof o == "string")
300
+ );
301
+ u && i.push(
302
+ s(
303
+ "duplicate_input_id",
304
+ `Duplicate input id: ${u}.`,
305
+ "inputs"
306
+ )
307
+ );
308
+ for (const [o, a] of c.entries()) {
309
+ const l = `inputs.${o}`;
310
+ if (!m(a)) {
311
+ i.push(s("invalid_input", "Dashboard input must be an object.", l));
312
+ continue;
313
+ }
314
+ t(a.id) || i.push(s("missing_input_id", "Input needs an id.", `${l}.id`)), t(a.label) || i.push(
315
+ s("missing_input_label", "Input needs a label.", `${l}.label`)
316
+ ), !a.field || !t(a.field.name) ? i.push(
317
+ s("missing_input_field", "Input needs a field.", `${l}.field`)
318
+ ) : f(a.field, `${l}.field`, i), a.source && _(a.source, `${l}.source`, i);
319
+ }
320
+ const d = Array.isArray(e.sections) ? e.sections : [];
321
+ d.length === 0 && i.push(
322
+ s(
323
+ "missing_sections",
324
+ "Dashboard intent needs at least one section.",
325
+ "sections"
326
+ )
327
+ );
328
+ const p = d.flatMap(
329
+ (o) => o && typeof o == "object" && Array.isArray(o.views) ? o.views.filter(m).map((a) => a.id).filter((a) => !!a) : []
330
+ ), r = h(p);
331
+ r && i.push(
332
+ s(
333
+ "duplicate_view_id",
334
+ `Duplicate dashboard view id: ${r}.`,
335
+ "sections"
336
+ )
337
+ );
338
+ for (const [o, a] of d.entries()) {
339
+ const l = `sections.${o}`;
340
+ if (!a || typeof a != "object") {
341
+ i.push(
342
+ s("invalid_section", "Dashboard section must be an object.", l)
343
+ );
344
+ continue;
345
+ }
346
+ if (t(a.title) || i.push(
347
+ s("missing_section_title", "Dashboard section needs a title.", l)
348
+ ), !Array.isArray(a.views) || a.views.length === 0) {
349
+ i.push(
350
+ s(
351
+ "missing_section_views",
352
+ "Dashboard section needs at least one view.",
353
+ `${l}.views`
354
+ )
355
+ );
356
+ continue;
357
+ }
358
+ for (const [b, v] of a.views.entries())
359
+ S(
360
+ v,
361
+ `${l}.views.${b}`,
362
+ i,
363
+ n
364
+ );
365
+ }
366
+ return { ok: i.length === 0, errors: i, warnings: n };
367
+ }
368
+ export {
369
+ x as a,
370
+ g as v
371
+ };
@@ -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 h(e){const i=new Set;for(const n of e){if(i.has(n))return n;i.add(n)}return null}function t(e){return typeof e=="string"&&e.trim().length>0}function m(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function _(e,i,n,c={}){if(!e||typeof e!="object"){n.push(s("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){t(e.domainId)||n.push(s("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),t(e.datasetName)||n.push(s("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){t(e.connectionId)||n.push(s("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),t(e.tableName)||n.push(s("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){t(e.connectionId)||n.push(s("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`)),c.requireSqlText!==!1&&!t(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,c={}){if(!e||!m(e)){c.required&&n.push(s("missing_field_ref","Field reference needs a name.",i));return}t(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 b(e){var c,u,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"||!t(e.sql)}),e.kind==="metric"?(t(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(r=>!t(r))&&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(r=>!m(r)||!t(r.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((r,o)=>{f(r,`dimensions.${o}`,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(r=>!m(r)||!t(r.name))&&i.push(s("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((r,o)=>{f(r,`fields.${o}`,i)}),e.dateField!==void 0&&f(e.dateField,"dateField",i)):e.kind==="inputOptions"?((!e.field||!t(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"?(((c=e.source)==null?void 0:c.kind)!=="sql"&&((u=e.source)==null?void 0:u.kind)!=="physical"&&i.push(s("invalid_sql_source","SQL analytics intent must use a SQL or physical source.","source")),t(e.sql)&&((d=e.source)==null?void 0:d.kind)==="sql"&&t(e.source.sql)&&y(e.sql)!==y(e.source.sql)&&i.push(s("conflicting_sql","SQL analytics intent cannot define different SQL text in source.sql and sql.","sql")),!t(e.sql)&&!(((p=e.source)==null?void 0:p.kind)==="sql"&&t(e.source.sql))&&i.push(s("missing_sql","SQL analytics intent needs SQL text.","sql")),Array.isArray(e.fields)&&e.fields.forEach((r,o)=>{f(r,`fields.${o}`,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 y(e){return e.replace(/\r\n/g,`
2
+ `).trim()}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 S(e,i,n,c){if(!e||typeof e!="object"){n.push(s("invalid_view","Dashboard view must be an object.",i));return}if(t(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"){t(e.text)||c.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 u=b(e.analytics);for(const d of u.errors)n.push(s(d.code,d.message,`${i}.analytics${d.path?`.${d.path}`:""}`));for(const d of u.warnings)c.push(s(d.code,d.message,`${i}.analytics${d.path?`.${d.path}`:""}`))}function A(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.")),t(e.title)||i.push(s("missing_title","Dashboard intent needs a title.","title"));const c=Array.isArray(e.inputs)?e.inputs:[],u=h(c.filter(m).map(o=>o.id).filter(o=>typeof o=="string"));u&&i.push(s("duplicate_input_id",`Duplicate input id: ${u}.`,"inputs"));for(const[o,a]of c.entries()){const l=`inputs.${o}`;if(!m(a)){i.push(s("invalid_input","Dashboard input must be an object.",l));continue}t(a.id)||i.push(s("missing_input_id","Input needs an id.",`${l}.id`)),t(a.label)||i.push(s("missing_input_label","Input needs a label.",`${l}.label`)),!a.field||!t(a.field.name)?i.push(s("missing_input_field","Input needs a field.",`${l}.field`)):f(a.field,`${l}.field`,i),a.source&&_(a.source,`${l}.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(o=>o&&typeof o=="object"&&Array.isArray(o.views)?o.views.filter(m).map(a=>a.id).filter(a=>!!a):[]),r=h(p);r&&i.push(s("duplicate_view_id",`Duplicate dashboard view id: ${r}.`,"sections"));for(const[o,a]of d.entries()){const l=`sections.${o}`;if(!a||typeof a!="object"){i.push(s("invalid_section","Dashboard section must be an object.",l));continue}if(t(a.title)||i.push(s("missing_section_title","Dashboard section needs a title.",l)),!Array.isArray(a.views)||a.views.length===0){i.push(s("missing_section_views","Dashboard section needs at least one view.",`${l}.views`));continue}for(const[v,g]of a.views.entries())S(g,`${l}.views.${v}`,i,n)}return{ok:i.length===0,errors:i,warnings:n}}exports.validateSemaphorAnalyticsIntent=b;exports.validateSemaphorDashboardIntent=A;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-YTk9Hab2.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-BD90s-wf.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-CffvIaZO.js";
1
+ import { D as o } from "../chunks/index-DTlbYpxd.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,