react-semaphor 0.1.421 → 0.1.423
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/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +913 -712
- package/dist/chunks/{analyze-result-contract-sWcmvBOA.js → analyze-result-contract-D7pjjYPy.js} +45 -46
- package/dist/chunks/{analyze-result-contract-B5Eeu7vD.js → analyze-result-contract-DpDcImgk.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-CscmhyuZ.js → calendar-preferences-dialog-CTmeASaM.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-cN3_2C-u.js → calendar-preferences-dialog-t5ET6MON.js} +3 -3
- package/dist/chunks/card-config-utils-15sRtebL.js +1 -0
- package/dist/chunks/card-config-utils-BYZ5MJOh.js +16 -0
- package/dist/chunks/dashboard-briefing-launcher-Cavd0QJb.js +3401 -0
- package/dist/chunks/dashboard-briefing-launcher-S2akO-ub.js +26 -0
- package/dist/chunks/dashboard-controls-BJLrErjW.js +2322 -0
- package/dist/chunks/dashboard-controls-DzbP8AXA.js +52 -0
- package/dist/chunks/dashboard-json-5tWb5KD6.js +1 -0
- package/dist/chunks/{dashboard-json-Cxhw2TZc.js → dashboard-json-Do2-pdPZ.js} +12 -11
- package/dist/chunks/{edit-dashboard-visual-BigSJ3-x.js → edit-dashboard-visual-Cw6bq4_w.js} +7058 -6989
- package/dist/chunks/edit-dashboard-visual-Yh5YFgMF.js +178 -0
- package/dist/chunks/index-BPM3gDRw.js +1406 -0
- package/dist/chunks/{index-CH2ZzQo4.js → index-yHe0SeLO.js} +81534 -75430
- package/dist/chunks/{switch-TbCsyhv9.js → switch-2bh3Hka1.js} +620 -633
- package/dist/chunks/{switch-CiOjVyVI.js → switch-DMT7qf_R.js} +24 -24
- package/dist/chunks/{update-policy-2MZ-Vf7v.js → update-policy-BCJc0oI5.js} +1 -1
- package/dist/chunks/{update-policy-qpyAkOyO.js → update-policy-C1pmhLz9.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-BzcJWNzh.js → use-create-flow-overlay-state-5MDbZcs1.js} +515 -544
- package/dist/chunks/use-create-flow-overlay-state-BNczg9Gj.js +11 -0
- package/dist/chunks/{validators-Dj1Y-46V.js → validators-DMlVbd1p.js} +1 -1
- package/dist/chunks/{validators-D0pfj3jJ.js → validators-PXkij33j.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 +108 -108
- 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 +165 -340
- package/dist/data-app-codegen-node/index.js +761 -952
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +91 -95
- 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 +168 -164
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +0 -4
- package/dist/types/briefings.d.ts +2388 -7
- package/dist/types/dashboard-assistant.d.ts +0 -1
- package/dist/types/data-app-sdk-validation.d.ts +0 -1
- package/dist/types/data-app-sdk.d.ts +0 -2
- package/dist/types/main.d.ts +70 -10
- package/dist/types/types.d.ts +4 -8
- package/package.json +1 -1
- package/dist/chunks/dashboard-briefing-launcher-BYTBNetR.js +0 -9077
- package/dist/chunks/dashboard-briefing-launcher-DmZkzIC3.js +0 -80
- package/dist/chunks/dashboard-controls-9DFeKIP4.js +0 -52
- package/dist/chunks/dashboard-controls-PhzuaTBj.js +0 -2280
- package/dist/chunks/dashboard-json-DyRHI3mL.js +0 -1
- package/dist/chunks/edit-dashboard-visual-3_jiBXsu.js +0 -178
- package/dist/chunks/index-BKDQw0aK.js +0 -1346
- package/dist/chunks/use-create-flow-overlay-state-DUQmgb9H.js +0 -21
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("../chunks/analyze-result-contract-DpDcImgk.js"),R=require("../chunks/update-policy-C1pmhLz9.js"),he=require("node:crypto"),Ce="src/semaphor/generated",H=`// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
|
|
2
2
|
// Regenerate from the accepted semaphor_plan_data_app codegenSummary when the plan changes.
|
|
3
|
-
`;function
|
|
4
|
-
`};return{schemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,files:
|
|
3
|
+
`;function Oe(e,n={}){R.assertValidCodegenSummary(e);const r=Me(e);if(r.views.length===0&&!n.allowEmpty)throw new Error("Contract generation produced zero executable views. Stop and ask for a different domain/goal or semantic model improvement; pass --allow-empty only for an explicit model-gap report.");const t=ke(r),o=Ne({contract:r,files:t,generatorName:n.generatorName||"react-semaphor/data-app-codegen/node",generatorVersion:n.generatorVersion||"unknown"}),a={...t,"contract.manifest.json":`${JSON.stringify(o,null,2)}
|
|
4
|
+
`};return{schemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,files:a,manifest:o,contentHash:String(o.generatedContentHash||""),usageExample:Te(r),warnings:r.warnings,stats:{inputCount:r.inputs.length,executableViewCount:r.views.length,presentationViewCount:r.presentationViews.length,queryCount:r.views.length,optionQueryCount:r.optionQueries.length}}}function Me(e){var d,p,m,i,l,g,h,I,$,M,b,E;const n=[],r=[];for(const s of e.inputs){S(r,s.fieldRef);for(const V of s.bindings||[])S(r,V.fieldRef);S(r,(d=s.optionQuery)==null?void 0:d.valueFieldRef),S(r,(p=s.optionQuery)==null?void 0:p.labelFieldRef),S(r,(m=s.optionQuery)==null?void 0:m.filterFieldRef),D(r,(i=s.optionQuery)==null?void 0:i.spec)}for(const s of e.filterContracts){S(r,s.fieldRef),S(r,(l=s.optionQuery)==null?void 0:l.valueFieldRef),S(r,(g=s.optionQuery)==null?void 0:g.labelFieldRef),S(r,(h=s.optionQuery)==null?void 0:h.filterFieldRef),D(r,(I=s.optionQuery)==null?void 0:I.spec);for(const V of s.bindings||[])S(r,V.fieldRef)}for(const s of e.views){for(const V of s.fields||[])S(r,V);D(r,($=s.sdkSpec)==null?void 0:$.spec),D(r,s.visualSpec)}const t=e.implementationChecklist||{};for(const s of Object.values(t.bindingsByView||{}))for(const V of Array.isArray(s)?s:[])S(r,V.fieldRef),S(r,V.optionValueField),S(r,V.optionLabelField);for(const s of t.requiredInputOptions||[])S(r,s.visibleLabelField),S(r,s.optionValueField),S(r,s.runtimeFilterField);const o=pn([...e.sources.map(s=>({raw:s,key:Ie(s),aliases:Ve(s),name:""})),...r.map(s=>an(s)).filter(x)]);P(o,s=>{const V=F(s.raw);return j(s.raw.label||(V==null?void 0:V.datasetName)||(V==null?void 0:V.datasetId)||(V==null?void 0:V.name)||s.raw.kind||"source")});const a=ln(o),u=ne(r.filter(s=>s.name).map(s=>({raw:s,key:X(s),name:""})),s=>s.key);P(u,s=>j([s.raw.sourceKey?yn(s.raw.sourceKey):"",s.raw.aggregate?s.raw.aggregate.toLowerCase():"",s.raw.name].filter(Boolean).join("_")));const c=new Map(u.map(s=>[s.key,s.name])),w=e.inputs.map(s=>({raw:s,name:j(s.id||s.label||"input")}));P(w,s=>s.name);const f=w.filter(s=>!!s.raw.optionQuery).map(s=>({input:s,name:`${s.name}Options`,raw:s.raw.optionQuery}));P(f,s=>s.name);for(const s of f)un(s.raw.labelFieldRef,s.raw.valueFieldRef)&&dn(s.raw.valueFieldRef)&&n.push(`Input option query ${((M=s.raw.spec)==null?void 0:M.inputId)||s.input.raw.id||s.name} uses identifier field ${s.raw.valueFieldRef.name} as both label and value. It can execute, but the UI will show key values unless the semantic model exposes a human-readable label through a modeled relationship.`);const y=e.views.filter(s=>{var V,K;return!!((V=s.sdkSpec)!=null&&V.builder&&((K=s.sdkSpec)!=null&&K.spec))}).map(s=>({raw:s,name:j(s.id||s.title||"query")}));P(y,s=>s.name);const k=e.views.filter(s=>fe(s)&&!("sdkSpec"in s)).map(s=>sn(s));for(const s of e.views)(!("sdkSpec"in s)||!((b=s.sdkSpec)!=null&&b.builder)||!((E=s.sdkSpec)!=null&&E.spec))&&!fe(s)&&n.push(`Skipped view ${s.id||s.title||"unknown"} because it has no sdkSpec.`);return Ee({inputs:w,views:y,filterContracts:e.filterContracts}),{summary:e,title:e.title||"Semaphor Data App",sources:o,fields:u,inputs:w,optionQueries:f,views:y,presentationViews:k,filterContracts:e.filterContracts,checklist:t,sourceNameByKey:a,fieldNameByKey:c,warnings:n}}function Ee({inputs:e,views:n,filterContracts:r}){const t=new Set(e.map(a=>a.raw.id).filter(Boolean)),o=new Set(n.map(a=>a.raw.id).filter(Boolean));for(const[a,u]of r.entries()){if(!t.has(u.inputId))throw new Error(`filterContracts.${a}.inputId must reference a generated input.`);const c=new Set(u.appliesToViewIds||[]),w=new Set(u.notAppliedToViewIds||[]);for(const[f,y]of(u.appliesToViewIds||[]).entries())if(!o.has(y))throw new Error(`filterContracts.${a}.appliesToViewIds.${f} must reference an executable generated view.`);for(const[f,y]of(u.notAppliedToViewIds||[]).entries())if(!o.has(y))throw new Error(`filterContracts.${a}.notAppliedToViewIds.${f} must reference an executable generated view.`);for(const[f,y]of(u.bindings||[]).entries()){if(!o.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must reference an executable generated view.`);if(!c.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must be included in appliesToViewIds.`);if(w.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must not be listed in notAppliedToViewIds.`)}}}function ke(e){return{"sources.ts":ve(e),"fields.ts":qe(e),"inputs.ts":De(e),"queries.ts":Pe(e),"bindings.ts":Le(e),"accessors.ts":Ye(e),"metadata.ts":We(e),"index.ts":Xe(),"USAGE.md":Ae(e)}}function Ne({contract:e,files:n,generatorName:r,generatorVersion:t}){return{schemaVersion:R.CONTRACT_MANIFEST_SCHEMA_VERSION,generatedContractSchemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,generator:{name:r,version:t},generatedContentHash:Ge(n),codegenSummaryValidatorVersion:R.CODEGEN_SUMMARY_VALIDATOR_VERSION,codegenSummaryHash:xe(e.summary),codegenSummary:e.summary}}function Ge(e){const n=he.createHash("sha256");for(const r of Object.keys(e).filter(t=>t.endsWith(".ts")).sort())n.update(r),n.update("\0"),n.update(e[r]),n.update("\0");return`sha256:${n.digest("hex")}`}function Ae(e){const n=["# Semaphor Generated Data App Contract","","Generated files in this directory are governed Semaphor analytics wiring. Do not hand-edit them.","","Use the app-facing exports from `index.ts`:","","- `queries`: generated governed query factories.","- `queryOptionsForView`: active-input wiring for each generated view.","- `rowsForView`: table/records row readers.","- `rowValuesForView`: friendly row object readers for chart/table views.","- `metricValuesForView`: friendly metric-value readers.","- `kpiPropsForView`: KPI component props derived from runtime metric results.","- `roleValuesForView`: canonical dimension/measure/date/id role readers.","- `appInputSpecs`: generated input/filter specs.","- `inputOptionQueries`: option-list query factories for generated inputs.","- `semaphorGeneratedContractMetadata`: generated view/input metadata and presentation-only views.","","Start with these exports before opening large generated internals such as `metadata.ts`.",""];return e.views.length>0&&(n.push("Generated executable views:"),e.views.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.title||r.name}`)}),n.push("")),e.inputs.length>0&&(n.push("Generated inputs:"),e.inputs.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.label||r.name}`)}),n.push("")),`${n.join(`
|
|
5
5
|
`)}
|
|
6
|
-
`}function
|
|
7
|
-
`);const
|
|
8
|
-
`);const t=e.views.find(
|
|
9
|
-
`);const o=e.views.find(
|
|
10
|
-
`);const
|
|
11
|
-
`);const
|
|
12
|
-
`);const
|
|
13
|
-
`)}function
|
|
14
|
-
`),
|
|
15
|
-
|
|
16
|
-
`:"";return`${
|
|
17
|
-
${
|
|
18
|
-
${
|
|
6
|
+
`}function xe(e){return`sha256:${he.createHash("sha256").update(ue(e)).digest("hex")}`}function ue(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t=>ue(t)).join(",")}]`;const n=e;return`{${Object.keys(n).sort().filter(t=>n[t]!==void 0).map(t=>`${JSON.stringify(t)}:${ue(n[t])}`).join(",")}}`}function Te(e){const n=e.views.find(f=>T(f)&&_(f));if(n)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const sortOption = recordsSortOptionsForView.${n.name}[0];`,'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',`const query = queries.${n.name}({ page, pageSize, sort });`,`const result = useSemaphorQuery(query, queryOptionsForView.${n.name}(inputHandles));`,`const rows = rowsForView.${n.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
7
|
+
`);const r=e.views.find(f=>T(f));if(r)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const sortOption = recordsSortOptionsForView.${r.name}[0];`,'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',`const query = queries.${r.name}({ sort });`,`const result = useSemaphorQuery(query, queryOptionsForView.${r.name}(inputHandles));`,`const rows = rowsForView.${r.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
8
|
+
`);const t=e.views.find(f=>Z(f)&&_(f));if(t)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const query = queries.${t.name}({ page, pageSize });`,`const result = useSemaphorQuery(query, queryOptionsForView.${t.name}(inputHandles));`,`const rows = rowsForView.${t.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
9
|
+
`);const o=e.views.find(f=>pe(f)&&_(f));if(o)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const query = queries.${o.name}({ page, pageSize });`,`const result = useSemaphorQuery(query, queryOptionsForView.${o.name}(inputHandles));`,`const rows = rowsForView.${o.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
10
|
+
`);const a=e.views.find(f=>{var y;return mn((y=f.raw.sdkSpec)==null?void 0:y.builder)});if(a)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const result = useSemaphorQuery(queries.${a.name}(), queryOptionsForView.${a.name}(inputHandles));`,`const rows = rowsForView.${a.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
11
|
+
`);const u=e.views.find(f=>_e(f));if(u)return['import { appInputSpecs, createInputHandleMap, kpiPropsForView, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const result = useSemaphorQuery(queries.${u.name}(), queryOptionsForView.${u.name}(inputHandles));`,`const kpiProps = kpiPropsForView.${u.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
12
|
+
`);const c=e.views[0];return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",c?`const result = useSemaphorQuery(queries.${c.name}(), queryOptionsForView.${c.name}(inputHandles));`:"const result = undefined;","const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
13
|
+
`)}function Z(e){var n;return q((n=e.raw.sdkSpec)==null?void 0:n.builder)==="records"}function _e(e){var n;return q((n=e.raw.sdkSpec)==null?void 0:n.builder)==="metric"}function T(e){var n,r,t;return Z(e)&&((t=(r=(n=e.raw.visualSpec)==null?void 0:n.tableBehavior)==null?void 0:r.sorting)==null?void 0:t.mode)==="server"}function pe(e){var n;return q((n=e.raw.sdkSpec)==null?void 0:n.builder)==="sql"}function _(e){var n,r,t;return((t=(r=(n=e.raw.visualSpec)==null?void 0:n.tableBehavior)==null?void 0:r.pagination)==null?void 0:t.mode)==="server"}function He(e){return Z(e)&&(_(e)||T(e))||pe(e)&&_(e)}function ve(e){const n=e.sources.map(({name:t,raw:o})=>{const a=je(o);return` ${t}: ${a},`}).join(`
|
|
14
|
+
`),r=e.sources.some(t=>t.raw.kind==="semantic")?`import { semaphor } from "react-semaphor/data-app-sdk";
|
|
15
|
+
|
|
16
|
+
`:"";return`${H}
|
|
17
|
+
${r}export const sources = {
|
|
18
|
+
${n}
|
|
19
19
|
} as const;
|
|
20
|
-
`}function
|
|
21
|
-
`),n
|
|
20
|
+
`}function je(e){if(e.kind==="semantic"){const n={domainId:e.domainId,datasetId:e.datasetId,datasetName:e.datasetName,label:e.label};return`semaphor.source.semantic(${C(A(n))})`}return`${C(A({...e,sourceKey:void 0}))} as const`}function qe(e){const n=e.fields.map(({name:t,raw:o})=>{const a=Ke(o,e);return` ${t}: ${a},`}).join(`
|
|
21
|
+
`),r=n.includes("sources.")?`import { sources } from "./sources";
|
|
22
22
|
|
|
23
|
-
`:"";return`${
|
|
24
|
-
${
|
|
25
|
-
${
|
|
23
|
+
`:"";return`${H}
|
|
24
|
+
${r}export const fields = {
|
|
25
|
+
${n}
|
|
26
26
|
} as const;
|
|
27
|
-
`}function
|
|
28
|
-
`),
|
|
29
|
-
`),
|
|
30
|
-
inputs.push(semaphor.bindInput(${
|
|
27
|
+
`}function Ke(e,n){const r={name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate},t=cn(e),o=t?n.sourceNameByKey.get(t):void 0;if(t&&!o)throw new Error(`Field ${e.name} references source ${t}, but that source is not renderable. Include the source in codegenSummary.sources or provide field.source.`);const a=Object.entries(A(r)).map(([u,c])=>`${JSON.stringify(u)}: ${G(c,n)}`);return o&&a.push(`"source": sources.${o}`),`{ ${a.join(", ")} }`}function De(e){const n=e.inputs.map(m=>{const i=O(m.raw.fieldRef,e),l=[`id: ${JSON.stringify(m.raw.id)}`,`label: ${JSON.stringify(m.raw.label||m.raw.id)}`,`operator: ${JSON.stringify(fn(m.raw))}`];if(i&&l.push(`field: fields.${i}`),m.raw.relationshipHint&&l.push(`relationshipHint: ${C(m.raw.relationshipHint)}`),!i)throw new Error(`Input ${m.raw.id||m.name} is missing a generated field reference.`);return` ${m.name}: semaphor.filter({ ${l.join(", ")} }),`}).join(`
|
|
28
|
+
`),r=e.inputs.map(m=>`filterSpecs.${m.name}`).join(", "),t=e.inputs.map(m=>JSON.stringify(m.raw.id)).join(", "),o=e.optionQueries.map(m=>{const i=m.input.raw,l=m.raw,g=F(l.spec)||{},{id:h,inputId:I,source:$,sourceKey:M,valueField:b,labelField:E,population:s,dependencies:V,limit:K,...re}=g,J=l.sourceKey?{sourceKey:l.sourceKey}:l.source||$||(typeof M=="string"?{sourceKey:M}:void 0),te=$e(J,e),oe=O(l.valueFieldRef,e),se=O(l.labelFieldRef,e),ae=ge(m),ie={...re,id:l.id||g.id||`${i.id}-options`,inputId:i.id,source:J,valueField:l.valueFieldRef,labelField:l.labelFieldRef,population:l.population||s,dependencies:ae,limit:l.limit||K||100};if(!te||!oe||!se)throw new Error(`Input option query ${l.id||`${i.id}-options`} is missing source, valueField, or labelField.`);const Fe=Object.entries(A(ie)).map(([be,Re])=>`${JSON.stringify(be)}: ${G(Re,e)}`);return` ${m.name}: semaphor.inputOptions({ ${Fe.join(", ")} }),`}).join(`
|
|
29
|
+
`),a=e.optionQueries.map(m=>{const i=Be(e,m),l=i.length>0?"inputHandles":"_inputHandles",g=i.map(h=>{const I=O(h.raw.fieldRef,e);if(!I)throw new Error(`Input option query ${m.raw.id||`${m.input.raw.id}-options`} references input ${h.raw.id} without a generated field reference.`);const $=`inputHandles[${JSON.stringify(h.raw.id)}]`;return` if (${$}) {
|
|
30
|
+
inputs.push(semaphor.bindInput(${$}, { field: fields.${I} }));
|
|
31
31
|
}`}).join(`
|
|
32
|
-
`);return` ${
|
|
32
|
+
`);return` ${m.name}(${l}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
33
33
|
const inputs: SemaphorInputReference[] = [];
|
|
34
34
|
${g}
|
|
35
35
|
return inputs;
|
|
36
36
|
},`}).join(`
|
|
37
37
|
|
|
38
|
-
`),
|
|
38
|
+
`),u=e.optionQueries.map(m=>` ${m.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
39
39
|
return {
|
|
40
|
-
inputs: inputsForInputOptionQuery.${
|
|
40
|
+
inputs: inputsForInputOptionQuery.${m.name}(inputHandles),
|
|
41
41
|
};
|
|
42
42
|
},`).join(`
|
|
43
43
|
|
|
44
|
-
`),
|
|
45
|
-
return queryOptionsForInputOptionQuery.${
|
|
46
|
-
`),
|
|
47
|
-
`);return`${
|
|
48
|
-
${
|
|
44
|
+
`),c=e.optionQueries.map(m=>` case ${JSON.stringify(m.raw.id||`${m.input.raw.id}-options`)}:
|
|
45
|
+
return queryOptionsForInputOptionQuery.${m.name}(inputHandles);`).join(`
|
|
46
|
+
`),w=e.inputs.length>0,f=e.optionQueries.length>0,y=f?"inputOptionQueryId":"_inputOptionQueryId",k=f?"inputHandles":"_inputHandles",d=["SemaphorInputHandle",f?"SemaphorInputReference":void 0,"SemaphorQueryRuntimeOptions"].filter(x).join(", "),p=[w||f?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,`import type { ${d} } from "react-semaphor/data-app-sdk";`,w||f?'import { fields } from "./fields";':void 0,f?'import { sources } from "./sources";':void 0,'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'].filter(x).join(`
|
|
47
|
+
`);return`${H}
|
|
48
|
+
${p}
|
|
49
49
|
|
|
50
50
|
export const filterSpecs = {
|
|
51
|
-
${
|
|
51
|
+
${n}
|
|
52
52
|
} as const;
|
|
53
53
|
|
|
54
|
-
export const appInputSpecs = [${
|
|
54
|
+
export const appInputSpecs = [${r}] as const;
|
|
55
55
|
export const appInputIds = [${t}] as const;
|
|
56
56
|
|
|
57
57
|
export type SemaphorGeneratedInputHandleMap = Partial<Record<SemaphorGeneratedInputId, SemaphorInputHandle>>;
|
|
@@ -65,56 +65,56 @@ ${o}
|
|
|
65
65
|
} as const;
|
|
66
66
|
|
|
67
67
|
export const inputsForInputOptionQuery = {
|
|
68
|
-
${
|
|
68
|
+
${a}
|
|
69
69
|
} as const;
|
|
70
70
|
|
|
71
71
|
export const queryOptionsForInputOptionQuery = {
|
|
72
|
-
${
|
|
72
|
+
${u}
|
|
73
73
|
} as const;
|
|
74
74
|
|
|
75
75
|
export function queryOptionsForInputOptionQueryId(
|
|
76
|
-
${
|
|
77
|
-
${
|
|
76
|
+
${y}: SemaphorGeneratedInputOptionQueryId,
|
|
77
|
+
${k}: SemaphorGeneratedInputHandleMap,
|
|
78
78
|
): SemaphorQueryRuntimeOptions {
|
|
79
|
-
switch (${
|
|
80
|
-
${
|
|
79
|
+
switch (${y}) {
|
|
80
|
+
${c}
|
|
81
81
|
}
|
|
82
|
-
throw new Error(\`Unknown generated Semaphor input option query id: \${${
|
|
82
|
+
throw new Error(\`Unknown generated Semaphor input option query id: \${${y}}\`);
|
|
83
83
|
}
|
|
84
|
-
`}function Be(e,
|
|
85
|
-
recordsSortFieldsForView.${
|
|
84
|
+
`}function Be(e,n){const r=ge(n);if(!r||r.mode==="independent")return[];if(r.mode!=="explicit")return[];const t=new Set(r.includeInputIds||[]),o=new Set([n.input.raw.id,...r.excludeInputIds||[]]);return e.inputs.filter(a=>o.has(a.raw.id)?!1:t.has(a.raw.id))}function ge(e){var n;return e.raw.dependencies||((n=e.raw.spec)==null?void 0:n.dependencies)}function Pe(e){const n=e.views.map(p=>{var l,g,h,I,$,M;const m=q(p.raw.sdkSpec.builder),i=Qe(p);if(Z(p)&&He(p)){const b=(l=p.raw.visualSpec)==null?void 0:l.tableBehavior,E=F(i.pagination),s=_(p),V=T(p),K=((g=b==null?void 0:b.pagination)==null?void 0:g.pageSize)||L(E==null?void 0:E.pageSize)||L(i.limit)||100,re=V?z(p,e):[],J=V?Ue({view:p,contract:e,sortFields:re,defaultField:(h=b==null?void 0:b.sorting)==null?void 0:h.defaultField}):void 0,te=V?(I=b==null?void 0:b.sorting)==null?void 0:I.defaultDirection:void 0,oe=Je({viewName:p.name,supportsPagination:s,supportsSort:V}),se=V?` const orderBy = resolveRecordsOrderBy(
|
|
85
|
+
recordsSortFieldsForView.${p.name},
|
|
86
86
|
params.sort,
|
|
87
|
-
${
|
|
88
|
-
${
|
|
87
|
+
${G(J,e)},
|
|
88
|
+
${G(te,e)},
|
|
89
89
|
);
|
|
90
|
-
`:"",
|
|
91
|
-
`:"",ie=
|
|
92
|
-
`:"";return` ${
|
|
90
|
+
`:"",ae=V?` ...(orderBy ? { orderBy } : {}),
|
|
91
|
+
`:"",ie=s?` pagination: resolveServerTablePagination(params, ${JSON.stringify(K)}),
|
|
92
|
+
`:"";return` ${p.name}(
|
|
93
93
|
params: ${oe} = {},
|
|
94
94
|
) {
|
|
95
|
-
${
|
|
96
|
-
...${
|
|
97
|
-
${
|
|
98
|
-
},`}if(
|
|
95
|
+
${se} return semaphor.${m}({
|
|
96
|
+
...${G(i,e)},
|
|
97
|
+
${ae}${ie} });
|
|
98
|
+
},`}if(pe(p)&&_(p)){const b=($=p.raw.visualSpec)==null?void 0:$.tableBehavior,E=F(i.pagination),s=((M=b==null?void 0:b.pagination)==null?void 0:M.pageSize)||L(E==null?void 0:E.pageSize)||L(i.limit)||100;return` ${p.name}(
|
|
99
99
|
params: SemaphorGeneratedServerPaginationParams = {},
|
|
100
100
|
) {
|
|
101
|
-
return semaphor.${
|
|
102
|
-
...${
|
|
103
|
-
pagination: resolveServerTablePagination(params, ${JSON.stringify(
|
|
101
|
+
return semaphor.${m}({
|
|
102
|
+
...${G(i,e)},
|
|
103
|
+
pagination: resolveServerTablePagination(params, ${JSON.stringify(s)}),
|
|
104
104
|
});
|
|
105
|
-
},`}return` ${
|
|
106
|
-
`),
|
|
107
|
-
`);return` ${
|
|
108
|
-
${
|
|
105
|
+
},`}return` ${p.name}: () => semaphor.${m}(${G(i,e)}),`}).join(`
|
|
106
|
+
`),r=e.views.filter(p=>T(p)).map(p=>{const i=z(p,e).map(l=>` ${JSON.stringify(l.key)}: fields.${l.fieldName},`).join(`
|
|
107
|
+
`);return` ${p.name}: {
|
|
108
|
+
${i}
|
|
109
109
|
},`}).join(`
|
|
110
|
-
`),t=e.views.filter(
|
|
111
|
-
`);return` ${
|
|
112
|
-
${
|
|
110
|
+
`),t=e.views.filter(p=>T(p)).map(p=>{const i=z(p,e).map(l=>` { key: ${JSON.stringify(l.key)}, label: ${JSON.stringify(l.label)}, field: fields.${l.fieldName} },`).join(`
|
|
111
|
+
`);return` ${p.name}: [
|
|
112
|
+
${i}
|
|
113
113
|
],`}).join(`
|
|
114
|
-
`),o=e.views.some(
|
|
115
|
-
`),
|
|
116
|
-
`);return`${
|
|
117
|
-
${
|
|
114
|
+
`),o=e.views.some(p=>T(p)),a=e.views.some(p=>_(p)),u=[n,r,t].join(`
|
|
115
|
+
`),c=[n?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,o?'import type { SemaphorFieldRef } from "react-semaphor/data-app-sdk";':void 0,u.includes("fields.")?'import { fields } from "./fields";':void 0,u.includes("sources.")?'import { sources } from "./sources";':void 0].filter(x).join(`
|
|
116
|
+
`);return`${H}
|
|
117
|
+
${c}
|
|
118
118
|
${o?`export type SemaphorGeneratedRecordsSortDirection = "asc" | "desc";
|
|
119
119
|
|
|
120
120
|
export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
@@ -125,17 +125,17 @@ export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
|
125
125
|
export type SemaphorGeneratedRecordsSortParams<TSortKey extends string = string> = {
|
|
126
126
|
sort?: SemaphorGeneratedRecordsSort<TSortKey> | null;
|
|
127
127
|
};
|
|
128
|
-
`:""}${
|
|
128
|
+
`:""}${a?`export type SemaphorGeneratedServerPaginationParams = {
|
|
129
129
|
page?: number;
|
|
130
130
|
pageSize?: number;
|
|
131
131
|
};
|
|
132
|
-
`:""}${o&&
|
|
132
|
+
`:""}${o&&a?`export type SemaphorGeneratedRecordsQueryParams<TSortKey extends string = string> =
|
|
133
133
|
SemaphorGeneratedServerPaginationParams &
|
|
134
134
|
SemaphorGeneratedRecordsSortParams<TSortKey>;
|
|
135
135
|
`:""}
|
|
136
136
|
|
|
137
137
|
export const recordsSortFieldsForView = {
|
|
138
|
-
${
|
|
138
|
+
${r}
|
|
139
139
|
} as const;
|
|
140
140
|
|
|
141
141
|
export const recordsSortOptionsForView = {
|
|
@@ -143,7 +143,7 @@ ${t}
|
|
|
143
143
|
} as const;
|
|
144
144
|
|
|
145
145
|
export const queries = {
|
|
146
|
-
${
|
|
146
|
+
${n}
|
|
147
147
|
} as const;
|
|
148
148
|
|
|
149
149
|
${o?`function resolveRecordsOrderBy<TSortKey extends string>(
|
|
@@ -166,7 +166,7 @@ ${o?`function resolveRecordsOrderBy<TSortKey extends string>(
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
`:""}
|
|
169
|
-
${
|
|
169
|
+
${a?`function resolveServerTablePagination(
|
|
170
170
|
params: SemaphorGeneratedServerPaginationParams,
|
|
171
171
|
defaultPageSize: number,
|
|
172
172
|
) {
|
|
@@ -176,29 +176,29 @@ ${i?`function resolveServerTablePagination(
|
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
`:""}
|
|
179
|
-
`}function Qe(e){var
|
|
180
|
-
inputs.push(semaphor.bindInput(${g}, { ${
|
|
179
|
+
`}function Qe(e){var a,u;const n=F((a=e.raw.sdkSpec)==null?void 0:a.spec)||{},{kind:r,id:t,...o}=n;return{...o,id:e.raw.id,label:((u=e.raw.visualSpec)==null?void 0:u.title)||e.raw.title||o.label}}function z(e,n){var a,u;const r=[],t=F((a=e.raw.sdkSpec)==null?void 0:a.spec)||{};for(const c of v(t.fields))S(r,c);S(r,t.dateField),S(r,(u=F(t.orderBy))==null?void 0:u.field);for(const c of e.raw.fields||[])S(r,c);return ne(r.map(c=>{const w=O(c,n);if(!(!c.name||!w))return{key:w,fieldName:w,rawName:c.name,label:c.label||c.name}}).filter(x),c=>c.key)}function Ue({view:e,contract:n,sortFields:r,defaultField:t}){var w,f;const o=new Set(r.map(y=>y.key));if(t&&o.has(t))return t;const a=r.filter(y=>y.rawName===t);if(a.length===1)return a[0].key;const u=F((w=e.raw.sdkSpec)==null?void 0:w.spec),c=O((f=F(u==null?void 0:u.orderBy))==null?void 0:f.field,n);return c&&o.has(c)?c:void 0}function Je({viewName:e,supportsPagination:n,supportsSort:r}){return n&&r?`SemaphorGeneratedRecordsQueryParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>`:r?`SemaphorGeneratedRecordsSortParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>`:"SemaphorGeneratedServerPaginationParams"}function Le(e){const n=e.views.map(y=>{const d=ze(e,y.raw.id).map(p=>{const m=p.inputId,i=O(p.fieldRef,e);if(!m||!i)return"";const l=[`field: fields.${i}`];if(p.relationshipHint)l.push(`relationshipHint: ${C(p.relationshipHint)}`);else if(Array.isArray(p.relationshipsUsed)&&p.relationshipsUsed.length>0){const h=p.relationshipsUsed.map(I=>{var $;return($=F(I))==null?void 0:$.id}).filter(I=>typeof I=="string"&&I.length>0);h.length>0&&l.push(`relationshipHint: ${C({relationshipIds:h})}`)}const g=`inputHandles[${JSON.stringify(m)}]`;return` if (${g}) {
|
|
180
|
+
inputs.push(semaphor.bindInput(${g}, { ${l.join(", ")} }));
|
|
181
181
|
}`}).filter(Boolean).join(`
|
|
182
|
-
`);return{view:
|
|
182
|
+
`);return{view:y,renderedBindings:d}}),r=n.some(y=>y.renderedBindings.length>0),t=n.map(({view:y,renderedBindings:k})=>{const d=k?"inputHandles":"_inputHandles";return` ${y.name}(${d}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
183
183
|
const inputs: SemaphorInputReference[] = [];
|
|
184
|
-
${
|
|
184
|
+
${k}
|
|
185
185
|
return inputs;
|
|
186
186
|
},`}).join(`
|
|
187
187
|
|
|
188
|
-
`),o=e.views.map(
|
|
188
|
+
`),o=e.views.map(y=>` ${y.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
189
189
|
return {
|
|
190
|
-
inputs: inputsForView.${
|
|
191
|
-
debug: queryDebugForView.${
|
|
190
|
+
inputs: inputsForView.${y.name}(inputHandles),
|
|
191
|
+
debug: queryDebugForView.${y.name},
|
|
192
192
|
};
|
|
193
193
|
},`).join(`
|
|
194
194
|
|
|
195
|
-
`),
|
|
196
|
-
return inputsForView.${
|
|
197
|
-
`),
|
|
198
|
-
return queryOptionsForView.${
|
|
199
|
-
`),
|
|
200
|
-
`);return`${
|
|
201
|
-
${
|
|
195
|
+
`),a=e.views.map(y=>` case ${JSON.stringify(y.raw.id)}:
|
|
196
|
+
return inputsForView.${y.name}(inputHandles);`).join(`
|
|
197
|
+
`),u=e.views.map(y=>` case ${JSON.stringify(y.raw.id)}:
|
|
198
|
+
return queryOptionsForView.${y.name}(inputHandles);`).join(`
|
|
199
|
+
`),c=e.views.length>0,w=c?"inputHandles":"_inputHandles",f=[r?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,'import type { SemaphorInputReference, SemaphorQueryRuntimeOptions } from "react-semaphor/data-app-sdk";',r?'import { fields } from "./fields";':void 0,'import type { SemaphorGeneratedInputHandleMap } from "./inputs";',c?'import { queryDebugForView } from "./metadata";':void 0,'import type { SemaphorGeneratedQueryViewId } from "./metadata";'].filter(x).join(`
|
|
200
|
+
`);return`${H}
|
|
201
|
+
${f}
|
|
202
202
|
|
|
203
203
|
export const inputsForView = {
|
|
204
204
|
${t}
|
|
@@ -210,116 +210,113 @@ ${o}
|
|
|
210
210
|
|
|
211
211
|
export function inputsForViewId(
|
|
212
212
|
viewId: SemaphorGeneratedQueryViewId,
|
|
213
|
-
${
|
|
213
|
+
${w}: SemaphorGeneratedInputHandleMap,
|
|
214
214
|
): SemaphorInputReference[] {
|
|
215
215
|
switch (viewId) {
|
|
216
|
-
${
|
|
216
|
+
${a}
|
|
217
217
|
}
|
|
218
218
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
export function queryOptionsForViewId(
|
|
222
222
|
viewId: SemaphorGeneratedQueryViewId,
|
|
223
|
-
${
|
|
223
|
+
${w}: SemaphorGeneratedInputHandleMap,
|
|
224
224
|
): SemaphorQueryRuntimeOptions {
|
|
225
225
|
switch (viewId) {
|
|
226
|
-
${
|
|
226
|
+
${u}
|
|
227
227
|
}
|
|
228
228
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
229
229
|
}
|
|
230
|
-
`}function ze(e,
|
|
231
|
-
`);return` ${
|
|
232
|
-
${
|
|
233
|
-
},`}).join(`
|
|
234
|
-
`),n=e.views.map(s=>{const h=B(s,e).map(y=>{const I=C(y.raw,e);return I?` ${y.name}: fields.${I},`:""}).filter(Boolean).join(`
|
|
235
|
-
`);return` ${s.name}: {
|
|
236
|
-
${h}
|
|
230
|
+
`}function ze(e,n){return e.filterContracts.flatMap(r=>(r.bindings||[]).filter(t=>t.viewId===n).map(t=>({inputId:r.inputId,fieldRef:t.fieldRef,relationshipHint:t.relationshipHint,relationshipsUsed:t.relationshipsUsed})))}function Ye(e){const n=e.views.map(i=>{const g=Q(i,e).map(h=>{const I=O(h.raw,e);return I?` ${h.name}: fields.${I},`:""}).filter(Boolean).join(`
|
|
231
|
+
`);return` ${i.name}: {
|
|
232
|
+
${g}
|
|
237
233
|
},`}).join(`
|
|
238
|
-
`),
|
|
239
|
-
`);return` ${
|
|
240
|
-
${
|
|
234
|
+
`),r=e.views.map(i=>{const g=B(i,e).map(h=>{const I=O(h.raw,e);return I?` ${h.name}: fields.${I},`:""}).filter(Boolean).join(`
|
|
235
|
+
`);return` ${i.name}: {
|
|
236
|
+
${g}
|
|
241
237
|
},`}).join(`
|
|
242
|
-
`),
|
|
243
|
-
`);return` ${
|
|
244
|
-
${
|
|
238
|
+
`),t=e.views.map(i=>{const g=B(i,e).map((h,I)=>` ${h.name}: ${JSON.stringify(en(i,h,I))},`).join(`
|
|
239
|
+
`);return` ${i.name}: {
|
|
240
|
+
${g}
|
|
245
241
|
},`}).join(`
|
|
246
|
-
`),
|
|
242
|
+
`),o=e.views.map(i=>{const l=B(i,e);if(l.length===0)return` ${i.name}(): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
247
243
|
return {};
|
|
248
|
-
},`;const
|
|
249
|
-
`);return` ${
|
|
244
|
+
},`;const g=l.map(h=>{const $=`readMetricValueByBinding(measures, measureBindings, ${`metricMeasureBindingKeysForView.${i.name}.${h.name}`})`;return` ${h.name}: ${$},`}).join(`
|
|
245
|
+
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
250
246
|
const measures = result?.measures;
|
|
251
247
|
const measureBindings = result?.measureBindings;
|
|
252
|
-
const primaryValue = result?.primaryValue;
|
|
253
248
|
return {
|
|
254
|
-
${
|
|
249
|
+
${g}
|
|
255
250
|
};
|
|
256
251
|
},`}).join(`
|
|
257
252
|
|
|
258
|
-
`),
|
|
253
|
+
`),a=e.views.map(i=>{const l=B(i,e);if(l.length===0)return` ${i.name}(): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
259
254
|
return [];
|
|
260
|
-
},`;const
|
|
261
|
-
`);return` ${
|
|
255
|
+
},`;const g=l.map((h,I)=>{const $=`metricMeasureBindingKeysForView.${i.name}.${h.name}`,M=I===0?`readMetricValueByBinding(measures, measureBindings, ${$}) === undefined && !hasOwnPrimaryMetricValue(result)`:`readMetricValueByBinding(measures, measureBindings, ${$}) === undefined`;return` ...(missing.has(${$}) || (${M}) ? [${JSON.stringify(h.name)} as keyof typeof metricFieldsForView.${i.name}] : []),`}).join(`
|
|
256
|
+
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
262
257
|
const missing = new Set(result?.missingMeasures || []);
|
|
258
|
+
const measures = result?.measures;
|
|
259
|
+
const measureBindings = result?.measureBindings;
|
|
263
260
|
return [
|
|
264
|
-
${
|
|
261
|
+
${g}
|
|
265
262
|
];
|
|
266
263
|
},`}).join(`
|
|
267
264
|
|
|
268
|
-
`),
|
|
269
|
-
`);return` ${
|
|
270
|
-
const values = mapMetricDisplayValues(metricValuesForView.${
|
|
271
|
-
const missing = missingMetricMeasuresForView.${
|
|
272
|
-
const primaryMissing = missing.includes(${JSON.stringify(
|
|
273
|
-
const
|
|
274
|
-
|
|
265
|
+
`),u=e.views.map(i=>{const l=B(i,e);if(l.length===0)return"";const g=l[0],h=l.map($=>`{ key: ${JSON.stringify($.name)}, label: ${JSON.stringify($.raw.label||$.raw.name)} }`).join(", "),I=l.filter($=>$.name!==g.name).map($=>` if (missing.includes(${JSON.stringify($.name)})) delete values.${$.name};`).join(`
|
|
266
|
+
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): SemaphorGeneratedKpiProps {
|
|
267
|
+
const values = mapMetricDisplayValues(metricValuesForView.${i.name}(result));
|
|
268
|
+
const missing = missingMetricMeasuresForView.${i.name}(result).map((key) => String(key));
|
|
269
|
+
const primaryMissing = missing.includes(${JSON.stringify(g.name)});
|
|
270
|
+
const boundPrimaryValue = values.${g.name};
|
|
271
|
+
const primaryValue = primaryMissing || boundPrimaryValue === undefined ? result?.primaryValue : boundPrimaryValue;
|
|
272
|
+
if (primaryMissing) values.${g.name} = metricDisplayValue(result?.primaryValue);
|
|
275
273
|
${I}
|
|
276
274
|
return {
|
|
277
275
|
result: {
|
|
278
276
|
...(result || {}),
|
|
279
|
-
value: metricDisplayValue(result?.value),
|
|
280
277
|
primaryValue: metricDisplayValue(result?.primaryValue),
|
|
281
278
|
comparisonValue: metricDisplayValue(result?.comparisonValue),
|
|
282
279
|
measures: values,
|
|
283
280
|
},
|
|
284
|
-
title: ${JSON.stringify(
|
|
285
|
-
label: ${JSON.stringify(
|
|
281
|
+
title: ${JSON.stringify(i.raw.title||i.raw.id)},
|
|
282
|
+
label: ${JSON.stringify(g.raw.label||g.raw.name)},
|
|
286
283
|
value: metricDisplayValue(primaryValue),
|
|
287
|
-
measures: [${
|
|
284
|
+
measures: [${h}],
|
|
288
285
|
missingMeasures: missing,
|
|
289
286
|
showComparison: Boolean(result?.comparisonKind),
|
|
290
287
|
};
|
|
291
288
|
},`}).filter(Boolean).join(`
|
|
292
289
|
|
|
293
|
-
`),
|
|
294
|
-
`),
|
|
295
|
-
`);return` ${
|
|
290
|
+
`),c=e.views.map(i=>{const l=Ze(i,e);return` ${i.name}: ${C(l)},`}).join(`
|
|
291
|
+
`),w=e.views.map(i=>{const g=Q(i,e).map(h=>` ${h.name}: resolveColumnKey(columns, fieldsForView.${i.name}.${h.name}),`).join(`
|
|
292
|
+
`);return` ${i.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, string | undefined> {
|
|
296
293
|
return {
|
|
297
|
-
${
|
|
294
|
+
${g}
|
|
298
295
|
};
|
|
299
296
|
},`}).join(`
|
|
300
297
|
|
|
301
|
-
`),
|
|
302
|
-
`);return` ${
|
|
298
|
+
`),f=e.views.map(i=>{const g=Q(i,e).map(h=>` ${h.name}: readCell(row, columns, fieldsForView.${i.name}.${h.name}),`).join(`
|
|
299
|
+
`);return` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, unknown> {
|
|
303
300
|
return {
|
|
304
|
-
${
|
|
301
|
+
${g}
|
|
305
302
|
};
|
|
306
303
|
},`}).join(`
|
|
307
304
|
|
|
308
|
-
`),
|
|
309
|
-
return (result?.records || []).map((row) => rowValuesForView.${
|
|
305
|
+
`),y=e.views.map(i=>` ${i.name}(result: SemaphorGeneratedRecordsResult): Array<Record<keyof typeof fieldsForView.${i.name}, unknown>> {
|
|
306
|
+
return (result?.records || []).map((row) => rowValuesForView.${i.name}(row, result?.columns));
|
|
310
307
|
},`).join(`
|
|
311
308
|
|
|
312
|
-
`),
|
|
313
|
-
`);return` ${
|
|
314
|
-
const values = rowValuesForView.${
|
|
309
|
+
`),k=e.views.map(i=>{const l=Q(i,e),g=l.filter(s=>s.raw.role==="dimension"),h=l.filter(s=>s.raw.role==="measure"),I=g[0],$=g[1],M=h[0],b=h[1],E=[I?` primaryDimension: values.${I.name},`:" primaryDimension: undefined,",$?` secondaryDimension: values.${$.name},`:" secondaryDimension: undefined,",M?` primaryMeasure: values.${M.name},`:" primaryMeasure: undefined,",b?` secondaryMeasure: values.${b.name},`:" secondaryMeasure: undefined,"].join(`
|
|
310
|
+
`);return` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): SemaphorGeneratedRoleValues {
|
|
311
|
+
const values = rowValuesForView.${i.name}(row, columns);
|
|
315
312
|
return {
|
|
316
|
-
${
|
|
313
|
+
${E}
|
|
317
314
|
};
|
|
318
315
|
},`}).join(`
|
|
319
316
|
|
|
320
|
-
`),d=
|
|
321
|
-
`);return`${
|
|
322
|
-
${
|
|
317
|
+
`),d=n.includes("fields.")||r.includes("fields."),m=[`import { ${["type SemaphorFieldRef","type SemaphorResultColumn"].filter(x).join(", ")} } from "react-semaphor/data-app-sdk";`,d?'import { fields } from "./fields";':void 0].filter(x).join(`
|
|
318
|
+
`);return`${H}
|
|
319
|
+
${m}
|
|
323
320
|
|
|
324
321
|
export type SemaphorGeneratedRow = Record<string, unknown>;
|
|
325
322
|
export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
|
|
@@ -335,7 +332,6 @@ export type SemaphorGeneratedMetricResult = {
|
|
|
335
332
|
readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
|
|
336
333
|
readonly missingMeasures?: readonly string[];
|
|
337
334
|
readonly primaryValue: unknown;
|
|
338
|
-
readonly value?: unknown;
|
|
339
335
|
readonly comparisonKind?: string;
|
|
340
336
|
readonly comparisonValue?: unknown;
|
|
341
337
|
readonly delta?: number | null;
|
|
@@ -356,7 +352,6 @@ export type SemaphorGeneratedTableColumn = {
|
|
|
356
352
|
};
|
|
357
353
|
export type SemaphorGeneratedKpiResult<TValues extends Record<string, SemaphorGeneratedMetricValue> = Record<string, SemaphorGeneratedMetricValue>> =
|
|
358
354
|
Record<string, unknown> & {
|
|
359
|
-
readonly value?: SemaphorGeneratedMetricValue;
|
|
360
355
|
readonly primaryValue?: SemaphorGeneratedMetricValue;
|
|
361
356
|
readonly comparisonValue?: SemaphorGeneratedMetricValue;
|
|
362
357
|
readonly comparisonKind?: string;
|
|
@@ -379,51 +374,47 @@ export type SemaphorGeneratedKpiProps = {
|
|
|
379
374
|
};
|
|
380
375
|
|
|
381
376
|
export const fieldsForView = {
|
|
382
|
-
${r}
|
|
383
|
-
} as const;
|
|
384
|
-
|
|
385
|
-
export const metricFieldsForView = {
|
|
386
377
|
${n}
|
|
387
378
|
} as const;
|
|
388
379
|
|
|
389
|
-
export const
|
|
390
|
-
${
|
|
380
|
+
export const metricFieldsForView = {
|
|
381
|
+
${r}
|
|
391
382
|
} as const;
|
|
392
383
|
|
|
393
384
|
export const metricMeasureBindingKeysForView = {
|
|
394
|
-
${
|
|
385
|
+
${t}
|
|
395
386
|
} as const;
|
|
396
387
|
|
|
397
388
|
export const tableColumnsForView = {
|
|
398
|
-
${
|
|
389
|
+
${c}
|
|
399
390
|
} as const;
|
|
400
391
|
|
|
401
392
|
export const columnKeysForView = {
|
|
402
|
-
${
|
|
393
|
+
${w}
|
|
403
394
|
} as const;
|
|
404
395
|
|
|
405
396
|
export const rowValuesForView = {
|
|
406
|
-
${
|
|
397
|
+
${f}
|
|
407
398
|
} as const;
|
|
408
399
|
|
|
409
400
|
export const rowsForView = {
|
|
410
|
-
${
|
|
401
|
+
${y}
|
|
411
402
|
} as const;
|
|
412
403
|
|
|
413
404
|
export const roleValuesForView = {
|
|
414
|
-
${
|
|
405
|
+
${k}
|
|
415
406
|
} as const;
|
|
416
407
|
|
|
417
408
|
export const metricValuesForView = {
|
|
418
|
-
${
|
|
409
|
+
${o}
|
|
419
410
|
} as const;
|
|
420
411
|
|
|
421
412
|
export const missingMetricMeasuresForView = {
|
|
422
|
-
${
|
|
413
|
+
${a}
|
|
423
414
|
} as const;
|
|
424
415
|
|
|
425
416
|
export const kpiPropsForView = {
|
|
426
|
-
${
|
|
417
|
+
${u}
|
|
427
418
|
} as const;
|
|
428
419
|
|
|
429
420
|
export function resolveColumnKey(
|
|
@@ -467,82 +458,22 @@ export function readStringCell(
|
|
|
467
458
|
return value === null || value === undefined ? "" : String(value);
|
|
468
459
|
}
|
|
469
460
|
|
|
470
|
-
export function readMetricValue(
|
|
471
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
472
|
-
field: SemaphorFieldRef,
|
|
473
|
-
): unknown {
|
|
474
|
-
return readMetricValueByKeys(measures, metricKeysForField(field));
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
export function readMetricValueByKeys(
|
|
478
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
479
|
-
keys: readonly string[],
|
|
480
|
-
): unknown {
|
|
481
|
-
if (!measures) {
|
|
482
|
-
return undefined;
|
|
483
|
-
}
|
|
484
|
-
for (const key of keys) {
|
|
485
|
-
if (Object.prototype.hasOwnProperty.call(measures, key)) {
|
|
486
|
-
return measures[key];
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
return undefined;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
461
|
export function readMetricValueByBinding(
|
|
493
462
|
measures: SemaphorGeneratedMetricMeasures,
|
|
494
463
|
measureBindings: SemaphorGeneratedMetricMeasureBindings,
|
|
495
464
|
bindingKey: string,
|
|
496
|
-
fallbackKeys: readonly string[],
|
|
497
465
|
): unknown {
|
|
498
466
|
const resultKey = measureBindings?.[bindingKey];
|
|
499
467
|
if (resultKey && measures && Object.prototype.hasOwnProperty.call(measures, resultKey)) {
|
|
500
468
|
return measures[resultKey];
|
|
501
469
|
}
|
|
502
|
-
return
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
export function readMetricValueByKeysWithFallback(
|
|
506
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
507
|
-
keys: readonly string[],
|
|
508
|
-
fallbackValue: unknown,
|
|
509
|
-
): unknown {
|
|
510
|
-
const value = readMetricValueByKeys(measures, keys);
|
|
511
|
-
return value === undefined ? fallbackValue : value;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
export function readMetricValueByBindingWithFallback(
|
|
515
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
516
|
-
measureBindings: SemaphorGeneratedMetricMeasureBindings,
|
|
517
|
-
bindingKey: string,
|
|
518
|
-
fallbackKeys: readonly string[],
|
|
519
|
-
fallbackValue: unknown,
|
|
520
|
-
): unknown {
|
|
521
|
-
const value = readMetricValueByBinding(measures, measureBindings, bindingKey, fallbackKeys);
|
|
522
|
-
return value === undefined ? fallbackValue : value;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
export function readNumberMetricValue(
|
|
526
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
527
|
-
field: SemaphorFieldRef,
|
|
528
|
-
): number | null {
|
|
529
|
-
const value = readMetricValue(measures, field);
|
|
530
|
-
if (typeof value === "number") {
|
|
531
|
-
return Number.isFinite(value) ? value : null;
|
|
532
|
-
}
|
|
533
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
534
|
-
const parsed = Number(value);
|
|
535
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
536
|
-
}
|
|
537
|
-
return null;
|
|
470
|
+
return undefined;
|
|
538
471
|
}
|
|
539
472
|
|
|
540
|
-
export function
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const value = readMetricValue(measures, field);
|
|
545
|
-
return value === null || value === undefined ? "" : String(value);
|
|
473
|
+
export function hasOwnPrimaryMetricValue(
|
|
474
|
+
result: SemaphorGeneratedMetricResult,
|
|
475
|
+
): boolean {
|
|
476
|
+
return Boolean(result && Object.prototype.hasOwnProperty.call(result, "primaryValue"));
|
|
546
477
|
}
|
|
547
478
|
|
|
548
479
|
export function mapMetricDisplayValues(
|
|
@@ -565,112 +496,6 @@ export function metricDisplayValue(value: unknown): SemaphorGeneratedMetricValue
|
|
|
565
496
|
return String(value);
|
|
566
497
|
}
|
|
567
498
|
|
|
568
|
-
export function metricKeysForField(
|
|
569
|
-
field: SemaphorFieldRef,
|
|
570
|
-
options: { allowNameFallback?: boolean; excludedKeys?: readonly string[] } = {},
|
|
571
|
-
): string[] {
|
|
572
|
-
const prefixes = metricKeyPrefixesForSource(field.source);
|
|
573
|
-
const aggregate = metricAggregateForField(field);
|
|
574
|
-
const excludedKeys = new Set(options.excludedKeys || []);
|
|
575
|
-
return uniqueStrings([
|
|
576
|
-
metricQualifiedKeyForField(field),
|
|
577
|
-
...prefixes.map((prefix) => \`\${prefix}.\${field.name}\`),
|
|
578
|
-
\`\${aggregate.toLowerCase()}_\${field.name}\`,
|
|
579
|
-
\`\${aggregate}_\${field.name}\`,
|
|
580
|
-
\`\${field.name}_\${aggregate.toLowerCase()}\`,
|
|
581
|
-
\`\${field.name}_\${aggregate}\`,
|
|
582
|
-
...(options.allowNameFallback === false ? [] : [field.name]),
|
|
583
|
-
]).filter((key) => !excludedKeys.has(key));
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
function metricQualifiedKeyForField(field: SemaphorFieldRef): string {
|
|
587
|
-
return [
|
|
588
|
-
field.source ? sourceIdentityKey(field.source as Record<string, unknown>) : "unknown",
|
|
589
|
-
metricAggregateForField(field),
|
|
590
|
-
field.name,
|
|
591
|
-
].filter(Boolean).join(":");
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
function metricAggregateForField(field: SemaphorFieldRef): string {
|
|
595
|
-
return (field.aggregate || "SUM").toUpperCase();
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
function metricKeyPrefixesForSource(
|
|
599
|
-
source: SemaphorFieldRef["source"] | undefined,
|
|
600
|
-
): string[] {
|
|
601
|
-
if (!source) {
|
|
602
|
-
return [];
|
|
603
|
-
}
|
|
604
|
-
const sourceRecord = source as Record<string, unknown>;
|
|
605
|
-
if (source.kind === "semantic") {
|
|
606
|
-
const prefixes: string[] = [];
|
|
607
|
-
const datasetName = stringProperty(sourceRecord, "datasetName");
|
|
608
|
-
const datasetId = stringProperty(sourceRecord, "datasetId");
|
|
609
|
-
if (datasetName) {
|
|
610
|
-
prefixes.push(datasetName);
|
|
611
|
-
}
|
|
612
|
-
if (datasetId) {
|
|
613
|
-
prefixes.push(datasetId);
|
|
614
|
-
}
|
|
615
|
-
return uniqueStrings(prefixes);
|
|
616
|
-
}
|
|
617
|
-
if (source.kind === "physical") {
|
|
618
|
-
const prefixes: string[] = [];
|
|
619
|
-
const databaseName = stringProperty(sourceRecord, "databaseName");
|
|
620
|
-
const schemaName = stringProperty(sourceRecord, "schemaName");
|
|
621
|
-
const tableName = stringProperty(sourceRecord, "tableName");
|
|
622
|
-
if (tableName) {
|
|
623
|
-
prefixes.push(tableName);
|
|
624
|
-
}
|
|
625
|
-
if (schemaName && tableName) {
|
|
626
|
-
prefixes.push(\`\${schemaName}.\${tableName}\`);
|
|
627
|
-
}
|
|
628
|
-
if (databaseName && schemaName && tableName) {
|
|
629
|
-
prefixes.push(\`\${databaseName}.\${schemaName}.\${tableName}\`);
|
|
630
|
-
}
|
|
631
|
-
return uniqueStrings(prefixes);
|
|
632
|
-
}
|
|
633
|
-
return [];
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
function sourceIdentityKey(source: Record<string, unknown>): string {
|
|
637
|
-
const kind = stringProperty(source, "kind");
|
|
638
|
-
if (kind === "semantic") {
|
|
639
|
-
const datasetId = stringProperty(source, "datasetId");
|
|
640
|
-
return [
|
|
641
|
-
kind,
|
|
642
|
-
stringProperty(source, "domainId") || "",
|
|
643
|
-
datasetId
|
|
644
|
-
? \`datasetId:\${datasetId}\`
|
|
645
|
-
: \`datasetName:\${stringProperty(source, "datasetName") || ""}\`,
|
|
646
|
-
].join(":");
|
|
647
|
-
}
|
|
648
|
-
if (kind === "physical") {
|
|
649
|
-
return [
|
|
650
|
-
kind,
|
|
651
|
-
stringProperty(source, "connectionId") || "",
|
|
652
|
-
stringProperty(source, "databaseName") || "",
|
|
653
|
-
stringProperty(source, "schemaName") || "",
|
|
654
|
-
stringProperty(source, "tableName") || "",
|
|
655
|
-
].join(":");
|
|
656
|
-
}
|
|
657
|
-
return [
|
|
658
|
-
kind || "unknown",
|
|
659
|
-
stringProperty(source, "connectionId") || "",
|
|
660
|
-
stringProperty(source, "dialect") || "",
|
|
661
|
-
stringProperty(source, "label") || "",
|
|
662
|
-
].join(":");
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
function stringProperty(record: Record<string, unknown>, key: string): string | undefined {
|
|
666
|
-
const value = record[key];
|
|
667
|
-
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
function uniqueStrings(values: string[]): string[] {
|
|
671
|
-
return Array.from(new Set(values.filter((value) => value.length > 0)));
|
|
672
|
-
}
|
|
673
|
-
|
|
674
499
|
function resolveColumn(
|
|
675
500
|
columns: SemaphorGeneratedColumns,
|
|
676
501
|
field: SemaphorFieldRef,
|
|
@@ -773,13 +598,13 @@ function sourcesReferToSameDataset(
|
|
|
773
598
|
}
|
|
774
599
|
return false;
|
|
775
600
|
}
|
|
776
|
-
`}function
|
|
777
|
-
export const generatedViewIds = ${
|
|
778
|
-
export const generatedQueryViewIds = ${
|
|
779
|
-
export const generatedInputIds = ${
|
|
780
|
-
export const generatedInputOptionQueryIds = ${
|
|
781
|
-
export const generatedViewAuthoring = ${
|
|
782
|
-
export const generatedInputAuthoring = ${
|
|
601
|
+
`}function Ze(e,n){const r=Q(e,n),t=new Map((T(e)?z(e,n):[]).map(o=>[o.fieldName,o.key]));return r.map(o=>{const a=O(o.raw,n),u=a?t.get(a):void 0;return A({key:o.name,label:o.raw.label||o.raw.name,dataType:o.raw.dataType,sortable:!!u,sortKey:u})})}function We(e){const n=e.checklist.filterScopeByInput||[],r=e.checklist.requiredDevtools||{},t=e.summary.views.map(d=>d.id).filter(Boolean),o=e.views.map(d=>d.raw.id).filter(Boolean),a=e.inputs.map(d=>d.raw.id).filter(Boolean),u=e.optionQueries.map(d=>d.raw.id||`${d.input.raw.id}-options`).filter(Boolean),c=Object.fromEntries(o.map(d=>[d,e.filterContracts.filter(p=>Array.isArray(p.appliesToViewIds)&&p.appliesToViewIds.includes(d)).map(p=>p.inputId)])),w=Object.fromEntries(e.views.map(d=>[d.raw.id,{title:d.raw.title,visual:d.raw.visual,visualSpec:d.raw.visualSpec,queryKind:d.raw.queryKind,sdkBuilder:d.raw.sdkBuilder}])),f=Object.fromEntries(e.views.map(d=>{var p;return[d.raw.id,A({viewId:d.raw.id,queryId:d.name,title:d.raw.title,visualType:((p=d.raw.visualSpec)==null?void 0:p.visualType)||d.raw.visual,suggestedComponentName:ye(d.raw.title||d.raw.id||d.name),marker:{attribute:"data-semaphor-view-id",value:d.raw.id}})]})),y=Object.fromEntries(e.inputs.map(d=>{var p;return[d.raw.id,A({inputId:d.raw.id,label:d.raw.label,type:d.raw.type,optionQueryId:((p=d.raw.optionQuery)==null?void 0:p.id)||(d.raw.optionQuery?`${d.raw.id}-options`:void 0),suggestedComponentName:ye(d.raw.label||d.raw.id||d.name),marker:{attribute:"data-semaphor-input-id",value:d.raw.id}})]})),k=Object.fromEntries(e.views.map(d=>{var p,m,i;return[d.name,A({viewId:d.raw.id,viewTitle:((p=d.raw.visualSpec)==null?void 0:p.title)||d.raw.title,visualType:(m=d.raw.visualSpec)==null?void 0:m.visualType,title:((i=d.raw.visualSpec)==null?void 0:i.title)||d.raw.title})]}));return`${H}
|
|
602
|
+
export const generatedViewIds = ${C(t)} as const;
|
|
603
|
+
export const generatedQueryViewIds = ${C(o)} as const;
|
|
604
|
+
export const generatedInputIds = ${C(a)} as const;
|
|
605
|
+
export const generatedInputOptionQueryIds = ${C(u)} as const;
|
|
606
|
+
export const generatedViewAuthoring = ${C(f)} as const;
|
|
607
|
+
export const generatedInputAuthoring = ${C(y)} as const;
|
|
783
608
|
|
|
784
609
|
export type SemaphorGeneratedViewId = typeof generatedViewIds[number];
|
|
785
610
|
export type SemaphorGeneratedQueryViewId = typeof generatedQueryViewIds[number];
|
|
@@ -798,8 +623,8 @@ export type SemaphorGeneratedFilterContract = {
|
|
|
798
623
|
readonly [key: string]: unknown;
|
|
799
624
|
};
|
|
800
625
|
|
|
801
|
-
export const generatedInputIdsForView = ${
|
|
802
|
-
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${
|
|
626
|
+
export const generatedInputIdsForView = ${C(c)} as const;
|
|
627
|
+
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${C(e.filterContracts)} as const;
|
|
803
628
|
|
|
804
629
|
export function semaphorViewMarkerProps(viewId: SemaphorGeneratedViewId) {
|
|
805
630
|
return {
|
|
@@ -819,10 +644,10 @@ export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
|
819
644
|
);
|
|
820
645
|
}
|
|
821
646
|
|
|
822
|
-
export const queryDebugForView = ${
|
|
647
|
+
export const queryDebugForView = ${C(k)} as const;
|
|
823
648
|
|
|
824
|
-
export const semaphorGeneratedContractMetadata = ${
|
|
825
|
-
`}function Xe(){return`${
|
|
649
|
+
export const semaphorGeneratedContractMetadata = ${C({schemaVersion:"semaphor-generated-data-app-contract/v1",title:e.title,requiredDevtools:r,filterContracts:e.filterContracts,filterScopeByInput:n,generatedViewIds:t,generatedQueryViewIds:o,generatedInputIds:a,generatedInputOptionQueryIds:u,generatedInputIdsForView:c,generatedViewAuthoring:f,generatedInputAuthoring:y,visualSpecs:w,presentationViews:e.presentationViews})} as const;
|
|
650
|
+
`}function Xe(){return`${H}
|
|
826
651
|
export * from "./sources";
|
|
827
652
|
export * from "./fields";
|
|
828
653
|
export * from "./inputs";
|
|
@@ -830,4 +655,4 @@ export * from "./queries";
|
|
|
830
655
|
export * from "./bindings";
|
|
831
656
|
export * from "./accessors";
|
|
832
657
|
export * from "./metadata";
|
|
833
|
-
`}function D(e,
|
|
658
|
+
`}function D(e,n){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(const r of n)D(e,r);return}N(n)&&S(e,W(n));for(const r of Object.values(n))D(e,r)}}function Q(e,n){const r=[];if(on(r,e.raw.sdkSpec),r.length===0)for(const o of e.raw.fields||[])S(r,o);const t=ne(r.filter(o=>o.name&&O(o,n)).map(o=>({raw:o,key:X(o),name:""})),o=>o.key);return Se(t,n,"field"),t}function B(e,n){if(q(e.raw.sdkSpec.builder)!=="metric")return[];const r=F(e.raw.sdkSpec.spec),t=[];S(t,r==null?void 0:r.primaryMeasure);for(const a of v(r==null?void 0:r.measures))S(t,a);const o=ne(t.filter(a=>a.name&&O(a,n)).map(a=>({raw:a,key:X(a),name:""})),a=>a.key);return Se(o,n,"metric"),o}function en(e,n,r){var o;const t=(o=e.raw.metricBindingKeys)==null?void 0:o[r];if(typeof t=="string"&&t.trim())return t;throw new Error(`views.${e.raw.id}.metricBindingKeys must include a binding key for metric field ${n.raw.name}.`)}function Se(e,n,r){const t=new Map,o=new Map;for(const u of e){const c=j(u.raw.name||u.raw.label||r)||r;t.set(u.key,c),o.set(c,(o.get(c)||0)+1)}const a=new Set;for(const u of e){const c=t.get(u.key)||r,w=O(u.raw,n)||c,f=o.get(c)===1?c:w;u.name=nn(f,u.key,a)}}function nn(e,n,r){const t=tn(e)?e:j(e||"field")||"field";if(!r.has(t))return r.add(t),t;const o=rn(n),a=`${t}${o}`;if(!r.has(a))return r.add(a),a;let u=2;for(;r.has(`${a}${u}`);)u+=1;const c=`${a}${u}`;return r.add(c),c}function rn(e){let n=0;for(let r=0;r<e.length;r+=1)n=n*31+e.charCodeAt(r)>>>0;return n.toString(36).slice(0,6).replace(/^[0-9]/,"x$&")}function tn(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function on(e,n){const r=F(n.spec);if(!r)return;const t=q(n.builder);if(t==="records"){for(const o of v(r.fields))S(e,o);return}if(t==="sql"){for(const o of v(r.fields))S(e,o);return}if(t==="analysis"||t==="metric"){S(e,r.primaryMeasure);for(const o of v(r.measures))S(e,o);for(const o of v(r.dimensions))S(e,o);S(e,r.dateField);return}if(t==="matrix"){const o=ce(r.rows),a=ce(r.columns),u=v(r.values);for(const c of o)me(e,c);for(const c of a)me(e,c);for(const c of u){const w=F(c);S(e,w==null?void 0:w.field),S(e,w==null?void 0:w.measure)}}}function ce(e){if(Array.isArray(e))return e;const n=F(e);return Array.isArray(n==null?void 0:n.levels)?n.levels:[]}function me(e,n){var r;if(N(n)){S(e,n);return}S(e,(r=F(n))==null?void 0:r.field)}function fe(e){var n,r,t,o;return((n=e==null?void 0:e.computation)==null?void 0:n.kind)==="presentation_only"||((r=e==null?void 0:e.computation)==null?void 0:r.kind)==="derived"||((t=e==null?void 0:e.computation)==null?void 0:t.kind)==="unsupported"||(e==null?void 0:e.visual)==="text_block"||((o=e==null?void 0:e.visualSpec)==null?void 0:o.visualType)==="text_block"}function sn(e){const n=F(e)||{};return A({id:e.id,title:e.title,purpose:e.purpose,visual:e.visual,visualSpec:e.visualSpec,computation:e.computation,uxExpectations:e.uxExpectations,validation:e.validation,sourceViewIds:n.sourceViewIds,content:n.content,description:n.description})}function S(e,n){N(n)&&e.push(W(n))}function W(e){return{name:e.name,label:e.label,role:e.role,dataType:e.dataType,aggregate:e.aggregate,sourceKey:e.sourceKey||(e.source?le(e.source):void 0),...e.source?{source:e.source}:{}}}function an(e){if(!e.source)return;const n={...e.source,...e.sourceKey?{sourceKey:e.sourceKey}:{}},r=Ie(n);if(r)return{raw:n,key:r,aliases:Ve(n),name:""}}function N(e){const n=F(e);return!!(n&&typeof n.name=="string"&&(typeof n.role=="string"||typeof n.dataType=="string"||typeof n.aggregate=="string"||n.source||n.sourceKey))}function we(e){const n=F(e);return!!(n&&(typeof n.sourceKey=="string"||n.kind==="semantic"||typeof n.datasetName=="string"&&typeof n.domainId=="string"))}function G(e,n){if(e===void 0)return"undefined";if(e===null||typeof e=="number"||typeof e=="boolean"||typeof e=="string")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(o=>G(o,n)).join(", ")}]`;if(N(e)){const o=O(W(e),n);if(o)return`fields.${o}`}if(we(e)){const o=$e(e,n);if(o)return`sources.${o}`}const r=F(e);return r?`{ ${Object.entries(r).filter(([,o])=>o!==void 0).map(([o,a])=>`${JSON.stringify(o)}: ${G(a,n)}`).join(", ")} }`:JSON.stringify(e)}function C(e){return JSON.stringify(e,null,2)}function O(e,n){if(N(e))return n.fieldNameByKey.get(X(W(e)))}function $e(e,n){if(we(e))for(const r of ee(e)){const t=n.sourceNameByKey.get(r);if(t)return t}}function X(e){return[e.sourceKey||"",e.name||"",e.role||"",e.aggregate||""].join("|")}function un(e,n){return!N(e)||!N(n)||e.name!==n.name?!1:de(e).some(r=>de(n).includes(r))}function dn(e){return N(e)&&e.role==="id"}function pn(e){const n=[],r=new Map;for(const t of e){const o=U(t.aliases.length?t.aliases:[t.key]),a=o.map(u=>r.get(u)).find(x);if(a){a.aliases=U([...a.aliases,...o]);continue}t.aliases=o,n.push(t);for(const u of o)r.set(u,t)}return n}function ln(e){const n=new Map;for(const r of e)for(const t of U([r.key,...r.aliases])){const o=n.get(t);if(o&&o!==r.name)throw new Error(`Source identity ${t} resolves to multiple generated sources.`);n.set(t,r.name)}return n}function U(e){return Array.from(new Set(e.filter(Boolean)))}function Ie(e){return ee(e)[0]||le(e)}function ee(e){const n=F(e);if(!n)return[];const r=[];if(typeof n.sourceKey=="string"&&r.push(n.sourceKey),n.kind==="semantic"||n.datasetName){const t=typeof n.domainId=="string"?n.domainId:"";t&&typeof n.datasetId=="string"&&r.push(`semantic:${t}:datasetId:${n.datasetId}`),t&&typeof n.datasetName=="string"&&r.push(`semantic:${t}:datasetName:${n.datasetName}`)}return r.length===0&&r.push(le(e)),U(r)}function Ve(e){return ee(e)}function le(e){const n=F(e);return n?typeof n.sourceKey=="string"?n.sourceKey:JSON.stringify(n):""}function cn(e){return N(e)&&de(e)[0]||""}function de(e){return N(e)?U([...typeof e.sourceKey=="string"?[e.sourceKey]:[],...e.source?ee(e.source):[]]):[]}function q(e){const n=String(e||"").replace(/^semaphor\./,"");if(!["metric","records","analysis","matrix","sql"].includes(n))throw new Error(`Unsupported sdkSpec builder: ${e}`);return n}function mn(e){const n=q(e);return n==="records"||n==="sql"}function fn(e){const n=F(e);return typeof(n==null?void 0:n.operator)=="string"?n.operator:e.type==="date_range"?"between":e.type==="multi_select"||e.type==="select"?"in":"="}function P(e,n){const r=new Map;for(const t of e){const o=n(t)||"item",a=r.get(o)||0;r.set(o,a+1),t.name=a===0?o:`${o}${a+1}`}}function ne(e,n){const r=new Set,t=[];for(const o of e){const a=n(o);!a||r.has(a)||(r.add(a),t.push(o))}return t}function j(e){const n=String(e||"").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);if(n.length===0)return"item";const[r,...t]=n,o=[r.toLowerCase(),...t.map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase())].join("");return/^[A-Za-z_$]/.test(o)?o:`item${o}`}function ye(e){const n=j(e);return n.charAt(0).toUpperCase()+n.slice(1)}function yn(e){const n=String(e).split(":");return n[n.length-1]||String(e)}function A(e){return Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}function F(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function v(e){return Array.isArray(e)?e:[]}function L(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function x(e){return e!==void 0}exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=Y.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=Y.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=Y.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=Y.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=R.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=R.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=R.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=R.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=R.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=R.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=R.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=R.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=R.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=R.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=R.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=R.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=R.validateCodegenSummary;exports.validateSemaphorGeneratedContract=R.validateSemaphorGeneratedContract;exports.DEFAULT_GENERATED_CONTRACT_OUTPUT_DIR=Ce;exports.generateSemaphorDataAppContract=Oe;
|