react-semaphor 0.1.343 → 0.1.345
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 -1
- package/dist/analytics-protocol/index.js +1 -1
- package/dist/chunks/{calendar-preferences-dialog-hS6POgEs.js → calendar-preferences-dialog-AVORk8vl.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-_u4Xm011.js → calendar-preferences-dialog-CaeYg4gz.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DHzIiaKF.js → dashboard-briefing-launcher-B7hc62UJ.js} +2062 -2062
- package/dist/chunks/dashboard-briefing-launcher-GmwoVZDA.js +106 -0
- package/dist/chunks/{dashboard-controls-CilLVS_Q.js → dashboard-controls-Bthl3kl3.js} +1 -1
- package/dist/chunks/{dashboard-controls-g1OcteYf.js → dashboard-controls-DOwo-4PX.js} +3 -3
- package/dist/chunks/{dashboard-json-ClH0kTga.js → dashboard-json-Bjge3tEx.js} +1 -1
- package/dist/chunks/{dashboard-json-BjnGSaxC.js → dashboard-json-CqWAmaOX.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DbVMVMKM.js → edit-dashboard-visual-NXdSdqQS.js} +3 -3
- package/dist/chunks/{edit-dashboard-visual-C_3NYnPz.js → edit-dashboard-visual-biDU5oky.js} +1 -1
- package/dist/chunks/{index-BNZjkxPH.js → index-D7U5s9Uk.js} +70 -70
- package/dist/chunks/{index-CuSvSh86.js → index-DhuiooCy.js} +9167 -9167
- package/dist/chunks/{resource-management-panel-DxjN2uw4.js → resource-management-panel-DIt7NxsX.js} +2 -2
- package/dist/chunks/{resource-management-panel-N5iUOE89.js → resource-management-panel-MHam0keE.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-CSjc7cXZ.js → use-create-flow-overlay-state-DS5aPcKd.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-CXPnnXh1.js → use-create-flow-overlay-state-p_i0aUhH.js} +2 -2
- package/dist/chunks/{use-visual-utils-C3MRLrHu.js → use-visual-utils-EazVs86Z.js} +1 -1
- package/dist/chunks/{use-visual-utils-DsoGoqPF.js → use-visual-utils-PfpWtYcR.js} +1 -1
- package/dist/chunks/validators-8R9pr2K9.js +1 -0
- package/dist/chunks/{validators-BqEnmlC6.js → validators-yMB7Tm4j.js} +120 -109
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +1 -1
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +240 -227
- 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/dashboard-authoring.d.ts +1 -0
- package/dist/types/dashboard.d.ts +1 -0
- package/dist/types/main.d.ts +15 -0
- package/dist/types/shared.d.ts +1 -0
- package/dist/types/surfboard.d.ts +1 -0
- package/dist/types/types.d.ts +15 -0
- package/package.json +1 -1
- package/dist/chunks/dashboard-briefing-launcher-D18qNhwa.js +0 -106
- package/dist/chunks/validators-v8WAqhaN.js +0 -1
package/dist/chunks/{resource-management-panel-DxjN2uw4.js → resource-management-panel-DIt7NxsX.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as e, jsxs as n, Fragment as oe } from "react/jsx-runtime";
|
|
2
2
|
import { c as He, u as se, G as Ge, a as Z, B as O, f as te, N as be, V as $e, L as ie, a2 as de, X as ke, Z as We, _ as Xe, $ as Ye, a1 as Ze, az as Je } from "./switch-CP7SmEIZ.js";
|
|
3
3
|
import Qe, { useState as b, useEffect as ee, useRef as qe } from "react";
|
|
4
|
-
import { ah as ue, aL as et, aM as tt, aI as ce, aN as nt, aO as at, aP as st, aQ as it, aR as Y, aS as ot, aT as rt, aU as lt, aV as xe, az as he, aW as dt, aX as ct, aY as Ne, aZ as we, a_ as ut, J as ye, A as Ce, a$ as ve, b0 as Se, b1 as Ee, b2 as Ve, b3 as Le, b4 as Ae, b5 as Oe, b6 as Te, b7 as Re, b8 as ht, b9 as pe, ba as pt, y as ae, u as mt, bb as Ue, c as Ie, d as ze, e as Me, f as Pe, g as Fe, bc as ft, o as je, bd as gt, be as De, bf as xt } from "./index-
|
|
4
|
+
import { ah as ue, aL as et, aM as tt, aI as ce, aN as nt, aO as at, aP as st, aQ as it, aR as Y, aS as ot, aT as rt, aU as lt, aV as xe, az as he, aW as dt, aX as ct, aY as Ne, aZ as we, a_ as ut, J as ye, A as Ce, a$ as ve, b0 as Se, b1 as Ee, b2 as Ve, b3 as Le, b4 as Ae, b5 as Oe, b6 as Te, b7 as Re, b8 as ht, b9 as pe, ba as pt, y as ae, u as mt, bb as Ue, c as Ie, d as ze, e as Me, f as Pe, g as Fe, bc as ft, o as je, bd as gt, be as De, bf as xt } from "./index-DhuiooCy.js";
|
|
5
5
|
import "./index-CuHybtft.js";
|
|
6
|
-
import { u as Be } from "./use-visual-utils-
|
|
6
|
+
import { u as Be } from "./use-visual-utils-PfpWtYcR.js";
|
|
7
7
|
/**
|
|
8
8
|
* @license lucide-react v0.453.0 - ISC
|
|
9
9
|
*
|
package/dist/chunks/{resource-management-panel-N5iUOE89.js → resource-management-panel-MHam0keE.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-DYRgERrC.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-DYRgERrC.js"),x=require("react"),t=require("./index-D7U5s9Uk.js");require("./index-BxM99sFL.js");const oe=require("./use-visual-utils-EazVs86Z.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-DYRgERrC.js"),v=require("react"),p=require("./index-
|
|
1
|
+
"use strict";const s=require("./switch-DYRgERrC.js"),v=require("react"),p=require("./index-D7U5s9Uk.js"),e=require("react/jsx-runtime");require("./index-BxM99sFL.js");const re=require("./use-visual-utils-EazVs86Z.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { c as te, G as L, H as ne, u as oe, Z as ft, _ as ht, $ as gt, a as ie, a1 as bt, a9 as yt, B as V, e as xt, X as Ke, E as Pe, f as Ye, S as Ge, aa as vt, ab as Ct, ac as se, ad as Ae, ae as ze, af as be, ag as ye, ah as kt, ai as Me, aj as Nt, ak as St, al as le, am as Dt, an as Oe, g as Be, ao as Xe, ap as Je, aq as Ze, L as P, a2 as We, a3 as xe, a4 as ve, a5 as Ce, a6 as ke, a7 as Ne, ar as et, as as wt, at as It, au as Re, av as Et, aw as Qe, ax as Tt, ay as Se } from "./switch-CP7SmEIZ.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-
|
|
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-DhuiooCy.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-
|
|
6
|
+
import { u as we } from "./use-visual-utils-PfpWtYcR.js";
|
|
7
7
|
/**
|
|
8
8
|
* @license lucide-react v0.453.0 - ISC
|
|
9
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("./index-
|
|
1
|
+
"use strict";const u=require("./index-D7U5s9Uk.js"),f=require("./switch-DYRgERrC.js"),S=require("react");function K(e){const[a,s]=S.useState(null),[r,t]=S.useState(null),o=u.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!o)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const i=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(i,{method:"HEAD"})).ok)throw new Error(`Module not found at ${i}`)}catch{}const m=await import(i);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>m.useChartStore),t(null)}catch(n){const i=n instanceof Error?n.message:"Unknown error";console.error("Failed to load remote chart store:",i),t(i),s(null)}})()},[e,o]),a}function X(e,a){if(e.length===0)return"";const s=e.find(r=>{var t,o;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((o=r.customCardPreferences)!=null&&o.dataInputCardIds)});if(s)return s.id;if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const l=t.split("__")[0],n=e.find(i=>i.tabTitle===l);return n?n.id:e[0].id}return a}}return e[0].id}const A=new Set;function Y(e){return A.add(e),()=>{A.delete(e)}}function z(){A.forEach(e=>{e()})}const Z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:a,...s}=e;return s};async function B(e,a,s,r){if(!a||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],o=r.getQueryData(t);if(o)return console.log("Using cached visual data for:",s),{data:o,fromCache:!0};console.log("Fetching visual data from network for:",s);const l=u.ue.loading("Loading visual...",{position:"top-center"});try{const n=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${a}`}});if(!n.ok)throw new Error("Failed to load visual");const i=await n.json();return r.setQueryData(t,i),u.ue.dismiss(l),{data:i,fromCache:!1}}catch(n){throw u.ue.dismiss(l),n}}function H(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function ee(e,a){var o,l;const s=(e==null?void 0:e.frameObject)??((o=e==null?void 0:e.visual)==null?void 0:o.frameObject);if(!s)return!1;const r=H(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(l=r.cards)==null?void 0:l.find(n=>n.id===r.activeCardId);return t?(u.setupEditorWithCard({...a,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function te(){const e=f.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),a=K(e);return{getUpdatedFrame:S.useCallback(()=>{var b;z();const{frame:r,card:t,isDevMode:o,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y}=f.useEditorStore.getState(),I=t.sql,U=(b=a==null?void 0:a.getState())==null?void 0:b.settings,V=f.buildSavedEditorCard(t,{isDevMode:o,cardSql:I,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y,remoteChartSettings:U,stripConfig:Z}),g=r.cards.map(E=>E.id===t.id?V:E);return{...r,cards:g,activeCardId:X(g,r.activeCardId)}},[a])}}function re(){const{authToken:e,tokenProps:a}=u.useSemaphorContext(),s=u.useQueryClient(),r=u.useAddFrameWithFreshSemanticExecutionPayload(),t=u.useSelectedVisual(),{selectVisual:o}=u.useManagementActions(),{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,clearEditorContext:L}=f.useEditorActions(),{setIsDashboardEditing:v,setIsVisualEditing:T,setSelectedFrameId:j,clearSelectedFrameId:N,setIsDashboardPanelOpen:R}=f.useDashboardActions(),w=f.useDashboardStore(c=>c.selectedSheetId),W=f.useDashboardStore(c=>c.selectedFrameId),$=f.useDashboardStore(c=>c.dashboard),_=f.useDashboardStore(c=>c.filterValues),x=f.useDashboardStore(c=>c.inlineFilterValuesMap),F=u.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),Q=S.useCallback(async c=>{try{o(c),N(),L();const{data:h,fromCache:D}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s);if(!ee(h,{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,setIsDashboardEditing:v,setIsVisualEditing:T,dashboard:$,selectedSheetId:w,selectedFrameId:W,filterValues:_,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:D}}catch(h){return console.error("Error editing visual:",h),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,l,n,v,T,i,m,p,y,I,U,V,g,b,E,P,M,k,L,N,$,w,W,_,x]),G=S.useCallback(async c=>{var D;const h=d=>(u.ue.error(d),{success:!1,error:d});try{if(o(c),!w)return h("No sheet selected. Please select a sheet first.");const{data:d,fromCache:J}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s),O=(d==null?void 0:d.frameObject)??((D=d==null?void 0:d.visual)==null?void 0:D.frameObject);if(!O)return h("Visual has no frame data");const C=H(O);if(!(C!=null&&C.cards)||C.cards.length===0)return h("Visual frame is malformed");const q={...u.cloneLinkedFrameWithSourceMapping(C),visualId:c.id};return await r(w,q,"end"),v(!0),j(q.id),R(!1),{success:!0,fromCache:J}}catch(d){return console.error("Error adding visual:",d),h(d instanceof Error?d.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,w,v,j,R,r]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:Q,handleAddLibraryVisual:G,getUpdatedFrame:te().getUpdatedFrame,refetch:F.refetch}}exports.flushPendingEditorDrafts=z;exports.registerPendingEditorDraftFlusher=Y;exports.useVisualUtils=re;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as X, u as Y, ae as Z, af as ee, ag as te, ah as re, ai as se, aj as ae, p as V, ak as oe } from "./index-
|
|
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-DhuiooCy.js";
|
|
2
2
|
import { H as ne, E as ie, u as b, G as H, I as ce } from "./switch-CP7SmEIZ.js";
|
|
3
3
|
import { useState as z, useEffect as de, useCallback as A } from "react";
|
|
4
4
|
function le(e) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function _(e){return e?e.kind==="semantic"?[e.kind,e.domainId,e.datasetId||"",e.datasetName].join(":"):e.kind==="physical"?[e.kind,e.connectionId,e.databaseName||"",e.schemaName||"",e.tableName].join(":"):[e.kind,e.connectionId,e.dialect||"",e.label||""].join(":"):""}function b(e,i){return!e||!i?e===i:e.kind!==i.kind?!1:e.kind==="semantic"&&i.kind==="semantic"?e.domainId!==i.domainId?!1:e.datasetId&&i.datasetId?e.datasetId===i.datasetId:e.datasetName===i.datasetName:_(e)===_(i)}function A(e,i){return e.kind!=="semantic"||i.kind!=="semantic"?e:{...e,datasetId:e.datasetId||i.datasetId,label:e.label||i.label,connectionId:e.connectionId||i.connectionId}}function I(e,i){return e.name===i.name&&b(e.source,i.source)}function F(e,i){return{...e,label:e.label||i.label,role:e.role||i.role,dataType:e.dataType||i.dataType,source:e.source&&i.source?A(e.source,i.source):e.source||i.source}}function a(e,i,n){return n?{code:e,message:i,path:n}:{code:e,message:i}}function j(e){for(let i=0;i<e.length;i+=1){const n=e[i];if(e.some((o,r)=>r!==i&&M(o,n)))return!1}return!0}function S(e,i){return I(e,i)}function M(e,i){return S(e,i)&&y(e)===y(i)}function T(e){return`Metric intent has duplicate metric "${e.name}" with the same aggregate (${y(e)}). Use different aggregates to request both, or remove one entry.`}function D(e,i){return h(e,i).length===1}function x(e,i){return h(e,i).length===1}function h(e,i){return i.filter(o=>q(e,o))}function q(e,i){return C(e,i)?e.source?S(i,e):!0:!1}function C(e,i){return!(i.name!==e.name||e.role!==void 0&&i.role!==void 0&&i.role!==e.role||E(e,i)&&y(i)!==y(e))}function E(e,i){return e.role==="measure"||i.role==="measure"||e.aggregate!==void 0||i.aggregate!==void 0}function y(e){return(e.aggregate||"SUM").toUpperCase()}function d(e){return typeof e=="string"&&e.trim().length>0}function c(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function g(e){const i=new Set;for(const n of e){if(i.has(n))return n;i.add(n)}return null}const P=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function k(e,i,n){if(!e||typeof e!="object"){n.push(a("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){d(e.domainId)||n.push(a("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),d(e.datasetName)||n.push(a("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){d(e.connectionId)||n.push(a("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),d(e.tableName)||n.push(a("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){d(e.connectionId)||n.push(a("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`));return}n.push(a("invalid_source_kind","Source kind is not supported.",i))}function f(e,i,n,o={}){if(!e||!c(e)){o.required&&n.push(a("missing_field_ref","Field reference needs a name.",i));return}d(e.name)||n.push(a("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&k(e.source,`${i}.source`,n),O(e.aggregate,`${i}.aggregate`,n)}function O(e,i,n){e!==void 0&&(typeof e!="string"||!P.has(e))&&n.push(a("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",i))}function H(e,i){if(e.analysis===void 0)return;if(!c(e.analysis)){i.push(a("invalid_metric_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(a("invalid_metric_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(a("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(a("missing_analysis_time_grain","Period-change analysis needs a timeGrain.","timeGrain")),e.analysis.orderBy!==void 0&&e.analysis.orderBy!=="absolute_change"&&e.analysis.orderBy!=="positive_change"&&e.analysis.orderBy!=="negative_change"&&e.analysis.orderBy!=="period"&&i.push(a("invalid_metric_analysis","Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.","analysis.orderBy"));const{timeWindow:n}=e.analysis;n!==void 0&&w(n,"analysis.timeWindow",i)}function w(e,i,n){if(!c(e)){n.push(a("invalid_time_window","Time window must be a structured object.",i));return}e.unit!=="second"&&e.unit!=="minute"&&e.unit!=="hour"&&e.unit!=="day"&&e.unit!=="week"&&e.unit!=="month"&&e.unit!=="quarter"&&e.unit!=="year"&&n.push(a("invalid_time_window","Time window unit must be second, minute, hour, day, week, month, quarter, or year.",`${i}.unit`)),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<=0)&&n.push(a("invalid_time_window","Time window value must be a positive number.",`${i}.value`)),e.anchor!==void 0&&e.anchor!=="now"&&e.anchor!=="latest_available"&&n.push(a("invalid_time_window","Time window anchor must be now or latest_available.",`${i}.anchor`)),e.completeness!==void 0&&e.completeness!=="include_partial"&&e.completeness!=="complete_periods"&&n.push(a("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${i}.completeness`))}function U(e,i,n){if(e!==void 0){if(!Array.isArray(e)){n.push(a("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((o,r)=>{const s=`${i}.${r}`;if(!c(o)){n.push(a("invalid_analytics_filter","Analytics filter must be a structured object.",s));return}const t=o;f(t.field,`${s}.field`,n,{required:!0});const p=t.operator==="is_null"||t.operator==="is_not_null";if(t.operator!==void 0&&t.operator!=="="&&t.operator!=="!="&&t.operator!=="in"&&t.operator!=="not_in"&&t.operator!=="contains"&&t.operator!=="not_contains"&&t.operator!=="between"&&t.operator!=="not_between"&&t.operator!==">"&&t.operator!==">="&&t.operator!=="<"&&t.operator!=="<="&&t.operator!=="is_null"&&t.operator!=="is_not_null"&&n.push(a("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${s}.operator`)),t.values===void 0&&!p&&n.push(a("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",s)),p&&t.values!==void 0){n.push(a("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${s}.values`));return}t.values!==void 0&&!Array.isArray(t.values)&&n.push(a("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${s}.values`))})}}function v(e){var o;const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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."}]};if(e.version!==void 0&&e.version!==1&&i.push(a("invalid_version","Analytics intent version must be 1.","version")),k(e.source,"source",i),e.kind==="metric"){const r=Array.isArray(e.metrics)?e.metrics.filter(s=>c(s)&&d(s.name)):[];if(!Array.isArray(e.metrics)||e.metrics.length===0?i.push(a("missing_metric","Metric intent needs at least one metric.","metrics")):e.metrics.some(s=>!c(s)||!d(s.name))&&i.push(a("invalid_metric_list","Metric intent metrics must be an array of field references with names.","metrics")),r.forEach((s,t)=>{f(s,`metrics.${t}`,i,{required:!0})}),r.length>0&&!j(r)){const s=r.find((t,p)=>r.some((u,l)=>l!==p&&M(u,t)));s&&i.push(a("duplicate_metric",T(s),"metrics"))}if(c(e.primaryMetric)&&d(e.primaryMetric.name)&&h(e.primaryMetric,r).length>1&&i.push(a("ambiguous_primary_metric","Metric intent primaryMetric must identify exactly one selected metric.","primaryMetric")),e.primaryMetric!==void 0&&(f(e.primaryMetric,"primaryMetric",i,{required:!0}),c(e.primaryMetric)&&d(e.primaryMetric.name)&&r.length>0&&!D(e.primaryMetric,r)&&i.push(a("invalid_primary_metric","Metric intent primaryMetric must match one metric field reference.","primaryMetric"))),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(a("invalid_metric_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(s=>!c(s)||!d(s.name))&&i.push(a("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),e.timeWindow!==void 0&&(w(e.timeWindow,"timeWindow",i),e.dateField||i.push(a("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),U(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((s,t)=>{f(s,`dimensions.${t}`,i)}),e.orderBy!==void 0){if(!c(e.orderBy))i.push(a("invalid_metric_order_by","Metric intent orderBy must be a structured object.","orderBy"));else if(f(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_metric_order_direction","Metric intent orderBy direction must be asc or desc.","orderBy.direction")),c(e.orderBy.field)&&d(e.orderBy.field.name)){const s=[...r,...e.timeGrain&&e.dateField&&c(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(t=>c(t)&&d(t.name)):[]];s.length>0&&!x(e.orderBy.field,s)&&i.push(a("invalid_metric_order_by","Metric intent orderBy.field must match one selected metric, grouped dateField, or dimension.","orderBy.field"))}}H(e,i)}else e.kind==="records"?(!Array.isArray(e.fields)||e.fields.length===0?i.push(a("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(r=>!c(r)||!d(r.name))&&i.push(a("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((r,s)=>{f(r,`fields.${s}`,i)}),e.dateField!==void 0&&f(e.dateField,"dateField",i),e.orderBy!==void 0&&(c(e.orderBy)?(f(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_record_order_direction","Records intent orderBy direction must be asc or desc.","orderBy.direction"))):i.push(a("invalid_record_order_by","Records intent orderBy must be a structured object.","orderBy")))):e.kind==="inputOptions"?((!e.field||!d(e.field.name))&&i.push(a("missing_input_options_field","Input options intent needs a field.","field")),f(e.field,"field",i,{required:!0})):e.kind==="sql"?(((o=e.source)==null?void 0:o.kind)!=="sql"&&i.push(a("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),d(e.sql)||i.push(a("missing_sql","SQL analytics intent needs SQL text.","sql")),Array.isArray(e.fields)&&e.fields.forEach((r,s)=>{f(r,`fields.${s}`,i)})):i.push(a("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:L(i)}}function $(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(a("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(a("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((o,r)=>{d(o.id)||i.push(a("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${r}.id`)),d(o.prompt)||i.push(a("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${r}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(d(e.instruction)||i.push(a("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const o=v(e.analyticsIntent);i.push(...o.errors),n.push(...o.warnings)}}else i.push(a("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:N(i)}}function G(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(a("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(a("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const o=$(e.operationIntent);return i.push(...o.errors),n.push(...o.warnings),Array.isArray(e.plannedToolCalls)||i.push(a("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:n,repairHints:N(i)}}function N(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 L(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 Q(e,i,n,o){if(!e||typeof e!="object"){n.push(a("invalid_view","Dashboard view must be an object.",i));return}if(d(e.title)||n.push(a("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){n.push(a("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){d(e.text)||o.push(a("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){n.push(a("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}const r=v(e.analytics);for(const s of r.errors)n.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`));for(const s of r.warnings)o.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`))}function V(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:n};e.version!==1&&i.push(a("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(a("invalid_kind","Experience intent kind must be dashboard.")),d(e.title)||i.push(a("missing_title","Dashboard intent needs a title.","title"));const o=Array.isArray(e.inputs)?e.inputs:[],r=g(o.filter(c).map(u=>u.id).filter(u=>typeof u=="string"));r&&i.push(a("duplicate_input_id",`Duplicate input id: ${r}.`,"inputs"));for(const[u,l]of o.entries()){const m=`inputs.${u}`;if(!c(l)){i.push(a("invalid_input","Dashboard input must be an object.",m));continue}d(l.id)||i.push(a("missing_input_id","Input needs an id.",`${m}.id`)),d(l.label)||i.push(a("missing_input_label","Input needs a label.",`${m}.label`)),!l.field||!d(l.field.name)?i.push(a("missing_input_field","Input needs a field.",`${m}.field`)):f(l.field,`${m}.field`,i)}const s=Array.isArray(e.sections)?e.sections:[];s.length===0&&i.push(a("missing_sections","Dashboard intent needs at least one section.","sections"));const t=s.flatMap(u=>u&&typeof u=="object"&&Array.isArray(u.views)?u.views.filter(c).map(l=>l.id).filter(l=>!!l):[]),p=g(t);p&&i.push(a("duplicate_view_id",`Duplicate dashboard view id: ${p}.`,"sections"));for(const[u,l]of s.entries()){const m=`sections.${u}`;if(!l||typeof l!="object"){i.push(a("invalid_section","Dashboard section must be an object.",m));continue}if(d(l.title)||i.push(a("missing_section_title","Dashboard section needs a title.",m)),!Array.isArray(l.views)||l.views.length===0){i.push(a("missing_section_views","Dashboard section needs at least one view.",`${m}.views`));continue}for(const[R,B]of l.views.entries())Q(B,`${m}.views.${R}`,i,n)}return{ok:i.length===0,errors:i,warnings:n}}exports.preferSemaphorFieldRefMetadata=F;exports.preferSemaphorSourceMetadata=A;exports.semaphorFieldRefsMatch=I;exports.semaphorSourceIdentityKey=_;exports.semaphorSourcesReferToSameDataset=b;exports.validateSemaphorAnalyticsIntent=v;exports.validateSemaphorAnalyticsRecoveryPlan=G;exports.validateSemaphorDashboardIntent=V;exports.validateSemaphorOperationIntent=$;
|