react-semaphor 0.1.416 → 0.1.418
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 +49 -50
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +2 -2
- package/dist/chunks/analyze-result-contract-Akysi2ML.js +2003 -0
- package/dist/chunks/analyze-result-contract-COjyJzYm.js +1 -0
- package/dist/chunks/{calendar-preferences-dialog-B8FmFRHX.js → calendar-preferences-dialog-BbuLgela.js} +3 -3
- package/dist/chunks/{calendar-preferences-dialog-ck4AU-to.js → calendar-preferences-dialog-CInkkhl_.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Br_1IK1z.js → dashboard-briefing-launcher-B4OWNsVD.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Tr2SqDMK.js → dashboard-briefing-launcher-D7FNuDuc.js} +4 -4
- package/dist/chunks/{dashboard-controls-B7OObDNl.js → dashboard-controls-DTC1eCz0.js} +1 -1
- package/dist/chunks/{dashboard-controls-B2bEv8uG.js → dashboard-controls-DcX7Mid4.js} +5 -5
- package/dist/chunks/{dashboard-json-DAB8WVyb.js → dashboard-json-BHWbQS6I.js} +3 -3
- package/dist/chunks/{dashboard-json-DNixjalS.js → dashboard-json-vu38P5pV.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DWygSAp3.js → edit-dashboard-visual-CkBhJBhp.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-Dh8Ge3-B.js → edit-dashboard-visual-DsCr90_3.js} +4 -4
- package/dist/chunks/{index-BkTLAfKy.js → index-C56DuHI8.js} +163 -164
- package/dist/chunks/{index-CQIMj-FF.js → index-C8thRvkW.js} +4 -4
- package/dist/chunks/{switch-DMlqgIx_.js → switch-BXuyni6l.js} +1 -1
- package/dist/chunks/{switch-DgiogS4X.js → switch-Dsx-IwBE.js} +1 -1
- package/dist/chunks/{update-policy-BnEbPhHW.js → update-policy-B5S_LfEu.js} +347 -314
- package/dist/chunks/update-policy-BqBKUk3Q.js +3 -0
- package/dist/chunks/{use-create-flow-overlay-state-CZA-dSns.js → use-create-flow-overlay-state-BDv_VpL6.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-uujasvbD.js → use-create-flow-overlay-state-CzftV84t.js} +3 -3
- package/dist/chunks/{validators-UqQI3Cg_.js → validators-CLzrE2N_.js} +1 -1
- package/dist/chunks/validators-CPFcUMrV.js +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +28 -29
- 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 +154 -125
- package/dist/data-app-codegen-node/index.js +691 -609
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +171 -157
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +26 -27
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +17 -18
- 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 +6 -1
- package/dist/types/dashboard-assistant.d.ts +1 -0
- package/dist/types/data-app-codegen-node.d.ts +5 -3
- package/dist/types/data-app-codegen.d.ts +5 -3
- package/dist/types/data-app-sdk-validation.d.ts +1 -0
- package/dist/types/data-app-sdk.d.ts +6 -0
- package/package.json +1 -1
- package/dist/chunks/analyze-result-contract-8nxUOWp8.js +0 -1
- package/dist/chunks/analyze-result-contract-DPjm6btg.js +0 -1869
- package/dist/chunks/source-identity-BM2FvJDP.js +0 -1
- package/dist/chunks/source-identity-Cv4Nm3TM.js +0 -75
- package/dist/chunks/update-policy-CWg9c08k.js +0 -3
- package/dist/chunks/validators-JzI7olk4.js +0 -1
|
@@ -1,56 +1,56 @@
|
|
|
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-COjyJzYm.js"),V=require("../chunks/update-policy-BqBKUk3Q.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(
|
|
6
|
-
`);const
|
|
7
|
-
`);const
|
|
8
|
-
`);const
|
|
9
|
-
`);const
|
|
10
|
-
`);const
|
|
11
|
-
`)}function X(e){var n;return
|
|
12
|
-
`),r=e.sources.some(
|
|
13
|
-
|
|
14
|
-
`:"";return`${
|
|
3
|
+
`;function Ce(e,n={}){V.assertValidCodegenSummary(e);const r=Me(e);if(r.views.length===0&&!n.allowEmpty)throw new Error("Contract generation produced zero executable views. Stop and ask for a different domain/goal or semantic model improvement; pass --allow-empty only for an explicit model-gap report.");const t=Oe(r),o=Ee({contract:r,files:t,generatorName:n.generatorName||"react-semaphor/data-app-codegen/node",generatorVersion:n.generatorVersion||"unknown"}),i={...t,"contract.manifest.json":`${JSON.stringify(o,null,2)}
|
|
4
|
+
`};return{schemaVersion:V.GENERATED_CONTRACT_SCHEMA_VERSION,files:i,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 Me(e){var d,s,u,c,p,w,$,F,b,G,R,N;const n=[],r=[];for(const a of e.inputs){g(r,a.fieldRef);for(const S of a.bindings||[])g(r,S.fieldRef);g(r,(d=a.optionQuery)==null?void 0:d.valueFieldRef),g(r,(s=a.optionQuery)==null?void 0:s.labelFieldRef),g(r,(u=a.optionQuery)==null?void 0:u.filterFieldRef),Q(r,(c=a.optionQuery)==null?void 0:c.spec)}for(const a of e.filterContracts){g(r,a.fieldRef),g(r,(p=a.optionQuery)==null?void 0:p.valueFieldRef),g(r,(w=a.optionQuery)==null?void 0:w.labelFieldRef),g(r,($=a.optionQuery)==null?void 0:$.filterFieldRef),Q(r,(F=a.optionQuery)==null?void 0:F.spec);for(const S of a.bindings||[])g(r,S.fieldRef)}for(const a of e.views){for(const S of a.fields||[])g(r,S);Q(r,(b=a.sdkSpec)==null?void 0:b.spec),Q(r,a.visualSpec)}const t=e.implementationChecklist||{};for(const a of Object.values(t.bindingsByView||{}))for(const S of Array.isArray(a)?a:[])g(r,S.fieldRef),g(r,S.optionValueField),g(r,S.optionLabelField);for(const a of t.requiredInputOptions||[])g(r,a.visibleLabelField),g(r,a.optionValueField),g(r,a.runtimeFilterField);const o=dn([...e.sources.map(a=>({raw:a,key:$e(a),aliases:Fe(a),name:""})),...r.map(a=>sn(a)).filter(x)]);H(o,a=>{const S=I(a.raw);return q(a.raw.label||(S==null?void 0:S.datasetName)||(S==null?void 0:S.datasetId)||(S==null?void 0:S.name)||a.raw.kind||"source")});const i=pn(o),l=ne(r.filter(a=>a.name).map(a=>({raw:a,key:L(a),name:""})),a=>a.key);H(l,a=>q([a.raw.sourceKey?fn(a.raw.sourceKey):"",a.raw.aggregate?a.raw.aggregate.toLowerCase():"",a.raw.name].filter(Boolean).join("_")));const y=new Map(l.map(a=>[a.key,a.name])),h=e.inputs.map(a=>({raw:a,name:q(a.id||a.label||"input")}));H(h,a=>a.name);const f=h.filter(a=>!!a.raw.optionQuery).map(a=>({input:a,name:`${a.name}Options`,raw:a.raw.optionQuery}));H(f,a=>a.name);for(const a of f)an(a.raw.labelFieldRef,a.raw.valueFieldRef)&&un(a.raw.valueFieldRef)&&n.push(`Input option query ${((G=a.raw.spec)==null?void 0:G.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 m=e.views.filter(a=>{var S,j;return!!((S=a.sdkSpec)!=null&&S.builder&&((j=a.sdkSpec)!=null&&j.spec))}).map(a=>({raw:a,name:q(a.id||a.title||"query")}));H(m,a=>a.name);const M=e.views.filter(a=>fe(a)&&!("sdkSpec"in a)).map(a=>on(a));for(const a of e.views)(!("sdkSpec"in a)||!((R=a.sdkSpec)!=null&&R.builder)||!((N=a.sdkSpec)!=null&&N.spec))&&!fe(a)&&n.push(`Skipped view ${a.id||a.title||"unknown"} because it has no sdkSpec.`);return Ne({inputs:h,views:m,filterContracts:e.filterContracts}),{summary:e,title:e.title||"Semaphor Data App",sources:o,fields:l,inputs:h,optionQueries:f,views:m,presentationViews:M,filterContracts:e.filterContracts,checklist:t,sourceNameByKey:i,fieldNameByKey:y,warnings:n}}function Ne({inputs:e,views:n,filterContracts:r}){const t=new Set(e.map(i=>i.raw.id).filter(Boolean)),o=new Set(n.map(i=>i.raw.id).filter(Boolean));for(const[i,l]of r.entries()){if(!t.has(l.inputId))throw new Error(`filterContracts.${i}.inputId must reference a generated input.`);const y=new Set(l.appliesToViewIds||[]),h=new Set(l.notAppliedToViewIds||[]);for(const[f,m]of(l.appliesToViewIds||[]).entries())if(!o.has(m))throw new Error(`filterContracts.${i}.appliesToViewIds.${f} must reference an executable generated view.`);for(const[f,m]of(l.notAppliedToViewIds||[]).entries())if(!o.has(m))throw new Error(`filterContracts.${i}.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.${i}.bindings.${f}.viewId must reference an executable generated view.`);if(!y.has(m.viewId))throw new Error(`filterContracts.${i}.bindings.${f}.viewId must be included in appliesToViewIds.`);if(h.has(m.viewId))throw new Error(`filterContracts.${i}.bindings.${f}.viewId must not be listed in notAppliedToViewIds.`)}}}function Oe(e){return{"sources.ts":Ke(e),"fields.ts":ve(e),"inputs.ts":Be(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:V.CONTRACT_MANIFEST_SCHEMA_VERSION,generatedContractSchemaVersion:V.GENERATED_CONTRACT_SCHEMA_VERSION,generator:{name:r,version:t},generatedContentHash:Ae(n),codegenSummaryValidatorVersion:V.CODEGEN_SUMMARY_VALIDATOR_VERSION,codegenSummaryHash:xe(e.summary),codegenSummary:e.summary}}function Ae(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 xe(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, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const sortOption = recordsSortOptionsForView.${n.name}[0];`,'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',`const query = queries.${n.name}({ page, pageSize, sort });`,`const result = useSemaphorQuery(query, queryOptionsForView.${n.name}(inputHandles));`,`const rows = result.records.map((row) => rowValuesForView.${n.name}(row, result.columns));`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
5
|
+
`);const r=e.views.find(f=>T(f));if(r)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const sortOption = recordsSortOptionsForView.${r.name}[0];`,'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',`const query = queries.${r.name}({ sort });`,`const result = useSemaphorQuery(query, queryOptionsForView.${r.name}(inputHandles));`,`const rows = result.records.map((row) => rowValuesForView.${r.name}(row, result.columns));`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
6
|
+
`);const t=e.views.find(f=>X(f)&&_(f));if(t)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const query = queries.${t.name}({ page, pageSize });`,`const result = useSemaphorQuery(query, queryOptionsForView.${t.name}(inputHandles));`,`const rows = result.records.map((row) => rowValuesForView.${t.name}(row, result.columns));`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
7
|
+
`);const o=e.views.find(f=>pe(f)&&_(f));if(o)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const query = queries.${o.name}({ page, pageSize });`,`const result = useSemaphorQuery(query, queryOptionsForView.${o.name}(inputHandles));`,`const rows = result.records.map((row) => rowValuesForView.${o.name}(row, result.columns));`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
8
|
+
`);const i=e.views.find(f=>{var m;return cn((m=f.raw.sdkSpec)==null?void 0:m.builder)});if(i)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const result = useSemaphorQuery(queries.${i.name}(), queryOptionsForView.${i.name}(inputHandles));`,`const rows = result.records.map((row) => rowValuesForView.${i.name}(row, result.columns));`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
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
|
+
`);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 B((n=e.raw.sdkSpec)==null?void 0:n.builder)==="records"}function Te(e){var n;return B((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 B((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 i=He(o);return` ${t}: ${i},`}).join(`
|
|
12
|
+
`),r=e.sources.some(t=>t.raw.kind==="semantic")?`import { semaphor } from "react-semaphor/data-app-sdk";
|
|
13
|
+
|
|
14
|
+
`:"";return`${K}
|
|
15
15
|
${r}export const sources = {
|
|
16
16
|
${n}
|
|
17
17
|
} as const;
|
|
18
|
-
`}function
|
|
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 i=qe(o,e);return` ${t}: ${i},`}).join(`
|
|
19
19
|
`),r=n.includes("sources.")?`import { sources } from "./sources";
|
|
20
20
|
|
|
21
|
-
`:"";return`${
|
|
21
|
+
`:"";return`${K}
|
|
22
22
|
${r}export const fields = {
|
|
23
23
|
${n}
|
|
24
24
|
} as const;
|
|
25
|
-
`}function
|
|
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 i=Object.entries(A(r)).map(([l,y])=>`${JSON.stringify(l)}: ${E(y,n)}`);return o&&i.push(`"source": sources.${o}`),`{ ${i.join(", ")} }`}function Be(e){const n=e.inputs.map(u=>{const c=C(u.raw.fieldRef,e),p=[`id: ${JSON.stringify(u.raw.id)}`,`label: ${JSON.stringify(u.raw.label||u.raw.id)}`,`operator: ${JSON.stringify(mn(u.raw))}`];if(c&&p.push(`field: fields.${c}`),u.raw.relationshipHint&&p.push(`relationshipHint: ${k(u.raw.relationshipHint)}`),!c)throw new Error(`Input ${u.raw.id||u.name} is missing a generated field reference.`);return` ${u.name}: semaphor.filter({ ${p.join(", ")} }),`}).join(`
|
|
26
|
+
`),r=e.inputs.map(u=>`filterSpecs.${u.name}`).join(", "),t=e.inputs.map(u=>JSON.stringify(u.raw.id)).join(", "),o=e.optionQueries.map(u=>{const c=u.input.raw,p=u.raw,w=I(p.spec)||{},{id:$,inputId:F,source:b,sourceKey:G,valueField:R,labelField:N,population:a,dependencies:S,limit:j,...re}=w,J=p.sourceKey?{sourceKey:p.sourceKey}:p.source||b||(typeof G=="string"?{sourceKey:G}:void 0),te=Ie(J,e),oe=C(p.valueFieldRef,e),se=C(p.labelFieldRef,e),ae=he(u),ie={...re,id:p.id||w.id||`${c.id}-options`,inputId:c.id,source:J,valueField:p.valueFieldRef,labelField:p.labelFieldRef,population:p.population||a,dependencies:ae,limit:p.limit||j||100};if(!te||!oe||!se)throw new Error(`Input option query ${p.id||`${c.id}-options`} is missing source, valueField, or labelField.`);const Ve=Object.entries(A(ie)).map(([be,Re])=>`${JSON.stringify(be)}: ${E(Re,e)}`);return` ${u.name}: semaphor.inputOptions({ ${Ve.join(", ")} }),`}).join(`
|
|
27
|
+
`),i=e.optionQueries.map(u=>{const c=je(e,u),p=c.length>0?"inputHandles":"_inputHandles",w=c.map($=>{const F=C($.raw.fieldRef,e);if(!F)throw new Error(`Input option query ${u.raw.id||`${u.input.raw.id}-options`} references input ${$.raw.id} without a generated field reference.`);const b=`inputHandles[${JSON.stringify($.raw.id)}]`;return` if (${b}) {
|
|
28
|
+
inputs.push(semaphor.bindInput(${b}, { field: fields.${F} }));
|
|
29
29
|
}`}).join(`
|
|
30
|
-
`);return` ${
|
|
30
|
+
`);return` ${u.name}(${p}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
31
31
|
const inputs: SemaphorInputReference[] = [];
|
|
32
|
-
${
|
|
32
|
+
${w}
|
|
33
33
|
return inputs;
|
|
34
34
|
},`}).join(`
|
|
35
35
|
|
|
36
|
-
`),
|
|
36
|
+
`),l=e.optionQueries.map(u=>` ${u.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
37
37
|
return {
|
|
38
|
-
inputs: inputsForInputOptionQuery.${
|
|
38
|
+
inputs: inputsForInputOptionQuery.${u.name}(inputHandles),
|
|
39
39
|
};
|
|
40
40
|
},`).join(`
|
|
41
41
|
|
|
42
|
-
`),
|
|
43
|
-
return queryOptionsForInputOptionQuery.${
|
|
44
|
-
`),h=e.inputs.length>0,
|
|
45
|
-
`);return`${
|
|
46
|
-
${
|
|
42
|
+
`),y=e.optionQueries.map(u=>` case ${JSON.stringify(u.raw.id||`${u.input.raw.id}-options`)}:
|
|
43
|
+
return queryOptionsForInputOptionQuery.${u.name}(inputHandles);`).join(`
|
|
44
|
+
`),h=e.inputs.length>0,f=e.optionQueries.length>0,m=f?"inputOptionQueryId":"_inputOptionQueryId",M=f?"inputHandles":"_inputHandles",d=["SemaphorInputHandle",f?"SemaphorInputReference":void 0,"SemaphorQueryRuntimeOptions"].filter(x).join(", "),s=[h||f?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,`import type { ${d} } from "react-semaphor/data-app-sdk";`,h||f?'import { fields } from "./fields";':void 0,f?'import { sources } from "./sources";':void 0,'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'].filter(x).join(`
|
|
45
|
+
`);return`${K}
|
|
46
|
+
${s}
|
|
47
47
|
|
|
48
48
|
export const filterSpecs = {
|
|
49
49
|
${n}
|
|
50
50
|
} as const;
|
|
51
51
|
|
|
52
52
|
export const appInputSpecs = [${r}] as const;
|
|
53
|
-
export const appInputIds = [${
|
|
53
|
+
export const appInputIds = [${t}] as const;
|
|
54
54
|
|
|
55
55
|
export type SemaphorGeneratedInputHandleMap = Partial<Record<SemaphorGeneratedInputId, SemaphorInputHandle>>;
|
|
56
56
|
|
|
@@ -59,61 +59,61 @@ export function createInputHandleMap(handles: readonly SemaphorInputHandle[]): S
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export const inputOptionQueries = {
|
|
62
|
-
${
|
|
62
|
+
${o}
|
|
63
63
|
} as const;
|
|
64
64
|
|
|
65
65
|
export const inputsForInputOptionQuery = {
|
|
66
|
-
${
|
|
66
|
+
${i}
|
|
67
67
|
} as const;
|
|
68
68
|
|
|
69
69
|
export const queryOptionsForInputOptionQuery = {
|
|
70
|
-
${
|
|
70
|
+
${l}
|
|
71
71
|
} as const;
|
|
72
72
|
|
|
73
73
|
export function queryOptionsForInputOptionQueryId(
|
|
74
|
-
${
|
|
75
|
-
${
|
|
74
|
+
${m}: SemaphorGeneratedInputOptionQueryId,
|
|
75
|
+
${M}: SemaphorGeneratedInputHandleMap,
|
|
76
76
|
): SemaphorQueryRuntimeOptions {
|
|
77
|
-
switch (${
|
|
78
|
-
${
|
|
77
|
+
switch (${m}) {
|
|
78
|
+
${y}
|
|
79
79
|
}
|
|
80
|
-
throw new Error(\`Unknown generated Semaphor input option query id: \${${
|
|
80
|
+
throw new Error(\`Unknown generated Semaphor input option query id: \${${m}}\`);
|
|
81
81
|
}
|
|
82
|
-
`}function
|
|
83
|
-
recordsSortFieldsForView.${
|
|
82
|
+
`}function je(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(i=>o.has(i.raw.id)?!1:t.has(i.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(s=>{var p,w,$,F,b,G;const u=B(s.raw.sdkSpec.builder),c=Pe(s);if(X(s)&&_e(s)){const R=(p=s.raw.visualSpec)==null?void 0:p.tableBehavior,N=I(c.pagination),a=_(s),S=T(s),j=((w=R==null?void 0:R.pagination)==null?void 0:w.pageSize)||z(N==null?void 0:N.pageSize)||z(c.limit)||100,re=S?Y(s,e):[],J=S?De({view:s,contract:e,sortFields:re,defaultField:($=R==null?void 0:R.sorting)==null?void 0:$.defaultField}):void 0,te=S?(F=R==null?void 0:R.sorting)==null?void 0:F.defaultDirection:void 0,oe=Ue({viewName:s.name,supportsPagination:a,supportsSort:S}),se=S?` const orderBy = resolveRecordsOrderBy(
|
|
83
|
+
recordsSortFieldsForView.${s.name},
|
|
84
84
|
params.sort,
|
|
85
|
-
${E(
|
|
85
|
+
${E(J,e)},
|
|
86
86
|
${E(te,e)},
|
|
87
87
|
);
|
|
88
88
|
`:"",ae=S?` ...(orderBy ? { orderBy } : {}),
|
|
89
|
-
`:"",ie=
|
|
90
|
-
`:"";return` ${
|
|
89
|
+
`:"",ie=a?` pagination: resolveServerTablePagination(params, ${JSON.stringify(j)}),
|
|
90
|
+
`:"";return` ${s.name}(
|
|
91
91
|
params: ${oe} = {},
|
|
92
92
|
) {
|
|
93
|
-
${se} return semaphor.${
|
|
94
|
-
...${E(
|
|
93
|
+
${se} return semaphor.${u}({
|
|
94
|
+
...${E(c,e)},
|
|
95
95
|
${ae}${ie} });
|
|
96
|
-
},`}if(pe(
|
|
96
|
+
},`}if(pe(s)&&_(s)){const R=(b=s.raw.visualSpec)==null?void 0:b.tableBehavior,N=I(c.pagination),a=((G=R==null?void 0:R.pagination)==null?void 0:G.pageSize)||z(N==null?void 0:N.pageSize)||z(c.limit)||100;return` ${s.name}(
|
|
97
97
|
params: SemaphorGeneratedServerPaginationParams = {},
|
|
98
98
|
) {
|
|
99
|
-
return semaphor.${
|
|
100
|
-
...${E(
|
|
101
|
-
pagination: resolveServerTablePagination(params, ${JSON.stringify(
|
|
99
|
+
return semaphor.${u}({
|
|
100
|
+
...${E(c,e)},
|
|
101
|
+
pagination: resolveServerTablePagination(params, ${JSON.stringify(a)}),
|
|
102
102
|
});
|
|
103
|
-
},`}return` ${
|
|
104
|
-
`),r=e.views.filter(
|
|
105
|
-
`);return` ${
|
|
106
|
-
${
|
|
103
|
+
},`}return` ${s.name}: () => semaphor.${u}(${E(c,e)}),`}).join(`
|
|
104
|
+
`),r=e.views.filter(s=>T(s)).map(s=>{const c=Y(s,e).map(p=>` ${JSON.stringify(p.key)}: fields.${p.fieldName},`).join(`
|
|
105
|
+
`);return` ${s.name}: {
|
|
106
|
+
${c}
|
|
107
107
|
},`}).join(`
|
|
108
|
-
`),
|
|
109
|
-
`);return` ${
|
|
110
|
-
${
|
|
108
|
+
`),t=e.views.filter(s=>T(s)).map(s=>{const c=Y(s,e).map(p=>` { key: ${JSON.stringify(p.key)}, label: ${JSON.stringify(p.label)}, field: fields.${p.fieldName} },`).join(`
|
|
109
|
+
`);return` ${s.name}: [
|
|
110
|
+
${c}
|
|
111
111
|
],`}).join(`
|
|
112
|
-
`),
|
|
113
|
-
`),
|
|
114
|
-
`);return`${
|
|
115
|
-
${
|
|
116
|
-
${
|
|
112
|
+
`),o=e.views.some(s=>T(s)),i=e.views.some(s=>_(s)),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(x).join(`
|
|
114
|
+
`);return`${K}
|
|
115
|
+
${y}
|
|
116
|
+
${o?`export type SemaphorGeneratedRecordsSortDirection = "asc" | "desc";
|
|
117
117
|
|
|
118
118
|
export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
119
119
|
key: TSortKey;
|
|
@@ -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
|
+
`:""}${i?`export type SemaphorGeneratedServerPaginationParams = {
|
|
127
127
|
page?: number;
|
|
128
128
|
pageSize?: number;
|
|
129
129
|
};
|
|
130
|
-
`:""}${
|
|
130
|
+
`:""}${o&&i?`export type SemaphorGeneratedRecordsQueryParams<TSortKey extends string = string> =
|
|
131
131
|
SemaphorGeneratedServerPaginationParams &
|
|
132
132
|
SemaphorGeneratedRecordsSortParams<TSortKey>;
|
|
133
133
|
`:""}
|
|
@@ -137,14 +137,14 @@ ${r}
|
|
|
137
137
|
} as const;
|
|
138
138
|
|
|
139
139
|
export const recordsSortOptionsForView = {
|
|
140
|
-
${
|
|
140
|
+
${t}
|
|
141
141
|
} as const;
|
|
142
142
|
|
|
143
143
|
export const queries = {
|
|
144
144
|
${n}
|
|
145
145
|
} as const;
|
|
146
146
|
|
|
147
|
-
${
|
|
147
|
+
${o?`function resolveRecordsOrderBy<TSortKey extends string>(
|
|
148
148
|
sortFields: Record<TSortKey, SemaphorFieldRef>,
|
|
149
149
|
sort: SemaphorGeneratedRecordsSort<TSortKey> | null | undefined,
|
|
150
150
|
defaultKey: TSortKey | undefined,
|
|
@@ -164,7 +164,7 @@ ${t?`function resolveRecordsOrderBy<TSortKey extends string>(
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
`:""}
|
|
167
|
-
${
|
|
167
|
+
${i?`function resolveServerTablePagination(
|
|
168
168
|
params: SemaphorGeneratedServerPaginationParams,
|
|
169
169
|
defaultPageSize: number,
|
|
170
170
|
) {
|
|
@@ -174,36 +174,36 @@ ${a?`function resolveServerTablePagination(
|
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
`:""}
|
|
177
|
-
`}function
|
|
178
|
-
inputs.push(semaphor.bindInput(${w}, { ${
|
|
177
|
+
`}function Pe(e){var i,l;const n=I((i=e.raw.sdkSpec)==null?void 0:i.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 Y(e,n){var i,l;const r=[],t=I((i=e.raw.sdkSpec)==null?void 0:i.spec)||{};for(const y of v(t.fields))g(r,y);g(r,t.dateField),g(r,(l=I(t.orderBy))==null?void 0:l.field);for(const y of e.raw.fields||[])g(r,y);return ne(r.map(y=>{const h=C(y,n);if(!(!y.name||!h))return{key:h,fieldName:h,rawName:y.name,label:y.label||y.name}}).filter(x),y=>y.key)}function De({view:e,contract:n,sortFields:r,defaultField:t}){var h,f;const o=new Set(r.map(m=>m.key));if(t&&o.has(t))return t;const i=r.filter(m=>m.rawName===t);if(i.length===1)return i[0].key;const l=I((h=e.raw.sdkSpec)==null?void 0:h.spec),y=C((f=I(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 d=Je(e,m.raw.id).map(s=>{const u=s.inputId,c=C(s.fieldRef,e);if(!u||!c)return"";const p=[`field: fields.${c}`];if(s.relationshipHint)p.push(`relationshipHint: ${k(s.relationshipHint)}`);else if(Array.isArray(s.relationshipsUsed)&&s.relationshipsUsed.length>0){const $=s.relationshipsUsed.map(F=>{var b;return(b=I(F))==null?void 0:b.id}).filter(F=>typeof F=="string"&&F.length>0);$.length>0&&p.push(`relationshipHint: ${k({relationshipIds:$})}`)}const w=`inputHandles[${JSON.stringify(u)}]`;return` if (${w}) {
|
|
178
|
+
inputs.push(semaphor.bindInput(${w}, { ${p.join(", ")} }));
|
|
179
179
|
}`}).filter(Boolean).join(`
|
|
180
|
-
`);return{view:
|
|
180
|
+
`);return{view:m,renderedBindings:d}}),r=n.some(m=>m.renderedBindings.length>0),t=n.map(({view:m,renderedBindings:M})=>{const d=M?"inputHandles":"_inputHandles";return` ${m.name}(${d}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
181
181
|
const inputs: SemaphorInputReference[] = [];
|
|
182
|
-
${
|
|
182
|
+
${M}
|
|
183
183
|
return inputs;
|
|
184
184
|
},`}).join(`
|
|
185
185
|
|
|
186
|
-
`),
|
|
186
|
+
`),o=e.views.map(m=>` ${m.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
187
187
|
return {
|
|
188
|
-
inputs: inputsForView.${
|
|
189
|
-
debug: queryDebugForView.${
|
|
188
|
+
inputs: inputsForView.${m.name}(inputHandles),
|
|
189
|
+
debug: queryDebugForView.${m.name},
|
|
190
190
|
};
|
|
191
191
|
},`).join(`
|
|
192
192
|
|
|
193
|
-
`),
|
|
194
|
-
return inputsForView.${
|
|
195
|
-
`),
|
|
196
|
-
return queryOptionsForView.${
|
|
197
|
-
`),
|
|
198
|
-
`);return`${
|
|
199
|
-
${
|
|
193
|
+
`),i=e.views.map(m=>` case ${JSON.stringify(m.raw.id)}:
|
|
194
|
+
return inputsForView.${m.name}(inputHandles);`).join(`
|
|
195
|
+
`),l=e.views.map(m=>` case ${JSON.stringify(m.raw.id)}:
|
|
196
|
+
return queryOptionsForView.${m.name}(inputHandles);`).join(`
|
|
197
|
+
`),y=e.views.length>0,h=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(x).join(`
|
|
198
|
+
`);return`${K}
|
|
199
|
+
${f}
|
|
200
200
|
|
|
201
201
|
export const inputsForView = {
|
|
202
|
-
${
|
|
202
|
+
${t}
|
|
203
203
|
} as const;
|
|
204
204
|
|
|
205
205
|
export const queryOptionsForView = {
|
|
206
|
-
${
|
|
206
|
+
${o}
|
|
207
207
|
} as const;
|
|
208
208
|
|
|
209
209
|
export function inputsForViewId(
|
|
@@ -211,7 +211,7 @@ export function inputsForViewId(
|
|
|
211
211
|
${h}: SemaphorGeneratedInputHandleMap,
|
|
212
212
|
): SemaphorInputReference[] {
|
|
213
213
|
switch (viewId) {
|
|
214
|
-
${
|
|
214
|
+
${i}
|
|
215
215
|
}
|
|
216
216
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
217
217
|
}
|
|
@@ -221,56 +221,66 @@ export function queryOptionsForViewId(
|
|
|
221
221
|
${h}: 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
|
|
229
|
-
`);return` ${
|
|
230
|
-
${
|
|
231
|
-
},`}).join(`
|
|
232
|
-
`),r=e.views.map(l=>{const d=J(l,e).map(m=>{const c=C(m.raw,e);return c?` ${m.name}: fields.${c},`:""}).filter(Boolean).join(`
|
|
233
|
-
`);return` ${l.name}: {
|
|
234
|
-
${d}
|
|
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(s=>{const c=W(s,e).map(p=>{const w=C(p.raw,e);return w?` ${p.name}: fields.${w},`:""}).filter(Boolean).join(`
|
|
229
|
+
`);return` ${s.name}: {
|
|
230
|
+
${c}
|
|
235
231
|
},`}).join(`
|
|
236
|
-
`),
|
|
237
|
-
`);return` ${
|
|
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}: {
|
|
238
234
|
${c}
|
|
239
235
|
},`}).join(`
|
|
240
|
-
`),t=e.views.map(
|
|
241
|
-
`);return` ${
|
|
242
|
-
${
|
|
236
|
+
`),t=e.views.map(s=>{const u=D(s,e),c=rn(u),p=nn(u),w=u.map($=>{const F=Array.from(new Set(Se($.raw).filter(b=>p.has(b))));return` ${$.name}: metricKeysForField(metricFieldsForView.${s.name}.${$.name}, { allowNameFallback: ${c.has($.raw.name)?"false":"true"}, excludedKeys: ${k(F)} }),`}).join(`
|
|
237
|
+
`);return` ${s.name}: {
|
|
238
|
+
${w}
|
|
243
239
|
},`}).join(`
|
|
244
|
-
`),
|
|
240
|
+
`),o=e.views.map(s=>{const c=D(s,e).map((p,w)=>` ${p.name}: ${JSON.stringify(Xe(s,p,w))},`).join(`
|
|
241
|
+
`);return` ${s.name}: {
|
|
242
|
+
${c}
|
|
243
|
+
},`}).join(`
|
|
244
|
+
`),i=e.views.map(s=>{const u=D(s,e);if(u.length===0)return` ${s.name}(): Record<keyof typeof metricFieldsForView.${s.name}, unknown> {
|
|
245
245
|
return {};
|
|
246
|
-
},`;const
|
|
247
|
-
`);return` ${
|
|
246
|
+
},`;const c=en(s,u),p=u.map(w=>{const $=`metricMeasureKeysForView.${s.name}.${w.name}`,F=`metricMeasureBindingKeysForView.${s.name}.${w.name}`,b=c.has(w.name)?`readMetricValueByBindingWithFallback(measures, measureBindings, ${F}, ${$}, scalarValue)`:`readMetricValueByBinding(measures, measureBindings, ${F}, ${$})`;return` ${w.name}: ${b},`}).join(`
|
|
247
|
+
`);return` ${s.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${s.name}, unknown> {
|
|
248
248
|
const measures = result?.measures;
|
|
249
249
|
const measureBindings = result?.measureBindings;
|
|
250
250
|
const scalarValue = result?.value;
|
|
251
251
|
return {
|
|
252
|
-
${
|
|
252
|
+
${p}
|
|
253
253
|
};
|
|
254
254
|
},`}).join(`
|
|
255
255
|
|
|
256
|
-
`),
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
`),l=e.views.map(s=>{const u=D(s,e);if(u.length===0)return` ${s.name}(): Array<keyof typeof metricFieldsForView.${s.name}> {
|
|
257
|
+
return [];
|
|
258
|
+
},`;const c=u.map(p=>` ...(missing.has(metricMeasureBindingKeysForView.${s.name}.${p.name}) ? [${JSON.stringify(p.name)} as keyof typeof metricFieldsForView.${s.name}] : []),`).join(`
|
|
259
|
+
`);return` ${s.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${s.name}> {
|
|
260
|
+
const missing = new Set(result?.missingMeasures || []);
|
|
261
|
+
return [
|
|
262
|
+
${c}
|
|
263
|
+
];
|
|
264
|
+
},`}).join(`
|
|
265
|
+
|
|
266
|
+
`),y=e.views.map(s=>{const u=Ye(s,e);return` ${s.name}: ${k(u)},`}).join(`
|
|
267
|
+
`),h=e.views.map(s=>{const c=W(s,e).map(p=>` ${p.name}: resolveColumnKey(columns, fieldsForView.${s.name}.${p.name}),`).join(`
|
|
268
|
+
`);return` ${s.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${s.name}, string | undefined> {
|
|
259
269
|
return {
|
|
260
|
-
${
|
|
270
|
+
${c}
|
|
261
271
|
};
|
|
262
272
|
},`}).join(`
|
|
263
273
|
|
|
264
|
-
`),
|
|
265
|
-
`);return` ${
|
|
274
|
+
`),f=e.views.map(s=>{const c=W(s,e).map(p=>` ${p.name}: readCell(row, columns, fieldsForView.${s.name}.${p.name}),`).join(`
|
|
275
|
+
`);return` ${s.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${s.name}, unknown> {
|
|
266
276
|
return {
|
|
267
|
-
${
|
|
277
|
+
${c}
|
|
268
278
|
};
|
|
269
279
|
},`}).join(`
|
|
270
280
|
|
|
271
|
-
`),
|
|
272
|
-
`);return`${
|
|
273
|
-
${
|
|
281
|
+
`),m=n.includes("fields.")||r.includes("fields."),d=[`import { ${["type SemaphorFieldRef","type SemaphorResultColumn","semaphorMetricMeasureBindingKey"].filter(x).join(", ")} } from "react-semaphor/data-app-sdk";`,m?'import { fields } from "./fields";':void 0].filter(x).join(`
|
|
282
|
+
`);return`${K}
|
|
283
|
+
${d}
|
|
274
284
|
|
|
275
285
|
export type SemaphorGeneratedRow = Record<string, unknown>;
|
|
276
286
|
export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
|
|
@@ -279,6 +289,7 @@ export type SemaphorGeneratedMetricMeasureBindings = Record<string, string> | nu
|
|
|
279
289
|
export type SemaphorGeneratedMetricResult = {
|
|
280
290
|
readonly measures?: SemaphorGeneratedMetricMeasures;
|
|
281
291
|
readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
|
|
292
|
+
readonly missingMeasures?: readonly string[];
|
|
282
293
|
readonly value?: unknown;
|
|
283
294
|
} | null | undefined;
|
|
284
295
|
export type SemaphorGeneratedTableColumn = {
|
|
@@ -298,27 +309,31 @@ ${r}
|
|
|
298
309
|
} as const;
|
|
299
310
|
|
|
300
311
|
export const metricMeasureKeysForView = {
|
|
301
|
-
${
|
|
312
|
+
${t}
|
|
302
313
|
} as const;
|
|
303
314
|
|
|
304
315
|
export const metricMeasureBindingKeysForView = {
|
|
305
|
-
${
|
|
316
|
+
${o}
|
|
306
317
|
} as const;
|
|
307
318
|
|
|
308
319
|
export const tableColumnsForView = {
|
|
309
|
-
${
|
|
320
|
+
${y}
|
|
310
321
|
} as const;
|
|
311
322
|
|
|
312
323
|
export const columnKeysForView = {
|
|
313
|
-
${
|
|
324
|
+
${h}
|
|
314
325
|
} as const;
|
|
315
326
|
|
|
316
327
|
export const rowValuesForView = {
|
|
317
|
-
${
|
|
328
|
+
${f}
|
|
318
329
|
} as const;
|
|
319
330
|
|
|
320
331
|
export const metricValuesForView = {
|
|
321
|
-
${
|
|
332
|
+
${i}
|
|
333
|
+
} as const;
|
|
334
|
+
|
|
335
|
+
export const missingMetricMeasuresForView = {
|
|
336
|
+
${l}
|
|
322
337
|
} as const;
|
|
323
338
|
|
|
324
339
|
export function resolveColumnKey(
|
|
@@ -615,11 +630,13 @@ function sourcesReferToSameDataset(
|
|
|
615
630
|
}
|
|
616
631
|
return false;
|
|
617
632
|
}
|
|
618
|
-
`}function
|
|
619
|
-
export const generatedViewIds = ${k(
|
|
620
|
-
export const generatedQueryViewIds = ${k(
|
|
621
|
-
export const generatedInputIds = ${k(
|
|
622
|
-
export const generatedInputOptionQueryIds = ${k(
|
|
633
|
+
`}function Ye(e,n){const r=W(e,n),t=new Map((T(e)?Y(e,n):[]).map(o=>[o.fieldName,o.key]));return r.map(o=>{const i=C(o.raw,n),l=i?t.get(i):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(d=>d.id).filter(Boolean),o=e.views.map(d=>d.raw.id).filter(Boolean),i=e.inputs.map(d=>d.raw.id).filter(Boolean),l=e.optionQueries.map(d=>d.raw.id||`${d.input.raw.id}-options`).filter(Boolean),y=Object.fromEntries(o.map(d=>[d,e.filterContracts.filter(s=>Array.isArray(s.appliesToViewIds)&&s.appliesToViewIds.includes(d)).map(s=>s.inputId)])),h=Object.fromEntries(e.views.map(d=>[d.raw.id,{title:d.raw.title,visual:d.raw.visual,visualSpec:d.raw.visualSpec,queryKind:d.raw.queryKind,sdkBuilder:d.raw.sdkBuilder}])),f=Object.fromEntries(e.views.map(d=>{var s;return[d.raw.id,A({viewId:d.raw.id,queryId:d.name,title:d.raw.title,visualType:((s=d.raw.visualSpec)==null?void 0:s.visualType)||d.raw.visual,suggestedComponentName:ye(d.raw.title||d.raw.id||d.name),marker:{attribute:"data-semaphor-view-id",value:d.raw.id}})]})),m=Object.fromEntries(e.inputs.map(d=>{var s;return[d.raw.id,A({inputId:d.raw.id,label:d.raw.label,type:d.raw.type,optionQueryId:((s=d.raw.optionQuery)==null?void 0:s.id)||(d.raw.optionQuery?`${d.raw.id}-options`:void 0),suggestedComponentName:ye(d.raw.label||d.raw.id||d.name),marker:{attribute:"data-semaphor-input-id",value:d.raw.id}})]})),M=Object.fromEntries(e.views.map(d=>{var s,u,c;return[d.name,A({viewId:d.raw.id,viewTitle:((s=d.raw.visualSpec)==null?void 0:s.title)||d.raw.title,visualType:(u=d.raw.visualSpec)==null?void 0:u.visualType,title:((c=d.raw.visualSpec)==null?void 0:c.title)||d.raw.title})]}));return`${K}
|
|
634
|
+
export const generatedViewIds = ${k(t)} as const;
|
|
635
|
+
export const generatedQueryViewIds = ${k(o)} as const;
|
|
636
|
+
export const generatedInputIds = ${k(i)} as const;
|
|
637
|
+
export const generatedInputOptionQueryIds = ${k(l)} as const;
|
|
638
|
+
export const generatedViewAuthoring = ${k(f)} as const;
|
|
639
|
+
export const generatedInputAuthoring = ${k(m)} as const;
|
|
623
640
|
|
|
624
641
|
export type SemaphorGeneratedViewId = typeof generatedViewIds[number];
|
|
625
642
|
export type SemaphorGeneratedQueryViewId = typeof generatedQueryViewIds[number];
|
|
@@ -638,19 +655,31 @@ export type SemaphorGeneratedFilterContract = {
|
|
|
638
655
|
readonly [key: string]: unknown;
|
|
639
656
|
};
|
|
640
657
|
|
|
641
|
-
export const generatedInputIdsForView = ${k(
|
|
658
|
+
export const generatedInputIdsForView = ${k(y)} as const;
|
|
642
659
|
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${k(e.filterContracts)} as const;
|
|
643
660
|
|
|
661
|
+
export function semaphorViewMarkerProps(viewId: SemaphorGeneratedViewId) {
|
|
662
|
+
return {
|
|
663
|
+
"data-semaphor-view-id": viewId,
|
|
664
|
+
} as const;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
export function semaphorInputMarkerProps(inputId: SemaphorGeneratedInputId) {
|
|
668
|
+
return {
|
|
669
|
+
"data-semaphor-input-id": inputId,
|
|
670
|
+
} as const;
|
|
671
|
+
}
|
|
672
|
+
|
|
644
673
|
export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
645
674
|
return generatedFilterContracts.filter((filterContract) =>
|
|
646
675
|
filterContract.appliesToViewIds.includes(viewId)
|
|
647
676
|
);
|
|
648
677
|
}
|
|
649
678
|
|
|
650
|
-
export const queryDebugForView = ${k(
|
|
679
|
+
export const queryDebugForView = ${k(M)} as const;
|
|
651
680
|
|
|
652
|
-
export const semaphorGeneratedContractMetadata = ${k({schemaVersion:"semaphor-generated-data-app-contract/v1",title:e.title,requiredDevtools:r,filterContracts:e.filterContracts,filterScopeByInput:n,generatedViewIds:
|
|
653
|
-
`}function
|
|
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:i,generatedInputOptionQueryIds:l,generatedInputIdsForView:y,generatedViewAuthoring:f,generatedInputAuthoring:m,visualSpecs:h,presentationViews:e.presentationViews})} as const;
|
|
682
|
+
`}function Ze(){return`${K}
|
|
654
683
|
export * from "./sources";
|
|
655
684
|
export * from "./fields";
|
|
656
685
|
export * from "./inputs";
|
|
@@ -658,4 +687,4 @@ export * from "./queries";
|
|
|
658
687
|
export * from "./bindings";
|
|
659
688
|
export * from "./accessors";
|
|
660
689
|
export * from "./metadata";
|
|
661
|
-
`}function
|
|
690
|
+
`}function Q(e,n){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(const r of n)Q(e,r);return}O(n)&&g(e,U(n));for(const r of Object.values(n))Q(e,r)}}function W(e,n){const r=[];if(tn(r,e.raw.sdkSpec),r.length===0)for(const o of e.raw.fields||[])g(r,o);const t=ne(r.filter(o=>o.name&&C(o,n)).map(o=>({raw:o,key:L(o),name:""})),o=>o.key);return H(t,o=>q(o.raw.label||o.raw.name||"field")),t}function D(e,n){if(B(e.raw.sdkSpec.builder)!=="metric")return[];const r=I(e.raw.sdkSpec.spec),t=[];g(t,r==null?void 0:r.primaryMeasure);for(const i of v(r==null?void 0:r.measures))g(t,i);const o=ne(t.filter(i=>i.name&&C(i,n)).map(i=>({raw:i,key:L(i),name:""})),i=>i.key);return H(o,i=>q(i.raw.label||i.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=I(e.raw.sdkSpec.spec);if(!O(r==null?void 0:r.primaryMeasure))return new Set;const t=L(U(r.primaryMeasure)),o=n.find(i=>i.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 P([`${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=I(n.spec);if(!r)return;const t=B(n.builder);if(t==="records"){for(const o of v(r.fields))g(e,o);return}if(t==="sql"){for(const o of v(r.fields))g(e,o);return}if(t==="analysis"||t==="metric"){g(e,r.primaryMeasure);for(const o of v(r.measures))g(e,o);for(const o of v(r.dimensions))g(e,o);g(e,r.dateField);return}if(t==="matrix"){const o=ce(r.rows),i=ce(r.columns),l=v(r.values);for(const y of o)me(e,y);for(const y of i)me(e,y);for(const y of l){const h=I(y);g(e,h==null?void 0:h.field),g(e,h==null?void 0:h.measure)}}}function ce(e){if(Array.isArray(e))return e;const n=I(e);return Array.isArray(n==null?void 0:n.levels)?n.levels:[]}function me(e,n){var r;if(O(n)){g(e,n);return}g(e,(r=I(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=I(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 g(e,n){O(n)&&e.push(U(n))}function U(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=$e(n);if(r)return{raw:n,key:r,aliases:Fe(n),name:""}}function O(e){const n=I(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=I(e);return!!(n&&(typeof n.sourceKey=="string"||n.kind==="semantic"||typeof n.datasetName=="string"&&typeof n.domainId=="string"))}function E(e,n){if(e===void 0)return"undefined";if(e===null||typeof e=="number"||typeof e=="boolean"||typeof e=="string")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(o=>E(o,n)).join(", ")}]`;if(O(e)){const o=C(U(e),n);if(o)return`fields.${o}`}if(we(e)){const o=Ie(e,n);if(o)return`sources.${o}`}const r=I(e);return r?`{ ${Object.entries(r).filter(([,o])=>o!==void 0).map(([o,i])=>`${JSON.stringify(o)}: ${E(i,n)}`).join(", ")} }`:JSON.stringify(e)}function k(e){return JSON.stringify(e,null,2)}function C(e,n){if(O(e))return n.fieldNameByKey.get(L(U(e)))}function Ie(e,n){if(we(e))for(const r of ee(e)){const t=n.sourceNameByKey.get(r);if(t)return t}}function L(e){return[e.sourceKey||"",e.name||"",e.role||"",e.aggregate||""].join("|")}function an(e,n){return!O(e)||!O(n)||e.name!==n.name?!1:de(e).some(r=>de(n).includes(r))}function un(e){return O(e)&&e.role==="id"}function dn(e){const n=[],r=new Map;for(const t of e){const o=P(t.aliases.length?t.aliases:[t.key]),i=o.map(l=>r.get(l)).find(x);if(i){i.aliases=P([...i.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 P([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 P(e){return Array.from(new Set(e.filter(Boolean)))}function $e(e){return ee(e)[0]||le(e)}function ee(e){const n=I(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)),P(r)}function Fe(e){return ee(e)}function le(e){const n=I(e);return n?typeof n.sourceKey=="string"?n.sourceKey:JSON.stringify(n):""}function ln(e){return O(e)&&de(e)[0]||""}function de(e){return O(e)?P([...typeof e.sourceKey=="string"?[e.sourceKey]:[],...e.source?ee(e.source):[]]):[]}function B(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=B(e);return n==="records"||n==="sql"}function mn(e){const n=I(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",i=r.get(o)||0;r.set(o,i+1),t.name=i===0?o:`${o}${i+1}`}}function ne(e,n){const r=new Set,t=[];for(const o of e){const i=n(o);!i||r.has(i)||(r.add(i),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(i=>i.charAt(0).toUpperCase()+i.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 I(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function v(e){return Array.isArray(e)?e:[]}function z(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function x(e){return e!==void 0}exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=Z.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=Z.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=Z.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=Z.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=V.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=V.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=V.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=V.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=V.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=V.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=V.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=V.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=V.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=V.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=V.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=V.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=V.validateCodegenSummary;exports.validateSemaphorGeneratedContract=V.validateSemaphorGeneratedContract;exports.DEFAULT_GENERATED_CONTRACT_OUTPUT_DIR=ke;exports.generateSemaphorDataAppContract=Ce;
|