react-semaphor 0.1.399 → 0.1.400

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.
Files changed (48) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +1 -1
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +2 -2
  5. package/dist/chunks/{analyze-result-contract-CUO5QmqV.js → analyze-result-contract-BUgK3759.js} +675 -639
  6. package/dist/chunks/analyze-result-contract-S8u7CcPL.js +1 -0
  7. package/dist/chunks/{calendar-preferences-dialog-B3fnFtJt.js → calendar-preferences-dialog-Ci3rHHgA.js} +1 -1
  8. package/dist/chunks/{calendar-preferences-dialog-9SvYDLp6.js → calendar-preferences-dialog-i3-jBIYS.js} +3 -3
  9. package/dist/chunks/{dashboard-briefing-launcher-APVyc9al.js → dashboard-briefing-launcher-BpwjeJsQ.js} +4 -4
  10. package/dist/chunks/{dashboard-briefing-launcher-D3R4R7ww.js → dashboard-briefing-launcher-DiEpMS9E.js} +1 -1
  11. package/dist/chunks/{dashboard-controls-v7jslCXR.js → dashboard-controls-BaUUrvSI.js} +1 -1
  12. package/dist/chunks/{dashboard-controls-CHDQlMZ9.js → dashboard-controls-Bkjpgr3d.js} +5 -5
  13. package/dist/chunks/{dashboard-json-L1Qo5xcX.js → dashboard-json-CxNyExRm.js} +1 -1
  14. package/dist/chunks/{dashboard-json-DF_syvRu.js → dashboard-json-DvULhhN2.js} +3 -3
  15. package/dist/chunks/{edit-dashboard-visual-DwfIWUe-.js → edit-dashboard-visual-DBrsgEtL.js} +4 -4
  16. package/dist/chunks/{edit-dashboard-visual-qdruQruO.js → edit-dashboard-visual-DJRPiKdY.js} +1 -1
  17. package/dist/chunks/{index-DH7hOGQl.js → index-BepF6hoa.js} +2 -2
  18. package/dist/chunks/{index-BdVymLVq.js → index-Drz04wqE.js} +5 -5
  19. package/dist/chunks/{switch-CYG3dY8r.js → switch-D2oOmorN.js} +1 -1
  20. package/dist/chunks/{switch-BiU6-YSY.js → switch-qUw8u-gU.js} +1 -1
  21. package/dist/chunks/update-policy-BmtOqvbf.js +3 -0
  22. package/dist/chunks/update-policy-KImUg4Od.js +831 -0
  23. package/dist/chunks/{use-create-flow-overlay-state-CwUkhLBL.js → use-create-flow-overlay-state-CFJIHt5D.js} +3 -3
  24. package/dist/chunks/{use-create-flow-overlay-state-qe7DHQKr.js → use-create-flow-overlay-state-DrkYiyQz.js} +1 -1
  25. package/dist/dashboard/index.cjs +1 -1
  26. package/dist/dashboard/index.js +1 -1
  27. package/dist/dashboard-authoring/index.cjs +1 -1
  28. package/dist/dashboard-authoring/index.js +1 -1
  29. package/dist/data-app-builder/index.cjs +1 -1
  30. package/dist/data-app-builder/index.js +2 -2
  31. package/dist/data-app-codegen/index.cjs +1 -0
  32. package/dist/data-app-codegen/index.js +22 -0
  33. package/dist/data-app-codegen-node/index.cjs +462 -0
  34. package/dist/data-app-codegen-node/index.js +1424 -0
  35. package/dist/data-app-sdk/index.cjs +1 -1
  36. package/dist/data-app-sdk/index.js +1 -1
  37. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  38. package/dist/data-app-sdk-adapters/index.js +1 -1
  39. package/dist/data-app-sdk-validation/index.cjs +1 -1
  40. package/dist/data-app-sdk-validation/index.js +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.js +7 -7
  43. package/dist/surfboard/index.cjs +1 -1
  44. package/dist/surfboard/index.js +2 -2
  45. package/dist/types/data-app-codegen-node.d.ts +1165 -0
  46. package/dist/types/data-app-codegen.d.ts +1137 -0
  47. package/package.json +9 -1
  48. package/dist/chunks/analyze-result-contract-OqFtOCpZ.js +0 -1
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.399",
8
+ "version": "0.1.400",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -84,6 +84,14 @@
84
84
  "import": "./dist/data-app-sdk-validation/index.js",
85
85
  "require": "./dist/data-app-sdk-validation/index.cjs"
86
86
  },
87
+ "./data-app-codegen": {
88
+ "types": "./dist/types/data-app-codegen.d.ts",
89
+ "import": "./dist/data-app-codegen/index.js"
90
+ },
91
+ "./data-app-codegen/node": {
92
+ "types": "./dist/types/data-app-codegen-node.d.ts",
93
+ "import": "./dist/data-app-codegen-node/index.js"
94
+ },
87
95
  "./data-app-builder": {
88
96
  "types": "./dist/types/data-app-builder.d.ts",
89
97
  "import": "./dist/data-app-builder/index.js",
@@ -1 +0,0 @@
1
- "use strict";const e=require("zod"),q={answerSummary:"string",responseDetail:"responseDetail",mode:"string",comparisonType:"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"},I="semaphor-data-app-codegen-summary/v1",_e="semaphor-data-app-codegen-summary-validator/v2",Ie=new Set(["metric","records","matrix","analysis","sql_fallback"]),je=new Set(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]),Ce=new Set(["absolute_delta","largest_negative","largest_positive","positive_and_negative","all"]),te=new Set(["source","id","label","measures","primaryMeasure","dateField","timeGrain","dimensions","comparison","orderBy","filters","relationshipHint","limit","derivedFields"]),qe=new Set([...te,"analysis","timeWindow","filters","driverMode","includePopulation","calendarContext","chartTitle","chartType"]),xe=new Set(["source","id","label","fields","dateField","timeGrain","timeWindow","filters","orderBy","relationshipHint","limit","pagination","totals","derivedFields"]),Ee=new Set(["source","id","label","filters","relationshipHint","rows","columns","values","totals","sort","expansion","layout","displayLimits"]),Fe=new Set(["source","id","label","sql","defaultParameters","pythonCode","fields","limit","pagination","rationale"]),Te=new Set(["kpi","line_chart","bar_chart","stacked_bar_chart","pie_chart","donut_chart","area_chart","table","matrix","narrative","text_block","custom"]),De=new Set(["missing_measure","missing_dimension","missing_date","missing_relationship","missing_semantic_role","missing_current_app_state","unsupported_change_intent","ambiguous_field_grounding","invalid_ranker_output","latest_snapshot_selector_not_modeled","unsupported_grain","requires_sql_escape_hatch","unsupported_sdk_capability"]);function Ne(i){return P(i).ok}function P(i){const t=[];if(!i||typeof i!="object")return{ok:!1,issues:["Summary must be an object."]};const o=i;return o.schemaVersion!==I&&t.push(`schemaVersion must be ${I}.`),(typeof o.title!="string"||!o.title.trim())&&t.push("title is required."),Array.isArray(o.sources)||t.push("sources must be an array."),Array.isArray(o.inputs)||t.push("inputs must be an array."),Array.isArray(o.views)||t.push("views must be an array."),Array.isArray(o.filterContracts)||t.push("filterContracts must be an array."),(!o.implementationChecklist||typeof o.implementationChecklist!="object")&&t.push("implementationChecklist must be an object."),o.implementationChecklist&&typeof o.implementationChecklist=="object"&&t.push(...Me(o.implementationChecklist)),Array.isArray(o.sources)&&o.sources.forEach((s,r)=>{t.push(...$(s,`sources.${r}`))}),Array.isArray(o.inputs)&&o.inputs.forEach((s,r)=>{t.push(...Ke(s,`inputs.${r}`))}),Array.isArray(o.views)&&o.views.forEach((s,r)=>{t.push(...Pe(s,`views.${r}`))}),Array.isArray(o.filterContracts)&&o.filterContracts.forEach((s,r)=>{t.push(...Ge(s,`filterContracts.${r}`))}),o.unsupportedInsights!==void 0&&(Array.isArray(o.unsupportedInsights)?o.unsupportedInsights.forEach((s,r)=>{t.push(...po(s,`unsupportedInsights.${r}`))}):t.push("unsupportedInsights must be an array.")),t.push(...Oe(o)),{ok:t.length===0,issues:t}}function Oe(i){const t=Array.isArray(i.unsupportedInsights)&&i.unsupportedInsights.some(l=>{var u;return((u=a(l))==null?void 0:u.reason)==="missing_relationship"}),o=Array.isArray(i.views)&&i.views.some(l=>{var p;const u=a((p=a(l))==null?void 0:p.computation);return(u==null?void 0:u.kind)==="unsupported"&&u.reason==="missing_relationship"});if(!t&&!o)return[];const s=[],r=a(i.validation);(r==null?void 0:r.status)!=="blocked"&&s.push("validation.status must be blocked when missing_relationship gaps are present.");const n=a(i.nextRequiredTool);return(n==null?void 0:n.name)!=="semaphor_propose_semantic_model_change"&&s.push("nextRequiredTool.name must be semaphor_propose_semantic_model_change when missing_relationship gaps are present."),s}function $(i,t){const o=a(i);return o?o.kind==="semantic"?typeof o.domainId=="string"&&o.domainId.trim()&&typeof o.datasetName=="string"&&o.datasetName.trim()?[]:[`${t} must include sourceKey or a supported source identity.`]:typeof o.sourceKey=="string"&&o.sourceKey.trim()?[]:o.kind==="physical"&&typeof o.tableName=="string"&&o.tableName.trim()&&typeof o.connectionId=="string"&&o.connectionId.trim()?[]:o.kind==="sql"&&typeof o.connectionId=="string"&&o.connectionId.trim()?[]:[`${t} must include sourceKey or a supported source identity.`]:[`${t} must be an object.`]}function Me(i){const t=a(i);if(!t)return["implementationChecklist must be an object."];const o=[],s=["requiredDevtools","requiredInputOptions","filterScopeByInput","bindingsByView","validationCommands","browserSmokeChecks"];for(const n of s)n in t||o.push(`implementationChecklist.${n} is required.`);const r=a(t.requiredDevtools);return r?typeof r.mountRootDevtools!="boolean"&&o.push("implementationChecklist.requiredDevtools.mountRootDevtools must be a boolean."):o.push("implementationChecklist.requiredDevtools must be an object."),Array.isArray(t.requiredInputOptions)||o.push("implementationChecklist.requiredInputOptions must be an array."),Array.isArray(t.filterScopeByInput)||o.push("implementationChecklist.filterScopeByInput must be an array."),a(t.bindingsByView)||o.push("implementationChecklist.bindingsByView must be an object."),g(t.validationCommands)||o.push("implementationChecklist.validationCommands must be an array of strings."),g(t.browserSmokeChecks)||o.push("implementationChecklist.browserSmokeChecks must be an array of strings."),o}function Ke(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];return(typeof o.id!="string"||!o.id.trim())&&s.push(`${t}.id is required.`),o.fieldRef&&s.push(...d(o.fieldRef,`${t}.fieldRef`)),s.push(...se(o.optionQuery,`${t}.optionQuery`)),g(o.appliesToViewIds)||s.push(`${t}.appliesToViewIds must be an array of strings.`),o.bindings!==void 0&&!Array.isArray(o.bindings)&&s.push(`${t}.bindings must be an array.`),Array.isArray(o.bindings)&&o.bindings.forEach((r,n)=>{const l=a(r);if(!l){s.push(`${t}.bindings.${n} must be an object.`);return}g(l.appliesToViewIds)||s.push(`${t}.bindings.${n}.appliesToViewIds must be an array of strings.`),s.push(...d(l.fieldRef,`${t}.bindings.${n}.fieldRef`))}),s}function Pe(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];if((typeof o.id!="string"||!o.id.trim())&&s.push(`${t}.id is required.`),o.visualSpec!==void 0&&s.push(...io(o.visualSpec,`${t}.visualSpec`)),o.computation!==void 0&&s.push(...co(o.computation,`${t}.computation`)),so(o))return o.fields!==void 0&&(Array.isArray(o.fields)?o.fields.forEach((n,l)=>{s.push(...d(n,`${t}.fields.${l}`))}):s.push(`${t}.fields must be an array.`)),o.queryKind!==void 0&&s.push(`${t}.queryKind is not allowed for non-executable views.`),o.sdkBuilder!==void 0&&s.push(`${t}.sdkBuilder is not allowed for non-executable views.`),o.sdkSpec!==void 0&&s.push(`${t}.sdkSpec is not allowed for non-executable views.`),s;if(!Array.isArray(o.fields))return s.push(`${t}.fields must be an array.`),(o.sdkSpec!==void 0||o.sdkBuilder!==void 0)&&s.push(`${t}.fields must be an array for executable views.`),s;o.fields.forEach((n,l)=>{s.push(...d(n,`${t}.fields.${l}`))}),v(o.queryKind)||s.push(`${t}.queryKind must be a supported codegen query kind.`),o.sdkBuilder!==void 0&&!re(o.sdkBuilder)&&s.push(`${t}.sdkBuilder must be a supported SDK builder.`);const r=a(o.computation);return(r==null?void 0:r.kind)==="server_query"&&v(o.queryKind)&&v(r.queryKind)&&r.queryKind!==o.queryKind&&s.push(`${t}.computation.queryKind must match queryKind.`),s.push(...He({value:o.sdkSpec,path:`${t}.sdkSpec`,queryKind:typeof o.queryKind=="string"?o.queryKind:void 0,sdkBuilder:typeof o.sdkBuilder=="string"?o.sdkBuilder:void 0}),...Be(o,`${t}`)),s}function Be(i,t){var W,Z;const o=a((W=a(i.visualSpec))==null?void 0:W.tableBehavior);if(!o)return[];const s=a(o.totals);if(!s)return[];const r=a(i.sdkSpec),n=a(r==null?void 0:r.spec),l=a(n==null?void 0:n.totals),u=[],p=typeof(r==null?void 0:r.builder)=="string"?r.builder:void 0,Re=(Z=a(o.pagination))==null?void 0:Z.mode;return s.mode==="server"&&(p!=="semaphor.records"&&u.push(`${t}.visualSpec.tableBehavior.totals.mode server is only supported for semaphor.records views.`),!l||l.mode!=="server"?u.push(`${t}.sdkSpec.spec.totals.mode must be server when tableBehavior.totals.mode is server.`):u.push(...Ve({left:s.measures,right:l.measures,leftPath:`${t}.visualSpec.tableBehavior.totals.measures`,rightPath:`${t}.sdkSpec.spec.totals.measures`}))),s.mode!=="server"&&l&&u.push(`${t}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),s.mode==="local"&&Re==="server"&&u.push(`${t}.visualSpec.tableBehavior.totals.mode must not be local for server-paginated tables.`),p==="semaphor.sql"&&s.mode!=="none"&&u.push(`${t}.visualSpec.tableBehavior.totals.mode must be none for semaphor.sql views.`),p==="semaphor.sql"&&l&&u.push(`${t}.sdkSpec.spec.totals is not supported for semaphor.sql.`),u}function Ve({left:i,right:t,leftPath:o,rightPath:s}){if(!Array.isArray(i)||!Array.isArray(t))return[`${s} must match ${o}.`];const r=[];return i.length!==t.length?(r.push(`${s} must match ${o}.`),r):(i.forEach((n,l)=>{Le(a(n),a(t[l]))||r.push(`${s}.${l} must match ${o}.${l}.`)}),r)}function Le(i,t){return!i||!t?!1:i.name===t.name&&(i.role||"measure")===(t.role||"measure")&&X(i)===X(t)&&Ue(i,t)}function X(i){return typeof i.aggregate=="string"?i.aggregate.toUpperCase():"SUM"}function Ue(i,t){const o=typeof i.sourceKey=="string"?i.sourceKey:void 0,s=typeof t.sourceKey=="string"?t.sourceKey:void 0;if(o||s)return o===s;const r=a(i.source),n=a(t.source);return!r||!n||r.kind!==n.kind?!1:r.kind==="semantic"?r.domainId===n.domainId&&r.datasetName===n.datasetName&&(r.datasetId===void 0||n.datasetId===void 0||r.datasetId===n.datasetId):r.kind==="physical"?r.connectionId===n.connectionId&&r.tableName===n.tableName:r.kind==="sql"?r.connectionId===n.connectionId:!1}function Ge(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];if(o.fieldRef&&s.push(...d(o.fieldRef,`${t}.fieldRef`)),(typeof o.inputId!="string"||!o.inputId.trim())&&s.push(`${t}.inputId is required.`),s.push(...se(o.optionQuery,`${t}.optionQuery`)),g(o.appliesToViewIds)||s.push(`${t}.appliesToViewIds must be an array of strings.`),g(o.notAppliedToViewIds)||s.push(`${t}.notAppliedToViewIds must be an array of strings.`),!Array.isArray(o.bindings))s.push(`${t}.bindings must be an array.`);else{const r=g(o.appliesToViewIds)?new Set(o.appliesToViewIds):void 0,n=g(o.notAppliedToViewIds)?new Set(o.notAppliedToViewIds):void 0;o.bindings.forEach((l,u)=>{const p=a(l);if(!p){s.push(`${t}.bindings.${u} must be an object.`);return}typeof p.viewId!="string"||!p.viewId?s.push(`${t}.bindings.${u}.viewId is required.`):(r&&!r.has(p.viewId)&&s.push(`${t}.bindings.${u}.viewId must be included in appliesToViewIds.`),n!=null&&n.has(p.viewId)&&s.push(`${t}.bindings.${u}.viewId must not be listed in notAppliedToViewIds.`)),s.push(...d(p.fieldRef,`${t}.bindings.${u}.fieldRef`))})}return s}function se(i,t){if(i===void 0)return[];const o=a(i);if(!o)return[`${t} must be an object.`];const s=[...h(o.valueFieldRef,`${t}.valueFieldRef`),...h(o.labelFieldRef,`${t}.labelFieldRef`),...h(o.filterFieldRef,`${t}.filterFieldRef`)];return o.builder!=="semaphor.inputOptions"&&s.push(`${t}.builder must be semaphor.inputOptions.`),typeof o.sourceKey!="string"&&o.source===void 0&&s.push(`${t} must include source or sourceKey.`),o.source!==void 0&&s.push(...$(o.source,`${t}.source`)),a(o.valueFieldRef)||s.push(`${t}.valueFieldRef is required.`),a(o.labelFieldRef)||s.push(`${t}.labelFieldRef is required.`),o.limit!==void 0&&(typeof o.limit!="number"||!Number.isInteger(o.limit)||o.limit<=0)&&s.push(`${t}.limit must be a positive integer.`),s}function He(i){var r;const t=a(i.value);if(!t)return[`${i.path} is required for executable views.`];const o=[];if(!re(t.builder))return o.push(`${i.path}.builder must be a supported SDK builder.`),o;i.sdkBuilder&&t.builder!==i.sdkBuilder&&o.push(`${i.path}.builder must match sdkBuilder.`),i.queryKind&&v(i.queryKind)&&t.builder!==to(i.queryKind)&&o.push(`${i.path}.builder must match queryKind.`);const s=a(t.spec);if(!s)return o.push(`${i.path}.spec must be an object.`),o;switch(t.builder){case"semaphor.metric":o.push(...S(s,te,`${i.path}.spec`),...k(s,i.path),...N(s.measures,`${i.path}.spec.measures`),...h(s.primaryMeasure,`${i.path}.spec.primaryMeasure`),...h(s.dateField,`${i.path}.spec.dateField`),...O(s.dimensions,`${i.path}.spec.dimensions`),...M(s.orderBy,`${i.path}.spec.orderBy`),...R(s.filters,`${i.path}.spec.filters`));break;case"semaphor.analysis":o.push(...S(s,qe,`${i.path}.spec`),...k(s,i.path),...N(s.measures,`${i.path}.spec.measures`),...h(s.primaryMeasure,`${i.path}.spec.primaryMeasure`),...h(s.dateField,`${i.path}.spec.dateField`),...O(s.dimensions,`${i.path}.spec.dimensions`),...M(s.orderBy,`${i.path}.spec.orderBy`),...R(s.filters,`${i.path}.spec.filters`),...Qe(s,`${i.path}.spec`));break;case"semaphor.records":o.push(...S(s,xe,`${i.path}.spec`),...k(s,i.path),...N(s.fields,`${i.path}.spec.fields`),...h(s.dateField,`${i.path}.spec.dateField`),...M(s.orderBy,`${i.path}.spec.orderBy`),...R(s.filters,`${i.path}.spec.filters`),...Ye(s.totals,`${i.path}.spec.totals`));break;case"semaphor.matrix":o.push(...S(s,Ee,`${i.path}.spec`),...We(s,i.path),...Ze(s.rows,`${i.path}.spec.rows`),...Xe(s.columns,`${i.path}.spec.columns`),...Je(s.values,`${i.path}.spec.values`),...eo(s.sort,`${i.path}.spec.sort`),...R(s.filters,`${i.path}.spec.filters`));break;case"semaphor.sql":o.push(...S(s,Fe,`${i.path}.spec`),...k(s,i.path)),((r=a(s.source))==null?void 0:r.kind)!=="sql"&&o.push(`${i.path}.spec.source.kind must be sql.`),(typeof s.sql!="string"||!s.sql.trim())&&o.push(`${i.path}.spec.sql is required.`),o.push(...O(s.fields,`${i.path}.spec.fields`));break}return o}function Qe(i,t){const o=[];if(i.driverMode!==void 0&&!Ce.has(i.driverMode)&&o.push(`${t}.driverMode must be a supported analysis driver mode.`),i.includePopulation!==void 0&&typeof i.includePopulation!="boolean"&&o.push(`${t}.includePopulation must be a boolean.`),i.calendarContext!==void 0){const s=a(i.calendarContext);if(!s)o.push(`${t}.calendarContext must be an object.`);else{s.tz!==void 0&&typeof s.tz!="string"&&o.push(`${t}.calendarContext.tz must be a string.`),s.weekStart!==void 0&&(typeof s.weekStart!="number"||!Number.isInteger(s.weekStart)||s.weekStart<0||s.weekStart>6)&&o.push(`${t}.calendarContext.weekStart must be an integer between 0 and 6.`);const r=s.anchor;if(r!==void 0&&r!=="now"){const n=a(r);(!n||typeof n.iso!="string"||!n.iso.trim())&&o.push(`${t}.calendarContext.anchor must be now or { iso }.`)}}}return o}function Ye(i,t){if(i===void 0)return[];const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];return o.mode!=="server"&&s.push(`${t}.mode must be server.`),!Array.isArray(o.measures)||o.measures.length===0?s.push(`${t}.measures must include at least one measure.`):o.measures.forEach((r,n)=>{var l;s.push(...ne(r,`${t}.measures.${n}`)),((l=a(r))==null?void 0:l.role)!=="measure"&&s.push(`${t}.measures.${n}.role must be measure.`)}),s}function S(i,t,o){const s=[];return Object.keys(i).forEach(r=>{t.has(r)||s.push(`${o}.${r} is not supported for this SDK builder.`)}),s}function k(i,t){return a(i.source)?$(i.source,`${t}.spec.source`):[`${t}.spec.source must be an object.`]}function We(i,t){const o=a(i.source);if(!o)return[`${t}.spec.source must be an object.`];const s=$(i.source,`${t}.spec.source`);return o.kind!=="semantic"&&o.kind!=="physical"&&s.push(`${t}.spec.source.kind must be semantic or physical.`),s}function N(i,t){const o=B(i,t);return Array.isArray(i)&&i.forEach((s,r)=>{o.push(...d(s,`${t}.${r}`))}),o}function O(i,t){if(i===void 0)return[];if(!Array.isArray(i))return[`${t} must be an array.`];const o=[];return i.forEach((s,r)=>{o.push(...d(s,`${t}.${r}`))}),o}function M(i,t){if(i===void 0)return[];const o=a(i);return o?[...d(o.field,`${t}.field`),...ie(o.direction,`${t}.direction`)]:[`${t} must be an object.`]}function Ze(i,t){const o=B(i,t);return Array.isArray(i)&&i.forEach((s,r)=>{const n=a(s);if(!n){o.push(`${t}.${r} must be an object.`);return}o.push(...d(n.field,`${t}.${r}.field`))}),o}function Xe(i,t){if(i===void 0)return[];const o=[];return Array.isArray(i)?(i.forEach((s,r)=>{const n=a(s);if(!n){o.push(`${t}.${r} must be an object.`);return}o.push(...d(n.field,`${t}.${r}.field`))}),o):[`${t} must be an array.`]}function Je(i,t){const o=B(i,t);return Array.isArray(i)&&i.forEach((s,r)=>{const n=a(s);if(!n){o.push(`${t}.${r} must be an object.`);return}o.push(...d(n.field,`${t}.${r}.field`))}),o}function eo(i,t){if(i===void 0)return[];if(!Array.isArray(i))return[`${t} must be an array.`];const o=[];return i.forEach((s,r)=>{const n=a(s);if(!n){o.push(`${t}.${r} must be an object.`);return}n.axis!=="row"&&n.axis!=="column"&&o.push(`${t}.${r}.axis must be row or column.`),o.push(...ie(n.direction,`${t}.${r}.direction`),...oo(n.by,`${t}.${r}.by`))}),o}function oo(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];switch(o.kind){case"label":return[];case"field":return d(o.field,`${t}.field`);case"value":return typeof o.valueId!="string"||!o.valueId.trim()?[`${t}.valueId is required.`]:[];default:return[`${t}.kind must be label, field, or value.`]}}function ie(i,t){return i==="asc"||i==="desc"?[]:[`${t} must be asc or desc.`]}function R(i,t){if(i===void 0)return[];if(!Array.isArray(i))return[`${t} must be an array.`];const o=[];return i.forEach((s,r)=>{const n=a(s);if(!n){o.push(`${t}.${r} must be an object.`);return}o.push(...d(n.field,`${t}.${r}.field`))}),o}function B(i,t){return!Array.isArray(i)||i.length===0?[`${t} must be a non-empty array.`]:[]}function to(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 so(i){const t=a(i.computation),o=a(i.visualSpec);return(t==null?void 0:t.kind)==="presentation_only"||(t==null?void 0:t.kind)==="derived"||(t==null?void 0:t.kind)==="unsupported"||i.visual==="text_block"||(o==null?void 0:o.visualType)==="text_block"}function io(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];return Te.has(o.visualType)||s.push(`${t}.visualType must be a supported visual type.`),o.limit!==void 0&&(typeof o.limit!="number"||!Number.isInteger(o.limit)||o.limit<=0)&&s.push(`${t}.limit must be a positive integer.`),o.tableBehavior!==void 0&&s.push(...ro(o.tableBehavior,`${t}.tableBehavior`)),s}function ro(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];return o.tableMode!=="bounded"&&o.tableMode!=="server_paginated"&&o.tableMode!=="server_windowed"&&s.push(`${t}.tableMode must be a supported table mode.`),s.push(...no(o.height,`${t}.height`),...ao(o.pagination,`${t}.pagination`),...lo(o.sorting,`${t}.sorting`),...uo(o.totals,`${t}.totals`)),typeof o.serverSideRequired!="boolean"&&s.push(`${t}.serverSideRequired must be a boolean.`),s}function no(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];return(typeof o.maxPx!="number"||!Number.isInteger(o.maxPx)||o.maxPx<=0)&&s.push(`${t}.maxPx must be a positive integer.`),o.scroll!=="vertical"&&o.scroll!=="both"&&s.push(`${t}.scroll must be vertical or both.`),typeof o.stickyHeader!="boolean"&&s.push(`${t}.stickyHeader must be a boolean.`),s}function ao(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];return o.mode!=="none"&&o.mode!=="server"&&o.mode!=="client_for_bounded_rows"&&s.push(`${t}.mode must be a supported pagination mode.`),o.pageSize!==void 0&&(typeof o.pageSize!="number"||!Number.isInteger(o.pageSize)||o.pageSize<=0)&&s.push(`${t}.pageSize must be a positive integer.`),o.readsFrom!==void 0&&o.readsFrom!=="result.pagination"&&s.push(`${t}.readsFrom must be result.pagination.`),s}function lo(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];return o.mode!=="server"&&o.mode!=="client_for_bounded_rows"&&s.push(`${t}.mode must be a supported sorting mode.`),o.defaultField!==void 0&&(typeof o.defaultField!="string"||!o.defaultField.trim())&&s.push(`${t}.defaultField must be a non-empty string.`),o.defaultDirection!==void 0&&o.defaultDirection!=="asc"&&o.defaultDirection!=="desc"&&s.push(`${t}.defaultDirection must be asc or desc.`),o.resetPageOnChange!==void 0&&typeof o.resetPageOnChange!="boolean"&&s.push(`${t}.resetPageOnChange must be a boolean.`),s}function uo(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];return o.mode!=="none"&&o.mode!=="server"&&o.mode!=="local"?(s.push(`${t}.mode must be none, server, or local.`),s):o.mode==="none"?(o.measures!==void 0&&s.push(`${t}.measures is not allowed when mode is none.`),o.label!==void 0&&s.push(`${t}.label is not allowed when mode is none.`),s):o.mode==="server"?(!Array.isArray(o.measures)||o.measures.length===0?s.push(`${t}.measures must include at least one measure when mode is server.`):o.measures.forEach((r,n)=>{var l;s.push(...ne(r,`${t}.measures.${n}`)),((l=a(r))==null?void 0:l.role)!=="measure"&&s.push(`${t}.measures.${n}.role must be measure.`)}),o.label!==void 0&&s.push(`${t}.label is not allowed when mode is server.`),s):(o.mode==="local"&&(o.label!=="Displayed rows"&&o.label!=="Current page"&&s.push(`${t}.label must be Displayed rows or Current page when mode is local.`),o.measures!==void 0&&s.push(`${t}.measures is not allowed when mode is local.`)),s)}function co(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];switch(o.kind){case"server_query":v(o.queryKind)||s.push(`${t}.queryKind must be a supported codegen query kind.`),o.queryOwnership!==void 0&&o.queryOwnership!=="view_owned"&&o.queryOwnership!=="shared_query"&&s.push(`${t}.queryOwnership must be view_owned or shared_query.`),o.sourceKeys!==void 0&&!g(o.sourceKeys)&&s.push(`${t}.sourceKeys must be an array of strings.`),o.fieldNames!==void 0&&!g(o.fieldNames)&&s.push(`${t}.fieldNames must be an array of strings.`);break;case"derived":(typeof o.upstreamViewId!="string"||!o.upstreamViewId.trim())&&s.push(`${t}.upstreamViewId is required.`),(typeof o.derivation!="string"||!o.derivation.trim())&&s.push(`${t}.derivation is required.`);break;case"presentation_only":break;case"unsupported":(typeof o.reason!="string"||!o.reason.trim())&&s.push(`${t}.reason is required.`),(typeof o.suggestedModelingFix!="string"||!o.suggestedModelingFix.trim())&&s.push(`${t}.suggestedModelingFix is required.`);break;default:s.push(`${t}.kind must be a supported computation kind.`)}return s}function po(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];for(const n of["title","requestedQuestion","suggestedModelingFix"])(typeof o[n]!="string"||!o[n].trim())&&s.push(`${t}.${n} is required.`);return De.has(o.reason)||s.push(`${t}.reason must be a supported unsupported insight reason.`),(o.relationshipCandidate!==void 0||o.nextRepairAction!==void 0)&&o.reason!=="missing_relationship"&&s.push(`${t} relationship repair metadata is only valid for missing_relationship unsupported insights.`),o.relationshipCandidate!==void 0&&s.push(...go(o.relationshipCandidate,`${t}.relationshipCandidate`)),o.nextRepairAction!==void 0&&s.push(...mo(o.nextRepairAction,`${t}.nextRepairAction`)),s}function mo(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[],r=new Set(["tool","reason"]);return Object.keys(o).forEach(n=>{r.has(n)||s.push(`${t}.${n} is not supported; repair actions support only tool and reason.`)}),o.tool!=="semaphor_propose_semantic_model_change"&&s.push(`${t}.tool must be semaphor_propose_semantic_model_change.`),o.reason!=="missing_relationship"&&s.push(`${t}.reason must be missing_relationship.`),s}function go(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[],r=new Set(["source","sourceFields","target","targetFields"]);Object.keys(o).forEach(n=>{r.has(n)||s.push(`${t}.${n} is not supported; relationship candidates support only source, sourceFields, target, and targetFields.`)}),s.push(...J(o.source,`${t}.source`)),s.push(...J(o.target,`${t}.target`));for(const n of["sourceFields","targetFields"]){const l=o[n];if(!Array.isArray(l)||l.length===0){s.push(`${t}.${n} must be a non-empty endpoint field array.`);continue}l.forEach((u,p)=>{s.push(...ho(u,`${t}.${n}.${p}`))})}return s}function ho(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[],r=new Set(["name","label","role","dataType"]);return Object.keys(o).forEach(n=>{r.has(n)||s.push(`${t}.${n} is not supported; relationship candidate fields are scoped by their endpoint and support only name, label, role, and dataType.`)}),(typeof o.name!="string"||!o.name.trim())&&s.push(`${t}.name must be a non-empty string.`),o.role!==void 0&&(typeof o.role!="string"||!["dimension","measure","date","id","unknown"].includes(o.role))&&s.push(`${t}.role must be dimension, measure, date, id, or unknown.`),o.dataType!==void 0&&(typeof o.dataType!="string"||!["string","number","boolean","date","datetime","unknown"].includes(o.dataType))&&s.push(`${t}.dataType must be string, number, boolean, date, datetime, or unknown.`),s}function J(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[],r=new Set(["kind","domainId","datasetName","datasetId","label","sourceKey"]);return Object.keys(o).forEach(n=>{r.has(n)||s.push(`${t}.${n} is not supported; relationship candidate sources support only semantic identity fields.`)}),o.kind!=="semantic"&&s.push(`${t} must use semantic source identity.`),(typeof o.domainId!="string"||!o.domainId.trim()||typeof o.datasetName!="string"||!o.datasetName.trim())&&s.push(`${t} must include semantic domainId and datasetName.`),s}function v(i){return Ie.has(i)}function re(i){return je.has(i)}function h(i,t){return i===void 0?[]:d(i,t)}function d(i,t){const o=a(i);if(!o)return[`${t} must be an object.`];const s=[];return(typeof o.name!="string"||!o.name.trim())&&s.push(`${t}.name is required.`),!o.source&&typeof o.sourceKey!="string"&&s.push(`${t} must include source or sourceKey.`),s}function ne(i,t){const o=a(i),s=d(i,t);if(!o||typeof o.sourceKey=="string"&&o.sourceKey.trim())return s;if(o.source!==void 0){const n=$(o.source,`${t}.source`);return n.length===0||s.push(...n),s}return s.includes(`${t} must include source or sourceKey.`)||s.push(`${t} must include source or sourceKey.`),s}function a(i){return i&&typeof i=="object"&&!Array.isArray(i)?i:void 0}function g(i){return Array.isArray(i)&&i.every(t=>typeof t=="string")}const m=e.z.record(e.z.string(),e.z.unknown()),x=e.z.array(m),c=e.z.enum(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]),E=e.z.enum(["postgres","mysql","mssql","snowflake","clickhouse","bigquery","redshift","duckdb","sqlite","unknown"]),ae=e.z.enum(["hour","day","week","month","quarter","year"]),F=e.z.enum(["dimension","measure","date","id","unknown"]),T=e.z.enum(["string","number","boolean","date","datetime","unknown"]),le=e.z.enum(["semantic_model","caller_override","default_sum"]),_=e.z.union([e.z.number(),e.z.string(),e.z.null()]),K=e.z.enum(["millisecond","second","minute","hour","day"]),ue=e.z.union([e.z.object({type:e.z.enum(["number","currency","percent","percentage","scientific"]),locale:e.z.string().optional(),minimumFractionDigits:e.z.number().optional(),maximumFractionDigits:e.z.number().optional(),useGrouping:e.z.boolean().optional(),prefix:e.z.string().optional(),suffix:e.z.string().optional(),negativeStyle:e.z.enum(["minus","parentheses"]).optional(),compact:e.z.boolean().optional(),scale:e.z.number().optional(),currency:e.z.string().optional(),percentValueMode:e.z.enum(["fraction","whole"]).optional()}).passthrough(),e.z.object({type:e.z.enum(["date","datetime"]),locale:e.z.string().optional(),pattern:e.z.string().optional(),relative:e.z.boolean().optional(),timezone:e.z.string().optional(),sourceTimezone:e.z.string().optional(),prefix:e.z.string().optional(),suffix:e.z.string().optional()}).passthrough(),e.z.object({type:e.z.literal("duration"),inputUnit:K.optional(),outputStyle:e.z.enum(["compact","digital","long"]).optional(),largestUnit:K.optional(),smallestUnit:K.optional(),maxUnits:e.z.number().optional(),prefix:e.z.string().optional(),suffix:e.z.string().optional(),negativeStyle:e.z.enum(["minus","parentheses"]).optional()}).passthrough(),e.z.object({type:e.z.literal("string"),prefix:e.z.string().optional(),suffix:e.z.string().optional()}).passthrough()]),fo=e.z.union([e.z.object({kind:e.z.literal("defaultAggregate")}).passthrough(),e.z.object({kind:e.z.literal("blank")}).passthrough(),e.z.object({kind:e.z.literal("labelOnly"),label:e.z.string().optional()}).passthrough(),e.z.object({kind:e.z.literal("customAggregate"),aggregate:c}).passthrough(),e.z.object({kind:e.z.literal("percentOfParent")}).passthrough(),e.z.object({kind:e.z.literal("percentOfGrandTotal")}).passthrough(),e.z.object({kind:e.z.literal("customExpression"),expressionId:e.z.string()}).passthrough()]);function w(i,t){return e.z.object(i).passthrough().superRefine((o,s)=>{for(const r of t)Object.prototype.hasOwnProperty.call(o,r)||s.addIssue({code:"custom",path:[r],message:`Required field "${r}" is missing.`})})}const V=e.z.object({kind:e.z.literal("semantic"),domainId:e.z.string(),datasetName:e.z.string(),datasetId:e.z.string().optional(),label:e.z.string().optional(),connectionId:e.z.string().optional()}).passthrough(),ce=e.z.object({kind:e.z.literal("physical"),connectionId:e.z.string(),connectionType:e.z.string().optional(),tableName:e.z.string(),databaseName:e.z.string().optional(),schemaName:e.z.string().optional(),label:e.z.string().optional(),dialect:E.optional()}).passthrough(),de=e.z.object({kind:e.z.literal("sql"),connectionId:e.z.string(),dialect:E.optional(),label:e.z.string().optional()}).passthrough(),b=e.z.union([V,ce,de]),z=e.z.object({name:e.z.string(),label:e.z.string().optional(),role:F.optional(),dataType:T.optional(),source:b.optional(),aggregate:c.optional()}).passthrough(),zo=e.z.object({kind:e.z.literal("field"),field:z,aggregate:c.optional()}).passthrough(),L=e.z.object({kind:e.z.literal("derived_field"),name:e.z.string(),label:e.z.string(),description:e.z.string().optional(),resultRole:F,dataType:T,computeStage:e.z.enum(["row","aggregate"]),expression:e.z.string(),expressionLanguage:e.z.literal("semaphor_sql_template").optional(),inputs:e.z.record(zo),defaultAggregate:c.optional(),aggregationBehavior:e.z.enum(["additive","non_additive","ratio_of_sums","weighted","pre_aggregated","snapshot"]).optional(),aggregationStrategy:e.z.enum(["default","symmetric_aggregate","aggregate_then_join","weighted"]).optional(),format:ue.optional(),tags:e.z.array(e.z.string()).optional()}).passthrough(),D=z.and(e.z.object({semanticAggregate:c.optional(),effectiveAggregate:c.optional(),aggregateSource:le.optional(),derivedField:L.optional()}).passthrough()),bo=V,yo=e.z.object({kind:e.z.literal("physical"),connectionId:e.z.string().optional(),connectionType:e.z.string().optional(),tableName:e.z.string(),databaseName:e.z.string().optional(),schemaName:e.z.string().optional(),label:e.z.string().optional(),dialect:E.optional()}).passthrough(),So=e.z.object({kind:e.z.literal("sql"),connectionId:e.z.string().optional(),dialect:E.optional(),label:e.z.string().optional()}).passthrough(),vo=e.z.union([bo,yo,So]),$o=e.z.object({key:e.z.string().optional(),name:e.z.string(),label:e.z.string().optional(),role:F.optional(),dataType:T.optional(),source:vo.optional(),aggregate:c.optional(),semanticAggregate:c.optional(),effectiveAggregate:c.optional(),aggregateSource:le.optional(),derivedField:e.z.never().optional()}).passthrough(),j=e.z.object({key:e.z.string(),name:e.z.string(),label:e.z.string(),role:F.optional(),dataType:T.optional(),aggregate:c.optional(),source:b.optional(),derivedField:L.optional()}).passthrough(),pe=e.z.object({code:e.z.string(),message:e.z.string().optional(),invalidField:e.z.string().optional(),fieldRole:e.z.enum(["measure","date","dimension","input","source","sql"]).optional(),validMeasureCandidates:e.z.array(e.z.string()).optional(),validDateCandidates:e.z.array(e.z.string()).optional(),validDimensionCandidates:e.z.array(e.z.string()).optional(),recommendedNextStep:e.z.string()}).passthrough(),C=e.z.object({code:e.z.string(),message:e.z.string(),path:e.z.string().optional(),fieldRole:e.z.enum(["measure","date","dimension","input","source","sql"]).optional(),repairHint:pe.optional()}).passthrough(),U=e.z.object({ok:e.z.boolean(),errors:e.z.array(C),warnings:e.z.array(C),repairHints:e.z.array(pe)}).passthrough(),wo=e.z.object({page:e.z.number(),pageSize:e.z.number(),pageCount:e.z.number(),totalCount:e.z.number(),hasNextPage:e.z.boolean(),hasPrevPage:e.z.boolean()}).passthrough(),A={intentId:e.z.string().optional(),queryPath:e.z.enum(["query_spec","sql","sql_python"]),warnings:e.z.array(e.z.string()).optional(),rowCount:e.z.number().optional(),rowLimitExceeded:e.z.boolean().optional(),limit:e.z.number().optional(),pagination:wo.optional()},me=e.z.object({...A,kind:e.z.literal("metric"),value:_,measures:e.z.record(_).optional(),comparison:e.z.object({kind:e.z.enum(["previous_period","previous_year","target"]),value:_.optional(),delta:e.z.union([e.z.number(),e.z.null()]).optional(),deltaPercent:e.z.union([e.z.number(),e.z.null()]).optional()}).passthrough().optional(),records:x.optional()}).passthrough(),ge=e.z.object({...A,kind:e.z.literal("records"),columns:e.z.array(j),records:x,totals:e.z.object({mode:e.z.literal("server"),scope:e.z.literal("filtered_result"),row:e.z.record(e.z.string(),e.z.unknown()),columns:e.z.array(j).optional()}).passthrough().optional()}).passthrough(),he=e.z.object({...A,kind:e.z.literal("inputOptions"),options:e.z.array(w({label:e.z.string(),value:e.z.unknown(),count:e.z.number().optional(),disambiguation:e.z.array(e.z.string()).optional()},["value"]))}).passthrough(),fe=e.z.object({...A,kind:e.z.literal("sql"),columns:e.z.array(j),records:x,sqlShape:e.z.object({statementType:e.z.string().optional(),explicitLimit:e.z.number().optional(),hasPythonCode:e.z.boolean().optional()}).passthrough().optional()}).passthrough(),Ao=e.z.object({enabled:e.z.boolean().optional(),position:e.z.enum(["before","after"]).optional(),label:e.z.string().optional()}).passthrough(),ee=e.z.object({id:e.z.enum(["rows","columns"]),levels:e.z.array(e.z.object({instanceId:e.z.string(),fieldKey:e.z.string(),label:e.z.string(),field:z,grain:ae.optional(),subtotal:Ao.optional()}).passthrough()),nodeIds:e.z.array(e.z.string())}).passthrough(),y=w({instanceId:e.z.string(),fieldKey:e.z.string(),value:e.z.unknown(),label:e.z.string()},["value"]),ko=e.z.union([e.z.object({kind:e.z.literal("label")}).passthrough(),e.z.object({kind:e.z.literal("field"),field:z,aggregate:c.optional()}).passthrough(),e.z.object({kind:e.z.literal("value"),valueId:e.z.string(),rowPath:e.z.array(y).optional(),columnPath:e.z.array(y).optional()}).passthrough()]),Ro=e.z.enum(["present","presentNull","missing","densified"]),_o=e.z.enum(["value","rowSubtotal","columnSubtotal","subtotalIntersection","rowGrandTotal","columnGrandTotal","matrixGrandTotal"]),Io=e.z.object({instanceId:e.z.string(),fieldKey:e.z.string(),field:z,role:e.z.enum(["row","column","measure","sort","filter"]),label:e.z.string().optional()}).passthrough(),jo=e.z.union([e.z.object({kind:e.z.literal("additive"),aggregate:c.optional()}).passthrough(),e.z.object({kind:e.z.literal("semiAdditive"),aggregate:c.optional(),grain:ae.optional()}).passthrough(),e.z.object({kind:e.z.literal("nonAdditive"),aggregate:c.optional()}).passthrough(),e.z.object({kind:e.z.literal("ratio"),numeratorMeasureInstanceId:e.z.string().optional(),denominatorMeasureInstanceId:e.z.string().optional()}).passthrough(),e.z.object({kind:e.z.literal("custom"),expressionId:e.z.string().optional()}).passthrough()]),Co=e.z.object({instanceId:e.z.string(),fieldKey:e.z.string(),label:e.z.string(),field:z,aggregate:c.optional(),format:ue.optional(),totalBehavior:fo.optional(),semantics:jo}).passthrough(),qo=e.z.object({id:e.z.string(),measureId:e.z.string(),aggregate:c.optional(),label:e.z.string().optional(),source:e.z.enum(["measureDefault","rowSubtotal","columnSubtotal","subtotalIntersection","rowGrandTotal","columnGrandTotal","matrixGrandTotal","custom"]),scope:e.z.object({rowLevelId:e.z.string().optional(),columnLevelId:e.z.string().optional(),rowNodeId:e.z.string().optional(),columnNodeId:e.z.string().optional()}).passthrough().optional()}).passthrough(),xo=e.z.object({kind:e.z.string(),label:e.z.string().optional(),payload:e.z.record(e.z.string(),e.z.unknown()).optional()}).passthrough(),Eo=w({id:e.z.string(),axis:e.z.enum(["row","column"]),path:e.z.array(y),level:e.z.number(),label:e.z.string(),value:e.z.unknown(),parentId:e.z.string().optional(),hasChildren:e.z.boolean(),isExpanded:e.z.boolean().optional(),isSubtotal:e.z.boolean().optional(),isGrandTotal:e.z.boolean().optional(),subtotalFunction:c.optional(),childCount:e.z.number().optional(),actions:e.z.array(xo).optional()},["value"]),Fo=e.z.object({rowHeaderLevels:e.z.array(e.z.object({id:e.z.string(),label:e.z.string(),fieldInstanceId:e.z.string()}).passthrough()),columnHeaderRows:e.z.array(e.z.object({id:e.z.string(),cells:e.z.array(e.z.object({id:e.z.string(),label:e.z.string(),role:e.z.enum(["rowHeader","columnHeader","measureHeader","subtotal","grandTotal"]),colSpan:e.z.number(),rowSpan:e.z.number(),columnPath:e.z.array(y),measureInstanceId:e.z.string().optional()}).passthrough())}).passthrough()),columns:e.z.array(e.z.object({id:e.z.string(),label:e.z.string(),columnNodeId:e.z.string().optional(),columnPath:e.z.array(y),measureInstanceId:e.z.string(),role:e.z.enum(["value","columnSubtotal","columnGrandTotal"])}).passthrough())}).passthrough(),To=w({rowId:e.z.string(),columnId:e.z.string().optional(),measureId:e.z.string(),value:e.z.unknown(),formattedValue:e.z.string().optional(),presence:Ro,role:_o,calculationId:e.z.string().optional()},["value"]),Do=e.z.object({rows:e.z.boolean().optional(),columns:e.z.boolean().optional(),grandTotal:e.z.union([e.z.boolean(),e.z.object({rows:e.z.boolean().optional(),columns:e.z.boolean().optional()}).passthrough()]).optional()}).passthrough(),No=w({id:e.z.string(),axis:e.z.enum(["row","column"]),targetInstanceId:e.z.string().optional(),direction:e.z.enum(["asc","desc"]),nulls:e.z.enum(["warehouseDefault","first","last"]).optional(),scope:e.z.enum(["global","withinParent"]).optional(),by:ko},["by"]),Oo=e.z.object({rowOffset:e.z.number().optional(),rowLimit:e.z.number().optional(),columnOffset:e.z.number().optional(),columnLimit:e.z.number().optional(),hasMoreRows:e.z.boolean().optional(),hasMoreColumns:e.z.boolean().optional()}).passthrough(),Mo=e.z.object({axis:e.z.enum(["row","column"]),path:e.z.array(y),depth:e.z.number().optional()}).passthrough(),Ko=e.z.object({rowLazyLoading:e.z.boolean().optional(),columnLazyLoading:e.z.boolean().optional(),expandableRowNodeIds:e.z.array(e.z.string()).optional(),expandableColumnNodeIds:e.z.array(e.z.string()).optional(),nextRequests:e.z.array(Mo).optional()}).passthrough(),Po=e.z.object({domains:e.z.record(e.z.object({min:e.z.number().optional(),max:e.z.number().optional()}).passthrough()).optional(),rules:e.z.array(e.z.record(e.z.string(),e.z.unknown())).optional()}).passthrough(),ze=e.z.object({...A,kind:e.z.literal("matrix"),schemaVersion:e.z.literal(1),shape:e.z.enum(["hierarchical","pivot"]),capabilities:e.z.array(e.z.string()),executionMetadata:e.z.record(e.z.string(),e.z.unknown()),fieldsById:e.z.record(e.z.string(),Io),measuresById:e.z.record(e.z.string(),Co),calculationsById:e.z.record(e.z.string(),qo).optional(),axes:e.z.object({rows:ee,columns:ee}).passthrough(),nodesById:e.z.record(e.z.string(),Eo),layout:Fo,cells:e.z.array(To),totals:Do,sort:e.z.array(No),formattingContext:Po,pageInfo:Oo.optional(),expansion:Ko.optional()}).passthrough(),be=e.z.union([me,ge,he,fe,ze]),ye=e.z.object({status:e.z.enum(["not_required","resolved","missing","ambiguous","fanout_risk","unknown"]),requiredSources:e.z.array(b).optional(),relationshipsUsed:e.z.array(e.z.string()).optional(),missingSources:e.z.array(e.z.string()).optional(),warnings:e.z.array(e.z.string()).optional(),message:e.z.string().optional(),recommendedNextStep:e.z.string().optional(),joinPlanSummary:e.z.object({baseSource:b.optional(),joinedSources:e.z.array(b).optional(),joinCount:e.z.number().optional()}).passthrough().optional(),fanoutRisk:e.z.object({status:e.z.enum(["none","warning","error","unknown"]),message:e.z.string().optional()}).passthrough().optional()}).passthrough(),oe=e.z.enum(["ambiguous_fields","empty_result","missing_grounded_fields","missing_relationship","no_grounded_query","partial_result","presentation_incomplete","query_validation_failed","unsafe_join"]),G=e.z.object({version:e.z.literal(1),status:e.z.enum(["answered","partial","blocked"]),summary:e.z.string(),answered:e.z.array(e.z.object({slotId:e.z.string().optional(),queryId:e.z.string().optional(),summary:e.z.string(),evidenceIds:e.z.array(e.z.string()).optional(),fieldsUsed:e.z.array(D).optional()}).passthrough()),blocked:e.z.array(e.z.object({slotId:e.z.string().optional(),queryId:e.z.string().optional(),reasonCode:oe,message:e.z.string(),missingFields:e.z.array(e.z.string()).optional(),availableFields:e.z.array(e.z.string()).optional(),ambiguousFields:e.z.array(e.z.string()).optional(),missingRelationships:e.z.array(e.z.string()).optional(),evidenceIds:e.z.array(e.z.string()).optional(),neededFromUser:e.z.array(e.z.string()).optional(),recommendedNextStep:e.z.string().optional()}).passthrough()),semanticModelRecommendations:e.z.array(e.z.object({reasonCode:oe,message:e.z.string(),recommendedNextStep:e.z.string().optional()}).passthrough()).optional()}).passthrough(),H=e.z.object({scope:e.z.literal("filtered_query"),measures:e.z.record(_)}).passthrough(),Q=e.z.object({answeredObligations:e.z.array(e.z.string()),missingObligations:e.z.array(e.z.string()),warnings:e.z.array(C).optional()}).passthrough(),Se=e.z.object({intentId:e.z.string().optional(),queryId:e.z.string().optional(),status:e.z.enum(["answered","partial","failed"]),resultShape:e.z.enum(["metric","records","inputOptions","sql","matrix","period_change","analysis"]).optional(),intent:e.z.unknown().optional(),compiledQuery:e.z.unknown().optional(),fieldsUsed:e.z.array(D).optional(),result:be.optional(),validation:U,coverage:Q.optional(),missingFields:e.z.array(e.z.string()).optional(),warnings:e.z.array(e.z.string()).optional(),relationshipDiagnostics:ye.optional(),diagnosticFeedback:G.optional(),population:H.optional(),metadata:e.z.record(e.z.string(),e.z.unknown()).optional()}).passthrough();function Bo(i){switch(i){case"boolean":return e.z.boolean().optional();case"compactExecutionFieldArray":return e.z.array($o).optional();case"coverage":return Q.optional();case"diagnosticFeedback":return G.optional();case"executionFieldArray":return e.z.array(D).optional();case"executionResult":return Se.optional();case"number":return e.z.number().finite().optional();case"population":return H.optional();case"record":return m.optional();case"recordArray":return x.optional();case"responseDetail":return e.z.enum(["compact","standard","debug"]).optional();case"string":return e.z.string().optional();case"stringArray":return e.z.array(e.z.string()).optional();case"unknown":return e.z.unknown().optional();case"unknownArray":return e.z.array(e.z.unknown()).optional();case"validationResult":return U.optional()}}const ve=Object.fromEntries(Object.entries(q).map(([i,t])=>[i,Bo(t)])),$e=e.z.object(ve).strict(),Y=e.z.object({sourceKey:e.z.string().optional(),kind:e.z.enum(["semantic","physical","sql"]).optional(),domainId:e.z.string().optional(),datasetName:e.z.string().optional(),datasetId:e.z.string().optional(),connectionId:e.z.string().optional(),tableName:e.z.string().optional(),label:e.z.string().optional()}).passthrough(),f=e.z.object({name:e.z.string(),label:e.z.string().optional(),role:e.z.enum(["dimension","measure","date","id","unknown"]).optional(),dataType:e.z.enum(["string","number","boolean","date","datetime","unknown"]).optional(),aggregate:c.optional(),sourceKey:e.z.string().optional(),source:Y.optional()}).passthrough(),we=e.z.object({id:e.z.string().optional(),builder:e.z.literal("semaphor.inputOptions"),source:Y.optional(),sourceKey:e.z.string().optional(),valueFieldRef:f,labelFieldRef:f,filterFieldRef:f.optional(),population:e.z.unknown().optional(),dependencies:e.z.unknown().optional(),limit:e.z.number().int().positive().optional(),spec:m.optional()}).passthrough(),Ae=e.z.object({appliesToViewIds:e.z.array(e.z.string()).optional(),viewId:e.z.string().optional(),fieldRef:f,relationshipHint:e.z.unknown().optional(),relationshipsUsed:e.z.array(m).optional()}).passthrough(),Vo=e.z.object({id:e.z.string(),label:e.z.string().optional(),type:e.z.string().optional(),serverSide:e.z.boolean().optional(),fieldRef:f.optional(),optionQuery:we.optional(),bindings:e.z.array(Ae).optional(),appliesToViewIds:e.z.array(e.z.string()),relationshipHint:e.z.unknown().optional(),relationshipsUsed:e.z.array(m).optional()}).passthrough(),Lo=e.z.object({builder:e.z.enum(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]),spec:m,fallbackReason:m.optional()}).passthrough(),Uo=e.z.object({id:e.z.string(),title:e.z.string().optional(),purpose:e.z.string().optional(),sourcePresentation:e.z.object({sourceKeys:e.z.array(e.z.string()).optional(),sourceLabels:e.z.array(e.z.string()).optional()}).passthrough().optional(),visual:e.z.string().optional(),visualSpec:m.optional(),queryKind:e.z.enum(["metric","records","matrix","analysis","sql_fallback"]).optional(),sdkBuilder:e.z.enum(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]).optional(),sdkSpec:Lo.optional(),fields:e.z.array(f).optional(),computation:m.optional(),uxExpectations:e.z.array(e.z.string()).optional(),validation:m.optional()}).passthrough(),Go=e.z.object({inputId:e.z.string(),label:e.z.string().optional(),type:e.z.string().optional(),serverSide:e.z.boolean().optional(),fieldRef:f.optional(),optionQuery:we.optional(),bindings:e.z.array(Ae),appliesToViewIds:e.z.array(e.z.string()),notAppliedToViewIds:e.z.array(e.z.string())}).passthrough(),Ho=e.z.object({schemaVersion:e.z.literal(I),title:e.z.string(),purpose:e.z.string().optional(),userGoal:e.z.string().optional(),nextStep:e.z.string().optional(),sources:e.z.array(Y),inputs:e.z.array(Vo),views:e.z.array(Uo),filterContracts:e.z.array(Go),implementationChecklist:e.z.object({schemaVersion:e.z.string().optional(),requiredDevtools:e.z.object({mountRootDevtools:e.z.boolean(),providerDebugBridge:e.z.string().optional(),panelPosition:e.z.string().optional(),forbidden:e.z.array(e.z.string()).optional()}).passthrough(),requiredInputOptions:e.z.array(m),filterScopeByInput:e.z.array(m),bindingsByView:e.z.record(e.z.string(),e.z.array(m)),validationCommands:e.z.array(e.z.string()),browserSmokeChecks:e.z.array(e.z.string())}).passthrough(),nextRequiredTool:e.z.object({name:e.z.string(),reason:e.z.string().optional()}).optional(),unsupportedInsights:e.z.array(e.z.object({title:e.z.string(),requestedQuestion:e.z.string(),reason:e.z.string(),suggestedModelingFix:e.z.string()}).passthrough()).optional(),assumptions:e.z.array(e.z.string()).optional(),validation:m.optional()}).passthrough().superRefine((i,t)=>{const o=P(i);for(const s of o.issues)t.addIssue({code:e.z.ZodIssueCode.custom,message:s})}),Qo=new Set(Object.keys(q));function Yo(){return Object.keys(q)}function ke(i){return Qo.has(i)}function Wo(i){if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Semaphor analyze result must be an object.");const o=Object.keys(i).filter(s=>!ke(s));if(o.length)throw new Error(`Semaphor analyze result contains unsupported top-level field(s): ${o.join(", ")}.`);return $e.parse(i)}exports.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT=q;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=I;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=_e;exports.getSemaphorAnalyzeResultFieldNames=Yo;exports.isSemaphorAnalyzeResultFieldName=ke;exports.isSemaphorDataAppCodegenSummary=Ne;exports.parseSemaphorAnalyzeResult=Wo;exports.semaphorAnalyticsCoverageSchema=Q;exports.semaphorAnalyticsDiagnosticFeedbackSchema=G;exports.semaphorAnalyticsExecutionResultSchema=Se;exports.semaphorAnalyticsPopulationSchema=H;exports.semaphorAnalyticsResultSchema=be;exports.semaphorAnalyticsValidationIssueSchema=C;exports.semaphorAnalyticsValidationResultSchema=U;exports.semaphorAnalyzeResultSchema=$e;exports.semaphorAnalyzeResultShape=ve;exports.semaphorDataAppCodegenSummarySchema=Ho;exports.semaphorDerivedFieldDefinitionSchema=L;exports.semaphorExecutionFieldRefSchema=D;exports.semaphorFieldRefSchema=z;exports.semaphorInputOptionsResultSchema=he;exports.semaphorMatrixResultSchema=ze;exports.semaphorMetricResultSchema=me;exports.semaphorPhysicalSourceRefSchema=ce;exports.semaphorRecordsResultSchema=ge;exports.semaphorRelationshipDiagnosticsSchema=ye;exports.semaphorResultColumnSchema=j;exports.semaphorSemanticSourceRefSchema=V;exports.semaphorSourceRefSchema=b;exports.semaphorSqlResultSchema=fe;exports.semaphorSqlSourceRefSchema=de;exports.validateSemaphorDataAppCodegenSummary=P;