@malloydata/render 0.0.429 → 0.0.430

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.
@@ -83685,7 +83685,7 @@ function u9e() {
83685
83685
  }
83686
83686
  var eg = {}, AA = {}, Vae;
83687
83687
  function l9e() {
83688
- return Vae || (Vae = 1, Object.defineProperty(AA, "__esModule", { value: !0 }), AA.MALLOY_VERSION = void 0, AA.MALLOY_VERSION = "0.0.429"), AA;
83688
+ return Vae || (Vae = 1, Object.defineProperty(AA, "__esModule", { value: !0 }), AA.MALLOY_VERSION = void 0, AA.MALLOY_VERSION = "0.0.430"), AA;
83689
83689
  }
83690
83690
  var Gae;
83691
83691
  function q1e() {
@@ -1380,7 +1380,7 @@ ${de}`:U=de}return U}childRequest(U){var X;const ae=decodeURI(new URL(U,this.sou
1380
1380
  `)}}this.stream.write(`
1381
1381
  ]
1382
1382
  `),this.stream.close()}}Ed.JSONWriter=n;class r extends t{constructor(){super(...arguments),this.columnSeparator=",",this.rowSeparator=`
1383
- `,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(s){const o=s.includes(this.quoteCharacter),a=s.includes(this.columnSeparator),u=s.includes(this.rowSeparator),c=a||o||u;return o&&(s=s.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),c&&(s=this.quoteCharacter+s+this.quoteCharacter),s}stringify(s){return s===null?this.emptyCell:s instanceof Date?s.toISOString():typeof s=="boolean"||typeof s=="number"?JSON.stringify(s):typeof s=="bigint"?s.toString():`${s}`}getColWeight(s){let o=s;Array.isArray(s)&&(o=s[0]);let a=0;for(const u in o){a=a+1;const c=o[u];if((0,e.isCompoundArrayData)(c)){const l=this.getColWeight(c)-1;a=a+l}}return a}getHeaderRow(s){const o=[];let a=0;for(const u in s){o.push(this.escape(u));const c=s[u];if(a++,(0,e.isCompoundArrayData)(c)){const l=this.getColWeight(c)-1;a=a+l;for(let f=0;f<l;f++)o.push(this.emptyCell)}}return{rows:[o.join(this.columnSeparator)],length:1,width:a}}mergeMatrices(s){const o=Math.max(...s.map(c=>c.length)),a=s.reduce((c,l)=>c+l.width,0),u=[];for(let c=0;c<o;c++){const l=[];for(const f of s)if(c<f.length)l.push(f.rows[c]);else{const d=Array(f.width).fill(this.emptyCell);l.push(...d)}u.push(l.join(this.columnSeparator))}return{rows:u,length:o,width:a}}getChildMatrix(s){if(Array.isArray(s)){if(s.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const o=[],a=this.getHeaderRow(s[0]);o.push(...a.rows);const u=a.width;let c=1;for(const l of s){const f=this.getRowMatrix(l);c=c+f.length,o.push(...f.rows)}return{rows:o,length:c,width:u}}getRowMatrix(s){const o=[];for(const a in s){const u=s[a];if((0,e.isCompoundArrayData)(u)){const c=this.getChildMatrix(u);o.push(c)}else{const c={rows:[this.stringify(u)],length:1,width:1};o.push(c)}}return this.mergeMatrices(o)}async process(s){let o=!1;for await(const a of s){if(!o&&this.includeHeader){const c=this.getHeaderRow(a.toObject());this.stream.write(c.rows[0]),this.stream.write(this.rowSeparator),o=!0}const u=this.getRowMatrix(a.toObject());for(const c of u.rows)this.stream.write(c),this.stream.write(this.rowSeparator)}this.stream.close()}}return Ed.CSVWriter=r,Ed}var cs={},dx={},cw={},ga={},kce;function GA(){if(kce)return ga;kce=1,Object.defineProperty(ga,"__esModule",{value:!0}),ga.isConnectionConfigEntry=e,ga.registerConnectionType=n,ga.getConnectionProperties=r,ga.getConnectionTypeDisplayName=i,ga.getRegisteredConnectionTypes=s,ga.getConnectionTypeDef=o,ga.validateConnectionConfigProperties=a,ga.readConnectionsConfig=u,ga.writeConnectionsConfig=c,ga.createConnectionsFromConfig=l;function e(f){return typeof f=="object"&&f!==null&&typeof f.is=="string"}const t=new Map;function n(f,d){t.set(f,d)}function r(f){var d;return(d=t.get(f))===null||d===void 0?void 0:d.properties}function i(f){var d;return(d=t.get(f))===null||d===void 0?void 0:d.displayName}function s(){return[...t.keys()]}function o(f){return t.get(f)}function a(f,d,p){var x,g;const m=(g=(x=t.get(d))===null||x===void 0?void 0:x.properties)!==null&&g!==void 0?g:[];for(const y of m){if(!y.requireLiteralString)continue;const E=p[y.name];if(E!==void 0&&typeof E!="string")throw new Error(`Connection "${f}" property "${y.name}" must be a literal string`)}}function u(f){var d;const p=JSON.parse(f),x=Object.fromEntries(Object.entries((d=p.connections)!==null&&d!==void 0?d:{}).filter(([,g])=>e(g)));return{...p,connections:x}}function c(f){return JSON.stringify(f,null,2)}function l(f,d){const p=Object.entries(f.connections),x=p.length>0?p[0][0]:void 0,g=new Map;return{async lookupConnection(m){if(m===void 0&&(m=x),m===void 0)throw new Error("No connections defined in config");const y=g.get(m);if(y)return y;const E=f.connections[m];if(!E)throw new Error(`No connection named "${m}" found in config`);const v=t.get(E.is);if(!v)throw new Error(`No registered connection type "${E.is}" for connection "${m}". Did you forget to import the connection package?`);const S={name:m};for(const[C,R]of Object.entries(E))C!=="is"&&R!=null&&(S[C]=R);a(m,E.is,S);const b=await v.factory(S);return d&&d(m,b),g.set(m,b),b},async close(){const m=[...g.values()];g.clear();for(const y of m)await y.close()},async idle(){for(const m of g.values())await m.idle()}}}return ga}var Pce;function a9e(){if(Pce)return cw;Pce=1,Object.defineProperty(cw,"__esModule",{value:!0}),cw.compileConfig=i;const e=GA(),t=tee(),n={connections:s,manifestPath:u,givensPath:c,finalizeGivens:l,virtualMap:f,includeDefaultConnections:d},r=new Set(Object.keys(n));function i(E){const v=[],S={kind:"dict",entries:{}};if(!x(E))return v.push({message:"config is not a JSON object",severity:"error",code:"config-validation"}),{compiled:S,log:v};for(const[b,C]of Object.entries(E)){const R=n[b];if(!R){const w=(0,t.closestMatch)(b,[...r]),T=w?`. Did you mean "${w}"?`:"";v.push(g(b,`unknown config key "${b}"${T}`));continue}const _=R(C,v);_!==void 0&&(S.entries[b]=_)}return{compiled:S,log:v}}function s(E,v){if(!x(E)){v.push(g("connections",'"connections" should be an object'));return}const S=new Set((0,e.getRegisteredConnectionTypes)()),b={kind:"dict",entries:{}};for(const[C,R]of Object.entries(E)){const _=`connections.${C}`;if(!x(R)){v.push(g(_,"should be an object"));continue}const w=R.is;if(w==null||w===""){v.push(g(_,'missing required "is" field (connection type)'));continue}if(typeof w!="string"){v.push(g(`${_}.is`,'"is" should be a string'));continue}if(!S.has(w)){const O=(0,t.closestMatch)(w,[...S]),F=O?` Did you mean "${O}"?`:"";v.push(g(`${_}.is`,`unknown connection type "${w}".${F} Available types: ${[...S].join(", ")}`));continue}const T=o(_,w,R,v);b.entries[C]=T}return b}function o(E,v,S,b){var C;const R=(C=(0,e.getConnectionProperties)(v))!==null&&C!==void 0?C:[],_=new Map(R.map(T=>[T.name,T])),w={kind:"dict",entries:{}};w.entries.is={kind:"value",value:v};for(const[T,O]of Object.entries(S)){if(T==="is")continue;const F=_.get(T);if(!F){const B=(0,t.closestMatch)(T,[..._.keys()]),j=B?`. Did you mean "${B}"?`:"";b.push(g(`${E}.${T}`,`unknown property "${T}" for connection type "${v}"${j}`));continue}const L=a(`${E}.${T}`,F,O,b);L!==void 0&&(w.entries[T]=L)}return w}function a(E,v,S,b){if(S==null)return;if(v.type==="json")return{kind:"value",value:S};const C=p(S);if(C!==void 0)return v.requireLiteralString?(b.push(g(E,"must be a literal string and cannot use an overlay reference")),{kind:"value",value:S}):C;const R=y(S,v.type);if(R){if(v.requireLiteralString)return b.push(g(E,`must be a literal string, got ${m(S)}`)),{kind:"value",value:S};b.push(g(E,`${R} (expected ${v.type})`));return}return{kind:"value",value:S}}function u(E,v){const S=p(E);if(S!==void 0)return S;if(typeof E!="string"){v.push(g("manifestPath",'"manifestPath" should be a string or an overlay reference'));return}return{kind:"value",value:E}}function c(E,v){const S=p(E);if(S!==void 0)return S;if(typeof E!="string"){v.push(g("givensPath",'"givensPath" should be a string or an overlay reference'));return}return{kind:"value",value:E}}function l(E,v){if(!Array.isArray(E)||!E.every(S=>typeof S=="string")){v.push(g("finalizeGivens",'"finalizeGivens" should be an array of given names'));return}return{kind:"value",value:E}}function f(E,v){return{kind:"value",value:E}}function d(E,v){return{kind:"value",value:E}}function p(E){if(typeof E!="object"||E===null||Array.isArray(E))return;const v=Object.keys(E);if(v.length!==1)return;const S=v[0],b=E[S];if(typeof b=="string")return{kind:"reference",source:S,path:[b]};if(Array.isArray(b)&&b.every(C=>typeof C=="string"))return{kind:"reference",source:S,path:b}}function x(E){return typeof E=="object"&&E!==null&&!Array.isArray(E)}function g(E,v){return{message:`${E}: ${v}`,severity:"warn",code:"config-validation"}}function m(E){return Array.isArray(E)?"array":typeof E}function y(E,v){switch(v){case"number":if(typeof E!="number")return`should be a number, got ${typeof E}`;break;case"boolean":if(typeof E!="boolean")return`should be a boolean, got ${typeof E}`;break;case"string":case"password":case"secret":case"file":case"text":if(typeof E!="string")return`should be a string, got ${typeof E}`;break}}return cw}var fw={},q1={},$ce;function Lk(){if($ce)return q1;$ce=1;var e={};Object.defineProperty(q1,"__esModule",{value:!0}),q1.envOverlay=t,q1.contextOverlay=n,q1.defaultConfigOverlays=r,q1.isThenable=i;function t(){return typeof process>"u"||!e?()=>{}:s=>e[s[0]]}function n(s){return o=>s[o[0]]}function r(){return{env:t(),config:()=>{}}}function i(s){return typeof s=="object"&&s!==null&&"then"in s&&typeof s.then=="function"}return q1}var Bce;function u9e(){if(Bce)return fw;Bce=1,Object.defineProperty(fw,"__esModule",{value:!0}),fw.prepareConfig=n;const e=GA(),t=Lk();function n(a,u,c){let l={},f,d,p,x,g=!1;for(const[m,y]of Object.entries(a.entries))switch(m){case"connections":{if(y.kind!=="dict")break;l=i(y);break}case"manifestPath":{f=o(y,u,c,"manifestPath");break}case"givensPath":{d=o(y,u,c,"givensPath");break}case"finalizeGivens":{y.kind==="value"&&r(y.value)&&(p=y.value);break}case"virtualMap":{y.kind==="value"&&(x=y.value);break}case"includeDefaultConnections":{y.kind==="value"&&typeof y.value=="boolean"&&(g=y.value);break}}return g&&s(l),{compiledConnections:l,manifestPath:f,givensPath:d,finalizeGivens:p,virtualMap:x}}function r(a){return Array.isArray(a)&&a.every(u=>typeof u=="string")}function i(a){const u={};for(const[c,l]of Object.entries(a.entries))l.kind==="dict"&&(u[c]=l);return u}function s(a){for(const u of(0,e.getRegisteredConnectionTypes)())a[u]||(a[u]={kind:"dict",entries:{is:{kind:"value",value:u}}})}function o(a,u,c,l){if(a.kind==="value")return typeof a.value=="string"?a.value:void 0;if(a.kind==="reference"){const f=u[a.source];if(!f){c.push({message:`unknown overlay source "${a.source}" for "${l}"`,severity:"warn",code:"config-overlay"});return}const d=f(a.path);if((0,t.isThenable)(d)){c.push({message:`the \`${a.source}\` overlay returned a Promise for "${l}"; top-level string settings must resolve synchronously`,severity:"warn",code:"config-overlay"});return}return typeof d=="string"?d:void 0}}return fw}var dw={},qce;function l9e(){if(qce)return dw;qce=1,Object.defineProperty(dw,"__esModule",{value:!0}),dw.buildManagedLookup=t;const e=GA();function t(a,u,c){const l=Object.entries(a),f=l.length>0?l[0][0]:void 0,d=new Map;return{async lookupConnection(p){if(p===void 0&&(p=f),p===void 0)throw new Error("No connections defined in config");const x=d.get(p);if(x)return x;const g=a[p];if(!g)throw new Error(`No connection named "${p}" found in config`);const m=await n(g,u,c);if(typeof m.is!="string")throw new Error(`Connection "${p}" is missing a valid "is" field`);const y=(0,e.getConnectionTypeDef)(m.is);if(!y)throw new Error(`No registered connection type "${m.is}" for connection "${p}". Did you forget to import the connection package?`);const E={name:p};for(const[S,b]of Object.entries(m))S!=="is"&&b!=null&&(E[S]=b);(0,e.validateConnectionConfigProperties)(p,m.is,E);const v=await y.factory(E);return d.set(p,v),v},async close(){const p=[...d.values()];d.clear();for(const x of p)await x.close()},async idle(){for(const p of d.values())await p.idle()}}}async function n(a,u,c){const l=await r(a,u,c);if(!(0,e.isConnectionConfigEntry)(l))throw new Error("Connection entry did not resolve to a valid {is: string, ...} dict");return await s(l,u),l}async function r(a,u,c){switch(a.kind){case"value":return a.value;case"reference":return i(a,u,c);case"dict":{const l={};for(const[f,d]of Object.entries(a.entries)){const p=await r(d,u,c);p!==void 0&&(l[f]=p)}return l}}}async function i(a,u,c){const l=u[a.source];if(!l){c.push({message:`unknown overlay source "${a.source}" for reference path ${JSON.stringify(a.path)}`,severity:"warn",code:"config-overlay"});return}return await l(a.path)}async function s(a,u){var c;const l=a.is;if(typeof l!="string")return;const f=(c=(0,e.getConnectionProperties)(l))!==null&&c!==void 0?c:[];for(const d of f){if(d.default===void 0||a[d.name]!==void 0)continue;const p=await o(d.default,u);p!==void 0&&(a[d.name]=p)}}async function o(a,u){if(typeof a!="object")return a;const c=Object.keys(a);if(c.length!==1)return;const l=c[0],f=a[l],d=typeof f=="string"?[f]:f;if(!Array.isArray(d))return;const p=u[l];if(p)return await p(d)}return dw}var Uce;function Ik(){if(Uce)return dx;Uce=1,Object.defineProperty(dx,"__esModule",{value:!0}),dx.MalloyConfig=dx.Manifest=void 0,dx.isBuildManifestEntry=E;const e=a9e(),t=u9e(),n=l9e(),r=Lk(),i=Ok();class s{constructor(){this._manifest={entries:{},strict:!1},this._touched=new Set}loadText(S){this._clearEntries(),this._touched.clear(),this._manifest.strict=!1,this._loadParsed(JSON.parse(S))}get buildManifest(){return this._manifest}get strict(){var S;return(S=this._manifest.strict)!==null&&S!==void 0?S:!1}set strict(S){this._manifest.strict=S}update(S,b){(0,i.requireCanonicalTablePathAnyDialect)(b.tableName,`Manifest entry '${S}'`),this._manifest.entries[S]=b,this._touched.add(S)}touch(S){this._touched.add(S)}get activeEntries(){const S={};for(const b of this._touched)this._manifest.entries[b]&&(S[b]=this._manifest.entries[b]);return{entries:S,strict:this._manifest.strict}}_clearEntries(){for(const S of Object.keys(this._manifest.entries))delete this._manifest.entries[S]}_loadParsed(S){typeof S.strict=="boolean"&&(this._manifest.strict=S.strict);const b=y(S.entries)?S.entries:S;for(const[C,R]of Object.entries(b))C==="strict"||!E(R)||((0,i.requireCanonicalTablePathAnyDialect)(R.tableName,`Manifest entry '${C}'`),this._manifest.entries[C]=R)}}dx.Manifest=s;class o{constructor(S,b){const C=[];let R;if(typeof S=="string")try{R=JSON.parse(S)}catch(B){C.push({message:`Invalid JSON: ${B instanceof Error?B.message:String(B)}`,severity:"error",code:"config-validation"}),R={}}else R=S;const _=(0,e.compileConfig)(R);C.push(..._.log);const w=f(b,C),T=g(w.configURL,"configURL",C),O=w.rootDirectory,F={...(0,r.defaultConfigOverlays)(),...w.overlays,config:(0,r.contextOverlay)({configURL:T,rootDirectory:O})},L=(0,t.prepareConfig)(_.compiled,F,C);this._managedLookup=(0,n.buildManagedLookup)(L.compiledConnections,F,C),this._connections=this._managedLookup,this._overlays=F,this.virtualMap=m(L.virtualMap,C),this.configURL=T,this.rootDirectory=O,this.manifestPath=L.manifestPath,this.manifestURL=c(L.manifestPath,T),this.givensPath=L.givensPath,this.givensURL=l(L.givensPath,T,C),this.finalizeGivens=L.finalizeGivens,this.log=C}get connections(){return this._connections}wrapConnections(S){this._connections=S(this._connections)}async shutdown(S="close"){S==="idle"?await this._managedLookup.idle():await this._managedLookup.close()}async releaseConnections(){await this.shutdown("close")}async readOverlay(S,...b){var C,R;return await((R=(C=this._overlays)[S])===null||R===void 0?void 0:R.call(C,b))}}dx.MalloyConfig=o;const a="MANIFESTS",u="malloy-manifest.json";function c(v,S){if(!S)return;let b;try{b=new URL(S)}catch{return}const C=v??a;let R;try{R=new URL(C,b)}catch{return}const _=R.toString(),w=_.endsWith("/")?R:new URL(_+"/");return new URL(u,w).toString()}function l(v,S,b){if(!v)return;if(!S){b.push({message:"givensPath is set but no configURL is available; per-runtime givens will not be loaded. Pass `configURL` (or use an absolute URL such as `file:///...`).",severity:"warn",code:"config-overlay"});return}let C;try{C=new URL(S)}catch{return}try{return new URL(v,C).toString()}catch(R){const _=R instanceof Error?R.message:String(R);b.push({message:`givensPath '${v}' could not be resolved against configURL '${S}': ${_}`,severity:"warn",code:"config-validation"});return}}function f(v,S){if(v===void 0)return{};if(d(v))return p(v,S);const b=v;if(b.overlays&&"config"in b.overlays){S.push({message:"`config` is reserved by MalloyConfig; pass `configURL` and `rootDirectory` directly instead. Supplied `overlays.config` ignored.",severity:"warn",code:"config-overlay"});const{config:C,...R}=b.overlays;return{...b,overlays:R}}return b}function d(v){for(const S of Object.values(v))if(typeof S=="function")return!0;return!1}function p(v,S){const b=v.config;if(!b)return{overlays:v};const C=x(b,"configURL",S),R=x(b,"rootDirectory",S),{config:_,...w}=v;return{configURL:C,rootDirectory:R,overlays:w}}function x(v,S,b){const C=v([S]);if((0,r.isThenable)(C)){b.push({message:`the legacy \`config\` overlay returned a Promise for \`${S}\`; top-level FS context must resolve synchronously. ${S} will be undefined.`,severity:"warn",code:"config-overlay"});return}return typeof C=="string"?C:void 0}function g(v,S,b){if(v!==void 0)try{return new URL(v),v}catch{b.push({message:`${S} must be a URL-shaped string (e.g. 'file:///path/to/...'), got '${v}'. In Node, use \`url.pathToFileURL(path).toString()\`.`,severity:"warn",code:"config-validation"});return}}function m(v,S){if(!y(v))return;const b=new Map;for(const[C,R]of Object.entries(v)){if(!y(R))continue;const _=new Map;for(const[w,T]of Object.entries(R)){if(typeof T!="string")continue;const O=(0,i.validateCanonicalTablePathAnyDialect)(T);if(O!==void 0){S.push({message:`virtualMap entry '${C}.${w}': ${O}`,severity:"error",code:"config-validation"});continue}_.set(w,T)}_.size>0&&b.set(C,_)}return b.size>0?b:void 0}function y(v){return typeof v=="object"&&v!==null&&!Array.isArray(v)}function E(v){return y(v)&&typeof v.tableName=="string"}return dx}var WA={},jce;function c9e(){if(jce)return WA;jce=1,Object.defineProperty(WA,"__esModule",{value:!0}),WA.resolvePersistWalk=t,WA.mkBuildTargets=i;function e(s,o){const a=s.get(o);if(a===void 0)throw new Error("build target "+String(o)+" vanished between passes");return a}function t(s,o){const a=[];for(const u of s._walkPersistSources(o))a.push({node:u,source:u.persistent?s._persistSourceFor(u.sourceID):void 0});return a}function n(s,o){return`${s}:${o}`}function r(s,o,a){for(const u of a)o.has(u)||(o.add(u),s.push(u))}function i(s,o){var a;const u=new Map,c=new Map;for(const{node:m,source:y}of s){const E=[],v=new Set;for(const O of m.dependsOn)r(E,v,(a=c.get(O))!==null&&a!==void 0?a:[]);if(y===void 0){c.set(m.sourceID,E);continue}const S=y.connectionName,b=o[S];if(b===void 0)throw new Error(`No connection digest for '${S}', needed to compute the BuildID of '${m.sourceID}'. Supply a digest for every connection named by a persist source.`);const C=y.getSQL(),R=y.makeBuildId(b,C),_=n(S,R);let w=u.get(_);w===void 0&&(w={buildId:R,connectionName:S,sql:C,sources:[],dependsOn:new Set},u.set(_,w));const T=new Set;for(const O of E)O!==_&&T.add(O);if(w.sources.length===0)w.dependsOn=T;else for(const O of[...w.dependsOn])T.has(O)||w.dependsOn.delete(O);w.sources.push(y),c.set(m.sourceID,[_])}const l=new Map;for(const[m,y]of u)l.set(m,{buildId:y.buildId,connectionName:y.connectionName,sql:y.sql,sources:y.sources,dependsOn:[]});for(const[m,y]of u){const E=e(l,m);for(const v of y.dependsOn)E.dependsOn.push(e(l,v))}const f=new Map,d=new Set,p=new Set,x=m=>{if(d.has(m))return;if(p.has(m)){const v=e(u,m).sources.map(S=>S.sourceID).join(", ");throw new Error(`Cycle in the persistence build graph at: ${v}`)}p.add(m);for(const v of e(u,m).dependsOn)x(v);p.delete(m),d.add(m);const y=e(l,m),E=f.get(y.connectionName);E===void 0?f.set(y.connectionName,[y]):E.push(y)};for(const m of u.keys())x(m);const g=[];for(const[m,y]of f)g.push({connectionName:m,targets:y});return g}return WA}var U1={},YA={},zce;function f9e(){return zce||(zce=1,Object.defineProperty(YA,"__esModule",{value:!0}),YA.MALLOY_VERSION=void 0,YA.MALLOY_VERSION="0.0.429"),YA}var Hce;function Qce(){if(Hce)return U1;Hce=1,Object.defineProperty(U1,"__esModule",{value:!0}),U1.Malloy=U1.MalloyError=void 0;const e=Fk(),t=GA(),n=Ti(),r=w4(),i=f9e(),s=uw(),o=Fce(),a=Xp(),u=lw(),c=Ice();function l(x="loadModel"){return`internal://${x}/${(0,a.v4)()}`}function f(x){return[...Object.keys(x),...Object.values(x).map(f).flat()]}class d extends Error{constructor(g,m=[]){super(g),this.problems=m}}U1.MalloyError=d;class p{static get version(){return i.MALLOY_VERSION}static registerConnectionType(g,m){(0,t.registerConnectionType)(g,m)}static getConnectionProperties(g){return(0,t.getConnectionProperties)(g)}static getConnectionTypeDisplayName(g){return(0,t.getConnectionTypeDisplayName)(g)}static getRegisteredConnectionTypes(){return(0,t.getRegisteredConnectionTypes)()}static _parse(g,m,y,E,v){var S;m===void 0&&(m=new URL(l(E==null?void 0:E.method)));let b=m;E!=null&&E.importBaseURL&&(b=E==null?void 0:E.importBaseURL);const C=new e.MalloyTranslator(m.toString(),b.toString(),{urls:{[m.toString()]:g}},y,(S=E==null?void 0:E.restrictedMode)!==null&&S!==void 0?S:!1);return E!=null&&E.testEnvironment&&(C.allDialectsEnabled=!0),new o.Parse(C,v)}static parse({url:g,urlReader:m,source:y,eventStream:E,options:v}){if(y!==void 0)return p._parse(y,g,E,v);if(m===void 0)throw new Error("Internal Error: urlReader is required.");if(g===void 0)throw new Error("Internal Error: url is required if source not present.");return(0,s.readURL)(m,g).then(({contents:S,invalidationKey:b})=>p._parse(S,g,E,v,b))}static async compile(g){var m,y,E,v,S;let{url:b,source:C,importBaseURL:R,cacheManager:_}=g;const{parse:w,urlReader:T,connections:O,model:F,refreshSchemaCache:L,noThrowOnError:B,eventStream:j,restrictedMode:W,method:te}=g;W&&(_=void 0);let se;if(L&&(se=typeof L=="number"?L:Date.now()),b===void 0&&C===void 0&&w===void 0)throw new Error("Internal Error: url, source, or parse required.");b===void 0&&(w!==void 0?b=new URL(w._translator.sourceURL):b=new URL(l(te)));const U={};if(C===void 0&&_!==void 0){const de=await _.getCachedModelDef(T,b.toString());if(de)return new u.Model(de.modelDef,[],[b.toString(),...f(de.modelDef.dependencies)])}R??(R=b);let X;const ae=b.toString();if(w!==void 0){if(W!==void 0&&w._translator.restrictedMode!==W)throw new Error(`Malloy.compile: restrictedMode (${W}) does not match the pre-parsed translator's restrictedMode (${w._translator.restrictedMode}). Set restrictedMode at parse time.`);X=w._translator;const de=(m=w._invalidationKey)!==null&&m!==void 0?m:await(0,s.getInvalidationKey)(T,b);U[ae]=de}else{if(C===void 0){const{contents:de,invalidationKey:I}=await(0,s.readURL)(T,b);U[ae]=I,C=de}else{const de=await(0,s.getInvalidationKey)(T,b);U[ae]=de}X=new e.MalloyTranslator(ae,R.toString(),{urls:{[ae]:C}},j,W??!1)}for(;;){const de=X.translate(F==null?void 0:F._modelDef);if(de.final)if(de.modelDef){await(_==null?void 0:_.setCachedModelDef(b.toString(),{modelDef:de.modelDef,invalidationKeys:U}));for(const q of X.newlyTranslatedDependencies())await(_==null?void 0:_.setCachedModelDef(q.url,{modelDef:q.modelDef,invalidationKeys:U}));const I=!de.modelWasModified&&F?F.getExistingQueryModel():void 0;return new u.Model(de.modelDef,de.problems||[],[...(y=F==null?void 0:F.fromSources)!==null&&y!==void 0?y:[],...(E=de.fromSources)!==null&&E!==void 0?E:[]],I)}else if(B){const I=(0,n.mkModelDef)("modelDidNotCompile"),q=(F==null?void 0:F._modelDef)||I;return new u.Model(q,de.problems||[],[...(v=F==null?void 0:F.fromSources)!==null&&v!==void 0?v:[],...(S=de.fromSources)!==null&&S!==void 0?S:[]])}else{const I=de.problems||[],q=X.prettyErrors();throw new d(`Error(s) compiling model:
1383
+ `,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(s){const o=s.includes(this.quoteCharacter),a=s.includes(this.columnSeparator),u=s.includes(this.rowSeparator),c=a||o||u;return o&&(s=s.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),c&&(s=this.quoteCharacter+s+this.quoteCharacter),s}stringify(s){return s===null?this.emptyCell:s instanceof Date?s.toISOString():typeof s=="boolean"||typeof s=="number"?JSON.stringify(s):typeof s=="bigint"?s.toString():`${s}`}getColWeight(s){let o=s;Array.isArray(s)&&(o=s[0]);let a=0;for(const u in o){a=a+1;const c=o[u];if((0,e.isCompoundArrayData)(c)){const l=this.getColWeight(c)-1;a=a+l}}return a}getHeaderRow(s){const o=[];let a=0;for(const u in s){o.push(this.escape(u));const c=s[u];if(a++,(0,e.isCompoundArrayData)(c)){const l=this.getColWeight(c)-1;a=a+l;for(let f=0;f<l;f++)o.push(this.emptyCell)}}return{rows:[o.join(this.columnSeparator)],length:1,width:a}}mergeMatrices(s){const o=Math.max(...s.map(c=>c.length)),a=s.reduce((c,l)=>c+l.width,0),u=[];for(let c=0;c<o;c++){const l=[];for(const f of s)if(c<f.length)l.push(f.rows[c]);else{const d=Array(f.width).fill(this.emptyCell);l.push(...d)}u.push(l.join(this.columnSeparator))}return{rows:u,length:o,width:a}}getChildMatrix(s){if(Array.isArray(s)){if(s.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const o=[],a=this.getHeaderRow(s[0]);o.push(...a.rows);const u=a.width;let c=1;for(const l of s){const f=this.getRowMatrix(l);c=c+f.length,o.push(...f.rows)}return{rows:o,length:c,width:u}}getRowMatrix(s){const o=[];for(const a in s){const u=s[a];if((0,e.isCompoundArrayData)(u)){const c=this.getChildMatrix(u);o.push(c)}else{const c={rows:[this.stringify(u)],length:1,width:1};o.push(c)}}return this.mergeMatrices(o)}async process(s){let o=!1;for await(const a of s){if(!o&&this.includeHeader){const c=this.getHeaderRow(a.toObject());this.stream.write(c.rows[0]),this.stream.write(this.rowSeparator),o=!0}const u=this.getRowMatrix(a.toObject());for(const c of u.rows)this.stream.write(c),this.stream.write(this.rowSeparator)}this.stream.close()}}return Ed.CSVWriter=r,Ed}var cs={},dx={},cw={},ga={},kce;function GA(){if(kce)return ga;kce=1,Object.defineProperty(ga,"__esModule",{value:!0}),ga.isConnectionConfigEntry=e,ga.registerConnectionType=n,ga.getConnectionProperties=r,ga.getConnectionTypeDisplayName=i,ga.getRegisteredConnectionTypes=s,ga.getConnectionTypeDef=o,ga.validateConnectionConfigProperties=a,ga.readConnectionsConfig=u,ga.writeConnectionsConfig=c,ga.createConnectionsFromConfig=l;function e(f){return typeof f=="object"&&f!==null&&typeof f.is=="string"}const t=new Map;function n(f,d){t.set(f,d)}function r(f){var d;return(d=t.get(f))===null||d===void 0?void 0:d.properties}function i(f){var d;return(d=t.get(f))===null||d===void 0?void 0:d.displayName}function s(){return[...t.keys()]}function o(f){return t.get(f)}function a(f,d,p){var x,g;const m=(g=(x=t.get(d))===null||x===void 0?void 0:x.properties)!==null&&g!==void 0?g:[];for(const y of m){if(!y.requireLiteralString)continue;const E=p[y.name];if(E!==void 0&&typeof E!="string")throw new Error(`Connection "${f}" property "${y.name}" must be a literal string`)}}function u(f){var d;const p=JSON.parse(f),x=Object.fromEntries(Object.entries((d=p.connections)!==null&&d!==void 0?d:{}).filter(([,g])=>e(g)));return{...p,connections:x}}function c(f){return JSON.stringify(f,null,2)}function l(f,d){const p=Object.entries(f.connections),x=p.length>0?p[0][0]:void 0,g=new Map;return{async lookupConnection(m){if(m===void 0&&(m=x),m===void 0)throw new Error("No connections defined in config");const y=g.get(m);if(y)return y;const E=f.connections[m];if(!E)throw new Error(`No connection named "${m}" found in config`);const v=t.get(E.is);if(!v)throw new Error(`No registered connection type "${E.is}" for connection "${m}". Did you forget to import the connection package?`);const S={name:m};for(const[C,R]of Object.entries(E))C!=="is"&&R!=null&&(S[C]=R);a(m,E.is,S);const b=await v.factory(S);return d&&d(m,b),g.set(m,b),b},async close(){const m=[...g.values()];g.clear();for(const y of m)await y.close()},async idle(){for(const m of g.values())await m.idle()}}}return ga}var Pce;function a9e(){if(Pce)return cw;Pce=1,Object.defineProperty(cw,"__esModule",{value:!0}),cw.compileConfig=i;const e=GA(),t=tee(),n={connections:s,manifestPath:u,givensPath:c,finalizeGivens:l,virtualMap:f,includeDefaultConnections:d},r=new Set(Object.keys(n));function i(E){const v=[],S={kind:"dict",entries:{}};if(!x(E))return v.push({message:"config is not a JSON object",severity:"error",code:"config-validation"}),{compiled:S,log:v};for(const[b,C]of Object.entries(E)){const R=n[b];if(!R){const w=(0,t.closestMatch)(b,[...r]),T=w?`. Did you mean "${w}"?`:"";v.push(g(b,`unknown config key "${b}"${T}`));continue}const _=R(C,v);_!==void 0&&(S.entries[b]=_)}return{compiled:S,log:v}}function s(E,v){if(!x(E)){v.push(g("connections",'"connections" should be an object'));return}const S=new Set((0,e.getRegisteredConnectionTypes)()),b={kind:"dict",entries:{}};for(const[C,R]of Object.entries(E)){const _=`connections.${C}`;if(!x(R)){v.push(g(_,"should be an object"));continue}const w=R.is;if(w==null||w===""){v.push(g(_,'missing required "is" field (connection type)'));continue}if(typeof w!="string"){v.push(g(`${_}.is`,'"is" should be a string'));continue}if(!S.has(w)){const O=(0,t.closestMatch)(w,[...S]),F=O?` Did you mean "${O}"?`:"";v.push(g(`${_}.is`,`unknown connection type "${w}".${F} Available types: ${[...S].join(", ")}`));continue}const T=o(_,w,R,v);b.entries[C]=T}return b}function o(E,v,S,b){var C;const R=(C=(0,e.getConnectionProperties)(v))!==null&&C!==void 0?C:[],_=new Map(R.map(T=>[T.name,T])),w={kind:"dict",entries:{}};w.entries.is={kind:"value",value:v};for(const[T,O]of Object.entries(S)){if(T==="is")continue;const F=_.get(T);if(!F){const B=(0,t.closestMatch)(T,[..._.keys()]),j=B?`. Did you mean "${B}"?`:"";b.push(g(`${E}.${T}`,`unknown property "${T}" for connection type "${v}"${j}`));continue}const L=a(`${E}.${T}`,F,O,b);L!==void 0&&(w.entries[T]=L)}return w}function a(E,v,S,b){if(S==null)return;if(v.type==="json")return{kind:"value",value:S};const C=p(S);if(C!==void 0)return v.requireLiteralString?(b.push(g(E,"must be a literal string and cannot use an overlay reference")),{kind:"value",value:S}):C;const R=y(S,v.type);if(R){if(v.requireLiteralString)return b.push(g(E,`must be a literal string, got ${m(S)}`)),{kind:"value",value:S};b.push(g(E,`${R} (expected ${v.type})`));return}return{kind:"value",value:S}}function u(E,v){const S=p(E);if(S!==void 0)return S;if(typeof E!="string"){v.push(g("manifestPath",'"manifestPath" should be a string or an overlay reference'));return}return{kind:"value",value:E}}function c(E,v){const S=p(E);if(S!==void 0)return S;if(typeof E!="string"){v.push(g("givensPath",'"givensPath" should be a string or an overlay reference'));return}return{kind:"value",value:E}}function l(E,v){if(!Array.isArray(E)||!E.every(S=>typeof S=="string")){v.push(g("finalizeGivens",'"finalizeGivens" should be an array of given names'));return}return{kind:"value",value:E}}function f(E,v){return{kind:"value",value:E}}function d(E,v){return{kind:"value",value:E}}function p(E){if(typeof E!="object"||E===null||Array.isArray(E))return;const v=Object.keys(E);if(v.length!==1)return;const S=v[0],b=E[S];if(typeof b=="string")return{kind:"reference",source:S,path:[b]};if(Array.isArray(b)&&b.every(C=>typeof C=="string"))return{kind:"reference",source:S,path:b}}function x(E){return typeof E=="object"&&E!==null&&!Array.isArray(E)}function g(E,v){return{message:`${E}: ${v}`,severity:"warn",code:"config-validation"}}function m(E){return Array.isArray(E)?"array":typeof E}function y(E,v){switch(v){case"number":if(typeof E!="number")return`should be a number, got ${typeof E}`;break;case"boolean":if(typeof E!="boolean")return`should be a boolean, got ${typeof E}`;break;case"string":case"password":case"secret":case"file":case"text":if(typeof E!="string")return`should be a string, got ${typeof E}`;break}}return cw}var fw={},q1={},$ce;function Lk(){if($ce)return q1;$ce=1;var e={};Object.defineProperty(q1,"__esModule",{value:!0}),q1.envOverlay=t,q1.contextOverlay=n,q1.defaultConfigOverlays=r,q1.isThenable=i;function t(){return typeof process>"u"||!e?()=>{}:s=>e[s[0]]}function n(s){return o=>s[o[0]]}function r(){return{env:t(),config:()=>{}}}function i(s){return typeof s=="object"&&s!==null&&"then"in s&&typeof s.then=="function"}return q1}var Bce;function u9e(){if(Bce)return fw;Bce=1,Object.defineProperty(fw,"__esModule",{value:!0}),fw.prepareConfig=n;const e=GA(),t=Lk();function n(a,u,c){let l={},f,d,p,x,g=!1;for(const[m,y]of Object.entries(a.entries))switch(m){case"connections":{if(y.kind!=="dict")break;l=i(y);break}case"manifestPath":{f=o(y,u,c,"manifestPath");break}case"givensPath":{d=o(y,u,c,"givensPath");break}case"finalizeGivens":{y.kind==="value"&&r(y.value)&&(p=y.value);break}case"virtualMap":{y.kind==="value"&&(x=y.value);break}case"includeDefaultConnections":{y.kind==="value"&&typeof y.value=="boolean"&&(g=y.value);break}}return g&&s(l),{compiledConnections:l,manifestPath:f,givensPath:d,finalizeGivens:p,virtualMap:x}}function r(a){return Array.isArray(a)&&a.every(u=>typeof u=="string")}function i(a){const u={};for(const[c,l]of Object.entries(a.entries))l.kind==="dict"&&(u[c]=l);return u}function s(a){for(const u of(0,e.getRegisteredConnectionTypes)())a[u]||(a[u]={kind:"dict",entries:{is:{kind:"value",value:u}}})}function o(a,u,c,l){if(a.kind==="value")return typeof a.value=="string"?a.value:void 0;if(a.kind==="reference"){const f=u[a.source];if(!f){c.push({message:`unknown overlay source "${a.source}" for "${l}"`,severity:"warn",code:"config-overlay"});return}const d=f(a.path);if((0,t.isThenable)(d)){c.push({message:`the \`${a.source}\` overlay returned a Promise for "${l}"; top-level string settings must resolve synchronously`,severity:"warn",code:"config-overlay"});return}return typeof d=="string"?d:void 0}}return fw}var dw={},qce;function l9e(){if(qce)return dw;qce=1,Object.defineProperty(dw,"__esModule",{value:!0}),dw.buildManagedLookup=t;const e=GA();function t(a,u,c){const l=Object.entries(a),f=l.length>0?l[0][0]:void 0,d=new Map;return{async lookupConnection(p){if(p===void 0&&(p=f),p===void 0)throw new Error("No connections defined in config");const x=d.get(p);if(x)return x;const g=a[p];if(!g)throw new Error(`No connection named "${p}" found in config`);const m=await n(g,u,c);if(typeof m.is!="string")throw new Error(`Connection "${p}" is missing a valid "is" field`);const y=(0,e.getConnectionTypeDef)(m.is);if(!y)throw new Error(`No registered connection type "${m.is}" for connection "${p}". Did you forget to import the connection package?`);const E={name:p};for(const[S,b]of Object.entries(m))S!=="is"&&b!=null&&(E[S]=b);(0,e.validateConnectionConfigProperties)(p,m.is,E);const v=await y.factory(E);return d.set(p,v),v},async close(){const p=[...d.values()];d.clear();for(const x of p)await x.close()},async idle(){for(const p of d.values())await p.idle()}}}async function n(a,u,c){const l=await r(a,u,c);if(!(0,e.isConnectionConfigEntry)(l))throw new Error("Connection entry did not resolve to a valid {is: string, ...} dict");return await s(l,u),l}async function r(a,u,c){switch(a.kind){case"value":return a.value;case"reference":return i(a,u,c);case"dict":{const l={};for(const[f,d]of Object.entries(a.entries)){const p=await r(d,u,c);p!==void 0&&(l[f]=p)}return l}}}async function i(a,u,c){const l=u[a.source];if(!l){c.push({message:`unknown overlay source "${a.source}" for reference path ${JSON.stringify(a.path)}`,severity:"warn",code:"config-overlay"});return}return await l(a.path)}async function s(a,u){var c;const l=a.is;if(typeof l!="string")return;const f=(c=(0,e.getConnectionProperties)(l))!==null&&c!==void 0?c:[];for(const d of f){if(d.default===void 0||a[d.name]!==void 0)continue;const p=await o(d.default,u);p!==void 0&&(a[d.name]=p)}}async function o(a,u){if(typeof a!="object")return a;const c=Object.keys(a);if(c.length!==1)return;const l=c[0],f=a[l],d=typeof f=="string"?[f]:f;if(!Array.isArray(d))return;const p=u[l];if(p)return await p(d)}return dw}var Uce;function Ik(){if(Uce)return dx;Uce=1,Object.defineProperty(dx,"__esModule",{value:!0}),dx.MalloyConfig=dx.Manifest=void 0,dx.isBuildManifestEntry=E;const e=a9e(),t=u9e(),n=l9e(),r=Lk(),i=Ok();class s{constructor(){this._manifest={entries:{},strict:!1},this._touched=new Set}loadText(S){this._clearEntries(),this._touched.clear(),this._manifest.strict=!1,this._loadParsed(JSON.parse(S))}get buildManifest(){return this._manifest}get strict(){var S;return(S=this._manifest.strict)!==null&&S!==void 0?S:!1}set strict(S){this._manifest.strict=S}update(S,b){(0,i.requireCanonicalTablePathAnyDialect)(b.tableName,`Manifest entry '${S}'`),this._manifest.entries[S]=b,this._touched.add(S)}touch(S){this._touched.add(S)}get activeEntries(){const S={};for(const b of this._touched)this._manifest.entries[b]&&(S[b]=this._manifest.entries[b]);return{entries:S,strict:this._manifest.strict}}_clearEntries(){for(const S of Object.keys(this._manifest.entries))delete this._manifest.entries[S]}_loadParsed(S){typeof S.strict=="boolean"&&(this._manifest.strict=S.strict);const b=y(S.entries)?S.entries:S;for(const[C,R]of Object.entries(b))C==="strict"||!E(R)||((0,i.requireCanonicalTablePathAnyDialect)(R.tableName,`Manifest entry '${C}'`),this._manifest.entries[C]=R)}}dx.Manifest=s;class o{constructor(S,b){const C=[];let R;if(typeof S=="string")try{R=JSON.parse(S)}catch(B){C.push({message:`Invalid JSON: ${B instanceof Error?B.message:String(B)}`,severity:"error",code:"config-validation"}),R={}}else R=S;const _=(0,e.compileConfig)(R);C.push(..._.log);const w=f(b,C),T=g(w.configURL,"configURL",C),O=w.rootDirectory,F={...(0,r.defaultConfigOverlays)(),...w.overlays,config:(0,r.contextOverlay)({configURL:T,rootDirectory:O})},L=(0,t.prepareConfig)(_.compiled,F,C);this._managedLookup=(0,n.buildManagedLookup)(L.compiledConnections,F,C),this._connections=this._managedLookup,this._overlays=F,this.virtualMap=m(L.virtualMap,C),this.configURL=T,this.rootDirectory=O,this.manifestPath=L.manifestPath,this.manifestURL=c(L.manifestPath,T),this.givensPath=L.givensPath,this.givensURL=l(L.givensPath,T,C),this.finalizeGivens=L.finalizeGivens,this.log=C}get connections(){return this._connections}wrapConnections(S){this._connections=S(this._connections)}async shutdown(S="close"){S==="idle"?await this._managedLookup.idle():await this._managedLookup.close()}async releaseConnections(){await this.shutdown("close")}async readOverlay(S,...b){var C,R;return await((R=(C=this._overlays)[S])===null||R===void 0?void 0:R.call(C,b))}}dx.MalloyConfig=o;const a="MANIFESTS",u="malloy-manifest.json";function c(v,S){if(!S)return;let b;try{b=new URL(S)}catch{return}const C=v??a;let R;try{R=new URL(C,b)}catch{return}const _=R.toString(),w=_.endsWith("/")?R:new URL(_+"/");return new URL(u,w).toString()}function l(v,S,b){if(!v)return;if(!S){b.push({message:"givensPath is set but no configURL is available; per-runtime givens will not be loaded. Pass `configURL` (or use an absolute URL such as `file:///...`).",severity:"warn",code:"config-overlay"});return}let C;try{C=new URL(S)}catch{return}try{return new URL(v,C).toString()}catch(R){const _=R instanceof Error?R.message:String(R);b.push({message:`givensPath '${v}' could not be resolved against configURL '${S}': ${_}`,severity:"warn",code:"config-validation"});return}}function f(v,S){if(v===void 0)return{};if(d(v))return p(v,S);const b=v;if(b.overlays&&"config"in b.overlays){S.push({message:"`config` is reserved by MalloyConfig; pass `configURL` and `rootDirectory` directly instead. Supplied `overlays.config` ignored.",severity:"warn",code:"config-overlay"});const{config:C,...R}=b.overlays;return{...b,overlays:R}}return b}function d(v){for(const S of Object.values(v))if(typeof S=="function")return!0;return!1}function p(v,S){const b=v.config;if(!b)return{overlays:v};const C=x(b,"configURL",S),R=x(b,"rootDirectory",S),{config:_,...w}=v;return{configURL:C,rootDirectory:R,overlays:w}}function x(v,S,b){const C=v([S]);if((0,r.isThenable)(C)){b.push({message:`the legacy \`config\` overlay returned a Promise for \`${S}\`; top-level FS context must resolve synchronously. ${S} will be undefined.`,severity:"warn",code:"config-overlay"});return}return typeof C=="string"?C:void 0}function g(v,S,b){if(v!==void 0)try{return new URL(v),v}catch{b.push({message:`${S} must be a URL-shaped string (e.g. 'file:///path/to/...'), got '${v}'. In Node, use \`url.pathToFileURL(path).toString()\`.`,severity:"warn",code:"config-validation"});return}}function m(v,S){if(!y(v))return;const b=new Map;for(const[C,R]of Object.entries(v)){if(!y(R))continue;const _=new Map;for(const[w,T]of Object.entries(R)){if(typeof T!="string")continue;const O=(0,i.validateCanonicalTablePathAnyDialect)(T);if(O!==void 0){S.push({message:`virtualMap entry '${C}.${w}': ${O}`,severity:"error",code:"config-validation"});continue}_.set(w,T)}_.size>0&&b.set(C,_)}return b.size>0?b:void 0}function y(v){return typeof v=="object"&&v!==null&&!Array.isArray(v)}function E(v){return y(v)&&typeof v.tableName=="string"}return dx}var WA={},jce;function c9e(){if(jce)return WA;jce=1,Object.defineProperty(WA,"__esModule",{value:!0}),WA.resolvePersistWalk=t,WA.mkBuildTargets=i;function e(s,o){const a=s.get(o);if(a===void 0)throw new Error("build target "+String(o)+" vanished between passes");return a}function t(s,o){const a=[];for(const u of s._walkPersistSources(o))a.push({node:u,source:u.persistent?s._persistSourceFor(u.sourceID):void 0});return a}function n(s,o){return`${s}:${o}`}function r(s,o,a){for(const u of a)o.has(u)||(o.add(u),s.push(u))}function i(s,o){var a;const u=new Map,c=new Map;for(const{node:m,source:y}of s){const E=[],v=new Set;for(const O of m.dependsOn)r(E,v,(a=c.get(O))!==null&&a!==void 0?a:[]);if(y===void 0){c.set(m.sourceID,E);continue}const S=y.connectionName,b=o[S];if(b===void 0)throw new Error(`No connection digest for '${S}', needed to compute the BuildID of '${m.sourceID}'. Supply a digest for every connection named by a persist source.`);const C=y.getSQL(),R=y.makeBuildId(b,C),_=n(S,R);let w=u.get(_);w===void 0&&(w={buildId:R,connectionName:S,sql:C,sources:[],dependsOn:new Set},u.set(_,w));const T=new Set;for(const O of E)O!==_&&T.add(O);if(w.sources.length===0)w.dependsOn=T;else for(const O of[...w.dependsOn])T.has(O)||w.dependsOn.delete(O);w.sources.push(y),c.set(m.sourceID,[_])}const l=new Map;for(const[m,y]of u)l.set(m,{buildId:y.buildId,connectionName:y.connectionName,sql:y.sql,sources:y.sources,dependsOn:[]});for(const[m,y]of u){const E=e(l,m);for(const v of y.dependsOn)E.dependsOn.push(e(l,v))}const f=new Map,d=new Set,p=new Set,x=m=>{if(d.has(m))return;if(p.has(m)){const v=e(u,m).sources.map(S=>S.sourceID).join(", ");throw new Error(`Cycle in the persistence build graph at: ${v}`)}p.add(m);for(const v of e(u,m).dependsOn)x(v);p.delete(m),d.add(m);const y=e(l,m),E=f.get(y.connectionName);E===void 0?f.set(y.connectionName,[y]):E.push(y)};for(const m of u.keys())x(m);const g=[];for(const[m,y]of f)g.push({connectionName:m,targets:y});return g}return WA}var U1={},YA={},zce;function f9e(){return zce||(zce=1,Object.defineProperty(YA,"__esModule",{value:!0}),YA.MALLOY_VERSION=void 0,YA.MALLOY_VERSION="0.0.430"),YA}var Hce;function Qce(){if(Hce)return U1;Hce=1,Object.defineProperty(U1,"__esModule",{value:!0}),U1.Malloy=U1.MalloyError=void 0;const e=Fk(),t=GA(),n=Ti(),r=w4(),i=f9e(),s=uw(),o=Fce(),a=Xp(),u=lw(),c=Ice();function l(x="loadModel"){return`internal://${x}/${(0,a.v4)()}`}function f(x){return[...Object.keys(x),...Object.values(x).map(f).flat()]}class d extends Error{constructor(g,m=[]){super(g),this.problems=m}}U1.MalloyError=d;class p{static get version(){return i.MALLOY_VERSION}static registerConnectionType(g,m){(0,t.registerConnectionType)(g,m)}static getConnectionProperties(g){return(0,t.getConnectionProperties)(g)}static getConnectionTypeDisplayName(g){return(0,t.getConnectionTypeDisplayName)(g)}static getRegisteredConnectionTypes(){return(0,t.getRegisteredConnectionTypes)()}static _parse(g,m,y,E,v){var S;m===void 0&&(m=new URL(l(E==null?void 0:E.method)));let b=m;E!=null&&E.importBaseURL&&(b=E==null?void 0:E.importBaseURL);const C=new e.MalloyTranslator(m.toString(),b.toString(),{urls:{[m.toString()]:g}},y,(S=E==null?void 0:E.restrictedMode)!==null&&S!==void 0?S:!1);return E!=null&&E.testEnvironment&&(C.allDialectsEnabled=!0),new o.Parse(C,v)}static parse({url:g,urlReader:m,source:y,eventStream:E,options:v}){if(y!==void 0)return p._parse(y,g,E,v);if(m===void 0)throw new Error("Internal Error: urlReader is required.");if(g===void 0)throw new Error("Internal Error: url is required if source not present.");return(0,s.readURL)(m,g).then(({contents:S,invalidationKey:b})=>p._parse(S,g,E,v,b))}static async compile(g){var m,y,E,v,S;let{url:b,source:C,importBaseURL:R,cacheManager:_}=g;const{parse:w,urlReader:T,connections:O,model:F,refreshSchemaCache:L,noThrowOnError:B,eventStream:j,restrictedMode:W,method:te}=g;W&&(_=void 0);let se;if(L&&(se=typeof L=="number"?L:Date.now()),b===void 0&&C===void 0&&w===void 0)throw new Error("Internal Error: url, source, or parse required.");b===void 0&&(w!==void 0?b=new URL(w._translator.sourceURL):b=new URL(l(te)));const U={};if(C===void 0&&_!==void 0){const de=await _.getCachedModelDef(T,b.toString());if(de)return new u.Model(de.modelDef,[],[b.toString(),...f(de.modelDef.dependencies)])}R??(R=b);let X;const ae=b.toString();if(w!==void 0){if(W!==void 0&&w._translator.restrictedMode!==W)throw new Error(`Malloy.compile: restrictedMode (${W}) does not match the pre-parsed translator's restrictedMode (${w._translator.restrictedMode}). Set restrictedMode at parse time.`);X=w._translator;const de=(m=w._invalidationKey)!==null&&m!==void 0?m:await(0,s.getInvalidationKey)(T,b);U[ae]=de}else{if(C===void 0){const{contents:de,invalidationKey:I}=await(0,s.readURL)(T,b);U[ae]=I,C=de}else{const de=await(0,s.getInvalidationKey)(T,b);U[ae]=de}X=new e.MalloyTranslator(ae,R.toString(),{urls:{[ae]:C}},j,W??!1)}for(;;){const de=X.translate(F==null?void 0:F._modelDef);if(de.final)if(de.modelDef){await(_==null?void 0:_.setCachedModelDef(b.toString(),{modelDef:de.modelDef,invalidationKeys:U}));for(const q of X.newlyTranslatedDependencies())await(_==null?void 0:_.setCachedModelDef(q.url,{modelDef:q.modelDef,invalidationKeys:U}));const I=!de.modelWasModified&&F?F.getExistingQueryModel():void 0;return new u.Model(de.modelDef,de.problems||[],[...(y=F==null?void 0:F.fromSources)!==null&&y!==void 0?y:[],...(E=de.fromSources)!==null&&E!==void 0?E:[]],I)}else if(B){const I=(0,n.mkModelDef)("modelDidNotCompile"),q=(F==null?void 0:F._modelDef)||I;return new u.Model(q,de.problems||[],[...(v=F==null?void 0:F.fromSources)!==null&&v!==void 0?v:[],...(S=de.fromSources)!==null&&S!==void 0?S:[]])}else{const I=de.problems||[],q=X.prettyErrors();throw new d(`Error(s) compiling model:
1384
1384
  ${q}`,I)}else{if(de.urls)for(const I of de.urls)try{if((0,s.isInternalURL)(I))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(_!==void 0){const $=await _.getCachedModelDef(T,I);if($){for(const N in $.invalidationKeys)U[N]=$.invalidationKeys[N];X.update({translations:{[I]:$.modelDef}});continue}}const{contents:q,invalidationKey:z}=await(0,s.readURL)(T,new URL(I)),M={[I]:q};U[I]=z,X.update({urls:M})}catch(q){X.update({errors:{urls:{[I]:q.message}}})}if(de.tables){const I=new Map;for(const q in de.tables){const{connectionName:z,tablePath:M}=de.tables[q],$=I.get(z);$===void 0?I.set(z,{[q]:M}):$[q]=M}for(const[q,z]of I)try{const M=await O.lookupConnection(q),{schemas:$,errors:N}=await p.safelyFetchTableSchema(M,z,{refreshTimestamp:se});X.update({tables:$,errors:{tables:N}})}catch(M){const $={},N={};for(const k in z)N[k]=M.toString();X.update({tables:$,errors:{tables:N}})}}if(de.connectionDialects)for(const I in de.connectionDialects){const{connectionName:q}=de.connectionDialects[I];try{const z=await O.lookupConnection(q);X.update({connectionDialects:{[I]:z.dialectName}})}catch(z){X.update({errors:{connectionDialects:{[I]:z.toString()}}})}}if(de.compileSQL){const I=de.compileSQL,q=I.connection,z=(0,r.sqlKey)(I.connection,I.selectStr);try{const $=await(await O.lookupConnection(q)).fetchSchemaForSQLStruct(I,{refreshTimestamp:se});$.error&&X.update({errors:{compileSQL:{[z]:$.error}}}),$.structDef&&X.update({compileSQL:{[z]:$.structDef}})}catch(M){const $={};$[z]=M.toString(),X.update({errors:{compileSQL:$}})}}}}}static async safelyFetchTableSchema(g,m,y){const E=await g.fetchSchemaForTables(m,y);for(const v of Object.keys(m))if(E.schemas[v]===void 0&&E.errors[v]===void 0)throw new Error(`Schema fetch error for ${g.name}, no response for ${v} from ${g.dialectName}`);return E}static async run({connections:g,preparedResult:m,sqlStruct:y,connection:E,options:v}){if(!E){if(!g)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const S=(y==null?void 0:y.connection)||(m==null?void 0:m.connectionName);E=await g.lookupConnection(S)}if(y){const S=await E.runSQL(y.selectStr,{queryMetadata:v==null?void 0:v.queryMetadata});return new c.Result({structs:[y],sql:y.selectStr,result:S.rows,totalRows:S.totalRows,runStats:S.runStats,lastStageName:y.name,malloy:"",connectionName:y.connection,sourceExplore:"",sourceFilters:[],profilingUrl:S.profilingUrl},(0,n.mkModelDef)("empty_model"))}else if(m){const S=await E.runSQL(m.sql,v);return new c.Result({...m._rawQuery,result:S.rows,totalRows:S.totalRows,runStats:S.runStats,profilingUrl:S.profilingUrl},m._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:g,preparedResult:m,sqlStruct:y,connection:E,options:v}){if(y===void 0&&m===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const S=(y==null?void 0:y.connection)||(m==null?void 0:m.connectionName);if(E===void 0){if(g===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");E=await g.lookupConnection(S)}if(!E.canStream())throw new Error(`Connection '${S}' cannot stream results.`);let b,C;if(y)C=new u.Explore((0,u.pseudoModelFor)(y),y),b=y.selectStr;else if(m!==void 0)C=m.resultExplore,b=m.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let R=0;for await(const _ of E.runSQLStream(b,v))yield new c.DataRecord(_,R,C,void 0,void 0),R+=1}static async estimateQueryCost({connections:g,preparedResult:m,sqlStruct:y}){if(!g)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const E=(y==null?void 0:y.connection)||(m==null?void 0:m.connectionName),v=await g.lookupConnection(E);if(y)return await v.estimateQueryCost(y.selectStr);if(m)return await v.estimateQueryCost(m.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}}return U1.Malloy=p,U1}var Vce;function d9e(){if(Vce)return cs;Vce=1,Object.defineProperty(cs,"__esModule",{value:!0}),cs.ExploreMaterializer=cs.PreparedResultMaterializer=cs.QueryMaterializer=cs.ModelMaterializer=cs.SingleConnectionRuntime=cs.ConnectionRuntime=cs.Runtime=void 0;const e=Ti(),t=i0(),n=Ok(),r=Ik(),i=Gv(),s=uw(),o=c9e(),a=lw(),u=Qce();class c{constructor(b,C){this.runtime=b,this._materialize=C}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(b,C){return new x(this.runtime,b,C)}makeExploreMaterializer(b,C){return new m(this.runtime,b,C)}makePreparedResultMaterializer(b){return new g(this.runtime,b)}}class l{constructor({urlReader:b,connections:C,connection:R,config:_,buildManifest:w,eventStream:T,cacheManager:O,givens:F}){var L,B;if(this.isTestRuntime=!1,_!==void 0)this._config=_,C=C??_.connections;else if(C===void 0){if(R===void 0)throw new Error("A MalloyConfig, LookupConnection<Connection>, or Connection is required.");C={lookupConnection:()=>Promise.resolve(R)}}if(b===void 0&&(b=new s.EmptyURLReader),this._urlReader=b,this._connections=C,this._buildManifest=w,this._eventStream=T,this._cacheManager=O,F){for(const[j,W]of Object.entries(F))if(W===void 0)throw new Error(`Runtime givens.${j}: explicit undefined is not a valid value. Omit the key to defer to declaration default or the file layer; use null for an explicit null value.`)}this._constructorGivensMap=F?new Map(Object.entries(F)):new Map,this._finalizedGivensSet=new Set((B=(L=this._config)===null||L===void 0?void 0:L.finalizeGivens)!==null&&B!==void 0?B:[])}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}get _constructorGivens(){return this._constructorGivensMap}async getGivens(){const b=await this._resolveGivens(),C=new Map;if(b)for(const[R,_]of Object.entries(b))C.set(R,_);for(const[R,_]of this._constructorGivensMap)C.set(R,_);return C}get _finalizedGivens(){return this._finalizedGivensSet}set buildManifest(b){this._buildManifest=b,this._resolvedBuildManifestPromise=void 0}_resolveBuildManifest(){var b;if(this._buildManifest)return Promise.resolve(this._buildManifest);const C=(b=this._config)===null||b===void 0?void 0:b.manifestURL;return C?(this._resolvedBuildManifestPromise||(this._resolvedBuildManifestPromise=(async()=>{let R;try{const _=await this._urlReader.readURL(new URL(C));R=typeof _=="string"?_:_.contents}catch{return}try{const _=JSON.parse(R);if(!y(_))throw new Error('manifest is not an object with an "entries" map');for(const[w,T]of Object.entries(_.entries)){if(!(0,r.isBuildManifestEntry)(T))throw new Error(`Manifest entry '${w}' is missing a string tableName`);(0,n.requireCanonicalTablePathAnyDialect)(T.tableName,`Manifest entry '${w}'`)}return _}catch(_){const w=_ instanceof Error?_.message:String(_);return{entries:{},loadError:`Manifest file at ${C} could not be parsed: ${w}`}}})()),this._resolvedBuildManifestPromise):Promise.resolve(void 0)}_resolveGivens(){var b;const C=(b=this._config)===null||b===void 0?void 0:b.givensURL;return C?(this._resolvedGivensPromise||(this._resolvedGivensPromise=(async()=>{let R;try{const w=await this._urlReader.readURL(new URL(C));R=typeof w=="string"?w:w.contents}catch(w){const T=w instanceof Error?w.message:String(w);throw new Error(`givens: failed to read givens file at ${C}: ${T}`)}let _;try{_=JSON.parse(R)}catch(w){const T=w instanceof Error?w.message:String(w);throw new Error(`givens: failed to parse JSON at ${C}: ${T}`)}if(!E(_)){const w=Array.isArray(_)?"array":_===null?"null":typeof _;throw new Error(`givens: file at ${C} must be a JSON object of name → value pairs, got ${w}`)}return _})()),this._resolvedGivensPromise):Promise.resolve(void 0)}_invalidateGivensCache(){this._resolvedGivensPromise=void 0}get virtualMap(){var b,C;return(b=this._virtualMap)!==null&&b!==void 0?b:(C=this._config)===null||C===void 0?void 0:C.virtualMap}set virtualMap(b){this._virtualMap=b}async shutdown(b="close"){var C;await((C=this._config)===null||C===void 0?void 0:C.shutdown(b))}async releaseConnections(){await this.shutdown("close")}loadModel(b,C){const{refreshSchemaCache:R,noThrowOnError:_}=C||{};this.isTestRuntime&&(C===void 0?C={testEnvironment:!0}:C={...C,testEnvironment:!0});const w=b instanceof URL?{url:b}:{source:b};return new p(this,async()=>{const T=await u.Malloy.compile({...w,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:R,noThrowOnError:_,eventStream:this.eventStream,importBaseURL:C==null?void 0:C.importBaseURL,testEnvironment:C==null?void 0:C.testEnvironment,cacheManager:this.cacheManager});return this._withRuntimeContext(T)},C)}_withRuntimeContext(b){return this._finalizedGivensSet.size===0?b:new a.Model(b._modelDef,b.problems,b.fromSources,b.getExistingQueryModel(),{finalizedGivens:this._finalizedGivensSet})}_loadModelFromModelDef(b,C){return new p(this,async()=>new a.Model(b,[],[],void 0,this._finalizedGivensSet.size>0?{finalizedGivens:this._finalizedGivensSet}:void 0),C)}loadQuery(b,C){return this.loadModel(b,C).loadFinalQuery()}loadQueryByIndex(b,C,R){return this.loadModel(b,R).loadQueryByIndex(C,R)}loadQueryByName(b,C,R){return this.loadModel(b,R).loadQueryByName(C,R)}getModel(b,C){return this.loadModel(b,C).getModel()}getQuery(b,C){return this.loadQuery(b,C).getPreparedQuery()}getQueryByIndex(b,C,R){return this.loadQueryByIndex(b,C,R).getPreparedQuery()}getQueryByName(b,C,R){return this.loadQueryByName(b,C,R).getPreparedQuery()}async getBuildTargets(b){const C=[],R=(0,o.resolvePersistWalk)(b,C),_=(0,e.mkSafeRecord)();for(const{source:w}of R){if(w===void 0)continue;const T=w.connectionName;if(!(T in _)){const O=await this.connections.lookupConnection(T);_[T]=O.getDigest()}}return{connections:(0,o.mkBuildTargets)(R,_),tagParseLog:C}}}cs.Runtime=l;class f extends l{constructor({urlReader:b,connections:C}){super({connections:s.FixedConnectionMap.fromArray(C),urlReader:b}),this.rawConnections=C}}cs.ConnectionRuntime=f;class d extends l{constructor({urlReader:b,connection:C,eventStream:R,cacheManager:_}){super({urlReader:b,eventStream:R,cacheManager:_,connection:C}),this.connection=C}get supportsNesting(){return(0,t.getDialect)(this.connection.dialectName).supportsNesting}quote(b){return(0,t.getDialect)(this.connection.dialectName).sqlQuoteIdentifier(b)}get dialect(){return(0,t.getDialect)(this.connection.dialectName)}getQuoter(){return b=>this.quote(b.toString())}}cs.SingleConnectionRuntime=d;class p extends c{constructor(b,C,R){super(b,C),this.runtime=b,this.compileQueryOptions=R}loadFinalQuery(b){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...b})}loadQueryByIndex(b,C){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(b),{...this.compileQueryOptions,...C})}loadQueryByName(b,C){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(b),{...this.compileQueryOptions,...C})}loadQuery(b,C){const{importBaseURL:R,testEnvironment:_,refreshSchemaCache:w,noThrowOnError:T,restrictedMode:O,method:F,...L}=C??{},B={...this.compileQueryOptions,...L};return this.makeQueryMaterializer(async()=>{const j=b instanceof URL?{url:b}:{source:b};return(await u.Malloy.compile({...j,urlReader:this.runtime.urlReader,connections:this.runtime.connections,model:await this.getModel(),refreshSchemaCache:w,noThrowOnError:T,importBaseURL:R,testEnvironment:_||this.runtime.isTestRuntime,...B})).preparedQuery},B)}loadRestrictedQuery(b){return this.makeQueryMaterializer(async()=>{const C=this.runtime.urlReader,R=this.runtime.connections,_=this.runtime.isTestRuntime?!0:void 0,w=await this.getModel();return(await u.Malloy.compile({source:b,restrictedMode:!0,method:"query",urlReader:C,connections:R,model:w,testEnvironment:_,...this.compileQueryOptions})).preparedQuery})}extendModel(b,C){return this.runtime.isTestRuntime&&(C===void 0?C={testEnvironment:!0}:C={...C,testEnvironment:!0}),new p(this.runtime,async()=>{const R=this.runtime.urlReader,_=this.runtime.connections,w=b instanceof URL?{url:b}:{source:b},T=await this.getModel(),O=await u.Malloy.compile({...w,urlReader:R,connections:_,model:T,method:"extendModel",refreshSchemaCache:C==null?void 0:C.refreshSchemaCache,noThrowOnError:C==null?void 0:C.noThrowOnError,importBaseURL:C==null?void 0:C.importBaseURL,testEnvironment:C==null?void 0:C.testEnvironment,...this.compileQueryOptions});return this.runtime._withRuntimeContext(O)},C)}async search(b,C,R=1e3,_=void 0){const w=await this.materialize(),T=w.queryModel,O=w.getExploreByName(b).structDef;if(!(0,e.isSourceDef)(O))throw new Error("Source to be searched was unexpectedly, not a source");const F=O.connection,L=await this.runtime.connections.lookupConnection(F);return await T.searchIndex(L,b,C,R,_)}async searchValueMap(b,C=10,R){const w=(await this.materialize()).getExploreByName(b);if(!(0,e.isSourceDef)(w.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let T="{index: *}";w.getFieldByNameIfExists("search_index")&&(T="search_index");const O=`
1385
1385
  run: ${b}
1386
1386
  -> ${T}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/render",
3
- "version": "0.0.429",
3
+ "version": "0.0.430",
4
4
  "license": "MIT",
5
5
  "main": "dist/module/index.umd.js",
6
6
  "types": "dist/module/index.d.ts",
@@ -31,8 +31,8 @@
31
31
  "generate-flow": "ts-node ../../scripts/gen-flow.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@malloydata/malloy-interfaces": "0.0.429",
35
- "@malloydata/malloy-tag": "0.0.429",
34
+ "@malloydata/malloy-interfaces": "0.0.430",
35
+ "@malloydata/malloy-tag": "0.0.430",
36
36
  "@tanstack/solid-virtual": "^3.13.33",
37
37
  "lodash": "^4.18.1",
38
38
  "luxon": "^3.7.2",
@@ -44,8 +44,8 @@
44
44
  "vega-lite": "^5.2.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@malloydata/db-duckdb": "0.0.429",
48
- "@malloydata/malloy": "0.0.429",
47
+ "@malloydata/db-duckdb": "0.0.430",
48
+ "@malloydata/malloy": "0.0.430",
49
49
  "@storybook/addon-essentials": "^8.6.18",
50
50
  "@storybook/addon-interactions": "^8.6.18",
51
51
  "@storybook/addon-links": "^8.6.15",