react-semaphor 0.1.420 → 0.1.421
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-B5Eeu7vD.js +1 -0
- package/dist/chunks/analyze-result-contract-sWcmvBOA.js +2070 -0
- package/dist/chunks/{calendar-preferences-dialog-f0Z7Kf-U.js → calendar-preferences-dialog-CscmhyuZ.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-DIfAbE_y.js → calendar-preferences-dialog-cN3_2C-u.js} +3 -3
- package/dist/chunks/{dashboard-briefing-launcher-anh-Jy5v.js → dashboard-briefing-launcher-BYTBNetR.js} +4 -4
- package/dist/chunks/{dashboard-briefing-launcher-C3tNkGFG.js → dashboard-briefing-launcher-DmZkzIC3.js} +1 -1
- package/dist/chunks/{dashboard-controls-DQxlOxzy.js → dashboard-controls-9DFeKIP4.js} +1 -1
- package/dist/chunks/{dashboard-controls-8dCQaPaq.js → dashboard-controls-PhzuaTBj.js} +5 -5
- package/dist/chunks/{dashboard-json-i7Ae9KGD.js → dashboard-json-Cxhw2TZc.js} +3 -3
- package/dist/chunks/{dashboard-json-B309EInF.js → dashboard-json-DyRHI3mL.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-4HycwBHR.js → edit-dashboard-visual-3_jiBXsu.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-z3IqzYnj.js → edit-dashboard-visual-BigSJ3-x.js} +4 -4
- package/dist/chunks/{index-yxKWKFdr.js → index-BKDQw0aK.js} +2 -2
- package/dist/chunks/{index-B6DLEXRX.js → index-CH2ZzQo4.js} +5 -5
- package/dist/chunks/{switch-D6Ygf3wA.js → switch-CiOjVyVI.js} +1 -1
- package/dist/chunks/{switch-COWQU8aK.js → switch-TbCsyhv9.js} +1 -1
- package/dist/chunks/{update-policy-BzT2k4n6.js → update-policy-2MZ-Vf7v.js} +211 -187
- package/dist/chunks/update-policy-qpyAkOyO.js +3 -0
- package/dist/chunks/{use-create-flow-overlay-state-CX0D-6HM.js → use-create-flow-overlay-state-BzcJWNzh.js} +3 -3
- package/dist/chunks/{use-create-flow-overlay-state-DENfd7sW.js → use-create-flow-overlay-state-DUQmgb9H.js} +1 -1
- package/dist/chunks/{validators-Cxr9qbrR.js → validators-D0pfj3jJ.js} +93 -93
- package/dist/chunks/validators-Dj1Y-46V.js +1 -0
- 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 +251 -139
- package/dist/data-app-codegen-node/index.js +806 -657
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +730 -686
- 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/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +12 -5
- package/dist/types/dashboard-assistant.d.ts +0 -5
- 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 -5
- package/dist/types/data-app-sdk.d.ts +17 -5
- 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,55 +1,57 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("../chunks/analyze-result-contract-B5Eeu7vD.js"),R=require("../chunks/update-policy-qpyAkOyO.js"),ge=require("node:crypto"),Re="src/semaphor/generated",T=`// 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 Me(e,
|
|
4
|
-
`};return{schemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,files:
|
|
5
|
-
`)
|
|
6
|
-
`);const t=e.views.find(
|
|
7
|
-
`);const
|
|
8
|
-
`);const
|
|
9
|
-
`);const
|
|
10
|
-
`);const
|
|
11
|
-
`)
|
|
12
|
-
`)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
`;function Me(e,r={}){R.assertValidCodegenSummary(e);const n=Ne(e);if(n.views.length===0&&!r.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=Oe(n),o=Ee({contract:n,files:t,generatorName:r.generatorName||"react-semaphor/data-app-codegen/node",generatorVersion:r.generatorVersion||"unknown"}),i={...t,"contract.manifest.json":`${JSON.stringify(o,null,2)}
|
|
4
|
+
`};return{schemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,files:i,manifest:o,contentHash:String(o.generatedContentHash||""),usageExample:ve(n),warnings:n.warnings,stats:{inputCount:n.inputs.length,executableViewCount:n.views.length,presentationViewCount:n.presentationViews.length,queryCount:n.views.length,optionQueryCount:n.optionQueries.length}}}function Ne(e){var u,d,p,$,s,g,h,y,I,V,b,M;const r=[],n=[];for(const a of e.inputs){S(n,a.fieldRef);for(const w of a.bindings||[])S(n,w.fieldRef);S(n,(u=a.optionQuery)==null?void 0:u.valueFieldRef),S(n,(d=a.optionQuery)==null?void 0:d.labelFieldRef),S(n,(p=a.optionQuery)==null?void 0:p.filterFieldRef),D(n,($=a.optionQuery)==null?void 0:$.spec)}for(const a of e.filterContracts){S(n,a.fieldRef),S(n,(s=a.optionQuery)==null?void 0:s.valueFieldRef),S(n,(g=a.optionQuery)==null?void 0:g.labelFieldRef),S(n,(h=a.optionQuery)==null?void 0:h.filterFieldRef),D(n,(y=a.optionQuery)==null?void 0:y.spec);for(const w of a.bindings||[])S(n,w.fieldRef)}for(const a of e.views){for(const w of a.fields||[])S(n,w);D(n,(I=a.sdkSpec)==null?void 0:I.spec),D(n,a.visualSpec)}const t=e.implementationChecklist||{};for(const a of Object.values(t.bindingsByView||{}))for(const w of Array.isArray(a)?a:[])S(n,w.fieldRef),S(n,w.optionValueField),S(n,w.optionLabelField);for(const a of t.requiredInputOptions||[])S(n,a.visibleLabelField),S(n,a.optionValueField),S(n,a.runtimeFilterField);const o=dr([...e.sources.map(a=>({raw:a,key:Ie(a),aliases:Fe(a),name:""})),...n.map(a=>sr(a)).filter(A)]);_(o,a=>{const w=k(a.raw);return j(a.raw.label||(w==null?void 0:w.datasetName)||(w==null?void 0:w.datasetId)||(w==null?void 0:w.name)||a.raw.kind||"source")});const i=lr(o),l=re(n.filter(a=>a.name).map(a=>({raw:a,key:z(a),name:""})),a=>a.key);_(l,a=>j([a.raw.sourceKey?fr(a.raw.sourceKey):"",a.raw.aggregate?a.raw.aggregate.toLowerCase():"",a.raw.name].filter(Boolean).join("_")));const f=new Map(l.map(a=>[a.key,a.name])),F=e.inputs.map(a=>({raw:a,name:j(a.id||a.label||"input")}));_(F,a=>a.name);const m=F.filter(a=>!!a.raw.optionQuery).map(a=>({input:a,name:`${a.name}Options`,raw:a.raw.optionQuery}));_(m,a=>a.name);for(const a of m)ir(a.raw.labelFieldRef,a.raw.valueFieldRef)&&ur(a.raw.valueFieldRef)&&r.push(`Input option query ${((V=a.raw.spec)==null?void 0:V.inputId)||a.input.raw.id||a.name} uses identifier field ${a.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 c=e.views.filter(a=>{var w,P;return!!((w=a.sdkSpec)!=null&&w.builder&&((P=a.sdkSpec)!=null&&P.spec))}).map(a=>({raw:a,name:j(a.id||a.title||"query")}));_(c,a=>a.name);const O=e.views.filter(a=>fe(a)&&!("sdkSpec"in a)).map(a=>ar(a));for(const a of e.views)(!("sdkSpec"in a)||!((b=a.sdkSpec)!=null&&b.builder)||!((M=a.sdkSpec)!=null&&M.spec))&&!fe(a)&&r.push(`Skipped view ${a.id||a.title||"unknown"} because it has no sdkSpec.`);return Ce({inputs:F,views:c,filterContracts:e.filterContracts}),{summary:e,title:e.title||"Semaphor Data App",sources:o,fields:l,inputs:F,optionQueries:m,views:c,presentationViews:O,filterContracts:e.filterContracts,checklist:t,sourceNameByKey:i,fieldNameByKey:f,warnings:r}}function Ce({inputs:e,views:r,filterContracts:n}){const t=new Set(e.map(i=>i.raw.id).filter(Boolean)),o=new Set(r.map(i=>i.raw.id).filter(Boolean));for(const[i,l]of n.entries()){if(!t.has(l.inputId))throw new Error(`filterContracts.${i}.inputId must reference a generated input.`);const f=new Set(l.appliesToViewIds||[]),F=new Set(l.notAppliedToViewIds||[]);for(const[m,c]of(l.appliesToViewIds||[]).entries())if(!o.has(c))throw new Error(`filterContracts.${i}.appliesToViewIds.${m} must reference an executable generated view.`);for(const[m,c]of(l.notAppliedToViewIds||[]).entries())if(!o.has(c))throw new Error(`filterContracts.${i}.notAppliedToViewIds.${m} must reference an executable generated view.`);for(const[m,c]of(l.bindings||[]).entries()){if(!o.has(c.viewId))throw new Error(`filterContracts.${i}.bindings.${m}.viewId must reference an executable generated view.`);if(!f.has(c.viewId))throw new Error(`filterContracts.${i}.bindings.${m}.viewId must be included in appliesToViewIds.`);if(F.has(c.viewId))throw new Error(`filterContracts.${i}.bindings.${m}.viewId must not be listed in notAppliedToViewIds.`)}}}function Oe(e){return{"sources.ts":_e(e),"fields.ts":je(e),"inputs.ts":Pe(e),"queries.ts":De(e),"bindings.ts":Je(e),"accessors.ts":Ye(e),"metadata.ts":Ze(e),"index.ts":Xe(),"USAGE.md":Ge(e)}}function Ee({contract:e,files:r,generatorName:n,generatorVersion:t}){return{schemaVersion:R.CONTRACT_MANIFEST_SCHEMA_VERSION,generatedContractSchemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,generator:{name:n,version:t},generatedContentHash:xe(r),codegenSummaryValidatorVersion:R.CODEGEN_SUMMARY_VALIDATOR_VERSION,codegenSummaryHash:Ae(e.summary),codegenSummary:e.summary}}function xe(e){const r=ge.createHash("sha256");for(const n of Object.keys(e).filter(t=>t.endsWith(".ts")).sort())r.update(n),r.update("\0"),r.update(e[n]),r.update("\0");return`sha256:${r.digest("hex")}`}function Ge(e){const r=["# 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&&(r.push("Generated executable views:"),e.views.forEach(n=>{r.push(`- \`${n.raw.id}\`: ${n.raw.title||n.name}`)}),r.push("")),e.inputs.length>0&&(r.push("Generated inputs:"),e.inputs.forEach(n=>{r.push(`- \`${n.raw.id}\`: ${n.raw.label||n.name}`)}),r.push("")),`${r.join(`
|
|
5
|
+
`)}
|
|
6
|
+
`}function Ae(e){return`sha256:${ge.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 r=e;return`{${Object.keys(r).sort().filter(t=>r[t]!==void 0).map(t=>`${JSON.stringify(t)}:${ue(r[t])}`).join(",")}}`}function ve(e){const r=e.views.find(m=>v(m)&&K(m));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}({ page, pageSize, sort });`,`const result = useSemaphorQuery(query, queryOptionsForView.${r.name}(inputHandles));`,`const rows = rowsForView.${r.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
7
|
+
`);const n=e.views.find(m=>v(m));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}({ sort });`,`const result = useSemaphorQuery(query, queryOptionsForView.${n.name}(inputHandles));`,`const rows = rowsForView.${n.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
8
|
+
`);const t=e.views.find(m=>X(m)&&K(m));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(`
|
|
9
|
+
`);const o=e.views.find(m=>le(m)&&K(m));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(`
|
|
10
|
+
`);const i=e.views.find(m=>{var c;return cr((c=m.raw.sdkSpec)==null?void 0:c.builder)});if(i)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const result = useSemaphorQuery(queries.${i.name}(), queryOptionsForView.${i.name}(inputHandles));`,`const rows = rowsForView.${i.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
11
|
+
`);const l=e.views.find(m=>Ke(m));if(l)return['import { appInputSpecs, createInputHandleMap, kpiPropsForView, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const result = useSemaphorQuery(queries.${l.name}(), queryOptionsForView.${l.name}(inputHandles));`,`const kpiProps = kpiPropsForView.${l.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
12
|
+
`);const f=e.views[0];return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",f?`const result = useSemaphorQuery(queries.${f.name}(), queryOptionsForView.${f.name}(inputHandles));`:"const result = undefined;","const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
13
|
+
`)}function X(e){var r;return q((r=e.raw.sdkSpec)==null?void 0:r.builder)==="records"}function Ke(e){var r;return q((r=e.raw.sdkSpec)==null?void 0:r.builder)==="metric"}function v(e){var r,n,t;return X(e)&&((t=(n=(r=e.raw.visualSpec)==null?void 0:r.tableBehavior)==null?void 0:n.sorting)==null?void 0:t.mode)==="server"}function le(e){var r;return q((r=e.raw.sdkSpec)==null?void 0:r.builder)==="sql"}function K(e){var r,n,t;return((t=(n=(r=e.raw.visualSpec)==null?void 0:r.tableBehavior)==null?void 0:n.pagination)==null?void 0:t.mode)==="server"}function Te(e){return X(e)&&(K(e)||v(e))||le(e)&&K(e)}function _e(e){const r=e.sources.map(({name:t,raw:o})=>{const i=He(o);return` ${t}: ${i},`}).join(`
|
|
14
|
+
`),n=e.sources.some(t=>t.raw.kind==="semantic")?`import { semaphor } from "react-semaphor/data-app-sdk";
|
|
15
|
+
|
|
16
|
+
`:"";return`${T}
|
|
17
|
+
${n}export const sources = {
|
|
18
|
+
${r}
|
|
17
19
|
} as const;
|
|
18
|
-
`}function He(e){if(e.kind==="semantic"){const
|
|
19
|
-
`),r
|
|
20
|
+
`}function He(e){if(e.kind==="semantic"){const r={domainId:e.domainId,datasetId:e.datasetId,datasetName:e.datasetName,label:e.label};return`semaphor.source.semantic(${N(G(r))})`}return`${N(G({...e,sourceKey:void 0}))} as const`}function je(e){const r=e.fields.map(({name:t,raw:o})=>{const i=qe(o,e);return` ${t}: ${i},`}).join(`
|
|
21
|
+
`),n=r.includes("sources.")?`import { sources } from "./sources";
|
|
20
22
|
|
|
21
|
-
`:"";return`${
|
|
22
|
-
${
|
|
23
|
-
${
|
|
23
|
+
`:"";return`${T}
|
|
24
|
+
${n}export const fields = {
|
|
25
|
+
${r}
|
|
24
26
|
} as const;
|
|
25
|
-
`}function qe(e,
|
|
26
|
-
`),
|
|
27
|
-
`),
|
|
28
|
-
inputs.push(semaphor.bindInput(${
|
|
27
|
+
`}function qe(e,r){const n={name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate},t=pr(e),o=t?r.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 i=Object.entries(G(n)).map(([l,f])=>`${JSON.stringify(l)}: ${x(f,r)}`);return o&&i.push(`"source": sources.${o}`),`{ ${i.join(", ")} }`}function Pe(e){const r=e.inputs.map(p=>{const $=C(p.raw.fieldRef,e),s=[`id: ${JSON.stringify(p.raw.id)}`,`label: ${JSON.stringify(p.raw.label||p.raw.id)}`,`operator: ${JSON.stringify(mr(p.raw))}`];if($&&s.push(`field: fields.${$}`),p.raw.relationshipHint&&s.push(`relationshipHint: ${N(p.raw.relationshipHint)}`),!$)throw new Error(`Input ${p.raw.id||p.name} is missing a generated field reference.`);return` ${p.name}: semaphor.filter({ ${s.join(", ")} }),`}).join(`
|
|
28
|
+
`),n=e.inputs.map(p=>`filterSpecs.${p.name}`).join(", "),t=e.inputs.map(p=>JSON.stringify(p.raw.id)).join(", "),o=e.optionQueries.map(p=>{const $=p.input.raw,s=p.raw,g=k(s.spec)||{},{id:h,inputId:y,source:I,sourceKey:V,valueField:b,labelField:M,population:a,dependencies:w,limit:P,...ne}=g,Y=s.sourceKey?{sourceKey:s.sourceKey}:s.source||I||(typeof V=="string"?{sourceKey:V}:void 0),te=$e(Y,e),oe=C(s.valueFieldRef,e),ae=C(s.labelFieldRef,e),se=he(p),ie={...ne,id:s.id||g.id||`${$.id}-options`,inputId:$.id,source:Y,valueField:s.valueFieldRef,labelField:s.labelFieldRef,population:s.population||a,dependencies:se,limit:s.limit||P||100};if(!te||!oe||!ae)throw new Error(`Input option query ${s.id||`${$.id}-options`} is missing source, valueField, or labelField.`);const Ve=Object.entries(G(ie)).map(([be,ke])=>`${JSON.stringify(be)}: ${x(ke,e)}`);return` ${p.name}: semaphor.inputOptions({ ${Ve.join(", ")} }),`}).join(`
|
|
29
|
+
`),i=e.optionQueries.map(p=>{const $=Be(e,p),s=$.length>0?"inputHandles":"_inputHandles",g=$.map(h=>{const y=C(h.raw.fieldRef,e);if(!y)throw new Error(`Input option query ${p.raw.id||`${p.input.raw.id}-options`} references input ${h.raw.id} without a generated field reference.`);const I=`inputHandles[${JSON.stringify(h.raw.id)}]`;return` if (${I}) {
|
|
30
|
+
inputs.push(semaphor.bindInput(${I}, { field: fields.${y} }));
|
|
29
31
|
}`}).join(`
|
|
30
|
-
`);return` ${
|
|
32
|
+
`);return` ${p.name}(${s}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
31
33
|
const inputs: SemaphorInputReference[] = [];
|
|
32
|
-
${
|
|
34
|
+
${g}
|
|
33
35
|
return inputs;
|
|
34
36
|
},`}).join(`
|
|
35
37
|
|
|
36
|
-
`),l=e.optionQueries.map(
|
|
38
|
+
`),l=e.optionQueries.map(p=>` ${p.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
37
39
|
return {
|
|
38
|
-
inputs: inputsForInputOptionQuery.${
|
|
40
|
+
inputs: inputsForInputOptionQuery.${p.name}(inputHandles),
|
|
39
41
|
};
|
|
40
42
|
},`).join(`
|
|
41
43
|
|
|
42
|
-
`),
|
|
43
|
-
return queryOptionsForInputOptionQuery.${
|
|
44
|
-
`),
|
|
45
|
-
`);return`${
|
|
44
|
+
`),f=e.optionQueries.map(p=>` case ${JSON.stringify(p.raw.id||`${p.input.raw.id}-options`)}:
|
|
45
|
+
return queryOptionsForInputOptionQuery.${p.name}(inputHandles);`).join(`
|
|
46
|
+
`),F=e.inputs.length>0,m=e.optionQueries.length>0,c=m?"inputOptionQueryId":"_inputOptionQueryId",O=m?"inputHandles":"_inputHandles",u=["SemaphorInputHandle",m?"SemaphorInputReference":void 0,"SemaphorQueryRuntimeOptions"].filter(A).join(", "),d=[F||m?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,`import type { ${u} } from "react-semaphor/data-app-sdk";`,F||m?'import { fields } from "./fields";':void 0,m?'import { sources } from "./sources";':void 0,'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'].filter(A).join(`
|
|
47
|
+
`);return`${T}
|
|
46
48
|
${d}
|
|
47
49
|
|
|
48
50
|
export const filterSpecs = {
|
|
49
|
-
${
|
|
51
|
+
${r}
|
|
50
52
|
} as const;
|
|
51
53
|
|
|
52
|
-
export const appInputSpecs = [${
|
|
54
|
+
export const appInputSpecs = [${n}] as const;
|
|
53
55
|
export const appInputIds = [${t}] as const;
|
|
54
56
|
|
|
55
57
|
export type SemaphorGeneratedInputHandleMap = Partial<Record<SemaphorGeneratedInputId, SemaphorInputHandle>>;
|
|
@@ -63,7 +65,7 @@ ${o}
|
|
|
63
65
|
} as const;
|
|
64
66
|
|
|
65
67
|
export const inputsForInputOptionQuery = {
|
|
66
|
-
${
|
|
68
|
+
${i}
|
|
67
69
|
} as const;
|
|
68
70
|
|
|
69
71
|
export const queryOptionsForInputOptionQuery = {
|
|
@@ -71,48 +73,48 @@ ${l}
|
|
|
71
73
|
} as const;
|
|
72
74
|
|
|
73
75
|
export function queryOptionsForInputOptionQueryId(
|
|
74
|
-
${
|
|
76
|
+
${c}: SemaphorGeneratedInputOptionQueryId,
|
|
75
77
|
${O}: SemaphorGeneratedInputHandleMap,
|
|
76
78
|
): SemaphorQueryRuntimeOptions {
|
|
77
|
-
switch (${
|
|
78
|
-
${
|
|
79
|
+
switch (${c}) {
|
|
80
|
+
${f}
|
|
79
81
|
}
|
|
80
|
-
throw new Error(\`Unknown generated Semaphor input option query id: \${${
|
|
82
|
+
throw new Error(\`Unknown generated Semaphor input option query id: \${${c}}\`);
|
|
81
83
|
}
|
|
82
|
-
`}function Be(e,
|
|
84
|
+
`}function Be(e,r){const n=he(r);if(!n||n.mode==="independent")return[];if(n.mode!=="explicit")return[];const t=new Set(n.includeInputIds||[]),o=new Set([r.input.raw.id,...n.excludeInputIds||[]]);return e.inputs.filter(i=>o.has(i.raw.id)?!1:t.has(i.raw.id))}function he(e){var r;return e.raw.dependencies||((r=e.raw.spec)==null?void 0:r.dependencies)}function De(e){const r=e.views.map(d=>{var s,g,h,y,I,V;const p=q(d.raw.sdkSpec.builder),$=Qe(d);if(X(d)&&Te(d)){const b=(s=d.raw.visualSpec)==null?void 0:s.tableBehavior,M=k($.pagination),a=K(d),w=v(d),P=((g=b==null?void 0:b.pagination)==null?void 0:g.pageSize)||W(M==null?void 0:M.pageSize)||W($.limit)||100,ne=w?Z(d,e):[],Y=w?Ue({view:d,contract:e,sortFields:ne,defaultField:(h=b==null?void 0:b.sorting)==null?void 0:h.defaultField}):void 0,te=w?(y=b==null?void 0:b.sorting)==null?void 0:y.defaultDirection:void 0,oe=Le({viewName:d.name,supportsPagination:a,supportsSort:w}),ae=w?` const orderBy = resolveRecordsOrderBy(
|
|
83
85
|
recordsSortFieldsForView.${d.name},
|
|
84
86
|
params.sort,
|
|
85
|
-
${x(
|
|
87
|
+
${x(Y,e)},
|
|
86
88
|
${x(te,e)},
|
|
87
89
|
);
|
|
88
|
-
`:"",
|
|
89
|
-
`:"",ie=
|
|
90
|
+
`:"",se=w?` ...(orderBy ? { orderBy } : {}),
|
|
91
|
+
`:"",ie=a?` pagination: resolveServerTablePagination(params, ${JSON.stringify(P)}),
|
|
90
92
|
`:"";return` ${d.name}(
|
|
91
93
|
params: ${oe} = {},
|
|
92
94
|
) {
|
|
93
|
-
${
|
|
94
|
-
...${x(
|
|
95
|
-
${
|
|
96
|
-
},`}if(
|
|
95
|
+
${ae} return semaphor.${p}({
|
|
96
|
+
...${x($,e)},
|
|
97
|
+
${se}${ie} });
|
|
98
|
+
},`}if(le(d)&&K(d)){const b=(I=d.raw.visualSpec)==null?void 0:I.tableBehavior,M=k($.pagination),a=((V=b==null?void 0:b.pagination)==null?void 0:V.pageSize)||W(M==null?void 0:M.pageSize)||W($.limit)||100;return` ${d.name}(
|
|
97
99
|
params: SemaphorGeneratedServerPaginationParams = {},
|
|
98
100
|
) {
|
|
99
|
-
return semaphor.${
|
|
100
|
-
...${x(
|
|
101
|
-
pagination: resolveServerTablePagination(params, ${JSON.stringify(
|
|
101
|
+
return semaphor.${p}({
|
|
102
|
+
...${x($,e)},
|
|
103
|
+
pagination: resolveServerTablePagination(params, ${JSON.stringify(a)}),
|
|
102
104
|
});
|
|
103
|
-
},`}return` ${d.name}: () => semaphor.${
|
|
104
|
-
`),
|
|
105
|
+
},`}return` ${d.name}: () => semaphor.${p}(${x($,e)}),`}).join(`
|
|
106
|
+
`),n=e.views.filter(d=>v(d)).map(d=>{const $=Z(d,e).map(s=>` ${JSON.stringify(s.key)}: fields.${s.fieldName},`).join(`
|
|
105
107
|
`);return` ${d.name}: {
|
|
106
|
-
${
|
|
108
|
+
${$}
|
|
107
109
|
},`}).join(`
|
|
108
|
-
`),t=e.views.filter(d=>
|
|
110
|
+
`),t=e.views.filter(d=>v(d)).map(d=>{const $=Z(d,e).map(s=>` { key: ${JSON.stringify(s.key)}, label: ${JSON.stringify(s.label)}, field: fields.${s.fieldName} },`).join(`
|
|
109
111
|
`);return` ${d.name}: [
|
|
110
|
-
${
|
|
112
|
+
${$}
|
|
111
113
|
],`}).join(`
|
|
112
|
-
`),o=e.views.some(d=>
|
|
113
|
-
`),
|
|
114
|
-
`);return`${
|
|
115
|
-
${
|
|
114
|
+
`),o=e.views.some(d=>v(d)),i=e.views.some(d=>K(d)),l=[r,n,t].join(`
|
|
115
|
+
`),f=[r?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,o?'import type { SemaphorFieldRef } from "react-semaphor/data-app-sdk";':void 0,l.includes("fields.")?'import { fields } from "./fields";':void 0,l.includes("sources.")?'import { sources } from "./sources";':void 0].filter(A).join(`
|
|
116
|
+
`);return`${T}
|
|
117
|
+
${f}
|
|
116
118
|
${o?`export type SemaphorGeneratedRecordsSortDirection = "asc" | "desc";
|
|
117
119
|
|
|
118
120
|
export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
@@ -123,17 +125,17 @@ export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
|
123
125
|
export type SemaphorGeneratedRecordsSortParams<TSortKey extends string = string> = {
|
|
124
126
|
sort?: SemaphorGeneratedRecordsSort<TSortKey> | null;
|
|
125
127
|
};
|
|
126
|
-
`:""}${
|
|
128
|
+
`:""}${i?`export type SemaphorGeneratedServerPaginationParams = {
|
|
127
129
|
page?: number;
|
|
128
130
|
pageSize?: number;
|
|
129
131
|
};
|
|
130
|
-
`:""}${o&&
|
|
132
|
+
`:""}${o&&i?`export type SemaphorGeneratedRecordsQueryParams<TSortKey extends string = string> =
|
|
131
133
|
SemaphorGeneratedServerPaginationParams &
|
|
132
134
|
SemaphorGeneratedRecordsSortParams<TSortKey>;
|
|
133
135
|
`:""}
|
|
134
136
|
|
|
135
137
|
export const recordsSortFieldsForView = {
|
|
136
|
-
${
|
|
138
|
+
${n}
|
|
137
139
|
} as const;
|
|
138
140
|
|
|
139
141
|
export const recordsSortOptionsForView = {
|
|
@@ -141,7 +143,7 @@ ${t}
|
|
|
141
143
|
} as const;
|
|
142
144
|
|
|
143
145
|
export const queries = {
|
|
144
|
-
${
|
|
146
|
+
${r}
|
|
145
147
|
} as const;
|
|
146
148
|
|
|
147
149
|
${o?`function resolveRecordsOrderBy<TSortKey extends string>(
|
|
@@ -164,7 +166,7 @@ ${o?`function resolveRecordsOrderBy<TSortKey extends string>(
|
|
|
164
166
|
};
|
|
165
167
|
}
|
|
166
168
|
`:""}
|
|
167
|
-
${
|
|
169
|
+
${i?`function resolveServerTablePagination(
|
|
168
170
|
params: SemaphorGeneratedServerPaginationParams,
|
|
169
171
|
defaultPageSize: number,
|
|
170
172
|
) {
|
|
@@ -174,29 +176,29 @@ ${a?`function resolveServerTablePagination(
|
|
|
174
176
|
};
|
|
175
177
|
}
|
|
176
178
|
`:""}
|
|
177
|
-
`}function
|
|
178
|
-
inputs.push(semaphor.bindInput(${
|
|
179
|
+
`}function Qe(e){var i,l;const r=k((i=e.raw.sdkSpec)==null?void 0:i.spec)||{},{kind:n,id:t,...o}=r;return{...o,id:e.raw.id,label:((l=e.raw.visualSpec)==null?void 0:l.title)||e.raw.title||o.label}}function Z(e,r){var i,l;const n=[],t=k((i=e.raw.sdkSpec)==null?void 0:i.spec)||{};for(const f of H(t.fields))S(n,f);S(n,t.dateField),S(n,(l=k(t.orderBy))==null?void 0:l.field);for(const f of e.raw.fields||[])S(n,f);return re(n.map(f=>{const F=C(f,r);if(!(!f.name||!F))return{key:F,fieldName:F,rawName:f.name,label:f.label||f.name}}).filter(A),f=>f.key)}function Ue({view:e,contract:r,sortFields:n,defaultField:t}){var F,m;const o=new Set(n.map(c=>c.key));if(t&&o.has(t))return t;const i=n.filter(c=>c.rawName===t);if(i.length===1)return i[0].key;const l=k((F=e.raw.sdkSpec)==null?void 0:F.spec),f=C((m=k(l==null?void 0:l.orderBy))==null?void 0:m.field,r);return f&&o.has(f)?f:void 0}function Le({viewName:e,supportsPagination:r,supportsSort:n}){return r&&n?`SemaphorGeneratedRecordsQueryParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>`:n?`SemaphorGeneratedRecordsSortParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>`:"SemaphorGeneratedServerPaginationParams"}function Je(e){const r=e.views.map(c=>{const u=ze(e,c.raw.id).map(d=>{const p=d.inputId,$=C(d.fieldRef,e);if(!p||!$)return"";const s=[`field: fields.${$}`];if(d.relationshipHint)s.push(`relationshipHint: ${N(d.relationshipHint)}`);else if(Array.isArray(d.relationshipsUsed)&&d.relationshipsUsed.length>0){const h=d.relationshipsUsed.map(y=>{var I;return(I=k(y))==null?void 0:I.id}).filter(y=>typeof y=="string"&&y.length>0);h.length>0&&s.push(`relationshipHint: ${N({relationshipIds:h})}`)}const g=`inputHandles[${JSON.stringify(p)}]`;return` if (${g}) {
|
|
180
|
+
inputs.push(semaphor.bindInput(${g}, { ${s.join(", ")} }));
|
|
179
181
|
}`}).filter(Boolean).join(`
|
|
180
|
-
`);return{view:
|
|
182
|
+
`);return{view:c,renderedBindings:u}}),n=r.some(c=>c.renderedBindings.length>0),t=r.map(({view:c,renderedBindings:O})=>{const u=O?"inputHandles":"_inputHandles";return` ${c.name}(${u}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
181
183
|
const inputs: SemaphorInputReference[] = [];
|
|
182
184
|
${O}
|
|
183
185
|
return inputs;
|
|
184
186
|
},`}).join(`
|
|
185
187
|
|
|
186
|
-
`),o=e.views.map(
|
|
188
|
+
`),o=e.views.map(c=>` ${c.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
187
189
|
return {
|
|
188
|
-
inputs: inputsForView.${
|
|
189
|
-
debug: queryDebugForView.${
|
|
190
|
+
inputs: inputsForView.${c.name}(inputHandles),
|
|
191
|
+
debug: queryDebugForView.${c.name},
|
|
190
192
|
};
|
|
191
193
|
},`).join(`
|
|
192
194
|
|
|
193
|
-
`),
|
|
194
|
-
return inputsForView.${
|
|
195
|
-
`),l=e.views.map(
|
|
196
|
-
return queryOptionsForView.${
|
|
197
|
-
`),
|
|
198
|
-
`);return`${
|
|
199
|
-
${
|
|
195
|
+
`),i=e.views.map(c=>` case ${JSON.stringify(c.raw.id)}:
|
|
196
|
+
return inputsForView.${c.name}(inputHandles);`).join(`
|
|
197
|
+
`),l=e.views.map(c=>` case ${JSON.stringify(c.raw.id)}:
|
|
198
|
+
return queryOptionsForView.${c.name}(inputHandles);`).join(`
|
|
199
|
+
`),f=e.views.length>0,F=f?"inputHandles":"_inputHandles",m=[n?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,'import type { SemaphorInputReference, SemaphorQueryRuntimeOptions } from "react-semaphor/data-app-sdk";',n?'import { fields } from "./fields";':void 0,'import type { SemaphorGeneratedInputHandleMap } from "./inputs";',f?'import { queryDebugForView } from "./metadata";':void 0,'import type { SemaphorGeneratedQueryViewId } from "./metadata";'].filter(A).join(`
|
|
200
|
+
`);return`${T}
|
|
201
|
+
${m}
|
|
200
202
|
|
|
201
203
|
export const inputsForView = {
|
|
202
204
|
${t}
|
|
@@ -208,91 +210,116 @@ ${o}
|
|
|
208
210
|
|
|
209
211
|
export function inputsForViewId(
|
|
210
212
|
viewId: SemaphorGeneratedQueryViewId,
|
|
211
|
-
${
|
|
213
|
+
${F}: SemaphorGeneratedInputHandleMap,
|
|
212
214
|
): SemaphorInputReference[] {
|
|
213
215
|
switch (viewId) {
|
|
214
|
-
${
|
|
216
|
+
${i}
|
|
215
217
|
}
|
|
216
218
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
export function queryOptionsForViewId(
|
|
220
222
|
viewId: SemaphorGeneratedQueryViewId,
|
|
221
|
-
${
|
|
223
|
+
${F}: SemaphorGeneratedInputHandleMap,
|
|
222
224
|
): SemaphorQueryRuntimeOptions {
|
|
223
225
|
switch (viewId) {
|
|
224
226
|
${l}
|
|
225
227
|
}
|
|
226
228
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
227
229
|
}
|
|
228
|
-
`}function
|
|
229
|
-
`);return` ${
|
|
230
|
-
${
|
|
230
|
+
`}function ze(e,r){return e.filterContracts.flatMap(n=>(n.bindings||[]).filter(t=>t.viewId===r).map(t=>({inputId:n.inputId,fieldRef:t.fieldRef,relationshipHint:t.relationshipHint,relationshipsUsed:t.relationshipsUsed})))}function Ye(e){const r=e.views.map(s=>{const h=U(s,e).map(y=>{const I=C(y.raw,e);return I?` ${y.name}: fields.${I},`:""}).filter(Boolean).join(`
|
|
231
|
+
`);return` ${s.name}: {
|
|
232
|
+
${h}
|
|
231
233
|
},`}).join(`
|
|
232
|
-
`),
|
|
233
|
-
`);return` ${
|
|
234
|
-
${
|
|
234
|
+
`),n=e.views.map(s=>{const h=B(s,e).map(y=>{const I=C(y.raw,e);return I?` ${y.name}: fields.${I},`:""}).filter(Boolean).join(`
|
|
235
|
+
`);return` ${s.name}: {
|
|
236
|
+
${h}
|
|
235
237
|
},`}).join(`
|
|
236
|
-
`),t=e.views.map(
|
|
237
|
-
`);return` ${
|
|
238
|
-
${
|
|
238
|
+
`),t=e.views.map(s=>{const g=B(s,e),h=tr(g),y=nr(g),I=g.map(V=>{const b=Array.from(new Set(Se(V.raw).filter(M=>y.has(M))));return` ${V.name}: metricKeysForField(metricFieldsForView.${s.name}.${V.name}, { allowNameFallback: ${h.has(V.raw.name)?"false":"true"}, excludedKeys: ${N(b)} }),`}).join(`
|
|
239
|
+
`);return` ${s.name}: {
|
|
240
|
+
${I}
|
|
239
241
|
},`}).join(`
|
|
240
|
-
`),o=e.views.map(
|
|
241
|
-
`);return` ${
|
|
242
|
-
${
|
|
242
|
+
`),o=e.views.map(s=>{const h=B(s,e).map((y,I)=>` ${y.name}: ${JSON.stringify(er(s,y,I))},`).join(`
|
|
243
|
+
`);return` ${s.name}: {
|
|
244
|
+
${h}
|
|
243
245
|
},`}).join(`
|
|
244
|
-
`),
|
|
246
|
+
`),i=e.views.map(s=>{const g=B(s,e);if(g.length===0)return` ${s.name}(): Record<keyof typeof metricFieldsForView.${s.name}, unknown> {
|
|
245
247
|
return {};
|
|
246
|
-
},`;const
|
|
247
|
-
`);return` ${
|
|
248
|
+
},`;const h=rr(s,g),y=g.map(I=>{const V=`metricMeasureKeysForView.${s.name}.${I.name}`,b=`metricMeasureBindingKeysForView.${s.name}.${I.name}`,M=h.has(I.name)?`readMetricValueByBindingWithFallback(measures, measureBindings, ${b}, ${V}, primaryValue)`:`readMetricValueByBinding(measures, measureBindings, ${b}, ${V})`;return` ${I.name}: ${M},`}).join(`
|
|
249
|
+
`);return` ${s.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${s.name}, unknown> {
|
|
248
250
|
const measures = result?.measures;
|
|
249
251
|
const measureBindings = result?.measureBindings;
|
|
250
252
|
const primaryValue = result?.primaryValue;
|
|
251
253
|
return {
|
|
252
|
-
${
|
|
254
|
+
${y}
|
|
253
255
|
};
|
|
254
256
|
},`}).join(`
|
|
255
257
|
|
|
256
|
-
`),l=e.views.map(
|
|
258
|
+
`),l=e.views.map(s=>{const g=B(s,e);if(g.length===0)return` ${s.name}(): Array<keyof typeof metricFieldsForView.${s.name}> {
|
|
257
259
|
return [];
|
|
258
|
-
},`;const
|
|
259
|
-
`);return` ${
|
|
260
|
+
},`;const h=g.map(y=>` ...(missing.has(metricMeasureBindingKeysForView.${s.name}.${y.name}) ? [${JSON.stringify(y.name)} as keyof typeof metricFieldsForView.${s.name}] : []),`).join(`
|
|
261
|
+
`);return` ${s.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${s.name}> {
|
|
260
262
|
const missing = new Set(result?.missingMeasures || []);
|
|
261
263
|
return [
|
|
262
|
-
${
|
|
264
|
+
${h}
|
|
263
265
|
];
|
|
264
266
|
},`}).join(`
|
|
265
267
|
|
|
266
|
-
`),
|
|
267
|
-
`)
|
|
268
|
-
|
|
268
|
+
`),f=e.views.map(s=>{const g=B(s,e);if(g.length===0)return"";const h=g[0],y=g.map(V=>`{ key: ${JSON.stringify(V.name)}, label: ${JSON.stringify(V.raw.label||V.raw.name)} }`).join(", "),I=g.filter(V=>V.name!==h.name).map(V=>` if (missing.includes(${JSON.stringify(V.name)})) delete values.${V.name};`).join(`
|
|
269
|
+
`);return` ${s.name}(result: SemaphorGeneratedMetricResult): SemaphorGeneratedKpiProps {
|
|
270
|
+
const values = mapMetricDisplayValues(metricValuesForView.${s.name}(result));
|
|
271
|
+
const missing = missingMetricMeasuresForView.${s.name}(result).map((key) => String(key));
|
|
272
|
+
const primaryMissing = missing.includes(${JSON.stringify(h.name)});
|
|
273
|
+
const primaryValue = primaryMissing ? result?.primaryValue : values.${h.name};
|
|
274
|
+
if (primaryMissing) values.${h.name} = metricDisplayValue(result?.primaryValue);
|
|
275
|
+
${I}
|
|
276
|
+
return {
|
|
277
|
+
result: {
|
|
278
|
+
...(result || {}),
|
|
279
|
+
value: metricDisplayValue(result?.value),
|
|
280
|
+
primaryValue: metricDisplayValue(result?.primaryValue),
|
|
281
|
+
comparisonValue: metricDisplayValue(result?.comparisonValue),
|
|
282
|
+
measures: values,
|
|
283
|
+
},
|
|
284
|
+
title: ${JSON.stringify(s.raw.title||s.raw.id)},
|
|
285
|
+
label: ${JSON.stringify(h.raw.label||h.raw.name)},
|
|
286
|
+
value: metricDisplayValue(primaryValue),
|
|
287
|
+
measures: [${y}],
|
|
288
|
+
missingMeasures: missing,
|
|
289
|
+
showComparison: Boolean(result?.comparisonKind),
|
|
290
|
+
};
|
|
291
|
+
},`}).filter(Boolean).join(`
|
|
292
|
+
|
|
293
|
+
`),F=e.views.map(s=>{const g=We(s,e);return` ${s.name}: ${N(g)},`}).join(`
|
|
294
|
+
`),m=e.views.map(s=>{const h=U(s,e).map(y=>` ${y.name}: resolveColumnKey(columns, fieldsForView.${s.name}.${y.name}),`).join(`
|
|
295
|
+
`);return` ${s.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${s.name}, string | undefined> {
|
|
269
296
|
return {
|
|
270
|
-
${
|
|
297
|
+
${h}
|
|
271
298
|
};
|
|
272
299
|
},`}).join(`
|
|
273
300
|
|
|
274
|
-
`),
|
|
275
|
-
`);return` ${
|
|
301
|
+
`),c=e.views.map(s=>{const h=U(s,e).map(y=>` ${y.name}: readCell(row, columns, fieldsForView.${s.name}.${y.name}),`).join(`
|
|
302
|
+
`);return` ${s.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${s.name}, unknown> {
|
|
276
303
|
return {
|
|
277
|
-
${
|
|
304
|
+
${h}
|
|
278
305
|
};
|
|
279
306
|
},`}).join(`
|
|
280
307
|
|
|
281
|
-
`),
|
|
282
|
-
return (result?.records || []).map((row) => rowValuesForView.${
|
|
308
|
+
`),O=e.views.map(s=>` ${s.name}(result: SemaphorGeneratedRecordsResult): Array<Record<keyof typeof fieldsForView.${s.name}, unknown>> {
|
|
309
|
+
return (result?.records || []).map((row) => rowValuesForView.${s.name}(row, result?.columns));
|
|
283
310
|
},`).join(`
|
|
284
311
|
|
|
285
|
-
`),
|
|
286
|
-
`);return` ${
|
|
287
|
-
const values = rowValuesForView.${
|
|
312
|
+
`),u=e.views.map(s=>{const g=U(s,e),h=g.filter(w=>w.raw.role==="dimension"),y=g.filter(w=>w.raw.role==="measure"),I=h[0],V=h[1],b=y[0],M=y[1],a=[I?` primaryDimension: values.${I.name},`:" primaryDimension: undefined,",V?` secondaryDimension: values.${V.name},`:" secondaryDimension: undefined,",b?` primaryMeasure: values.${b.name},`:" primaryMeasure: undefined,",M?` secondaryMeasure: values.${M.name},`:" secondaryMeasure: undefined,"].join(`
|
|
313
|
+
`);return` ${s.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): SemaphorGeneratedRoleValues {
|
|
314
|
+
const values = rowValuesForView.${s.name}(row, columns);
|
|
288
315
|
return {
|
|
289
|
-
${
|
|
316
|
+
${a}
|
|
290
317
|
};
|
|
291
318
|
},`}).join(`
|
|
292
319
|
|
|
293
|
-
`),
|
|
294
|
-
`);return`${
|
|
295
|
-
${
|
|
320
|
+
`),d=r.includes("fields.")||n.includes("fields."),$=[`import { ${["type SemaphorFieldRef","type SemaphorResultColumn"].filter(A).join(", ")} } from "react-semaphor/data-app-sdk";`,d?'import { fields } from "./fields";':void 0].filter(A).join(`
|
|
321
|
+
`);return`${T}
|
|
322
|
+
${$}
|
|
296
323
|
|
|
297
324
|
export type SemaphorGeneratedRow = Record<string, unknown>;
|
|
298
325
|
export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
|
|
@@ -302,12 +329,17 @@ export type SemaphorGeneratedRecordsResult = {
|
|
|
302
329
|
} | null | undefined;
|
|
303
330
|
export type SemaphorGeneratedMetricMeasures = Record<string, unknown> | null | undefined;
|
|
304
331
|
export type SemaphorGeneratedMetricMeasureBindings = Record<string, string> | null | undefined;
|
|
332
|
+
export type SemaphorGeneratedMetricValue = number | string | null;
|
|
305
333
|
export type SemaphorGeneratedMetricResult = {
|
|
306
334
|
readonly measures?: SemaphorGeneratedMetricMeasures;
|
|
307
335
|
readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
|
|
308
336
|
readonly missingMeasures?: readonly string[];
|
|
309
337
|
readonly primaryValue: unknown;
|
|
310
338
|
readonly value?: unknown;
|
|
339
|
+
readonly comparisonKind?: string;
|
|
340
|
+
readonly comparisonValue?: unknown;
|
|
341
|
+
readonly delta?: number | null;
|
|
342
|
+
readonly deltaPercent?: number | null;
|
|
311
343
|
} | null | undefined;
|
|
312
344
|
export type SemaphorGeneratedRoleValues = {
|
|
313
345
|
readonly primaryDimension: unknown;
|
|
@@ -322,13 +354,36 @@ export type SemaphorGeneratedTableColumn = {
|
|
|
322
354
|
readonly sortable?: boolean;
|
|
323
355
|
readonly sortKey?: string;
|
|
324
356
|
};
|
|
357
|
+
export type SemaphorGeneratedKpiResult<TValues extends Record<string, SemaphorGeneratedMetricValue> = Record<string, SemaphorGeneratedMetricValue>> =
|
|
358
|
+
Record<string, unknown> & {
|
|
359
|
+
readonly value?: SemaphorGeneratedMetricValue;
|
|
360
|
+
readonly primaryValue?: SemaphorGeneratedMetricValue;
|
|
361
|
+
readonly comparisonValue?: SemaphorGeneratedMetricValue;
|
|
362
|
+
readonly comparisonKind?: string;
|
|
363
|
+
readonly delta?: number | null;
|
|
364
|
+
readonly deltaPercent?: number | null;
|
|
365
|
+
readonly measures: TValues;
|
|
366
|
+
};
|
|
367
|
+
export type SemaphorGeneratedKpiMeasureConfig = {
|
|
368
|
+
key: string;
|
|
369
|
+
label: string;
|
|
370
|
+
};
|
|
371
|
+
export type SemaphorGeneratedKpiProps = {
|
|
372
|
+
readonly result: SemaphorGeneratedKpiResult;
|
|
373
|
+
readonly title: string;
|
|
374
|
+
readonly label: string;
|
|
375
|
+
readonly value: SemaphorGeneratedMetricValue;
|
|
376
|
+
readonly measures: SemaphorGeneratedKpiMeasureConfig[];
|
|
377
|
+
readonly missingMeasures: readonly string[];
|
|
378
|
+
readonly showComparison: boolean;
|
|
379
|
+
};
|
|
325
380
|
|
|
326
381
|
export const fieldsForView = {
|
|
327
|
-
${
|
|
382
|
+
${r}
|
|
328
383
|
} as const;
|
|
329
384
|
|
|
330
385
|
export const metricFieldsForView = {
|
|
331
|
-
${
|
|
386
|
+
${n}
|
|
332
387
|
} as const;
|
|
333
388
|
|
|
334
389
|
export const metricMeasureKeysForView = {
|
|
@@ -340,33 +395,37 @@ ${o}
|
|
|
340
395
|
} as const;
|
|
341
396
|
|
|
342
397
|
export const tableColumnsForView = {
|
|
343
|
-
${
|
|
398
|
+
${F}
|
|
344
399
|
} as const;
|
|
345
400
|
|
|
346
401
|
export const columnKeysForView = {
|
|
347
|
-
${
|
|
402
|
+
${m}
|
|
348
403
|
} as const;
|
|
349
404
|
|
|
350
405
|
export const rowValuesForView = {
|
|
351
|
-
${
|
|
406
|
+
${c}
|
|
352
407
|
} as const;
|
|
353
408
|
|
|
354
409
|
export const rowsForView = {
|
|
355
|
-
${
|
|
410
|
+
${O}
|
|
356
411
|
} as const;
|
|
357
412
|
|
|
358
413
|
export const roleValuesForView = {
|
|
359
|
-
${
|
|
414
|
+
${u}
|
|
360
415
|
} as const;
|
|
361
416
|
|
|
362
417
|
export const metricValuesForView = {
|
|
363
|
-
${
|
|
418
|
+
${i}
|
|
364
419
|
} as const;
|
|
365
420
|
|
|
366
421
|
export const missingMetricMeasuresForView = {
|
|
367
422
|
${l}
|
|
368
423
|
} as const;
|
|
369
424
|
|
|
425
|
+
export const kpiPropsForView = {
|
|
426
|
+
${f}
|
|
427
|
+
} as const;
|
|
428
|
+
|
|
370
429
|
export function resolveColumnKey(
|
|
371
430
|
columns: SemaphorGeneratedColumns,
|
|
372
431
|
field: SemaphorFieldRef,
|
|
@@ -486,6 +545,26 @@ export function readStringMetricValue(
|
|
|
486
545
|
return value === null || value === undefined ? "" : String(value);
|
|
487
546
|
}
|
|
488
547
|
|
|
548
|
+
export function mapMetricDisplayValues(
|
|
549
|
+
values: Record<string, unknown>,
|
|
550
|
+
): Record<string, SemaphorGeneratedMetricValue> {
|
|
551
|
+
return Object.fromEntries(
|
|
552
|
+
Object.entries(values)
|
|
553
|
+
.map(([key, value]) => [key, metricDisplayValue(value)] as const)
|
|
554
|
+
.filter(([key]) => values[key] !== undefined),
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export function metricDisplayValue(value: unknown): SemaphorGeneratedMetricValue {
|
|
559
|
+
if (value === null || value === undefined) {
|
|
560
|
+
return null;
|
|
561
|
+
}
|
|
562
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
563
|
+
return value;
|
|
564
|
+
}
|
|
565
|
+
return String(value);
|
|
566
|
+
}
|
|
567
|
+
|
|
489
568
|
export function metricKeysForField(
|
|
490
569
|
field: SemaphorFieldRef,
|
|
491
570
|
options: { allowNameFallback?: boolean; excludedKeys?: readonly string[] } = {},
|
|
@@ -505,11 +584,15 @@ export function metricKeysForField(
|
|
|
505
584
|
}
|
|
506
585
|
|
|
507
586
|
function metricQualifiedKeyForField(field: SemaphorFieldRef): string {
|
|
508
|
-
return
|
|
587
|
+
return [
|
|
588
|
+
field.source ? sourceIdentityKey(field.source as Record<string, unknown>) : "unknown",
|
|
589
|
+
metricAggregateForField(field),
|
|
590
|
+
field.name,
|
|
591
|
+
].filter(Boolean).join(":");
|
|
509
592
|
}
|
|
510
593
|
|
|
511
594
|
function metricAggregateForField(field: SemaphorFieldRef): string {
|
|
512
|
-
return
|
|
595
|
+
return (field.aggregate || "SUM").toUpperCase();
|
|
513
596
|
}
|
|
514
597
|
|
|
515
598
|
function metricKeyPrefixesForSource(
|
|
@@ -550,6 +633,35 @@ function metricKeyPrefixesForSource(
|
|
|
550
633
|
return [];
|
|
551
634
|
}
|
|
552
635
|
|
|
636
|
+
function sourceIdentityKey(source: Record<string, unknown>): string {
|
|
637
|
+
const kind = stringProperty(source, "kind");
|
|
638
|
+
if (kind === "semantic") {
|
|
639
|
+
const datasetId = stringProperty(source, "datasetId");
|
|
640
|
+
return [
|
|
641
|
+
kind,
|
|
642
|
+
stringProperty(source, "domainId") || "",
|
|
643
|
+
datasetId
|
|
644
|
+
? \`datasetId:\${datasetId}\`
|
|
645
|
+
: \`datasetName:\${stringProperty(source, "datasetName") || ""}\`,
|
|
646
|
+
].join(":");
|
|
647
|
+
}
|
|
648
|
+
if (kind === "physical") {
|
|
649
|
+
return [
|
|
650
|
+
kind,
|
|
651
|
+
stringProperty(source, "connectionId") || "",
|
|
652
|
+
stringProperty(source, "databaseName") || "",
|
|
653
|
+
stringProperty(source, "schemaName") || "",
|
|
654
|
+
stringProperty(source, "tableName") || "",
|
|
655
|
+
].join(":");
|
|
656
|
+
}
|
|
657
|
+
return [
|
|
658
|
+
kind || "unknown",
|
|
659
|
+
stringProperty(source, "connectionId") || "",
|
|
660
|
+
stringProperty(source, "dialect") || "",
|
|
661
|
+
stringProperty(source, "label") || "",
|
|
662
|
+
].join(":");
|
|
663
|
+
}
|
|
664
|
+
|
|
553
665
|
function stringProperty(record: Record<string, unknown>, key: string): string | undefined {
|
|
554
666
|
const value = record[key];
|
|
555
667
|
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -661,13 +773,13 @@ function sourcesReferToSameDataset(
|
|
|
661
773
|
}
|
|
662
774
|
return false;
|
|
663
775
|
}
|
|
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 = ${
|
|
776
|
+
`}function We(e,r){const n=U(e,r),t=new Map((v(e)?Z(e,r):[]).map(o=>[o.fieldName,o.key]));return n.map(o=>{const i=C(o.raw,r),l=i?t.get(i):void 0;return G({key:o.name,label:o.raw.label||o.raw.name,dataType:o.raw.dataType,sortable:!!l,sortKey:l})})}function Ze(e){const r=e.checklist.filterScopeByInput||[],n=e.checklist.requiredDevtools||{},t=e.summary.views.map(u=>u.id).filter(Boolean),o=e.views.map(u=>u.raw.id).filter(Boolean),i=e.inputs.map(u=>u.raw.id).filter(Boolean),l=e.optionQueries.map(u=>u.raw.id||`${u.input.raw.id}-options`).filter(Boolean),f=Object.fromEntries(o.map(u=>[u,e.filterContracts.filter(d=>Array.isArray(d.appliesToViewIds)&&d.appliesToViewIds.includes(u)).map(d=>d.inputId)])),F=Object.fromEntries(e.views.map(u=>[u.raw.id,{title:u.raw.title,visual:u.raw.visual,visualSpec:u.raw.visualSpec,queryKind:u.raw.queryKind,sdkBuilder:u.raw.sdkBuilder}])),m=Object.fromEntries(e.views.map(u=>{var d;return[u.raw.id,G({viewId:u.raw.id,queryId:u.name,title:u.raw.title,visualType:((d=u.raw.visualSpec)==null?void 0:d.visualType)||u.raw.visual,suggestedComponentName:ye(u.raw.title||u.raw.id||u.name),marker:{attribute:"data-semaphor-view-id",value:u.raw.id}})]})),c=Object.fromEntries(e.inputs.map(u=>{var d;return[u.raw.id,G({inputId:u.raw.id,label:u.raw.label,type:u.raw.type,optionQueryId:((d=u.raw.optionQuery)==null?void 0:d.id)||(u.raw.optionQuery?`${u.raw.id}-options`:void 0),suggestedComponentName:ye(u.raw.label||u.raw.id||u.name),marker:{attribute:"data-semaphor-input-id",value:u.raw.id}})]})),O=Object.fromEntries(e.views.map(u=>{var d,p,$;return[u.name,G({viewId:u.raw.id,viewTitle:((d=u.raw.visualSpec)==null?void 0:d.title)||u.raw.title,visualType:(p=u.raw.visualSpec)==null?void 0:p.visualType,title:(($=u.raw.visualSpec)==null?void 0:$.title)||u.raw.title})]}));return`${T}
|
|
777
|
+
export const generatedViewIds = ${N(t)} as const;
|
|
778
|
+
export const generatedQueryViewIds = ${N(o)} as const;
|
|
779
|
+
export const generatedInputIds = ${N(i)} as const;
|
|
780
|
+
export const generatedInputOptionQueryIds = ${N(l)} as const;
|
|
781
|
+
export const generatedViewAuthoring = ${N(m)} as const;
|
|
782
|
+
export const generatedInputAuthoring = ${N(c)} as const;
|
|
671
783
|
|
|
672
784
|
export type SemaphorGeneratedViewId = typeof generatedViewIds[number];
|
|
673
785
|
export type SemaphorGeneratedQueryViewId = typeof generatedQueryViewIds[number];
|
|
@@ -686,8 +798,8 @@ export type SemaphorGeneratedFilterContract = {
|
|
|
686
798
|
readonly [key: string]: unknown;
|
|
687
799
|
};
|
|
688
800
|
|
|
689
|
-
export const generatedInputIdsForView = ${
|
|
690
|
-
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${
|
|
801
|
+
export const generatedInputIdsForView = ${N(f)} as const;
|
|
802
|
+
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${N(e.filterContracts)} as const;
|
|
691
803
|
|
|
692
804
|
export function semaphorViewMarkerProps(viewId: SemaphorGeneratedViewId) {
|
|
693
805
|
return {
|
|
@@ -707,10 +819,10 @@ export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
|
707
819
|
);
|
|
708
820
|
}
|
|
709
821
|
|
|
710
|
-
export const queryDebugForView = ${
|
|
822
|
+
export const queryDebugForView = ${N(O)} as const;
|
|
711
823
|
|
|
712
|
-
export const semaphorGeneratedContractMetadata = ${
|
|
713
|
-
`}function
|
|
824
|
+
export const semaphorGeneratedContractMetadata = ${N({schemaVersion:"semaphor-generated-data-app-contract/v1",title:e.title,requiredDevtools:n,filterContracts:e.filterContracts,filterScopeByInput:r,generatedViewIds:t,generatedQueryViewIds:o,generatedInputIds:i,generatedInputOptionQueryIds:l,generatedInputIdsForView:f,generatedViewAuthoring:m,generatedInputAuthoring:c,visualSpecs:F,presentationViews:e.presentationViews})} as const;
|
|
825
|
+
`}function Xe(){return`${T}
|
|
714
826
|
export * from "./sources";
|
|
715
827
|
export * from "./fields";
|
|
716
828
|
export * from "./inputs";
|
|
@@ -718,4 +830,4 @@ export * from "./queries";
|
|
|
718
830
|
export * from "./bindings";
|
|
719
831
|
export * from "./accessors";
|
|
720
832
|
export * from "./metadata";
|
|
721
|
-
`}function
|
|
833
|
+
`}function D(e,r){if(!(!r||typeof r!="object")){if(Array.isArray(r)){for(const n of r)D(e,n);return}E(r)&&S(e,J(r));for(const n of Object.values(r))D(e,n)}}function U(e,r){const n=[];if(or(n,e.raw.sdkSpec),n.length===0)for(const o of e.raw.fields||[])S(n,o);const t=re(n.filter(o=>o.name&&C(o,r)).map(o=>({raw:o,key:z(o),name:""})),o=>o.key);return _(t,o=>j(o.raw.label||o.raw.name||"field")),t}function B(e,r){if(q(e.raw.sdkSpec.builder)!=="metric")return[];const n=k(e.raw.sdkSpec.spec),t=[];S(t,n==null?void 0:n.primaryMeasure);for(const i of H(n==null?void 0:n.measures))S(t,i);const o=re(t.filter(i=>i.name&&C(i,r)).map(i=>({raw:i,key:z(i),name:""})),i=>i.key);return _(o,i=>j(i.raw.label||i.raw.name||"metric")),o}function er(e,r,n){var o;const t=(o=e.raw.metricBindingKeys)==null?void 0:o[n];if(typeof t=="string"&&t.trim())return t;throw new Error(`views.${e.raw.id}.metricBindingKeys must include a binding key for metric field ${r.raw.name}.`)}function rr(e,r){if(r.length===1)return new Set([r[0].name]);const n=k(e.raw.sdkSpec.spec);if(!E(n==null?void 0:n.primaryMeasure))return new Set;const t=z(J(n.primaryMeasure)),o=r.find(i=>i.key===t);return o?new Set([o.name]):new Set}function nr(e){const r=new Map;for(const n of e)for(const t of new Set(Se(n.raw)))r.set(t,(r.get(t)||0)+1);return new Set(Array.from(r.entries()).filter(([,n])=>n>1).map(([n])=>n))}function Se(e){const r=L.semaphorMetricAggregate(e);return Q([`${r.toLowerCase()}_${e.name}`,`${r}_${e.name}`,`${e.name}_${r.toLowerCase()}`,`${e.name}_${r}`,e.name])}function tr(e){const r=new Map;for(const n of e)r.set(n.raw.name,(r.get(n.raw.name)||0)+1);return new Set(Array.from(r.entries()).filter(([,n])=>n>1).map(([n])=>n))}function or(e,r){const n=k(r.spec);if(!n)return;const t=q(r.builder);if(t==="records"){for(const o of H(n.fields))S(e,o);return}if(t==="sql"){for(const o of H(n.fields))S(e,o);return}if(t==="analysis"||t==="metric"){S(e,n.primaryMeasure);for(const o of H(n.measures))S(e,o);for(const o of H(n.dimensions))S(e,o);S(e,n.dateField);return}if(t==="matrix"){const o=ce(n.rows),i=ce(n.columns),l=H(n.values);for(const f of o)me(e,f);for(const f of i)me(e,f);for(const f of l){const F=k(f);S(e,F==null?void 0:F.field),S(e,F==null?void 0:F.measure)}}}function ce(e){if(Array.isArray(e))return e;const r=k(e);return Array.isArray(r==null?void 0:r.levels)?r.levels:[]}function me(e,r){var n;if(E(r)){S(e,r);return}S(e,(n=k(r))==null?void 0:n.field)}function fe(e){var r,n,t,o;return((r=e==null?void 0:e.computation)==null?void 0:r.kind)==="presentation_only"||((n=e==null?void 0:e.computation)==null?void 0:n.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 ar(e){const r=k(e)||{};return G({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:r.sourceViewIds,content:r.content,description:r.description})}function S(e,r){E(r)&&e.push(J(r))}function J(e){return{name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate,sourceKey:e.sourceKey||(e.source?pe(e.source):void 0),...e.source?{source:e.source}:{}}}function sr(e){if(!e.source)return;const r={...e.source,...e.sourceKey?{sourceKey:e.sourceKey}:{}},n=Ie(r);if(n)return{raw:r,key:n,aliases:Fe(r),name:""}}function E(e){const r=k(e);return!!(r&&typeof r.name=="string"&&(typeof r.role=="string"||typeof r.dataType=="string"||typeof r.aggregate=="string"||r.source||r.sourceKey))}function we(e){const r=k(e);return!!(r&&(typeof r.sourceKey=="string"||r.kind==="semantic"||typeof r.datasetName=="string"&&typeof r.domainId=="string"))}function x(e,r){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=>x(o,r)).join(", ")}]`;if(E(e)){const o=C(J(e),r);if(o)return`fields.${o}`}if(we(e)){const o=$e(e,r);if(o)return`sources.${o}`}const n=k(e);return n?`{ ${Object.entries(n).filter(([,o])=>o!==void 0).map(([o,i])=>`${JSON.stringify(o)}: ${x(i,r)}`).join(", ")} }`:JSON.stringify(e)}function N(e){return JSON.stringify(e,null,2)}function C(e,r){if(E(e))return r.fieldNameByKey.get(z(J(e)))}function $e(e,r){if(we(e))for(const n of ee(e)){const t=r.sourceNameByKey.get(n);if(t)return t}}function z(e){return[e.sourceKey||"",e.name||"",e.role||"",e.aggregate||""].join("|")}function ir(e,r){return!E(e)||!E(r)||e.name!==r.name?!1:de(e).some(n=>de(r).includes(n))}function ur(e){return E(e)&&e.role==="id"}function dr(e){const r=[],n=new Map;for(const t of e){const o=Q(t.aliases.length?t.aliases:[t.key]),i=o.map(l=>n.get(l)).find(A);if(i){i.aliases=Q([...i.aliases,...o]);continue}t.aliases=o,r.push(t);for(const l of o)n.set(l,t)}return r}function lr(e){const r=new Map;for(const n of e)for(const t of Q([n.key,...n.aliases])){const o=r.get(t);if(o&&o!==n.name)throw new Error(`Source identity ${t} resolves to multiple generated sources.`);r.set(t,n.name)}return r}function Q(e){return Array.from(new Set(e.filter(Boolean)))}function Ie(e){return ee(e)[0]||pe(e)}function ee(e){const r=k(e);if(!r)return[];const n=[];if(typeof r.sourceKey=="string"&&n.push(r.sourceKey),r.kind==="semantic"||r.datasetName){const t=typeof r.domainId=="string"?r.domainId:"";t&&typeof r.datasetId=="string"&&n.push(`semantic:${t}:datasetId:${r.datasetId}`),t&&typeof r.datasetName=="string"&&n.push(`semantic:${t}:datasetName:${r.datasetName}`)}return n.length===0&&n.push(pe(e)),Q(n)}function Fe(e){return ee(e)}function pe(e){const r=k(e);return r?typeof r.sourceKey=="string"?r.sourceKey:JSON.stringify(r):""}function pr(e){return E(e)&&de(e)[0]||""}function de(e){return E(e)?Q([...typeof e.sourceKey=="string"?[e.sourceKey]:[],...e.source?ee(e.source):[]]):[]}function q(e){const r=String(e||"").replace(/^semaphor\./,"");if(!["metric","records","analysis","matrix","sql"].includes(r))throw new Error(`Unsupported sdkSpec builder: ${e}`);return r}function cr(e){const r=q(e);return r==="records"||r==="sql"}function mr(e){const r=k(e);return typeof(r==null?void 0:r.operator)=="string"?r.operator:e.type==="date_range"?"between":e.type==="multi_select"||e.type==="select"?"in":"="}function _(e,r){const n=new Map;for(const t of e){const o=r(t)||"item",i=n.get(o)||0;n.set(o,i+1),t.name=i===0?o:`${o}${i+1}`}}function re(e,r){const n=new Set,t=[];for(const o of e){const i=r(o);!i||n.has(i)||(n.add(i),t.push(o))}return t}function j(e){const r=String(e||"").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);if(r.length===0)return"item";const[n,...t]=r,o=[n.toLowerCase(),...t.map(i=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase())].join("");return/^[A-Za-z_$]/.test(o)?o:`item${o}`}function ye(e){const r=j(e);return r.charAt(0).toUpperCase()+r.slice(1)}function fr(e){const r=String(e).split(":");return r[r.length-1]||String(e)}function G(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}function k(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function H(e){return Array.isArray(e)?e:[]}function W(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function A(e){return e!==void 0}exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=L.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=L.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=L.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=L.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=Re;exports.generateSemaphorDataAppContract=Me;
|