@malloydata/render 0.0.242-dev250313045635 → 0.0.243-dev250313213354
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
|
@@ -148097,7 +148097,7 @@ lp.exploreQueryWalkerBuilder = $ft;
|
|
|
148097
148097
|
var Oe = {}, WR = {};
|
|
148098
148098
|
Object.defineProperty(WR, "__esModule", { value: !0 });
|
|
148099
148099
|
WR.MALLOY_VERSION = void 0;
|
|
148100
|
-
WR.MALLOY_VERSION = "0.0.
|
|
148100
|
+
WR.MALLOY_VERSION = "0.0.243";
|
|
148101
148101
|
Object.defineProperty(Oe, "__esModule", { value: !0 });
|
|
148102
148102
|
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;
|
|
148103
148103
|
const IV = Jb, Kr = Ui, BV = rT, o7 = r2, kft = WR, Mft = i2, On = si, Pft = wl, $V = "internal://internal.malloy";
|
package/dist/module/index.umd.js
CHANGED
|
@@ -1468,7 +1468,7 @@ wxxyyzz{{||}}}ҵ
|
|
|
1468
1468
|
| ${c}`,a>0&&(s=s+`
|
|
1469
1469
|
| ${" ".repeat(a)}^`)}else s=`line ${u+1}: char ${a}: ${i.message}`}r!==o&&(s=`FILE: ${o}
|
|
1470
1470
|
`+s,r=o),e!==""?e=`${e}
|
|
1471
|
-
${s}`:e=s}return e}childRequest(e){var r;const i=decodeURI(new URL(e,this.sourceURL).toString()),s=(r=this.childTranslators.get(i))===null||r===void 0?void 0:r.translate();if(s!=null&&s.compileSQL)return{compileSQL:s.compileSQL}}getChildExports(e){const r={},i=decodeURI(new URL(e,this.sourceURL).toString()),s=this.childTranslators.get(i);if(s&&s.translate().modelDef)for(const u of s.modelDef.exports){const a=s.modelDef.contents[u];((0,Uct.isSourceDef)(a)||a.type==="query")&&(r[u]=a)}return r}translate(e){if(this.finalAnswer)return this.finalAnswer;const r=this.translateStep.step(this,e);return r.final&&(this.finalAnswer=r),r}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let r=0;r<this.imports.length;r++){const i=this.imports[r];if((0,SM.locationContainsPosition)(i.location,e))return i}}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(0,SM.rangeFromContext)(this.parseStep.sourceInfo,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const r=this.compilerFlags.tag("experimental");return r!==void 0&&(r.bare()||r.has("dialect",e))}}Sc.MalloyTranslation=bM;class Ofe extends bM{constructor(e,r){super(e),this.root=r}}Sc.MalloyChildTranslator=Ofe;class uft extends bM{constructor(e,r=null,i=null,s=null){super(e,r),this.eventStream=s,this.schemaZone=new CM.Zone,this.importZone=new CM.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new CM.Zone,this.root=this,this.logger=new Dfe.BaseMessageLogger(s),i&&this.update(i)}update(e){var r,i,s;this.schemaZone.updateFrom(e.tables,(r=e.errors)===null||r===void 0?void 0:r.tables),this.importZone.updateFrom(e.urls,(i=e.errors)===null||i===void 0?void 0:i.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(s=e.errors)===null||s===void 0?void 0:s.compileSQL);for(const o in e.translations)this.pretranslatedModels.set(o,e.translations[o])}logError(e,r,i){return this.logger.log((0,Dfe.makeLogMessage)(e,r,{severity:"error",...i})),e}}Sc.MalloyTranslator=uft;function Ffe(t){return[...Object.keys(t),...Object.keys(t).map(e=>Ffe(t[e])).flat()]}var g2={};Object.defineProperty(g2,"__esModule",{value:!0}),g2.exploreQueryWalkerBuilder=g2.ExploreQueryWalker=void 0;const aft=ic;class wfe{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}filterAtOffset(e){const r=this.exploreQueryAtOffset(e);if(r)return r.filterRefs.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e)}hasFilterListAtOffset(e){const r=this.exploreQueryAtOffset(e);return r?!!r.filterLists.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}g2.ExploreQueryWalker=wfe;function lft(t,e){const r=new wfe(t),i=r;return aft.ParseTreeWalker.DEFAULT.walk(i,e),r}g2.exploreQueryWalkerBuilder=lft,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=Sc;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var r=g2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return r.exploreQueryWalkerBuilder}})}(O4);var Oe={},lR={};Object.defineProperty(lR,"__esModule",{value:!0}),lR.MALLOY_VERSION=void 0,lR.MALLOY_VERSION="0.0.
|
|
1471
|
+
${s}`:e=s}return e}childRequest(e){var r;const i=decodeURI(new URL(e,this.sourceURL).toString()),s=(r=this.childTranslators.get(i))===null||r===void 0?void 0:r.translate();if(s!=null&&s.compileSQL)return{compileSQL:s.compileSQL}}getChildExports(e){const r={},i=decodeURI(new URL(e,this.sourceURL).toString()),s=this.childTranslators.get(i);if(s&&s.translate().modelDef)for(const u of s.modelDef.exports){const a=s.modelDef.contents[u];((0,Uct.isSourceDef)(a)||a.type==="query")&&(r[u]=a)}return r}translate(e){if(this.finalAnswer)return this.finalAnswer;const r=this.translateStep.step(this,e);return r.final&&(this.finalAnswer=r),r}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let r=0;r<this.imports.length;r++){const i=this.imports[r];if((0,SM.locationContainsPosition)(i.location,e))return i}}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(0,SM.rangeFromContext)(this.parseStep.sourceInfo,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const r=this.compilerFlags.tag("experimental");return r!==void 0&&(r.bare()||r.has("dialect",e))}}Sc.MalloyTranslation=bM;class Ofe extends bM{constructor(e,r){super(e),this.root=r}}Sc.MalloyChildTranslator=Ofe;class uft extends bM{constructor(e,r=null,i=null,s=null){super(e,r),this.eventStream=s,this.schemaZone=new CM.Zone,this.importZone=new CM.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new CM.Zone,this.root=this,this.logger=new Dfe.BaseMessageLogger(s),i&&this.update(i)}update(e){var r,i,s;this.schemaZone.updateFrom(e.tables,(r=e.errors)===null||r===void 0?void 0:r.tables),this.importZone.updateFrom(e.urls,(i=e.errors)===null||i===void 0?void 0:i.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(s=e.errors)===null||s===void 0?void 0:s.compileSQL);for(const o in e.translations)this.pretranslatedModels.set(o,e.translations[o])}logError(e,r,i){return this.logger.log((0,Dfe.makeLogMessage)(e,r,{severity:"error",...i})),e}}Sc.MalloyTranslator=uft;function Ffe(t){return[...Object.keys(t),...Object.keys(t).map(e=>Ffe(t[e])).flat()]}var g2={};Object.defineProperty(g2,"__esModule",{value:!0}),g2.exploreQueryWalkerBuilder=g2.ExploreQueryWalker=void 0;const aft=ic;class wfe{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}filterAtOffset(e){const r=this.exploreQueryAtOffset(e);if(r)return r.filterRefs.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e)}hasFilterListAtOffset(e){const r=this.exploreQueryAtOffset(e);return r?!!r.filterLists.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}g2.ExploreQueryWalker=wfe;function lft(t,e){const r=new wfe(t),i=r;return aft.ParseTreeWalker.DEFAULT.walk(i,e),r}g2.exploreQueryWalkerBuilder=lft,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=Sc;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var r=g2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return r.exploreQueryWalkerBuilder}})}(O4);var Oe={},lR={};Object.defineProperty(lR,"__esModule",{value:!0}),lR.MALLOY_VERSION=void 0,lR.MALLOY_VERSION="0.0.243",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 Nfe=O4,ai=Mi,Lfe=k4,TM=Np,cft=lR,fft=Ip,wn=si,xft=zl,Ife="internal://internal.malloy";let Xl=class sD{static get version(){return cft.MALLOY_VERSION}static _parse(e,r,i,s,o){r===void 0&&(r=new URL(Ife));let u=r;s!=null&&s.importBaseURL&&(u=s==null?void 0:s.importBaseURL);const a=new Nfe.MalloyTranslator(r.toString(),u.toString(),{urls:{[r.toString()]:e}},i);return s!=null&&s.testEnvironment&&(a.allDialectsEnabled=!0),new $fe(a,o)}static parse({url:e,urlReader:r,source:i,eventStream:s,options:o}){if(i!==void 0)return sD._parse(i,e,s,o);if(r===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 gR(r,e).then(({contents:u,invalidationKey:a})=>sD._parse(u,e,s,o,a))}static async compile({url:e,source:r,parse:i,urlReader:s,connections:o,model:u,refreshSchemaCache:a,noThrowOnError:l,eventStream:c,importBaseURL:f,cacheManager:x}){var h,p,m,g,y;let A;if(a&&(A=typeof a=="number"?a:Date.now()),e===void 0&&r===void 0&&i===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(i!==void 0?e=new URL(i._translator.sourceURL):e=new URL(Ife));const E={};if(r===void 0&&x!==void 0){const C=await x.getCachedModelDef(s,e.toString());if(C)return new y2(C.modelDef,[],[e.toString(),...mR(C.modelDef.dependencies)])}f??(f=e);let _;const v=e.toString();if(i!==void 0){_=i._translator;const C=(h=i._invalidationKey)!==null&&h!==void 0?h:await PM(s,e);E[v]=C}else{if(r===void 0){const{contents:C,invalidationKey:b}=await gR(s,e);E[v]=b,r=C}else{const C=await PM(s,e);E[v]=C}_=new Nfe.MalloyTranslator(v,f.toString(),{urls:{[v]:r}},c)}for(;;){const C=_.translate(u==null?void 0:u._modelDef);if(C.final)if(C.modelDef){await(x==null?void 0:x.setCachedModelDef(e.toString(),{modelDef:C.modelDef,invalidationKeys:E}));for(const b of _.newlyTranslatedDependencies())await(x==null?void 0:x.setCachedModelDef(b.url,{modelDef:b.modelDef,invalidationKeys:E}));return new y2(C.modelDef,C.problems||[],[...(p=u==null?void 0:u.fromSources)!==null&&p!==void 0?p:[],...(m=C.fromSources)!==null&&m!==void 0?m:[]],b=>_.referenceAt(b),b=>_.importAt(b))}else if(l){const b={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},S=(u==null?void 0:u._modelDef)||b;return new y2(S,C.problems||[],[...(g=u==null?void 0:u.fromSources)!==null&&g!==void 0?g:[],...(y=C.fromSources)!==null&&y!==void 0?y:[]],R=>_.referenceAt(R),R=>_.importAt(R))}else{const b=C.problems||[],S=_.prettyErrors();throw new Bfe(`Error(s) compiling model:
|
|
1472
1472
|
${S}`,b)}else{if(C.urls)for(const S of C.urls)try{if(yR(S))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(x!==void 0){const D=await x.getCachedModelDef(s,S);if(D){for(const $ in D.invalidationKeys)E[$]=D.invalidationKeys[$];_.update({translations:{[S]:D.modelDef}});continue}}const{contents:R,invalidationKey:O}=await gR(s,new URL(S)),B={[S]:R};E[S]=O,_.update({urls:B})}catch(R){_.update({errors:{urls:{[S]:R.message}}})}const{modelAnnotation:b}=_.modelAnnotation(u==null?void 0:u._modelDef);if(C.tables){const S=new Map;for(const R in C.tables){const{connectionName:O,tablePath:B}=C.tables[R],D=S.get(O);D===void 0?S.set(O,{[R]:B}):D[R]=B}for(const[R,O]of S)try{const B=await o.lookupConnection(R),{schemas:D,errors:$}=await sD.safelyFetchTableSchema(B,O,{refreshTimestamp:A,modelAnnotation:b});_.update({tables:D,errors:{tables:$}})}catch(B){const D={},$={};for(const q in O)$[q]=B.toString();_.update({tables:D,errors:{tables:$}})}}if(C.compileSQL){const S=C.compileSQL,R=S.connection,O=(0,xft.sqlKey)(S.connection,S.selectStr);try{const D=await(await o.lookupConnection(R)).fetchSchemaForSQLStruct(S,{refreshTimestamp:A,modelAnnotation:b});D.error&&_.update({errors:{compileSQL:{[O]:D.error}}}),D.structDef&&_.update({compileSQL:{[O]:D.structDef}})}catch(B){const D={};D[O]=B.toString(),_.update({errors:{compileSQL:D}})}}}}}static async safelyFetchTableSchema(e,r,i){const s=await e.fetchSchemaForTables(r,i);for(const o of Object.keys(r))if(s.schemas[o]===void 0&&s.errors[o]===void 0)throw new Error(`Schema fetch error for ${e.name}, no response for ${o} from ${e.dialectName}`);return s}static async run({connections:e,preparedResult:r,sqlStruct:i,connection:s,options:o}){if(!s){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const u=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName);s=await e.lookupConnection(u)}if(i){const u=await s.runSQL(i.selectStr);return new lE({structs:[i],sql:i.selectStr,result:u.rows,totalRows:u.totalRows,runStats:u.runStats,lastStageName:i.name,malloy:"",connectionName:i.connection,sourceExplore:"",sourceFilters:[],profilingUrl:u.profilingUrl},{name:"empty_model",exports:[],contents:{},queryList:[],dependencies:{}})}else if(r){const u=await s.runSQL(r.sql,o);return new lE({...r._rawQuery,result:u.rows,totalRows:u.totalRows,runStats:u.runStats,profilingUrl:u.profilingUrl},r._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:e,preparedResult:r,sqlStruct:i,connection:s,options:o}){if(i===void 0&&r===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const u=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName);if(s===void 0){if(e===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");s=await e.lookupConnection(u)}if(!s.canStream())throw new Error(`Connection '${u}' cannot stream results.`);let a,l;if(i)l=new Ms(i),a=i.selectStr;else if(r!==void 0)l=r.resultExplore,a=r.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let c=0;for await(const f of s.runSQLStream(a,o))yield new ad(f,c,l,void 0,void 0),c+=1}static async estimateQueryCost({connections:e,preparedResult:r,sqlStruct:i}){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const s=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName),o=await e.lookupConnection(s);if(i)return await o.estimateQueryCost(i.selectStr);if(r)return await o.estimateQueryCost(r.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}};Oe.Malloy=Xl;class Bfe extends Error{constructor(e,r=[]){super(e),this.problems=r}}Oe.MalloyError=Bfe;class y2{constructor(e,r,i,s=()=>{},o=()=>{}){this.modelDef=e,this.problems=r,this.fromSources=i,this._referenceAt=s,this._importAt=o}tagParse(e){return(0,wn.annotationToTag)(this.modelDef.annotation,e)}getTaglines(e){return(0,wn.annotationToTaglines)(this.modelDef.annotation,e)}getReference(e){return this._referenceAt(e)}getImport(e){return this._importAt(e)}getPreparedQueryByName(e){const r=this.modelDef.contents[e];if((r==null?void 0:r.type)==="query")return new E2(r,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 E2(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 E2(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const r=this.modelDef.contents[e];if((0,ai.isSourceDef)(r))return new Ms(r);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(ai.isSourceDef).map(e=>new Ms(e))}get namedQueries(){const e=r=>r.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=y2;class E2{constructor(e,r,i,s){this.problems=i,this.name=s,this._query=e,this._modelDef=r}tagParse(e){const r=(0,wn.annotationToTag)(this._modelDef.annotation).tag;return e=(0,wn.addModelScope)(e,r),(0,wn.annotationToTag)(this._query.annotation,e)}getTaglines(e){return(0,wn.annotationToTaglines)(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const i=new ai.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new uE({...i,queryName:this.name||i.queryName},this._modelDef)}get dialect(){const e=this._query.structRef,r=typeof e=="string"?this._modelDef.contents[e]:e;if(!(0,ai.isSourceDef)(r))throw new Error("Invalid source for query");return r.dialect}getFlattenedQuery(e){return this}}Oe.PreparedQuery=E2;class $fe{constructor(e,r){this.translator=e,this.invalidationKey=r}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new cR(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(i=>new kfe(i))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(r=>new Mfe(r))}helpContext(e){return this.translator.helpContext(e).helpContext}}Oe.Parse=$fe;class kfe{constructor(e){this._range=A2.fromJSON(e.range),this._connectionId=e.connectionId,this._tablePath=e.tablePath}get range(){return this._range}get connectionId(){return this._connectionId}get tablePath(){return this._tablePath}}Oe.DocumentTablePath=kfe;class A2{constructor(e,r){this._start=e,this._end=r}get start(){return this._start}get end(){return this._end}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}static fromJSON(e){return new A2(new RM(e.start.line,e.start.character),new RM(e.end.line,e.end.character))}}Oe.DocumentRange=A2;class RM{constructor(e,r){this._line=e,this._character=r}get line(){return this._line}get character(){return this._character}toJSON(){return{line:this.line,character:this.character}}}Oe.DocumentPosition=RM;class cR{constructor(e){this._range=A2.fromJSON(e.range),this._lensRange=e.lensRange?A2.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(r=>new cR(r))}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=cR;class Mfe{constructor(e){this.type=e.type,this.text=e.text}}Oe.DocumentCompletion=Mfe;class uE{constructor(e,r){this.modelDef=r,this.inner=e}static fromJson({query:e,modelDef:r}){if(!e||!r)throw new Error("Missing required properties in JSON data");return new uE(e,r)}tagParse(e){const r=(0,wn.annotationToTag)(this.modelDef.annotation).tag;return e=(0,wn.addModelScope)(e,r),(0,wn.annotationToTag)(this.inner.annotation,e)}getTaglines(e){return(0,wn.annotationToTaglines)(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return(0,wn.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],r={...e,annotation:this.inner.annotation,name:this.inner.queryName||e.name};try{return new Ms(r,this.sourceExplore)}catch{return new Ms(r)}}get sourceExplore(){const e=this.inner.sourceExplore,r=this.modelDef.contents[e];if(r&&(0,ai.isSourceDef)(r))return new Ms(r)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}Oe.PreparedResult=uE;class Pfe{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}Oe.EmptyURLReader=Pfe;class dft{constructor(e){this.files=e}async readURL(e){const r=this.files.get(e.toString());if(r!==void 0)return Promise.resolve({contents:r,invalidationKey:this.invalidationKey(e,r)});throw new Error(`File not found '${e}'`)}async getInvalidationKey(e){const r=this.files.get(e.toString());if(r!==void 0)return Promise.resolve(this.invalidationKey(e,r));throw new Error(`File not found '${e}'`)}invalidationKey(e,r){return yR(e.toString())?null:exe(r)}}Oe.InMemoryURLReader=dft;class fR{constructor(e,r){this.connections=e,this.defaultConnectionName=r}async getConnection(e){if(e===void 0)if(this.defaultConnectionName!==void 0)e=this.defaultConnectionName;else throw new Error("No default connection.");const r=this.connections.get(e);if(r!==void 0)return Promise.resolve(r);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 fR(new Map(e.map(r=>[r.name,r])))}}Oe.FixedConnectionMap=fR;var Ufe;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(Ufe||(Oe.SourceRelationship=Ufe={}));class DM{constructor(e,r,i){this._name=e,this._parent=r,this._source=i}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 r=this._parent;for(;r;)e.unshift(r.name),r=r._parent;return e}hasParentExplore(){return this._parent!==void 0}isExplore(){return this instanceof Ms}isQuery(){return this instanceof BM}}class Ms extends DM{constructor(e,r,i){super(e.as||e.name,r,i),this._structDef=e,this._parentExplore=r,this.sourceExplore=i}get source(){return this.sourceExplore}isIntrinsic(){return(0,ai.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return(0,wn.annotationToTag)(this._structDef.annotation,e)}getTaglines(e){return(0,wn.annotationToTaglines)(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=(0,wn.annotationToTag)(this._structDef.modelAnnotation).tag),this.parsedModelTag}get name(){return this.structDef.as||this.structDef.name}getQueryByName(e){const r=this.sourceStructDef;if(!r)throw new Error(`Cannot get query by name from a struct of type ${this.structDef.type}`);const i={type:"query",structRef:r,pipeline:[{type:"reduce",queryFields:[{type:"fieldref",path:[e]}]}]};return new E2(i,this.modelDef,[],e)}get modelDef(){if(!(0,ai.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 y2(this.modelDef,[],[])}get fieldMap(){var e;if(this._fieldMap===void 0){const r=((e=this.source)===null||e===void 0?void 0:e.fieldMap)||new Map;this._fieldMap=new Map(this.structDef.fields.map(i=>{const s=i.as||i.name,o=r.get(i.name);if((0,ai.isJoined)(i))return[s,new $M(i,this,o)];if(i.type==="turtle")return[s,new BM(i,this,o)];if(i.type==="string")return[s,new IM(i,this,o)];if(i.type==="number")return[s,new xR(i,this,o)];if(i.type==="date")return i.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(i.timeframe)?[s,new xR({...i,type:"number"},this,o)]:[s,new OM(i,this,o)];if(i.type==="timestamp")return[s,new FM(i,this,o)];if(i.type==="boolean")return[s,new wM(i,this,o)];if(i.type==="json")return[s,new NM(i,this,o)];if(i.type==="sql native")return[s,new LM(i,this,o)]}))}return this._fieldMap}get allFields(){return[...this.fieldMap.values()]}get allFieldsWithOrder(){var e,r,i;if(!this._allFieldsWithOrder){const s=[...((i=(r=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||r===void 0?void 0:r.orderBy)===null||i===void 0?void 0:i.map(u=>{if(typeof u.field=="string")return{field:this.fieldMap.get(u.field),dir:u.dir};throw new Error("Does not support mapping order by from number.")}))||[]],o=new Set(s.map(u=>u.field.name));this._allFieldsWithOrder=[...s,...this.allFields.filter(u=>!o.has(u.name)).map(u=>({field:u,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 r=this.fieldMap.get(e);if(r===void 0)throw new Error(`No such field ${e}.`);return r}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 $M}get filters(){var e;return(0,ai.isSourceDef)(this.structDef)?((e=this.structDef.resultMetadata)===null||e===void 0?void 0:e.filterList)||[]:[]}get limit(){var e,r;return(r=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||r===void 0?void 0:r.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,ai.isSourceDef)(this.structDef))return this.structDef}toJSON(){var e,r;return{_structDef:this._structDef,sourceExplore:(e=this.sourceExplore)===null||e===void 0?void 0:e.toJSON(),_parentExplore:(r=this._parentExplore)===null||r===void 0?void 0:r.toJSON()}}static fromJSON(e){const r=e._parentExplore!==void 0?Ms.fromJSON(e._parentExplore):void 0,i=e.sourceExplore!==void 0?Ms.fromJSON(e.sourceExplore):void 0;return new Ms(e._structDef,r,i)}get location(){return this.structDef.location}}Oe.Explore=Ms;var Fa;(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"})(Fa||(Oe.AtomicFieldType=Fa={}));class Qc extends DM{constructor(e,r,i){super(e.as||e.name,r,i),this.fieldTypeDef=e,this.parent=r}get type(){switch(this.fieldTypeDef.type){case"string":return Fa.String;case"boolean":return Fa.Boolean;case"date":return Fa.Date;case"timestamp":return Fa.Timestamp;case"number":return Fa.Number;case"json":return Fa.Json;case"sql native":return Fa.NativeUnsupported;case"error":return Fa.Error;case"record":case"array":throw new Error(`MTOY TODO IMPLEMENT Atomic ${this.fieldTypeDef.type}`);default:{const e=this.fieldTypeDef;throw new Error(`Can't make an atomic field from ${e}`)}}}tagParse(e){return e=(0,wn.addModelScope)(e,this.parent.modelTag),(0,wn.annotationToTag)(this.fieldTypeDef.annotation,e)}getTaglines(e){return(0,wn.annotationToTaglines)(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,ai.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,ai.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,r;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((r=this.fieldTypeDef.resultMetadata)===null||r===void 0?void 0:r.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 IM}isNumber(){return this instanceof xR}isDate(){return this instanceof OM}isBoolean(){return this instanceof wM}isJSON(){return this instanceof NM}isTimestamp(){return this instanceof FM}isUnsupported(){return this instanceof LM}get parentExplore(){return this.parent}get expression(){const e=".",r=this.fieldTypeDef.resultMetadata;return(r==null?void 0:r.sourceExpression)||(r!=null&&r.sourceField.includes(e)?r==null?void 0:r.sourceField:this.name)}get location(){return this.fieldTypeDef.location}}Oe.AtomicField=Qc;var ud;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(ud||(Oe.DateTimeframe=ud={}));var wa;(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"})(wa||(Oe.TimestampTimeframe=wa={}));class OM extends Qc{constructor(e,r,i){super(e,r,i),this.fieldDateDef=e}get timeframe(){if(this.fieldDateDef.timeframe!==void 0)switch(this.fieldDateDef.timeframe){case"day":return ud.Day;case"week":return ud.Week;case"month":return ud.Month;case"quarter":return ud.Quarter;case"year":return ud.Year}}}Oe.DateField=OM;class FM extends Qc{constructor(e,r,i){super(e,r,i),this.fieldTimestampDef=e}get timeframe(){if(this.fieldTimestampDef.timeframe!==void 0)switch(this.fieldTimestampDef.timeframe){case"day":return wa.Day;case"week":return wa.Week;case"month":return wa.Month;case"quarter":return wa.Quarter;case"year":return wa.Year;case"second":return wa.Second;case"hour":return wa.Hour;case"minute":return wa.Minute}}}Oe.TimestampField=FM;class xR extends Qc{constructor(e,r,i){super(e,r,i),this.fieldNumberDef=e}}Oe.NumberField=xR;class wM extends Qc{constructor(e,r,i){super(e,r,i),this.fieldBooleanDef=e}}Oe.BooleanField=wM;class NM extends Qc{constructor(e,r,i){super(e,r,i),this.fieldJSONDef=e}}Oe.JSONField=NM;class LM extends Qc{constructor(e,r,i){super(e,r,i),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}Oe.UnsupportedField=LM;class IM extends Qc{constructor(e,r,i){super(e,r,i),this.fieldStringDef=e}}Oe.StringField=IM;class jfe extends DM{constructor(e,r,i){super(e.as||e.name,r,i),this.turtleDef=e}get source(){return this.sourceQuery}isIntrinsic(){return!1}get location(){return this.turtleDef.location}}Oe.Query=jfe;class BM extends jfe{constructor(e,r,i){super(e,r,i),this.parent=r}tagParse(e){return e=(0,wn.addModelScope)(e,this.parent.modelTag),(0,wn.annotationToTag)(this.turtleDef.annotation,e)}getTaglines(e){return(0,wn.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=BM;var _2;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(_2||(Oe.JoinRelationship=_2={}));class $M extends Ms{constructor(e,r,i){super(e,r,i),this._parentExplore=r}get joinRelationship(){if((0,ai.isJoined)(this.structDef))switch(this.structDef.join){case"one":return _2.OneToOne;case"many":case"cross":return _2.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===_2.OneToOne}get isArray(){return this.joinRelationship!==_2.OneToOne}tagParse(e){return e=(0,wn.addModelScope)(e,this._parentExplore.modelTag),(0,wn.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=$M;class kM{constructor({urlReader:e,connections:r,connection:i,eventStream:s,cacheManager:o}){if(this.isTestRuntime=!1,r===void 0){if(i===void 0)throw new Error("A LookupConnection<Connection> or Connection is required.");r={lookupConnection:()=>Promise.resolve(i)}}e===void 0&&(e=new Pfe),this._urlReader=e,this._connections=r,this._eventStream=s,this._cacheManager=o}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}loadModel(e,r){const{refreshSchemaCache:i,noThrowOnError:s}=r||{};this.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0});const o=e instanceof URL?{url:e}:{source:e};return new aE(this,async()=>Xl.compile({...o,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:i,noThrowOnError:s,eventStream:this.eventStream,replaceMaterializedReferences:r==null?void 0:r.replaceMaterializedReferences,materializedTablePrefix:r==null?void 0:r.materializedTablePrefix,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,cacheManager:this.cacheManager}),r)}_loadModelFromModelDef(e,r){return new aE(this,async()=>new y2(e,[],[]),r)}loadQuery(e,r){return this.loadModel(e,r).loadFinalQuery()}loadQueryByIndex(e,r,i){return this.loadModel(e,i).loadQueryByIndex(r,i)}loadQueryByName(e,r,i){return this.loadModel(e,i).loadQueryByName(r,i)}getModel(e,r){return this.loadModel(e,r).getModel()}getQuery(e,r){return this.loadQuery(e,r).getPreparedQuery()}getQueryByIndex(e,r,i){return this.loadQueryByIndex(e,r,i).getPreparedQuery()}getQueryByName(e,r,i){return this.loadQueryByName(e,r,i).getPreparedQuery()}}Oe.Runtime=kM;class hft extends kM{constructor({urlReader:e,connections:r}){super({connections:fR.fromArray(r),urlReader:e}),this.rawConnections=r}}Oe.ConnectionRuntime=hft;class pft extends kM{constructor({urlReader:e,connection:r,eventStream:i,cacheManager:s}){super({urlReader:e,eventStream:i,cacheManager:s,connection:r}),this.connection=r}get supportsNesting(){return(0,TM.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,TM.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,TM.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}Oe.SingleConnectionRuntime=pft;class dR{constructor(e,r){this.runtime=e,this._materialize=r}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(e,r){return new qfe(this.runtime,e,r)}makeExploreMaterializer(e,r){return new Qfe(this.runtime,e,r)}makePreparedResultMaterializer(e){return new Hfe(this.runtime,e)}}class aE extends dR{constructor(e,r,i){super(e,r),this.runtime=e,this.compileQueryOptions=i}loadFinalQuery(e){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...e})}loadQueryByIndex(e,r){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(e),{...this.compileQueryOptions,...r})}loadQueryByName(e,r){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(e),{...this.compileQueryOptions,...r})}loadQuery(e,r){const{refreshSchemaCache:i,noThrowOnError:s}=r||{};return this.makeQueryMaterializer(async()=>{const o=this.runtime.urlReader,u=this.runtime.connections;this.runtime.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0});const a=e instanceof URL?{url:e}:{source:e},l=await this.getModel();return(await Xl.compile({...a,urlReader:o,connections:u,model:l,refreshSchemaCache:i,noThrowOnError:s,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,...this.compileQueryOptions})).preparedQuery})}extendModel(e,r){return this.runtime.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0}),new aE(this.runtime,async()=>{const i=this.runtime.urlReader,s=this.runtime.connections,o=e instanceof URL?{url:e}:{source:e},u=await this.getModel();return await Xl.compile({...o,urlReader:i,connections:s,model:u,refreshSchemaCache:r==null?void 0:r.refreshSchemaCache,noThrowOnError:r==null?void 0:r.noThrowOnError,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,...this.compileQueryOptions})},r)}async search(e,r,i=1e3,s=void 0,o){const u=await this.materialize(),a=new ai.QueryModel(u._modelDef,o),l=u.getExploreByName(e).structDef;if(!(0,ai.isSourceDef)(l))throw new Error("Source to be searched was unexpectedly, not a source");const c=l.connection,f=await this.runtime.connections.lookupConnection(c);return await a.searchIndex(f,e,r,i,s)}async searchValueMap(e,r=10,i){const o=(await this.materialize()).getExploreByName(e);if(!(0,ai.isSourceDef)(o.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let u="{index: *}";o.getFieldByNameIfExists("search_index")&&(u="search_index");const a=`
|
|
1473
1473
|
run: ${e}
|
|
1474
1474
|
-> ${u}
|
|
@@ -151909,7 +151909,7 @@ jp.exploreQueryWalkerBuilder = wht;
|
|
|
151909
151909
|
var Ne = {}, AD = {};
|
|
151910
151910
|
Object.defineProperty(AD, "__esModule", { value: !0 });
|
|
151911
151911
|
AD.MALLOY_VERSION = void 0;
|
|
151912
|
-
AD.MALLOY_VERSION = "0.0.
|
|
151912
|
+
AD.MALLOY_VERSION = "0.0.243";
|
|
151913
151913
|
Object.defineProperty(Ne, "__esModule", { value: !0 });
|
|
151914
151914
|
Ne.InMemoryModelCache = Ne.CacheManager = Ne.CSVWriter = Ne.JSONWriter = Ne.DataWriter = Ne.DataRecord = Ne.DataArray = Ne.Result = Ne.ExploreMaterializer = Ne.PreparedResultMaterializer = Ne.QueryMaterializer = Ne.ModelMaterializer = Ne.SingleConnectionRuntime = Ne.ConnectionRuntime = Ne.Runtime = Ne.ExploreField = Ne.JoinRelationship = Ne.QueryField = Ne.Query = Ne.StringField = Ne.UnsupportedField = Ne.JSONField = Ne.BooleanField = Ne.NumberField = Ne.TimestampField = Ne.DateField = Ne.TimestampTimeframe = Ne.DateTimeframe = Ne.AtomicField = Ne.AtomicFieldType = Ne.Explore = Ne.SourceRelationship = Ne.FixedConnectionMap = Ne.InMemoryURLReader = Ne.EmptyURLReader = Ne.PreparedResult = Ne.DocumentCompletion = Ne.DocumentSymbol = Ne.DocumentPosition = Ne.DocumentRange = Ne.DocumentTablePath = Ne.Parse = Ne.PreparedQuery = Ne.Model = Ne.MalloyError = Ne.Malloy = void 0;
|
|
151915
151915
|
const fY = bT, ni = Vi, xY = mi, M7 = B2, Fht = AD, Nht = k2, Ln = xi, Lht = Xl, dY = "internal://internal.malloy";
|
|
@@ -1863,7 +1863,7 @@ wxxyyzz{{||}}}ҵ
|
|
|
1863
1863
|
| ${c}`,a>0&&(s=s+`
|
|
1864
1864
|
| ${" ".repeat(a)}^`)}else s=`line ${u+1}: char ${a}: ${i.message}`}r!==o&&(s=`FILE: ${o}
|
|
1865
1865
|
`+s,r=o),e!==""?e=`${e}
|
|
1866
|
-
${s}`:e=s}return e}childRequest(e){var r;const i=decodeURI(new URL(e,this.sourceURL).toString()),s=(r=this.childTranslators.get(i))===null||r===void 0?void 0:r.translate();if(s!=null&&s.compileSQL)return{compileSQL:s.compileSQL}}getChildExports(e){const r={},i=decodeURI(new URL(e,this.sourceURL).toString()),s=this.childTranslators.get(i);if(s&&s.translate().modelDef)for(const u of s.modelDef.exports){const a=s.modelDef.contents[u];((0,Ndt.isSourceDef)(a)||a.type==="query")&&(r[u]=a)}return r}translate(e){if(this.finalAnswer)return this.finalAnswer;const r=this.translateStep.step(this,e);return r.final&&(this.finalAnswer=r),r}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let r=0;r<this.imports.length;r++){const i=this.imports[r];if((0,zM.locationContainsPosition)(i.location,e))return i}}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(0,zM.rangeFromContext)(this.parseStep.sourceInfo,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const r=this.compilerFlags.tag("experimental");return r!==void 0&&(r.bare()||r.has("dialect",e))}}zc.MalloyTranslation=QM;class wxe extends QM{constructor(e,r){super(e),this.root=r}}zc.MalloyChildTranslator=wxe;class Zdt extends QM{constructor(e,r=null,i=null,s=null){super(e,r),this.eventStream=s,this.schemaZone=new HM.Zone,this.importZone=new HM.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new HM.Zone,this.root=this,this.logger=new Oxe.BaseMessageLogger(s),i&&this.update(i)}update(e){var r,i,s;this.schemaZone.updateFrom(e.tables,(r=e.errors)===null||r===void 0?void 0:r.tables),this.importZone.updateFrom(e.urls,(i=e.errors)===null||i===void 0?void 0:i.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(s=e.errors)===null||s===void 0?void 0:s.compileSQL);for(const o in e.translations)this.pretranslatedModels.set(o,e.translations[o])}logError(e,r,i){return this.logger.log((0,Oxe.makeLogMessage)(e,r,{severity:"error",...i})),e}}zc.MalloyTranslator=Zdt;function Fxe(t){return[...Object.keys(t),...Object.keys(t).map(e=>Fxe(t[e])).flat()]}var V2={};Object.defineProperty(V2,"__esModule",{value:!0}),V2.exploreQueryWalkerBuilder=V2.ExploreQueryWalker=void 0;const eht=C0;class Nxe{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}filterAtOffset(e){const r=this.exploreQueryAtOffset(e);if(r)return r.filterRefs.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e)}hasFilterListAtOffset(e){const r=this.exploreQueryAtOffset(e);return r?!!r.filterLists.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}V2.ExploreQueryWalker=Nxe;function tht(t,e){const r=new Nxe(t),i=r;return eht.ParseTreeWalker.DEFAULT.walk(i,e),r}V2.exploreQueryWalkerBuilder=tht,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=zc;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var r=V2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return r.exploreQueryWalkerBuilder}})}(T4);var Ne={},oD={};Object.defineProperty(oD,"__esModule",{value:!0}),oD.MALLOY_VERSION=void 0,oD.MALLOY_VERSION="0.0.
|
|
1866
|
+
${s}`:e=s}return e}childRequest(e){var r;const i=decodeURI(new URL(e,this.sourceURL).toString()),s=(r=this.childTranslators.get(i))===null||r===void 0?void 0:r.translate();if(s!=null&&s.compileSQL)return{compileSQL:s.compileSQL}}getChildExports(e){const r={},i=decodeURI(new URL(e,this.sourceURL).toString()),s=this.childTranslators.get(i);if(s&&s.translate().modelDef)for(const u of s.modelDef.exports){const a=s.modelDef.contents[u];((0,Ndt.isSourceDef)(a)||a.type==="query")&&(r[u]=a)}return r}translate(e){if(this.finalAnswer)return this.finalAnswer;const r=this.translateStep.step(this,e);return r.final&&(this.finalAnswer=r),r}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let r=0;r<this.imports.length;r++){const i=this.imports[r];if((0,zM.locationContainsPosition)(i.location,e))return i}}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(0,zM.rangeFromContext)(this.parseStep.sourceInfo,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const r=this.compilerFlags.tag("experimental");return r!==void 0&&(r.bare()||r.has("dialect",e))}}zc.MalloyTranslation=QM;class wxe extends QM{constructor(e,r){super(e),this.root=r}}zc.MalloyChildTranslator=wxe;class Zdt extends QM{constructor(e,r=null,i=null,s=null){super(e,r),this.eventStream=s,this.schemaZone=new HM.Zone,this.importZone=new HM.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new HM.Zone,this.root=this,this.logger=new Oxe.BaseMessageLogger(s),i&&this.update(i)}update(e){var r,i,s;this.schemaZone.updateFrom(e.tables,(r=e.errors)===null||r===void 0?void 0:r.tables),this.importZone.updateFrom(e.urls,(i=e.errors)===null||i===void 0?void 0:i.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(s=e.errors)===null||s===void 0?void 0:s.compileSQL);for(const o in e.translations)this.pretranslatedModels.set(o,e.translations[o])}logError(e,r,i){return this.logger.log((0,Oxe.makeLogMessage)(e,r,{severity:"error",...i})),e}}zc.MalloyTranslator=Zdt;function Fxe(t){return[...Object.keys(t),...Object.keys(t).map(e=>Fxe(t[e])).flat()]}var V2={};Object.defineProperty(V2,"__esModule",{value:!0}),V2.exploreQueryWalkerBuilder=V2.ExploreQueryWalker=void 0;const eht=C0;class Nxe{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}filterAtOffset(e){const r=this.exploreQueryAtOffset(e);if(r)return r.filterRefs.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e)}hasFilterListAtOffset(e){const r=this.exploreQueryAtOffset(e);return r?!!r.filterLists.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}V2.ExploreQueryWalker=Nxe;function tht(t,e){const r=new Nxe(t),i=r;return eht.ParseTreeWalker.DEFAULT.walk(i,e),r}V2.exploreQueryWalkerBuilder=tht,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=zc;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var r=V2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return r.exploreQueryWalkerBuilder}})}(T4);var Ne={},oD={};Object.defineProperty(oD,"__esModule",{value:!0}),oD.MALLOY_VERSION=void 0,oD.MALLOY_VERSION="0.0.243",Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.InMemoryModelCache=Ne.CacheManager=Ne.CSVWriter=Ne.JSONWriter=Ne.DataWriter=Ne.DataRecord=Ne.DataArray=Ne.Result=Ne.ExploreMaterializer=Ne.PreparedResultMaterializer=Ne.QueryMaterializer=Ne.ModelMaterializer=Ne.SingleConnectionRuntime=Ne.ConnectionRuntime=Ne.Runtime=Ne.ExploreField=Ne.JoinRelationship=Ne.QueryField=Ne.Query=Ne.StringField=Ne.UnsupportedField=Ne.JSONField=Ne.BooleanField=Ne.NumberField=Ne.TimestampField=Ne.DateField=Ne.TimestampTimeframe=Ne.DateTimeframe=Ne.AtomicField=Ne.AtomicFieldType=Ne.Explore=Ne.SourceRelationship=Ne.FixedConnectionMap=Ne.InMemoryURLReader=Ne.EmptyURLReader=Ne.PreparedResult=Ne.DocumentCompletion=Ne.DocumentSymbol=Ne.DocumentPosition=Ne.DocumentRange=Ne.DocumentTablePath=Ne.Parse=Ne.PreparedQuery=Ne.Model=Ne.MalloyError=Ne.Malloy=void 0;const Lxe=T4,gi=Gi,Ixe=ai,GM=l2,nht=oD,rht=f2,$n=hi,iht=d0,$xe="internal://internal.malloy";let A0=class LD{static get version(){return nht.MALLOY_VERSION}static _parse(e,r,i,s,o){r===void 0&&(r=new URL($xe));let u=r;s!=null&&s.importBaseURL&&(u=s==null?void 0:s.importBaseURL);const a=new Lxe.MalloyTranslator(r.toString(),u.toString(),{urls:{[r.toString()]:e}},i);return s!=null&&s.testEnvironment&&(a.allDialectsEnabled=!0),new kxe(a,o)}static parse({url:e,urlReader:r,source:i,eventStream:s,options:o}){if(i!==void 0)return LD._parse(i,e,s,o);if(r===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 hD(r,e).then(({contents:u,invalidationKey:a})=>LD._parse(u,e,s,o,a))}static async compile({url:e,source:r,parse:i,urlReader:s,connections:o,model:u,refreshSchemaCache:a,noThrowOnError:l,eventStream:c,importBaseURL:f,cacheManager:x}){var h,p,m,g,y;let E;if(a&&(E=typeof a=="number"?a:Date.now()),e===void 0&&r===void 0&&i===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(i!==void 0?e=new URL(i._translator.sourceURL):e=new URL($xe));const A={};if(r===void 0&&x!==void 0){const C=await x.getCachedModelDef(s,e.toString());if(C)return new Y2(C.modelDef,[],[e.toString(),...dD(C.modelDef.dependencies)])}f??(f=e);let _;const v=e.toString();if(i!==void 0){_=i._translator;const C=(h=i._invalidationKey)!==null&&h!==void 0?h:await sP(s,e);A[v]=C}else{if(r===void 0){const{contents:C,invalidationKey:S}=await hD(s,e);A[v]=S,r=C}else{const C=await sP(s,e);A[v]=C}_=new Lxe.MalloyTranslator(v,f.toString(),{urls:{[v]:r}},c)}for(;;){const C=_.translate(u==null?void 0:u._modelDef);if(C.final)if(C.modelDef){await(x==null?void 0:x.setCachedModelDef(e.toString(),{modelDef:C.modelDef,invalidationKeys:A}));for(const S of _.newlyTranslatedDependencies())await(x==null?void 0:x.setCachedModelDef(S.url,{modelDef:S.modelDef,invalidationKeys:A}));return new Y2(C.modelDef,C.problems||[],[...(p=u==null?void 0:u.fromSources)!==null&&p!==void 0?p:[],...(m=C.fromSources)!==null&&m!==void 0?m:[]],S=>_.referenceAt(S),S=>_.importAt(S))}else if(l){const S={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},b=(u==null?void 0:u._modelDef)||S;return new Y2(b,C.problems||[],[...(g=u==null?void 0:u.fromSources)!==null&&g!==void 0?g:[],...(y=C.fromSources)!==null&&y!==void 0?y:[]],R=>_.referenceAt(R),R=>_.importAt(R))}else{const S=C.problems||[],b=_.prettyErrors();throw new Bxe(`Error(s) compiling model:
|
|
1867
1867
|
${b}`,S)}else{if(C.urls)for(const b of C.urls)try{if(pD(b))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(x!==void 0){const D=await x.getCachedModelDef(s,b);if(D){for(const $ in D.invalidationKeys)A[$]=D.invalidationKeys[$];_.update({translations:{[b]:D.modelDef}});continue}}const{contents:R,invalidationKey:N}=await hD(s,new URL(b)),B={[b]:R};A[b]=N,_.update({urls:B})}catch(R){_.update({errors:{urls:{[b]:R.message}}})}const{modelAnnotation:S}=_.modelAnnotation(u==null?void 0:u._modelDef);if(C.tables){const b=new Map;for(const R in C.tables){const{connectionName:N,tablePath:B}=C.tables[R],D=b.get(N);D===void 0?b.set(N,{[R]:B}):D[R]=B}for(const[R,N]of b)try{const B=await o.lookupConnection(R),{schemas:D,errors:$}=await LD.safelyFetchTableSchema(B,N,{refreshTimestamp:E,modelAnnotation:S});_.update({tables:D,errors:{tables:$}})}catch(B){const D={},$={};for(const j in N)$[j]=B.toString();_.update({tables:D,errors:{tables:$}})}}if(C.compileSQL){const b=C.compileSQL,R=b.connection,N=(0,iht.sqlKey)(b.connection,b.selectStr);try{const D=await(await o.lookupConnection(R)).fetchSchemaForSQLStruct(b,{refreshTimestamp:E,modelAnnotation:S});D.error&&_.update({errors:{compileSQL:{[N]:D.error}}}),D.structDef&&_.update({compileSQL:{[N]:D.structDef}})}catch(B){const D={};D[N]=B.toString(),_.update({errors:{compileSQL:D}})}}}}}static async safelyFetchTableSchema(e,r,i){const s=await e.fetchSchemaForTables(r,i);for(const o of Object.keys(r))if(s.schemas[o]===void 0&&s.errors[o]===void 0)throw new Error(`Schema fetch error for ${e.name}, no response for ${o} from ${e.dialectName}`);return s}static async run({connections:e,preparedResult:r,sqlStruct:i,connection:s,options:o}){if(!s){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const u=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName);s=await e.lookupConnection(u)}if(i){const u=await s.runSQL(i.selectStr);return new zE({structs:[i],sql:i.selectStr,result:u.rows,totalRows:u.totalRows,runStats:u.runStats,lastStageName:i.name,malloy:"",connectionName:i.connection,sourceExplore:"",sourceFilters:[],profilingUrl:u.profilingUrl},{name:"empty_model",exports:[],contents:{},queryList:[],dependencies:{}})}else if(r){const u=await s.runSQL(r.sql,o);return new zE({...r._rawQuery,result:u.rows,totalRows:u.totalRows,runStats:u.runStats,profilingUrl:u.profilingUrl},r._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:e,preparedResult:r,sqlStruct:i,connection:s,options:o}){if(i===void 0&&r===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const u=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName);if(s===void 0){if(e===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");s=await e.lookupConnection(u)}if(!s.canStream())throw new Error(`Connection '${u}' cannot stream results.`);let a,l;if(i)l=new Gs(i),a=i.selectStr;else if(r!==void 0)l=r.resultExplore,a=r.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let c=0;for await(const f of s.runSQLStream(a,o))yield new Ld(f,c,l,void 0,void 0),c+=1}static async estimateQueryCost({connections:e,preparedResult:r,sqlStruct:i}){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const s=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName),o=await e.lookupConnection(s);if(i)return await o.estimateQueryCost(i.selectStr);if(r)return await o.estimateQueryCost(r.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}};Ne.Malloy=A0;class Bxe extends Error{constructor(e,r=[]){super(e),this.problems=r}}Ne.MalloyError=Bxe;class Y2{constructor(e,r,i,s=()=>{},o=()=>{}){this.modelDef=e,this.problems=r,this.fromSources=i,this._referenceAt=s,this._importAt=o}tagParse(e){return(0,$n.annotationToTag)(this.modelDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.modelDef.annotation,e)}getReference(e){return this._referenceAt(e)}getImport(e){return this._importAt(e)}getPreparedQueryByName(e){const r=this.modelDef.contents[e];if((r==null?void 0:r.type)==="query")return new K2(r,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 K2(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 K2(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const r=this.modelDef.contents[e];if((0,gi.isSourceDef)(r))return new Gs(r);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(gi.isSourceDef).map(e=>new Gs(e))}get namedQueries(){const e=r=>r.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}}Ne.Model=Y2;class K2{constructor(e,r,i,s){this.problems=i,this.name=s,this._query=e,this._modelDef=r}tagParse(e){const r=(0,$n.annotationToTag)(this._modelDef.annotation).tag;return e=(0,$n.addModelScope)(e,r),(0,$n.annotationToTag)(this._query.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const i=new gi.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new qE({...i,queryName:this.name||i.queryName},this._modelDef)}get dialect(){const e=this._query.structRef,r=typeof e=="string"?this._modelDef.contents[e]:e;if(!(0,gi.isSourceDef)(r))throw new Error("Invalid source for query");return r.dialect}getFlattenedQuery(e){return this}}Ne.PreparedQuery=K2;class kxe{constructor(e,r){this.translator=e,this.invalidationKey=r}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new uD(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(i=>new Mxe(i))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(r=>new Pxe(r))}helpContext(e){return this.translator.helpContext(e).helpContext}}Ne.Parse=kxe;class Mxe{constructor(e){this._range=J2.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}}Ne.DocumentTablePath=Mxe;class J2{constructor(e,r){this._start=e,this._end=r}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 J2(new WM(e.start.line,e.start.character),new WM(e.end.line,e.end.character))}}Ne.DocumentRange=J2;class WM{constructor(e,r){this._line=e,this._character=r}get line(){return this._line}get character(){return this._character}toJSON(){return{line:this.line,character:this.character}}}Ne.DocumentPosition=WM;class uD{constructor(e){this._range=J2.fromJSON(e.range),this._lensRange=e.lensRange?J2.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(r=>new uD(r))}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}}Ne.DocumentSymbol=uD;class Pxe{constructor(e){this.type=e.type,this.text=e.text}}Ne.DocumentCompletion=Pxe;class qE{constructor(e,r){this.modelDef=r,this.inner=e}static fromJson({query:e,modelDef:r}){if(!e||!r)throw new Error("Missing required properties in JSON data");return new qE(e,r)}tagParse(e){const r=(0,$n.annotationToTag)(this.modelDef.annotation).tag;return e=(0,$n.addModelScope)(e,r),(0,$n.annotationToTag)(this.inner.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return(0,$n.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],r={...e,annotation:this.inner.annotation,name:this.inner.queryName||e.name};try{return new Gs(r,this.sourceExplore)}catch{return new Gs(r)}}get sourceExplore(){const e=this.inner.sourceExplore,r=this.modelDef.contents[e];if(r&&(0,gi.isSourceDef)(r))return new Gs(r)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}Ne.PreparedResult=qE;class Uxe{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}Ne.EmptyURLReader=Uxe;class sht{constructor(e){this.files=e}async readURL(e){const r=this.files.get(e.toString());if(r!==void 0)return Promise.resolve({contents:r,invalidationKey:this.invalidationKey(e,r)});throw new Error(`File not found '${e}'`)}async getInvalidationKey(e){const r=this.files.get(e.toString());if(r!==void 0)return Promise.resolve(this.invalidationKey(e,r));throw new Error(`File not found '${e}'`)}invalidationKey(e,r){return pD(e.toString())?null:tde(r)}}Ne.InMemoryURLReader=sht;class aD{constructor(e,r){this.connections=e,this.defaultConnectionName=r}async getConnection(e){if(e===void 0)if(this.defaultConnectionName!==void 0)e=this.defaultConnectionName;else throw new Error("No default connection.");const r=this.connections.get(e);if(r!==void 0)return Promise.resolve(r);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 aD(new Map(e.map(r=>[r.name,r])))}}Ne.FixedConnectionMap=aD;var jxe;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(jxe||(Ne.SourceRelationship=jxe={}));class VM{constructor(e,r,i){this._name=e,this._parent=r,this._source=i}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 r=this._parent;for(;r;)e.unshift(r.name),r=r._parent;return e}hasParentExplore(){return this._parent!==void 0}isExplore(){return this instanceof Gs}isQuery(){return this instanceof tP}}class Gs extends VM{constructor(e,r,i){super(e.as||e.name,r,i),this._structDef=e,this._parentExplore=r,this.sourceExplore=i}get source(){return this.sourceExplore}isIntrinsic(){return(0,gi.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return(0,$n.annotationToTag)(this._structDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=(0,$n.annotationToTag)(this._structDef.modelAnnotation).tag),this.parsedModelTag}get name(){return this.structDef.as||this.structDef.name}getQueryByName(e){const r=this.sourceStructDef;if(!r)throw new Error(`Cannot get query by name from a struct of type ${this.structDef.type}`);const i={type:"query",structRef:r,pipeline:[{type:"reduce",queryFields:[{type:"fieldref",path:[e]}]}]};return new K2(i,this.modelDef,[],e)}get modelDef(){if(!(0,gi.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 Y2(this.modelDef,[],[])}get fieldMap(){var e;if(this._fieldMap===void 0){const r=((e=this.source)===null||e===void 0?void 0:e.fieldMap)||new Map;this._fieldMap=new Map(this.structDef.fields.map(i=>{const s=i.as||i.name,o=r.get(i.name);if((0,gi.isJoined)(i))return[s,new nP(i,this,o)];if(i.type==="turtle")return[s,new tP(i,this,o)];if(i.type==="string")return[s,new eP(i,this,o)];if(i.type==="number")return[s,new lD(i,this,o)];if(i.type==="date")return i.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(i.timeframe)?[s,new lD({...i,type:"number"},this,o)]:[s,new YM(i,this,o)];if(i.type==="timestamp")return[s,new KM(i,this,o)];if(i.type==="boolean")return[s,new JM(i,this,o)];if(i.type==="json")return[s,new XM(i,this,o)];if(i.type==="sql native")return[s,new ZM(i,this,o)]}))}return this._fieldMap}get allFields(){return[...this.fieldMap.values()]}get allFieldsWithOrder(){var e,r,i;if(!this._allFieldsWithOrder){const s=[...((i=(r=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||r===void 0?void 0:r.orderBy)===null||i===void 0?void 0:i.map(u=>{if(typeof u.field=="string")return{field:this.fieldMap.get(u.field),dir:u.dir};throw new Error("Does not support mapping order by from number.")}))||[]],o=new Set(s.map(u=>u.field.name));this._allFieldsWithOrder=[...s,...this.allFields.filter(u=>!o.has(u.name)).map(u=>({field:u,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 r=this.fieldMap.get(e);if(r===void 0)throw new Error(`No such field ${e}.`);return r}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 nP}get filters(){var e;return(0,gi.isSourceDef)(this.structDef)?((e=this.structDef.resultMetadata)===null||e===void 0?void 0:e.filterList)||[]:[]}get limit(){var e,r;return(r=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||r===void 0?void 0:r.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,gi.isSourceDef)(this.structDef))return this.structDef}toJSON(){var e,r;return{_structDef:this._structDef,sourceExplore:(e=this.sourceExplore)===null||e===void 0?void 0:e.toJSON(),_parentExplore:(r=this._parentExplore)===null||r===void 0?void 0:r.toJSON()}}static fromJSON(e){const r=e._parentExplore!==void 0?Gs.fromJSON(e._parentExplore):void 0,i=e.sourceExplore!==void 0?Gs.fromJSON(e.sourceExplore):void 0;return new Gs(e._structDef,r,i)}get location(){return this.structDef.location}}Ne.Explore=Gs;var Qa;(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"})(Qa||(Ne.AtomicFieldType=Qa={}));class ff extends VM{constructor(e,r,i){super(e.as||e.name,r,i),this.fieldTypeDef=e,this.parent=r}get type(){switch(this.fieldTypeDef.type){case"string":return Qa.String;case"boolean":return Qa.Boolean;case"date":return Qa.Date;case"timestamp":return Qa.Timestamp;case"number":return Qa.Number;case"json":return Qa.Json;case"sql native":return Qa.NativeUnsupported;case"error":return Qa.Error;case"record":case"array":throw new Error(`MTOY TODO IMPLEMENT Atomic ${this.fieldTypeDef.type}`);default:{const e=this.fieldTypeDef;throw new Error(`Can't make an atomic field from ${e}`)}}}tagParse(e){return e=(0,$n.addModelScope)(e,this.parent.modelTag),(0,$n.annotationToTag)(this.fieldTypeDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,gi.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,gi.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,r;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((r=this.fieldTypeDef.resultMetadata)===null||r===void 0?void 0:r.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 eP}isNumber(){return this instanceof lD}isDate(){return this instanceof YM}isBoolean(){return this instanceof JM}isJSON(){return this instanceof XM}isTimestamp(){return this instanceof KM}isUnsupported(){return this instanceof ZM}get parentExplore(){return this.parent}get expression(){const e=".",r=this.fieldTypeDef.resultMetadata;return(r==null?void 0:r.sourceExpression)||(r!=null&&r.sourceField.includes(e)?r==null?void 0:r.sourceField:this.name)}get location(){return this.fieldTypeDef.location}}Ne.AtomicField=ff;var Nd;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(Nd||(Ne.DateTimeframe=Nd={}));var Ga;(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"})(Ga||(Ne.TimestampTimeframe=Ga={}));class YM extends ff{constructor(e,r,i){super(e,r,i),this.fieldDateDef=e}get timeframe(){if(this.fieldDateDef.timeframe!==void 0)switch(this.fieldDateDef.timeframe){case"day":return Nd.Day;case"week":return Nd.Week;case"month":return Nd.Month;case"quarter":return Nd.Quarter;case"year":return Nd.Year}}}Ne.DateField=YM;class KM extends ff{constructor(e,r,i){super(e,r,i),this.fieldTimestampDef=e}get timeframe(){if(this.fieldTimestampDef.timeframe!==void 0)switch(this.fieldTimestampDef.timeframe){case"day":return Ga.Day;case"week":return Ga.Week;case"month":return Ga.Month;case"quarter":return Ga.Quarter;case"year":return Ga.Year;case"second":return Ga.Second;case"hour":return Ga.Hour;case"minute":return Ga.Minute}}}Ne.TimestampField=KM;class lD extends ff{constructor(e,r,i){super(e,r,i),this.fieldNumberDef=e}}Ne.NumberField=lD;class JM extends ff{constructor(e,r,i){super(e,r,i),this.fieldBooleanDef=e}}Ne.BooleanField=JM;class XM extends ff{constructor(e,r,i){super(e,r,i),this.fieldJSONDef=e}}Ne.JSONField=XM;class ZM extends ff{constructor(e,r,i){super(e,r,i),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}Ne.UnsupportedField=ZM;class eP extends ff{constructor(e,r,i){super(e,r,i),this.fieldStringDef=e}}Ne.StringField=eP;class qxe extends VM{constructor(e,r,i){super(e.as||e.name,r,i),this.turtleDef=e}get source(){return this.sourceQuery}isIntrinsic(){return!1}get location(){return this.turtleDef.location}}Ne.Query=qxe;class tP extends qxe{constructor(e,r,i){super(e,r,i),this.parent=r}tagParse(e){return e=(0,$n.addModelScope)(e,this.parent.modelTag),(0,$n.annotationToTag)(this.turtleDef.annotation,e)}getTaglines(e){return(0,$n.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}}Ne.QueryField=tP;var X2;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(X2||(Ne.JoinRelationship=X2={}));class nP extends Gs{constructor(e,r,i){super(e,r,i),this._parentExplore=r}get joinRelationship(){if((0,gi.isJoined)(this.structDef))switch(this.structDef.join){case"one":return X2.OneToOne;case"many":case"cross":return X2.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===X2.OneToOne}get isArray(){return this.joinRelationship!==X2.OneToOne}tagParse(e){return e=(0,$n.addModelScope)(e,this._parentExplore.modelTag),(0,$n.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]:[]}}Ne.ExploreField=nP;class rP{constructor({urlReader:e,connections:r,connection:i,eventStream:s,cacheManager:o}){if(this.isTestRuntime=!1,r===void 0){if(i===void 0)throw new Error("A LookupConnection<Connection> or Connection is required.");r={lookupConnection:()=>Promise.resolve(i)}}e===void 0&&(e=new Uxe),this._urlReader=e,this._connections=r,this._eventStream=s,this._cacheManager=o}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}loadModel(e,r){const{refreshSchemaCache:i,noThrowOnError:s}=r||{};this.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0});const o=e instanceof URL?{url:e}:{source:e};return new HE(this,async()=>A0.compile({...o,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:i,noThrowOnError:s,eventStream:this.eventStream,replaceMaterializedReferences:r==null?void 0:r.replaceMaterializedReferences,materializedTablePrefix:r==null?void 0:r.materializedTablePrefix,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,cacheManager:this.cacheManager}),r)}_loadModelFromModelDef(e,r){return new HE(this,async()=>new Y2(e,[],[]),r)}loadQuery(e,r){return this.loadModel(e,r).loadFinalQuery()}loadQueryByIndex(e,r,i){return this.loadModel(e,i).loadQueryByIndex(r,i)}loadQueryByName(e,r,i){return this.loadModel(e,i).loadQueryByName(r,i)}getModel(e,r){return this.loadModel(e,r).getModel()}getQuery(e,r){return this.loadQuery(e,r).getPreparedQuery()}getQueryByIndex(e,r,i){return this.loadQueryByIndex(e,r,i).getPreparedQuery()}getQueryByName(e,r,i){return this.loadQueryByName(e,r,i).getPreparedQuery()}}Ne.Runtime=rP;class oht extends rP{constructor({urlReader:e,connections:r}){super({connections:aD.fromArray(r),urlReader:e}),this.rawConnections=r}}Ne.ConnectionRuntime=oht;class uht extends rP{constructor({urlReader:e,connection:r,eventStream:i,cacheManager:s}){super({urlReader:e,eventStream:i,cacheManager:s,connection:r}),this.connection=r}get supportsNesting(){return(0,GM.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,GM.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,GM.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}Ne.SingleConnectionRuntime=uht;class cD{constructor(e,r){this.runtime=e,this._materialize=r}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(e,r){return new Hxe(this.runtime,e,r)}makeExploreMaterializer(e,r){return new Qxe(this.runtime,e,r)}makePreparedResultMaterializer(e){return new zxe(this.runtime,e)}}class HE extends cD{constructor(e,r,i){super(e,r),this.runtime=e,this.compileQueryOptions=i}loadFinalQuery(e){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...e})}loadQueryByIndex(e,r){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(e),{...this.compileQueryOptions,...r})}loadQueryByName(e,r){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(e),{...this.compileQueryOptions,...r})}loadQuery(e,r){const{refreshSchemaCache:i,noThrowOnError:s}=r||{};return this.makeQueryMaterializer(async()=>{const o=this.runtime.urlReader,u=this.runtime.connections;this.runtime.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0});const a=e instanceof URL?{url:e}:{source:e},l=await this.getModel();return(await A0.compile({...a,urlReader:o,connections:u,model:l,refreshSchemaCache:i,noThrowOnError:s,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,...this.compileQueryOptions})).preparedQuery})}extendModel(e,r){return this.runtime.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0}),new HE(this.runtime,async()=>{const i=this.runtime.urlReader,s=this.runtime.connections,o=e instanceof URL?{url:e}:{source:e},u=await this.getModel();return await A0.compile({...o,urlReader:i,connections:s,model:u,refreshSchemaCache:r==null?void 0:r.refreshSchemaCache,noThrowOnError:r==null?void 0:r.noThrowOnError,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,...this.compileQueryOptions})},r)}async search(e,r,i=1e3,s=void 0,o){const u=await this.materialize(),a=new gi.QueryModel(u._modelDef,o),l=u.getExploreByName(e).structDef;if(!(0,gi.isSourceDef)(l))throw new Error("Source to be searched was unexpectedly, not a source");const c=l.connection,f=await this.runtime.connections.lookupConnection(c);return await a.searchIndex(f,e,r,i,s)}async searchValueMap(e,r=10,i){const o=(await this.materialize()).getExploreByName(e);if(!(0,gi.isSourceDef)(o.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let u="{index: *}";o.getFieldByNameIfExists("search_index")&&(u="search_index");const a=`
|
|
1868
1868
|
run: ${e}
|
|
1869
1869
|
-> ${u}
|
|
@@ -151909,7 +151909,7 @@ jp.exploreQueryWalkerBuilder = wht;
|
|
|
151909
151909
|
var Ne = {}, AD = {};
|
|
151910
151910
|
Object.defineProperty(AD, "__esModule", { value: !0 });
|
|
151911
151911
|
AD.MALLOY_VERSION = void 0;
|
|
151912
|
-
AD.MALLOY_VERSION = "0.0.
|
|
151912
|
+
AD.MALLOY_VERSION = "0.0.243";
|
|
151913
151913
|
Object.defineProperty(Ne, "__esModule", { value: !0 });
|
|
151914
151914
|
Ne.InMemoryModelCache = Ne.CacheManager = Ne.CSVWriter = Ne.JSONWriter = Ne.DataWriter = Ne.DataRecord = Ne.DataArray = Ne.Result = Ne.ExploreMaterializer = Ne.PreparedResultMaterializer = Ne.QueryMaterializer = Ne.ModelMaterializer = Ne.SingleConnectionRuntime = Ne.ConnectionRuntime = Ne.Runtime = Ne.ExploreField = Ne.JoinRelationship = Ne.QueryField = Ne.Query = Ne.StringField = Ne.UnsupportedField = Ne.JSONField = Ne.BooleanField = Ne.NumberField = Ne.TimestampField = Ne.DateField = Ne.TimestampTimeframe = Ne.DateTimeframe = Ne.AtomicField = Ne.AtomicFieldType = Ne.Explore = Ne.SourceRelationship = Ne.FixedConnectionMap = Ne.InMemoryURLReader = Ne.EmptyURLReader = Ne.PreparedResult = Ne.DocumentCompletion = Ne.DocumentSymbol = Ne.DocumentPosition = Ne.DocumentRange = Ne.DocumentTablePath = Ne.Parse = Ne.PreparedQuery = Ne.Model = Ne.MalloyError = Ne.Malloy = void 0;
|
|
151915
151915
|
const fY = bT, ni = Vi, xY = mi, M7 = B2, Fht = AD, Nht = k2, Ln = xi, Lht = Xl, dY = "internal://internal.malloy";
|
|
@@ -1863,7 +1863,7 @@ wxxyyzz{{||}}}ҵ
|
|
|
1863
1863
|
| ${c}`,a>0&&(s=s+`
|
|
1864
1864
|
| ${" ".repeat(a)}^`)}else s=`line ${u+1}: char ${a}: ${i.message}`}r!==o&&(s=`FILE: ${o}
|
|
1865
1865
|
`+s,r=o),e!==""?e=`${e}
|
|
1866
|
-
${s}`:e=s}return e}childRequest(e){var r;const i=decodeURI(new URL(e,this.sourceURL).toString()),s=(r=this.childTranslators.get(i))===null||r===void 0?void 0:r.translate();if(s!=null&&s.compileSQL)return{compileSQL:s.compileSQL}}getChildExports(e){const r={},i=decodeURI(new URL(e,this.sourceURL).toString()),s=this.childTranslators.get(i);if(s&&s.translate().modelDef)for(const u of s.modelDef.exports){const a=s.modelDef.contents[u];((0,Ndt.isSourceDef)(a)||a.type==="query")&&(r[u]=a)}return r}translate(e){if(this.finalAnswer)return this.finalAnswer;const r=this.translateStep.step(this,e);return r.final&&(this.finalAnswer=r),r}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let r=0;r<this.imports.length;r++){const i=this.imports[r];if((0,HM.locationContainsPosition)(i.location,e))return i}}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(0,HM.rangeFromContext)(this.parseStep.sourceInfo,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const r=this.compilerFlags.tag("experimental");return r!==void 0&&(r.bare()||r.has("dialect",e))}}zc.MalloyTranslation=zM;class Oxe extends zM{constructor(e,r){super(e),this.root=r}}zc.MalloyChildTranslator=Oxe;class Zdt extends zM{constructor(e,r=null,i=null,s=null){super(e,r),this.eventStream=s,this.schemaZone=new qM.Zone,this.importZone=new qM.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new qM.Zone,this.root=this,this.logger=new Dxe.BaseMessageLogger(s),i&&this.update(i)}update(e){var r,i,s;this.schemaZone.updateFrom(e.tables,(r=e.errors)===null||r===void 0?void 0:r.tables),this.importZone.updateFrom(e.urls,(i=e.errors)===null||i===void 0?void 0:i.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(s=e.errors)===null||s===void 0?void 0:s.compileSQL);for(const o in e.translations)this.pretranslatedModels.set(o,e.translations[o])}logError(e,r,i){return this.logger.log((0,Dxe.makeLogMessage)(e,r,{severity:"error",...i})),e}}zc.MalloyTranslator=Zdt;function wxe(t){return[...Object.keys(t),...Object.keys(t).map(e=>wxe(t[e])).flat()]}var V2={};Object.defineProperty(V2,"__esModule",{value:!0}),V2.exploreQueryWalkerBuilder=V2.ExploreQueryWalker=void 0;const eht=C0;class Fxe{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}filterAtOffset(e){const r=this.exploreQueryAtOffset(e);if(r)return r.filterRefs.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e)}hasFilterListAtOffset(e){const r=this.exploreQueryAtOffset(e);return r?!!r.filterLists.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}V2.ExploreQueryWalker=Fxe;function tht(t,e){const r=new Fxe(t),i=r;return eht.ParseTreeWalker.DEFAULT.walk(i,e),r}V2.exploreQueryWalkerBuilder=tht,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=zc;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var r=V2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return r.exploreQueryWalkerBuilder}})}(b4);var Ne={},sD={};Object.defineProperty(sD,"__esModule",{value:!0}),sD.MALLOY_VERSION=void 0,sD.MALLOY_VERSION="0.0.
|
|
1866
|
+
${s}`:e=s}return e}childRequest(e){var r;const i=decodeURI(new URL(e,this.sourceURL).toString()),s=(r=this.childTranslators.get(i))===null||r===void 0?void 0:r.translate();if(s!=null&&s.compileSQL)return{compileSQL:s.compileSQL}}getChildExports(e){const r={},i=decodeURI(new URL(e,this.sourceURL).toString()),s=this.childTranslators.get(i);if(s&&s.translate().modelDef)for(const u of s.modelDef.exports){const a=s.modelDef.contents[u];((0,Ndt.isSourceDef)(a)||a.type==="query")&&(r[u]=a)}return r}translate(e){if(this.finalAnswer)return this.finalAnswer;const r=this.translateStep.step(this,e);return r.final&&(this.finalAnswer=r),r}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let r=0;r<this.imports.length;r++){const i=this.imports[r];if((0,HM.locationContainsPosition)(i.location,e))return i}}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(0,HM.rangeFromContext)(this.parseStep.sourceInfo,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const r=this.compilerFlags.tag("experimental");return r!==void 0&&(r.bare()||r.has("dialect",e))}}zc.MalloyTranslation=zM;class Oxe extends zM{constructor(e,r){super(e),this.root=r}}zc.MalloyChildTranslator=Oxe;class Zdt extends zM{constructor(e,r=null,i=null,s=null){super(e,r),this.eventStream=s,this.schemaZone=new qM.Zone,this.importZone=new qM.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new qM.Zone,this.root=this,this.logger=new Dxe.BaseMessageLogger(s),i&&this.update(i)}update(e){var r,i,s;this.schemaZone.updateFrom(e.tables,(r=e.errors)===null||r===void 0?void 0:r.tables),this.importZone.updateFrom(e.urls,(i=e.errors)===null||i===void 0?void 0:i.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(s=e.errors)===null||s===void 0?void 0:s.compileSQL);for(const o in e.translations)this.pretranslatedModels.set(o,e.translations[o])}logError(e,r,i){return this.logger.log((0,Dxe.makeLogMessage)(e,r,{severity:"error",...i})),e}}zc.MalloyTranslator=Zdt;function wxe(t){return[...Object.keys(t),...Object.keys(t).map(e=>wxe(t[e])).flat()]}var V2={};Object.defineProperty(V2,"__esModule",{value:!0}),V2.exploreQueryWalkerBuilder=V2.ExploreQueryWalker=void 0;const eht=C0;class Fxe{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}filterAtOffset(e){const r=this.exploreQueryAtOffset(e);if(r)return r.filterRefs.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e)}hasFilterListAtOffset(e){const r=this.exploreQueryAtOffset(e);return r?!!r.filterLists.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}V2.ExploreQueryWalker=Fxe;function tht(t,e){const r=new Fxe(t),i=r;return eht.ParseTreeWalker.DEFAULT.walk(i,e),r}V2.exploreQueryWalkerBuilder=tht,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=zc;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var r=V2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return r.exploreQueryWalkerBuilder}})}(b4);var Ne={},sD={};Object.defineProperty(sD,"__esModule",{value:!0}),sD.MALLOY_VERSION=void 0,sD.MALLOY_VERSION="0.0.243",Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.InMemoryModelCache=Ne.CacheManager=Ne.CSVWriter=Ne.JSONWriter=Ne.DataWriter=Ne.DataRecord=Ne.DataArray=Ne.Result=Ne.ExploreMaterializer=Ne.PreparedResultMaterializer=Ne.QueryMaterializer=Ne.ModelMaterializer=Ne.SingleConnectionRuntime=Ne.ConnectionRuntime=Ne.Runtime=Ne.ExploreField=Ne.JoinRelationship=Ne.QueryField=Ne.Query=Ne.StringField=Ne.UnsupportedField=Ne.JSONField=Ne.BooleanField=Ne.NumberField=Ne.TimestampField=Ne.DateField=Ne.TimestampTimeframe=Ne.DateTimeframe=Ne.AtomicField=Ne.AtomicFieldType=Ne.Explore=Ne.SourceRelationship=Ne.FixedConnectionMap=Ne.InMemoryURLReader=Ne.EmptyURLReader=Ne.PreparedResult=Ne.DocumentCompletion=Ne.DocumentSymbol=Ne.DocumentPosition=Ne.DocumentRange=Ne.DocumentTablePath=Ne.Parse=Ne.PreparedQuery=Ne.Model=Ne.MalloyError=Ne.Malloy=void 0;const Nxe=b4,gi=Gi,Lxe=ai,QM=l2,nht=sD,rht=f2,$n=hi,iht=d0,Ixe="internal://internal.malloy";let A0=class ND{static get version(){return nht.MALLOY_VERSION}static _parse(e,r,i,s,o){r===void 0&&(r=new URL(Ixe));let u=r;s!=null&&s.importBaseURL&&(u=s==null?void 0:s.importBaseURL);const a=new Nxe.MalloyTranslator(r.toString(),u.toString(),{urls:{[r.toString()]:e}},i);return s!=null&&s.testEnvironment&&(a.allDialectsEnabled=!0),new Bxe(a,o)}static parse({url:e,urlReader:r,source:i,eventStream:s,options:o}){if(i!==void 0)return ND._parse(i,e,s,o);if(r===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 dD(r,e).then(({contents:u,invalidationKey:a})=>ND._parse(u,e,s,o,a))}static async compile({url:e,source:r,parse:i,urlReader:s,connections:o,model:u,refreshSchemaCache:a,noThrowOnError:l,eventStream:c,importBaseURL:f,cacheManager:x}){var h,p,m,g,y;let E;if(a&&(E=typeof a=="number"?a:Date.now()),e===void 0&&r===void 0&&i===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(i!==void 0?e=new URL(i._translator.sourceURL):e=new URL(Ixe));const A={};if(r===void 0&&x!==void 0){const C=await x.getCachedModelDef(s,e.toString());if(C)return new Y2(C.modelDef,[],[e.toString(),...xD(C.modelDef.dependencies)])}f??(f=e);let _;const v=e.toString();if(i!==void 0){_=i._translator;const C=(h=i._invalidationKey)!==null&&h!==void 0?h:await iP(s,e);A[v]=C}else{if(r===void 0){const{contents:C,invalidationKey:S}=await dD(s,e);A[v]=S,r=C}else{const C=await iP(s,e);A[v]=C}_=new Nxe.MalloyTranslator(v,f.toString(),{urls:{[v]:r}},c)}for(;;){const C=_.translate(u==null?void 0:u._modelDef);if(C.final)if(C.modelDef){await(x==null?void 0:x.setCachedModelDef(e.toString(),{modelDef:C.modelDef,invalidationKeys:A}));for(const S of _.newlyTranslatedDependencies())await(x==null?void 0:x.setCachedModelDef(S.url,{modelDef:S.modelDef,invalidationKeys:A}));return new Y2(C.modelDef,C.problems||[],[...(p=u==null?void 0:u.fromSources)!==null&&p!==void 0?p:[],...(m=C.fromSources)!==null&&m!==void 0?m:[]],S=>_.referenceAt(S),S=>_.importAt(S))}else if(l){const S={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},b=(u==null?void 0:u._modelDef)||S;return new Y2(b,C.problems||[],[...(g=u==null?void 0:u.fromSources)!==null&&g!==void 0?g:[],...(y=C.fromSources)!==null&&y!==void 0?y:[]],R=>_.referenceAt(R),R=>_.importAt(R))}else{const S=C.problems||[],b=_.prettyErrors();throw new $xe(`Error(s) compiling model:
|
|
1867
1867
|
${b}`,S)}else{if(C.urls)for(const b of C.urls)try{if(hD(b))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(x!==void 0){const D=await x.getCachedModelDef(s,b);if(D){for(const $ in D.invalidationKeys)A[$]=D.invalidationKeys[$];_.update({translations:{[b]:D.modelDef}});continue}}const{contents:R,invalidationKey:N}=await dD(s,new URL(b)),B={[b]:R};A[b]=N,_.update({urls:B})}catch(R){_.update({errors:{urls:{[b]:R.message}}})}const{modelAnnotation:S}=_.modelAnnotation(u==null?void 0:u._modelDef);if(C.tables){const b=new Map;for(const R in C.tables){const{connectionName:N,tablePath:B}=C.tables[R],D=b.get(N);D===void 0?b.set(N,{[R]:B}):D[R]=B}for(const[R,N]of b)try{const B=await o.lookupConnection(R),{schemas:D,errors:$}=await ND.safelyFetchTableSchema(B,N,{refreshTimestamp:E,modelAnnotation:S});_.update({tables:D,errors:{tables:$}})}catch(B){const D={},$={};for(const j in N)$[j]=B.toString();_.update({tables:D,errors:{tables:$}})}}if(C.compileSQL){const b=C.compileSQL,R=b.connection,N=(0,iht.sqlKey)(b.connection,b.selectStr);try{const D=await(await o.lookupConnection(R)).fetchSchemaForSQLStruct(b,{refreshTimestamp:E,modelAnnotation:S});D.error&&_.update({errors:{compileSQL:{[N]:D.error}}}),D.structDef&&_.update({compileSQL:{[N]:D.structDef}})}catch(B){const D={};D[N]=B.toString(),_.update({errors:{compileSQL:D}})}}}}}static async safelyFetchTableSchema(e,r,i){const s=await e.fetchSchemaForTables(r,i);for(const o of Object.keys(r))if(s.schemas[o]===void 0&&s.errors[o]===void 0)throw new Error(`Schema fetch error for ${e.name}, no response for ${o} from ${e.dialectName}`);return s}static async run({connections:e,preparedResult:r,sqlStruct:i,connection:s,options:o}){if(!s){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const u=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName);s=await e.lookupConnection(u)}if(i){const u=await s.runSQL(i.selectStr);return new qE({structs:[i],sql:i.selectStr,result:u.rows,totalRows:u.totalRows,runStats:u.runStats,lastStageName:i.name,malloy:"",connectionName:i.connection,sourceExplore:"",sourceFilters:[],profilingUrl:u.profilingUrl},{name:"empty_model",exports:[],contents:{},queryList:[],dependencies:{}})}else if(r){const u=await s.runSQL(r.sql,o);return new qE({...r._rawQuery,result:u.rows,totalRows:u.totalRows,runStats:u.runStats,profilingUrl:u.profilingUrl},r._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:e,preparedResult:r,sqlStruct:i,connection:s,options:o}){if(i===void 0&&r===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const u=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName);if(s===void 0){if(e===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");s=await e.lookupConnection(u)}if(!s.canStream())throw new Error(`Connection '${u}' cannot stream results.`);let a,l;if(i)l=new Gs(i),a=i.selectStr;else if(r!==void 0)l=r.resultExplore,a=r.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let c=0;for await(const f of s.runSQLStream(a,o))yield new Ld(f,c,l,void 0,void 0),c+=1}static async estimateQueryCost({connections:e,preparedResult:r,sqlStruct:i}){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const s=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName),o=await e.lookupConnection(s);if(i)return await o.estimateQueryCost(i.selectStr);if(r)return await o.estimateQueryCost(r.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}};Ne.Malloy=A0;class $xe extends Error{constructor(e,r=[]){super(e),this.problems=r}}Ne.MalloyError=$xe;class Y2{constructor(e,r,i,s=()=>{},o=()=>{}){this.modelDef=e,this.problems=r,this.fromSources=i,this._referenceAt=s,this._importAt=o}tagParse(e){return(0,$n.annotationToTag)(this.modelDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.modelDef.annotation,e)}getReference(e){return this._referenceAt(e)}getImport(e){return this._importAt(e)}getPreparedQueryByName(e){const r=this.modelDef.contents[e];if((r==null?void 0:r.type)==="query")return new K2(r,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 K2(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 K2(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const r=this.modelDef.contents[e];if((0,gi.isSourceDef)(r))return new Gs(r);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(gi.isSourceDef).map(e=>new Gs(e))}get namedQueries(){const e=r=>r.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}}Ne.Model=Y2;class K2{constructor(e,r,i,s){this.problems=i,this.name=s,this._query=e,this._modelDef=r}tagParse(e){const r=(0,$n.annotationToTag)(this._modelDef.annotation).tag;return e=(0,$n.addModelScope)(e,r),(0,$n.annotationToTag)(this._query.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const i=new gi.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new UE({...i,queryName:this.name||i.queryName},this._modelDef)}get dialect(){const e=this._query.structRef,r=typeof e=="string"?this._modelDef.contents[e]:e;if(!(0,gi.isSourceDef)(r))throw new Error("Invalid source for query");return r.dialect}getFlattenedQuery(e){return this}}Ne.PreparedQuery=K2;class Bxe{constructor(e,r){this.translator=e,this.invalidationKey=r}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new oD(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(i=>new kxe(i))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(r=>new Mxe(r))}helpContext(e){return this.translator.helpContext(e).helpContext}}Ne.Parse=Bxe;class kxe{constructor(e){this._range=J2.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}}Ne.DocumentTablePath=kxe;class J2{constructor(e,r){this._start=e,this._end=r}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 J2(new GM(e.start.line,e.start.character),new GM(e.end.line,e.end.character))}}Ne.DocumentRange=J2;class GM{constructor(e,r){this._line=e,this._character=r}get line(){return this._line}get character(){return this._character}toJSON(){return{line:this.line,character:this.character}}}Ne.DocumentPosition=GM;class oD{constructor(e){this._range=J2.fromJSON(e.range),this._lensRange=e.lensRange?J2.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(r=>new oD(r))}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}}Ne.DocumentSymbol=oD;class Mxe{constructor(e){this.type=e.type,this.text=e.text}}Ne.DocumentCompletion=Mxe;class UE{constructor(e,r){this.modelDef=r,this.inner=e}static fromJson({query:e,modelDef:r}){if(!e||!r)throw new Error("Missing required properties in JSON data");return new UE(e,r)}tagParse(e){const r=(0,$n.annotationToTag)(this.modelDef.annotation).tag;return e=(0,$n.addModelScope)(e,r),(0,$n.annotationToTag)(this.inner.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return(0,$n.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],r={...e,annotation:this.inner.annotation,name:this.inner.queryName||e.name};try{return new Gs(r,this.sourceExplore)}catch{return new Gs(r)}}get sourceExplore(){const e=this.inner.sourceExplore,r=this.modelDef.contents[e];if(r&&(0,gi.isSourceDef)(r))return new Gs(r)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}Ne.PreparedResult=UE;class Pxe{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}Ne.EmptyURLReader=Pxe;class sht{constructor(e){this.files=e}async readURL(e){const r=this.files.get(e.toString());if(r!==void 0)return Promise.resolve({contents:r,invalidationKey:this.invalidationKey(e,r)});throw new Error(`File not found '${e}'`)}async getInvalidationKey(e){const r=this.files.get(e.toString());if(r!==void 0)return Promise.resolve(this.invalidationKey(e,r));throw new Error(`File not found '${e}'`)}invalidationKey(e,r){return hD(e.toString())?null:ede(r)}}Ne.InMemoryURLReader=sht;class uD{constructor(e,r){this.connections=e,this.defaultConnectionName=r}async getConnection(e){if(e===void 0)if(this.defaultConnectionName!==void 0)e=this.defaultConnectionName;else throw new Error("No default connection.");const r=this.connections.get(e);if(r!==void 0)return Promise.resolve(r);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 uD(new Map(e.map(r=>[r.name,r])))}}Ne.FixedConnectionMap=uD;var Uxe;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(Uxe||(Ne.SourceRelationship=Uxe={}));class WM{constructor(e,r,i){this._name=e,this._parent=r,this._source=i}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 r=this._parent;for(;r;)e.unshift(r.name),r=r._parent;return e}hasParentExplore(){return this._parent!==void 0}isExplore(){return this instanceof Gs}isQuery(){return this instanceof eP}}class Gs extends WM{constructor(e,r,i){super(e.as||e.name,r,i),this._structDef=e,this._parentExplore=r,this.sourceExplore=i}get source(){return this.sourceExplore}isIntrinsic(){return(0,gi.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return(0,$n.annotationToTag)(this._structDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=(0,$n.annotationToTag)(this._structDef.modelAnnotation).tag),this.parsedModelTag}get name(){return this.structDef.as||this.structDef.name}getQueryByName(e){const r=this.sourceStructDef;if(!r)throw new Error(`Cannot get query by name from a struct of type ${this.structDef.type}`);const i={type:"query",structRef:r,pipeline:[{type:"reduce",queryFields:[{type:"fieldref",path:[e]}]}]};return new K2(i,this.modelDef,[],e)}get modelDef(){if(!(0,gi.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 Y2(this.modelDef,[],[])}get fieldMap(){var e;if(this._fieldMap===void 0){const r=((e=this.source)===null||e===void 0?void 0:e.fieldMap)||new Map;this._fieldMap=new Map(this.structDef.fields.map(i=>{const s=i.as||i.name,o=r.get(i.name);if((0,gi.isJoined)(i))return[s,new tP(i,this,o)];if(i.type==="turtle")return[s,new eP(i,this,o)];if(i.type==="string")return[s,new ZM(i,this,o)];if(i.type==="number")return[s,new aD(i,this,o)];if(i.type==="date")return i.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(i.timeframe)?[s,new aD({...i,type:"number"},this,o)]:[s,new VM(i,this,o)];if(i.type==="timestamp")return[s,new YM(i,this,o)];if(i.type==="boolean")return[s,new KM(i,this,o)];if(i.type==="json")return[s,new JM(i,this,o)];if(i.type==="sql native")return[s,new XM(i,this,o)]}))}return this._fieldMap}get allFields(){return[...this.fieldMap.values()]}get allFieldsWithOrder(){var e,r,i;if(!this._allFieldsWithOrder){const s=[...((i=(r=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||r===void 0?void 0:r.orderBy)===null||i===void 0?void 0:i.map(u=>{if(typeof u.field=="string")return{field:this.fieldMap.get(u.field),dir:u.dir};throw new Error("Does not support mapping order by from number.")}))||[]],o=new Set(s.map(u=>u.field.name));this._allFieldsWithOrder=[...s,...this.allFields.filter(u=>!o.has(u.name)).map(u=>({field:u,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 r=this.fieldMap.get(e);if(r===void 0)throw new Error(`No such field ${e}.`);return r}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 tP}get filters(){var e;return(0,gi.isSourceDef)(this.structDef)?((e=this.structDef.resultMetadata)===null||e===void 0?void 0:e.filterList)||[]:[]}get limit(){var e,r;return(r=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||r===void 0?void 0:r.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,gi.isSourceDef)(this.structDef))return this.structDef}toJSON(){var e,r;return{_structDef:this._structDef,sourceExplore:(e=this.sourceExplore)===null||e===void 0?void 0:e.toJSON(),_parentExplore:(r=this._parentExplore)===null||r===void 0?void 0:r.toJSON()}}static fromJSON(e){const r=e._parentExplore!==void 0?Gs.fromJSON(e._parentExplore):void 0,i=e.sourceExplore!==void 0?Gs.fromJSON(e.sourceExplore):void 0;return new Gs(e._structDef,r,i)}get location(){return this.structDef.location}}Ne.Explore=Gs;var Qa;(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"})(Qa||(Ne.AtomicFieldType=Qa={}));class ff extends WM{constructor(e,r,i){super(e.as||e.name,r,i),this.fieldTypeDef=e,this.parent=r}get type(){switch(this.fieldTypeDef.type){case"string":return Qa.String;case"boolean":return Qa.Boolean;case"date":return Qa.Date;case"timestamp":return Qa.Timestamp;case"number":return Qa.Number;case"json":return Qa.Json;case"sql native":return Qa.NativeUnsupported;case"error":return Qa.Error;case"record":case"array":throw new Error(`MTOY TODO IMPLEMENT Atomic ${this.fieldTypeDef.type}`);default:{const e=this.fieldTypeDef;throw new Error(`Can't make an atomic field from ${e}`)}}}tagParse(e){return e=(0,$n.addModelScope)(e,this.parent.modelTag),(0,$n.annotationToTag)(this.fieldTypeDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,gi.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,gi.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,r;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((r=this.fieldTypeDef.resultMetadata)===null||r===void 0?void 0:r.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 ZM}isNumber(){return this instanceof aD}isDate(){return this instanceof VM}isBoolean(){return this instanceof KM}isJSON(){return this instanceof JM}isTimestamp(){return this instanceof YM}isUnsupported(){return this instanceof XM}get parentExplore(){return this.parent}get expression(){const e=".",r=this.fieldTypeDef.resultMetadata;return(r==null?void 0:r.sourceExpression)||(r!=null&&r.sourceField.includes(e)?r==null?void 0:r.sourceField:this.name)}get location(){return this.fieldTypeDef.location}}Ne.AtomicField=ff;var Nd;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(Nd||(Ne.DateTimeframe=Nd={}));var Ga;(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"})(Ga||(Ne.TimestampTimeframe=Ga={}));class VM extends ff{constructor(e,r,i){super(e,r,i),this.fieldDateDef=e}get timeframe(){if(this.fieldDateDef.timeframe!==void 0)switch(this.fieldDateDef.timeframe){case"day":return Nd.Day;case"week":return Nd.Week;case"month":return Nd.Month;case"quarter":return Nd.Quarter;case"year":return Nd.Year}}}Ne.DateField=VM;class YM extends ff{constructor(e,r,i){super(e,r,i),this.fieldTimestampDef=e}get timeframe(){if(this.fieldTimestampDef.timeframe!==void 0)switch(this.fieldTimestampDef.timeframe){case"day":return Ga.Day;case"week":return Ga.Week;case"month":return Ga.Month;case"quarter":return Ga.Quarter;case"year":return Ga.Year;case"second":return Ga.Second;case"hour":return Ga.Hour;case"minute":return Ga.Minute}}}Ne.TimestampField=YM;class aD extends ff{constructor(e,r,i){super(e,r,i),this.fieldNumberDef=e}}Ne.NumberField=aD;class KM extends ff{constructor(e,r,i){super(e,r,i),this.fieldBooleanDef=e}}Ne.BooleanField=KM;class JM extends ff{constructor(e,r,i){super(e,r,i),this.fieldJSONDef=e}}Ne.JSONField=JM;class XM extends ff{constructor(e,r,i){super(e,r,i),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}Ne.UnsupportedField=XM;class ZM extends ff{constructor(e,r,i){super(e,r,i),this.fieldStringDef=e}}Ne.StringField=ZM;class jxe extends WM{constructor(e,r,i){super(e.as||e.name,r,i),this.turtleDef=e}get source(){return this.sourceQuery}isIntrinsic(){return!1}get location(){return this.turtleDef.location}}Ne.Query=jxe;class eP extends jxe{constructor(e,r,i){super(e,r,i),this.parent=r}tagParse(e){return e=(0,$n.addModelScope)(e,this.parent.modelTag),(0,$n.annotationToTag)(this.turtleDef.annotation,e)}getTaglines(e){return(0,$n.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}}Ne.QueryField=eP;var X2;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(X2||(Ne.JoinRelationship=X2={}));class tP extends Gs{constructor(e,r,i){super(e,r,i),this._parentExplore=r}get joinRelationship(){if((0,gi.isJoined)(this.structDef))switch(this.structDef.join){case"one":return X2.OneToOne;case"many":case"cross":return X2.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===X2.OneToOne}get isArray(){return this.joinRelationship!==X2.OneToOne}tagParse(e){return e=(0,$n.addModelScope)(e,this._parentExplore.modelTag),(0,$n.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]:[]}}Ne.ExploreField=tP;class nP{constructor({urlReader:e,connections:r,connection:i,eventStream:s,cacheManager:o}){if(this.isTestRuntime=!1,r===void 0){if(i===void 0)throw new Error("A LookupConnection<Connection> or Connection is required.");r={lookupConnection:()=>Promise.resolve(i)}}e===void 0&&(e=new Pxe),this._urlReader=e,this._connections=r,this._eventStream=s,this._cacheManager=o}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}loadModel(e,r){const{refreshSchemaCache:i,noThrowOnError:s}=r||{};this.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0});const o=e instanceof URL?{url:e}:{source:e};return new jE(this,async()=>A0.compile({...o,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:i,noThrowOnError:s,eventStream:this.eventStream,replaceMaterializedReferences:r==null?void 0:r.replaceMaterializedReferences,materializedTablePrefix:r==null?void 0:r.materializedTablePrefix,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,cacheManager:this.cacheManager}),r)}_loadModelFromModelDef(e,r){return new jE(this,async()=>new Y2(e,[],[]),r)}loadQuery(e,r){return this.loadModel(e,r).loadFinalQuery()}loadQueryByIndex(e,r,i){return this.loadModel(e,i).loadQueryByIndex(r,i)}loadQueryByName(e,r,i){return this.loadModel(e,i).loadQueryByName(r,i)}getModel(e,r){return this.loadModel(e,r).getModel()}getQuery(e,r){return this.loadQuery(e,r).getPreparedQuery()}getQueryByIndex(e,r,i){return this.loadQueryByIndex(e,r,i).getPreparedQuery()}getQueryByName(e,r,i){return this.loadQueryByName(e,r,i).getPreparedQuery()}}Ne.Runtime=nP;class oht extends nP{constructor({urlReader:e,connections:r}){super({connections:uD.fromArray(r),urlReader:e}),this.rawConnections=r}}Ne.ConnectionRuntime=oht;class uht extends nP{constructor({urlReader:e,connection:r,eventStream:i,cacheManager:s}){super({urlReader:e,eventStream:i,cacheManager:s,connection:r}),this.connection=r}get supportsNesting(){return(0,QM.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,QM.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,QM.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}Ne.SingleConnectionRuntime=uht;class lD{constructor(e,r){this.runtime=e,this._materialize=r}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(e,r){return new qxe(this.runtime,e,r)}makeExploreMaterializer(e,r){return new zxe(this.runtime,e,r)}makePreparedResultMaterializer(e){return new Hxe(this.runtime,e)}}class jE extends lD{constructor(e,r,i){super(e,r),this.runtime=e,this.compileQueryOptions=i}loadFinalQuery(e){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...e})}loadQueryByIndex(e,r){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(e),{...this.compileQueryOptions,...r})}loadQueryByName(e,r){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(e),{...this.compileQueryOptions,...r})}loadQuery(e,r){const{refreshSchemaCache:i,noThrowOnError:s}=r||{};return this.makeQueryMaterializer(async()=>{const o=this.runtime.urlReader,u=this.runtime.connections;this.runtime.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0});const a=e instanceof URL?{url:e}:{source:e},l=await this.getModel();return(await A0.compile({...a,urlReader:o,connections:u,model:l,refreshSchemaCache:i,noThrowOnError:s,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,...this.compileQueryOptions})).preparedQuery})}extendModel(e,r){return this.runtime.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0}),new jE(this.runtime,async()=>{const i=this.runtime.urlReader,s=this.runtime.connections,o=e instanceof URL?{url:e}:{source:e},u=await this.getModel();return await A0.compile({...o,urlReader:i,connections:s,model:u,refreshSchemaCache:r==null?void 0:r.refreshSchemaCache,noThrowOnError:r==null?void 0:r.noThrowOnError,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,...this.compileQueryOptions})},r)}async search(e,r,i=1e3,s=void 0,o){const u=await this.materialize(),a=new gi.QueryModel(u._modelDef,o),l=u.getExploreByName(e).structDef;if(!(0,gi.isSourceDef)(l))throw new Error("Source to be searched was unexpectedly, not a source");const c=l.connection,f=await this.runtime.connections.lookupConnection(c);return await a.searchIndex(f,e,r,i,s)}async searchValueMap(e,r=10,i){const o=(await this.materialize()).getExploreByName(e);if(!(0,gi.isSourceDef)(o.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let u="{index: *}";o.getFieldByNameIfExists("search_index")&&(u="search_index");const a=`
|
|
1868
1868
|
run: ${e}
|
|
1869
1869
|
-> ${u}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/render",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.243-dev250313213354",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/module/index.umd.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"generate-flow": "ts-node ../../scripts/gen-flow.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@malloydata/db-duckdb": "^0.0.
|
|
36
|
-
"@malloydata/malloy": "^0.0.
|
|
37
|
-
"@malloydata/malloy-interfaces": "^0.0.
|
|
38
|
-
"@malloydata/malloy-tag": "^0.0.
|
|
35
|
+
"@malloydata/db-duckdb": "^0.0.243-dev250313213354",
|
|
36
|
+
"@malloydata/malloy": "^0.0.243-dev250313213354",
|
|
37
|
+
"@malloydata/malloy-interfaces": "^0.0.243-dev250313213354",
|
|
38
|
+
"@malloydata/malloy-tag": "^0.0.243-dev250313213354",
|
|
39
39
|
"@tanstack/solid-virtual": "^3.10.4",
|
|
40
40
|
"component-register": "^0.8.6",
|
|
41
41
|
"lodash": "^4.17.20",
|