@malloydata/render 0.0.239-dev250227193901 → 0.0.240-dev250304195705
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module/index.mjs
CHANGED
|
@@ -54153,7 +54153,7 @@ mh.exploreQueryWalkerBuilder = pOe;
|
|
|
54153
54153
|
var Oe = {}, fb = {};
|
|
54154
54154
|
Object.defineProperty(fb, "__esModule", { value: !0 });
|
|
54155
54155
|
fb.MALLOY_VERSION = void 0;
|
|
54156
|
-
fb.MALLOY_VERSION = "0.0.
|
|
54156
|
+
fb.MALLOY_VERSION = "0.0.240";
|
|
54157
54157
|
Object.defineProperty(Oe, "__esModule", { value: !0 });
|
|
54158
54158
|
Oe.InMemoryModelCache = Oe.CacheManager = Oe.CSVWriter = Oe.JSONWriter = Oe.DataWriter = Oe.DataRecord = Oe.DataArray = Oe.Result = Oe.ExploreMaterializer = Oe.PreparedResultMaterializer = Oe.QueryMaterializer = Oe.ModelMaterializer = Oe.SingleConnectionRuntime = Oe.ConnectionRuntime = Oe.Runtime = Oe.ExploreField = Oe.JoinRelationship = Oe.QueryField = Oe.Query = Oe.StringField = Oe.UnsupportedField = Oe.JSONField = Oe.BooleanField = Oe.NumberField = Oe.TimestampField = Oe.DateField = Oe.TimestampTimeframe = Oe.DateTimeframe = Oe.AtomicField = Oe.AtomicFieldType = Oe.Explore = Oe.SourceRelationship = Oe.FixedConnectionMap = Oe.InMemoryURLReader = Oe.EmptyURLReader = Oe.PreparedResult = Oe.DocumentCompletion = Oe.DocumentSymbol = Oe.DocumentPosition = Oe.DocumentRange = Oe.DocumentTablePath = Oe.Parse = Oe.PreparedQuery = Oe.Model = Oe.MalloyError = Oe.Malloy = void 0;
|
|
54159
54159
|
const nq = mS, Hr = Oi, rq = p9, JR = Yh, mOe = fb, gOe = wg, Tn = hs, yOe = dl, iq = "internal://internal.malloy";
|
package/dist/module/index.umd.js
CHANGED
|
@@ -1271,7 +1271,7 @@ QUERY: ${(0,DG.inspect)(n,{breakLength:72,depth:1/0})}`)}return OG.ErrorFactory.
|
|
|
1271
1271
|
| ${l}`,u>0&&(i=i+`
|
|
1272
1272
|
| ${" ".repeat(u)}^`)}else i=`line ${o+1}: char ${u}: ${r.message}`}n!==s&&(i=`FILE: ${s}
|
|
1273
1273
|
`+i,n=s),e!==""?e=`${e}
|
|
1274
|
-
${i}`:e=i}return e}childRequest(e){var n;const r=decodeURI(new URL(e,this.sourceURL).toString()),i=(n=this.childTranslators.get(r))===null||n===void 0?void 0:n.translate();if(i!=null&&i.compileSQL)return{compileSQL:i.compileSQL}}getChildExports(e){const n={},r=decodeURI(new URL(e,this.sourceURL).toString()),i=this.childTranslators.get(r);if(i&&i.translate().modelDef)for(const o of i.modelDef.exports){const u=i.modelDef.contents[o];((0,UDe.isSourceDef)(u)||u.type==="query")&&(n[o]=u)}return n}translate(e){if(this.finalAnswer)return this.finalAnswer;const n=this.translateStep.step(this,e);return n.final&&(this.finalAnswer=n),n}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let n=0;n<this.imports.length;n++){const r=this.imports[n];if((0,YDe.locationContainsPosition)(r.location,e))return r}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return this.rangeFromTokens(e.start,e.stop||e.start)}rangeFromTokens(e,n){const r={line:e.line-1,character:e.charPositionInLine};if(this.parseStep.sourceInfo&&n.stopIndex!==-1){const i=this.parseStep.sourceInfo.lines.length-1;for(let s=e.line-1;s<=i;s++){const o=this.parseStep.sourceInfo.at[s];if(n.stopIndex>=o.begin&&n.stopIndex<o.end)return{start:r,end:{line:s,character:n.stopIndex-o.begin+1}}}return{start:r,end:{line:i,character:this.parseStep.sourceInfo.lines[i].length}}}return{start:r,end:r}}rangeFromToken(e){return this.rangeFromTokens(e,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const n=this.compilerFlags.tag("experimental");return n!==void 0&&(n.bare()||n.has("dialect",e))}}l0.MalloyTranslation=gF;class xV extends gF{constructor(e,n){super(e),this.root=n}}l0.MalloyChildTranslator=xV;class xOe extends gF{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new mF.Zone,this.importZone=new mF.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new mF.Zone,this.root=this,this.logger=new fV.BaseMessageLogger(i),r&&this.update(r)}update(e){var n,r,i;this.schemaZone.updateFrom(e.tables,(n=e.errors)===null||n===void 0?void 0:n.tables),this.importZone.updateFrom(e.urls,(r=e.errors)===null||r===void 0?void 0:r.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(i=e.errors)===null||i===void 0?void 0:i.compileSQL);for(const s in e.translations)this.pretranslatedModels.set(s,e.translations[s])}logError(e,n,r){return this.logger.log((0,fV.makeLogMessage)(e,n,{severity:"error",...r})),e}}l0.MalloyTranslator=xOe;function dV(t){return[...Object.keys(t),...Object.keys(t).map(e=>dV(t[e])).flat()]}var Dh={};Object.defineProperty(Dh,"__esModule",{value:!0}),Dh.exploreQueryWalkerBuilder=Dh.ExploreQueryWalker=void 0;const dOe=Yl;class hV{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(n=>n.range[0]===void 0||n.range[1]===void 0?!1:n.range[0]<=e&&n.range[1]>=e)}filterAtOffset(e){const n=this.exploreQueryAtOffset(e);if(n)return n.filterRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}hasFilterListAtOffset(e){const n=this.exploreQueryAtOffset(e);return n?!!n.filterLists.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}Dh.ExploreQueryWalker=hV;function hOe(t,e){const n=new hV(t),r=n;return dOe.ParseTreeWalker.DEFAULT.walk(r,e),n}Dh.exploreQueryWalkerBuilder=hOe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=l0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=Dh;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(KA);var Oe={},MC={};Object.defineProperty(MC,"__esModule",{value:!0}),MC.MALLOY_VERSION=void 0,MC.MALLOY_VERSION="0.0.
|
|
1274
|
+
${i}`:e=i}return e}childRequest(e){var n;const r=decodeURI(new URL(e,this.sourceURL).toString()),i=(n=this.childTranslators.get(r))===null||n===void 0?void 0:n.translate();if(i!=null&&i.compileSQL)return{compileSQL:i.compileSQL}}getChildExports(e){const n={},r=decodeURI(new URL(e,this.sourceURL).toString()),i=this.childTranslators.get(r);if(i&&i.translate().modelDef)for(const o of i.modelDef.exports){const u=i.modelDef.contents[o];((0,UDe.isSourceDef)(u)||u.type==="query")&&(n[o]=u)}return n}translate(e){if(this.finalAnswer)return this.finalAnswer;const n=this.translateStep.step(this,e);return n.final&&(this.finalAnswer=n),n}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let n=0;n<this.imports.length;n++){const r=this.imports[n];if((0,YDe.locationContainsPosition)(r.location,e))return r}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return this.rangeFromTokens(e.start,e.stop||e.start)}rangeFromTokens(e,n){const r={line:e.line-1,character:e.charPositionInLine};if(this.parseStep.sourceInfo&&n.stopIndex!==-1){const i=this.parseStep.sourceInfo.lines.length-1;for(let s=e.line-1;s<=i;s++){const o=this.parseStep.sourceInfo.at[s];if(n.stopIndex>=o.begin&&n.stopIndex<o.end)return{start:r,end:{line:s,character:n.stopIndex-o.begin+1}}}return{start:r,end:{line:i,character:this.parseStep.sourceInfo.lines[i].length}}}return{start:r,end:r}}rangeFromToken(e){return this.rangeFromTokens(e,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const n=this.compilerFlags.tag("experimental");return n!==void 0&&(n.bare()||n.has("dialect",e))}}l0.MalloyTranslation=gF;class xV extends gF{constructor(e,n){super(e),this.root=n}}l0.MalloyChildTranslator=xV;class xOe extends gF{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new mF.Zone,this.importZone=new mF.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new mF.Zone,this.root=this,this.logger=new fV.BaseMessageLogger(i),r&&this.update(r)}update(e){var n,r,i;this.schemaZone.updateFrom(e.tables,(n=e.errors)===null||n===void 0?void 0:n.tables),this.importZone.updateFrom(e.urls,(r=e.errors)===null||r===void 0?void 0:r.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(i=e.errors)===null||i===void 0?void 0:i.compileSQL);for(const s in e.translations)this.pretranslatedModels.set(s,e.translations[s])}logError(e,n,r){return this.logger.log((0,fV.makeLogMessage)(e,n,{severity:"error",...r})),e}}l0.MalloyTranslator=xOe;function dV(t){return[...Object.keys(t),...Object.keys(t).map(e=>dV(t[e])).flat()]}var Dh={};Object.defineProperty(Dh,"__esModule",{value:!0}),Dh.exploreQueryWalkerBuilder=Dh.ExploreQueryWalker=void 0;const dOe=Yl;class hV{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(n=>n.range[0]===void 0||n.range[1]===void 0?!1:n.range[0]<=e&&n.range[1]>=e)}filterAtOffset(e){const n=this.exploreQueryAtOffset(e);if(n)return n.filterRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}hasFilterListAtOffset(e){const n=this.exploreQueryAtOffset(e);return n?!!n.filterLists.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}Dh.ExploreQueryWalker=hV;function hOe(t,e){const n=new hV(t),r=n;return dOe.ParseTreeWalker.DEFAULT.walk(r,e),n}Dh.exploreQueryWalkerBuilder=hOe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=l0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=Dh;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(KA);var Oe={},MC={};Object.defineProperty(MC,"__esModule",{value:!0}),MC.MALLOY_VERSION=void 0,MC.MALLOY_VERSION="0.0.240",Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.InMemoryModelCache=Oe.CacheManager=Oe.CSVWriter=Oe.JSONWriter=Oe.DataWriter=Oe.DataRecord=Oe.DataArray=Oe.Result=Oe.ExploreMaterializer=Oe.PreparedResultMaterializer=Oe.QueryMaterializer=Oe.ModelMaterializer=Oe.SingleConnectionRuntime=Oe.ConnectionRuntime=Oe.Runtime=Oe.ExploreField=Oe.JoinRelationship=Oe.QueryField=Oe.Query=Oe.StringField=Oe.UnsupportedField=Oe.JSONField=Oe.BooleanField=Oe.NumberField=Oe.TimestampField=Oe.DateField=Oe.TimestampTimeframe=Oe.DateTimeframe=Oe.AtomicField=Oe.AtomicFieldType=Oe.Explore=Oe.SourceRelationship=Oe.FixedConnectionMap=Oe.InMemoryURLReader=Oe.EmptyURLReader=Oe.PreparedResult=Oe.DocumentCompletion=Oe.DocumentSymbol=Oe.DocumentPosition=Oe.DocumentRange=Oe.DocumentTablePath=Oe.Parse=Oe.PreparedQuery=Oe.Model=Oe.MalloyError=Oe.Malloy=void 0;const pV=KA,qr=ni,mV=p7,yF=ed,pOe=MC,mOe=ap,Rn=os,gOe=Qa,gV="internal://internal.malloy";let Ka=class v6{static get version(){return pOe.MALLOY_VERSION}static _parse(e,n,r,i,s){n===void 0&&(n=new URL(gV));let o=n;i!=null&&i.importBaseURL&&(o=i==null?void 0:i.importBaseURL);const u=new pV.MalloyTranslator(n.toString(),o.toString(),{urls:{[n.toString()]:e}},r);return i!=null&&i.testEnvironment&&(u.allDialectsEnabled=!0),new EV(u,s)}static parse({url:e,urlReader:n,source:r,eventStream:i,options:s}){if(r!==void 0)return v6._parse(r,e,i,s);if(n===void 0)throw new Error("Internal Error: urlReader is required.");if(e===void 0)throw new Error("Internal Error: url is required if source not present.");return GC(n,e).then(({contents:o,invalidationKey:u})=>v6._parse(o,e,i,s,u))}static async compile({url:e,source:n,parse:r,urlReader:i,connections:s,model:o,refreshSchemaCache:u,noThrowOnError:a,eventStream:l,importBaseURL:c,cacheManager:f}){var d,h,p,g,m;let y;if(u&&(y=typeof u=="number"?u:Date.now()),e===void 0&&n===void 0&&r===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(r!==void 0?e=new URL(r._translator.sourceURL):e=new URL(gV));const E={};if(n===void 0&&f!==void 0){const v=await f.getCachedModelDef(i,e.toString());if(v)return new Oh(v.modelDef,[],[e.toString(),...QC(v.modelDef.dependencies)])}c??(c=e);let A;const _=e.toString();if(r!==void 0){A=r._translator;const v=(d=r._invalidationKey)!==null&&d!==void 0?d:await NF(i,e);E[_]=v}else{if(n===void 0){const{contents:v,invalidationKey:C}=await GC(i,e);E[_]=C,n=v}else{const v=await NF(i,e);E[_]=v}A=new pV.MalloyTranslator(_,c.toString(),{urls:{[_]:n}},l)}for(;;){const v=A.translate(o==null?void 0:o._modelDef);if(v.final)if(v.modelDef){await(f==null?void 0:f.setCachedModelDef(e.toString(),{modelDef:v.modelDef,invalidationKeys:E}));for(const C of A.newlyTranslatedDependencies())await(f==null?void 0:f.setCachedModelDef(C.url,{modelDef:C.modelDef,invalidationKeys:E}));return new Oh(v.modelDef,v.problems||[],[...(h=o==null?void 0:o.fromSources)!==null&&h!==void 0?h:[],...(p=v.fromSources)!==null&&p!==void 0?p:[]],C=>A.referenceAt(C),C=>A.importAt(C))}else if(a){const C={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},S=(o==null?void 0:o._modelDef)||C;return new Oh(S,v.problems||[],[...(g=o==null?void 0:o.fromSources)!==null&&g!==void 0?g:[],...(m=v.fromSources)!==null&&m!==void 0?m:[]],T=>A.referenceAt(T),T=>A.importAt(T))}else{const C=v.problems||[],S=A.prettyErrors();throw new yV(`Error(s) compiling model:
|
|
1275
1275
|
${S}`,C)}else{if(v.urls)for(const S of v.urls)try{if(WC(S))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(f!==void 0){const I=await f.getCachedModelDef(i,S);if(I){for(const U in I.invalidationKeys)E[U]=I.invalidationKeys[U];A.update({translations:{[S]:I.modelDef}});continue}}const{contents:T,invalidationKey:R}=await GC(i,new URL(S)),L={[S]:T};E[S]=R,A.update({urls:L})}catch(T){A.update({errors:{urls:{[S]:T.message}}})}const{modelAnnotation:C}=A.modelAnnotation(o==null?void 0:o._modelDef);if(v.tables){const S=new Map;for(const T in v.tables){const{connectionName:R,tablePath:L}=v.tables[T],I=S.get(R);I===void 0?S.set(R,{[T]:L}):I[T]=L}for(const[T,R]of S)try{const L=await s.lookupConnection(T),{schemas:I,errors:U}=await v6.safelyFetchTableSchema(L,R,{refreshTimestamp:y,modelAnnotation:C});A.update({tables:I,errors:{tables:U}})}catch(L){const I={},U={};for(const z in R)U[z]=L.toString();A.update({tables:I,errors:{tables:U}})}}if(v.compileSQL){const S=v.compileSQL,T=S.connection,R=(0,gOe.sqlKey)(S.connection,S.selectStr);try{const I=await(await s.lookupConnection(T)).fetchSchemaForSQLStruct(S,{refreshTimestamp:y,modelAnnotation:C});I.error&&A.update({errors:{compileSQL:{[R]:I.error}}}),I.structDef&&A.update({compileSQL:{[R]:I.structDef}})}catch(L){const I={};I[R]=L.toString(),A.update({errors:{compileSQL:I}})}}}}}static async safelyFetchTableSchema(e,n,r){const i=await e.fetchSchemaForTables(n,r);for(const s of Object.keys(n))if(i.schemas[s]===void 0&&i.errors[s]===void 0)throw new Error(`Schema fetch error for ${e.name}, no response for ${s} from ${e.dialectName}`);return i}static async run({connections:e,preparedResult:n,sqlStruct:r,connection:i,options:s}){if(!i){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const o=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName);i=await e.lookupConnection(o)}if(r){const o=await i.runSQL(r.selectStr);return new og({structs:[r],sql:r.selectStr,result:o.rows,totalRows:o.totalRows,runStats:o.runStats,lastStageName:r.name,malloy:"",connectionName:r.connection,sourceExplore:"",sourceFilters:[],profilingUrl:o.profilingUrl},{name:"empty_model",exports:[],contents:{},queryList:[],dependencies:{}})}else if(n){const o=await i.runSQL(n.sql,s);return new og({...n._rawQuery,result:o.rows,totalRows:o.totalRows,runStats:o.runStats,profilingUrl:o.profilingUrl},n._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:e,preparedResult:n,sqlStruct:r,connection:i,options:s}){if(r===void 0&&n===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const o=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName);if(i===void 0){if(e===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");i=await e.lookupConnection(o)}if(!i.canStream())throw new Error(`Connection '${o}' cannot stream results.`);let u,a;if(r)a=new Es(r),u=r.selectStr;else if(n!==void 0)a=n.resultExplore,u=n.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let l=0;for await(const c of i.runSQLStream(u,s))yield new Mf(c,l,a,void 0,void 0),l+=1}static async estimateQueryCost({connections:e,preparedResult:n,sqlStruct:r}){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const i=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName),s=await e.lookupConnection(i);if(r)return await s.estimateQueryCost(r.selectStr);if(n)return await s.estimateQueryCost(n.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}};Oe.Malloy=Ka;class yV extends Error{constructor(e,n=[]){super(e),this.problems=n}}Oe.MalloyError=yV;let Oh=class{constructor(e,n,r,i=()=>{},s=()=>{}){this.modelDef=e,this.problems=n,this.fromSources=r,this._referenceAt=i,this._importAt=s}tagParse(e){return(0,Rn.annotationToTag)(this.modelDef.annotation,e)}getTaglines(e){return(0,Rn.annotationToTaglines)(this.modelDef.annotation,e)}getReference(e){return this._referenceAt(e)}getImport(e){return this._importAt(e)}getPreparedQueryByName(e){const n=this.modelDef.contents[e];if((n==null?void 0:n.type)==="query")return new Fh(n,this.modelDef,this.problems,e);throw new Error("Given query name does not refer to a named query.")}getPreparedQueryByIndex(e){if(e<0)throw new Error(`Invalid index ${e}.`);if(e>=this.modelDef.queryList.length)throw new Error(`Query index ${e} is out of bounds.`);return new Fh(this.modelDef.queryList[e],this.modelDef,this.problems)}get preparedQuery(){return this.getPreparedQuery()}getPreparedQuery(){if(this.modelDef.queryList.length===0)throw new Error("Model has no queries.");return new Fh(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const n=this.modelDef.contents[e];if((0,qr.isSourceDef)(n))return new Es(n);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(qr.isSourceDef).map(e=>new Es(e))}get namedQueries(){const e=n=>n.type==="query";return Object.values(this.modelDef.contents).filter(e)}get exportedExplores(){return this.explores.filter(e=>this.modelDef.exports.includes(e.name))}get _modelDef(){return this.modelDef}};Oe.Model=Oh;class Fh{constructor(e,n,r,i){this.problems=r,this.name=i,this._query=e,this._modelDef=n}tagParse(e){const n=(0,Rn.annotationToTag)(this._modelDef.annotation).tag;return e=(0,Rn.addModelScope)(e,n),(0,Rn.annotationToTag)(this._query.annotation,e)}getTaglines(e){return(0,Rn.annotationToTaglines)(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const r=new qr.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new ig({...r,queryName:this.name||r.queryName},this._modelDef)}get dialect(){const e=this._query.structRef,n=typeof e=="string"?this._modelDef.contents[e]:e;if(!(0,qr.isSourceDef)(n))throw new Error("Invalid source for query");return n.dialect}getFlattenedQuery(e){return this}}Oe.PreparedQuery=Fh;class EV{constructor(e,n){this.translator=e,this.invalidationKey=n}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new PC(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(r=>new AV(r))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(n=>new _V(n))}helpContext(e){return this.translator.helpContext(e).helpContext}}Oe.Parse=EV;class AV{constructor(e){this._range=Nh.fromJSON(e.range),this._connectionId=e.connectionId,this._tablePath=e.tablePath}get range(){return this._range}get connectionId(){return this._connectionId}get tablePath(){return this._tablePath}}Oe.DocumentTablePath=AV;class Nh{constructor(e,n){this._start=e,this._end=n}get start(){return this._start}get end(){return this._end}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}static fromJSON(e){return new Nh(new EF(e.start.line,e.start.character),new EF(e.end.line,e.end.character))}}Oe.DocumentRange=Nh;class EF{constructor(e,n){this._line=e,this._character=n}get line(){return this._line}get character(){return this._character}toJSON(){return{line:this.line,character:this.character}}}Oe.DocumentPosition=EF;class PC{constructor(e){this._range=Nh.fromJSON(e.range),this._lensRange=e.lensRange?Nh.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(n=>new PC(n))}get range(){return this._range}get lensRange(){var e;return(e=this._lensRange)!==null&&e!==void 0?e:this._range}get type(){return this._type}get name(){return this._name}get children(){return this._children}}Oe.DocumentSymbol=PC;class _V{constructor(e){this.type=e.type,this.text=e.text}}Oe.DocumentCompletion=_V;class ig{constructor(e,n){this.modelDef=n,this.inner=e}static fromJson({query:e,modelDef:n}){if(!e||!n)throw new Error("Missing required properties in JSON data");return new ig(e,n)}tagParse(e){const n=(0,Rn.annotationToTag)(this.modelDef.annotation).tag;return e=(0,Rn.addModelScope)(e,n),(0,Rn.annotationToTag)(this.inner.annotation,e)}getTaglines(e){return(0,Rn.annotationToTaglines)(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return(0,Rn.annotationToTag)(this.modelDef.annotation).tag}get connectionName(){return this.inner.connectionName}get _rawQuery(){return this.inner}get _modelDef(){return this.modelDef}get sql(){return this.inner.sql}get dependenciesToMaterialize(){return this.inner.dependenciesToMaterialize}get materialization(){return this.inner.materialization}get resultExplore(){if(this.inner.structs.length===0)throw new Error("Malformed query result.");const e=this.inner.structs[this.inner.structs.length-1],n={...e,annotation:this.inner.annotation,name:this.inner.queryName||e.name};try{return new Es(n,this.sourceExplore)}catch{return new Es(n)}}get sourceExplore(){const e=this.inner.sourceExplore,n=this.modelDef.contents[e];if(n===void 0)throw new Error("Malformed query result.");if((0,qr.isSourceDef)(n))return new Es(n);throw new Error(`'${e} is not an explore`)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}Oe.PreparedResult=ig;class vV{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}Oe.EmptyURLReader=vV;class yOe{constructor(e){this.files=e}async readURL(e){const n=this.files.get(e.toString());if(n!==void 0)return Promise.resolve({contents:n,invalidationKey:this.invalidationKey(e,n)});throw new Error(`File not found '${e}'`)}async getInvalidationKey(e){const n=this.files.get(e.toString());if(n!==void 0)return Promise.resolve(this.invalidationKey(e,n));throw new Error(`File not found '${e}'`)}invalidationKey(e,n){return WC(e.toString())?null:kV(n)}}Oe.InMemoryURLReader=yOe;class UC{constructor(e,n){this.connections=e,this.defaultConnectionName=n}async getConnection(e){if(e===void 0)if(this.defaultConnectionName!==void 0)e=this.defaultConnectionName;else throw new Error("No default connection.");const n=this.connections.get(e);if(n!==void 0)return Promise.resolve(n);throw new Error(`No connection found with name ${e}.`)}listConnections(){return Array.from(this.connections.values())}async lookupConnection(e){return this.getConnection(e)}static fromArray(e){return new UC(new Map(e.map(n=>[n.name,n])))}}Oe.FixedConnectionMap=UC;var CV;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(CV||(Oe.SourceRelationship=CV={}));class AF{constructor(e,n,r){this._name=e,this._parent=n,this._source=r}get source(){return this.source}get name(){return this._name}get sourceClasses(){const e=[];return this.source&&e.push(this.source.name),e.push(this.name),e}get fieldPath(){const e=[this.name];let n=this._parent;for(;n;)e.unshift(n.name),n=n._parent;return e}hasParentExplore(){return this._parent!==void 0}isExplore(){return this instanceof Es}isQuery(){return this instanceof RF}}class Es extends AF{constructor(e,n,r){super(e.as||e.name,n,r),this._structDef=e,this._parentExplore=n,this.sourceExplore=r}get source(){return this.sourceExplore}isIntrinsic(){return(0,qr.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return(0,Rn.annotationToTag)(this._structDef.annotation,e)}getTaglines(e){return(0,Rn.annotationToTaglines)(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=(0,Rn.annotationToTag)(this._structDef.modelAnnotation).tag),this.parsedModelTag}get name(){return this.structDef.as||this.structDef.name}getQueryByName(e){const n=this.sourceStructDef;if(!n)throw new Error(`Cannot get query by name from a struct of type ${this.structDef.type}`);const r={type:"query",structRef:n,pipeline:[{type:"reduce",queryFields:[{type:"fieldref",path:[e]}]}]};return new Fh(r,this.modelDef,[],e)}get modelDef(){if(!(0,qr.isSourceDef)(this.structDef))throw new Error(`Cannot create pseudo model for struct type ${this.structDef.type}`);return{name:"generated_model",exports:[],contents:{[this.structDef.name]:this.structDef},queryList:[],dependencies:{}}}getSingleExploreModel(){return new Oh(this.modelDef,[],[])}get fieldMap(){var e;if(this._fieldMap===void 0){const n=((e=this.source)===null||e===void 0?void 0:e.fieldMap)||new Map;this._fieldMap=new Map(this.structDef.fields.map(r=>{const i=r.as||r.name,s=n.get(r.name);if((0,qr.isJoined)(r))return[i,new DF(r,this,s)];if(r.type==="turtle")return[i,new RF(r,this,s)];if(r.type==="string")return[i,new TF(r,this,s)];if(r.type==="number")return[i,new jC(r,this,s)];if(r.type==="date")return r.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(r.timeframe)?[i,new jC({...r,type:"number"},this,s)]:[i,new _F(r,this,s)];if(r.type==="timestamp")return[i,new vF(r,this,s)];if(r.type==="boolean")return[i,new CF(r,this,s)];if(r.type==="json")return[i,new SF(r,this,s)];if(r.type==="sql native")return[i,new bF(r,this,s)]}))}return this._fieldMap}get allFields(){return[...this.fieldMap.values()]}get allFieldsWithOrder(){var e,n,r;if(!this._allFieldsWithOrder){const i=[...((r=(n=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||n===void 0?void 0:n.orderBy)===null||r===void 0?void 0:r.map(o=>{if(typeof o.field=="string")return{field:this.fieldMap.get(o.field),dir:o.dir};throw new Error("Does not support mapping order by from number.")}))||[]],s=new Set(i.map(o=>o.field.name));this._allFieldsWithOrder=[...i,...this.allFields.filter(o=>!s.has(o.name)).map(o=>({field:o,dir:"asc"}))]}return this._allFieldsWithOrder}get intrinsicFields(){return[...this.fieldMap.values()].filter(e=>e.isIntrinsic())}get dimensions(){return[...this.allFieldsWithOrder].filter(e=>e.field.isAtomicField()&&e.field.sourceWasDimension())}getFieldByName(e){const n=this.fieldMap.get(e);if(n===void 0)throw new Error(`No such field ${e}.`);return n}getFieldByNameIfExists(e){return this.fieldMap.get(e)}get primaryKey(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.primaryKey}get parentExplore(){return this._parentExplore}hasParentExplore(){return this instanceof DF}get filters(){var e;return(0,qr.isSourceDef)(this.structDef)?((e=this.structDef.resultMetadata)===null||e===void 0?void 0:e.filterList)||[]:[]}get limit(){var e,n;return(n=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||n===void 0?void 0:n.limit}get structDef(){return this._structDef}get queryTimezone(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.queryTimezone}get sourceStructDef(){if((0,qr.isSourceDef)(this.structDef))return this.structDef}toJSON(){var e,n;return{_structDef:this._structDef,sourceExplore:(e=this.sourceExplore)===null||e===void 0?void 0:e.toJSON(),_parentExplore:(n=this._parentExplore)===null||n===void 0?void 0:n.toJSON()}}static fromJSON(e){const n=e._parentExplore!==void 0?Es.fromJSON(e._parentExplore):void 0,r=e.sourceExplore!==void 0?Es.fromJSON(e.sourceExplore):void 0;return new Es(e._structDef,n,r)}get location(){return this.structDef.location}}Oe.Explore=Es;var wu;(function(t){t.String="string",t.Number="number",t.Boolean="boolean",t.Date="date",t.Timestamp="timestamp",t.Json="json",t.NativeUnsupported="sql native",t.Error="error"})(wu||(Oe.AtomicFieldType=wu={}));class w0 extends AF{constructor(e,n,r){super(e.as||e.name,n,r),this.fieldTypeDef=e,this.parent=n}get type(){switch(this.fieldTypeDef.type){case"string":return wu.String;case"boolean":return wu.Boolean;case"date":return wu.Date;case"timestamp":return wu.Timestamp;case"number":return wu.Number;case"json":return wu.Json;case"sql native":return wu.NativeUnsupported;case"error":return wu.Error;case"record":case"array":throw new Error(`MTOY TODO IMPLEMENT Atomic ${this.fieldTypeDef.type}`);default:{const e=this.fieldTypeDef;throw new Error(`Can't make an atomic field from ${e}`)}}}tagParse(e){return e=(0,Rn.addModelScope)(e,this.parent.modelTag),(0,Rn.annotationToTag)(this.fieldTypeDef.annotation,e)}getTaglines(e){return(0,Rn.annotationToTaglines)(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,qr.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,qr.expressionIsCalculation)(this.fieldTypeDef.expressionType)}get sourceField(){throw new Error}get sourceClasses(){const e=this.fieldTypeDef.name||this.fieldTypeDef.as;return e?[e]:[]}get referenceId(){var e;return(e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.referenceId}sourceWasMeasure(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"}sourceWasMeasureLike(){var e,n;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((n=this.fieldTypeDef.resultMetadata)===null||n===void 0?void 0:n.fieldKind)==="struct"}sourceWasDimension(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="dimension"}hasParentExplore(){return!0}isString(){return this instanceof TF}isNumber(){return this instanceof jC}isDate(){return this instanceof _F}isBoolean(){return this instanceof CF}isJSON(){return this instanceof SF}isTimestamp(){return this instanceof vF}isUnsupported(){return this instanceof bF}get parentExplore(){return this.parent}get expression(){const e=".",n=this.fieldTypeDef.resultMetadata;return(n==null?void 0:n.sourceExpression)||(n!=null&&n.sourceField.includes(e)?n==null?void 0:n.sourceField:this.name)}get location(){return this.fieldTypeDef.location}}Oe.AtomicField=w0;var kf;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(kf||(Oe.DateTimeframe=kf={}));var Lu;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year",t.Second="second",t.Hour="hour",t.Minute="minute"})(Lu||(Oe.TimestampTimeframe=Lu={}));class _F extends w0{constructor(e,n,r){super(e,n,r),this.fieldDateDef=e}get timeframe(){if(this.fieldDateDef.timeframe!==void 0)switch(this.fieldDateDef.timeframe){case"day":return kf.Day;case"week":return kf.Week;case"month":return kf.Month;case"quarter":return kf.Quarter;case"year":return kf.Year}}}Oe.DateField=_F;class vF extends w0{constructor(e,n,r){super(e,n,r),this.fieldTimestampDef=e}get timeframe(){if(this.fieldTimestampDef.timeframe!==void 0)switch(this.fieldTimestampDef.timeframe){case"day":return Lu.Day;case"week":return Lu.Week;case"month":return Lu.Month;case"quarter":return Lu.Quarter;case"year":return Lu.Year;case"second":return Lu.Second;case"hour":return Lu.Hour;case"minute":return Lu.Minute}}}Oe.TimestampField=vF;class jC extends w0{constructor(e,n,r){super(e,n,r),this.fieldNumberDef=e}}Oe.NumberField=jC;class CF extends w0{constructor(e,n,r){super(e,n,r),this.fieldBooleanDef=e}}Oe.BooleanField=CF;class SF extends w0{constructor(e,n,r){super(e,n,r),this.fieldJSONDef=e}}Oe.JSONField=SF;class bF extends w0{constructor(e,n,r){super(e,n,r),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}Oe.UnsupportedField=bF;class TF extends w0{constructor(e,n,r){super(e,n,r),this.fieldStringDef=e}}Oe.StringField=TF;class SV extends AF{constructor(e,n,r){super(e.as||e.name,n,r),this.turtleDef=e}get source(){return this.sourceQuery}isIntrinsic(){return!1}get location(){return this.turtleDef.location}}Oe.Query=SV;class RF extends SV{constructor(e,n,r){super(e,n,r),this.parent=n}tagParse(e){return e=(0,Rn.addModelScope)(e,this.parent.modelTag),(0,Rn.annotationToTag)(this.turtleDef.annotation,e)}getTaglines(e){return(0,Rn.annotationToTaglines)(this.turtleDef.annotation,e)}isQueryField(){return!0}isExploreField(){return!1}isAtomicField(){return!1}get sourceClasses(){const e=this.turtleDef.name||this.turtleDef.as;return e?[e]:[]}hasParentExplore(){return!0}get parentExplore(){return this.parent}get expression(){return this.name}}Oe.QueryField=RF;var wh;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(wh||(Oe.JoinRelationship=wh={}));class DF extends Es{constructor(e,n,r){super(e,n,r),this._parentExplore=n}get joinRelationship(){if((0,qr.isJoined)(this.structDef))switch(this.structDef.join){case"one":return wh.OneToOne;case"many":case"cross":return wh.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===wh.OneToOne}get isArray(){return this.joinRelationship!==wh.OneToOne}tagParse(e){return e=(0,Rn.addModelScope)(e,this._parentExplore.modelTag),(0,Rn.annotationToTag)(this._structDef.annotation,e)}isQueryField(){return!1}isExploreField(){return!0}isAtomicField(){return!1}get parentExplore(){return this._parentExplore}get sourceClasses(){const e=this.structDef.name||this.structDef.as;return e?[e]:[]}}Oe.ExploreField=DF;class OF{constructor({urlReader:e,connections:n,connection:r,eventStream:i,cacheManager:s}){if(this.isTestRuntime=!1,n===void 0){if(r===void 0)throw new Error("A LookupConnection<Connection> or Connection is required.");n={lookupConnection:()=>Promise.resolve(r)}}e===void 0&&(e=new vV),this._urlReader=e,this._connections=n,this._eventStream=i,this._cacheManager=s}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}loadModel(e,n){const{refreshSchemaCache:r,noThrowOnError:i}=n||{};this.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0});const s=e instanceof URL?{url:e}:{source:e};return new sg(this,async()=>Ka.compile({...s,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:r,noThrowOnError:i,eventStream:this.eventStream,replaceMaterializedReferences:n==null?void 0:n.replaceMaterializedReferences,materializedTablePrefix:n==null?void 0:n.materializedTablePrefix,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,cacheManager:this.cacheManager}),n)}_loadModelFromModelDef(e,n){return new sg(this,async()=>new Oh(e,[],[]),n)}loadQuery(e,n){return this.loadModel(e,n).loadFinalQuery()}loadQueryByIndex(e,n,r){return this.loadModel(e,r).loadQueryByIndex(n,r)}loadQueryByName(e,n,r){return this.loadModel(e,r).loadQueryByName(n,r)}getModel(e,n){return this.loadModel(e,n).getModel()}getQuery(e,n){return this.loadQuery(e,n).getPreparedQuery()}getQueryByIndex(e,n,r){return this.loadQueryByIndex(e,n,r).getPreparedQuery()}getQueryByName(e,n,r){return this.loadQueryByName(e,n,r).getPreparedQuery()}}Oe.Runtime=OF;class EOe extends OF{constructor({urlReader:e,connections:n}){super({connections:UC.fromArray(n),urlReader:e}),this.rawConnections=n}}Oe.ConnectionRuntime=EOe;class AOe extends OF{constructor({urlReader:e,connection:n,eventStream:r,cacheManager:i}){super({urlReader:e,eventStream:r,cacheManager:i,connection:n}),this.connection=n}get supportsNesting(){return(0,yF.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,yF.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,yF.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}Oe.SingleConnectionRuntime=AOe;class qC{constructor(e,n){this.runtime=e,this._materialize=n}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(e,n){return new bV(this.runtime,e,n)}makeExploreMaterializer(e,n){return new RV(this.runtime,e,n)}makePreparedResultMaterializer(e){return new TV(this.runtime,e)}}class sg extends qC{constructor(e,n,r){super(e,n),this.runtime=e,this.compileQueryOptions=r}loadFinalQuery(e){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...e})}loadQueryByIndex(e,n){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(e),{...this.compileQueryOptions,...n})}loadQueryByName(e,n){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(e),{...this.compileQueryOptions,...n})}loadQuery(e,n){const{refreshSchemaCache:r,noThrowOnError:i}=n||{};return this.makeQueryMaterializer(async()=>{const s=this.runtime.urlReader,o=this.runtime.connections;this.runtime.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0});const u=e instanceof URL?{url:e}:{source:e},a=await this.getModel();return(await Ka.compile({...u,urlReader:s,connections:o,model:a,refreshSchemaCache:r,noThrowOnError:i,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,...this.compileQueryOptions})).preparedQuery})}extendModel(e,n){return this.runtime.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0}),new sg(this.runtime,async()=>{const r=this.runtime.urlReader,i=this.runtime.connections,s=e instanceof URL?{url:e}:{source:e},o=await this.getModel();return await Ka.compile({...s,urlReader:r,connections:i,model:o,refreshSchemaCache:n==null?void 0:n.refreshSchemaCache,noThrowOnError:n==null?void 0:n.noThrowOnError,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,...this.compileQueryOptions})},n)}async search(e,n,r=1e3,i=void 0,s){const o=await this.materialize(),u=new qr.QueryModel(o._modelDef,s),a=o.getExploreByName(e).structDef;if(!(0,qr.isSourceDef)(a))throw new Error("Source to be searched was unexpectedly, not a source");const l=a.connection,c=await this.runtime.connections.lookupConnection(l);return await u.searchIndex(c,e,n,r,i)}async searchValueMap(e,n=10,r){const s=(await this.materialize()).getExploreByName(e);if(!(0,qr.isSourceDef)(s.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let o="{index: *}";s.getFieldByNameIfExists("search_index")&&(o="search_index");const u=`
|
|
1276
1276
|
run: ${e}
|
|
1277
1277
|
-> ${o}
|
|
@@ -55292,7 +55292,7 @@ Jh.exploreQueryWalkerBuilder = dFe;
|
|
|
55292
55292
|
var we = {}, G4 = {};
|
|
55293
55293
|
Object.defineProperty(G4, "__esModule", { value: !0 });
|
|
55294
55294
|
G4.MALLOY_VERSION = void 0;
|
|
55295
|
-
G4.MALLOY_VERSION = "0.0.
|
|
55295
|
+
G4.MALLOY_VERSION = "0.0.240";
|
|
55296
55296
|
Object.defineProperty(we, "__esModule", { value: !0 });
|
|
55297
55297
|
we.InMemoryModelCache = we.CacheManager = we.CSVWriter = we.JSONWriter = we.DataWriter = we.DataRecord = we.DataArray = we.Result = we.ExploreMaterializer = we.PreparedResultMaterializer = we.QueryMaterializer = we.ModelMaterializer = we.SingleConnectionRuntime = we.ConnectionRuntime = we.Runtime = we.ExploreField = we.JoinRelationship = we.QueryField = we.Query = we.StringField = we.UnsupportedField = we.JSONField = we.BooleanField = we.NumberField = we.TimestampField = we.DateField = we.TimestampTimeframe = we.DateTimeframe = we.AtomicField = we.AtomicFieldType = we.Explore = we.SourceRelationship = we.FixedConnectionMap = we.InMemoryURLReader = we.EmptyURLReader = we.PreparedResult = we.DocumentCompletion = we.DocumentSymbol = we.DocumentPosition = we.DocumentRange = we.DocumentTablePath = we.Parse = we.PreparedQuery = we.Model = we.MalloyError = we.Malloy = void 0;
|
|
55298
55298
|
const Pq = J5, Yr = $i, Uq = Mi, $D = N2, hFe = G4, pFe = v3, On = Ss, gFe = Ll, jq = "internal://internal.malloy";
|
|
@@ -1271,7 +1271,7 @@ QUERY: ${(0,bW.inspect)(n,{breakLength:72,depth:1/0})}`)}return TW.ErrorFactory.
|
|
|
1271
1271
|
| ${l}`,u>0&&(i=i+`
|
|
1272
1272
|
| ${" ".repeat(u)}^`)}else i=`line ${o+1}: char ${u}: ${r.message}`}n!==s&&(i=`FILE: ${s}
|
|
1273
1273
|
`+i,n=s),e!==""?e=`${e}
|
|
1274
|
-
${i}`:e=i}return e}childRequest(e){var n;const r=decodeURI(new URL(e,this.sourceURL).toString()),i=(n=this.childTranslators.get(r))===null||n===void 0?void 0:n.translate();if(i!=null&&i.compileSQL)return{compileSQL:i.compileSQL}}getChildExports(e){const n={},r=decodeURI(new URL(e,this.sourceURL).toString()),i=this.childTranslators.get(r);if(i&&i.translate().modelDef)for(const o of i.modelDef.exports){const u=i.modelDef.contents[o];((0,k7e.isSourceDef)(u)||u.type==="query")&&(n[o]=u)}return n}translate(e){if(this.finalAnswer)return this.finalAnswer;const n=this.translateStep.step(this,e);return n.final&&(this.finalAnswer=n),n}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let n=0;n<this.imports.length;n++){const r=this.imports[n];if((0,G7e.locationContainsPosition)(r.location,e))return r}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return this.rangeFromTokens(e.start,e.stop||e.start)}rangeFromTokens(e,n){const r={line:e.line-1,character:e.charPositionInLine};if(this.parseStep.sourceInfo&&n.stopIndex!==-1){const i=this.parseStep.sourceInfo.lines.length-1;for(let s=e.line-1;s<=i;s++){const o=this.parseStep.sourceInfo.at[s];if(n.stopIndex>=o.begin&&n.stopIndex<o.end)return{start:r,end:{line:s,character:n.stopIndex-o.begin+1}}}return{start:r,end:{line:i,character:this.parseStep.sourceInfo.lines[i].length}}}return{start:r,end:r}}rangeFromToken(e){return this.rangeFromTokens(e,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const n=this.compilerFlags.tag("experimental");return n!==void 0&&(n.bare()||n.has("dialect",e))}}w0.MalloyTranslation=cw;class lY extends cw{constructor(e,n){super(e),this.root=n}}w0.MalloyChildTranslator=lY;class lFe extends cw{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new lw.Zone,this.importZone=new lw.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new lw.Zone,this.root=this,this.logger=new aY.BaseMessageLogger(i),r&&this.update(r)}update(e){var n,r,i;this.schemaZone.updateFrom(e.tables,(n=e.errors)===null||n===void 0?void 0:n.tables),this.importZone.updateFrom(e.urls,(r=e.errors)===null||r===void 0?void 0:r.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(i=e.errors)===null||i===void 0?void 0:i.compileSQL);for(const s in e.translations)this.pretranslatedModels.set(s,e.translations[s])}logError(e,n,r){return this.logger.log((0,aY.makeLogMessage)(e,n,{severity:"error",...r})),e}}w0.MalloyTranslator=lFe;function cY(t){return[...Object.keys(t),...Object.keys(t).map(e=>cY(t[e])).flat()]}var s2={};Object.defineProperty(s2,"__esModule",{value:!0}),s2.exploreQueryWalkerBuilder=s2.ExploreQueryWalker=void 0;const cFe=m0;class fY{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(n=>n.range[0]===void 0||n.range[1]===void 0?!1:n.range[0]<=e&&n.range[1]>=e)}filterAtOffset(e){const n=this.exploreQueryAtOffset(e);if(n)return n.filterRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}hasFilterListAtOffset(e){const n=this.exploreQueryAtOffset(e);return n?!!n.filterLists.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}s2.ExploreQueryWalker=fY;function fFe(t,e){const n=new fY(t),r=n;return cFe.ParseTreeWalker.DEFAULT.walk(r,e),n}s2.exploreQueryWalkerBuilder=fFe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=w0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=s2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(Wv);var we={},BS={};Object.defineProperty(BS,"__esModule",{value:!0}),BS.MALLOY_VERSION=void 0,BS.MALLOY_VERSION="0.0.
|
|
1274
|
+
${i}`:e=i}return e}childRequest(e){var n;const r=decodeURI(new URL(e,this.sourceURL).toString()),i=(n=this.childTranslators.get(r))===null||n===void 0?void 0:n.translate();if(i!=null&&i.compileSQL)return{compileSQL:i.compileSQL}}getChildExports(e){const n={},r=decodeURI(new URL(e,this.sourceURL).toString()),i=this.childTranslators.get(r);if(i&&i.translate().modelDef)for(const o of i.modelDef.exports){const u=i.modelDef.contents[o];((0,k7e.isSourceDef)(u)||u.type==="query")&&(n[o]=u)}return n}translate(e){if(this.finalAnswer)return this.finalAnswer;const n=this.translateStep.step(this,e);return n.final&&(this.finalAnswer=n),n}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let n=0;n<this.imports.length;n++){const r=this.imports[n];if((0,G7e.locationContainsPosition)(r.location,e))return r}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return this.rangeFromTokens(e.start,e.stop||e.start)}rangeFromTokens(e,n){const r={line:e.line-1,character:e.charPositionInLine};if(this.parseStep.sourceInfo&&n.stopIndex!==-1){const i=this.parseStep.sourceInfo.lines.length-1;for(let s=e.line-1;s<=i;s++){const o=this.parseStep.sourceInfo.at[s];if(n.stopIndex>=o.begin&&n.stopIndex<o.end)return{start:r,end:{line:s,character:n.stopIndex-o.begin+1}}}return{start:r,end:{line:i,character:this.parseStep.sourceInfo.lines[i].length}}}return{start:r,end:r}}rangeFromToken(e){return this.rangeFromTokens(e,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const n=this.compilerFlags.tag("experimental");return n!==void 0&&(n.bare()||n.has("dialect",e))}}w0.MalloyTranslation=cw;class lY extends cw{constructor(e,n){super(e),this.root=n}}w0.MalloyChildTranslator=lY;class lFe extends cw{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new lw.Zone,this.importZone=new lw.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new lw.Zone,this.root=this,this.logger=new aY.BaseMessageLogger(i),r&&this.update(r)}update(e){var n,r,i;this.schemaZone.updateFrom(e.tables,(n=e.errors)===null||n===void 0?void 0:n.tables),this.importZone.updateFrom(e.urls,(r=e.errors)===null||r===void 0?void 0:r.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(i=e.errors)===null||i===void 0?void 0:i.compileSQL);for(const s in e.translations)this.pretranslatedModels.set(s,e.translations[s])}logError(e,n,r){return this.logger.log((0,aY.makeLogMessage)(e,n,{severity:"error",...r})),e}}w0.MalloyTranslator=lFe;function cY(t){return[...Object.keys(t),...Object.keys(t).map(e=>cY(t[e])).flat()]}var s2={};Object.defineProperty(s2,"__esModule",{value:!0}),s2.exploreQueryWalkerBuilder=s2.ExploreQueryWalker=void 0;const cFe=m0;class fY{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(n=>n.range[0]===void 0||n.range[1]===void 0?!1:n.range[0]<=e&&n.range[1]>=e)}filterAtOffset(e){const n=this.exploreQueryAtOffset(e);if(n)return n.filterRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}hasFilterListAtOffset(e){const n=this.exploreQueryAtOffset(e);return n?!!n.filterLists.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}s2.ExploreQueryWalker=fY;function fFe(t,e){const n=new fY(t),r=n;return cFe.ParseTreeWalker.DEFAULT.walk(r,e),n}s2.exploreQueryWalkerBuilder=fFe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=w0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=s2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(Wv);var we={},BS={};Object.defineProperty(BS,"__esModule",{value:!0}),BS.MALLOY_VERSION=void 0,BS.MALLOY_VERSION="0.0.240",Object.defineProperty(we,"__esModule",{value:!0}),we.InMemoryModelCache=we.CacheManager=we.CSVWriter=we.JSONWriter=we.DataWriter=we.DataRecord=we.DataArray=we.Result=we.ExploreMaterializer=we.PreparedResultMaterializer=we.QueryMaterializer=we.ModelMaterializer=we.SingleConnectionRuntime=we.ConnectionRuntime=we.Runtime=we.ExploreField=we.JoinRelationship=we.QueryField=we.Query=we.StringField=we.UnsupportedField=we.JSONField=we.BooleanField=we.NumberField=we.TimestampField=we.DateField=we.TimestampTimeframe=we.DateTimeframe=we.AtomicField=we.AtomicFieldType=we.Explore=we.SourceRelationship=we.FixedConnectionMap=we.InMemoryURLReader=we.EmptyURLReader=we.PreparedResult=we.DocumentCompletion=we.DocumentSymbol=we.DocumentPosition=we.DocumentRange=we.DocumentTablePath=we.Parse=we.PreparedQuery=we.Model=we.MalloyError=we.Malloy=void 0;const xY=Wv,Kr=li,dY=pi,fw=wd,xFe=BS,dFe=Yp,Fn=gs,hFe=cl,hY="internal://internal.malloy";let pl=class sR{static get version(){return xFe.MALLOY_VERSION}static _parse(e,n,r,i,s){n===void 0&&(n=new URL(hY));let o=n;i!=null&&i.importBaseURL&&(o=i==null?void 0:i.importBaseURL);const u=new xY.MalloyTranslator(n.toString(),o.toString(),{urls:{[n.toString()]:e}},r);return i!=null&&i.testEnvironment&&(u.allDialectsEnabled=!0),new gY(u,s)}static parse({url:e,urlReader:n,source:r,eventStream:i,options:s}){if(r!==void 0)return sR._parse(r,e,i,s);if(n===void 0)throw new Error("Internal Error: urlReader is required.");if(e===void 0)throw new Error("Internal Error: url is required if source not present.");return HS(n,e).then(({contents:o,invalidationKey:u})=>sR._parse(o,e,i,s,u))}static async compile({url:e,source:n,parse:r,urlReader:i,connections:s,model:o,refreshSchemaCache:u,noThrowOnError:a,eventStream:l,importBaseURL:c,cacheManager:f}){var d,h,p,m,g;let y;if(u&&(y=typeof u=="number"?u:Date.now()),e===void 0&&n===void 0&&r===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(r!==void 0?e=new URL(r._translator.sourceURL):e=new URL(hY));const E={};if(n===void 0&&f!==void 0){const _=await f.getCachedModelDef(i,e.toString());if(_)return new o2(_.modelDef,[],[e.toString(),...qS(_.modelDef.dependencies)])}c??(c=e);let A;const v=e.toString();if(r!==void 0){A=r._translator;const _=(d=r._invalidationKey)!==null&&d!==void 0?d:await Sw(i,e);E[v]=_}else{if(n===void 0){const{contents:_,invalidationKey:C}=await HS(i,e);E[v]=C,n=_}else{const _=await Sw(i,e);E[v]=_}A=new xY.MalloyTranslator(v,c.toString(),{urls:{[v]:n}},l)}for(;;){const _=A.translate(o==null?void 0:o._modelDef);if(_.final)if(_.modelDef){await(f==null?void 0:f.setCachedModelDef(e.toString(),{modelDef:_.modelDef,invalidationKeys:E}));for(const C of A.newlyTranslatedDependencies())await(f==null?void 0:f.setCachedModelDef(C.url,{modelDef:C.modelDef,invalidationKeys:E}));return new o2(_.modelDef,_.problems||[],[...(h=o==null?void 0:o.fromSources)!==null&&h!==void 0?h:[],...(p=_.fromSources)!==null&&p!==void 0?p:[]],C=>A.referenceAt(C),C=>A.importAt(C))}else if(a){const C={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},S=(o==null?void 0:o._modelDef)||C;return new o2(S,_.problems||[],[...(m=o==null?void 0:o.fromSources)!==null&&m!==void 0?m:[],...(g=_.fromSources)!==null&&g!==void 0?g:[]],T=>A.referenceAt(T),T=>A.importAt(T))}else{const C=_.problems||[],S=A.prettyErrors();throw new pY(`Error(s) compiling model:
|
|
1275
1275
|
${S}`,C)}else{if(_.urls)for(const S of _.urls)try{if(zS(S))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(f!==void 0){const L=await f.getCachedModelDef(i,S);if(L){for(const M in L.invalidationKeys)E[M]=L.invalidationKeys[M];A.update({translations:{[S]:L.modelDef}});continue}}const{contents:T,invalidationKey:D}=await HS(i,new URL(S)),I={[S]:T};E[S]=D,A.update({urls:I})}catch(T){A.update({errors:{urls:{[S]:T.message}}})}const{modelAnnotation:C}=A.modelAnnotation(o==null?void 0:o._modelDef);if(_.tables){const S=new Map;for(const T in _.tables){const{connectionName:D,tablePath:I}=_.tables[T],L=S.get(D);L===void 0?S.set(D,{[T]:I}):L[T]=I}for(const[T,D]of S)try{const I=await s.lookupConnection(T),{schemas:L,errors:M}=await sR.safelyFetchTableSchema(I,D,{refreshTimestamp:y,modelAnnotation:C});A.update({tables:L,errors:{tables:M}})}catch(I){const L={},M={};for(const q in D)M[q]=I.toString();A.update({tables:L,errors:{tables:M}})}}if(_.compileSQL){const S=_.compileSQL,T=S.connection,D=(0,hFe.sqlKey)(S.connection,S.selectStr);try{const L=await(await s.lookupConnection(T)).fetchSchemaForSQLStruct(S,{refreshTimestamp:y,modelAnnotation:C});L.error&&A.update({errors:{compileSQL:{[D]:L.error}}}),L.structDef&&A.update({compileSQL:{[D]:L.structDef}})}catch(I){const L={};L[D]=I.toString(),A.update({errors:{compileSQL:L}})}}}}}static async safelyFetchTableSchema(e,n,r){const i=await e.fetchSchemaForTables(n,r);for(const s of Object.keys(n))if(i.schemas[s]===void 0&&i.errors[s]===void 0)throw new Error(`Schema fetch error for ${e.name}, no response for ${s} from ${e.dialectName}`);return i}static async run({connections:e,preparedResult:n,sqlStruct:r,connection:i,options:s}){if(!i){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const o=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName);i=await e.lookupConnection(o)}if(r){const o=await i.runSQL(r.selectStr);return new Wm({structs:[r],sql:r.selectStr,result:o.rows,totalRows:o.totalRows,runStats:o.runStats,lastStageName:r.name,malloy:"",connectionName:r.connection,sourceExplore:"",sourceFilters:[],profilingUrl:o.profilingUrl},{name:"empty_model",exports:[],contents:{},queryList:[],dependencies:{}})}else if(n){const o=await i.runSQL(n.sql,s);return new Wm({...n._rawQuery,result:o.rows,totalRows:o.totalRows,runStats:o.runStats,profilingUrl:o.profilingUrl},n._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:e,preparedResult:n,sqlStruct:r,connection:i,options:s}){if(r===void 0&&n===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const o=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName);if(i===void 0){if(e===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");i=await e.lookupConnection(o)}if(!i.canStream())throw new Error(`Connection '${o}' cannot stream results.`);let u,a;if(r)a=new Os(r),u=r.selectStr;else if(n!==void 0)a=n.resultExplore,u=n.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let l=0;for await(const c of i.runSQLStream(u,s))yield new ax(c,l,a,void 0,void 0),l+=1}static async estimateQueryCost({connections:e,preparedResult:n,sqlStruct:r}){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const i=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName),s=await e.lookupConnection(i);if(r)return await s.estimateQueryCost(r.selectStr);if(n)return await s.estimateQueryCost(n.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}};we.Malloy=pl;class pY extends Error{constructor(e,n=[]){super(e),this.problems=n}}we.MalloyError=pY;let o2=class{constructor(e,n,r,i=()=>{},s=()=>{}){this.modelDef=e,this.problems=n,this.fromSources=r,this._referenceAt=i,this._importAt=s}tagParse(e){return(0,Fn.annotationToTag)(this.modelDef.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this.modelDef.annotation,e)}getReference(e){return this._referenceAt(e)}getImport(e){return this._importAt(e)}getPreparedQueryByName(e){const n=this.modelDef.contents[e];if((n==null?void 0:n.type)==="query")return new u2(n,this.modelDef,this.problems,e);throw new Error("Given query name does not refer to a named query.")}getPreparedQueryByIndex(e){if(e<0)throw new Error(`Invalid index ${e}.`);if(e>=this.modelDef.queryList.length)throw new Error(`Query index ${e} is out of bounds.`);return new u2(this.modelDef.queryList[e],this.modelDef,this.problems)}get preparedQuery(){return this.getPreparedQuery()}getPreparedQuery(){if(this.modelDef.queryList.length===0)throw new Error("Model has no queries.");return new u2(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const n=this.modelDef.contents[e];if((0,Kr.isSourceDef)(n))return new Os(n);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(Kr.isSourceDef).map(e=>new Os(e))}get namedQueries(){const e=n=>n.type==="query";return Object.values(this.modelDef.contents).filter(e)}get exportedExplores(){return this.explores.filter(e=>this.modelDef.exports.includes(e.name))}get _modelDef(){return this.modelDef}};we.Model=o2;class u2{constructor(e,n,r,i){this.problems=r,this.name=i,this._query=e,this._modelDef=n}tagParse(e){const n=(0,Fn.annotationToTag)(this._modelDef.annotation).tag;return e=(0,Fn.addModelScope)(e,n),(0,Fn.annotationToTag)(this._query.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const r=new Kr.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new Qm({...r,queryName:this.name||r.queryName},this._modelDef)}get dialect(){const e=this._query.structRef,n=typeof e=="string"?this._modelDef.contents[e]:e;if(!(0,Kr.isSourceDef)(n))throw new Error("Invalid source for query");return n.dialect}getFlattenedQuery(e){return this}}we.PreparedQuery=u2;class gY{constructor(e,n){this.translator=e,this.invalidationKey=n}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new $S(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(r=>new mY(r))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(n=>new yY(n))}helpContext(e){return this.translator.helpContext(e).helpContext}}we.Parse=gY;class mY{constructor(e){this._range=a2.fromJSON(e.range),this._connectionId=e.connectionId,this._tablePath=e.tablePath}get range(){return this._range}get connectionId(){return this._connectionId}get tablePath(){return this._tablePath}}we.DocumentTablePath=mY;class a2{constructor(e,n){this._start=e,this._end=n}get start(){return this._start}get end(){return this._end}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}static fromJSON(e){return new a2(new xw(e.start.line,e.start.character),new xw(e.end.line,e.end.character))}}we.DocumentRange=a2;class xw{constructor(e,n){this._line=e,this._character=n}get line(){return this._line}get character(){return this._character}toJSON(){return{line:this.line,character:this.character}}}we.DocumentPosition=xw;class $S{constructor(e){this._range=a2.fromJSON(e.range),this._lensRange=e.lensRange?a2.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(n=>new $S(n))}get range(){return this._range}get lensRange(){var e;return(e=this._lensRange)!==null&&e!==void 0?e:this._range}get type(){return this._type}get name(){return this._name}get children(){return this._children}}we.DocumentSymbol=$S;class yY{constructor(e){this.type=e.type,this.text=e.text}}we.DocumentCompletion=yY;class Qm{constructor(e,n){this.modelDef=n,this.inner=e}static fromJson({query:e,modelDef:n}){if(!e||!n)throw new Error("Missing required properties in JSON data");return new Qm(e,n)}tagParse(e){const n=(0,Fn.annotationToTag)(this.modelDef.annotation).tag;return e=(0,Fn.addModelScope)(e,n),(0,Fn.annotationToTag)(this.inner.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return(0,Fn.annotationToTag)(this.modelDef.annotation).tag}get connectionName(){return this.inner.connectionName}get _rawQuery(){return this.inner}get _modelDef(){return this.modelDef}get sql(){return this.inner.sql}get dependenciesToMaterialize(){return this.inner.dependenciesToMaterialize}get materialization(){return this.inner.materialization}get resultExplore(){if(this.inner.structs.length===0)throw new Error("Malformed query result.");const e=this.inner.structs[this.inner.structs.length-1],n={...e,annotation:this.inner.annotation,name:this.inner.queryName||e.name};try{return new Os(n,this.sourceExplore)}catch{return new Os(n)}}get sourceExplore(){const e=this.inner.sourceExplore,n=this.modelDef.contents[e];if(n===void 0)throw new Error("Malformed query result.");if((0,Kr.isSourceDef)(n))return new Os(n);throw new Error(`'${e} is not an explore`)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}we.PreparedResult=Qm;class EY{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}we.EmptyURLReader=EY;class pFe{constructor(e){this.files=e}async readURL(e){const n=this.files.get(e.toString());if(n!==void 0)return Promise.resolve({contents:n,invalidationKey:this.invalidationKey(e,n)});throw new Error(`File not found '${e}'`)}async getInvalidationKey(e){const n=this.files.get(e.toString());if(n!==void 0)return Promise.resolve(this.invalidationKey(e,n));throw new Error(`File not found '${e}'`)}invalidationKey(e,n){return zS(e.toString())?null:IY(n)}}we.InMemoryURLReader=pFe;class kS{constructor(e,n){this.connections=e,this.defaultConnectionName=n}async getConnection(e){if(e===void 0)if(this.defaultConnectionName!==void 0)e=this.defaultConnectionName;else throw new Error("No default connection.");const n=this.connections.get(e);if(n!==void 0)return Promise.resolve(n);throw new Error(`No connection found with name ${e}.`)}listConnections(){return Array.from(this.connections.values())}async lookupConnection(e){return this.getConnection(e)}static fromArray(e){return new kS(new Map(e.map(n=>[n.name,n])))}}we.FixedConnectionMap=kS;var AY;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(AY||(we.SourceRelationship=AY={}));class dw{constructor(e,n,r){this._name=e,this._parent=n,this._source=r}get source(){return this.source}get name(){return this._name}get sourceClasses(){const e=[];return this.source&&e.push(this.source.name),e.push(this.name),e}get fieldPath(){const e=[this.name];let n=this._parent;for(;n;)e.unshift(n.name),n=n._parent;return e}hasParentExplore(){return this._parent!==void 0}isExplore(){return this instanceof Os}isQuery(){return this instanceof Aw}}class Os extends dw{constructor(e,n,r){super(e.as||e.name,n,r),this._structDef=e,this._parentExplore=n,this.sourceExplore=r}get source(){return this.sourceExplore}isIntrinsic(){return(0,Kr.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return(0,Fn.annotationToTag)(this._structDef.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=(0,Fn.annotationToTag)(this._structDef.modelAnnotation).tag),this.parsedModelTag}get name(){return this.structDef.as||this.structDef.name}getQueryByName(e){const n=this.sourceStructDef;if(!n)throw new Error(`Cannot get query by name from a struct of type ${this.structDef.type}`);const r={type:"query",structRef:n,pipeline:[{type:"reduce",queryFields:[{type:"fieldref",path:[e]}]}]};return new u2(r,this.modelDef,[],e)}get modelDef(){if(!(0,Kr.isSourceDef)(this.structDef))throw new Error(`Cannot create pseudo model for struct type ${this.structDef.type}`);return{name:"generated_model",exports:[],contents:{[this.structDef.name]:this.structDef},queryList:[],dependencies:{}}}getSingleExploreModel(){return new o2(this.modelDef,[],[])}get fieldMap(){var e;if(this._fieldMap===void 0){const n=((e=this.source)===null||e===void 0?void 0:e.fieldMap)||new Map;this._fieldMap=new Map(this.structDef.fields.map(r=>{const i=r.as||r.name,s=n.get(r.name);if((0,Kr.isJoined)(r))return[i,new vw(r,this,s)];if(r.type==="turtle")return[i,new Aw(r,this,s)];if(r.type==="string")return[i,new Ew(r,this,s)];if(r.type==="number")return[i,new MS(r,this,s)];if(r.type==="date")return r.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(r.timeframe)?[i,new MS({...r,type:"number"},this,s)]:[i,new hw(r,this,s)];if(r.type==="timestamp")return[i,new pw(r,this,s)];if(r.type==="boolean")return[i,new gw(r,this,s)];if(r.type==="json")return[i,new mw(r,this,s)];if(r.type==="sql native")return[i,new yw(r,this,s)]}))}return this._fieldMap}get allFields(){return[...this.fieldMap.values()]}get allFieldsWithOrder(){var e,n,r;if(!this._allFieldsWithOrder){const i=[...((r=(n=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||n===void 0?void 0:n.orderBy)===null||r===void 0?void 0:r.map(o=>{if(typeof o.field=="string")return{field:this.fieldMap.get(o.field),dir:o.dir};throw new Error("Does not support mapping order by from number.")}))||[]],s=new Set(i.map(o=>o.field.name));this._allFieldsWithOrder=[...i,...this.allFields.filter(o=>!s.has(o.name)).map(o=>({field:o,dir:"asc"}))]}return this._allFieldsWithOrder}get intrinsicFields(){return[...this.fieldMap.values()].filter(e=>e.isIntrinsic())}get dimensions(){return[...this.allFieldsWithOrder].filter(e=>e.field.isAtomicField()&&e.field.sourceWasDimension())}getFieldByName(e){const n=this.fieldMap.get(e);if(n===void 0)throw new Error(`No such field ${e}.`);return n}getFieldByNameIfExists(e){return this.fieldMap.get(e)}get primaryKey(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.primaryKey}get parentExplore(){return this._parentExplore}hasParentExplore(){return this instanceof vw}get filters(){var e;return(0,Kr.isSourceDef)(this.structDef)?((e=this.structDef.resultMetadata)===null||e===void 0?void 0:e.filterList)||[]:[]}get limit(){var e,n;return(n=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||n===void 0?void 0:n.limit}get structDef(){return this._structDef}get queryTimezone(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.queryTimezone}get sourceStructDef(){if((0,Kr.isSourceDef)(this.structDef))return this.structDef}toJSON(){var e,n;return{_structDef:this._structDef,sourceExplore:(e=this.sourceExplore)===null||e===void 0?void 0:e.toJSON(),_parentExplore:(n=this._parentExplore)===null||n===void 0?void 0:n.toJSON()}}static fromJSON(e){const n=e._parentExplore!==void 0?Os.fromJSON(e._parentExplore):void 0,r=e.sourceExplore!==void 0?Os.fromJSON(e.sourceExplore):void 0;return new Os(e._structDef,n,r)}get location(){return this.structDef.location}}we.Explore=Os;var Vu;(function(t){t.String="string",t.Number="number",t.Boolean="boolean",t.Date="date",t.Timestamp="timestamp",t.Json="json",t.NativeUnsupported="sql native",t.Error="error"})(Vu||(we.AtomicFieldType=Vu={}));class ec extends dw{constructor(e,n,r){super(e.as||e.name,n,r),this.fieldTypeDef=e,this.parent=n}get type(){switch(this.fieldTypeDef.type){case"string":return Vu.String;case"boolean":return Vu.Boolean;case"date":return Vu.Date;case"timestamp":return Vu.Timestamp;case"number":return Vu.Number;case"json":return Vu.Json;case"sql native":return Vu.NativeUnsupported;case"error":return Vu.Error;case"record":case"array":throw new Error(`MTOY TODO IMPLEMENT Atomic ${this.fieldTypeDef.type}`);default:{const e=this.fieldTypeDef;throw new Error(`Can't make an atomic field from ${e}`)}}}tagParse(e){return e=(0,Fn.addModelScope)(e,this.parent.modelTag),(0,Fn.annotationToTag)(this.fieldTypeDef.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,Kr.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,Kr.expressionIsCalculation)(this.fieldTypeDef.expressionType)}get sourceField(){throw new Error}get sourceClasses(){const e=this.fieldTypeDef.name||this.fieldTypeDef.as;return e?[e]:[]}get referenceId(){var e;return(e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.referenceId}sourceWasMeasure(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"}sourceWasMeasureLike(){var e,n;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((n=this.fieldTypeDef.resultMetadata)===null||n===void 0?void 0:n.fieldKind)==="struct"}sourceWasDimension(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="dimension"}hasParentExplore(){return!0}isString(){return this instanceof Ew}isNumber(){return this instanceof MS}isDate(){return this instanceof hw}isBoolean(){return this instanceof gw}isJSON(){return this instanceof mw}isTimestamp(){return this instanceof pw}isUnsupported(){return this instanceof yw}get parentExplore(){return this.parent}get expression(){const e=".",n=this.fieldTypeDef.resultMetadata;return(n==null?void 0:n.sourceExpression)||(n!=null&&n.sourceField.includes(e)?n==null?void 0:n.sourceField:this.name)}get location(){return this.fieldTypeDef.location}}we.AtomicField=ec;var ux;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(ux||(we.DateTimeframe=ux={}));var Yu;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year",t.Second="second",t.Hour="hour",t.Minute="minute"})(Yu||(we.TimestampTimeframe=Yu={}));class hw extends ec{constructor(e,n,r){super(e,n,r),this.fieldDateDef=e}get timeframe(){if(this.fieldDateDef.timeframe!==void 0)switch(this.fieldDateDef.timeframe){case"day":return ux.Day;case"week":return ux.Week;case"month":return ux.Month;case"quarter":return ux.Quarter;case"year":return ux.Year}}}we.DateField=hw;class pw extends ec{constructor(e,n,r){super(e,n,r),this.fieldTimestampDef=e}get timeframe(){if(this.fieldTimestampDef.timeframe!==void 0)switch(this.fieldTimestampDef.timeframe){case"day":return Yu.Day;case"week":return Yu.Week;case"month":return Yu.Month;case"quarter":return Yu.Quarter;case"year":return Yu.Year;case"second":return Yu.Second;case"hour":return Yu.Hour;case"minute":return Yu.Minute}}}we.TimestampField=pw;class MS extends ec{constructor(e,n,r){super(e,n,r),this.fieldNumberDef=e}}we.NumberField=MS;class gw extends ec{constructor(e,n,r){super(e,n,r),this.fieldBooleanDef=e}}we.BooleanField=gw;class mw extends ec{constructor(e,n,r){super(e,n,r),this.fieldJSONDef=e}}we.JSONField=mw;class yw extends ec{constructor(e,n,r){super(e,n,r),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}we.UnsupportedField=yw;class Ew extends ec{constructor(e,n,r){super(e,n,r),this.fieldStringDef=e}}we.StringField=Ew;class vY extends dw{constructor(e,n,r){super(e.as||e.name,n,r),this.turtleDef=e}get source(){return this.sourceQuery}isIntrinsic(){return!1}get location(){return this.turtleDef.location}}we.Query=vY;class Aw extends vY{constructor(e,n,r){super(e,n,r),this.parent=n}tagParse(e){return e=(0,Fn.addModelScope)(e,this.parent.modelTag),(0,Fn.annotationToTag)(this.turtleDef.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this.turtleDef.annotation,e)}isQueryField(){return!0}isExploreField(){return!1}isAtomicField(){return!1}get sourceClasses(){const e=this.turtleDef.name||this.turtleDef.as;return e?[e]:[]}hasParentExplore(){return!0}get parentExplore(){return this.parent}get expression(){return this.name}}we.QueryField=Aw;var l2;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(l2||(we.JoinRelationship=l2={}));class vw extends Os{constructor(e,n,r){super(e,n,r),this._parentExplore=n}get joinRelationship(){if((0,Kr.isJoined)(this.structDef))switch(this.structDef.join){case"one":return l2.OneToOne;case"many":case"cross":return l2.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===l2.OneToOne}get isArray(){return this.joinRelationship!==l2.OneToOne}tagParse(e){return e=(0,Fn.addModelScope)(e,this._parentExplore.modelTag),(0,Fn.annotationToTag)(this._structDef.annotation,e)}isQueryField(){return!1}isExploreField(){return!0}isAtomicField(){return!1}get parentExplore(){return this._parentExplore}get sourceClasses(){const e=this.structDef.name||this.structDef.as;return e?[e]:[]}}we.ExploreField=vw;class _w{constructor({urlReader:e,connections:n,connection:r,eventStream:i,cacheManager:s}){if(this.isTestRuntime=!1,n===void 0){if(r===void 0)throw new Error("A LookupConnection<Connection> or Connection is required.");n={lookupConnection:()=>Promise.resolve(r)}}e===void 0&&(e=new EY),this._urlReader=e,this._connections=n,this._eventStream=i,this._cacheManager=s}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}loadModel(e,n){const{refreshSchemaCache:r,noThrowOnError:i}=n||{};this.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0});const s=e instanceof URL?{url:e}:{source:e};return new Gm(this,async()=>pl.compile({...s,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:r,noThrowOnError:i,eventStream:this.eventStream,replaceMaterializedReferences:n==null?void 0:n.replaceMaterializedReferences,materializedTablePrefix:n==null?void 0:n.materializedTablePrefix,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,cacheManager:this.cacheManager}),n)}_loadModelFromModelDef(e,n){return new Gm(this,async()=>new o2(e,[],[]),n)}loadQuery(e,n){return this.loadModel(e,n).loadFinalQuery()}loadQueryByIndex(e,n,r){return this.loadModel(e,r).loadQueryByIndex(n,r)}loadQueryByName(e,n,r){return this.loadModel(e,r).loadQueryByName(n,r)}getModel(e,n){return this.loadModel(e,n).getModel()}getQuery(e,n){return this.loadQuery(e,n).getPreparedQuery()}getQueryByIndex(e,n,r){return this.loadQueryByIndex(e,n,r).getPreparedQuery()}getQueryByName(e,n,r){return this.loadQueryByName(e,n,r).getPreparedQuery()}}we.Runtime=_w;class gFe extends _w{constructor({urlReader:e,connections:n}){super({connections:kS.fromArray(n),urlReader:e}),this.rawConnections=n}}we.ConnectionRuntime=gFe;class mFe extends _w{constructor({urlReader:e,connection:n,eventStream:r,cacheManager:i}){super({urlReader:e,eventStream:r,cacheManager:i,connection:n}),this.connection=n}get supportsNesting(){return(0,fw.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,fw.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,fw.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}we.SingleConnectionRuntime=mFe;class PS{constructor(e,n){this.runtime=e,this._materialize=n}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(e,n){return new _Y(this.runtime,e,n)}makeExploreMaterializer(e,n){return new SY(this.runtime,e,n)}makePreparedResultMaterializer(e){return new CY(this.runtime,e)}}class Gm extends PS{constructor(e,n,r){super(e,n),this.runtime=e,this.compileQueryOptions=r}loadFinalQuery(e){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...e})}loadQueryByIndex(e,n){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(e),{...this.compileQueryOptions,...n})}loadQueryByName(e,n){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(e),{...this.compileQueryOptions,...n})}loadQuery(e,n){const{refreshSchemaCache:r,noThrowOnError:i}=n||{};return this.makeQueryMaterializer(async()=>{const s=this.runtime.urlReader,o=this.runtime.connections;this.runtime.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0});const u=e instanceof URL?{url:e}:{source:e},a=await this.getModel();return(await pl.compile({...u,urlReader:s,connections:o,model:a,refreshSchemaCache:r,noThrowOnError:i,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,...this.compileQueryOptions})).preparedQuery})}extendModel(e,n){return this.runtime.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0}),new Gm(this.runtime,async()=>{const r=this.runtime.urlReader,i=this.runtime.connections,s=e instanceof URL?{url:e}:{source:e},o=await this.getModel();return await pl.compile({...s,urlReader:r,connections:i,model:o,refreshSchemaCache:n==null?void 0:n.refreshSchemaCache,noThrowOnError:n==null?void 0:n.noThrowOnError,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,...this.compileQueryOptions})},n)}async search(e,n,r=1e3,i=void 0,s){const o=await this.materialize(),u=new Kr.QueryModel(o._modelDef,s),a=o.getExploreByName(e).structDef;if(!(0,Kr.isSourceDef)(a))throw new Error("Source to be searched was unexpectedly, not a source");const l=a.connection,c=await this.runtime.connections.lookupConnection(l);return await u.searchIndex(c,e,n,r,i)}async searchValueMap(e,n=10,r){const s=(await this.materialize()).getExploreByName(e);if(!(0,Kr.isSourceDef)(s.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let o="{index: *}";s.getFieldByNameIfExists("search_index")&&(o="search_index");const u=`
|
|
1276
1276
|
run: ${e}
|
|
1277
1277
|
-> ${o}
|
|
@@ -55292,7 +55292,7 @@ Jh.exploreQueryWalkerBuilder = dFe;
|
|
|
55292
55292
|
var we = {}, G4 = {};
|
|
55293
55293
|
Object.defineProperty(G4, "__esModule", { value: !0 });
|
|
55294
55294
|
G4.MALLOY_VERSION = void 0;
|
|
55295
|
-
G4.MALLOY_VERSION = "0.0.
|
|
55295
|
+
G4.MALLOY_VERSION = "0.0.240";
|
|
55296
55296
|
Object.defineProperty(we, "__esModule", { value: !0 });
|
|
55297
55297
|
we.InMemoryModelCache = we.CacheManager = we.CSVWriter = we.JSONWriter = we.DataWriter = we.DataRecord = we.DataArray = we.Result = we.ExploreMaterializer = we.PreparedResultMaterializer = we.QueryMaterializer = we.ModelMaterializer = we.SingleConnectionRuntime = we.ConnectionRuntime = we.Runtime = we.ExploreField = we.JoinRelationship = we.QueryField = we.Query = we.StringField = we.UnsupportedField = we.JSONField = we.BooleanField = we.NumberField = we.TimestampField = we.DateField = we.TimestampTimeframe = we.DateTimeframe = we.AtomicField = we.AtomicFieldType = we.Explore = we.SourceRelationship = we.FixedConnectionMap = we.InMemoryURLReader = we.EmptyURLReader = we.PreparedResult = we.DocumentCompletion = we.DocumentSymbol = we.DocumentPosition = we.DocumentRange = we.DocumentTablePath = we.Parse = we.PreparedQuery = we.Model = we.MalloyError = we.Malloy = void 0;
|
|
55298
55298
|
const Pq = J5, Yr = $i, Uq = Mi, $D = N2, hFe = G4, pFe = v3, On = Ss, gFe = Ll, jq = "internal://internal.malloy";
|
|
@@ -1271,7 +1271,7 @@ QUERY: ${(0,SW.inspect)(n,{breakLength:72,depth:1/0})}`)}return bW.ErrorFactory.
|
|
|
1271
1271
|
| ${l}`,u>0&&(i=i+`
|
|
1272
1272
|
| ${" ".repeat(u)}^`)}else i=`line ${o+1}: char ${u}: ${r.message}`}n!==s&&(i=`FILE: ${s}
|
|
1273
1273
|
`+i,n=s),e!==""?e=`${e}
|
|
1274
|
-
${i}`:e=i}return e}childRequest(e){var n;const r=decodeURI(new URL(e,this.sourceURL).toString()),i=(n=this.childTranslators.get(r))===null||n===void 0?void 0:n.translate();if(i!=null&&i.compileSQL)return{compileSQL:i.compileSQL}}getChildExports(e){const n={},r=decodeURI(new URL(e,this.sourceURL).toString()),i=this.childTranslators.get(r);if(i&&i.translate().modelDef)for(const o of i.modelDef.exports){const u=i.modelDef.contents[o];((0,k7e.isSourceDef)(u)||u.type==="query")&&(n[o]=u)}return n}translate(e){if(this.finalAnswer)return this.finalAnswer;const n=this.translateStep.step(this,e);return n.final&&(this.finalAnswer=n),n}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let n=0;n<this.imports.length;n++){const r=this.imports[n];if((0,G7e.locationContainsPosition)(r.location,e))return r}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return this.rangeFromTokens(e.start,e.stop||e.start)}rangeFromTokens(e,n){const r={line:e.line-1,character:e.charPositionInLine};if(this.parseStep.sourceInfo&&n.stopIndex!==-1){const i=this.parseStep.sourceInfo.lines.length-1;for(let s=e.line-1;s<=i;s++){const o=this.parseStep.sourceInfo.at[s];if(n.stopIndex>=o.begin&&n.stopIndex<o.end)return{start:r,end:{line:s,character:n.stopIndex-o.begin+1}}}return{start:r,end:{line:i,character:this.parseStep.sourceInfo.lines[i].length}}}return{start:r,end:r}}rangeFromToken(e){return this.rangeFromTokens(e,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const n=this.compilerFlags.tag("experimental");return n!==void 0&&(n.bare()||n.has("dialect",e))}}w0.MalloyTranslation=lw;class aY extends lw{constructor(e,n){super(e),this.root=n}}w0.MalloyChildTranslator=aY;class lFe extends lw{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new aw.Zone,this.importZone=new aw.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new aw.Zone,this.root=this,this.logger=new uY.BaseMessageLogger(i),r&&this.update(r)}update(e){var n,r,i;this.schemaZone.updateFrom(e.tables,(n=e.errors)===null||n===void 0?void 0:n.tables),this.importZone.updateFrom(e.urls,(r=e.errors)===null||r===void 0?void 0:r.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(i=e.errors)===null||i===void 0?void 0:i.compileSQL);for(const s in e.translations)this.pretranslatedModels.set(s,e.translations[s])}logError(e,n,r){return this.logger.log((0,uY.makeLogMessage)(e,n,{severity:"error",...r})),e}}w0.MalloyTranslator=lFe;function lY(t){return[...Object.keys(t),...Object.keys(t).map(e=>lY(t[e])).flat()]}var s2={};Object.defineProperty(s2,"__esModule",{value:!0}),s2.exploreQueryWalkerBuilder=s2.ExploreQueryWalker=void 0;const cFe=m0;class cY{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(n=>n.range[0]===void 0||n.range[1]===void 0?!1:n.range[0]<=e&&n.range[1]>=e)}filterAtOffset(e){const n=this.exploreQueryAtOffset(e);if(n)return n.filterRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}hasFilterListAtOffset(e){const n=this.exploreQueryAtOffset(e);return n?!!n.filterLists.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}s2.ExploreQueryWalker=cY;function fFe(t,e){const n=new cY(t),r=n;return cFe.ParseTreeWalker.DEFAULT.walk(r,e),n}s2.exploreQueryWalkerBuilder=fFe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=w0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=s2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(Gv);var we={},IS={};Object.defineProperty(IS,"__esModule",{value:!0}),IS.MALLOY_VERSION=void 0,IS.MALLOY_VERSION="0.0.
|
|
1274
|
+
${i}`:e=i}return e}childRequest(e){var n;const r=decodeURI(new URL(e,this.sourceURL).toString()),i=(n=this.childTranslators.get(r))===null||n===void 0?void 0:n.translate();if(i!=null&&i.compileSQL)return{compileSQL:i.compileSQL}}getChildExports(e){const n={},r=decodeURI(new URL(e,this.sourceURL).toString()),i=this.childTranslators.get(r);if(i&&i.translate().modelDef)for(const o of i.modelDef.exports){const u=i.modelDef.contents[o];((0,k7e.isSourceDef)(u)||u.type==="query")&&(n[o]=u)}return n}translate(e){if(this.finalAnswer)return this.finalAnswer;const n=this.translateStep.step(this,e);return n.final&&(this.finalAnswer=n),n}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let n=0;n<this.imports.length;n++){const r=this.imports[n];if((0,G7e.locationContainsPosition)(r.location,e))return r}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return this.rangeFromTokens(e.start,e.stop||e.start)}rangeFromTokens(e,n){const r={line:e.line-1,character:e.charPositionInLine};if(this.parseStep.sourceInfo&&n.stopIndex!==-1){const i=this.parseStep.sourceInfo.lines.length-1;for(let s=e.line-1;s<=i;s++){const o=this.parseStep.sourceInfo.at[s];if(n.stopIndex>=o.begin&&n.stopIndex<o.end)return{start:r,end:{line:s,character:n.stopIndex-o.begin+1}}}return{start:r,end:{line:i,character:this.parseStep.sourceInfo.lines[i].length}}}return{start:r,end:r}}rangeFromToken(e){return this.rangeFromTokens(e,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const n=this.compilerFlags.tag("experimental");return n!==void 0&&(n.bare()||n.has("dialect",e))}}w0.MalloyTranslation=lw;class aY extends lw{constructor(e,n){super(e),this.root=n}}w0.MalloyChildTranslator=aY;class lFe extends lw{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new aw.Zone,this.importZone=new aw.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new aw.Zone,this.root=this,this.logger=new uY.BaseMessageLogger(i),r&&this.update(r)}update(e){var n,r,i;this.schemaZone.updateFrom(e.tables,(n=e.errors)===null||n===void 0?void 0:n.tables),this.importZone.updateFrom(e.urls,(r=e.errors)===null||r===void 0?void 0:r.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(i=e.errors)===null||i===void 0?void 0:i.compileSQL);for(const s in e.translations)this.pretranslatedModels.set(s,e.translations[s])}logError(e,n,r){return this.logger.log((0,uY.makeLogMessage)(e,n,{severity:"error",...r})),e}}w0.MalloyTranslator=lFe;function lY(t){return[...Object.keys(t),...Object.keys(t).map(e=>lY(t[e])).flat()]}var s2={};Object.defineProperty(s2,"__esModule",{value:!0}),s2.exploreQueryWalkerBuilder=s2.ExploreQueryWalker=void 0;const cFe=m0;class cY{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(n=>n.range[0]===void 0||n.range[1]===void 0?!1:n.range[0]<=e&&n.range[1]>=e)}filterAtOffset(e){const n=this.exploreQueryAtOffset(e);if(n)return n.filterRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}hasFilterListAtOffset(e){const n=this.exploreQueryAtOffset(e);return n?!!n.filterLists.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}s2.ExploreQueryWalker=cY;function fFe(t,e){const n=new cY(t),r=n;return cFe.ParseTreeWalker.DEFAULT.walk(r,e),n}s2.exploreQueryWalkerBuilder=fFe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=w0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=s2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(Gv);var we={},IS={};Object.defineProperty(IS,"__esModule",{value:!0}),IS.MALLOY_VERSION=void 0,IS.MALLOY_VERSION="0.0.240",Object.defineProperty(we,"__esModule",{value:!0}),we.InMemoryModelCache=we.CacheManager=we.CSVWriter=we.JSONWriter=we.DataWriter=we.DataRecord=we.DataArray=we.Result=we.ExploreMaterializer=we.PreparedResultMaterializer=we.QueryMaterializer=we.ModelMaterializer=we.SingleConnectionRuntime=we.ConnectionRuntime=we.Runtime=we.ExploreField=we.JoinRelationship=we.QueryField=we.Query=we.StringField=we.UnsupportedField=we.JSONField=we.BooleanField=we.NumberField=we.TimestampField=we.DateField=we.TimestampTimeframe=we.DateTimeframe=we.AtomicField=we.AtomicFieldType=we.Explore=we.SourceRelationship=we.FixedConnectionMap=we.InMemoryURLReader=we.EmptyURLReader=we.PreparedResult=we.DocumentCompletion=we.DocumentSymbol=we.DocumentPosition=we.DocumentRange=we.DocumentTablePath=we.Parse=we.PreparedQuery=we.Model=we.MalloyError=we.Malloy=void 0;const fY=Gv,Kr=li,xY=pi,cw=wd,xFe=IS,dFe=Wp,Fn=gs,hFe=cl,dY="internal://internal.malloy";let pl=class iR{static get version(){return xFe.MALLOY_VERSION}static _parse(e,n,r,i,s){n===void 0&&(n=new URL(dY));let o=n;i!=null&&i.importBaseURL&&(o=i==null?void 0:i.importBaseURL);const u=new fY.MalloyTranslator(n.toString(),o.toString(),{urls:{[n.toString()]:e}},r);return i!=null&&i.testEnvironment&&(u.allDialectsEnabled=!0),new pY(u,s)}static parse({url:e,urlReader:n,source:r,eventStream:i,options:s}){if(r!==void 0)return iR._parse(r,e,i,s);if(n===void 0)throw new Error("Internal Error: urlReader is required.");if(e===void 0)throw new Error("Internal Error: url is required if source not present.");return qS(n,e).then(({contents:o,invalidationKey:u})=>iR._parse(o,e,i,s,u))}static async compile({url:e,source:n,parse:r,urlReader:i,connections:s,model:o,refreshSchemaCache:u,noThrowOnError:a,eventStream:l,importBaseURL:c,cacheManager:f}){var d,h,p,m,g;let y;if(u&&(y=typeof u=="number"?u:Date.now()),e===void 0&&n===void 0&&r===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(r!==void 0?e=new URL(r._translator.sourceURL):e=new URL(dY));const E={};if(n===void 0&&f!==void 0){const _=await f.getCachedModelDef(i,e.toString());if(_)return new o2(_.modelDef,[],[e.toString(),...jS(_.modelDef.dependencies)])}c??(c=e);let A;const v=e.toString();if(r!==void 0){A=r._translator;const _=(d=r._invalidationKey)!==null&&d!==void 0?d:await Cw(i,e);E[v]=_}else{if(n===void 0){const{contents:_,invalidationKey:C}=await qS(i,e);E[v]=C,n=_}else{const _=await Cw(i,e);E[v]=_}A=new fY.MalloyTranslator(v,c.toString(),{urls:{[v]:n}},l)}for(;;){const _=A.translate(o==null?void 0:o._modelDef);if(_.final)if(_.modelDef){await(f==null?void 0:f.setCachedModelDef(e.toString(),{modelDef:_.modelDef,invalidationKeys:E}));for(const C of A.newlyTranslatedDependencies())await(f==null?void 0:f.setCachedModelDef(C.url,{modelDef:C.modelDef,invalidationKeys:E}));return new o2(_.modelDef,_.problems||[],[...(h=o==null?void 0:o.fromSources)!==null&&h!==void 0?h:[],...(p=_.fromSources)!==null&&p!==void 0?p:[]],C=>A.referenceAt(C),C=>A.importAt(C))}else if(a){const C={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},S=(o==null?void 0:o._modelDef)||C;return new o2(S,_.problems||[],[...(m=o==null?void 0:o.fromSources)!==null&&m!==void 0?m:[],...(g=_.fromSources)!==null&&g!==void 0?g:[]],T=>A.referenceAt(T),T=>A.importAt(T))}else{const C=_.problems||[],S=A.prettyErrors();throw new hY(`Error(s) compiling model:
|
|
1275
1275
|
${S}`,C)}else{if(_.urls)for(const S of _.urls)try{if(HS(S))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(f!==void 0){const L=await f.getCachedModelDef(i,S);if(L){for(const M in L.invalidationKeys)E[M]=L.invalidationKeys[M];A.update({translations:{[S]:L.modelDef}});continue}}const{contents:T,invalidationKey:D}=await qS(i,new URL(S)),I={[S]:T};E[S]=D,A.update({urls:I})}catch(T){A.update({errors:{urls:{[S]:T.message}}})}const{modelAnnotation:C}=A.modelAnnotation(o==null?void 0:o._modelDef);if(_.tables){const S=new Map;for(const T in _.tables){const{connectionName:D,tablePath:I}=_.tables[T],L=S.get(D);L===void 0?S.set(D,{[T]:I}):L[T]=I}for(const[T,D]of S)try{const I=await s.lookupConnection(T),{schemas:L,errors:M}=await iR.safelyFetchTableSchema(I,D,{refreshTimestamp:y,modelAnnotation:C});A.update({tables:L,errors:{tables:M}})}catch(I){const L={},M={};for(const q in D)M[q]=I.toString();A.update({tables:L,errors:{tables:M}})}}if(_.compileSQL){const S=_.compileSQL,T=S.connection,D=(0,hFe.sqlKey)(S.connection,S.selectStr);try{const L=await(await s.lookupConnection(T)).fetchSchemaForSQLStruct(S,{refreshTimestamp:y,modelAnnotation:C});L.error&&A.update({errors:{compileSQL:{[D]:L.error}}}),L.structDef&&A.update({compileSQL:{[D]:L.structDef}})}catch(I){const L={};L[D]=I.toString(),A.update({errors:{compileSQL:L}})}}}}}static async safelyFetchTableSchema(e,n,r){const i=await e.fetchSchemaForTables(n,r);for(const s of Object.keys(n))if(i.schemas[s]===void 0&&i.errors[s]===void 0)throw new Error(`Schema fetch error for ${e.name}, no response for ${s} from ${e.dialectName}`);return i}static async run({connections:e,preparedResult:n,sqlStruct:r,connection:i,options:s}){if(!i){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const o=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName);i=await e.lookupConnection(o)}if(r){const o=await i.runSQL(r.selectStr);return new Qm({structs:[r],sql:r.selectStr,result:o.rows,totalRows:o.totalRows,runStats:o.runStats,lastStageName:r.name,malloy:"",connectionName:r.connection,sourceExplore:"",sourceFilters:[],profilingUrl:o.profilingUrl},{name:"empty_model",exports:[],contents:{},queryList:[],dependencies:{}})}else if(n){const o=await i.runSQL(n.sql,s);return new Qm({...n._rawQuery,result:o.rows,totalRows:o.totalRows,runStats:o.runStats,profilingUrl:o.profilingUrl},n._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:e,preparedResult:n,sqlStruct:r,connection:i,options:s}){if(r===void 0&&n===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const o=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName);if(i===void 0){if(e===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");i=await e.lookupConnection(o)}if(!i.canStream())throw new Error(`Connection '${o}' cannot stream results.`);let u,a;if(r)a=new Os(r),u=r.selectStr;else if(n!==void 0)a=n.resultExplore,u=n.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let l=0;for await(const c of i.runSQLStream(u,s))yield new ax(c,l,a,void 0,void 0),l+=1}static async estimateQueryCost({connections:e,preparedResult:n,sqlStruct:r}){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const i=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName),s=await e.lookupConnection(i);if(r)return await s.estimateQueryCost(r.selectStr);if(n)return await s.estimateQueryCost(n.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}};we.Malloy=pl;class hY extends Error{constructor(e,n=[]){super(e),this.problems=n}}we.MalloyError=hY;let o2=class{constructor(e,n,r,i=()=>{},s=()=>{}){this.modelDef=e,this.problems=n,this.fromSources=r,this._referenceAt=i,this._importAt=s}tagParse(e){return(0,Fn.annotationToTag)(this.modelDef.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this.modelDef.annotation,e)}getReference(e){return this._referenceAt(e)}getImport(e){return this._importAt(e)}getPreparedQueryByName(e){const n=this.modelDef.contents[e];if((n==null?void 0:n.type)==="query")return new u2(n,this.modelDef,this.problems,e);throw new Error("Given query name does not refer to a named query.")}getPreparedQueryByIndex(e){if(e<0)throw new Error(`Invalid index ${e}.`);if(e>=this.modelDef.queryList.length)throw new Error(`Query index ${e} is out of bounds.`);return new u2(this.modelDef.queryList[e],this.modelDef,this.problems)}get preparedQuery(){return this.getPreparedQuery()}getPreparedQuery(){if(this.modelDef.queryList.length===0)throw new Error("Model has no queries.");return new u2(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const n=this.modelDef.contents[e];if((0,Kr.isSourceDef)(n))return new Os(n);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(Kr.isSourceDef).map(e=>new Os(e))}get namedQueries(){const e=n=>n.type==="query";return Object.values(this.modelDef.contents).filter(e)}get exportedExplores(){return this.explores.filter(e=>this.modelDef.exports.includes(e.name))}get _modelDef(){return this.modelDef}};we.Model=o2;class u2{constructor(e,n,r,i){this.problems=r,this.name=i,this._query=e,this._modelDef=n}tagParse(e){const n=(0,Fn.annotationToTag)(this._modelDef.annotation).tag;return e=(0,Fn.addModelScope)(e,n),(0,Fn.annotationToTag)(this._query.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const r=new Kr.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new Hm({...r,queryName:this.name||r.queryName},this._modelDef)}get dialect(){const e=this._query.structRef,n=typeof e=="string"?this._modelDef.contents[e]:e;if(!(0,Kr.isSourceDef)(n))throw new Error("Invalid source for query");return n.dialect}getFlattenedQuery(e){return this}}we.PreparedQuery=u2;class pY{constructor(e,n){this.translator=e,this.invalidationKey=n}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new BS(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(r=>new gY(r))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(n=>new mY(n))}helpContext(e){return this.translator.helpContext(e).helpContext}}we.Parse=pY;class gY{constructor(e){this._range=a2.fromJSON(e.range),this._connectionId=e.connectionId,this._tablePath=e.tablePath}get range(){return this._range}get connectionId(){return this._connectionId}get tablePath(){return this._tablePath}}we.DocumentTablePath=gY;class a2{constructor(e,n){this._start=e,this._end=n}get start(){return this._start}get end(){return this._end}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}static fromJSON(e){return new a2(new fw(e.start.line,e.start.character),new fw(e.end.line,e.end.character))}}we.DocumentRange=a2;class fw{constructor(e,n){this._line=e,this._character=n}get line(){return this._line}get character(){return this._character}toJSON(){return{line:this.line,character:this.character}}}we.DocumentPosition=fw;class BS{constructor(e){this._range=a2.fromJSON(e.range),this._lensRange=e.lensRange?a2.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(n=>new BS(n))}get range(){return this._range}get lensRange(){var e;return(e=this._lensRange)!==null&&e!==void 0?e:this._range}get type(){return this._type}get name(){return this._name}get children(){return this._children}}we.DocumentSymbol=BS;class mY{constructor(e){this.type=e.type,this.text=e.text}}we.DocumentCompletion=mY;class Hm{constructor(e,n){this.modelDef=n,this.inner=e}static fromJson({query:e,modelDef:n}){if(!e||!n)throw new Error("Missing required properties in JSON data");return new Hm(e,n)}tagParse(e){const n=(0,Fn.annotationToTag)(this.modelDef.annotation).tag;return e=(0,Fn.addModelScope)(e,n),(0,Fn.annotationToTag)(this.inner.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return(0,Fn.annotationToTag)(this.modelDef.annotation).tag}get connectionName(){return this.inner.connectionName}get _rawQuery(){return this.inner}get _modelDef(){return this.modelDef}get sql(){return this.inner.sql}get dependenciesToMaterialize(){return this.inner.dependenciesToMaterialize}get materialization(){return this.inner.materialization}get resultExplore(){if(this.inner.structs.length===0)throw new Error("Malformed query result.");const e=this.inner.structs[this.inner.structs.length-1],n={...e,annotation:this.inner.annotation,name:this.inner.queryName||e.name};try{return new Os(n,this.sourceExplore)}catch{return new Os(n)}}get sourceExplore(){const e=this.inner.sourceExplore,n=this.modelDef.contents[e];if(n===void 0)throw new Error("Malformed query result.");if((0,Kr.isSourceDef)(n))return new Os(n);throw new Error(`'${e} is not an explore`)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}we.PreparedResult=Hm;class yY{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}we.EmptyURLReader=yY;class pFe{constructor(e){this.files=e}async readURL(e){const n=this.files.get(e.toString());if(n!==void 0)return Promise.resolve({contents:n,invalidationKey:this.invalidationKey(e,n)});throw new Error(`File not found '${e}'`)}async getInvalidationKey(e){const n=this.files.get(e.toString());if(n!==void 0)return Promise.resolve(this.invalidationKey(e,n));throw new Error(`File not found '${e}'`)}invalidationKey(e,n){return HS(e.toString())?null:LY(n)}}we.InMemoryURLReader=pFe;class $S{constructor(e,n){this.connections=e,this.defaultConnectionName=n}async getConnection(e){if(e===void 0)if(this.defaultConnectionName!==void 0)e=this.defaultConnectionName;else throw new Error("No default connection.");const n=this.connections.get(e);if(n!==void 0)return Promise.resolve(n);throw new Error(`No connection found with name ${e}.`)}listConnections(){return Array.from(this.connections.values())}async lookupConnection(e){return this.getConnection(e)}static fromArray(e){return new $S(new Map(e.map(n=>[n.name,n])))}}we.FixedConnectionMap=$S;var EY;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(EY||(we.SourceRelationship=EY={}));class xw{constructor(e,n,r){this._name=e,this._parent=n,this._source=r}get source(){return this.source}get name(){return this._name}get sourceClasses(){const e=[];return this.source&&e.push(this.source.name),e.push(this.name),e}get fieldPath(){const e=[this.name];let n=this._parent;for(;n;)e.unshift(n.name),n=n._parent;return e}hasParentExplore(){return this._parent!==void 0}isExplore(){return this instanceof Os}isQuery(){return this instanceof Ew}}class Os extends xw{constructor(e,n,r){super(e.as||e.name,n,r),this._structDef=e,this._parentExplore=n,this.sourceExplore=r}get source(){return this.sourceExplore}isIntrinsic(){return(0,Kr.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return(0,Fn.annotationToTag)(this._structDef.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=(0,Fn.annotationToTag)(this._structDef.modelAnnotation).tag),this.parsedModelTag}get name(){return this.structDef.as||this.structDef.name}getQueryByName(e){const n=this.sourceStructDef;if(!n)throw new Error(`Cannot get query by name from a struct of type ${this.structDef.type}`);const r={type:"query",structRef:n,pipeline:[{type:"reduce",queryFields:[{type:"fieldref",path:[e]}]}]};return new u2(r,this.modelDef,[],e)}get modelDef(){if(!(0,Kr.isSourceDef)(this.structDef))throw new Error(`Cannot create pseudo model for struct type ${this.structDef.type}`);return{name:"generated_model",exports:[],contents:{[this.structDef.name]:this.structDef},queryList:[],dependencies:{}}}getSingleExploreModel(){return new o2(this.modelDef,[],[])}get fieldMap(){var e;if(this._fieldMap===void 0){const n=((e=this.source)===null||e===void 0?void 0:e.fieldMap)||new Map;this._fieldMap=new Map(this.structDef.fields.map(r=>{const i=r.as||r.name,s=n.get(r.name);if((0,Kr.isJoined)(r))return[i,new Aw(r,this,s)];if(r.type==="turtle")return[i,new Ew(r,this,s)];if(r.type==="string")return[i,new yw(r,this,s)];if(r.type==="number")return[i,new kS(r,this,s)];if(r.type==="date")return r.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(r.timeframe)?[i,new kS({...r,type:"number"},this,s)]:[i,new dw(r,this,s)];if(r.type==="timestamp")return[i,new hw(r,this,s)];if(r.type==="boolean")return[i,new pw(r,this,s)];if(r.type==="json")return[i,new gw(r,this,s)];if(r.type==="sql native")return[i,new mw(r,this,s)]}))}return this._fieldMap}get allFields(){return[...this.fieldMap.values()]}get allFieldsWithOrder(){var e,n,r;if(!this._allFieldsWithOrder){const i=[...((r=(n=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||n===void 0?void 0:n.orderBy)===null||r===void 0?void 0:r.map(o=>{if(typeof o.field=="string")return{field:this.fieldMap.get(o.field),dir:o.dir};throw new Error("Does not support mapping order by from number.")}))||[]],s=new Set(i.map(o=>o.field.name));this._allFieldsWithOrder=[...i,...this.allFields.filter(o=>!s.has(o.name)).map(o=>({field:o,dir:"asc"}))]}return this._allFieldsWithOrder}get intrinsicFields(){return[...this.fieldMap.values()].filter(e=>e.isIntrinsic())}get dimensions(){return[...this.allFieldsWithOrder].filter(e=>e.field.isAtomicField()&&e.field.sourceWasDimension())}getFieldByName(e){const n=this.fieldMap.get(e);if(n===void 0)throw new Error(`No such field ${e}.`);return n}getFieldByNameIfExists(e){return this.fieldMap.get(e)}get primaryKey(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.primaryKey}get parentExplore(){return this._parentExplore}hasParentExplore(){return this instanceof Aw}get filters(){var e;return(0,Kr.isSourceDef)(this.structDef)?((e=this.structDef.resultMetadata)===null||e===void 0?void 0:e.filterList)||[]:[]}get limit(){var e,n;return(n=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||n===void 0?void 0:n.limit}get structDef(){return this._structDef}get queryTimezone(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.queryTimezone}get sourceStructDef(){if((0,Kr.isSourceDef)(this.structDef))return this.structDef}toJSON(){var e,n;return{_structDef:this._structDef,sourceExplore:(e=this.sourceExplore)===null||e===void 0?void 0:e.toJSON(),_parentExplore:(n=this._parentExplore)===null||n===void 0?void 0:n.toJSON()}}static fromJSON(e){const n=e._parentExplore!==void 0?Os.fromJSON(e._parentExplore):void 0,r=e.sourceExplore!==void 0?Os.fromJSON(e.sourceExplore):void 0;return new Os(e._structDef,n,r)}get location(){return this.structDef.location}}we.Explore=Os;var Vu;(function(t){t.String="string",t.Number="number",t.Boolean="boolean",t.Date="date",t.Timestamp="timestamp",t.Json="json",t.NativeUnsupported="sql native",t.Error="error"})(Vu||(we.AtomicFieldType=Vu={}));class ec extends xw{constructor(e,n,r){super(e.as||e.name,n,r),this.fieldTypeDef=e,this.parent=n}get type(){switch(this.fieldTypeDef.type){case"string":return Vu.String;case"boolean":return Vu.Boolean;case"date":return Vu.Date;case"timestamp":return Vu.Timestamp;case"number":return Vu.Number;case"json":return Vu.Json;case"sql native":return Vu.NativeUnsupported;case"error":return Vu.Error;case"record":case"array":throw new Error(`MTOY TODO IMPLEMENT Atomic ${this.fieldTypeDef.type}`);default:{const e=this.fieldTypeDef;throw new Error(`Can't make an atomic field from ${e}`)}}}tagParse(e){return e=(0,Fn.addModelScope)(e,this.parent.modelTag),(0,Fn.annotationToTag)(this.fieldTypeDef.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,Kr.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,Kr.expressionIsCalculation)(this.fieldTypeDef.expressionType)}get sourceField(){throw new Error}get sourceClasses(){const e=this.fieldTypeDef.name||this.fieldTypeDef.as;return e?[e]:[]}get referenceId(){var e;return(e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.referenceId}sourceWasMeasure(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"}sourceWasMeasureLike(){var e,n;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((n=this.fieldTypeDef.resultMetadata)===null||n===void 0?void 0:n.fieldKind)==="struct"}sourceWasDimension(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="dimension"}hasParentExplore(){return!0}isString(){return this instanceof yw}isNumber(){return this instanceof kS}isDate(){return this instanceof dw}isBoolean(){return this instanceof pw}isJSON(){return this instanceof gw}isTimestamp(){return this instanceof hw}isUnsupported(){return this instanceof mw}get parentExplore(){return this.parent}get expression(){const e=".",n=this.fieldTypeDef.resultMetadata;return(n==null?void 0:n.sourceExpression)||(n!=null&&n.sourceField.includes(e)?n==null?void 0:n.sourceField:this.name)}get location(){return this.fieldTypeDef.location}}we.AtomicField=ec;var ux;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(ux||(we.DateTimeframe=ux={}));var Yu;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year",t.Second="second",t.Hour="hour",t.Minute="minute"})(Yu||(we.TimestampTimeframe=Yu={}));class dw extends ec{constructor(e,n,r){super(e,n,r),this.fieldDateDef=e}get timeframe(){if(this.fieldDateDef.timeframe!==void 0)switch(this.fieldDateDef.timeframe){case"day":return ux.Day;case"week":return ux.Week;case"month":return ux.Month;case"quarter":return ux.Quarter;case"year":return ux.Year}}}we.DateField=dw;class hw extends ec{constructor(e,n,r){super(e,n,r),this.fieldTimestampDef=e}get timeframe(){if(this.fieldTimestampDef.timeframe!==void 0)switch(this.fieldTimestampDef.timeframe){case"day":return Yu.Day;case"week":return Yu.Week;case"month":return Yu.Month;case"quarter":return Yu.Quarter;case"year":return Yu.Year;case"second":return Yu.Second;case"hour":return Yu.Hour;case"minute":return Yu.Minute}}}we.TimestampField=hw;class kS extends ec{constructor(e,n,r){super(e,n,r),this.fieldNumberDef=e}}we.NumberField=kS;class pw extends ec{constructor(e,n,r){super(e,n,r),this.fieldBooleanDef=e}}we.BooleanField=pw;class gw extends ec{constructor(e,n,r){super(e,n,r),this.fieldJSONDef=e}}we.JSONField=gw;class mw extends ec{constructor(e,n,r){super(e,n,r),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}we.UnsupportedField=mw;class yw extends ec{constructor(e,n,r){super(e,n,r),this.fieldStringDef=e}}we.StringField=yw;class AY extends xw{constructor(e,n,r){super(e.as||e.name,n,r),this.turtleDef=e}get source(){return this.sourceQuery}isIntrinsic(){return!1}get location(){return this.turtleDef.location}}we.Query=AY;class Ew extends AY{constructor(e,n,r){super(e,n,r),this.parent=n}tagParse(e){return e=(0,Fn.addModelScope)(e,this.parent.modelTag),(0,Fn.annotationToTag)(this.turtleDef.annotation,e)}getTaglines(e){return(0,Fn.annotationToTaglines)(this.turtleDef.annotation,e)}isQueryField(){return!0}isExploreField(){return!1}isAtomicField(){return!1}get sourceClasses(){const e=this.turtleDef.name||this.turtleDef.as;return e?[e]:[]}hasParentExplore(){return!0}get parentExplore(){return this.parent}get expression(){return this.name}}we.QueryField=Ew;var l2;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(l2||(we.JoinRelationship=l2={}));class Aw extends Os{constructor(e,n,r){super(e,n,r),this._parentExplore=n}get joinRelationship(){if((0,Kr.isJoined)(this.structDef))switch(this.structDef.join){case"one":return l2.OneToOne;case"many":case"cross":return l2.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===l2.OneToOne}get isArray(){return this.joinRelationship!==l2.OneToOne}tagParse(e){return e=(0,Fn.addModelScope)(e,this._parentExplore.modelTag),(0,Fn.annotationToTag)(this._structDef.annotation,e)}isQueryField(){return!1}isExploreField(){return!0}isAtomicField(){return!1}get parentExplore(){return this._parentExplore}get sourceClasses(){const e=this.structDef.name||this.structDef.as;return e?[e]:[]}}we.ExploreField=Aw;class vw{constructor({urlReader:e,connections:n,connection:r,eventStream:i,cacheManager:s}){if(this.isTestRuntime=!1,n===void 0){if(r===void 0)throw new Error("A LookupConnection<Connection> or Connection is required.");n={lookupConnection:()=>Promise.resolve(r)}}e===void 0&&(e=new yY),this._urlReader=e,this._connections=n,this._eventStream=i,this._cacheManager=s}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}loadModel(e,n){const{refreshSchemaCache:r,noThrowOnError:i}=n||{};this.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0});const s=e instanceof URL?{url:e}:{source:e};return new zm(this,async()=>pl.compile({...s,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:r,noThrowOnError:i,eventStream:this.eventStream,replaceMaterializedReferences:n==null?void 0:n.replaceMaterializedReferences,materializedTablePrefix:n==null?void 0:n.materializedTablePrefix,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,cacheManager:this.cacheManager}),n)}_loadModelFromModelDef(e,n){return new zm(this,async()=>new o2(e,[],[]),n)}loadQuery(e,n){return this.loadModel(e,n).loadFinalQuery()}loadQueryByIndex(e,n,r){return this.loadModel(e,r).loadQueryByIndex(n,r)}loadQueryByName(e,n,r){return this.loadModel(e,r).loadQueryByName(n,r)}getModel(e,n){return this.loadModel(e,n).getModel()}getQuery(e,n){return this.loadQuery(e,n).getPreparedQuery()}getQueryByIndex(e,n,r){return this.loadQueryByIndex(e,n,r).getPreparedQuery()}getQueryByName(e,n,r){return this.loadQueryByName(e,n,r).getPreparedQuery()}}we.Runtime=vw;class gFe extends vw{constructor({urlReader:e,connections:n}){super({connections:$S.fromArray(n),urlReader:e}),this.rawConnections=n}}we.ConnectionRuntime=gFe;class mFe extends vw{constructor({urlReader:e,connection:n,eventStream:r,cacheManager:i}){super({urlReader:e,eventStream:r,cacheManager:i,connection:n}),this.connection=n}get supportsNesting(){return(0,cw.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,cw.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,cw.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}we.SingleConnectionRuntime=mFe;class MS{constructor(e,n){this.runtime=e,this._materialize=n}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(e,n){return new vY(this.runtime,e,n)}makeExploreMaterializer(e,n){return new CY(this.runtime,e,n)}makePreparedResultMaterializer(e){return new _Y(this.runtime,e)}}class zm extends MS{constructor(e,n,r){super(e,n),this.runtime=e,this.compileQueryOptions=r}loadFinalQuery(e){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...e})}loadQueryByIndex(e,n){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(e),{...this.compileQueryOptions,...n})}loadQueryByName(e,n){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(e),{...this.compileQueryOptions,...n})}loadQuery(e,n){const{refreshSchemaCache:r,noThrowOnError:i}=n||{};return this.makeQueryMaterializer(async()=>{const s=this.runtime.urlReader,o=this.runtime.connections;this.runtime.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0});const u=e instanceof URL?{url:e}:{source:e},a=await this.getModel();return(await pl.compile({...u,urlReader:s,connections:o,model:a,refreshSchemaCache:r,noThrowOnError:i,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,...this.compileQueryOptions})).preparedQuery})}extendModel(e,n){return this.runtime.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0}),new zm(this.runtime,async()=>{const r=this.runtime.urlReader,i=this.runtime.connections,s=e instanceof URL?{url:e}:{source:e},o=await this.getModel();return await pl.compile({...s,urlReader:r,connections:i,model:o,refreshSchemaCache:n==null?void 0:n.refreshSchemaCache,noThrowOnError:n==null?void 0:n.noThrowOnError,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,...this.compileQueryOptions})},n)}async search(e,n,r=1e3,i=void 0,s){const o=await this.materialize(),u=new Kr.QueryModel(o._modelDef,s),a=o.getExploreByName(e).structDef;if(!(0,Kr.isSourceDef)(a))throw new Error("Source to be searched was unexpectedly, not a source");const l=a.connection,c=await this.runtime.connections.lookupConnection(l);return await u.searchIndex(c,e,n,r,i)}async searchValueMap(e,n=10,r){const s=(await this.materialize()).getExploreByName(e);if(!(0,Kr.isSourceDef)(s.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let o="{index: *}";s.getFieldByNameIfExists("search_index")&&(o="search_index");const u=`
|
|
1276
1276
|
run: ${e}
|
|
1277
1277
|
-> ${o}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/render",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.240-dev250304195705",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/module/index.umd.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"build-types": "tsc --build --declaration --emitDeclarationOnly"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@malloydata/malloy": "^0.0.
|
|
35
|
-
"@malloydata/malloy-tag": "^0.0.
|
|
34
|
+
"@malloydata/malloy": "^0.0.240-dev250304195705",
|
|
35
|
+
"@malloydata/malloy-tag": "^0.0.240-dev250304195705",
|
|
36
36
|
"@tanstack/solid-virtual": "^3.10.4",
|
|
37
37
|
"component-register": "^0.8.6",
|
|
38
38
|
"lodash": "^4.17.20",
|