react-semaphor 0.1.323 → 0.1.325
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.
- package/dist/analytics-protocol/index.cjs +1 -0
- package/dist/analytics-protocol/index.js +240 -0
- package/dist/chunks/{calendar-preferences-dialog-CLXaVo3h.js → calendar-preferences-dialog-BxeROxyq.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-B9Hz3pTH.js → calendar-preferences-dialog-DHhT6Sja.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CUEn7cr6.js → dashboard-briefing-launcher-BzIxRlzW.js} +3 -3
- package/dist/chunks/{dashboard-briefing-launcher-COLpvReF.js → dashboard-briefing-launcher-DZiFMK8I.js} +1 -1
- package/dist/chunks/{dashboard-controls-DH8gdpOc.js → dashboard-controls-BX693lE0.js} +1 -1
- package/dist/chunks/{dashboard-controls-CLShFyUq.js → dashboard-controls-DVwsWny9.js} +3 -3
- package/dist/chunks/{dashboard-json-Db0DpTMw.js → dashboard-json-D15C_I9e.js} +1 -1
- package/dist/chunks/{dashboard-json-eGBWfSN1.js → dashboard-json-DxNEFM-p.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-Cc3xpTNQ.js → edit-dashboard-visual-90_qEgRc.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DmMKWtln.js → edit-dashboard-visual-wQyJEcVH.js} +3 -3
- package/dist/chunks/{index-PTx7430W.js → index-CffvIaZO.js} +33125 -32694
- package/dist/chunks/{index-CMS4bp9G.js → index-YTk9Hab2.js} +203 -203
- package/dist/chunks/{resource-management-panel-C1mbF-2a.js → resource-management-panel-CLoO2DL3.js} +2 -2
- package/dist/chunks/{resource-management-panel-DR7Ku6sa.js → resource-management-panel-DlnrD0y-.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-CmxTpqeg.js → use-create-flow-overlay-state-DocFanjO.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-B65gg2oB.js → use-create-flow-overlay-state-DsPoCfMu.js} +2 -2
- package/dist/chunks/{use-visual-utils-Diuguy3D.js → use-visual-utils-BdO22fQZ.js} +1 -1
- package/dist/chunks/{use-visual-utils-51Nsy8cj.js → use-visual-utils-DSbXQQD1.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +825 -310
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +172 -0
- package/dist/types/dashboard-authoring.d.ts +161 -0
- package/dist/types/main.d.ts +1 -0
- package/package.json +6 -1
package/dist/chunks/{resource-management-panel-C1mbF-2a.js → resource-management-panel-CLoO2DL3.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as e, jsxs as n, Fragment as oe } from "react/jsx-runtime";
|
|
2
2
|
import { c as _e, u as se, G as Ge, a as Z, B as A, f as te, M as be, Q as Ye, L as ie, a1 as de, X as ke, Y as Qe, Z as We, _ as Xe, a0 as Ze, ay as $e } from "./switch-Deo2Ltmj.js";
|
|
3
3
|
import qe, { useState as b, useEffect as ee, useRef as Je } from "react";
|
|
4
|
-
import { ag as ue, aK as et, aL as tt, aH as ce, aM as nt, aN as at, aO as st, aP as it, aQ as X, aR as ot, aS as rt, aT as lt, aU as xe, ay as he, aV as dt, aW as ct, aX as we, aY as Ne, aZ as ut, H as ye, z as Ce, a_ as ve, a$ as Se, b0 as Ee, b1 as Ve, b2 as Le, b3 as Oe, b4 as Ae, b5 as Te, b6 as Re, b7 as ht, b8 as pe, b9 as pt, x as ae, u as mt, ba as Ue, b as Ie, c as Me, d as Pe, e as ze, f as Fe, bb as ft, n as je, bc as gt, bd as De, be as xt } from "./index-
|
|
5
|
-
import { u as Be } from "./use-visual-utils-
|
|
4
|
+
import { ag as ue, aK as et, aL as tt, aH as ce, aM as nt, aN as at, aO as st, aP as it, aQ as X, aR as ot, aS as rt, aT as lt, aU as xe, ay as he, aV as dt, aW as ct, aX as we, aY as Ne, aZ as ut, H as ye, z as Ce, a_ as ve, a$ as Se, b0 as Ee, b1 as Ve, b2 as Le, b3 as Oe, b4 as Ae, b5 as Te, b6 as Re, b7 as ht, b8 as pe, b9 as pt, x as ae, u as mt, ba as Ue, b as Ie, c as Me, d as Pe, e as ze, f as Fe, bb as ft, n as je, bc as gt, bd as De, be as xt } from "./index-CffvIaZO.js";
|
|
5
|
+
import { u as Be } from "./use-visual-utils-BdO22fQZ.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license lucide-react v0.453.0 - ISC
|
|
8
8
|
*
|
package/dist/chunks/{resource-management-panel-DR7Ku6sa.js → resource-management-panel-DlnrD0y-.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./switch-BXICAlvS.js"),x=require("react"),t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("./switch-BXICAlvS.js"),x=require("react"),t=require("./index-YTk9Hab2.js"),oe=require("./use-visual-utils-DSbXQQD1.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const s=require("./switch-BXICAlvS.js"),v=require("react"),p=require("./index-
|
|
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");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
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";
|
|
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-
|
|
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";
|
|
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-
|
|
5
|
+
import { u as we } from "./use-visual-utils-BdO22fQZ.js";
|
|
6
6
|
import { S as nt } from "./save-DxkSzUTZ.js";
|
|
7
7
|
/**
|
|
8
8
|
* @license lucide-react v0.453.0 - ISC
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
2
|
import { H as ne, E as ie, u as b, G as H, I as ce } from "./switch-Deo2Ltmj.js";
|
|
3
3
|
import { useState as z, useEffect as de, useCallback as A } from "react";
|
|
4
4
|
function le(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("./index-
|
|
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;
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-
|
|
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;
|
package/dist/dashboard/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`)||"Dashboard plan is invalid.");const e
|
|
3
|
-
`)||"Dashboard change plan is invalid.");const e=H(t.dashboard),s=[...a.warnings],n=[],d=new Map(t.cardArtifacts.map(r=>[r.planCardId,r])),i=$(e);if(!i)throw new Error("Dashboard has no editable dashboard sheet.");i.frames??(i.frames=[]);for(const r of t.changePlan.operations)switch(r.kind){case"addCard":{if((i.frames||[]).reduce((m,o)=>{var h;return m+(((h=o.cards)==null?void 0:h.length)||0)},0)>=_){n.push(g("generated_card_limit_reached",`MVP AI refinement is capped at ${_} cards.`,r.card.id));break}const f=d.get(r.card.id);if(!f){n.push(g("missing_card_artifact",`Card "${r.card.title}" was skipped because no generated artifact was supplied.`,r.card.id));break}const b={id:r.card.frameId,cards:[f.card],activeCardId:f.card.id};i.frames.push(b),j(i,b);break}case"addFilterInput":{e.inputs??(e.inputs=[]);const u={id:r.input.id,kind:"filter",label:r.input.label,variableName:r.input.variableName,scope:{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:e.inputs.length},exports:["label","value","start","end","range"],filter:r.input.filter};e.inputs.push(u),W(e,r.input);break}case"addCalculatedField":{if(r.field.scope==="dashboard"&&r.field.field)e.calculatedFields??(e.calculatedFields=[]),e.calculatedFields.push(r.field.field);else if(r.field.scope==="sheet"&&r.field.field)i.calculatedFields??(i.calculatedFields=[]),i.calculatedFields.push(r.field.field);else if(r.field.scope==="card"&&r.field.field){const u=r.field.targetCardId?D(e,r.field.targetCardId):null;u?((l=u.card).calculatedFields??(l.calculatedFields=[]),u.card.calculatedFields.push(r.field.field)):n.push(g("missing_calculated_field_target",`Calculated field "${r.field.name}" needs a valid target card.`))}break}case"renameCard":{const u=D(e,r.cardId);if(!u){n.push(g("card_not_found",`Card "${r.cardId}" could not be renamed because it was not found.`,r.cardId));break}u.card.title=r.title,r.description!==void 0&&(u.card.description=r.description);break}case"reorderCards":{const u=new Map;for(let f=0;f<r.cardIds.length;f+=1){const b=r.cardIds[f],m=D(e,b);m&&u.set(m.frame.id,f)}P(i,u);break}case"reuseCalculatedField":s.push(g("reused_calculated_field",`Calculated field "${r.fieldId}" is reused by reference.`));break;case"unsupported":n.push(g("unsupported_operation",r.reason||r.requestedAction));break}return{dashboard:e,warnings:s,skippedOperations:n}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=A;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=_;exports.applyDashboardChangePlan=G;exports.compileDashboardFromPlan=E;exports.compileResponsiveDashboardLayouts=w;exports.validateDashboardChangePlan=F;exports.validateDashboardPlan=C;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("../analytics-protocol/index.cjs"),H=["lg","md","sm","xs","xxs"],S=10;function f(e,t,a){return a?{code:e,message:t,cardId:a}:{code:e,message:t}}function $(e){const t=new Set;for(const a of e){if(t.has(a))return a;t.add(a)}return null}function W(e){var _,x;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[f("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const a=e,n=[...a.warnings||[]];a.version!==1&&t.push(f("invalid_version","Dashboard plan version must be 1.")),(_=a.title)!=null&&_.trim()||t.push(f("missing_title","Dashboard plan needs a title."));const i=Array.isArray(a.datasets)?a.datasets:[],r=Array.isArray(a.sheets)?a.sheets:[];i.length!==1&&t.push(f("invalid_dataset_count","MVP dashboard authoring requires exactly one selected dataset.")),r.length!==1&&t.push(f("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const d=r[0];d&&d.kind!=="dashboard"&&t.push(f("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const l=(d==null?void 0:d.cards)||[];l.length>S&&t.push(f("too_many_cards",`Generated dashboards can contain at most ${S} cards.`));const s=$(l.map(u=>u.id));s&&t.push(f("duplicate_card_id",`Duplicate generated card id: ${s}.`));const c=$(l.map(u=>u.frameId));c&&t.push(f("duplicate_frame_id",`Duplicate generated frame id: ${c}.`));for(const u of l)(x=u.title)!=null&&x.trim()||t.push(f("missing_card_title","Card title is required.",u.id)),u.type==="custom"&&t.push(f("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",u.id)),u.type!=="text"&&!u.query&&n.push(f("missing_query_intent","Non-text card has no query intent and may be skipped by the app layer.",u.id));const h=Array.isArray(a.filterInputs)?a.filterInputs:[],y=h.map(u=>u.id),g=$(y);g&&t.push(f("duplicate_input_id",`Duplicate dashboard input id: ${g}.`));const o=h.map(u=>u.variableName).filter(Boolean)||[],b=$(o);b&&t.push(f("duplicate_input_variable",`Duplicate dashboard input variable name: ${b}.`));const k=Array.isArray(a.calculatedFields)?a.calculatedFields:[];for(const u of k)u.scope==="domain"&&u.reuseOnly!==!0&&t.push(f("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${u.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:n}}function G(e){var d;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[f("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const a=e,n=[...a.warnings||[]];a.version!==1&&t.push(f("invalid_version","Dashboard change plan version must be 1.")),(d=a.dashboardId)!=null&&d.trim()||t.push(f("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const i=Array.isArray(a.datasets)?a.datasets:[],r=Array.isArray(a.operations)?a.operations:[];i.length>1&&t.push(f("invalid_dataset_count","MVP dashboard refinement can ground new AI operations in at most one selected dataset."));for(const l of r){if(l.kind==="unsupported"){n.push(f("unsupported_operation",l.reason||l.requestedAction));continue}l.kind==="addCard"&&l.card.type==="custom"&&t.push(f("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.card.id)),l.kind==="addCalculatedField"&&l.field.scope==="domain"&&l.field.reuseOnly!==!0&&t.push(f("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:n}}const ae={lg:48,md:36,sm:24,xs:12,xxs:6};function ne(e,t){let a=0,n=0,i=0;return e.map(r=>{const d=Math.min(r.w,t);a>0&&a+d>t&&(a=0,n+=i,i=0);const l={i:r.frameId,x:a,y:n,w:d,h:r.h,minW:Math.min(r.minW,t),minH:r.minH,static:!1};return a+=d,i=Math.max(i,r.h),l})}function re(e){const t=[...e].sort((s,c)=>s.priority-c.priority),a=t.filter(s=>s.role==="kpi"),n=t.filter(s=>s.role==="chart"),i=t.filter(s=>s.role==="table"),r=t.filter(s=>s.role==="text"),d=r.slice(0,1),l=r.slice(d.length);return{kpis:a,introText:d,charts:n,tables:i,supportingText:l}}function ie(e,t,a){return t==="xxs"||t==="xs"?a:t==="sm"?Math.min(12,a):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function se(e,t,a,n){return a==="xxs"||a==="xs"||a==="sm"||a==="md"||t===1||t%2===1&&e===0?n:n/2}function de(e){const{item:t,band:a,index:n,bandCount:i,breakpoint:r,columns:d}=e;return a==="kpi"?{...t,band:a,w:ie(i,r,d),h:15,minW:Math.min(6,d),minH:12}:a==="table"?{...t,band:a,w:d,h:r==="xxs"||r==="xs"?34:38,minW:Math.min(12,d),minH:18}:a==="introText"?{...t,band:a,w:d,h:r==="xxs"||r==="xs"?12:10,minW:Math.min(12,d),minH:8}:a==="supportingText"?{...t,band:a,w:r==="lg"?d/2:d,h:r==="xxs"||r==="xs"?12:10,minW:Math.min(12,d),minH:8}:{...t,band:a,w:se(n,i,r,d),h:r==="xxs"||r==="xs"?28:30,minW:Math.min(12,d),minH:16}}function F(e,t,a,n){return e.map((i,r)=>de({item:i,band:t,index:r,bandCount:e.length,breakpoint:a,columns:n}))}function N(e){const t=re(e);return Object.fromEntries(H.map(a=>{const n=ae[a],i=[...F(t.introText,"introText",a,n),...F(t.kpis,"kpi",a,n),...F(t.charts,"chart",a,n),...F(t.tables,"table",a,n),...F(t.supportingText,"supportingText",a,n)];return[a,ne(i,n)]}))}function oe(e){const t=String(e||"").trim().toLowerCase();return t.includes("date")||t.includes("time")||t.includes("timestamp")?"date":t.includes("int")||t.includes("float")||t.includes("double")||t.includes("decimal")||t.includes("numeric")||t.includes("number")||t.includes("currency")||t.includes("percent")?"number":t.includes("bool")?"boolean":"string"}function le(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function ce(e){return le(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function ue(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function fe(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function q(e,t){if(t===void 0)return;const a=oe(e.dataType),n=e.operation||"in";if(ce(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:a,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(n==="is null"||n==="is not null")return{filterId:e.id,name:e.column,operation:n,valueType:a,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const i=Array.isArray(t)?t:[t],r=a==="date"?fe(i):ue(i);if(r.length!==0&&!((n==="between"||n==="not between")&&r.length<2))return{filterId:e.id,name:e.column,operation:n,valueType:a,values:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function pe(e,t,a){return a?{code:e,message:t,cardId:a}:{code:e,message:t}}function he(e,t,a){const n=(t||[]).filter(i=>i.scope==="card"&&i.targetCardId===a).map(i=>i.field).filter(Boolean);return n.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...n]}}function me(e){const t={};return{inputs:(e.filterInputs||[]).map((n,i)=>{const r=q(n.filter,n.defaultValue);return r&&(t.shared??(t.shared={}),t.shared[n.id]={status:"set",value:{kind:"filter",filterValue:r}}),{id:n.id,kind:"filter",label:n.label,variableName:n.variableName,scope:n.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:n.filter}}),defaultInputValues:t.shared&&Object.keys(t.shared).length>0?t:void 0}}function be(e){var y,g;const t=W(e.plan);if(!t.ok)throw new Error(t.errors.map(o=>o.message).join(`
|
|
2
|
+
`)||"Dashboard plan is invalid.");const a=e.plan.sheets[0],n=[...t.warnings],i=[],r=new Map(e.cardArtifacts.map(o=>[o.planCardId,o])),d=[];for(const o of a.cards){const b=r.get(o.id);if(!b){const _=pe("missing_card_artifact",`Card "${o.title}" was skipped because no generated artifact was supplied.`,o.id);i.push(_);continue}n.push(...b.warnings||[]);const k=he(b.card,e.plan.calculatedFields,o.id);d.push({id:o.frameId,cards:[k],activeCardId:k.id})}if(d.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:l,defaultInputValues:s}=me(e.plan),c=N(a.cards.filter(o=>d.some(b=>b.id===o.frameId)).map(o=>({frameId:o.frameId,priority:o.priority,role:o.role})));return{dashboard:{id:e.dashboardId,title:e.plan.title,description:e.plan.description||"",sheets:[{id:a.id,kind:"dashboard",title:a.title,description:a.description,frames:d,layouts:c,calculatedFields:(y=e.plan.calculatedFields)==null?void 0:y.filter(o=>o.scope==="sheet"&&o.field).map(o=>o.field)}],calculatedFields:(g=e.plan.calculatedFields)==null?void 0:g.filter(o=>o.scope==="dashboard"&&o.field).map(o=>o.field),inputs:l,...s?{defaultInputValues:s}:{}},warnings:n,skippedOperations:i}}function v(e,t,a){return a?{code:e,message:t,cardId:a}:{code:e,message:t}}function ge(e){return JSON.parse(JSON.stringify(e))}function Ie(e){var t;return(t=e.sheets)==null?void 0:t.find(a=>(a.kind||"dashboard")==="dashboard")}function P(e,t){var a;for(const n of e.sheets||[])for(const i of n.frames||[]){const r=(a=i.cards)==null?void 0:a.find(d=>d.id===t);if(r)return{sheet:n,frame:i,card:r}}return null}function K(e){var a,n;const t=(n=(a=e.cards)==null?void 0:a[0])==null?void 0:n.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function ye(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((a,n)=>[a.i,n]))}function U(e,t=new Map){const a=ye(e),n=Math.max(a.size,t.size),i=(e.frames||[]).map((r,d)=>({frameId:r.id,role:K(r),priority:t.get(r.id)??a.get(r.id)??n+d}));e.layouts=N(i)}function _e(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function we(e,t){if(!_e(e)){U(e);return}const a=N([{frameId:t.id,role:K(t),priority:0}]);e.layouts??(e.layouts={});for(const[n,i]of Object.entries(a)){const r=e.layouts[n]||[];if(r.some(s=>s.i===t.id))continue;const d=i[0];if(!d)continue;const l=r.reduce((s,c)=>Math.max(s,c.y+c.h),0);e.layouts[n]=[...r,{...d,y:l}]}}function ve(e,t){var n;const a=q(t.filter,t.defaultValue);a&&(e.defaultInputValues??(e.defaultInputValues={}),(n=e.defaultInputValues).shared??(n.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:a}})}function Ce(e){var l;const t=G(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
|
|
3
|
+
`)||"Dashboard change plan is invalid.");const a=ge(e.dashboard),n=[...t.warnings],i=[],r=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),d=Ie(a);if(!d)throw new Error("Dashboard has no editable dashboard sheet.");d.frames??(d.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((d.frames||[]).reduce((g,o)=>{var b;return g+(((b=o.cards)==null?void 0:b.length)||0)},0)>=S){i.push(v("generated_card_limit_reached",`MVP AI refinement is capped at ${S} cards.`,s.card.id));break}const h=r.get(s.card.id);if(!h){i.push(v("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const y={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};d.frames.push(y),we(d,y);break}case"addFilterInput":{a.inputs??(a.inputs=[]);const c={id:s.input.id,kind:"filter",label:s.input.label,variableName:s.input.variableName,scope:s.input.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:a.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};a.inputs.push(c),ve(a,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)a.calculatedFields??(a.calculatedFields=[]),a.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)d.calculatedFields??(d.calculatedFields=[]),d.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const c=s.field.targetCardId?P(a,s.field.targetCardId):null;c?((l=c.card).calculatedFields??(l.calculatedFields=[]),c.card.calculatedFields.push(s.field.field)):i.push(v("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const c=P(a,s.cardId);if(!c){i.push(v("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}c.card.title=s.title,s.description!==void 0&&(c.card.description=s.description);break}case"reorderCards":{const c=new Map;for(let h=0;h<s.cardIds.length;h+=1){const y=s.cardIds[h],g=P(a,y);g&&c.set(g.frame.id,h)}U(d,c);break}case"reuseCalculatedField":n.push(v("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":i.push(v("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:a,warnings:n,skippedOperations:i}}function I(e,t,a){return a?{code:e,message:t,cardId:a}:{code:e,message:t}}function D(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function X(e,t){if(!t.has(e))return t.add(e),e;let a=2,n=`${e}-${a}`;for(;t.has(n);)a+=1,n=`${e}-${a}`;return t.add(n),n}function ke(e){return e.kind==="semantic"?["semantic",e.domainId,e.datasetId||"",e.datasetName,e.connectionId||""].join(":"):e.kind==="physical"?["physical",e.connectionId,e.databaseName||"",e.schemaName||"",e.tableName].join(":"):["sql",e.connectionId,e.sql].join(":")}function C(e){return!!(e&&typeof e=="object")}function E(e){return C(e)&&(e.kind==="semantic"||e.kind==="physical"||e.kind==="sql")}function J(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>C(t)&&typeof t.id=="string"):[]}function Y(e){return Array.isArray(e.sections)?e.sections.filter(t=>C(t)):[]}function Q(e){return Array.isArray(e.views)?e.views.filter(t=>C(t)):[]}function xe(e){return e.kind==="semantic"?{kind:"semantic",domainId:e.domainId,datasetName:e.datasetName,datasetId:e.datasetId,label:e.label,connectionId:e.connectionId}:e.kind==="physical"?{kind:"physical",connectionId:e.connectionId,databaseName:e.databaseName,schemaName:e.schemaName,tableName:e.tableName,label:e.label}:null}function Ae(e){return(e==null?void 0:e.source)||null}function Z(e){const t=[];for(const a of J(e))E(a.source)&&t.push(a.source);for(const a of Y(e))for(const n of Q(a)){const i=Ae(n.analytics);E(i)&&t.push(i)}return t}function Fe(e,t){const a=new Map;for(const i of Z(e))a.set(ke(i),i);const n=[...a.values()].map(xe).filter(i=>!!i);return n.length===0?(t.push(I("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[]):(n.length>1&&t.push(I("multiple_datasets_out_of_scope","The current dashboard authoring compiler supports one selected dataset; using the first source and deferring the rest.")),[n[0]])}function De(e){return(Array.isArray(e.fields)?e.fields:[]).map(t=>t.name).filter(t=>{var a;return t!==((a=e.dateField)==null?void 0:a.name)})}function Se(e){var t,a;if(e){if(e.kind==="metric")return{metric:e.metric,dateField:(t=e.dateField)==null?void 0:t.name};if(e.kind==="records")return{metrics:e.measures,dateField:(a=e.dateField)==null?void 0:a.name,timeGrain:e.timeGrain==="hour"?"day":e.timeGrain,dimensions:De(e),limit:e.limit}}}function Te(e){var t;switch((t=e.presentation)==null?void 0:t.kind){case"kpi":return"kpi";case"lineChart":return"line";case"barChart":return"bar";case"areaChart":return"area";case"table":return"table";case"text":return"text";default:return null}}function $e(e){var t,a,n;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((a=e.presentation)==null?void 0:a.kind)==="table"?"table":((n=e.presentation)==null?void 0:n.kind)==="text"?"text":"chart"}function Ne(e){switch(e){case"not_in":return"not in";case"contains":return"like";default:return e||"in"}}function Me(e){return C(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function Pe(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function Ve(e,t,a,n,i){if(e.kind!=="filter")return i.push(I("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!C(e.field)||typeof e.field.name!="string")return i.push(I("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const r=e.source||t,d=(r==null?void 0:r.kind)==="semantic"||(r==null?void 0:r.kind)==="physical"||(r==null?void 0:r.kind)==="sql"?r.connectionId:void 0;if(!d)return i.push(I("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const c={id:`filter-${X(D(e.id,e.field.name),n)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:Me(e),qualifiedTableName:Pe(r),sql:"",operation:Ne(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(r==null?void 0:r.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(r==null?void 0:r.kind)==="semantic"?{semanticDomainId:r.domainId,connectionId:r.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:a,filter:c,defaultValue:q(c,e.defaultValue)}}function V(e){const t=[],a=[];for(const n of e.viewIds){const i=e.viewIdToCardId.get(n);i?t.push(i):a.push(n)}return a.length>0&&e.warnings.push(I("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${a.join(", ")}.`)),Array.from(new Set(t))}function qe(e){var n,i;if(!e.protocolScope){const r=Array.from(new Set(e.boundCardIds));return r.length>0&&r.length<e.allCardIds.length?{kind:"cards",cardIds:r}:void 0}if(e.protocolScope.level==="dashboard"){if(!((n=e.protocolScope.excludeViewIds)!=null&&n.length))return;const r=new Set(V({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(d=>!r.has(d))}}if(e.protocolScope.level==="view"){const r=V({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return r.length===0?(e.warnings.push(I("input_scope_has_no_materialized_cards",`Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`)),null):{kind:"cards",cardIds:r}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(I("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((i=e.protocolScope.excludeViewIds)!=null&&i.length))return{kind:"cards",cardIds:t};const a=new Set(V({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(r=>!a.has(r))}}function Re(e){var _,x,u;const t=[],a=te.validateSemaphorDashboardIntent(e);for(const p of a.warnings)t.push(I(p.code,p.message));for(const p of a.errors)t.push(I(p.code,p.message));const n=Y(e),i=J(e),r=Fe(e,t),d=Z(e)[0],l=[],s=new Map,c=new Map,h=new Map,y=new Set,g=new Set;let o=0;for(const[p,w]of n.entries()){const A=typeof w.title=="string"?w.title:`Section ${p+1}`,R=w.id||D(A,`section-${p+1}`);c.set(R,[]);for(const[B,m]of Q(w).entries()){const O=Te(m),M=D(m.id||`${A}-${m.title||`View ${B+1}`}`,`card-${p+1}-${B+1}`);if(!O){t.push(I("unsupported_presentation",`Dashboard presentation "${((_=m.presentation)==null?void 0:_.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${M}`));continue}if(((x=m.analytics)==null?void 0:x.kind)==="sql"){t.push(I("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${M}`));continue}const L=X(M,y),T=`card-${L}`;m.id&&s.set(m.id,T),(u=c.get(R))==null||u.push(T);const ee=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const z of ee||[]){const j=h.get(z.inputId)||[];j.push(T),h.set(z.inputId,j)}l.push({id:T,frameId:`frame-${L}`,title:m.title,description:m.description,type:O,role:$e(m),priority:o,section:A,query:Se(m.analytics),text:m.text}),o+=1}}const b=i.map(p=>{const w=qe({protocolScope:p.scope,inputLabel:p.label,allCardIds:l.map(A=>A.id),boundCardIds:h.get(p.id)||[],viewIdToCardId:s,sectionIdToCardIds:c,warnings:t});return w===null?null:Ve(p,d,w,g,t)}).filter(p=>!!p);return{plan:{version:1,id:`plan-${D(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:r,sheets:[{id:`sheet-${D(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:l}],filterInputs:b.length?b:void 0,warnings:t.length?t:void 0,unresolvedRequests:a.ok?void 0:a.errors.map(p=>p.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=H;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=S;exports.applyDashboardChangePlan=Ce;exports.compileDashboardFromPlan=be;exports.compileResponsiveDashboardLayouts=N;exports.dashboardPlanFromSemaphorDashboardIntent=Re;exports.validateDashboardChangePlan=G;exports.validateDashboardPlan=W;
|