react-semaphor 0.1.418 → 0.1.419
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 +2 -2
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +2 -2
- package/dist/chunks/{analyze-result-contract-Akysi2ML.js → analyze-result-contract-DdhEt99q.js} +46 -45
- package/dist/chunks/{analyze-result-contract-COjyJzYm.js → analyze-result-contract-DwRzl7yJ.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-BbuLgela.js → calendar-preferences-dialog-DIfAbE_y.js} +3 -3
- package/dist/chunks/{calendar-preferences-dialog-CInkkhl_.js → calendar-preferences-dialog-f0Z7Kf-U.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-B4OWNsVD.js → dashboard-briefing-launcher-C3tNkGFG.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-D7FNuDuc.js → dashboard-briefing-launcher-anh-Jy5v.js} +4 -4
- package/dist/chunks/{dashboard-controls-DcX7Mid4.js → dashboard-controls-8dCQaPaq.js} +5 -5
- package/dist/chunks/{dashboard-controls-DTC1eCz0.js → dashboard-controls-DQxlOxzy.js} +1 -1
- package/dist/chunks/{dashboard-json-vu38P5pV.js → dashboard-json-B309EInF.js} +1 -1
- package/dist/chunks/{dashboard-json-BHWbQS6I.js → dashboard-json-i7Ae9KGD.js} +3 -3
- package/dist/chunks/{edit-dashboard-visual-CkBhJBhp.js → edit-dashboard-visual-4HycwBHR.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DsCr90_3.js → edit-dashboard-visual-z3IqzYnj.js} +4 -4
- package/dist/chunks/{index-C56DuHI8.js → index-B6DLEXRX.js} +5 -5
- package/dist/chunks/{index-C8thRvkW.js → index-yxKWKFdr.js} +2 -2
- package/dist/chunks/{switch-Dsx-IwBE.js → switch-COWQU8aK.js} +1 -1
- package/dist/chunks/{switch-BXuyni6l.js → switch-D6Ygf3wA.js} +1 -1
- package/dist/chunks/{update-policy-B5S_LfEu.js → update-policy-BzT2k4n6.js} +1 -1
- package/dist/chunks/{update-policy-BqBKUk3Q.js → update-policy-VloD-0YM.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-CzftV84t.js → use-create-flow-overlay-state-CX0D-6HM.js} +3 -3
- package/dist/chunks/{use-create-flow-overlay-state-BDv_VpL6.js → use-create-flow-overlay-state-DENfd7sW.js} +1 -1
- package/dist/chunks/{validators-CPFcUMrV.js → validators-BMQo93Y0.js} +1 -1
- package/dist/chunks/{validators-CLzrE2N_.js → validators-Cxr9qbrR.js} +1 -1
- 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 +2 -2
- 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 +123 -92
- package/dist/data-app-codegen-node/index.js +461 -422
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +193 -188
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +1 -1
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +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 +4 -0
- package/dist/types/dashboard-assistant.d.ts +1 -0
- package/dist/types/data-app-sdk-validation.d.ts +1 -0
- package/dist/types/data-app-sdk.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("../chunks/analyze-result-contract-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("../chunks/analyze-result-contract-DwRzl7yJ.js"),R=require("../chunks/update-policy-VloD-0YM.js"),ge=require("node:crypto"),ke="src/semaphor/generated",K=`// 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:
|
|
5
|
-
`);const r=e.views.find(f=>T(f));if(r)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView,
|
|
6
|
-
`);const t=e.views.find(f=>X(f)&&_(f));if(t)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView,
|
|
7
|
-
`);const o=e.views.find(f=>pe(f)&&_(f));if(o)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView,
|
|
8
|
-
`);const
|
|
3
|
+
`;function Me(e,n={}){R.assertValidCodegenSummary(e);const r=Ce(e);if(r.views.length===0&&!n.allowEmpty)throw new Error("Contract generation produced zero executable views. Stop and ask for a different domain/goal or semantic model improvement; pass --allow-empty only for an explicit model-gap report.");const t=Oe(r),o=Ee({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:Ge(r),warnings:r.warnings,stats:{inputCount:r.inputs.length,executableViewCount:r.views.length,presentationViewCount:r.presentationViews.length,queryCount:r.views.length,optionQueryCount:r.optionQueries.length}}}function Ce(e){var u,d,c,i,p,w,g,$,F,M,V,C;const n=[],r=[];for(const s of e.inputs){h(r,s.fieldRef);for(const I of s.bindings||[])h(r,I.fieldRef);h(r,(u=s.optionQuery)==null?void 0:u.valueFieldRef),h(r,(d=s.optionQuery)==null?void 0:d.labelFieldRef),h(r,(c=s.optionQuery)==null?void 0:c.filterFieldRef),Q(r,(i=s.optionQuery)==null?void 0:i.spec)}for(const s of e.filterContracts){h(r,s.fieldRef),h(r,(p=s.optionQuery)==null?void 0:p.valueFieldRef),h(r,(w=s.optionQuery)==null?void 0:w.labelFieldRef),h(r,(g=s.optionQuery)==null?void 0:g.filterFieldRef),Q(r,($=s.optionQuery)==null?void 0:$.spec);for(const I of s.bindings||[])h(r,I.fieldRef)}for(const s of e.views){for(const I of s.fields||[])h(r,I);Q(r,(F=s.sdkSpec)==null?void 0:F.spec),Q(r,s.visualSpec)}const t=e.implementationChecklist||{};for(const s of Object.values(t.bindingsByView||{}))for(const I of Array.isArray(s)?s:[])h(r,I.fieldRef),h(r,I.optionValueField),h(r,I.optionLabelField);for(const s of t.requiredInputOptions||[])h(r,s.visibleLabelField),h(r,s.optionValueField),h(r,s.runtimeFilterField);const o=dn([...e.sources.map(s=>({raw:s,key:Ie(s),aliases:Fe(s),name:""})),...r.map(s=>sn(s)).filter(G)]);H(o,s=>{const I=b(s.raw);return q(s.raw.label||(I==null?void 0:I.datasetName)||(I==null?void 0:I.datasetId)||(I==null?void 0:I.name)||s.raw.kind||"source")});const a=pn(o),l=ne(r.filter(s=>s.name).map(s=>({raw:s,key:J(s),name:""})),s=>s.key);H(l,s=>q([s.raw.sourceKey?fn(s.raw.sourceKey):"",s.raw.aggregate?s.raw.aggregate.toLowerCase():"",s.raw.name].filter(Boolean).join("_")));const y=new Map(l.map(s=>[s.key,s.name])),S=e.inputs.map(s=>({raw:s,name:q(s.id||s.label||"input")}));H(S,s=>s.name);const f=S.filter(s=>!!s.raw.optionQuery).map(s=>({input:s,name:`${s.name}Options`,raw:s.raw.optionQuery}));H(f,s=>s.name);for(const s of f)an(s.raw.labelFieldRef,s.raw.valueFieldRef)&&un(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 m=e.views.filter(s=>{var I,B;return!!((I=s.sdkSpec)!=null&&I.builder&&((B=s.sdkSpec)!=null&&B.spec))}).map(s=>({raw:s,name:q(s.id||s.title||"query")}));H(m,s=>s.name);const O=e.views.filter(s=>fe(s)&&!("sdkSpec"in s)).map(s=>on(s));for(const s of e.views)(!("sdkSpec"in s)||!((V=s.sdkSpec)!=null&&V.builder)||!((C=s.sdkSpec)!=null&&C.spec))&&!fe(s)&&n.push(`Skipped view ${s.id||s.title||"unknown"} because it has no sdkSpec.`);return Ne({inputs:S,views:m,filterContracts:e.filterContracts}),{summary:e,title:e.title||"Semaphor Data App",sources:o,fields:l,inputs:S,optionQueries:f,views:m,presentationViews:O,filterContracts:e.filterContracts,checklist:t,sourceNameByKey:a,fieldNameByKey:y,warnings:n}}function Ne({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,l]of r.entries()){if(!t.has(l.inputId))throw new Error(`filterContracts.${a}.inputId must reference a generated input.`);const y=new Set(l.appliesToViewIds||[]),S=new Set(l.notAppliedToViewIds||[]);for(const[f,m]of(l.appliesToViewIds||[]).entries())if(!o.has(m))throw new Error(`filterContracts.${a}.appliesToViewIds.${f} must reference an executable generated view.`);for(const[f,m]of(l.notAppliedToViewIds||[]).entries())if(!o.has(m))throw new Error(`filterContracts.${a}.notAppliedToViewIds.${f} must reference an executable generated view.`);for(const[f,m]of(l.bindings||[]).entries()){if(!o.has(m.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must reference an executable generated view.`);if(!y.has(m.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must be included in appliesToViewIds.`);if(S.has(m.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must not be listed in notAppliedToViewIds.`)}}}function Oe(e){return{"sources.ts":Ke(e),"fields.ts":ve(e),"inputs.ts":je(e),"queries.ts":Qe(e),"bindings.ts":Le(e),"accessors.ts":ze(e),"metadata.ts":We(e),"index.ts":Ze()}}function Ee({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:xe(n),codegenSummaryValidatorVersion:R.CODEGEN_SUMMARY_VALIDATOR_VERSION,codegenSummaryHash:Ae(e.summary),codegenSummary:e.summary}}function xe(e){const n=ge.createHash("sha256");for(const r of Object.keys(e).sort())n.update(r),n.update("\0"),n.update(e[r]),n.update("\0");return`sha256:${n.digest("hex")}`}function 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 n=e;return`{${Object.keys(n).sort().filter(t=>n[t]!==void 0).map(t=>`${JSON.stringify(t)}:${ue(n[t])}`).join(",")}}`}function Ge(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
|
+
`);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=>X(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
|
+
`);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 m;return cn((m=f.raw.sdkSpec)==null?void 0:m.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(`
|
|
9
9
|
`);const l=e.views.find(f=>Te(f));if(l)return['import { appInputSpecs, createInputHandleMap, metricValuesForView, 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 metrics = metricValuesForView.${l.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
10
10
|
`);const y=e.views[0];return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",y?`const result = useSemaphorQuery(queries.${y.name}(), queryOptionsForView.${y.name}(inputHandles));`:"const result = undefined;","const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
11
|
-
`)}function X(e){var n;return
|
|
11
|
+
`)}function X(e){var n;return j((n=e.raw.sdkSpec)==null?void 0:n.builder)==="records"}function Te(e){var n;return j((n=e.raw.sdkSpec)==null?void 0:n.builder)==="metric"}function T(e){var n,r,t;return X(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 j((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 _e(e){return X(e)&&(_(e)||T(e))||pe(e)&&_(e)}function Ke(e){const n=e.sources.map(({name:t,raw:o})=>{const a=He(o);return` ${t}: ${a},`}).join(`
|
|
12
12
|
`),r=e.sources.some(t=>t.raw.kind==="semantic")?`import { semaphor } from "react-semaphor/data-app-sdk";
|
|
13
13
|
|
|
14
14
|
`:"";return`${K}
|
|
15
15
|
${r}export const sources = {
|
|
16
16
|
${n}
|
|
17
17
|
} as const;
|
|
18
|
-
`}function He(e){if(e.kind==="semantic"){const n={domainId:e.domainId,datasetId:e.datasetId,datasetName:e.datasetName,label:e.label};return`semaphor.source.semantic(${k(A(n))})`}return`${k(A({...e,sourceKey:void 0}))} as const`}function ve(e){const n=e.fields.map(({name:t,raw:o})=>{const
|
|
18
|
+
`}function He(e){if(e.kind==="semantic"){const n={domainId:e.domainId,datasetId:e.datasetId,datasetName:e.datasetName,label:e.label};return`semaphor.source.semantic(${k(A(n))})`}return`${k(A({...e,sourceKey:void 0}))} as const`}function ve(e){const n=e.fields.map(({name:t,raw:o})=>{const a=qe(o,e);return` ${t}: ${a},`}).join(`
|
|
19
19
|
`),r=n.includes("sources.")?`import { sources } from "./sources";
|
|
20
20
|
|
|
21
21
|
`:"";return`${K}
|
|
22
22
|
${r}export const fields = {
|
|
23
23
|
${n}
|
|
24
24
|
} as const;
|
|
25
|
-
`}function qe(e,n){const r={name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate},t=ln(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
|
|
26
|
-
`),r=e.inputs.map(
|
|
27
|
-
`),
|
|
28
|
-
inputs.push(semaphor.bindInput(${
|
|
25
|
+
`}function qe(e,n){const r={name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate},t=ln(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(([l,y])=>`${JSON.stringify(l)}: ${x(y,n)}`);return o&&a.push(`"source": sources.${o}`),`{ ${a.join(", ")} }`}function je(e){const n=e.inputs.map(c=>{const i=N(c.raw.fieldRef,e),p=[`id: ${JSON.stringify(c.raw.id)}`,`label: ${JSON.stringify(c.raw.label||c.raw.id)}`,`operator: ${JSON.stringify(mn(c.raw))}`];if(i&&p.push(`field: fields.${i}`),c.raw.relationshipHint&&p.push(`relationshipHint: ${k(c.raw.relationshipHint)}`),!i)throw new Error(`Input ${c.raw.id||c.name} is missing a generated field reference.`);return` ${c.name}: semaphor.filter({ ${p.join(", ")} }),`}).join(`
|
|
26
|
+
`),r=e.inputs.map(c=>`filterSpecs.${c.name}`).join(", "),t=e.inputs.map(c=>JSON.stringify(c.raw.id)).join(", "),o=e.optionQueries.map(c=>{const i=c.input.raw,p=c.raw,w=b(p.spec)||{},{id:g,inputId:$,source:F,sourceKey:M,valueField:V,labelField:C,population:s,dependencies:I,limit:B,...re}=w,z=p.sourceKey?{sourceKey:p.sourceKey}:p.source||F||(typeof M=="string"?{sourceKey:M}:void 0),te=$e(z,e),oe=N(p.valueFieldRef,e),se=N(p.labelFieldRef,e),ae=he(c),ie={...re,id:p.id||w.id||`${i.id}-options`,inputId:i.id,source:z,valueField:p.valueFieldRef,labelField:p.labelFieldRef,population:p.population||s,dependencies:ae,limit:p.limit||B||100};if(!te||!oe||!se)throw new Error(`Input option query ${p.id||`${i.id}-options`} is missing source, valueField, or labelField.`);const Ve=Object.entries(A(ie)).map(([be,Re])=>`${JSON.stringify(be)}: ${x(Re,e)}`);return` ${c.name}: semaphor.inputOptions({ ${Ve.join(", ")} }),`}).join(`
|
|
27
|
+
`),a=e.optionQueries.map(c=>{const i=Be(e,c),p=i.length>0?"inputHandles":"_inputHandles",w=i.map(g=>{const $=N(g.raw.fieldRef,e);if(!$)throw new Error(`Input option query ${c.raw.id||`${c.input.raw.id}-options`} references input ${g.raw.id} without a generated field reference.`);const F=`inputHandles[${JSON.stringify(g.raw.id)}]`;return` if (${F}) {
|
|
28
|
+
inputs.push(semaphor.bindInput(${F}, { field: fields.${$} }));
|
|
29
29
|
}`}).join(`
|
|
30
|
-
`);return` ${
|
|
30
|
+
`);return` ${c.name}(${p}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
31
31
|
const inputs: SemaphorInputReference[] = [];
|
|
32
32
|
${w}
|
|
33
33
|
return inputs;
|
|
34
34
|
},`}).join(`
|
|
35
35
|
|
|
36
|
-
`),l=e.optionQueries.map(
|
|
36
|
+
`),l=e.optionQueries.map(c=>` ${c.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
37
37
|
return {
|
|
38
|
-
inputs: inputsForInputOptionQuery.${
|
|
38
|
+
inputs: inputsForInputOptionQuery.${c.name}(inputHandles),
|
|
39
39
|
};
|
|
40
40
|
},`).join(`
|
|
41
41
|
|
|
42
|
-
`),y=e.optionQueries.map(
|
|
43
|
-
return queryOptionsForInputOptionQuery.${
|
|
44
|
-
`),
|
|
42
|
+
`),y=e.optionQueries.map(c=>` case ${JSON.stringify(c.raw.id||`${c.input.raw.id}-options`)}:
|
|
43
|
+
return queryOptionsForInputOptionQuery.${c.name}(inputHandles);`).join(`
|
|
44
|
+
`),S=e.inputs.length>0,f=e.optionQueries.length>0,m=f?"inputOptionQueryId":"_inputOptionQueryId",O=f?"inputHandles":"_inputHandles",u=["SemaphorInputHandle",f?"SemaphorInputReference":void 0,"SemaphorQueryRuntimeOptions"].filter(G).join(", "),d=[S||f?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,`import type { ${u} } from "react-semaphor/data-app-sdk";`,S||f?'import { fields } from "./fields";':void 0,f?'import { sources } from "./sources";':void 0,'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'].filter(G).join(`
|
|
45
45
|
`);return`${K}
|
|
46
|
-
${
|
|
46
|
+
${d}
|
|
47
47
|
|
|
48
48
|
export const filterSpecs = {
|
|
49
49
|
${n}
|
|
@@ -63,7 +63,7 @@ ${o}
|
|
|
63
63
|
} as const;
|
|
64
64
|
|
|
65
65
|
export const inputsForInputOptionQuery = {
|
|
66
|
-
${
|
|
66
|
+
${a}
|
|
67
67
|
} as const;
|
|
68
68
|
|
|
69
69
|
export const queryOptionsForInputOptionQuery = {
|
|
@@ -72,45 +72,45 @@ ${l}
|
|
|
72
72
|
|
|
73
73
|
export function queryOptionsForInputOptionQueryId(
|
|
74
74
|
${m}: SemaphorGeneratedInputOptionQueryId,
|
|
75
|
-
${
|
|
75
|
+
${O}: SemaphorGeneratedInputHandleMap,
|
|
76
76
|
): SemaphorQueryRuntimeOptions {
|
|
77
77
|
switch (${m}) {
|
|
78
78
|
${y}
|
|
79
79
|
}
|
|
80
80
|
throw new Error(\`Unknown generated Semaphor input option query id: \${${m}}\`);
|
|
81
81
|
}
|
|
82
|
-
`}function
|
|
83
|
-
recordsSortFieldsForView.${
|
|
82
|
+
`}function Be(e,n){const r=he(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 he(e){var n;return e.raw.dependencies||((n=e.raw.spec)==null?void 0:n.dependencies)}function Qe(e){const n=e.views.map(d=>{var p,w,g,$,F,M;const c=j(d.raw.sdkSpec.builder),i=De(d);if(X(d)&&_e(d)){const V=(p=d.raw.visualSpec)==null?void 0:p.tableBehavior,C=b(i.pagination),s=_(d),I=T(d),B=((w=V==null?void 0:V.pagination)==null?void 0:w.pageSize)||Y(C==null?void 0:C.pageSize)||Y(i.limit)||100,re=I?W(d,e):[],z=I?Pe({view:d,contract:e,sortFields:re,defaultField:(g=V==null?void 0:V.sorting)==null?void 0:g.defaultField}):void 0,te=I?($=V==null?void 0:V.sorting)==null?void 0:$.defaultDirection:void 0,oe=Ue({viewName:d.name,supportsPagination:s,supportsSort:I}),se=I?` const orderBy = resolveRecordsOrderBy(
|
|
83
|
+
recordsSortFieldsForView.${d.name},
|
|
84
84
|
params.sort,
|
|
85
|
-
${
|
|
86
|
-
${
|
|
85
|
+
${x(z,e)},
|
|
86
|
+
${x(te,e)},
|
|
87
87
|
);
|
|
88
|
-
`:"",ae=
|
|
89
|
-
`:"",ie=
|
|
90
|
-
`:"";return` ${
|
|
88
|
+
`:"",ae=I?` ...(orderBy ? { orderBy } : {}),
|
|
89
|
+
`:"",ie=s?` pagination: resolveServerTablePagination(params, ${JSON.stringify(B)}),
|
|
90
|
+
`:"";return` ${d.name}(
|
|
91
91
|
params: ${oe} = {},
|
|
92
92
|
) {
|
|
93
|
-
${se} return semaphor.${
|
|
94
|
-
...${
|
|
93
|
+
${se} return semaphor.${c}({
|
|
94
|
+
...${x(i,e)},
|
|
95
95
|
${ae}${ie} });
|
|
96
|
-
},`}if(pe(
|
|
96
|
+
},`}if(pe(d)&&_(d)){const V=(F=d.raw.visualSpec)==null?void 0:F.tableBehavior,C=b(i.pagination),s=((M=V==null?void 0:V.pagination)==null?void 0:M.pageSize)||Y(C==null?void 0:C.pageSize)||Y(i.limit)||100;return` ${d.name}(
|
|
97
97
|
params: SemaphorGeneratedServerPaginationParams = {},
|
|
98
98
|
) {
|
|
99
|
-
return semaphor.${
|
|
100
|
-
...${
|
|
101
|
-
pagination: resolveServerTablePagination(params, ${JSON.stringify(
|
|
99
|
+
return semaphor.${c}({
|
|
100
|
+
...${x(i,e)},
|
|
101
|
+
pagination: resolveServerTablePagination(params, ${JSON.stringify(s)}),
|
|
102
102
|
});
|
|
103
|
-
},`}return` ${
|
|
104
|
-
`),r=e.views.filter(
|
|
105
|
-
`);return` ${
|
|
106
|
-
${
|
|
103
|
+
},`}return` ${d.name}: () => semaphor.${c}(${x(i,e)}),`}).join(`
|
|
104
|
+
`),r=e.views.filter(d=>T(d)).map(d=>{const i=W(d,e).map(p=>` ${JSON.stringify(p.key)}: fields.${p.fieldName},`).join(`
|
|
105
|
+
`);return` ${d.name}: {
|
|
106
|
+
${i}
|
|
107
107
|
},`}).join(`
|
|
108
|
-
`),t=e.views.filter(
|
|
109
|
-
`);return` ${
|
|
110
|
-
${
|
|
108
|
+
`),t=e.views.filter(d=>T(d)).map(d=>{const i=W(d,e).map(p=>` { key: ${JSON.stringify(p.key)}, label: ${JSON.stringify(p.label)}, field: fields.${p.fieldName} },`).join(`
|
|
109
|
+
`);return` ${d.name}: [
|
|
110
|
+
${i}
|
|
111
111
|
],`}).join(`
|
|
112
|
-
`),o=e.views.some(
|
|
113
|
-
`),y=[n?'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(
|
|
112
|
+
`),o=e.views.some(d=>T(d)),a=e.views.some(d=>_(d)),l=[n,r,t].join(`
|
|
113
|
+
`),y=[n?'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(G).join(`
|
|
114
114
|
`);return`${K}
|
|
115
115
|
${y}
|
|
116
116
|
${o?`export type SemaphorGeneratedRecordsSortDirection = "asc" | "desc";
|
|
@@ -123,11 +123,11 @@ export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
|
123
123
|
export type SemaphorGeneratedRecordsSortParams<TSortKey extends string = string> = {
|
|
124
124
|
sort?: SemaphorGeneratedRecordsSort<TSortKey> | null;
|
|
125
125
|
};
|
|
126
|
-
`:""}${
|
|
126
|
+
`:""}${a?`export type SemaphorGeneratedServerPaginationParams = {
|
|
127
127
|
page?: number;
|
|
128
128
|
pageSize?: number;
|
|
129
129
|
};
|
|
130
|
-
`:""}${o&&
|
|
130
|
+
`:""}${o&&a?`export type SemaphorGeneratedRecordsQueryParams<TSortKey extends string = string> =
|
|
131
131
|
SemaphorGeneratedServerPaginationParams &
|
|
132
132
|
SemaphorGeneratedRecordsSortParams<TSortKey>;
|
|
133
133
|
`:""}
|
|
@@ -164,7 +164,7 @@ ${o?`function resolveRecordsOrderBy<TSortKey extends string>(
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
`:""}
|
|
167
|
-
${
|
|
167
|
+
${a?`function resolveServerTablePagination(
|
|
168
168
|
params: SemaphorGeneratedServerPaginationParams,
|
|
169
169
|
defaultPageSize: number,
|
|
170
170
|
) {
|
|
@@ -174,12 +174,12 @@ ${i?`function resolveServerTablePagination(
|
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
`:""}
|
|
177
|
-
`}function
|
|
177
|
+
`}function De(e){var a,l;const n=b((a=e.raw.sdkSpec)==null?void 0:a.spec)||{},{kind:r,id:t,...o}=n;return{...o,id:e.raw.id,label:((l=e.raw.visualSpec)==null?void 0:l.title)||e.raw.title||o.label}}function W(e,n){var a,l;const r=[],t=b((a=e.raw.sdkSpec)==null?void 0:a.spec)||{};for(const y of v(t.fields))h(r,y);h(r,t.dateField),h(r,(l=b(t.orderBy))==null?void 0:l.field);for(const y of e.raw.fields||[])h(r,y);return ne(r.map(y=>{const S=N(y,n);if(!(!y.name||!S))return{key:S,fieldName:S,rawName:y.name,label:y.label||y.name}}).filter(G),y=>y.key)}function Pe({view:e,contract:n,sortFields:r,defaultField:t}){var S,f;const o=new Set(r.map(m=>m.key));if(t&&o.has(t))return t;const a=r.filter(m=>m.rawName===t);if(a.length===1)return a[0].key;const l=b((S=e.raw.sdkSpec)==null?void 0:S.spec),y=N((f=b(l==null?void 0:l.orderBy))==null?void 0:f.field,n);return y&&o.has(y)?y:void 0}function Ue({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(m=>{const u=Je(e,m.raw.id).map(d=>{const c=d.inputId,i=N(d.fieldRef,e);if(!c||!i)return"";const p=[`field: fields.${i}`];if(d.relationshipHint)p.push(`relationshipHint: ${k(d.relationshipHint)}`);else if(Array.isArray(d.relationshipsUsed)&&d.relationshipsUsed.length>0){const g=d.relationshipsUsed.map($=>{var F;return(F=b($))==null?void 0:F.id}).filter($=>typeof $=="string"&&$.length>0);g.length>0&&p.push(`relationshipHint: ${k({relationshipIds:g})}`)}const w=`inputHandles[${JSON.stringify(c)}]`;return` if (${w}) {
|
|
178
178
|
inputs.push(semaphor.bindInput(${w}, { ${p.join(", ")} }));
|
|
179
179
|
}`}).filter(Boolean).join(`
|
|
180
|
-
`);return{view:m,renderedBindings:
|
|
180
|
+
`);return{view:m,renderedBindings:u}}),r=n.some(m=>m.renderedBindings.length>0),t=n.map(({view:m,renderedBindings:O})=>{const u=O?"inputHandles":"_inputHandles";return` ${m.name}(${u}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
181
181
|
const inputs: SemaphorInputReference[] = [];
|
|
182
|
-
${
|
|
182
|
+
${O}
|
|
183
183
|
return inputs;
|
|
184
184
|
},`}).join(`
|
|
185
185
|
|
|
@@ -190,11 +190,11 @@ ${M}
|
|
|
190
190
|
};
|
|
191
191
|
},`).join(`
|
|
192
192
|
|
|
193
|
-
`),
|
|
193
|
+
`),a=e.views.map(m=>` case ${JSON.stringify(m.raw.id)}:
|
|
194
194
|
return inputsForView.${m.name}(inputHandles);`).join(`
|
|
195
195
|
`),l=e.views.map(m=>` case ${JSON.stringify(m.raw.id)}:
|
|
196
196
|
return queryOptionsForView.${m.name}(inputHandles);`).join(`
|
|
197
|
-
`),y=e.views.length>0,
|
|
197
|
+
`),y=e.views.length>0,S=y?"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";',y?'import { queryDebugForView } from "./metadata";':void 0,'import type { SemaphorGeneratedQueryViewId } from "./metadata";'].filter(G).join(`
|
|
198
198
|
`);return`${K}
|
|
199
199
|
${f}
|
|
200
200
|
|
|
@@ -208,90 +208,113 @@ ${o}
|
|
|
208
208
|
|
|
209
209
|
export function inputsForViewId(
|
|
210
210
|
viewId: SemaphorGeneratedQueryViewId,
|
|
211
|
-
${
|
|
211
|
+
${S}: SemaphorGeneratedInputHandleMap,
|
|
212
212
|
): SemaphorInputReference[] {
|
|
213
213
|
switch (viewId) {
|
|
214
|
-
${
|
|
214
|
+
${a}
|
|
215
215
|
}
|
|
216
216
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
export function queryOptionsForViewId(
|
|
220
220
|
viewId: SemaphorGeneratedQueryViewId,
|
|
221
|
-
${
|
|
221
|
+
${S}: SemaphorGeneratedInputHandleMap,
|
|
222
222
|
): SemaphorQueryRuntimeOptions {
|
|
223
223
|
switch (viewId) {
|
|
224
224
|
${l}
|
|
225
225
|
}
|
|
226
226
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
227
227
|
}
|
|
228
|
-
`}function Je(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 ze(e){const n=e.views.map(
|
|
229
|
-
`);return` ${
|
|
230
|
-
${
|
|
231
|
-
},`}).join(`
|
|
232
|
-
`),r=e.views.map(s=>{const c=D(s,e).map(p=>{const w=C(p.raw,e);return w?` ${p.name}: fields.${w},`:""}).filter(Boolean).join(`
|
|
233
|
-
`);return` ${s.name}: {
|
|
234
|
-
${c}
|
|
228
|
+
`}function Je(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 ze(e){const n=e.views.map(i=>{const w=U(i,e).map(g=>{const $=N(g.raw,e);return $?` ${g.name}: fields.${$},`:""}).filter(Boolean).join(`
|
|
229
|
+
`);return` ${i.name}: {
|
|
230
|
+
${w}
|
|
235
231
|
},`}).join(`
|
|
236
|
-
`),
|
|
237
|
-
`);return` ${
|
|
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(`
|
|
233
|
+
`);return` ${i.name}: {
|
|
238
234
|
${w}
|
|
239
235
|
},`}).join(`
|
|
240
|
-
`),
|
|
241
|
-
`);return` ${
|
|
242
|
-
${
|
|
236
|
+
`),t=e.views.map(i=>{const p=P(i,e),w=rn(p),g=nn(p),$=p.map(F=>{const M=Array.from(new Set(Se(F.raw).filter(V=>g.has(V))));return` ${F.name}: metricKeysForField(metricFieldsForView.${i.name}.${F.name}, { allowNameFallback: ${w.has(F.raw.name)?"false":"true"}, excludedKeys: ${k(M)} }),`}).join(`
|
|
237
|
+
`);return` ${i.name}: {
|
|
238
|
+
${$}
|
|
239
|
+
},`}).join(`
|
|
240
|
+
`),o=e.views.map(i=>{const w=P(i,e).map((g,$)=>` ${g.name}: ${JSON.stringify(Xe(i,g,$))},`).join(`
|
|
241
|
+
`);return` ${i.name}: {
|
|
242
|
+
${w}
|
|
243
243
|
},`}).join(`
|
|
244
|
-
`),
|
|
244
|
+
`),a=e.views.map(i=>{const p=P(i,e);if(p.length===0)return` ${i.name}(): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
245
245
|
return {};
|
|
246
|
-
},`;const
|
|
247
|
-
`);return` ${
|
|
246
|
+
},`;const w=en(i,p),g=p.map($=>{const F=`metricMeasureKeysForView.${i.name}.${$.name}`,M=`metricMeasureBindingKeysForView.${i.name}.${$.name}`,V=w.has($.name)?`readMetricValueByBindingWithFallback(measures, measureBindings, ${M}, ${F}, primaryValue)`:`readMetricValueByBinding(measures, measureBindings, ${M}, ${F})`;return` ${$.name}: ${V},`}).join(`
|
|
247
|
+
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
248
248
|
const measures = result?.measures;
|
|
249
249
|
const measureBindings = result?.measureBindings;
|
|
250
|
-
const
|
|
250
|
+
const primaryValue = result?.primaryValue;
|
|
251
251
|
return {
|
|
252
|
-
${
|
|
252
|
+
${g}
|
|
253
253
|
};
|
|
254
254
|
},`}).join(`
|
|
255
255
|
|
|
256
|
-
`),l=e.views.map(
|
|
256
|
+
`),l=e.views.map(i=>{const p=P(i,e);if(p.length===0)return` ${i.name}(): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
257
257
|
return [];
|
|
258
|
-
},`;const
|
|
259
|
-
`);return` ${
|
|
258
|
+
},`;const w=p.map(g=>` ...(missing.has(metricMeasureBindingKeysForView.${i.name}.${g.name}) ? [${JSON.stringify(g.name)} as keyof typeof metricFieldsForView.${i.name}] : []),`).join(`
|
|
259
|
+
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
260
260
|
const missing = new Set(result?.missingMeasures || []);
|
|
261
261
|
return [
|
|
262
|
-
${
|
|
262
|
+
${w}
|
|
263
263
|
];
|
|
264
264
|
},`}).join(`
|
|
265
265
|
|
|
266
|
-
`),y=e.views.map(
|
|
267
|
-
`),
|
|
268
|
-
`);return` ${
|
|
266
|
+
`),y=e.views.map(i=>{const p=Ye(i,e);return` ${i.name}: ${k(p)},`}).join(`
|
|
267
|
+
`),S=e.views.map(i=>{const w=U(i,e).map(g=>` ${g.name}: resolveColumnKey(columns, fieldsForView.${i.name}.${g.name}),`).join(`
|
|
268
|
+
`);return` ${i.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, string | undefined> {
|
|
269
269
|
return {
|
|
270
|
-
${
|
|
270
|
+
${w}
|
|
271
271
|
};
|
|
272
272
|
},`}).join(`
|
|
273
273
|
|
|
274
|
-
`),f=e.views.map(
|
|
275
|
-
`);return` ${
|
|
274
|
+
`),f=e.views.map(i=>{const w=U(i,e).map(g=>` ${g.name}: readCell(row, columns, fieldsForView.${i.name}.${g.name}),`).join(`
|
|
275
|
+
`);return` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, unknown> {
|
|
276
276
|
return {
|
|
277
|
-
${
|
|
277
|
+
${w}
|
|
278
278
|
};
|
|
279
279
|
},`}).join(`
|
|
280
280
|
|
|
281
|
-
`),m=
|
|
281
|
+
`),m=e.views.map(i=>` ${i.name}(result: SemaphorGeneratedRecordsResult): Array<Record<keyof typeof fieldsForView.${i.name}, unknown>> {
|
|
282
|
+
return (result?.records || []).map((row) => rowValuesForView.${i.name}(row, result?.columns));
|
|
283
|
+
},`).join(`
|
|
284
|
+
|
|
285
|
+
`),O=e.views.map(i=>{const p=U(i,e),w=p.filter(s=>s.raw.role==="dimension"),g=p.filter(s=>s.raw.role==="measure"),$=w[0],F=w[1],M=g[0],V=g[1],C=[$?` primaryDimension: values.${$.name},`:" primaryDimension: undefined,",F?` secondaryDimension: values.${F.name},`:" secondaryDimension: undefined,",M?` primaryMeasure: values.${M.name},`:" primaryMeasure: undefined,",V?` secondaryMeasure: values.${V.name},`:" secondaryMeasure: undefined,"].join(`
|
|
286
|
+
`);return` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): SemaphorGeneratedRoleValues {
|
|
287
|
+
const values = rowValuesForView.${i.name}(row, columns);
|
|
288
|
+
return {
|
|
289
|
+
${C}
|
|
290
|
+
};
|
|
291
|
+
},`}).join(`
|
|
292
|
+
|
|
293
|
+
`),u=n.includes("fields.")||r.includes("fields."),c=[`import { ${["type SemaphorFieldRef","type SemaphorResultColumn","semaphorMetricMeasureBindingKey"].filter(G).join(", ")} } from "react-semaphor/data-app-sdk";`,u?'import { fields } from "./fields";':void 0].filter(G).join(`
|
|
282
294
|
`);return`${K}
|
|
283
|
-
${
|
|
295
|
+
${c}
|
|
284
296
|
|
|
285
297
|
export type SemaphorGeneratedRow = Record<string, unknown>;
|
|
286
298
|
export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
|
|
299
|
+
export type SemaphorGeneratedRecordsResult = {
|
|
300
|
+
readonly records?: readonly SemaphorGeneratedRow[];
|
|
301
|
+
readonly columns?: SemaphorGeneratedColumns;
|
|
302
|
+
} | null | undefined;
|
|
287
303
|
export type SemaphorGeneratedMetricMeasures = Record<string, unknown> | null | undefined;
|
|
288
304
|
export type SemaphorGeneratedMetricMeasureBindings = Record<string, string> | null | undefined;
|
|
289
305
|
export type SemaphorGeneratedMetricResult = {
|
|
290
306
|
readonly measures?: SemaphorGeneratedMetricMeasures;
|
|
291
307
|
readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
|
|
292
308
|
readonly missingMeasures?: readonly string[];
|
|
309
|
+
readonly primaryValue: unknown;
|
|
293
310
|
readonly value?: unknown;
|
|
294
311
|
} | null | undefined;
|
|
312
|
+
export type SemaphorGeneratedRoleValues = {
|
|
313
|
+
readonly primaryDimension: unknown;
|
|
314
|
+
readonly secondaryDimension: unknown;
|
|
315
|
+
readonly primaryMeasure: unknown;
|
|
316
|
+
readonly secondaryMeasure: unknown;
|
|
317
|
+
};
|
|
295
318
|
export type SemaphorGeneratedTableColumn = {
|
|
296
319
|
readonly key: string;
|
|
297
320
|
readonly label: string;
|
|
@@ -321,15 +344,23 @@ ${y}
|
|
|
321
344
|
} as const;
|
|
322
345
|
|
|
323
346
|
export const columnKeysForView = {
|
|
324
|
-
${
|
|
347
|
+
${S}
|
|
325
348
|
} as const;
|
|
326
349
|
|
|
327
350
|
export const rowValuesForView = {
|
|
328
351
|
${f}
|
|
329
352
|
} as const;
|
|
330
353
|
|
|
354
|
+
export const rowsForView = {
|
|
355
|
+
${m}
|
|
356
|
+
} as const;
|
|
357
|
+
|
|
358
|
+
export const roleValuesForView = {
|
|
359
|
+
${O}
|
|
360
|
+
} as const;
|
|
361
|
+
|
|
331
362
|
export const metricValuesForView = {
|
|
332
|
-
${
|
|
363
|
+
${a}
|
|
333
364
|
} as const;
|
|
334
365
|
|
|
335
366
|
export const missingMetricMeasuresForView = {
|
|
@@ -630,10 +661,10 @@ function sourcesReferToSameDataset(
|
|
|
630
661
|
}
|
|
631
662
|
return false;
|
|
632
663
|
}
|
|
633
|
-
`}function Ye(e,n){const r=
|
|
664
|
+
`}function Ye(e,n){const r=U(e,n),t=new Map((T(e)?W(e,n):[]).map(o=>[o.fieldName,o.key]));return r.map(o=>{const a=N(o.raw,n),l=a?t.get(a):void 0;return A({key:o.name,label:o.raw.label||o.raw.name,dataType:o.raw.dataType,sortable:!!l,sortKey:l})})}function We(e){const n=e.checklist.filterScopeByInput||[],r=e.checklist.requiredDevtools||{},t=e.summary.views.map(u=>u.id).filter(Boolean),o=e.views.map(u=>u.raw.id).filter(Boolean),a=e.inputs.map(u=>u.raw.id).filter(Boolean),l=e.optionQueries.map(u=>u.raw.id||`${u.input.raw.id}-options`).filter(Boolean),y=Object.fromEntries(o.map(u=>[u,e.filterContracts.filter(d=>Array.isArray(d.appliesToViewIds)&&d.appliesToViewIds.includes(u)).map(d=>d.inputId)])),S=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}])),f=Object.fromEntries(e.views.map(u=>{var d;return[u.raw.id,A({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}})]})),m=Object.fromEntries(e.inputs.map(u=>{var d;return[u.raw.id,A({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,c,i;return[u.name,A({viewId:u.raw.id,viewTitle:((d=u.raw.visualSpec)==null?void 0:d.title)||u.raw.title,visualType:(c=u.raw.visualSpec)==null?void 0:c.visualType,title:((i=u.raw.visualSpec)==null?void 0:i.title)||u.raw.title})]}));return`${K}
|
|
634
665
|
export const generatedViewIds = ${k(t)} as const;
|
|
635
666
|
export const generatedQueryViewIds = ${k(o)} as const;
|
|
636
|
-
export const generatedInputIds = ${k(
|
|
667
|
+
export const generatedInputIds = ${k(a)} as const;
|
|
637
668
|
export const generatedInputOptionQueryIds = ${k(l)} as const;
|
|
638
669
|
export const generatedViewAuthoring = ${k(f)} as const;
|
|
639
670
|
export const generatedInputAuthoring = ${k(m)} as const;
|
|
@@ -676,9 +707,9 @@ export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
|
676
707
|
);
|
|
677
708
|
}
|
|
678
709
|
|
|
679
|
-
export const queryDebugForView = ${k(
|
|
710
|
+
export const queryDebugForView = ${k(O)} as const;
|
|
680
711
|
|
|
681
|
-
export const semaphorGeneratedContractMetadata = ${k({schemaVersion:"semaphor-generated-data-app-contract/v1",title:e.title,requiredDevtools:r,filterContracts:e.filterContracts,filterScopeByInput:n,generatedViewIds:t,generatedQueryViewIds:o,generatedInputIds:
|
|
712
|
+
export const semaphorGeneratedContractMetadata = ${k({schemaVersion:"semaphor-generated-data-app-contract/v1",title:e.title,requiredDevtools:r,filterContracts:e.filterContracts,filterScopeByInput:n,generatedViewIds:t,generatedQueryViewIds:o,generatedInputIds:a,generatedInputOptionQueryIds:l,generatedInputIdsForView:y,generatedViewAuthoring:f,generatedInputAuthoring:m,visualSpecs:S,presentationViews:e.presentationViews})} as const;
|
|
682
713
|
`}function Ze(){return`${K}
|
|
683
714
|
export * from "./sources";
|
|
684
715
|
export * from "./fields";
|
|
@@ -687,4 +718,4 @@ export * from "./queries";
|
|
|
687
718
|
export * from "./bindings";
|
|
688
719
|
export * from "./accessors";
|
|
689
720
|
export * from "./metadata";
|
|
690
|
-
`}function Q(e,n){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(const r of n)Q(e,r);return}
|
|
721
|
+
`}function Q(e,n){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(const r of n)Q(e,r);return}E(n)&&h(e,L(n));for(const r of Object.values(n))Q(e,r)}}function U(e,n){const r=[];if(tn(r,e.raw.sdkSpec),r.length===0)for(const o of e.raw.fields||[])h(r,o);const t=ne(r.filter(o=>o.name&&N(o,n)).map(o=>({raw:o,key:J(o),name:""})),o=>o.key);return H(t,o=>q(o.raw.label||o.raw.name||"field")),t}function P(e,n){if(j(e.raw.sdkSpec.builder)!=="metric")return[];const r=b(e.raw.sdkSpec.spec),t=[];h(t,r==null?void 0:r.primaryMeasure);for(const a of v(r==null?void 0:r.measures))h(t,a);const o=ne(t.filter(a=>a.name&&N(a,n)).map(a=>({raw:a,key:J(a),name:""})),a=>a.key);return H(o,a=>q(a.raw.label||a.raw.name||"metric")),o}function Xe(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 en(e,n){if(n.length===1)return new Set([n[0].name]);const r=b(e.raw.sdkSpec.spec);if(!E(r==null?void 0:r.primaryMeasure))return new Set;const t=J(L(r.primaryMeasure)),o=n.find(a=>a.key===t);return o?new Set([o.name]):new Set}function nn(e){const n=new Map;for(const r of e)for(const t of new Set(Se(r.raw)))n.set(t,(n.get(t)||0)+1);return new Set(Array.from(n.entries()).filter(([,r])=>r>1).map(([r])=>r))}function Se(e){const n=(e.aggregate||"SUM").toUpperCase();return D([`${n.toLowerCase()}_${e.name}`,`${n}_${e.name}`,`${e.name}_${n.toLowerCase()}`,`${e.name}_${n}`,e.name])}function rn(e){const n=new Map;for(const r of e)n.set(r.raw.name,(n.get(r.raw.name)||0)+1);return new Set(Array.from(n.entries()).filter(([,r])=>r>1).map(([r])=>r))}function tn(e,n){const r=b(n.spec);if(!r)return;const t=j(n.builder);if(t==="records"){for(const o of v(r.fields))h(e,o);return}if(t==="sql"){for(const o of v(r.fields))h(e,o);return}if(t==="analysis"||t==="metric"){h(e,r.primaryMeasure);for(const o of v(r.measures))h(e,o);for(const o of v(r.dimensions))h(e,o);h(e,r.dateField);return}if(t==="matrix"){const o=ce(r.rows),a=ce(r.columns),l=v(r.values);for(const y of o)me(e,y);for(const y of a)me(e,y);for(const y of l){const S=b(y);h(e,S==null?void 0:S.field),h(e,S==null?void 0:S.measure)}}}function ce(e){if(Array.isArray(e))return e;const n=b(e);return Array.isArray(n==null?void 0:n.levels)?n.levels:[]}function me(e,n){var r;if(E(n)){h(e,n);return}h(e,(r=b(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 on(e){const n=b(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 h(e,n){E(n)&&e.push(L(n))}function L(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 sn(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:Fe(n),name:""}}function E(e){const n=b(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=b(e);return!!(n&&(typeof n.sourceKey=="string"||n.kind==="semantic"||typeof n.datasetName=="string"&&typeof n.domainId=="string"))}function x(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=>x(o,n)).join(", ")}]`;if(E(e)){const o=N(L(e),n);if(o)return`fields.${o}`}if(we(e)){const o=$e(e,n);if(o)return`sources.${o}`}const r=b(e);return r?`{ ${Object.entries(r).filter(([,o])=>o!==void 0).map(([o,a])=>`${JSON.stringify(o)}: ${x(a,n)}`).join(", ")} }`:JSON.stringify(e)}function k(e){return JSON.stringify(e,null,2)}function N(e,n){if(E(e))return n.fieldNameByKey.get(J(L(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 J(e){return[e.sourceKey||"",e.name||"",e.role||"",e.aggregate||""].join("|")}function an(e,n){return!E(e)||!E(n)||e.name!==n.name?!1:de(e).some(r=>de(n).includes(r))}function un(e){return E(e)&&e.role==="id"}function dn(e){const n=[],r=new Map;for(const t of e){const o=D(t.aliases.length?t.aliases:[t.key]),a=o.map(l=>r.get(l)).find(G);if(a){a.aliases=D([...a.aliases,...o]);continue}t.aliases=o,n.push(t);for(const l of o)r.set(l,t)}return n}function pn(e){const n=new Map;for(const r of e)for(const t of D([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 D(e){return Array.from(new Set(e.filter(Boolean)))}function Ie(e){return ee(e)[0]||le(e)}function ee(e){const n=b(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)),D(r)}function Fe(e){return ee(e)}function le(e){const n=b(e);return n?typeof n.sourceKey=="string"?n.sourceKey:JSON.stringify(n):""}function ln(e){return E(e)&&de(e)[0]||""}function de(e){return E(e)?D([...typeof e.sourceKey=="string"?[e.sourceKey]:[],...e.source?ee(e.source):[]]):[]}function j(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 cn(e){const n=j(e);return n==="records"||n==="sql"}function mn(e){const n=b(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 H(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 q(e){const n=String(e||"").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);if(n.length===0)return"item";const[r,...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=q(e);return n.charAt(0).toUpperCase()+n.slice(1)}function fn(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 b(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function v(e){return Array.isArray(e)?e:[]}function Y(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function G(e){return e!==void 0}exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=Z.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=Z.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=Z.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=Z.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=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=ke;exports.generateSemaphorDataAppContract=Me;
|