react-semaphor 0.1.420 → 0.1.422
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 +28 -27
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +2 -2
- package/dist/chunks/analyze-result-contract-D7pjjYPy.js +2069 -0
- package/dist/chunks/analyze-result-contract-DpDcImgk.js +1 -0
- package/dist/chunks/{calendar-preferences-dialog-f0Z7Kf-U.js → calendar-preferences-dialog-C2fBRNZh.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-DIfAbE_y.js → calendar-preferences-dialog-Cbavs2EK.js} +3 -3
- package/dist/chunks/{dashboard-briefing-launcher-anh-Jy5v.js → dashboard-briefing-launcher-C0_ZbBK3.js} +4 -4
- package/dist/chunks/{dashboard-briefing-launcher-C3tNkGFG.js → dashboard-briefing-launcher-CGfEFUnX.js} +1 -1
- package/dist/chunks/{dashboard-controls-DQxlOxzy.js → dashboard-controls-BUuS-BGl.js} +1 -1
- package/dist/chunks/{dashboard-controls-8dCQaPaq.js → dashboard-controls-ae5t32xV.js} +5 -5
- package/dist/chunks/{dashboard-json-B309EInF.js → dashboard-json-DTL_kYhz.js} +1 -1
- package/dist/chunks/{dashboard-json-i7Ae9KGD.js → dashboard-json-Db3rkY_a.js} +3 -3
- package/dist/chunks/{edit-dashboard-visual-z3IqzYnj.js → edit-dashboard-visual-CW7mv_si.js} +7030 -6963
- package/dist/chunks/{edit-dashboard-visual-4HycwBHR.js → edit-dashboard-visual-Ciqdu58a.js} +38 -38
- package/dist/chunks/{index-yxKWKFdr.js → index-8y8XX7sX.js} +121 -121
- package/dist/chunks/{index-B6DLEXRX.js → index-OD6mLD7U.js} +257 -256
- package/dist/chunks/{switch-COWQU8aK.js → switch-CWcWwwDJ.js} +1 -1
- package/dist/chunks/{switch-D6Ygf3wA.js → switch-DRNqX0v0.js} +1 -1
- package/dist/chunks/{update-policy-BzT2k4n6.js → update-policy-BCJc0oI5.js} +211 -187
- package/dist/chunks/update-policy-C1pmhLz9.js +3 -0
- package/dist/chunks/{use-create-flow-overlay-state-DENfd7sW.js → use-create-flow-overlay-state-C0Uhmlpd.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-CX0D-6HM.js → use-create-flow-overlay-state-CkMmXhI-.js} +3 -3
- package/dist/chunks/validators-DMlVbd1p.js +1 -0
- package/dist/chunks/{validators-Cxr9qbrR.js → validators-PXkij33j.js} +93 -93
- 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 +14 -14
- 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 +188 -251
- package/dist/data-app-codegen-node/index.js +631 -673
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +678 -638
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +51 -51
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +12 -9
- package/dist/types/dashboard-assistant.d.ts +0 -6
- package/dist/types/data-app-codegen-node.d.ts +12 -2
- package/dist/types/data-app-codegen.d.ts +12 -2
- package/dist/types/data-app-sdk-validation.d.ts +0 -6
- package/dist/types/data-app-sdk.d.ts +17 -7
- package/package.json +1 -1
- package/dist/chunks/analyze-result-contract-DdhEt99q.js +0 -2004
- package/dist/chunks/analyze-result-contract-DwRzl7yJ.js +0 -1
- package/dist/chunks/update-policy-VloD-0YM.js +0 -3
- package/dist/chunks/validators-BMQo93Y0.js +0 -1
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("../chunks/analyze-result-contract-DpDcImgk.js"),R=require("../chunks/update-policy-C1pmhLz9.js"),he=require("node:crypto"),Ce="src/semaphor/generated",H=`// 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
|
-
`;function
|
|
4
|
-
`};return{schemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,files:a,manifest:o,contentHash:String(o.generatedContentHash||""),usageExample:
|
|
3
|
+
`;function Oe(e,n={}){R.assertValidCodegenSummary(e);const r=Me(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 t=ke(r),o=Ne({contract:r,files:t,generatorName:n.generatorName||"react-semaphor/data-app-codegen/node",generatorVersion:n.generatorVersion||"unknown"}),a={...t,"contract.manifest.json":`${JSON.stringify(o,null,2)}
|
|
4
|
+
`};return{schemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,files:a,manifest:o,contentHash:String(o.generatedContentHash||""),usageExample:Te(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 Me(e){var d,p,m,i,l,g,h,I,$,M,b,E;const n=[],r=[];for(const s of e.inputs){S(r,s.fieldRef);for(const V of s.bindings||[])S(r,V.fieldRef);S(r,(d=s.optionQuery)==null?void 0:d.valueFieldRef),S(r,(p=s.optionQuery)==null?void 0:p.labelFieldRef),S(r,(m=s.optionQuery)==null?void 0:m.filterFieldRef),D(r,(i=s.optionQuery)==null?void 0:i.spec)}for(const s of e.filterContracts){S(r,s.fieldRef),S(r,(l=s.optionQuery)==null?void 0:l.valueFieldRef),S(r,(g=s.optionQuery)==null?void 0:g.labelFieldRef),S(r,(h=s.optionQuery)==null?void 0:h.filterFieldRef),D(r,(I=s.optionQuery)==null?void 0:I.spec);for(const V of s.bindings||[])S(r,V.fieldRef)}for(const s of e.views){for(const V of s.fields||[])S(r,V);D(r,($=s.sdkSpec)==null?void 0:$.spec),D(r,s.visualSpec)}const t=e.implementationChecklist||{};for(const s of Object.values(t.bindingsByView||{}))for(const V of Array.isArray(s)?s:[])S(r,V.fieldRef),S(r,V.optionValueField),S(r,V.optionLabelField);for(const s of t.requiredInputOptions||[])S(r,s.visibleLabelField),S(r,s.optionValueField),S(r,s.runtimeFilterField);const o=pn([...e.sources.map(s=>({raw:s,key:Ie(s),aliases:Ve(s),name:""})),...r.map(s=>an(s)).filter(x)]);P(o,s=>{const V=F(s.raw);return j(s.raw.label||(V==null?void 0:V.datasetName)||(V==null?void 0:V.datasetId)||(V==null?void 0:V.name)||s.raw.kind||"source")});const a=ln(o),u=ne(r.filter(s=>s.name).map(s=>({raw:s,key:X(s),name:""})),s=>s.key);P(u,s=>j([s.raw.sourceKey?yn(s.raw.sourceKey):"",s.raw.aggregate?s.raw.aggregate.toLowerCase():"",s.raw.name].filter(Boolean).join("_")));const c=new Map(u.map(s=>[s.key,s.name])),w=e.inputs.map(s=>({raw:s,name:j(s.id||s.label||"input")}));P(w,s=>s.name);const f=w.filter(s=>!!s.raw.optionQuery).map(s=>({input:s,name:`${s.name}Options`,raw:s.raw.optionQuery}));P(f,s=>s.name);for(const s of f)un(s.raw.labelFieldRef,s.raw.valueFieldRef)&&dn(s.raw.valueFieldRef)&&n.push(`Input option query ${((M=s.raw.spec)==null?void 0:M.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 y=e.views.filter(s=>{var V,K;return!!((V=s.sdkSpec)!=null&&V.builder&&((K=s.sdkSpec)!=null&&K.spec))}).map(s=>({raw:s,name:j(s.id||s.title||"query")}));P(y,s=>s.name);const k=e.views.filter(s=>fe(s)&&!("sdkSpec"in s)).map(s=>sn(s));for(const s of e.views)(!("sdkSpec"in s)||!((b=s.sdkSpec)!=null&&b.builder)||!((E=s.sdkSpec)!=null&&E.spec))&&!fe(s)&&n.push(`Skipped view ${s.id||s.title||"unknown"} because it has no sdkSpec.`);return Ee({inputs:w,views:y,filterContracts:e.filterContracts}),{summary:e,title:e.title||"Semaphor Data App",sources:o,fields:u,inputs:w,optionQueries:f,views:y,presentationViews:k,filterContracts:e.filterContracts,checklist:t,sourceNameByKey:a,fieldNameByKey:c,warnings:n}}function Ee({inputs:e,views:n,filterContracts:r}){const t=new Set(e.map(a=>a.raw.id).filter(Boolean)),o=new Set(n.map(a=>a.raw.id).filter(Boolean));for(const[a,u]of r.entries()){if(!t.has(u.inputId))throw new Error(`filterContracts.${a}.inputId must reference a generated input.`);const c=new Set(u.appliesToViewIds||[]),w=new Set(u.notAppliedToViewIds||[]);for(const[f,y]of(u.appliesToViewIds||[]).entries())if(!o.has(y))throw new Error(`filterContracts.${a}.appliesToViewIds.${f} must reference an executable generated view.`);for(const[f,y]of(u.notAppliedToViewIds||[]).entries())if(!o.has(y))throw new Error(`filterContracts.${a}.notAppliedToViewIds.${f} must reference an executable generated view.`);for(const[f,y]of(u.bindings||[]).entries()){if(!o.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must reference an executable generated view.`);if(!c.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must be included in appliesToViewIds.`);if(w.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must not be listed in notAppliedToViewIds.`)}}}function ke(e){return{"sources.ts":ve(e),"fields.ts":qe(e),"inputs.ts":De(e),"queries.ts":Pe(e),"bindings.ts":Le(e),"accessors.ts":Ye(e),"metadata.ts":We(e),"index.ts":Xe(),"USAGE.md":Ae(e)}}function Ne({contract:e,files:n,generatorName:r,generatorVersion:t}){return{schemaVersion:R.CONTRACT_MANIFEST_SCHEMA_VERSION,generatedContractSchemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,generator:{name:r,version:t},generatedContentHash:Ge(n),codegenSummaryValidatorVersion:R.CODEGEN_SUMMARY_VALIDATOR_VERSION,codegenSummaryHash:xe(e.summary),codegenSummary:e.summary}}function Ge(e){const n=he.createHash("sha256");for(const r of Object.keys(e).filter(t=>t.endsWith(".ts")).sort())n.update(r),n.update("\0"),n.update(e[r]),n.update("\0");return`sha256:${n.digest("hex")}`}function Ae(e){const n=["# Semaphor Generated Data App Contract","","Generated files in this directory are governed Semaphor analytics wiring. Do not hand-edit them.","","Use the app-facing exports from `index.ts`:","","- `queries`: generated governed query factories.","- `queryOptionsForView`: active-input wiring for each generated view.","- `rowsForView`: table/records row readers.","- `rowValuesForView`: friendly row object readers for chart/table views.","- `metricValuesForView`: friendly metric-value readers.","- `kpiPropsForView`: KPI component props derived from runtime metric results.","- `roleValuesForView`: canonical dimension/measure/date/id role readers.","- `appInputSpecs`: generated input/filter specs.","- `inputOptionQueries`: option-list query factories for generated inputs.","- `semaphorGeneratedContractMetadata`: generated view/input metadata and presentation-only views.","","Start with these exports before opening large generated internals such as `metadata.ts`.",""];return e.views.length>0&&(n.push("Generated executable views:"),e.views.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.title||r.name}`)}),n.push("")),e.inputs.length>0&&(n.push("Generated inputs:"),e.inputs.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.label||r.name}`)}),n.push("")),`${n.join(`
|
|
5
|
+
`)}
|
|
6
|
+
`}function xe(e){return`sha256:${he.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(t=>ue(t)).join(",")}]`;const n=e;return`{${Object.keys(n).sort().filter(t=>n[t]!==void 0).map(t=>`${JSON.stringify(t)}:${ue(n[t])}`).join(",")}}`}function Te(e){const n=e.views.find(f=>T(f)&&_(f));if(n)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowsForView, 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 = rowsForView.${n.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
5
7
|
`);const r=e.views.find(f=>T(f));if(r)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowsForView, 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 = rowsForView.${r.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
6
|
-
`);const t=e.views.find(f=>
|
|
8
|
+
`);const t=e.views.find(f=>Z(f)&&_(f));if(t)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, 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 = rowsForView.${t.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
7
9
|
`);const o=e.views.find(f=>pe(f)&&_(f));if(o)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, 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 = rowsForView.${o.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
8
|
-
`);const a=e.views.find(f=>{var
|
|
9
|
-
`);const
|
|
10
|
-
`);const
|
|
11
|
-
`)}function
|
|
10
|
+
`);const a=e.views.find(f=>{var y;return mn((y=f.raw.sdkSpec)==null?void 0:y.builder)});if(a)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const result = useSemaphorQuery(queries.${a.name}(), queryOptionsForView.${a.name}(inputHandles));`,`const rows = rowsForView.${a.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
11
|
+
`);const u=e.views.find(f=>_e(f));if(u)return['import { appInputSpecs, createInputHandleMap, kpiPropsForView, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const result = useSemaphorQuery(queries.${u.name}(), queryOptionsForView.${u.name}(inputHandles));`,`const kpiProps = kpiPropsForView.${u.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
12
|
+
`);const c=e.views[0];return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",c?`const result = useSemaphorQuery(queries.${c.name}(), queryOptionsForView.${c.name}(inputHandles));`:"const result = undefined;","const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
13
|
+
`)}function Z(e){var n;return q((n=e.raw.sdkSpec)==null?void 0:n.builder)==="records"}function _e(e){var n;return q((n=e.raw.sdkSpec)==null?void 0:n.builder)==="metric"}function T(e){var n,r,t;return Z(e)&&((t=(r=(n=e.raw.visualSpec)==null?void 0:n.tableBehavior)==null?void 0:r.sorting)==null?void 0:t.mode)==="server"}function pe(e){var n;return q((n=e.raw.sdkSpec)==null?void 0:n.builder)==="sql"}function _(e){var n,r,t;return((t=(r=(n=e.raw.visualSpec)==null?void 0:n.tableBehavior)==null?void 0:r.pagination)==null?void 0:t.mode)==="server"}function He(e){return Z(e)&&(_(e)||T(e))||pe(e)&&_(e)}function ve(e){const n=e.sources.map(({name:t,raw:o})=>{const a=je(o);return` ${t}: ${a},`}).join(`
|
|
12
14
|
`),r=e.sources.some(t=>t.raw.kind==="semantic")?`import { semaphor } from "react-semaphor/data-app-sdk";
|
|
13
15
|
|
|
14
|
-
`:"";return`${
|
|
16
|
+
`:"";return`${H}
|
|
15
17
|
${r}export const sources = {
|
|
16
18
|
${n}
|
|
17
19
|
} as const;
|
|
18
|
-
`}function
|
|
20
|
+
`}function je(e){if(e.kind==="semantic"){const n={domainId:e.domainId,datasetId:e.datasetId,datasetName:e.datasetName,label:e.label};return`semaphor.source.semantic(${C(A(n))})`}return`${C(A({...e,sourceKey:void 0}))} as const`}function qe(e){const n=e.fields.map(({name:t,raw:o})=>{const a=Ke(o,e);return` ${t}: ${a},`}).join(`
|
|
19
21
|
`),r=n.includes("sources.")?`import { sources } from "./sources";
|
|
20
22
|
|
|
21
|
-
`:"";return`${
|
|
23
|
+
`:"";return`${H}
|
|
22
24
|
${r}export const fields = {
|
|
23
25
|
${n}
|
|
24
26
|
} as const;
|
|
25
|
-
`}function
|
|
26
|
-
`),r=e.inputs.map(
|
|
27
|
-
`),a=e.optionQueries.map(
|
|
28
|
-
inputs.push(semaphor.bindInput(${
|
|
27
|
+
`}function Ke(e,n){const r={name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate},t=cn(e),o=t?n.sourceNameByKey.get(t):void 0;if(t&&!o)throw new Error(`Field ${e.name} references source ${t}, but that source is not renderable. Include the source in codegenSummary.sources or provide field.source.`);const a=Object.entries(A(r)).map(([u,c])=>`${JSON.stringify(u)}: ${G(c,n)}`);return o&&a.push(`"source": sources.${o}`),`{ ${a.join(", ")} }`}function De(e){const n=e.inputs.map(m=>{const i=O(m.raw.fieldRef,e),l=[`id: ${JSON.stringify(m.raw.id)}`,`label: ${JSON.stringify(m.raw.label||m.raw.id)}`,`operator: ${JSON.stringify(fn(m.raw))}`];if(i&&l.push(`field: fields.${i}`),m.raw.relationshipHint&&l.push(`relationshipHint: ${C(m.raw.relationshipHint)}`),!i)throw new Error(`Input ${m.raw.id||m.name} is missing a generated field reference.`);return` ${m.name}: semaphor.filter({ ${l.join(", ")} }),`}).join(`
|
|
28
|
+
`),r=e.inputs.map(m=>`filterSpecs.${m.name}`).join(", "),t=e.inputs.map(m=>JSON.stringify(m.raw.id)).join(", "),o=e.optionQueries.map(m=>{const i=m.input.raw,l=m.raw,g=F(l.spec)||{},{id:h,inputId:I,source:$,sourceKey:M,valueField:b,labelField:E,population:s,dependencies:V,limit:K,...re}=g,J=l.sourceKey?{sourceKey:l.sourceKey}:l.source||$||(typeof M=="string"?{sourceKey:M}:void 0),te=$e(J,e),oe=O(l.valueFieldRef,e),se=O(l.labelFieldRef,e),ae=ge(m),ie={...re,id:l.id||g.id||`${i.id}-options`,inputId:i.id,source:J,valueField:l.valueFieldRef,labelField:l.labelFieldRef,population:l.population||s,dependencies:ae,limit:l.limit||K||100};if(!te||!oe||!se)throw new Error(`Input option query ${l.id||`${i.id}-options`} is missing source, valueField, or labelField.`);const Fe=Object.entries(A(ie)).map(([be,Re])=>`${JSON.stringify(be)}: ${G(Re,e)}`);return` ${m.name}: semaphor.inputOptions({ ${Fe.join(", ")} }),`}).join(`
|
|
29
|
+
`),a=e.optionQueries.map(m=>{const i=Be(e,m),l=i.length>0?"inputHandles":"_inputHandles",g=i.map(h=>{const I=O(h.raw.fieldRef,e);if(!I)throw new Error(`Input option query ${m.raw.id||`${m.input.raw.id}-options`} references input ${h.raw.id} without a generated field reference.`);const $=`inputHandles[${JSON.stringify(h.raw.id)}]`;return` if (${$}) {
|
|
30
|
+
inputs.push(semaphor.bindInput(${$}, { field: fields.${I} }));
|
|
29
31
|
}`}).join(`
|
|
30
|
-
`);return` ${
|
|
32
|
+
`);return` ${m.name}(${l}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
31
33
|
const inputs: SemaphorInputReference[] = [];
|
|
32
|
-
${
|
|
34
|
+
${g}
|
|
33
35
|
return inputs;
|
|
34
36
|
},`}).join(`
|
|
35
37
|
|
|
36
|
-
`),
|
|
38
|
+
`),u=e.optionQueries.map(m=>` ${m.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
37
39
|
return {
|
|
38
|
-
inputs: inputsForInputOptionQuery.${
|
|
40
|
+
inputs: inputsForInputOptionQuery.${m.name}(inputHandles),
|
|
39
41
|
};
|
|
40
42
|
},`).join(`
|
|
41
43
|
|
|
42
|
-
`),
|
|
43
|
-
return queryOptionsForInputOptionQuery.${
|
|
44
|
-
`),
|
|
45
|
-
`);return`${
|
|
46
|
-
${
|
|
44
|
+
`),c=e.optionQueries.map(m=>` case ${JSON.stringify(m.raw.id||`${m.input.raw.id}-options`)}:
|
|
45
|
+
return queryOptionsForInputOptionQuery.${m.name}(inputHandles);`).join(`
|
|
46
|
+
`),w=e.inputs.length>0,f=e.optionQueries.length>0,y=f?"inputOptionQueryId":"_inputOptionQueryId",k=f?"inputHandles":"_inputHandles",d=["SemaphorInputHandle",f?"SemaphorInputReference":void 0,"SemaphorQueryRuntimeOptions"].filter(x).join(", "),p=[w||f?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,`import type { ${d} } from "react-semaphor/data-app-sdk";`,w||f?'import { fields } from "./fields";':void 0,f?'import { sources } from "./sources";':void 0,'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'].filter(x).join(`
|
|
47
|
+
`);return`${H}
|
|
48
|
+
${p}
|
|
47
49
|
|
|
48
50
|
export const filterSpecs = {
|
|
49
51
|
${n}
|
|
@@ -67,52 +69,52 @@ ${a}
|
|
|
67
69
|
} as const;
|
|
68
70
|
|
|
69
71
|
export const queryOptionsForInputOptionQuery = {
|
|
70
|
-
${
|
|
72
|
+
${u}
|
|
71
73
|
} as const;
|
|
72
74
|
|
|
73
75
|
export function queryOptionsForInputOptionQueryId(
|
|
74
|
-
${
|
|
75
|
-
${
|
|
76
|
+
${y}: SemaphorGeneratedInputOptionQueryId,
|
|
77
|
+
${k}: SemaphorGeneratedInputHandleMap,
|
|
76
78
|
): SemaphorQueryRuntimeOptions {
|
|
77
|
-
switch (${
|
|
78
|
-
${
|
|
79
|
+
switch (${y}) {
|
|
80
|
+
${c}
|
|
79
81
|
}
|
|
80
|
-
throw new Error(\`Unknown generated Semaphor input option query id: \${${
|
|
82
|
+
throw new Error(\`Unknown generated Semaphor input option query id: \${${y}}\`);
|
|
81
83
|
}
|
|
82
|
-
`}function Be(e,n){const r=
|
|
83
|
-
recordsSortFieldsForView.${
|
|
84
|
+
`}function Be(e,n){const r=ge(n);if(!r||r.mode==="independent")return[];if(r.mode!=="explicit")return[];const t=new Set(r.includeInputIds||[]),o=new Set([n.input.raw.id,...r.excludeInputIds||[]]);return e.inputs.filter(a=>o.has(a.raw.id)?!1:t.has(a.raw.id))}function ge(e){var n;return e.raw.dependencies||((n=e.raw.spec)==null?void 0:n.dependencies)}function Pe(e){const n=e.views.map(p=>{var l,g,h,I,$,M;const m=q(p.raw.sdkSpec.builder),i=Qe(p);if(Z(p)&&He(p)){const b=(l=p.raw.visualSpec)==null?void 0:l.tableBehavior,E=F(i.pagination),s=_(p),V=T(p),K=((g=b==null?void 0:b.pagination)==null?void 0:g.pageSize)||L(E==null?void 0:E.pageSize)||L(i.limit)||100,re=V?z(p,e):[],J=V?Ue({view:p,contract:e,sortFields:re,defaultField:(h=b==null?void 0:b.sorting)==null?void 0:h.defaultField}):void 0,te=V?(I=b==null?void 0:b.sorting)==null?void 0:I.defaultDirection:void 0,oe=Je({viewName:p.name,supportsPagination:s,supportsSort:V}),se=V?` const orderBy = resolveRecordsOrderBy(
|
|
85
|
+
recordsSortFieldsForView.${p.name},
|
|
84
86
|
params.sort,
|
|
85
|
-
${
|
|
86
|
-
${
|
|
87
|
+
${G(J,e)},
|
|
88
|
+
${G(te,e)},
|
|
87
89
|
);
|
|
88
|
-
`:"",ae=
|
|
89
|
-
`:"",ie=s?` pagination: resolveServerTablePagination(params, ${JSON.stringify(
|
|
90
|
-
`:"";return` ${
|
|
90
|
+
`:"",ae=V?` ...(orderBy ? { orderBy } : {}),
|
|
91
|
+
`:"",ie=s?` pagination: resolveServerTablePagination(params, ${JSON.stringify(K)}),
|
|
92
|
+
`:"";return` ${p.name}(
|
|
91
93
|
params: ${oe} = {},
|
|
92
94
|
) {
|
|
93
|
-
${se} return semaphor.${
|
|
94
|
-
...${
|
|
95
|
+
${se} return semaphor.${m}({
|
|
96
|
+
...${G(i,e)},
|
|
95
97
|
${ae}${ie} });
|
|
96
|
-
},`}if(pe(
|
|
98
|
+
},`}if(pe(p)&&_(p)){const b=($=p.raw.visualSpec)==null?void 0:$.tableBehavior,E=F(i.pagination),s=((M=b==null?void 0:b.pagination)==null?void 0:M.pageSize)||L(E==null?void 0:E.pageSize)||L(i.limit)||100;return` ${p.name}(
|
|
97
99
|
params: SemaphorGeneratedServerPaginationParams = {},
|
|
98
100
|
) {
|
|
99
|
-
return semaphor.${
|
|
100
|
-
...${
|
|
101
|
+
return semaphor.${m}({
|
|
102
|
+
...${G(i,e)},
|
|
101
103
|
pagination: resolveServerTablePagination(params, ${JSON.stringify(s)}),
|
|
102
104
|
});
|
|
103
|
-
},`}return` ${
|
|
104
|
-
`),r=e.views.filter(
|
|
105
|
-
`);return` ${
|
|
105
|
+
},`}return` ${p.name}: () => semaphor.${m}(${G(i,e)}),`}).join(`
|
|
106
|
+
`),r=e.views.filter(p=>T(p)).map(p=>{const i=z(p,e).map(l=>` ${JSON.stringify(l.key)}: fields.${l.fieldName},`).join(`
|
|
107
|
+
`);return` ${p.name}: {
|
|
106
108
|
${i}
|
|
107
109
|
},`}).join(`
|
|
108
|
-
`),t=e.views.filter(
|
|
109
|
-
`);return` ${
|
|
110
|
+
`),t=e.views.filter(p=>T(p)).map(p=>{const i=z(p,e).map(l=>` { key: ${JSON.stringify(l.key)}, label: ${JSON.stringify(l.label)}, field: fields.${l.fieldName} },`).join(`
|
|
111
|
+
`);return` ${p.name}: [
|
|
110
112
|
${i}
|
|
111
113
|
],`}).join(`
|
|
112
|
-
`),o=e.views.some(
|
|
113
|
-
`),
|
|
114
|
-
`);return`${
|
|
115
|
-
${
|
|
114
|
+
`),o=e.views.some(p=>T(p)),a=e.views.some(p=>_(p)),u=[n,r,t].join(`
|
|
115
|
+
`),c=[n?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,o?'import type { SemaphorFieldRef } from "react-semaphor/data-app-sdk";':void 0,u.includes("fields.")?'import { fields } from "./fields";':void 0,u.includes("sources.")?'import { sources } from "./sources";':void 0].filter(x).join(`
|
|
116
|
+
`);return`${H}
|
|
117
|
+
${c}
|
|
116
118
|
${o?`export type SemaphorGeneratedRecordsSortDirection = "asc" | "desc";
|
|
117
119
|
|
|
118
120
|
export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
@@ -174,28 +176,28 @@ ${a?`function resolveServerTablePagination(
|
|
|
174
176
|
};
|
|
175
177
|
}
|
|
176
178
|
`:""}
|
|
177
|
-
`}function
|
|
178
|
-
inputs.push(semaphor.bindInput(${
|
|
179
|
+
`}function Qe(e){var a,u;const n=F((a=e.raw.sdkSpec)==null?void 0:a.spec)||{},{kind:r,id:t,...o}=n;return{...o,id:e.raw.id,label:((u=e.raw.visualSpec)==null?void 0:u.title)||e.raw.title||o.label}}function z(e,n){var a,u;const r=[],t=F((a=e.raw.sdkSpec)==null?void 0:a.spec)||{};for(const c of v(t.fields))S(r,c);S(r,t.dateField),S(r,(u=F(t.orderBy))==null?void 0:u.field);for(const c of e.raw.fields||[])S(r,c);return ne(r.map(c=>{const w=O(c,n);if(!(!c.name||!w))return{key:w,fieldName:w,rawName:c.name,label:c.label||c.name}}).filter(x),c=>c.key)}function Ue({view:e,contract:n,sortFields:r,defaultField:t}){var w,f;const o=new Set(r.map(y=>y.key));if(t&&o.has(t))return t;const a=r.filter(y=>y.rawName===t);if(a.length===1)return a[0].key;const u=F((w=e.raw.sdkSpec)==null?void 0:w.spec),c=O((f=F(u==null?void 0:u.orderBy))==null?void 0:f.field,n);return c&&o.has(c)?c:void 0}function Je({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 Le(e){const n=e.views.map(y=>{const d=ze(e,y.raw.id).map(p=>{const m=p.inputId,i=O(p.fieldRef,e);if(!m||!i)return"";const l=[`field: fields.${i}`];if(p.relationshipHint)l.push(`relationshipHint: ${C(p.relationshipHint)}`);else if(Array.isArray(p.relationshipsUsed)&&p.relationshipsUsed.length>0){const h=p.relationshipsUsed.map(I=>{var $;return($=F(I))==null?void 0:$.id}).filter(I=>typeof I=="string"&&I.length>0);h.length>0&&l.push(`relationshipHint: ${C({relationshipIds:h})}`)}const g=`inputHandles[${JSON.stringify(m)}]`;return` if (${g}) {
|
|
180
|
+
inputs.push(semaphor.bindInput(${g}, { ${l.join(", ")} }));
|
|
179
181
|
}`}).filter(Boolean).join(`
|
|
180
|
-
`);return{view:
|
|
182
|
+
`);return{view:y,renderedBindings:d}}),r=n.some(y=>y.renderedBindings.length>0),t=n.map(({view:y,renderedBindings:k})=>{const d=k?"inputHandles":"_inputHandles";return` ${y.name}(${d}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
181
183
|
const inputs: SemaphorInputReference[] = [];
|
|
182
|
-
${
|
|
184
|
+
${k}
|
|
183
185
|
return inputs;
|
|
184
186
|
},`}).join(`
|
|
185
187
|
|
|
186
|
-
`),o=e.views.map(
|
|
188
|
+
`),o=e.views.map(y=>` ${y.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
187
189
|
return {
|
|
188
|
-
inputs: inputsForView.${
|
|
189
|
-
debug: queryDebugForView.${
|
|
190
|
+
inputs: inputsForView.${y.name}(inputHandles),
|
|
191
|
+
debug: queryDebugForView.${y.name},
|
|
190
192
|
};
|
|
191
193
|
},`).join(`
|
|
192
194
|
|
|
193
|
-
`),a=e.views.map(
|
|
194
|
-
return inputsForView.${
|
|
195
|
-
`),
|
|
196
|
-
return queryOptionsForView.${
|
|
197
|
-
`),
|
|
198
|
-
`);return`${
|
|
195
|
+
`),a=e.views.map(y=>` case ${JSON.stringify(y.raw.id)}:
|
|
196
|
+
return inputsForView.${y.name}(inputHandles);`).join(`
|
|
197
|
+
`),u=e.views.map(y=>` case ${JSON.stringify(y.raw.id)}:
|
|
198
|
+
return queryOptionsForView.${y.name}(inputHandles);`).join(`
|
|
199
|
+
`),c=e.views.length>0,w=c?"inputHandles":"_inputHandles",f=[r?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,'import type { SemaphorInputReference, SemaphorQueryRuntimeOptions } from "react-semaphor/data-app-sdk";',r?'import { fields } from "./fields";':void 0,'import type { SemaphorGeneratedInputHandleMap } from "./inputs";',c?'import { queryDebugForView } from "./metadata";':void 0,'import type { SemaphorGeneratedQueryViewId } from "./metadata";'].filter(x).join(`
|
|
200
|
+
`);return`${H}
|
|
199
201
|
${f}
|
|
200
202
|
|
|
201
203
|
export const inputsForView = {
|
|
@@ -208,7 +210,7 @@ ${o}
|
|
|
208
210
|
|
|
209
211
|
export function inputsForViewId(
|
|
210
212
|
viewId: SemaphorGeneratedQueryViewId,
|
|
211
|
-
${
|
|
213
|
+
${w}: SemaphorGeneratedInputHandleMap,
|
|
212
214
|
): SemaphorInputReference[] {
|
|
213
215
|
switch (viewId) {
|
|
214
216
|
${a}
|
|
@@ -218,81 +220,103 @@ ${a}
|
|
|
218
220
|
|
|
219
221
|
export function queryOptionsForViewId(
|
|
220
222
|
viewId: SemaphorGeneratedQueryViewId,
|
|
221
|
-
${
|
|
223
|
+
${w}: SemaphorGeneratedInputHandleMap,
|
|
222
224
|
): SemaphorQueryRuntimeOptions {
|
|
223
225
|
switch (viewId) {
|
|
224
|
-
${
|
|
226
|
+
${u}
|
|
225
227
|
}
|
|
226
228
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
227
229
|
}
|
|
228
|
-
`}function
|
|
229
|
-
`);return` ${i.name}: {
|
|
230
|
-
${w}
|
|
231
|
-
},`}).join(`
|
|
232
|
-
`),r=e.views.map(i=>{const w=P(i,e).map(g=>{const $=N(g.raw,e);return $?` ${g.name}: fields.${$},`:""}).filter(Boolean).join(`
|
|
230
|
+
`}function ze(e,n){return e.filterContracts.flatMap(r=>(r.bindings||[]).filter(t=>t.viewId===n).map(t=>({inputId:r.inputId,fieldRef:t.fieldRef,relationshipHint:t.relationshipHint,relationshipsUsed:t.relationshipsUsed})))}function Ye(e){const n=e.views.map(i=>{const g=Q(i,e).map(h=>{const I=O(h.raw,e);return I?` ${h.name}: fields.${I},`:""}).filter(Boolean).join(`
|
|
233
231
|
`);return` ${i.name}: {
|
|
234
|
-
${
|
|
232
|
+
${g}
|
|
235
233
|
},`}).join(`
|
|
236
|
-
`),
|
|
234
|
+
`),r=e.views.map(i=>{const g=B(i,e).map(h=>{const I=O(h.raw,e);return I?` ${h.name}: fields.${I},`:""}).filter(Boolean).join(`
|
|
237
235
|
`);return` ${i.name}: {
|
|
238
|
-
${
|
|
236
|
+
${g}
|
|
239
237
|
},`}).join(`
|
|
240
|
-
`),
|
|
238
|
+
`),t=e.views.map(i=>{const g=B(i,e).map((h,I)=>` ${h.name}: ${JSON.stringify(en(i,h,I))},`).join(`
|
|
241
239
|
`);return` ${i.name}: {
|
|
242
|
-
${
|
|
240
|
+
${g}
|
|
243
241
|
},`}).join(`
|
|
244
|
-
`),
|
|
242
|
+
`),o=e.views.map(i=>{const l=B(i,e);if(l.length===0)return` ${i.name}(): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
245
243
|
return {};
|
|
246
|
-
},`;const
|
|
244
|
+
},`;const g=l.map(h=>{const $=`readMetricValueByBinding(measures, measureBindings, ${`metricMeasureBindingKeysForView.${i.name}.${h.name}`})`;return` ${h.name}: ${$},`}).join(`
|
|
247
245
|
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
248
246
|
const measures = result?.measures;
|
|
249
247
|
const measureBindings = result?.measureBindings;
|
|
250
|
-
const primaryValue = result?.primaryValue;
|
|
251
248
|
return {
|
|
252
249
|
${g}
|
|
253
250
|
};
|
|
254
251
|
},`}).join(`
|
|
255
252
|
|
|
256
|
-
`),
|
|
253
|
+
`),a=e.views.map(i=>{const l=B(i,e);if(l.length===0)return` ${i.name}(): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
257
254
|
return [];
|
|
258
|
-
},`;const
|
|
255
|
+
},`;const g=l.map((h,I)=>{const $=`metricMeasureBindingKeysForView.${i.name}.${h.name}`,M=I===0?`readMetricValueByBinding(measures, measureBindings, ${$}) === undefined && !hasOwnPrimaryMetricValue(result)`:`readMetricValueByBinding(measures, measureBindings, ${$}) === undefined`;return` ...(missing.has(${$}) || (${M}) ? [${JSON.stringify(h.name)} as keyof typeof metricFieldsForView.${i.name}] : []),`}).join(`
|
|
259
256
|
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
260
257
|
const missing = new Set(result?.missingMeasures || []);
|
|
258
|
+
const measures = result?.measures;
|
|
259
|
+
const measureBindings = result?.measureBindings;
|
|
261
260
|
return [
|
|
262
|
-
${
|
|
261
|
+
${g}
|
|
263
262
|
];
|
|
264
263
|
},`}).join(`
|
|
265
264
|
|
|
266
|
-
`),
|
|
267
|
-
`)
|
|
265
|
+
`),u=e.views.map(i=>{const l=B(i,e);if(l.length===0)return"";const g=l[0],h=l.map($=>`{ key: ${JSON.stringify($.name)}, label: ${JSON.stringify($.raw.label||$.raw.name)} }`).join(", "),I=l.filter($=>$.name!==g.name).map($=>` if (missing.includes(${JSON.stringify($.name)})) delete values.${$.name};`).join(`
|
|
266
|
+
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): SemaphorGeneratedKpiProps {
|
|
267
|
+
const values = mapMetricDisplayValues(metricValuesForView.${i.name}(result));
|
|
268
|
+
const missing = missingMetricMeasuresForView.${i.name}(result).map((key) => String(key));
|
|
269
|
+
const primaryMissing = missing.includes(${JSON.stringify(g.name)});
|
|
270
|
+
const boundPrimaryValue = values.${g.name};
|
|
271
|
+
const primaryValue = primaryMissing || boundPrimaryValue === undefined ? result?.primaryValue : boundPrimaryValue;
|
|
272
|
+
if (primaryMissing) values.${g.name} = metricDisplayValue(result?.primaryValue);
|
|
273
|
+
${I}
|
|
274
|
+
return {
|
|
275
|
+
result: {
|
|
276
|
+
...(result || {}),
|
|
277
|
+
primaryValue: metricDisplayValue(result?.primaryValue),
|
|
278
|
+
comparisonValue: metricDisplayValue(result?.comparisonValue),
|
|
279
|
+
measures: values,
|
|
280
|
+
},
|
|
281
|
+
title: ${JSON.stringify(i.raw.title||i.raw.id)},
|
|
282
|
+
label: ${JSON.stringify(g.raw.label||g.raw.name)},
|
|
283
|
+
value: metricDisplayValue(primaryValue),
|
|
284
|
+
measures: [${h}],
|
|
285
|
+
missingMeasures: missing,
|
|
286
|
+
showComparison: Boolean(result?.comparisonKind),
|
|
287
|
+
};
|
|
288
|
+
},`}).filter(Boolean).join(`
|
|
289
|
+
|
|
290
|
+
`),c=e.views.map(i=>{const l=Ze(i,e);return` ${i.name}: ${C(l)},`}).join(`
|
|
291
|
+
`),w=e.views.map(i=>{const g=Q(i,e).map(h=>` ${h.name}: resolveColumnKey(columns, fieldsForView.${i.name}.${h.name}),`).join(`
|
|
268
292
|
`);return` ${i.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, string | undefined> {
|
|
269
293
|
return {
|
|
270
|
-
${
|
|
294
|
+
${g}
|
|
271
295
|
};
|
|
272
296
|
},`}).join(`
|
|
273
297
|
|
|
274
|
-
`),f=e.views.map(i=>{const
|
|
298
|
+
`),f=e.views.map(i=>{const g=Q(i,e).map(h=>` ${h.name}: readCell(row, columns, fieldsForView.${i.name}.${h.name}),`).join(`
|
|
275
299
|
`);return` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, unknown> {
|
|
276
300
|
return {
|
|
277
|
-
${
|
|
301
|
+
${g}
|
|
278
302
|
};
|
|
279
303
|
},`}).join(`
|
|
280
304
|
|
|
281
|
-
`),
|
|
305
|
+
`),y=e.views.map(i=>` ${i.name}(result: SemaphorGeneratedRecordsResult): Array<Record<keyof typeof fieldsForView.${i.name}, unknown>> {
|
|
282
306
|
return (result?.records || []).map((row) => rowValuesForView.${i.name}(row, result?.columns));
|
|
283
307
|
},`).join(`
|
|
284
308
|
|
|
285
|
-
`),
|
|
309
|
+
`),k=e.views.map(i=>{const l=Q(i,e),g=l.filter(s=>s.raw.role==="dimension"),h=l.filter(s=>s.raw.role==="measure"),I=g[0],$=g[1],M=h[0],b=h[1],E=[I?` primaryDimension: values.${I.name},`:" primaryDimension: undefined,",$?` secondaryDimension: values.${$.name},`:" secondaryDimension: undefined,",M?` primaryMeasure: values.${M.name},`:" primaryMeasure: undefined,",b?` secondaryMeasure: values.${b.name},`:" secondaryMeasure: undefined,"].join(`
|
|
286
310
|
`);return` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): SemaphorGeneratedRoleValues {
|
|
287
311
|
const values = rowValuesForView.${i.name}(row, columns);
|
|
288
312
|
return {
|
|
289
|
-
${
|
|
313
|
+
${E}
|
|
290
314
|
};
|
|
291
315
|
},`}).join(`
|
|
292
316
|
|
|
293
|
-
`),
|
|
294
|
-
`);return`${
|
|
295
|
-
${
|
|
317
|
+
`),d=n.includes("fields.")||r.includes("fields."),m=[`import { ${["type SemaphorFieldRef","type SemaphorResultColumn"].filter(x).join(", ")} } from "react-semaphor/data-app-sdk";`,d?'import { fields } from "./fields";':void 0].filter(x).join(`
|
|
318
|
+
`);return`${H}
|
|
319
|
+
${m}
|
|
296
320
|
|
|
297
321
|
export type SemaphorGeneratedRow = Record<string, unknown>;
|
|
298
322
|
export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
|
|
@@ -302,12 +326,16 @@ export type SemaphorGeneratedRecordsResult = {
|
|
|
302
326
|
} | null | undefined;
|
|
303
327
|
export type SemaphorGeneratedMetricMeasures = Record<string, unknown> | null | undefined;
|
|
304
328
|
export type SemaphorGeneratedMetricMeasureBindings = Record<string, string> | null | undefined;
|
|
329
|
+
export type SemaphorGeneratedMetricValue = number | string | null;
|
|
305
330
|
export type SemaphorGeneratedMetricResult = {
|
|
306
331
|
readonly measures?: SemaphorGeneratedMetricMeasures;
|
|
307
332
|
readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
|
|
308
333
|
readonly missingMeasures?: readonly string[];
|
|
309
334
|
readonly primaryValue: unknown;
|
|
310
|
-
readonly
|
|
335
|
+
readonly comparisonKind?: string;
|
|
336
|
+
readonly comparisonValue?: unknown;
|
|
337
|
+
readonly delta?: number | null;
|
|
338
|
+
readonly deltaPercent?: number | null;
|
|
311
339
|
} | null | undefined;
|
|
312
340
|
export type SemaphorGeneratedRoleValues = {
|
|
313
341
|
readonly primaryDimension: unknown;
|
|
@@ -322,6 +350,28 @@ export type SemaphorGeneratedTableColumn = {
|
|
|
322
350
|
readonly sortable?: boolean;
|
|
323
351
|
readonly sortKey?: string;
|
|
324
352
|
};
|
|
353
|
+
export type SemaphorGeneratedKpiResult<TValues extends Record<string, SemaphorGeneratedMetricValue> = Record<string, SemaphorGeneratedMetricValue>> =
|
|
354
|
+
Record<string, unknown> & {
|
|
355
|
+
readonly primaryValue?: SemaphorGeneratedMetricValue;
|
|
356
|
+
readonly comparisonValue?: SemaphorGeneratedMetricValue;
|
|
357
|
+
readonly comparisonKind?: string;
|
|
358
|
+
readonly delta?: number | null;
|
|
359
|
+
readonly deltaPercent?: number | null;
|
|
360
|
+
readonly measures: TValues;
|
|
361
|
+
};
|
|
362
|
+
export type SemaphorGeneratedKpiMeasureConfig = {
|
|
363
|
+
key: string;
|
|
364
|
+
label: string;
|
|
365
|
+
};
|
|
366
|
+
export type SemaphorGeneratedKpiProps = {
|
|
367
|
+
readonly result: SemaphorGeneratedKpiResult;
|
|
368
|
+
readonly title: string;
|
|
369
|
+
readonly label: string;
|
|
370
|
+
readonly value: SemaphorGeneratedMetricValue;
|
|
371
|
+
readonly measures: SemaphorGeneratedKpiMeasureConfig[];
|
|
372
|
+
readonly missingMeasures: readonly string[];
|
|
373
|
+
readonly showComparison: boolean;
|
|
374
|
+
};
|
|
325
375
|
|
|
326
376
|
export const fieldsForView = {
|
|
327
377
|
${n}
|
|
@@ -331,20 +381,16 @@ export const metricFieldsForView = {
|
|
|
331
381
|
${r}
|
|
332
382
|
} as const;
|
|
333
383
|
|
|
334
|
-
export const metricMeasureKeysForView = {
|
|
335
|
-
${t}
|
|
336
|
-
} as const;
|
|
337
|
-
|
|
338
384
|
export const metricMeasureBindingKeysForView = {
|
|
339
|
-
${
|
|
385
|
+
${t}
|
|
340
386
|
} as const;
|
|
341
387
|
|
|
342
388
|
export const tableColumnsForView = {
|
|
343
|
-
${
|
|
389
|
+
${c}
|
|
344
390
|
} as const;
|
|
345
391
|
|
|
346
392
|
export const columnKeysForView = {
|
|
347
|
-
${
|
|
393
|
+
${w}
|
|
348
394
|
} as const;
|
|
349
395
|
|
|
350
396
|
export const rowValuesForView = {
|
|
@@ -352,19 +398,23 @@ ${f}
|
|
|
352
398
|
} as const;
|
|
353
399
|
|
|
354
400
|
export const rowsForView = {
|
|
355
|
-
${
|
|
401
|
+
${y}
|
|
356
402
|
} as const;
|
|
357
403
|
|
|
358
404
|
export const roleValuesForView = {
|
|
359
|
-
${
|
|
405
|
+
${k}
|
|
360
406
|
} as const;
|
|
361
407
|
|
|
362
408
|
export const metricValuesForView = {
|
|
363
|
-
${
|
|
409
|
+
${o}
|
|
364
410
|
} as const;
|
|
365
411
|
|
|
366
412
|
export const missingMetricMeasuresForView = {
|
|
367
|
-
${
|
|
413
|
+
${a}
|
|
414
|
+
} as const;
|
|
415
|
+
|
|
416
|
+
export const kpiPropsForView = {
|
|
417
|
+
${u}
|
|
368
418
|
} as const;
|
|
369
419
|
|
|
370
420
|
export function resolveColumnKey(
|
|
@@ -408,155 +458,42 @@ export function readStringCell(
|
|
|
408
458
|
return value === null || value === undefined ? "" : String(value);
|
|
409
459
|
}
|
|
410
460
|
|
|
411
|
-
export function readMetricValue(
|
|
412
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
413
|
-
field: SemaphorFieldRef,
|
|
414
|
-
): unknown {
|
|
415
|
-
return readMetricValueByKeys(measures, metricKeysForField(field));
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
export function readMetricValueByKeys(
|
|
419
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
420
|
-
keys: readonly string[],
|
|
421
|
-
): unknown {
|
|
422
|
-
if (!measures) {
|
|
423
|
-
return undefined;
|
|
424
|
-
}
|
|
425
|
-
for (const key of keys) {
|
|
426
|
-
if (Object.prototype.hasOwnProperty.call(measures, key)) {
|
|
427
|
-
return measures[key];
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
return undefined;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
461
|
export function readMetricValueByBinding(
|
|
434
462
|
measures: SemaphorGeneratedMetricMeasures,
|
|
435
463
|
measureBindings: SemaphorGeneratedMetricMeasureBindings,
|
|
436
464
|
bindingKey: string,
|
|
437
|
-
fallbackKeys: readonly string[],
|
|
438
465
|
): unknown {
|
|
439
466
|
const resultKey = measureBindings?.[bindingKey];
|
|
440
467
|
if (resultKey && measures && Object.prototype.hasOwnProperty.call(measures, resultKey)) {
|
|
441
468
|
return measures[resultKey];
|
|
442
469
|
}
|
|
443
|
-
return
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
export function readMetricValueByKeysWithFallback(
|
|
447
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
448
|
-
keys: readonly string[],
|
|
449
|
-
fallbackValue: unknown,
|
|
450
|
-
): unknown {
|
|
451
|
-
const value = readMetricValueByKeys(measures, keys);
|
|
452
|
-
return value === undefined ? fallbackValue : value;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
export function readMetricValueByBindingWithFallback(
|
|
456
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
457
|
-
measureBindings: SemaphorGeneratedMetricMeasureBindings,
|
|
458
|
-
bindingKey: string,
|
|
459
|
-
fallbackKeys: readonly string[],
|
|
460
|
-
fallbackValue: unknown,
|
|
461
|
-
): unknown {
|
|
462
|
-
const value = readMetricValueByBinding(measures, measureBindings, bindingKey, fallbackKeys);
|
|
463
|
-
return value === undefined ? fallbackValue : value;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
export function readNumberMetricValue(
|
|
467
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
468
|
-
field: SemaphorFieldRef,
|
|
469
|
-
): number | null {
|
|
470
|
-
const value = readMetricValue(measures, field);
|
|
471
|
-
if (typeof value === "number") {
|
|
472
|
-
return Number.isFinite(value) ? value : null;
|
|
473
|
-
}
|
|
474
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
475
|
-
const parsed = Number(value);
|
|
476
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
477
|
-
}
|
|
478
|
-
return null;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
export function readStringMetricValue(
|
|
482
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
483
|
-
field: SemaphorFieldRef,
|
|
484
|
-
): string {
|
|
485
|
-
const value = readMetricValue(measures, field);
|
|
486
|
-
return value === null || value === undefined ? "" : String(value);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
export function metricKeysForField(
|
|
490
|
-
field: SemaphorFieldRef,
|
|
491
|
-
options: { allowNameFallback?: boolean; excludedKeys?: readonly string[] } = {},
|
|
492
|
-
): string[] {
|
|
493
|
-
const prefixes = metricKeyPrefixesForSource(field.source);
|
|
494
|
-
const aggregate = metricAggregateForField(field);
|
|
495
|
-
const excludedKeys = new Set(options.excludedKeys || []);
|
|
496
|
-
return uniqueStrings([
|
|
497
|
-
metricQualifiedKeyForField(field),
|
|
498
|
-
...prefixes.map((prefix) => \`\${prefix}.\${field.name}\`),
|
|
499
|
-
\`\${aggregate.toLowerCase()}_\${field.name}\`,
|
|
500
|
-
\`\${aggregate}_\${field.name}\`,
|
|
501
|
-
\`\${field.name}_\${aggregate.toLowerCase()}\`,
|
|
502
|
-
\`\${field.name}_\${aggregate}\`,
|
|
503
|
-
...(options.allowNameFallback === false ? [] : [field.name]),
|
|
504
|
-
]).filter((key) => !excludedKeys.has(key));
|
|
470
|
+
return undefined;
|
|
505
471
|
}
|
|
506
472
|
|
|
507
|
-
function
|
|
508
|
-
|
|
473
|
+
export function hasOwnPrimaryMetricValue(
|
|
474
|
+
result: SemaphorGeneratedMetricResult,
|
|
475
|
+
): boolean {
|
|
476
|
+
return Boolean(result && Object.prototype.hasOwnProperty.call(result, "primaryValue"));
|
|
509
477
|
}
|
|
510
478
|
|
|
511
|
-
function
|
|
512
|
-
|
|
479
|
+
export function mapMetricDisplayValues(
|
|
480
|
+
values: Record<string, unknown>,
|
|
481
|
+
): Record<string, SemaphorGeneratedMetricValue> {
|
|
482
|
+
return Object.fromEntries(
|
|
483
|
+
Object.entries(values)
|
|
484
|
+
.map(([key, value]) => [key, metricDisplayValue(value)] as const)
|
|
485
|
+
.filter(([key]) => values[key] !== undefined),
|
|
486
|
+
);
|
|
513
487
|
}
|
|
514
488
|
|
|
515
|
-
function
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if (!source) {
|
|
519
|
-
return [];
|
|
489
|
+
export function metricDisplayValue(value: unknown): SemaphorGeneratedMetricValue {
|
|
490
|
+
if (value === null || value === undefined) {
|
|
491
|
+
return null;
|
|
520
492
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const prefixes: string[] = [];
|
|
524
|
-
const datasetName = stringProperty(sourceRecord, "datasetName");
|
|
525
|
-
const datasetId = stringProperty(sourceRecord, "datasetId");
|
|
526
|
-
if (datasetName) {
|
|
527
|
-
prefixes.push(datasetName);
|
|
528
|
-
}
|
|
529
|
-
if (datasetId) {
|
|
530
|
-
prefixes.push(datasetId);
|
|
531
|
-
}
|
|
532
|
-
return uniqueStrings(prefixes);
|
|
493
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
494
|
+
return value;
|
|
533
495
|
}
|
|
534
|
-
|
|
535
|
-
const prefixes: string[] = [];
|
|
536
|
-
const databaseName = stringProperty(sourceRecord, "databaseName");
|
|
537
|
-
const schemaName = stringProperty(sourceRecord, "schemaName");
|
|
538
|
-
const tableName = stringProperty(sourceRecord, "tableName");
|
|
539
|
-
if (tableName) {
|
|
540
|
-
prefixes.push(tableName);
|
|
541
|
-
}
|
|
542
|
-
if (schemaName && tableName) {
|
|
543
|
-
prefixes.push(\`\${schemaName}.\${tableName}\`);
|
|
544
|
-
}
|
|
545
|
-
if (databaseName && schemaName && tableName) {
|
|
546
|
-
prefixes.push(\`\${databaseName}.\${schemaName}.\${tableName}\`);
|
|
547
|
-
}
|
|
548
|
-
return uniqueStrings(prefixes);
|
|
549
|
-
}
|
|
550
|
-
return [];
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
function stringProperty(record: Record<string, unknown>, key: string): string | undefined {
|
|
554
|
-
const value = record[key];
|
|
555
|
-
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function uniqueStrings(values: string[]): string[] {
|
|
559
|
-
return Array.from(new Set(values.filter((value) => value.length > 0)));
|
|
496
|
+
return String(value);
|
|
560
497
|
}
|
|
561
498
|
|
|
562
499
|
function resolveColumn(
|
|
@@ -661,13 +598,13 @@ function sourcesReferToSameDataset(
|
|
|
661
598
|
}
|
|
662
599
|
return false;
|
|
663
600
|
}
|
|
664
|
-
`}function
|
|
665
|
-
export const generatedViewIds = ${
|
|
666
|
-
export const generatedQueryViewIds = ${
|
|
667
|
-
export const generatedInputIds = ${
|
|
668
|
-
export const generatedInputOptionQueryIds = ${
|
|
669
|
-
export const generatedViewAuthoring = ${
|
|
670
|
-
export const generatedInputAuthoring = ${
|
|
601
|
+
`}function Ze(e,n){const r=Q(e,n),t=new Map((T(e)?z(e,n):[]).map(o=>[o.fieldName,o.key]));return r.map(o=>{const a=O(o.raw,n),u=a?t.get(a):void 0;return A({key:o.name,label:o.raw.label||o.raw.name,dataType:o.raw.dataType,sortable:!!u,sortKey:u})})}function We(e){const n=e.checklist.filterScopeByInput||[],r=e.checklist.requiredDevtools||{},t=e.summary.views.map(d=>d.id).filter(Boolean),o=e.views.map(d=>d.raw.id).filter(Boolean),a=e.inputs.map(d=>d.raw.id).filter(Boolean),u=e.optionQueries.map(d=>d.raw.id||`${d.input.raw.id}-options`).filter(Boolean),c=Object.fromEntries(o.map(d=>[d,e.filterContracts.filter(p=>Array.isArray(p.appliesToViewIds)&&p.appliesToViewIds.includes(d)).map(p=>p.inputId)])),w=Object.fromEntries(e.views.map(d=>[d.raw.id,{title:d.raw.title,visual:d.raw.visual,visualSpec:d.raw.visualSpec,queryKind:d.raw.queryKind,sdkBuilder:d.raw.sdkBuilder}])),f=Object.fromEntries(e.views.map(d=>{var p;return[d.raw.id,A({viewId:d.raw.id,queryId:d.name,title:d.raw.title,visualType:((p=d.raw.visualSpec)==null?void 0:p.visualType)||d.raw.visual,suggestedComponentName:ye(d.raw.title||d.raw.id||d.name),marker:{attribute:"data-semaphor-view-id",value:d.raw.id}})]})),y=Object.fromEntries(e.inputs.map(d=>{var p;return[d.raw.id,A({inputId:d.raw.id,label:d.raw.label,type:d.raw.type,optionQueryId:((p=d.raw.optionQuery)==null?void 0:p.id)||(d.raw.optionQuery?`${d.raw.id}-options`:void 0),suggestedComponentName:ye(d.raw.label||d.raw.id||d.name),marker:{attribute:"data-semaphor-input-id",value:d.raw.id}})]})),k=Object.fromEntries(e.views.map(d=>{var p,m,i;return[d.name,A({viewId:d.raw.id,viewTitle:((p=d.raw.visualSpec)==null?void 0:p.title)||d.raw.title,visualType:(m=d.raw.visualSpec)==null?void 0:m.visualType,title:((i=d.raw.visualSpec)==null?void 0:i.title)||d.raw.title})]}));return`${H}
|
|
602
|
+
export const generatedViewIds = ${C(t)} as const;
|
|
603
|
+
export const generatedQueryViewIds = ${C(o)} as const;
|
|
604
|
+
export const generatedInputIds = ${C(a)} as const;
|
|
605
|
+
export const generatedInputOptionQueryIds = ${C(u)} as const;
|
|
606
|
+
export const generatedViewAuthoring = ${C(f)} as const;
|
|
607
|
+
export const generatedInputAuthoring = ${C(y)} as const;
|
|
671
608
|
|
|
672
609
|
export type SemaphorGeneratedViewId = typeof generatedViewIds[number];
|
|
673
610
|
export type SemaphorGeneratedQueryViewId = typeof generatedQueryViewIds[number];
|
|
@@ -686,8 +623,8 @@ export type SemaphorGeneratedFilterContract = {
|
|
|
686
623
|
readonly [key: string]: unknown;
|
|
687
624
|
};
|
|
688
625
|
|
|
689
|
-
export const generatedInputIdsForView = ${
|
|
690
|
-
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${
|
|
626
|
+
export const generatedInputIdsForView = ${C(c)} as const;
|
|
627
|
+
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${C(e.filterContracts)} as const;
|
|
691
628
|
|
|
692
629
|
export function semaphorViewMarkerProps(viewId: SemaphorGeneratedViewId) {
|
|
693
630
|
return {
|
|
@@ -707,10 +644,10 @@ export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
|
707
644
|
);
|
|
708
645
|
}
|
|
709
646
|
|
|
710
|
-
export const queryDebugForView = ${k
|
|
647
|
+
export const queryDebugForView = ${C(k)} as const;
|
|
711
648
|
|
|
712
|
-
export const semaphorGeneratedContractMetadata = ${
|
|
713
|
-
`}function
|
|
649
|
+
export const semaphorGeneratedContractMetadata = ${C({schemaVersion:"semaphor-generated-data-app-contract/v1",title:e.title,requiredDevtools:r,filterContracts:e.filterContracts,filterScopeByInput:n,generatedViewIds:t,generatedQueryViewIds:o,generatedInputIds:a,generatedInputOptionQueryIds:u,generatedInputIdsForView:c,generatedViewAuthoring:f,generatedInputAuthoring:y,visualSpecs:w,presentationViews:e.presentationViews})} as const;
|
|
650
|
+
`}function Xe(){return`${H}
|
|
714
651
|
export * from "./sources";
|
|
715
652
|
export * from "./fields";
|
|
716
653
|
export * from "./inputs";
|
|
@@ -718,4 +655,4 @@ export * from "./queries";
|
|
|
718
655
|
export * from "./bindings";
|
|
719
656
|
export * from "./accessors";
|
|
720
657
|
export * from "./metadata";
|
|
721
|
-
`}function
|
|
658
|
+
`}function D(e,n){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(const r of n)D(e,r);return}N(n)&&S(e,W(n));for(const r of Object.values(n))D(e,r)}}function Q(e,n){const r=[];if(on(r,e.raw.sdkSpec),r.length===0)for(const o of e.raw.fields||[])S(r,o);const t=ne(r.filter(o=>o.name&&O(o,n)).map(o=>({raw:o,key:X(o),name:""})),o=>o.key);return Se(t,n,"field"),t}function B(e,n){if(q(e.raw.sdkSpec.builder)!=="metric")return[];const r=F(e.raw.sdkSpec.spec),t=[];S(t,r==null?void 0:r.primaryMeasure);for(const a of v(r==null?void 0:r.measures))S(t,a);const o=ne(t.filter(a=>a.name&&O(a,n)).map(a=>({raw:a,key:X(a),name:""})),a=>a.key);return Se(o,n,"metric"),o}function en(e,n,r){var o;const t=(o=e.raw.metricBindingKeys)==null?void 0:o[r];if(typeof t=="string"&&t.trim())return t;throw new Error(`views.${e.raw.id}.metricBindingKeys must include a binding key for metric field ${n.raw.name}.`)}function Se(e,n,r){const t=new Map,o=new Map;for(const u of e){const c=j(u.raw.name||u.raw.label||r)||r;t.set(u.key,c),o.set(c,(o.get(c)||0)+1)}const a=new Set;for(const u of e){const c=t.get(u.key)||r,w=O(u.raw,n)||c,f=o.get(c)===1?c:w;u.name=nn(f,u.key,a)}}function nn(e,n,r){const t=tn(e)?e:j(e||"field")||"field";if(!r.has(t))return r.add(t),t;const o=rn(n),a=`${t}${o}`;if(!r.has(a))return r.add(a),a;let u=2;for(;r.has(`${a}${u}`);)u+=1;const c=`${a}${u}`;return r.add(c),c}function rn(e){let n=0;for(let r=0;r<e.length;r+=1)n=n*31+e.charCodeAt(r)>>>0;return n.toString(36).slice(0,6).replace(/^[0-9]/,"x$&")}function tn(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function on(e,n){const r=F(n.spec);if(!r)return;const t=q(n.builder);if(t==="records"){for(const o of v(r.fields))S(e,o);return}if(t==="sql"){for(const o of v(r.fields))S(e,o);return}if(t==="analysis"||t==="metric"){S(e,r.primaryMeasure);for(const o of v(r.measures))S(e,o);for(const o of v(r.dimensions))S(e,o);S(e,r.dateField);return}if(t==="matrix"){const o=ce(r.rows),a=ce(r.columns),u=v(r.values);for(const c of o)me(e,c);for(const c of a)me(e,c);for(const c of u){const w=F(c);S(e,w==null?void 0:w.field),S(e,w==null?void 0:w.measure)}}}function ce(e){if(Array.isArray(e))return e;const n=F(e);return Array.isArray(n==null?void 0:n.levels)?n.levels:[]}function me(e,n){var r;if(N(n)){S(e,n);return}S(e,(r=F(n))==null?void 0:r.field)}function fe(e){var n,r,t,o;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"||((t=e==null?void 0:e.computation)==null?void 0:t.kind)==="unsupported"||(e==null?void 0:e.visual)==="text_block"||((o=e==null?void 0:e.visualSpec)==null?void 0:o.visualType)==="text_block"}function sn(e){const n=F(e)||{};return A({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 S(e,n){N(n)&&e.push(W(n))}function W(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 an(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:Ve(n),name:""}}function N(e){const n=F(e);return!!(n&&typeof n.name=="string"&&(typeof n.role=="string"||typeof n.dataType=="string"||typeof n.aggregate=="string"||n.source||n.sourceKey))}function we(e){const n=F(e);return!!(n&&(typeof n.sourceKey=="string"||n.kind==="semantic"||typeof n.datasetName=="string"&&typeof n.domainId=="string"))}function G(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(o=>G(o,n)).join(", ")}]`;if(N(e)){const o=O(W(e),n);if(o)return`fields.${o}`}if(we(e)){const o=$e(e,n);if(o)return`sources.${o}`}const r=F(e);return r?`{ ${Object.entries(r).filter(([,o])=>o!==void 0).map(([o,a])=>`${JSON.stringify(o)}: ${G(a,n)}`).join(", ")} }`:JSON.stringify(e)}function C(e){return JSON.stringify(e,null,2)}function O(e,n){if(N(e))return n.fieldNameByKey.get(X(W(e)))}function $e(e,n){if(we(e))for(const r of ee(e)){const t=n.sourceNameByKey.get(r);if(t)return t}}function X(e){return[e.sourceKey||"",e.name||"",e.role||"",e.aggregate||""].join("|")}function un(e,n){return!N(e)||!N(n)||e.name!==n.name?!1:de(e).some(r=>de(n).includes(r))}function dn(e){return N(e)&&e.role==="id"}function pn(e){const n=[],r=new Map;for(const t of e){const o=U(t.aliases.length?t.aliases:[t.key]),a=o.map(u=>r.get(u)).find(x);if(a){a.aliases=U([...a.aliases,...o]);continue}t.aliases=o,n.push(t);for(const u of o)r.set(u,t)}return n}function ln(e){const n=new Map;for(const r of e)for(const t of U([r.key,...r.aliases])){const o=n.get(t);if(o&&o!==r.name)throw new Error(`Source identity ${t} resolves to multiple generated sources.`);n.set(t,r.name)}return n}function U(e){return Array.from(new Set(e.filter(Boolean)))}function Ie(e){return ee(e)[0]||le(e)}function ee(e){const n=F(e);if(!n)return[];const r=[];if(typeof n.sourceKey=="string"&&r.push(n.sourceKey),n.kind==="semantic"||n.datasetName){const t=typeof n.domainId=="string"?n.domainId:"";t&&typeof n.datasetId=="string"&&r.push(`semantic:${t}:datasetId:${n.datasetId}`),t&&typeof n.datasetName=="string"&&r.push(`semantic:${t}:datasetName:${n.datasetName}`)}return r.length===0&&r.push(le(e)),U(r)}function Ve(e){return ee(e)}function le(e){const n=F(e);return n?typeof n.sourceKey=="string"?n.sourceKey:JSON.stringify(n):""}function cn(e){return N(e)&&de(e)[0]||""}function de(e){return N(e)?U([...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 mn(e){const n=q(e);return n==="records"||n==="sql"}function fn(e){const n=F(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 P(e,n){const r=new Map;for(const t of e){const o=n(t)||"item",a=r.get(o)||0;r.set(o,a+1),t.name=a===0?o:`${o}${a+1}`}}function ne(e,n){const r=new Set,t=[];for(const o of e){const a=n(o);!a||r.has(a)||(r.add(a),t.push(o))}return t}function j(e){const n=String(e||"").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);if(n.length===0)return"item";const[r,...t]=n,o=[r.toLowerCase(),...t.map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase())].join("");return/^[A-Za-z_$]/.test(o)?o:`item${o}`}function ye(e){const n=j(e);return n.charAt(0).toUpperCase()+n.slice(1)}function yn(e){const n=String(e).split(":");return n[n.length-1]||String(e)}function A(e){return Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}function F(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function v(e){return Array.isArray(e)?e:[]}function L(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=Y.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=Y.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=Y.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=Y.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=R.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=R.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=R.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=R.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=R.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=R.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=R.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=R.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=R.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=R.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=R.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=R.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=R.validateCodegenSummary;exports.validateSemaphorGeneratedContract=R.validateSemaphorGeneratedContract;exports.DEFAULT_GENERATED_CONTRACT_OUTPUT_DIR=Ce;exports.generateSemaphorDataAppContract=Oe;
|