@malloy-publisher/server 0.0.171 → 0.0.172
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/build.ts +2 -0
- package/dist/app/api-doc.yaml +44 -2
- package/dist/app/assets/HomePage-Q4kzZesl.js +1 -0
- package/dist/app/assets/{MainPage-rmI25cDG.js → MainPage-BRd1ffqx.js} +1 -1
- package/dist/app/assets/ModelPage-_cFj4QLf.js +1 -0
- package/dist/app/assets/{PackagePage-C3oW8KXe.js → PackagePage-DI3p7cpq.js} +1 -1
- package/dist/app/assets/ProjectPage-4K_Nlx3j.js +1 -0
- package/dist/app/assets/{RouteError-BKfQ9y-k.js → RouteError-A5gz--Jr.js} +1 -1
- package/dist/app/assets/WorkbookPage-BF625z3S.js +1 -0
- package/dist/app/assets/{index-DUmIwFQ_.js → index-CGKwxuak.js} +110 -110
- package/dist/app/assets/{index-LGQlLlFF.js → index-DHOyIUsr.js} +1 -1
- package/dist/app/assets/{index-DJ4KYt-l.js → index-DHvz0hCo.js} +1 -1
- package/dist/app/assets/{index.umd-BCEVvpz1.js → index.umd-Dc3ElUSE.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/server.js +436 -8
- package/package.json +3 -1
- package/src/controller/connection.controller.ts +129 -1
- package/src/controller/watch-mode.controller.ts +2 -2
- package/src/service/connection.ts +230 -13
- package/src/service/db_utils.ts +288 -0
- package/src/service/project_store.ts +59 -0
- package/dist/app/assets/HomePage-oXJcPThQ.js +0 -1
- package/dist/app/assets/ModelPage-DtywEBbr.js +0 -1
- package/dist/app/assets/ProjectPage-CvmjaWsE.js +0 -1
- package/dist/app/assets/WorkbookPage-NNNUEWM5.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{V as I0,W as Mp}from"./index-
|
|
1
|
+
import{V as I0,W as Mp}from"./index-CGKwxuak.js";function qp(a,d){for(var y=0;y<d.length;y++){const m=d[y];if(typeof m!="string"&&!Array.isArray(m)){for(const h in m)if(h!=="default"&&!(h in a)){const u=Object.getOwnPropertyDescriptor(m,h);u&&Object.defineProperty(a,h,u.get?u:{enumerable:!0,get:()=>m[h]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}var mo={},Cr={},Xe={},Ma;function pe(){if(Ma)return Xe;Ma=1;/*!
|
|
2
2
|
* Copyright 2016 The ANTLR Project. All rights reserved.
|
|
3
3
|
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
|
|
4
4
|
*/Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.SuppressWarnings=Xe.Override=Xe.Nullable=Xe.NotNull=void 0;function a(h,u,r){}Xe.NotNull=a;function d(h,u,r){}Xe.Nullable=d;function y(h,u,r){}Xe.Override=y;function m(h){return(u,r,o)=>{}}return Xe.SuppressWarnings=m,Xe}var Or={},Dr={},qa;function Ve(){if(qa)return Dr;qa=1;/*!
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{L as K9,a as w,j as R,N as gr,R as iT,Q as sT,U as lo}from"./index-DUmIwFQ_.js";import{r as y0,a as Nh,b as oT,c as J9,d as aT,e as _2,f as uT,g as lT,h as S2,j as b2,k as cT,l as dT,m as xT,n as fT,o as hT,p as pT,q as mT,s as gT,t as d3,u as x3,v as f3,w as _t}from"./index-LGQlLlFF.js";import{a as s1}from"./index.umd-BCEVvpz1.js";var fa={},$g={},Vr={},qg={},Jv;function at(){return Jv||(Jv=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=r,e.mkSafeRecord=i,e.exprHasKids=a,e.exprHasE=o,e.exprIsLeaf=c,e.isAsymmetricExpr=d,e.mkTemporal=f,e.isRawCast=u,e.isFilterExprType=p,e.isTimeLiteral=h,e.isParameterType=m,e.paramHasValue=x,e.expressionIsScalar=v,e.expressionIsAggregate=C,e.expressionIsUngroupedAggregate=g,e.expressionInvolvesAggregate=_,e.expressionIsCalculation=S,e.expressionIsAnalytic=E,e.isExpressionTypeLEQ=T,e.maxExpressionType=L,e.maxOfExpressionTypes=F,e.hasExpression=k,e.isTemporalType=D,e.isBasicAtomicType=N,e.isAtomicFieldType=M,e.canOrderBy=$,e.fieldIsIntrinsic=B,e.mkFieldDef=P,e.mkArrayDef=G,e.mkArrayTypeDef=Z,e.isRepeatedRecordFunctionParam=re,e.isRepeatedRecord=I,e.isRecordOrRepeatedRecord=X,e.isBasicArray=W,e.isMatrixOperation=te,e.isJoinable=z,e.isJoined=ie,e.isJoinedSource=de,e.isDateUnit=ge,e.isTimestampUnit=ae,e.isExtractUnit=oe,e.refIsStructDef=Ce,e.segmentHasErrors=xe,e.structHasErrors=ke,e.isReduceSegment=He,e.isPartialSegment=Xe,e.isProjectSegment=Oe,e.isQuerySegment=We,e.isSamplingRows=we,e.isSamplingPercent=mt,e.isSamplingEnable=xt,e.isRawSegment=lt,e.isIndexSegment=Kt,e.bareFieldUsage=Wt,e.isSegmentSQL=Gt,e.isSegmentSource=ur,e.isSourceRegistryReference=yr,e.sourceBase=Jr,e.isSourceDef=Vt,e.isPersistableSourceDef=Re,e.isBaseTable=je,e.isLiteral=At,e.mergeEvalSpaces=Ue,e.isBasicAtomic=ue,e.getIdentifier=le,e.isCompoundArrayData=Te,e.isTurtle=Ne,e.isAtomic=Ge,e.isValueString=it,e.isValueNumber=Ze,e.isValueBoolean=Dt,e.isValueTimestamp=bt,e.isValueDate=me,e.mergeUniqueKeyRequirement=nt;const t=Object.prototype.hasOwnProperty;function r(ee,Le){return t.call(ee,Le)?ee[Le]:void 0}function i(){return Object.create(null)}function a(ee){return"kids"in ee}function o(ee){return"e"in ee}function c(ee){return!(a(ee)||o(ee))}function d(ee){return ee.node==="aggregate"&&["sum","avg","count","distinct"].includes(ee.function)}function l(ee){return ee.node!=="arrayLiteral"&&ee.node!=="recordLiteral"}function f(ee,Le){if(!("typeDef"in ee)){const Ie=typeof Le=="string"?{type:Le}:Le;if(l(ee))return{...ee,typeDef:{...Ie}}}return ee}function u(ee){return"dstSQLType"in ee}function p(ee){return["string","number","boolean","date","timestamp","timestamptz"].includes(ee)}function h(ee){return ee.node==="dateLiteral"||ee.node==="timestampLiteral"||ee.node==="timestamptzLiteral"}function m(ee){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ee)}function x(ee){return ee.value!==null}function v(ee){return ee===void 0||ee==="scalar"}function C(ee){return ee==="aggregate"||ee==="ungrouped_aggregate"}function g(ee){return ee==="ungrouped_aggregate"}function _(ee){return ee==="aggregate"||ee==="ungrouped_aggregate"||ee==="aggregate_analytic"}function S(ee){return ee==="aggregate"||ee==="scalar_analytic"||ee==="aggregate_analytic"||ee==="ungrouped_aggregate"}function E(ee){return ee==="aggregate_analytic"||ee==="scalar_analytic"}function b(ee){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ee]}function T(ee,Le){return ee===Le||b(ee)<b(Le)}function L(ee,Le){let Ie="scalar";return(ee==="aggregate"||Le==="aggregate")&&(Ie="aggregate"),(ee==="ungrouped_aggregate"||Le==="ungrouped_aggregate")&&(Ie="ungrouped_aggregate"),(ee==="scalar_analytic"||Le==="scalar_analytic")&&(Ie="scalar_analytic"),(ee==="aggregate_analytic"||Le==="aggregate_analytic")&&(Ie="aggregate_analytic"),(ee==="scalar_analytic"&&Le==="aggregate"||ee==="aggregate"&&Le==="scalar_analytic")&&(Ie="aggregate_analytic"),Ie}function F(ee){return ee.reduce(L,"scalar")}function k(ee){return"e"in ee&&ee.e!==void 0}function D(ee){return ee==="date"||ee==="timestamp"||ee==="timestamptz"}function N(ee){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ee)}function M(ee){return N(ee)||ee==="record"||ee==="array"}function $(ee){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ee)}function B(ee){return M(ee.type)&&!k(ee)}function P(ee,Le){if(W(ee))return G(ee.elementTypeDef,Le);if(I(ee)){const{type:Je,fields:$e,elementTypeDef:gt}=ee;return{type:Je,fields:$e,elementTypeDef:gt,join:"many",name:Le}}if(ee.type==="record"){const{type:Je,fields:$e}=ee;return{type:Je,fields:$e,join:"one",name:Le}}const Ie={name:Le,type:ee.type};switch(ee.type){case"sql native":return{...Ie,rawType:ee.rawType};case"number":{const Je=ee.numberType;return Je?{...Ie,numberType:Je}:Ie}case"date":{const Je=ee.timeframe;return Je?{name:Le,type:"date",timeframe:Je}:Ie}case"timestamp":{const Je={name:Le,type:"timestamp"};return ee.timeframe&&(Je.timeframe=ee.timeframe),Je}case"timestamptz":{const Je={name:Le,type:"timestamptz"};return ee.timeframe&&(Je.timeframe=ee.timeframe),Je}}return Ie}function G(ee,Le){if(ee.type==="record")return{type:"array",join:"many",name:Le,elementTypeDef:{type:"record_element"},fields:ee.fields};const Ie=P(ee,"value");return{type:"array",join:"many",name:Le,elementTypeDef:ee,fields:[Ie,{...Ie,name:"each",e:{node:"field",path:["value"]}}]}}function Z(ee){return ee.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ee.fields}:{type:"array",elementTypeDef:ee}}function re(ee){return ee.type==="array"&&ee.elementTypeDef.type==="record_element"}function I(ee){return ee.type==="array"&&ee.elementTypeDef.type==="record_element"}function X(ee){return ee.type==="record"||ee.type==="array"&&"elementTypeDef"in ee&&ee.elementTypeDef.type==="record_element"}function W(ee){return ee.type==="array"&&ee.elementTypeDef.type!=="record_element"}function te(ee){return["left","right","full","inner"].includes(ee)}function z(ee){return["composite","table","sql_select","query_source","array","record"].includes(ee.type)}function ie(ee){return"join"in ee}function de(ee){return Vt(ee)&&ie(ee)}function ge(ee){return["day","week","month","quarter","year"].includes(ee)}function ae(ee){return ge(ee)||["hour","minute","second"].includes(ee)}function oe(ee){return ae(ee)||ee==="day_of_week"||ee==="day_of_year"}var fe;(function(ee){ee.Date="date",ee.Timestamp="timestamp",ee.Number="number",ee.String="string"})(fe||(e.ValueType=fe={}));function Ce(ee){return typeof ee!="string"}function xe(ee){return!!((ee.type==="reduce"||ee.type==="project"||ee.type==="partial")&&(ee.extendSource&&ee.extendSource.some(Le=>Le.type==="error")||ee.queryFields.some(Le=>Le.type==="error")))}function ke(ee){return ee.fields.some(Le=>Le.type==="error")}function He(ee){return ee.type==="reduce"}function Xe(ee){return ee.type==="partial"}function Oe(ee){return ee.type==="project"}function We(ee){return Oe(ee)||He(ee)}function we(ee){return ee.rows!==void 0}function mt(ee){return ee.percent!==void 0}function xt(ee){return ee.enable!==void 0}function lt(ee){return ee.type==="raw"}function Kt(ee){return ee.type==="index"}function Wt(ee){return ee.uniqueKeyRequirement===void 0&&ee.analyticFunctionUse===void 0}function Gt(ee){return"sql"in ee}function ur(ee){return"type"in ee&&(ee.type==="sql_select"||ee.type==="query_source")}function yr(ee){return ee.type==="source_registry_reference"}function Jr(ee){return{...ee}}function Vt(ee){return ee.type==="table"||ee.type==="sql_select"||ee.type==="query_source"||ee.type==="query_result"||ee.type==="finalize"||ee.type==="nest_source"||ee.type==="composite"}function Re(ee){return ee.type==="sql_select"||ee.type==="query_source"}function je(ee){return de(ee)?!1:!!Vt(ee)}function At(ee){return ee==="literal"}function Ue(...ee){return ee.length<=1&&ee.every(Le=>Le==="literal")?"literal":ee.every(Le=>Le==="constant"||Le==="literal")?"constant":ee.every(Le=>Le==="output"||Le==="constant"||Le==="literal")?"output":"input"}function ue(ee){return ee.type==="string"||D(ee.type)||ee.type==="number"||ee.type==="boolean"||ee.type==="json"||ee.type==="sql native"||ee.type==="error"}function le(ee){return ee.as!==void 0?ee.as:ee.name}function Te(ee){return Array.isArray(ee)&&(ee.length===0||typeof ee[0]=="object"&&ee[0]!==null&&!Array.isArray(ee[0]))}function Ne(ee){return ee.type==="turtle"}function Ge(ee){return M(ee.type)}function it(ee,Le){return Le.type==="string"}function Ze(ee,Le){return Le.type==="number"}function Dt(ee,Le){return Le.type==="boolean"}function bt(ee,Le){return Le.type==="timestamp"}function me(ee,Le){return Le.type==="date"}e.TD={isAtomic(ee){return ee!==void 0&&M(ee.type)},isBasicAtomic(ee){return ee!==void 0&&ue({type:ee.type})},isString:ee=>ee?.type==="string",isNumber:ee=>ee?.type==="number",isBoolean:ee=>ee?.type==="boolean",isJSON:ee=>ee?.type==="json",isSQL:ee=>ee?.type==="sql native",isDate:ee=>ee?.type==="date",isTimestamp:ee=>ee?.type==="timestamp",isTimestamptz:ee=>ee?.type==="timestamptz",isAnyTimestamp(ee){return ee?.type==="timestamp"||ee?.type==="timestamptz"},isTemporal(ee){var Le;const Ie=(Le=ee?.type)!==null&&Le!==void 0?Le:"";return D(Ie)},isError:ee=>ee?.type==="error",eq(ee,Le){if(ee===void 0||Le===void 0)return!1;function Ie(Je,$e){const gt={};for(const Et of Je.fields||[])if(Et.name)gt[Et.name]=Et;else return!1;for(const Et of $e.fields||[])if(!e.TD.eq(gt[Et.name],Et))return!1;return!0}return ee.type==="array"&&Le.type==="array"?ee.elementTypeDef.type!==Le.elementTypeDef.type?!1:ee.elementTypeDef.type!=="record_element"&&Le.elementTypeDef.type!=="record_element"?e.TD.eq(ee.elementTypeDef,Le.elementTypeDef):e.TD.isAtomic(ee)&&e.TD.isAtomic(Le)&&Ie(ee,Le):ee.type==="record"&&Le.type==="record"?e.TD.isAtomic(ee)&&e.TD.isAtomic(Le)&&Ie(ee,Le):ee.type==="sql native"&&Le.type==="sql native"?ee.rawType!==void 0&&ee.rawType===Le.rawType:ee.type===Le.type}};function nt(ee,Le){return ee?Le?{isCount:ee.isCount||Le.isCount}:ee:Le}})(qg)),qg}var Xv;function go(){if(Xv)return Vr;Xv=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.arg=t,Vr.spread=r,Vr.sql=i,Vr.constant=a,Vr.output=o,Vr.literal=c,Vr.variadicParam=d,Vr.param=l,Vr.makeParam=f,Vr.maxScalar=u,Vr.maxAggregate=p,Vr.anyExprType=h,Vr.maxUngroupedAggregate=m,Vr.maxAnalytic=x,Vr.minScalar=v,Vr.minAggregate=C,Vr.minAnalytic=g,Vr.overload=_,Vr.expandBlueprintMap=te,Vr.expandOverrideMapFromBase=de,Vr.def=ae;const e=at();function t(oe){return{node:"function_parameter",name:oe}}function r(oe,fe=void 0,Ce=void 0){return{node:"spread",e:oe,prefix:fe,suffix:Ce}}function i(oe,...fe){const Ce={node:"genericSQLExpr",kids:{args:[]},src:[]},xe=[...fe];let ke="";for(const He of oe){ke+=He;const Xe=xe.shift();Xe!==void 0&&(typeof Xe=="string"?ke+=Xe:(Ce.src.push(ke),Ce.kids.args.push(Xe),ke=""))}return ke.length>0&&Ce.src.push(ke),Ce}function a(oe){return{...oe,evalSpace:"constant"}}function o(oe){return{...oe,evalSpace:"output"}}function c(oe){return{...oe,evalSpace:"literal"}}function d(oe,...fe){return{name:oe,isVariadic:!0,allowedTypes:fe}}function l(oe,...fe){return{name:oe,isVariadic:!1,allowedTypes:fe}}function f(oe,...fe){return{param:l(oe,...fe),arg:t(oe)}}function u(oe){return{...oe,expressionType:"scalar",evalSpace:"input"}}function p(oe){return{...oe,expressionType:"aggregate",evalSpace:"input"}}function h(oe){return{...oe,expressionType:void 0,evalSpace:"input"}}function m(oe){return{...oe,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function x(oe){return{...oe,expressionType:"aggregate_analytic",evalSpace:"input"}}function v(oe){return{...oe,expressionType:"scalar",evalSpace:"input"}}function C(oe){return{...oe,expressionType:"aggregate",evalSpace:"input"}}function g(oe){return{...oe,expressionType:"scalar_analytic",evalSpace:"input"}}function _(oe,fe,Ce,xe){return{returnType:oe,params:fe,e:Ce,needsWindowOrderBy:xe?.needsWindowOrderBy,between:xe?.between,isSymmetric:xe?.isSymmetric,supportsOrderBy:xe?.supportsOrderBy,defaultOrderByArgIndex:xe?.defaultOrderByArgIndex,supportsLimit:xe?.supportsLimit}}function S(oe,fe=!0,Ce=!0){if(!fe&&oe==="any")throw new Error("Return type cannot include any");if(typeof oe=="string")return{type:oe};if("array"in oe){const xe=fe?S(oe.array,!0):S(oe.array,!1);return xe.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:xe.fields}:{type:"array",elementTypeDef:xe}}else if("record"in oe){const xe=[];for(const[ke,He]of Object.entries(oe.record)){const Xe=fe?S(He,!0):S(He,!1);e.TD.isAtomic(Xe)&&xe.push((0,e.mkFieldDef)(Xe,ke))}return{type:"record",fields:xe}}else if("generic"in oe){if(!Ce)throw new Error("Cannot use generic");return{type:"generic",generic:oe.generic}}else if("sql_native"in oe)return{type:"sql native",rawType:oe.sql_native};throw new Error("Cannot figure out type")}function E(oe){if(oe==="any")throw new Error("Cannot return any type");if(typeof oe=="string")return v({type:oe});if("array"in oe)return h(S(oe,!1));if("record"in oe)return h(S(oe,!1));if("generic"in oe)return v(S(oe,!1));if("literal"in oe)return c(v(S(oe.literal,!1)));if("constant"in oe)return a(v(S(oe.constant,!1)));if("dimension"in oe)return v(S(oe.dimension,!1));if("measure"in oe)return C(S(oe.measure,!1));if("sql_native"in oe)return h({type:"sql native",rawType:oe.sql_native});if("calculation"in oe)return g(S(oe.calculation,!1));throw new Error("Invalid function blueprint")}function b(oe){return typeof oe=="string"||"array"in oe||"record"in oe||"generic"in oe||"literal"in oe||"constant"in oe||"dimension"in oe||"measure"in oe||"calculation"in oe||"sql_native"in oe}function T(oe){return b(oe)?[oe]:Array.isArray(oe)?oe:b(oe.variadic)?[oe.variadic]:oe.variadic}function L(oe){if(typeof oe=="string")return h({type:oe});if("generic"in oe)return h(S(oe));if("literal"in oe)return c(u(S(oe.literal)));if("constant"in oe)return a(u(S(oe.constant)));if("dimension"in oe)return u(S(oe.dimension));if("measure"in oe)return p(S(oe.measure));if("array"in oe)return h(S(oe,!1));if("record"in oe)return h(S(oe,!1));if("sql_native"in oe)return h({type:"sql native",rawType:oe.sql_native});if("calculation"in oe)return x(S(oe.calculation));throw new Error("Invalid function blueprint")}function F(oe){return oe.map(fe=>L(fe))}function k(oe){return typeof oe!="string"&&"variadic"in oe}function D(oe,fe){return{name:oe,allowedTypes:F(T(fe)),isVariadic:k(fe)}}function N(oe){return Object.entries(oe).map(Ce=>D(Ce[0],Ce[1]))}function M(oe){const fe=[],Ce=[];let xe=oe;for(;xe.length>0;){const He=xe.indexOf("${");if(He===-1){fe.push(xe);break}const Xe=xe.slice(0,He);xe=xe.slice(He);const Oe=xe.indexOf("}");if(Oe===-1){fe.push(Xe+xe);break}const We=xe.slice(2,Oe);xe=xe.slice(Oe+1);const we=We.startsWith("..."),mt=We.endsWith(":"),xt=we?We.slice(3):mt?We.slice(0,-1):We,lt={node:"function_parameter",name:xt};fe.push(Xe),we?Ce.push({node:"spread",e:lt,prefix:"",suffix:""}):mt&&xt==="order_by"?Ce.push({node:"aggregate_order_by"}):mt&&xt==="limit"?Ce.push({node:"aggregate_limit"}):Ce.push(lt)}return{node:"genericSQLExpr",kids:{args:Ce},src:fe}}function $(oe,fe){return k(fe)?{node:"spread",e:{node:"function_parameter",name:oe},prefix:"",suffix:""}:{node:"function_parameter",name:oe}}function B(oe,fe){const Ce=Object.entries(fe.takes),xe=Ce.length>0?Ce.length-1:0;return{node:"genericSQLExpr",kids:{args:Ce.map(ke=>$(ke[0],ke[1]))},src:[`${oe}(`,...Array(xe).fill(","),")"]}}function P(oe){return"sql"in oe.impl?M(oe.impl.sql):"expr"in oe.impl?oe.impl.expr:B(oe.impl.function,oe)}function G(oe){return{e:P(oe),between:oe.impl.between,needsWindowOrderBy:oe.impl.needsWindowOrderBy,defaultOrderByArgIndex:oe.impl.defaultOrderByArgIndex}}function Z(oe){if(oe!==void 0)return Object.entries(oe).map(([fe,Ce])=>({name:fe,acceptibleTypes:Ce.map(xe=>S(xe,!0,!1))}))}function re(oe){return{returnType:E(oe.returns),params:N(oe.takes),isSymmetric:oe.isSymmetric,supportsOrderBy:oe.supportsOrderBy,supportsLimit:oe.supportsLimit,genericTypes:Z(oe.generic),...G(oe)}}function I(oe){return"takes"in oe&&"returns"in oe&&"impl"in oe}function X(oe){return"function"in oe||"sql"in oe||"expr"in oe}function W(oe){return I(oe)?[re(oe)]:Object.values(oe).flatMap(fe=>re(fe))}function te(oe){const fe={};for(const Ce in oe)fe[Ce]=W(oe[Ce]);return fe}function z(oe,fe){return[re({...oe,impl:fe})]}function ie(oe,fe,Ce){if(X(Ce)){if(!I(fe))throw new Error(`Malformed function override: ${oe}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(fe)})`);return z(fe,Ce)}else{if(I(fe))throw new Error(`Malformed function override: ${oe}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(Ce)})`);return Object.entries(Ce).flatMap(([xe,ke])=>{const He=fe[xe];if(He===void 0)throw new Error(`Malformed function override: ${oe}. No overload named ${xe}`);return z(He,ke)})}}function de(oe,fe){const Ce={};for(const xe in fe){if(!(xe in oe))throw new Error(`Malformed function override: ${xe}. No such function in Malloy standard`);Ce[xe]=ie(xe,oe[xe],fe[xe])}return Ce}function*ge(oe){if(typeof oe!="string"){if("generic"in oe)yield oe;else if("record"in oe)for(const fe of Object.values(oe.record))yield*ge(fe);else for(const fe of["array","literal","measure","dimension","measure","constant","cacluation"])if(fe in oe){yield*ge(oe[fe]);return}}}function ae(oe,fe,Ce,xe={}){let ke=!1;const He={};for(const Oe of Object.values(fe))for(const We of ge(Oe))He[We.generic]=["any"],ke=!0;ke&&xe.generic===void 0&&(xe.generic=He);const Xe={takes:fe,returns:Ce,impl:{function:oe.toUpperCase()},...xe};return{[oe]:Xe}}return Vr}var jg={},Zv;function $a(){return Zv||(Zv=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Dialect=e.dayIndex=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=i,e.qtz=a;const t=at();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");const r=["microsecond","millisecond","second","minute","hour","day","week","month","quarter","year"];e.dayIndex=r.indexOf("day");function i(c){return r.indexOf(c)>=e.dayIndex}function a(c){const d=c.queryTimezone;if(!(d===void 0||d===c.systemTimezone))return d}class o{constructor(){this.cantPartitionWindowFunctionsOnExpressions=!1,this.supportsPipelinesInViews=!0,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"}]}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 f=BigInt(d);for(const u of this.integerTypeMappings)if(f>=u.min&&f<=u.max)return{type:"number",numberType:u.numberType};return{type:"number",numberType:"bigint"}}static makeTimeLiteralNode(d,l,f,u,p){var h;const m=(h=d?.hasTimestamptz)!==null&&h!==void 0?h:!1;return p==="date"?{node:"dateLiteral",literal:l,typeDef:{type:"date",timeframe:u!==void 0&&(0,t.isDateUnit)(u)?u:void 0}}:f&&m?{node:"timestamptzLiteral",literal:l,typeDef:{type:"timestamptz",timeframe:u},timezone:f}:f?{node:"timestampLiteral",literal:l,typeDef:{type:"timestamp",timeframe:u},timezone:f}:{node:"timestampLiteral",literal:l,typeDef:{type:"timestamp",timeframe:u}}}sqlTurtleOrderByClause(d){const l=d.map(f=>` ${f.field} ${f.dir.toUpperCase()}`);return" "+this.sqlOrderBy(l,"turtle")}sqlFinalStage(d,l){throw new Error("Dialect has no final Stage but called Anyway")}sqlDateToString(d){return this.castToString(`DATE(${d})`)}sqlLiteralNumber(d){return d}ignoreInProject(d){return!1}needsCivilTimeComputation(d,l,f,u){const p=["day","week","month","quarter","year"],h=l!==void 0&&p.includes(l),m=f!==void 0&&p.includes(f),x=a(u);return{needed:t.TD.isAnyTimestamp(d)&&(h||m)&&x!==void 0,tz:x}}sqlTruncAndOffset(d,l,f,u){if(t.TD.isAnyTimestamp(d.typeDef)){const{needed:h,tz:m}=this.needsCivilTimeComputation(d.typeDef,f,u?.unit,l);if(h&&m){const x=this.sqlConvertToCivilTime(d.sql,m,d.typeDef);let v=x.sql;const C=x.typeDef;return f&&(v=this.sqlTruncate(v,f,C,!0,m)),u&&(v=this.sqlOffsetTime(v,u.op,u.magnitude,u.unit,C,!0,m)),this.sqlConvertFromCivilTime(v,m,d.typeDef)}}let p=d.sql;return f&&(p=this.sqlTruncate(p,f,d.typeDef,!1,a(l))),u&&(p=this.sqlOffsetTime(p,u.op,u.magnitude,u.unit,d.typeDef,!1,a(l))),p}exprToSQL(d,l){switch(l.node){case"now":return this.sqlNowExpr();case"timeDiff":return this.sqlMeasureTimeExpr(l);case"delta":{const f=l.kids.base;return f.node==="trunc"?this.sqlTruncAndOffset(f.e,d,f.units,{op:l.op,magnitude:l.kids.delta.sql,unit:l.units}):this.sqlTruncAndOffset(f,d,void 0,{op:l.op,magnitude:l.kids.delta.sql,unit:l.units})}case"trunc":return this.sqlTruncAndOffset(l.e,d,l.units);case"extract":return this.sqlTimeExtractExpr(d,l);case"cast":return this.sqlCast(d,l);case"regexpMatch":return this.sqlRegexpMatch(l);case"/":return this.divisionIsInteger?`${l.kids.left.sql}*1.0/${l.kids.right.sql}`:void 0;case"%":return this.hasModOperator?void 0:`MOD(${l.kids.left.sql},${l.kids.right.sql})`;case"dateLiteral":return this.sqlDateLiteral(d,l.literal);case"timestampLiteral":return this.sqlTimestampLiteral(d,l.literal,l.timezone);case"timestamptzLiteral":return this.sqlTimestamptzLiteral(d,l.literal,l.timezone);case"stringLiteral":return this.sqlLiteralString(l.literal);case"numberLiteral":return this.sqlLiteralNumber(l.literal);case"regexpLiteral":return this.sqlLiteralRegexp(l.literal);case"recordLiteral":return this.sqlLiteralRecord(l);case"arrayLiteral":return this.sqlLiteralArray(l)}}sqlSumDistinct(d,l,f){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(d,l,f){return"sqlAggDistinct called but not implemented"}sqlSampleTable(d,l){if(l!==void 0)throw new Error(`Sampling is not supported on dialect ${this.name}.`);return d}sqlOrderBy(d,l){return`ORDER BY ${d.join(",")}`}sqlTzStr(d){return`"${d.queryTimezone}"`}sqlMakeUnnestKey(d,l){return this.concat(d,"'x'",l)}sqlStringAggDistinct(d,l,f){const u="__STRING_AGG_KS__",p="__STRING_AGG_KE__";return`REGEXP_REPLACE(
|
|
1
|
+
import{L as K9,r as w,j as R,N as gr,R as iT,Q as sT,U as lo}from"./index-CGKwxuak.js";import{r as y0,a as Nh,b as oT,c as J9,d as aT,e as _2,f as uT,g as lT,h as S2,j as b2,k as cT,l as dT,m as xT,n as fT,o as hT,p as pT,q as mT,s as gT,t as d3,u as x3,v as f3,w as _t}from"./index-DHOyIUsr.js";import{a as s1}from"./index.umd-Dc3ElUSE.js";var fa={},$g={},Vr={},qg={},Jv;function at(){return Jv||(Jv=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=r,e.mkSafeRecord=i,e.exprHasKids=a,e.exprHasE=o,e.exprIsLeaf=c,e.isAsymmetricExpr=d,e.mkTemporal=f,e.isRawCast=u,e.isFilterExprType=p,e.isTimeLiteral=h,e.isParameterType=m,e.paramHasValue=x,e.expressionIsScalar=v,e.expressionIsAggregate=C,e.expressionIsUngroupedAggregate=g,e.expressionInvolvesAggregate=_,e.expressionIsCalculation=S,e.expressionIsAnalytic=E,e.isExpressionTypeLEQ=T,e.maxExpressionType=L,e.maxOfExpressionTypes=F,e.hasExpression=k,e.isTemporalType=D,e.isBasicAtomicType=N,e.isAtomicFieldType=M,e.canOrderBy=$,e.fieldIsIntrinsic=B,e.mkFieldDef=P,e.mkArrayDef=G,e.mkArrayTypeDef=Z,e.isRepeatedRecordFunctionParam=re,e.isRepeatedRecord=I,e.isRecordOrRepeatedRecord=X,e.isBasicArray=W,e.isMatrixOperation=te,e.isJoinable=z,e.isJoined=ie,e.isJoinedSource=de,e.isDateUnit=ge,e.isTimestampUnit=ae,e.isExtractUnit=oe,e.refIsStructDef=Ce,e.segmentHasErrors=xe,e.structHasErrors=ke,e.isReduceSegment=He,e.isPartialSegment=Xe,e.isProjectSegment=Oe,e.isQuerySegment=We,e.isSamplingRows=we,e.isSamplingPercent=mt,e.isSamplingEnable=xt,e.isRawSegment=lt,e.isIndexSegment=Kt,e.bareFieldUsage=Wt,e.isSegmentSQL=Gt,e.isSegmentSource=ur,e.isSourceRegistryReference=yr,e.sourceBase=Jr,e.isSourceDef=Vt,e.isPersistableSourceDef=Re,e.isBaseTable=je,e.isLiteral=At,e.mergeEvalSpaces=Ue,e.isBasicAtomic=ue,e.getIdentifier=le,e.isCompoundArrayData=Te,e.isTurtle=Ne,e.isAtomic=Ge,e.isValueString=it,e.isValueNumber=Ze,e.isValueBoolean=Dt,e.isValueTimestamp=bt,e.isValueDate=me,e.mergeUniqueKeyRequirement=nt;const t=Object.prototype.hasOwnProperty;function r(ee,Le){return t.call(ee,Le)?ee[Le]:void 0}function i(){return Object.create(null)}function a(ee){return"kids"in ee}function o(ee){return"e"in ee}function c(ee){return!(a(ee)||o(ee))}function d(ee){return ee.node==="aggregate"&&["sum","avg","count","distinct"].includes(ee.function)}function l(ee){return ee.node!=="arrayLiteral"&&ee.node!=="recordLiteral"}function f(ee,Le){if(!("typeDef"in ee)){const Ie=typeof Le=="string"?{type:Le}:Le;if(l(ee))return{...ee,typeDef:{...Ie}}}return ee}function u(ee){return"dstSQLType"in ee}function p(ee){return["string","number","boolean","date","timestamp","timestamptz"].includes(ee)}function h(ee){return ee.node==="dateLiteral"||ee.node==="timestampLiteral"||ee.node==="timestamptzLiteral"}function m(ee){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ee)}function x(ee){return ee.value!==null}function v(ee){return ee===void 0||ee==="scalar"}function C(ee){return ee==="aggregate"||ee==="ungrouped_aggregate"}function g(ee){return ee==="ungrouped_aggregate"}function _(ee){return ee==="aggregate"||ee==="ungrouped_aggregate"||ee==="aggregate_analytic"}function S(ee){return ee==="aggregate"||ee==="scalar_analytic"||ee==="aggregate_analytic"||ee==="ungrouped_aggregate"}function E(ee){return ee==="aggregate_analytic"||ee==="scalar_analytic"}function b(ee){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ee]}function T(ee,Le){return ee===Le||b(ee)<b(Le)}function L(ee,Le){let Ie="scalar";return(ee==="aggregate"||Le==="aggregate")&&(Ie="aggregate"),(ee==="ungrouped_aggregate"||Le==="ungrouped_aggregate")&&(Ie="ungrouped_aggregate"),(ee==="scalar_analytic"||Le==="scalar_analytic")&&(Ie="scalar_analytic"),(ee==="aggregate_analytic"||Le==="aggregate_analytic")&&(Ie="aggregate_analytic"),(ee==="scalar_analytic"&&Le==="aggregate"||ee==="aggregate"&&Le==="scalar_analytic")&&(Ie="aggregate_analytic"),Ie}function F(ee){return ee.reduce(L,"scalar")}function k(ee){return"e"in ee&&ee.e!==void 0}function D(ee){return ee==="date"||ee==="timestamp"||ee==="timestamptz"}function N(ee){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ee)}function M(ee){return N(ee)||ee==="record"||ee==="array"}function $(ee){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ee)}function B(ee){return M(ee.type)&&!k(ee)}function P(ee,Le){if(W(ee))return G(ee.elementTypeDef,Le);if(I(ee)){const{type:Je,fields:$e,elementTypeDef:gt}=ee;return{type:Je,fields:$e,elementTypeDef:gt,join:"many",name:Le}}if(ee.type==="record"){const{type:Je,fields:$e}=ee;return{type:Je,fields:$e,join:"one",name:Le}}const Ie={name:Le,type:ee.type};switch(ee.type){case"sql native":return{...Ie,rawType:ee.rawType};case"number":{const Je=ee.numberType;return Je?{...Ie,numberType:Je}:Ie}case"date":{const Je=ee.timeframe;return Je?{name:Le,type:"date",timeframe:Je}:Ie}case"timestamp":{const Je={name:Le,type:"timestamp"};return ee.timeframe&&(Je.timeframe=ee.timeframe),Je}case"timestamptz":{const Je={name:Le,type:"timestamptz"};return ee.timeframe&&(Je.timeframe=ee.timeframe),Je}}return Ie}function G(ee,Le){if(ee.type==="record")return{type:"array",join:"many",name:Le,elementTypeDef:{type:"record_element"},fields:ee.fields};const Ie=P(ee,"value");return{type:"array",join:"many",name:Le,elementTypeDef:ee,fields:[Ie,{...Ie,name:"each",e:{node:"field",path:["value"]}}]}}function Z(ee){return ee.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ee.fields}:{type:"array",elementTypeDef:ee}}function re(ee){return ee.type==="array"&&ee.elementTypeDef.type==="record_element"}function I(ee){return ee.type==="array"&&ee.elementTypeDef.type==="record_element"}function X(ee){return ee.type==="record"||ee.type==="array"&&"elementTypeDef"in ee&&ee.elementTypeDef.type==="record_element"}function W(ee){return ee.type==="array"&&ee.elementTypeDef.type!=="record_element"}function te(ee){return["left","right","full","inner"].includes(ee)}function z(ee){return["composite","table","sql_select","query_source","array","record"].includes(ee.type)}function ie(ee){return"join"in ee}function de(ee){return Vt(ee)&&ie(ee)}function ge(ee){return["day","week","month","quarter","year"].includes(ee)}function ae(ee){return ge(ee)||["hour","minute","second"].includes(ee)}function oe(ee){return ae(ee)||ee==="day_of_week"||ee==="day_of_year"}var fe;(function(ee){ee.Date="date",ee.Timestamp="timestamp",ee.Number="number",ee.String="string"})(fe||(e.ValueType=fe={}));function Ce(ee){return typeof ee!="string"}function xe(ee){return!!((ee.type==="reduce"||ee.type==="project"||ee.type==="partial")&&(ee.extendSource&&ee.extendSource.some(Le=>Le.type==="error")||ee.queryFields.some(Le=>Le.type==="error")))}function ke(ee){return ee.fields.some(Le=>Le.type==="error")}function He(ee){return ee.type==="reduce"}function Xe(ee){return ee.type==="partial"}function Oe(ee){return ee.type==="project"}function We(ee){return Oe(ee)||He(ee)}function we(ee){return ee.rows!==void 0}function mt(ee){return ee.percent!==void 0}function xt(ee){return ee.enable!==void 0}function lt(ee){return ee.type==="raw"}function Kt(ee){return ee.type==="index"}function Wt(ee){return ee.uniqueKeyRequirement===void 0&&ee.analyticFunctionUse===void 0}function Gt(ee){return"sql"in ee}function ur(ee){return"type"in ee&&(ee.type==="sql_select"||ee.type==="query_source")}function yr(ee){return ee.type==="source_registry_reference"}function Jr(ee){return{...ee}}function Vt(ee){return ee.type==="table"||ee.type==="sql_select"||ee.type==="query_source"||ee.type==="query_result"||ee.type==="finalize"||ee.type==="nest_source"||ee.type==="composite"}function Re(ee){return ee.type==="sql_select"||ee.type==="query_source"}function je(ee){return de(ee)?!1:!!Vt(ee)}function At(ee){return ee==="literal"}function Ue(...ee){return ee.length<=1&&ee.every(Le=>Le==="literal")?"literal":ee.every(Le=>Le==="constant"||Le==="literal")?"constant":ee.every(Le=>Le==="output"||Le==="constant"||Le==="literal")?"output":"input"}function ue(ee){return ee.type==="string"||D(ee.type)||ee.type==="number"||ee.type==="boolean"||ee.type==="json"||ee.type==="sql native"||ee.type==="error"}function le(ee){return ee.as!==void 0?ee.as:ee.name}function Te(ee){return Array.isArray(ee)&&(ee.length===0||typeof ee[0]=="object"&&ee[0]!==null&&!Array.isArray(ee[0]))}function Ne(ee){return ee.type==="turtle"}function Ge(ee){return M(ee.type)}function it(ee,Le){return Le.type==="string"}function Ze(ee,Le){return Le.type==="number"}function Dt(ee,Le){return Le.type==="boolean"}function bt(ee,Le){return Le.type==="timestamp"}function me(ee,Le){return Le.type==="date"}e.TD={isAtomic(ee){return ee!==void 0&&M(ee.type)},isBasicAtomic(ee){return ee!==void 0&&ue({type:ee.type})},isString:ee=>ee?.type==="string",isNumber:ee=>ee?.type==="number",isBoolean:ee=>ee?.type==="boolean",isJSON:ee=>ee?.type==="json",isSQL:ee=>ee?.type==="sql native",isDate:ee=>ee?.type==="date",isTimestamp:ee=>ee?.type==="timestamp",isTimestamptz:ee=>ee?.type==="timestamptz",isAnyTimestamp(ee){return ee?.type==="timestamp"||ee?.type==="timestamptz"},isTemporal(ee){var Le;const Ie=(Le=ee?.type)!==null&&Le!==void 0?Le:"";return D(Ie)},isError:ee=>ee?.type==="error",eq(ee,Le){if(ee===void 0||Le===void 0)return!1;function Ie(Je,$e){const gt={};for(const Et of Je.fields||[])if(Et.name)gt[Et.name]=Et;else return!1;for(const Et of $e.fields||[])if(!e.TD.eq(gt[Et.name],Et))return!1;return!0}return ee.type==="array"&&Le.type==="array"?ee.elementTypeDef.type!==Le.elementTypeDef.type?!1:ee.elementTypeDef.type!=="record_element"&&Le.elementTypeDef.type!=="record_element"?e.TD.eq(ee.elementTypeDef,Le.elementTypeDef):e.TD.isAtomic(ee)&&e.TD.isAtomic(Le)&&Ie(ee,Le):ee.type==="record"&&Le.type==="record"?e.TD.isAtomic(ee)&&e.TD.isAtomic(Le)&&Ie(ee,Le):ee.type==="sql native"&&Le.type==="sql native"?ee.rawType!==void 0&&ee.rawType===Le.rawType:ee.type===Le.type}};function nt(ee,Le){return ee?Le?{isCount:ee.isCount||Le.isCount}:ee:Le}})(qg)),qg}var Xv;function go(){if(Xv)return Vr;Xv=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.arg=t,Vr.spread=r,Vr.sql=i,Vr.constant=a,Vr.output=o,Vr.literal=c,Vr.variadicParam=d,Vr.param=l,Vr.makeParam=f,Vr.maxScalar=u,Vr.maxAggregate=p,Vr.anyExprType=h,Vr.maxUngroupedAggregate=m,Vr.maxAnalytic=x,Vr.minScalar=v,Vr.minAggregate=C,Vr.minAnalytic=g,Vr.overload=_,Vr.expandBlueprintMap=te,Vr.expandOverrideMapFromBase=de,Vr.def=ae;const e=at();function t(oe){return{node:"function_parameter",name:oe}}function r(oe,fe=void 0,Ce=void 0){return{node:"spread",e:oe,prefix:fe,suffix:Ce}}function i(oe,...fe){const Ce={node:"genericSQLExpr",kids:{args:[]},src:[]},xe=[...fe];let ke="";for(const He of oe){ke+=He;const Xe=xe.shift();Xe!==void 0&&(typeof Xe=="string"?ke+=Xe:(Ce.src.push(ke),Ce.kids.args.push(Xe),ke=""))}return ke.length>0&&Ce.src.push(ke),Ce}function a(oe){return{...oe,evalSpace:"constant"}}function o(oe){return{...oe,evalSpace:"output"}}function c(oe){return{...oe,evalSpace:"literal"}}function d(oe,...fe){return{name:oe,isVariadic:!0,allowedTypes:fe}}function l(oe,...fe){return{name:oe,isVariadic:!1,allowedTypes:fe}}function f(oe,...fe){return{param:l(oe,...fe),arg:t(oe)}}function u(oe){return{...oe,expressionType:"scalar",evalSpace:"input"}}function p(oe){return{...oe,expressionType:"aggregate",evalSpace:"input"}}function h(oe){return{...oe,expressionType:void 0,evalSpace:"input"}}function m(oe){return{...oe,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function x(oe){return{...oe,expressionType:"aggregate_analytic",evalSpace:"input"}}function v(oe){return{...oe,expressionType:"scalar",evalSpace:"input"}}function C(oe){return{...oe,expressionType:"aggregate",evalSpace:"input"}}function g(oe){return{...oe,expressionType:"scalar_analytic",evalSpace:"input"}}function _(oe,fe,Ce,xe){return{returnType:oe,params:fe,e:Ce,needsWindowOrderBy:xe?.needsWindowOrderBy,between:xe?.between,isSymmetric:xe?.isSymmetric,supportsOrderBy:xe?.supportsOrderBy,defaultOrderByArgIndex:xe?.defaultOrderByArgIndex,supportsLimit:xe?.supportsLimit}}function S(oe,fe=!0,Ce=!0){if(!fe&&oe==="any")throw new Error("Return type cannot include any");if(typeof oe=="string")return{type:oe};if("array"in oe){const xe=fe?S(oe.array,!0):S(oe.array,!1);return xe.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:xe.fields}:{type:"array",elementTypeDef:xe}}else if("record"in oe){const xe=[];for(const[ke,He]of Object.entries(oe.record)){const Xe=fe?S(He,!0):S(He,!1);e.TD.isAtomic(Xe)&&xe.push((0,e.mkFieldDef)(Xe,ke))}return{type:"record",fields:xe}}else if("generic"in oe){if(!Ce)throw new Error("Cannot use generic");return{type:"generic",generic:oe.generic}}else if("sql_native"in oe)return{type:"sql native",rawType:oe.sql_native};throw new Error("Cannot figure out type")}function E(oe){if(oe==="any")throw new Error("Cannot return any type");if(typeof oe=="string")return v({type:oe});if("array"in oe)return h(S(oe,!1));if("record"in oe)return h(S(oe,!1));if("generic"in oe)return v(S(oe,!1));if("literal"in oe)return c(v(S(oe.literal,!1)));if("constant"in oe)return a(v(S(oe.constant,!1)));if("dimension"in oe)return v(S(oe.dimension,!1));if("measure"in oe)return C(S(oe.measure,!1));if("sql_native"in oe)return h({type:"sql native",rawType:oe.sql_native});if("calculation"in oe)return g(S(oe.calculation,!1));throw new Error("Invalid function blueprint")}function b(oe){return typeof oe=="string"||"array"in oe||"record"in oe||"generic"in oe||"literal"in oe||"constant"in oe||"dimension"in oe||"measure"in oe||"calculation"in oe||"sql_native"in oe}function T(oe){return b(oe)?[oe]:Array.isArray(oe)?oe:b(oe.variadic)?[oe.variadic]:oe.variadic}function L(oe){if(typeof oe=="string")return h({type:oe});if("generic"in oe)return h(S(oe));if("literal"in oe)return c(u(S(oe.literal)));if("constant"in oe)return a(u(S(oe.constant)));if("dimension"in oe)return u(S(oe.dimension));if("measure"in oe)return p(S(oe.measure));if("array"in oe)return h(S(oe,!1));if("record"in oe)return h(S(oe,!1));if("sql_native"in oe)return h({type:"sql native",rawType:oe.sql_native});if("calculation"in oe)return x(S(oe.calculation));throw new Error("Invalid function blueprint")}function F(oe){return oe.map(fe=>L(fe))}function k(oe){return typeof oe!="string"&&"variadic"in oe}function D(oe,fe){return{name:oe,allowedTypes:F(T(fe)),isVariadic:k(fe)}}function N(oe){return Object.entries(oe).map(Ce=>D(Ce[0],Ce[1]))}function M(oe){const fe=[],Ce=[];let xe=oe;for(;xe.length>0;){const He=xe.indexOf("${");if(He===-1){fe.push(xe);break}const Xe=xe.slice(0,He);xe=xe.slice(He);const Oe=xe.indexOf("}");if(Oe===-1){fe.push(Xe+xe);break}const We=xe.slice(2,Oe);xe=xe.slice(Oe+1);const we=We.startsWith("..."),mt=We.endsWith(":"),xt=we?We.slice(3):mt?We.slice(0,-1):We,lt={node:"function_parameter",name:xt};fe.push(Xe),we?Ce.push({node:"spread",e:lt,prefix:"",suffix:""}):mt&&xt==="order_by"?Ce.push({node:"aggregate_order_by"}):mt&&xt==="limit"?Ce.push({node:"aggregate_limit"}):Ce.push(lt)}return{node:"genericSQLExpr",kids:{args:Ce},src:fe}}function $(oe,fe){return k(fe)?{node:"spread",e:{node:"function_parameter",name:oe},prefix:"",suffix:""}:{node:"function_parameter",name:oe}}function B(oe,fe){const Ce=Object.entries(fe.takes),xe=Ce.length>0?Ce.length-1:0;return{node:"genericSQLExpr",kids:{args:Ce.map(ke=>$(ke[0],ke[1]))},src:[`${oe}(`,...Array(xe).fill(","),")"]}}function P(oe){return"sql"in oe.impl?M(oe.impl.sql):"expr"in oe.impl?oe.impl.expr:B(oe.impl.function,oe)}function G(oe){return{e:P(oe),between:oe.impl.between,needsWindowOrderBy:oe.impl.needsWindowOrderBy,defaultOrderByArgIndex:oe.impl.defaultOrderByArgIndex}}function Z(oe){if(oe!==void 0)return Object.entries(oe).map(([fe,Ce])=>({name:fe,acceptibleTypes:Ce.map(xe=>S(xe,!0,!1))}))}function re(oe){return{returnType:E(oe.returns),params:N(oe.takes),isSymmetric:oe.isSymmetric,supportsOrderBy:oe.supportsOrderBy,supportsLimit:oe.supportsLimit,genericTypes:Z(oe.generic),...G(oe)}}function I(oe){return"takes"in oe&&"returns"in oe&&"impl"in oe}function X(oe){return"function"in oe||"sql"in oe||"expr"in oe}function W(oe){return I(oe)?[re(oe)]:Object.values(oe).flatMap(fe=>re(fe))}function te(oe){const fe={};for(const Ce in oe)fe[Ce]=W(oe[Ce]);return fe}function z(oe,fe){return[re({...oe,impl:fe})]}function ie(oe,fe,Ce){if(X(Ce)){if(!I(fe))throw new Error(`Malformed function override: ${oe}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(fe)})`);return z(fe,Ce)}else{if(I(fe))throw new Error(`Malformed function override: ${oe}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(Ce)})`);return Object.entries(Ce).flatMap(([xe,ke])=>{const He=fe[xe];if(He===void 0)throw new Error(`Malformed function override: ${oe}. No overload named ${xe}`);return z(He,ke)})}}function de(oe,fe){const Ce={};for(const xe in fe){if(!(xe in oe))throw new Error(`Malformed function override: ${xe}. No such function in Malloy standard`);Ce[xe]=ie(xe,oe[xe],fe[xe])}return Ce}function*ge(oe){if(typeof oe!="string"){if("generic"in oe)yield oe;else if("record"in oe)for(const fe of Object.values(oe.record))yield*ge(fe);else for(const fe of["array","literal","measure","dimension","measure","constant","cacluation"])if(fe in oe){yield*ge(oe[fe]);return}}}function ae(oe,fe,Ce,xe={}){let ke=!1;const He={};for(const Oe of Object.values(fe))for(const We of ge(Oe))He[We.generic]=["any"],ke=!0;ke&&xe.generic===void 0&&(xe.generic=He);const Xe={takes:fe,returns:Ce,impl:{function:oe.toUpperCase()},...xe};return{[oe]:Xe}}return Vr}var jg={},Zv;function $a(){return Zv||(Zv=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Dialect=e.dayIndex=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=i,e.qtz=a;const t=at();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");const r=["microsecond","millisecond","second","minute","hour","day","week","month","quarter","year"];e.dayIndex=r.indexOf("day");function i(c){return r.indexOf(c)>=e.dayIndex}function a(c){const d=c.queryTimezone;if(!(d===void 0||d===c.systemTimezone))return d}class o{constructor(){this.cantPartitionWindowFunctionsOnExpressions=!1,this.supportsPipelinesInViews=!0,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"}]}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 f=BigInt(d);for(const u of this.integerTypeMappings)if(f>=u.min&&f<=u.max)return{type:"number",numberType:u.numberType};return{type:"number",numberType:"bigint"}}static makeTimeLiteralNode(d,l,f,u,p){var h;const m=(h=d?.hasTimestamptz)!==null&&h!==void 0?h:!1;return p==="date"?{node:"dateLiteral",literal:l,typeDef:{type:"date",timeframe:u!==void 0&&(0,t.isDateUnit)(u)?u:void 0}}:f&&m?{node:"timestamptzLiteral",literal:l,typeDef:{type:"timestamptz",timeframe:u},timezone:f}:f?{node:"timestampLiteral",literal:l,typeDef:{type:"timestamp",timeframe:u},timezone:f}:{node:"timestampLiteral",literal:l,typeDef:{type:"timestamp",timeframe:u}}}sqlTurtleOrderByClause(d){const l=d.map(f=>` ${f.field} ${f.dir.toUpperCase()}`);return" "+this.sqlOrderBy(l,"turtle")}sqlFinalStage(d,l){throw new Error("Dialect has no final Stage but called Anyway")}sqlDateToString(d){return this.castToString(`DATE(${d})`)}sqlLiteralNumber(d){return d}ignoreInProject(d){return!1}needsCivilTimeComputation(d,l,f,u){const p=["day","week","month","quarter","year"],h=l!==void 0&&p.includes(l),m=f!==void 0&&p.includes(f),x=a(u);return{needed:t.TD.isAnyTimestamp(d)&&(h||m)&&x!==void 0,tz:x}}sqlTruncAndOffset(d,l,f,u){if(t.TD.isAnyTimestamp(d.typeDef)){const{needed:h,tz:m}=this.needsCivilTimeComputation(d.typeDef,f,u?.unit,l);if(h&&m){const x=this.sqlConvertToCivilTime(d.sql,m,d.typeDef);let v=x.sql;const C=x.typeDef;return f&&(v=this.sqlTruncate(v,f,C,!0,m)),u&&(v=this.sqlOffsetTime(v,u.op,u.magnitude,u.unit,C,!0,m)),this.sqlConvertFromCivilTime(v,m,d.typeDef)}}let p=d.sql;return f&&(p=this.sqlTruncate(p,f,d.typeDef,!1,a(l))),u&&(p=this.sqlOffsetTime(p,u.op,u.magnitude,u.unit,d.typeDef,!1,a(l))),p}exprToSQL(d,l){switch(l.node){case"now":return this.sqlNowExpr();case"timeDiff":return this.sqlMeasureTimeExpr(l);case"delta":{const f=l.kids.base;return f.node==="trunc"?this.sqlTruncAndOffset(f.e,d,f.units,{op:l.op,magnitude:l.kids.delta.sql,unit:l.units}):this.sqlTruncAndOffset(f,d,void 0,{op:l.op,magnitude:l.kids.delta.sql,unit:l.units})}case"trunc":return this.sqlTruncAndOffset(l.e,d,l.units);case"extract":return this.sqlTimeExtractExpr(d,l);case"cast":return this.sqlCast(d,l);case"regexpMatch":return this.sqlRegexpMatch(l);case"/":return this.divisionIsInteger?`${l.kids.left.sql}*1.0/${l.kids.right.sql}`:void 0;case"%":return this.hasModOperator?void 0:`MOD(${l.kids.left.sql},${l.kids.right.sql})`;case"dateLiteral":return this.sqlDateLiteral(d,l.literal);case"timestampLiteral":return this.sqlTimestampLiteral(d,l.literal,l.timezone);case"timestamptzLiteral":return this.sqlTimestamptzLiteral(d,l.literal,l.timezone);case"stringLiteral":return this.sqlLiteralString(l.literal);case"numberLiteral":return this.sqlLiteralNumber(l.literal);case"regexpLiteral":return this.sqlLiteralRegexp(l.literal);case"recordLiteral":return this.sqlLiteralRecord(l);case"arrayLiteral":return this.sqlLiteralArray(l)}}sqlSumDistinct(d,l,f){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(d,l,f){return"sqlAggDistinct called but not implemented"}sqlSampleTable(d,l){if(l!==void 0)throw new Error(`Sampling is not supported on dialect ${this.name}.`);return d}sqlOrderBy(d,l){return`ORDER BY ${d.join(",")}`}sqlTzStr(d){return`"${d.queryTimezone}"`}sqlMakeUnnestKey(d,l){return this.concat(d,"'x'",l)}sqlStringAggDistinct(d,l,f){const u="__STRING_AGG_KS__",p="__STRING_AGG_KE__";return`REGEXP_REPLACE(
|
|
2
2
|
STRING_AGG(DISTINCT ${`concat('${u}', ${d}, '${p}', ${l})`}${f.length>0?","+f:""}),
|
|
3
3
|
'${u}.*?${p}',
|
|
4
4
|
''
|