react-semaphor 0.1.494 → 0.1.496
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 +233 -218
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +4 -4
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +5 -5
- package/dist/chunks/calculated-field-identity-Cq9GwHfE.js +1266 -0
- package/dist/chunks/calculated-field-identity-DTfyvvLC.cjs +1 -0
- package/dist/chunks/{constants-D47EhfJR.js → constants-CC3WKmqC.js} +14 -14
- package/dist/chunks/{constants-BMfm1XgO.cjs → constants-DIuhVR6J.cjs} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DQFa0Ti1.js → dashboard-briefing-launcher-Bbz4cwHb.js} +9 -9
- package/dist/chunks/{dashboard-briefing-launcher-nWBKnd0X.cjs → dashboard-briefing-launcher-CM6LTGw5.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-BbPWWVO-.cjs → dashboard-controls-B2nrczJl.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-DWpnRtQI.js → dashboard-controls-BsgADy-S.js} +11 -11
- package/dist/chunks/{dashboard-date-comparison-definition-CKXgDzSB.js → dashboard-date-comparison-definition-Bqti6YAo.js} +1 -1
- package/dist/chunks/{dashboard-date-comparison-definition-DCIUwJnZ.cjs → dashboard-date-comparison-definition-C69F-zaC.cjs} +1 -1
- package/dist/chunks/{dashboard-json-DyTQysQF.js → dashboard-json-CA-BChbt.js} +7 -7
- package/dist/chunks/{dashboard-json-BFJNDHxv.cjs → dashboard-json-CwRRBSSL.cjs} +1 -1
- package/dist/chunks/edit-dashboard-visual-BlS27LDw.cjs +172 -0
- package/dist/chunks/{edit-dashboard-visual-D-gauuNQ.js → edit-dashboard-visual-CEiPgdkX.js} +7903 -7939
- package/dist/chunks/{editor-action-buttons-DMgnHVY1.js → editor-action-buttons-6HBjjcfK.js} +6 -6
- package/dist/chunks/{editor-action-buttons-B7YezrkC.cjs → editor-action-buttons-kk2BNiTe.cjs} +1 -1
- package/dist/chunks/{field-aggregations-J7de9KZm.js → field-aggregations-C8kZqMTD.js} +11 -11
- package/dist/chunks/{field-aggregations-hx8odlTh.cjs → field-aggregations-naKZ7S2Q.cjs} +1 -1
- package/dist/chunks/{index-DXQsuuMQ.cjs → index-BSRwdFTN.cjs} +226 -225
- package/dist/chunks/{index-Df4YBtX5.cjs → index-CCa-A-Yx.cjs} +1 -1
- package/dist/chunks/{index-CPWfCksu.js → index-Cgoz65yM.js} +39519 -38739
- package/dist/chunks/{index-BDtC8et3.js → index-oll4m-qi.js} +11 -11
- package/dist/chunks/{matrix-analytical-definition-DAFStKt2.js → matrix-analytical-definition-B1xhoCak.js} +1 -1
- package/dist/chunks/{matrix-analytical-definition-B3p3vF0K.cjs → matrix-analytical-definition-BK5y9XHH.cjs} +1 -1
- package/dist/chunks/{matrix-card-5R39CCdj.js → matrix-card-BEb6hr8i.js} +2 -2
- package/dist/chunks/{matrix-card-DzkJRoM4.cjs → matrix-card-Ii8yYSnw.cjs} +1 -1
- package/dist/chunks/{matrix-control-sources-BWbqiGmN.cjs → matrix-control-sources-CdegRBcA.cjs} +1 -1
- package/dist/chunks/{matrix-control-sources-DxjWV8ry.js → matrix-control-sources-cbYmqWNg.js} +5 -5
- package/dist/chunks/{matrix-definition-Z80mIEfu.cjs → matrix-definition-CSNthxru.cjs} +1 -1
- package/dist/chunks/{matrix-definition-BcJi7qGZ.js → matrix-definition-CZM5-YJX.js} +1 -1
- package/dist/chunks/{matrix-formatter-3QR1mqhn.cjs → matrix-formatter-C19PZAal.cjs} +1 -1
- package/dist/chunks/{matrix-formatter-youWVghC.js → matrix-formatter-CiXzpX6X.js} +27 -27
- package/dist/chunks/matrix-member-presentation-CQHvq18l.cjs +1 -0
- package/dist/chunks/matrix-member-presentation-CabW8mJc.js +105 -0
- package/dist/chunks/{matrix-operation-contract-D5I-t3i7.js → matrix-operation-contract-0Nor-C71.js} +21 -21
- package/dist/chunks/{matrix-operation-contract-BiUMcd6G.cjs → matrix-operation-contract-o9GXbiHw.cjs} +1 -1
- package/dist/chunks/{metric-comparison-vr9j4Z_Z.js → metric-comparison-Br8l0WkK.js} +1 -1
- package/dist/chunks/{metric-comparison-D1VRq5Os.cjs → metric-comparison-DeiOjEm5.cjs} +1 -1
- package/dist/chunks/{operators-C8TxpM4C.js → operators-B3zZoskU.js} +28 -10
- package/dist/chunks/operators-DEfKaU_V.cjs +1 -0
- package/dist/chunks/{pivot-header-presentation-Dcd4IBM5.cjs → pivot-header-presentation-DRv-cSIP.cjs} +1 -1
- package/dist/chunks/{pivot-header-presentation-BslEo_4O.js → pivot-header-presentation-DW-ti5ek.js} +3 -3
- package/dist/chunks/{pivot-result-identity-CmvwpG4K.cjs → pivot-result-identity-DEenUrMj.cjs} +1 -1
- package/dist/chunks/{pivot-result-identity-CMz27nri.js → pivot-result-identity-sZc1RaIz.js} +1 -1
- package/dist/chunks/{pivot-result-lifecycle-H_pntnd9.cjs → pivot-result-lifecycle-D81qcCcZ.cjs} +1 -1
- package/dist/chunks/{pivot-result-lifecycle-BCoOFUiU.js → pivot-result-lifecycle-DJ40gdwk.js} +7 -7
- package/dist/chunks/{raw-temporal-DcHmXurp.cjs → raw-temporal-DDTt2yv5.cjs} +1 -1
- package/dist/chunks/{raw-temporal-YWo1GEmr.js → raw-temporal-DHCZrFe7.js} +15 -15
- package/dist/chunks/{raw-temporal-contract-Bg1mtRGE.cjs → raw-temporal-contract-BcbV56Rc.cjs} +1 -1
- package/dist/chunks/{raw-temporal-contract-DY-Jd4Sc.js → raw-temporal-contract-CkvdtPYA.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-Bt8T3To1.js → report-preferences-dialog-CVRJOCQu.js} +6 -6
- package/dist/chunks/{report-preferences-dialog-oT-C29vV.cjs → report-preferences-dialog-DGEq-iBF.cjs} +1 -1
- package/dist/chunks/{report-runtime-context-nCHl3uHC.js → report-runtime-context-BlDpc-F-.js} +1 -1
- package/dist/chunks/{report-runtime-context-Bb0ejvVq.cjs → report-runtime-context-lSIvyKm2.cjs} +1 -1
- package/dist/chunks/{semantic-format-CMPIcb8l.cjs → semantic-format--_VEin18.cjs} +1 -1
- package/dist/chunks/{semantic-format-UvUAyZS-.js → semantic-format-ew5zviaT.js} +2 -2
- package/dist/chunks/{source-entity-resolution-Dm4in31q.js → source-entity-resolution-79Rihbk3.js} +121 -107
- package/dist/chunks/source-entity-resolution-DPjslVgx.cjs +1 -0
- package/dist/chunks/{switch-DHOv6xHT.js → switch-BmyuyM7e.js} +4736 -4697
- package/dist/chunks/switch-nDjQC2y3.cjs +139 -0
- package/dist/chunks/{temporal-bucket-contract-CPuYzg7A.cjs → temporal-bucket-contract-BYR6tj6F.cjs} +1 -1
- package/dist/chunks/{temporal-bucket-contract-Bx5TJXF3.js → temporal-bucket-contract-C-kKQ_W4.js} +1 -1
- package/dist/chunks/{token-types-5buW2I6f.js → token-types-BIYFAsGq.js} +1 -1
- package/dist/chunks/{token-types-hl08eNuY.cjs → token-types-CkAGFhiW.cjs} +1 -1
- package/dist/chunks/{update-policy-BP_2uCgs.cjs → update-policy-BCtFr2Qh.cjs} +1 -1
- package/dist/chunks/{update-policy-D3I1J2kl.js → update-policy-CP_A1IVD.js} +2 -2
- package/dist/chunks/{validators-BpJDwDnG.js → validators-D-_IT-Xw.js} +1134 -1013
- package/dist/chunks/validators-ux2obZB9.cjs +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +157 -150
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +2 -2
- package/dist/data-app-codegen-node/index.js +33 -36
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +232 -230
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +3 -3
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +5 -5
- package/dist/format-utils/index.cjs +1 -1
- package/dist/format-utils/index.js +26 -26
- package/dist/index.cjs +1 -1
- package/dist/index.js +15 -15
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +2 -2
- 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 +265 -1
- package/dist/types/briefings.d.ts +55 -0
- package/dist/types/dashboard-assistant.d.ts +55 -1
- package/dist/types/dashboard-authoring.d.ts +140 -2
- package/dist/types/dashboard.d.ts +57 -0
- package/dist/types/data-app-builder.d.ts +32 -1
- package/dist/types/data-app-codegen-node.d.ts +32 -1
- package/dist/types/data-app-codegen.d.ts +32 -1
- package/dist/types/data-app-sdk-adapters.d.ts +32 -1
- package/dist/types/data-app-sdk-validation.d.ts +55 -1
- package/dist/types/data-app-sdk.d.ts +60 -1
- package/dist/types/format-utils.d.ts +9 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +122 -1
- package/dist/types/shared.d.ts +55 -0
- package/dist/types/surfboard.d.ts +57 -0
- package/dist/types/types.d.ts +57 -0
- package/package.json +1 -1
- package/dist/chunks/calculated-field-identity-CSabKrXt.js +0 -1117
- package/dist/chunks/calculated-field-identity-D4VOHjBJ.cjs +0 -1
- package/dist/chunks/edit-dashboard-visual-Dtacp_qY.cjs +0 -172
- package/dist/chunks/matrix-member-presentation-BEWAH5xK.js +0 -24
- package/dist/chunks/matrix-member-presentation-DtLGyv8w.cjs +0 -1
- package/dist/chunks/operators-DrTQsJXv.cjs +0 -1
- package/dist/chunks/source-entity-resolution-DeH38dTU.cjs +0 -1
- package/dist/chunks/switch-CatLIoK-.cjs +0 -139
- package/dist/chunks/validators-4dRtYUI1.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("zod"),n=require("./validators-4dRtYUI1.cjs"),I={answerSummary:"string",responseDetail:"responseDetail",mode:"string",comparisonKind:"string",executionResult:"executionResult",compiledQuery:"unknown",data:"unknown",resultSets:"record",analysisWarnings:"unknownArray",columns:"unknownArray",records:"recordArray",rowCount:"number",rowLimitExceeded:"boolean",output:"string",querySpec:"unknown",metadata:"record",validation:"validationResult",coverage:"coverage",diagnosticFeedback:"diagnosticFeedback",missingFields:"stringArray",warnings:"unknownArray",comparison:"unknown",population:"population",comparisons:"recordArray",fieldsUsed:"compactExecutionFieldArray",primary:"recordArray",contributors:"recordArray",segments:"recordArray",periodChanges:"recordArray",changes:"recordArray",largestNegativeChanges:"recordArray",largestPositiveChanges:"recordArray",drivers:"recordArray",absoluteDeltaDrivers:"recordArray",largestNegativeDrivers:"recordArray",largestPositiveDrivers:"recordArray",periodRows:"recordArray",sql:"unknown",omitted:"stringArray"},ke=Object.freeze({coordinates:2e4}),v=r.z.string().uuid(),p=r.z.string().min(1),Ae=r.z.number().int().positive().max(Number.MAX_SAFE_INTEGER);function m(i,s,e){i.addIssue({code:"custom",path:s,message:e})}function h(i,s,e){new Set(i).size!==i.length&&m(s,e,"Duplicate identity.")}const Z=r.z.object({id:p,axis:n.matrixAxisSchema,parent:n.matrixPathSchema,position:r.z.union([r.z.object({kind:r.z.literal("first")}).strict(),r.z.object({kind:r.z.enum(["after","before"]),cursor:p}).strict()]),size:Ae}).strict(),K=r.z.object({paths:r.z.array(n.matrixPathSchema).readonly(),pageIds:r.z.array(p).readonly()}).strict(),ee=r.z.object({id:p,rows:K,columns:K,measureIds:r.z.array(v).min(1).readonly()}).strict(),D=r.z.object({pages:r.z.array(Z).readonly(),blocks:r.z.array(ee).readonly()}).strict().superRefine((i,s)=>{!i.pages.length&&!i.blocks.length&&m(s,[],"Request at least one page or block."),h([...i.pages,...i.blocks].map(e=>e.id),s,[]);for(const e of i.blocks){h(e.measureIds,s,["blocks",e.id,"measureIds"]);for(const t of["rows","columns"])for(const a of e[t].pageIds)i.pages.some(o=>o.id===a&&o.axis===t)||m(s,["blocks",e.id,t],"Page reference must name a page on this axis in this operation.")}}),Ie=r.z.object({spec:n.matrixSpecSchema,request:D}).strict().superRefine(({spec:i,request:s},e)=>{for(const t of s.pages)n.checkMatrixPath(i,t.axis,t.parent,e,["pages",t.id],!0),t.parent.length>=i[t.axis].length&&m(e,["pages",t.id],"Cannot request children of a leaf or empty axis.");for(const t of s.blocks){t.measureIds.some(a=>!i.measures.some(o=>o.id===a))&&m(e,["blocks",t.id],"Unknown block measure.");for(const a of["rows","columns"])for(const o of t[a].paths)n.checkMatrixPath(i,a,o,e,["blocks",t.id,a])}}),se=r.z.object({requestId:p,axis:n.matrixAxisSchema,parent:n.matrixPathSchema,members:r.z.array(r.z.object({path:n.matrixPathSchema}).strict()).readonly(),before:p.nullable(),after:p.nullable(),exactCount:r.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}).strict().superRefine((i,s)=>{i.parent.some(t=>t.member.kind==="others")&&m(s,["parent"],"Others has no children.");const e=i.members.filter(({path:t})=>{var a;return((a=t[t.length-1])==null?void 0:a.member.kind)==="others"});e.length>1&&m(s,["members"],"A page may contain Others only once."),e.length&&(i.members[i.members.length-1]!==e[0]&&m(s,["members"],"Others must be the last page member."),i.after!==null&&m(s,["after"],"Others must end the branch.")),new Set(i.members.map(t=>{var a;return(a=t.path[t.path.length-1])==null?void 0:a.levelId})).size>1&&m(s,["members"],"One page must contain one child level."),h(i.members.map(t=>n.matrixPathKey(t.path)),s,["members"]);for(const t of i.members)(t.path.length!==i.parent.length+1||n.matrixPathKey(t.path.slice(0,-1))!==n.matrixPathKey(i.parent))&&m(s,["members"],"Page members must be immediate children.")}),te=r.z.object({requestId:p,coverage:r.z.object({rowPaths:r.z.array(n.matrixPathSchema).readonly(),columnPaths:r.z.array(n.matrixPathSchema).readonly(),measureIds:r.z.array(v).readonly()}).strict(),cells:r.z.array(n.matrixCoordinateSchema.extend({value:n.semaphorScalarValueSchema}).strict()).readonly()}).strict().superRefine((i,s)=>{const e=i.coverage.rowPaths.map(n.matrixPathKey),t=i.coverage.columnPaths.map(n.matrixPathKey);h(e,s,["coverage","rowPaths"]),h(t,s,["coverage","columnPaths"]),h(i.coverage.measureIds,s,["coverage","measureIds"]);const a=new Set(e),o=new Set(t),d=new Set(i.coverage.measureIds);h(i.cells.map(c=>JSON.stringify([n.matrixPathKey(c.rowPath),n.matrixPathKey(c.columnPath),c.measureId])),s,["cells"]);for(const c of i.cells)(!a.has(n.matrixPathKey(c.rowPath))||!o.has(n.matrixPathKey(c.columnPath))||!d.has(c.measureId))&&m(s,["cells"],"Cell is outside certified coverage.")}),N=r.z.object({id:v,column:n.semaphorResultColumnSchema,nativeDataType:p,semanticFormat:n.semaphorValueFormatSchema.optional()}).strict(),ie=r.z.object({levels:r.z.array(N).readonly(),measures:r.z.array(N).readonly()}).strict(),_=r.z.object({code:r.z.enum(["invalid_request","unsupported_capability","stale_cursor","forbidden","budget_exceeded","source_truncated","execution_failed","cancelled"]),message:p,detail:p.optional(),retryable:r.z.boolean(),scope:r.z.union([r.z.object({kind:r.z.literal("operation")}).strict(),r.z.object({kind:r.z.enum(["page","block"]),requestId:p}).strict()])}).strict(),re=r.z.object({dialect:r.z.enum(["postgres","clickhouse","duckdb"]),aggregates:r.z.array(n.matrixAggregateSchema).readonly()}).strict(),B=r.z.object({queryIdentity:p,descriptors:ie,capabilities:re,pages:r.z.array(se).readonly(),blocks:r.z.array(te).readonly(),failures:r.z.array(_).readonly()}).strict().superRefine((i,s)=>{const e=new Set(i.descriptors.levels.map(o=>o.id)),t=new Set(i.descriptors.measures.map(o=>o.id)),a=i.pages.flatMap(o=>[o.parent,...o.members.map(d=>d.path)]);for(const o of i.blocks)a.push(...o.coverage.rowPaths,...o.coverage.columnPaths),o.coverage.measureIds.some(d=>!t.has(d))&&m(s,["blocks",o.requestId],"Coverage references an unknown measure descriptor.");a.some(o=>o.some(d=>!e.has(d.levelId)))&&m(s,["descriptors"],"Acquired paths require level descriptors."),h([...i.descriptors.levels,...i.descriptors.measures].map(o=>o.id),s,["descriptors"]),h([...i.pages,...i.blocks].map(o=>o.requestId),s,[]),h(i.failures.map(o=>o.scope.kind==="operation"?"operation":o.scope.requestId),s,["failures"]);for(const o of i.failures)if(o.scope.kind==="operation")m(s,["failures"],"Operation failure cannot accompany acquired data.");else{const d=o.scope.requestId;[...i.pages,...i.blocks].some(c=>c.requestId===d)&&m(s,["failures"],"A requested unit cannot both succeed and fail.")}}),_e=r.z.union([r.z.object({status:r.z.enum(["success","partial"]),window:B}).strict(),r.z.object({status:r.z.literal("failed"),failure:_}).strict()]).superRefine((i,s)=>{if(i.status==="failed")return;const{window:e}=i;!e.pages.length&&!e.blocks.length&&m(s,["window"],"A window outcome requires successful acquired work."),i.status==="success"!=(e.failures.length===0)&&m(s,["status"],"Status must match failure coverage.")}),M=r.z.object({kind:r.z.literal("matrix"),window:B}).strict(),ae=r.z.enum(["member","subtotal","grand_total"]),oe=r.z.discriminatedUnion("kind",[r.z.object({kind:r.z.literal("hierarchy"),label:r.z.string()}).strict(),r.z.object({kind:r.z.literal("level"),levelId:v,label:r.z.string()}).strict(),r.z.object({kind:r.z.literal("measure"),measureId:v,columnPath:n.matrixPathSchema,role:ae,label:r.z.string()}).strict()]),ne=r.z.object({columns:r.z.array(oe).readonly(),descriptors:ie}).strict(),O=r.z.union([r.z.object({kind:r.z.literal("value"),value:n.semaphorScalarValueSchema.refine(i=>i!==null)}).strict(),r.z.object({kind:r.z.enum(["null","empty"])}).strict()]),ue=r.z.discriminatedUnion("kind",[r.z.object({kind:r.z.literal("layout"),rowPath:n.matrixPathSchema,role:ae,values:r.z.array(O).readonly()}).strict(),r.z.object({kind:r.z.literal("flat"),rowPath:n.matrixPathSchema,columnPath:n.matrixPathSchema,values:r.z.array(O).readonly()}).strict()]),Re=r.z.discriminatedUnion("kind",[r.z.object({kind:r.z.literal("layout"),layout:ne,next:p}).strict(),r.z.object({kind:r.z.literal("rows"),rows:r.z.array(ue).readonly(),next:p.nullable()}).strict()]),T=r.z.object({intent:n.matrixAnalyticalIntentSchema,matrixWindowRequest:D}).strict(),A="semaphor-data-app-codegen-summary/v1",xe="semaphor-data-app-codegen-summary-validator/v2",Ee=new Set(["metric","records","matrix","analysis","sql_fallback"]),Ce=new Set(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]),qe=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]),je=new Set(["absolute_delta","largest_negative","largest_positive","positive_and_negative","all"]),ce=new Set(["source","id","label","measures","primaryMeasure","dateField","timeGrain","dimensions","comparison","orderBy","filters","relationshipHint","limit","derivedFields"]),Fe=new Set([...ce,"analysis","timeWindow","filters","driverMode","includePopulation","calendarContext","chartTitle","chartType"]),Ke=new Set(["source","id","label","fields","dateField","timeGrain","timeWindow","filters","orderBy","relationshipHint","limit","pagination","totals","derivedFields"]),Ne=new Set(["source","id","label","sql","defaultParameters","pythonCode","fields","limit","pagination","rationale"]),Oe=new Set(["kpi","line_chart","bar_chart","stacked_bar_chart","pie_chart","donut_chart","area_chart","table","matrix","narrative","text_block","custom"]),Pe=new Set(["missing_measure","missing_dimension","missing_date","missing_relationship","missing_semantic_role","missing_current_app_state","raw_identifier_filter_options","unsupported_change_intent","ambiguous_field_grounding","bounded_intent_unavailable","invalid_bounded_intent_output","latest_snapshot_selector_not_modeled","unsupported_grain","requires_sql_escape_hatch","unsupported_sdk_capability"]);function De(i){return V(i).ok}function V(i){const s=[];if(!i||typeof i!="object")return{ok:!1,issues:["Summary must be an object."]};const e=i;return e.schemaVersion!==A&&s.push(`schemaVersion must be ${A}.`),(typeof e.title!="string"||!e.title.trim())&&s.push("title is required."),Array.isArray(e.sources)||s.push("sources must be an array."),Array.isArray(e.inputs)||s.push("inputs must be an array."),Array.isArray(e.views)||s.push("views must be an array."),Array.isArray(e.filterContracts)||s.push("filterContracts must be an array."),(!e.implementationChecklist||typeof e.implementationChecklist!="object")&&s.push("implementationChecklist must be an object."),e.implementationChecklist&&typeof e.implementationChecklist=="object"&&s.push(...Me(e.implementationChecklist)),Array.isArray(e.sources)&&e.sources.forEach((t,a)=>{s.push(...R(t,`sources.${a}`))}),Array.isArray(e.inputs)&&e.inputs.forEach((t,a)=>{s.push(...Te(t,`inputs.${a}`))}),Array.isArray(e.views)&&e.views.forEach((t,a)=>{s.push(...Ve(t,`views.${a}`))}),Array.isArray(e.filterContracts)&&e.filterContracts.forEach((t,a)=>{s.push(...Ze(t,`filterContracts.${a}`))}),e.unsupportedInsights!==void 0&&(Array.isArray(e.unsupportedInsights)?e.unsupportedInsights.forEach((t,a)=>{s.push(...fs(t,`unsupportedInsights.${a}`))}):s.push("unsupportedInsights must be an array.")),s.push(...Be(e)),{ok:s.length===0,issues:s}}function Be(i){const s=Array.isArray(i.unsupportedInsights)&&i.unsupportedInsights.some(d=>{var c;return H.has((c=u(d))==null?void 0:c.reason)}),e=Array.isArray(i.views)&&i.views.some(d=>{var l;const c=u((l=u(d))==null?void 0:l.computation);return(c==null?void 0:c.kind)==="unsupported"&&H.has(c.reason)});if(!s&&!e)return[];const t=[],a=u(i.validation);(a==null?void 0:a.status)!=="blocked"&&t.push("validation.status must be blocked when semantic model repair gaps are present.");const o=u(i.nextRequiredTool);return(o==null?void 0:o.name)!=="semaphor_propose_semantic_model_change"&&t.push("nextRequiredTool.name must be semaphor_propose_semantic_model_change when semantic model repair gaps are present."),t}const H=new Set(["missing_relationship","raw_identifier_filter_options"]);function R(i,s){const e=u(i);return e?e.kind==="semantic"?typeof e.domainId=="string"&&e.domainId.trim()&&typeof e.datasetName=="string"&&e.datasetName.trim()?[]:[`${s} must include sourceKey or a supported source identity.`]:typeof e.sourceKey=="string"&&e.sourceKey.trim()?[]:e.kind==="physical"&&typeof e.tableName=="string"&&e.tableName.trim()&&typeof e.connectionId=="string"&&e.connectionId.trim()?[]:e.kind==="sql"&&typeof e.connectionId=="string"&&e.connectionId.trim()?[]:[`${s} must include sourceKey or a supported source identity.`]:[`${s} must be an object.`]}function Me(i){const s=u(i);if(!s)return["implementationChecklist must be an object."];const e=[],t=["requiredDevtools","requiredInputOptions","filterScopeByInput","bindingsByView","validationCommands","browserSmokeChecks"];for(const o of t)o in s||e.push(`implementationChecklist.${o} is required.`);const a=u(s.requiredDevtools);return a?typeof a.mountRootDevtools!="boolean"&&e.push("implementationChecklist.requiredDevtools.mountRootDevtools must be a boolean."):e.push("implementationChecklist.requiredDevtools must be an object."),Array.isArray(s.requiredInputOptions)||e.push("implementationChecklist.requiredInputOptions must be an array."),Array.isArray(s.filterScopeByInput)||e.push("implementationChecklist.filterScopeByInput must be an array."),u(s.bindingsByView)||e.push("implementationChecklist.bindingsByView must be an object."),y(s.validationCommands)||e.push("implementationChecklist.validationCommands must be an array of strings."),y(s.browserSmokeChecks)||e.push("implementationChecklist.browserSmokeChecks must be an array of strings."),e}function Te(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return(typeof e.id!="string"||!e.id.trim())&&t.push(`${s}.id is required.`),e.fieldRef&&t.push(...f(e.fieldRef,`${s}.fieldRef`)),t.push(...le(e.optionQuery,`${s}.optionQuery`)),y(e.appliesToViewIds)||t.push(`${s}.appliesToViewIds must be an array of strings.`),e.bindings!==void 0&&!Array.isArray(e.bindings)&&t.push(`${s}.bindings must be an array.`),Array.isArray(e.bindings)&&e.bindings.forEach((a,o)=>{const d=u(a);if(!d){t.push(`${s}.bindings.${o} must be an object.`);return}y(d.appliesToViewIds)||t.push(`${s}.bindings.${o}.appliesToViewIds must be an array of strings.`),t.push(...f(d.fieldRef,`${s}.bindings.${o}.fieldRef`))}),t}function Ve(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];if((typeof e.id!="string"||!e.id.trim())&&t.push(`${s}.id is required.`),e.visualSpec!==void 0&&t.push(...ns(e.visualSpec,`${s}.visualSpec`)),e.computation!==void 0&&t.push(...ps(e.computation,`${s}.computation`)),os(e))return t.push(...E(e,`${s}`)),e.fields!==void 0&&(Array.isArray(e.fields)?e.fields.forEach((l,g)=>{t.push(...f(l,`${s}.fields.${g}`))}):t.push(`${s}.fields must be an array.`)),e.queryKind!==void 0&&t.push(`${s}.queryKind is not allowed for non-executable views.`),e.sdkBuilder!==void 0&&t.push(`${s}.sdkBuilder is not allowed for non-executable views.`),e.sdkSpec!==void 0&&t.push(`${s}.sdkSpec is not allowed for non-executable views.`),t;if(!Array.isArray(e.fields))return t.push(`${s}.fields must be an array.`),(e.sdkSpec!==void 0||e.sdkBuilder!==void 0)&&t.push(`${s}.fields must be an array for executable views.`),t.push(...E(e,`${s}`)),t;e.fields.forEach((l,g)=>{t.push(...f(l,`${s}.fields.${g}`))}),z(e.queryKind)||t.push(`${s}.queryKind must be a supported codegen query kind.`),e.sdkBuilder!==void 0&&!pe(e.sdkBuilder)&&t.push(`${s}.sdkBuilder must be a supported SDK builder.`),e.metricBindingKeys!==void 0&&(Array.isArray(e.metricBindingKeys)?e.metricBindingKeys.some(l=>typeof l!="string"||l.trim().length===0)&&t.push(`${s}.metricBindingKeys must be an array of strings.`):t.push(`${s}.metricBindingKeys must be an array of strings.`));const a=u(e.sdkSpec),o=(a==null?void 0:a.builder)==="semaphor.metric";o&&(!Array.isArray(e.metricBindingKeys)||e.metricBindingKeys.length===0)&&t.push(`${s}.metricBindingKeys is required for metric views.`);const d=Ue(e);o&&Array.isArray(e.metricBindingKeys)&&d&&JSON.stringify(e.metricBindingKeys)!==JSON.stringify(d)&&t.push(`${s}.metricBindingKeys must match the generated metric field binding keys in order.`);const c=u(e.computation);return(c==null?void 0:c.kind)==="server_query"&&z(e.queryKind)&&z(c.queryKind)&&c.queryKind!==e.queryKind&&t.push(`${s}.computation.queryKind must match queryKind.`),t.push(...es({value:e.sdkSpec,path:`${s}.sdkSpec`,queryKind:typeof e.queryKind=="string"?e.queryKind:void 0,sdkBuilder:typeof e.sdkBuilder=="string"?e.sdkBuilder:void 0}),...E(e,`${s}`)),t}function Ue(i){const s=u(i.sdkSpec);if((s==null?void 0:s.builder)!=="semaphor.metric")return;const e=u(s.spec);if(!e)return;const a=[e.primaryMeasure,...Array.isArray(e.measures)?e.measures:[]].map(Le).filter(o=>!!o);return Array.from(new Map(a.map(o=>[o.identity,o.bindingKey])).values())}function Le(i){const s=u(i);if(!s||typeof s.name!="string"||!s.name.trim())return;const e=Ge(s);return e?{identity:JSON.stringify({source:e,name:s.name,aggregate:de(s)}),bindingKey:Qe(s)}:void 0}function Ge(i){if(typeof i.sourceKey=="string"&&i.sourceKey.trim())return{sourceKey:i.sourceKey};const s=u(i.source);if(s)return{kind:s.kind,domainId:s.domainId,datasetId:s.datasetId,datasetName:s.datasetName,name:s.name}}function Qe(i){return typeof i.sourceKey=="string"&&i.sourceKey.trim()?[i.sourceKey,de(i),i.name].filter(Boolean).join(":"):n.semaphorMetricMeasureBindingKey(i)}function de(i){return n.semaphorMetricAggregate(i)}function E(i,s){var g;const e=u((g=u(i.visualSpec))==null?void 0:g.tableBehavior),t=u(i.sdkSpec),a=u(t==null?void 0:t.spec),o=typeof(t==null?void 0:t.builder)=="string"?t.builder:void 0,d=o==="semaphor.records"?u(a==null?void 0:a.totals):void 0,c=[];if(!e)return d&&c.push(`${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),c;const l=u(e.totals);return l?(l.mode==="server"&&(o!=="semaphor.records"&&c.push(`${s}.visualSpec.tableBehavior.totals.mode server is only supported for semaphor.records views.`),!d||d.mode!=="server"?c.push(`${s}.sdkSpec.spec.totals.mode must be server when tableBehavior.totals.mode is server.`):c.push(...We({left:l.measures,right:d.measures,leftPath:`${s}.visualSpec.tableBehavior.totals.measures`,rightPath:`${s}.sdkSpec.spec.totals.measures`}))),l.mode!=="server"&&d&&c.push(`${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),o==="semaphor.sql"&&l.mode!=="none"&&c.push(`${s}.visualSpec.tableBehavior.totals.mode must be none for semaphor.sql views.`),o==="semaphor.sql"&&u(a==null?void 0:a.totals)&&c.push(`${s}.sdkSpec.spec.totals is not supported for semaphor.sql.`),c):(d&&c.push(`${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),c)}function We({left:i,right:s,leftPath:e,rightPath:t}){if(!Array.isArray(i)||!Array.isArray(s))return[`${t} must match ${e}.`];const a=[];return i.length!==s.length?(a.push(`${t} must match ${e}.`),a):(i.forEach((o,d)=>{He(u(o),u(s[d]))||a.push(`${t}.${d} must match ${e}.${d}.`)}),a)}function He(i,s){return!i||!s?!1:i.name===s.name&&(i.role||"measure")===(s.role||"measure")&&Y(i)===Y(s)&&Ye(i,s)}function Y(i){return typeof i.aggregate=="string"?i.aggregate.toUpperCase():"SUM"}function Ye(i,s){const e=u(i.source),t=u(s.source);if(Xe(e,t))return!1;const a=X(i),o=X(s);if(a.size>0||o.size>0){for(const d of a)if(o.has(d))return!0;return!1}return!e||!t||e.kind!==t.kind?!1:e.kind==="semantic"?e.domainId===t.domainId&&e.datasetName===t.datasetName&&(e.datasetId===void 0||t.datasetId===void 0||e.datasetId===t.datasetId):e.kind==="physical"?e.connectionId===t.connectionId&&e.tableName===t.tableName:e.kind==="sql"?e.connectionId===t.connectionId:!1}function Xe(i,s){if(!i||!s||i.kind!=="semantic"||s.kind!=="semantic")return!1;const e=typeof i.datasetId=="string"?i.datasetId.trim():"",t=typeof s.datasetId=="string"?s.datasetId.trim():"";return!!(e&&t&&e!==t)}function X(i){const s=typeof i.sourceKey=="string"?i.sourceKey.trim():"";return s?new Set([s]):Je(u(i.source))}function Je(i){const s=new Set;if(!i)return s;const e=typeof i.sourceKey=="string"?i.sourceKey.trim():"";if(e&&s.add(e),i.kind==="semantic"){const t=typeof i.domainId=="string"?i.domainId:"",a=typeof i.datasetName=="string"?i.datasetName:"",o=typeof i.datasetId=="string"?i.datasetId:"";t&&o&&s.add(`semantic:${t}:datasetId:${o}`),t&&a&&s.add(`semantic:${t}:datasetName:${a}`)}if(i.kind==="physical"){const t=typeof i.connectionId=="string"?i.connectionId:"",a=typeof i.tableName=="string"?i.tableName:"",o=typeof i.databaseName=="string"?i.databaseName:"",d=typeof i.schemaName=="string"?i.schemaName:"";t&&a&&(s.add(["physical",t,o,d,a].join(":")),s.add(`physical:${t}:${a}`))}if(i.kind==="sql"){const t=typeof i.connectionId=="string"?i.connectionId:"",a=typeof i.dialect=="string"?i.dialect:"",o=typeof i.label=="string"?i.label:"";t&&(s.add(["sql",t,a,o].join(":")),s.add(`sql:${t}`))}return s}function Ze(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];if(e.fieldRef&&t.push(...f(e.fieldRef,`${s}.fieldRef`)),(typeof e.inputId!="string"||!e.inputId.trim())&&t.push(`${s}.inputId is required.`),t.push(...le(e.optionQuery,`${s}.optionQuery`)),y(e.appliesToViewIds)||t.push(`${s}.appliesToViewIds must be an array of strings.`),y(e.notAppliedToViewIds)||t.push(`${s}.notAppliedToViewIds must be an array of strings.`),!Array.isArray(e.bindings))t.push(`${s}.bindings must be an array.`);else{const a=y(e.appliesToViewIds)?new Set(e.appliesToViewIds):void 0,o=y(e.notAppliedToViewIds)?new Set(e.notAppliedToViewIds):void 0;e.bindings.forEach((d,c)=>{const l=u(d);if(!l){t.push(`${s}.bindings.${c} must be an object.`);return}typeof l.viewId!="string"||!l.viewId?t.push(`${s}.bindings.${c}.viewId is required.`):(a&&!a.has(l.viewId)&&t.push(`${s}.bindings.${c}.viewId must be included in appliesToViewIds.`),o!=null&&o.has(l.viewId)&&t.push(`${s}.bindings.${c}.viewId must not be listed in notAppliedToViewIds.`)),t.push(...f(l.fieldRef,`${s}.bindings.${c}.fieldRef`))})}return t}function le(i,s){if(i===void 0)return[];const e=u(i);if(!e)return[`${s} must be an object.`];const t=[...b(e.valueFieldRef,`${s}.valueFieldRef`),...b(e.labelFieldRef,`${s}.labelFieldRef`),...b(e.filterFieldRef,`${s}.filterFieldRef`)];if(e.builder!=="semaphor.inputOptions"&&t.push(`${s}.builder must be semaphor.inputOptions.`),typeof e.sourceKey!="string"&&e.source===void 0&&t.push(`${s} must include source or sourceKey.`),e.source!==void 0){const a=u(e.source);!a||a.kind!=="semantic"&&a.kind!=="physical"?t.push(`${s}.source.kind must be semantic or physical.`):t.push(...R(e.source,`${s}.source`))}return u(e.valueFieldRef)||t.push(`${s}.valueFieldRef is required.`),u(e.labelFieldRef)||t.push(`${s}.labelFieldRef is required.`),e.limit!==void 0&&(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<=0)&&t.push(`${s}.limit must be a positive integer.`),t}function es(i){var a;const s=u(i.value);if(!s)return[`${i.path} is required for executable views.`];const e=[];if(!pe(s.builder))return e.push(`${i.path}.builder must be a supported SDK builder.`),e;i.sdkBuilder&&s.builder!==i.sdkBuilder&&e.push(`${i.path}.builder must match sdkBuilder.`),i.queryKind&&z(i.queryKind)&&s.builder!==as(i.queryKind)&&e.push(`${i.path}.builder must match queryKind.`);const t=u(s.spec);if(!t)return e.push(`${i.path}.spec must be an object.`),e;switch(s.builder){case"semaphor.metric":e.push(...w(t,ce,`${i.path}.spec`),...k(t,i.path),...C(t.measures,`${i.path}.spec.measures`),...b(t.primaryMeasure,`${i.path}.spec.primaryMeasure`),...b(t.dateField,`${i.path}.spec.dateField`),...q(t.dimensions,`${i.path}.spec.dimensions`),...j(t.orderBy,`${i.path}.spec.orderBy`),...F(t.filters,`${i.path}.spec.filters`));break;case"semaphor.analysis":e.push(...w(t,Fe,`${i.path}.spec`),...k(t,i.path),...C(t.measures,`${i.path}.spec.measures`),...b(t.primaryMeasure,`${i.path}.spec.primaryMeasure`),...b(t.dateField,`${i.path}.spec.dateField`),...q(t.dimensions,`${i.path}.spec.dimensions`),...j(t.orderBy,`${i.path}.spec.orderBy`),...F(t.filters,`${i.path}.spec.filters`),...ss(t,`${i.path}.spec`));break;case"semaphor.records":e.push(...w(t,Ke,`${i.path}.spec`),...k(t,i.path),...C(t.fields,`${i.path}.spec.fields`),...b(t.dateField,`${i.path}.spec.dateField`),...j(t.orderBy,`${i.path}.spec.orderBy`),...F(t.filters,`${i.path}.spec.filters`),...ts(t.totals,`${i.path}.spec.totals`));break;case"semaphor.matrix":{const{id:o,label:d,matrixWindowRequest:c,...l}=t;for(const[$,x]of Object.entries({id:o,label:d}))x!==void 0&&(typeof x!="string"||!x.trim())&&e.push(`${i.path}.spec.${$} must be a nonempty string.`);const g=T.safeParse({intent:{...l,kind:"matrix"},matrixWindowRequest:c});g.success||e.push(...g.error.issues.map($=>`${i.path}.spec.${$.path.join(".")}: ${$.message}`));break}case"semaphor.sql":e.push(...w(t,Ne,`${i.path}.spec`),...k(t,i.path)),((a=u(t.source))==null?void 0:a.kind)!=="sql"&&e.push(`${i.path}.spec.source.kind must be sql.`),(typeof t.sql!="string"||!t.sql.trim())&&e.push(`${i.path}.spec.sql is required.`),e.push(...q(t.fields,`${i.path}.spec.fields`));break}return e}function ss(i,s){const e=[];if(i.driverMode!==void 0&&!je.has(i.driverMode)&&e.push(`${s}.driverMode must be a supported analysis driver mode.`),i.includePopulation!==void 0&&typeof i.includePopulation!="boolean"&&e.push(`${s}.includePopulation must be a boolean.`),i.calendarContext!==void 0){const t=u(i.calendarContext);if(!t)e.push(`${s}.calendarContext must be an object.`);else{t.tz!==void 0&&typeof t.tz!="string"&&e.push(`${s}.calendarContext.tz must be a string.`),t.weekStart!==void 0&&(typeof t.weekStart!="number"||!Number.isInteger(t.weekStart)||t.weekStart<0||t.weekStart>6)&&e.push(`${s}.calendarContext.weekStart must be an integer between 0 and 6.`);const a=t.anchor;if(a!==void 0&&a!=="now"){const o=u(a);(!o||typeof o.iso!="string"||!o.iso.trim())&&e.push(`${s}.calendarContext.anchor must be now or { iso }.`)}}}return e}function ts(i,s){if(i===void 0)return[];const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.mode!=="server"&&t.push(`${s}.mode must be server.`),!Array.isArray(e.measures)||e.measures.length===0?t.push(`${s}.measures must include at least one measure.`):e.measures.forEach((a,o)=>{var d;t.push(...fe(a,`${s}.measures.${o}`)),((d=u(a))==null?void 0:d.role)!=="measure"&&t.push(`${s}.measures.${o}.role must be measure.`)}),t}function w(i,s,e){const t=[];return Object.keys(i).forEach(a=>{s.has(a)||t.push(`${e}.${a} is not supported for this SDK builder.`)}),t}function k(i,s){return u(i.source)?R(i.source,`${s}.spec.source`):[`${s}.spec.source must be an object.`]}function C(i,s){const e=rs(i,s);return Array.isArray(i)&&i.forEach((t,a)=>{e.push(...f(t,`${s}.${a}`))}),e}function q(i,s){if(i===void 0)return[];if(!Array.isArray(i))return[`${s} must be an array.`];const e=[];return i.forEach((t,a)=>{e.push(...f(t,`${s}.${a}`))}),e}function j(i,s){if(i===void 0)return[];const e=u(i);return e?[...f(e.field,`${s}.field`),...is(e.direction,`${s}.direction`)]:[`${s} must be an object.`]}function is(i,s){return i==="asc"||i==="desc"?[]:[`${s} must be asc or desc.`]}function F(i,s){if(i===void 0)return[];if(!Array.isArray(i))return[`${s} must be an array.`];const e=[];return i.forEach((t,a)=>{const o=u(t);if(!o){e.push(`${s}.${a} must be an object.`);return}e.push(...f(o.field,`${s}.${a}.field`))}),e}function rs(i,s){return!Array.isArray(i)||i.length===0?[`${s} must be a non-empty array.`]:[]}function as(i){switch(i){case"metric":return"semaphor.metric";case"records":return"semaphor.records";case"matrix":return"semaphor.matrix";case"analysis":return"semaphor.analysis";case"sql_fallback":return"semaphor.sql"}}function os(i){const s=u(i.computation),e=u(i.visualSpec);return(s==null?void 0:s.kind)==="presentation_only"||(s==null?void 0:s.kind)==="derived"||(s==null?void 0:s.kind)==="unsupported"||i.visual==="text_block"||(e==null?void 0:e.visualType)==="text_block"}function ns(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return Oe.has(e.visualType)||t.push(`${s}.visualType must be a supported visual type.`),e.limit!==void 0&&(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<=0)&&t.push(`${s}.limit must be a positive integer.`),e.tableBehavior!==void 0&&t.push(...us(e.tableBehavior,`${s}.tableBehavior`)),t}function us(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.tableMode!=="bounded"&&e.tableMode!=="server_paginated"&&e.tableMode!=="server_windowed"&&t.push(`${s}.tableMode must be a supported table mode.`),t.push(...cs(e.height,`${s}.height`),...ds(e.pagination,`${s}.pagination`),...ls(e.sorting,`${s}.sorting`),...ms(e.totals,`${s}.totals`)),typeof e.serverSideRequired!="boolean"&&t.push(`${s}.serverSideRequired must be a boolean.`),t}function cs(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return(typeof e.maxPx!="number"||!Number.isInteger(e.maxPx)||e.maxPx<=0)&&t.push(`${s}.maxPx must be a positive integer.`),e.scroll!=="vertical"&&e.scroll!=="both"&&t.push(`${s}.scroll must be vertical or both.`),typeof e.stickyHeader!="boolean"&&t.push(`${s}.stickyHeader must be a boolean.`),t}function ds(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.mode!=="none"&&e.mode!=="server"&&e.mode!=="client_for_bounded_rows"&&t.push(`${s}.mode must be a supported pagination mode.`),e.pageSize!==void 0&&(typeof e.pageSize!="number"||!Number.isInteger(e.pageSize)||e.pageSize<=0)&&t.push(`${s}.pageSize must be a positive integer.`),e.readsFrom!==void 0&&e.readsFrom!=="result.pagination"&&t.push(`${s}.readsFrom must be result.pagination.`),t}function ls(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.mode!=="server"&&e.mode!=="client_for_bounded_rows"&&t.push(`${s}.mode must be a supported sorting mode.`),e.defaultField!==void 0&&(typeof e.defaultField!="string"||!e.defaultField.trim())&&t.push(`${s}.defaultField must be a non-empty string.`),e.defaultDirection!==void 0&&e.defaultDirection!=="asc"&&e.defaultDirection!=="desc"&&t.push(`${s}.defaultDirection must be asc or desc.`),e.resetPageOnChange!==void 0&&typeof e.resetPageOnChange!="boolean"&&t.push(`${s}.resetPageOnChange must be a boolean.`),t}function ms(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.mode!=="none"&&e.mode!=="server"&&e.mode!=="local"?(t.push(`${s}.mode must be none, server, or local.`),t):e.mode==="none"?(e.measures!==void 0&&t.push(`${s}.measures is not allowed when mode is none.`),e.label!==void 0&&t.push(`${s}.label is not allowed when mode is none.`),t):e.mode==="server"?(!Array.isArray(e.measures)||e.measures.length===0?t.push(`${s}.measures must include at least one measure when mode is server.`):e.measures.forEach((a,o)=>{var d;t.push(...fe(a,`${s}.measures.${o}`)),((d=u(a))==null?void 0:d.role)!=="measure"&&t.push(`${s}.measures.${o}.role must be measure.`)}),e.label!==void 0&&t.push(`${s}.label is not allowed when mode is server.`),t):(e.mode==="local"&&(e.label!=="Displayed rows"&&e.label!=="Current page"&&t.push(`${s}.label must be Displayed rows or Current page when mode is local.`),e.measures!==void 0&&t.push(`${s}.measures is not allowed when mode is local.`)),t)}function ps(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];switch(e.kind){case"server_query":z(e.queryKind)||t.push(`${s}.queryKind must be a supported codegen query kind.`),e.queryOwnership!==void 0&&e.queryOwnership!=="view_owned"&&e.queryOwnership!=="shared_query"&&t.push(`${s}.queryOwnership must be view_owned or shared_query.`),e.sourceKeys!==void 0&&!y(e.sourceKeys)&&t.push(`${s}.sourceKeys must be an array of strings.`),e.fieldNames!==void 0&&!y(e.fieldNames)&&t.push(`${s}.fieldNames must be an array of strings.`);break;case"derived":(typeof e.upstreamViewId!="string"||!e.upstreamViewId.trim())&&t.push(`${s}.upstreamViewId is required.`),(typeof e.derivation!="string"||!e.derivation.trim())&&t.push(`${s}.derivation is required.`);break;case"presentation_only":break;case"unsupported":(typeof e.reason!="string"||!e.reason.trim())&&t.push(`${s}.reason is required.`),(typeof e.suggestedModelingFix!="string"||!e.suggestedModelingFix.trim())&&t.push(`${s}.suggestedModelingFix is required.`);break;default:t.push(`${s}.kind must be a supported computation kind.`)}return t}function fs(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];for(const o of["title","requestedQuestion","suggestedModelingFix"])(typeof e[o]!="string"||!e[o].trim())&&t.push(`${s}.${o} is required.`);return Pe.has(e.reason)||t.push(`${s}.reason must be a supported unsupported insight reason.`),(e.relationshipCandidate!==void 0||e.nextRepairAction!==void 0)&&e.reason!=="missing_relationship"&&t.push(`${s} relationship repair metadata is only valid for missing_relationship unsupported insights.`),e.diagnostic!==void 0&&t.push(...hs(e.diagnostic,`${s}.diagnostic`,e.reason)),e.relationshipCandidate!==void 0&&t.push(...gs(e.relationshipCandidate,`${s}.relationshipCandidate`)),e.nextRepairAction!==void 0&&t.push(...ys(e.nextRepairAction,`${s}.nextRepairAction`)),t}function hs(i,s,e){const t=u(i);if(!t)return[`${s} must be an object.`];const a=[],o=new Set(["kind","inputId","inputLabel","optionSource","optionField","missingEvidence"]);Object.keys(t).forEach(c=>{o.has(c)||a.push(`${s}.${c} is not supported; raw identifier diagnostics support only kind, inputId, inputLabel, optionSource, optionField, and missingEvidence.`)}),e!=="raw_identifier_filter_options"&&a.push(`${s} is only valid for raw_identifier_filter_options unsupported insights.`),t.kind!=="raw_identifier_filter_options"&&a.push(`${s}.kind must be raw_identifier_filter_options.`);for(const c of["inputId","inputLabel"])(typeof t[c]!="string"||!t[c].trim())&&a.push(`${s}.${c} must be a non-empty string.`);a.push(...P(t.optionSource,`${s}.optionSource`)),a.push(...me(t.optionField,`${s}.optionField`));const d=new Set(["display_field","relationship_display_path"]);return!Array.isArray(t.missingEvidence)||t.missingEvidence.length===0?a.push(`${s}.missingEvidence must be a non-empty evidence array.`):t.missingEvidence.forEach((c,l)=>{d.has(c)||a.push(`${s}.missingEvidence.${l} must be display_field or relationship_display_path.`)}),a}function ys(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[],a=new Set(["tool","reason"]);return Object.keys(e).forEach(o=>{a.has(o)||t.push(`${s}.${o} is not supported; repair actions support only tool and reason.`)}),e.tool!=="semaphor_propose_semantic_model_change"&&t.push(`${s}.tool must be semaphor_propose_semantic_model_change.`),e.reason!=="missing_relationship"&&t.push(`${s}.reason must be missing_relationship.`),t}function gs(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[],a=new Set(["source","sourceFields","target","targetFields"]);Object.keys(e).forEach(o=>{a.has(o)||t.push(`${s}.${o} is not supported; relationship candidates support only source, sourceFields, target, and targetFields.`)}),t.push(...P(e.source,`${s}.source`)),t.push(...P(e.target,`${s}.target`));for(const o of["sourceFields","targetFields"]){const d=e[o];if(!Array.isArray(d)||d.length===0){t.push(`${s}.${o} must be a non-empty endpoint field array.`);continue}d.forEach((c,l)=>{t.push(...me(c,`${s}.${o}.${l}`))})}return t}function me(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[],a=new Set(["name","label","role","dataType"]);return Object.keys(e).forEach(o=>{a.has(o)||t.push(`${s}.${o} is not supported; relationship candidate fields are scoped by their endpoint and support only name, label, role, and dataType.`)}),(typeof e.name!="string"||!e.name.trim())&&t.push(`${s}.name must be a non-empty string.`),e.role!==void 0&&(typeof e.role!="string"||!["dimension","measure","date","id","unknown"].includes(e.role))&&t.push(`${s}.role must be dimension, measure, date, id, or unknown.`),e.dataType!==void 0&&(typeof e.dataType!="string"||!["string","number","boolean","date","datetime","unknown"].includes(e.dataType))&&t.push(`${s}.dataType must be string, number, boolean, date, datetime, or unknown.`),t}function P(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[],a=new Set(["kind","domainId","datasetName","datasetId","label","sourceKey"]);return Object.keys(e).forEach(o=>{a.has(o)||t.push(`${s}.${o} is not supported; relationship candidate sources support only semantic identity fields.`)}),e.kind!=="semantic"&&t.push(`${s} must use semantic source identity.`),(typeof e.domainId!="string"||!e.domainId.trim()||typeof e.datasetName!="string"||!e.datasetName.trim())&&t.push(`${s} must include semantic domainId and datasetName.`),t}function z(i){return Ee.has(i)}function pe(i){return Ce.has(i)}function b(i,s){return i===void 0?[]:f(i,s)}function f(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return(typeof e.name!="string"||!e.name.trim())&&t.push(`${s}.name is required.`),!e.source&&typeof e.sourceKey!="string"&&t.push(`${s} must include source or sourceKey.`),e.aggregate!==void 0&&!qe.has(e.aggregate)&&t.push(`${s}.aggregate must be a supported aggregate function.`),t}function fe(i,s){const e=u(i),t=f(i,s);if(!e||typeof e.sourceKey=="string"&&e.sourceKey.trim())return t;if(e.source!==void 0){const o=R(e.source,`${s}.source`);return o.length===0||t.push(...o),t}return t.includes(`${s} must include source or sourceKey.`)||t.push(`${s} must include source or sourceKey.`),t}function u(i){return i&&typeof i=="object"&&!Array.isArray(i)?i:void 0}function y(i){return Array.isArray(i)&&i.every(s=>typeof s=="string")}const he=r.z.union([n.semaphorMetricResultSchema,n.semaphorRecordsResultSchema,n.semaphorInputOptionsResultSchema,n.semaphorSqlResultSchema,M]),ye=r.z.object({status:r.z.enum(["not_required","resolved","missing","ambiguous","fanout_risk","unknown"]),requiredSources:r.z.array(n.semaphorSourceRefSchema).optional(),relationshipsUsed:r.z.array(r.z.string()).optional(),missingSources:r.z.array(r.z.string()).optional(),warnings:r.z.array(r.z.string()).optional(),message:r.z.string().optional(),recommendedNextStep:r.z.string().optional(),joinPlanSummary:r.z.object({baseSource:n.semaphorSourceRefSchema.optional(),joinedSources:r.z.array(n.semaphorSourceRefSchema).optional(),joinCount:r.z.number().optional()}).passthrough().optional(),fanoutRisk:r.z.object({status:r.z.enum(["none","warning","error","unknown"]),message:r.z.string().optional()}).passthrough().optional()}).passthrough(),J=r.z.enum(["ambiguous_fields","empty_result","missing_grounded_fields","missing_relationship","no_grounded_query","partial_result","presentation_incomplete","query_validation_failed","unsafe_join"]),U=r.z.object({version:r.z.literal(1),status:r.z.enum(["answered","partial","blocked"]),summary:r.z.string(),answered:r.z.array(r.z.object({slotId:r.z.string().optional(),queryId:r.z.string().optional(),summary:r.z.string(),evidenceIds:r.z.array(r.z.string()).optional(),fieldsUsed:r.z.array(n.semaphorExecutionFieldRefSchema).optional()}).passthrough()),blocked:r.z.array(r.z.object({slotId:r.z.string().optional(),queryId:r.z.string().optional(),reasonCode:J,message:r.z.string(),missingFields:r.z.array(r.z.string()).optional(),availableFields:r.z.array(r.z.string()).optional(),ambiguousFields:r.z.array(r.z.string()).optional(),missingRelationships:r.z.array(r.z.string()).optional(),evidenceIds:r.z.array(r.z.string()).optional(),neededFromUser:r.z.array(r.z.string()).optional(),recommendedNextStep:r.z.string().optional()}).passthrough()),semanticModelRecommendations:r.z.array(r.z.object({reasonCode:J,message:r.z.string(),recommendedNextStep:r.z.string().optional()}).passthrough()).optional()}).passthrough(),L=r.z.object({scope:r.z.literal("filtered_query"),measures:r.z.record(n.nullableScalarSchema)}).passthrough(),G=r.z.object({answeredObligations:r.z.array(r.z.string()),missingObligations:r.z.array(r.z.string()),warnings:r.z.array(n.semaphorAnalyticsValidationIssueSchema).optional()}).passthrough(),Q=r.z.object({intentId:r.z.string().optional(),queryId:r.z.string().optional(),status:r.z.enum(["answered","partial","failed"]),resultShape:r.z.enum(["metric","records","inputOptions","sql","matrix","period_change","analysis"]).optional(),intent:r.z.unknown().optional(),compiledQuery:r.z.unknown().optional(),fieldsUsed:r.z.array(n.semaphorExecutionFieldRefSchema).optional(),result:he.optional(),validation:n.semaphorAnalyticsValidationResultSchema,coverage:G.optional(),missingFields:r.z.array(r.z.string()).optional(),warnings:r.z.array(r.z.string()).optional(),relationshipDiagnostics:ye.optional(),diagnosticFeedback:U.optional(),population:L.optional(),metadata:r.z.record(r.z.string(),r.z.unknown()).optional()}).passthrough(),ge=Q;function bs(i){switch(i){case"boolean":return r.z.boolean().optional();case"compactExecutionFieldArray":return r.z.array(n.semaphorCompactFieldRefSchema).optional();case"coverage":return G.optional();case"diagnosticFeedback":return U.optional();case"executionFieldArray":return r.z.array(n.semaphorExecutionFieldRefSchema).optional();case"executionResult":return ge.optional();case"number":return r.z.number().finite().optional();case"population":return L.optional();case"record":return n.recordSchema.optional();case"recordArray":return n.recordArraySchema.optional();case"responseDetail":return r.z.enum(["compact","standard","debug"]).optional();case"string":return r.z.string().optional();case"stringArray":return r.z.array(r.z.string()).optional();case"unknown":return r.z.unknown().optional();case"unknownArray":return r.z.array(r.z.unknown()).optional();case"validationResult":return n.semaphorAnalyticsValidationResultSchema.optional()}}const be=Object.fromEntries(Object.entries(I).map(([i,s])=>[i,bs(s)])),Se=r.z.object(be).strict(),W=r.z.object({sourceKey:r.z.string().optional(),kind:r.z.enum(["semantic","physical","sql"]).optional(),domainId:r.z.string().optional(),datasetName:r.z.string().optional(),datasetId:r.z.string().optional(),connectionId:r.z.string().optional(),tableName:r.z.string().optional(),label:r.z.string().optional()}).passthrough(),S=r.z.object({name:r.z.string(),label:r.z.string().optional(),role:r.z.enum(["dimension","measure","date","id","unknown"]).optional(),dataType:r.z.enum(["string","number","boolean","date","datetime","unknown"]).optional(),aggregate:n.semaphorAggregateFunctionSchema.optional(),sourceKey:r.z.string().optional(),source:W.optional()}).passthrough(),ze=r.z.object({id:r.z.string().optional(),builder:r.z.literal("semaphor.inputOptions"),source:W.optional(),sourceKey:r.z.string().optional(),valueFieldRef:S,labelFieldRef:S,filterFieldRef:S.optional(),population:r.z.unknown().optional(),dependencies:r.z.unknown().optional(),limit:r.z.number().int().positive().optional(),spec:n.recordSchema.optional()}).passthrough(),ve=r.z.object({appliesToViewIds:r.z.array(r.z.string()).optional(),viewId:r.z.string().optional(),fieldRef:S,relationshipHint:r.z.unknown().optional(),relationshipsUsed:r.z.array(n.recordSchema).optional()}).passthrough(),Ss=r.z.object({id:r.z.string(),label:r.z.string().optional(),type:r.z.string().optional(),serverSide:r.z.boolean().optional(),fieldRef:S.optional(),optionQuery:ze.optional(),bindings:r.z.array(ve).optional(),appliesToViewIds:r.z.array(r.z.string()),relationshipHint:r.z.unknown().optional(),relationshipsUsed:r.z.array(n.recordSchema).optional()}).passthrough(),zs=r.z.object({builder:r.z.enum(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]),spec:n.recordSchema,fallbackReason:n.recordSchema.optional()}).passthrough(),vs=r.z.object({id:r.z.string(),title:r.z.string().optional(),purpose:r.z.string().optional(),sourcePresentation:r.z.object({sourceKeys:r.z.array(r.z.string()).optional(),sourceLabels:r.z.array(r.z.string()).optional()}).passthrough().optional(),visual:r.z.string().optional(),visualSpec:n.recordSchema.optional(),queryKind:r.z.enum(["metric","records","matrix","analysis","sql_fallback"]).optional(),sdkBuilder:r.z.enum(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]).optional(),sdkSpec:zs.optional(),fields:r.z.array(S).optional(),computation:n.recordSchema.optional(),uxExpectations:r.z.array(r.z.string()).optional(),validation:n.recordSchema.optional()}).passthrough(),$s=r.z.object({inputId:r.z.string(),label:r.z.string().optional(),type:r.z.string().optional(),serverSide:r.z.boolean().optional(),fieldRef:S.optional(),optionQuery:ze.optional(),bindings:r.z.array(ve),appliesToViewIds:r.z.array(r.z.string()),notAppliedToViewIds:r.z.array(r.z.string())}).passthrough(),ws=r.z.object({schemaVersion:r.z.literal(A),title:r.z.string(),purpose:r.z.string().optional(),userGoal:r.z.string().optional(),nextStep:r.z.string().optional(),sources:r.z.array(W),inputs:r.z.array(Ss),views:r.z.array(vs),filterContracts:r.z.array($s),implementationChecklist:r.z.object({schemaVersion:r.z.string().optional(),requiredDevtools:r.z.object({mountRootDevtools:r.z.boolean(),providerDebugBridge:r.z.string().optional(),panelPosition:r.z.string().optional(),forbidden:r.z.array(r.z.string()).optional()}).passthrough(),requiredInputOptions:r.z.array(n.recordSchema),filterScopeByInput:r.z.array(n.recordSchema),bindingsByView:r.z.record(r.z.string(),r.z.array(n.recordSchema)),validationCommands:r.z.array(r.z.string()),browserSmokeChecks:r.z.array(r.z.string())}).passthrough(),nextRequiredTool:r.z.object({name:r.z.string(),reason:r.z.string().optional()}).optional(),unsupportedInsights:r.z.array(r.z.object({title:r.z.string(),requestedQuestion:r.z.string(),reason:r.z.string(),suggestedModelingFix:r.z.string()}).passthrough()).optional(),assumptions:r.z.array(r.z.string()).optional(),validation:n.recordSchema.optional()}).passthrough().superRefine((i,s)=>{const e=V(i);for(const t of e.issues)s.addIssue({code:r.z.ZodIssueCode.custom,message:t})}),ks=new Set(Object.keys(I));function As(){return Object.keys(I)}function $e(i){return ks.has(i)}function Is(i){if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Semaphor analyze result must be an object.");const e=Object.keys(i).filter(t=>!$e(t));if(e.length)throw new Error(`Semaphor analyze result contains unsupported top-level field(s): ${e.join(", ")}.`);return Se.parse(i)}const we=r.z.object({runtimeFilters:n.matrixSpecSchema.innerType().shape.filters,runtimeSorts:n.matrixSpecSchema.innerType().shape.sorts.optional()});function _s(i){return we.parse(i)}const Rs={compiledQuery:r.z.never().optional(),intent:T.shape.intent,resultShape:r.z.literal("matrix"),result:M.optional(),metadata:r.z.object({rowLimitExceeded:r.z.boolean(),matrixFailure:_.optional()}).passthrough()},xs=Q.extend(Rs),Es=xs.superRefine((i,s)=>{i.status==="failed"==!!i.result&&s.addIssue({code:"custom",message:"Only answered or partial Matrix execution carries a window."}),i.result&&i.status==="partial"!=i.result.window.failures.length>0&&s.addIssue({code:"custom",message:"Matrix execution status must match acquired window failures."})});exports.MATRIX_WINDOW_LIMITS=ke;exports.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT=I;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=A;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=xe;exports.analyticsExecutionEnvelopeSchema=Q;exports.getSemaphorAnalyzeResultFieldNames=As;exports.isSemaphorAnalyzeResultFieldName=$e;exports.isSemaphorDataAppCodegenSummary=De;exports.matrixAxisPageSchema=se;exports.matrixBlockRequestSchema=ee;exports.matrixCapabilitiesSchema=re;exports.matrixCellBlockSchema=te;exports.matrixDescriptorSchema=N;exports.matrixExecutionResultSchema=Es;exports.matrixExportBatchSchema=Re;exports.matrixExportColumnSchema=oe;exports.matrixExportLayoutSchema=ne;exports.matrixExportRowSchema=ue;exports.matrixExportValueSchema=O;exports.matrixFailureSchema=_;exports.matrixOperationRequestSchema=T;exports.matrixPageRequestSchema=Z;exports.matrixPathSelectionSchema=K;exports.matrixResultSchema=M;exports.matrixRuntimeInputsSchema=we;exports.matrixWindowInputSchema=Ie;exports.matrixWindowOutcomeSchema=_e;exports.matrixWindowRequestSchema=D;exports.matrixWindowSchema=B;exports.parseMatrixRuntimeInputs=_s;exports.parseSemaphorAnalyzeResult=Is;exports.semaphorAnalyticsCoverageSchema=G;exports.semaphorAnalyticsDiagnosticFeedbackSchema=U;exports.semaphorAnalyticsExecutionResultSchema=ge;exports.semaphorAnalyticsPopulationSchema=L;exports.semaphorAnalyticsResultSchema=he;exports.semaphorAnalyzeResultSchema=Se;exports.semaphorAnalyzeResultShape=be;exports.semaphorDataAppCodegenSummarySchema=ws;exports.semaphorRelationshipDiagnosticsSchema=ye;exports.validateSemaphorDataAppCodegenSummary=V;
|
|
1
|
+
"use strict";const r=require("zod"),n=require("./validators-ux2obZB9.cjs"),I={answerSummary:"string",responseDetail:"responseDetail",mode:"string",comparisonKind:"string",executionResult:"executionResult",compiledQuery:"unknown",data:"unknown",resultSets:"record",analysisWarnings:"unknownArray",columns:"unknownArray",records:"recordArray",rowCount:"number",rowLimitExceeded:"boolean",output:"string",querySpec:"unknown",metadata:"record",validation:"validationResult",coverage:"coverage",diagnosticFeedback:"diagnosticFeedback",missingFields:"stringArray",warnings:"unknownArray",comparison:"unknown",population:"population",comparisons:"recordArray",fieldsUsed:"compactExecutionFieldArray",primary:"recordArray",contributors:"recordArray",segments:"recordArray",periodChanges:"recordArray",changes:"recordArray",largestNegativeChanges:"recordArray",largestPositiveChanges:"recordArray",drivers:"recordArray",absoluteDeltaDrivers:"recordArray",largestNegativeDrivers:"recordArray",largestPositiveDrivers:"recordArray",periodRows:"recordArray",sql:"unknown",omitted:"stringArray"},ke=Object.freeze({coordinates:2e4}),v=r.z.string().uuid(),p=r.z.string().min(1),Ae=r.z.number().int().positive().max(Number.MAX_SAFE_INTEGER);function m(i,s,e){i.addIssue({code:"custom",path:s,message:e})}function h(i,s,e){new Set(i).size!==i.length&&m(s,e,"Duplicate identity.")}const Z=r.z.object({id:p,axis:n.matrixAxisSchema,parent:n.matrixPathSchema,position:r.z.union([r.z.object({kind:r.z.literal("first")}).strict(),r.z.object({kind:r.z.enum(["after","before"]),cursor:p}).strict()]),size:Ae}).strict(),K=r.z.object({paths:r.z.array(n.matrixPathSchema).readonly(),pageIds:r.z.array(p).readonly()}).strict(),ee=r.z.object({id:p,rows:K,columns:K,measureIds:r.z.array(v).min(1).readonly()}).strict(),D=r.z.object({pages:r.z.array(Z).readonly(),blocks:r.z.array(ee).readonly()}).strict().superRefine((i,s)=>{!i.pages.length&&!i.blocks.length&&m(s,[],"Request at least one page or block."),h([...i.pages,...i.blocks].map(e=>e.id),s,[]);for(const e of i.blocks){h(e.measureIds,s,["blocks",e.id,"measureIds"]);for(const t of["rows","columns"])for(const a of e[t].pageIds)i.pages.some(o=>o.id===a&&o.axis===t)||m(s,["blocks",e.id,t],"Page reference must name a page on this axis in this operation.")}}),Ie=r.z.object({spec:n.matrixSpecSchema,request:D}).strict().superRefine(({spec:i,request:s},e)=>{for(const t of s.pages)n.checkMatrixPath(i,t.axis,t.parent,e,["pages",t.id],!0),t.parent.length>=i[t.axis].length&&m(e,["pages",t.id],"Cannot request children of a leaf or empty axis.");for(const t of s.blocks){t.measureIds.some(a=>!i.measures.some(o=>o.id===a))&&m(e,["blocks",t.id],"Unknown block measure.");for(const a of["rows","columns"])for(const o of t[a].paths)n.checkMatrixPath(i,a,o,e,["blocks",t.id,a])}}),se=r.z.object({requestId:p,axis:n.matrixAxisSchema,parent:n.matrixPathSchema,members:r.z.array(r.z.object({path:n.matrixPathSchema}).strict()).readonly(),before:p.nullable(),after:p.nullable(),exactCount:r.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}).strict().superRefine((i,s)=>{i.parent.some(t=>t.member.kind==="others")&&m(s,["parent"],"Others has no children.");const e=i.members.filter(({path:t})=>{var a;return((a=t[t.length-1])==null?void 0:a.member.kind)==="others"});e.length>1&&m(s,["members"],"A page may contain Others only once."),e.length&&(i.members[i.members.length-1]!==e[0]&&m(s,["members"],"Others must be the last page member."),i.after!==null&&m(s,["after"],"Others must end the branch.")),new Set(i.members.map(t=>{var a;return(a=t.path[t.path.length-1])==null?void 0:a.levelId})).size>1&&m(s,["members"],"One page must contain one child level."),h(i.members.map(t=>n.matrixPathKey(t.path)),s,["members"]);for(const t of i.members)(t.path.length!==i.parent.length+1||n.matrixPathKey(t.path.slice(0,-1))!==n.matrixPathKey(i.parent))&&m(s,["members"],"Page members must be immediate children.")}),te=r.z.object({requestId:p,coverage:r.z.object({rowPaths:r.z.array(n.matrixPathSchema).readonly(),columnPaths:r.z.array(n.matrixPathSchema).readonly(),measureIds:r.z.array(v).readonly()}).strict(),cells:r.z.array(n.matrixCoordinateSchema.extend({value:n.semaphorScalarValueSchema}).strict()).readonly()}).strict().superRefine((i,s)=>{const e=i.coverage.rowPaths.map(n.matrixPathKey),t=i.coverage.columnPaths.map(n.matrixPathKey);h(e,s,["coverage","rowPaths"]),h(t,s,["coverage","columnPaths"]),h(i.coverage.measureIds,s,["coverage","measureIds"]);const a=new Set(e),o=new Set(t),d=new Set(i.coverage.measureIds);h(i.cells.map(c=>JSON.stringify([n.matrixPathKey(c.rowPath),n.matrixPathKey(c.columnPath),c.measureId])),s,["cells"]);for(const c of i.cells)(!a.has(n.matrixPathKey(c.rowPath))||!o.has(n.matrixPathKey(c.columnPath))||!d.has(c.measureId))&&m(s,["cells"],"Cell is outside certified coverage.")}),N=r.z.object({id:v,column:n.semaphorResultColumnSchema,nativeDataType:p,semanticFormat:n.semaphorValueFormatSchema.optional()}).strict(),ie=r.z.object({levels:r.z.array(N).readonly(),measures:r.z.array(N).readonly()}).strict(),_=r.z.object({code:r.z.enum(["invalid_request","unsupported_capability","stale_cursor","forbidden","budget_exceeded","source_truncated","execution_failed","cancelled"]),message:p,detail:p.optional(),retryable:r.z.boolean(),scope:r.z.union([r.z.object({kind:r.z.literal("operation")}).strict(),r.z.object({kind:r.z.enum(["page","block"]),requestId:p}).strict()])}).strict(),re=r.z.object({dialect:r.z.enum(["postgres","clickhouse","duckdb"]),aggregates:r.z.array(n.matrixAggregateSchema).readonly()}).strict(),B=r.z.object({queryIdentity:p,descriptors:ie,capabilities:re,pages:r.z.array(se).readonly(),blocks:r.z.array(te).readonly(),failures:r.z.array(_).readonly()}).strict().superRefine((i,s)=>{const e=new Set(i.descriptors.levels.map(o=>o.id)),t=new Set(i.descriptors.measures.map(o=>o.id)),a=i.pages.flatMap(o=>[o.parent,...o.members.map(d=>d.path)]);for(const o of i.blocks)a.push(...o.coverage.rowPaths,...o.coverage.columnPaths),o.coverage.measureIds.some(d=>!t.has(d))&&m(s,["blocks",o.requestId],"Coverage references an unknown measure descriptor.");a.some(o=>o.some(d=>!e.has(d.levelId)))&&m(s,["descriptors"],"Acquired paths require level descriptors."),h([...i.descriptors.levels,...i.descriptors.measures].map(o=>o.id),s,["descriptors"]),h([...i.pages,...i.blocks].map(o=>o.requestId),s,[]),h(i.failures.map(o=>o.scope.kind==="operation"?"operation":o.scope.requestId),s,["failures"]);for(const o of i.failures)if(o.scope.kind==="operation")m(s,["failures"],"Operation failure cannot accompany acquired data.");else{const d=o.scope.requestId;[...i.pages,...i.blocks].some(c=>c.requestId===d)&&m(s,["failures"],"A requested unit cannot both succeed and fail.")}}),_e=r.z.union([r.z.object({status:r.z.enum(["success","partial"]),window:B}).strict(),r.z.object({status:r.z.literal("failed"),failure:_}).strict()]).superRefine((i,s)=>{if(i.status==="failed")return;const{window:e}=i;!e.pages.length&&!e.blocks.length&&m(s,["window"],"A window outcome requires successful acquired work."),i.status==="success"!=(e.failures.length===0)&&m(s,["status"],"Status must match failure coverage.")}),M=r.z.object({kind:r.z.literal("matrix"),window:B}).strict(),ae=r.z.enum(["member","subtotal","grand_total"]),oe=r.z.discriminatedUnion("kind",[r.z.object({kind:r.z.literal("hierarchy"),label:r.z.string()}).strict(),r.z.object({kind:r.z.literal("level"),levelId:v,label:r.z.string()}).strict(),r.z.object({kind:r.z.literal("measure"),measureId:v,columnPath:n.matrixPathSchema,role:ae,label:r.z.string()}).strict()]),ne=r.z.object({columns:r.z.array(oe).readonly(),descriptors:ie}).strict(),O=r.z.union([r.z.object({kind:r.z.literal("value"),value:n.semaphorScalarValueSchema.refine(i=>i!==null)}).strict(),r.z.object({kind:r.z.enum(["null","empty"])}).strict()]),ue=r.z.discriminatedUnion("kind",[r.z.object({kind:r.z.literal("layout"),rowPath:n.matrixPathSchema,role:ae,values:r.z.array(O).readonly()}).strict(),r.z.object({kind:r.z.literal("flat"),rowPath:n.matrixPathSchema,columnPath:n.matrixPathSchema,values:r.z.array(O).readonly()}).strict()]),Re=r.z.discriminatedUnion("kind",[r.z.object({kind:r.z.literal("layout"),layout:ne,next:p}).strict(),r.z.object({kind:r.z.literal("rows"),rows:r.z.array(ue).readonly(),next:p.nullable()}).strict()]),T=r.z.object({intent:n.matrixAnalyticalIntentSchema,matrixWindowRequest:D}).strict(),A="semaphor-data-app-codegen-summary/v1",xe="semaphor-data-app-codegen-summary-validator/v2",Ee=new Set(["metric","records","matrix","analysis","sql_fallback"]),Ce=new Set(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]),qe=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]),je=new Set(["absolute_delta","largest_negative","largest_positive","positive_and_negative","all"]),ce=new Set(["source","id","label","measures","primaryMeasure","dateField","timeGrain","dimensions","comparison","orderBy","filters","relationshipHint","limit","derivedFields"]),Fe=new Set([...ce,"analysis","timeWindow","filters","driverMode","includePopulation","calendarContext","chartTitle","chartType"]),Ke=new Set(["source","id","label","fields","dateField","timeGrain","timeWindow","filters","orderBy","relationshipHint","limit","pagination","totals","derivedFields"]),Ne=new Set(["source","id","label","sql","defaultParameters","pythonCode","fields","limit","pagination","rationale"]),Oe=new Set(["kpi","line_chart","bar_chart","stacked_bar_chart","pie_chart","donut_chart","area_chart","table","matrix","narrative","text_block","custom"]),Pe=new Set(["missing_measure","missing_dimension","missing_date","missing_relationship","missing_semantic_role","missing_current_app_state","raw_identifier_filter_options","unsupported_change_intent","ambiguous_field_grounding","bounded_intent_unavailable","invalid_bounded_intent_output","latest_snapshot_selector_not_modeled","unsupported_grain","requires_sql_escape_hatch","unsupported_sdk_capability"]);function De(i){return V(i).ok}function V(i){const s=[];if(!i||typeof i!="object")return{ok:!1,issues:["Summary must be an object."]};const e=i;return e.schemaVersion!==A&&s.push(`schemaVersion must be ${A}.`),(typeof e.title!="string"||!e.title.trim())&&s.push("title is required."),Array.isArray(e.sources)||s.push("sources must be an array."),Array.isArray(e.inputs)||s.push("inputs must be an array."),Array.isArray(e.views)||s.push("views must be an array."),Array.isArray(e.filterContracts)||s.push("filterContracts must be an array."),(!e.implementationChecklist||typeof e.implementationChecklist!="object")&&s.push("implementationChecklist must be an object."),e.implementationChecklist&&typeof e.implementationChecklist=="object"&&s.push(...Me(e.implementationChecklist)),Array.isArray(e.sources)&&e.sources.forEach((t,a)=>{s.push(...R(t,`sources.${a}`))}),Array.isArray(e.inputs)&&e.inputs.forEach((t,a)=>{s.push(...Te(t,`inputs.${a}`))}),Array.isArray(e.views)&&e.views.forEach((t,a)=>{s.push(...Ve(t,`views.${a}`))}),Array.isArray(e.filterContracts)&&e.filterContracts.forEach((t,a)=>{s.push(...Ze(t,`filterContracts.${a}`))}),e.unsupportedInsights!==void 0&&(Array.isArray(e.unsupportedInsights)?e.unsupportedInsights.forEach((t,a)=>{s.push(...fs(t,`unsupportedInsights.${a}`))}):s.push("unsupportedInsights must be an array.")),s.push(...Be(e)),{ok:s.length===0,issues:s}}function Be(i){const s=Array.isArray(i.unsupportedInsights)&&i.unsupportedInsights.some(d=>{var c;return H.has((c=u(d))==null?void 0:c.reason)}),e=Array.isArray(i.views)&&i.views.some(d=>{var l;const c=u((l=u(d))==null?void 0:l.computation);return(c==null?void 0:c.kind)==="unsupported"&&H.has(c.reason)});if(!s&&!e)return[];const t=[],a=u(i.validation);(a==null?void 0:a.status)!=="blocked"&&t.push("validation.status must be blocked when semantic model repair gaps are present.");const o=u(i.nextRequiredTool);return(o==null?void 0:o.name)!=="semaphor_propose_semantic_model_change"&&t.push("nextRequiredTool.name must be semaphor_propose_semantic_model_change when semantic model repair gaps are present."),t}const H=new Set(["missing_relationship","raw_identifier_filter_options"]);function R(i,s){const e=u(i);return e?e.kind==="semantic"?typeof e.domainId=="string"&&e.domainId.trim()&&typeof e.datasetName=="string"&&e.datasetName.trim()?[]:[`${s} must include sourceKey or a supported source identity.`]:typeof e.sourceKey=="string"&&e.sourceKey.trim()?[]:e.kind==="physical"&&typeof e.tableName=="string"&&e.tableName.trim()&&typeof e.connectionId=="string"&&e.connectionId.trim()?[]:e.kind==="sql"&&typeof e.connectionId=="string"&&e.connectionId.trim()?[]:[`${s} must include sourceKey or a supported source identity.`]:[`${s} must be an object.`]}function Me(i){const s=u(i);if(!s)return["implementationChecklist must be an object."];const e=[],t=["requiredDevtools","requiredInputOptions","filterScopeByInput","bindingsByView","validationCommands","browserSmokeChecks"];for(const o of t)o in s||e.push(`implementationChecklist.${o} is required.`);const a=u(s.requiredDevtools);return a?typeof a.mountRootDevtools!="boolean"&&e.push("implementationChecklist.requiredDevtools.mountRootDevtools must be a boolean."):e.push("implementationChecklist.requiredDevtools must be an object."),Array.isArray(s.requiredInputOptions)||e.push("implementationChecklist.requiredInputOptions must be an array."),Array.isArray(s.filterScopeByInput)||e.push("implementationChecklist.filterScopeByInput must be an array."),u(s.bindingsByView)||e.push("implementationChecklist.bindingsByView must be an object."),y(s.validationCommands)||e.push("implementationChecklist.validationCommands must be an array of strings."),y(s.browserSmokeChecks)||e.push("implementationChecklist.browserSmokeChecks must be an array of strings."),e}function Te(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return(typeof e.id!="string"||!e.id.trim())&&t.push(`${s}.id is required.`),e.fieldRef&&t.push(...f(e.fieldRef,`${s}.fieldRef`)),t.push(...le(e.optionQuery,`${s}.optionQuery`)),y(e.appliesToViewIds)||t.push(`${s}.appliesToViewIds must be an array of strings.`),e.bindings!==void 0&&!Array.isArray(e.bindings)&&t.push(`${s}.bindings must be an array.`),Array.isArray(e.bindings)&&e.bindings.forEach((a,o)=>{const d=u(a);if(!d){t.push(`${s}.bindings.${o} must be an object.`);return}y(d.appliesToViewIds)||t.push(`${s}.bindings.${o}.appliesToViewIds must be an array of strings.`),t.push(...f(d.fieldRef,`${s}.bindings.${o}.fieldRef`))}),t}function Ve(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];if((typeof e.id!="string"||!e.id.trim())&&t.push(`${s}.id is required.`),e.visualSpec!==void 0&&t.push(...ns(e.visualSpec,`${s}.visualSpec`)),e.computation!==void 0&&t.push(...ps(e.computation,`${s}.computation`)),os(e))return t.push(...E(e,`${s}`)),e.fields!==void 0&&(Array.isArray(e.fields)?e.fields.forEach((l,g)=>{t.push(...f(l,`${s}.fields.${g}`))}):t.push(`${s}.fields must be an array.`)),e.queryKind!==void 0&&t.push(`${s}.queryKind is not allowed for non-executable views.`),e.sdkBuilder!==void 0&&t.push(`${s}.sdkBuilder is not allowed for non-executable views.`),e.sdkSpec!==void 0&&t.push(`${s}.sdkSpec is not allowed for non-executable views.`),t;if(!Array.isArray(e.fields))return t.push(`${s}.fields must be an array.`),(e.sdkSpec!==void 0||e.sdkBuilder!==void 0)&&t.push(`${s}.fields must be an array for executable views.`),t.push(...E(e,`${s}`)),t;e.fields.forEach((l,g)=>{t.push(...f(l,`${s}.fields.${g}`))}),z(e.queryKind)||t.push(`${s}.queryKind must be a supported codegen query kind.`),e.sdkBuilder!==void 0&&!pe(e.sdkBuilder)&&t.push(`${s}.sdkBuilder must be a supported SDK builder.`),e.metricBindingKeys!==void 0&&(Array.isArray(e.metricBindingKeys)?e.metricBindingKeys.some(l=>typeof l!="string"||l.trim().length===0)&&t.push(`${s}.metricBindingKeys must be an array of strings.`):t.push(`${s}.metricBindingKeys must be an array of strings.`));const a=u(e.sdkSpec),o=(a==null?void 0:a.builder)==="semaphor.metric";o&&(!Array.isArray(e.metricBindingKeys)||e.metricBindingKeys.length===0)&&t.push(`${s}.metricBindingKeys is required for metric views.`);const d=Ue(e);o&&Array.isArray(e.metricBindingKeys)&&d&&JSON.stringify(e.metricBindingKeys)!==JSON.stringify(d)&&t.push(`${s}.metricBindingKeys must match the generated metric field binding keys in order.`);const c=u(e.computation);return(c==null?void 0:c.kind)==="server_query"&&z(e.queryKind)&&z(c.queryKind)&&c.queryKind!==e.queryKind&&t.push(`${s}.computation.queryKind must match queryKind.`),t.push(...es({value:e.sdkSpec,path:`${s}.sdkSpec`,queryKind:typeof e.queryKind=="string"?e.queryKind:void 0,sdkBuilder:typeof e.sdkBuilder=="string"?e.sdkBuilder:void 0}),...E(e,`${s}`)),t}function Ue(i){const s=u(i.sdkSpec);if((s==null?void 0:s.builder)!=="semaphor.metric")return;const e=u(s.spec);if(!e)return;const a=[e.primaryMeasure,...Array.isArray(e.measures)?e.measures:[]].map(Le).filter(o=>!!o);return Array.from(new Map(a.map(o=>[o.identity,o.bindingKey])).values())}function Le(i){const s=u(i);if(!s||typeof s.name!="string"||!s.name.trim())return;const e=Ge(s);return e?{identity:JSON.stringify({source:e,name:s.name,aggregate:de(s)}),bindingKey:Qe(s)}:void 0}function Ge(i){if(typeof i.sourceKey=="string"&&i.sourceKey.trim())return{sourceKey:i.sourceKey};const s=u(i.source);if(s)return{kind:s.kind,domainId:s.domainId,datasetId:s.datasetId,datasetName:s.datasetName,name:s.name}}function Qe(i){return typeof i.sourceKey=="string"&&i.sourceKey.trim()?[i.sourceKey,de(i),i.name].filter(Boolean).join(":"):n.semaphorMetricMeasureBindingKey(i)}function de(i){return n.semaphorMetricAggregate(i)}function E(i,s){var g;const e=u((g=u(i.visualSpec))==null?void 0:g.tableBehavior),t=u(i.sdkSpec),a=u(t==null?void 0:t.spec),o=typeof(t==null?void 0:t.builder)=="string"?t.builder:void 0,d=o==="semaphor.records"?u(a==null?void 0:a.totals):void 0,c=[];if(!e)return d&&c.push(`${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),c;const l=u(e.totals);return l?(l.mode==="server"&&(o!=="semaphor.records"&&c.push(`${s}.visualSpec.tableBehavior.totals.mode server is only supported for semaphor.records views.`),!d||d.mode!=="server"?c.push(`${s}.sdkSpec.spec.totals.mode must be server when tableBehavior.totals.mode is server.`):c.push(...We({left:l.measures,right:d.measures,leftPath:`${s}.visualSpec.tableBehavior.totals.measures`,rightPath:`${s}.sdkSpec.spec.totals.measures`}))),l.mode!=="server"&&d&&c.push(`${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),o==="semaphor.sql"&&l.mode!=="none"&&c.push(`${s}.visualSpec.tableBehavior.totals.mode must be none for semaphor.sql views.`),o==="semaphor.sql"&&u(a==null?void 0:a.totals)&&c.push(`${s}.sdkSpec.spec.totals is not supported for semaphor.sql.`),c):(d&&c.push(`${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),c)}function We({left:i,right:s,leftPath:e,rightPath:t}){if(!Array.isArray(i)||!Array.isArray(s))return[`${t} must match ${e}.`];const a=[];return i.length!==s.length?(a.push(`${t} must match ${e}.`),a):(i.forEach((o,d)=>{He(u(o),u(s[d]))||a.push(`${t}.${d} must match ${e}.${d}.`)}),a)}function He(i,s){return!i||!s?!1:i.name===s.name&&(i.role||"measure")===(s.role||"measure")&&Y(i)===Y(s)&&Ye(i,s)}function Y(i){return typeof i.aggregate=="string"?i.aggregate.toUpperCase():"SUM"}function Ye(i,s){const e=u(i.source),t=u(s.source);if(Xe(e,t))return!1;const a=X(i),o=X(s);if(a.size>0||o.size>0){for(const d of a)if(o.has(d))return!0;return!1}return!e||!t||e.kind!==t.kind?!1:e.kind==="semantic"?e.domainId===t.domainId&&e.datasetName===t.datasetName&&(e.datasetId===void 0||t.datasetId===void 0||e.datasetId===t.datasetId):e.kind==="physical"?e.connectionId===t.connectionId&&e.tableName===t.tableName:e.kind==="sql"?e.connectionId===t.connectionId:!1}function Xe(i,s){if(!i||!s||i.kind!=="semantic"||s.kind!=="semantic")return!1;const e=typeof i.datasetId=="string"?i.datasetId.trim():"",t=typeof s.datasetId=="string"?s.datasetId.trim():"";return!!(e&&t&&e!==t)}function X(i){const s=typeof i.sourceKey=="string"?i.sourceKey.trim():"";return s?new Set([s]):Je(u(i.source))}function Je(i){const s=new Set;if(!i)return s;const e=typeof i.sourceKey=="string"?i.sourceKey.trim():"";if(e&&s.add(e),i.kind==="semantic"){const t=typeof i.domainId=="string"?i.domainId:"",a=typeof i.datasetName=="string"?i.datasetName:"",o=typeof i.datasetId=="string"?i.datasetId:"";t&&o&&s.add(`semantic:${t}:datasetId:${o}`),t&&a&&s.add(`semantic:${t}:datasetName:${a}`)}if(i.kind==="physical"){const t=typeof i.connectionId=="string"?i.connectionId:"",a=typeof i.tableName=="string"?i.tableName:"",o=typeof i.databaseName=="string"?i.databaseName:"",d=typeof i.schemaName=="string"?i.schemaName:"";t&&a&&(s.add(["physical",t,o,d,a].join(":")),s.add(`physical:${t}:${a}`))}if(i.kind==="sql"){const t=typeof i.connectionId=="string"?i.connectionId:"",a=typeof i.dialect=="string"?i.dialect:"",o=typeof i.label=="string"?i.label:"";t&&(s.add(["sql",t,a,o].join(":")),s.add(`sql:${t}`))}return s}function Ze(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];if(e.fieldRef&&t.push(...f(e.fieldRef,`${s}.fieldRef`)),(typeof e.inputId!="string"||!e.inputId.trim())&&t.push(`${s}.inputId is required.`),t.push(...le(e.optionQuery,`${s}.optionQuery`)),y(e.appliesToViewIds)||t.push(`${s}.appliesToViewIds must be an array of strings.`),y(e.notAppliedToViewIds)||t.push(`${s}.notAppliedToViewIds must be an array of strings.`),!Array.isArray(e.bindings))t.push(`${s}.bindings must be an array.`);else{const a=y(e.appliesToViewIds)?new Set(e.appliesToViewIds):void 0,o=y(e.notAppliedToViewIds)?new Set(e.notAppliedToViewIds):void 0;e.bindings.forEach((d,c)=>{const l=u(d);if(!l){t.push(`${s}.bindings.${c} must be an object.`);return}typeof l.viewId!="string"||!l.viewId?t.push(`${s}.bindings.${c}.viewId is required.`):(a&&!a.has(l.viewId)&&t.push(`${s}.bindings.${c}.viewId must be included in appliesToViewIds.`),o!=null&&o.has(l.viewId)&&t.push(`${s}.bindings.${c}.viewId must not be listed in notAppliedToViewIds.`)),t.push(...f(l.fieldRef,`${s}.bindings.${c}.fieldRef`))})}return t}function le(i,s){if(i===void 0)return[];const e=u(i);if(!e)return[`${s} must be an object.`];const t=[...b(e.valueFieldRef,`${s}.valueFieldRef`),...b(e.labelFieldRef,`${s}.labelFieldRef`),...b(e.filterFieldRef,`${s}.filterFieldRef`)];if(e.builder!=="semaphor.inputOptions"&&t.push(`${s}.builder must be semaphor.inputOptions.`),typeof e.sourceKey!="string"&&e.source===void 0&&t.push(`${s} must include source or sourceKey.`),e.source!==void 0){const a=u(e.source);!a||a.kind!=="semantic"&&a.kind!=="physical"?t.push(`${s}.source.kind must be semantic or physical.`):t.push(...R(e.source,`${s}.source`))}return u(e.valueFieldRef)||t.push(`${s}.valueFieldRef is required.`),u(e.labelFieldRef)||t.push(`${s}.labelFieldRef is required.`),e.limit!==void 0&&(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<=0)&&t.push(`${s}.limit must be a positive integer.`),t}function es(i){var a;const s=u(i.value);if(!s)return[`${i.path} is required for executable views.`];const e=[];if(!pe(s.builder))return e.push(`${i.path}.builder must be a supported SDK builder.`),e;i.sdkBuilder&&s.builder!==i.sdkBuilder&&e.push(`${i.path}.builder must match sdkBuilder.`),i.queryKind&&z(i.queryKind)&&s.builder!==as(i.queryKind)&&e.push(`${i.path}.builder must match queryKind.`);const t=u(s.spec);if(!t)return e.push(`${i.path}.spec must be an object.`),e;switch(s.builder){case"semaphor.metric":e.push(...w(t,ce,`${i.path}.spec`),...k(t,i.path),...C(t.measures,`${i.path}.spec.measures`),...b(t.primaryMeasure,`${i.path}.spec.primaryMeasure`),...b(t.dateField,`${i.path}.spec.dateField`),...q(t.dimensions,`${i.path}.spec.dimensions`),...j(t.orderBy,`${i.path}.spec.orderBy`),...F(t.filters,`${i.path}.spec.filters`));break;case"semaphor.analysis":e.push(...w(t,Fe,`${i.path}.spec`),...k(t,i.path),...C(t.measures,`${i.path}.spec.measures`),...b(t.primaryMeasure,`${i.path}.spec.primaryMeasure`),...b(t.dateField,`${i.path}.spec.dateField`),...q(t.dimensions,`${i.path}.spec.dimensions`),...j(t.orderBy,`${i.path}.spec.orderBy`),...F(t.filters,`${i.path}.spec.filters`),...ss(t,`${i.path}.spec`));break;case"semaphor.records":e.push(...w(t,Ke,`${i.path}.spec`),...k(t,i.path),...C(t.fields,`${i.path}.spec.fields`),...b(t.dateField,`${i.path}.spec.dateField`),...j(t.orderBy,`${i.path}.spec.orderBy`),...F(t.filters,`${i.path}.spec.filters`),...ts(t.totals,`${i.path}.spec.totals`));break;case"semaphor.matrix":{const{id:o,label:d,matrixWindowRequest:c,...l}=t;for(const[$,x]of Object.entries({id:o,label:d}))x!==void 0&&(typeof x!="string"||!x.trim())&&e.push(`${i.path}.spec.${$} must be a nonempty string.`);const g=T.safeParse({intent:{...l,kind:"matrix"},matrixWindowRequest:c});g.success||e.push(...g.error.issues.map($=>`${i.path}.spec.${$.path.join(".")}: ${$.message}`));break}case"semaphor.sql":e.push(...w(t,Ne,`${i.path}.spec`),...k(t,i.path)),((a=u(t.source))==null?void 0:a.kind)!=="sql"&&e.push(`${i.path}.spec.source.kind must be sql.`),(typeof t.sql!="string"||!t.sql.trim())&&e.push(`${i.path}.spec.sql is required.`),e.push(...q(t.fields,`${i.path}.spec.fields`));break}return e}function ss(i,s){const e=[];if(i.driverMode!==void 0&&!je.has(i.driverMode)&&e.push(`${s}.driverMode must be a supported analysis driver mode.`),i.includePopulation!==void 0&&typeof i.includePopulation!="boolean"&&e.push(`${s}.includePopulation must be a boolean.`),i.calendarContext!==void 0){const t=u(i.calendarContext);if(!t)e.push(`${s}.calendarContext must be an object.`);else{t.tz!==void 0&&typeof t.tz!="string"&&e.push(`${s}.calendarContext.tz must be a string.`),t.weekStart!==void 0&&(typeof t.weekStart!="number"||!Number.isInteger(t.weekStart)||t.weekStart<0||t.weekStart>6)&&e.push(`${s}.calendarContext.weekStart must be an integer between 0 and 6.`);const a=t.anchor;if(a!==void 0&&a!=="now"){const o=u(a);(!o||typeof o.iso!="string"||!o.iso.trim())&&e.push(`${s}.calendarContext.anchor must be now or { iso }.`)}}}return e}function ts(i,s){if(i===void 0)return[];const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.mode!=="server"&&t.push(`${s}.mode must be server.`),!Array.isArray(e.measures)||e.measures.length===0?t.push(`${s}.measures must include at least one measure.`):e.measures.forEach((a,o)=>{var d;t.push(...fe(a,`${s}.measures.${o}`)),((d=u(a))==null?void 0:d.role)!=="measure"&&t.push(`${s}.measures.${o}.role must be measure.`)}),t}function w(i,s,e){const t=[];return Object.keys(i).forEach(a=>{s.has(a)||t.push(`${e}.${a} is not supported for this SDK builder.`)}),t}function k(i,s){return u(i.source)?R(i.source,`${s}.spec.source`):[`${s}.spec.source must be an object.`]}function C(i,s){const e=rs(i,s);return Array.isArray(i)&&i.forEach((t,a)=>{e.push(...f(t,`${s}.${a}`))}),e}function q(i,s){if(i===void 0)return[];if(!Array.isArray(i))return[`${s} must be an array.`];const e=[];return i.forEach((t,a)=>{e.push(...f(t,`${s}.${a}`))}),e}function j(i,s){if(i===void 0)return[];const e=u(i);return e?[...f(e.field,`${s}.field`),...is(e.direction,`${s}.direction`)]:[`${s} must be an object.`]}function is(i,s){return i==="asc"||i==="desc"?[]:[`${s} must be asc or desc.`]}function F(i,s){if(i===void 0)return[];if(!Array.isArray(i))return[`${s} must be an array.`];const e=[];return i.forEach((t,a)=>{const o=u(t);if(!o){e.push(`${s}.${a} must be an object.`);return}e.push(...f(o.field,`${s}.${a}.field`))}),e}function rs(i,s){return!Array.isArray(i)||i.length===0?[`${s} must be a non-empty array.`]:[]}function as(i){switch(i){case"metric":return"semaphor.metric";case"records":return"semaphor.records";case"matrix":return"semaphor.matrix";case"analysis":return"semaphor.analysis";case"sql_fallback":return"semaphor.sql"}}function os(i){const s=u(i.computation),e=u(i.visualSpec);return(s==null?void 0:s.kind)==="presentation_only"||(s==null?void 0:s.kind)==="derived"||(s==null?void 0:s.kind)==="unsupported"||i.visual==="text_block"||(e==null?void 0:e.visualType)==="text_block"}function ns(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return Oe.has(e.visualType)||t.push(`${s}.visualType must be a supported visual type.`),e.limit!==void 0&&(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<=0)&&t.push(`${s}.limit must be a positive integer.`),e.tableBehavior!==void 0&&t.push(...us(e.tableBehavior,`${s}.tableBehavior`)),t}function us(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.tableMode!=="bounded"&&e.tableMode!=="server_paginated"&&e.tableMode!=="server_windowed"&&t.push(`${s}.tableMode must be a supported table mode.`),t.push(...cs(e.height,`${s}.height`),...ds(e.pagination,`${s}.pagination`),...ls(e.sorting,`${s}.sorting`),...ms(e.totals,`${s}.totals`)),typeof e.serverSideRequired!="boolean"&&t.push(`${s}.serverSideRequired must be a boolean.`),t}function cs(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return(typeof e.maxPx!="number"||!Number.isInteger(e.maxPx)||e.maxPx<=0)&&t.push(`${s}.maxPx must be a positive integer.`),e.scroll!=="vertical"&&e.scroll!=="both"&&t.push(`${s}.scroll must be vertical or both.`),typeof e.stickyHeader!="boolean"&&t.push(`${s}.stickyHeader must be a boolean.`),t}function ds(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.mode!=="none"&&e.mode!=="server"&&e.mode!=="client_for_bounded_rows"&&t.push(`${s}.mode must be a supported pagination mode.`),e.pageSize!==void 0&&(typeof e.pageSize!="number"||!Number.isInteger(e.pageSize)||e.pageSize<=0)&&t.push(`${s}.pageSize must be a positive integer.`),e.readsFrom!==void 0&&e.readsFrom!=="result.pagination"&&t.push(`${s}.readsFrom must be result.pagination.`),t}function ls(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.mode!=="server"&&e.mode!=="client_for_bounded_rows"&&t.push(`${s}.mode must be a supported sorting mode.`),e.defaultField!==void 0&&(typeof e.defaultField!="string"||!e.defaultField.trim())&&t.push(`${s}.defaultField must be a non-empty string.`),e.defaultDirection!==void 0&&e.defaultDirection!=="asc"&&e.defaultDirection!=="desc"&&t.push(`${s}.defaultDirection must be asc or desc.`),e.resetPageOnChange!==void 0&&typeof e.resetPageOnChange!="boolean"&&t.push(`${s}.resetPageOnChange must be a boolean.`),t}function ms(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return e.mode!=="none"&&e.mode!=="server"&&e.mode!=="local"?(t.push(`${s}.mode must be none, server, or local.`),t):e.mode==="none"?(e.measures!==void 0&&t.push(`${s}.measures is not allowed when mode is none.`),e.label!==void 0&&t.push(`${s}.label is not allowed when mode is none.`),t):e.mode==="server"?(!Array.isArray(e.measures)||e.measures.length===0?t.push(`${s}.measures must include at least one measure when mode is server.`):e.measures.forEach((a,o)=>{var d;t.push(...fe(a,`${s}.measures.${o}`)),((d=u(a))==null?void 0:d.role)!=="measure"&&t.push(`${s}.measures.${o}.role must be measure.`)}),e.label!==void 0&&t.push(`${s}.label is not allowed when mode is server.`),t):(e.mode==="local"&&(e.label!=="Displayed rows"&&e.label!=="Current page"&&t.push(`${s}.label must be Displayed rows or Current page when mode is local.`),e.measures!==void 0&&t.push(`${s}.measures is not allowed when mode is local.`)),t)}function ps(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];switch(e.kind){case"server_query":z(e.queryKind)||t.push(`${s}.queryKind must be a supported codegen query kind.`),e.queryOwnership!==void 0&&e.queryOwnership!=="view_owned"&&e.queryOwnership!=="shared_query"&&t.push(`${s}.queryOwnership must be view_owned or shared_query.`),e.sourceKeys!==void 0&&!y(e.sourceKeys)&&t.push(`${s}.sourceKeys must be an array of strings.`),e.fieldNames!==void 0&&!y(e.fieldNames)&&t.push(`${s}.fieldNames must be an array of strings.`);break;case"derived":(typeof e.upstreamViewId!="string"||!e.upstreamViewId.trim())&&t.push(`${s}.upstreamViewId is required.`),(typeof e.derivation!="string"||!e.derivation.trim())&&t.push(`${s}.derivation is required.`);break;case"presentation_only":break;case"unsupported":(typeof e.reason!="string"||!e.reason.trim())&&t.push(`${s}.reason is required.`),(typeof e.suggestedModelingFix!="string"||!e.suggestedModelingFix.trim())&&t.push(`${s}.suggestedModelingFix is required.`);break;default:t.push(`${s}.kind must be a supported computation kind.`)}return t}function fs(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];for(const o of["title","requestedQuestion","suggestedModelingFix"])(typeof e[o]!="string"||!e[o].trim())&&t.push(`${s}.${o} is required.`);return Pe.has(e.reason)||t.push(`${s}.reason must be a supported unsupported insight reason.`),(e.relationshipCandidate!==void 0||e.nextRepairAction!==void 0)&&e.reason!=="missing_relationship"&&t.push(`${s} relationship repair metadata is only valid for missing_relationship unsupported insights.`),e.diagnostic!==void 0&&t.push(...hs(e.diagnostic,`${s}.diagnostic`,e.reason)),e.relationshipCandidate!==void 0&&t.push(...gs(e.relationshipCandidate,`${s}.relationshipCandidate`)),e.nextRepairAction!==void 0&&t.push(...ys(e.nextRepairAction,`${s}.nextRepairAction`)),t}function hs(i,s,e){const t=u(i);if(!t)return[`${s} must be an object.`];const a=[],o=new Set(["kind","inputId","inputLabel","optionSource","optionField","missingEvidence"]);Object.keys(t).forEach(c=>{o.has(c)||a.push(`${s}.${c} is not supported; raw identifier diagnostics support only kind, inputId, inputLabel, optionSource, optionField, and missingEvidence.`)}),e!=="raw_identifier_filter_options"&&a.push(`${s} is only valid for raw_identifier_filter_options unsupported insights.`),t.kind!=="raw_identifier_filter_options"&&a.push(`${s}.kind must be raw_identifier_filter_options.`);for(const c of["inputId","inputLabel"])(typeof t[c]!="string"||!t[c].trim())&&a.push(`${s}.${c} must be a non-empty string.`);a.push(...P(t.optionSource,`${s}.optionSource`)),a.push(...me(t.optionField,`${s}.optionField`));const d=new Set(["display_field","relationship_display_path"]);return!Array.isArray(t.missingEvidence)||t.missingEvidence.length===0?a.push(`${s}.missingEvidence must be a non-empty evidence array.`):t.missingEvidence.forEach((c,l)=>{d.has(c)||a.push(`${s}.missingEvidence.${l} must be display_field or relationship_display_path.`)}),a}function ys(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[],a=new Set(["tool","reason"]);return Object.keys(e).forEach(o=>{a.has(o)||t.push(`${s}.${o} is not supported; repair actions support only tool and reason.`)}),e.tool!=="semaphor_propose_semantic_model_change"&&t.push(`${s}.tool must be semaphor_propose_semantic_model_change.`),e.reason!=="missing_relationship"&&t.push(`${s}.reason must be missing_relationship.`),t}function gs(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[],a=new Set(["source","sourceFields","target","targetFields"]);Object.keys(e).forEach(o=>{a.has(o)||t.push(`${s}.${o} is not supported; relationship candidates support only source, sourceFields, target, and targetFields.`)}),t.push(...P(e.source,`${s}.source`)),t.push(...P(e.target,`${s}.target`));for(const o of["sourceFields","targetFields"]){const d=e[o];if(!Array.isArray(d)||d.length===0){t.push(`${s}.${o} must be a non-empty endpoint field array.`);continue}d.forEach((c,l)=>{t.push(...me(c,`${s}.${o}.${l}`))})}return t}function me(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[],a=new Set(["name","label","role","dataType"]);return Object.keys(e).forEach(o=>{a.has(o)||t.push(`${s}.${o} is not supported; relationship candidate fields are scoped by their endpoint and support only name, label, role, and dataType.`)}),(typeof e.name!="string"||!e.name.trim())&&t.push(`${s}.name must be a non-empty string.`),e.role!==void 0&&(typeof e.role!="string"||!["dimension","measure","date","id","unknown"].includes(e.role))&&t.push(`${s}.role must be dimension, measure, date, id, or unknown.`),e.dataType!==void 0&&(typeof e.dataType!="string"||!["string","number","boolean","date","datetime","unknown"].includes(e.dataType))&&t.push(`${s}.dataType must be string, number, boolean, date, datetime, or unknown.`),t}function P(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[],a=new Set(["kind","domainId","datasetName","datasetId","label","sourceKey"]);return Object.keys(e).forEach(o=>{a.has(o)||t.push(`${s}.${o} is not supported; relationship candidate sources support only semantic identity fields.`)}),e.kind!=="semantic"&&t.push(`${s} must use semantic source identity.`),(typeof e.domainId!="string"||!e.domainId.trim()||typeof e.datasetName!="string"||!e.datasetName.trim())&&t.push(`${s} must include semantic domainId and datasetName.`),t}function z(i){return Ee.has(i)}function pe(i){return Ce.has(i)}function b(i,s){return i===void 0?[]:f(i,s)}function f(i,s){const e=u(i);if(!e)return[`${s} must be an object.`];const t=[];return(typeof e.name!="string"||!e.name.trim())&&t.push(`${s}.name is required.`),!e.source&&typeof e.sourceKey!="string"&&t.push(`${s} must include source or sourceKey.`),e.aggregate!==void 0&&!qe.has(e.aggregate)&&t.push(`${s}.aggregate must be a supported aggregate function.`),t}function fe(i,s){const e=u(i),t=f(i,s);if(!e||typeof e.sourceKey=="string"&&e.sourceKey.trim())return t;if(e.source!==void 0){const o=R(e.source,`${s}.source`);return o.length===0||t.push(...o),t}return t.includes(`${s} must include source or sourceKey.`)||t.push(`${s} must include source or sourceKey.`),t}function u(i){return i&&typeof i=="object"&&!Array.isArray(i)?i:void 0}function y(i){return Array.isArray(i)&&i.every(s=>typeof s=="string")}const he=r.z.union([n.semaphorMetricResultSchema,n.semaphorRecordsResultSchema,n.semaphorInputOptionsResultSchema,n.semaphorSqlResultSchema,M]),ye=r.z.object({status:r.z.enum(["not_required","resolved","missing","ambiguous","fanout_risk","unknown"]),requiredSources:r.z.array(n.semaphorSourceRefSchema).optional(),relationshipsUsed:r.z.array(r.z.string()).optional(),missingSources:r.z.array(r.z.string()).optional(),warnings:r.z.array(r.z.string()).optional(),message:r.z.string().optional(),recommendedNextStep:r.z.string().optional(),joinPlanSummary:r.z.object({baseSource:n.semaphorSourceRefSchema.optional(),joinedSources:r.z.array(n.semaphorSourceRefSchema).optional(),joinCount:r.z.number().optional()}).passthrough().optional(),fanoutRisk:r.z.object({status:r.z.enum(["none","warning","error","unknown"]),message:r.z.string().optional()}).passthrough().optional()}).passthrough(),J=r.z.enum(["ambiguous_fields","empty_result","missing_grounded_fields","missing_relationship","no_grounded_query","partial_result","presentation_incomplete","query_validation_failed","unsafe_join"]),U=r.z.object({version:r.z.literal(1),status:r.z.enum(["answered","partial","blocked"]),summary:r.z.string(),answered:r.z.array(r.z.object({slotId:r.z.string().optional(),queryId:r.z.string().optional(),summary:r.z.string(),evidenceIds:r.z.array(r.z.string()).optional(),fieldsUsed:r.z.array(n.semaphorExecutionFieldRefSchema).optional()}).passthrough()),blocked:r.z.array(r.z.object({slotId:r.z.string().optional(),queryId:r.z.string().optional(),reasonCode:J,message:r.z.string(),missingFields:r.z.array(r.z.string()).optional(),availableFields:r.z.array(r.z.string()).optional(),ambiguousFields:r.z.array(r.z.string()).optional(),missingRelationships:r.z.array(r.z.string()).optional(),evidenceIds:r.z.array(r.z.string()).optional(),neededFromUser:r.z.array(r.z.string()).optional(),recommendedNextStep:r.z.string().optional()}).passthrough()),semanticModelRecommendations:r.z.array(r.z.object({reasonCode:J,message:r.z.string(),recommendedNextStep:r.z.string().optional()}).passthrough()).optional()}).passthrough(),L=r.z.object({scope:r.z.literal("filtered_query"),measures:r.z.record(n.nullableScalarSchema)}).passthrough(),G=r.z.object({answeredObligations:r.z.array(r.z.string()),missingObligations:r.z.array(r.z.string()),warnings:r.z.array(n.semaphorAnalyticsValidationIssueSchema).optional()}).passthrough(),Q=r.z.object({intentId:r.z.string().optional(),queryId:r.z.string().optional(),status:r.z.enum(["answered","partial","failed"]),resultShape:r.z.enum(["metric","records","inputOptions","sql","matrix","period_change","analysis"]).optional(),intent:r.z.unknown().optional(),compiledQuery:r.z.unknown().optional(),fieldsUsed:r.z.array(n.semaphorExecutionFieldRefSchema).optional(),result:he.optional(),validation:n.semaphorAnalyticsValidationResultSchema,coverage:G.optional(),missingFields:r.z.array(r.z.string()).optional(),warnings:r.z.array(r.z.string()).optional(),relationshipDiagnostics:ye.optional(),diagnosticFeedback:U.optional(),population:L.optional(),metadata:r.z.record(r.z.string(),r.z.unknown()).optional()}).passthrough(),ge=Q;function bs(i){switch(i){case"boolean":return r.z.boolean().optional();case"compactExecutionFieldArray":return r.z.array(n.semaphorCompactFieldRefSchema).optional();case"coverage":return G.optional();case"diagnosticFeedback":return U.optional();case"executionFieldArray":return r.z.array(n.semaphorExecutionFieldRefSchema).optional();case"executionResult":return ge.optional();case"number":return r.z.number().finite().optional();case"population":return L.optional();case"record":return n.recordSchema.optional();case"recordArray":return n.recordArraySchema.optional();case"responseDetail":return r.z.enum(["compact","standard","debug"]).optional();case"string":return r.z.string().optional();case"stringArray":return r.z.array(r.z.string()).optional();case"unknown":return r.z.unknown().optional();case"unknownArray":return r.z.array(r.z.unknown()).optional();case"validationResult":return n.semaphorAnalyticsValidationResultSchema.optional()}}const be=Object.fromEntries(Object.entries(I).map(([i,s])=>[i,bs(s)])),Se=r.z.object(be).strict(),W=r.z.object({sourceKey:r.z.string().optional(),kind:r.z.enum(["semantic","physical","sql"]).optional(),domainId:r.z.string().optional(),datasetName:r.z.string().optional(),datasetId:r.z.string().optional(),connectionId:r.z.string().optional(),tableName:r.z.string().optional(),label:r.z.string().optional()}).passthrough(),S=r.z.object({name:r.z.string(),label:r.z.string().optional(),role:r.z.enum(["dimension","measure","date","id","unknown"]).optional(),dataType:r.z.enum(["string","number","boolean","date","datetime","unknown"]).optional(),aggregate:n.semaphorAggregateFunctionSchema.optional(),sourceKey:r.z.string().optional(),source:W.optional()}).passthrough(),ze=r.z.object({id:r.z.string().optional(),builder:r.z.literal("semaphor.inputOptions"),source:W.optional(),sourceKey:r.z.string().optional(),valueFieldRef:S,labelFieldRef:S,filterFieldRef:S.optional(),population:r.z.unknown().optional(),dependencies:r.z.unknown().optional(),limit:r.z.number().int().positive().optional(),spec:n.recordSchema.optional()}).passthrough(),ve=r.z.object({appliesToViewIds:r.z.array(r.z.string()).optional(),viewId:r.z.string().optional(),fieldRef:S,relationshipHint:r.z.unknown().optional(),relationshipsUsed:r.z.array(n.recordSchema).optional()}).passthrough(),Ss=r.z.object({id:r.z.string(),label:r.z.string().optional(),type:r.z.string().optional(),serverSide:r.z.boolean().optional(),fieldRef:S.optional(),optionQuery:ze.optional(),bindings:r.z.array(ve).optional(),appliesToViewIds:r.z.array(r.z.string()),relationshipHint:r.z.unknown().optional(),relationshipsUsed:r.z.array(n.recordSchema).optional()}).passthrough(),zs=r.z.object({builder:r.z.enum(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]),spec:n.recordSchema,fallbackReason:n.recordSchema.optional()}).passthrough(),vs=r.z.object({id:r.z.string(),title:r.z.string().optional(),purpose:r.z.string().optional(),sourcePresentation:r.z.object({sourceKeys:r.z.array(r.z.string()).optional(),sourceLabels:r.z.array(r.z.string()).optional()}).passthrough().optional(),visual:r.z.string().optional(),visualSpec:n.recordSchema.optional(),queryKind:r.z.enum(["metric","records","matrix","analysis","sql_fallback"]).optional(),sdkBuilder:r.z.enum(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]).optional(),sdkSpec:zs.optional(),fields:r.z.array(S).optional(),computation:n.recordSchema.optional(),uxExpectations:r.z.array(r.z.string()).optional(),validation:n.recordSchema.optional()}).passthrough(),$s=r.z.object({inputId:r.z.string(),label:r.z.string().optional(),type:r.z.string().optional(),serverSide:r.z.boolean().optional(),fieldRef:S.optional(),optionQuery:ze.optional(),bindings:r.z.array(ve),appliesToViewIds:r.z.array(r.z.string()),notAppliedToViewIds:r.z.array(r.z.string())}).passthrough(),ws=r.z.object({schemaVersion:r.z.literal(A),title:r.z.string(),purpose:r.z.string().optional(),userGoal:r.z.string().optional(),nextStep:r.z.string().optional(),sources:r.z.array(W),inputs:r.z.array(Ss),views:r.z.array(vs),filterContracts:r.z.array($s),implementationChecklist:r.z.object({schemaVersion:r.z.string().optional(),requiredDevtools:r.z.object({mountRootDevtools:r.z.boolean(),providerDebugBridge:r.z.string().optional(),panelPosition:r.z.string().optional(),forbidden:r.z.array(r.z.string()).optional()}).passthrough(),requiredInputOptions:r.z.array(n.recordSchema),filterScopeByInput:r.z.array(n.recordSchema),bindingsByView:r.z.record(r.z.string(),r.z.array(n.recordSchema)),validationCommands:r.z.array(r.z.string()),browserSmokeChecks:r.z.array(r.z.string())}).passthrough(),nextRequiredTool:r.z.object({name:r.z.string(),reason:r.z.string().optional()}).optional(),unsupportedInsights:r.z.array(r.z.object({title:r.z.string(),requestedQuestion:r.z.string(),reason:r.z.string(),suggestedModelingFix:r.z.string()}).passthrough()).optional(),assumptions:r.z.array(r.z.string()).optional(),validation:n.recordSchema.optional()}).passthrough().superRefine((i,s)=>{const e=V(i);for(const t of e.issues)s.addIssue({code:r.z.ZodIssueCode.custom,message:t})}),ks=new Set(Object.keys(I));function As(){return Object.keys(I)}function $e(i){return ks.has(i)}function Is(i){if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Semaphor analyze result must be an object.");const e=Object.keys(i).filter(t=>!$e(t));if(e.length)throw new Error(`Semaphor analyze result contains unsupported top-level field(s): ${e.join(", ")}.`);return Se.parse(i)}const we=r.z.object({runtimeFilters:n.matrixSpecSchema.innerType().shape.filters,runtimeSorts:n.matrixSpecSchema.innerType().shape.sorts.optional()});function _s(i){return we.parse(i)}const Rs={compiledQuery:r.z.never().optional(),intent:T.shape.intent,resultShape:r.z.literal("matrix"),result:M.optional(),metadata:r.z.object({rowLimitExceeded:r.z.boolean(),matrixFailure:_.optional()}).passthrough()},xs=Q.extend(Rs),Es=xs.superRefine((i,s)=>{i.status==="failed"==!!i.result&&s.addIssue({code:"custom",message:"Only answered or partial Matrix execution carries a window."}),i.result&&i.status==="partial"!=i.result.window.failures.length>0&&s.addIssue({code:"custom",message:"Matrix execution status must match acquired window failures."})});exports.MATRIX_WINDOW_LIMITS=ke;exports.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT=I;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=A;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=xe;exports.analyticsExecutionEnvelopeSchema=Q;exports.getSemaphorAnalyzeResultFieldNames=As;exports.isSemaphorAnalyzeResultFieldName=$e;exports.isSemaphorDataAppCodegenSummary=De;exports.matrixAxisPageSchema=se;exports.matrixBlockRequestSchema=ee;exports.matrixCapabilitiesSchema=re;exports.matrixCellBlockSchema=te;exports.matrixDescriptorSchema=N;exports.matrixExecutionResultSchema=Es;exports.matrixExportBatchSchema=Re;exports.matrixExportColumnSchema=oe;exports.matrixExportLayoutSchema=ne;exports.matrixExportRowSchema=ue;exports.matrixExportValueSchema=O;exports.matrixFailureSchema=_;exports.matrixOperationRequestSchema=T;exports.matrixPageRequestSchema=Z;exports.matrixPathSelectionSchema=K;exports.matrixResultSchema=M;exports.matrixRuntimeInputsSchema=we;exports.matrixWindowInputSchema=Ie;exports.matrixWindowOutcomeSchema=_e;exports.matrixWindowRequestSchema=D;exports.matrixWindowSchema=B;exports.parseMatrixRuntimeInputs=_s;exports.parseSemaphorAnalyzeResult=Is;exports.semaphorAnalyticsCoverageSchema=G;exports.semaphorAnalyticsDiagnosticFeedbackSchema=U;exports.semaphorAnalyticsExecutionResultSchema=ge;exports.semaphorAnalyticsPopulationSchema=L;exports.semaphorAnalyticsResultSchema=he;exports.semaphorAnalyzeResultSchema=Se;exports.semaphorAnalyzeResultShape=be;exports.semaphorDataAppCodegenSummarySchema=ws;exports.semaphorRelationshipDiagnosticsSchema=ye;exports.validateSemaphorDataAppCodegenSummary=V;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const g=require("./validators-
|
|
1
|
+
"use strict";const g=require("./validators-ux2obZB9.cjs"),b="higher_is_better",C={displayMode:"difference",showComparison:!0,indicatorStyle:"arrow_badge",showColor:!0,conditionalLabel:!1};function w(o){return g.parseSemaphorIsoInstant(o)!==null}function $(o){var i,e,s,t;if(((i=o.metricComparison)==null?void 0:i.mode)!=="off"){if(((e=o.metricComparison)==null?void 0:e.mode)==="explicit")return{source:"explicit",spec:o.metricComparison.spec};if(!((o.inheritGlobalComparison??((s=o.globalDateComparison)==null?void 0:s.inheritGlobalComparison))===!1||((t=o.globalDateComparison)==null?void 0:t.selection.mode)!=="period"))return{source:"inherited",spec:o.globalDateComparison.selection.spec,...o.globalDateComparison.owner?{owner:o.globalDateComparison.owner}:{}}}}function h(o){if(o.alias)return o.alias;const i=o.entityName&&o.entityName!=="SEMAPHOR_CALCULATED_FIELD"?o.entityName:void 0,e=i&&i!==o.name?`${i}_`:"";if(o.role!=="metric")return`${e}${o.name}`;let s=o.aggregate||"metric";if(o.expression){const t=o.expression.match(/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i);s=t?t[1].toLowerCase():"expr"}else s=s.toLowerCase();return`${e}${o.name}_${s}`}function n(o,i,e){return e?{code:o,message:i,path:e}:{code:o,message:i}}function p(o){return!!o&&typeof o=="object"&&!Array.isArray(o)}function a(o,i,e,s){Object.keys(o).forEach(t=>{i.includes(t)||s.push(n("invalid_comparison_spec",`Comparison kind does not accept field "${t}".`,`${e}.${t}`))})}function f(o,i,e){o.alignment!==void 0&&o.alignment!=="calendar"&&o.alignment!=="weekday"&&e.push(n("invalid_comparison_spec",'Comparison alignment must be "calendar" or "weekday".',`${i}.alignment`)),o.toDate!==void 0&&typeof o.toDate!="boolean"&&e.push(n("invalid_comparison_spec","Comparison toDate must be a boolean.",`${i}.toDate`))}function _(o,i,e){o!==void 0&&(typeof o!="number"||!Number.isSafeInteger(o)||o<=0)&&e.push(n("invalid_comparison_spec","Comparison offset must be a positive safe integer.",i))}function d(o,i="comparison"){const e=[];return p(o)?(o.kind==="previous_period"?(a(o,["kind","offsetPeriods","alignment","toDate"],i,e),_(o.offsetPeriods,`${i}.offsetPeriods`,e),f(o,i,e)):o.kind==="previous_year"?(a(o,["kind","offsetYears","alignment","toDate"],i,e),_(o.offsetYears,`${i}.offsetYears`,e),f(o,i,e)):o.kind==="target"?(a(o,["kind","targetValue"],i,e),(typeof o.targetValue!="number"||!Number.isFinite(o.targetValue))&&e.push(n("invalid_comparison_spec","Target comparison requires a finite targetValue.",`${i}.targetValue`))):e.push(n("invalid_comparison_spec","Comparison kind must be previous_period, previous_year, or target.",`${i}.kind`)),{ok:e.length===0,errors:e,warnings:[]}):{ok:!1,errors:[n("invalid_comparison_spec","Comparison spec must be an object.",i)],warnings:[]}}function D(o,i="comparison"){if(!p(o))return{ok:!1,errors:[n("invalid_comparison_config","Comparison config must be an object.",i)],warnings:[]};const e=[];return o.mode==="off"?a(o,["mode"],i,e):o.mode==="explicit"?(a(o,["mode","spec"],i,e),e.push(...d(o.spec,`${i}.spec`).errors)):e.push(n("invalid_comparison_config","Comparison mode must be off or explicit.",`${i}.mode`)),{ok:e.length===0,errors:e,warnings:[]}}function u(o,i="comparisonSelection"){if(!p(o))return{ok:!1,errors:[n("invalid_global_date_comparison","Global Date comparison selection must be an object.",i)],warnings:[]};const e=[];if(o.mode==="off")a(o,["mode"],i,e);else if(o.mode==="period"){a(o,["mode","spec"],i,e);const s=d(o.spec,`${i}.spec`);e.push(...s.errors),p(o.spec)&&o.spec.kind==="target"&&e.push(n("invalid_global_date_comparison","Global Date comparison supports previous_period or previous_year, not target.",`${i}.spec.kind`))}else e.push(n("invalid_global_date_comparison","Global Date comparison mode must be off or period.",`${i}.mode`));return{ok:e.length===0,errors:e,warnings:[]}}function I(o,i="globalDateComparison"){if(!p(o))return{ok:!1,errors:[n("invalid_global_date_comparison","Global Date comparison context must be an object.",i)],warnings:[]};const e=[];return a(o,["selection","inheritGlobalComparison","owner","referenceTime"],i,e),e.push(...u(o.selection,`${i}.selection`).errors),o.inheritGlobalComparison!==void 0&&o.inheritGlobalComparison!==!1&&e.push(n("invalid_global_date_comparison","inheritGlobalComparison may only be false when present.",`${i}.inheritGlobalComparison`)),o.owner!==void 0&&(p(o.owner)?o.owner.kind==="global_date"?a(o.owner,["kind"],`${i}.owner`,e):o.owner.kind==="field_date"?(a(o.owner,["kind","filterId","label"],`${i}.owner`,e),(typeof o.owner.filterId!="string"||!o.owner.filterId.trim())&&e.push(n("invalid_global_date_comparison","Field Date comparison owner requires a non-empty filterId.",`${i}.owner.filterId`)),(typeof o.owner.label!="string"||!o.owner.label.trim())&&e.push(n("invalid_global_date_comparison","Field Date comparison owner requires a non-empty label.",`${i}.owner.label`))):e.push(n("invalid_global_date_comparison","Comparison owner kind must be global_date or field_date.",`${i}.owner.kind`)):e.push(n("invalid_global_date_comparison","Comparison owner must be an object.",`${i}.owner`))),o.referenceTime!==void 0&&(typeof o.referenceTime!="string"||!w(o.referenceTime))&&e.push(n("invalid_global_date_comparison","referenceTime must be a valid ISO date-time string when present.",`${i}.referenceTime`)),{ok:e.length===0,errors:e,warnings:[]}}function M(o,i="comparisonPolarity"){return o==="higher_is_better"||o==="lower_is_better"||o==="neutral"?{ok:!0,errors:[],warnings:[]}:{ok:!1,errors:[n("invalid_comparison_polarity","Comparison polarity must be higher_is_better, lower_is_better, or neutral.",i)],warnings:[]}}function S(o,i="comparisonPresentation"){if(!p(o))return{ok:!1,errors:[n("invalid_comparison_presentation","Comparison presentation must be an object.",i)],warnings:[]};const e=[],s=["displayMode","showComparison","precision","indicatorStyle","showColor","position","conditionalLabel","labelName","conditionalLabels","colors"];return Object.keys(o).forEach(r=>{s.includes(r)||e.push(n("invalid_comparison_presentation",`Comparison presentation does not accept field "${r}".`,`${i}.${r}`))}),[["displayMode",["difference","percent_change","both","ratio"]],["indicatorStyle",["arrow_badge","arrow","badge","none"]],["position",["left","right","top"]]].forEach(([r,l])=>{o[r]!==void 0&&!l.includes(o[r])&&e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} is invalid.`,`${i}.${r}`))}),["showComparison","showColor","conditionalLabel"].forEach(r=>{o[r]!==void 0&&typeof o[r]!="boolean"&&e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} must be a boolean.`,`${i}.${r}`))}),o.precision!==void 0&&(typeof o.precision!="number"||!Number.isInteger(o.precision)||o.precision<0||o.precision>6)&&e.push(n("invalid_comparison_presentation","Comparison presentation precision must be an integer from 0 through 6.",`${i}.precision`)),o.labelName!==void 0&&typeof o.labelName!="string"&&e.push(n("invalid_comparison_presentation","Comparison presentation labelName must be a string.",`${i}.labelName`)),["conditionalLabels","colors"].forEach(r=>{const l=o[r];if(l!==void 0){if(!p(l)){e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} must be an object.`,`${i}.${r}`));return}Object.keys(l).forEach(c=>{["increase","decrease","neutral"].includes(c)||e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} does not accept field "${c}".`,`${i}.${r}.${c}`))}),Object.entries(l).forEach(([c,m])=>{m!==void 0&&typeof m!="string"&&e.push(n("invalid_comparison_presentation",`Comparison presentation ${r}.${c} must be a string.`,`${i}.${r}.${c}`))})}}),{ok:e.length===0,errors:e,warnings:[]}}function N(o){return o===null?"unknown":o>0?"increase":o<0?"decrease":"no_change"}function T(o,i){return o==="unknown"||o==="no_change"||i==="neutral"?"neutral":i==="higher_is_better"&&o==="increase"||i==="lower_is_better"&&o==="decrease"?"favorable":"unfavorable"}function y(o){const{currentValue:i,comparisonValue:e,polarity:s=b}=o,r=i!==null&&e!==null?i-e:null,l=r!==null&&e!==null&&e!==0?r/Math.abs(e):null,c=i!==null&&e!==null&&e!==0?i/e:null,m=N(r);return{status:e===null?"insufficient_history":"available",currentValue:i,comparisonValue:e,delta:r,percentChange:l,ratio:c,direction:m,sentiment:T(m,s)}}exports.COMPARISON_PRESENTATION_DEFAULTS=C;exports.DEFAULT_METRIC_COMPARISON_POLARITY=b;exports.evaluateMetricComparison=y;exports.resolveMetricComparisonRequest=$;exports.resolveMetricResultAlias=h;exports.validateComparisonPresentationSpec=S;exports.validateGlobalDateComparisonContext=I;exports.validateGlobalDateComparisonSelection=u;exports.validateMetricComparisonConfig=D;exports.validateMetricComparisonPolarity=M;exports.validateMetricComparisonSpec=d;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
function
|
|
2
|
-
const t =
|
|
3
|
-
return
|
|
1
|
+
function r(n) {
|
|
2
|
+
const t = o(n);
|
|
3
|
+
return e(t) ? t : void 0;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function o(n) {
|
|
6
6
|
if (typeof n != "string" || n.trim().length === 0)
|
|
7
7
|
return;
|
|
8
8
|
const t = n.trim().toLowerCase();
|
|
@@ -33,16 +33,34 @@ function e(n) {
|
|
|
33
33
|
case "is_not_null":
|
|
34
34
|
return "is_not_null";
|
|
35
35
|
default:
|
|
36
|
-
return
|
|
36
|
+
return i(n) ? n : void 0;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function e(n) {
|
|
40
40
|
return n === "=" || n === "!=" || n === "in" || n === "not_in" || n === "contains" || n === "not_contains" || n === "between" || n === "not_between" || n === ">" || n === ">=" || n === "<" || n === "<=";
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
42
|
+
function i(n) {
|
|
43
|
+
return e(n) || n === "not_contains" || n === "is_null" || n === "is_not_null";
|
|
44
|
+
}
|
|
45
|
+
function s(n) {
|
|
46
|
+
switch (n) {
|
|
47
|
+
case "not in":
|
|
48
|
+
return "not_in";
|
|
49
|
+
case "like":
|
|
50
|
+
return "contains";
|
|
51
|
+
case "not like":
|
|
52
|
+
return "not_contains";
|
|
53
|
+
case "not between":
|
|
54
|
+
return "not_between";
|
|
55
|
+
case "is null":
|
|
56
|
+
case "is not null":
|
|
57
|
+
return;
|
|
58
|
+
default:
|
|
59
|
+
return r(n);
|
|
60
|
+
}
|
|
44
61
|
}
|
|
45
62
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
o as a,
|
|
64
|
+
r as n,
|
|
65
|
+
s as t
|
|
48
66
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function r(n){const t=e(n);return o(t)?t:void 0}function e(n){if(typeof n!="string"||n.trim().length===0)return;const t=n.trim().toLowerCase();switch(t){case"=":return"=";case"!=":return"!=";case"in":return"in";case"not_in":return"not_in";case"contains":return"contains";case"not_contains":return"not_contains";case"between":return"between";case"not_between":return"not_between";case">":case">=":case"<":case"<=":return t;case"is_null":return"is_null";case"is_not_null":return"is_not_null";default:return i(n)?n:void 0}}function o(n){return n==="="||n==="!="||n==="in"||n==="not_in"||n==="contains"||n==="not_contains"||n==="between"||n==="not_between"||n===">"||n===">="||n==="<"||n==="<="}function i(n){return o(n)||n==="not_contains"||n==="is_null"||n==="is_not_null"}function s(n){switch(n){case"not in":return"not_in";case"like":return"contains";case"not like":return"not_contains";case"not between":return"not_between";case"is null":case"is not null":return;default:return r(n)}}exports.normalizeSemaphorAnalyticsFilterOperator=e;exports.normalizeSemaphorInputOperator=r;exports.toSemaphorInputOperatorFromFilterOperation=s;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var X=(e,r,t)=>r in e?v(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var w=(e,r,t)=>X(e,typeof r!="symbol"?r+"":r,t);const D=require("./semantic-format
|
|
1
|
+
"use strict";var v=Object.defineProperty;var X=(e,r,t)=>r in e?v(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var w=(e,r,t)=>X(e,typeof r!="symbol"?r+"":r,t);const D=require("./semantic-format--_VEin18.cjs"),k=require("./matrix-formatter-C19PZAal.cjs"),f=require("./raw-temporal-DDTt2yv5.cjs"),d=require("../pdf-export-policy/index.cjs"),G=require("./temporal-bucket-4YEPEKlJ.cjs");function B(e,r,t){const n={...r,locale:r.locale??t};if(n.type==="number")return f.formatNumericCanonical(e,n);const{prefix:o,suffix:a,...s}=n;return`${o??""}${f.formatNumericCanonical(e,{...s,negativeStyle:n.type==="currency"?n.negativeStyle:"minus"})}${a??""}`}function A(e,r,t){return e===null?{value:e,text:null}:!r||!D.isNumericCanonicalFormat(r)&&r.type!=="duration"?{value:e,text:f.formatNumericCanonical(e,{type:"number",locale:t})}:r.type==="duration"?{value:e,text:k.formatDuration(e,{inputUnit:r.inputUnit,outputStyle:r.outputStyle,largestUnit:r.largestUnit,smallestUnit:r.smallestUnit,maxUnits:r.maxUnits,prefix:r.prefix,suffix:r.suffix,negativeInParentheses:r.negativeStyle==="parentheses"})}:{value:e,text:B(e,r,t)}}function T(e,r,t,n){return e===null?{value:e,text:null}:n==="percent"?{value:e,text:f.formatNumericCanonical(e,{type:"percent",locale:t,minimumFractionDigits:r,maximumFractionDigits:r,percentValueMode:"fraction"})}:{value:e,text:f.formatNumericCanonical(e,{type:"number",locale:t,minimumFractionDigits:r,maximumFractionDigits:r,suffix:"×"})}}function _(e,r){if(e===void 0)return r;if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("Comparison precision must be an integer from 0 to 6.");return e}function $(e,r){const t={mode:r.displayMode,current:A(e.currentValue,r.metricFormat,r.locale),comparison:A(e.comparisonValue,r.metricFormat,r.locale)};return(r.displayMode==="difference"||r.displayMode==="both")&&(t.difference=A(e.delta,r.metricFormat,r.locale)),(r.displayMode==="percent_change"||r.displayMode==="both")&&(t.percentChange=T(e.percentChange,_(r.precision,1),r.locale,"percent")),r.displayMode==="ratio"&&(t.ratio=T(e.ratio,_(r.precision,2),r.locale,"ratio")),t}function U(e){const r=e.trimStart().charAt(0);return["=","+","-","@"].includes(r)||[" ","\r",`
|
|
2
2
|
`].includes(e.charAt(0))?`'${e}`:e}function C(e,r=","){if(e==null)return"";const t=String(e);return t.includes(r)||t.includes('"')||t.includes(`
|
|
3
3
|
`)||t.includes("\r")?`"${t.replace(/"/g,'""')}"`:t}function b(e,r=","){return e.map(t=>C(t,r)).join(r)}function h(e,r={}){const{delimiter:t=",",lineEnding:n=`
|
|
4
4
|
`}=r;return e.map(o=>b(o,t)).join(n)}function N(e,r={}){if(e.length===0)return"";const{delimiter:t=",",lineEnding:n=`
|
package/dist/chunks/{pivot-header-presentation-BslEo_4O.js → pivot-header-presentation-DW-ti5ek.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var x = Object.defineProperty;
|
|
2
2
|
var T = (e, r, t) => r in e ? x(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
3
|
var y = (e, r, t) => T(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
-
import { i as C } from "./semantic-format-
|
|
5
|
-
import { d as _ } from "./matrix-formatter-
|
|
6
|
-
import { b as g } from "./raw-temporal-
|
|
4
|
+
import { i as C } from "./semantic-format-ew5zviaT.js";
|
|
5
|
+
import { d as _ } from "./matrix-formatter-CiXzpX6X.js";
|
|
6
|
+
import { b as g } from "./raw-temporal-DHCZrFe7.js";
|
|
7
7
|
import { PDF_SAFETY_LIMIT_EXCEEDED as S, getUtf8ByteLength as V, FAST_PDF_POLICY as M } from "../pdf-export-policy/index.js";
|
|
8
8
|
import { f as P } from "./temporal-bucket-B9hMwemw.js";
|
|
9
9
|
function R(e, r, t) {
|
package/dist/chunks/{pivot-result-identity-CmvwpG4K.cjs → pivot-result-identity-DEenUrMj.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-
|
|
1
|
+
"use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-BYR6tj6F.cjs");function y(t){return!!(t!=null&&t.isSubtotal&&t.subtotalScope==="pivot-value")}function c(t){var e;return t.expectedPivotFieldIds.length===0?!0:!!((e=t.classification)!=null&&e.isSubtotal&&t.classification.subtotalScope==="grand-total")}class u extends Error{constructor(r){super(`missing_pivot_member_identity: ${r}`);n(this,"deliveryBlocking",!0);n(this,"code","missing_pivot_member_identity");this.name="PivotResultIdentityError"}}function d(t){const{identity:e,columnKey:r,expectedPivotFieldIds:i,allowPrefix:l=!1}=t,s=t.allowEmpty??((i==null?void 0:i.length)||0)===0;if(!e||typeof e!="object"||Array.isArray(e)||typeof e.metricId!="string"||!e.metricId||typeof e.metricAlias!="string"||!e.metricAlias||!Array.isArray(e.members))throw new u(`Physical pivot column "${r}" is missing stable metric or member identity.`);if(e.members.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o)||typeof o.fieldId!="string"||!o.fieldId||o.value!==null&&typeof o.value!="string"||o.temporalBucket!==void 0&&!f.validateTemporalBucketMetadata(o.temporalBucket).ok)throw new u(`Physical pivot column "${r}" has invalid identity for member ${a}.`);if(i&&o.fieldId!==i[a])throw new u(`Physical pivot column "${r}" has member "${o.fieldId}" at tuple position ${a}; expected "${i[a]||"no member"}".`)}),e.members.length===0){if(s)return e.members;throw new u(`Physical pivot column "${r}" is missing its required pivot tuple.`)}if(i&&(!l&&e.members.length!==i.length||e.members.length>i.length))throw new u(`Physical pivot column "${r}" has ${e.members.length} members; expected ${l?"at most ":""}${i.length}.`);return e.members}function p(t,e){t.forEach(r=>{var l,s,o;if(r.pivotIdentity===void 0)return;const i=(l=e.columnClassifications)==null?void 0:l[r.key];d({identity:r.pivotIdentity,columnKey:r.key,expectedPivotFieldIds:e.expectedPivotFieldIds,allowPrefix:((s=e.allowPrefixForColumn)==null?void 0:s.call(e,r))??y(i),allowEmpty:((o=e.allowEmptyForColumn)==null?void 0:o.call(e,r))??c({expectedPivotFieldIds:e.expectedPivotFieldIds,classification:i})})})}function h(t,e,r){var l;const i=t==null?void 0:t.byRole;if(!(!i||typeof i!="object"||Array.isArray(i)))return(l=i[r])==null?void 0:l[e]}function P(t,e){if(!t)return;const r=t.byRole;if(!r||typeof r!="object"||Array.isArray(r))return;const i=Object.values(r).flatMap(s=>{const o=s==null?void 0:s[e];return o?[o]:[]});if(i.length!==1)return;const[l]=i;if(!(l.role==="metric"&&Object.values(t.byMetricAlias??{}).some(s=>s.role===l.role&&s.rawKey===l.rawKey&&s.outputKey===l.outputKey)))return l}exports.PivotResultIdentityError=u;exports.isPivotEmptyTupleAllowed=c;exports.isPivotSubtotalPrefix=y;exports.requirePivotHeaderMembers=d;exports.requirePivotResultColumnIdentities=p;exports.resolveQueryColumnKeyMapEntry=h;exports.resolveUniqueQueryColumnKeyMapEntry=P;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var y = Object.defineProperty;
|
|
2
2
|
var c = (t, e, r) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var u = (t, e, r) => c(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { v as d } from "./temporal-bucket-contract-
|
|
4
|
+
import { v as d } from "./temporal-bucket-contract-C-kKQ_W4.js";
|
|
5
5
|
function f(t) {
|
|
6
6
|
return !!(t != null && t.isSubtotal && t.subtotalScope === "pivot-value");
|
|
7
7
|
}
|
package/dist/chunks/{pivot-result-lifecycle-H_pntnd9.cjs → pivot-result-lifecycle-D81qcCcZ.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var M=(e,o,t)=>o in e?P(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var p=(e,o,t)=>M(e,typeof o!="symbol"?o+"":o,t);const x=require("./raw-temporal-DcHmXurp.cjs"),T=require("./report-runtime-context-Bb0ejvVq.cjs"),u=require("./temporal-bucket-4YEPEKlJ.cjs"),q=require("./validators-4dRtYUI1.cjs");require("./matrix-operation-contract-BiUMcd6G.cjs");const O=require("./metric-comparison-D1VRq5Os.cjs"),B=require("./temporal-bucket-contract-CPuYzg7A.cjs"),k=require("./pivot-result-identity-CmvwpG4K.cjs");class b extends Error{constructor(t){super(`invalid_presentation_execution_snapshot: ${t} Resave this report before running it again.`);p(this,"code","invalid_presentation_execution_snapshot");p(this,"deliveryBlocking",!0);this.name="PresentationExecutionSnapshotError"}}class J extends Error{constructor(t){super(`missing_resolved_raw_temporal_format: Column "${t}" has no captured presentation. Resave this report before running it again.`);p(this,"code","missing_resolved_raw_temporal_format");p(this,"deliveryBlocking",!0);this.name="MissingResolvedRawTemporalFormatError"}}function v(e,o,t){const n=new Set(o),r=Object.keys(e).find(i=>!n.has(i));if(r)throw new Error(`${t} contains unknown property "${r}"`)}function _(e,o="scope"){if(!u.isPlainJsonRecord(e))throw new Error(`${o} must be an object`);v(e,["dashboardId","cardId","attachmentIndex"],o);const t=typeof e.dashboardId=="string"?e.dashboardId.trim():"";if(!t)throw new Error(`${o}.dashboardId is required`);const n=typeof e.cardId=="string"?e.cardId.trim():void 0;if(e.cardId!==void 0&&!n)throw new Error(`${o}.cardId must be a non-empty string`);const r=e.attachmentIndex;if(r!==void 0&&(typeof r!="number"||!Number.isInteger(r)||r<0))throw new Error(`${o}.attachmentIndex must be a non-negative integer`);return{dashboardId:t,...n?{cardId:n}:{},...typeof r=="number"?{attachmentIndex:r}:{}}}function y(e,o,t,n){if(e.kind!==o)return;v(e,["kind",t],n);const r=typeof e[t]=="string"?e[t].trim():"";if(!r)throw new Error(`${n}.${t} is required`);return r}function N(e,o){if(!u.isPlainJsonRecord(e))throw new Error(`${o} must be an object`);const t=y(e,"metric","metricId",o);if(t)return{kind:"metric",metricId:t};const n=y(e,"column","columnKey",o);if(n)return{kind:"column",columnKey:n};const r=y(e,"matrix_measure","measureId",o);if(r)return{kind:"matrix_measure",measureId:r};throw new Error(`${o} is not a valid numeric presentation target`)}function z(e,o){if(!u.isPlainJsonRecord(e))throw new Error(`${o} must be an object`);if(e.kind==="field"){v(e,["kind","fieldId","role"],o);const r=typeof e.fieldId=="string"?e.fieldId.trim():"";if(!r)throw new Error(`${o}.fieldId is required`);const i=e.role;if(i!==void 0&&i!=="groupby"&&i!=="pivotby")throw new Error(`${o}.role must be groupby or pivotby`);return{kind:"field",fieldId:r,...i?{role:i}:{}}}const t=y(e,"column","columnKey",o);if(t)return{kind:"column",columnKey:t};const n=y(e,"matrix_axis","axisInstanceId",o);if(n)return{kind:"matrix_axis",axisInstanceId:n};throw new Error(`${o} is not a valid temporal bucket presentation target`)}function L(e,o){if(!u.isPlainJsonRecord(e))throw new Error(`${o} must be an object`);const t=y(e,"column","columnKey",o);if(!t)throw new Error(`${o} must identify a column`);return{kind:"column",columnKey:t}}function D(e){return[e.dashboardId,e.cardId??null,e.attachmentIndex??null]}function h(e){switch(e.kind){case"metric":return[e.kind,e.metricId];case"column":return[e.kind,e.columnKey];case"matrix_measure":return[e.kind,e.measureId];case"field":return[e.kind,e.fieldId,e.role??""];case"matrix_axis":return[e.kind,e.axisInstanceId]}}function g(e,o){return e.dashboardId===o.dashboardId&&e.cardId===o.cardId&&e.attachmentIndex===o.attachmentIndex}function R(e,o){const t=h(e),n=h(o);return t.length===n.length&&t.every((r,i)=>r===n[i])}function K(e){if(!Array.isArray(e))throw new Error("resolvedFormats must be an array");const o=new Set;return e.map((t,n)=>{var m,f;const r=`resolvedFormats.${n}`;if(!u.isPlainJsonRecord(t))throw new Error(`${r} must be an object`);v(t,["scope","target","format"],r);const i=_(t.scope,`${r}.scope`);if(!u.isPlainJsonRecord(t.format))throw new Error(`${r}.format must be an object`);let s;switch(t.format.type){case"temporal_bucket":{const l=u.parseResolvedTemporalBucketFormat(t.format);if(!l.ok)throw new Error(`${r}.format is invalid: ${((m=l.issues[0])==null?void 0:m.message)??"invalid value"}`);s={scope:i,target:z(t.target,`${r}.target`),format:l.value};break}case"raw_temporal":s={scope:i,target:L(t.target,`${r}.target`),format:x.parseResolvedRawTemporalFormat(t.format)};break;case"number":case"currency":case"percent":case"scientific":{const l=x.parseResolvedNumericCanonicalFormat(t.format);if(!l.ok)throw new Error(`${r}.format is invalid: ${((f=l.issues[0])==null?void 0:f.message)??"invalid value"}`);s={scope:i,target:N(t.target,`${r}.target`),format:l.value};break}default:throw new Error(`${r}.format.type is unsupported`)}const c=JSON.stringify([...D(s.scope),...h(s.target)]);if(o.has(c))throw new Error(`${r} duplicates a scoped presentation target`);return o.add(c),s})}function F(e){try{if(!u.isPlainJsonRecord(e))throw new Error("presentation execution snapshot must be an object");if(v(e,["version","reportContext","resolvedFormats"],"presentation execution snapshot"),e.version!==1)throw new Error("presentation execution snapshot version must be 1");const o=T.parseReportRuntimeContext(e.reportContext);if(!o.ok){const t=o.issues[0];throw new Error(`presentation execution snapshot reportContext is invalid: ${t!=null&&t.path&&t.path!=="$"?`${t.path}: `:""}${(t==null?void 0:t.message)??"invalid value"}`)}return{version:1,reportContext:o.value,resolvedFormats:K(e.resolvedFormats)}}catch(o){throw o instanceof b?o:new b(o instanceof Error?o.message:"Snapshot is invalid.")}}function U(e){return F({version:1,reportContext:e.reportContext,resolvedFormats:[...e.resolvedFormats]})}function V(e){const o=e.snapshot.resolvedFormats.find(t=>t.format.type!=="temporal_bucket"&&t.format.type!=="raw_temporal"&&g(t.scope,e.scope)&&R(t.target,e.target));return o==null?void 0:o.format}function G(e){const o=e.snapshot.resolvedFormats.find(t=>t.format.type==="raw_temporal"&&g(t.scope,e.scope)&&R(t.target,e.target));return o==null?void 0:o.format}function H(e){const o=e.snapshot.resolvedFormats.find(t=>t.format.type==="temporal_bucket"&&g(t.scope,e.scope)&&R(t.target,e.target));return o==null?void 0:o.format}function Q(e){var r;const o=new Set,t=new Set;if(e.snapshot.resolvedFormats.forEach((i,s)=>{if(i.scope.attachmentIndex!==void 0)throw new Error(`resolvedFormats.${s}.scope.attachmentIndex is not valid for a card export`);if(i.scope.dashboardId!==e.expectedScope.dashboardId||i.scope.cardId!==e.expectedScope.cardId)throw new Error(`resolvedFormats.${s}.scope must match the executing dashboard/card`);if(i.target.kind==="field"&&i.format.type==="temporal_bucket"){const c=JSON.stringify(h(i.target));if(t.has(c))throw new Error(`resolvedFormats.${s} duplicates export field "${i.target.fieldId}"`);t.add(c);return}if(i.target.kind!=="column")throw new Error(`resolvedFormats.${s}.target must identify an export column or temporal pivot field`);if(o.has(i.target.columnKey))throw new Error(`resolvedFormats.${s} duplicates export column "${i.target.columnKey}"`);o.add(i.target.columnKey)}),!e.useFormattedValues)return;if(!((r=e.visibleColumns)!=null&&r.length))throw new Error("visibleColumns must identify every formatted export column");const n=e.visibleColumns.find(i=>!o.has(i));if(n)throw new Error(`resolvedFormats is missing visible export column "${n}"`)}function w(e){return Array.from(new Set((e??[]).flatMap(o=>typeof o.id=="string"&&o.id?[o.id]:[])))}function S(e){const o=new Map;return e.forEach(t=>{t.id&&o.set(t.id,(o.get(t.id)??0)+1)}),e.flatMap(t=>t.id&&(o.get(t.id)??0)>1?[O.resolveMetricResultAlias(t)]:[])}function W(e){const o=e.metricFields??[],t=w(o);return{expectedRoleFieldIds:{groupby:w(e.groupByFields),metric:t.length>0?t:[q.SEMAPHOR_GENERATED_COUNT_METRIC_ID],pivotby:w(e.pivotByFields),detail:w(e.detailFields)},expectedMetricAliases:S(o)}}class a extends Error{constructor(t,n){super(`invalid_pivot_result_lifecycle: ${t}`);p(this,"code","invalid_pivot_result_lifecycle");p(this,"deliveryBlocking",!0);this.cause=n,this.name="PivotResultLifecycleError"}}function X(e){if(!Array.isArray(e)||e.some(t=>!t||typeof t!="object"||Array.isArray(t)||typeof t.key!="string"||!t.key||typeof t.name!="string"||typeof t.label!="string"))throw new a("Canonical pivot columns must be an array of keyed, named result descriptors.");const o=e;if(new Set(o.map(t=>t.key)).size!==o.length)throw new a("Canonical pivot column keys must be unique.");for(const t of o){const n=B.validateTemporalBucketResultColumn(t,{metadataRequired:!1});if(!n.ok)throw new a(`Canonical pivot column "${t.key}" has invalid temporal metadata: ${n.error.message}`)}return o}function C(e){if(!e||typeof e!="object"||Array.isArray(e)||e.version!==1||e.source!=="explorer"||!e.byRole||typeof e.byRole!="object"||Array.isArray(e.byRole))throw new a("A loaded canonical pivot result requires its role-scoped column key map.");const o=e,t=new Set(["groupby","metric","pivotby","detail"]);for(const[n,r]of Object.entries(o.byRole)){if(!t.has(n)||!r||typeof r!="object"||Array.isArray(r))throw new a(`Canonical pivot role map contains invalid "${n}" bindings.`);for(const[i,s]of Object.entries(r))if(!i||!s||typeof s!="object"||Array.isArray(s)||s.role!==n||typeof s.rawKey!="string"||!s.rawKey||s.outputKey!==void 0&&(typeof s.outputKey!="string"||!s.outputKey))throw new a(`Canonical pivot role map contains an invalid "${n}:${i}" binding.`)}if(o.byMetricAlias!==void 0){if(!o.byMetricAlias||typeof o.byMetricAlias!="object"||Array.isArray(o.byMetricAlias))throw new a("Canonical pivot metric-alias bindings must be an object.");for(const[n,r]of Object.entries(o.byMetricAlias))if(!n||!r||typeof r!="object"||Array.isArray(r)||r.role!=="metric"||typeof r.rawKey!="string"||!r.rawKey||r.outputKey!==void 0&&(typeof r.outputKey!="string"||!r.outputKey))throw new a(`Canonical pivot metric-alias map contains an invalid "${n}" binding.`)}return o}function Y(e){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))throw new a("Canonical pivot column metadata must be an object.");for(const[o,t]of Object.entries(e)){if(!o||!t||typeof t!="object"||Array.isArray(t))throw new a(`Canonical pivot column metadata contains an invalid "${o}" classification.`);const{isSubtotal:n,subtotalScope:r}=t;if(n!==void 0&&typeof n!="boolean"||r!==void 0&&r!=="base"&&r!=="pivot-value"&&r!=="grand-total"||n===!0&&r!=="pivot-value"&&r!=="grand-total"||(r==="pivot-value"||r==="grand-total")&&n!==!0||r==="base"&&n===!0)throw new a(`Canonical pivot column metadata contains an incoherent "${o}" subtotal classification.`)}return e}function A(e,o){if(!Array.isArray(e)||e.some(t=>typeof t!="string"||!t)||new Set(e).size!==e.length)throw new a(`Canonical pivot contract ${o} must be an array of unique field identities.`);return e}function Z(e,o){if(!e||typeof e!="object"||Array.isArray(e)||e.version!==1)throw new a("A canonical pivot result requires its versioned result contract.");const t=e,n=t.expectedRoleFieldIds;if(!n||typeof n!="object"||Array.isArray(n))throw new a("Canonical pivot contract role identities must be an object.");const i=Object.fromEntries(["groupby","metric","pivotby","detail"].map(d=>[d,A(n[d],`expectedRoleFieldIds.${d}`)])),s=A(t.expectedMetricAliases,"expectedMetricAliases"),c=t.columnKinds;if(!c||typeof c!="object"||Array.isArray(c))throw new a("Canonical pivot contract column kinds must be an object.");const m=new Set(["row","pivot_metric","value"]),f=o.map(d=>d.key),l=Object.keys(c);if(l.length!==f.length||l.some(d=>!f.includes(d)||!m.has(c[d])))throw new a("Canonical pivot contract must classify every authoritative result column exactly once.");const I=Y(t.columnClassifications);if(Object.keys(I).some(d=>!f.includes(d)))throw new a("Canonical pivot contract contains a classification for an unknown result column.");return{version:1,expectedRoleFieldIds:i,expectedMetricAliases:s,columnKinds:c,columnClassifications:I}}function E(e,o){const t=["groupby","metric","pivotby","detail"];for(const i of t){const s=new Set(o.expectedRoleFieldIds[i]??[]),c=Object.keys(e.byRole[i]??{});if(c.length!==s.size||c.some(m=>!s.has(m)))throw new a(`The role-scoped ${i} bindings do not match the authored result fields.`)}const n=new Set(o.expectedMetricAliases),r=Object.keys(e.byMetricAlias??{});if(r.length!==n.size||r.some(i=>!n.has(i)))throw new a("The metric-alias bindings do not match the authored metric instances.")}function ee(e){if(!Array.isArray(e)||e.some(o=>!o||typeof o!="object"||Array.isArray(o)))throw new a("Canonical pivot records must be an array of row objects.");return e}function te(e,o){e.forEach((t,n)=>{o.forEach(r=>{if(!Object.prototype.hasOwnProperty.call(t,r.key)||t[r.key]===void 0)throw new a(`Canonical pivot column "${r.key}" is absent from row ${n}.`)})})}function oe(e,o,t){const n=new Set(o.map(r=>r.key));["groupby","detail"].forEach(r=>{Object.entries(e.byRole[r]??{}).forEach(([i,s])=>{const c=s.outputKey||s.rawKey;if(!n.has(c)||t.columnKinds[c]!=="row")throw new a(`The role-scoped ${r} binding for "${i}" does not name an authoritative result column.`)})})}function $(e,o){o.forEach(t=>{const n=e.columnKinds[t.key];if(n==="pivot_metric"&&t.pivotIdentity===void 0)throw new a(`Physical pivot result column "${t.key}" is missing its identity.`);if(n!=="pivot_metric"&&t.pivotIdentity!==void 0)throw new a(`Canonical pivot result column "${t.key}" carries pivot identity outside the physical pivot projection.`)})}function j(e){const o=ee(e.records),t=X(e.columns),n=Z(e.pivotResultContract,t),r=n.expectedRoleFieldIds.pivotby??[];if(e.pivotResultState==="loaded_empty"){if(o.length!==0)throw new a("A loaded_empty pivot result cannot carry records.");if(t.some(m=>n.columnKinds[m.key]==="pivot_metric"))throw new a("A loaded_empty pivot result cannot carry physical pivot columns.");$(n,t);const c=C(e.columnKeyMap);return E(c,n),{pivotResultState:"loaded_empty",records:[],columns:t,columnKeyMap:c,pivotResultContract:n}}if(e.pivotResultState!=="loaded_valid")throw new a("A canonical pivot result must declare loaded_empty or loaded_valid.");if(o.length===0)throw new a("A loaded_valid pivot result must carry at least one record.");const i=C(e.columnKeyMap);E(i,n),oe(i,t,n),$(n,t);const s=t.filter(c=>n.columnKinds[c.key]==="pivot_metric");if(r.length>0&&s.length===0)throw new a("A loaded_valid pivot result is missing its physical pivot columns.");try{k.requirePivotResultColumnIdentities(s,{expectedPivotFieldIds:r,columnClassifications:n.columnClassifications})}catch(c){throw c instanceof k.PivotResultIdentityError?new a(c.message,c):c}return te(o,t),{pivotResultState:"loaded_valid",records:o,columns:t,columnKeyMap:i,pivotResultContract:n}}function re(e){const o=new Set;["groupby","detail"].forEach(i=>{Object.values(e.columnKeyMap.byRole[i]??{}).forEach(s=>{o.add(s.outputKey||s.rawKey)})});const t=new Set(e.physicalPivotColumnKeys),n=new Set(e.columns.map(i=>i.key)),r={version:1,expectedRoleFieldIds:{groupby:Array.from(new Set(e.expectedRoleFieldIds.groupby??[])),metric:Array.from(new Set(e.expectedRoleFieldIds.metric??[])),pivotby:Array.from(new Set(e.expectedRoleFieldIds.pivotby??[])),detail:Array.from(new Set(e.expectedRoleFieldIds.detail??[]))},expectedMetricAliases:[...e.expectedMetricAliases??[]],columnKinds:Object.fromEntries(e.columns.map(i=>[i.key,o.has(i.key)?"row":t.has(i.key)?"pivot_metric":"value"])),columnClassifications:Object.fromEntries(Object.entries(e.columnMetadata??{}).filter(([i])=>n.has(i)))};return j({pivotResultState:e.records.length===0?"loaded_empty":"loaded_valid",pivotResultContract:r,records:e.records,columns:e.columns,columnKeyMap:e.columnKeyMap})}exports.MissingResolvedRawTemporalFormatError=J;exports.PivotResultLifecycleError=a;exports.PresentationExecutionSnapshotError=b;exports.createCanonicalPivotResultTransport=re;exports.createPresentationExecutionSnapshot=U;exports.deriveMetricInstanceAliasExpectations=S;exports.derivePivotResultContractExpectations=W;exports.findResolvedNumericFormat=V;exports.findResolvedRawTemporalFormat=G;exports.findResolvedTemporalBucketFormat=H;exports.parseCanonicalPivotResultTransport=j;exports.parsePresentationExecutionSnapshot=F;exports.parsePresentationScope=_;exports.parseResolvedPresentationEntries=K;exports.validateCardExportPresentationSnapshot=Q;
|
|
1
|
+
"use strict";var P=Object.defineProperty;var M=(e,o,t)=>o in e?P(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var p=(e,o,t)=>M(e,typeof o!="symbol"?o+"":o,t);const x=require("./raw-temporal-DDTt2yv5.cjs"),T=require("./report-runtime-context-lSIvyKm2.cjs"),u=require("./temporal-bucket-4YEPEKlJ.cjs"),q=require("./validators-ux2obZB9.cjs");require("./matrix-operation-contract-o9GXbiHw.cjs");const O=require("./metric-comparison-DeiOjEm5.cjs"),B=require("./temporal-bucket-contract-BYR6tj6F.cjs"),k=require("./pivot-result-identity-DEenUrMj.cjs");class b extends Error{constructor(t){super(`invalid_presentation_execution_snapshot: ${t} Resave this report before running it again.`);p(this,"code","invalid_presentation_execution_snapshot");p(this,"deliveryBlocking",!0);this.name="PresentationExecutionSnapshotError"}}class J extends Error{constructor(t){super(`missing_resolved_raw_temporal_format: Column "${t}" has no captured presentation. Resave this report before running it again.`);p(this,"code","missing_resolved_raw_temporal_format");p(this,"deliveryBlocking",!0);this.name="MissingResolvedRawTemporalFormatError"}}function v(e,o,t){const n=new Set(o),r=Object.keys(e).find(i=>!n.has(i));if(r)throw new Error(`${t} contains unknown property "${r}"`)}function _(e,o="scope"){if(!u.isPlainJsonRecord(e))throw new Error(`${o} must be an object`);v(e,["dashboardId","cardId","attachmentIndex"],o);const t=typeof e.dashboardId=="string"?e.dashboardId.trim():"";if(!t)throw new Error(`${o}.dashboardId is required`);const n=typeof e.cardId=="string"?e.cardId.trim():void 0;if(e.cardId!==void 0&&!n)throw new Error(`${o}.cardId must be a non-empty string`);const r=e.attachmentIndex;if(r!==void 0&&(typeof r!="number"||!Number.isInteger(r)||r<0))throw new Error(`${o}.attachmentIndex must be a non-negative integer`);return{dashboardId:t,...n?{cardId:n}:{},...typeof r=="number"?{attachmentIndex:r}:{}}}function y(e,o,t,n){if(e.kind!==o)return;v(e,["kind",t],n);const r=typeof e[t]=="string"?e[t].trim():"";if(!r)throw new Error(`${n}.${t} is required`);return r}function N(e,o){if(!u.isPlainJsonRecord(e))throw new Error(`${o} must be an object`);const t=y(e,"metric","metricId",o);if(t)return{kind:"metric",metricId:t};const n=y(e,"column","columnKey",o);if(n)return{kind:"column",columnKey:n};const r=y(e,"matrix_measure","measureId",o);if(r)return{kind:"matrix_measure",measureId:r};throw new Error(`${o} is not a valid numeric presentation target`)}function z(e,o){if(!u.isPlainJsonRecord(e))throw new Error(`${o} must be an object`);if(e.kind==="field"){v(e,["kind","fieldId","role"],o);const r=typeof e.fieldId=="string"?e.fieldId.trim():"";if(!r)throw new Error(`${o}.fieldId is required`);const i=e.role;if(i!==void 0&&i!=="groupby"&&i!=="pivotby")throw new Error(`${o}.role must be groupby or pivotby`);return{kind:"field",fieldId:r,...i?{role:i}:{}}}const t=y(e,"column","columnKey",o);if(t)return{kind:"column",columnKey:t};const n=y(e,"matrix_axis","axisInstanceId",o);if(n)return{kind:"matrix_axis",axisInstanceId:n};throw new Error(`${o} is not a valid temporal bucket presentation target`)}function L(e,o){if(!u.isPlainJsonRecord(e))throw new Error(`${o} must be an object`);const t=y(e,"column","columnKey",o);if(!t)throw new Error(`${o} must identify a column`);return{kind:"column",columnKey:t}}function D(e){return[e.dashboardId,e.cardId??null,e.attachmentIndex??null]}function h(e){switch(e.kind){case"metric":return[e.kind,e.metricId];case"column":return[e.kind,e.columnKey];case"matrix_measure":return[e.kind,e.measureId];case"field":return[e.kind,e.fieldId,e.role??""];case"matrix_axis":return[e.kind,e.axisInstanceId]}}function g(e,o){return e.dashboardId===o.dashboardId&&e.cardId===o.cardId&&e.attachmentIndex===o.attachmentIndex}function R(e,o){const t=h(e),n=h(o);return t.length===n.length&&t.every((r,i)=>r===n[i])}function K(e){if(!Array.isArray(e))throw new Error("resolvedFormats must be an array");const o=new Set;return e.map((t,n)=>{var m,f;const r=`resolvedFormats.${n}`;if(!u.isPlainJsonRecord(t))throw new Error(`${r} must be an object`);v(t,["scope","target","format"],r);const i=_(t.scope,`${r}.scope`);if(!u.isPlainJsonRecord(t.format))throw new Error(`${r}.format must be an object`);let s;switch(t.format.type){case"temporal_bucket":{const l=u.parseResolvedTemporalBucketFormat(t.format);if(!l.ok)throw new Error(`${r}.format is invalid: ${((m=l.issues[0])==null?void 0:m.message)??"invalid value"}`);s={scope:i,target:z(t.target,`${r}.target`),format:l.value};break}case"raw_temporal":s={scope:i,target:L(t.target,`${r}.target`),format:x.parseResolvedRawTemporalFormat(t.format)};break;case"number":case"currency":case"percent":case"scientific":{const l=x.parseResolvedNumericCanonicalFormat(t.format);if(!l.ok)throw new Error(`${r}.format is invalid: ${((f=l.issues[0])==null?void 0:f.message)??"invalid value"}`);s={scope:i,target:N(t.target,`${r}.target`),format:l.value};break}default:throw new Error(`${r}.format.type is unsupported`)}const c=JSON.stringify([...D(s.scope),...h(s.target)]);if(o.has(c))throw new Error(`${r} duplicates a scoped presentation target`);return o.add(c),s})}function F(e){try{if(!u.isPlainJsonRecord(e))throw new Error("presentation execution snapshot must be an object");if(v(e,["version","reportContext","resolvedFormats"],"presentation execution snapshot"),e.version!==1)throw new Error("presentation execution snapshot version must be 1");const o=T.parseReportRuntimeContext(e.reportContext);if(!o.ok){const t=o.issues[0];throw new Error(`presentation execution snapshot reportContext is invalid: ${t!=null&&t.path&&t.path!=="$"?`${t.path}: `:""}${(t==null?void 0:t.message)??"invalid value"}`)}return{version:1,reportContext:o.value,resolvedFormats:K(e.resolvedFormats)}}catch(o){throw o instanceof b?o:new b(o instanceof Error?o.message:"Snapshot is invalid.")}}function U(e){return F({version:1,reportContext:e.reportContext,resolvedFormats:[...e.resolvedFormats]})}function V(e){const o=e.snapshot.resolvedFormats.find(t=>t.format.type!=="temporal_bucket"&&t.format.type!=="raw_temporal"&&g(t.scope,e.scope)&&R(t.target,e.target));return o==null?void 0:o.format}function G(e){const o=e.snapshot.resolvedFormats.find(t=>t.format.type==="raw_temporal"&&g(t.scope,e.scope)&&R(t.target,e.target));return o==null?void 0:o.format}function H(e){const o=e.snapshot.resolvedFormats.find(t=>t.format.type==="temporal_bucket"&&g(t.scope,e.scope)&&R(t.target,e.target));return o==null?void 0:o.format}function Q(e){var r;const o=new Set,t=new Set;if(e.snapshot.resolvedFormats.forEach((i,s)=>{if(i.scope.attachmentIndex!==void 0)throw new Error(`resolvedFormats.${s}.scope.attachmentIndex is not valid for a card export`);if(i.scope.dashboardId!==e.expectedScope.dashboardId||i.scope.cardId!==e.expectedScope.cardId)throw new Error(`resolvedFormats.${s}.scope must match the executing dashboard/card`);if(i.target.kind==="field"&&i.format.type==="temporal_bucket"){const c=JSON.stringify(h(i.target));if(t.has(c))throw new Error(`resolvedFormats.${s} duplicates export field "${i.target.fieldId}"`);t.add(c);return}if(i.target.kind!=="column")throw new Error(`resolvedFormats.${s}.target must identify an export column or temporal pivot field`);if(o.has(i.target.columnKey))throw new Error(`resolvedFormats.${s} duplicates export column "${i.target.columnKey}"`);o.add(i.target.columnKey)}),!e.useFormattedValues)return;if(!((r=e.visibleColumns)!=null&&r.length))throw new Error("visibleColumns must identify every formatted export column");const n=e.visibleColumns.find(i=>!o.has(i));if(n)throw new Error(`resolvedFormats is missing visible export column "${n}"`)}function w(e){return Array.from(new Set((e??[]).flatMap(o=>typeof o.id=="string"&&o.id?[o.id]:[])))}function S(e){const o=new Map;return e.forEach(t=>{t.id&&o.set(t.id,(o.get(t.id)??0)+1)}),e.flatMap(t=>t.id&&(o.get(t.id)??0)>1?[O.resolveMetricResultAlias(t)]:[])}function W(e){const o=e.metricFields??[],t=w(o);return{expectedRoleFieldIds:{groupby:w(e.groupByFields),metric:t.length>0?t:[q.SEMAPHOR_GENERATED_COUNT_METRIC_ID],pivotby:w(e.pivotByFields),detail:w(e.detailFields)},expectedMetricAliases:S(o)}}class a extends Error{constructor(t,n){super(`invalid_pivot_result_lifecycle: ${t}`);p(this,"code","invalid_pivot_result_lifecycle");p(this,"deliveryBlocking",!0);this.cause=n,this.name="PivotResultLifecycleError"}}function X(e){if(!Array.isArray(e)||e.some(t=>!t||typeof t!="object"||Array.isArray(t)||typeof t.key!="string"||!t.key||typeof t.name!="string"||typeof t.label!="string"))throw new a("Canonical pivot columns must be an array of keyed, named result descriptors.");const o=e;if(new Set(o.map(t=>t.key)).size!==o.length)throw new a("Canonical pivot column keys must be unique.");for(const t of o){const n=B.validateTemporalBucketResultColumn(t,{metadataRequired:!1});if(!n.ok)throw new a(`Canonical pivot column "${t.key}" has invalid temporal metadata: ${n.error.message}`)}return o}function C(e){if(!e||typeof e!="object"||Array.isArray(e)||e.version!==1||e.source!=="explorer"||!e.byRole||typeof e.byRole!="object"||Array.isArray(e.byRole))throw new a("A loaded canonical pivot result requires its role-scoped column key map.");const o=e,t=new Set(["groupby","metric","pivotby","detail"]);for(const[n,r]of Object.entries(o.byRole)){if(!t.has(n)||!r||typeof r!="object"||Array.isArray(r))throw new a(`Canonical pivot role map contains invalid "${n}" bindings.`);for(const[i,s]of Object.entries(r))if(!i||!s||typeof s!="object"||Array.isArray(s)||s.role!==n||typeof s.rawKey!="string"||!s.rawKey||s.outputKey!==void 0&&(typeof s.outputKey!="string"||!s.outputKey))throw new a(`Canonical pivot role map contains an invalid "${n}:${i}" binding.`)}if(o.byMetricAlias!==void 0){if(!o.byMetricAlias||typeof o.byMetricAlias!="object"||Array.isArray(o.byMetricAlias))throw new a("Canonical pivot metric-alias bindings must be an object.");for(const[n,r]of Object.entries(o.byMetricAlias))if(!n||!r||typeof r!="object"||Array.isArray(r)||r.role!=="metric"||typeof r.rawKey!="string"||!r.rawKey||r.outputKey!==void 0&&(typeof r.outputKey!="string"||!r.outputKey))throw new a(`Canonical pivot metric-alias map contains an invalid "${n}" binding.`)}return o}function Y(e){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))throw new a("Canonical pivot column metadata must be an object.");for(const[o,t]of Object.entries(e)){if(!o||!t||typeof t!="object"||Array.isArray(t))throw new a(`Canonical pivot column metadata contains an invalid "${o}" classification.`);const{isSubtotal:n,subtotalScope:r}=t;if(n!==void 0&&typeof n!="boolean"||r!==void 0&&r!=="base"&&r!=="pivot-value"&&r!=="grand-total"||n===!0&&r!=="pivot-value"&&r!=="grand-total"||(r==="pivot-value"||r==="grand-total")&&n!==!0||r==="base"&&n===!0)throw new a(`Canonical pivot column metadata contains an incoherent "${o}" subtotal classification.`)}return e}function A(e,o){if(!Array.isArray(e)||e.some(t=>typeof t!="string"||!t)||new Set(e).size!==e.length)throw new a(`Canonical pivot contract ${o} must be an array of unique field identities.`);return e}function Z(e,o){if(!e||typeof e!="object"||Array.isArray(e)||e.version!==1)throw new a("A canonical pivot result requires its versioned result contract.");const t=e,n=t.expectedRoleFieldIds;if(!n||typeof n!="object"||Array.isArray(n))throw new a("Canonical pivot contract role identities must be an object.");const i=Object.fromEntries(["groupby","metric","pivotby","detail"].map(d=>[d,A(n[d],`expectedRoleFieldIds.${d}`)])),s=A(t.expectedMetricAliases,"expectedMetricAliases"),c=t.columnKinds;if(!c||typeof c!="object"||Array.isArray(c))throw new a("Canonical pivot contract column kinds must be an object.");const m=new Set(["row","pivot_metric","value"]),f=o.map(d=>d.key),l=Object.keys(c);if(l.length!==f.length||l.some(d=>!f.includes(d)||!m.has(c[d])))throw new a("Canonical pivot contract must classify every authoritative result column exactly once.");const I=Y(t.columnClassifications);if(Object.keys(I).some(d=>!f.includes(d)))throw new a("Canonical pivot contract contains a classification for an unknown result column.");return{version:1,expectedRoleFieldIds:i,expectedMetricAliases:s,columnKinds:c,columnClassifications:I}}function E(e,o){const t=["groupby","metric","pivotby","detail"];for(const i of t){const s=new Set(o.expectedRoleFieldIds[i]??[]),c=Object.keys(e.byRole[i]??{});if(c.length!==s.size||c.some(m=>!s.has(m)))throw new a(`The role-scoped ${i} bindings do not match the authored result fields.`)}const n=new Set(o.expectedMetricAliases),r=Object.keys(e.byMetricAlias??{});if(r.length!==n.size||r.some(i=>!n.has(i)))throw new a("The metric-alias bindings do not match the authored metric instances.")}function ee(e){if(!Array.isArray(e)||e.some(o=>!o||typeof o!="object"||Array.isArray(o)))throw new a("Canonical pivot records must be an array of row objects.");return e}function te(e,o){e.forEach((t,n)=>{o.forEach(r=>{if(!Object.prototype.hasOwnProperty.call(t,r.key)||t[r.key]===void 0)throw new a(`Canonical pivot column "${r.key}" is absent from row ${n}.`)})})}function oe(e,o,t){const n=new Set(o.map(r=>r.key));["groupby","detail"].forEach(r=>{Object.entries(e.byRole[r]??{}).forEach(([i,s])=>{const c=s.outputKey||s.rawKey;if(!n.has(c)||t.columnKinds[c]!=="row")throw new a(`The role-scoped ${r} binding for "${i}" does not name an authoritative result column.`)})})}function $(e,o){o.forEach(t=>{const n=e.columnKinds[t.key];if(n==="pivot_metric"&&t.pivotIdentity===void 0)throw new a(`Physical pivot result column "${t.key}" is missing its identity.`);if(n!=="pivot_metric"&&t.pivotIdentity!==void 0)throw new a(`Canonical pivot result column "${t.key}" carries pivot identity outside the physical pivot projection.`)})}function j(e){const o=ee(e.records),t=X(e.columns),n=Z(e.pivotResultContract,t),r=n.expectedRoleFieldIds.pivotby??[];if(e.pivotResultState==="loaded_empty"){if(o.length!==0)throw new a("A loaded_empty pivot result cannot carry records.");if(t.some(m=>n.columnKinds[m.key]==="pivot_metric"))throw new a("A loaded_empty pivot result cannot carry physical pivot columns.");$(n,t);const c=C(e.columnKeyMap);return E(c,n),{pivotResultState:"loaded_empty",records:[],columns:t,columnKeyMap:c,pivotResultContract:n}}if(e.pivotResultState!=="loaded_valid")throw new a("A canonical pivot result must declare loaded_empty or loaded_valid.");if(o.length===0)throw new a("A loaded_valid pivot result must carry at least one record.");const i=C(e.columnKeyMap);E(i,n),oe(i,t,n),$(n,t);const s=t.filter(c=>n.columnKinds[c.key]==="pivot_metric");if(r.length>0&&s.length===0)throw new a("A loaded_valid pivot result is missing its physical pivot columns.");try{k.requirePivotResultColumnIdentities(s,{expectedPivotFieldIds:r,columnClassifications:n.columnClassifications})}catch(c){throw c instanceof k.PivotResultIdentityError?new a(c.message,c):c}return te(o,t),{pivotResultState:"loaded_valid",records:o,columns:t,columnKeyMap:i,pivotResultContract:n}}function re(e){const o=new Set;["groupby","detail"].forEach(i=>{Object.values(e.columnKeyMap.byRole[i]??{}).forEach(s=>{o.add(s.outputKey||s.rawKey)})});const t=new Set(e.physicalPivotColumnKeys),n=new Set(e.columns.map(i=>i.key)),r={version:1,expectedRoleFieldIds:{groupby:Array.from(new Set(e.expectedRoleFieldIds.groupby??[])),metric:Array.from(new Set(e.expectedRoleFieldIds.metric??[])),pivotby:Array.from(new Set(e.expectedRoleFieldIds.pivotby??[])),detail:Array.from(new Set(e.expectedRoleFieldIds.detail??[]))},expectedMetricAliases:[...e.expectedMetricAliases??[]],columnKinds:Object.fromEntries(e.columns.map(i=>[i.key,o.has(i.key)?"row":t.has(i.key)?"pivot_metric":"value"])),columnClassifications:Object.fromEntries(Object.entries(e.columnMetadata??{}).filter(([i])=>n.has(i)))};return j({pivotResultState:e.records.length===0?"loaded_empty":"loaded_valid",pivotResultContract:r,records:e.records,columns:e.columns,columnKeyMap:e.columnKeyMap})}exports.MissingResolvedRawTemporalFormatError=J;exports.PivotResultLifecycleError=a;exports.PresentationExecutionSnapshotError=b;exports.createCanonicalPivotResultTransport=re;exports.createPresentationExecutionSnapshot=U;exports.deriveMetricInstanceAliasExpectations=S;exports.derivePivotResultContractExpectations=W;exports.findResolvedNumericFormat=V;exports.findResolvedRawTemporalFormat=G;exports.findResolvedTemporalBucketFormat=H;exports.parseCanonicalPivotResultTransport=j;exports.parsePresentationExecutionSnapshot=F;exports.parsePresentationScope=_;exports.parseResolvedPresentationEntries=K;exports.validateCardExportPresentationSnapshot=Q;
|
package/dist/chunks/{pivot-result-lifecycle-BCoOFUiU.js → pivot-result-lifecycle-DJ40gdwk.js}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var $ = Object.defineProperty;
|
|
2
2
|
var E = (e, o, t) => o in e ? $(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t;
|
|
3
3
|
var u = (e, o, t) => E(e, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
-
import { p as _, a as K } from "./raw-temporal-
|
|
5
|
-
import { b as j } from "./report-runtime-context-
|
|
4
|
+
import { p as _, a as K } from "./raw-temporal-DHCZrFe7.js";
|
|
5
|
+
import { b as j } from "./report-runtime-context-BlDpc-F-.js";
|
|
6
6
|
import { i as f, p as F } from "./temporal-bucket-B9hMwemw.js";
|
|
7
|
-
import {
|
|
8
|
-
import "./matrix-operation-contract-
|
|
9
|
-
import { a as M } from "./metric-comparison-
|
|
10
|
-
import { a as P } from "./temporal-bucket-contract-
|
|
11
|
-
import { b as T, P as O } from "./pivot-result-identity-
|
|
7
|
+
import { a2 as S } from "./validators-D-_IT-Xw.js";
|
|
8
|
+
import "./matrix-operation-contract-0Nor-C71.js";
|
|
9
|
+
import { a as M } from "./metric-comparison-Br8l0WkK.js";
|
|
10
|
+
import { a as P } from "./temporal-bucket-contract-C-kKQ_W4.js";
|
|
11
|
+
import { b as T, P as O } from "./pivot-result-identity-sZc1RaIz.js";
|
|
12
12
|
class x extends Error {
|
|
13
13
|
constructor(t) {
|
|
14
14
|
super(
|