@malloydata/render 0.0.236 → 0.0.237-dev250221175121
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
|
@@ -53708,7 +53708,7 @@ Md.exploreQueryWalkerBuilder = cRe;
|
|
|
53708
53708
|
var Oe = {}, x4 = {};
|
|
53709
53709
|
Object.defineProperty(x4, "__esModule", { value: !0 });
|
|
53710
53710
|
x4.MALLOY_VERSION = void 0;
|
|
53711
|
-
x4.MALLOY_VERSION = "0.0.
|
|
53711
|
+
x4.MALLOY_VERSION = "0.0.237";
|
|
53712
53712
|
Object.defineProperty(Oe, "__esModule", { value: !0 });
|
|
53713
53713
|
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;
|
|
53714
53714
|
const OU = O8, Kn = hs, DU = Jw, An = bo, M6 = yh, fRe = x4, xRe = zm, NU = "internal://internal.malloy";
|
package/dist/module/index.umd.js
CHANGED
|
@@ -1264,7 +1264,7 @@ QUERY: ${(0,iQ.inspect)(n,{breakLength:72,depth:1/0})}`)}return sQ.ErrorFactory.
|
|
|
1264
1264
|
| ${l}`,u>0&&(i=i+`
|
|
1265
1265
|
| ${" ".repeat(u)}^`)}else i=`line ${o+1}: char ${u}: ${r.message}`}n!==s&&(i=`FILE: ${s}
|
|
1266
1266
|
`+i,n=s),e!==""?e=`${e}
|
|
1267
|
-
${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,partialModel:i.partialModel}}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,k6e.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,G6e.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))}}Pl.MalloyTranslation=o7;class BG extends o7{constructor(e,n){super(e),this.root=n}}Pl.MalloyChildTranslator=BG;class uRe extends o7{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new s7.Zone,this.importZone=new s7.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new s7.Zone,this.root=this,this.logger=new LG.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,LG.makeLogMessage)(e,n,{severity:"error",...r})),e}}Pl.MalloyTranslator=uRe;function $G(t){return[...Object.keys(t),...Object.keys(t).map(e=>$G(t[e])).flat()]}var Kd={};Object.defineProperty(Kd,"__esModule",{value:!0}),Kd.exploreQueryWalkerBuilder=Kd.ExploreQueryWalker=void 0;const aRe=Cl;class kG{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}}Kd.ExploreQueryWalker=kG;function lRe(t,e){const n=new kG(t),r=n;return aRe.ParseTreeWalker.DEFAULT.walk(r,e),n}Kd.exploreQueryWalkerBuilder=lRe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=Pl;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=Kd;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(hR);var Oe={},Q_={};Object.defineProperty(Q_,"__esModule",{value:!0}),Q_.MALLOY_VERSION=void 0,Q_.MALLOY_VERSION="0.0.
|
|
1267
|
+
${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,partialModel:i.partialModel}}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,k6e.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,G6e.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))}}Pl.MalloyTranslation=o7;class BG extends o7{constructor(e,n){super(e),this.root=n}}Pl.MalloyChildTranslator=BG;class uRe extends o7{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new s7.Zone,this.importZone=new s7.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new s7.Zone,this.root=this,this.logger=new LG.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,LG.makeLogMessage)(e,n,{severity:"error",...r})),e}}Pl.MalloyTranslator=uRe;function $G(t){return[...Object.keys(t),...Object.keys(t).map(e=>$G(t[e])).flat()]}var Kd={};Object.defineProperty(Kd,"__esModule",{value:!0}),Kd.exploreQueryWalkerBuilder=Kd.ExploreQueryWalker=void 0;const aRe=Cl;class kG{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}}Kd.ExploreQueryWalker=kG;function lRe(t,e){const n=new kG(t),r=n;return aRe.ParseTreeWalker.DEFAULT.walk(r,e),n}Kd.exploreQueryWalkerBuilder=lRe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=Pl;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=Kd;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(hR);var Oe={},Q_={};Object.defineProperty(Q_,"__esModule",{value:!0}),Q_.MALLOY_VERSION=void 0,Q_.MALLOY_VERSION="0.0.237",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 PG=hR,Xn=Qi,MG=sD,vn=Js,u7=Cx,cRe=Q_,fRe=O2,UG="internal://internal.malloy";class Ri{static get version(){return cRe.MALLOY_VERSION}static _parse(e,n,r,i,s){n===void 0&&(n=new URL(UG));let o=n;i!=null&&i.importBaseURL&&(o=i==null?void 0:i.importBaseURL);const u=new PG.MalloyTranslator(n.toString(),o.toString(),{urls:{[n.toString()]:e}},r);return i!=null&&i.testEnvironment&&(u.allDialectsEnabled=!0),new qG(u,s)}static parse({url:e,urlReader:n,source:r,eventStream:i,options:s}){if(r!==void 0)return Ri._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 Z_(n,e).then(({contents:o,invalidationKey:u})=>Ri._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,replaceMaterializedReferences:c,materializedTablePrefix:f,importBaseURL:d,cacheManager:h}){var p,g,m,y,E;let A;if(u&&(A=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(UG));const v={};if(n===void 0&&h!==void 0){const C=await h.getCachedModelDef(i,e.toString());if(C)return new Jd(C.modelDef,[],[e.toString(),...X_(C.modelDef.dependencies)])}d??(d=e);let _;const S=e.toString();if(r!==void 0){_=r._translator;const C=(p=r._invalidationKey)!==null&&p!==void 0?p:await A7(i,e);v[S]=C}else{if(n===void 0){const{contents:C,invalidationKey:b}=await Z_(i,e);v[S]=b,n=C}else{const C=await A7(i,e);v[S]=C}_=new PG.MalloyTranslator(S,d.toString(),{urls:{[S]:n}},l)}for(;;){const C=_.translate(o==null?void 0:o._modelDef);if(C.final)if(C.modelDef){await(h==null?void 0:h.setCachedModelDef(e.toString(),{modelDef:C.modelDef,invalidationKeys:v}));for(const b of _.newlyTranslatedDependencies())await(h==null?void 0:h.setCachedModelDef(b.url,{modelDef:b.modelDef,invalidationKeys:v}));return new Jd(C.modelDef,C.problems||[],[...(g=o==null?void 0:o.fromSources)!==null&&g!==void 0?g:[],...(m=C.fromSources)!==null&&m!==void 0?m:[]],b=>_.referenceAt(b),b=>_.importAt(b))}else if(a){const b={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},R=(o==null?void 0:o._modelDef)||b;return new Jd(R,C.problems||[],[...(y=o==null?void 0:o.fromSources)!==null&&y!==void 0?y:[],...(E=C.fromSources)!==null&&E!==void 0?E:[]],N=>_.referenceAt(N),N=>_.importAt(N))}else{const b=C.problems||[],R=_.prettyErrors();throw new jG(`Error(s) compiling model:
|
|
1268
1268
|
${R}`,b)}else{if(C.urls)for(const R of C.urls)try{if(e5(R))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(h!==void 0){const q=await h.getCachedModelDef(i,R);if(q){for(const J in q.invalidationKeys)v[J]=q.invalidationKeys[J];_.update({translations:{[R]:q.modelDef}});continue}}const{contents:N,invalidationKey:I}=await Z_(i,new URL(R)),P={[R]:N};v[R]=I,_.update({urls:P})}catch(N){_.update({errors:{urls:{[R]:N.message}}})}const{modelAnnotation:b}=_.modelAnnotation(o==null?void 0:o._modelDef);if(C.tables){const R=new Map;for(const N in C.tables){const{connectionName:I,tablePath:P}=C.tables[N],q=R.get(I);q===void 0?R.set(I,{[N]:P}):q[N]=P}for(const[N,I]of R)try{const P=await s.lookupConnection(N),{schemas:q,errors:J}=await Ri.safelyFetchTableSchema(P,I,{refreshTimestamp:A,modelAnnotation:b});_.update({tables:q,errors:{tables:J}})}catch(P){const q={},J={};for(const W in I)J[W]=P.toString();_.update({tables:q,errors:{tables:J}})}}if(C.compileSQL){const R=C.compileSQL,N=R.connection;try{const I=await s.lookupConnection(N),P=Ri.compileSQLBlock(I.dialectName,C.partialModel,R,{replaceMaterializedReferences:c,materializedTablePrefix:f,eventStream:l}),q=await I.fetchSchemaForSQLStruct(P,{refreshTimestamp:A,modelAnnotation:b});q.error&&_.update({errors:{compileSQL:{[P.name]:q.error}}}),q.structDef&&_.update({compileSQL:{[P.name]:q.structDef}})}catch(I){const P={};P[R.name]=I.toString(),_.update({errors:{compileSQL:P}})}}}}}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 compileSQLBlock(e,n,r,i){let s,o="",u=!1;for(const c of r.select)if((0,Xn.isSegmentSQL)(c))o+=c.sql,u=c.sql.match(/\(\s*$/)!==null;else{if(!s){if(!n)throw new Error("Internal error: Partial model missing when compiling SQL block");s=new Xn.QueryModel(n,i==null?void 0:i.eventStream)}const f=s.compileQuery(c,{...i,defaultRowLimit:void 0},!1).sql;o+=u?f:`(${f})`,u=!1}const{name:a,connection:l}=r;return{type:"sql_select",name:a,connection:l,dialect:e,selectStr:o,fields:[]}}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 Sm({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 Sm({...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 ss(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 cf(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=Ri;class jG extends Error{constructor(e,n=[]){super(e),this.problems=n}}Oe.MalloyError=jG;let Jd=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 vn.Tag.annotationToTag(this.modelDef.annotation,e)}getTaglines(e){return vn.Tag.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 Xd(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 Xd(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 Xd(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const n=this.modelDef.contents[e];if((0,Xn.isSourceDef)(n))return new ss(n);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(Xn.isSourceDef).map(e=>new ss(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=Jd;class Xd{constructor(e,n,r,i){this.problems=r,this.name=i,this._query=e,this._modelDef=n}tagParse(e){const n=vn.Tag.annotationToTag(this._modelDef.annotation).tag;return e=vn.Tag.addModelScope(e,n),vn.Tag.annotationToTag(this._query.annotation,e)}getTaglines(e){return vn.Tag.annotationToTaglines(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const r=new Xn.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new _m({...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,Xn.isSourceDef)(n))throw new Error("Invalid source for query");return n.dialect}getFlattenedQuery(e){return this}}Oe.PreparedQuery=Xd;class qG{constructor(e,n){this.translator=e,this.invalidationKey=n}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new G_(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(r=>new HG(r))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(n=>new zG(n))}helpContext(e){return this.translator.helpContext(e).helpContext}}Oe.Parse=qG;class HG{constructor(e){this._range=Zd.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=HG;class Zd{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 Zd(new a7(e.start.line,e.start.character),new a7(e.end.line,e.end.character))}}Oe.DocumentRange=Zd;class a7{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=a7;class G_{constructor(e){this._range=Zd.fromJSON(e.range),this._lensRange=e.lensRange?Zd.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(n=>new G_(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=G_;class zG{constructor(e){this.type=e.type,this.text=e.text}}Oe.DocumentCompletion=zG;class _m{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 _m(e,n)}tagParse(e){const n=vn.Tag.annotationToTag(this.modelDef.annotation).tag;return e=vn.Tag.addModelScope(e,n),vn.Tag.annotationToTag(this.inner.annotation,e)}getTaglines(e){return vn.Tag.annotationToTaglines(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return vn.Tag.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 ss(n,this.sourceExplore)}catch{return new ss(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,Xn.isSourceDef)(n))return new ss(n);throw new Error(`'${e} is not an explore`)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}Oe.PreparedResult=_m;class QG{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}Oe.EmptyURLReader=QG;class xRe{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 e5(e.toString())?null:oW(n)}}Oe.InMemoryURLReader=xRe;class W_{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 W_(new Map(e.map(n=>[n.name,n])))}}Oe.FixedConnectionMap=W_;var GG;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(GG||(Oe.SourceRelationship=GG={}));class l7{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 ss}isQuery(){return this instanceof m7}}class ss extends l7{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,Xn.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return vn.Tag.annotationToTag(this._structDef.annotation,e)}getTaglines(e){return vn.Tag.annotationToTaglines(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=vn.Tag.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 Xd(r,this.modelDef,[],e)}get modelDef(){if(!(0,Xn.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 Jd(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,Xn.isJoined)(r))return[i,new g7(r,this,s)];if(r.type==="turtle")return[i,new m7(r,this,s)];if(r.type==="string")return[i,new p7(r,this,s)];if(r.type==="number")return[i,new V_(r,this,s)];if(r.type==="date")return r.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(r.timeframe)?[i,new V_({...r,type:"number"},this,s)]:[i,new c7(r,this,s)];if(r.type==="timestamp")return[i,new f7(r,this,s)];if(r.type==="boolean")return[i,new x7(r,this,s)];if(r.type==="json")return[i,new d7(r,this,s)];if(r.type==="sql native")return[i,new h7(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 g7}get filters(){var e;return(0,Xn.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,Xn.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?ss.fromJSON(e._parentExplore):void 0,r=e.sourceExplore!==void 0?ss.fromJSON(e.sourceExplore):void 0;return new ss(e._structDef,n,r)}get location(){return this.structDef.location}}Oe.Explore=ss;var pu;(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"})(pu||(Oe.AtomicFieldType=pu={}));class u0 extends l7{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 pu.String;case"boolean":return pu.Boolean;case"date":return pu.Date;case"timestamp":return pu.Timestamp;case"number":return pu.Number;case"json":return pu.Json;case"sql native":return pu.NativeUnsupported;case"error":return pu.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=vn.Tag.addModelScope(e,this.parent.modelTag),vn.Tag.annotationToTag(this.fieldTypeDef.annotation,e)}getTaglines(e){return vn.Tag.annotationToTaglines(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,Xn.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,Xn.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 p7}isNumber(){return this instanceof V_}isDate(){return this instanceof c7}isBoolean(){return this instanceof x7}isJSON(){return this instanceof d7}isTimestamp(){return this instanceof f7}isUnsupported(){return this instanceof h7}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=u0;var lf;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(lf||(Oe.DateTimeframe=lf={}));var mu;(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"})(mu||(Oe.TimestampTimeframe=mu={}));class c7 extends u0{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 lf.Day;case"week":return lf.Week;case"month":return lf.Month;case"quarter":return lf.Quarter;case"year":return lf.Year}}}Oe.DateField=c7;class f7 extends u0{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 mu.Day;case"week":return mu.Week;case"month":return mu.Month;case"quarter":return mu.Quarter;case"year":return mu.Year;case"second":return mu.Second;case"hour":return mu.Hour;case"minute":return mu.Minute}}}Oe.TimestampField=f7;class V_ extends u0{constructor(e,n,r){super(e,n,r),this.fieldNumberDef=e}}Oe.NumberField=V_;class x7 extends u0{constructor(e,n,r){super(e,n,r),this.fieldBooleanDef=e}}Oe.BooleanField=x7;class d7 extends u0{constructor(e,n,r){super(e,n,r),this.fieldJSONDef=e}}Oe.JSONField=d7;class h7 extends u0{constructor(e,n,r){super(e,n,r),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}Oe.UnsupportedField=h7;class p7 extends u0{constructor(e,n,r){super(e,n,r),this.fieldStringDef=e}}Oe.StringField=p7;class WG extends l7{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=WG;class m7 extends WG{constructor(e,n,r){super(e,n,r),this.parent=n}tagParse(e){return e=vn.Tag.addModelScope(e,this.parent.modelTag),vn.Tag.annotationToTag(this.turtleDef.annotation,e)}getTaglines(e){return vn.Tag.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=m7;var eh;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(eh||(Oe.JoinRelationship=eh={}));class g7 extends ss{constructor(e,n,r){super(e,n,r),this._parentExplore=n}get joinRelationship(){if((0,Xn.isJoined)(this.structDef))switch(this.structDef.join){case"one":return eh.OneToOne;case"many":case"cross":return eh.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===eh.OneToOne}get isArray(){return this.joinRelationship!==eh.OneToOne}tagParse(e){return e=vn.Tag.addModelScope(e,this._parentExplore.modelTag),vn.Tag.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=g7;class y7{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 QG),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 Cm(this,async()=>Ri.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 Cm(this,async()=>new Jd(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=y7;class dRe extends y7{constructor({urlReader:e,connections:n}){super({connections:W_.fromArray(n),urlReader:e}),this.rawConnections=n}}Oe.ConnectionRuntime=dRe;class hRe extends y7{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,u7.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,u7.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,u7.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}Oe.SingleConnectionRuntime=hRe;class Y_{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 VG(this.runtime,e,n)}makeExploreMaterializer(e,n){return new KG(this.runtime,e,n)}makePreparedResultMaterializer(e){return new YG(this.runtime,e)}}class Cm extends Y_{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 Ri.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 Cm(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 Ri.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 Xn.QueryModel(o._modelDef,s),a=o.getExploreByName(e).structDef;if(!(0,Xn.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,Xn.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=`
|
|
1269
1269
|
run: ${e}
|
|
1270
1270
|
-> ${o}
|
|
@@ -54813,7 +54813,7 @@ Ah.exploreQueryWalkerBuilder = oDe;
|
|
|
54813
54813
|
var we = {}, W4 = {};
|
|
54814
54814
|
Object.defineProperty(W4, "__esModule", { value: !0 });
|
|
54815
54815
|
W4.MALLOY_VERSION = void 0;
|
|
54816
|
-
W4.MALLOY_VERSION = "0.0.
|
|
54816
|
+
W4.MALLOY_VERSION = "0.0.237";
|
|
54817
54817
|
Object.defineProperty(we, "__esModule", { value: !0 });
|
|
54818
54818
|
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;
|
|
54819
54819
|
const cj = r8, tr = Cs, fj = bi, Sn = Uo, C6 = t2, uDe = W4, aDe = Fm, xj = "internal://internal.malloy";
|
|
@@ -1264,7 +1264,7 @@ QUERY: ${(0,ZQ.inspect)(n,{breakLength:72,depth:1/0})}`)}return eG.ErrorFactory.
|
|
|
1264
1264
|
| ${l}`,u>0&&(i=i+`
|
|
1265
1265
|
| ${" ".repeat(u)}^`)}else i=`line ${o+1}: char ${u}: ${r.message}`}n!==s&&(i=`FILE: ${s}
|
|
1266
1266
|
`+i,n=s),e!==""?e=`${e}
|
|
1267
|
-
${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,partialModel:i.partialModel}}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,FOe.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,jOe.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))}}o0.MalloyTranslation=Z7;class wW extends Z7{constructor(e,n){super(e),this.root=n}}o0.MalloyChildTranslator=wW;class nDe extends Z7{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new X7.Zone,this.importZone=new X7.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new X7.Zone,this.root=this,this.logger=new OW.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,OW.makeLogMessage)(e,n,{severity:"error",...r})),e}}o0.MalloyTranslator=nDe;function NW(t){return[...Object.keys(t),...Object.keys(t).map(e=>NW(t[e])).flat()]}var Rh={};Object.defineProperty(Rh,"__esModule",{value:!0}),Rh.exploreQueryWalkerBuilder=Rh.ExploreQueryWalker=void 0;const rDe=Ql;class FW{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}}Rh.ExploreQueryWalker=FW;function iDe(t,e){const n=new FW(t),r=n;return rDe.ParseTreeWalker.DEFAULT.walk(r,e),n}Rh.exploreQueryWalkerBuilder=iDe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=o0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=Rh;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(aO);var we={},qS={};Object.defineProperty(qS,"__esModule",{value:!0}),qS.MALLOY_VERSION=void 0,qS.MALLOY_VERSION="0.0.
|
|
1267
|
+
${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,partialModel:i.partialModel}}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,FOe.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,jOe.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))}}o0.MalloyTranslation=Z7;class wW extends Z7{constructor(e,n){super(e),this.root=n}}o0.MalloyChildTranslator=wW;class nDe extends Z7{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new X7.Zone,this.importZone=new X7.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new X7.Zone,this.root=this,this.logger=new OW.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,OW.makeLogMessage)(e,n,{severity:"error",...r})),e}}o0.MalloyTranslator=nDe;function NW(t){return[...Object.keys(t),...Object.keys(t).map(e=>NW(t[e])).flat()]}var Rh={};Object.defineProperty(Rh,"__esModule",{value:!0}),Rh.exploreQueryWalkerBuilder=Rh.ExploreQueryWalker=void 0;const rDe=Ql;class FW{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}}Rh.ExploreQueryWalker=FW;function iDe(t,e){const n=new FW(t),r=n;return rDe.ParseTreeWalker.DEFAULT.walk(r,e),n}Rh.exploreQueryWalkerBuilder=iDe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=o0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=Rh;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(aO);var we={},qS={};Object.defineProperty(qS,"__esModule",{value:!0}),qS.MALLOY_VERSION=void 0,qS.MALLOY_VERSION="0.0.237",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 LW=aO,rr=ts,IW=ri,Cn=fo,ew=ed,sDe=qS,oDe=hp,BW="internal://internal.malloy";class Ii{static get version(){return sDe.MALLOY_VERSION}static _parse(e,n,r,i,s){n===void 0&&(n=new URL(BW));let o=n;i!=null&&i.importBaseURL&&(o=i==null?void 0:i.importBaseURL);const u=new LW.MalloyTranslator(n.toString(),o.toString(),{urls:{[n.toString()]:e}},r);return i!=null&&i.testEnvironment&&(u.allDialectsEnabled=!0),new kW(u,s)}static parse({url:e,urlReader:n,source:r,eventStream:i,options:s}){if(r!==void 0)return Ii._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 KS(n,e).then(({contents:o,invalidationKey:u})=>Ii._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,replaceMaterializedReferences:c,materializedTablePrefix:f,importBaseURL:d,cacheManager:h}){var p,m,g,y,E;let A;if(u&&(A=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(BW));const v={};if(n===void 0&&h!==void 0){const C=await h.getCachedModelDef(i,e.toString());if(C)return new Oh(C.modelDef,[],[e.toString(),...YS(C.modelDef.dependencies)])}d??(d=e);let _;const S=e.toString();if(r!==void 0){_=r._translator;const C=(p=r._invalidationKey)!==null&&p!==void 0?p:await dw(i,e);v[S]=C}else{if(n===void 0){const{contents:C,invalidationKey:b}=await KS(i,e);v[S]=b,n=C}else{const C=await dw(i,e);v[S]=C}_=new LW.MalloyTranslator(S,d.toString(),{urls:{[S]:n}},l)}for(;;){const C=_.translate(o==null?void 0:o._modelDef);if(C.final)if(C.modelDef){await(h==null?void 0:h.setCachedModelDef(e.toString(),{modelDef:C.modelDef,invalidationKeys:v}));for(const b of _.newlyTranslatedDependencies())await(h==null?void 0:h.setCachedModelDef(b.url,{modelDef:b.modelDef,invalidationKeys:v}));return new Oh(C.modelDef,C.problems||[],[...(m=o==null?void 0:o.fromSources)!==null&&m!==void 0?m:[],...(g=C.fromSources)!==null&&g!==void 0?g:[]],b=>_.referenceAt(b),b=>_.importAt(b))}else if(a){const b={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},w=(o==null?void 0:o._modelDef)||b;return new Oh(w,C.problems||[],[...(y=o==null?void 0:o.fromSources)!==null&&y!==void 0?y:[],...(E=C.fromSources)!==null&&E!==void 0?E:[]],F=>_.referenceAt(F),F=>_.importAt(F))}else{const b=C.problems||[],w=_.prettyErrors();throw new $W(`Error(s) compiling model:
|
|
1268
1268
|
${w}`,b)}else{if(C.urls)for(const w of C.urls)try{if(JS(w))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(h!==void 0){const U=await h.getCachedModelDef(i,w);if(U){for(const J in U.invalidationKeys)v[J]=U.invalidationKeys[J];_.update({translations:{[w]:U.modelDef}});continue}}const{contents:F,invalidationKey:I}=await KS(i,new URL(w)),M={[w]:F};v[w]=I,_.update({urls:M})}catch(F){_.update({errors:{urls:{[w]:F.message}}})}const{modelAnnotation:b}=_.modelAnnotation(o==null?void 0:o._modelDef);if(C.tables){const w=new Map;for(const F in C.tables){const{connectionName:I,tablePath:M}=C.tables[F],U=w.get(I);U===void 0?w.set(I,{[F]:M}):U[F]=M}for(const[F,I]of w)try{const M=await s.lookupConnection(F),{schemas:U,errors:J}=await Ii.safelyFetchTableSchema(M,I,{refreshTimestamp:A,modelAnnotation:b});_.update({tables:U,errors:{tables:J}})}catch(M){const U={},J={};for(const Q in I)J[Q]=M.toString();_.update({tables:U,errors:{tables:J}})}}if(C.compileSQL){const w=C.compileSQL,F=w.connection;try{const I=await s.lookupConnection(F),M=Ii.compileSQLBlock(I.dialectName,C.partialModel,w,{replaceMaterializedReferences:c,materializedTablePrefix:f,eventStream:l}),U=await I.fetchSchemaForSQLStruct(M,{refreshTimestamp:A,modelAnnotation:b});U.error&&_.update({errors:{compileSQL:{[M.name]:U.error}}}),U.structDef&&_.update({compileSQL:{[M.name]:U.structDef}})}catch(I){const M={};M[w.name]=I.toString(),_.update({errors:{compileSQL:M}})}}}}}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 compileSQLBlock(e,n,r,i){let s,o="",u=!1;for(const c of r.select)if((0,rr.isSegmentSQL)(c))o+=c.sql,u=c.sql.match(/\(\s*$/)!==null;else{if(!s){if(!n)throw new Error("Internal error: Partial model missing when compiling SQL block");s=new rr.QueryModel(n,i==null?void 0:i.eventStream)}const f=s.compileQuery(c,{...i,defaultRowLimit:void 0},!1).sql;o+=u?f:`(${f})`,u=!1}const{name:a,connection:l}=r;return{type:"sql_select",name:a,connection:l,dialect:e,selectStr:o,fields:[]}}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 cm({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 cm({...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 ps(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 If(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=Ii;class $W extends Error{constructor(e,n=[]){super(e),this.problems=n}}we.MalloyError=$W;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 Cn.Tag.annotationToTag(this.modelDef.annotation,e)}getTaglines(e){return Cn.Tag.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 Dh(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 Dh(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 Dh(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const n=this.modelDef.contents[e];if((0,rr.isSourceDef)(n))return new ps(n);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(rr.isSourceDef).map(e=>new ps(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=Oh;class Dh{constructor(e,n,r,i){this.problems=r,this.name=i,this._query=e,this._modelDef=n}tagParse(e){const n=Cn.Tag.annotationToTag(this._modelDef.annotation).tag;return e=Cn.Tag.addModelScope(e,n),Cn.Tag.annotationToTag(this._query.annotation,e)}getTaglines(e){return Cn.Tag.annotationToTaglines(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const r=new rr.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new am({...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,rr.isSourceDef)(n))throw new Error("Invalid source for query");return n.dialect}getFlattenedQuery(e){return this}}we.PreparedQuery=Dh;class kW{constructor(e,n){this.translator=e,this.invalidationKey=n}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new HS(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(r=>new MW(r))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(n=>new PW(n))}helpContext(e){return this.translator.helpContext(e).helpContext}}we.Parse=kW;class MW{constructor(e){this._range=wh.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=MW;class wh{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 wh(new tw(e.start.line,e.start.character),new tw(e.end.line,e.end.character))}}we.DocumentRange=wh;class tw{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=tw;class HS{constructor(e){this._range=wh.fromJSON(e.range),this._lensRange=e.lensRange?wh.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(n=>new HS(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=HS;class PW{constructor(e){this.type=e.type,this.text=e.text}}we.DocumentCompletion=PW;class am{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 am(e,n)}tagParse(e){const n=Cn.Tag.annotationToTag(this.modelDef.annotation).tag;return e=Cn.Tag.addModelScope(e,n),Cn.Tag.annotationToTag(this.inner.annotation,e)}getTaglines(e){return Cn.Tag.annotationToTaglines(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return Cn.Tag.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 ps(n,this.sourceExplore)}catch{return new ps(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,rr.isSourceDef)(n))return new ps(n);throw new Error(`'${e} is not an explore`)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}we.PreparedResult=am;class UW{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}we.EmptyURLReader=UW;class uDe{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 JS(e.toString())?null:tV(n)}}we.InMemoryURLReader=uDe;class zS{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 zS(new Map(e.map(n=>[n.name,n])))}}we.FixedConnectionMap=zS;var jW;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(jW||(we.SourceRelationship=jW={}));class nw{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 ps}isQuery(){return this instanceof lw}}class ps extends nw{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,rr.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return Cn.Tag.annotationToTag(this._structDef.annotation,e)}getTaglines(e){return Cn.Tag.annotationToTaglines(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=Cn.Tag.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 Dh(r,this.modelDef,[],e)}get modelDef(){if(!(0,rr.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,rr.isJoined)(r))return[i,new cw(r,this,s)];if(r.type==="turtle")return[i,new lw(r,this,s)];if(r.type==="string")return[i,new aw(r,this,s)];if(r.type==="number")return[i,new QS(r,this,s)];if(r.type==="date")return r.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(r.timeframe)?[i,new QS({...r,type:"number"},this,s)]:[i,new rw(r,this,s)];if(r.type==="timestamp")return[i,new iw(r,this,s)];if(r.type==="boolean")return[i,new sw(r,this,s)];if(r.type==="json")return[i,new ow(r,this,s)];if(r.type==="sql native")return[i,new uw(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 cw}get filters(){var e;return(0,rr.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,rr.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?ps.fromJSON(e._parentExplore):void 0,r=e.sourceExplore!==void 0?ps.fromJSON(e.sourceExplore):void 0;return new ps(e._structDef,n,r)}get location(){return this.structDef.location}}we.Explore=ps;var Nu;(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"})(Nu||(we.AtomicFieldType=Nu={}));class D0 extends nw{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 Nu.String;case"boolean":return Nu.Boolean;case"date":return Nu.Date;case"timestamp":return Nu.Timestamp;case"number":return Nu.Number;case"json":return Nu.Json;case"sql native":return Nu.NativeUnsupported;case"error":return Nu.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=Cn.Tag.addModelScope(e,this.parent.modelTag),Cn.Tag.annotationToTag(this.fieldTypeDef.annotation,e)}getTaglines(e){return Cn.Tag.annotationToTaglines(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,rr.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,rr.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 aw}isNumber(){return this instanceof QS}isDate(){return this instanceof rw}isBoolean(){return this instanceof sw}isJSON(){return this instanceof ow}isTimestamp(){return this instanceof iw}isUnsupported(){return this instanceof uw}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=D0;var Lf;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(Lf||(we.DateTimeframe=Lf={}));var Fu;(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"})(Fu||(we.TimestampTimeframe=Fu={}));class rw extends D0{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 Lf.Day;case"week":return Lf.Week;case"month":return Lf.Month;case"quarter":return Lf.Quarter;case"year":return Lf.Year}}}we.DateField=rw;class iw extends D0{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 Fu.Day;case"week":return Fu.Week;case"month":return Fu.Month;case"quarter":return Fu.Quarter;case"year":return Fu.Year;case"second":return Fu.Second;case"hour":return Fu.Hour;case"minute":return Fu.Minute}}}we.TimestampField=iw;class QS extends D0{constructor(e,n,r){super(e,n,r),this.fieldNumberDef=e}}we.NumberField=QS;class sw extends D0{constructor(e,n,r){super(e,n,r),this.fieldBooleanDef=e}}we.BooleanField=sw;class ow extends D0{constructor(e,n,r){super(e,n,r),this.fieldJSONDef=e}}we.JSONField=ow;class uw extends D0{constructor(e,n,r){super(e,n,r),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}we.UnsupportedField=uw;class aw extends D0{constructor(e,n,r){super(e,n,r),this.fieldStringDef=e}}we.StringField=aw;class qW extends nw{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=qW;class lw extends qW{constructor(e,n,r){super(e,n,r),this.parent=n}tagParse(e){return e=Cn.Tag.addModelScope(e,this.parent.modelTag),Cn.Tag.annotationToTag(this.turtleDef.annotation,e)}getTaglines(e){return Cn.Tag.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=lw;var Nh;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(Nh||(we.JoinRelationship=Nh={}));class cw extends ps{constructor(e,n,r){super(e,n,r),this._parentExplore=n}get joinRelationship(){if((0,rr.isJoined)(this.structDef))switch(this.structDef.join){case"one":return Nh.OneToOne;case"many":case"cross":return Nh.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===Nh.OneToOne}get isArray(){return this.joinRelationship!==Nh.OneToOne}tagParse(e){return e=Cn.Tag.addModelScope(e,this._parentExplore.modelTag),Cn.Tag.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=cw;class fw{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 UW),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 lm(this,async()=>Ii.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 lm(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()}}we.Runtime=fw;class aDe extends fw{constructor({urlReader:e,connections:n}){super({connections:zS.fromArray(n),urlReader:e}),this.rawConnections=n}}we.ConnectionRuntime=aDe;class lDe extends fw{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,ew.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,ew.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,ew.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}we.SingleConnectionRuntime=lDe;class GS{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 HW(this.runtime,e,n)}makeExploreMaterializer(e,n){return new QW(this.runtime,e,n)}makePreparedResultMaterializer(e){return new zW(this.runtime,e)}}class lm extends GS{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 Ii.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 lm(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 Ii.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 rr.QueryModel(o._modelDef,s),a=o.getExploreByName(e).structDef;if(!(0,rr.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,rr.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=`
|
|
1269
1269
|
run: ${e}
|
|
1270
1270
|
-> ${o}
|
|
@@ -54813,7 +54813,7 @@ Ah.exploreQueryWalkerBuilder = oDe;
|
|
|
54813
54813
|
var we = {}, W4 = {};
|
|
54814
54814
|
Object.defineProperty(W4, "__esModule", { value: !0 });
|
|
54815
54815
|
W4.MALLOY_VERSION = void 0;
|
|
54816
|
-
W4.MALLOY_VERSION = "0.0.
|
|
54816
|
+
W4.MALLOY_VERSION = "0.0.237";
|
|
54817
54817
|
Object.defineProperty(we, "__esModule", { value: !0 });
|
|
54818
54818
|
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;
|
|
54819
54819
|
const cj = r8, tr = Cs, fj = bi, Sn = Uo, C6 = t2, uDe = W4, aDe = Fm, xj = "internal://internal.malloy";
|
|
@@ -1264,7 +1264,7 @@ QUERY: ${(0,XQ.inspect)(n,{breakLength:72,depth:1/0})}`)}return ZQ.ErrorFactory.
|
|
|
1264
1264
|
| ${l}`,u>0&&(i=i+`
|
|
1265
1265
|
| ${" ".repeat(u)}^`)}else i=`line ${o+1}: char ${u}: ${r.message}`}n!==s&&(i=`FILE: ${s}
|
|
1266
1266
|
`+i,n=s),e!==""?e=`${e}
|
|
1267
|
-
${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,partialModel:i.partialModel}}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,FOe.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,jOe.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))}}o0.MalloyTranslation=X7;class DW extends X7{constructor(e,n){super(e),this.root=n}}o0.MalloyChildTranslator=DW;class nDe extends X7{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new J7.Zone,this.importZone=new J7.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new J7.Zone,this.root=this,this.logger=new RW.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,RW.makeLogMessage)(e,n,{severity:"error",...r})),e}}o0.MalloyTranslator=nDe;function wW(t){return[...Object.keys(t),...Object.keys(t).map(e=>wW(t[e])).flat()]}var Rh={};Object.defineProperty(Rh,"__esModule",{value:!0}),Rh.exploreQueryWalkerBuilder=Rh.ExploreQueryWalker=void 0;const rDe=Ql;class NW{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}}Rh.ExploreQueryWalker=NW;function iDe(t,e){const n=new NW(t),r=n;return rDe.ParseTreeWalker.DEFAULT.walk(r,e),n}Rh.exploreQueryWalkerBuilder=iDe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=o0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=Rh;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(uO);var we={},jS={};Object.defineProperty(jS,"__esModule",{value:!0}),jS.MALLOY_VERSION=void 0,jS.MALLOY_VERSION="0.0.
|
|
1267
|
+
${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,partialModel:i.partialModel}}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,FOe.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,jOe.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))}}o0.MalloyTranslation=X7;class DW extends X7{constructor(e,n){super(e),this.root=n}}o0.MalloyChildTranslator=DW;class nDe extends X7{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new J7.Zone,this.importZone=new J7.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new J7.Zone,this.root=this,this.logger=new RW.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,RW.makeLogMessage)(e,n,{severity:"error",...r})),e}}o0.MalloyTranslator=nDe;function wW(t){return[...Object.keys(t),...Object.keys(t).map(e=>wW(t[e])).flat()]}var Rh={};Object.defineProperty(Rh,"__esModule",{value:!0}),Rh.exploreQueryWalkerBuilder=Rh.ExploreQueryWalker=void 0;const rDe=Ql;class NW{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}}Rh.ExploreQueryWalker=NW;function iDe(t,e){const n=new NW(t),r=n;return rDe.ParseTreeWalker.DEFAULT.walk(r,e),n}Rh.exploreQueryWalkerBuilder=iDe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=o0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=Rh;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(uO);var we={},jS={};Object.defineProperty(jS,"__esModule",{value:!0}),jS.MALLOY_VERSION=void 0,jS.MALLOY_VERSION="0.0.237",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 FW=uO,rr=ts,LW=ri,Cn=fo,Z7=ed,sDe=jS,oDe=xp,IW="internal://internal.malloy";class Ii{static get version(){return sDe.MALLOY_VERSION}static _parse(e,n,r,i,s){n===void 0&&(n=new URL(IW));let o=n;i!=null&&i.importBaseURL&&(o=i==null?void 0:i.importBaseURL);const u=new FW.MalloyTranslator(n.toString(),o.toString(),{urls:{[n.toString()]:e}},r);return i!=null&&i.testEnvironment&&(u.allDialectsEnabled=!0),new $W(u,s)}static parse({url:e,urlReader:n,source:r,eventStream:i,options:s}){if(r!==void 0)return Ii._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 YS(n,e).then(({contents:o,invalidationKey:u})=>Ii._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,replaceMaterializedReferences:c,materializedTablePrefix:f,importBaseURL:d,cacheManager:h}){var p,m,g,y,E;let A;if(u&&(A=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(IW));const v={};if(n===void 0&&h!==void 0){const C=await h.getCachedModelDef(i,e.toString());if(C)return new Oh(C.modelDef,[],[e.toString(),...VS(C.modelDef.dependencies)])}d??(d=e);let _;const S=e.toString();if(r!==void 0){_=r._translator;const C=(p=r._invalidationKey)!==null&&p!==void 0?p:await xw(i,e);v[S]=C}else{if(n===void 0){const{contents:C,invalidationKey:b}=await YS(i,e);v[S]=b,n=C}else{const C=await xw(i,e);v[S]=C}_=new FW.MalloyTranslator(S,d.toString(),{urls:{[S]:n}},l)}for(;;){const C=_.translate(o==null?void 0:o._modelDef);if(C.final)if(C.modelDef){await(h==null?void 0:h.setCachedModelDef(e.toString(),{modelDef:C.modelDef,invalidationKeys:v}));for(const b of _.newlyTranslatedDependencies())await(h==null?void 0:h.setCachedModelDef(b.url,{modelDef:b.modelDef,invalidationKeys:v}));return new Oh(C.modelDef,C.problems||[],[...(m=o==null?void 0:o.fromSources)!==null&&m!==void 0?m:[],...(g=C.fromSources)!==null&&g!==void 0?g:[]],b=>_.referenceAt(b),b=>_.importAt(b))}else if(a){const b={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},w=(o==null?void 0:o._modelDef)||b;return new Oh(w,C.problems||[],[...(y=o==null?void 0:o.fromSources)!==null&&y!==void 0?y:[],...(E=C.fromSources)!==null&&E!==void 0?E:[]],F=>_.referenceAt(F),F=>_.importAt(F))}else{const b=C.problems||[],w=_.prettyErrors();throw new BW(`Error(s) compiling model:
|
|
1268
1268
|
${w}`,b)}else{if(C.urls)for(const w of C.urls)try{if(KS(w))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(h!==void 0){const U=await h.getCachedModelDef(i,w);if(U){for(const J in U.invalidationKeys)v[J]=U.invalidationKeys[J];_.update({translations:{[w]:U.modelDef}});continue}}const{contents:F,invalidationKey:I}=await YS(i,new URL(w)),M={[w]:F};v[w]=I,_.update({urls:M})}catch(F){_.update({errors:{urls:{[w]:F.message}}})}const{modelAnnotation:b}=_.modelAnnotation(o==null?void 0:o._modelDef);if(C.tables){const w=new Map;for(const F in C.tables){const{connectionName:I,tablePath:M}=C.tables[F],U=w.get(I);U===void 0?w.set(I,{[F]:M}):U[F]=M}for(const[F,I]of w)try{const M=await s.lookupConnection(F),{schemas:U,errors:J}=await Ii.safelyFetchTableSchema(M,I,{refreshTimestamp:A,modelAnnotation:b});_.update({tables:U,errors:{tables:J}})}catch(M){const U={},J={};for(const Q in I)J[Q]=M.toString();_.update({tables:U,errors:{tables:J}})}}if(C.compileSQL){const w=C.compileSQL,F=w.connection;try{const I=await s.lookupConnection(F),M=Ii.compileSQLBlock(I.dialectName,C.partialModel,w,{replaceMaterializedReferences:c,materializedTablePrefix:f,eventStream:l}),U=await I.fetchSchemaForSQLStruct(M,{refreshTimestamp:A,modelAnnotation:b});U.error&&_.update({errors:{compileSQL:{[M.name]:U.error}}}),U.structDef&&_.update({compileSQL:{[M.name]:U.structDef}})}catch(I){const M={};M[w.name]=I.toString(),_.update({errors:{compileSQL:M}})}}}}}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 compileSQLBlock(e,n,r,i){let s,o="",u=!1;for(const c of r.select)if((0,rr.isSegmentSQL)(c))o+=c.sql,u=c.sql.match(/\(\s*$/)!==null;else{if(!s){if(!n)throw new Error("Internal error: Partial model missing when compiling SQL block");s=new rr.QueryModel(n,i==null?void 0:i.eventStream)}const f=s.compileQuery(c,{...i,defaultRowLimit:void 0},!1).sql;o+=u?f:`(${f})`,u=!1}const{name:a,connection:l}=r;return{type:"sql_select",name:a,connection:l,dialect:e,selectStr:o,fields:[]}}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 am({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 am({...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 ps(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 If(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=Ii;class BW extends Error{constructor(e,n=[]){super(e),this.problems=n}}we.MalloyError=BW;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 Cn.Tag.annotationToTag(this.modelDef.annotation,e)}getTaglines(e){return Cn.Tag.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 Dh(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 Dh(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 Dh(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const n=this.modelDef.contents[e];if((0,rr.isSourceDef)(n))return new ps(n);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(rr.isSourceDef).map(e=>new ps(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=Oh;class Dh{constructor(e,n,r,i){this.problems=r,this.name=i,this._query=e,this._modelDef=n}tagParse(e){const n=Cn.Tag.annotationToTag(this._modelDef.annotation).tag;return e=Cn.Tag.addModelScope(e,n),Cn.Tag.annotationToTag(this._query.annotation,e)}getTaglines(e){return Cn.Tag.annotationToTaglines(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const r=new rr.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new om({...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,rr.isSourceDef)(n))throw new Error("Invalid source for query");return n.dialect}getFlattenedQuery(e){return this}}we.PreparedQuery=Dh;class $W{constructor(e,n){this.translator=e,this.invalidationKey=n}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new qS(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(r=>new kW(r))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(n=>new MW(n))}helpContext(e){return this.translator.helpContext(e).helpContext}}we.Parse=$W;class kW{constructor(e){this._range=wh.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=kW;class wh{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 wh(new ew(e.start.line,e.start.character),new ew(e.end.line,e.end.character))}}we.DocumentRange=wh;class ew{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=ew;class qS{constructor(e){this._range=wh.fromJSON(e.range),this._lensRange=e.lensRange?wh.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(n=>new qS(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=qS;class MW{constructor(e){this.type=e.type,this.text=e.text}}we.DocumentCompletion=MW;class om{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 om(e,n)}tagParse(e){const n=Cn.Tag.annotationToTag(this.modelDef.annotation).tag;return e=Cn.Tag.addModelScope(e,n),Cn.Tag.annotationToTag(this.inner.annotation,e)}getTaglines(e){return Cn.Tag.annotationToTaglines(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return Cn.Tag.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 ps(n,this.sourceExplore)}catch{return new ps(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,rr.isSourceDef)(n))return new ps(n);throw new Error(`'${e} is not an explore`)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}we.PreparedResult=om;class PW{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}we.EmptyURLReader=PW;class uDe{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 KS(e.toString())?null:eV(n)}}we.InMemoryURLReader=uDe;class HS{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 HS(new Map(e.map(n=>[n.name,n])))}}we.FixedConnectionMap=HS;var UW;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(UW||(we.SourceRelationship=UW={}));class tw{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 ps}isQuery(){return this instanceof aw}}class ps extends tw{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,rr.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return Cn.Tag.annotationToTag(this._structDef.annotation,e)}getTaglines(e){return Cn.Tag.annotationToTaglines(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=Cn.Tag.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 Dh(r,this.modelDef,[],e)}get modelDef(){if(!(0,rr.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,rr.isJoined)(r))return[i,new lw(r,this,s)];if(r.type==="turtle")return[i,new aw(r,this,s)];if(r.type==="string")return[i,new uw(r,this,s)];if(r.type==="number")return[i,new zS(r,this,s)];if(r.type==="date")return r.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(r.timeframe)?[i,new zS({...r,type:"number"},this,s)]:[i,new nw(r,this,s)];if(r.type==="timestamp")return[i,new rw(r,this,s)];if(r.type==="boolean")return[i,new iw(r,this,s)];if(r.type==="json")return[i,new sw(r,this,s)];if(r.type==="sql native")return[i,new ow(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 lw}get filters(){var e;return(0,rr.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,rr.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?ps.fromJSON(e._parentExplore):void 0,r=e.sourceExplore!==void 0?ps.fromJSON(e.sourceExplore):void 0;return new ps(e._structDef,n,r)}get location(){return this.structDef.location}}we.Explore=ps;var Nu;(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"})(Nu||(we.AtomicFieldType=Nu={}));class D0 extends tw{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 Nu.String;case"boolean":return Nu.Boolean;case"date":return Nu.Date;case"timestamp":return Nu.Timestamp;case"number":return Nu.Number;case"json":return Nu.Json;case"sql native":return Nu.NativeUnsupported;case"error":return Nu.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=Cn.Tag.addModelScope(e,this.parent.modelTag),Cn.Tag.annotationToTag(this.fieldTypeDef.annotation,e)}getTaglines(e){return Cn.Tag.annotationToTaglines(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,rr.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,rr.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 uw}isNumber(){return this instanceof zS}isDate(){return this instanceof nw}isBoolean(){return this instanceof iw}isJSON(){return this instanceof sw}isTimestamp(){return this instanceof rw}isUnsupported(){return this instanceof ow}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=D0;var Lf;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(Lf||(we.DateTimeframe=Lf={}));var Fu;(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"})(Fu||(we.TimestampTimeframe=Fu={}));class nw extends D0{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 Lf.Day;case"week":return Lf.Week;case"month":return Lf.Month;case"quarter":return Lf.Quarter;case"year":return Lf.Year}}}we.DateField=nw;class rw extends D0{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 Fu.Day;case"week":return Fu.Week;case"month":return Fu.Month;case"quarter":return Fu.Quarter;case"year":return Fu.Year;case"second":return Fu.Second;case"hour":return Fu.Hour;case"minute":return Fu.Minute}}}we.TimestampField=rw;class zS extends D0{constructor(e,n,r){super(e,n,r),this.fieldNumberDef=e}}we.NumberField=zS;class iw extends D0{constructor(e,n,r){super(e,n,r),this.fieldBooleanDef=e}}we.BooleanField=iw;class sw extends D0{constructor(e,n,r){super(e,n,r),this.fieldJSONDef=e}}we.JSONField=sw;class ow extends D0{constructor(e,n,r){super(e,n,r),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}we.UnsupportedField=ow;class uw extends D0{constructor(e,n,r){super(e,n,r),this.fieldStringDef=e}}we.StringField=uw;class jW extends tw{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=jW;class aw extends jW{constructor(e,n,r){super(e,n,r),this.parent=n}tagParse(e){return e=Cn.Tag.addModelScope(e,this.parent.modelTag),Cn.Tag.annotationToTag(this.turtleDef.annotation,e)}getTaglines(e){return Cn.Tag.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 Nh;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(Nh||(we.JoinRelationship=Nh={}));class lw extends ps{constructor(e,n,r){super(e,n,r),this._parentExplore=n}get joinRelationship(){if((0,rr.isJoined)(this.structDef))switch(this.structDef.join){case"one":return Nh.OneToOne;case"many":case"cross":return Nh.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===Nh.OneToOne}get isArray(){return this.joinRelationship!==Nh.OneToOne}tagParse(e){return e=Cn.Tag.addModelScope(e,this._parentExplore.modelTag),Cn.Tag.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=lw;class cw{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 PW),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 um(this,async()=>Ii.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 um(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()}}we.Runtime=cw;class aDe extends cw{constructor({urlReader:e,connections:n}){super({connections:HS.fromArray(n),urlReader:e}),this.rawConnections=n}}we.ConnectionRuntime=aDe;class lDe extends cw{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,Z7.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,Z7.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,Z7.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}we.SingleConnectionRuntime=lDe;class QS{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 qW(this.runtime,e,n)}makeExploreMaterializer(e,n){return new zW(this.runtime,e,n)}makePreparedResultMaterializer(e){return new HW(this.runtime,e)}}class um extends QS{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 Ii.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 um(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 Ii.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 rr.QueryModel(o._modelDef,s),a=o.getExploreByName(e).structDef;if(!(0,rr.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,rr.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=`
|
|
1269
1269
|
run: ${e}
|
|
1270
1270
|
-> ${o}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/render",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.237-dev250221175121",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/module/index.umd.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build-types": "tsc --build --declaration --emitDeclarationOnly"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@malloydata/malloy": "^0.0.
|
|
34
|
+
"@malloydata/malloy": "^0.0.237-dev250221175121",
|
|
35
35
|
"@tanstack/solid-virtual": "^3.10.4",
|
|
36
36
|
"component-register": "^0.8.6",
|
|
37
37
|
"lodash": "^4.17.20",
|