react-semaphor 0.1.416 → 0.1.417
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/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +2 -2
- package/dist/chunks/{analyze-result-contract-DPjm6btg.js → analyze-result-contract-B0O3oIYu.js} +2 -1
- package/dist/chunks/analyze-result-contract-CL97m8X8.js +1 -0
- package/dist/chunks/{calendar-preferences-dialog-B8FmFRHX.js → calendar-preferences-dialog-BOfryj8P.js} +3 -3
- package/dist/chunks/{calendar-preferences-dialog-ck4AU-to.js → calendar-preferences-dialog-Rq9qiG3X.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Br_1IK1z.js → dashboard-briefing-launcher-D_P0cNQ_.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Tr2SqDMK.js → dashboard-briefing-launcher-DgvlOcRI.js} +4 -4
- package/dist/chunks/{dashboard-controls-B7OObDNl.js → dashboard-controls-DzVA-wWu.js} +1 -1
- package/dist/chunks/{dashboard-controls-B2bEv8uG.js → dashboard-controls-JYTKRokc.js} +5 -5
- package/dist/chunks/{dashboard-json-DNixjalS.js → dashboard-json-D5TEri2w.js} +1 -1
- package/dist/chunks/{dashboard-json-DAB8WVyb.js → dashboard-json-h6YMk_-l.js} +3 -3
- package/dist/chunks/{edit-dashboard-visual-Dh8Ge3-B.js → edit-dashboard-visual-DOtCYmDn.js} +4 -4
- package/dist/chunks/{edit-dashboard-visual-DWygSAp3.js → edit-dashboard-visual-kfbu03n9.js} +1 -1
- package/dist/chunks/{index-CQIMj-FF.js → index-Beol8cOo.js} +2 -2
- package/dist/chunks/{index-BkTLAfKy.js → index-BgESS5r7.js} +5 -5
- package/dist/chunks/{switch-DMlqgIx_.js → switch--FHwRAOL.js} +1 -1
- package/dist/chunks/{switch-DgiogS4X.js → switch-C8_t4Pio.js} +1 -1
- package/dist/chunks/update-policy-B50M0Jeg.js +3 -0
- package/dist/chunks/{update-policy-BnEbPhHW.js → update-policy-CQLHKQ_h.js} +304 -290
- package/dist/chunks/{use-create-flow-overlay-state-CZA-dSns.js → use-create-flow-overlay-state-BEPWzqQn.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-uujasvbD.js → use-create-flow-overlay-state-NEs9ePDy.js} +3 -3
- 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 +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +18 -18
- package/dist/data-app-codegen-node/index.js +81 -81
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +1 -1
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +1 -1
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +1 -1
- package/dist/types/data-app-codegen-node.d.ts +4 -3
- package/dist/types/data-app-codegen.d.ts +4 -3
- package/package.json +1 -1
- package/dist/chunks/analyze-result-contract-8nxUOWp8.js +0 -1
- package/dist/chunks/update-policy-CWg9c08k.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const W=require("./x-B6ghREd2.js"),C=require("react"),s=require("./switch
|
|
1
|
+
"use strict";const W=require("./x-B6ghREd2.js"),C=require("react"),s=require("./switch--FHwRAOL.js"),f=require("./index-Beol8cOo.js"),e=require("react/jsx-runtime");require("./analyze-result-contract-CL97m8X8.js");const ke=require("./save-C__QggEE.js"),ye=require("./search-DNCejM7Z.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 ge, X as et, C as je } from "./x-CXDkqdur.js";
|
|
2
2
|
import { useState as K, useEffect as ie, useCallback as B, useMemo as P, useRef as Se, Fragment as bt } from "react";
|
|
3
|
-
import { F as de, A as Le, u as Z, E as M, a4 as yt, Q as vt, V as xt, W as Ct, c as fe, Y as kt, a5 as St, B as q, d as Nt, e as tt, a6 as wt, a7 as Dt, a8 as pe, a9 as Qe, aa as $e, ab as Ne, ac as we, ad as Et, ae as Pe, af as It, ag as Ft, ah as me, ai as Vt, aj as He, ak as at, al as rt, am as st, L as oe, Z as nt, _ as De, $ as Ee, a0 as Ie, a1 as Fe, a2 as Ve, an as ot, ao as Tt, ap as _t, aq as We, ar as Lt, as as Ke, at as At, au as Te } from "./switch-
|
|
4
|
-
import { aB as qt, u as Mt, aC as ce, aD as Ot, aE as Ae, aF as zt, aG as Ut, aH as Bt, p as R, aI as Rt, aJ as jt, aK as lt, aL as Qt, aM as $t, aN as Pt, aO as Ht, aP as Wt, y as Kt, aQ as Yt, aR as it, aS as dt, aT as Gt, aU as Jt, aV as Xt, aW as Zt, aX as ea, aY as ct, aZ as ut, a_ as ta, a$ as aa, b0 as ra, b1 as sa, b2 as na, ar as oa, b3 as la, b4 as ia } from "./index-
|
|
3
|
+
import { F as de, A as Le, u as Z, E as M, a4 as yt, Q as vt, V as xt, W as Ct, c as fe, Y as kt, a5 as St, B as q, d as Nt, e as tt, a6 as wt, a7 as Dt, a8 as pe, a9 as Qe, aa as $e, ab as Ne, ac as we, ad as Et, ae as Pe, af as It, ag as Ft, ah as me, ai as Vt, aj as He, ak as at, al as rt, am as st, L as oe, Z as nt, _ as De, $ as Ee, a0 as Ie, a1 as Fe, a2 as Ve, an as ot, ao as Tt, ap as _t, aq as We, ar as Lt, as as Ke, at as At, au as Te } from "./switch-C8_t4Pio.js";
|
|
4
|
+
import { aB as qt, u as Mt, aC as ce, aD as Ot, aE as Ae, aF as zt, aG as Ut, aH as Bt, p as R, aI as Rt, aJ as jt, aK as lt, aL as Qt, aM as $t, aN as Pt, aO as Ht, aP as Wt, y as Kt, aQ as Yt, aR as it, aS as dt, aT as Gt, aU as Jt, aV as Xt, aW as Zt, aX as ea, aY as ct, aZ as ut, a_ as ta, a$ as aa, b0 as ra, b1 as sa, b2 as na, ar as oa, b3 as la, b4 as ia } from "./index-BgESS5r7.js";
|
|
5
5
|
import { jsx as a, jsxs as m, Fragment as re } from "react/jsx-runtime";
|
|
6
|
-
import "./analyze-result-contract-
|
|
6
|
+
import "./analyze-result-contract-B0O3oIYu.js";
|
|
7
7
|
import { S as pt } from "./save-DgMfP0j8.js";
|
|
8
8
|
import { C as Ye } from "./search-BHsQIWBV.js";
|
|
9
9
|
/**
|
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-Beol8cOo.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 C=require("../chunks/contracts-CtB2VONT.js"),M=require("../chunks/source-identity-BM2FvJDP.js"),U=require("../chunks/validators-JzI7olk4.js");require("../chunks/analyze-result-contract-8nxUOWp8.js");const De=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),ve=require("../chunks/operators-DrTQsJXv.js");function _(e){return e&&typeof e=="object"?e:null}function D(e){return typeof e=="string"?e:null}function oe(e){var t,r,n;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((r=_(e))==null?void 0:r.kind)==="physical"||((n=_(e))==null?void 0:n.kind)==="sql")}function F(e){return oe(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function Ce(e){return M.semaphorSourceIdentityKey(e)}function K(e,t){return M.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return M.preferSemaphorSourceMetadata(e,t)}function N(e){const t=[];for(const r of e){const n=t.findIndex(o=>K(o,r));n===-1?t.push(r):t[n]=se(t[n],r)}return t}function ke(e){return N(e)[0]}function j(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!M.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function G(e){return F(e)?e:void 0}function ae(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&M.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function w(e,t){const r=G(e==null?void 0:e.source);return r?j(r,t):void 0}function de({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=G(e),i=a?j(a,ae(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=w(t,r),s=d?j(d,ae(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return G(r)}function xe(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=w(e),n=w(t);return!r||!n?!0:K(r,n)}function k(e){var t;return D((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return k(e)!=="semantic"?null:((r=D((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Fe(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetName)}function Te(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetId)}function Re(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.connectionId)}function Ne(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.tableName)}function Me(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.schemaName)||""}function le(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function ue({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(ce),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function q(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Te(e);return ce(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Fe(e)===t.datasetName:!1}return t.kind==="physical"?Re(e)===t.connectionId&&Ne(e)===t.tableName&&Me(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Be(e,t){return e.find(r=>q(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function fe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=le(e);if(!n){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>q(o,n))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function P(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function V(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function ie(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Oe(e){var r,n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...P([...V(e.measures),e.primaryMeasure,e.dateField,...V(e.dimensions),...ie(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...P([...V(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...ie(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((n=e.population)==null?void 0:n.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...P([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...P(e.fields||[])),t}function pe({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Oe(e.analyticsIntent))if(n&&!t.some(o=>q(o,n))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function he({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=U.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const n of r.errors)t.push(p(n.code,n.path?`${n.path}: ${n.message}`:n.message,e.id))}function me({datasets:e,errors:t,requireAtLeastOne:r}){const n=ue({datasets:e,requireAtLeastOne:r});if(!n.ok){if(n.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function ge(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.sheets)?r.sheets:[];me({datasets:o,errors:t,requireAtLeastOne:!0}),a.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const i=a[0];i&&i.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(i==null?void 0:i.cards)||[];d.length>C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=O(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=O(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),fe({card:l,datasets:o,errors:t}),he({card:l,errors:t}),pe({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),S=O(I);S&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${S}.`));const A=h.map(l=>l.variableName).filter(Boolean)||[],y=O(A);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:n}}function be(e){var i;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(i=r.dashboardId)!=null&&i.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.operations)?r.operations:[];me({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of a){if(d.kind==="unsupported"){n.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(fe({card:d.card,datasets:o,errors:t}),he({card:d.card,errors:t}),pe({card:d.card,datasets:o,errors:t})),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:n}}const Pe={lg:48,md:36,sm:24,xs:12,xxs:6};function qe(e,t){let r=0,n=0,o=0;return e.map(a=>{const i=Math.min(a.w,t);r>0&&r+i>t&&(r=0,n+=o,o=0);const d={i:a.frameId,x:r,y:n,w:i,h:a.h,minW:Math.min(a.minW,t),minH:a.minH,static:!1};return r+=i,o=Math.max(o,a.h),d})}function ze(e){const t=[...e].sort((s,u)=>s.priority-u.priority),r=t.filter(s=>s.role==="kpi"),n=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),a=t.filter(s=>s.role==="text"),i=a.slice(0,1),d=a.slice(i.length);return{kpis:r,introText:i,charts:n,tables:o,supportingText:d}}function Ee(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Ve(e,t,r,n){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?n:n/2}function He(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ee(o,a,i),h:15,minW:Math.min(6,i),minH:12}:r==="table"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?34:38,minW:Math.min(12,i),minH:18}:r==="introText"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:r==="supportingText"?{...t,band:r,w:a==="lg"?i/2:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:{...t,band:r,w:Ve(n,o,a,i),h:a==="xxs"||a==="xs"?28:30,minW:Math.min(12,i),minH:16}}function T(e,t,r,n){return e.map((o,a)=>He({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function z(e){const t=ze(e);return Object.fromEntries(C.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=Pe[r],o=[...T(t.introText,"introText",r,n),...T(t.kpis,"kpi",r,n),...T(t.charts,"chart",r,n),...T(t.tables,"table",r,n),...T(t.supportingText,"supportingText",r,n)];return[r,qe(o,n)]}))}function Le(e){const t=De.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function je(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ge(e){return je(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function We(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function Ue(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function X(e,t){if(t===void 0)return;const r=Le(e.dataType),n=e.operation||"in";if(Ge(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,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:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],a=r==="date"?Ue(o):We(o);if(a.length!==0&&!((n==="between"||n==="not between")&&a.length<2))return{filterId:e.id,name:e.column,operation:n,valueType:r,values:a,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function Ie(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ke(e,t,r){const n=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return n.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...n]}}function W(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Xe(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=W(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Je(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:W(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:W(e.excludeCardIds,t)}:{}}}function Qe(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Xe(a.scope,t);if(d===null)return n.push(Ie("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=X(a.filter,a.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[a.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:a.id,kind:"filter",label:a.label,variableName:a.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:Je(a.filter,t)}]}),warnings:n,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function Ye(e){var A,y;const t=ge(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("../chunks/contracts-CtB2VONT.js"),M=require("../chunks/source-identity-BM2FvJDP.js"),U=require("../chunks/validators-JzI7olk4.js");require("../chunks/analyze-result-contract-CL97m8X8.js");const De=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),ve=require("../chunks/operators-DrTQsJXv.js");function _(e){return e&&typeof e=="object"?e:null}function D(e){return typeof e=="string"?e:null}function oe(e){var t,r,n;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((r=_(e))==null?void 0:r.kind)==="physical"||((n=_(e))==null?void 0:n.kind)==="sql")}function F(e){return oe(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function Ce(e){return M.semaphorSourceIdentityKey(e)}function K(e,t){return M.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return M.preferSemaphorSourceMetadata(e,t)}function N(e){const t=[];for(const r of e){const n=t.findIndex(o=>K(o,r));n===-1?t.push(r):t[n]=se(t[n],r)}return t}function ke(e){return N(e)[0]}function j(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!M.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function G(e){return F(e)?e:void 0}function ae(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&M.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function w(e,t){const r=G(e==null?void 0:e.source);return r?j(r,t):void 0}function de({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=G(e),i=a?j(a,ae(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=w(t,r),s=d?j(d,ae(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return G(r)}function xe(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=w(e),n=w(t);return!r||!n?!0:K(r,n)}function k(e){var t;return D((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return k(e)!=="semantic"?null:((r=D((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Fe(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetName)}function Te(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetId)}function Re(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.connectionId)}function Ne(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.tableName)}function Me(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.schemaName)||""}function le(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function ue({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(ce),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function q(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Te(e);return ce(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Fe(e)===t.datasetName:!1}return t.kind==="physical"?Re(e)===t.connectionId&&Ne(e)===t.tableName&&Me(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Be(e,t){return e.find(r=>q(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function fe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=le(e);if(!n){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>q(o,n))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function P(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function V(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function ie(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Oe(e){var r,n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...P([...V(e.measures),e.primaryMeasure,e.dateField,...V(e.dimensions),...ie(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...P([...V(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...ie(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((n=e.population)==null?void 0:n.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...P([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...P(e.fields||[])),t}function pe({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Oe(e.analyticsIntent))if(n&&!t.some(o=>q(o,n))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function he({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=U.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const n of r.errors)t.push(p(n.code,n.path?`${n.path}: ${n.message}`:n.message,e.id))}function me({datasets:e,errors:t,requireAtLeastOne:r}){const n=ue({datasets:e,requireAtLeastOne:r});if(!n.ok){if(n.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function ge(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.sheets)?r.sheets:[];me({datasets:o,errors:t,requireAtLeastOne:!0}),a.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const i=a[0];i&&i.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(i==null?void 0:i.cards)||[];d.length>C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=O(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=O(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),fe({card:l,datasets:o,errors:t}),he({card:l,errors:t}),pe({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),S=O(I);S&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${S}.`));const A=h.map(l=>l.variableName).filter(Boolean)||[],y=O(A);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:n}}function be(e){var i;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(i=r.dashboardId)!=null&&i.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.operations)?r.operations:[];me({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of a){if(d.kind==="unsupported"){n.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(fe({card:d.card,datasets:o,errors:t}),he({card:d.card,errors:t}),pe({card:d.card,datasets:o,errors:t})),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:n}}const Pe={lg:48,md:36,sm:24,xs:12,xxs:6};function qe(e,t){let r=0,n=0,o=0;return e.map(a=>{const i=Math.min(a.w,t);r>0&&r+i>t&&(r=0,n+=o,o=0);const d={i:a.frameId,x:r,y:n,w:i,h:a.h,minW:Math.min(a.minW,t),minH:a.minH,static:!1};return r+=i,o=Math.max(o,a.h),d})}function ze(e){const t=[...e].sort((s,u)=>s.priority-u.priority),r=t.filter(s=>s.role==="kpi"),n=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),a=t.filter(s=>s.role==="text"),i=a.slice(0,1),d=a.slice(i.length);return{kpis:r,introText:i,charts:n,tables:o,supportingText:d}}function Ee(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Ve(e,t,r,n){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?n:n/2}function He(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ee(o,a,i),h:15,minW:Math.min(6,i),minH:12}:r==="table"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?34:38,minW:Math.min(12,i),minH:18}:r==="introText"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:r==="supportingText"?{...t,band:r,w:a==="lg"?i/2:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:{...t,band:r,w:Ve(n,o,a,i),h:a==="xxs"||a==="xs"?28:30,minW:Math.min(12,i),minH:16}}function T(e,t,r,n){return e.map((o,a)=>He({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function z(e){const t=ze(e);return Object.fromEntries(C.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=Pe[r],o=[...T(t.introText,"introText",r,n),...T(t.kpis,"kpi",r,n),...T(t.charts,"chart",r,n),...T(t.tables,"table",r,n),...T(t.supportingText,"supportingText",r,n)];return[r,qe(o,n)]}))}function Le(e){const t=De.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function je(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ge(e){return je(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function We(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function Ue(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function X(e,t){if(t===void 0)return;const r=Le(e.dataType),n=e.operation||"in";if(Ge(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,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:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],a=r==="date"?Ue(o):We(o);if(a.length!==0&&!((n==="between"||n==="not between")&&a.length<2))return{filterId:e.id,name:e.column,operation:n,valueType:r,values:a,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function Ie(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ke(e,t,r){const n=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return n.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...n]}}function W(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Xe(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=W(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Je(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:W(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:W(e.excludeCardIds,t)}:{}}}function Qe(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Xe(a.scope,t);if(d===null)return n.push(Ie("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=X(a.filter,a.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[a.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:a.id,kind:"filter",label:a.label,variableName:a.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:Je(a.filter,t)}]}),warnings:n,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function Ye(e){var A,y;const t=ge(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
|
|
2
2
|
`)||"Dashboard plan is invalid.");const r=e.plan.sheets[0],n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(c=>[c.planCardId,c])),i=new Map(e.cardArtifacts.map(c=>[c.planCardId,c.card.id])),d=[];for(const c of r.cards){const f=a.get(c.id);if(!f){const l=Ie("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);o.push(l);continue}n.push(...f.warnings||[]);const g=Ke(f.card,e.plan.calculatedFields,c.id);d.push({id:c.frameId,cards:[g],activeCardId:g.id})}if(d.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:s,defaultInputValues:u,warnings:h}=Qe(e.plan,i);n.push(...h);const I=z(r.cards.filter(c=>d.some(f=>f.id===c.frameId)).map(c=>({frameId:c.frameId,priority:c.priority,role:c.role})));return{dashboard:{id:e.dashboardId,title:e.plan.title,description:e.plan.description||"",sheets:[{id:r.id,kind:"dashboard",title:r.title,description:r.description,frames:d,layouts:I,calculatedFields:(A=e.plan.calculatedFields)==null?void 0:A.filter(c=>c.scope==="sheet"&&c.field).map(c=>c.field)}],calculatedFields:(y=e.plan.calculatedFields)==null?void 0:y.filter(c=>c.scope==="dashboard"&&c.field).map(c=>c.field),inputs:s,...u?{defaultInputValues:u}:{}},warnings:n,skippedOperations:o}}function x(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ze(e){return JSON.parse(JSON.stringify(e))}function et(e){var t;return(t=e.sheets)==null?void 0:t.find(r=>(r.kind||"dashboard")==="dashboard")}function H(e,t){var r;for(const n of e.sheets||[])for(const o of n.frames||[]){const a=(r=o.cards)==null?void 0:r.find(i=>i.id===t);if(a)return{sheet:n,frame:o,card:a}}return null}function ye(e){var r,n;const t=(n=(r=e.cards)==null?void 0:r[0])==null?void 0:n.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function tt(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((r,n)=>[r.i,n]))}function _e(e,t=new Map){const r=tt(e),n=Math.max(r.size,t.size),o=(e.frames||[]).map((a,i)=>({frameId:a.id,role:ye(a),priority:t.get(a.id)??r.get(a.id)??n+i}));e.layouts=z(o)}function rt(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function nt(e,t){if(!rt(e)){_e(e);return}const r=z([{frameId:t.id,role:ye(t),priority:0}]);e.layouts??(e.layouts={});for(const[n,o]of Object.entries(r)){const a=e.layouts[n]||[];if(a.some(s=>s.i===t.id))continue;const i=o[0];if(!i)continue;const d=a.reduce((s,u)=>Math.max(s,u.y+u.h),0);e.layouts[n]=[...a,{...i,y:d}]}}function at(e,t){var n;const r=X(t.filter,t.defaultValue);r&&(e.defaultInputValues??(e.defaultInputValues={}),(n=e.defaultInputValues).shared??(n.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:r}})}function it(e){var d;const t=be(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
|
|
3
3
|
`)||"Dashboard change plan is invalid.");const r=Ze(e.dashboard),n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),i=et(r);if(!i)throw new Error("Dashboard has no editable dashboard sheet.");i.frames??(i.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((i.frames||[]).reduce((S,A)=>{var y;return S+(((y=A.cards)==null?void 0:y.length)||0)},0)>=C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(x("generated_card_limit_reached",`AI refinement is capped at ${C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`,s.card.id));break}const h=a.get(s.card.id);if(!h){o.push(x("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const I={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};i.frames.push(I),nt(i,I);break}case"addFilterInput":{r.inputs??(r.inputs=[]);const u={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:r.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};r.inputs.push(u),at(r,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)r.calculatedFields??(r.calculatedFields=[]),r.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)i.calculatedFields??(i.calculatedFields=[]),i.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const u=s.field.targetCardId?H(r,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.card.calculatedFields.push(s.field.field)):o.push(x("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const u=H(r,s.cardId);if(!u){o.push(x("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}u.card.title=s.title,s.description!==void 0&&(u.card.description=s.description);break}case"reorderCards":{const u=new Map;for(let h=0;h<s.cardIds.length;h+=1){const I=s.cardIds[h],S=H(r,I);S&&u.set(S.frame.id,h)}_e(i,u);break}case"reuseCalculatedField":n.push(x("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":o.push(x("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:r,warnings:n,skippedOperations:o}}function b(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function R(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function Se(e,t){if(!t.has(e))return t.add(e),e;let r=2,n=`${e}-${r}`;for(;t.has(n);)r+=1,n=`${e}-${r}`;return t.add(n),n}function $(e){return!!(e&&typeof e=="object")}function Ae(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>$(t)&&typeof t.id=="string"):[]}function J(e){return Array.isArray(e.sections)?e.sections.filter(t=>$(t)):[]}function Q(e){return Array.isArray(e.views)?e.views.filter(t=>$(t)):[]}function v(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const n=w(r);n&&t.push(n)}return t}function ot(e){var n,o,a;if(!e)return[];const t=[];if(F(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...v(e.measures));const i=w(e.dateField);i&&t.push(i),t.push(...v(e.dimensions)),t.push(...v((n=e.filters)==null?void 0:n.map(d=>d.field)))}else if(e.kind==="records"){const i=w(e.dateField);i&&t.push(i),t.push(...v(e.fields)),t.push(...v((o=e.filters)==null?void 0:o.map(d=>d.field)))}else e.kind==="inputOptions"?(((a=e.population)==null?void 0:a.kind)==="related_population"&&F(e.population.baseSource)&&t.push(e.population.baseSource),t.push(...v([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(i=>!!i)))):e.kind==="sql"&&t.push(...v(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const i of r){const d=w(i.field);d&&t.push(d)}return t}function st(e){const t=[];for(const r of Ae(e)){const n=w(r.field);n&&t.push(n)}for(const r of J(e))for(const n of Q(r))t.push(...ot(n.analytics));return t}function dt(e){var r;const t=[];for(const n of J(e))for(const o of Q(n))F((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function ct(e,t){const r=N(e).filter(F);if(r.length===0)return t.push(b("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const n=r.every(a=>a.kind==="semantic"),o=Array.from(new Set(r.filter(a=>a.kind==="semantic").map(a=>a.domainId)));return r.length>1&&(!n||o.length!==1)?(t.push(b("multiple_datasets_out_of_scope","The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest.")),[r[0]]):r}function lt(e,t){const r=J(e),n=Ae(e),o=N(st(e)),a=N(dt(e));return{sections:r,inputs:n,sources:o,primarySources:a,defaultSource:a.length===1?a[0]:void 0,datasets:ct(o,t)}}function ut(e){return e&&U.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function ft(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 pt(e){var t,r,n;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((r=e.presentation)==null?void 0:r.kind)==="table"?"table":((n=e.presentation)==null?void 0:n.kind)==="text"?"text":"chart"}function ht(e){const t=ve.normalizeSemaphorInputOperator(e);switch(t){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";case"not_contains":return"not like";default:return t||"in"}}function mt(e){return $(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function gt(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function bt(e,t,r,n,o,a){if(e.kind!=="filter")return a.push(b("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!$(e.field)||typeof e.field.name!="string")return a.push(b("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const i=de({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:r}),d=(i==null?void 0:i.kind)==="semantic"||(i==null?void 0:i.kind)==="physical"?i.connectionId:void 0;if(!d)return a.push(b("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${Se(R(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:mt(e),qualifiedTableName:gt(i),sql:"",operation:ht(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(i==null?void 0:i.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(i==null?void 0:i.kind)==="semantic"?{semanticDomainId:i.domainId,connectionId:i.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:n,filter:h,defaultValue:X(h,e.defaultValue)}}function L(e){const t=[],r=[];for(const n of e.viewIds){const o=e.viewIdToCardId.get(n);o?t.push(o):r.push(n)}return r.length>0&&e.warnings.push(b("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${r.join(", ")}.`)),Array.from(new Set(t))}function It(e){var n,o;if(!e.protocolScope){const a=Array.from(new Set(e.boundCardIds));return a.length>0&&a.length<e.allCardIds.length?{kind:"cards",cardIds:a}:void 0}if(e.protocolScope.level==="dashboard"){if(!((n=e.protocolScope.excludeViewIds)!=null&&n.length))return;const a=new Set(L({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(i=>!a.has(i))}}if(e.protocolScope.level==="view"){const a=L({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return a.length===0?(e.warnings.push(b("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:a}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(b("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((o=e.protocolScope.excludeViewIds)!=null&&o.length))return{kind:"cards",cardIds:t};const r=new Set(L({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(a=>!r.has(a))}}function yt(e){var A,y,c;const t=[],r=U.validateSemaphorDashboardIntent(e);for(const f of r.warnings)t.push(b(f.code,f.message));for(const f of r.errors)t.push(b(f.code,f.message));const n=lt(e,t),o=[],a=new Map,i=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[f,g]of n.sections.entries()){const l=typeof g.title=="string"?g.title:`Section ${f+1}`,Y=g.id||R(l,`section-${f+1}`);i.set(Y,[]);for(const[Z,m]of Q(g).entries()){const ee=ft(m),E=R(m.id||`${l}-${m.title||`View ${Z+1}`}`,`card-${f+1}-${Z+1}`);if(!ee){t.push(b("unsupported_presentation",`Dashboard presentation "${((A=m.presentation)==null?void 0:A.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${E}`));continue}if(((y=m.analytics)==null?void 0:y.kind)==="sql"){t.push(b("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${E}`));continue}const te=Se(E,s),B=`card-${te}`;m.id&&a.set(m.id,B),(c=i.get(Y))==null||c.push(B);const we=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const re of we||[]){const ne=d.get(re.inputId)||[];ne.push(B),d.set(re.inputId,ne)}o.push({id:B,frameId:`frame-${te}`,title:m.title,description:m.description,type:ee,role:pt(m),priority:h,section:l,analyticsIntent:ut(m.analytics),text:m.text}),h+=1}}const I=n.inputs.map(f=>{const g=It({protocolScope:f.scope,inputLabel:f.label,allCardIds:o.map(l=>l.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:a,sectionIdToCardIds:i,warnings:t});return g===null?null:bt(f,n.defaultSource,n.sources,g,u,t)}).filter(f=>!!f);return{plan:{version:1,id:`plan-${R(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:n.datasets,sheets:[{id:`sheet-${R(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:o}],filterInputs:I.length?I:void 0,warnings:t.length?t:void 0,unresolvedRequests:r.ok?void 0:r.errors.map(f=>f.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=C.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.applyDashboardChangePlan=it;exports.compileDashboardFromPlan=Ye;exports.compileResponsiveDashboardLayouts=z;exports.dashboardAuthoringDatasetMatchesSource=q;exports.dashboardAuthoringFieldsReferToSameTarget=xe;exports.dashboardAuthoringSourceFromField=w;exports.dashboardAuthoringSourceKey=Ce;exports.dashboardAuthoringSourcesReferToSameDataset=K;exports.dashboardPlanFromSemaphorDashboardIntent=yt;exports.findDashboardAuthoringDatasetForSource=Be;exports.getDashboardAuthoringCardSource=le;exports.isMaterializableDashboardAuthoringSource=F;exports.isSemaphorSourceRef=oe;exports.mergeDashboardAuthoringSources=N;exports.preferDashboardAuthoringSourceMetadata=se;exports.preferredDashboardAuthoringSource=ke;exports.resolveDashboardAuthoringSource=de;exports.validateDashboardAuthoringDatasetScope=ue;exports.validateDashboardChangePlan=be;exports.validateDashboardPlan=ge;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { D as P, a as be } from "../chunks/contracts-CoCOpd_i.js";
|
|
2
2
|
import { a as Ie, b as E, c as ye } from "../chunks/source-identity-Cv4Nm3TM.js";
|
|
3
3
|
import { b as ae, e as _e } from "../chunks/validators-UqQI3Cg_.js";
|
|
4
|
-
import "../chunks/analyze-result-contract-
|
|
4
|
+
import "../chunks/analyze-result-contract-B0O3oIYu.js";
|
|
5
5
|
import { b as we } from "../chunks/catalog-field-grounding-CJKAqtiC.js";
|
|
6
6
|
import { n as ve } from "../chunks/operators-C8TxpM4C.js";
|
|
7
7
|
function _(e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/index-Beol8cOo.js"),w=require("../chunks/switch--FHwRAOL.js"),Ze=require("../data-app-builder-browser-runtime/index.cjs"),Q=require("../chunks/x-B6ghREd2.js"),Cn=require("../chunks/save-C__QggEE.js"),tt=require("../chunks/search-DNCejM7Z.js");function Tr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const d=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,d.get?d:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const Rn=Tr(p),Bn=Tr(An);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -2,8 +2,8 @@ import { jsx as r, jsxs as c, Fragment as re } from "react/jsx-runtime";
|
|
|
2
2
|
import * as Yn from "react";
|
|
3
3
|
import { useContext as Zn, useState as x, useRef as oe, useMemo as ze, useEffect as W, useCallback as Ot } from "react";
|
|
4
4
|
import * as Xn from "react-dom/client";
|
|
5
|
-
import { ae as ea, af as ta, ag as Ir, ah as jr, ai as zr, aj as ra, ak as Wr, al as Hr, am as Jr, an as Vr, ao as _r, ap as Ur, aq as Gr, ar as na, as as aa, at as oa, au as Ht, av as on, x as Kr, aw as sa, ax as Vt, ay as sn, az as ia, aA as la } from "../chunks/index-
|
|
6
|
-
import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, e as me, R as ma, d as _t } from "../chunks/switch-
|
|
5
|
+
import { ae as ea, af as ta, ag as Ir, ah as jr, ai as zr, aj as ra, ak as Wr, al as Hr, am as Jr, an as Vr, ao as _r, ap as Ur, aq as Gr, ar as na, as as aa, at as oa, au as Ht, av as on, x as Kr, aw as sa, ax as Vt, ay as sn, az as ia, aA as la } from "../chunks/index-BgESS5r7.js";
|
|
6
|
+
import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, e as me, R as ma, d as _t } from "../chunks/switch-C8_t4Pio.js";
|
|
7
7
|
import { loadSemaphorBrowserRuntime as ot } from "../data-app-builder-browser-runtime/index.js";
|
|
8
8
|
import { c as $e, X as Je } from "../chunks/x-CXDkqdur.js";
|
|
9
9
|
import { S as fa } from "../chunks/save-DgMfP0j8.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/analyze-result-contract-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/analyze-result-contract-CL97m8X8.js"),e=require("../chunks/update-policy-B50M0Jeg.js");exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=a.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=a.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=e.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=e.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=e.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=e.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=e.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=e.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=e.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=e.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=e.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=e.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=e.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=e.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=e.validateCodegenSummary;exports.validateSemaphorGeneratedContract=e.validateSemaphorGeneratedContract;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as E, a as S, i as A, v as t } from "../chunks/analyze-result-contract-
|
|
2
|
-
import { C as R, a as r, b as s, G as C, e as o, R as p, c as d, f as O, g as i, h as m, i as n, j as N, v as T, d as I } from "../chunks/update-policy-
|
|
1
|
+
import { S as E, a as S, i as A, v as t } from "../chunks/analyze-result-contract-B0O3oIYu.js";
|
|
2
|
+
import { C as R, a as r, b as s, G as C, e as o, R as p, c as d, f as O, g as i, h as m, i as n, j as N, v as T, d as I } from "../chunks/update-policy-CQLHKQ_h.js";
|
|
3
3
|
export {
|
|
4
4
|
R as CODEGEN_SUMMARY_SCHEMA_VERSION,
|
|
5
5
|
r as CODEGEN_SUMMARY_VALIDATOR_VERSION,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("../chunks/analyze-result-contract-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("../chunks/analyze-result-contract-CL97m8X8.js"),$=require("../chunks/update-policy-B50M0Jeg.js"),ye=require("node:crypto"),Re="src/semaphor/generated",_=`// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
|
|
2
2
|
// Regenerate from the accepted semaphor_plan_data_app codegenSummary when the plan changes.
|
|
3
3
|
`;function ke(e,n={}){$.assertValidCodegenSummary(e);const r=Ce(e);if(r.views.length===0&&!n.allowEmpty)throw new Error("Contract generation produced zero executable views. Stop and ask for a different domain/goal or semantic model improvement; pass --allow-empty only for an explicit model-gap report.");const o=Me(r),t=Oe({contract:r,files:o,generatorName:n.generatorName||"react-semaphor/data-app-codegen/node",generatorVersion:n.generatorVersion||"unknown"}),a={...o,"contract.manifest.json":`${JSON.stringify(t,null,2)}
|
|
4
|
-
`};return{schemaVersion:$.GENERATED_CONTRACT_SCHEMA_VERSION,files:a,manifest:t,contentHash:String(t.generatedContentHash||""),usageExample:Ae(r),warnings:r.warnings,stats:{inputCount:r.inputs.length,executableViewCount:r.views.length,presentationViewCount:r.presentationViews.length,queryCount:r.views.length,optionQueryCount:r.optionQueries.length}}}function Ce(e){var l,u,d,m,c,
|
|
4
|
+
`};return{schemaVersion:$.GENERATED_CONTRACT_SCHEMA_VERSION,files:a,manifest:t,contentHash:String(t.generatedContentHash||""),usageExample:Ae(r),warnings:r.warnings,stats:{inputCount:r.inputs.length,executableViewCount:r.views.length,presentationViewCount:r.presentationViews.length,queryCount:r.views.length,optionQueryCount:r.optionQueries.length}}}function Ce(e){var l,u,d,m,c,I,V,b,C,A,R,M;const n=[],r=[];for(const s of e.inputs){g(r,s.fieldRef);for(const S of s.bindings||[])g(r,S.fieldRef);g(r,(l=s.optionQuery)==null?void 0:l.valueFieldRef),g(r,(u=s.optionQuery)==null?void 0:u.labelFieldRef),g(r,(d=s.optionQuery)==null?void 0:d.filterFieldRef),j(r,(m=s.optionQuery)==null?void 0:m.spec)}for(const s of e.filterContracts){g(r,s.fieldRef),g(r,(c=s.optionQuery)==null?void 0:c.valueFieldRef),g(r,(I=s.optionQuery)==null?void 0:I.labelFieldRef),g(r,(V=s.optionQuery)==null?void 0:V.filterFieldRef),j(r,(b=s.optionQuery)==null?void 0:b.spec);for(const S of s.bindings||[])g(r,S.fieldRef)}for(const s of e.views){for(const S of s.fields||[])g(r,S);j(r,(C=s.sdkSpec)==null?void 0:C.spec),j(r,s.visualSpec)}const o=e.implementationChecklist||{};for(const s of Object.values(o.bindingsByView||{}))for(const S of Array.isArray(s)?s:[])g(r,S.fieldRef),g(r,S.optionValueField),g(r,S.optionLabelField);for(const s of o.requiredInputOptions||[])g(r,s.visibleLabelField),g(r,s.optionValueField),g(r,s.runtimeFilterField);const t=an([...e.sources.map(s=>({raw:s,key:Ie(s),aliases:$e(s),name:""})),...r.map(s=>tn(s)).filter(x)]);K(t,s=>{const S=w(s.raw);return Q(s.raw.label||(S==null?void 0:S.datasetName)||(S==null?void 0:S.datasetId)||(S==null?void 0:S.name)||s.raw.kind||"source")});const a=un(t),p=ne(r.filter(s=>s.name).map(s=>({raw:s,key:U(s),name:""})),s=>s.key);K(p,s=>Q([s.raw.sourceKey?cn(s.raw.sourceKey):"",s.raw.aggregate?s.raw.aggregate.toLowerCase():"",s.raw.name].filter(Boolean).join("_")));const f=new Map(p.map(s=>[s.key,s.name])),h=e.inputs.map(s=>({raw:s,name:Q(s.id||s.label||"input")}));K(h,s=>s.name);const y=h.filter(s=>!!s.raw.optionQuery).map(s=>({input:s,name:`${s.name}Options`,raw:s.raw.optionQuery}));K(y,s=>s.name);for(const s of y)on(s.raw.labelFieldRef,s.raw.valueFieldRef)&&sn(s.raw.valueFieldRef)&&n.push(`Input option query ${((A=s.raw.spec)==null?void 0:A.inputId)||s.input.raw.id||s.name} uses identifier field ${s.raw.valueFieldRef.name} as both label and value. It can execute, but the UI will show key values unless the semantic model exposes a human-readable label through a modeled relationship.`);const i=e.views.filter(s=>{var S,B;return!!((S=s.sdkSpec)!=null&&S.builder&&((B=s.sdkSpec)!=null&&B.spec))}).map(s=>({raw:s,name:Q(s.id||s.title||"query")}));K(i,s=>s.name);const F=e.views.filter(s=>fe(s)&&!("sdkSpec"in s)).map(s=>rn(s));for(const s of e.views)(!("sdkSpec"in s)||!((R=s.sdkSpec)!=null&&R.builder)||!((M=s.sdkSpec)!=null&&M.spec))&&!fe(s)&&n.push(`Skipped view ${s.id||s.title||"unknown"} because it has no sdkSpec.`);return Ne({inputs:h,views:i,filterContracts:e.filterContracts}),{summary:e,title:e.title||"Semaphor Data App",sources:t,fields:p,inputs:h,optionQueries:y,views:i,presentationViews:F,filterContracts:e.filterContracts,checklist:o,sourceNameByKey:a,fieldNameByKey:f,warnings:n}}function Ne({inputs:e,views:n,filterContracts:r}){const o=new Set(e.map(a=>a.raw.id).filter(Boolean)),t=new Set(n.map(a=>a.raw.id).filter(Boolean));for(const[a,p]of r.entries()){if(!o.has(p.inputId))throw new Error(`filterContracts.${a}.inputId must reference a generated input.`);const f=new Set(p.appliesToViewIds||[]),h=new Set(p.notAppliedToViewIds||[]);for(const[y,i]of(p.appliesToViewIds||[]).entries())if(!t.has(i))throw new Error(`filterContracts.${a}.appliesToViewIds.${y} must reference an executable generated view.`);for(const[y,i]of(p.notAppliedToViewIds||[]).entries())if(!t.has(i))throw new Error(`filterContracts.${a}.notAppliedToViewIds.${y} must reference an executable generated view.`);for(const[y,i]of(p.bindings||[]).entries()){if(!t.has(i.viewId))throw new Error(`filterContracts.${a}.bindings.${y}.viewId must reference an executable generated view.`);if(!f.has(i.viewId))throw new Error(`filterContracts.${a}.bindings.${y}.viewId must be included in appliesToViewIds.`);if(h.has(i.viewId))throw new Error(`filterContracts.${a}.bindings.${y}.viewId must not be listed in notAppliedToViewIds.`)}}}function Me(e){return{"sources.ts":_e(e),"fields.ts":He(e),"inputs.ts":qe(e),"queries.ts":je(e),"bindings.ts":Ue(e),"accessors.ts":Je(e),"metadata.ts":Ye(e),"index.ts":We()}}function Oe({contract:e,files:n,generatorName:r,generatorVersion:o}){return{schemaVersion:$.CONTRACT_MANIFEST_SCHEMA_VERSION,generatedContractSchemaVersion:$.GENERATED_CONTRACT_SCHEMA_VERSION,generator:{name:r,version:o},generatedContentHash:Ee(n),codegenSummaryValidatorVersion:$.CODEGEN_SUMMARY_VALIDATOR_VERSION,codegenSummaryHash:xe(e.summary),codegenSummary:e.summary}}function Ee(e){const n=ye.createHash("sha256");for(const r of Object.keys(e).sort())n.update(r),n.update("\0"),n.update(e[r]),n.update("\0");return`sha256:${n.digest("hex")}`}function xe(e){return`sha256:${ye.createHash("sha256").update(ue(e)).digest("hex")}`}function ue(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(o=>ue(o)).join(",")}]`;const n=e;return`{${Object.keys(n).sort().filter(o=>n[o]!==void 0).map(o=>`${JSON.stringify(o)}:${ue(n[o])}`).join(",")}}`}function Ae(e){const n=e.views.find(y=>G(y)&&T(y));if(n)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const sortOption = recordsSortOptionsForView.${n.name}[0];`,'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',`const query = queries.${n.name}({ page, pageSize, sort });`,`const result = useSemaphorQuery(query, queryOptionsForView.${n.name}(inputHandles));`,`const rows = result.records.map((row) => rowValuesForView.${n.name}(row, result.columns));`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
5
5
|
`);const r=e.views.find(y=>G(y));if(r)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const sortOption = recordsSortOptionsForView.${r.name}[0];`,'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',`const query = queries.${r.name}({ sort });`,`const result = useSemaphorQuery(query, queryOptionsForView.${r.name}(inputHandles));`,`const rows = result.records.map((row) => rowValuesForView.${r.name}(row, result.columns));`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
6
6
|
`);const o=e.views.find(y=>X(y)&&T(y));if(o)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const query = queries.${o.name}({ page, pageSize });`,`const result = useSemaphorQuery(query, queryOptionsForView.${o.name}(inputHandles));`,`const rows = result.records.map((row) => rowValuesForView.${o.name}(row, result.columns));`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
7
7
|
`);const t=e.views.find(y=>pe(y)&&T(y));if(t)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const query = queries.${t.name}({ page, pageSize });`,`const result = useSemaphorQuery(query, queryOptionsForView.${t.name}(inputHandles));`,`const rows = result.records.map((row) => rowValuesForView.${t.name}(row, result.columns));`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
@@ -22,14 +22,14 @@ ${n}
|
|
|
22
22
|
${r}export const fields = {
|
|
23
23
|
${n}
|
|
24
24
|
} as const;
|
|
25
|
-
`}function ve(e,n){const r={name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate},o=dn(e),t=o?n.sourceNameByKey.get(o):void 0;if(o&&!t)throw new Error(`Field ${e.name} references source ${o}, but that source is not renderable. Include the source in codegenSummary.sources or provide field.source.`);const a=Object.entries(v(r)).map(([p,f])=>`${JSON.stringify(p)}: ${E(f,n)}`);return t&&a.push(`"source": sources.${t}`),`{ ${a.join(", ")} }`}function qe(e){const n=e.inputs.map(d=>{const m=
|
|
26
|
-
`),r=e.inputs.map(d=>`filterSpecs.${d.name}`).join(", "),o=e.inputs.map(d=>JSON.stringify(d.raw.id)).join(", "),t=e.optionQueries.map(d=>{const m=d.input.raw,c=d.raw,w
|
|
27
|
-
`),a=e.optionQueries.map(d=>{const
|
|
28
|
-
inputs.push(semaphor.bindInput(${
|
|
25
|
+
`}function ve(e,n){const r={name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate},o=dn(e),t=o?n.sourceNameByKey.get(o):void 0;if(o&&!t)throw new Error(`Field ${e.name} references source ${o}, but that source is not renderable. Include the source in codegenSummary.sources or provide field.source.`);const a=Object.entries(v(r)).map(([p,f])=>`${JSON.stringify(p)}: ${E(f,n)}`);return t&&a.push(`"source": sources.${t}`),`{ ${a.join(", ")} }`}function qe(e){const n=e.inputs.map(d=>{const m=N(d.raw.fieldRef,e),c=[`id: ${JSON.stringify(d.raw.id)}`,`label: ${JSON.stringify(d.raw.label||d.raw.id)}`,`operator: ${JSON.stringify(ln(d.raw))}`];if(m&&c.push(`field: fields.${m}`),d.raw.relationshipHint&&c.push(`relationshipHint: ${k(d.raw.relationshipHint)}`),!m)throw new Error(`Input ${d.raw.id||d.name} is missing a generated field reference.`);return` ${d.name}: semaphor.filter({ ${c.join(", ")} }),`}).join(`
|
|
26
|
+
`),r=e.inputs.map(d=>`filterSpecs.${d.name}`).join(", "),o=e.inputs.map(d=>JSON.stringify(d.raw.id)).join(", "),t=e.optionQueries.map(d=>{const m=d.input.raw,c=d.raw,I=w(c.spec)||{},{id:V,inputId:b,source:C,sourceKey:A,valueField:R,labelField:M,population:s,dependencies:S,limit:B,...re}=I,L=c.sourceKey?{sourceKey:c.sourceKey}:c.source||C||(typeof A=="string"?{sourceKey:A}:void 0),te=we(L,e),oe=N(c.valueFieldRef,e),se=N(c.labelFieldRef,e),ae=ge(d),ie={...re,id:c.id||I.id||`${m.id}-options`,inputId:m.id,source:L,valueField:c.valueFieldRef,labelField:c.labelFieldRef,population:c.population||s,dependencies:ae,limit:c.limit||B||100};if(!te||!oe||!se)throw new Error(`Input option query ${c.id||`${m.id}-options`} is missing source, valueField, or labelField.`);const Fe=Object.entries(v(ie)).map(([Ve,be])=>`${JSON.stringify(Ve)}: ${E(be,e)}`);return` ${d.name}: semaphor.inputOptions({ ${Fe.join(", ")} }),`}).join(`
|
|
27
|
+
`),a=e.optionQueries.map(d=>{const m=Be(e,d),c=m.length>0?"inputHandles":"_inputHandles",I=m.map(V=>{const b=N(V.raw.fieldRef,e);if(!b)throw new Error(`Input option query ${d.raw.id||`${d.input.raw.id}-options`} references input ${V.raw.id} without a generated field reference.`);const C=`inputHandles[${JSON.stringify(V.raw.id)}]`;return` if (${C}) {
|
|
28
|
+
inputs.push(semaphor.bindInput(${C}, { field: fields.${b} }));
|
|
29
29
|
}`}).join(`
|
|
30
|
-
`);return` ${d.name}(
|
|
30
|
+
`);return` ${d.name}(${c}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
31
31
|
const inputs: SemaphorInputReference[] = [];
|
|
32
|
-
${
|
|
32
|
+
${I}
|
|
33
33
|
return inputs;
|
|
34
34
|
},`}).join(`
|
|
35
35
|
|
|
@@ -79,7 +79,7 @@ ${f}
|
|
|
79
79
|
}
|
|
80
80
|
throw new Error(\`Unknown generated Semaphor input option query id: \${${i}}\`);
|
|
81
81
|
}
|
|
82
|
-
`}function Be(e,n){const r=ge(n);if(!r||r.mode==="independent")return[];if(r.mode!=="explicit")return[];const o=new Set(r.includeInputIds||[]),t=new Set([n.input.raw.id,...r.excludeInputIds||[]]);return e.inputs.filter(a=>t.has(a.raw.id)?!1:o.has(a.raw.id))}function ge(e){var n;return e.raw.dependencies||((n=e.raw.spec)==null?void 0:n.dependencies)}function je(e){const n=e.views.map(u=>{var c,
|
|
82
|
+
`}function Be(e,n){const r=ge(n);if(!r||r.mode==="independent")return[];if(r.mode!=="explicit")return[];const o=new Set(r.includeInputIds||[]),t=new Set([n.input.raw.id,...r.excludeInputIds||[]]);return e.inputs.filter(a=>t.has(a.raw.id)?!1:o.has(a.raw.id))}function ge(e){var n;return e.raw.dependencies||((n=e.raw.spec)==null?void 0:n.dependencies)}function je(e){const n=e.views.map(u=>{var c,I,V,b,C,A;const d=q(u.raw.sdkSpec.builder),m=Qe(u);if(X(u)&&Te(u)){const R=(c=u.raw.visualSpec)==null?void 0:c.tableBehavior,M=w(m.pagination),s=T(u),S=G(u),B=((I=R==null?void 0:R.pagination)==null?void 0:I.pageSize)||z(M==null?void 0:M.pageSize)||z(m.limit)||100,re=S?Y(u,e):[],L=S?Pe({view:u,contract:e,sortFields:re,defaultField:(V=R==null?void 0:R.sorting)==null?void 0:V.defaultField}):void 0,te=S?(b=R==null?void 0:R.sorting)==null?void 0:b.defaultDirection:void 0,oe=De({viewName:u.name,supportsPagination:s,supportsSort:S}),se=S?` const orderBy = resolveRecordsOrderBy(
|
|
83
83
|
recordsSortFieldsForView.${u.name},
|
|
84
84
|
params.sort,
|
|
85
85
|
${E(L,e)},
|
|
@@ -93,7 +93,7 @@ ${f}
|
|
|
93
93
|
${se} return semaphor.${d}({
|
|
94
94
|
...${E(m,e)},
|
|
95
95
|
${ae}${ie} });
|
|
96
|
-
},`}if(pe(u)&&T(u)){const R=(
|
|
96
|
+
},`}if(pe(u)&&T(u)){const R=(C=u.raw.visualSpec)==null?void 0:C.tableBehavior,M=w(m.pagination),s=((A=R==null?void 0:R.pagination)==null?void 0:A.pageSize)||z(M==null?void 0:M.pageSize)||z(m.limit)||100;return` ${u.name}(
|
|
97
97
|
params: SemaphorGeneratedServerPaginationParams = {},
|
|
98
98
|
) {
|
|
99
99
|
return semaphor.${d}({
|
|
@@ -174,8 +174,8 @@ ${a?`function resolveServerTablePagination(
|
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
`:""}
|
|
177
|
-
`}function Qe(e){var a,p;const n=
|
|
178
|
-
inputs.push(semaphor.bindInput(${
|
|
177
|
+
`}function Qe(e){var a,p;const n=w((a=e.raw.sdkSpec)==null?void 0:a.spec)||{},{kind:r,id:o,...t}=n;return{...t,id:e.raw.id,label:((p=e.raw.visualSpec)==null?void 0:p.title)||e.raw.title||t.label}}function Y(e,n){var a,p;const r=[],o=w((a=e.raw.sdkSpec)==null?void 0:a.spec)||{};for(const f of H(o.fields))g(r,f);g(r,o.dateField),g(r,(p=w(o.orderBy))==null?void 0:p.field);for(const f of e.raw.fields||[])g(r,f);return ne(r.map(f=>{const h=N(f,n);if(!(!f.name||!h))return{key:h,fieldName:h,rawName:f.name,label:f.label||f.name}}).filter(x),f=>f.key)}function Pe({view:e,contract:n,sortFields:r,defaultField:o}){var h,y;const t=new Set(r.map(i=>i.key));if(o&&t.has(o))return o;const a=r.filter(i=>i.rawName===o);if(a.length===1)return a[0].key;const p=w((h=e.raw.sdkSpec)==null?void 0:h.spec),f=N((y=w(p==null?void 0:p.orderBy))==null?void 0:y.field,n);return f&&t.has(f)?f:void 0}function De({viewName:e,supportsPagination:n,supportsSort:r}){return n&&r?`SemaphorGeneratedRecordsQueryParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>`:r?`SemaphorGeneratedRecordsSortParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>`:"SemaphorGeneratedServerPaginationParams"}function Ue(e){const n=e.views.map(i=>{const l=Le(e,i.raw.id).map(u=>{const d=u.inputId,m=N(u.fieldRef,e);if(!d||!m)return"";const c=[`field: fields.${m}`];if(u.relationshipHint)c.push(`relationshipHint: ${k(u.relationshipHint)}`);else if(Array.isArray(u.relationshipsUsed)&&u.relationshipsUsed.length>0){const V=u.relationshipsUsed.map(b=>{var C;return(C=w(b))==null?void 0:C.id}).filter(b=>typeof b=="string"&&b.length>0);V.length>0&&c.push(`relationshipHint: ${k({relationshipIds:V})}`)}const I=`inputHandles[${JSON.stringify(d)}]`;return` if (${I}) {
|
|
178
|
+
inputs.push(semaphor.bindInput(${I}, { ${c.join(", ")} }));
|
|
179
179
|
}`}).filter(Boolean).join(`
|
|
180
180
|
`);return{view:i,renderedBindings:l}}),r=n.some(i=>i.renderedBindings.length>0),o=n.map(({view:i,renderedBindings:F})=>{const l=F?"inputHandles":"_inputHandles";return` ${i.name}(${l}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
181
181
|
const inputs: SemaphorInputReference[] = [];
|
|
@@ -225,15 +225,15 @@ ${p}
|
|
|
225
225
|
}
|
|
226
226
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
227
227
|
}
|
|
228
|
-
`}function Le(e,n){return e.filterContracts.flatMap(r=>(r.bindings||[]).filter(o=>o.viewId===n).map(o=>({inputId:r.inputId,fieldRef:o.fieldRef,relationshipHint:o.relationshipHint,relationshipsUsed:o.relationshipsUsed})))}function Je(e){const n=e.views.map(l=>{const d=W(l,e).map(m=>{const c=
|
|
228
|
+
`}function Le(e,n){return e.filterContracts.flatMap(r=>(r.bindings||[]).filter(o=>o.viewId===n).map(o=>({inputId:r.inputId,fieldRef:o.fieldRef,relationshipHint:o.relationshipHint,relationshipsUsed:o.relationshipsUsed})))}function Je(e){const n=e.views.map(l=>{const d=W(l,e).map(m=>{const c=N(m.raw,e);return c?` ${m.name}: fields.${c},`:""}).filter(Boolean).join(`
|
|
229
229
|
`);return` ${l.name}: {
|
|
230
230
|
${d}
|
|
231
231
|
},`}).join(`
|
|
232
|
-
`),r=e.views.map(l=>{const d=J(l,e).map(m=>{const c=
|
|
232
|
+
`),r=e.views.map(l=>{const d=J(l,e).map(m=>{const c=N(m.raw,e);return c?` ${m.name}: fields.${c},`:""}).filter(Boolean).join(`
|
|
233
233
|
`);return` ${l.name}: {
|
|
234
234
|
${d}
|
|
235
235
|
},`}).join(`
|
|
236
|
-
`),o=e.views.map(l=>{const u=J(l,e),d=en(u),m=Xe(u),c=u.map(
|
|
236
|
+
`),o=e.views.map(l=>{const u=J(l,e),d=en(u),m=Xe(u),c=u.map(I=>{const V=Array.from(new Set(he(I.raw).filter(b=>m.has(b))));return` ${I.name}: metricKeysForField(metricFieldsForView.${l.name}.${I.name}, { allowNameFallback: ${d.has(I.raw.name)?"false":"true"}, excludedKeys: ${k(V)} }),`}).join(`
|
|
237
237
|
`);return` ${l.name}: {
|
|
238
238
|
${c}
|
|
239
239
|
},`}).join(`
|
|
@@ -243,7 +243,7 @@ ${d}
|
|
|
243
243
|
},`}).join(`
|
|
244
244
|
`),a=e.views.map(l=>{const u=J(l,e);if(u.length===0)return` ${l.name}(): Record<keyof typeof metricFieldsForView.${l.name}, unknown> {
|
|
245
245
|
return {};
|
|
246
|
-
},`;const d=Ze(l,u),m=u.map(c=>{const
|
|
246
|
+
},`;const d=Ze(l,u),m=u.map(c=>{const I=`metricMeasureKeysForView.${l.name}.${c.name}`,V=`metricMeasureBindingKeysForView.${l.name}.${c.name}`,b=d.has(c.name)?`readMetricValueByBindingWithFallback(measures, measureBindings, ${V}, ${I}, scalarValue)`:`readMetricValueByBinding(measures, measureBindings, ${V}, ${I})`;return` ${c.name}: ${b},`}).join(`
|
|
247
247
|
`);return` ${l.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${l.name}, unknown> {
|
|
248
248
|
const measures = result?.measures;
|
|
249
249
|
const measureBindings = result?.measureBindings;
|
|
@@ -615,7 +615,7 @@ function sourcesReferToSameDataset(
|
|
|
615
615
|
}
|
|
616
616
|
return false;
|
|
617
617
|
}
|
|
618
|
-
`}function ze(e,n){const r=W(e,n),o=new Map((G(e)?Y(e,n):[]).map(t=>[t.fieldName,t.key]));return r.map(t=>{const a=
|
|
618
|
+
`}function ze(e,n){const r=W(e,n),o=new Map((G(e)?Y(e,n):[]).map(t=>[t.fieldName,t.key]));return r.map(t=>{const a=N(t.raw,n),p=a?o.get(a):void 0;return v({key:t.name,label:t.raw.label||t.raw.name,dataType:t.raw.dataType,sortable:!!p,sortKey:p})})}function Ye(e){const n=e.checklist.filterScopeByInput||[],r=e.checklist.requiredDevtools||{},o=e.summary.views.map(i=>i.id).filter(Boolean),t=e.views.map(i=>i.raw.id).filter(Boolean),a=e.inputs.map(i=>i.raw.id).filter(Boolean),p=e.optionQueries.map(i=>i.raw.id||`${i.input.raw.id}-options`).filter(Boolean),f=Object.fromEntries(t.map(i=>[i,e.filterContracts.filter(F=>Array.isArray(F.appliesToViewIds)&&F.appliesToViewIds.includes(i)).map(F=>F.inputId)])),h=Object.fromEntries(e.views.map(i=>[i.raw.id,{title:i.raw.title,visual:i.raw.visual,visualSpec:i.raw.visualSpec,queryKind:i.raw.queryKind,sdkBuilder:i.raw.sdkBuilder}])),y=Object.fromEntries(e.views.map(i=>{var F,l,u;return[i.name,v({viewId:i.raw.id,viewTitle:((F=i.raw.visualSpec)==null?void 0:F.title)||i.raw.title,visualType:(l=i.raw.visualSpec)==null?void 0:l.visualType,title:((u=i.raw.visualSpec)==null?void 0:u.title)||i.raw.title})]}));return`${_}
|
|
619
619
|
export const generatedViewIds = ${k(o)} as const;
|
|
620
620
|
export const generatedQueryViewIds = ${k(t)} as const;
|
|
621
621
|
export const generatedInputIds = ${k(a)} as const;
|
|
@@ -658,4 +658,4 @@ export * from "./queries";
|
|
|
658
658
|
export * from "./bindings";
|
|
659
659
|
export * from "./accessors";
|
|
660
660
|
export * from "./metadata";
|
|
661
|
-
`}function j(e,n){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(const r of n)j(e,r);return}
|
|
661
|
+
`}function j(e,n){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(const r of n)j(e,r);return}O(n)&&g(e,D(n));for(const r of Object.values(n))j(e,r)}}function W(e,n){const r=[];if(nn(r,e.raw.sdkSpec),r.length===0)for(const t of e.raw.fields||[])g(r,t);const o=ne(r.filter(t=>t.name&&N(t,n)).map(t=>({raw:t,key:U(t),name:""})),t=>t.key);return K(o,t=>Q(t.raw.label||t.raw.name||"field")),o}function J(e,n){if(q(e.raw.sdkSpec.builder)!=="metric")return[];const r=w(e.raw.sdkSpec.spec),o=[];g(o,r==null?void 0:r.primaryMeasure);for(const a of H(r==null?void 0:r.measures))g(o,a);const t=ne(o.filter(a=>a.name&&N(a,n)).map(a=>({raw:a,key:U(a),name:""})),a=>a.key);return K(t,a=>Q(a.raw.label||a.raw.name||"metric")),t}function Ze(e,n){if(n.length===1)return new Set([n[0].name]);const r=w(e.raw.sdkSpec.spec);if(!O(r==null?void 0:r.primaryMeasure))return new Set;const o=U(D(r.primaryMeasure)),t=n.find(a=>a.key===o);return t?new Set([t.name]):new Set}function Xe(e){const n=new Map;for(const r of e)for(const o of new Set(he(r.raw)))n.set(o,(n.get(o)||0)+1);return new Set(Array.from(n.entries()).filter(([,r])=>r>1).map(([r])=>r))}function he(e){const n=(e.aggregate||"SUM").toUpperCase();return P([`${n.toLowerCase()}_${e.name}`,`${n}_${e.name}`,`${e.name}_${n.toLowerCase()}`,`${e.name}_${n}`,e.name])}function en(e){const n=new Map;for(const r of e)n.set(r.raw.name,(n.get(r.raw.name)||0)+1);return new Set(Array.from(n.entries()).filter(([,r])=>r>1).map(([r])=>r))}function nn(e,n){const r=w(n.spec);if(!r)return;const o=q(n.builder);if(o==="records"){for(const t of H(r.fields))g(e,t);return}if(o==="sql"){for(const t of H(r.fields))g(e,t);return}if(o==="analysis"||o==="metric"){g(e,r.primaryMeasure);for(const t of H(r.measures))g(e,t);for(const t of H(r.dimensions))g(e,t);g(e,r.dateField);return}if(o==="matrix"){const t=ce(r.rows),a=ce(r.columns),p=H(r.values);for(const f of t)me(e,f);for(const f of a)me(e,f);for(const f of p){const h=w(f);g(e,h==null?void 0:h.field),g(e,h==null?void 0:h.measure)}}}function ce(e){if(Array.isArray(e))return e;const n=w(e);return Array.isArray(n==null?void 0:n.levels)?n.levels:[]}function me(e,n){var r;if(O(n)){g(e,n);return}g(e,(r=w(n))==null?void 0:r.field)}function fe(e){var n,r,o,t;return((n=e==null?void 0:e.computation)==null?void 0:n.kind)==="presentation_only"||((r=e==null?void 0:e.computation)==null?void 0:r.kind)==="derived"||((o=e==null?void 0:e.computation)==null?void 0:o.kind)==="unsupported"||(e==null?void 0:e.visual)==="text_block"||((t=e==null?void 0:e.visualSpec)==null?void 0:t.visualType)==="text_block"}function rn(e){const n=w(e)||{};return v({id:e.id,title:e.title,purpose:e.purpose,visual:e.visual,visualSpec:e.visualSpec,computation:e.computation,uxExpectations:e.uxExpectations,validation:e.validation,sourceViewIds:n.sourceViewIds,content:n.content,description:n.description})}function g(e,n){O(n)&&e.push(D(n))}function D(e){return{name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate,sourceKey:e.sourceKey||(e.source?le(e.source):void 0),...e.source?{source:e.source}:{}}}function tn(e){if(!e.source)return;const n={...e.source,...e.sourceKey?{sourceKey:e.sourceKey}:{}},r=Ie(n);if(r)return{raw:n,key:r,aliases:$e(n),name:""}}function O(e){const n=w(e);return!!(n&&typeof n.name=="string"&&(typeof n.role=="string"||typeof n.dataType=="string"||typeof n.aggregate=="string"||n.source||n.sourceKey))}function Se(e){const n=w(e);return!!(n&&(typeof n.sourceKey=="string"||n.kind==="semantic"||typeof n.datasetName=="string"&&typeof n.domainId=="string"))}function E(e,n){if(e===void 0)return"undefined";if(e===null||typeof e=="number"||typeof e=="boolean"||typeof e=="string")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t=>E(t,n)).join(", ")}]`;if(O(e)){const t=N(D(e),n);if(t)return`fields.${t}`}if(Se(e)){const t=we(e,n);if(t)return`sources.${t}`}const r=w(e);return r?`{ ${Object.entries(r).filter(([,t])=>t!==void 0).map(([t,a])=>`${JSON.stringify(t)}: ${E(a,n)}`).join(", ")} }`:JSON.stringify(e)}function k(e){return JSON.stringify(e,null,2)}function N(e,n){if(O(e))return n.fieldNameByKey.get(U(D(e)))}function we(e,n){if(Se(e))for(const r of ee(e)){const o=n.sourceNameByKey.get(r);if(o)return o}}function U(e){return[e.sourceKey||"",e.name||"",e.role||"",e.aggregate||""].join("|")}function on(e,n){return!O(e)||!O(n)||e.name!==n.name?!1:de(e).some(r=>de(n).includes(r))}function sn(e){return O(e)&&e.role==="id"}function an(e){const n=[],r=new Map;for(const o of e){const t=P(o.aliases.length?o.aliases:[o.key]),a=t.map(p=>r.get(p)).find(x);if(a){a.aliases=P([...a.aliases,...t]);continue}o.aliases=t,n.push(o);for(const p of t)r.set(p,o)}return n}function un(e){const n=new Map;for(const r of e)for(const o of P([r.key,...r.aliases])){const t=n.get(o);if(t&&t!==r.name)throw new Error(`Source identity ${o} resolves to multiple generated sources.`);n.set(o,r.name)}return n}function P(e){return Array.from(new Set(e.filter(Boolean)))}function Ie(e){return ee(e)[0]||le(e)}function ee(e){const n=w(e);if(!n)return[];const r=[];if(typeof n.sourceKey=="string"&&r.push(n.sourceKey),n.kind==="semantic"||n.datasetName){const o=typeof n.domainId=="string"?n.domainId:"";o&&typeof n.datasetId=="string"&&r.push(`semantic:${o}:datasetId:${n.datasetId}`),o&&typeof n.datasetName=="string"&&r.push(`semantic:${o}:datasetName:${n.datasetName}`)}return r.length===0&&r.push(le(e)),P(r)}function $e(e){return ee(e)}function le(e){const n=w(e);return n?typeof n.sourceKey=="string"?n.sourceKey:JSON.stringify(n):""}function dn(e){return O(e)&&de(e)[0]||""}function de(e){return O(e)?P([...typeof e.sourceKey=="string"?[e.sourceKey]:[],...e.source?ee(e.source):[]]):[]}function q(e){const n=String(e||"").replace(/^semaphor\./,"");if(!["metric","records","analysis","matrix","sql"].includes(n))throw new Error(`Unsupported sdkSpec builder: ${e}`);return n}function pn(e){const n=q(e);return n==="records"||n==="sql"}function ln(e){const n=w(e);return typeof(n==null?void 0:n.operator)=="string"?n.operator:e.type==="date_range"?"between":e.type==="multi_select"||e.type==="select"?"in":"="}function K(e,n){const r=new Map;for(const o of e){const t=n(o)||"item",a=r.get(t)||0;r.set(t,a+1),o.name=a===0?t:`${t}${a+1}`}}function ne(e,n){const r=new Set,o=[];for(const t of e){const a=n(t);!a||r.has(a)||(r.add(a),o.push(t))}return o}function Q(e){const n=String(e||"").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);if(n.length===0)return"item";const[r,...o]=n,t=[r.toLowerCase(),...o.map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase())].join("");return/^[A-Za-z_$]/.test(t)?t:`item${t}`}function cn(e){const n=String(e).split(":");return n[n.length-1]||String(e)}function v(e){return Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}function w(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function H(e){return Array.isArray(e)?e:[]}function z(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function x(e){return e!==void 0}exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=Z.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=Z.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=Z.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=Z.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=$.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=$.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=$.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=$.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=$.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=$.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=$.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=$.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=$.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=$.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=$.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=$.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=$.validateCodegenSummary;exports.validateSemaphorGeneratedContract=$.validateSemaphorGeneratedContract;exports.DEFAULT_GENERATED_CONTRACT_OUTPUT_DIR=Re;exports.generateSemaphorDataAppContract=ke;
|