react-semaphor 0.1.518 → 0.1.520
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/CHANGELOG.md +5 -0
- package/dist/chunks/{dashboard-briefing-launcher-D5HGRwtb.js → dashboard-briefing-launcher-Bz1Nehno.js} +2 -2
- package/dist/chunks/{dashboard-controls-C0Aw74JP.js → dashboard-controls-BGAQHm9o.js} +3 -3
- package/dist/chunks/{dashboard-json-B5LLO49G.js → dashboard-json-BD-OvzAw.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-D3TrgFMg.js → edit-dashboard-visual-D0nKMhz2.js} +2 -2
- package/dist/chunks/{editor-action-buttons-BfWg6DdZ.js → editor-action-buttons-H5vGG2GE.js} +1 -1
- package/dist/chunks/{index-DqTelnri.js → index-D6FCYNH2.js} +15938 -15937
- package/dist/chunks/{report-preferences-dialog-BzxqfcF8.js → report-preferences-dialog-B1sfHmXr.js} +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/data-app-builder/index.js +1 -1
- package/dist/index.js +4 -4
- package/dist/surfboard/index.js +2 -2
- package/dist/types/lib/utils/filter-formatter.d.ts +5 -0
- package/package.json +25 -48
- package/dist/analytics-protocol/index.cjs +0 -1
- package/dist/appearance/index.cjs +0 -1
- package/dist/appearance-runtime/index.cjs +0 -1
- package/dist/brand-studio/index.cjs +0 -16
- package/dist/briefings/index.cjs +0 -1
- package/dist/chunks/appearance-context-DzqCdhB4.cjs +0 -1
- package/dist/chunks/appearance-runtime-provider-D5pkvgE4.cjs +0 -1
- package/dist/chunks/braces-v55uLCAK.cjs +0 -6
- package/dist/chunks/calculated-field-identity-5bg9oHTw.cjs +0 -1
- package/dist/chunks/canonical-result-keys-Cb96edol.cjs +0 -1
- package/dist/chunks/card-config-utils-z86y6tSq.cjs +0 -1
- package/dist/chunks/color-CyB5o13F.cjs +0 -4
- package/dist/chunks/column-bands-CU0byntA.cjs +0 -1
- package/dist/chunks/common-types-nBuCd3u2.cjs +0 -1
- package/dist/chunks/constants-B00YUv89.cjs +0 -1
- package/dist/chunks/dashboard-briefing-launcher-RpT4b0d5.cjs +0 -21
- package/dist/chunks/dashboard-controls-DidqEx0U.cjs +0 -52
- package/dist/chunks/dashboard-date-comparison-definition-Y6JZwpcr.cjs +0 -1
- package/dist/chunks/dashboard-json-rY4lTftA.cjs +0 -1
- package/dist/chunks/edit-dashboard-visual-NABO8NBr.cjs +0 -172
- package/dist/chunks/editor-action-buttons-xQ5aj-0q.cjs +0 -16
- package/dist/chunks/field-aggregations-pH_3kymD.cjs +0 -1
- package/dist/chunks/field-dependencies-EB485TdB.cjs +0 -1
- package/dist/chunks/index-CapO5Uw9.cjs +0 -4
- package/dist/chunks/index-Cx3qmRUB.cjs +0 -1
- package/dist/chunks/index-Dgv9vzT0.cjs +0 -1434
- package/dist/chunks/layout-grid-xm8pqtx0.cjs +0 -6
- package/dist/chunks/matrix-analytical-definition-BWd159lN.cjs +0 -1
- package/dist/chunks/matrix-card-C2RjEYZ8.cjs +0 -1
- package/dist/chunks/matrix-continuation-6nhDy-lF.cjs +0 -1
- package/dist/chunks/matrix-control-sources-BvEJF7d3.cjs +0 -1
- package/dist/chunks/matrix-definition-DanUT11P.cjs +0 -1
- package/dist/chunks/matrix-formatter-Qk8xsR05.cjs +0 -1
- package/dist/chunks/matrix-member-presentation-DvXDEo0U.cjs +0 -1
- package/dist/chunks/matrix-operation-contract-0RxoU_M3.cjs +0 -1
- package/dist/chunks/metric-comparison-CUmltzpz.cjs +0 -1
- package/dist/chunks/mouse-pointer-2-DX4A_XZw.cjs +0 -6
- package/dist/chunks/normalize-dashboard-for-dirty-check-BYtBA708.cjs +0 -1
- package/dist/chunks/numeric-presentation-mY6wJMdB.cjs +0 -1
- package/dist/chunks/operators-DEfKaU_V.cjs +0 -1
- package/dist/chunks/palette-BN-jYtaK.cjs +0 -6
- package/dist/chunks/pivot-header-presentation-DV2aBB6p.cjs +0 -5
- package/dist/chunks/pivot-result-identity-gquWljbd.cjs +0 -1
- package/dist/chunks/pivot-result-lifecycle-OXAgoIYm.cjs +0 -1
- package/dist/chunks/raw-temporal-CYdOOyR5.cjs +0 -1
- package/dist/chunks/raw-temporal-contract-CklMVG_1.cjs +0 -1
- package/dist/chunks/report-preferences-dialog-DLnhOXXg.cjs +0 -1
- package/dist/chunks/report-runtime-context-CzSrCBsu.cjs +0 -1
- package/dist/chunks/save-3dYRmehL.cjs +0 -6
- package/dist/chunks/selection-reducer-Kl22OzIk.cjs +0 -26
- package/dist/chunks/semantic-format-Bd7HmLG_.cjs +0 -1
- package/dist/chunks/source-entity-resolution-R46X34SE.cjs +0 -1
- package/dist/chunks/stable-serialize-jqCpyZvd.cjs +0 -1
- package/dist/chunks/switch-C0520nRt.cjs +0 -134
- package/dist/chunks/temporal-bucket-4YEPEKlJ.cjs +0 -1
- package/dist/chunks/temporal-bucket-contract-nTv6gvX5.cjs +0 -1
- package/dist/chunks/temporal-input-presentation-BIOSVWCL.cjs +0 -1
- package/dist/chunks/token-types-aWrzwonf.cjs +0 -1
- package/dist/chunks/update-policy-DRDLWe7Y.cjs +0 -3
- package/dist/chunks/use-debounced-dirty-check-XHSwAefL.cjs +0 -1
- package/dist/chunks/validators-DFeDcdpA.cjs +0 -1
- package/dist/chunks/x-B6ghREd2.cjs +0 -31
- package/dist/dashboard/index.cjs +0 -1
- package/dist/dashboard-assistant/index.cjs +0 -1
- package/dist/dashboard-authoring/index.cjs +0 -3
- package/dist/data-app-builder/index.cjs +0 -51
- package/dist/data-app-builder-browser-runtime/index.cjs +0 -1
- package/dist/data-app-codegen/index.cjs +0 -1
- package/dist/data-app-codegen-node/index.cjs +0 -660
- package/dist/data-app-sdk/index.cjs +0 -117
- package/dist/data-app-sdk-adapters/index.cjs +0 -1
- package/dist/data-app-sdk-validation/index.cjs +0 -1
- package/dist/format-utils/index.cjs +0 -3
- package/dist/index.cjs +0 -1
- package/dist/layouts/index.cjs +0 -1
- package/dist/pdf-export-policy/index.cjs +0 -1
- package/dist/pdf-table-layout/index.cjs +0 -1
- package/dist/report-runtime-context/index.cjs +0 -1
- package/dist/shared/index.cjs +0 -1
- package/dist/surfboard/index.cjs +0 -1
- package/dist/types/index.cjs +0 -1
- package/dist/value-format-preferences/index.cjs +0 -1
|
@@ -1,660 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("../chunks/matrix-operation-contract-0RxoU_M3.cjs"),C=require("../chunks/update-policy-DRDLWe7Y.cjs"),he=require("node:crypto"),Ce="src/semaphor/generated",H=`// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
|
|
2
|
-
// Regenerate from the accepted semaphor_plan_data_app codegenSummary when the plan changes.
|
|
3
|
-
`;function Oe(e,n={}){C.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:C.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,l,m,i,c,h,y,V,w,O,R,k;const n=[],r=[];for(const s of e.inputs){g(r,s.fieldRef);for(const I of s.bindings||[])g(r,I.fieldRef);g(r,(d=s.optionQuery)==null?void 0:d.valueFieldRef),g(r,(l=s.optionQuery)==null?void 0:l.labelFieldRef),g(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){g(r,s.fieldRef),g(r,(c=s.optionQuery)==null?void 0:c.valueFieldRef),g(r,(h=s.optionQuery)==null?void 0:h.labelFieldRef),g(r,(y=s.optionQuery)==null?void 0:y.filterFieldRef),D(r,(V=s.optionQuery)==null?void 0:V.spec);for(const I of s.bindings||[])g(r,I.fieldRef)}for(const s of e.views){for(const I of s.fields||[])g(r,I);D(r,(w=s.sdkSpec)==null?void 0:w.spec),D(r,s.visualSpec)}const t=e.implementationChecklist||{};for(const s of Object.values(t.bindingsByView||{}))for(const I of Array.isArray(s)?s:[])g(r,I.fieldRef),g(r,I.optionValueField),g(r,I.optionLabelField);for(const s of t.requiredInputOptions||[])g(r,s.visibleLabelField),g(r,s.optionValueField),g(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)]);B(o,s=>{const I=b(s.raw);return q(s.raw.label||(I==null?void 0:I.datasetName)||(I==null?void 0:I.datasetId)||(I==null?void 0:I.name)||s.raw.kind||"source")});const a=ln(o),u=ne(r.filter(s=>s.name).map(s=>({raw:s,key:X(s),name:""})),s=>s.key);B(u,s=>q([s.raw.sourceKey?yn(s.raw.sourceKey):"",s.raw.aggregate?s.raw.aggregate.toLowerCase():"",s.raw.name].filter(Boolean).join("_")));const p=new Map(u.map(s=>[s.key,s.name])),S=e.inputs.map(s=>({raw:s,name:q(s.id||s.label||"input")}));B(S,s=>s.name);const f=S.filter(s=>!!s.raw.optionQuery).map(s=>({input:s,name:`${s.name}Options`,raw:s.raw.optionQuery}));B(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 ${((O=s.raw.spec)==null?void 0:O.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 $=e.views.filter(s=>{var I,K;return!!((I=s.sdkSpec)!=null&&I.builder&&((K=s.sdkSpec)!=null&&K.spec))}).map(s=>({raw:s,name:q(s.id||s.title||"query")}));B($,s=>s.name);const F=e.views.filter(s=>fe(s)&&!("sdkSpec"in s)).map(s=>sn(s));for(const s of e.views)(!("sdkSpec"in s)||!((R=s.sdkSpec)!=null&&R.builder)||!((k=s.sdkSpec)!=null&&k.spec))&&!fe(s)&&n.push(`Skipped view ${s.id||s.title||"unknown"} because it has no sdkSpec.`);return Ee({inputs:S,views:$,filterContracts:e.filterContracts}),{summary:e,title:e.title||"Semaphor Data App",sources:o,fields:u,inputs:S,optionQueries:f,views:$,presentationViews:F,filterContracts:e.filterContracts,checklist:t,sourceNameByKey:a,fieldNameByKey:p,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 p=new Set(u.appliesToViewIds||[]),S=new Set(u.notAppliedToViewIds||[]);for(const[f,$]of(u.appliesToViewIds||[]).entries())if(!o.has($))throw new Error(`filterContracts.${a}.appliesToViewIds.${f} must reference an executable generated view.`);for(const[f,$]of(u.notAppliedToViewIds||[]).entries())if(!o.has($))throw new Error(`filterContracts.${a}.notAppliedToViewIds.${f} must reference an executable generated view.`);for(const[f,$]of(u.bindings||[]).entries()){if(!o.has($.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must reference an executable generated view.`);if(!p.has($.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must be included in appliesToViewIds.`);if(S.has($.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":je(e),"inputs.ts":De(e),"queries.ts":Be(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:C.CONTRACT_MANIFEST_SCHEMA_VERSION,generatedContractSchemaVersion:C.GENERATED_CONTRACT_SCHEMA_VERSION,generator:{name:r,version:t},generatedContentHash:Ge(n),codegenSummaryValidatorVersion:C.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`: scalar-input and explicit selection 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`.","","For click-to-filter behavior, create one `semaphor.selection({ id, fields })` per source chart, call `useSemaphorSelection`, render its tuples as removable chips in app code, and pass the target view's selection handles as the second argument to `queryOptionsForView.<view>(inputHandles, selections)`. Do not mix selection handles into `appInputSpecs` or scalar input arrays.",""];return e.views.length>0&&(n.push("Generated executable views:"),e.views.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.title||r.name}`)}),n.push("")),e.inputs.length>0&&(n.push("Generated inputs:"),e.inputs.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.label||r.name}`)}),n.push("")),`${n.join(`
|
|
5
|
-
`)}
|
|
6
|
-
`}function xe(e){return`sha256:${he.createHash("sha256").update(ue(e)).digest("hex")}`}function ue(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t=>ue(t)).join(",")}]`;const n=e;return`{${Object.keys(n).sort().filter(t=>n[t]!==void 0).map(t=>`${JSON.stringify(t)}:${ue(n[t])}`).join(",")}}`}function Te(e){const n=e.views.find(f=>T(f)&&_(f));if(n)return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",`const sortOption = recordsSortOptionsForView.${n.name}[0];`,'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',`const query = queries.${n.name}({ page, pageSize, sort });`,`const result = useSemaphorQuery(query, queryOptionsForView.${n.name}(inputHandles));`,`const rows = rowsForView.${n.name}(result);`,"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
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 $;return mn(($=f.raw.sdkSpec)==null?void 0:$.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 p=e.views[0];return['import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',"const handles = useSemaphorInputs(appInputSpecs);","const inputHandles = createInputHandleMap(handles);",p?`const result = useSemaphorQuery(queries.${p.name}(), queryOptionsForView.${p.name}(inputHandles));`:"const result = undefined;","const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"].join(`
|
|
13
|
-
`)}function Z(e){var n;return j((n=e.raw.sdkSpec)==null?void 0:n.builder)==="records"}function _e(e){var n;return j((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 j((n=e.raw.sdkSpec)==null?void 0:n.builder)==="sql"}function _(e){var n,r,t;return((t=(r=(n=e.raw.visualSpec)==null?void 0:n.tableBehavior)==null?void 0:r.pagination)==null?void 0:t.mode)==="server"}function 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=qe(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
|
-
} as const;
|
|
20
|
-
`}function qe(e){if(e.kind==="semantic"){const n={domainId:e.domainId,datasetId:e.datasetId,datasetName:e.datasetName,label:e.label};return`semaphor.source.semantic(${M(A(n))})`}return`${M(A({...e,sourceKey:void 0}))} as const`}function je(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
|
-
|
|
23
|
-
`:"";return`${H}
|
|
24
|
-
${r}export const fields = {
|
|
25
|
-
${n}
|
|
26
|
-
} as const;
|
|
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,p])=>`${JSON.stringify(u)}: ${G(p,n)}`);return o&&a.push(`"source": sources.${o}`),`{ ${a.join(", ")} }`}function De(e){const n=e.inputs.map(m=>{const i=E(m.raw.fieldRef,e),c=[`id: ${JSON.stringify(m.raw.id)}`,`label: ${JSON.stringify(m.raw.label||m.raw.id)}`,`operator: ${JSON.stringify(fn(m.raw))}`];if(i&&c.push(`field: fields.${i}`),m.raw.relationshipHint&&c.push(`relationshipHint: ${M(m.raw.relationshipHint)}`),!i)throw new Error(`Input ${m.raw.id||m.name} is missing a generated field reference.`);return` ${m.name}: semaphor.filter({ ${c.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,c=m.raw,h=b(c.spec)||{},{id:y,inputId:V,source:w,sourceKey:O,valueField:R,labelField:k,population:s,dependencies:I,limit:K,...re}=h,J=c.sourceKey?{sourceKey:c.sourceKey}:c.source||w||(typeof O=="string"?{sourceKey:O}:void 0),te=$e(J,e),oe=E(c.valueFieldRef,e),se=E(c.labelFieldRef,e),ae=ge(m),ie={...re,id:c.id||h.id||`${i.id}-options`,inputId:i.id,source:J,valueField:c.valueFieldRef,labelField:c.labelFieldRef,population:c.population||s,dependencies:ae,limit:c.limit||K||100};if(!te||!oe||!se)throw new Error(`Input option query ${c.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=Pe(e,m),c=i.length>0?"inputHandles":"_inputHandles",h=i.map(y=>{const V=E(y.raw.fieldRef,e);if(!V)throw new Error(`Input option query ${m.raw.id||`${m.input.raw.id}-options`} references input ${y.raw.id} without a generated field reference.`);const w=`inputHandles[${JSON.stringify(y.raw.id)}]`;return` if (${w}) {
|
|
30
|
-
inputs.push(semaphor.bindInput(${w}, { field: fields.${V} }));
|
|
31
|
-
}`}).join(`
|
|
32
|
-
`);return` ${m.name}(${c}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
33
|
-
const inputs: SemaphorInputReference[] = [];
|
|
34
|
-
${h}
|
|
35
|
-
return inputs;
|
|
36
|
-
},`}).join(`
|
|
37
|
-
|
|
38
|
-
`),u=e.optionQueries.map(m=>` ${m.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
39
|
-
return {
|
|
40
|
-
inputs: inputsForInputOptionQuery.${m.name}(inputHandles),
|
|
41
|
-
};
|
|
42
|
-
},`).join(`
|
|
43
|
-
|
|
44
|
-
`),p=e.optionQueries.map(m=>` case ${JSON.stringify(m.raw.id||`${m.input.raw.id}-options`)}:
|
|
45
|
-
return queryOptionsForInputOptionQuery.${m.name}(inputHandles);`).join(`
|
|
46
|
-
`),S=e.inputs.length>0,f=e.optionQueries.length>0,$=f?"inputOptionQueryId":"_inputOptionQueryId",F=f?"inputHandles":"_inputHandles",d=["SemaphorInputHandle",f?"SemaphorInputReference":void 0,"SemaphorQueryRuntimeOptions"].filter(x).join(", "),l=[S||f?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,`import type { ${d} } from "react-semaphor/data-app-sdk";`,S||f?'import { fields } from "./fields";':void 0,f?'import { sources } from "./sources";':void 0,'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'].filter(x).join(`
|
|
47
|
-
`);return`${H}
|
|
48
|
-
${l}
|
|
49
|
-
|
|
50
|
-
export const filterSpecs = {
|
|
51
|
-
${n}
|
|
52
|
-
} as const;
|
|
53
|
-
|
|
54
|
-
export const appInputSpecs = [${r}] as const;
|
|
55
|
-
export const appInputIds = [${t}] as const;
|
|
56
|
-
|
|
57
|
-
export type SemaphorGeneratedInputHandleMap = Partial<Record<SemaphorGeneratedInputId, SemaphorInputHandle>>;
|
|
58
|
-
|
|
59
|
-
export function createInputHandleMap(handles: readonly SemaphorInputHandle[]): SemaphorGeneratedInputHandleMap {
|
|
60
|
-
return Object.fromEntries(appInputIds.map((id, index) => [id, handles[index]])) as SemaphorGeneratedInputHandleMap;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const inputOptionQueries = {
|
|
64
|
-
${o}
|
|
65
|
-
} as const;
|
|
66
|
-
|
|
67
|
-
export const inputsForInputOptionQuery = {
|
|
68
|
-
${a}
|
|
69
|
-
} as const;
|
|
70
|
-
|
|
71
|
-
export const queryOptionsForInputOptionQuery = {
|
|
72
|
-
${u}
|
|
73
|
-
} as const;
|
|
74
|
-
|
|
75
|
-
export function queryOptionsForInputOptionQueryId(
|
|
76
|
-
${$}: SemaphorGeneratedInputOptionQueryId,
|
|
77
|
-
${F}: SemaphorGeneratedInputHandleMap,
|
|
78
|
-
): SemaphorQueryRuntimeOptions {
|
|
79
|
-
switch (${$}) {
|
|
80
|
-
${p}
|
|
81
|
-
}
|
|
82
|
-
throw new Error(\`Unknown generated Semaphor input option query id: \${${$}}\`);
|
|
83
|
-
}
|
|
84
|
-
`}function Pe(e,n){const r=ge(n);if(!(r!=null&&r.mode)||r.mode==="independent")return[];const t=new Set(r.includeInputIds||[]);return e.inputs.filter(o=>o.raw.id!==n.input.raw.id&&(r.mode==="all_applicable"||t.has(o.raw.id)))}function ge(e){var n;return e.raw.dependencies||((n=e.raw.spec)==null?void 0:n.dependencies)}function Be(e){const n=e.views.map(l=>{var c,h,y,V,w,O;const m=j(l.raw.sdkSpec.builder),i=Qe(l);if(Z(l)&&He(l)){const R=(c=l.raw.visualSpec)==null?void 0:c.tableBehavior,k=b(i.pagination),s=_(l),I=T(l),K=((h=R==null?void 0:R.pagination)==null?void 0:h.pageSize)||L(k==null?void 0:k.pageSize)||L(i.limit)||100,re=I?z(l,e):[],J=I?Ue({view:l,contract:e,sortFields:re,defaultField:(y=R==null?void 0:R.sorting)==null?void 0:y.defaultField}):void 0,te=I?(V=R==null?void 0:R.sorting)==null?void 0:V.defaultDirection:void 0,oe=Je({viewName:l.name,supportsPagination:s,supportsSort:I}),se=I?` const orderBy = resolveRecordsOrderBy(
|
|
85
|
-
recordsSortFieldsForView.${l.name},
|
|
86
|
-
params.sort,
|
|
87
|
-
${G(J,e)},
|
|
88
|
-
${G(te,e)},
|
|
89
|
-
);
|
|
90
|
-
`:"",ae=I?` ...(orderBy ? { orderBy } : {}),
|
|
91
|
-
`:"",ie=s?` pagination: resolveServerTablePagination(params, ${JSON.stringify(K)}),
|
|
92
|
-
`:"";return` ${l.name}(
|
|
93
|
-
params: ${oe} = {},
|
|
94
|
-
) {
|
|
95
|
-
${se} return semaphor.${m}({
|
|
96
|
-
...${G(i,e)},
|
|
97
|
-
${ae}${ie} });
|
|
98
|
-
},`}if(pe(l)&&_(l)){const R=(w=l.raw.visualSpec)==null?void 0:w.tableBehavior,k=b(i.pagination),s=((O=R==null?void 0:R.pagination)==null?void 0:O.pageSize)||L(k==null?void 0:k.pageSize)||L(i.limit)||100;return` ${l.name}(
|
|
99
|
-
params: SemaphorGeneratedServerPaginationParams = {},
|
|
100
|
-
) {
|
|
101
|
-
return semaphor.${m}({
|
|
102
|
-
...${G(i,e)},
|
|
103
|
-
pagination: resolveServerTablePagination(params, ${JSON.stringify(s)}),
|
|
104
|
-
});
|
|
105
|
-
},`}return` ${l.name}: () => semaphor.${m}(${G(i,e)}),`}).join(`
|
|
106
|
-
`),r=e.views.filter(l=>T(l)).map(l=>{const i=z(l,e).map(c=>` ${JSON.stringify(c.key)}: fields.${c.fieldName},`).join(`
|
|
107
|
-
`);return` ${l.name}: {
|
|
108
|
-
${i}
|
|
109
|
-
},`}).join(`
|
|
110
|
-
`),t=e.views.filter(l=>T(l)).map(l=>{const i=z(l,e).map(c=>` { key: ${JSON.stringify(c.key)}, label: ${JSON.stringify(c.label)}, field: fields.${c.fieldName} },`).join(`
|
|
111
|
-
`);return` ${l.name}: [
|
|
112
|
-
${i}
|
|
113
|
-
],`}).join(`
|
|
114
|
-
`),o=e.views.some(l=>T(l)),a=e.views.some(l=>_(l)),u=[n,r,t].join(`
|
|
115
|
-
`),p=[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
|
-
${p}
|
|
118
|
-
${o?`export type SemaphorGeneratedRecordsSortDirection = "asc" | "desc";
|
|
119
|
-
|
|
120
|
-
export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
121
|
-
key: TSortKey;
|
|
122
|
-
direction: SemaphorGeneratedRecordsSortDirection;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export type SemaphorGeneratedRecordsSortParams<TSortKey extends string = string> = {
|
|
126
|
-
sort?: SemaphorGeneratedRecordsSort<TSortKey> | null;
|
|
127
|
-
};
|
|
128
|
-
`:""}${a?`export type SemaphorGeneratedServerPaginationParams = {
|
|
129
|
-
page?: number;
|
|
130
|
-
pageSize?: number;
|
|
131
|
-
};
|
|
132
|
-
`:""}${o&&a?`export type SemaphorGeneratedRecordsQueryParams<TSortKey extends string = string> =
|
|
133
|
-
SemaphorGeneratedServerPaginationParams &
|
|
134
|
-
SemaphorGeneratedRecordsSortParams<TSortKey>;
|
|
135
|
-
`:""}
|
|
136
|
-
|
|
137
|
-
export const recordsSortFieldsForView = {
|
|
138
|
-
${r}
|
|
139
|
-
} as const;
|
|
140
|
-
|
|
141
|
-
export const recordsSortOptionsForView = {
|
|
142
|
-
${t}
|
|
143
|
-
} as const;
|
|
144
|
-
|
|
145
|
-
export const queries = {
|
|
146
|
-
${n}
|
|
147
|
-
} as const;
|
|
148
|
-
|
|
149
|
-
${o?`function resolveRecordsOrderBy<TSortKey extends string>(
|
|
150
|
-
sortFields: Record<TSortKey, SemaphorFieldRef>,
|
|
151
|
-
sort: SemaphorGeneratedRecordsSort<TSortKey> | null | undefined,
|
|
152
|
-
defaultKey: TSortKey | undefined,
|
|
153
|
-
defaultDirection: SemaphorGeneratedRecordsSortDirection | undefined,
|
|
154
|
-
) {
|
|
155
|
-
const key = sort?.key ?? defaultKey;
|
|
156
|
-
if (!key) {
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
|
-
const field = sortFields[key];
|
|
160
|
-
if (!field) {
|
|
161
|
-
return undefined;
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
field,
|
|
165
|
-
direction: sort?.direction ?? defaultDirection ?? "asc",
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
`:""}
|
|
169
|
-
${a?`function resolveServerTablePagination(
|
|
170
|
-
params: SemaphorGeneratedServerPaginationParams,
|
|
171
|
-
defaultPageSize: number,
|
|
172
|
-
) {
|
|
173
|
-
return {
|
|
174
|
-
page: params.page ?? 1,
|
|
175
|
-
pageSize: params.pageSize ?? defaultPageSize,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
`:""}
|
|
179
|
-
`}function Qe(e){var a,u;const n=b((a=e.raw.sdkSpec)==null?void 0:a.spec)||{},{kind:r,id:t,...o}=n;return{...o,id:e.raw.id,label:((u=e.raw.visualSpec)==null?void 0:u.title)||e.raw.title||o.label}}function z(e,n){var a,u;const r=[],t=b((a=e.raw.sdkSpec)==null?void 0:a.spec)||{};for(const p of v(t.fields))g(r,p);g(r,t.dateField),g(r,(u=b(t.orderBy))==null?void 0:u.field);for(const p of e.raw.fields||[])g(r,p);return ne(r.map(p=>{const S=E(p,n);if(!(!p.name||!S))return{key:S,fieldName:S,rawName:p.name,label:p.label||p.name}}).filter(x),p=>p.key)}function Ue({view:e,contract:n,sortFields:r,defaultField:t}){var S,f;const o=new Set(r.map($=>$.key));if(t&&o.has(t))return t;const a=r.filter($=>$.rawName===t);if(a.length===1)return a[0].key;const u=b((S=e.raw.sdkSpec)==null?void 0:S.spec),p=E((f=b(u==null?void 0:u.orderBy))==null?void 0:f.field,n);return p&&o.has(p)?p: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(F=>{const l=ze(e,F.raw.id).map(m=>{const i=m.inputId,c=E(m.fieldRef,e);if(!i||!c)return"";const h=[`field: fields.${c}`];if(m.relationshipHint)h.push(`relationshipHint: ${M(m.relationshipHint)}`);else if(Array.isArray(m.relationshipsUsed)&&m.relationshipsUsed.length>0){const V=m.relationshipsUsed.map(w=>{var O;return(O=b(w))==null?void 0:O.id}).filter(w=>typeof w=="string"&&w.length>0);V.length>0&&h.push(`relationshipHint: ${M({relationshipIds:V})}`)}const y=`inputHandles[${JSON.stringify(i)}]`;return` if (${y}) {
|
|
180
|
-
inputs.push(semaphor.bindInput(${y}, { ${h.join(", ")} }));
|
|
181
|
-
}`}).filter(Boolean).join(`
|
|
182
|
-
`);return{view:F,renderedBindings:l}}),r=n.some(F=>F.renderedBindings.length>0),t=n.map(({view:F,renderedBindings:d})=>{const l=d?"inputHandles":"_inputHandles";return` ${F.name}(${l}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
183
|
-
const inputs: SemaphorInputReference[] = [];
|
|
184
|
-
${d}
|
|
185
|
-
return inputs;
|
|
186
|
-
},`}).join(`
|
|
187
|
-
|
|
188
|
-
`),o=e.views.map(F=>` ${F.name}(inputHandles: SemaphorGeneratedInputHandleMap, selections: SemaphorSelectionReference[] = []): SemaphorQueryRuntimeOptions {
|
|
189
|
-
return {
|
|
190
|
-
inputs: inputsForView.${F.name}(inputHandles),
|
|
191
|
-
selections,
|
|
192
|
-
debug: queryDebugForView.${F.name},
|
|
193
|
-
};
|
|
194
|
-
},`).join(`
|
|
195
|
-
|
|
196
|
-
`),a=e.views.map(F=>` case ${JSON.stringify(F.raw.id)}:
|
|
197
|
-
return inputsForView.${F.name}(inputHandles);`).join(`
|
|
198
|
-
`),u=e.views.map(F=>` case ${JSON.stringify(F.raw.id)}:
|
|
199
|
-
return queryOptionsForView.${F.name}(inputHandles, selections);`).join(`
|
|
200
|
-
`),p=e.views.length>0,S=p?"inputHandles":"_inputHandles",f=p?"selections":"_selections",$=[r?'import { semaphor } from "react-semaphor/data-app-sdk";':void 0,'import type { SemaphorInputReference, SemaphorQueryRuntimeOptions, SemaphorSelectionReference } from "react-semaphor/data-app-sdk";',r?'import { fields } from "./fields";':void 0,'import type { SemaphorGeneratedInputHandleMap } from "./inputs";',p?'import { queryDebugForView } from "./metadata";':void 0,'import type { SemaphorGeneratedQueryViewId } from "./metadata";'].filter(x).join(`
|
|
201
|
-
`);return`${H}
|
|
202
|
-
${$}
|
|
203
|
-
|
|
204
|
-
export const inputsForView = {
|
|
205
|
-
${t}
|
|
206
|
-
} as const;
|
|
207
|
-
|
|
208
|
-
export const queryOptionsForView = {
|
|
209
|
-
${o}
|
|
210
|
-
} as const;
|
|
211
|
-
|
|
212
|
-
export function inputsForViewId(
|
|
213
|
-
viewId: SemaphorGeneratedQueryViewId,
|
|
214
|
-
${S}: SemaphorGeneratedInputHandleMap,
|
|
215
|
-
): SemaphorInputReference[] {
|
|
216
|
-
switch (viewId) {
|
|
217
|
-
${a}
|
|
218
|
-
}
|
|
219
|
-
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export function queryOptionsForViewId(
|
|
223
|
-
viewId: SemaphorGeneratedQueryViewId,
|
|
224
|
-
${S}: SemaphorGeneratedInputHandleMap,
|
|
225
|
-
${f}: SemaphorSelectionReference[] = [],
|
|
226
|
-
): SemaphorQueryRuntimeOptions {
|
|
227
|
-
switch (viewId) {
|
|
228
|
-
${u}
|
|
229
|
-
}
|
|
230
|
-
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
231
|
-
}
|
|
232
|
-
`}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 h=Q(i,e).map(y=>{const V=E(y.raw,e);return V?` ${y.name}: fields.${V},`:""}).filter(Boolean).join(`
|
|
233
|
-
`);return` ${i.name}: {
|
|
234
|
-
${h}
|
|
235
|
-
},`}).join(`
|
|
236
|
-
`),r=e.views.map(i=>{const h=P(i,e).map(y=>{const V=E(y.raw,e);return V?` ${y.name}: fields.${V},`:""}).filter(Boolean).join(`
|
|
237
|
-
`);return` ${i.name}: {
|
|
238
|
-
${h}
|
|
239
|
-
},`}).join(`
|
|
240
|
-
`),t=e.views.map(i=>{const h=P(i,e).map((y,V)=>` ${y.name}: ${JSON.stringify(en(i,y,V))},`).join(`
|
|
241
|
-
`);return` ${i.name}: {
|
|
242
|
-
${h}
|
|
243
|
-
},`}).join(`
|
|
244
|
-
`),o=e.views.map(i=>{const c=P(i,e);if(c.length===0)return` ${i.name}(): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
245
|
-
return {};
|
|
246
|
-
},`;const h=c.map(y=>{const w=`readMetricValueByBinding(measures, measureBindings, ${`metricMeasureBindingKeysForView.${i.name}.${y.name}`})`;return` ${y.name}: ${w},`}).join(`
|
|
247
|
-
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
248
|
-
const measures = result?.measures;
|
|
249
|
-
const measureBindings = result?.measureBindings;
|
|
250
|
-
return {
|
|
251
|
-
${h}
|
|
252
|
-
};
|
|
253
|
-
},`}).join(`
|
|
254
|
-
|
|
255
|
-
`),a=e.views.map(i=>{const c=P(i,e);if(c.length===0)return` ${i.name}(): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
256
|
-
return [];
|
|
257
|
-
},`;const h=c.map((y,V)=>{const w=`metricMeasureBindingKeysForView.${i.name}.${y.name}`,O=V===0?`readMetricValueByBinding(measures, measureBindings, ${w}) === undefined && !hasOwnPrimaryMetricValue(result)`:`readMetricValueByBinding(measures, measureBindings, ${w}) === undefined`;return` ...(missing.has(${w}) || (${O}) ? [${JSON.stringify(y.name)} as keyof typeof metricFieldsForView.${i.name}] : []),`}).join(`
|
|
258
|
-
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
259
|
-
const missing = new Set(result?.missingMeasures || []);
|
|
260
|
-
const measures = result?.measures;
|
|
261
|
-
const measureBindings = result?.measureBindings;
|
|
262
|
-
return [
|
|
263
|
-
${h}
|
|
264
|
-
];
|
|
265
|
-
},`}).join(`
|
|
266
|
-
|
|
267
|
-
`),u=e.views.map(i=>{const c=P(i,e);if(c.length===0)return"";const h=c[0],y=c.map(w=>`{ key: ${JSON.stringify(w.name)}, label: ${JSON.stringify(w.raw.label||w.raw.name)} }`).join(", "),V=c.filter(w=>w.name!==h.name).map(w=>` if (missing.includes(${JSON.stringify(w.name)})) delete values.${w.name};`).join(`
|
|
268
|
-
`);return` ${i.name}(result: SemaphorGeneratedMetricResult): SemaphorGeneratedKpiProps {
|
|
269
|
-
const values = mapMetricDisplayValues(metricValuesForView.${i.name}(result));
|
|
270
|
-
const missing = missingMetricMeasuresForView.${i.name}(result).map((key) => String(key));
|
|
271
|
-
const primaryMissing = missing.includes(${JSON.stringify(h.name)});
|
|
272
|
-
const boundPrimaryValue = values.${h.name};
|
|
273
|
-
const primaryValue = primaryMissing || boundPrimaryValue === undefined ? result?.primaryValue : boundPrimaryValue;
|
|
274
|
-
if (primaryMissing) values.${h.name} = metricDisplayValue(result?.primaryValue);
|
|
275
|
-
${V}
|
|
276
|
-
return {
|
|
277
|
-
result: {
|
|
278
|
-
...(result || {}),
|
|
279
|
-
primaryValue: metricDisplayValue(result?.primaryValue),
|
|
280
|
-
comparisonValue: metricDisplayValue(result?.comparisonValue),
|
|
281
|
-
measures: values,
|
|
282
|
-
},
|
|
283
|
-
title: ${JSON.stringify(i.raw.title||i.raw.id)},
|
|
284
|
-
label: ${JSON.stringify(h.raw.label||h.raw.name)},
|
|
285
|
-
value: metricDisplayValue(primaryValue),
|
|
286
|
-
measures: [${y}],
|
|
287
|
-
missingMeasures: missing,
|
|
288
|
-
showComparison: Boolean(result?.comparisonKind),
|
|
289
|
-
};
|
|
290
|
-
},`}).filter(Boolean).join(`
|
|
291
|
-
|
|
292
|
-
`),p=e.views.map(i=>{const c=Ze(i,e);return` ${i.name}: ${M(c)},`}).join(`
|
|
293
|
-
`),S=e.views.map(i=>{const h=Q(i,e).map(y=>` ${y.name}: resolveColumnKey(columns, fieldsForView.${i.name}.${y.name}),`).join(`
|
|
294
|
-
`);return` ${i.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, string | undefined> {
|
|
295
|
-
return {
|
|
296
|
-
${h}
|
|
297
|
-
};
|
|
298
|
-
},`}).join(`
|
|
299
|
-
|
|
300
|
-
`),f=e.views.map(i=>{const h=Q(i,e).map(y=>` ${y.name}: readCell(row, columns, fieldsForView.${i.name}.${y.name}),`).join(`
|
|
301
|
-
`);return` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, unknown> {
|
|
302
|
-
return {
|
|
303
|
-
${h}
|
|
304
|
-
};
|
|
305
|
-
},`}).join(`
|
|
306
|
-
|
|
307
|
-
`),$=e.views.map(i=>` ${i.name}(result: SemaphorGeneratedRecordsResult): Array<Record<keyof typeof fieldsForView.${i.name}, unknown>> {
|
|
308
|
-
return (result?.records || []).map((row) => rowValuesForView.${i.name}(row, result?.columns));
|
|
309
|
-
},`).join(`
|
|
310
|
-
|
|
311
|
-
`),F=e.views.map(i=>{const c=Q(i,e),h=c.filter(s=>s.raw.role==="dimension"),y=c.filter(s=>s.raw.role==="measure"),V=h[0],w=h[1],O=y[0],R=y[1],k=[V?` primaryDimension: values.${V.name},`:" primaryDimension: undefined,",w?` secondaryDimension: values.${w.name},`:" secondaryDimension: undefined,",O?` primaryMeasure: values.${O.name},`:" primaryMeasure: undefined,",R?` secondaryMeasure: values.${R.name},`:" secondaryMeasure: undefined,"].join(`
|
|
312
|
-
`);return` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): SemaphorGeneratedRoleValues {
|
|
313
|
-
const values = rowValuesForView.${i.name}(row, columns);
|
|
314
|
-
return {
|
|
315
|
-
${k}
|
|
316
|
-
};
|
|
317
|
-
},`}).join(`
|
|
318
|
-
|
|
319
|
-
`),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(`
|
|
320
|
-
`);return`${H}
|
|
321
|
-
${m}
|
|
322
|
-
|
|
323
|
-
export type SemaphorGeneratedRow = Record<string, unknown>;
|
|
324
|
-
export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
|
|
325
|
-
export type SemaphorGeneratedRecordsResult = {
|
|
326
|
-
readonly records?: readonly SemaphorGeneratedRow[];
|
|
327
|
-
readonly columns?: SemaphorGeneratedColumns;
|
|
328
|
-
} | null | undefined;
|
|
329
|
-
export type SemaphorGeneratedMetricMeasures = Record<string, unknown> | null | undefined;
|
|
330
|
-
export type SemaphorGeneratedMetricMeasureBindings = Record<string, string> | null | undefined;
|
|
331
|
-
export type SemaphorGeneratedMetricValue = number | string | null;
|
|
332
|
-
export type SemaphorGeneratedMetricResult = {
|
|
333
|
-
readonly measures?: SemaphorGeneratedMetricMeasures;
|
|
334
|
-
readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
|
|
335
|
-
readonly missingMeasures?: readonly string[];
|
|
336
|
-
readonly primaryValue: unknown;
|
|
337
|
-
readonly comparisonKind?: string;
|
|
338
|
-
readonly comparisonValue?: unknown;
|
|
339
|
-
readonly delta?: number | null;
|
|
340
|
-
readonly deltaPercent?: number | null;
|
|
341
|
-
} | null | undefined;
|
|
342
|
-
export type SemaphorGeneratedRoleValues = {
|
|
343
|
-
readonly primaryDimension: unknown;
|
|
344
|
-
readonly secondaryDimension: unknown;
|
|
345
|
-
readonly primaryMeasure: unknown;
|
|
346
|
-
readonly secondaryMeasure: unknown;
|
|
347
|
-
};
|
|
348
|
-
export type SemaphorGeneratedTableColumn = {
|
|
349
|
-
readonly key: string;
|
|
350
|
-
readonly label: string;
|
|
351
|
-
readonly dataType?: string;
|
|
352
|
-
readonly sortable?: boolean;
|
|
353
|
-
readonly sortKey?: string;
|
|
354
|
-
};
|
|
355
|
-
export type SemaphorGeneratedKpiResult<TValues extends Record<string, SemaphorGeneratedMetricValue> = Record<string, SemaphorGeneratedMetricValue>> =
|
|
356
|
-
Record<string, unknown> & {
|
|
357
|
-
readonly primaryValue?: SemaphorGeneratedMetricValue;
|
|
358
|
-
readonly comparisonValue?: SemaphorGeneratedMetricValue;
|
|
359
|
-
readonly comparisonKind?: string;
|
|
360
|
-
readonly delta?: number | null;
|
|
361
|
-
readonly deltaPercent?: number | null;
|
|
362
|
-
readonly measures: TValues;
|
|
363
|
-
};
|
|
364
|
-
export type SemaphorGeneratedKpiMeasureConfig = {
|
|
365
|
-
key: string;
|
|
366
|
-
label: string;
|
|
367
|
-
};
|
|
368
|
-
export type SemaphorGeneratedKpiProps = {
|
|
369
|
-
readonly result: SemaphorGeneratedKpiResult;
|
|
370
|
-
readonly title: string;
|
|
371
|
-
readonly label: string;
|
|
372
|
-
readonly value: SemaphorGeneratedMetricValue;
|
|
373
|
-
readonly measures: SemaphorGeneratedKpiMeasureConfig[];
|
|
374
|
-
readonly missingMeasures: readonly string[];
|
|
375
|
-
readonly showComparison: boolean;
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
export const fieldsForView = {
|
|
379
|
-
${n}
|
|
380
|
-
} as const;
|
|
381
|
-
|
|
382
|
-
export const metricFieldsForView = {
|
|
383
|
-
${r}
|
|
384
|
-
} as const;
|
|
385
|
-
|
|
386
|
-
export const metricMeasureBindingKeysForView = {
|
|
387
|
-
${t}
|
|
388
|
-
} as const;
|
|
389
|
-
|
|
390
|
-
export const tableColumnsForView = {
|
|
391
|
-
${p}
|
|
392
|
-
} as const;
|
|
393
|
-
|
|
394
|
-
export const columnKeysForView = {
|
|
395
|
-
${S}
|
|
396
|
-
} as const;
|
|
397
|
-
|
|
398
|
-
export const rowValuesForView = {
|
|
399
|
-
${f}
|
|
400
|
-
} as const;
|
|
401
|
-
|
|
402
|
-
export const rowsForView = {
|
|
403
|
-
${$}
|
|
404
|
-
} as const;
|
|
405
|
-
|
|
406
|
-
export const roleValuesForView = {
|
|
407
|
-
${F}
|
|
408
|
-
} as const;
|
|
409
|
-
|
|
410
|
-
export const metricValuesForView = {
|
|
411
|
-
${o}
|
|
412
|
-
} as const;
|
|
413
|
-
|
|
414
|
-
export const missingMetricMeasuresForView = {
|
|
415
|
-
${a}
|
|
416
|
-
} as const;
|
|
417
|
-
|
|
418
|
-
export const kpiPropsForView = {
|
|
419
|
-
${u}
|
|
420
|
-
} as const;
|
|
421
|
-
|
|
422
|
-
export function resolveColumnKey(
|
|
423
|
-
columns: SemaphorGeneratedColumns,
|
|
424
|
-
field: SemaphorFieldRef,
|
|
425
|
-
): string | undefined {
|
|
426
|
-
return resolveColumn(columns, field)?.key;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
export function readCell(
|
|
430
|
-
row: SemaphorGeneratedRow,
|
|
431
|
-
columns: SemaphorGeneratedColumns,
|
|
432
|
-
field: SemaphorFieldRef,
|
|
433
|
-
): unknown {
|
|
434
|
-
const key = resolveColumnKey(columns, field);
|
|
435
|
-
return key ? row[key] : undefined;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
export function readNumberCell(
|
|
439
|
-
row: SemaphorGeneratedRow,
|
|
440
|
-
columns: SemaphorGeneratedColumns,
|
|
441
|
-
field: SemaphorFieldRef,
|
|
442
|
-
): number | null {
|
|
443
|
-
const value = readCell(row, columns, field);
|
|
444
|
-
if (typeof value === "number") {
|
|
445
|
-
return Number.isFinite(value) ? value : null;
|
|
446
|
-
}
|
|
447
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
448
|
-
const parsed = Number(value);
|
|
449
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
450
|
-
}
|
|
451
|
-
return null;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
export function readStringCell(
|
|
455
|
-
row: SemaphorGeneratedRow,
|
|
456
|
-
columns: SemaphorGeneratedColumns,
|
|
457
|
-
field: SemaphorFieldRef,
|
|
458
|
-
): string {
|
|
459
|
-
const value = readCell(row, columns, field);
|
|
460
|
-
return value === null || value === undefined ? "" : String(value);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
export function readMetricValueByBinding(
|
|
464
|
-
measures: SemaphorGeneratedMetricMeasures,
|
|
465
|
-
measureBindings: SemaphorGeneratedMetricMeasureBindings,
|
|
466
|
-
bindingKey: string,
|
|
467
|
-
): unknown {
|
|
468
|
-
const resultKey = measureBindings?.[bindingKey];
|
|
469
|
-
if (resultKey && measures && Object.prototype.hasOwnProperty.call(measures, resultKey)) {
|
|
470
|
-
return measures[resultKey];
|
|
471
|
-
}
|
|
472
|
-
return undefined;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
export function hasOwnPrimaryMetricValue(
|
|
476
|
-
result: SemaphorGeneratedMetricResult,
|
|
477
|
-
): boolean {
|
|
478
|
-
return Boolean(result && Object.prototype.hasOwnProperty.call(result, "primaryValue"));
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
export function mapMetricDisplayValues(
|
|
482
|
-
values: Record<string, unknown>,
|
|
483
|
-
): Record<string, SemaphorGeneratedMetricValue> {
|
|
484
|
-
return Object.fromEntries(
|
|
485
|
-
Object.entries(values)
|
|
486
|
-
.map(([key, value]) => [key, metricDisplayValue(value)] as const)
|
|
487
|
-
.filter(([key]) => values[key] !== undefined),
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
export function metricDisplayValue(value: unknown): SemaphorGeneratedMetricValue {
|
|
492
|
-
if (value === null || value === undefined) {
|
|
493
|
-
return null;
|
|
494
|
-
}
|
|
495
|
-
if (typeof value === "number" || typeof value === "string") {
|
|
496
|
-
return value;
|
|
497
|
-
}
|
|
498
|
-
return String(value);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
function resolveColumn(
|
|
502
|
-
columns: SemaphorGeneratedColumns,
|
|
503
|
-
field: SemaphorFieldRef,
|
|
504
|
-
): SemaphorResultColumn | undefined {
|
|
505
|
-
if (!columns || columns.length === 0) {
|
|
506
|
-
return undefined;
|
|
507
|
-
}
|
|
508
|
-
return (
|
|
509
|
-
findUniqueColumn(columns, (column) => column.name === field.name && columnMatchesField(column, field, true, false)) ||
|
|
510
|
-
findUniqueColumn(columns, (column) => column.name === field.name && columnMatchesField(column, field, false, false)) ||
|
|
511
|
-
findUniqueColumn(columns, (column) => columnLabelMatchesField(column, field) && columnMatchesField(column, field, true, false)) ||
|
|
512
|
-
findUniqueColumn(columns, (column) => columnLabelMatchesField(column, field) && columnMatchesField(column, field, false, false)) ||
|
|
513
|
-
findUniqueColumn(columns, (column) => column.name === field.name && columnMatchesField(column, field, true, true)) ||
|
|
514
|
-
findUniqueColumn(columns, (column) => column.name === field.name && columnMatchesField(column, field, false, true)) ||
|
|
515
|
-
findUniqueColumn(columns, (column) => columnLabelMatchesField(column, field) && columnMatchesField(column, field, true, true)) ||
|
|
516
|
-
findUniqueColumn(columns, (column) => columnLabelMatchesField(column, field) && columnMatchesField(column, field, false, true))
|
|
517
|
-
);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
function findUniqueColumn(
|
|
521
|
-
columns: readonly SemaphorResultColumn[],
|
|
522
|
-
predicate: (column: SemaphorResultColumn) => boolean,
|
|
523
|
-
): SemaphorResultColumn | undefined {
|
|
524
|
-
const matches = columns.filter(predicate);
|
|
525
|
-
return matches.length === 1 ? matches[0] : undefined;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
function columnLabelMatchesField(
|
|
529
|
-
column: SemaphorResultColumn,
|
|
530
|
-
field: SemaphorFieldRef,
|
|
531
|
-
): boolean {
|
|
532
|
-
return Boolean(field.label && column.label === field.label);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
function columnMatchesField(
|
|
536
|
-
column: SemaphorResultColumn,
|
|
537
|
-
field: SemaphorFieldRef,
|
|
538
|
-
requireComparableSource: boolean,
|
|
539
|
-
allowImplicitAggregate: boolean,
|
|
540
|
-
): boolean {
|
|
541
|
-
if (field.aggregate && column.aggregate && normalizeAggregate(field.aggregate) !== normalizeAggregate(column.aggregate)) {
|
|
542
|
-
return false;
|
|
543
|
-
}
|
|
544
|
-
if (
|
|
545
|
-
!field.aggregate &&
|
|
546
|
-
column.aggregate &&
|
|
547
|
-
(!allowImplicitAggregate || field.role !== "measure")
|
|
548
|
-
) {
|
|
549
|
-
return false;
|
|
550
|
-
}
|
|
551
|
-
if (requireComparableSource && !column.source) {
|
|
552
|
-
return false;
|
|
553
|
-
}
|
|
554
|
-
return sourcesReferToSameDataset(column.source, field.source);
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
function normalizeAggregate(aggregate: string): string {
|
|
558
|
-
return aggregate.trim().toLowerCase();
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
function sourcesReferToSameDataset(
|
|
562
|
-
left: SemaphorFieldRef["source"] | undefined,
|
|
563
|
-
right: SemaphorFieldRef["source"] | undefined,
|
|
564
|
-
): boolean {
|
|
565
|
-
if (!left || !right) {
|
|
566
|
-
return true;
|
|
567
|
-
}
|
|
568
|
-
if (left.kind !== right.kind) {
|
|
569
|
-
return false;
|
|
570
|
-
}
|
|
571
|
-
if (left.kind === "physical" && right.kind === "physical") {
|
|
572
|
-
if (left.connectionId && right.connectionId && left.connectionId !== right.connectionId) {
|
|
573
|
-
return false;
|
|
574
|
-
}
|
|
575
|
-
if (left.databaseName && right.databaseName && left.databaseName !== right.databaseName) {
|
|
576
|
-
return false;
|
|
577
|
-
}
|
|
578
|
-
if (left.schemaName && right.schemaName && left.schemaName !== right.schemaName) {
|
|
579
|
-
return false;
|
|
580
|
-
}
|
|
581
|
-
if (left.tableName && right.tableName && left.tableName !== right.tableName) {
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
584
|
-
return true;
|
|
585
|
-
}
|
|
586
|
-
if (left.kind === "sql" && right.kind === "sql") {
|
|
587
|
-
return !left.connectionId || !right.connectionId || left.connectionId === right.connectionId;
|
|
588
|
-
}
|
|
589
|
-
if (left.kind === "semantic" && right.kind === "semantic") {
|
|
590
|
-
if (left.domainId && right.domainId && left.domainId !== right.domainId) {
|
|
591
|
-
return false;
|
|
592
|
-
}
|
|
593
|
-
if (left.datasetId && right.datasetId) {
|
|
594
|
-
return left.datasetId === right.datasetId;
|
|
595
|
-
}
|
|
596
|
-
if (left.datasetName && right.datasetName) {
|
|
597
|
-
return left.datasetName === right.datasetName;
|
|
598
|
-
}
|
|
599
|
-
return true;
|
|
600
|
-
}
|
|
601
|
-
return false;
|
|
602
|
-
}
|
|
603
|
-
`}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=E(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),p=Object.fromEntries(o.map(d=>[d,e.filterContracts.filter(l=>Array.isArray(l.appliesToViewIds)&&l.appliesToViewIds.includes(d)).map(l=>l.inputId)])),S=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 l;return[d.raw.id,A({viewId:d.raw.id,queryId:d.name,title:d.raw.title,visualType:((l=d.raw.visualSpec)==null?void 0:l.visualType)||d.raw.visual,suggestedComponentName:ye(d.raw.title||d.raw.id||d.name),marker:{attribute:"data-semaphor-view-id",value:d.raw.id}})]})),$=Object.fromEntries(e.inputs.map(d=>{var l;return[d.raw.id,A({inputId:d.raw.id,label:d.raw.label,type:d.raw.type,optionQueryId:((l=d.raw.optionQuery)==null?void 0:l.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}})]})),F=Object.fromEntries(e.views.map(d=>{var l,m,i;return[d.name,A({viewId:d.raw.id,viewTitle:((l=d.raw.visualSpec)==null?void 0:l.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}
|
|
604
|
-
export const generatedViewIds = ${M(t)} as const;
|
|
605
|
-
export const generatedQueryViewIds = ${M(o)} as const;
|
|
606
|
-
export const generatedInputIds = ${M(a)} as const;
|
|
607
|
-
export const generatedInputOptionQueryIds = ${M(u)} as const;
|
|
608
|
-
export const generatedViewAuthoring = ${M(f)} as const;
|
|
609
|
-
export const generatedInputAuthoring = ${M($)} as const;
|
|
610
|
-
|
|
611
|
-
export type SemaphorGeneratedViewId = typeof generatedViewIds[number];
|
|
612
|
-
export type SemaphorGeneratedQueryViewId = typeof generatedQueryViewIds[number];
|
|
613
|
-
export type SemaphorGeneratedInputId = typeof generatedInputIds[number];
|
|
614
|
-
export type SemaphorGeneratedInputOptionQueryId = typeof generatedInputOptionQueryIds[number];
|
|
615
|
-
export type SemaphorGeneratedFilterContract = {
|
|
616
|
-
readonly inputId: string;
|
|
617
|
-
readonly appliesToViewIds: readonly SemaphorGeneratedQueryViewId[];
|
|
618
|
-
readonly notAppliedToViewIds: readonly SemaphorGeneratedQueryViewId[];
|
|
619
|
-
readonly bindings: readonly {
|
|
620
|
-
readonly viewId: SemaphorGeneratedQueryViewId;
|
|
621
|
-
readonly fieldRef: Record<string, unknown>;
|
|
622
|
-
readonly relationshipHint?: Record<string, unknown>;
|
|
623
|
-
readonly relationshipsUsed?: readonly Record<string, unknown>[];
|
|
624
|
-
}[];
|
|
625
|
-
readonly [key: string]: unknown;
|
|
626
|
-
};
|
|
627
|
-
|
|
628
|
-
export const generatedInputIdsForView = ${M(p)} as const;
|
|
629
|
-
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${M(e.filterContracts)} as const;
|
|
630
|
-
|
|
631
|
-
export function semaphorViewMarkerProps(viewId: SemaphorGeneratedViewId) {
|
|
632
|
-
return {
|
|
633
|
-
"data-semaphor-view-id": viewId,
|
|
634
|
-
} as const;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
export function semaphorInputMarkerProps(inputId: SemaphorGeneratedInputId) {
|
|
638
|
-
return {
|
|
639
|
-
"data-semaphor-input-id": inputId,
|
|
640
|
-
} as const;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
644
|
-
return generatedFilterContracts.filter((filterContract) =>
|
|
645
|
-
filterContract.appliesToViewIds.includes(viewId)
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
export const queryDebugForView = ${M(F)} as const;
|
|
650
|
-
|
|
651
|
-
export const semaphorGeneratedContractMetadata = ${M({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:p,generatedViewAuthoring:f,generatedInputAuthoring:$,visualSpecs:S,presentationViews:e.presentationViews})} as const;
|
|
652
|
-
`}function Xe(){return`${H}
|
|
653
|
-
export * from "./sources";
|
|
654
|
-
export * from "./fields";
|
|
655
|
-
export * from "./inputs";
|
|
656
|
-
export * from "./queries";
|
|
657
|
-
export * from "./bindings";
|
|
658
|
-
export * from "./accessors";
|
|
659
|
-
export * from "./metadata";
|
|
660
|
-
`}function D(e,n){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(const r of n)D(e,r);return}N(n)&&g(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||[])g(r,o);const t=ne(r.filter(o=>o.name&&E(o,n)).map(o=>({raw:o,key:X(o),name:""})),o=>o.key);return Se(t,n,"field"),t}function P(e,n){if(j(e.raw.sdkSpec.builder)!=="metric")return[];const r=b(e.raw.sdkSpec.spec),t=[];g(t,r==null?void 0:r.primaryMeasure);for(const a of v(r==null?void 0:r.measures))g(t,a);const o=ne(t.filter(a=>a.name&&E(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 p=q(u.raw.name||u.raw.label||r)||r;t.set(u.key,p),o.set(p,(o.get(p)||0)+1)}const a=new Set;for(const u of e){const p=t.get(u.key)||r,S=E(u.raw,n)||p,f=o.get(p)===1?p:S;u.name=nn(f,u.key,a)}}function nn(e,n,r){const t=tn(e)?e:q(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 p=`${a}${u}`;return r.add(p),p}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=b(n.spec);if(!r)return;const t=j(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),a=ce(r.columns),u=v(r.values);for(const p of o)me(e,p);for(const p of a)me(e,p);for(const p of u){const S=b(p);g(e,S==null?void 0:S.field),g(e,S==null?void 0:S.measure)}}}function ce(e){if(Array.isArray(e))return e;const n=b(e);return Array.isArray(n==null?void 0:n.levels)?n.levels:[]}function me(e,n){var r;if(N(n)){g(e,n);return}g(e,(r=b(n))==null?void 0:r.field)}function fe(e){var n,r,t,o;return((n=e==null?void 0:e.computation)==null?void 0:n.kind)==="presentation_only"||((r=e==null?void 0:e.computation)==null?void 0:r.kind)==="derived"||((t=e==null?void 0:e.computation)==null?void 0:t.kind)==="unsupported"||(e==null?void 0:e.visual)==="text_block"||((o=e==null?void 0:e.visualSpec)==null?void 0:o.visualType)==="text_block"}function sn(e){const n=b(e)||{};return A({id:e.id,title:e.title,purpose:e.purpose,visual:e.visual,visualSpec:e.visualSpec,computation:e.computation,uxExpectations:e.uxExpectations,validation:e.validation,sourceViewIds:n.sourceViewIds,content:n.content,description:n.description})}function g(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=b(e);return!!(n&&typeof n.name=="string"&&(typeof n.role=="string"||typeof n.dataType=="string"||typeof n.aggregate=="string"||n.source||n.sourceKey))}function we(e){const n=b(e);return!!(n&&(typeof n.sourceKey=="string"||n.kind==="semantic"||typeof n.datasetName=="string"&&typeof n.domainId=="string"))}function 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=E(W(e),n);if(o)return`fields.${o}`}if(we(e)){const o=$e(e,n);if(o)return`sources.${o}`}const r=b(e);return r?`{ ${Object.entries(r).filter(([,o])=>o!==void 0).map(([o,a])=>`${JSON.stringify(o)}: ${G(a,n)}`).join(", ")} }`:JSON.stringify(e)}function M(e){return JSON.stringify(e,null,2)}function E(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=b(e);if(!n)return[];const r=[];if(typeof n.sourceKey=="string"&&r.push(n.sourceKey),n.kind==="semantic"||n.datasetName){const t=typeof n.domainId=="string"?n.domainId:"";t&&typeof n.datasetId=="string"&&r.push(`semantic:${t}:datasetId:${n.datasetId}`),t&&typeof n.datasetName=="string"&&r.push(`semantic:${t}:datasetName:${n.datasetName}`)}return r.length===0&&r.push(le(e)),U(r)}function Ve(e){return ee(e)}function le(e){const n=b(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 j(e){const n=String(e||"").replace(/^semaphor\./,"");if(!["metric","records","analysis","matrix","sql"].includes(n))throw new Error(`Unsupported sdkSpec builder: ${e}`);return n}function mn(e){const n=j(e);return n==="records"||n==="sql"}function fn(e){const n=b(e);return typeof(n==null?void 0:n.operator)=="string"?n.operator:e.type==="date_range"?"between":e.type==="multi_select"||e.type==="select"?"in":"="}function B(e,n){const r=new Map;for(const t of e){const o=n(t)||"item",a=r.get(o)||0;r.set(o,a+1),t.name=a===0?o:`${o}${a+1}`}}function ne(e,n){const r=new Set,t=[];for(const o of e){const a=n(o);!a||r.has(a)||(r.add(a),t.push(o))}return t}function q(e){const n=String(e||"").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);if(n.length===0)return"item";const[r,...t]=n,o=[r.toLowerCase(),...t.map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase())].join("");return/^[A-Za-z_$]/.test(o)?o:`item${o}`}function ye(e){const n=q(e);return n.charAt(0).toUpperCase()+n.slice(1)}function 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 b(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=C.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=C.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=C.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=C.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=C.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=C.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=C.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=C.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=C.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=C.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=C.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=C.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=C.validateCodegenSummary;exports.validateSemaphorGeneratedContract=C.validateSemaphorGeneratedContract;exports.DEFAULT_GENERATED_CONTRACT_OUTPUT_DIR=Ce;exports.generateSemaphorDataAppContract=Oe;
|