@malloy-publisher/server 0.0.233 → 0.0.235
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/README.docker.md +1 -0
- package/dist/app/api-doc.yaml +208 -0
- package/dist/app/assets/{EnvironmentPage-DutP7T8h.js → EnvironmentPage-BsAnavYN.js} +1 -1
- package/dist/app/assets/{HomePage-BcxDrBfl.js → HomePage-CADE138j.js} +1 -1
- package/dist/app/assets/{LightMode-BJukGxgz.js → LightMode-Cfh7KzN8.js} +1 -1
- package/dist/app/assets/{MainPage-DXbwlMeF.js → MainPage-CO3pRlnV.js} +2 -2
- package/dist/app/assets/{MaterializationsPage-BBQksmTU.js → MaterializationsPage-p9YjkRXZ.js} +1 -1
- package/dist/app/assets/{ModelPage-C6tK51uU.js → ModelPage-C1OSTv-x.js} +1 -1
- package/dist/app/assets/{PackagePage-Bo3cwwZE.js → PackagePage-e4kN75YR.js} +1 -1
- package/dist/app/assets/{RouteError-BufkcAKE.js → RouteError-CzbfOkng.js} +1 -1
- package/dist/app/assets/{ThemeEditorPage-DICvvKpa.js → ThemeEditorPage-CciagFTq.js} +1 -1
- package/dist/app/assets/{WorkbookPage-Dkwt75Nj.js → WorkbookPage-DNWmkCXa.js} +1 -1
- package/dist/app/assets/{core-C0nunIQT.es-DlMLKZBK.js → core-Rj_4rRnA.es-BZyvITuO.js} +1 -1
- package/dist/app/assets/{index-CmEVVe-8.js → index-CH2AcDzc.js} +4 -4
- package/dist/app/assets/{index-qnhU9CGo.js → index-DQa463gC.js} +2 -2
- package/dist/app/assets/{index-Cs4WVm2z.js → index-DQpV7MyA.js} +1 -1
- package/dist/app/assets/{index-BabP-V-S.js → index-DzaYbhnD.js} +1 -1
- package/dist/app/assets/{index-BusxL5Pt.js → index-VBbcc8s6.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/package_load_worker.mjs +53 -3
- package/dist/server.mjs +835 -97
- package/package.json +12 -12
- package/src/config.ts +35 -1
- package/src/controller/connection.controller.spec.ts +46 -0
- package/src/controller/connection.controller.ts +105 -2
- package/src/controller/materialization.controller.spec.ts +25 -0
- package/src/controller/materialization.controller.ts +60 -0
- package/src/controller/model.controller.ts +24 -0
- package/src/controller/query.controller.ts +83 -15
- package/src/mcp/handler_utils.ts +10 -2
- package/src/mcp/query_envelope.ts +10 -0
- package/src/mcp/skills/skills_bundle.json +1 -1
- package/src/mcp/tools/execute_query_tool.spec.ts +131 -0
- package/src/mcp/tools/execute_query_tool.ts +62 -25
- package/src/mcp_config.spec.ts +919 -0
- package/src/mcp_config.ts +425 -0
- package/src/oom_guards.integration.spec.ts +11 -3
- package/src/package_load/package_load_pool.ts +2 -0
- package/src/package_load/package_load_worker.ts +17 -5
- package/src/package_load/protocol.ts +6 -0
- package/src/query_metadata_metrics.ts +49 -0
- package/src/server.ts +99 -3
- package/src/service/build_plan.spec.ts +125 -0
- package/src/service/build_plan.ts +108 -7
- package/src/service/connection_config.ts +49 -0
- package/src/service/environment.ts +57 -3
- package/src/service/materialization_config_validation.spec.ts +99 -0
- package/src/service/materialization_config_validation.ts +120 -0
- package/src/service/materialization_schedule_surface.spec.ts +124 -0
- package/src/service/materialization_service.spec.ts +119 -0
- package/src/service/materialization_service.ts +186 -3
- package/src/service/materialization_test_fixtures.ts +86 -21
- package/src/service/model.spec.ts +45 -1
- package/src/service/model.ts +145 -19
- package/src/service/package.ts +24 -1
- package/src/service/package_manifest.spec.ts +137 -4
- package/src/service/package_manifest.ts +140 -5
- package/src/service/persist_annotation_validation.spec.ts +12 -0
- package/src/service/persist_annotation_validation.ts +9 -4
- package/src/service/query_metadata.spec.ts +408 -0
- package/src/service/query_metadata.ts +492 -0
- package/src/service/query_metadata_identity.spec.ts +149 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aG as XF,r as L,j as N,ac as Ht,R as ZF,aH as e9,aI as ns}from"./index-CmEVVe-8.js";import{r as Jd,a as dA,d as xt}from"./index-BusxL5Pt.js";import{r as Wa}from"./index-w_0OQJgZ.js";import{d as AU}from"./index-Cs4WVm2z.js";import{MalloyRenderer as t9,isCoreVizPluginInstance as TU}from"./index-BabP-V-S.js";var Eo={},K3={},fr={},J3={},gR;function Ge(){return gR||(gR=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=r,e.mkSafeRecord=i,e.exprHasKids=o,e.exprHasE=s,e.exprIsLeaf=a,e.isAsymmetricExpr=l,e.mkTemporal=d,e.isRawCast=c,e.isFilterExprType=x,e.isTimeLiteral=f,e.isParameterType=p,e.paramHasValue=h,e.activeName=g,e.expressionIsScalar=m,e.expressionIsAggregate=E,e.expressionIsUngroupedAggregate=v,e.expressionInvolvesAggregate=_,e.expressionIsCalculation=S,e.expressionIsAnalytic=T,e.isExpressionTypeLEQ=D,e.maxExpressionType=C,e.maxOfExpressionTypes=w,e.hasExpression=R,e.isTemporalType=O,e.isBasicAtomicType=I,e.isAtomicFieldType=k,e.canOrderBy=$,e.fieldIsIntrinsic=Y,e.mkFieldDef=ne,e.mkArrayDef=re,e.mkArrayTypeDef=oe,e.isRepeatedRecordFunctionParam=U,e.isRepeatedRecord=ee,e.isRecordOrRepeatedRecord=J,e.isBasicArray=te,e.isMatrixOperation=q,e.isJoinable=H,e.isJoined=Q,e.isJoinedSource=M,e.isDateUnit=j,e.isTimestampUnit=P,e.isExtractUnit=V,e.refIsStructDef=ae,e.segmentHasErrors=ce,e.structHasErrors=le,e.isReduceSegment=se,e.isPartialSegment=xe,e.isProjectSegment=pe,e.isQuerySegment=ye,e.isSamplingRows=Ce,e.isSamplingPercent=me,e.isSamplingEnable=_e,e.isRawSegment=we,e.isIndexSegment=Ke,e.bareFieldUsage=rt,e.fieldUsageFrom=ge,e.givenUsageFrom=Ee,e.mkRefSummary=Pe,e.mapFieldUsage=ke,e.setFieldUsage=Me,e.isSegmentSQL=Xe,e.isSegmentSource=at,e.isSourceRegistryReference=Qe,e.sourceBase=Et,e.isSourceDef=mt,e.isPersistableSourceDef=Te,e.isBaseTable=ze,e.isLiteral=st,e.mergeEvalSpaces=de,e.isBasicAtomic=he,e.isUserTypeDef=ve,e.isCompoundArrayData=be,e.isTurtle=Be,e.isAtomic=Ie,e.isValueString=We,e.isValueNumber=nt,e.isValueBoolean=gt,e.isValueTimestamp=yt,e.isValueDate=ut,e.mergeUniqueKeyRequirement=et;const t=Object.prototype.hasOwnProperty;function r(ie,Ae){return t.call(ie,Ae)?ie[Ae]:void 0}function i(){return Object.create(null)}function o(ie){return"kids"in ie}function s(ie){return"e"in ie}function a(ie){return!(o(ie)||s(ie))}function l(ie){return ie.node==="aggregate"&&["sum","avg","count","distinct"].includes(ie.function)}function u(ie){return ie.node!=="arrayLiteral"&&ie.node!=="recordLiteral"}function d(ie,Ae){if(!("typeDef"in ie)){const Oe=typeof Ae=="string"?{type:Ae}:Ae;if(u(ie))return{...ie,typeDef:{...Oe}}}return ie}function c(ie){return"dstSQLType"in ie}function x(ie){return["string","number","boolean","date","timestamp","timestamptz"].includes(ie)}function f(ie){return ie.node==="dateLiteral"||ie.node==="timestampLiteral"||ie.node==="timestamptzLiteral"}function p(ie){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ie)}function h(ie){return ie.value!==null}function g(ie){var Ae;return(Ae=ie.as)!==null&&Ae!==void 0?Ae:ie.name}function m(ie){return ie===void 0||ie==="scalar"}function E(ie){return ie==="aggregate"||ie==="ungrouped_aggregate"}function v(ie){return ie==="ungrouped_aggregate"}function _(ie){return ie==="aggregate"||ie==="ungrouped_aggregate"||ie==="aggregate_analytic"}function S(ie){return ie==="aggregate"||ie==="scalar_analytic"||ie==="aggregate_analytic"||ie==="ungrouped_aggregate"}function T(ie){return ie==="aggregate_analytic"||ie==="scalar_analytic"}function b(ie){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ie]}function D(ie,Ae){return ie===Ae||b(ie)<b(Ae)}function C(ie,Ae){let Oe="scalar";return(ie==="aggregate"||Ae==="aggregate")&&(Oe="aggregate"),(ie==="ungrouped_aggregate"||Ae==="ungrouped_aggregate")&&(Oe="ungrouped_aggregate"),(ie==="scalar_analytic"||Ae==="scalar_analytic")&&(Oe="scalar_analytic"),(ie==="aggregate_analytic"||Ae==="aggregate_analytic")&&(Oe="aggregate_analytic"),(ie==="scalar_analytic"&&Ae==="aggregate"||ie==="aggregate"&&Ae==="scalar_analytic")&&(Oe="aggregate_analytic"),Oe}function w(ie){return ie.reduce(C,"scalar")}function R(ie){return"e"in ie&&ie.e!==void 0}function O(ie){return ie==="date"||ie==="timestamp"||ie==="timestamptz"}function I(ie){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ie)}function k(ie){return I(ie)||ie==="record"||ie==="array"}function $(ie){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ie)}function Y(ie){return k(ie.type)&&!R(ie)}function ne(ie,Ae){if(te(ie))return re(ie.elementTypeDef,Ae);if(ee(ie)){const{type:je,fields:it,elementTypeDef:dt}=ie;return{type:je,fields:it,elementTypeDef:dt,join:"many",name:Ae}}if(ie.type==="record"){const{type:je,fields:it}=ie;return{type:je,fields:it,join:"one",name:Ae}}const Oe={name:Ae,type:ie.type};switch(ie.type){case"sql native":return{...Oe,rawType:ie.rawType};case"number":{const je=ie.numberType;return je?{...Oe,numberType:je}:Oe}case"date":{const je=ie.timeframe;return je?{name:Ae,type:"date",timeframe:je}:Oe}case"timestamp":{const je={name:Ae,type:"timestamp"};return ie.timeframe&&(je.timeframe=ie.timeframe),je}case"timestamptz":{const je={name:Ae,type:"timestamptz"};return ie.timeframe&&(je.timeframe=ie.timeframe),je}}return Oe}function re(ie,Ae){if(ie.type==="record")return{type:"array",join:"many",name:Ae,elementTypeDef:{type:"record_element"},fields:ie.fields};const Oe=ne(ie,"value");return{type:"array",join:"many",name:Ae,elementTypeDef:ie,fields:[Oe,{...Oe,name:"each",e:{node:"field",path:["value"]}}]}}function oe(ie){return ie.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ie.fields}:{type:"array",elementTypeDef:ie}}function U(ie){return ie.type==="array"&&ie.elementTypeDef.type==="record_element"}function ee(ie){return ie.type==="array"&&ie.elementTypeDef.type==="record_element"}function J(ie){return ie.type==="record"||ie.type==="array"&&"elementTypeDef"in ie&&ie.elementTypeDef.type==="record_element"}function te(ie){return ie.type==="array"&&ie.elementTypeDef.type!=="record_element"}function q(ie){return["left","right","full","inner"].includes(ie)}function H(ie){return["composite","table","sql_select","query_source","virtual","array","record"].includes(ie.type)}function Q(ie){return"join"in ie}function M(ie){return mt(ie)&&Q(ie)}function j(ie){return["day","week","month","quarter","year"].includes(ie)}function P(ie){return j(ie)||["hour","minute","second"].includes(ie)}function V(ie){return P(ie)||ie==="day_of_week"||ie==="day_of_year"}var Z;(function(ie){ie.Date="date",ie.Timestamp="timestamp",ie.Number="number",ie.String="string"})(Z||(e.ValueType=Z={}));function ae(ie){return typeof ie!="string"}function ce(ie){return!!((ie.type==="reduce"||ie.type==="project"||ie.type==="partial")&&(ie.extendSource&&ie.extendSource.some(Ae=>Ae.type==="error")||ie.queryFields.some(Ae=>Ae.type==="error")))}function le(ie){return ie.fields.some(Ae=>Ae.type==="error")}function se(ie){return ie.type==="reduce"}function xe(ie){return ie.type==="partial"}function pe(ie){return ie.type==="project"}function ye(ie){return pe(ie)||se(ie)}function Ce(ie){return ie.rows!==void 0}function me(ie){return ie.percent!==void 0}function _e(ie){return ie.enable!==void 0}function we(ie){return ie.type==="raw"}function Ke(ie){return ie.type==="index"}function rt(ie){return ie.uniqueKeyRequirement===void 0&&ie.analyticFunctionUse===void 0}function ge(ie){var Ae;return(Ae=ie?.fieldUsage)!==null&&Ae!==void 0?Ae:[]}function Ee(ie){var Ae;return(Ae=ie?.givenUsage)!==null&&Ae!==void 0?Ae:[]}function Pe({fieldUsage:ie,givenUsage:Ae}){if(!(ie===void 0&&Ae===void 0))return{fieldUsage:ie??[],...Ae&&{givenUsage:Ae}}}function ke(ie,Ae){return ie&&{...ie,fieldUsage:ie.fieldUsage.map(Ae)}}function Me(ie,Ae){ie.refSummary?ie.refSummary.fieldUsage=Ae:ie.refSummary={fieldUsage:Ae}}function Xe(ie){return"sql"in ie}function at(ie){return"type"in ie&&(ie.type==="sql_select"||ie.type==="query_source")}function Qe(ie){return ie.type==="source_registry_reference"}function Et(ie){return{...ie}}function mt(ie){return ie.type==="table"||ie.type==="sql_select"||ie.type==="query_source"||ie.type==="query_result"||ie.type==="finalize"||ie.type==="nest_source"||ie.type==="virtual"||ie.type==="composite"}function Te(ie){return ie.type==="sql_select"||ie.type==="query_source"}function ze(ie){return M(ie)?!1:!!mt(ie)}function st(ie){return ie==="literal"}function de(...ie){return ie.length<=1&&ie.every(Ae=>Ae==="literal")?"literal":ie.every(Ae=>Ae==="constant"||Ae==="literal")?"constant":ie.every(Ae=>Ae==="output"||Ae==="constant"||Ae==="literal")?"output":"input"}function he(ie){return ie.type==="string"||O(ie.type)||ie.type==="number"||ie.type==="boolean"||ie.type==="json"||ie.type==="sql native"||ie.type==="error"}function ve(ie){return ie.type==="userType"}function be(ie){return Array.isArray(ie)&&(ie.length===0||typeof ie[0]=="object"&&ie[0]!==null&&!Array.isArray(ie[0]))}function Be(ie){return ie.type==="turtle"}function Ie(ie){return k(ie.type)}function We(ie,Ae){return Ae.type==="string"}function nt(ie,Ae){return Ae.type==="number"}function gt(ie,Ae){return Ae.type==="boolean"}function yt(ie,Ae){return Ae.type==="timestamp"}function ut(ie,Ae){return Ae.type==="date"}e.TD={isAtomic(ie){return ie!==void 0&&k(ie.type)},isBasicAtomic(ie){return ie!==void 0&&he({type:ie.type})},isString:ie=>ie?.type==="string",isNumber:ie=>ie?.type==="number",isBoolean:ie=>ie?.type==="boolean",isJSON:ie=>ie?.type==="json",isSQL:ie=>ie?.type==="sql native",isDate:ie=>ie?.type==="date",isTimestamp:ie=>ie?.type==="timestamp",isTimestamptz:ie=>ie?.type==="timestamptz",isAnyTimestamp(ie){return ie?.type==="timestamp"||ie?.type==="timestamptz"},isTemporal(ie){var Ae;const Oe=(Ae=ie?.type)!==null&&Ae!==void 0?Ae:"";return O(Oe)},isError:ie=>ie?.type==="error",atomicDef(ie){if(!e.TD.isAtomic(ie))return{type:"error"};switch(ie.type){case"array":return ee(ie)?{type:"array",elementTypeDef:ie.elementTypeDef,fields:ie.fields}:{type:"array",elementTypeDef:ie.elementTypeDef};case"record":return{type:"record",fields:ie.fields};case"number":return ie.numberType?{type:"number",numberType:ie.numberType}:{type:"number"};case"sql native":return ie.rawType?{type:"sql native",rawType:ie.rawType}:{type:"sql native"};case"timestamp":case"timestamptz":return ie.timeframe?{type:ie.type,timeframe:ie.timeframe}:{type:ie.type};default:return{type:ie.type}}},eq(ie,Ae){if(ie===void 0||Ae===void 0)return!1;function Oe(je,it){const dt={},lt=je.fields||[],ft=it.fields||[];if(lt.length!==ft.length)return!1;for(const It of lt)if(It.name)dt[It.name]=It;else return!1;for(const It of ft)if(!e.TD.eq(dt[It.name],It))return!1;return!0}return ie.type==="array"&&Ae.type==="array"?ie.elementTypeDef.type!==Ae.elementTypeDef.type?!1:ie.elementTypeDef.type!=="record_element"&&Ae.elementTypeDef.type!=="record_element"?e.TD.eq(ie.elementTypeDef,Ae.elementTypeDef):e.TD.isAtomic(ie)&&e.TD.isAtomic(Ae)&&Oe(ie,Ae):ie.type==="record"&&Ae.type==="record"?e.TD.isAtomic(ie)&&e.TD.isAtomic(Ae)&&Oe(ie,Ae):ie.type==="sql native"&&Ae.type==="sql native"?ie.rawType!==void 0&&ie.rawType===Ae.rawType:ie.type===Ae.type}};function et(ie,Ae){return ie?Ae?{isCount:ie.isCount||Ae.isCount}:ie:Ae}})(J3)),J3}var yR;function cs(){if(yR)return fr;yR=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.arg=t,fr.spread=r,fr.sql=i,fr.constant=o,fr.output=s,fr.literal=a,fr.variadicParam=l,fr.param=u,fr.makeParam=d,fr.maxScalar=c,fr.maxAggregate=x,fr.anyExprType=f,fr.maxUngroupedAggregate=p,fr.maxAnalytic=h,fr.minScalar=g,fr.minAggregate=m,fr.minAnalytic=E,fr.overload=v,fr.expandBlueprintMap=te,fr.expandOverrideMapFromBase=Q,fr.def=j;const e=Ge();function t(P){return{node:"function_parameter",name:P}}function r(P,V=void 0,Z=void 0){return{node:"spread",e:P,prefix:V,suffix:Z}}function i(P,...V){const Z={node:"genericSQLExpr",kids:{args:[]},src:[]},ae=[...V];let ce="";for(const le of P){ce+=le;const se=ae.shift();se!==void 0&&(typeof se=="string"?ce+=se:(Z.src.push(ce),Z.kids.args.push(se),ce=""))}return ce.length>0&&Z.src.push(ce),Z}function o(P){return{...P,evalSpace:"constant"}}function s(P){return{...P,evalSpace:"output"}}function a(P){return{...P,evalSpace:"literal"}}function l(P,...V){return{name:P,isVariadic:!0,allowedTypes:V}}function u(P,...V){return{name:P,isVariadic:!1,allowedTypes:V}}function d(P,...V){return{param:u(P,...V),arg:t(P)}}function c(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function x(P){return{...P,expressionType:"aggregate",evalSpace:"input"}}function f(P){return{...P,expressionType:void 0,evalSpace:"input"}}function p(P){return{...P,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function h(P){return{...P,expressionType:"aggregate_analytic",evalSpace:"input"}}function g(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function m(P){return{...P,expressionType:"aggregate",evalSpace:"input"}}function E(P){return{...P,expressionType:"scalar_analytic",evalSpace:"input"}}function v(P,V,Z,ae){return{returnType:P,params:V,e:Z,needsWindowOrderBy:ae?.needsWindowOrderBy,between:ae?.between,isSymmetric:ae?.isSymmetric,supportsOrderBy:ae?.supportsOrderBy,defaultOrderByArgIndex:ae?.defaultOrderByArgIndex,supportsLimit:ae?.supportsLimit}}function _(P,V=!0,Z=!0){if(!V&&P==="any")throw new Error("Return type cannot include any");if(typeof P=="string")return{type:P};if("array"in P){const ae=V?_(P.array,!0):_(P.array,!1);return ae.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ae.fields}:{type:"array",elementTypeDef:ae}}else if("record"in P){const ae=[];for(const[ce,le]of Object.entries(P.record)){const se=V?_(le,!0):_(le,!1);e.TD.isAtomic(se)&&ae.push((0,e.mkFieldDef)(se,ce))}return{type:"record",fields:ae}}else if("generic"in P){if(!Z)throw new Error("Cannot use generic");return{type:"generic",generic:P.generic}}else if("sql_native"in P)return{type:"sql native",rawType:P.sql_native};throw new Error("Cannot figure out type")}function S(P){if(P==="any")throw new Error("Cannot return any type");if(typeof P=="string")return g({type:P});if("array"in P)return f(_(P,!1));if("record"in P)return f(_(P,!1));if("generic"in P)return g(_(P,!1));if("literal"in P)return a(g(_(P.literal,!1)));if("constant"in P)return o(g(_(P.constant,!1)));if("dimension"in P)return g(_(P.dimension,!1));if("measure"in P)return m(_(P.measure,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return E(_(P.calculation,!1));throw new Error("Invalid function blueprint")}function T(P){return typeof P=="string"||"array"in P||"record"in P||"generic"in P||"literal"in P||"constant"in P||"dimension"in P||"measure"in P||"calculation"in P||"sql_native"in P}function b(P){return T(P)?[P]:Array.isArray(P)?P:T(P.variadic)?[P.variadic]:P.variadic}function D(P){if(typeof P=="string")return f({type:P});if("generic"in P)return f(_(P));if("literal"in P)return a(c(_(P.literal)));if("constant"in P)return o(c(_(P.constant)));if("dimension"in P)return c(_(P.dimension));if("measure"in P)return x(_(P.measure));if("array"in P)return f(_(P,!1));if("record"in P)return f(_(P,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return h(_(P.calculation));throw new Error("Invalid function blueprint")}function C(P){return P.map(V=>D(V))}function w(P){return typeof P!="string"&&"variadic"in P}function R(P,V){return{name:P,allowedTypes:C(b(V)),isVariadic:w(V)}}function O(P){return Object.entries(P).map(Z=>R(Z[0],Z[1]))}function I(P){const V=[],Z=[];let ae=P;for(;ae.length>0;){const le=ae.indexOf("${");if(le===-1){V.push(ae);break}const se=ae.slice(0,le);ae=ae.slice(le);const xe=ae.indexOf("}");if(xe===-1){V.push(se+ae);break}const pe=ae.slice(2,xe);ae=ae.slice(xe+1);const ye=pe.startsWith("..."),Ce=pe.endsWith(":"),me=ye?pe.slice(3):Ce?pe.slice(0,-1):pe,_e={node:"function_parameter",name:me};V.push(se),ye?Z.push({node:"spread",e:_e,prefix:"",suffix:""}):Ce&&me==="order_by"?Z.push({node:"aggregate_order_by"}):Ce&&me==="limit"?Z.push({node:"aggregate_limit"}):Z.push(_e)}return{node:"genericSQLExpr",kids:{args:Z},src:V}}function k(P,V){return w(V)?{node:"spread",e:{node:"function_parameter",name:P},prefix:"",suffix:""}:{node:"function_parameter",name:P}}function $(P,V){const Z=Object.entries(V.takes),ae=Z.length>0?Z.length-1:0;return{node:"genericSQLExpr",kids:{args:Z.map(ce=>k(ce[0],ce[1]))},src:[`${P}(`,...Array(ae).fill(","),")"]}}function Y(P){return"sql"in P.impl?I(P.impl.sql):"expr"in P.impl?P.impl.expr:$(P.impl.function,P)}function ne(P){return{e:Y(P),between:P.impl.between,needsWindowOrderBy:P.impl.needsWindowOrderBy,defaultOrderByArgIndex:P.impl.defaultOrderByArgIndex}}function re(P){if(P!==void 0)return Object.entries(P).map(([V,Z])=>({name:V,acceptibleTypes:Z.map(ae=>_(ae,!0,!1))}))}function oe(P){return{returnType:S(P.returns),params:O(P.takes),isSymmetric:P.isSymmetric,supportsOrderBy:P.supportsOrderBy,supportsLimit:P.supportsLimit,genericTypes:re(P.generic),...ne(P)}}function U(P){return"takes"in P&&"returns"in P&&"impl"in P}function ee(P){return"function"in P||"sql"in P||"expr"in P}function J(P){return U(P)?[oe(P)]:Object.values(P).flatMap(V=>oe(V))}function te(P){const V={};for(const Z in P)V[Z]=J(P[Z]);return V}function q(P,V){return[oe({...P,impl:V})]}function H(P,V,Z){if(ee(Z)){if(!U(V))throw new Error(`Malformed function override: ${P}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(V)})`);return q(V,Z)}else{if(U(V))throw new Error(`Malformed function override: ${P}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(Z)})`);return Object.entries(Z).flatMap(([ae,ce])=>{const le=V[ae];if(le===void 0)throw new Error(`Malformed function override: ${P}. No overload named ${ae}`);return q(le,ce)})}}function Q(P,V){const Z={};for(const ae in V){if(!(ae in P))throw new Error(`Malformed function override: ${ae}. No such function in Malloy standard`);Z[ae]=H(ae,P[ae],V[ae])}return Z}function*M(P){if(typeof P!="string"){if("generic"in P)yield P;else if("record"in P)for(const V of Object.values(P.record))yield*M(V);else for(const V of["array","literal","measure","dimension","measure","constant","cacluation"])if(V in P){yield*M(P[V]);return}}}function j(P,V,Z,ae={}){let ce=!1;const le={};for(const xe of Object.values(V))for(const pe of M(xe))le[pe.generic]=["any"],ce=!0;ce&&ae.generic===void 0&&(ae.generic=le);const se={takes:V,returns:Z,impl:{function:P.toUpperCase()},...ae};return{[P]:se}}return fr}var X3={},Rx={},ER;function fA(){if(ER)return Rx;ER=1,Object.defineProperty(Rx,"__esModule",{value:!0}),Rx.decodeDottedTablePath=e,Rx.validateDottedTablePath=t;function e(o,s){const{quoteChar:a,escapeStyle:l,bareIdentRegex:u,dialectName:d}=s;if(o.length===0)return{ok:!1,error:`${d} table path is empty`};const c=[];let x=0;for(;;){let f,p;if(o[x]===a){const h=r(o,x,a,l);if(h===null)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — unterminated quoted segment`};f=h.decoded,p=!0,x=h.end}else{const h=o.slice(x).match(u);if(!h||h.index!==0||h[0].length===0)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — invalid segment at position ${x}`};f=h[0],p=!1,x+=h[0].length}if(f.includes(";")||f.includes("--"))return{ok:!1,error:`Invalid ${d} table path: segment ${JSON.stringify(f)} contains forbidden character; even when quoted, table-path segments may not contain \`;\` or \`--\`.`};if(c.push({value:f,quoted:p}),x===o.length)return{ok:!0,segments:c};if(o[x]!==".")return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — expected '.' at position ${x}`};if(x++,x===o.length)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — trailing dot`}}}function t(o,s){const a=e(o,s);return a.ok?{ok:!0,canonical:o}:a}function r(o,s,a,l){let u=s+1,d="";for(;u<o.length;){if(l==="backslash"&&o[u]==="\\"){if(u+1>=o.length)return null;d+=i(o[u+1]),u+=2;continue}if(o[u]===a){if(l==="doubled"&&o[u+1]===a){d+=a,u+=2;continue}return{decoded:d,end:u+1}}d+=o[u],u++}return null}function i(o){switch(o){case"n":return`
|
|
1
|
+
import{aG as XF,r as L,j as N,ac as Ht,R as ZF,aH as e9,aI as ns}from"./index-CH2AcDzc.js";import{r as Jd,a as dA,d as xt}from"./index-VBbcc8s6.js";import{r as Wa}from"./index-w_0OQJgZ.js";import{d as AU}from"./index-DQpV7MyA.js";import{MalloyRenderer as t9,isCoreVizPluginInstance as TU}from"./index-DzaYbhnD.js";var Eo={},K3={},fr={},J3={},gR;function Ge(){return gR||(gR=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=r,e.mkSafeRecord=i,e.exprHasKids=o,e.exprHasE=s,e.exprIsLeaf=a,e.isAsymmetricExpr=l,e.mkTemporal=d,e.isRawCast=c,e.isFilterExprType=x,e.isTimeLiteral=f,e.isParameterType=p,e.paramHasValue=h,e.activeName=g,e.expressionIsScalar=m,e.expressionIsAggregate=E,e.expressionIsUngroupedAggregate=v,e.expressionInvolvesAggregate=_,e.expressionIsCalculation=S,e.expressionIsAnalytic=T,e.isExpressionTypeLEQ=D,e.maxExpressionType=C,e.maxOfExpressionTypes=w,e.hasExpression=R,e.isTemporalType=O,e.isBasicAtomicType=I,e.isAtomicFieldType=k,e.canOrderBy=$,e.fieldIsIntrinsic=Y,e.mkFieldDef=ne,e.mkArrayDef=re,e.mkArrayTypeDef=oe,e.isRepeatedRecordFunctionParam=U,e.isRepeatedRecord=ee,e.isRecordOrRepeatedRecord=J,e.isBasicArray=te,e.isMatrixOperation=q,e.isJoinable=H,e.isJoined=Q,e.isJoinedSource=M,e.isDateUnit=j,e.isTimestampUnit=P,e.isExtractUnit=V,e.refIsStructDef=ae,e.segmentHasErrors=ce,e.structHasErrors=le,e.isReduceSegment=se,e.isPartialSegment=xe,e.isProjectSegment=pe,e.isQuerySegment=ye,e.isSamplingRows=Ce,e.isSamplingPercent=me,e.isSamplingEnable=_e,e.isRawSegment=we,e.isIndexSegment=Ke,e.bareFieldUsage=rt,e.fieldUsageFrom=ge,e.givenUsageFrom=Ee,e.mkRefSummary=Pe,e.mapFieldUsage=ke,e.setFieldUsage=Me,e.isSegmentSQL=Xe,e.isSegmentSource=at,e.isSourceRegistryReference=Qe,e.sourceBase=Et,e.isSourceDef=mt,e.isPersistableSourceDef=Te,e.isBaseTable=ze,e.isLiteral=st,e.mergeEvalSpaces=de,e.isBasicAtomic=he,e.isUserTypeDef=ve,e.isCompoundArrayData=be,e.isTurtle=Be,e.isAtomic=Ie,e.isValueString=We,e.isValueNumber=nt,e.isValueBoolean=gt,e.isValueTimestamp=yt,e.isValueDate=ut,e.mergeUniqueKeyRequirement=et;const t=Object.prototype.hasOwnProperty;function r(ie,Ae){return t.call(ie,Ae)?ie[Ae]:void 0}function i(){return Object.create(null)}function o(ie){return"kids"in ie}function s(ie){return"e"in ie}function a(ie){return!(o(ie)||s(ie))}function l(ie){return ie.node==="aggregate"&&["sum","avg","count","distinct"].includes(ie.function)}function u(ie){return ie.node!=="arrayLiteral"&&ie.node!=="recordLiteral"}function d(ie,Ae){if(!("typeDef"in ie)){const Oe=typeof Ae=="string"?{type:Ae}:Ae;if(u(ie))return{...ie,typeDef:{...Oe}}}return ie}function c(ie){return"dstSQLType"in ie}function x(ie){return["string","number","boolean","date","timestamp","timestamptz"].includes(ie)}function f(ie){return ie.node==="dateLiteral"||ie.node==="timestampLiteral"||ie.node==="timestamptzLiteral"}function p(ie){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ie)}function h(ie){return ie.value!==null}function g(ie){var Ae;return(Ae=ie.as)!==null&&Ae!==void 0?Ae:ie.name}function m(ie){return ie===void 0||ie==="scalar"}function E(ie){return ie==="aggregate"||ie==="ungrouped_aggregate"}function v(ie){return ie==="ungrouped_aggregate"}function _(ie){return ie==="aggregate"||ie==="ungrouped_aggregate"||ie==="aggregate_analytic"}function S(ie){return ie==="aggregate"||ie==="scalar_analytic"||ie==="aggregate_analytic"||ie==="ungrouped_aggregate"}function T(ie){return ie==="aggregate_analytic"||ie==="scalar_analytic"}function b(ie){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ie]}function D(ie,Ae){return ie===Ae||b(ie)<b(Ae)}function C(ie,Ae){let Oe="scalar";return(ie==="aggregate"||Ae==="aggregate")&&(Oe="aggregate"),(ie==="ungrouped_aggregate"||Ae==="ungrouped_aggregate")&&(Oe="ungrouped_aggregate"),(ie==="scalar_analytic"||Ae==="scalar_analytic")&&(Oe="scalar_analytic"),(ie==="aggregate_analytic"||Ae==="aggregate_analytic")&&(Oe="aggregate_analytic"),(ie==="scalar_analytic"&&Ae==="aggregate"||ie==="aggregate"&&Ae==="scalar_analytic")&&(Oe="aggregate_analytic"),Oe}function w(ie){return ie.reduce(C,"scalar")}function R(ie){return"e"in ie&&ie.e!==void 0}function O(ie){return ie==="date"||ie==="timestamp"||ie==="timestamptz"}function I(ie){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ie)}function k(ie){return I(ie)||ie==="record"||ie==="array"}function $(ie){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ie)}function Y(ie){return k(ie.type)&&!R(ie)}function ne(ie,Ae){if(te(ie))return re(ie.elementTypeDef,Ae);if(ee(ie)){const{type:je,fields:it,elementTypeDef:dt}=ie;return{type:je,fields:it,elementTypeDef:dt,join:"many",name:Ae}}if(ie.type==="record"){const{type:je,fields:it}=ie;return{type:je,fields:it,join:"one",name:Ae}}const Oe={name:Ae,type:ie.type};switch(ie.type){case"sql native":return{...Oe,rawType:ie.rawType};case"number":{const je=ie.numberType;return je?{...Oe,numberType:je}:Oe}case"date":{const je=ie.timeframe;return je?{name:Ae,type:"date",timeframe:je}:Oe}case"timestamp":{const je={name:Ae,type:"timestamp"};return ie.timeframe&&(je.timeframe=ie.timeframe),je}case"timestamptz":{const je={name:Ae,type:"timestamptz"};return ie.timeframe&&(je.timeframe=ie.timeframe),je}}return Oe}function re(ie,Ae){if(ie.type==="record")return{type:"array",join:"many",name:Ae,elementTypeDef:{type:"record_element"},fields:ie.fields};const Oe=ne(ie,"value");return{type:"array",join:"many",name:Ae,elementTypeDef:ie,fields:[Oe,{...Oe,name:"each",e:{node:"field",path:["value"]}}]}}function oe(ie){return ie.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ie.fields}:{type:"array",elementTypeDef:ie}}function U(ie){return ie.type==="array"&&ie.elementTypeDef.type==="record_element"}function ee(ie){return ie.type==="array"&&ie.elementTypeDef.type==="record_element"}function J(ie){return ie.type==="record"||ie.type==="array"&&"elementTypeDef"in ie&&ie.elementTypeDef.type==="record_element"}function te(ie){return ie.type==="array"&&ie.elementTypeDef.type!=="record_element"}function q(ie){return["left","right","full","inner"].includes(ie)}function H(ie){return["composite","table","sql_select","query_source","virtual","array","record"].includes(ie.type)}function Q(ie){return"join"in ie}function M(ie){return mt(ie)&&Q(ie)}function j(ie){return["day","week","month","quarter","year"].includes(ie)}function P(ie){return j(ie)||["hour","minute","second"].includes(ie)}function V(ie){return P(ie)||ie==="day_of_week"||ie==="day_of_year"}var Z;(function(ie){ie.Date="date",ie.Timestamp="timestamp",ie.Number="number",ie.String="string"})(Z||(e.ValueType=Z={}));function ae(ie){return typeof ie!="string"}function ce(ie){return!!((ie.type==="reduce"||ie.type==="project"||ie.type==="partial")&&(ie.extendSource&&ie.extendSource.some(Ae=>Ae.type==="error")||ie.queryFields.some(Ae=>Ae.type==="error")))}function le(ie){return ie.fields.some(Ae=>Ae.type==="error")}function se(ie){return ie.type==="reduce"}function xe(ie){return ie.type==="partial"}function pe(ie){return ie.type==="project"}function ye(ie){return pe(ie)||se(ie)}function Ce(ie){return ie.rows!==void 0}function me(ie){return ie.percent!==void 0}function _e(ie){return ie.enable!==void 0}function we(ie){return ie.type==="raw"}function Ke(ie){return ie.type==="index"}function rt(ie){return ie.uniqueKeyRequirement===void 0&&ie.analyticFunctionUse===void 0}function ge(ie){var Ae;return(Ae=ie?.fieldUsage)!==null&&Ae!==void 0?Ae:[]}function Ee(ie){var Ae;return(Ae=ie?.givenUsage)!==null&&Ae!==void 0?Ae:[]}function Pe({fieldUsage:ie,givenUsage:Ae}){if(!(ie===void 0&&Ae===void 0))return{fieldUsage:ie??[],...Ae&&{givenUsage:Ae}}}function ke(ie,Ae){return ie&&{...ie,fieldUsage:ie.fieldUsage.map(Ae)}}function Me(ie,Ae){ie.refSummary?ie.refSummary.fieldUsage=Ae:ie.refSummary={fieldUsage:Ae}}function Xe(ie){return"sql"in ie}function at(ie){return"type"in ie&&(ie.type==="sql_select"||ie.type==="query_source")}function Qe(ie){return ie.type==="source_registry_reference"}function Et(ie){return{...ie}}function mt(ie){return ie.type==="table"||ie.type==="sql_select"||ie.type==="query_source"||ie.type==="query_result"||ie.type==="finalize"||ie.type==="nest_source"||ie.type==="virtual"||ie.type==="composite"}function Te(ie){return ie.type==="sql_select"||ie.type==="query_source"}function ze(ie){return M(ie)?!1:!!mt(ie)}function st(ie){return ie==="literal"}function de(...ie){return ie.length<=1&&ie.every(Ae=>Ae==="literal")?"literal":ie.every(Ae=>Ae==="constant"||Ae==="literal")?"constant":ie.every(Ae=>Ae==="output"||Ae==="constant"||Ae==="literal")?"output":"input"}function he(ie){return ie.type==="string"||O(ie.type)||ie.type==="number"||ie.type==="boolean"||ie.type==="json"||ie.type==="sql native"||ie.type==="error"}function ve(ie){return ie.type==="userType"}function be(ie){return Array.isArray(ie)&&(ie.length===0||typeof ie[0]=="object"&&ie[0]!==null&&!Array.isArray(ie[0]))}function Be(ie){return ie.type==="turtle"}function Ie(ie){return k(ie.type)}function We(ie,Ae){return Ae.type==="string"}function nt(ie,Ae){return Ae.type==="number"}function gt(ie,Ae){return Ae.type==="boolean"}function yt(ie,Ae){return Ae.type==="timestamp"}function ut(ie,Ae){return Ae.type==="date"}e.TD={isAtomic(ie){return ie!==void 0&&k(ie.type)},isBasicAtomic(ie){return ie!==void 0&&he({type:ie.type})},isString:ie=>ie?.type==="string",isNumber:ie=>ie?.type==="number",isBoolean:ie=>ie?.type==="boolean",isJSON:ie=>ie?.type==="json",isSQL:ie=>ie?.type==="sql native",isDate:ie=>ie?.type==="date",isTimestamp:ie=>ie?.type==="timestamp",isTimestamptz:ie=>ie?.type==="timestamptz",isAnyTimestamp(ie){return ie?.type==="timestamp"||ie?.type==="timestamptz"},isTemporal(ie){var Ae;const Oe=(Ae=ie?.type)!==null&&Ae!==void 0?Ae:"";return O(Oe)},isError:ie=>ie?.type==="error",atomicDef(ie){if(!e.TD.isAtomic(ie))return{type:"error"};switch(ie.type){case"array":return ee(ie)?{type:"array",elementTypeDef:ie.elementTypeDef,fields:ie.fields}:{type:"array",elementTypeDef:ie.elementTypeDef};case"record":return{type:"record",fields:ie.fields};case"number":return ie.numberType?{type:"number",numberType:ie.numberType}:{type:"number"};case"sql native":return ie.rawType?{type:"sql native",rawType:ie.rawType}:{type:"sql native"};case"timestamp":case"timestamptz":return ie.timeframe?{type:ie.type,timeframe:ie.timeframe}:{type:ie.type};default:return{type:ie.type}}},eq(ie,Ae){if(ie===void 0||Ae===void 0)return!1;function Oe(je,it){const dt={},lt=je.fields||[],ft=it.fields||[];if(lt.length!==ft.length)return!1;for(const It of lt)if(It.name)dt[It.name]=It;else return!1;for(const It of ft)if(!e.TD.eq(dt[It.name],It))return!1;return!0}return ie.type==="array"&&Ae.type==="array"?ie.elementTypeDef.type!==Ae.elementTypeDef.type?!1:ie.elementTypeDef.type!=="record_element"&&Ae.elementTypeDef.type!=="record_element"?e.TD.eq(ie.elementTypeDef,Ae.elementTypeDef):e.TD.isAtomic(ie)&&e.TD.isAtomic(Ae)&&Oe(ie,Ae):ie.type==="record"&&Ae.type==="record"?e.TD.isAtomic(ie)&&e.TD.isAtomic(Ae)&&Oe(ie,Ae):ie.type==="sql native"&&Ae.type==="sql native"?ie.rawType!==void 0&&ie.rawType===Ae.rawType:ie.type===Ae.type}};function et(ie,Ae){return ie?Ae?{isCount:ie.isCount||Ae.isCount}:ie:Ae}})(J3)),J3}var yR;function cs(){if(yR)return fr;yR=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.arg=t,fr.spread=r,fr.sql=i,fr.constant=o,fr.output=s,fr.literal=a,fr.variadicParam=l,fr.param=u,fr.makeParam=d,fr.maxScalar=c,fr.maxAggregate=x,fr.anyExprType=f,fr.maxUngroupedAggregate=p,fr.maxAnalytic=h,fr.minScalar=g,fr.minAggregate=m,fr.minAnalytic=E,fr.overload=v,fr.expandBlueprintMap=te,fr.expandOverrideMapFromBase=Q,fr.def=j;const e=Ge();function t(P){return{node:"function_parameter",name:P}}function r(P,V=void 0,Z=void 0){return{node:"spread",e:P,prefix:V,suffix:Z}}function i(P,...V){const Z={node:"genericSQLExpr",kids:{args:[]},src:[]},ae=[...V];let ce="";for(const le of P){ce+=le;const se=ae.shift();se!==void 0&&(typeof se=="string"?ce+=se:(Z.src.push(ce),Z.kids.args.push(se),ce=""))}return ce.length>0&&Z.src.push(ce),Z}function o(P){return{...P,evalSpace:"constant"}}function s(P){return{...P,evalSpace:"output"}}function a(P){return{...P,evalSpace:"literal"}}function l(P,...V){return{name:P,isVariadic:!0,allowedTypes:V}}function u(P,...V){return{name:P,isVariadic:!1,allowedTypes:V}}function d(P,...V){return{param:u(P,...V),arg:t(P)}}function c(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function x(P){return{...P,expressionType:"aggregate",evalSpace:"input"}}function f(P){return{...P,expressionType:void 0,evalSpace:"input"}}function p(P){return{...P,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function h(P){return{...P,expressionType:"aggregate_analytic",evalSpace:"input"}}function g(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function m(P){return{...P,expressionType:"aggregate",evalSpace:"input"}}function E(P){return{...P,expressionType:"scalar_analytic",evalSpace:"input"}}function v(P,V,Z,ae){return{returnType:P,params:V,e:Z,needsWindowOrderBy:ae?.needsWindowOrderBy,between:ae?.between,isSymmetric:ae?.isSymmetric,supportsOrderBy:ae?.supportsOrderBy,defaultOrderByArgIndex:ae?.defaultOrderByArgIndex,supportsLimit:ae?.supportsLimit}}function _(P,V=!0,Z=!0){if(!V&&P==="any")throw new Error("Return type cannot include any");if(typeof P=="string")return{type:P};if("array"in P){const ae=V?_(P.array,!0):_(P.array,!1);return ae.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ae.fields}:{type:"array",elementTypeDef:ae}}else if("record"in P){const ae=[];for(const[ce,le]of Object.entries(P.record)){const se=V?_(le,!0):_(le,!1);e.TD.isAtomic(se)&&ae.push((0,e.mkFieldDef)(se,ce))}return{type:"record",fields:ae}}else if("generic"in P){if(!Z)throw new Error("Cannot use generic");return{type:"generic",generic:P.generic}}else if("sql_native"in P)return{type:"sql native",rawType:P.sql_native};throw new Error("Cannot figure out type")}function S(P){if(P==="any")throw new Error("Cannot return any type");if(typeof P=="string")return g({type:P});if("array"in P)return f(_(P,!1));if("record"in P)return f(_(P,!1));if("generic"in P)return g(_(P,!1));if("literal"in P)return a(g(_(P.literal,!1)));if("constant"in P)return o(g(_(P.constant,!1)));if("dimension"in P)return g(_(P.dimension,!1));if("measure"in P)return m(_(P.measure,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return E(_(P.calculation,!1));throw new Error("Invalid function blueprint")}function T(P){return typeof P=="string"||"array"in P||"record"in P||"generic"in P||"literal"in P||"constant"in P||"dimension"in P||"measure"in P||"calculation"in P||"sql_native"in P}function b(P){return T(P)?[P]:Array.isArray(P)?P:T(P.variadic)?[P.variadic]:P.variadic}function D(P){if(typeof P=="string")return f({type:P});if("generic"in P)return f(_(P));if("literal"in P)return a(c(_(P.literal)));if("constant"in P)return o(c(_(P.constant)));if("dimension"in P)return c(_(P.dimension));if("measure"in P)return x(_(P.measure));if("array"in P)return f(_(P,!1));if("record"in P)return f(_(P,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return h(_(P.calculation));throw new Error("Invalid function blueprint")}function C(P){return P.map(V=>D(V))}function w(P){return typeof P!="string"&&"variadic"in P}function R(P,V){return{name:P,allowedTypes:C(b(V)),isVariadic:w(V)}}function O(P){return Object.entries(P).map(Z=>R(Z[0],Z[1]))}function I(P){const V=[],Z=[];let ae=P;for(;ae.length>0;){const le=ae.indexOf("${");if(le===-1){V.push(ae);break}const se=ae.slice(0,le);ae=ae.slice(le);const xe=ae.indexOf("}");if(xe===-1){V.push(se+ae);break}const pe=ae.slice(2,xe);ae=ae.slice(xe+1);const ye=pe.startsWith("..."),Ce=pe.endsWith(":"),me=ye?pe.slice(3):Ce?pe.slice(0,-1):pe,_e={node:"function_parameter",name:me};V.push(se),ye?Z.push({node:"spread",e:_e,prefix:"",suffix:""}):Ce&&me==="order_by"?Z.push({node:"aggregate_order_by"}):Ce&&me==="limit"?Z.push({node:"aggregate_limit"}):Z.push(_e)}return{node:"genericSQLExpr",kids:{args:Z},src:V}}function k(P,V){return w(V)?{node:"spread",e:{node:"function_parameter",name:P},prefix:"",suffix:""}:{node:"function_parameter",name:P}}function $(P,V){const Z=Object.entries(V.takes),ae=Z.length>0?Z.length-1:0;return{node:"genericSQLExpr",kids:{args:Z.map(ce=>k(ce[0],ce[1]))},src:[`${P}(`,...Array(ae).fill(","),")"]}}function Y(P){return"sql"in P.impl?I(P.impl.sql):"expr"in P.impl?P.impl.expr:$(P.impl.function,P)}function ne(P){return{e:Y(P),between:P.impl.between,needsWindowOrderBy:P.impl.needsWindowOrderBy,defaultOrderByArgIndex:P.impl.defaultOrderByArgIndex}}function re(P){if(P!==void 0)return Object.entries(P).map(([V,Z])=>({name:V,acceptibleTypes:Z.map(ae=>_(ae,!0,!1))}))}function oe(P){return{returnType:S(P.returns),params:O(P.takes),isSymmetric:P.isSymmetric,supportsOrderBy:P.supportsOrderBy,supportsLimit:P.supportsLimit,genericTypes:re(P.generic),...ne(P)}}function U(P){return"takes"in P&&"returns"in P&&"impl"in P}function ee(P){return"function"in P||"sql"in P||"expr"in P}function J(P){return U(P)?[oe(P)]:Object.values(P).flatMap(V=>oe(V))}function te(P){const V={};for(const Z in P)V[Z]=J(P[Z]);return V}function q(P,V){return[oe({...P,impl:V})]}function H(P,V,Z){if(ee(Z)){if(!U(V))throw new Error(`Malformed function override: ${P}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(V)})`);return q(V,Z)}else{if(U(V))throw new Error(`Malformed function override: ${P}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(Z)})`);return Object.entries(Z).flatMap(([ae,ce])=>{const le=V[ae];if(le===void 0)throw new Error(`Malformed function override: ${P}. No overload named ${ae}`);return q(le,ce)})}}function Q(P,V){const Z={};for(const ae in V){if(!(ae in P))throw new Error(`Malformed function override: ${ae}. No such function in Malloy standard`);Z[ae]=H(ae,P[ae],V[ae])}return Z}function*M(P){if(typeof P!="string"){if("generic"in P)yield P;else if("record"in P)for(const V of Object.values(P.record))yield*M(V);else for(const V of["array","literal","measure","dimension","measure","constant","cacluation"])if(V in P){yield*M(P[V]);return}}}function j(P,V,Z,ae={}){let ce=!1;const le={};for(const xe of Object.values(V))for(const pe of M(xe))le[pe.generic]=["any"],ce=!0;ce&&ae.generic===void 0&&(ae.generic=le);const se={takes:V,returns:Z,impl:{function:P.toUpperCase()},...ae};return{[P]:se}}return fr}var X3={},Rx={},ER;function fA(){if(ER)return Rx;ER=1,Object.defineProperty(Rx,"__esModule",{value:!0}),Rx.decodeDottedTablePath=e,Rx.validateDottedTablePath=t;function e(o,s){const{quoteChar:a,escapeStyle:l,bareIdentRegex:u,dialectName:d}=s;if(o.length===0)return{ok:!1,error:`${d} table path is empty`};const c=[];let x=0;for(;;){let f,p;if(o[x]===a){const h=r(o,x,a,l);if(h===null)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — unterminated quoted segment`};f=h.decoded,p=!0,x=h.end}else{const h=o.slice(x).match(u);if(!h||h.index!==0||h[0].length===0)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — invalid segment at position ${x}`};f=h[0],p=!1,x+=h[0].length}if(f.includes(";")||f.includes("--"))return{ok:!1,error:`Invalid ${d} table path: segment ${JSON.stringify(f)} contains forbidden character; even when quoted, table-path segments may not contain \`;\` or \`--\`.`};if(c.push({value:f,quoted:p}),x===o.length)return{ok:!0,segments:c};if(o[x]!==".")return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — expected '.' at position ${x}`};if(x++,x===o.length)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — trailing dot`}}}function t(o,s){const a=e(o,s);return a.ok?{ok:!0,canonical:o}:a}function r(o,s,a,l){let u=s+1,d="";for(;u<o.length;){if(l==="backslash"&&o[u]==="\\"){if(u+1>=o.length)return null;d+=i(o[u+1]),u+=2;continue}if(o[u]===a){if(l==="doubled"&&o[u+1]===a){d+=a,u+=2;continue}return{decoded:d,end:u+1}}d+=o[u],u++}return null}function i(o){switch(o){case"n":return`
|
|
2
2
|
`;case"t":return" ";case"r":return"\r";default:return o}}return Rx}var vR;function Vs(){return vR||(vR=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Dialect=e.dayIndex=e.EscapeStyle=e.MAX_DECIMAL38=e.MIN_DECIMAL38=e.MAX_INT128=e.MIN_INT128=e.MAX_INT64=e.MIN_INT64=e.MAX_INT32=e.MIN_INT32=void 0,e.inDays=o,e.qtz=s,e.turtleGroupSetCondition=a;const t=Ge(),r=fA();e.MIN_INT32=-2147483648,e.MAX_INT32=2147483647,e.MIN_INT64=BigInt("-9223372036854775808"),e.MAX_INT64=BigInt("9223372036854775807"),e.MIN_INT128=BigInt("-170141183460469231731687303715884105728"),e.MAX_INT128=BigInt("170141183460469231731687303715884105727"),e.MIN_DECIMAL38=BigInt("-99999999999999999999999999999999999999"),e.MAX_DECIMAL38=BigInt("99999999999999999999999999999999999999"),e.EscapeStyle={Doubled:"doubled",Backslash:"backslash",Unset:"unset"};const i=["microsecond","millisecond","second","minute","hour","day","week","month","quarter","year"];e.dayIndex=i.indexOf("day");function o(u){return i.indexOf(u)>=e.dayIndex}function s(u){const d=u.queryTimezone;if(!(d===void 0||d===u.systemTimezone))return d}function a(u,d){return u===void 0?d:d?`group_set=${u} AND ${d}`:`group_set=${u}`}class l{constructor(){this.cantPartitionWindowFunctionsOnExpressions=!1,this.supportsPipelinesInViews=!0,this.supportsNestedProjectionLimit=!1,this.supportsArraysInData=!0,this.hasTimestamptz=!1,this.readsNestedData=!0,this.orderByClause="ordinal",this.nullMatchesFunctionSignature=!0,this.supportsSelectReplace=!0,this.supportsBigIntPrecision=!0,this.supportsComplexFilteredSources=!0,this.supportsTempTables=!0,this.maxIdentifierLength=128,this.hasModOperator=!0,this.supportsLeftJoinUnnest=!0,this.requiresExplicitUnnestOrdering=!1,this.hasLateralColumnAliasInSelect=!1,this.supportsCountApprox=!1,this.supportsHyperLogLog=!1,this.supportsFullJoin=!0,this.nestedArrays=!0,this.compoundObjectInSchema=!0,this.booleanType="supported",this.likeEscape=!0,this.integerTypeMappings=[{min:BigInt(e.MIN_INT32),max:BigInt(e.MAX_INT32),numberType:"integer"},{min:e.MIN_INT64,max:e.MAX_INT64,numberType:"bigint"}],this.tablePathBareIdentRegex=/^[A-Za-z_][A-Za-z0-9_]*/,this.identifierQuoteChar="",this.stringLiteralStyle=e.EscapeStyle.Unset,this.identifierEscapeStyle=e.EscapeStyle.Unset}sqlLateralJoinBag(d){throw this.cantPartitionWindowFunctionsOnExpressions?new Error(`Dialect '${this.name}' sets cantPartitionWindowFunctionsOnExpressions but does not implement sqlLateralJoinBag`):new Error("Internal error: sqlLateralJoinBag called but cantPartitionWindowFunctionsOnExpressions is false")}literalNumberType(d){if(!/^-?\d+$/.test(d))return{type:"number",numberType:"float"};const x=BigInt(d);for(const f of this.integerTypeMappings)if(x>=f.min&&x<=f.max)return{type:"number",numberType:f.numberType};return{type:"number",numberType:"bigint"}}static makeTimeLiteralNode(d,c,x,f,p){var h;const g=(h=d?.hasTimestamptz)!==null&&h!==void 0?h:!1;return p==="date"?{node:"dateLiteral",literal:c,typeDef:{type:"date",timeframe:f!==void 0&&(0,t.isDateUnit)(f)?f:void 0}}:x&&g?{node:"timestamptzLiteral",literal:c,typeDef:{type:"timestamptz",timeframe:f},timezone:x}:x?{node:"timestampLiteral",literal:c,typeDef:{type:"timestamp",timeframe:f},timezone:x}:{node:"timestampLiteral",literal:c,typeDef:{type:"timestamp",timeframe:f}}}sqlValidateTableName(d){if(this.identifierEscapeStyle!==e.EscapeStyle.Doubled&&this.identifierEscapeStyle!==e.EscapeStyle.Backslash)throw new Error(`${this.name}: sqlValidateTableName requires identifierEscapeStyle to be set to Doubled or Backslash (or override sqlValidateTableName).`);return(0,r.validateDottedTablePath)(d,{quoteChar:this.identifierQuoteChar,escapeStyle:this.identifierEscapeStyle,bareIdentRegex:this.tablePathBareIdentRegex,dialectName:this.name})}sqlTurtleOrderByClause(d){const c=d.map(x=>` ${x.field} ${x.dir.toUpperCase()}`);return" "+this.sqlOrderBy(c,"turtle")}sqlFinalStage(d,c){throw new Error("Dialect has no final Stage but called Anyway")}sqlDateToString(d){return this.castToString(`DATE(${d})`)}escapeBackslashStyle(d,c){let x="";for(const f of d)switch(f){case"\\":x+="\\\\";break;case`
|
|
3
3
|
`:x+="\\n";break;case"\r":x+="\\r";break;case" ":x+="\\t";break;case c:x+="\\"+c;break;default:x+=f}return x}sqlQuoteIdentifier(d){const c=this.identifierQuoteChar;if(!c)throw new Error(`${this.name}: identifierQuoteChar is not set. Set it on the dialect (e.g. '"' or "\`"), or override sqlQuoteIdentifier.`);if(this.identifierEscapeStyle===e.EscapeStyle.Doubled)return c+d.split(c).join(c+c)+c;if(this.identifierEscapeStyle===e.EscapeStyle.Backslash)return c+this.escapeBackslashStyle(d,c)+c;throw new Error(`${this.name}: identifierEscapeStyle is not set. Set it to EscapeStyle.Doubled or EscapeStyle.Backslash on the dialect, or override sqlQuoteIdentifier.`)}sqlLiteralNumber(d){return d}ignoreInProject(d){return!1}needsCivilTimeComputation(d,c,x,f){const p=["day","week","month","quarter","year"],h=c!==void 0&&p.includes(c),g=x!==void 0&&p.includes(x),m=s(f);return{needed:t.TD.isAnyTimestamp(d)&&(h||g)&&m!==void 0,tz:m}}sqlTruncAndOffset(d,c,x,f){if(t.TD.isAnyTimestamp(d.typeDef)){const{needed:h,tz:g}=this.needsCivilTimeComputation(d.typeDef,x,f?.unit,c);if(h&&g){const m=this.sqlConvertToCivilTime(d.sql,g,d.typeDef);let E=m.sql;const v=m.typeDef;return x&&(E=this.sqlTruncate(E,x,v,!0,g)),f&&(E=this.sqlOffsetTime(E,f.op,f.magnitude,f.unit,v,!0,g)),this.sqlConvertFromCivilTime(E,g,d.typeDef)}}let p=d.sql;return x&&(p=this.sqlTruncate(p,x,d.typeDef,!1,s(c))),f&&(p=this.sqlOffsetTime(p,f.op,f.magnitude,f.unit,d.typeDef,!1,s(c))),p}sqlLiteralString(d){if(this.stringLiteralStyle==="doubled")return"'"+d.split("'").join("''")+"'";if(this.stringLiteralStyle==="backslash")return"'"+this.escapeBackslashStyle(d,"'")+"'";throw new Error(`${this.name}: stringLiteralStyle is not set. Set it to EscapeStyle.Doubled or EscapeStyle.Backslash on the dialect, or override sqlLiteralString.`)}sqlLiteralRegexp(d){return this.sqlLiteralString(d)}exprToSQL(d,c){switch(c.node){case"now":return this.sqlNowExpr();case"timeDiff":return this.sqlMeasureTimeExpr(c);case"delta":{const x=c.kids.base;return x.node==="trunc"?this.sqlTruncAndOffset(x.e,d,x.units,{op:c.op,magnitude:c.kids.delta.sql,unit:c.units}):this.sqlTruncAndOffset(x,d,void 0,{op:c.op,magnitude:c.kids.delta.sql,unit:c.units})}case"trunc":return this.sqlTruncAndOffset(c.e,d,c.units);case"extract":return this.sqlTimeExtractExpr(d,c);case"cast":return this.sqlCast(d,c);case"regexpMatch":return this.sqlRegexpMatch(c);case"/":return this.divisionIsInteger?`${c.kids.left.sql}*1.0/${c.kids.right.sql}`:void 0;case"%":return this.hasModOperator?void 0:`MOD(${c.kids.left.sql},${c.kids.right.sql})`;case"dateLiteral":return this.sqlDateLiteral(d,c.literal);case"timestampLiteral":return this.sqlTimestampLiteral(d,c.literal,c.timezone);case"timestamptzLiteral":return this.sqlTimestamptzLiteral(d,c.literal,c.timezone);case"stringLiteral":return this.sqlLiteralString(c.literal);case"numberLiteral":return this.sqlLiteralNumber(c.literal);case"regexpLiteral":return this.sqlLiteralRegexp(c.literal);case"recordLiteral":return this.sqlLiteralRecord(c);case"arrayLiteral":return this.sqlLiteralArray(c)}}sqlSumDistinct(d,c,x){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(d,c,x){return"sqlAggDistinct called but not implemented"}sqlSampleTable(d,c){if(c!==void 0)throw new Error(`Sampling is not supported on dialect ${this.name}.`);return d}sqlOrderBy(d,c){return`ORDER BY ${d.join(",")}`}sqlTzStr(d){return`"${d.queryTimezone}"`}sqlMakeUnnestKey(d,c){return this.concat(d,"'x'",c)}sqlStringAggDistinct(d,c,x){const f="__STRING_AGG_KS__",p="__STRING_AGG_KE__";return`REGEXP_REPLACE(
|
|
4
4
|
STRING_AGG(DISTINCT ${`concat('${f}', ${d}, '${p}', ${c})`}${x.length>0?","+x:""}),
|
|
@@ -1303,7 +1303,7 @@ ${te}`:U=te}return U}childRequest(U){var ee;const J=decodeURI(new URL(U,this.sou
|
|
|
1303
1303
|
`)}}this.stream.write(`
|
|
1304
1304
|
]
|
|
1305
1305
|
`),this.stream.close()}}Da.JSONWriter=r;class i extends t{constructor(){super(...arguments),this.columnSeparator=",",this.rowSeparator=`
|
|
1306
|
-
`,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(s){const a=s.includes(this.quoteCharacter),l=s.includes(this.columnSeparator),u=s.includes(this.rowSeparator),d=l||a||u;return a&&(s=s.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),d&&(s=this.quoteCharacter+s+this.quoteCharacter),s}stringify(s){return s===null?this.emptyCell:s instanceof Date?s.toISOString():typeof s=="boolean"||typeof s=="number"?JSON.stringify(s):typeof s=="bigint"?s.toString():`${s}`}getColWeight(s){let a=s;Array.isArray(s)&&(a=s[0]);let l=0;for(const u in a){l=l+1;const d=a[u];if((0,e.isCompoundArrayData)(d)){const c=this.getColWeight(d)-1;l=l+c}}return l}getHeaderRow(s){const a=[];let l=0;for(const u in s){a.push(this.escape(u));const d=s[u];if(l++,(0,e.isCompoundArrayData)(d)){const c=this.getColWeight(d)-1;l=l+c;for(let x=0;x<c;x++)a.push(this.emptyCell)}}return{rows:[a.join(this.columnSeparator)],length:1,width:l}}mergeMatrices(s){const a=Math.max(...s.map(d=>d.length)),l=s.reduce((d,c)=>d+c.width,0),u=[];for(let d=0;d<a;d++){const c=[];for(const x of s)if(d<x.length)c.push(x.rows[d]);else{const f=Array(x.width).fill(this.emptyCell);c.push(...f)}u.push(c.join(this.columnSeparator))}return{rows:u,length:a,width:l}}getChildMatrix(s){if(Array.isArray(s)){if(s.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const a=[],l=this.getHeaderRow(s[0]);a.push(...l.rows);const u=l.width;let d=1;for(const c of s){const x=this.getRowMatrix(c);d=d+x.length,a.push(...x.rows)}return{rows:a,length:d,width:u}}getRowMatrix(s){const a=[];for(const l in s){const u=s[l];if((0,e.isCompoundArrayData)(u)){const d=this.getChildMatrix(u);a.push(d)}else{const d={rows:[this.stringify(u)],length:1,width:1};a.push(d)}}return this.mergeMatrices(a)}async process(s){let a=!1;for await(const l of s){if(!a&&this.includeHeader){const d=this.getHeaderRow(l.toObject());this.stream.write(d.rows[0]),this.stream.write(this.rowSeparator),a=!0}const u=this.getRowMatrix(l.toObject());for(const d of u.rows)this.stream.write(d),this.stream.write(this.rowSeparator)}this.stream.close()}}return Da.CSVWriter=i,Da}var Vr={},hu={},Qy={},jn={},_8;function cf(){if(_8)return jn;_8=1,Object.defineProperty(jn,"__esModule",{value:!0}),jn.isConnectionConfigEntry=e,jn.registerConnectionType=r,jn.getConnectionProperties=i,jn.getConnectionTypeDisplayName=o,jn.getRegisteredConnectionTypes=s,jn.getConnectionTypeDef=a,jn.validateConnectionConfigProperties=l,jn.readConnectionsConfig=u,jn.writeConnectionsConfig=d,jn.createConnectionsFromConfig=c;function e(x){return typeof x=="object"&&x!==null&&typeof x.is=="string"}const t=new Map;function r(x,f){t.set(x,f)}function i(x){var f;return(f=t.get(x))===null||f===void 0?void 0:f.properties}function o(x){var f;return(f=t.get(x))===null||f===void 0?void 0:f.displayName}function s(){return[...t.keys()]}function a(x){return t.get(x)}function l(x,f,p){var h,g;const m=(g=(h=t.get(f))===null||h===void 0?void 0:h.properties)!==null&&g!==void 0?g:[];for(const E of m){if(!E.requireLiteralString)continue;const v=p[E.name];if(v!==void 0&&typeof v!="string")throw new Error(`Connection "${x}" property "${E.name}" must be a literal string`)}}function u(x){var f;const p=JSON.parse(x),h=Object.fromEntries(Object.entries((f=p.connections)!==null&&f!==void 0?f:{}).filter(([,g])=>e(g)));return{...p,connections:h}}function d(x){return JSON.stringify(x,null,2)}function c(x,f){const p=Object.entries(x.connections),h=p.length>0?p[0][0]:void 0,g=new Map;return{async lookupConnection(m){if(m===void 0&&(m=h),m===void 0)throw new Error("No connections defined in config");const E=g.get(m);if(E)return E;const v=x.connections[m];if(!v)throw new Error(`No connection named "${m}" found in config`);const _=t.get(v.is);if(!_)throw new Error(`No registered connection type "${v.is}" for connection "${m}". Did you forget to import the connection package?`);const S={name:m};for(const[b,D]of Object.entries(v))b!=="is"&&D!=null&&(S[b]=D);l(m,v.is,S);const T=await _.factory(S);return f&&f(m,T),g.set(m,T),T},async close(){const m=[...g.values()];g.clear();for(const E of m)await E.close()},async idle(){for(const m of g.values())await m.idle()}}}return jn}var S8;function _z(){if(S8)return Qy;S8=1,Object.defineProperty(Qy,"__esModule",{value:!0}),Qy.compileConfig=o;const e=cf(),t=f9(),r={connections:s,manifestPath:u,givensPath:d,finalizeGivens:c,virtualMap:x,includeDefaultConnections:f},i=new Set(Object.keys(r));function o(v){const _=[],S={kind:"dict",entries:{}};if(!h(v))return _.push({message:"config is not a JSON object",severity:"error",code:"config-validation"}),{compiled:S,log:_};for(const[T,b]of Object.entries(v)){const D=r[T];if(!D){const w=(0,t.closestMatch)(T,[...i]),R=w?`. Did you mean "${w}"?`:"";_.push(g(T,`unknown config key "${T}"${R}`));continue}const C=D(b,_);C!==void 0&&(S.entries[T]=C)}return{compiled:S,log:_}}function s(v,_){if(!h(v)){_.push(g("connections",'"connections" should be an object'));return}const S=new Set((0,e.getRegisteredConnectionTypes)()),T={kind:"dict",entries:{}};for(const[b,D]of Object.entries(v)){const C=`connections.${b}`;if(!h(D)){_.push(g(C,"should be an object"));continue}const w=D.is;if(w==null||w===""){_.push(g(C,'missing required "is" field (connection type)'));continue}if(typeof w!="string"){_.push(g(`${C}.is`,'"is" should be a string'));continue}if(!S.has(w)){const O=(0,t.closestMatch)(w,[...S]),I=O?` Did you mean "${O}"?`:"";_.push(g(`${C}.is`,`unknown connection type "${w}".${I} Available types: ${[...S].join(", ")}`));continue}const R=a(C,w,D,_);T.entries[b]=R}return T}function a(v,_,S,T){var b;const D=(b=(0,e.getConnectionProperties)(_))!==null&&b!==void 0?b:[],C=new Map(D.map(R=>[R.name,R])),w={kind:"dict",entries:{}};w.entries.is={kind:"value",value:_};for(const[R,O]of Object.entries(S)){if(R==="is")continue;const I=C.get(R);if(!I){const $=(0,t.closestMatch)(R,[...C.keys()]),Y=$?`. Did you mean "${$}"?`:"";T.push(g(`${v}.${R}`,`unknown property "${R}" for connection type "${_}"${Y}`));continue}const k=l(`${v}.${R}`,I,O,T);k!==void 0&&(w.entries[R]=k)}return w}function l(v,_,S,T){if(S==null)return;if(_.type==="json")return{kind:"value",value:S};const b=p(S);if(b!==void 0)return _.requireLiteralString?(T.push(g(v,"must be a literal string and cannot use an overlay reference")),{kind:"value",value:S}):b;const D=E(S,_.type);if(D){if(_.requireLiteralString)return T.push(g(v,`must be a literal string, got ${m(S)}`)),{kind:"value",value:S};T.push(g(v,`${D} (expected ${_.type})`));return}return{kind:"value",value:S}}function u(v,_){const S=p(v);if(S!==void 0)return S;if(typeof v!="string"){_.push(g("manifestPath",'"manifestPath" should be a string or an overlay reference'));return}return{kind:"value",value:v}}function d(v,_){const S=p(v);if(S!==void 0)return S;if(typeof v!="string"){_.push(g("givensPath",'"givensPath" should be a string or an overlay reference'));return}return{kind:"value",value:v}}function c(v,_){if(!Array.isArray(v)||!v.every(S=>typeof S=="string")){_.push(g("finalizeGivens",'"finalizeGivens" should be an array of given names'));return}return{kind:"value",value:v}}function x(v,_){return{kind:"value",value:v}}function f(v,_){return{kind:"value",value:v}}function p(v){if(typeof v!="object"||v===null||Array.isArray(v))return;const _=Object.keys(v);if(_.length!==1)return;const S=_[0],T=v[S];if(typeof T=="string")return{kind:"reference",source:S,path:[T]};if(Array.isArray(T)&&T.every(b=>typeof b=="string"))return{kind:"reference",source:S,path:T}}function h(v){return typeof v=="object"&&v!==null&&!Array.isArray(v)}function g(v,_){return{message:`${v}: ${_}`,severity:"warn",code:"config-validation"}}function m(v){return Array.isArray(v)?"array":typeof v}function E(v,_){switch(_){case"number":if(typeof v!="number")return`should be a number, got ${typeof v}`;break;case"boolean":if(typeof v!="boolean")return`should be a boolean, got ${typeof v}`;break;case"string":case"password":case"secret":case"file":case"text":if(typeof v!="string")return`should be a string, got ${typeof v}`;break}}return Qy}var Wy={},Xc={},C8;function gT(){if(C8)return Xc;C8=1;var e={};Object.defineProperty(Xc,"__esModule",{value:!0}),Xc.envOverlay=t,Xc.contextOverlay=r,Xc.defaultConfigOverlays=i,Xc.isThenable=o;function t(){return typeof process>"u"||!e?()=>{}:s=>e[s[0]]}function r(s){return a=>s[a[0]]}function i(){return{env:t(),config:()=>{}}}function o(s){return typeof s=="object"&&s!==null&&"then"in s&&typeof s.then=="function"}return Xc}var A8;function Sz(){if(A8)return Wy;A8=1,Object.defineProperty(Wy,"__esModule",{value:!0}),Wy.prepareConfig=r;const e=cf(),t=gT();function r(l,u,d){let c={},x,f,p,h,g=!1;for(const[m,E]of Object.entries(l.entries))switch(m){case"connections":{if(E.kind!=="dict")break;c=o(E);break}case"manifestPath":{x=a(E,u,d,"manifestPath");break}case"givensPath":{f=a(E,u,d,"givensPath");break}case"finalizeGivens":{E.kind==="value"&&i(E.value)&&(p=E.value);break}case"virtualMap":{E.kind==="value"&&(h=E.value);break}case"includeDefaultConnections":{E.kind==="value"&&typeof E.value=="boolean"&&(g=E.value);break}}return g&&s(c),{compiledConnections:c,manifestPath:x,givensPath:f,finalizeGivens:p,virtualMap:h}}function i(l){return Array.isArray(l)&&l.every(u=>typeof u=="string")}function o(l){const u={};for(const[d,c]of Object.entries(l.entries))c.kind==="dict"&&(u[d]=c);return u}function s(l){for(const u of(0,e.getRegisteredConnectionTypes)())l[u]||(l[u]={kind:"dict",entries:{is:{kind:"value",value:u}}})}function a(l,u,d,c){if(l.kind==="value")return typeof l.value=="string"?l.value:void 0;if(l.kind==="reference"){const x=u[l.source];if(!x){d.push({message:`unknown overlay source "${l.source}" for "${c}"`,severity:"warn",code:"config-overlay"});return}const f=x(l.path);if((0,t.isThenable)(f)){d.push({message:`the \`${l.source}\` overlay returned a Promise for "${c}"; top-level string settings must resolve synchronously`,severity:"warn",code:"config-overlay"});return}return typeof f=="string"?f:void 0}}return Wy}var zy={},T8;function Cz(){if(T8)return zy;T8=1,Object.defineProperty(zy,"__esModule",{value:!0}),zy.buildManagedLookup=t;const e=cf();function t(l,u,d){const c=Object.entries(l),x=c.length>0?c[0][0]:void 0,f=new Map;return{async lookupConnection(p){if(p===void 0&&(p=x),p===void 0)throw new Error("No connections defined in config");const h=f.get(p);if(h)return h;const g=l[p];if(!g)throw new Error(`No connection named "${p}" found in config`);const m=await r(g,u,d);if(typeof m.is!="string")throw new Error(`Connection "${p}" is missing a valid "is" field`);const E=(0,e.getConnectionTypeDef)(m.is);if(!E)throw new Error(`No registered connection type "${m.is}" for connection "${p}". Did you forget to import the connection package?`);const v={name:p};for(const[S,T]of Object.entries(m))S!=="is"&&T!=null&&(v[S]=T);(0,e.validateConnectionConfigProperties)(p,m.is,v);const _=await E.factory(v);return f.set(p,_),_},async close(){const p=[...f.values()];f.clear();for(const h of p)await h.close()},async idle(){for(const p of f.values())await p.idle()}}}async function r(l,u,d){const c=await i(l,u,d);if(!(0,e.isConnectionConfigEntry)(c))throw new Error("Connection entry did not resolve to a valid {is: string, ...} dict");return await s(c,u),c}async function i(l,u,d){switch(l.kind){case"value":return l.value;case"reference":return o(l,u,d);case"dict":{const c={};for(const[x,f]of Object.entries(l.entries)){const p=await i(f,u,d);p!==void 0&&(c[x]=p)}return c}}}async function o(l,u,d){const c=u[l.source];if(!c){d.push({message:`unknown overlay source "${l.source}" for reference path ${JSON.stringify(l.path)}`,severity:"warn",code:"config-overlay"});return}return await c(l.path)}async function s(l,u){var d;const c=l.is;if(typeof c!="string")return;const x=(d=(0,e.getConnectionProperties)(c))!==null&&d!==void 0?d:[];for(const f of x){if(f.default===void 0||l[f.name]!==void 0)continue;const p=await a(f.default,u);p!==void 0&&(l[f.name]=p)}}async function a(l,u){if(typeof l!="object")return l;const d=Object.keys(l);if(d.length!==1)return;const c=d[0],x=l[c],f=typeof x=="string"?[x]:x;if(!Array.isArray(f))return;const p=u[c];if(p)return await p(f)}return zy}var b8;function yT(){if(b8)return hu;b8=1,Object.defineProperty(hu,"__esModule",{value:!0}),hu.MalloyConfig=hu.Manifest=void 0,hu.isBuildManifestEntry=v;const e=_z(),t=Sz(),r=Cz(),i=gT(),o=YE();class s{constructor(){this._manifest={entries:{},strict:!1},this._touched=new Set}loadText(S){this._clearEntries(),this._touched.clear(),this._manifest.strict=!1,this._loadParsed(JSON.parse(S))}get buildManifest(){return this._manifest}get strict(){var S;return(S=this._manifest.strict)!==null&&S!==void 0?S:!1}set strict(S){this._manifest.strict=S}update(S,T){(0,o.requireCanonicalTablePathAnyDialect)(T.tableName,`Manifest entry '${S}'`),this._manifest.entries[S]=T,this._touched.add(S)}touch(S){this._touched.add(S)}get activeEntries(){const S={};for(const T of this._touched)this._manifest.entries[T]&&(S[T]=this._manifest.entries[T]);return{entries:S,strict:this._manifest.strict}}_clearEntries(){for(const S of Object.keys(this._manifest.entries))delete this._manifest.entries[S]}_loadParsed(S){typeof S.strict=="boolean"&&(this._manifest.strict=S.strict);const T=E(S.entries)?S.entries:S;for(const[b,D]of Object.entries(T))b==="strict"||!v(D)||((0,o.requireCanonicalTablePathAnyDialect)(D.tableName,`Manifest entry '${b}'`),this._manifest.entries[b]=D)}}hu.Manifest=s;class a{constructor(S,T){const b=[];let D;if(typeof S=="string")try{D=JSON.parse(S)}catch($){b.push({message:`Invalid JSON: ${$ instanceof Error?$.message:String($)}`,severity:"error",code:"config-validation"}),D={}}else D=S;const C=(0,e.compileConfig)(D);b.push(...C.log);const w=x(T,b),R=g(w.configURL,"configURL",b),O=w.rootDirectory,I={...(0,i.defaultConfigOverlays)(),...w.overlays,config:(0,i.contextOverlay)({configURL:R,rootDirectory:O})},k=(0,t.prepareConfig)(C.compiled,I,b);this._managedLookup=(0,r.buildManagedLookup)(k.compiledConnections,I,b),this._connections=this._managedLookup,this._overlays=I,this.virtualMap=m(k.virtualMap,b),this.configURL=R,this.rootDirectory=O,this.manifestPath=k.manifestPath,this.manifestURL=d(k.manifestPath,R),this.givensPath=k.givensPath,this.givensURL=c(k.givensPath,R,b),this.finalizeGivens=k.finalizeGivens,this.log=b}get connections(){return this._connections}wrapConnections(S){this._connections=S(this._connections)}async shutdown(S="close"){S==="idle"?await this._managedLookup.idle():await this._managedLookup.close()}async releaseConnections(){await this.shutdown("close")}async readOverlay(S,...T){var b,D;return await((D=(b=this._overlays)[S])===null||D===void 0?void 0:D.call(b,T))}}hu.MalloyConfig=a;const l="MANIFESTS",u="malloy-manifest.json";function d(_,S){if(!S)return;let T;try{T=new URL(S)}catch{return}const b=_??l;let D;try{D=new URL(b,T)}catch{return}const C=D.toString(),w=C.endsWith("/")?D:new URL(C+"/");return new URL(u,w).toString()}function c(_,S,T){if(!_)return;if(!S){T.push({message:"givensPath is set but no configURL is available; per-runtime givens will not be loaded. Pass `configURL` (or use an absolute URL such as `file:///...`).",severity:"warn",code:"config-overlay"});return}let b;try{b=new URL(S)}catch{return}try{return new URL(_,b).toString()}catch(D){const C=D instanceof Error?D.message:String(D);T.push({message:`givensPath '${_}' could not be resolved against configURL '${S}': ${C}`,severity:"warn",code:"config-validation"});return}}function x(_,S){if(_===void 0)return{};if(f(_))return p(_,S);const T=_;if(T.overlays&&"config"in T.overlays){S.push({message:"`config` is reserved by MalloyConfig; pass `configURL` and `rootDirectory` directly instead. Supplied `overlays.config` ignored.",severity:"warn",code:"config-overlay"});const{config:b,...D}=T.overlays;return{...T,overlays:D}}return T}function f(_){for(const S of Object.values(_))if(typeof S=="function")return!0;return!1}function p(_,S){const T=_.config;if(!T)return{overlays:_};const b=h(T,"configURL",S),D=h(T,"rootDirectory",S),{config:C,...w}=_;return{configURL:b,rootDirectory:D,overlays:w}}function h(_,S,T){const b=_([S]);if((0,i.isThenable)(b)){T.push({message:`the legacy \`config\` overlay returned a Promise for \`${S}\`; top-level FS context must resolve synchronously. ${S} will be undefined.`,severity:"warn",code:"config-overlay"});return}return typeof b=="string"?b:void 0}function g(_,S,T){if(_!==void 0)try{return new URL(_),_}catch{T.push({message:`${S} must be a URL-shaped string (e.g. 'file:///path/to/...'), got '${_}'. In Node, use \`url.pathToFileURL(path).toString()\`.`,severity:"warn",code:"config-validation"});return}}function m(_,S){if(!E(_))return;const T=new Map;for(const[b,D]of Object.entries(_)){if(!E(D))continue;const C=new Map;for(const[w,R]of Object.entries(D)){if(typeof R!="string")continue;const O=(0,o.validateCanonicalTablePathAnyDialect)(R);if(O!==void 0){S.push({message:`virtualMap entry '${b}.${w}': ${O}`,severity:"error",code:"config-validation"});continue}C.set(w,R)}C.size>0&&T.set(b,C)}return T.size>0?T:void 0}function E(_){return typeof _=="object"&&_!==null&&!Array.isArray(_)}function v(_){return E(_)&&typeof _.tableName=="string"}return hu}var Zc={},Tm={},R8;function Az(){return R8||(R8=1,Object.defineProperty(Tm,"__esModule",{value:!0}),Tm.MALLOY_VERSION=void 0,Tm.MALLOY_VERSION="0.0.426"),Tm}var w8;function rk(){if(w8)return Zc;w8=1,Object.defineProperty(Zc,"__esModule",{value:!0}),Zc.Malloy=Zc.MalloyError=void 0;const e=mT(),t=cf(),r=jr(),i=F2(),o=Az(),s=JE(),a=ek(),l=v0(),u=XE(),d=tk();function c(h="loadModel"){return`internal://${h}/${(0,l.v4)()}`}function x(h){return[...Object.keys(h),...Object.values(h).map(x).flat()]}class f extends Error{constructor(g,m=[]){super(g),this.problems=m}}Zc.MalloyError=f;class p{static get version(){return o.MALLOY_VERSION}static registerConnectionType(g,m){(0,t.registerConnectionType)(g,m)}static getConnectionProperties(g){return(0,t.getConnectionProperties)(g)}static getConnectionTypeDisplayName(g){return(0,t.getConnectionTypeDisplayName)(g)}static getRegisteredConnectionTypes(){return(0,t.getRegisteredConnectionTypes)()}static _parse(g,m,E,v,_){var S;m===void 0&&(m=new URL(c(v?.method)));let T=m;v?.importBaseURL&&(T=v?.importBaseURL);const b=new e.MalloyTranslator(m.toString(),T.toString(),{urls:{[m.toString()]:g}},E,(S=v?.restrictedMode)!==null&&S!==void 0?S:!1);return v?.testEnvironment&&(b.allDialectsEnabled=!0),new a.Parse(b,_)}static parse({url:g,urlReader:m,source:E,eventStream:v,options:_}){if(E!==void 0)return p._parse(E,g,v,_);if(m===void 0)throw new Error("Internal Error: urlReader is required.");if(g===void 0)throw new Error("Internal Error: url is required if source not present.");return(0,s.readURL)(m,g).then(({contents:S,invalidationKey:T})=>p._parse(S,g,v,_,T))}static async compile(g){var m,E,v,_,S;let{url:T,source:b,importBaseURL:D,cacheManager:C}=g;const{parse:w,urlReader:R,connections:O,model:I,refreshSchemaCache:k,noThrowOnError:$,eventStream:Y,restrictedMode:ne,method:re}=g;ne&&(C=void 0);let oe;if(k&&(oe=typeof k=="number"?k:Date.now()),T===void 0&&b===void 0&&w===void 0)throw new Error("Internal Error: url, source, or parse required.");T===void 0&&(w!==void 0?T=new URL(w._translator.sourceURL):T=new URL(c(re)));const U={};if(b===void 0&&C!==void 0){const te=await C.getCachedModelDef(R,T.toString());if(te)return new u.Model(te.modelDef,[],[T.toString(),...x(te.modelDef.dependencies)])}D??(D=T);let ee;const J=T.toString();if(w!==void 0){if(ne!==void 0&&w._translator.restrictedMode!==ne)throw new Error(`Malloy.compile: restrictedMode (${ne}) does not match the pre-parsed translator's restrictedMode (${w._translator.restrictedMode}). Set restrictedMode at parse time.`);ee=w._translator;const te=(m=w._invalidationKey)!==null&&m!==void 0?m:await(0,s.getInvalidationKey)(R,T);U[J]=te}else{if(b===void 0){const{contents:te,invalidationKey:q}=await(0,s.readURL)(R,T);U[J]=q,b=te}else{const te=await(0,s.getInvalidationKey)(R,T);U[J]=te}ee=new e.MalloyTranslator(J,D.toString(),{urls:{[J]:b}},Y,ne??!1)}for(;;){const te=ee.translate(I?._modelDef);if(te.final)if(te.modelDef){await C?.setCachedModelDef(T.toString(),{modelDef:te.modelDef,invalidationKeys:U});for(const H of ee.newlyTranslatedDependencies())await C?.setCachedModelDef(H.url,{modelDef:H.modelDef,invalidationKeys:U});const q=!te.modelWasModified&&I?I.getExistingQueryModel():void 0;return new u.Model(te.modelDef,te.problems||[],[...(E=I?.fromSources)!==null&&E!==void 0?E:[],...(v=te.fromSources)!==null&&v!==void 0?v:[]],q)}else if($){const q=(0,r.mkModelDef)("modelDidNotCompile"),H=I?._modelDef||q;return new u.Model(H,te.problems||[],[...(_=I?.fromSources)!==null&&_!==void 0?_:[],...(S=te.fromSources)!==null&&S!==void 0?S:[]])}else{const q=te.problems||[],H=ee.prettyErrors();throw new f(`Error(s) compiling model:
|
|
1306
|
+
`,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(s){const a=s.includes(this.quoteCharacter),l=s.includes(this.columnSeparator),u=s.includes(this.rowSeparator),d=l||a||u;return a&&(s=s.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),d&&(s=this.quoteCharacter+s+this.quoteCharacter),s}stringify(s){return s===null?this.emptyCell:s instanceof Date?s.toISOString():typeof s=="boolean"||typeof s=="number"?JSON.stringify(s):typeof s=="bigint"?s.toString():`${s}`}getColWeight(s){let a=s;Array.isArray(s)&&(a=s[0]);let l=0;for(const u in a){l=l+1;const d=a[u];if((0,e.isCompoundArrayData)(d)){const c=this.getColWeight(d)-1;l=l+c}}return l}getHeaderRow(s){const a=[];let l=0;for(const u in s){a.push(this.escape(u));const d=s[u];if(l++,(0,e.isCompoundArrayData)(d)){const c=this.getColWeight(d)-1;l=l+c;for(let x=0;x<c;x++)a.push(this.emptyCell)}}return{rows:[a.join(this.columnSeparator)],length:1,width:l}}mergeMatrices(s){const a=Math.max(...s.map(d=>d.length)),l=s.reduce((d,c)=>d+c.width,0),u=[];for(let d=0;d<a;d++){const c=[];for(const x of s)if(d<x.length)c.push(x.rows[d]);else{const f=Array(x.width).fill(this.emptyCell);c.push(...f)}u.push(c.join(this.columnSeparator))}return{rows:u,length:a,width:l}}getChildMatrix(s){if(Array.isArray(s)){if(s.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const a=[],l=this.getHeaderRow(s[0]);a.push(...l.rows);const u=l.width;let d=1;for(const c of s){const x=this.getRowMatrix(c);d=d+x.length,a.push(...x.rows)}return{rows:a,length:d,width:u}}getRowMatrix(s){const a=[];for(const l in s){const u=s[l];if((0,e.isCompoundArrayData)(u)){const d=this.getChildMatrix(u);a.push(d)}else{const d={rows:[this.stringify(u)],length:1,width:1};a.push(d)}}return this.mergeMatrices(a)}async process(s){let a=!1;for await(const l of s){if(!a&&this.includeHeader){const d=this.getHeaderRow(l.toObject());this.stream.write(d.rows[0]),this.stream.write(this.rowSeparator),a=!0}const u=this.getRowMatrix(l.toObject());for(const d of u.rows)this.stream.write(d),this.stream.write(this.rowSeparator)}this.stream.close()}}return Da.CSVWriter=i,Da}var Vr={},hu={},Qy={},jn={},_8;function cf(){if(_8)return jn;_8=1,Object.defineProperty(jn,"__esModule",{value:!0}),jn.isConnectionConfigEntry=e,jn.registerConnectionType=r,jn.getConnectionProperties=i,jn.getConnectionTypeDisplayName=o,jn.getRegisteredConnectionTypes=s,jn.getConnectionTypeDef=a,jn.validateConnectionConfigProperties=l,jn.readConnectionsConfig=u,jn.writeConnectionsConfig=d,jn.createConnectionsFromConfig=c;function e(x){return typeof x=="object"&&x!==null&&typeof x.is=="string"}const t=new Map;function r(x,f){t.set(x,f)}function i(x){var f;return(f=t.get(x))===null||f===void 0?void 0:f.properties}function o(x){var f;return(f=t.get(x))===null||f===void 0?void 0:f.displayName}function s(){return[...t.keys()]}function a(x){return t.get(x)}function l(x,f,p){var h,g;const m=(g=(h=t.get(f))===null||h===void 0?void 0:h.properties)!==null&&g!==void 0?g:[];for(const E of m){if(!E.requireLiteralString)continue;const v=p[E.name];if(v!==void 0&&typeof v!="string")throw new Error(`Connection "${x}" property "${E.name}" must be a literal string`)}}function u(x){var f;const p=JSON.parse(x),h=Object.fromEntries(Object.entries((f=p.connections)!==null&&f!==void 0?f:{}).filter(([,g])=>e(g)));return{...p,connections:h}}function d(x){return JSON.stringify(x,null,2)}function c(x,f){const p=Object.entries(x.connections),h=p.length>0?p[0][0]:void 0,g=new Map;return{async lookupConnection(m){if(m===void 0&&(m=h),m===void 0)throw new Error("No connections defined in config");const E=g.get(m);if(E)return E;const v=x.connections[m];if(!v)throw new Error(`No connection named "${m}" found in config`);const _=t.get(v.is);if(!_)throw new Error(`No registered connection type "${v.is}" for connection "${m}". Did you forget to import the connection package?`);const S={name:m};for(const[b,D]of Object.entries(v))b!=="is"&&D!=null&&(S[b]=D);l(m,v.is,S);const T=await _.factory(S);return f&&f(m,T),g.set(m,T),T},async close(){const m=[...g.values()];g.clear();for(const E of m)await E.close()},async idle(){for(const m of g.values())await m.idle()}}}return jn}var S8;function _z(){if(S8)return Qy;S8=1,Object.defineProperty(Qy,"__esModule",{value:!0}),Qy.compileConfig=o;const e=cf(),t=f9(),r={connections:s,manifestPath:u,givensPath:d,finalizeGivens:c,virtualMap:x,includeDefaultConnections:f},i=new Set(Object.keys(r));function o(v){const _=[],S={kind:"dict",entries:{}};if(!h(v))return _.push({message:"config is not a JSON object",severity:"error",code:"config-validation"}),{compiled:S,log:_};for(const[T,b]of Object.entries(v)){const D=r[T];if(!D){const w=(0,t.closestMatch)(T,[...i]),R=w?`. Did you mean "${w}"?`:"";_.push(g(T,`unknown config key "${T}"${R}`));continue}const C=D(b,_);C!==void 0&&(S.entries[T]=C)}return{compiled:S,log:_}}function s(v,_){if(!h(v)){_.push(g("connections",'"connections" should be an object'));return}const S=new Set((0,e.getRegisteredConnectionTypes)()),T={kind:"dict",entries:{}};for(const[b,D]of Object.entries(v)){const C=`connections.${b}`;if(!h(D)){_.push(g(C,"should be an object"));continue}const w=D.is;if(w==null||w===""){_.push(g(C,'missing required "is" field (connection type)'));continue}if(typeof w!="string"){_.push(g(`${C}.is`,'"is" should be a string'));continue}if(!S.has(w)){const O=(0,t.closestMatch)(w,[...S]),I=O?` Did you mean "${O}"?`:"";_.push(g(`${C}.is`,`unknown connection type "${w}".${I} Available types: ${[...S].join(", ")}`));continue}const R=a(C,w,D,_);T.entries[b]=R}return T}function a(v,_,S,T){var b;const D=(b=(0,e.getConnectionProperties)(_))!==null&&b!==void 0?b:[],C=new Map(D.map(R=>[R.name,R])),w={kind:"dict",entries:{}};w.entries.is={kind:"value",value:_};for(const[R,O]of Object.entries(S)){if(R==="is")continue;const I=C.get(R);if(!I){const $=(0,t.closestMatch)(R,[...C.keys()]),Y=$?`. Did you mean "${$}"?`:"";T.push(g(`${v}.${R}`,`unknown property "${R}" for connection type "${_}"${Y}`));continue}const k=l(`${v}.${R}`,I,O,T);k!==void 0&&(w.entries[R]=k)}return w}function l(v,_,S,T){if(S==null)return;if(_.type==="json")return{kind:"value",value:S};const b=p(S);if(b!==void 0)return _.requireLiteralString?(T.push(g(v,"must be a literal string and cannot use an overlay reference")),{kind:"value",value:S}):b;const D=E(S,_.type);if(D){if(_.requireLiteralString)return T.push(g(v,`must be a literal string, got ${m(S)}`)),{kind:"value",value:S};T.push(g(v,`${D} (expected ${_.type})`));return}return{kind:"value",value:S}}function u(v,_){const S=p(v);if(S!==void 0)return S;if(typeof v!="string"){_.push(g("manifestPath",'"manifestPath" should be a string or an overlay reference'));return}return{kind:"value",value:v}}function d(v,_){const S=p(v);if(S!==void 0)return S;if(typeof v!="string"){_.push(g("givensPath",'"givensPath" should be a string or an overlay reference'));return}return{kind:"value",value:v}}function c(v,_){if(!Array.isArray(v)||!v.every(S=>typeof S=="string")){_.push(g("finalizeGivens",'"finalizeGivens" should be an array of given names'));return}return{kind:"value",value:v}}function x(v,_){return{kind:"value",value:v}}function f(v,_){return{kind:"value",value:v}}function p(v){if(typeof v!="object"||v===null||Array.isArray(v))return;const _=Object.keys(v);if(_.length!==1)return;const S=_[0],T=v[S];if(typeof T=="string")return{kind:"reference",source:S,path:[T]};if(Array.isArray(T)&&T.every(b=>typeof b=="string"))return{kind:"reference",source:S,path:T}}function h(v){return typeof v=="object"&&v!==null&&!Array.isArray(v)}function g(v,_){return{message:`${v}: ${_}`,severity:"warn",code:"config-validation"}}function m(v){return Array.isArray(v)?"array":typeof v}function E(v,_){switch(_){case"number":if(typeof v!="number")return`should be a number, got ${typeof v}`;break;case"boolean":if(typeof v!="boolean")return`should be a boolean, got ${typeof v}`;break;case"string":case"password":case"secret":case"file":case"text":if(typeof v!="string")return`should be a string, got ${typeof v}`;break}}return Qy}var Wy={},Xc={},C8;function gT(){if(C8)return Xc;C8=1;var e={};Object.defineProperty(Xc,"__esModule",{value:!0}),Xc.envOverlay=t,Xc.contextOverlay=r,Xc.defaultConfigOverlays=i,Xc.isThenable=o;function t(){return typeof process>"u"||!e?()=>{}:s=>e[s[0]]}function r(s){return a=>s[a[0]]}function i(){return{env:t(),config:()=>{}}}function o(s){return typeof s=="object"&&s!==null&&"then"in s&&typeof s.then=="function"}return Xc}var A8;function Sz(){if(A8)return Wy;A8=1,Object.defineProperty(Wy,"__esModule",{value:!0}),Wy.prepareConfig=r;const e=cf(),t=gT();function r(l,u,d){let c={},x,f,p,h,g=!1;for(const[m,E]of Object.entries(l.entries))switch(m){case"connections":{if(E.kind!=="dict")break;c=o(E);break}case"manifestPath":{x=a(E,u,d,"manifestPath");break}case"givensPath":{f=a(E,u,d,"givensPath");break}case"finalizeGivens":{E.kind==="value"&&i(E.value)&&(p=E.value);break}case"virtualMap":{E.kind==="value"&&(h=E.value);break}case"includeDefaultConnections":{E.kind==="value"&&typeof E.value=="boolean"&&(g=E.value);break}}return g&&s(c),{compiledConnections:c,manifestPath:x,givensPath:f,finalizeGivens:p,virtualMap:h}}function i(l){return Array.isArray(l)&&l.every(u=>typeof u=="string")}function o(l){const u={};for(const[d,c]of Object.entries(l.entries))c.kind==="dict"&&(u[d]=c);return u}function s(l){for(const u of(0,e.getRegisteredConnectionTypes)())l[u]||(l[u]={kind:"dict",entries:{is:{kind:"value",value:u}}})}function a(l,u,d,c){if(l.kind==="value")return typeof l.value=="string"?l.value:void 0;if(l.kind==="reference"){const x=u[l.source];if(!x){d.push({message:`unknown overlay source "${l.source}" for "${c}"`,severity:"warn",code:"config-overlay"});return}const f=x(l.path);if((0,t.isThenable)(f)){d.push({message:`the \`${l.source}\` overlay returned a Promise for "${c}"; top-level string settings must resolve synchronously`,severity:"warn",code:"config-overlay"});return}return typeof f=="string"?f:void 0}}return Wy}var zy={},T8;function Cz(){if(T8)return zy;T8=1,Object.defineProperty(zy,"__esModule",{value:!0}),zy.buildManagedLookup=t;const e=cf();function t(l,u,d){const c=Object.entries(l),x=c.length>0?c[0][0]:void 0,f=new Map;return{async lookupConnection(p){if(p===void 0&&(p=x),p===void 0)throw new Error("No connections defined in config");const h=f.get(p);if(h)return h;const g=l[p];if(!g)throw new Error(`No connection named "${p}" found in config`);const m=await r(g,u,d);if(typeof m.is!="string")throw new Error(`Connection "${p}" is missing a valid "is" field`);const E=(0,e.getConnectionTypeDef)(m.is);if(!E)throw new Error(`No registered connection type "${m.is}" for connection "${p}". Did you forget to import the connection package?`);const v={name:p};for(const[S,T]of Object.entries(m))S!=="is"&&T!=null&&(v[S]=T);(0,e.validateConnectionConfigProperties)(p,m.is,v);const _=await E.factory(v);return f.set(p,_),_},async close(){const p=[...f.values()];f.clear();for(const h of p)await h.close()},async idle(){for(const p of f.values())await p.idle()}}}async function r(l,u,d){const c=await i(l,u,d);if(!(0,e.isConnectionConfigEntry)(c))throw new Error("Connection entry did not resolve to a valid {is: string, ...} dict");return await s(c,u),c}async function i(l,u,d){switch(l.kind){case"value":return l.value;case"reference":return o(l,u,d);case"dict":{const c={};for(const[x,f]of Object.entries(l.entries)){const p=await i(f,u,d);p!==void 0&&(c[x]=p)}return c}}}async function o(l,u,d){const c=u[l.source];if(!c){d.push({message:`unknown overlay source "${l.source}" for reference path ${JSON.stringify(l.path)}`,severity:"warn",code:"config-overlay"});return}return await c(l.path)}async function s(l,u){var d;const c=l.is;if(typeof c!="string")return;const x=(d=(0,e.getConnectionProperties)(c))!==null&&d!==void 0?d:[];for(const f of x){if(f.default===void 0||l[f.name]!==void 0)continue;const p=await a(f.default,u);p!==void 0&&(l[f.name]=p)}}async function a(l,u){if(typeof l!="object")return l;const d=Object.keys(l);if(d.length!==1)return;const c=d[0],x=l[c],f=typeof x=="string"?[x]:x;if(!Array.isArray(f))return;const p=u[c];if(p)return await p(f)}return zy}var b8;function yT(){if(b8)return hu;b8=1,Object.defineProperty(hu,"__esModule",{value:!0}),hu.MalloyConfig=hu.Manifest=void 0,hu.isBuildManifestEntry=v;const e=_z(),t=Sz(),r=Cz(),i=gT(),o=YE();class s{constructor(){this._manifest={entries:{},strict:!1},this._touched=new Set}loadText(S){this._clearEntries(),this._touched.clear(),this._manifest.strict=!1,this._loadParsed(JSON.parse(S))}get buildManifest(){return this._manifest}get strict(){var S;return(S=this._manifest.strict)!==null&&S!==void 0?S:!1}set strict(S){this._manifest.strict=S}update(S,T){(0,o.requireCanonicalTablePathAnyDialect)(T.tableName,`Manifest entry '${S}'`),this._manifest.entries[S]=T,this._touched.add(S)}touch(S){this._touched.add(S)}get activeEntries(){const S={};for(const T of this._touched)this._manifest.entries[T]&&(S[T]=this._manifest.entries[T]);return{entries:S,strict:this._manifest.strict}}_clearEntries(){for(const S of Object.keys(this._manifest.entries))delete this._manifest.entries[S]}_loadParsed(S){typeof S.strict=="boolean"&&(this._manifest.strict=S.strict);const T=E(S.entries)?S.entries:S;for(const[b,D]of Object.entries(T))b==="strict"||!v(D)||((0,o.requireCanonicalTablePathAnyDialect)(D.tableName,`Manifest entry '${b}'`),this._manifest.entries[b]=D)}}hu.Manifest=s;class a{constructor(S,T){const b=[];let D;if(typeof S=="string")try{D=JSON.parse(S)}catch($){b.push({message:`Invalid JSON: ${$ instanceof Error?$.message:String($)}`,severity:"error",code:"config-validation"}),D={}}else D=S;const C=(0,e.compileConfig)(D);b.push(...C.log);const w=x(T,b),R=g(w.configURL,"configURL",b),O=w.rootDirectory,I={...(0,i.defaultConfigOverlays)(),...w.overlays,config:(0,i.contextOverlay)({configURL:R,rootDirectory:O})},k=(0,t.prepareConfig)(C.compiled,I,b);this._managedLookup=(0,r.buildManagedLookup)(k.compiledConnections,I,b),this._connections=this._managedLookup,this._overlays=I,this.virtualMap=m(k.virtualMap,b),this.configURL=R,this.rootDirectory=O,this.manifestPath=k.manifestPath,this.manifestURL=d(k.manifestPath,R),this.givensPath=k.givensPath,this.givensURL=c(k.givensPath,R,b),this.finalizeGivens=k.finalizeGivens,this.log=b}get connections(){return this._connections}wrapConnections(S){this._connections=S(this._connections)}async shutdown(S="close"){S==="idle"?await this._managedLookup.idle():await this._managedLookup.close()}async releaseConnections(){await this.shutdown("close")}async readOverlay(S,...T){var b,D;return await((D=(b=this._overlays)[S])===null||D===void 0?void 0:D.call(b,T))}}hu.MalloyConfig=a;const l="MANIFESTS",u="malloy-manifest.json";function d(_,S){if(!S)return;let T;try{T=new URL(S)}catch{return}const b=_??l;let D;try{D=new URL(b,T)}catch{return}const C=D.toString(),w=C.endsWith("/")?D:new URL(C+"/");return new URL(u,w).toString()}function c(_,S,T){if(!_)return;if(!S){T.push({message:"givensPath is set but no configURL is available; per-runtime givens will not be loaded. Pass `configURL` (or use an absolute URL such as `file:///...`).",severity:"warn",code:"config-overlay"});return}let b;try{b=new URL(S)}catch{return}try{return new URL(_,b).toString()}catch(D){const C=D instanceof Error?D.message:String(D);T.push({message:`givensPath '${_}' could not be resolved against configURL '${S}': ${C}`,severity:"warn",code:"config-validation"});return}}function x(_,S){if(_===void 0)return{};if(f(_))return p(_,S);const T=_;if(T.overlays&&"config"in T.overlays){S.push({message:"`config` is reserved by MalloyConfig; pass `configURL` and `rootDirectory` directly instead. Supplied `overlays.config` ignored.",severity:"warn",code:"config-overlay"});const{config:b,...D}=T.overlays;return{...T,overlays:D}}return T}function f(_){for(const S of Object.values(_))if(typeof S=="function")return!0;return!1}function p(_,S){const T=_.config;if(!T)return{overlays:_};const b=h(T,"configURL",S),D=h(T,"rootDirectory",S),{config:C,...w}=_;return{configURL:b,rootDirectory:D,overlays:w}}function h(_,S,T){const b=_([S]);if((0,i.isThenable)(b)){T.push({message:`the legacy \`config\` overlay returned a Promise for \`${S}\`; top-level FS context must resolve synchronously. ${S} will be undefined.`,severity:"warn",code:"config-overlay"});return}return typeof b=="string"?b:void 0}function g(_,S,T){if(_!==void 0)try{return new URL(_),_}catch{T.push({message:`${S} must be a URL-shaped string (e.g. 'file:///path/to/...'), got '${_}'. In Node, use \`url.pathToFileURL(path).toString()\`.`,severity:"warn",code:"config-validation"});return}}function m(_,S){if(!E(_))return;const T=new Map;for(const[b,D]of Object.entries(_)){if(!E(D))continue;const C=new Map;for(const[w,R]of Object.entries(D)){if(typeof R!="string")continue;const O=(0,o.validateCanonicalTablePathAnyDialect)(R);if(O!==void 0){S.push({message:`virtualMap entry '${b}.${w}': ${O}`,severity:"error",code:"config-validation"});continue}C.set(w,R)}C.size>0&&T.set(b,C)}return T.size>0?T:void 0}function E(_){return typeof _=="object"&&_!==null&&!Array.isArray(_)}function v(_){return E(_)&&typeof _.tableName=="string"}return hu}var Zc={},Tm={},R8;function Az(){return R8||(R8=1,Object.defineProperty(Tm,"__esModule",{value:!0}),Tm.MALLOY_VERSION=void 0,Tm.MALLOY_VERSION="0.0.427"),Tm}var w8;function rk(){if(w8)return Zc;w8=1,Object.defineProperty(Zc,"__esModule",{value:!0}),Zc.Malloy=Zc.MalloyError=void 0;const e=mT(),t=cf(),r=jr(),i=F2(),o=Az(),s=JE(),a=ek(),l=v0(),u=XE(),d=tk();function c(h="loadModel"){return`internal://${h}/${(0,l.v4)()}`}function x(h){return[...Object.keys(h),...Object.values(h).map(x).flat()]}class f extends Error{constructor(g,m=[]){super(g),this.problems=m}}Zc.MalloyError=f;class p{static get version(){return o.MALLOY_VERSION}static registerConnectionType(g,m){(0,t.registerConnectionType)(g,m)}static getConnectionProperties(g){return(0,t.getConnectionProperties)(g)}static getConnectionTypeDisplayName(g){return(0,t.getConnectionTypeDisplayName)(g)}static getRegisteredConnectionTypes(){return(0,t.getRegisteredConnectionTypes)()}static _parse(g,m,E,v,_){var S;m===void 0&&(m=new URL(c(v?.method)));let T=m;v?.importBaseURL&&(T=v?.importBaseURL);const b=new e.MalloyTranslator(m.toString(),T.toString(),{urls:{[m.toString()]:g}},E,(S=v?.restrictedMode)!==null&&S!==void 0?S:!1);return v?.testEnvironment&&(b.allDialectsEnabled=!0),new a.Parse(b,_)}static parse({url:g,urlReader:m,source:E,eventStream:v,options:_}){if(E!==void 0)return p._parse(E,g,v,_);if(m===void 0)throw new Error("Internal Error: urlReader is required.");if(g===void 0)throw new Error("Internal Error: url is required if source not present.");return(0,s.readURL)(m,g).then(({contents:S,invalidationKey:T})=>p._parse(S,g,v,_,T))}static async compile(g){var m,E,v,_,S;let{url:T,source:b,importBaseURL:D,cacheManager:C}=g;const{parse:w,urlReader:R,connections:O,model:I,refreshSchemaCache:k,noThrowOnError:$,eventStream:Y,restrictedMode:ne,method:re}=g;ne&&(C=void 0);let oe;if(k&&(oe=typeof k=="number"?k:Date.now()),T===void 0&&b===void 0&&w===void 0)throw new Error("Internal Error: url, source, or parse required.");T===void 0&&(w!==void 0?T=new URL(w._translator.sourceURL):T=new URL(c(re)));const U={};if(b===void 0&&C!==void 0){const te=await C.getCachedModelDef(R,T.toString());if(te)return new u.Model(te.modelDef,[],[T.toString(),...x(te.modelDef.dependencies)])}D??(D=T);let ee;const J=T.toString();if(w!==void 0){if(ne!==void 0&&w._translator.restrictedMode!==ne)throw new Error(`Malloy.compile: restrictedMode (${ne}) does not match the pre-parsed translator's restrictedMode (${w._translator.restrictedMode}). Set restrictedMode at parse time.`);ee=w._translator;const te=(m=w._invalidationKey)!==null&&m!==void 0?m:await(0,s.getInvalidationKey)(R,T);U[J]=te}else{if(b===void 0){const{contents:te,invalidationKey:q}=await(0,s.readURL)(R,T);U[J]=q,b=te}else{const te=await(0,s.getInvalidationKey)(R,T);U[J]=te}ee=new e.MalloyTranslator(J,D.toString(),{urls:{[J]:b}},Y,ne??!1)}for(;;){const te=ee.translate(I?._modelDef);if(te.final)if(te.modelDef){await C?.setCachedModelDef(T.toString(),{modelDef:te.modelDef,invalidationKeys:U});for(const H of ee.newlyTranslatedDependencies())await C?.setCachedModelDef(H.url,{modelDef:H.modelDef,invalidationKeys:U});const q=!te.modelWasModified&&I?I.getExistingQueryModel():void 0;return new u.Model(te.modelDef,te.problems||[],[...(E=I?.fromSources)!==null&&E!==void 0?E:[],...(v=te.fromSources)!==null&&v!==void 0?v:[]],q)}else if($){const q=(0,r.mkModelDef)("modelDidNotCompile"),H=I?._modelDef||q;return new u.Model(H,te.problems||[],[...(_=I?.fromSources)!==null&&_!==void 0?_:[],...(S=te.fromSources)!==null&&S!==void 0?S:[]])}else{const q=te.problems||[],H=ee.prettyErrors();throw new f(`Error(s) compiling model:
|
|
1307
1307
|
${H}`,q)}else{if(te.urls)for(const q of te.urls)try{if((0,s.isInternalURL)(q))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(C!==void 0){const j=await C.getCachedModelDef(R,q);if(j){for(const P in j.invalidationKeys)U[P]=j.invalidationKeys[P];ee.update({translations:{[q]:j.modelDef}});continue}}const{contents:H,invalidationKey:Q}=await(0,s.readURL)(R,new URL(q)),M={[q]:H};U[q]=Q,ee.update({urls:M})}catch(H){ee.update({errors:{urls:{[q]:H.message}}})}if(te.tables){const q=new Map;for(const H in te.tables){const{connectionName:Q,tablePath:M}=te.tables[H],j=q.get(Q);j===void 0?q.set(Q,{[H]:M}):j[H]=M}for(const[H,Q]of q)try{const M=await O.lookupConnection(H),{schemas:j,errors:P}=await p.safelyFetchTableSchema(M,Q,{refreshTimestamp:oe});ee.update({tables:j,errors:{tables:P}})}catch(M){const j={},P={};for(const V in Q)P[V]=M.toString();ee.update({tables:j,errors:{tables:P}})}}if(te.connectionDialects)for(const q in te.connectionDialects){const{connectionName:H}=te.connectionDialects[q];try{const Q=await O.lookupConnection(H);ee.update({connectionDialects:{[q]:Q.dialectName}})}catch(Q){ee.update({errors:{connectionDialects:{[q]:Q.toString()}}})}}if(te.compileSQL){const q=te.compileSQL,H=q.connection,Q=(0,i.sqlKey)(q.connection,q.selectStr);try{const j=await(await O.lookupConnection(H)).fetchSchemaForSQLStruct(q,{refreshTimestamp:oe});j.error&&ee.update({errors:{compileSQL:{[Q]:j.error}}}),j.structDef&&ee.update({compileSQL:{[Q]:j.structDef}})}catch(M){const j={};j[Q]=M.toString(),ee.update({errors:{compileSQL:j}})}}}}}static async safelyFetchTableSchema(g,m,E){const v=await g.fetchSchemaForTables(m,E);for(const _ of Object.keys(m))if(v.schemas[_]===void 0&&v.errors[_]===void 0)throw new Error(`Schema fetch error for ${g.name}, no response for ${_} from ${g.dialectName}`);return v}static async run({connections:g,preparedResult:m,sqlStruct:E,connection:v,options:_}){if(!v){if(!g)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const S=E?.connection||m?.connectionName;v=await g.lookupConnection(S)}if(E){const S=await v.runSQL(E.selectStr,{queryMetadata:_?.queryMetadata});return new d.Result({structs:[E],sql:E.selectStr,result:S.rows,totalRows:S.totalRows,runStats:S.runStats,lastStageName:E.name,malloy:"",connectionName:E.connection,sourceExplore:"",sourceFilters:[],profilingUrl:S.profilingUrl},(0,r.mkModelDef)("empty_model"))}else if(m){const S=await v.runSQL(m.sql,_);return new d.Result({...m._rawQuery,result:S.rows,totalRows:S.totalRows,runStats:S.runStats,profilingUrl:S.profilingUrl},m._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:g,preparedResult:m,sqlStruct:E,connection:v,options:_}){if(E===void 0&&m===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const S=E?.connection||m?.connectionName;if(v===void 0){if(g===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");v=await g.lookupConnection(S)}if(!v.canStream())throw new Error(`Connection '${S}' cannot stream results.`);let T,b;if(E)b=new u.Explore((0,u.pseudoModelFor)(E),E),T=E.selectStr;else if(m!==void 0)b=m.resultExplore,T=m.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let D=0;for await(const C of v.runSQLStream(T,_))yield new d.DataRecord(C,D,b,void 0,void 0),D+=1}static async estimateQueryCost({connections:g,preparedResult:m,sqlStruct:E}){if(!g)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const v=E?.connection||m?.connectionName,_=await g.lookupConnection(v);if(E)return await _.estimateQueryCost(E.selectStr);if(m)return await _.estimateQueryCost(m.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}}return Zc.Malloy=p,Zc}var D8;function Tz(){if(D8)return Vr;D8=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.ExploreMaterializer=Vr.PreparedResultMaterializer=Vr.QueryMaterializer=Vr.ModelMaterializer=Vr.SingleConnectionRuntime=Vr.ConnectionRuntime=Vr.Runtime=void 0;const e=jr(),t=za(),r=YE(),i=yT(),o=w2(),s=JE(),a=XE(),l=rk();class u{constructor(S,T){this.runtime=S,this._materialize=T}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(S,T){return new p(this.runtime,S,T)}makeExploreMaterializer(S,T){return new g(this.runtime,S,T)}makePreparedResultMaterializer(S){return new h(this.runtime,S)}}class d{constructor({urlReader:S,connections:T,connection:b,config:D,buildManifest:C,eventStream:w,cacheManager:R,givens:O}){var I,k;if(this.isTestRuntime=!1,D!==void 0)this._config=D,T=T??D.connections;else if(T===void 0){if(b===void 0)throw new Error("A MalloyConfig, LookupConnection<Connection>, or Connection is required.");T={lookupConnection:()=>Promise.resolve(b)}}if(S===void 0&&(S=new s.EmptyURLReader),this._urlReader=S,this._connections=T,this._buildManifest=C,this._eventStream=w,this._cacheManager=R,O){for(const[$,Y]of Object.entries(O))if(Y===void 0)throw new Error(`Runtime givens.${$}: explicit undefined is not a valid value. Omit the key to defer to declaration default or the file layer; use null for an explicit null value.`)}this._constructorGivensMap=O?new Map(Object.entries(O)):new Map,this._finalizedGivensSet=new Set((k=(I=this._config)===null||I===void 0?void 0:I.finalizeGivens)!==null&&k!==void 0?k:[])}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}get _constructorGivens(){return this._constructorGivensMap}async getGivens(){const S=await this._resolveGivens(),T=new Map;if(S)for(const[b,D]of Object.entries(S))T.set(b,D);for(const[b,D]of this._constructorGivensMap)T.set(b,D);return T}get _finalizedGivens(){return this._finalizedGivensSet}set buildManifest(S){this._buildManifest=S,this._resolvedBuildManifestPromise=void 0}_resolveBuildManifest(){var S;if(this._buildManifest)return Promise.resolve(this._buildManifest);const T=(S=this._config)===null||S===void 0?void 0:S.manifestURL;return T?(this._resolvedBuildManifestPromise||(this._resolvedBuildManifestPromise=(async()=>{let b;try{const D=await this._urlReader.readURL(new URL(T));b=typeof D=="string"?D:D.contents}catch{return}try{const D=JSON.parse(b);if(!m(D))throw new Error('manifest is not an object with an "entries" map');for(const[C,w]of Object.entries(D.entries)){if(!(0,i.isBuildManifestEntry)(w))throw new Error(`Manifest entry '${C}' is missing a string tableName`);(0,r.requireCanonicalTablePathAnyDialect)(w.tableName,`Manifest entry '${C}'`)}return D}catch(D){const C=D instanceof Error?D.message:String(D);return{entries:{},loadError:`Manifest file at ${T} could not be parsed: ${C}`}}})()),this._resolvedBuildManifestPromise):Promise.resolve(void 0)}_resolveGivens(){var S;const T=(S=this._config)===null||S===void 0?void 0:S.givensURL;return T?(this._resolvedGivensPromise||(this._resolvedGivensPromise=(async()=>{let b;try{const C=await this._urlReader.readURL(new URL(T));b=typeof C=="string"?C:C.contents}catch(C){const w=C instanceof Error?C.message:String(C);throw new Error(`givens: failed to read givens file at ${T}: ${w}`)}let D;try{D=JSON.parse(b)}catch(C){const w=C instanceof Error?C.message:String(C);throw new Error(`givens: failed to parse JSON at ${T}: ${w}`)}if(!E(D)){const C=Array.isArray(D)?"array":D===null?"null":typeof D;throw new Error(`givens: file at ${T} must be a JSON object of name → value pairs, got ${C}`)}return D})()),this._resolvedGivensPromise):Promise.resolve(void 0)}_invalidateGivensCache(){this._resolvedGivensPromise=void 0}get virtualMap(){var S,T;return(S=this._virtualMap)!==null&&S!==void 0?S:(T=this._config)===null||T===void 0?void 0:T.virtualMap}set virtualMap(S){this._virtualMap=S}async shutdown(S="close"){var T;await((T=this._config)===null||T===void 0?void 0:T.shutdown(S))}async releaseConnections(){await this.shutdown("close")}loadModel(S,T){const{refreshSchemaCache:b,noThrowOnError:D}=T||{};this.isTestRuntime&&(T===void 0?T={testEnvironment:!0}:T={...T,testEnvironment:!0});const C=S instanceof URL?{url:S}:{source:S};return new f(this,async()=>{const w=await l.Malloy.compile({...C,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:b,noThrowOnError:D,eventStream:this.eventStream,importBaseURL:T?.importBaseURL,testEnvironment:T?.testEnvironment,cacheManager:this.cacheManager});return this._withRuntimeContext(w)},T)}_withRuntimeContext(S){return this._finalizedGivensSet.size===0?S:new a.Model(S._modelDef,S.problems,S.fromSources,S.getExistingQueryModel(),{finalizedGivens:this._finalizedGivensSet})}_loadModelFromModelDef(S,T){return new f(this,async()=>new a.Model(S,[],[],void 0,this._finalizedGivensSet.size>0?{finalizedGivens:this._finalizedGivensSet}:void 0),T)}loadQuery(S,T){return this.loadModel(S,T).loadFinalQuery()}loadQueryByIndex(S,T,b){return this.loadModel(S,b).loadQueryByIndex(T,b)}loadQueryByName(S,T,b){return this.loadModel(S,b).loadQueryByName(T,b)}getModel(S,T){return this.loadModel(S,T).getModel()}getQuery(S,T){return this.loadQuery(S,T).getPreparedQuery()}getQueryByIndex(S,T,b){return this.loadQueryByIndex(S,T,b).getPreparedQuery()}getQueryByName(S,T,b){return this.loadQueryByName(S,T,b).getPreparedQuery()}}Vr.Runtime=d;class c extends d{constructor({urlReader:S,connections:T}){super({connections:s.FixedConnectionMap.fromArray(T),urlReader:S}),this.rawConnections=T}}Vr.ConnectionRuntime=c;class x extends d{constructor({urlReader:S,connection:T,eventStream:b,cacheManager:D}){super({urlReader:S,eventStream:b,cacheManager:D,connection:T}),this.connection=T}get supportsNesting(){return(0,t.getDialect)(this.connection.dialectName).supportsNesting}quote(S){return(0,t.getDialect)(this.connection.dialectName).sqlQuoteIdentifier(S)}get dialect(){return(0,t.getDialect)(this.connection.dialectName)}getQuoter(){return S=>this.quote(S.toString())}}Vr.SingleConnectionRuntime=x;class f extends u{constructor(S,T,b){super(S,T),this.runtime=S,this.compileQueryOptions=b}loadFinalQuery(S){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...S})}loadQueryByIndex(S,T){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(S),{...this.compileQueryOptions,...T})}loadQueryByName(S,T){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(S),{...this.compileQueryOptions,...T})}loadQuery(S,T){const{importBaseURL:b,testEnvironment:D,refreshSchemaCache:C,noThrowOnError:w,restrictedMode:R,method:O,...I}=T??{},k={...this.compileQueryOptions,...I};return this.makeQueryMaterializer(async()=>{const $=S instanceof URL?{url:S}:{source:S};return(await l.Malloy.compile({...$,urlReader:this.runtime.urlReader,connections:this.runtime.connections,model:await this.getModel(),refreshSchemaCache:C,noThrowOnError:w,importBaseURL:b,testEnvironment:D||this.runtime.isTestRuntime,...k})).preparedQuery},k)}loadRestrictedQuery(S){return this.makeQueryMaterializer(async()=>{const T=this.runtime.urlReader,b=this.runtime.connections,D=this.runtime.isTestRuntime?!0:void 0,C=await this.getModel();return(await l.Malloy.compile({source:S,restrictedMode:!0,method:"query",urlReader:T,connections:b,model:C,testEnvironment:D,...this.compileQueryOptions})).preparedQuery})}extendModel(S,T){return this.runtime.isTestRuntime&&(T===void 0?T={testEnvironment:!0}:T={...T,testEnvironment:!0}),new f(this.runtime,async()=>{const b=this.runtime.urlReader,D=this.runtime.connections,C=S instanceof URL?{url:S}:{source:S},w=await this.getModel(),R=await l.Malloy.compile({...C,urlReader:b,connections:D,model:w,method:"extendModel",refreshSchemaCache:T?.refreshSchemaCache,noThrowOnError:T?.noThrowOnError,importBaseURL:T?.importBaseURL,testEnvironment:T?.testEnvironment,...this.compileQueryOptions});return this.runtime._withRuntimeContext(R)},T)}async search(S,T,b=1e3,D=void 0){const C=await this.materialize(),w=C.queryModel,R=C.getExploreByName(S).structDef;if(!(0,e.isSourceDef)(R))throw new Error("Source to be searched was unexpectedly, not a source");const O=R.connection,I=await this.runtime.connections.lookupConnection(O);return await w.searchIndex(I,S,T,b,D)}async searchValueMap(S,T=10,b){const C=(await this.materialize()).getExploreByName(S);if(!(0,e.isSourceDef)(C.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let w="{index: *}";C.getFieldByNameIfExists("search_index")&&(w="search_index");const R=`
|
|
1308
1308
|
run: ${S}
|
|
1309
1309
|
-> ${w}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aJ as a}from"./index-
|
|
1
|
+
import{aJ as a}from"./index-CH2AcDzc.js";import{r as f}from"./index-w_0OQJgZ.js";function c(t,n){for(var o=0;o<n.length;o++){const e=n[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(e,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var s=f();const p=a(s),l=c({__proto__:null,default:p},[s]);export{s as d,l as i};
|
|
@@ -1380,7 +1380,7 @@ ${ce}`:B=ce}return B}childRequest(B){var J;const oe=decodeURI(new URL(B,this.sou
|
|
|
1380
1380
|
`)}}this.stream.write(`
|
|
1381
1381
|
]
|
|
1382
1382
|
`),this.stream.close()}}Ah.JSONWriter=r;class n extends t{constructor(){super(...arguments),this.columnSeparator=",",this.rowSeparator=`
|
|
1383
|
-
`,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(s){const o=s.includes(this.quoteCharacter),a=s.includes(this.columnSeparator),l=s.includes(this.rowSeparator),c=a||o||l;return o&&(s=s.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),c&&(s=this.quoteCharacter+s+this.quoteCharacter),s}stringify(s){return s===null?this.emptyCell:s instanceof Date?s.toISOString():typeof s=="boolean"||typeof s=="number"?JSON.stringify(s):typeof s=="bigint"?s.toString():`${s}`}getColWeight(s){let o=s;Array.isArray(s)&&(o=s[0]);let a=0;for(const l in o){a=a+1;const c=o[l];if((0,e.isCompoundArrayData)(c)){const u=this.getColWeight(c)-1;a=a+u}}return a}getHeaderRow(s){const o=[];let a=0;for(const l in s){o.push(this.escape(l));const c=s[l];if(a++,(0,e.isCompoundArrayData)(c)){const u=this.getColWeight(c)-1;a=a+u;for(let d=0;d<u;d++)o.push(this.emptyCell)}}return{rows:[o.join(this.columnSeparator)],length:1,width:a}}mergeMatrices(s){const o=Math.max(...s.map(c=>c.length)),a=s.reduce((c,u)=>c+u.width,0),l=[];for(let c=0;c<o;c++){const u=[];for(const d of s)if(c<d.length)u.push(d.rows[c]);else{const f=Array(d.width).fill(this.emptyCell);u.push(...f)}l.push(u.join(this.columnSeparator))}return{rows:l,length:o,width:a}}getChildMatrix(s){if(Array.isArray(s)){if(s.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const o=[],a=this.getHeaderRow(s[0]);o.push(...a.rows);const l=a.width;let c=1;for(const u of s){const d=this.getRowMatrix(u);c=c+d.length,o.push(...d.rows)}return{rows:o,length:c,width:l}}getRowMatrix(s){const o=[];for(const a in s){const l=s[a];if((0,e.isCompoundArrayData)(l)){const c=this.getChildMatrix(l);o.push(c)}else{const c={rows:[this.stringify(l)],length:1,width:1};o.push(c)}}return this.mergeMatrices(o)}async process(s){let o=!1;for await(const a of s){if(!o&&this.includeHeader){const c=this.getHeaderRow(a.toObject());this.stream.write(c.rows[0]),this.stream.write(this.rowSeparator),o=!0}const l=this.getRowMatrix(a.toObject());for(const c of l.rows)this.stream.write(c),this.stream.write(this.rowSeparator)}this.stream.close()}}return Ah.CSVWriter=n,Ah}var us={},pm={},gO={},ba={},lae;function M3(){if(lae)return ba;lae=1,Object.defineProperty(ba,"__esModule",{value:!0}),ba.isConnectionConfigEntry=e,ba.registerConnectionType=r,ba.getConnectionProperties=n,ba.getConnectionTypeDisplayName=i,ba.getRegisteredConnectionTypes=s,ba.getConnectionTypeDef=o,ba.validateConnectionConfigProperties=a,ba.readConnectionsConfig=l,ba.writeConnectionsConfig=c,ba.createConnectionsFromConfig=u;function e(d){return typeof d=="object"&&d!==null&&typeof d.is=="string"}const t=new Map;function r(d,f){t.set(d,f)}function n(d){var f;return(f=t.get(d))===null||f===void 0?void 0:f.properties}function i(d){var f;return(f=t.get(d))===null||f===void 0?void 0:f.displayName}function s(){return[...t.keys()]}function o(d){return t.get(d)}function a(d,f,m){var p,y;const g=(y=(p=t.get(f))===null||p===void 0?void 0:p.properties)!==null&&y!==void 0?y:[];for(const v of g){if(!v.requireLiteralString)continue;const x=m[v.name];if(x!==void 0&&typeof x!="string")throw new Error(`Connection "${d}" property "${v.name}" must be a literal string`)}}function l(d){var f;const m=JSON.parse(d),p=Object.fromEntries(Object.entries((f=m.connections)!==null&&f!==void 0?f:{}).filter(([,y])=>e(y)));return{...m,connections:p}}function c(d){return JSON.stringify(d,null,2)}function u(d,f){const m=Object.entries(d.connections),p=m.length>0?m[0][0]:void 0,y=new Map;return{async lookupConnection(g){if(g===void 0&&(g=p),g===void 0)throw new Error("No connections defined in config");const v=y.get(g);if(v)return v;const x=d.connections[g];if(!x)throw new Error(`No connection named "${g}" found in config`);const b=t.get(x.is);if(!b)throw new Error(`No registered connection type "${x.is}" for connection "${g}". Did you forget to import the connection package?`);const E={name:g};for(const[w,R]of Object.entries(x))w!=="is"&&R!=null&&(E[w]=R);a(g,x.is,E);const _=await b.factory(E);return f&&f(g,_),y.set(g,_),_},async close(){const g=[...y.values()];y.clear();for(const v of g)await v.close()},async idle(){for(const g of y.values())await g.idle()}}}return ba}var uae;function LIe(){if(uae)return gO;uae=1,Object.defineProperty(gO,"__esModule",{value:!0}),gO.compileConfig=i;const e=M3(),t=pge(),r={connections:s,manifestPath:l,givensPath:c,finalizeGivens:u,virtualMap:d,includeDefaultConnections:f},n=new Set(Object.keys(r));function i(x){const b=[],E={kind:"dict",entries:{}};if(!p(x))return b.push({message:"config is not a JSON object",severity:"error",code:"config-validation"}),{compiled:E,log:b};for(const[_,w]of Object.entries(x)){const R=r[_];if(!R){const A=(0,t.closestMatch)(_,[...n]),C=A?`. Did you mean "${A}"?`:"";b.push(y(_,`unknown config key "${_}"${C}`));continue}const S=R(w,b);S!==void 0&&(E.entries[_]=S)}return{compiled:E,log:b}}function s(x,b){if(!p(x)){b.push(y("connections",'"connections" should be an object'));return}const E=new Set((0,e.getRegisteredConnectionTypes)()),_={kind:"dict",entries:{}};for(const[w,R]of Object.entries(x)){const S=`connections.${w}`;if(!p(R)){b.push(y(S,"should be an object"));continue}const A=R.is;if(A==null||A===""){b.push(y(S,'missing required "is" field (connection type)'));continue}if(typeof A!="string"){b.push(y(`${S}.is`,'"is" should be a string'));continue}if(!E.has(A)){const N=(0,t.closestMatch)(A,[...E]),D=N?` Did you mean "${N}"?`:"";b.push(y(`${S}.is`,`unknown connection type "${A}".${D} Available types: ${[...E].join(", ")}`));continue}const C=o(S,A,R,b);_.entries[w]=C}return _}function o(x,b,E,_){var w;const R=(w=(0,e.getConnectionProperties)(b))!==null&&w!==void 0?w:[],S=new Map(R.map(C=>[C.name,C])),A={kind:"dict",entries:{}};A.entries.is={kind:"value",value:b};for(const[C,N]of Object.entries(E)){if(C==="is")continue;const D=S.get(C);if(!D){const U=(0,t.closestMatch)(C,[...S.keys()]),H=U?`. Did you mean "${U}"?`:"";_.push(y(`${x}.${C}`,`unknown property "${C}" for connection type "${b}"${H}`));continue}const M=a(`${x}.${C}`,D,N,_);M!==void 0&&(A.entries[C]=M)}return A}function a(x,b,E,_){if(E==null)return;if(b.type==="json")return{kind:"value",value:E};const w=m(E);if(w!==void 0)return b.requireLiteralString?(_.push(y(x,"must be a literal string and cannot use an overlay reference")),{kind:"value",value:E}):w;const R=v(E,b.type);if(R){if(b.requireLiteralString)return _.push(y(x,`must be a literal string, got ${g(E)}`)),{kind:"value",value:E};_.push(y(x,`${R} (expected ${b.type})`));return}return{kind:"value",value:E}}function l(x,b){const E=m(x);if(E!==void 0)return E;if(typeof x!="string"){b.push(y("manifestPath",'"manifestPath" should be a string or an overlay reference'));return}return{kind:"value",value:x}}function c(x,b){const E=m(x);if(E!==void 0)return E;if(typeof x!="string"){b.push(y("givensPath",'"givensPath" should be a string or an overlay reference'));return}return{kind:"value",value:x}}function u(x,b){if(!Array.isArray(x)||!x.every(E=>typeof E=="string")){b.push(y("finalizeGivens",'"finalizeGivens" should be an array of given names'));return}return{kind:"value",value:x}}function d(x,b){return{kind:"value",value:x}}function f(x,b){return{kind:"value",value:x}}function m(x){if(typeof x!="object"||x===null||Array.isArray(x))return;const b=Object.keys(x);if(b.length!==1)return;const E=b[0],_=x[E];if(typeof _=="string")return{kind:"reference",source:E,path:[_]};if(Array.isArray(_)&&_.every(w=>typeof w=="string"))return{kind:"reference",source:E,path:_}}function p(x){return typeof x=="object"&&x!==null&&!Array.isArray(x)}function y(x,b){return{message:`${x}: ${b}`,severity:"warn",code:"config-validation"}}function g(x){return Array.isArray(x)?"array":typeof x}function v(x,b){switch(b){case"number":if(typeof x!="number")return`should be a number, got ${typeof x}`;break;case"boolean":if(typeof x!="boolean")return`should be a boolean, got ${typeof x}`;break;case"string":case"password":case"secret":case"file":case"text":if(typeof x!="string")return`should be a string, got ${typeof x}`;break}}return gO}var yO={},Ty={},cae;function Vj(){if(cae)return Ty;cae=1;var e={};Object.defineProperty(Ty,"__esModule",{value:!0}),Ty.envOverlay=t,Ty.contextOverlay=r,Ty.defaultConfigOverlays=n,Ty.isThenable=i;function t(){return typeof process>"u"||!e?()=>{}:s=>e[s[0]]}function r(s){return o=>s[o[0]]}function n(){return{env:t(),config:()=>{}}}function i(s){return typeof s=="object"&&s!==null&&"then"in s&&typeof s.then=="function"}return Ty}var dae;function kIe(){if(dae)return yO;dae=1,Object.defineProperty(yO,"__esModule",{value:!0}),yO.prepareConfig=r;const e=M3(),t=Vj();function r(a,l,c){let u={},d,f,m,p,y=!1;for(const[g,v]of Object.entries(a.entries))switch(g){case"connections":{if(v.kind!=="dict")break;u=i(v);break}case"manifestPath":{d=o(v,l,c,"manifestPath");break}case"givensPath":{f=o(v,l,c,"givensPath");break}case"finalizeGivens":{v.kind==="value"&&n(v.value)&&(m=v.value);break}case"virtualMap":{v.kind==="value"&&(p=v.value);break}case"includeDefaultConnections":{v.kind==="value"&&typeof v.value=="boolean"&&(y=v.value);break}}return y&&s(u),{compiledConnections:u,manifestPath:d,givensPath:f,finalizeGivens:m,virtualMap:p}}function n(a){return Array.isArray(a)&&a.every(l=>typeof l=="string")}function i(a){const l={};for(const[c,u]of Object.entries(a.entries))u.kind==="dict"&&(l[c]=u);return l}function s(a){for(const l of(0,e.getRegisteredConnectionTypes)())a[l]||(a[l]={kind:"dict",entries:{is:{kind:"value",value:l}}})}function o(a,l,c,u){if(a.kind==="value")return typeof a.value=="string"?a.value:void 0;if(a.kind==="reference"){const d=l[a.source];if(!d){c.push({message:`unknown overlay source "${a.source}" for "${u}"`,severity:"warn",code:"config-overlay"});return}const f=d(a.path);if((0,t.isThenable)(f)){c.push({message:`the \`${a.source}\` overlay returned a Promise for "${u}"; top-level string settings must resolve synchronously`,severity:"warn",code:"config-overlay"});return}return typeof f=="string"?f:void 0}}return yO}var vO={},fae;function MIe(){if(fae)return vO;fae=1,Object.defineProperty(vO,"__esModule",{value:!0}),vO.buildManagedLookup=t;const e=M3();function t(a,l,c){const u=Object.entries(a),d=u.length>0?u[0][0]:void 0,f=new Map;return{async lookupConnection(m){if(m===void 0&&(m=d),m===void 0)throw new Error("No connections defined in config");const p=f.get(m);if(p)return p;const y=a[m];if(!y)throw new Error(`No connection named "${m}" found in config`);const g=await r(y,l,c);if(typeof g.is!="string")throw new Error(`Connection "${m}" is missing a valid "is" field`);const v=(0,e.getConnectionTypeDef)(g.is);if(!v)throw new Error(`No registered connection type "${g.is}" for connection "${m}". Did you forget to import the connection package?`);const x={name:m};for(const[E,_]of Object.entries(g))E!=="is"&&_!=null&&(x[E]=_);(0,e.validateConnectionConfigProperties)(m,g.is,x);const b=await v.factory(x);return f.set(m,b),b},async close(){const m=[...f.values()];f.clear();for(const p of m)await p.close()},async idle(){for(const m of f.values())await m.idle()}}}async function r(a,l,c){const u=await n(a,l,c);if(!(0,e.isConnectionConfigEntry)(u))throw new Error("Connection entry did not resolve to a valid {is: string, ...} dict");return await s(u,l),u}async function n(a,l,c){switch(a.kind){case"value":return a.value;case"reference":return i(a,l,c);case"dict":{const u={};for(const[d,f]of Object.entries(a.entries)){const m=await n(f,l,c);m!==void 0&&(u[d]=m)}return u}}}async function i(a,l,c){const u=l[a.source];if(!u){c.push({message:`unknown overlay source "${a.source}" for reference path ${JSON.stringify(a.path)}`,severity:"warn",code:"config-overlay"});return}return await u(a.path)}async function s(a,l){var c;const u=a.is;if(typeof u!="string")return;const d=(c=(0,e.getConnectionProperties)(u))!==null&&c!==void 0?c:[];for(const f of d){if(f.default===void 0||a[f.name]!==void 0)continue;const m=await o(f.default,l);m!==void 0&&(a[f.name]=m)}}async function o(a,l){if(typeof a!="object")return a;const c=Object.keys(a);if(c.length!==1)return;const u=c[0],d=a[u],f=typeof d=="string"?[d]:d;if(!Array.isArray(f))return;const m=l[u];if(m)return await m(f)}return vO}var hae;function Yj(){if(hae)return pm;hae=1,Object.defineProperty(pm,"__esModule",{value:!0}),pm.MalloyConfig=pm.Manifest=void 0,pm.isBuildManifestEntry=x;const e=LIe(),t=kIe(),r=MIe(),n=Vj(),i=Gj();class s{constructor(){this._manifest={entries:{},strict:!1},this._touched=new Set}loadText(E){this._clearEntries(),this._touched.clear(),this._manifest.strict=!1,this._loadParsed(JSON.parse(E))}get buildManifest(){return this._manifest}get strict(){var E;return(E=this._manifest.strict)!==null&&E!==void 0?E:!1}set strict(E){this._manifest.strict=E}update(E,_){(0,i.requireCanonicalTablePathAnyDialect)(_.tableName,`Manifest entry '${E}'`),this._manifest.entries[E]=_,this._touched.add(E)}touch(E){this._touched.add(E)}get activeEntries(){const E={};for(const _ of this._touched)this._manifest.entries[_]&&(E[_]=this._manifest.entries[_]);return{entries:E,strict:this._manifest.strict}}_clearEntries(){for(const E of Object.keys(this._manifest.entries))delete this._manifest.entries[E]}_loadParsed(E){typeof E.strict=="boolean"&&(this._manifest.strict=E.strict);const _=v(E.entries)?E.entries:E;for(const[w,R]of Object.entries(_))w==="strict"||!x(R)||((0,i.requireCanonicalTablePathAnyDialect)(R.tableName,`Manifest entry '${w}'`),this._manifest.entries[w]=R)}}pm.Manifest=s;class o{constructor(E,_){const w=[];let R;if(typeof E=="string")try{R=JSON.parse(E)}catch(U){w.push({message:`Invalid JSON: ${U instanceof Error?U.message:String(U)}`,severity:"error",code:"config-validation"}),R={}}else R=E;const S=(0,e.compileConfig)(R);w.push(...S.log);const A=d(_,w),C=y(A.configURL,"configURL",w),N=A.rootDirectory,D={...(0,n.defaultConfigOverlays)(),...A.overlays,config:(0,n.contextOverlay)({configURL:C,rootDirectory:N})},M=(0,t.prepareConfig)(S.compiled,D,w);this._managedLookup=(0,r.buildManagedLookup)(M.compiledConnections,D,w),this._connections=this._managedLookup,this._overlays=D,this.virtualMap=g(M.virtualMap,w),this.configURL=C,this.rootDirectory=N,this.manifestPath=M.manifestPath,this.manifestURL=c(M.manifestPath,C),this.givensPath=M.givensPath,this.givensURL=u(M.givensPath,C,w),this.finalizeGivens=M.finalizeGivens,this.log=w}get connections(){return this._connections}wrapConnections(E){this._connections=E(this._connections)}async shutdown(E="close"){E==="idle"?await this._managedLookup.idle():await this._managedLookup.close()}async releaseConnections(){await this.shutdown("close")}async readOverlay(E,..._){var w,R;return await((R=(w=this._overlays)[E])===null||R===void 0?void 0:R.call(w,_))}}pm.MalloyConfig=o;const a="MANIFESTS",l="malloy-manifest.json";function c(b,E){if(!E)return;let _;try{_=new URL(E)}catch{return}const w=b??a;let R;try{R=new URL(w,_)}catch{return}const S=R.toString(),A=S.endsWith("/")?R:new URL(S+"/");return new URL(l,A).toString()}function u(b,E,_){if(!b)return;if(!E){_.push({message:"givensPath is set but no configURL is available; per-runtime givens will not be loaded. Pass `configURL` (or use an absolute URL such as `file:///...`).",severity:"warn",code:"config-overlay"});return}let w;try{w=new URL(E)}catch{return}try{return new URL(b,w).toString()}catch(R){const S=R instanceof Error?R.message:String(R);_.push({message:`givensPath '${b}' could not be resolved against configURL '${E}': ${S}`,severity:"warn",code:"config-validation"});return}}function d(b,E){if(b===void 0)return{};if(f(b))return m(b,E);const _=b;if(_.overlays&&"config"in _.overlays){E.push({message:"`config` is reserved by MalloyConfig; pass `configURL` and `rootDirectory` directly instead. Supplied `overlays.config` ignored.",severity:"warn",code:"config-overlay"});const{config:w,...R}=_.overlays;return{..._,overlays:R}}return _}function f(b){for(const E of Object.values(b))if(typeof E=="function")return!0;return!1}function m(b,E){const _=b.config;if(!_)return{overlays:b};const w=p(_,"configURL",E),R=p(_,"rootDirectory",E),{config:S,...A}=b;return{configURL:w,rootDirectory:R,overlays:A}}function p(b,E,_){const w=b([E]);if((0,n.isThenable)(w)){_.push({message:`the legacy \`config\` overlay returned a Promise for \`${E}\`; top-level FS context must resolve synchronously. ${E} will be undefined.`,severity:"warn",code:"config-overlay"});return}return typeof w=="string"?w:void 0}function y(b,E,_){if(b!==void 0)try{return new URL(b),b}catch{_.push({message:`${E} must be a URL-shaped string (e.g. 'file:///path/to/...'), got '${b}'. In Node, use \`url.pathToFileURL(path).toString()\`.`,severity:"warn",code:"config-validation"});return}}function g(b,E){if(!v(b))return;const _=new Map;for(const[w,R]of Object.entries(b)){if(!v(R))continue;const S=new Map;for(const[A,C]of Object.entries(R)){if(typeof C!="string")continue;const N=(0,i.validateCanonicalTablePathAnyDialect)(C);if(N!==void 0){E.push({message:`virtualMap entry '${w}.${A}': ${N}`,severity:"error",code:"config-validation"});continue}S.set(A,C)}S.size>0&&_.set(w,S)}return _.size>0?_:void 0}function v(b){return typeof b=="object"&&b!==null&&!Array.isArray(b)}function x(b){return v(b)&&typeof b.tableName=="string"}return pm}var _y={},xO={},pae;function IIe(){return pae||(pae=1,Object.defineProperty(xO,"__esModule",{value:!0}),xO.MALLOY_VERSION=void 0,xO.MALLOY_VERSION="0.0.426"),xO}var mae;function uye(){if(mae)return _y;mae=1,Object.defineProperty(_y,"__esModule",{value:!0}),_y.Malloy=_y.MalloyError=void 0;const e=Wj(),t=M3(),r=ki(),n=cL(),i=IIe(),s=OL(),o=aye(),a=rv(),l=NL(),c=lye();function u(p="loadModel"){return`internal://${p}/${(0,a.v4)()}`}function d(p){return[...Object.keys(p),...Object.values(p).map(d).flat()]}class f extends Error{constructor(y,g=[]){super(y),this.problems=g}}_y.MalloyError=f;class m{static get version(){return i.MALLOY_VERSION}static registerConnectionType(y,g){(0,t.registerConnectionType)(y,g)}static getConnectionProperties(y){return(0,t.getConnectionProperties)(y)}static getConnectionTypeDisplayName(y){return(0,t.getConnectionTypeDisplayName)(y)}static getRegisteredConnectionTypes(){return(0,t.getRegisteredConnectionTypes)()}static _parse(y,g,v,x,b){var E;g===void 0&&(g=new URL(u(x?.method)));let _=g;x!=null&&x.importBaseURL&&(_=x?.importBaseURL);const w=new e.MalloyTranslator(g.toString(),_.toString(),{urls:{[g.toString()]:y}},v,(E=x?.restrictedMode)!==null&&E!==void 0?E:!1);return x!=null&&x.testEnvironment&&(w.allDialectsEnabled=!0),new o.Parse(w,b)}static parse({url:y,urlReader:g,source:v,eventStream:x,options:b}){if(v!==void 0)return m._parse(v,y,x,b);if(g===void 0)throw new Error("Internal Error: urlReader is required.");if(y===void 0)throw new Error("Internal Error: url is required if source not present.");return(0,s.readURL)(g,y).then(({contents:E,invalidationKey:_})=>m._parse(E,y,x,b,_))}static async compile(y){var g,v,x,b,E;let{url:_,source:w,importBaseURL:R,cacheManager:S}=y;const{parse:A,urlReader:C,connections:N,model:D,refreshSchemaCache:M,noThrowOnError:U,eventStream:H,restrictedMode:Y,method:re}=y;Y&&(S=void 0);let ue;if(M&&(ue=typeof M=="number"?M:Date.now()),_===void 0&&w===void 0&&A===void 0)throw new Error("Internal Error: url, source, or parse required.");_===void 0&&(A!==void 0?_=new URL(A._translator.sourceURL):_=new URL(u(re)));const B={};if(w===void 0&&S!==void 0){const ce=await S.getCachedModelDef(C,_.toString());if(ce)return new l.Model(ce.modelDef,[],[_.toString(),...d(ce.modelDef.dependencies)])}R??(R=_);let J;const oe=_.toString();if(A!==void 0){if(Y!==void 0&&A._translator.restrictedMode!==Y)throw new Error(`Malloy.compile: restrictedMode (${Y}) does not match the pre-parsed translator's restrictedMode (${A._translator.restrictedMode}). Set restrictedMode at parse time.`);J=A._translator;const ce=(g=A._invalidationKey)!==null&&g!==void 0?g:await(0,s.getInvalidationKey)(C,_);B[oe]=ce}else{if(w===void 0){const{contents:ce,invalidationKey:I}=await(0,s.readURL)(C,_);B[oe]=I,w=ce}else{const ce=await(0,s.getInvalidationKey)(C,_);B[oe]=ce}J=new e.MalloyTranslator(oe,R.toString(),{urls:{[oe]:w}},H,Y??!1)}for(;;){const ce=J.translate(D?._modelDef);if(ce.final)if(ce.modelDef){await S?.setCachedModelDef(_.toString(),{modelDef:ce.modelDef,invalidationKeys:B});for(const j of J.newlyTranslatedDependencies())await S?.setCachedModelDef(j.url,{modelDef:j.modelDef,invalidationKeys:B});const I=!ce.modelWasModified&&D?D.getExistingQueryModel():void 0;return new l.Model(ce.modelDef,ce.problems||[],[...(v=D?.fromSources)!==null&&v!==void 0?v:[],...(x=ce.fromSources)!==null&&x!==void 0?x:[]],I)}else if(U){const I=(0,r.mkModelDef)("modelDidNotCompile"),j=D?._modelDef||I;return new l.Model(j,ce.problems||[],[...(b=D?.fromSources)!==null&&b!==void 0?b:[],...(E=ce.fromSources)!==null&&E!==void 0?E:[]])}else{const I=ce.problems||[],j=J.prettyErrors();throw new f(`Error(s) compiling model:
|
|
1383
|
+
`,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(s){const o=s.includes(this.quoteCharacter),a=s.includes(this.columnSeparator),l=s.includes(this.rowSeparator),c=a||o||l;return o&&(s=s.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),c&&(s=this.quoteCharacter+s+this.quoteCharacter),s}stringify(s){return s===null?this.emptyCell:s instanceof Date?s.toISOString():typeof s=="boolean"||typeof s=="number"?JSON.stringify(s):typeof s=="bigint"?s.toString():`${s}`}getColWeight(s){let o=s;Array.isArray(s)&&(o=s[0]);let a=0;for(const l in o){a=a+1;const c=o[l];if((0,e.isCompoundArrayData)(c)){const u=this.getColWeight(c)-1;a=a+u}}return a}getHeaderRow(s){const o=[];let a=0;for(const l in s){o.push(this.escape(l));const c=s[l];if(a++,(0,e.isCompoundArrayData)(c)){const u=this.getColWeight(c)-1;a=a+u;for(let d=0;d<u;d++)o.push(this.emptyCell)}}return{rows:[o.join(this.columnSeparator)],length:1,width:a}}mergeMatrices(s){const o=Math.max(...s.map(c=>c.length)),a=s.reduce((c,u)=>c+u.width,0),l=[];for(let c=0;c<o;c++){const u=[];for(const d of s)if(c<d.length)u.push(d.rows[c]);else{const f=Array(d.width).fill(this.emptyCell);u.push(...f)}l.push(u.join(this.columnSeparator))}return{rows:l,length:o,width:a}}getChildMatrix(s){if(Array.isArray(s)){if(s.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const o=[],a=this.getHeaderRow(s[0]);o.push(...a.rows);const l=a.width;let c=1;for(const u of s){const d=this.getRowMatrix(u);c=c+d.length,o.push(...d.rows)}return{rows:o,length:c,width:l}}getRowMatrix(s){const o=[];for(const a in s){const l=s[a];if((0,e.isCompoundArrayData)(l)){const c=this.getChildMatrix(l);o.push(c)}else{const c={rows:[this.stringify(l)],length:1,width:1};o.push(c)}}return this.mergeMatrices(o)}async process(s){let o=!1;for await(const a of s){if(!o&&this.includeHeader){const c=this.getHeaderRow(a.toObject());this.stream.write(c.rows[0]),this.stream.write(this.rowSeparator),o=!0}const l=this.getRowMatrix(a.toObject());for(const c of l.rows)this.stream.write(c),this.stream.write(this.rowSeparator)}this.stream.close()}}return Ah.CSVWriter=n,Ah}var us={},pm={},gO={},ba={},lae;function M3(){if(lae)return ba;lae=1,Object.defineProperty(ba,"__esModule",{value:!0}),ba.isConnectionConfigEntry=e,ba.registerConnectionType=r,ba.getConnectionProperties=n,ba.getConnectionTypeDisplayName=i,ba.getRegisteredConnectionTypes=s,ba.getConnectionTypeDef=o,ba.validateConnectionConfigProperties=a,ba.readConnectionsConfig=l,ba.writeConnectionsConfig=c,ba.createConnectionsFromConfig=u;function e(d){return typeof d=="object"&&d!==null&&typeof d.is=="string"}const t=new Map;function r(d,f){t.set(d,f)}function n(d){var f;return(f=t.get(d))===null||f===void 0?void 0:f.properties}function i(d){var f;return(f=t.get(d))===null||f===void 0?void 0:f.displayName}function s(){return[...t.keys()]}function o(d){return t.get(d)}function a(d,f,m){var p,y;const g=(y=(p=t.get(f))===null||p===void 0?void 0:p.properties)!==null&&y!==void 0?y:[];for(const v of g){if(!v.requireLiteralString)continue;const x=m[v.name];if(x!==void 0&&typeof x!="string")throw new Error(`Connection "${d}" property "${v.name}" must be a literal string`)}}function l(d){var f;const m=JSON.parse(d),p=Object.fromEntries(Object.entries((f=m.connections)!==null&&f!==void 0?f:{}).filter(([,y])=>e(y)));return{...m,connections:p}}function c(d){return JSON.stringify(d,null,2)}function u(d,f){const m=Object.entries(d.connections),p=m.length>0?m[0][0]:void 0,y=new Map;return{async lookupConnection(g){if(g===void 0&&(g=p),g===void 0)throw new Error("No connections defined in config");const v=y.get(g);if(v)return v;const x=d.connections[g];if(!x)throw new Error(`No connection named "${g}" found in config`);const b=t.get(x.is);if(!b)throw new Error(`No registered connection type "${x.is}" for connection "${g}". Did you forget to import the connection package?`);const E={name:g};for(const[w,R]of Object.entries(x))w!=="is"&&R!=null&&(E[w]=R);a(g,x.is,E);const _=await b.factory(E);return f&&f(g,_),y.set(g,_),_},async close(){const g=[...y.values()];y.clear();for(const v of g)await v.close()},async idle(){for(const g of y.values())await g.idle()}}}return ba}var uae;function LIe(){if(uae)return gO;uae=1,Object.defineProperty(gO,"__esModule",{value:!0}),gO.compileConfig=i;const e=M3(),t=pge(),r={connections:s,manifestPath:l,givensPath:c,finalizeGivens:u,virtualMap:d,includeDefaultConnections:f},n=new Set(Object.keys(r));function i(x){const b=[],E={kind:"dict",entries:{}};if(!p(x))return b.push({message:"config is not a JSON object",severity:"error",code:"config-validation"}),{compiled:E,log:b};for(const[_,w]of Object.entries(x)){const R=r[_];if(!R){const A=(0,t.closestMatch)(_,[...n]),C=A?`. Did you mean "${A}"?`:"";b.push(y(_,`unknown config key "${_}"${C}`));continue}const S=R(w,b);S!==void 0&&(E.entries[_]=S)}return{compiled:E,log:b}}function s(x,b){if(!p(x)){b.push(y("connections",'"connections" should be an object'));return}const E=new Set((0,e.getRegisteredConnectionTypes)()),_={kind:"dict",entries:{}};for(const[w,R]of Object.entries(x)){const S=`connections.${w}`;if(!p(R)){b.push(y(S,"should be an object"));continue}const A=R.is;if(A==null||A===""){b.push(y(S,'missing required "is" field (connection type)'));continue}if(typeof A!="string"){b.push(y(`${S}.is`,'"is" should be a string'));continue}if(!E.has(A)){const N=(0,t.closestMatch)(A,[...E]),D=N?` Did you mean "${N}"?`:"";b.push(y(`${S}.is`,`unknown connection type "${A}".${D} Available types: ${[...E].join(", ")}`));continue}const C=o(S,A,R,b);_.entries[w]=C}return _}function o(x,b,E,_){var w;const R=(w=(0,e.getConnectionProperties)(b))!==null&&w!==void 0?w:[],S=new Map(R.map(C=>[C.name,C])),A={kind:"dict",entries:{}};A.entries.is={kind:"value",value:b};for(const[C,N]of Object.entries(E)){if(C==="is")continue;const D=S.get(C);if(!D){const U=(0,t.closestMatch)(C,[...S.keys()]),H=U?`. Did you mean "${U}"?`:"";_.push(y(`${x}.${C}`,`unknown property "${C}" for connection type "${b}"${H}`));continue}const M=a(`${x}.${C}`,D,N,_);M!==void 0&&(A.entries[C]=M)}return A}function a(x,b,E,_){if(E==null)return;if(b.type==="json")return{kind:"value",value:E};const w=m(E);if(w!==void 0)return b.requireLiteralString?(_.push(y(x,"must be a literal string and cannot use an overlay reference")),{kind:"value",value:E}):w;const R=v(E,b.type);if(R){if(b.requireLiteralString)return _.push(y(x,`must be a literal string, got ${g(E)}`)),{kind:"value",value:E};_.push(y(x,`${R} (expected ${b.type})`));return}return{kind:"value",value:E}}function l(x,b){const E=m(x);if(E!==void 0)return E;if(typeof x!="string"){b.push(y("manifestPath",'"manifestPath" should be a string or an overlay reference'));return}return{kind:"value",value:x}}function c(x,b){const E=m(x);if(E!==void 0)return E;if(typeof x!="string"){b.push(y("givensPath",'"givensPath" should be a string or an overlay reference'));return}return{kind:"value",value:x}}function u(x,b){if(!Array.isArray(x)||!x.every(E=>typeof E=="string")){b.push(y("finalizeGivens",'"finalizeGivens" should be an array of given names'));return}return{kind:"value",value:x}}function d(x,b){return{kind:"value",value:x}}function f(x,b){return{kind:"value",value:x}}function m(x){if(typeof x!="object"||x===null||Array.isArray(x))return;const b=Object.keys(x);if(b.length!==1)return;const E=b[0],_=x[E];if(typeof _=="string")return{kind:"reference",source:E,path:[_]};if(Array.isArray(_)&&_.every(w=>typeof w=="string"))return{kind:"reference",source:E,path:_}}function p(x){return typeof x=="object"&&x!==null&&!Array.isArray(x)}function y(x,b){return{message:`${x}: ${b}`,severity:"warn",code:"config-validation"}}function g(x){return Array.isArray(x)?"array":typeof x}function v(x,b){switch(b){case"number":if(typeof x!="number")return`should be a number, got ${typeof x}`;break;case"boolean":if(typeof x!="boolean")return`should be a boolean, got ${typeof x}`;break;case"string":case"password":case"secret":case"file":case"text":if(typeof x!="string")return`should be a string, got ${typeof x}`;break}}return gO}var yO={},Ty={},cae;function Vj(){if(cae)return Ty;cae=1;var e={};Object.defineProperty(Ty,"__esModule",{value:!0}),Ty.envOverlay=t,Ty.contextOverlay=r,Ty.defaultConfigOverlays=n,Ty.isThenable=i;function t(){return typeof process>"u"||!e?()=>{}:s=>e[s[0]]}function r(s){return o=>s[o[0]]}function n(){return{env:t(),config:()=>{}}}function i(s){return typeof s=="object"&&s!==null&&"then"in s&&typeof s.then=="function"}return Ty}var dae;function kIe(){if(dae)return yO;dae=1,Object.defineProperty(yO,"__esModule",{value:!0}),yO.prepareConfig=r;const e=M3(),t=Vj();function r(a,l,c){let u={},d,f,m,p,y=!1;for(const[g,v]of Object.entries(a.entries))switch(g){case"connections":{if(v.kind!=="dict")break;u=i(v);break}case"manifestPath":{d=o(v,l,c,"manifestPath");break}case"givensPath":{f=o(v,l,c,"givensPath");break}case"finalizeGivens":{v.kind==="value"&&n(v.value)&&(m=v.value);break}case"virtualMap":{v.kind==="value"&&(p=v.value);break}case"includeDefaultConnections":{v.kind==="value"&&typeof v.value=="boolean"&&(y=v.value);break}}return y&&s(u),{compiledConnections:u,manifestPath:d,givensPath:f,finalizeGivens:m,virtualMap:p}}function n(a){return Array.isArray(a)&&a.every(l=>typeof l=="string")}function i(a){const l={};for(const[c,u]of Object.entries(a.entries))u.kind==="dict"&&(l[c]=u);return l}function s(a){for(const l of(0,e.getRegisteredConnectionTypes)())a[l]||(a[l]={kind:"dict",entries:{is:{kind:"value",value:l}}})}function o(a,l,c,u){if(a.kind==="value")return typeof a.value=="string"?a.value:void 0;if(a.kind==="reference"){const d=l[a.source];if(!d){c.push({message:`unknown overlay source "${a.source}" for "${u}"`,severity:"warn",code:"config-overlay"});return}const f=d(a.path);if((0,t.isThenable)(f)){c.push({message:`the \`${a.source}\` overlay returned a Promise for "${u}"; top-level string settings must resolve synchronously`,severity:"warn",code:"config-overlay"});return}return typeof f=="string"?f:void 0}}return yO}var vO={},fae;function MIe(){if(fae)return vO;fae=1,Object.defineProperty(vO,"__esModule",{value:!0}),vO.buildManagedLookup=t;const e=M3();function t(a,l,c){const u=Object.entries(a),d=u.length>0?u[0][0]:void 0,f=new Map;return{async lookupConnection(m){if(m===void 0&&(m=d),m===void 0)throw new Error("No connections defined in config");const p=f.get(m);if(p)return p;const y=a[m];if(!y)throw new Error(`No connection named "${m}" found in config`);const g=await r(y,l,c);if(typeof g.is!="string")throw new Error(`Connection "${m}" is missing a valid "is" field`);const v=(0,e.getConnectionTypeDef)(g.is);if(!v)throw new Error(`No registered connection type "${g.is}" for connection "${m}". Did you forget to import the connection package?`);const x={name:m};for(const[E,_]of Object.entries(g))E!=="is"&&_!=null&&(x[E]=_);(0,e.validateConnectionConfigProperties)(m,g.is,x);const b=await v.factory(x);return f.set(m,b),b},async close(){const m=[...f.values()];f.clear();for(const p of m)await p.close()},async idle(){for(const m of f.values())await m.idle()}}}async function r(a,l,c){const u=await n(a,l,c);if(!(0,e.isConnectionConfigEntry)(u))throw new Error("Connection entry did not resolve to a valid {is: string, ...} dict");return await s(u,l),u}async function n(a,l,c){switch(a.kind){case"value":return a.value;case"reference":return i(a,l,c);case"dict":{const u={};for(const[d,f]of Object.entries(a.entries)){const m=await n(f,l,c);m!==void 0&&(u[d]=m)}return u}}}async function i(a,l,c){const u=l[a.source];if(!u){c.push({message:`unknown overlay source "${a.source}" for reference path ${JSON.stringify(a.path)}`,severity:"warn",code:"config-overlay"});return}return await u(a.path)}async function s(a,l){var c;const u=a.is;if(typeof u!="string")return;const d=(c=(0,e.getConnectionProperties)(u))!==null&&c!==void 0?c:[];for(const f of d){if(f.default===void 0||a[f.name]!==void 0)continue;const m=await o(f.default,l);m!==void 0&&(a[f.name]=m)}}async function o(a,l){if(typeof a!="object")return a;const c=Object.keys(a);if(c.length!==1)return;const u=c[0],d=a[u],f=typeof d=="string"?[d]:d;if(!Array.isArray(f))return;const m=l[u];if(m)return await m(f)}return vO}var hae;function Yj(){if(hae)return pm;hae=1,Object.defineProperty(pm,"__esModule",{value:!0}),pm.MalloyConfig=pm.Manifest=void 0,pm.isBuildManifestEntry=x;const e=LIe(),t=kIe(),r=MIe(),n=Vj(),i=Gj();class s{constructor(){this._manifest={entries:{},strict:!1},this._touched=new Set}loadText(E){this._clearEntries(),this._touched.clear(),this._manifest.strict=!1,this._loadParsed(JSON.parse(E))}get buildManifest(){return this._manifest}get strict(){var E;return(E=this._manifest.strict)!==null&&E!==void 0?E:!1}set strict(E){this._manifest.strict=E}update(E,_){(0,i.requireCanonicalTablePathAnyDialect)(_.tableName,`Manifest entry '${E}'`),this._manifest.entries[E]=_,this._touched.add(E)}touch(E){this._touched.add(E)}get activeEntries(){const E={};for(const _ of this._touched)this._manifest.entries[_]&&(E[_]=this._manifest.entries[_]);return{entries:E,strict:this._manifest.strict}}_clearEntries(){for(const E of Object.keys(this._manifest.entries))delete this._manifest.entries[E]}_loadParsed(E){typeof E.strict=="boolean"&&(this._manifest.strict=E.strict);const _=v(E.entries)?E.entries:E;for(const[w,R]of Object.entries(_))w==="strict"||!x(R)||((0,i.requireCanonicalTablePathAnyDialect)(R.tableName,`Manifest entry '${w}'`),this._manifest.entries[w]=R)}}pm.Manifest=s;class o{constructor(E,_){const w=[];let R;if(typeof E=="string")try{R=JSON.parse(E)}catch(U){w.push({message:`Invalid JSON: ${U instanceof Error?U.message:String(U)}`,severity:"error",code:"config-validation"}),R={}}else R=E;const S=(0,e.compileConfig)(R);w.push(...S.log);const A=d(_,w),C=y(A.configURL,"configURL",w),N=A.rootDirectory,D={...(0,n.defaultConfigOverlays)(),...A.overlays,config:(0,n.contextOverlay)({configURL:C,rootDirectory:N})},M=(0,t.prepareConfig)(S.compiled,D,w);this._managedLookup=(0,r.buildManagedLookup)(M.compiledConnections,D,w),this._connections=this._managedLookup,this._overlays=D,this.virtualMap=g(M.virtualMap,w),this.configURL=C,this.rootDirectory=N,this.manifestPath=M.manifestPath,this.manifestURL=c(M.manifestPath,C),this.givensPath=M.givensPath,this.givensURL=u(M.givensPath,C,w),this.finalizeGivens=M.finalizeGivens,this.log=w}get connections(){return this._connections}wrapConnections(E){this._connections=E(this._connections)}async shutdown(E="close"){E==="idle"?await this._managedLookup.idle():await this._managedLookup.close()}async releaseConnections(){await this.shutdown("close")}async readOverlay(E,..._){var w,R;return await((R=(w=this._overlays)[E])===null||R===void 0?void 0:R.call(w,_))}}pm.MalloyConfig=o;const a="MANIFESTS",l="malloy-manifest.json";function c(b,E){if(!E)return;let _;try{_=new URL(E)}catch{return}const w=b??a;let R;try{R=new URL(w,_)}catch{return}const S=R.toString(),A=S.endsWith("/")?R:new URL(S+"/");return new URL(l,A).toString()}function u(b,E,_){if(!b)return;if(!E){_.push({message:"givensPath is set but no configURL is available; per-runtime givens will not be loaded. Pass `configURL` (or use an absolute URL such as `file:///...`).",severity:"warn",code:"config-overlay"});return}let w;try{w=new URL(E)}catch{return}try{return new URL(b,w).toString()}catch(R){const S=R instanceof Error?R.message:String(R);_.push({message:`givensPath '${b}' could not be resolved against configURL '${E}': ${S}`,severity:"warn",code:"config-validation"});return}}function d(b,E){if(b===void 0)return{};if(f(b))return m(b,E);const _=b;if(_.overlays&&"config"in _.overlays){E.push({message:"`config` is reserved by MalloyConfig; pass `configURL` and `rootDirectory` directly instead. Supplied `overlays.config` ignored.",severity:"warn",code:"config-overlay"});const{config:w,...R}=_.overlays;return{..._,overlays:R}}return _}function f(b){for(const E of Object.values(b))if(typeof E=="function")return!0;return!1}function m(b,E){const _=b.config;if(!_)return{overlays:b};const w=p(_,"configURL",E),R=p(_,"rootDirectory",E),{config:S,...A}=b;return{configURL:w,rootDirectory:R,overlays:A}}function p(b,E,_){const w=b([E]);if((0,n.isThenable)(w)){_.push({message:`the legacy \`config\` overlay returned a Promise for \`${E}\`; top-level FS context must resolve synchronously. ${E} will be undefined.`,severity:"warn",code:"config-overlay"});return}return typeof w=="string"?w:void 0}function y(b,E,_){if(b!==void 0)try{return new URL(b),b}catch{_.push({message:`${E} must be a URL-shaped string (e.g. 'file:///path/to/...'), got '${b}'. In Node, use \`url.pathToFileURL(path).toString()\`.`,severity:"warn",code:"config-validation"});return}}function g(b,E){if(!v(b))return;const _=new Map;for(const[w,R]of Object.entries(b)){if(!v(R))continue;const S=new Map;for(const[A,C]of Object.entries(R)){if(typeof C!="string")continue;const N=(0,i.validateCanonicalTablePathAnyDialect)(C);if(N!==void 0){E.push({message:`virtualMap entry '${w}.${A}': ${N}`,severity:"error",code:"config-validation"});continue}S.set(A,C)}S.size>0&&_.set(w,S)}return _.size>0?_:void 0}function v(b){return typeof b=="object"&&b!==null&&!Array.isArray(b)}function x(b){return v(b)&&typeof b.tableName=="string"}return pm}var _y={},xO={},pae;function IIe(){return pae||(pae=1,Object.defineProperty(xO,"__esModule",{value:!0}),xO.MALLOY_VERSION=void 0,xO.MALLOY_VERSION="0.0.427"),xO}var mae;function uye(){if(mae)return _y;mae=1,Object.defineProperty(_y,"__esModule",{value:!0}),_y.Malloy=_y.MalloyError=void 0;const e=Wj(),t=M3(),r=ki(),n=cL(),i=IIe(),s=OL(),o=aye(),a=rv(),l=NL(),c=lye();function u(p="loadModel"){return`internal://${p}/${(0,a.v4)()}`}function d(p){return[...Object.keys(p),...Object.values(p).map(d).flat()]}class f extends Error{constructor(y,g=[]){super(y),this.problems=g}}_y.MalloyError=f;class m{static get version(){return i.MALLOY_VERSION}static registerConnectionType(y,g){(0,t.registerConnectionType)(y,g)}static getConnectionProperties(y){return(0,t.getConnectionProperties)(y)}static getConnectionTypeDisplayName(y){return(0,t.getConnectionTypeDisplayName)(y)}static getRegisteredConnectionTypes(){return(0,t.getRegisteredConnectionTypes)()}static _parse(y,g,v,x,b){var E;g===void 0&&(g=new URL(u(x?.method)));let _=g;x!=null&&x.importBaseURL&&(_=x?.importBaseURL);const w=new e.MalloyTranslator(g.toString(),_.toString(),{urls:{[g.toString()]:y}},v,(E=x?.restrictedMode)!==null&&E!==void 0?E:!1);return x!=null&&x.testEnvironment&&(w.allDialectsEnabled=!0),new o.Parse(w,b)}static parse({url:y,urlReader:g,source:v,eventStream:x,options:b}){if(v!==void 0)return m._parse(v,y,x,b);if(g===void 0)throw new Error("Internal Error: urlReader is required.");if(y===void 0)throw new Error("Internal Error: url is required if source not present.");return(0,s.readURL)(g,y).then(({contents:E,invalidationKey:_})=>m._parse(E,y,x,b,_))}static async compile(y){var g,v,x,b,E;let{url:_,source:w,importBaseURL:R,cacheManager:S}=y;const{parse:A,urlReader:C,connections:N,model:D,refreshSchemaCache:M,noThrowOnError:U,eventStream:H,restrictedMode:Y,method:re}=y;Y&&(S=void 0);let ue;if(M&&(ue=typeof M=="number"?M:Date.now()),_===void 0&&w===void 0&&A===void 0)throw new Error("Internal Error: url, source, or parse required.");_===void 0&&(A!==void 0?_=new URL(A._translator.sourceURL):_=new URL(u(re)));const B={};if(w===void 0&&S!==void 0){const ce=await S.getCachedModelDef(C,_.toString());if(ce)return new l.Model(ce.modelDef,[],[_.toString(),...d(ce.modelDef.dependencies)])}R??(R=_);let J;const oe=_.toString();if(A!==void 0){if(Y!==void 0&&A._translator.restrictedMode!==Y)throw new Error(`Malloy.compile: restrictedMode (${Y}) does not match the pre-parsed translator's restrictedMode (${A._translator.restrictedMode}). Set restrictedMode at parse time.`);J=A._translator;const ce=(g=A._invalidationKey)!==null&&g!==void 0?g:await(0,s.getInvalidationKey)(C,_);B[oe]=ce}else{if(w===void 0){const{contents:ce,invalidationKey:I}=await(0,s.readURL)(C,_);B[oe]=I,w=ce}else{const ce=await(0,s.getInvalidationKey)(C,_);B[oe]=ce}J=new e.MalloyTranslator(oe,R.toString(),{urls:{[oe]:w}},H,Y??!1)}for(;;){const ce=J.translate(D?._modelDef);if(ce.final)if(ce.modelDef){await S?.setCachedModelDef(_.toString(),{modelDef:ce.modelDef,invalidationKeys:B});for(const j of J.newlyTranslatedDependencies())await S?.setCachedModelDef(j.url,{modelDef:j.modelDef,invalidationKeys:B});const I=!ce.modelWasModified&&D?D.getExistingQueryModel():void 0;return new l.Model(ce.modelDef,ce.problems||[],[...(v=D?.fromSources)!==null&&v!==void 0?v:[],...(x=ce.fromSources)!==null&&x!==void 0?x:[]],I)}else if(U){const I=(0,r.mkModelDef)("modelDidNotCompile"),j=D?._modelDef||I;return new l.Model(j,ce.problems||[],[...(b=D?.fromSources)!==null&&b!==void 0?b:[],...(E=ce.fromSources)!==null&&E!==void 0?E:[]])}else{const I=ce.problems||[],j=J.prettyErrors();throw new f(`Error(s) compiling model:
|
|
1384
1384
|
${j}`,I)}else{if(ce.urls)for(const I of ce.urls)try{if((0,s.isInternalURL)(I))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(S!==void 0){const k=await S.getCachedModelDef(C,I);if(k){for(const L in k.invalidationKeys)B[L]=k.invalidationKeys[L];J.update({translations:{[I]:k.modelDef}});continue}}const{contents:j,invalidationKey:q}=await(0,s.readURL)(C,new URL(I)),F={[I]:j};B[I]=q,J.update({urls:F})}catch(j){J.update({errors:{urls:{[I]:j.message}}})}if(ce.tables){const I=new Map;for(const j in ce.tables){const{connectionName:q,tablePath:F}=ce.tables[j],k=I.get(q);k===void 0?I.set(q,{[j]:F}):k[j]=F}for(const[j,q]of I)try{const F=await N.lookupConnection(j),{schemas:k,errors:L}=await m.safelyFetchTableSchema(F,q,{refreshTimestamp:ue});J.update({tables:k,errors:{tables:L}})}catch(F){const k={},L={};for(const $ in q)L[$]=F.toString();J.update({tables:k,errors:{tables:L}})}}if(ce.connectionDialects)for(const I in ce.connectionDialects){const{connectionName:j}=ce.connectionDialects[I];try{const q=await N.lookupConnection(j);J.update({connectionDialects:{[I]:q.dialectName}})}catch(q){J.update({errors:{connectionDialects:{[I]:q.toString()}}})}}if(ce.compileSQL){const I=ce.compileSQL,j=I.connection,q=(0,n.sqlKey)(I.connection,I.selectStr);try{const F=await(await N.lookupConnection(j)).fetchSchemaForSQLStruct(I,{refreshTimestamp:ue});F.error&&J.update({errors:{compileSQL:{[q]:F.error}}}),F.structDef&&J.update({compileSQL:{[q]:F.structDef}})}catch(F){const k={};k[q]=F.toString(),J.update({errors:{compileSQL:k}})}}}}}static async safelyFetchTableSchema(y,g,v){const x=await y.fetchSchemaForTables(g,v);for(const b of Object.keys(g))if(x.schemas[b]===void 0&&x.errors[b]===void 0)throw new Error(`Schema fetch error for ${y.name}, no response for ${b} from ${y.dialectName}`);return x}static async run({connections:y,preparedResult:g,sqlStruct:v,connection:x,options:b}){if(!x){if(!y)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const E=v?.connection||g?.connectionName;x=await y.lookupConnection(E)}if(v){const E=await x.runSQL(v.selectStr,{queryMetadata:b?.queryMetadata});return new c.Result({structs:[v],sql:v.selectStr,result:E.rows,totalRows:E.totalRows,runStats:E.runStats,lastStageName:v.name,malloy:"",connectionName:v.connection,sourceExplore:"",sourceFilters:[],profilingUrl:E.profilingUrl},(0,r.mkModelDef)("empty_model"))}else if(g){const E=await x.runSQL(g.sql,b);return new c.Result({...g._rawQuery,result:E.rows,totalRows:E.totalRows,runStats:E.runStats,profilingUrl:E.profilingUrl},g._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:y,preparedResult:g,sqlStruct:v,connection:x,options:b}){if(v===void 0&&g===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const E=v?.connection||g?.connectionName;if(x===void 0){if(y===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");x=await y.lookupConnection(E)}if(!x.canStream())throw new Error(`Connection '${E}' cannot stream results.`);let _,w;if(v)w=new l.Explore((0,l.pseudoModelFor)(v),v),_=v.selectStr;else if(g!==void 0)w=g.resultExplore,_=g.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let R=0;for await(const S of x.runSQLStream(_,b))yield new c.DataRecord(S,R,w,void 0,void 0),R+=1}static async estimateQueryCost({connections:y,preparedResult:g,sqlStruct:v}){if(!y)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const x=v?.connection||g?.connectionName,b=await y.lookupConnection(x);if(v)return await b.estimateQueryCost(v.selectStr);if(g)return await b.estimateQueryCost(g.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}}return _y.Malloy=m,_y}var gae;function FIe(){if(gae)return us;gae=1,Object.defineProperty(us,"__esModule",{value:!0}),us.ExploreMaterializer=us.PreparedResultMaterializer=us.QueryMaterializer=us.ModelMaterializer=us.SingleConnectionRuntime=us.ConnectionRuntime=us.Runtime=void 0;const e=ki(),t=bp(),r=Gj(),n=Yj(),i=c3(),s=OL(),o=NL(),a=uye();class l{constructor(E,_){this.runtime=E,this._materialize=_}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(E,_){return new m(this.runtime,E,_)}makeExploreMaterializer(E,_){return new y(this.runtime,E,_)}makePreparedResultMaterializer(E){return new p(this.runtime,E)}}class c{constructor({urlReader:E,connections:_,connection:w,config:R,buildManifest:S,eventStream:A,cacheManager:C,givens:N}){var D,M;if(this.isTestRuntime=!1,R!==void 0)this._config=R,_=_??R.connections;else if(_===void 0){if(w===void 0)throw new Error("A MalloyConfig, LookupConnection<Connection>, or Connection is required.");_={lookupConnection:()=>Promise.resolve(w)}}if(E===void 0&&(E=new s.EmptyURLReader),this._urlReader=E,this._connections=_,this._buildManifest=S,this._eventStream=A,this._cacheManager=C,N){for(const[U,H]of Object.entries(N))if(H===void 0)throw new Error(`Runtime givens.${U}: explicit undefined is not a valid value. Omit the key to defer to declaration default or the file layer; use null for an explicit null value.`)}this._constructorGivensMap=N?new Map(Object.entries(N)):new Map,this._finalizedGivensSet=new Set((M=(D=this._config)===null||D===void 0?void 0:D.finalizeGivens)!==null&&M!==void 0?M:[])}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}get _constructorGivens(){return this._constructorGivensMap}async getGivens(){const E=await this._resolveGivens(),_=new Map;if(E)for(const[w,R]of Object.entries(E))_.set(w,R);for(const[w,R]of this._constructorGivensMap)_.set(w,R);return _}get _finalizedGivens(){return this._finalizedGivensSet}set buildManifest(E){this._buildManifest=E,this._resolvedBuildManifestPromise=void 0}_resolveBuildManifest(){var E;if(this._buildManifest)return Promise.resolve(this._buildManifest);const _=(E=this._config)===null||E===void 0?void 0:E.manifestURL;return _?(this._resolvedBuildManifestPromise||(this._resolvedBuildManifestPromise=(async()=>{let w;try{const R=await this._urlReader.readURL(new URL(_));w=typeof R=="string"?R:R.contents}catch{return}try{const R=JSON.parse(w);if(!g(R))throw new Error('manifest is not an object with an "entries" map');for(const[S,A]of Object.entries(R.entries)){if(!(0,n.isBuildManifestEntry)(A))throw new Error(`Manifest entry '${S}' is missing a string tableName`);(0,r.requireCanonicalTablePathAnyDialect)(A.tableName,`Manifest entry '${S}'`)}return R}catch(R){const S=R instanceof Error?R.message:String(R);return{entries:{},loadError:`Manifest file at ${_} could not be parsed: ${S}`}}})()),this._resolvedBuildManifestPromise):Promise.resolve(void 0)}_resolveGivens(){var E;const _=(E=this._config)===null||E===void 0?void 0:E.givensURL;return _?(this._resolvedGivensPromise||(this._resolvedGivensPromise=(async()=>{let w;try{const S=await this._urlReader.readURL(new URL(_));w=typeof S=="string"?S:S.contents}catch(S){const A=S instanceof Error?S.message:String(S);throw new Error(`givens: failed to read givens file at ${_}: ${A}`)}let R;try{R=JSON.parse(w)}catch(S){const A=S instanceof Error?S.message:String(S);throw new Error(`givens: failed to parse JSON at ${_}: ${A}`)}if(!v(R)){const S=Array.isArray(R)?"array":R===null?"null":typeof R;throw new Error(`givens: file at ${_} must be a JSON object of name → value pairs, got ${S}`)}return R})()),this._resolvedGivensPromise):Promise.resolve(void 0)}_invalidateGivensCache(){this._resolvedGivensPromise=void 0}get virtualMap(){var E,_;return(E=this._virtualMap)!==null&&E!==void 0?E:(_=this._config)===null||_===void 0?void 0:_.virtualMap}set virtualMap(E){this._virtualMap=E}async shutdown(E="close"){var _;await((_=this._config)===null||_===void 0?void 0:_.shutdown(E))}async releaseConnections(){await this.shutdown("close")}loadModel(E,_){const{refreshSchemaCache:w,noThrowOnError:R}=_||{};this.isTestRuntime&&(_===void 0?_={testEnvironment:!0}:_={..._,testEnvironment:!0});const S=E instanceof URL?{url:E}:{source:E};return new f(this,async()=>{const A=await a.Malloy.compile({...S,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:w,noThrowOnError:R,eventStream:this.eventStream,importBaseURL:_?.importBaseURL,testEnvironment:_?.testEnvironment,cacheManager:this.cacheManager});return this._withRuntimeContext(A)},_)}_withRuntimeContext(E){return this._finalizedGivensSet.size===0?E:new o.Model(E._modelDef,E.problems,E.fromSources,E.getExistingQueryModel(),{finalizedGivens:this._finalizedGivensSet})}_loadModelFromModelDef(E,_){return new f(this,async()=>new o.Model(E,[],[],void 0,this._finalizedGivensSet.size>0?{finalizedGivens:this._finalizedGivensSet}:void 0),_)}loadQuery(E,_){return this.loadModel(E,_).loadFinalQuery()}loadQueryByIndex(E,_,w){return this.loadModel(E,w).loadQueryByIndex(_,w)}loadQueryByName(E,_,w){return this.loadModel(E,w).loadQueryByName(_,w)}getModel(E,_){return this.loadModel(E,_).getModel()}getQuery(E,_){return this.loadQuery(E,_).getPreparedQuery()}getQueryByIndex(E,_,w){return this.loadQueryByIndex(E,_,w).getPreparedQuery()}getQueryByName(E,_,w){return this.loadQueryByName(E,_,w).getPreparedQuery()}}us.Runtime=c;class u extends c{constructor({urlReader:E,connections:_}){super({connections:s.FixedConnectionMap.fromArray(_),urlReader:E}),this.rawConnections=_}}us.ConnectionRuntime=u;class d extends c{constructor({urlReader:E,connection:_,eventStream:w,cacheManager:R}){super({urlReader:E,eventStream:w,cacheManager:R,connection:_}),this.connection=_}get supportsNesting(){return(0,t.getDialect)(this.connection.dialectName).supportsNesting}quote(E){return(0,t.getDialect)(this.connection.dialectName).sqlQuoteIdentifier(E)}get dialect(){return(0,t.getDialect)(this.connection.dialectName)}getQuoter(){return E=>this.quote(E.toString())}}us.SingleConnectionRuntime=d;class f extends l{constructor(E,_,w){super(E,_),this.runtime=E,this.compileQueryOptions=w}loadFinalQuery(E){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...E})}loadQueryByIndex(E,_){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(E),{...this.compileQueryOptions,..._})}loadQueryByName(E,_){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(E),{...this.compileQueryOptions,..._})}loadQuery(E,_){const{importBaseURL:w,testEnvironment:R,refreshSchemaCache:S,noThrowOnError:A,restrictedMode:C,method:N,...D}=_??{},M={...this.compileQueryOptions,...D};return this.makeQueryMaterializer(async()=>{const U=E instanceof URL?{url:E}:{source:E};return(await a.Malloy.compile({...U,urlReader:this.runtime.urlReader,connections:this.runtime.connections,model:await this.getModel(),refreshSchemaCache:S,noThrowOnError:A,importBaseURL:w,testEnvironment:R||this.runtime.isTestRuntime,...M})).preparedQuery},M)}loadRestrictedQuery(E){return this.makeQueryMaterializer(async()=>{const _=this.runtime.urlReader,w=this.runtime.connections,R=this.runtime.isTestRuntime?!0:void 0,S=await this.getModel();return(await a.Malloy.compile({source:E,restrictedMode:!0,method:"query",urlReader:_,connections:w,model:S,testEnvironment:R,...this.compileQueryOptions})).preparedQuery})}extendModel(E,_){return this.runtime.isTestRuntime&&(_===void 0?_={testEnvironment:!0}:_={..._,testEnvironment:!0}),new f(this.runtime,async()=>{const w=this.runtime.urlReader,R=this.runtime.connections,S=E instanceof URL?{url:E}:{source:E},A=await this.getModel(),C=await a.Malloy.compile({...S,urlReader:w,connections:R,model:A,method:"extendModel",refreshSchemaCache:_?.refreshSchemaCache,noThrowOnError:_?.noThrowOnError,importBaseURL:_?.importBaseURL,testEnvironment:_?.testEnvironment,...this.compileQueryOptions});return this.runtime._withRuntimeContext(C)},_)}async search(E,_,w=1e3,R=void 0){const S=await this.materialize(),A=S.queryModel,C=S.getExploreByName(E).structDef;if(!(0,e.isSourceDef)(C))throw new Error("Source to be searched was unexpectedly, not a source");const N=C.connection,D=await this.runtime.connections.lookupConnection(N);return await A.searchIndex(D,E,_,w,R)}async searchValueMap(E,_=10,w){const R=(await this.materialize()).getExploreByName(E);if(!(0,e.isSourceDef)(R.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let S="{index: *}";R.getFieldByNameIfExists("search_index")&&(S="search_index");const A=`
|
|
1385
1385
|
run: ${E}
|
|
1386
1386
|
-> ${S}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aJ as mi}from"./index-
|
|
1
|
+
import{aJ as mi}from"./index-CH2AcDzc.js";import{r as gi}from"./index-w_0OQJgZ.js";function yi(f,ie){for(var W=0;W<ie.length;W++){const P=ie[W];if(typeof P!="string"&&!Array.isArray(P)){for(const k in P)if(k!=="default"&&!(k in f)){const $=Object.getOwnPropertyDescriptor(P,k);$&&Object.defineProperty(f,k,$.get?$:{enumerable:!0,get:()=>P[k]})}}}return Object.freeze(Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}))}var Et={},dt={},Vr;function Ct(){if(Vr)return dt;Vr=1,Object.defineProperty(dt,"__esModule",{value:!0}),dt.isChainOp=f,dt.isStringCondition=ie,dt.isStringFilter=W,dt.isBooleanFilter=P,dt.isNumberFilter=k,dt.isTemporalFilter=$,dt.isFilterExpression=w,dt.isFilterable=y;function f(o){return["and","or",","].includes(o)}function ie(o){return["starts","ends","contains","="].includes(o.operator)}function W(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["starts","ends","contains","=","~","null","none","empty","and","or",",","()"].includes(o.operator)}function P(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["null","none","true","false","=false","=true"].includes(o.operator)}function k(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["range","<=",">=","!=","=",">","<","and","or","()","null","none"].includes(o.operator)}function $(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["literal","before","after","to","for","in","and","or","in_last","this","last","next","()","null","none"].includes(o.operator)}function w(o){return typeof o=="object"&&o!==null&&"operator"in o}function y(o){return["string","number","boolean","timestamp","timestamptz","date"].includes(o)}return dt}var Mt={},Lr;function vi(){return Lr||(Lr=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.BooleanFilterExpression=void 0,Mt.BooleanFilterExpression={parse(f){var ie;if(f.match(/^\s*$/))return{parsed:null,log:[]};const W={parsed:null,log:[]};let P=f.toLowerCase().trim().replace(/\s\s+/," "),k=!1;if(P.startsWith("not ")&&(k=!0,P=P.slice(4)),P==="true")W.parsed={operator:"true"};else if(P==="=true")W.parsed={operator:"=true"};else if(P==="false")W.parsed={operator:"false"};else if(P==="=false")W.parsed={operator:"=false"};else if(P==="null")W.parsed={operator:"null"};else if(P==="none")W.parsed={operator:"none"};else{const $=f.match(/[^\s]/),w=$&&(ie=$.index)!==null&&ie!==void 0?ie:0;W.log=[{message:`Illegal boolean filter '${P}'. Must be one of true,=true,false,=false,null,none`,severity:"error",startIndex:w,endIndex:w+f.length-1}]}return k&&W.parsed&&(W.parsed.not=!0),W},unparse(f){return f===null?"":(f.not?"not ":"")+f.operator}}),Mt}var yr={},ze={},Ir;function Xt(){if(Ir)return ze;Ir=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.maybeNot=ie,ze.unescape=W,ze.escape=P,ze.matchOp=$,ze.conjoin=y,ze.joinNumbers=o,ze.mkRange=d,ze.mkValues=e,ze.numNot=C,ze.temporalNot=N,ze.joinTemporal=Z,ze.timeLiteral=ne,ze.mkUnits=pe;const f=Ct();function ie(O){const[A,F]=O;return A&&F&&(0,f.isStringFilter)(F)?{...F,not:!0}:F}function W(O){return O.replace(/\\(.)/g,"$1")}function P(O){const A=O.toLowerCase();return A==="null"||A==="empty"||A==="none"?"\\"+O:O.replace(/([,; |()\\%_-])/g,"\\$1")}function k(O){let A=!1,F=!1,G=0,he=!1;const Fe=O.length;for(let we=0;we<Fe;we+=1){const He=O[we];if(He===" "||He===" "){G+=1;continue}G=0,He==="%"?(he=!0,we===0&&(A=!0),F=!0):(F=!1,He==="\\"?we+=1:He==="_"&&(he=!0))}return{hasLike:he,percentEnd:F&&Fe>1,percentStart:A&&Fe>1,endSpace:G}}function $(O){let A=O.trimStart();const{hasLike:F,percentEnd:G,percentStart:he,endSpace:Fe}=k(A);if(Fe>0&&(A=A.slice(0,-Fe)),F){if(he&&G){const we=A.slice(1,-1);if(!k(we).hasLike&&we.length>0)return{operator:"contains",values:[W(we)]}}else if(G){const we=A.slice(0,-1);if(!k(we).hasLike)return{operator:"starts",values:[W(we)]}}else if(he){const we=A.slice(1);if(!k(we).hasLike)return{operator:"ends",values:[W(we)]}}return{operator:"~",escaped_values:[A]}}return A.toLowerCase()==="null"?{operator:"null"}:A.toLowerCase()==="empty"?{operator:"empty"}:A.toLowerCase()==="none"?{operator:"none"}:{operator:"=",values:[W(A)]}}function w(O,A){var F,G;return O.operator===A.operator&&((F=O.not)!==null&&F!==void 0?F:!1)===((G=A.not)!==null&&G!==void 0?G:!1)}function y(O,A,F){if(A=A.toLowerCase(),(0,f.isStringFilter)(O)&&(0,f.isStringFilter)(F)){if(A===","){if(O.operator==="~"&&w(O,F))return{...O,escaped_values:[...O.escaped_values,...F.escaped_values]};if((0,f.isStringCondition)(O)&&w(O,F))return{...O,values:[...O.values,...F.values]}}const G=A===","?",":A==="|"?"or":A===";"?"and":void 0;if(G)return O.operator===G?{...O,members:[...O.members,F]}:{operator:G,members:[O,F]}}return null}function o(O,A,F){if(A=A.toLowerCase(),(0,f.isNumberFilter)(O)&&(0,f.isNumberFilter)(F)){if(A==="or"&&O.operator==="="&&w(O,F)){const G={operator:"=",values:[...O.values,...F.values]};return O.not&&(G.not=!0),G}if(A==="and"||A==="or")return O.operator===A?{...O,members:[...O.members,F]}:{operator:A,members:[O,F]}}return null}function d(O,A,F,G){return{operator:"range",startValue:A,startOperator:O==="("?">":">=",endValue:F,endOperator:G===")"?"<":"<="}}function e(O,A){return{values:[O,...A]}}function C(O,A){return(0,f.isNumberFilter)(O)&&A?O.operator==="="?{operator:"!=",values:O.values}:O.operator==="!="?{operator:"=",values:O.values}:{...O,not:!0}:O}function N(O,A){if((0,f.isTemporalFilter)(O)&&A){if("not"in O){const F={...O};return O.not?delete F.not:F.not=!0,F}return{...O,not:!0}}return O}function Z(O,A,F){return A=A.toLowerCase(),(0,f.isTemporalFilter)(O)&&(0,f.isTemporalFilter)(F)&&(A==="and"||A==="or")?O.operator===A?{...O,members:[...O.members,F]}:{operator:A,members:[O,F]}:null}function ne(O,A){const F={moment:"literal",literal:O};return A&&(F.units=A),F}function pe(O){switch(O.toLowerCase()){case"second":case"seconds":return"second";case"minute":case"minutes":return"minute";case"hour":case"hours":return"hour";case"day":case"days":return"day";case"week":case"weeks":return"week";case"month":case"months":return"month";case"quarter":case"quarters":return"quarter";case"year":case"years":return"year"}}return ze}var vr,Cr;function wi(){if(Cr)return vr;Cr=1;const{numNot:f,mkRange:ie,joinNumbers:W,mkValues:P}=Xt();function k(o,d){function e(){this.constructor=o}e.prototype=d.prototype,o.prototype=new e}function $(o,d,e,C){var N=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(N,$.prototype),N.expected=d,N.found=e,N.location=C,N.name="SyntaxError",N}k($,Error);function w(o,d,e){return e=e||" ",o.length>d?o:(d-=o.length,e+=e.repeat(d),o+e.slice(0,d))}$.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var e=null,C;for(C=0;C<o.length;C++)if(o[C].source===this.location.source){e=o[C].text.split(/\r\n|\n|\r/g);break}var N=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(N):N,ne=this.location.source+":"+Z.line+":"+Z.column;if(e){var pe=this.location.end,O=w("",Z.line.toString().length," "),A=e[N.line-1],F=N.line===pe.line?pe.column:A.length+1,G=F-N.column||1;d+=`
|
|
2
2
|
--> `+ne+`
|
|
3
3
|
`+O+` |
|
|
4
4
|
`+Z.line+" | "+A+`
|
package/dist/app/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
|
|
12
12
|
/>
|
|
13
13
|
<title>Malloy Publisher</title>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-CH2AcDzc.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-5eLCcNmP.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
|
@@ -11891,6 +11891,24 @@ function parsePackageScope(raw) {
|
|
|
11891
11891
|
}
|
|
11892
11892
|
throw new Error(`Invalid "scope" in the package manifest: ${JSON.stringify(raw)}. ` + `Expected "version" or "package" (default "package").`);
|
|
11893
11893
|
}
|
|
11894
|
+
function resolvePackageScope(rootRaw, materializationRaw) {
|
|
11895
|
+
const envelopeRaw = materializationRaw && typeof materializationRaw === "object" ? materializationRaw.scope : undefined;
|
|
11896
|
+
const rootDeclared = rootRaw !== undefined && rootRaw !== null;
|
|
11897
|
+
const envelopeDeclared = envelopeRaw !== undefined && envelopeRaw !== null;
|
|
11898
|
+
const rootScope = parsePackageScope(rootRaw);
|
|
11899
|
+
const envelopeScope = parsePackageScope(envelopeRaw);
|
|
11900
|
+
if (rootDeclared && envelopeDeclared) {
|
|
11901
|
+
if (rootScope !== envelopeScope) {
|
|
11902
|
+
throw new Error(`Conflicting "scope" in publisher.json: root "${rootScope}" vs ` + `"materialization.scope" "${envelopeScope}". The package cannot ` + `load until they agree. Edit "materialization": { "scope": ... } ` + `to the value you want and delete the root-level "scope" (the ` + `server rewrites both homes on its next manifest write).`);
|
|
11903
|
+
}
|
|
11904
|
+
return { scope: envelopeScope, warnings: [] };
|
|
11905
|
+
}
|
|
11906
|
+
if (rootDeclared) {
|
|
11907
|
+
return { scope: rootScope, warnings: [SCOPE_ROOT_DEPRECATION] };
|
|
11908
|
+
}
|
|
11909
|
+
return { scope: envelopeScope, warnings: [] };
|
|
11910
|
+
}
|
|
11911
|
+
var SCOPE_ROOT_DEPRECATION = `"scope" at the manifest root is deprecated: declare it as ` + `"materialization": { "scope": ... } alongside the other build knobs. The ` + `root form still works and will be removed in a future release; until then ` + `the server keeps both homes in sync when it writes the manifest, so an ` + `older publisher still reads the right value.`;
|
|
11894
11912
|
function parseFreshness(raw) {
|
|
11895
11913
|
if (!raw || typeof raw !== "object") {
|
|
11896
11914
|
return null;
|
|
@@ -11905,16 +11923,42 @@ function parseFreshness(raw) {
|
|
|
11905
11923
|
}
|
|
11906
11924
|
return freshness;
|
|
11907
11925
|
}
|
|
11926
|
+
function parseQueryMetadata(raw) {
|
|
11927
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
11928
|
+
return { metadata: null, warnings: [] };
|
|
11929
|
+
}
|
|
11930
|
+
const out = {};
|
|
11931
|
+
const warnings = [];
|
|
11932
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
11933
|
+
if (typeof value === "string") {
|
|
11934
|
+
out[name] = value;
|
|
11935
|
+
} else {
|
|
11936
|
+
warnings.push(`materialization.queryMetadata: property '${name}' must be a ` + `string (got ${value === null ? "null" : typeof value}); it is ` + `not attached to any statement`);
|
|
11937
|
+
}
|
|
11938
|
+
}
|
|
11939
|
+
return {
|
|
11940
|
+
metadata: Object.keys(out).length > 0 ? out : null,
|
|
11941
|
+
warnings
|
|
11942
|
+
};
|
|
11943
|
+
}
|
|
11908
11944
|
function parsePackageMaterialization(raw) {
|
|
11909
11945
|
if (!raw || typeof raw !== "object") {
|
|
11910
11946
|
return null;
|
|
11911
11947
|
}
|
|
11912
|
-
const { schedule, freshness } = raw;
|
|
11948
|
+
const { schedule, freshness, queryMetadata } = raw;
|
|
11913
11949
|
return {
|
|
11914
11950
|
schedule: typeof schedule === "string" ? schedule : null,
|
|
11915
|
-
freshness: parseFreshness(freshness)
|
|
11951
|
+
freshness: parseFreshness(freshness),
|
|
11952
|
+
queryMetadata: parseQueryMetadata(queryMetadata).metadata
|
|
11916
11953
|
};
|
|
11917
11954
|
}
|
|
11955
|
+
function packageMaterializationWarnings(raw) {
|
|
11956
|
+
if (!raw || typeof raw !== "object") {
|
|
11957
|
+
return [];
|
|
11958
|
+
}
|
|
11959
|
+
const { queryMetadata } = raw;
|
|
11960
|
+
return parseQueryMetadata(queryMetadata).warnings;
|
|
11961
|
+
}
|
|
11918
11962
|
|
|
11919
11963
|
// src/service/source_extraction.ts
|
|
11920
11964
|
import {
|
|
@@ -12487,6 +12531,11 @@ async function readPackageMetadata(packagePath) {
|
|
|
12487
12531
|
const manifestPath = path2.join(packagePath, PACKAGE_MANIFEST_NAME);
|
|
12488
12532
|
const contents = await fs2.promises.readFile(manifestPath, "utf8");
|
|
12489
12533
|
const parsed = JSON.parse(contents);
|
|
12534
|
+
const scope = resolvePackageScope(parsed.scope, parsed.materialization);
|
|
12535
|
+
const manifestWarnings = [
|
|
12536
|
+
...scope.warnings,
|
|
12537
|
+
...packageMaterializationWarnings(parsed.materialization)
|
|
12538
|
+
];
|
|
12490
12539
|
return {
|
|
12491
12540
|
name: parsed.name,
|
|
12492
12541
|
description: parsed.description,
|
|
@@ -12494,7 +12543,8 @@ async function readPackageMetadata(packagePath) {
|
|
|
12494
12543
|
queryableSources: parsed.queryableSources === "all" ? "all" : "declared",
|
|
12495
12544
|
manifestLocation: typeof parsed.manifestLocation === "string" ? parsed.manifestLocation : null,
|
|
12496
12545
|
materialization: parsePackageMaterialization(parsed.materialization),
|
|
12497
|
-
scope:
|
|
12546
|
+
scope: scope.scope,
|
|
12547
|
+
manifestWarnings: manifestWarnings.length > 0 ? manifestWarnings : undefined
|
|
12498
12548
|
};
|
|
12499
12549
|
}
|
|
12500
12550
|
async function listPackageFiles(packagePath) {
|