@malloydata/cli 0.0.56-next.2026.6.26.015031d → 0.0.56-next.2026.6.26.94fe16d
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/cli.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -3
package/dist/cli.js
CHANGED
|
@@ -854,7 +854,7 @@ Original error: ${Y1(t)}`)}async function RE(t){let{malloyConfig:e}=await Promis
|
|
|
854
854
|
at `+o}return e};zL.buildMessage=function(t,e){var r={literal:function(u){return'"'+i(u.text)+'"'},class:function(u){var l=u.parts.map(function(A){return Array.isArray(A)?s(A[0])+"-"+s(A[1]):s(A)});return"["+(u.inverted?"^":"")+l.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(u){return u.description}};function n(u){return u.charCodeAt(0).toString(16).toUpperCase()}function i(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(l){return"\\x0"+n(l)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(l){return"\\x"+n(l)})}function s(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(l){return"\\x0"+n(l)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(l){return"\\x"+n(l)})}function o(u){return r[u.type](u)}function a(u){var l=u.map(o),A,p;if(l.sort(),l.length>0){for(A=1,p=1;A<l.length;A++)l[A-1]!==l[A]&&(l[p]=l[A],p++);l.length=p}switch(l.length){case 1:return l[0];case 2:return l[0]+" or "+l[1];default:return l.slice(0,-1).join(", ")+", or "+l[l.length-1]}}function c(u){return u?'"'+i(u)+'"':"end of input"}return"Expected "+a(t)+" but "+c(e)+" found."};function ans(t,e){e=e!==void 0?e:{};var r={},n=e.grammarSource,i={start:ir},s=ir,o="(",a=")",c="%{",u="}%",l="//",A="--",p="/*",f="*/",h=/^[ \t]/,g=/^[\n\r]/,E=qe("query string"),y=ot(),I=He("(",!1),b=He(")",!1),S=He("%{",!1),w=He("}%",!1),v=qe("comment"),G=He("//",!1),$=He("--",!1),ne=He("/*",!1),ee=He("*/",!1),B=We([" "," "],!1,!1),F=qe("end of line"),z=We([`
|
|
855
855
|
`,"\r"],!1,!1),_=function(It){return{parts:It,range:Xe(),statementText:It.map(At=>At.text).join("")}},N=function(It){return{type:"other",text:It,range:Xe()}},k=function(It){return{type:"malloy",text:Mt(),malloy:It.malloy,malloyRange:It.malloyRange,range:Xe(),parenthesized:!0}},Y=function(It){return{type:"malloy",text:Mt(),malloy:It.text,malloyRange:It.malloyRange,range:Xe(),parenthesized:!1}},H=function(){return{malloyRange:Xe(),text:Mt()}},L=function(It){return{type:"comment",text:It,range:Xe()}},P=e.peg$currPos|0,q=P,W=[{line:1,column:1}],K=P,Fe=e.peg$maxFailExpected||[],Ne=e.peg$silentFails|0,Ge;if(e.startRule){if(!(e.startRule in i))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');s=i[e.startRule]}function Mt(){return t.substring(q,P)}function Vt(){return q}function ge(){return{source:n,start:q,end:P}}function Xe(){return ht(q,P)}function Ze(It,At){throw At=At!==void 0?At:ht(q,P),Jt([qe(It)],t.substring(q,P),At)}function Se(It,At){throw At=At!==void 0?At:ht(q,P),Ut(It,At)}function He(It,At){return{type:"literal",text:It,ignoreCase:At}}function We(It,At,Ht){return{type:"class",parts:It,inverted:At,ignoreCase:Ht}}function ot(){return{type:"any"}}function ze(){return{type:"end"}}function qe(It){return{type:"other",description:It}}function dt(It){var At=W[It],Ht;if(At)return At;if(It>=W.length)Ht=W.length-1;else for(Ht=It;!W[--Ht];);for(At=W[Ht],At={line:At.line,column:At.column};Ht<It;)t.charCodeAt(Ht)===10?(At.line++,At.column=1):At.column++,Ht++;return W[It]=At,At}function ht(It,At,Ht){var Pe=dt(It),De=dt(At),ft={source:n,start:{offset:It,line:Pe.line,column:Pe.column},end:{offset:At,line:De.line,column:De.column}};return Ht&&n&&typeof n.offset=="function"&&(ft.start=n.offset(ft.start),ft.end=n.offset(ft.end)),ft}function je(It){P<K||(P>K&&(K=P,Fe=[]),Fe.push(It))}function Ut(It,At){return new zL(It,null,null,At)}function Jt(It,At,Ht){return new zL(zL.buildMessage(It,At),It,At,Ht)}function ir(){var It;return It=fe(),It}function fe(){var It,At,Ht;for(It=P,At=[],Ht=ue(),Ht===r&&(Ht=Te(),Ht===r&&(Ht=ve()));Ht!==r;)At.push(Ht),Ht=ue(),Ht===r&&(Ht=Te(),Ht===r&&(Ht=ve()));return q=It,At=_(At),It=At,It}function ve(){var It,At,Ht,Pe,De,ft,xt;if(Ne++,It=P,At=P,Ht=[],Pe=P,De=P,Ne++,ft=ue(),Ne--,ft===r?De=void 0:(P=De,De=r),De!==r?(ft=P,Ne++,xt=Te(),Ne--,xt===r?ft=void 0:(P=ft,ft=r),ft!==r?(t.length>P?(xt=t.charAt(P),P++):(xt=r,Ne===0&&je(y)),xt!==r?(De=[De,ft,xt],Pe=De):(P=Pe,Pe=r)):(P=Pe,Pe=r)):(P=Pe,Pe=r),Pe!==r)for(;Pe!==r;)Ht.push(Pe),Pe=P,De=P,Ne++,ft=ue(),Ne--,ft===r?De=void 0:(P=De,De=r),De!==r?(ft=P,Ne++,xt=Te(),Ne--,xt===r?ft=void 0:(P=ft,ft=r),ft!==r?(t.length>P?(xt=t.charAt(P),P++):(xt=r,Ne===0&&je(y)),xt!==r?(De=[De,ft,xt],Pe=De):(P=Pe,Pe=r)):(P=Pe,Pe=r)):(P=Pe,Pe=r);else Ht=r;return Ht!==r?At=t.substring(At,P):At=Ht,At!==r&&(q=It,At=N(At)),It=At,Ne--,It===r&&(At=r,Ne===0&&je(E)),It}function Te(){var It;return It=lt(),It===r&&(It=me()),It}function lt(){var It,At,Ht,Pe,De,ft;return It=P,t.charCodeAt(P)===40?(At=o,P++):(At=r,Ne===0&&je(I)),At!==r?(Ht=Oe(),Pe=me(),Pe!==r?(De=Oe(),t.charCodeAt(P)===41?(ft=a,P++):(ft=r,Ne===0&&je(b)),ft!==r?(q=It,It=k(Pe)):(P=It,It=r)):(P=It,It=r)):(P=It,It=r),It}function me(){var It,At,Ht,Pe;return It=P,t.substr(P,2)===c?(At=c,P+=2):(At=r,Ne===0&&je(S)),At!==r?(Ht=J(),t.substr(P,2)===u?(Pe=u,P+=2):(Pe=r,Ne===0&&je(w)),Pe!==r?(q=It,It=Y(Ht)):(P=It,It=r)):(P=It,It=r),It}function J(){var It,At,Ht,Pe,De;for(It=P,At=[],Ht=P,Pe=P,Ne++,t.substr(P,2)===u?(De=u,P+=2):(De=r,Ne===0&&je(w)),Ne--,De===r?Pe=void 0:(P=Pe,Pe=r),Pe!==r?(t.length>P?(De=t.charAt(P),P++):(De=r,Ne===0&&je(y)),De!==r?(Pe=[Pe,De],Ht=Pe):(P=Ht,Ht=r)):(P=Ht,Ht=r);Ht!==r;)At.push(Ht),Ht=P,Pe=P,Ne++,t.substr(P,2)===u?(De=u,P+=2):(De=r,Ne===0&&je(w)),Ne--,De===r?Pe=void 0:(P=Pe,Pe=r),Pe!==r?(t.length>P?(De=t.charAt(P),P++):(De=r,Ne===0&&je(y)),De!==r?(Pe=[Pe,De],Ht=Pe):(P=Ht,Ht=r)):(P=Ht,Ht=r);return q=It,At=H(),It=At,It}function ue(){var It,At;return Ne++,It=P,At=Re(),At===r&&(At=$e()),At!==r&&(q=It,At=L(At)),It=At,Ne--,It===r&&(At=r,Ne===0&&je(v)),It}function Re(){var It,At,Ht,Pe,De,ft,xt;if(It=P,At=P,t.substr(P,2)===l?(Ht=l,P+=2):(Ht=r,Ne===0&&je(G)),Ht===r&&(t.substr(P,2)===A?(Ht=A,P+=2):(Ht=r,Ne===0&&je($))),Ht!==r){for(Pe=[],De=P,ft=P,Ne++,xt=Lt(),Ne--,xt===r?ft=void 0:(P=ft,ft=r),ft!==r?(t.length>P?(xt=t.charAt(P),P++):(xt=r,Ne===0&&je(y)),xt!==r?(ft=[ft,xt],De=ft):(P=De,De=r)):(P=De,De=r);De!==r;)Pe.push(De),De=P,ft=P,Ne++,xt=Lt(),Ne--,xt===r?ft=void 0:(P=ft,ft=r),ft!==r?(t.length>P?(xt=t.charAt(P),P++):(xt=r,Ne===0&&je(y)),xt!==r?(ft=[ft,xt],De=ft):(P=De,De=r)):(P=De,De=r);De=Oe(),ft=Lt(),ft===r&&(ft=jt()),ft!==r?(Ht=[Ht,Pe,De,ft],At=Ht):(P=At,At=r)}else P=At,At=r;return At!==r?It=t.substring(It,P):It=At,It}function $e(){var It,At,Ht,Pe,De,ft,xt;if(It=P,At=P,t.substr(P,2)===p?(Ht=p,P+=2):(Ht=r,Ne===0&&je(ne)),Ht!==r){for(Pe=[],De=P,ft=P,Ne++,t.substr(P,2)===f?(xt=f,P+=2):(xt=r,Ne===0&&je(ee)),Ne--,xt===r?ft=void 0:(P=ft,ft=r),ft!==r?(t.length>P?(xt=t.charAt(P),P++):(xt=r,Ne===0&&je(y)),xt!==r?(ft=[ft,xt],De=ft):(P=De,De=r)):(P=De,De=r);De!==r;)Pe.push(De),De=P,ft=P,Ne++,t.substr(P,2)===f?(xt=f,P+=2):(xt=r,Ne===0&&je(ee)),Ne--,xt===r?ft=void 0:(P=ft,ft=r),ft!==r?(t.length>P?(xt=t.charAt(P),P++):(xt=r,Ne===0&&je(y)),xt!==r?(ft=[ft,xt],De=ft):(P=De,De=r)):(P=De,De=r);t.substr(P,2)===f?(De=f,P+=2):(De=r,Ne===0&&je(ee)),De!==r?(Ht=[Ht,Pe,De],At=Ht):(P=At,At=r)}else P=At,At=r;return At!==r?It=t.substring(It,P):It=At,It}function Oe(){var It,At;for(It=[],At=_t();At!==r;)It.push(At),At=_t();return It}function _t(){var It;return It=t.charAt(P),h.test(It)?P++:(It=r,Ne===0&&je(B)),It}function Lt(){var It,At;return Ne++,It=t.charAt(P),g.test(It)?P++:(It=r,Ne===0&&je(z)),Ne--,It===r&&(At=r,Ne===0&&je(F)),It}function jt(){var It,At;return It=P,Ne++,t.length>P?(At=t.charAt(P),P++):(At=r,Ne===0&&je(y)),Ne--,At===r?It=void 0:(P=It,It=r),It}if(Ge=s(),e.peg$library)return{peg$result:Ge,peg$currPos:P,peg$FAILED:r,peg$maxFailExpected:Fe,peg$maxFailPos:K};if(Ge!==r&&P===t.length)return Ge;throw Ge!==r&&P<t.length&&je(ze()),Jt(Fe,K<t.length?t.charAt(K):null,K<t.length?ht(K,K+1):ht(K,K))}w5r.exports={StartRules:["start"],SyntaxError:zL,parse:ans}});var bQe=m(xY=>{"use strict";Object.defineProperty(xY,"__esModule",{value:!0});xY.MalloySQLSyntaxError=xY.MalloySQLParseError=void 0;var cns=Hc(),IQe=class extends cns.MalloyError{constructor(e,r=[]){super(e,r)}};xY.MalloySQLParseError=IQe;var l_t=class extends IQe{constructor(e,r,n,i){super(e,r),this.expected=n,this.found=i}};xY.MalloySQLSyntaxError=l_t});var d_t=m(cS=>{"use strict";var uns=cS&&cS.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),lns=cS&&cS.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Ans=cS&&cS.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&uns(r,e,n[i]);return lns(r,e),r}})();Object.defineProperty(cS,"__esModule",{value:!0});cS.MalloySQLSQLParser=void 0;var dns=Ans(S5r()),pns=bQe(),A_t=class{static convertLocation(e,r){let n={character:e.column-1,line:e.line-1};return r&&(n.line+=r.line-1),n}static convertRange(e,r){return{start:this.convertLocation(e.start,r),end:this.convertLocation(e.end,r)}}static parse(e,r=".",n=null){let i;try{i=dns.parse(e,void 0)}catch(c){return{comments:[],config:{},embeddedMalloyQueries:[],errors:[new pns.MalloySQLSyntaxError(c.message,[{code:"malloy-sql-syntax-error",message:c.message,at:{url:r,range:this.convertRange(c.location,n)},severity:"error"}],c.expected,c.found)]}}if(!i.parts)return{comments:[],config:{},embeddedMalloyQueries:[],errors:[]};let s=i.parts.filter(c=>c.type==="comment").map(c=>({range:this.convertRange(c.range,n),text:c.text})),o=i.parts.filter(c=>c.type==="malloy").map(c=>({query:c.malloy,parenthesized:c.parenthesized,range:this.convertRange(c.range,n),text:c.text,malloyRange:this.convertRange(c.malloyRange,n)})),a={};for(let c of s){let u=/\bconnection:\s*(?<connectionName>\S*)/.exec(c.text);u&&u.groups&&(a.connection=u.groups.connectionName)}return{comments:s,config:a,embeddedMalloyQueries:o,errors:[]}}};cS.MalloySQLSQLParser=A_t});var T5r=m(uS=>{"use strict";var fns=uS&&uS.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),hns=uS&&uS.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),gns=uS&&uS.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&fns(r,e,n[i]);return hns(r,e),r}})();Object.defineProperty(uS,"__esModule",{value:!0});uS.MalloySQLParser=void 0;var mns=gns(M5r()),p_t=c_t(),Ens=d_t(),R5r=bQe(),f_t=class{static convertLocation(e){return{character:e.column-1,line:e.line-1}}static convertRange(e){return{start:this.convertLocation(e.start),end:this.convertLocation(e.end)}}static createParseError(e,r,n,i="."){let s={message:r,code:e,at:{url:i,range:this.convertRange(n)},severity:"error"};return new R5r.MalloySQLParseError(r,[s])}static parse(e,r="."){let n;try{let l=mns.parse(e,void 0);n={initialComments:l[0],statements:l[1]}}catch(l){return{statements:[],errors:[new R5r.MalloySQLSyntaxError(l.message,[{code:"malloysql-syntax-error",message:l.message,at:{url:r,range:this.convertRange(l.location)},severity:"error"}],l.expected,l.found)]}}let i="",s=[],{initialComments:o}=n,a=o.split(/\r\n|\r|\n/).length-1,c=0,u=[];if(!n.statements)return{statements:s,errors:u};for(let l of n.statements){let A={};if(l.statementType==="malloy"&&l.config!==""&&u.push(this.createParseError("malloysql-illegal-statement-in-malloy-block",'Only comments are allowed after ">>>malloy"',l.delimiterRange,r)),l.config.startsWith("connection:")){let f=l.config.split("connection:");f.length>0?A={connection:f[1].trim(),fromDelimiter:!0}:u.push(this.createParseError("malloysql-invalid-connection-specification",'"connection:" found but no connection value was provided',l.delimiterRange,r))}let p={index:c,text:l.statementText,range:this.convertRange(l.range),delimiterRange:this.convertRange(l.delimiterRange)};if(c+=1,l.statementType==="markdown")s.push({...p,config:A,type:p_t.MalloySQLStatementType.MARKDOWN});else if(l.statementType==="malloy")s.push({...p,config:A,type:p_t.MalloySQLStatementType.MALLOY});else{let f=Ens.MalloySQLSQLParser.parse(l.statementText,r,l.range.start);A={...A,...f.config},A.connection||(i||u.push(this.createParseError("malloysql-missing-connection-specification","No connection configuration specified",l.delimiterRange,r)),A.connection=i,A.inheritedConnection=!0),i=A.connection;let h=f.embeddedMalloyQueries;s.push({...p,config:A,type:p_t.MalloySQLStatementType.SQL,embeddedMalloyQueries:h})}}return{statements:s,errors:u,initialCommentsLineCount:a,initialComments:o}}};uS.MalloySQLParser=f_t});var v5r=m(lS=>{"use strict";Object.defineProperty(lS,"__esModule",{value:!0});lS.MalloySQLStatementType=lS.MalloySQLSQLParser=lS.MalloySQLParseError=lS.MalloySQLParser=void 0;var yns=T5r();Object.defineProperty(lS,"MalloySQLParser",{enumerable:!0,get:function(){return yns.MalloySQLParser}});var Cns=bQe();Object.defineProperty(lS,"MalloySQLParseError",{enumerable:!0,get:function(){return Cns.MalloySQLParseError}});var Ins=d_t();Object.defineProperty(lS,"MalloySQLSQLParser",{enumerable:!0,get:function(){return Ins.MalloySQLSQLParser}});var bns=c_t();Object.defineProperty(lS,"MalloySQLStatementType",{enumerable:!0,get:function(){return bns.MalloySQLStatementType}})});async function Q5r(t,e){let r=x5r(t),n=e.compileOnly,i=e.queryOptions&&e.queryOptions.type==="index"?e.queryOptions.index:null,s=JSON.parse("{}"),o=_Qe(e.json?"json":["malloy","compiled-sql","results","tasks"]);e.queryOptions&&e.queryOptions.type==="name"&&o.error("--name and .malloysql are not compatible");try{let a=BY.MalloySQLParser.parse(r);a.errors.length>0&&o.error(`Parse errors encountered: ${a.errors.map(h=>h instanceof Error?h.message:`${h}`).join(`
|
|
856
856
|
`)}`);let c=a.statements,u=e.givens?{givens:e.givens}:{};i!==null?(o.task(`Running malloysql query from ${t} at statement index: ${i}`),i===0&&o.error("Statement indexes are 1-based - did you mean to use 1 instead of 0?"),i>c.length&&o.error(`Statement index ${i} is greater than number of possible statements ${c.length}`)):o.task(`Running malloysql file: ${t}`);let l=D5r.default.pathToFileURL(t),A=new h_t(DL),p=new N5r.Runtime({config:u0,urlReader:A}),f;for(let h=0;h<c.length;h++){let g=c[h];if(s[`statement_${h}`]={},g.type===BY.MalloySQLStatementType.SQL&&i!==null&&i!==h){o.task(`Skipping statement: ${h}`);continue}let E=g.text;if(o.task(`Running statement: ${h+1}`),g.type===BY.MalloySQLStatementType.MALLOY){A.setVirtualFile(l,g.text);try{f?f.extendModel(l):f=p.loadModel(l);let y=f.getModel();o.malloy("Compiling Malloy:"),o.malloy(g.text);try{let I=f.loadQuery(l),b=await RE(()=>I.getSQL(u));if(n)o.sql("Compiled SQL:"),o.sql(b.trim());else{o.task("Running Malloy");let S=e.rowLimit??qv,w=await RE(()=>I.run({rowLimit:S,...u}));w.toJSON().queryResult.result.length===S&&o.result(`WARNING: Results truncated to ${S} results.`),w&&o.result("Results:")}}catch{}}catch(y){o.error(Y1(y))}}else if(g.type===BY.MalloySQLStatementType.SQL){for(let y of g.embeddedMalloyQueries)try{if(o.malloy("Compiling Malloy:"),o.malloy(y.query),!f)throw new Error("Malloy cell must precede MalloySQL cell");let I=f.loadQuery(`
|
|
857
|
-
run: ${y.query}`),b=await RE(()=>I.getSQL(u));E=E.replace(y.text,`(${b})`)}catch(I){o.error(Y1(I))}if(s[`statement_${h}`].sql=E.trim(),n)return o.sql("Compiled SQL:"),o.sql(E.trim()),JSON.stringify(s);try{let y=await u0.connections.lookupConnection(g.config?.connection);o.sql("Executing SQL:"),o.sql(E);let I=await RE(()=>y.runSQL(E));I&&(o.task("Results:"),I.rows.length===0?(o.result("Statement successfully completed with no results"),s[`statement_${h}`].results=void 0):(o.result(JSON.stringify(I.rows,null,2)),s[`statement_${h}`].results=I.rows))}catch(y){o.error(Y1(y))}}if(h===i)break}}catch(a){o.error(Y1(a))}return o.json(JSON.stringify(s,null,2)),JSON.stringify(s)}var D5r,N5r,BY,h_t,z5r=te(()=>{"use strict";D5r=Nr(require("node:url")),N5r=Nr(Hc());Dy();BY=Nr(v5r());Fv();hU();h_t=class{constructor(e){this.uriReader=e;this.url=new URL("malloy://internal");this.contents=""}setVirtualFile(e,r){this.url=e,this.contents=r}async readURL(e){if(e.toString()===this.url.toString())return this.contents;{let r=await this.uriReader.readURL(e);return typeof r=="string"?r:r.contents}}}});async function k5r(t,e){let r=_Qe(e.json?"json":["malloy","compiled-sql","results","tasks"]),n=JSON.parse("{}"),i=P5r.default.pathToFileURL(t);try{return await RE(async()=>{let o=new L5r.Runtime({config:u0,urlReader:DL}).loadModel(i),a;if(e.queryOptions)switch(e.queryOptions.type){case"index":a=o.loadQueryByIndex(e.queryOptions.index);break;case"name":a=o.loadQueryByName(e.queryOptions.name);break;case"string":a=o.loadQuery(`run: ${e.queryOptions.query}`);break}else{let f=await o.getModel(),{named:h,unnamed:g}=f.queries();if(h.length+g===0){if(e.compileOnly)return r.malloy("Model compiled successfully (no queries to compile)."),JSON.stringify(n);r.error("Nothing to run: this model has no queries.")}a=o.loadFinalQuery()}let c=e.givens?{givens:e.givens}:{},u=await a.getSQL(c);if(n.sql=u.trim(),e.compileOnly)return r.sql("Compiled SQL:"),r.sql(u),JSON.stringify(n);let l=e.rowLimit??qv,p=(await a.run({rowLimit:l,...c})).toJSON().queryResult.result;return p.length===l&&r.result(`WARNING: Results truncated to ${l} results.`),r.result(JSON.stringify(p,null,2)),n.results=JSON.stringify(p),JSON.stringify(n)})}catch(s){r.error(Y1(s))}}var L5r,P5r,F5r=te(()=>{"use strict";L5r=Nr(Hc()),P5r=Nr(require("node:url"));Fv();hU();Dy()});var U5r=m((rKa,q5r)=>{"use strict";q5r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var g_t=m((nKa,W5r)=>{var w1e=U5r(),G5r={};for(let t of Object.keys(w1e))G5r[w1e[t]]=t;var Ii={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};W5r.exports=Ii;for(let t of Object.keys(Ii)){if(!("channels"in Ii[t]))throw new Error("missing channels property: "+t);if(!("labels"in Ii[t]))throw new Error("missing channel labels property: "+t);if(Ii[t].labels.length!==Ii[t].channels)throw new Error("channel and label counts mismatch: "+t);let{channels:e,labels:r}=Ii[t];delete Ii[t].channels,delete Ii[t].labels,Object.defineProperty(Ii[t],"channels",{value:e}),Object.defineProperty(Ii[t],"labels",{value:r})}Ii.rgb.hsl=function(t){let e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.min(e,r,n),s=Math.max(e,r,n),o=s-i,a,c;s===i?a=0:e===s?a=(r-n)/o:r===s?a=2+(n-e)/o:n===s&&(a=4+(e-r)/o),a=Math.min(a*60,360),a<0&&(a+=360);let u=(i+s)/2;return s===i?c=0:u<=.5?c=o/(s+i):c=o/(2-s-i),[a,c*100,u*100]};Ii.rgb.hsv=function(t){let e,r,n,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),l=u-Math.min(o,a,c),A=function(p){return(u-p)/6/l+1/2};return l===0?(i=0,s=0):(s=l/u,e=A(o),r=A(a),n=A(c),o===u?i=n-r:a===u?i=1/3+e-n:c===u&&(i=2/3+r-e),i<0?i+=1:i>1&&(i-=1)),[i*360,s*100,u*100]};Ii.rgb.hwb=function(t){let e=t[0],r=t[1],n=t[2],i=Ii.rgb.hsl(t)[0],s=1/255*Math.min(e,Math.min(r,n));return n=1-1/255*Math.max(e,Math.max(r,n)),[i,s*100,n*100]};Ii.rgb.cmyk=function(t){let e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.min(1-e,1-r,1-n),s=(1-e-i)/(1-i)||0,o=(1-r-i)/(1-i)||0,a=(1-n-i)/(1-i)||0;return[s*100,o*100,a*100,i*100]};function Bns(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}Ii.rgb.keyword=function(t){let e=G5r[t];if(e)return e;let r=1/0,n;for(let i of Object.keys(w1e)){let s=w1e[i],o=Bns(t,s);o<r&&(r=o,n=i)}return n};Ii.keyword.rgb=function(t){return w1e[t]};Ii.rgb.xyz=function(t){let e=t[0]/255,r=t[1]/255,n=t[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;let i=e*.4124+r*.3576+n*.1805,s=e*.2126+r*.7152+n*.0722,o=e*.0193+r*.1192+n*.9505;return[i*100,s*100,o*100]};Ii.rgb.lab=function(t){let e=Ii.rgb.xyz(t),r=e[0],n=e[1],i=e[2];r/=95.047,n/=100,i/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;let s=116*n-16,o=500*(r-n),a=200*(n-i);return[s,o,a]};Ii.hsl.rgb=function(t){let e=t[0]/360,r=t[1]/100,n=t[2]/100,i,s,o;if(r===0)return o=n*255,[o,o,o];n<.5?i=n*(1+r):i=n+r-n*r;let a=2*n-i,c=[0,0,0];for(let u=0;u<3;u++)s=e+1/3*-(u-1),s<0&&s++,s>1&&s--,6*s<1?o=a+(i-a)*6*s:2*s<1?o=i:3*s<2?o=a+(i-a)*(2/3-s)*6:o=a,c[u]=o*255;return c};Ii.hsl.hsv=function(t){let e=t[0],r=t[1]/100,n=t[2]/100,i=r,s=Math.max(n,.01);n*=2,r*=n<=1?n:2-n,i*=s<=1?s:2-s;let o=(n+r)/2,a=n===0?2*i/(s+i):2*r/(n+r);return[e,a*100,o*100]};Ii.hsv.rgb=function(t){let e=t[0]/60,r=t[1]/100,n=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*n*(1-r),a=255*n*(1-r*s),c=255*n*(1-r*(1-s));switch(n*=255,i){case 0:return[n,c,o];case 1:return[a,n,o];case 2:return[o,n,c];case 3:return[o,a,n];case 4:return[c,o,n];case 5:return[n,o,a]}};Ii.hsv.hsl=function(t){let e=t[0],r=t[1]/100,n=t[2]/100,i=Math.max(n,.01),s,o;o=(2-r)*n;let a=(2-r)*i;return s=r*i,s/=a<=1?a:2-a,s=s||0,o/=2,[e,s*100,o*100]};Ii.hwb.rgb=function(t){let e=t[0]/360,r=t[1]/100,n=t[2]/100,i=r+n,s;i>1&&(r/=i,n/=i);let o=Math.floor(6*e),a=1-n;s=6*e-o,(o&1)!==0&&(s=1-s);let c=r+s*(a-r),u,l,A;switch(o){default:case 6:case 0:u=a,l=c,A=r;break;case 1:u=c,l=a,A=r;break;case 2:u=r,l=a,A=c;break;case 3:u=r,l=c,A=a;break;case 4:u=c,l=r,A=a;break;case 5:u=a,l=r,A=c;break}return[u*255,l*255,A*255]};Ii.cmyk.rgb=function(t){let e=t[0]/100,r=t[1]/100,n=t[2]/100,i=t[3]/100,s=1-Math.min(1,e*(1-i)+i),o=1-Math.min(1,r*(1-i)+i),a=1-Math.min(1,n*(1-i)+i);return[s*255,o*255,a*255]};Ii.xyz.rgb=function(t){let e=t[0]/100,r=t[1]/100,n=t[2]/100,i,s,o;return i=e*3.2406+r*-1.5372+n*-.4986,s=e*-.9689+r*1.8758+n*.0415,o=e*.0557+r*-.204+n*1.057,i=i>.0031308?1.055*i**(1/2.4)-.055:i*12.92,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),o=Math.min(Math.max(0,o),1),[i*255,s*255,o*255]};Ii.xyz.lab=function(t){let e=t[0],r=t[1],n=t[2];e/=95.047,r/=100,n/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;let i=116*r-16,s=500*(e-r),o=200*(r-n);return[i,s,o]};Ii.lab.xyz=function(t){let e=t[0],r=t[1],n=t[2],i,s,o;s=(e+16)/116,i=r/500+s,o=s-n/200;let a=s**3,c=i**3,u=o**3;return s=a>.008856?a:(s-16/116)/7.787,i=c>.008856?c:(i-16/116)/7.787,o=u>.008856?u:(o-16/116)/7.787,i*=95.047,s*=100,o*=108.883,[i,s,o]};Ii.lab.lch=function(t){let e=t[0],r=t[1],n=t[2],i;i=Math.atan2(n,r)*360/2/Math.PI,i<0&&(i+=360);let o=Math.sqrt(r*r+n*n);return[e,o,i]};Ii.lch.lab=function(t){let e=t[0],r=t[1],i=t[2]/360*2*Math.PI,s=r*Math.cos(i),o=r*Math.sin(i);return[e,s,o]};Ii.rgb.ansi16=function(t,e=null){let[r,n,i]=t,s=e===null?Ii.rgb.hsv(t)[2]:e;if(s=Math.round(s/50),s===0)return 30;let o=30+(Math.round(i/255)<<2|Math.round(n/255)<<1|Math.round(r/255));return s===2&&(o+=60),o};Ii.hsv.ansi16=function(t){return Ii.rgb.ansi16(Ii.hsv.rgb(t),t[2])};Ii.rgb.ansi256=function(t){let e=t[0],r=t[1],n=t[2];return e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)};Ii.ansi16.rgb=function(t){let e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let r=(~~(t>50)+1)*.5,n=(e&1)*r*255,i=(e>>1&1)*r*255,s=(e>>2&1)*r*255;return[n,i,s]};Ii.ansi256.rgb=function(t){if(t>=232){let s=(t-232)*10+8;return[s,s,s]}t-=16;let e,r=Math.floor(t/36)/5*255,n=Math.floor((e=t%36)/6)/5*255,i=e%6/5*255;return[r,n,i]};Ii.rgb.hex=function(t){let r=(((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255)).toString(16).toUpperCase();return"000000".substring(r.length)+r};Ii.hex.rgb=function(t){let e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let r=e[0];e[0].length===3&&(r=r.split("").map(a=>a+a).join(""));let n=parseInt(r,16),i=n>>16&255,s=n>>8&255,o=n&255;return[i,s,o]};Ii.rgb.hcg=function(t){let e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.max(Math.max(e,r),n),s=Math.min(Math.min(e,r),n),o=i-s,a,c;return o<1?a=s/(1-o):a=0,o<=0?c=0:i===e?c=(r-n)/o%6:i===r?c=2+(n-e)/o:c=4+(e-r)/o,c/=6,c%=1,[c*360,o*100,a*100]};Ii.hsl.hcg=function(t){let e=t[1]/100,r=t[2]/100,n=r<.5?2*e*r:2*e*(1-r),i=0;return n<1&&(i=(r-.5*n)/(1-n)),[t[0],n*100,i*100]};Ii.hsv.hcg=function(t){let e=t[1]/100,r=t[2]/100,n=e*r,i=0;return n<1&&(i=(r-n)/(1-n)),[t[0],n*100,i*100]};Ii.hcg.rgb=function(t){let e=t[0]/360,r=t[1]/100,n=t[2]/100;if(r===0)return[n*255,n*255,n*255];let i=[0,0,0],s=e%1*6,o=s%1,a=1-o,c=0;switch(Math.floor(s)){case 0:i[0]=1,i[1]=o,i[2]=0;break;case 1:i[0]=a,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=o;break;case 3:i[0]=0,i[1]=a,i[2]=1;break;case 4:i[0]=o,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=a}return c=(1-r)*n,[(r*i[0]+c)*255,(r*i[1]+c)*255,(r*i[2]+c)*255]};Ii.hcg.hsv=function(t){let e=t[1]/100,r=t[2]/100,n=e+r*(1-e),i=0;return n>0&&(i=e/n),[t[0],i*100,n*100]};Ii.hcg.hsl=function(t){let e=t[1]/100,n=t[2]/100*(1-e)+.5*e,i=0;return n>0&&n<.5?i=e/(2*n):n>=.5&&n<1&&(i=e/(2*(1-n))),[t[0],i*100,n*100]};Ii.hcg.hwb=function(t){let e=t[1]/100,r=t[2]/100,n=e+r*(1-e);return[t[0],(n-e)*100,(1-n)*100]};Ii.hwb.hcg=function(t){let e=t[1]/100,n=1-t[2]/100,i=n-e,s=0;return i<1&&(s=(n-i)/(1-i)),[t[0],i*100,s*100]};Ii.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};Ii.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};Ii.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};Ii.gray.hsl=function(t){return[0,0,t[0]]};Ii.gray.hsv=Ii.gray.hsl;Ii.gray.hwb=function(t){return[0,100,t[0]]};Ii.gray.cmyk=function(t){return[0,0,0,t[0]]};Ii.gray.lab=function(t){return[t[0],0,0]};Ii.gray.hex=function(t){let e=Math.round(t[0]/100*255)&255,n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n};Ii.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]}});var H5r=m((iKa,j5r)=>{var xQe=g_t();function Mns(){let t={},e=Object.keys(xQe);for(let r=e.length,n=0;n<r;n++)t[e[n]]={distance:-1,parent:null};return t}function Ons(t){let e=Mns(),r=[t];for(e[t].distance=0;r.length;){let n=r.pop(),i=Object.keys(xQe[n]);for(let s=i.length,o=0;o<s;o++){let a=i[o],c=e[a];c.distance===-1&&(c.distance=e[n].distance+1,c.parent=n,r.unshift(a))}}return e}function wns(t,e){return function(r){return e(t(r))}}function Sns(t,e){let r=[e[t].parent,t],n=xQe[e[t].parent][t],i=e[t].parent;for(;e[i].parent;)r.unshift(e[i].parent),n=wns(xQe[e[i].parent][i],n),i=e[i].parent;return n.conversion=r,n}j5r.exports=function(t){let e=Ons(t),r={},n=Object.keys(e);for(let i=n.length,s=0;s<i;s++){let o=n[s];e[o].parent!==null&&(r[o]=Sns(o,e))}return r}});var $5r=m((sKa,V5r)=>{var m_t=g_t(),Rns=H5r(),MY={},Tns=Object.keys(m_t);function vns(t){let e=function(...r){let n=r[0];return n==null?n:(n.length>1&&(r=n),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function Dns(t){let e=function(...r){let n=r[0];if(n==null)return n;n.length>1&&(r=n);let i=t(r);if(typeof i=="object")for(let s=i.length,o=0;o<s;o++)i[o]=Math.round(i[o]);return i};return"conversion"in t&&(e.conversion=t.conversion),e}Tns.forEach(t=>{MY[t]={},Object.defineProperty(MY[t],"channels",{value:m_t[t].channels}),Object.defineProperty(MY[t],"labels",{value:m_t[t].labels});let e=Rns(t);Object.keys(e).forEach(n=>{let i=e[n];MY[t][n]=Dns(i),MY[t][n].raw=vns(i)})});V5r.exports=MY});var e6r=m((oKa,Z5r)=>{"use strict";var K5r=(t,e)=>(...r)=>`\x1B[${t(...r)+e}m`,Y5r=(t,e)=>(...r)=>{let n=t(...r);return`\x1B[${38+e};5;${n}m`},J5r=(t,e)=>(...r)=>{let n=t(...r);return`\x1B[${38+e};2;${n[0]};${n[1]};${n[2]}m`},BQe=t=>t,X5r=(t,e,r)=>[t,e,r],OY=(t,e,r)=>{Object.defineProperty(t,e,{get:()=>{let n=r();return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0}),n},enumerable:!0,configurable:!0})},E_t,wY=(t,e,r,n)=>{E_t===void 0&&(E_t=$5r());let i=n?10:0,s={};for(let[o,a]of Object.entries(E_t)){let c=o==="ansi16"?"ansi":o;o===e?s[c]=t(r,i):typeof a=="object"&&(s[c]=t(a[e],i))}return s};function Nns(){let t=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[r,n]of Object.entries(e)){for(let[i,s]of Object.entries(n))e[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[i]=e[i],t.set(s[0],s[1]);Object.defineProperty(e,r,{value:n,enumerable:!1})}return Object.defineProperty(e,"codes",{value:t,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",OY(e.color,"ansi",()=>wY(K5r,"ansi16",BQe,!1)),OY(e.color,"ansi256",()=>wY(Y5r,"ansi256",BQe,!1)),OY(e.color,"ansi16m",()=>wY(J5r,"rgb",X5r,!1)),OY(e.bgColor,"ansi",()=>wY(K5r,"ansi16",BQe,!0)),OY(e.bgColor,"ansi256",()=>wY(Y5r,"ansi256",BQe,!0)),OY(e.bgColor,"ansi16m",()=>wY(J5r,"rgb",X5r,!0)),e}Object.defineProperty(Z5r,"exports",{enumerable:!0,get:Nns})});var r6r=m((aKa,t6r)=>{"use strict";t6r.exports=(t,e=process.argv)=>{let r=t.startsWith("-")?"":t.length===1?"-":"--",n=e.indexOf(r+t),i=e.indexOf("--");return n!==-1&&(i===-1||n<i)}});var I_t=m((cKa,i6r)=>{"use strict";var Qns=require("os"),n6r=require("tty"),ZI=r6r(),{env:Sd}=process,LL;ZI("no-color")||ZI("no-colors")||ZI("color=false")||ZI("color=never")?LL=0:(ZI("color")||ZI("colors")||ZI("color=true")||ZI("color=always"))&&(LL=1);"FORCE_COLOR"in Sd&&(Sd.FORCE_COLOR==="true"?LL=1:Sd.FORCE_COLOR==="false"?LL=0:LL=Sd.FORCE_COLOR.length===0?1:Math.min(parseInt(Sd.FORCE_COLOR,10),3));function y_t(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function C_t(t,e){if(LL===0)return 0;if(ZI("color=16m")||ZI("color=full")||ZI("color=truecolor"))return 3;if(ZI("color=256"))return 2;if(t&&!e&&LL===void 0)return 0;let r=LL||0;if(Sd.TERM==="dumb")return r;if(process.platform==="win32"){let n=Qns.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in Sd)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in Sd)||Sd.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in Sd)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Sd.TEAMCITY_VERSION)?1:0;if(Sd.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Sd){let n=parseInt((Sd.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Sd.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Sd.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Sd.TERM)||"COLORTERM"in Sd?1:r}function zns(t){let e=C_t(t,t&&t.isTTY);return y_t(e)}i6r.exports={supportsColor:zns,stdout:y_t(C_t(!0,n6r.isatty(1))),stderr:y_t(C_t(!0,n6r.isatty(2)))}});var o6r=m((uKa,s6r)=>{"use strict";var Lns=(t,e,r)=>{let n=t.indexOf(e);if(n===-1)return t;let i=e.length,s=0,o="";do o+=t.substr(s,n-s)+e+r,s=n+i,n=t.indexOf(e,s);while(n!==-1);return o+=t.substr(s),o},Pns=(t,e,r,n)=>{let i=0,s="";do{let o=t[n-1]==="\r";s+=t.substr(i,(o?n-1:n)-i)+e+(o?`\r
|
|
857
|
+
run: ${y.query}`),b=await RE(()=>I.getSQL(u));E=E.replace(y.text,`(${b})`)}catch(I){o.error(Y1(I))}if(s[`statement_${h}`].sql=E.trim(),n)return o.sql("Compiled SQL:"),o.sql(E.trim()),JSON.stringify(s);try{let y=await u0.connections.lookupConnection(g.config?.connection);o.sql("Executing SQL:"),o.sql(E);let I=await RE(()=>y.runSQL(E));I&&(o.task("Results:"),I.rows.length===0?(o.result("Statement successfully completed with no results"),s[`statement_${h}`].results=void 0):(o.result(JSON.stringify(I.rows,null,2)),s[`statement_${h}`].results=I.rows))}catch(y){o.error(Y1(y))}}if(h===i)break}}catch(a){o.error(Y1(a))}return o.json(JSON.stringify(s,null,2)),JSON.stringify(s)}var D5r,N5r,BY,h_t,z5r=te(()=>{"use strict";D5r=Nr(require("node:url")),N5r=Nr(Hc());Dy();BY=Nr(v5r());Fv();hU();h_t=class{constructor(e){this.url=new URL("malloy://internal");this.contents="";this.uriReader=e}setVirtualFile(e,r){this.url=e,this.contents=r}async readURL(e){if(e.toString()===this.url.toString())return this.contents;{let r=await this.uriReader.readURL(e);return typeof r=="string"?r:r.contents}}}});async function k5r(t,e){let r=_Qe(e.json?"json":["malloy","compiled-sql","results","tasks"]),n=JSON.parse("{}"),i=P5r.default.pathToFileURL(t);try{return await RE(async()=>{let o=new L5r.Runtime({config:u0,urlReader:DL}).loadModel(i),a;if(e.queryOptions)switch(e.queryOptions.type){case"index":a=o.loadQueryByIndex(e.queryOptions.index);break;case"name":a=o.loadQueryByName(e.queryOptions.name);break;case"string":a=o.loadQuery(`run: ${e.queryOptions.query}`);break}else{let f=await o.getModel(),{named:h,unnamed:g}=f.queries();if(h.length+g===0){if(e.compileOnly)return r.malloy("Model compiled successfully (no queries to compile)."),JSON.stringify(n);r.error("Nothing to run: this model has no queries.")}a=o.loadFinalQuery()}let c=e.givens?{givens:e.givens}:{},u=await a.getSQL(c);if(n.sql=u.trim(),e.compileOnly)return r.sql("Compiled SQL:"),r.sql(u),JSON.stringify(n);let l=e.rowLimit??qv,p=(await a.run({rowLimit:l,...c})).toJSON().queryResult.result;return p.length===l&&r.result(`WARNING: Results truncated to ${l} results.`),r.result(JSON.stringify(p,null,2)),n.results=JSON.stringify(p),JSON.stringify(n)})}catch(s){r.error(Y1(s))}}var L5r,P5r,F5r=te(()=>{"use strict";L5r=Nr(Hc()),P5r=Nr(require("node:url"));Fv();hU();Dy()});var U5r=m((rKa,q5r)=>{"use strict";q5r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var g_t=m((nKa,W5r)=>{var w1e=U5r(),G5r={};for(let t of Object.keys(w1e))G5r[w1e[t]]=t;var Ii={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};W5r.exports=Ii;for(let t of Object.keys(Ii)){if(!("channels"in Ii[t]))throw new Error("missing channels property: "+t);if(!("labels"in Ii[t]))throw new Error("missing channel labels property: "+t);if(Ii[t].labels.length!==Ii[t].channels)throw new Error("channel and label counts mismatch: "+t);let{channels:e,labels:r}=Ii[t];delete Ii[t].channels,delete Ii[t].labels,Object.defineProperty(Ii[t],"channels",{value:e}),Object.defineProperty(Ii[t],"labels",{value:r})}Ii.rgb.hsl=function(t){let e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.min(e,r,n),s=Math.max(e,r,n),o=s-i,a,c;s===i?a=0:e===s?a=(r-n)/o:r===s?a=2+(n-e)/o:n===s&&(a=4+(e-r)/o),a=Math.min(a*60,360),a<0&&(a+=360);let u=(i+s)/2;return s===i?c=0:u<=.5?c=o/(s+i):c=o/(2-s-i),[a,c*100,u*100]};Ii.rgb.hsv=function(t){let e,r,n,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),l=u-Math.min(o,a,c),A=function(p){return(u-p)/6/l+1/2};return l===0?(i=0,s=0):(s=l/u,e=A(o),r=A(a),n=A(c),o===u?i=n-r:a===u?i=1/3+e-n:c===u&&(i=2/3+r-e),i<0?i+=1:i>1&&(i-=1)),[i*360,s*100,u*100]};Ii.rgb.hwb=function(t){let e=t[0],r=t[1],n=t[2],i=Ii.rgb.hsl(t)[0],s=1/255*Math.min(e,Math.min(r,n));return n=1-1/255*Math.max(e,Math.max(r,n)),[i,s*100,n*100]};Ii.rgb.cmyk=function(t){let e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.min(1-e,1-r,1-n),s=(1-e-i)/(1-i)||0,o=(1-r-i)/(1-i)||0,a=(1-n-i)/(1-i)||0;return[s*100,o*100,a*100,i*100]};function Bns(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}Ii.rgb.keyword=function(t){let e=G5r[t];if(e)return e;let r=1/0,n;for(let i of Object.keys(w1e)){let s=w1e[i],o=Bns(t,s);o<r&&(r=o,n=i)}return n};Ii.keyword.rgb=function(t){return w1e[t]};Ii.rgb.xyz=function(t){let e=t[0]/255,r=t[1]/255,n=t[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;let i=e*.4124+r*.3576+n*.1805,s=e*.2126+r*.7152+n*.0722,o=e*.0193+r*.1192+n*.9505;return[i*100,s*100,o*100]};Ii.rgb.lab=function(t){let e=Ii.rgb.xyz(t),r=e[0],n=e[1],i=e[2];r/=95.047,n/=100,i/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;let s=116*n-16,o=500*(r-n),a=200*(n-i);return[s,o,a]};Ii.hsl.rgb=function(t){let e=t[0]/360,r=t[1]/100,n=t[2]/100,i,s,o;if(r===0)return o=n*255,[o,o,o];n<.5?i=n*(1+r):i=n+r-n*r;let a=2*n-i,c=[0,0,0];for(let u=0;u<3;u++)s=e+1/3*-(u-1),s<0&&s++,s>1&&s--,6*s<1?o=a+(i-a)*6*s:2*s<1?o=i:3*s<2?o=a+(i-a)*(2/3-s)*6:o=a,c[u]=o*255;return c};Ii.hsl.hsv=function(t){let e=t[0],r=t[1]/100,n=t[2]/100,i=r,s=Math.max(n,.01);n*=2,r*=n<=1?n:2-n,i*=s<=1?s:2-s;let o=(n+r)/2,a=n===0?2*i/(s+i):2*r/(n+r);return[e,a*100,o*100]};Ii.hsv.rgb=function(t){let e=t[0]/60,r=t[1]/100,n=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*n*(1-r),a=255*n*(1-r*s),c=255*n*(1-r*(1-s));switch(n*=255,i){case 0:return[n,c,o];case 1:return[a,n,o];case 2:return[o,n,c];case 3:return[o,a,n];case 4:return[c,o,n];case 5:return[n,o,a]}};Ii.hsv.hsl=function(t){let e=t[0],r=t[1]/100,n=t[2]/100,i=Math.max(n,.01),s,o;o=(2-r)*n;let a=(2-r)*i;return s=r*i,s/=a<=1?a:2-a,s=s||0,o/=2,[e,s*100,o*100]};Ii.hwb.rgb=function(t){let e=t[0]/360,r=t[1]/100,n=t[2]/100,i=r+n,s;i>1&&(r/=i,n/=i);let o=Math.floor(6*e),a=1-n;s=6*e-o,(o&1)!==0&&(s=1-s);let c=r+s*(a-r),u,l,A;switch(o){default:case 6:case 0:u=a,l=c,A=r;break;case 1:u=c,l=a,A=r;break;case 2:u=r,l=a,A=c;break;case 3:u=r,l=c,A=a;break;case 4:u=c,l=r,A=a;break;case 5:u=a,l=r,A=c;break}return[u*255,l*255,A*255]};Ii.cmyk.rgb=function(t){let e=t[0]/100,r=t[1]/100,n=t[2]/100,i=t[3]/100,s=1-Math.min(1,e*(1-i)+i),o=1-Math.min(1,r*(1-i)+i),a=1-Math.min(1,n*(1-i)+i);return[s*255,o*255,a*255]};Ii.xyz.rgb=function(t){let e=t[0]/100,r=t[1]/100,n=t[2]/100,i,s,o;return i=e*3.2406+r*-1.5372+n*-.4986,s=e*-.9689+r*1.8758+n*.0415,o=e*.0557+r*-.204+n*1.057,i=i>.0031308?1.055*i**(1/2.4)-.055:i*12.92,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),o=Math.min(Math.max(0,o),1),[i*255,s*255,o*255]};Ii.xyz.lab=function(t){let e=t[0],r=t[1],n=t[2];e/=95.047,r/=100,n/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;let i=116*r-16,s=500*(e-r),o=200*(r-n);return[i,s,o]};Ii.lab.xyz=function(t){let e=t[0],r=t[1],n=t[2],i,s,o;s=(e+16)/116,i=r/500+s,o=s-n/200;let a=s**3,c=i**3,u=o**3;return s=a>.008856?a:(s-16/116)/7.787,i=c>.008856?c:(i-16/116)/7.787,o=u>.008856?u:(o-16/116)/7.787,i*=95.047,s*=100,o*=108.883,[i,s,o]};Ii.lab.lch=function(t){let e=t[0],r=t[1],n=t[2],i;i=Math.atan2(n,r)*360/2/Math.PI,i<0&&(i+=360);let o=Math.sqrt(r*r+n*n);return[e,o,i]};Ii.lch.lab=function(t){let e=t[0],r=t[1],i=t[2]/360*2*Math.PI,s=r*Math.cos(i),o=r*Math.sin(i);return[e,s,o]};Ii.rgb.ansi16=function(t,e=null){let[r,n,i]=t,s=e===null?Ii.rgb.hsv(t)[2]:e;if(s=Math.round(s/50),s===0)return 30;let o=30+(Math.round(i/255)<<2|Math.round(n/255)<<1|Math.round(r/255));return s===2&&(o+=60),o};Ii.hsv.ansi16=function(t){return Ii.rgb.ansi16(Ii.hsv.rgb(t),t[2])};Ii.rgb.ansi256=function(t){let e=t[0],r=t[1],n=t[2];return e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)};Ii.ansi16.rgb=function(t){let e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let r=(~~(t>50)+1)*.5,n=(e&1)*r*255,i=(e>>1&1)*r*255,s=(e>>2&1)*r*255;return[n,i,s]};Ii.ansi256.rgb=function(t){if(t>=232){let s=(t-232)*10+8;return[s,s,s]}t-=16;let e,r=Math.floor(t/36)/5*255,n=Math.floor((e=t%36)/6)/5*255,i=e%6/5*255;return[r,n,i]};Ii.rgb.hex=function(t){let r=(((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255)).toString(16).toUpperCase();return"000000".substring(r.length)+r};Ii.hex.rgb=function(t){let e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let r=e[0];e[0].length===3&&(r=r.split("").map(a=>a+a).join(""));let n=parseInt(r,16),i=n>>16&255,s=n>>8&255,o=n&255;return[i,s,o]};Ii.rgb.hcg=function(t){let e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.max(Math.max(e,r),n),s=Math.min(Math.min(e,r),n),o=i-s,a,c;return o<1?a=s/(1-o):a=0,o<=0?c=0:i===e?c=(r-n)/o%6:i===r?c=2+(n-e)/o:c=4+(e-r)/o,c/=6,c%=1,[c*360,o*100,a*100]};Ii.hsl.hcg=function(t){let e=t[1]/100,r=t[2]/100,n=r<.5?2*e*r:2*e*(1-r),i=0;return n<1&&(i=(r-.5*n)/(1-n)),[t[0],n*100,i*100]};Ii.hsv.hcg=function(t){let e=t[1]/100,r=t[2]/100,n=e*r,i=0;return n<1&&(i=(r-n)/(1-n)),[t[0],n*100,i*100]};Ii.hcg.rgb=function(t){let e=t[0]/360,r=t[1]/100,n=t[2]/100;if(r===0)return[n*255,n*255,n*255];let i=[0,0,0],s=e%1*6,o=s%1,a=1-o,c=0;switch(Math.floor(s)){case 0:i[0]=1,i[1]=o,i[2]=0;break;case 1:i[0]=a,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=o;break;case 3:i[0]=0,i[1]=a,i[2]=1;break;case 4:i[0]=o,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=a}return c=(1-r)*n,[(r*i[0]+c)*255,(r*i[1]+c)*255,(r*i[2]+c)*255]};Ii.hcg.hsv=function(t){let e=t[1]/100,r=t[2]/100,n=e+r*(1-e),i=0;return n>0&&(i=e/n),[t[0],i*100,n*100]};Ii.hcg.hsl=function(t){let e=t[1]/100,n=t[2]/100*(1-e)+.5*e,i=0;return n>0&&n<.5?i=e/(2*n):n>=.5&&n<1&&(i=e/(2*(1-n))),[t[0],i*100,n*100]};Ii.hcg.hwb=function(t){let e=t[1]/100,r=t[2]/100,n=e+r*(1-e);return[t[0],(n-e)*100,(1-n)*100]};Ii.hwb.hcg=function(t){let e=t[1]/100,n=1-t[2]/100,i=n-e,s=0;return i<1&&(s=(n-i)/(1-i)),[t[0],i*100,s*100]};Ii.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};Ii.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};Ii.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};Ii.gray.hsl=function(t){return[0,0,t[0]]};Ii.gray.hsv=Ii.gray.hsl;Ii.gray.hwb=function(t){return[0,100,t[0]]};Ii.gray.cmyk=function(t){return[0,0,0,t[0]]};Ii.gray.lab=function(t){return[t[0],0,0]};Ii.gray.hex=function(t){let e=Math.round(t[0]/100*255)&255,n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n};Ii.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]}});var H5r=m((iKa,j5r)=>{var xQe=g_t();function Mns(){let t={},e=Object.keys(xQe);for(let r=e.length,n=0;n<r;n++)t[e[n]]={distance:-1,parent:null};return t}function Ons(t){let e=Mns(),r=[t];for(e[t].distance=0;r.length;){let n=r.pop(),i=Object.keys(xQe[n]);for(let s=i.length,o=0;o<s;o++){let a=i[o],c=e[a];c.distance===-1&&(c.distance=e[n].distance+1,c.parent=n,r.unshift(a))}}return e}function wns(t,e){return function(r){return e(t(r))}}function Sns(t,e){let r=[e[t].parent,t],n=xQe[e[t].parent][t],i=e[t].parent;for(;e[i].parent;)r.unshift(e[i].parent),n=wns(xQe[e[i].parent][i],n),i=e[i].parent;return n.conversion=r,n}j5r.exports=function(t){let e=Ons(t),r={},n=Object.keys(e);for(let i=n.length,s=0;s<i;s++){let o=n[s];e[o].parent!==null&&(r[o]=Sns(o,e))}return r}});var $5r=m((sKa,V5r)=>{var m_t=g_t(),Rns=H5r(),MY={},Tns=Object.keys(m_t);function vns(t){let e=function(...r){let n=r[0];return n==null?n:(n.length>1&&(r=n),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function Dns(t){let e=function(...r){let n=r[0];if(n==null)return n;n.length>1&&(r=n);let i=t(r);if(typeof i=="object")for(let s=i.length,o=0;o<s;o++)i[o]=Math.round(i[o]);return i};return"conversion"in t&&(e.conversion=t.conversion),e}Tns.forEach(t=>{MY[t]={},Object.defineProperty(MY[t],"channels",{value:m_t[t].channels}),Object.defineProperty(MY[t],"labels",{value:m_t[t].labels});let e=Rns(t);Object.keys(e).forEach(n=>{let i=e[n];MY[t][n]=Dns(i),MY[t][n].raw=vns(i)})});V5r.exports=MY});var e6r=m((oKa,Z5r)=>{"use strict";var K5r=(t,e)=>(...r)=>`\x1B[${t(...r)+e}m`,Y5r=(t,e)=>(...r)=>{let n=t(...r);return`\x1B[${38+e};5;${n}m`},J5r=(t,e)=>(...r)=>{let n=t(...r);return`\x1B[${38+e};2;${n[0]};${n[1]};${n[2]}m`},BQe=t=>t,X5r=(t,e,r)=>[t,e,r],OY=(t,e,r)=>{Object.defineProperty(t,e,{get:()=>{let n=r();return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0}),n},enumerable:!0,configurable:!0})},E_t,wY=(t,e,r,n)=>{E_t===void 0&&(E_t=$5r());let i=n?10:0,s={};for(let[o,a]of Object.entries(E_t)){let c=o==="ansi16"?"ansi":o;o===e?s[c]=t(r,i):typeof a=="object"&&(s[c]=t(a[e],i))}return s};function Nns(){let t=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[r,n]of Object.entries(e)){for(let[i,s]of Object.entries(n))e[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[i]=e[i],t.set(s[0],s[1]);Object.defineProperty(e,r,{value:n,enumerable:!1})}return Object.defineProperty(e,"codes",{value:t,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",OY(e.color,"ansi",()=>wY(K5r,"ansi16",BQe,!1)),OY(e.color,"ansi256",()=>wY(Y5r,"ansi256",BQe,!1)),OY(e.color,"ansi16m",()=>wY(J5r,"rgb",X5r,!1)),OY(e.bgColor,"ansi",()=>wY(K5r,"ansi16",BQe,!0)),OY(e.bgColor,"ansi256",()=>wY(Y5r,"ansi256",BQe,!0)),OY(e.bgColor,"ansi16m",()=>wY(J5r,"rgb",X5r,!0)),e}Object.defineProperty(Z5r,"exports",{enumerable:!0,get:Nns})});var r6r=m((aKa,t6r)=>{"use strict";t6r.exports=(t,e=process.argv)=>{let r=t.startsWith("-")?"":t.length===1?"-":"--",n=e.indexOf(r+t),i=e.indexOf("--");return n!==-1&&(i===-1||n<i)}});var I_t=m((cKa,i6r)=>{"use strict";var Qns=require("os"),n6r=require("tty"),ZI=r6r(),{env:Sd}=process,LL;ZI("no-color")||ZI("no-colors")||ZI("color=false")||ZI("color=never")?LL=0:(ZI("color")||ZI("colors")||ZI("color=true")||ZI("color=always"))&&(LL=1);"FORCE_COLOR"in Sd&&(Sd.FORCE_COLOR==="true"?LL=1:Sd.FORCE_COLOR==="false"?LL=0:LL=Sd.FORCE_COLOR.length===0?1:Math.min(parseInt(Sd.FORCE_COLOR,10),3));function y_t(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function C_t(t,e){if(LL===0)return 0;if(ZI("color=16m")||ZI("color=full")||ZI("color=truecolor"))return 3;if(ZI("color=256"))return 2;if(t&&!e&&LL===void 0)return 0;let r=LL||0;if(Sd.TERM==="dumb")return r;if(process.platform==="win32"){let n=Qns.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in Sd)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in Sd)||Sd.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in Sd)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Sd.TEAMCITY_VERSION)?1:0;if(Sd.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Sd){let n=parseInt((Sd.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Sd.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Sd.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Sd.TERM)||"COLORTERM"in Sd?1:r}function zns(t){let e=C_t(t,t&&t.isTTY);return y_t(e)}i6r.exports={supportsColor:zns,stdout:y_t(C_t(!0,n6r.isatty(1))),stderr:y_t(C_t(!0,n6r.isatty(2)))}});var o6r=m((uKa,s6r)=>{"use strict";var Lns=(t,e,r)=>{let n=t.indexOf(e);if(n===-1)return t;let i=e.length,s=0,o="";do o+=t.substr(s,n-s)+e+r,s=n+i,n=t.indexOf(e,s);while(n!==-1);return o+=t.substr(s),o},Pns=(t,e,r,n)=>{let i=0,s="";do{let o=t[n-1]==="\r";s+=t.substr(i,(o?n-1:n)-i)+e+(o?`\r
|
|
858
858
|
`:`
|
|
859
859
|
`)+r,i=n+1,n=t.indexOf(`
|
|
860
860
|
`,i)}while(n!==-1);return s+=t.substr(i),s};s6r.exports={stringReplaceAll:Lns,stringEncaseCRLFWithFirstIndex:Pns}});var A6r=m((lKa,l6r)=>{"use strict";var kns=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,a6r=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,Fns=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,qns=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,Uns=new Map([["n",`
|
|
@@ -4520,7 +4520,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4520
4520
|
`+t}async function $F(t){if(t.uri&&t.source||!t.uri&&t.source===void 0)return{ok:!1,problems:[{severity:"error",code:"bad-input",message:"Exactly one of {uri, source} must be provided."}]};let e=t.source!==void 0?RPa(t.source):void 0,r=t.uri?hIi(t.uri):wPa(t.baseUri),{urlReader:n,readSource:i}=SPa(r,e),s=new Lut.Runtime({config:u0,urlReader:n});try{let o=await RE(()=>s.loadModel(r).getModel());return{ok:!0,loaded:{model:o,rootUrl:r,runtime:s,readSource:i},problems:VF(o.problems)}}catch(o){return o instanceof Lut.MalloyError?{ok:!1,problems:VF(o.problems)}:{ok:!1,problems:[bj(o,r.href)]}}}var A2r,pIi,fIi,Lut,OPa,Put=te(()=>{"use strict";A2r=Nr(require("node:url")),pIi=Nr(require("node:fs")),fIi=Nr(require("node:path")),Lut=Nr(Hc());Fv();Dy();l2r();OPa="memory://mcp/"});function _j(t){if(t)return[t.range.start.line,t.range.start.character]}function KF(t){return t?t.forRoute().map(e=>({route:e.route,text:e.content})):[]}function MBe(t,e){return!!t&&t.url===e}function p2r(t,e){if(!t||!e)return;let r=t.split(`
|
|
4521
4521
|
`),{start:n,end:i}=e.range;if(n.line<0||n.line>=r.length||i.line<0||i.line>=r.length)return;if(n.line===i.line)return r[n.line].slice(n.character,i.character);let s=[r[n.line].slice(n.character)];for(let o=n.line+1;o<i.line;o++)s.push(r[o]);return s.push(r[i.line].slice(0,i.character)),s.join(`
|
|
4522
4522
|
`)}function vPa(t){let e=t.structDef.join;return e==="one"||e==="many"||e==="cross"?e:"one"}function gIi(t){let e=t.structDef;return e.type==="array"&&e.elementTypeDef?.type!=="record_element"}function DPa(t){let e=t.structDef;return e.type==="array"&&e.elementTypeDef?.type==="record_element"}function NPa(t){return t.structDef.type==="record"}function QPa(t,e){return gIi(t)?e.filter(r=>r.name!=="value"):e}function zPa(t,e){let n=e.find(i=>i.name===t.name)?.expressionType;return n&&((0,kut.expressionIsAggregate)(n)||(0,kut.expressionIsAnalytic)(n))?"measure":"dimension"}function LPa(t,e){if(gIi(t)||DPa(t)||NPa(t))return;let r=t.structDef;if(r.sourceID){let n=r.sourceID.split("@")[0];if(n&&e.has(n))return n}if(r.name&&e.has(r.name))return r.name;if(e.has(t.name))return t.name}function mIi(t,e,r,n){let i=KF(t.annotations),s=t.location,o=MBe(s,n.rootUri),a={name:t.name,kind:"dimension"};if(i.length>0&&(a.annotations=i),o){let l=_j(s);l&&(a.location=l)}if(t.isExploreField()){let l=t,A=LPa(l,n.knownSources);if(a.kind="join",a.relationship=vPa(l),A&&(a.source_ref=A),(n.opts.expand==="inline"||!A)&&r<TPa){let f=l.structDef.fields??[],h=[];for(let g of l.allFields)h.push(mIi(g,f,r+1,n));a.fields=QPa(l,h)}return a}if(t.isQueryField()){let l=t;a.kind="view";let A=l.expression||void 0;if(A&&A!==t.name&&(a.expression=A),o&&s){let p=n.readSource(s.url),f=p2r(p,s);f&&(a.body=f)}return a}let c=t;a.kind=zPa(c,e),a.type=c.type;let u=c.expression||void 0;return u&&u!==t.name&&(a.expression=u),a}function PPa(t,e){let r=[],n=[],i=[],s=[],o=t.structDef.fields??[];for(let l of t.allFields){let A=mIi(l,o,0,e);switch(A.kind){case"dimension":r.push(A);break;case"measure":n.push(A);break;case"view":i.push(A);break;case"join":s.push(A);break}}let a=KF(t.annotations),c={name:t.name,dimensions:r,measures:n,views:i,joins:s};a.length>0&&(c.annotations=a);let u=_j(t.location);return u&&(c.location=u),t.primaryKey&&(c.primaryKey=t.primaryKey),c}function EIi(t){if(t.type==="filter expression")return t.filterType?`filter<${t.filterType}>`:"filter";if(t.type==="array"){let e=t.elementTypeDef;return e?e.type==="record_element"?"record[]":`${EIi(e)}[]`:"array"}return t.type}function kPa(t,e,r){let n={name:e,type:EIi(t.type),hasDefault:t.default!==void 0},i=KF(t.annotations);i.length>0&&(n.annotations=i);let s=t.location;if(s&&MBe(s,r.rootUri)){let o=_j(s);o&&(n.location=o);let a=p2r(r.readSource(s.url),s);a&&(n.body=a)}return n}function d2r(t){try{return[...t().givens.keys()]}catch{return[]}}async function FPa(t,e,r,n){let i=t.queries(),s=new Set([...t.explores.map(f=>f.name),...i.named]),o={rootUri:e,knownSources:s,opts:n,readSource:r},a=[];for(let f of t.explores)MBe(f.location,e)&&a.push(PPa(f,o));let c=[];for(let f of i.named){let h=t.getPreparedQueryByName(f),g=h.location;if(!MBe(g,e))continue;let E={name:f},y=KF(h.annotations);y.length>0&&(E.annotations=y);let I=_j(g);I&&(E.location=I);let b=p2r(r(e),g);b&&(E.body=b);let S=d2r(()=>h);S.length>0&&(E.givens=S),c.push(E)}let u=[];for(let f=0;f<i.unnamed;f++){let h=t.getPreparedQueryByIndex(f),g={index:f},E=KF(h.annotations);E.length>0&&(g.annotations=E);let y=_j(h.location);y&&(g.location=y);try{let I=[...h.givens.keys()];I.length>0&&(g.givens=I),n.emitRunSql&&(g.sql=h.preparedResult.sql.trim())}catch(I){n.emitRunSql&&(g.error=I instanceof Error?I.message:String(I))}u.push(g)}let l=[];for(let[f,h]of t.givens)l.push(kPa(h,f,o));let A=KF(t.annotations),p={rootUri:e,sources:a,queries:c,runs:u};return A.length>0&&(p.annotations=A),l.length>0&&(p.givens=l),p}async function OBe(t,e={}){let r=await $F(t);if(!r.ok||!r.loaded)return{ok:!1,problems:r.problems};let{model:n,rootUrl:i,readSource:s}=r.loaded;try{return{ok:!0,model:await FPa(n,i.href,s,{expand:e.expand??"ref",emitRunSql:e.emitRunSql??!1}),problems:r.problems}}catch(o){return{ok:!1,problems:[...r.problems,bj(o,i.href)]}}}async function yIi(t){let e=await $F(t);if(!e.ok||!e.loaded)return{ok:!1,runs:[],queries:[],problems:e.problems};let{model:r,rootUrl:n}=e.loaded,i=r.queries(),s=Array.from({length:i.unnamed},(a,c)=>{let u=r.getPreparedQueryByIndex(c),l={index:c},A=_j(u.location);A&&(l.location=A);let p=KF(u.annotations);p.length>0&&(l.annotations=p);let f=d2r(()=>u);return f.length>0&&(l.givens=f),l}),o=i.named.map(a=>{let c=r.getPreparedQueryByName(a),u=c.location;return{pq:c,queryName:a,loc:u}}).filter(({loc:a})=>MBe(a,n.href)).map(({pq:a,queryName:c,loc:u})=>{let l={name:c},A=_j(u);A&&(l.location=A);let p=KF(a.annotations);p.length>0&&(l.annotations=p);let f=d2r(()=>a);return f.length>0&&(l.givens=f),l});return{ok:!0,rootUri:n.href,runs:s,queries:o,problems:e.problems}}var kut,TPa,f2r=te(()=>{"use strict";kut=Nr(Hc());Put();TPa=4});async function h2r(t,e={}){let r=await $F(t);if(!r.ok||!r.loaded)return{ok:!1,problems:r.problems.map(u=>CIi(u,t))};let{model:n,rootUrl:i,runtime:s}=r.loaded,o=n.queries(),a=s.loadModel(i),c;if(e.name){if(!o.named.includes(e.name)){let u={queries:o.named,runs:o.unnamed};return{ok:!1,problems:[{severity:"error",code:"selector-not-found",message:`No query named '${e.name}'. Available: ${JSON.stringify(u)}`,uri:i.href}]}}c=a.loadQueryByName(e.name)}else if(typeof e.index=="number"){if(e.index<0||e.index>=o.unnamed)return{ok:!1,problems:[{severity:"error",code:"selector-out-of-range",message:`Index ${e.index} out of range; file has ${o.unnamed} run: statement(s).`,uri:i.href}]};c=a.loadQueryByIndex(e.index)}else{if(o.unnamed===0)return{ok:!1,problems:[{severity:"error",code:"no-run",message:"Source has no run: statement. Specify a named query via `name`, or add a run: to the source.",uri:i.href}]};c=a.loadFinalQuery()}return g2r(c,e.rowLimit??qv,e.givens,r.problems,{nudge:u=>CIi(u,t),uri:i.href})}async function g2r(t,e,r,n,i={}){let s=r?{givens:r}:void 0;try{let o=Date.now(),a=(await t.getSQL(s)).trim(),c=Date.now(),u=await RE(()=>t.run({rowLimit:e,...s})),l=Date.now(),A=u.toJSON().queryResult.result;return{ok:!0,sql:a,rowCount:A.length,truncated:A.length===e,rows:A,compileTimeMS:c-o,totalTimeMS:l-o,problems:n}}catch(o){let a=i.nudge??(c=>c);return o instanceof IIi.MalloyError?{ok:!1,problems:[...n,...VF(o.problems).map(a)]}:{ok:!1,problems:[...n,bj(o,i.uri)]}}}function CIi(t,e){if(t.code!=="field-not-found")return t;let r=e.uri?`Call compile_file with uri="${e.uri}" to see what fields, measures, views, and joins exist on this source.`:"Call compile on the same source (or compile_file on any imported file) to see what fields, measures, views, and joins exist.";return{...t,message:`${t.message} \u2014 ${r}`,help_topic:t.help_topic??"fields"}}var IIi,m2r=te(()=>{"use strict";IIi=Nr(Hc());Put();hU();Dy()});function BIi(t){return t.split(/\r?\n/).some(e=>_Ii.test(e)||xIi.test(e))}function qPa(t){let e=t.split(/\r?\n/);for(let r=0;r<e.length;r++){let n=_Ii.exec(e[r]);if(n){let s=n[1],o=[];for(let a=r+1;a<e.length;a++){if(/^[ \t]*\|##[ \t]*$/.test(e[a])){let c=o.map(u=>u.startsWith(s)?u.slice(s.length):u).join(`
|
|
4523
|
-
`).trim();return c.length>0?c:void 0}o.push(e[a])}return}let i=xIi.exec(e[r]);if(i){let s=i[1].trim();return s.length>0?s:void 0}}}function Hae(t){return{severity:"error",code:"model-not-found",message:`No published model '${t}'. Models are exposed by carrying the \`##|(mcp-description) \u2026 |##\` marker; call list_models to see what is available.`}}function E2r(t,e){if(K4.default.isAbsolute(e)||e.includes("\0"))return{problem:Hae(e)};let r=K4.default.resolve(t,e),n=K4.default.relative(t,r);if(n.startsWith("..")||K4.default.isAbsolute(n))return{problem:Hae(e)};if(n.split(K4.default.sep).some(i_t))return{problem:Hae(e)};if(!M1e(r)||!Fut.default.existsSync(r))return{problem:Hae(e)};let i;try{i=Fut.default.readFileSync(r,"utf8")}catch{return{problem:Hae(e)}}return BIi(i)?{abs:r}:{problem:Hae(e)}}function MIi(t){let e=[];for(let r of O1e(t)){let n;try{n=Fut.default.readFileSync(r,"utf8")}catch{continue}if(!BIi(n))continue;let i=K4.default.relative(t,r).split(K4.default.sep).join("/"),s=qPa(n);e.push(s?{handle:i,description:s}:{handle:i})}return e.sort((r,n)=>r.handle.localeCompare(n.handle)),e}async function OIi(t,e,r={}){let n=E2r(t,e);return"problem"in n?{ok:!1,problems:[n.problem]}:OBe({uri:n.abs},r)}async function wIi(t,e,r){let n=E2r(t,e);if("problem"in n)return{ok:!1,problems:[n.problem]};let i=await $F({uri:n.abs});if(!i.ok||!i.loaded)return{ok:!1,problems:i.problems};let{runtime:s,rootUrl:o}=i.loaded;try{let a=s.loadModel(o).loadRestrictedQuery(r),c=VF(await a.validate());return{ok:!c.some(l=>l.severity==="error"),problems:[...i.problems,...c]}}catch(a){return a instanceof bIi.MalloyError?{ok:!1,problems:[...i.problems,...VF(a.problems)]}:{ok:!1,problems:[...i.problems,bj(a)]}}}async function SIi(t,e,r,n={}){let i=E2r(t,e);if("problem"in i)return{ok:!1,problems:[i.problem]};let s=await $F({uri:i.abs});if(!s.ok||!s.loaded)return{ok:!1,problems:s.problems};let{runtime:o,rootUrl:a}=s.loaded,c=o.loadModel(a).loadRestrictedQuery(r);return g2r(c,n.rowLimit??qv,n.givens,s.problems)}function RIi(t){if(!t)throw new Error("Restricted MCP mode (--restricted) requires a project directory: pass -p DIR to scope which models are exposed.");return K4.default.resolve(t)}var Fut,K4,bIi,_Ii,xIi,TIi=te(()=>{"use strict";Fut=Nr(require("node:fs")),K4=Nr(require("node:path")),bIi=Nr(Hc());Put();f2r();m2r();hU();Dy();_Ii=/^([ \t]*)##\|\(mcp-description\)[ \t]*$/,xIi=/^[ \t]*##\(mcp-description\)[ \t]?(.*)$/});function wBe(t){let{result:e,errors:r}=(0,vIi.prettify)(t);return{formatted:e,errors:r}}var vIi,y2r=te(()=>{"use strict";vIi=Nr(mX())});var DIi=m((Ln0,UPa)=>{UPa.exports={name:"@malloydata/cli",version:"0.0.56-next.2026.6.26.015031d",description:"Malloy CLI",bin:{"malloy-cli":"dist/index.js","malloy-packages":"scripts/malloy-packages.ts"},files:["dist/**","scripts/malloy-packages.ts"],engines:{node:">=20"},pkg:{assets:["node_modules/@duckdb/node-bindings-*/libduckdb.*","node_modules/@duckdb/node-bindings-*/duckdb.dll"]},scripts:{lint:"tsc --noEmit && eslint .",pretest:"npm run lint",test:"NODE_ENV=test jest --projects jest.config.js --runInBand","pretest-silent":"npm run lint","test-silent":"NODE_ENV=test JEST_SILENT_REPORTER_SHOW_PATHS=true jest --projects jest.config.js --runInBand --reporters jest-silent-reporter","test-e2e":"npm run package-npm test > /dev/null 2>&1 && NODE_ENV=test jest --projects=jest-e2e.config.js --runInBand","test-silent-e2e":"npm run package-npm test > /dev/null 2>&1 && NODE_ENV=test JEST_SILENT_REPORTER_SHOW_PATHS=true jest --projects=jest-e2e.config.js --runInBand --reporters jest-silent-reporter",build:"ts-node scripts/build","build-action":"esbuild --platform=node --bundle ./.github/actions/permission-check/lib/index.ts --outfile=./.github/actions/permission-check/dist/index.js","build-action-dev":"npm run build-action -- --watch",cli:"npx ts-node ./dist/cli.js",watch:"ts-node scripts/build watch",package:"ts-node scripts/package","package-npm":"ts-node scripts/package-npm","npm-publish":"ts-node scripts/npm-publish",postpack:"npm run build","malloy-update-next":"npm install --no-fund --no-audit --save-exact $(./scripts/malloy-packages.ts next) && ts-node scripts/sync-duckdb.ts && npm install --no-fund --no-audit && npm run check-native","malloy-update":"npm install --no-fund --no-audit --save-exact $(./scripts/malloy-packages.ts latest) && ts-node scripts/sync-duckdb.ts && npm install --no-fund --no-audit && npm run check-native","check-native":"ts-node scripts/check-native.ts","approve-native":"ts-node scripts/approve-native.ts","malloy-link":"npm --no-fund --no-audit link $(./scripts/malloy-packages.ts)","malloy-unlink":"npm --no-fund --no-save --no-audit unlink $(./scripts/malloy-packages.ts) && npm --no-fund --no-audit install --force"},repository:{type:"git",url:"git+https://github.com/malloydata/malloy-cli.git"},author:"Malloy",license:"MIT",bugs:{url:"https://github.com/malloydata/malloy-cli/issues"},homepage:"https://github.com/malloydata/malloy-cli#readme",builtIntoPackageDependencies:["@malloydata/db-bigquery","@malloydata/db-duckdb","@malloydata/db-mysql","@malloydata/db-postgres","@malloydata/db-snowflake","@malloydata/db-presto","@malloydata/db-trino","@malloydata/malloy","@malloydata/malloy-connections","@malloydata/malloy-sql","chalk","commander","logform","winston"],optionalDependencies:{"@duckdb/node-bindings-darwin-arm64":"1.5.3-r.2","@duckdb/node-bindings-darwin-x64":"1.5.3-r.2","@duckdb/node-bindings-linux-arm64":"1.5.3-r.2","@duckdb/node-bindings-linux-arm64-musl":"1.5.3-r.2","@duckdb/node-bindings-linux-x64":"1.5.3-r.2","@duckdb/node-bindings-linux-x64-musl":"1.5.3-r.2","@duckdb/node-bindings-win32-arm64":"1.5.3-r.2","@duckdb/node-bindings-win32-x64":"1.5.3-r.2"},devDependencies:{"@actions/core":"^3.0.1","@actions/github":"^9.1.1","@commander-js/extra-typings":"^12.1.0","@duckdb/node-api":"1.5.3-r.2","@duckdb/node-bindings":"1.5.3-r.2","@malloydata/db-bigquery":"0.0.420","@malloydata/db-duckdb":"0.0.420","@malloydata/db-postgres":"0.0.420","@malloydata/db-snowflake":"0.0.420","@malloydata/db-trino":"0.0.420","@malloydata/malloy":"0.0.420","@malloydata/malloy-connections":"0.0.420","@malloydata/malloy-sql":"0.0.420","@types/jest":"^30.0.0","@types/node":"^24.13.1","@yao-pkg/pkg":"^6.20.0",ajv:"^8.12.0",axios:"^1.4.0",chalk:"^4.0.0",commander:"^12.1.0","csv-stringify":"^6.4.0",esbuild:"0.28.1",gts:"^7.0.0",jest:"^30.4.2","jest-silent-reporter":"^0.6.0",logform:"^2.5.1",prettier:"^3.0.3","ts-jest":"^29.1.0","ts-node":"^10.9.1",typescript:"^6.0.3",winston:"^3.9.0"},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0",zod:"^4.3.6"}}});function sI(t){let e={...t};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:e}}async function YF(){await u0.shutdown("idle")}function HPa(t){t.registerTool("prettify",{title:"Pretty-print Malloy source",description:"Reformat a Malloy source string. Returns the formatted source and any parse errors (lexer + parser only \u2014 semantic errors are not checked here; use `compile` for that). When `errors` is non-empty the formatted output is best-effort and may not round-trip; fix the parse errors first. Useful for cleaning up freshly-authored or machine-generated Malloy before saving.",inputSchema:{source:x2r}},async({source:r})=>sI(wBe(r))),t.registerTool("language_help",{title:"Malloy language reference (by topic)",description:"Look up a section of the Malloy language reference by topic slug or title. Call this before guessing syntax \u2014 especially for pipelines, reduction vs projection, aggregate locality, calculations/window functions, filtered aggregates, pick expressions, time ranges, tags/annotations. Also call this after any compile error whose fix is not obvious from the message \u2014 problems[] entries carry a `help_topic` field when there's a natural match. Call with no topic to list the available topics.",inputSchema:{topic:Vf.string().optional().describe("Topic slug or title to look up (case-insensitive; substrings match). Omit to list all available topics.")}},async({topic:r})=>{if(!r)return sI({topics:u2r()});let n=AIi(r);return sI(n?{slug:n.slug,title:n.title,body:n.body}:{error:`No topic matches '${r}'.`,topics:u2r()})});let e=cIi(zut());for(let r of e)t.registerPrompt(r.name,{title:r.name,description:r.description},()=>({messages:[{role:"user",content:{type:"text",text:r.body}}]})),t.registerResource(r.name,`malloy-skill://${r.name}`,{title:r.name,description:r.description,mimeType:"text/markdown"},async n=>({contents:[{uri:n.href,mimeType:"text/markdown",text:r.body}]}))}function VPa(t){t.registerTool("compile_file",{title:"Inspect a Malloy file (compile)",description:"PREFER THIS OVER READING A .malloy FILE AS TEXT. Compile a .malloy file at the given URI and return the full structured model: sources (with dimensions, measures, views, joins), named queries, top-level run: statements with their SQL, givens (model-level parameters declared with `given:`), and annotations. Each query/run carries the transitive set of given names it references \u2014 the values a caller must supply to execute it. This is the primary way to understand what is in a .malloy file \u2014 what data sources it defines, what can be queried, what the schema looks like \u2014 whether you are about to edit it, answer a question with it, or just explore it. Reading the file as text shows you syntax; compiling it shows you semantics. Joins to named sources render by reference via `source_ref` (look up the referenced source by name in the same response); pass `expand: 'inline'` to get recursive inlined fields instead.",inputSchema:{uri:C2r,expand:b2r,emit_run_sql:_2r}},async({uri:e,expand:r,emit_run_sql:n})=>{let i=await OBe({uri:e},{expand:r,emitRunSql:n});return await YF(),sI(i)}),t.registerTool("compile",{title:"Compile an inline Malloy source string",description:'Compile a Malloy source string (not backed by a file). Same output shape as compile_file. Use this when drafting new Malloy \u2014 the common pattern is `import "file.malloy"` + a new `run: ...`, which you iterate on against the `problems[]` feedback until clean. The compiler is ground truth; do not guess syntax. When in doubt about what fields / measures / views exist in the imported file, call compile_file on it first.',inputSchema:{source:x2r,base_uri:NIi,expand:b2r,emit_run_sql:_2r}},async({source:e,base_uri:r,expand:n,emit_run_sql:i})=>{let s=await OBe({source:e,baseUri:r},{expand:n,emitRunSql:i});return await YF(),sI(s)}),t.registerTool("run_file",{title:"Execute a run: from a Malloy file",description:"Execute one run: or named query from a .malloy file against the user's configured connections. Selection: `name` wins if provided, else `index` (0-based into run: statements), else the final run:. Returns the generated SQL and rows (default 10000, set row_limit to override). If the run/query references givens (model-level parameters \u2014 see `compile_file` output), supply per-call values via the `givens` map.",inputSchema:{uri:C2r,name:Vf.string().optional().describe("Name of a `query:` definition to execute. Wins over `index`."),index:Vf.number().int().optional().describe("0-based index into run: statements."),row_limit:B2r,givens:M2r}},async({uri:e,name:r,index:n,row_limit:i,givens:s})=>{let o=await h2r({uri:e},{name:r,index:n,rowLimit:i,givens:s});return await YF(),sI(o)}),t.registerTool("run",{title:"Execute inline Malloy source",description:"Compile an inline Malloy source and execute its final run: statement against the user's configured connections. Returns the generated SQL and rows (default 10000, set row_limit to override). If the source declares givens (model-level parameters), supply per-call values via the `givens` map. Use this after compile is clean to see the answer.",inputSchema:{source:x2r,base_uri:NIi,row_limit:B2r,givens:M2r}},async({source:e,base_uri:r,row_limit:n,givens:i})=>{let s=await h2r({source:e,baseUri:r},{rowLimit:n,givens:i});return await YF(),sI(s)}),t.registerTool("list_runs",{title:"List runnable queries in a Malloy file",description:"Lightweight discovery: return the runnable run: statements (with optional names and indexes) and named `query:` definitions in a file, without serializing the full model. Each entry also carries the transitive set of given names it references \u2014 the parameters a caller must supply to execute it. Use this when you only need to know what can be executed; if you need the full givens schema (types, defaults, annotations) or any source/field detail, use compile_file instead.",inputSchema:{uri:C2r}},async({uri:e})=>{let r=await yIi({uri:e});return await YF(),sI(r)})}function $Pa(t,e){t.registerTool("list_models",{title:"List published Malloy models",description:"List the models this server exposes. Each entry has a `handle` (pass it as `model` to describe_model / compile / run) and a `description` written by the model author. These are the only models you can query \u2014 you cannot open files by path or import anything else.",inputSchema:{}},async()=>sI({models:MIi(e)})),t.registerTool("describe_model",{title:"Inspect a published model",description:"Return the curated semantic surface of a published model: sources (with dimensions, measures, views, joins), named queries, and givens. Pick `model` from `list_models`. This is how you learn what is queryable before writing a restricted query \u2014 prefer it over guessing field names.",inputSchema:{model:I2r,expand:b2r,emit_run_sql:_2r}},async({model:r,expand:n,emit_run_sql:i})=>{let s=await OIi(e,r,{expand:n,emitRunSql:i});return await YF(),sI(s)}),t.registerTool("compile",{title:"Validate a restricted query against a model",description:"Compile (validate only, no execution) Malloy `query` text against the published `model`. Returns `problems[]`; iterate until clean, then `run`. Forbidden constructs (import, given: declarations, connection.table/sql, name!type(...), the sql_* functions, ##! flags) are rejected with code `restricted-construct-forbidden`.",inputSchema:{model:I2r,query:QIi}},async({model:r,query:n})=>{let i=await wIi(e,r,n);return await YF(),sI(i)}),t.registerTool("run",{title:"Run a restricted query against a model",description:"Compile `query` against the published `model` in restricted mode and execute it against the operator's configured connections. Returns the generated SQL and rows (default 10000, set row_limit to override). Supply values for any `$NAME` givens the model declares via the `givens` map. Same restrictions as `compile`.",inputSchema:{model:I2r,query:QIi,row_limit:B2r,givens:M2r}},async({model:r,query:n,row_limit:i,givens:s})=>{let o=await SIi(e,r,n,{rowLimit:i,givens:s});return await YF(),sI(o)})}async function zIi(t={}){let e=t.restricted?RIi(t.projectDir):void 0,r=new Dut({name:"malloy-cli",version:GPa.version??"development"},{instructions:t.restricted?jPa:WPa});e!==void 0?$Pa(r,e):VPa(r),HPa(r);let n=new Qut;await r.connect(n)}var GPa,b2r,_2r,C2r,x2r,B2r,M2r,NIi,I2r,QIi,WPa,jPa,LIi=te(()=>{"use strict";iIi();aIi();n2r();f2r();m2r();TIi();l2r();o2r();Fv();y2r();GPa=DIi(),b2r=Vf.enum(["ref","inline"]).optional().describe("How to render joins in the model output. 'ref' (default) references joined sources by name via `source_ref`. 'inline' recursively inlines the joined source schema (larger output, useful when the client cannot cross-reference)."),_2r=Vf.boolean().optional().describe("If true, compile each run: statement to SQL and include it as `model.runs[].sql`. Default false because run SQL is typically large and is not needed while inspecting the schema. Use run_file to execute a run: and get both SQL and rows."),C2r=Vf.string().describe("File URI (file://...) or bare filesystem path. Relative paths resolve against the server's working directory."),x2r=Vf.string().describe("Malloy source code."),B2r=Vf.number().int().optional().describe("Maximum number of rows to return. Defaults to 10000."),M2r=Vf.record(Vf.string(),Vf.unknown()).optional().describe('Per-query given values, keyed by caller-facing surface name (no `$` prefix). Override the runtime\'s defaults for this call only. Use `compile_file` (or `list_runs`) to see which givens a run/query needs \u2014 each entry carries a `givens` array of the names it references. For per-type JS shapes (date as ISO string, naive timestamp as ISO without offset, record as JS object, filter<T> as Malloy filter source string, ...) call `language_help("givens")` \u2014 the "JS shapes for supplied values" subsection is the canonical reference.'),NIi=Vf.string().optional().describe("Optional URI used to resolve relative imports in the inline source. Typically the file:// URI of the file the snippet will live next to. If omitted, imports must be absolute."),I2r=Vf.string().describe('Handle of a published model, as returned by `list_models` (a path relative to the server\'s model root, e.g. "sales/orders.malloy"). You cannot name an arbitrary file \u2014 only published models are reachable.'),QIi=Vf.string().describe("Malloy query text to compile against the chosen model. May contain `source:` / `query:` / `run:` statements and reference anything the model already defines, plus `$NAME` givens it declared. May NOT use `import`, declare `given:`, call `connection.table(...)` / `connection.sql(...)`, use the `name!type(...)` raw-SQL form or the `sql_*` functions, or set `##!` compiler flags \u2014 those are rejected with code `restricted-construct-forbidden`.");WPa=`
|
|
4523
|
+
`).trim();return c.length>0?c:void 0}o.push(e[a])}return}let i=xIi.exec(e[r]);if(i){let s=i[1].trim();return s.length>0?s:void 0}}}function Hae(t){return{severity:"error",code:"model-not-found",message:`No published model '${t}'. Models are exposed by carrying the \`##|(mcp-description) \u2026 |##\` marker; call list_models to see what is available.`}}function E2r(t,e){if(K4.default.isAbsolute(e)||e.includes("\0"))return{problem:Hae(e)};let r=K4.default.resolve(t,e),n=K4.default.relative(t,r);if(n.startsWith("..")||K4.default.isAbsolute(n))return{problem:Hae(e)};if(n.split(K4.default.sep).some(i_t))return{problem:Hae(e)};if(!M1e(r)||!Fut.default.existsSync(r))return{problem:Hae(e)};let i;try{i=Fut.default.readFileSync(r,"utf8")}catch{return{problem:Hae(e)}}return BIi(i)?{abs:r}:{problem:Hae(e)}}function MIi(t){let e=[];for(let r of O1e(t)){let n;try{n=Fut.default.readFileSync(r,"utf8")}catch{continue}if(!BIi(n))continue;let i=K4.default.relative(t,r).split(K4.default.sep).join("/"),s=qPa(n);e.push(s?{handle:i,description:s}:{handle:i})}return e.sort((r,n)=>r.handle.localeCompare(n.handle)),e}async function OIi(t,e,r={}){let n=E2r(t,e);return"problem"in n?{ok:!1,problems:[n.problem]}:OBe({uri:n.abs},r)}async function wIi(t,e,r){let n=E2r(t,e);if("problem"in n)return{ok:!1,problems:[n.problem]};let i=await $F({uri:n.abs});if(!i.ok||!i.loaded)return{ok:!1,problems:i.problems};let{runtime:s,rootUrl:o}=i.loaded;try{let a=s.loadModel(o).loadRestrictedQuery(r),c=VF(await a.validate());return{ok:!c.some(l=>l.severity==="error"),problems:[...i.problems,...c]}}catch(a){return a instanceof bIi.MalloyError?{ok:!1,problems:[...i.problems,...VF(a.problems)]}:{ok:!1,problems:[...i.problems,bj(a)]}}}async function SIi(t,e,r,n={}){let i=E2r(t,e);if("problem"in i)return{ok:!1,problems:[i.problem]};let s=await $F({uri:i.abs});if(!s.ok||!s.loaded)return{ok:!1,problems:s.problems};let{runtime:o,rootUrl:a}=s.loaded,c=o.loadModel(a).loadRestrictedQuery(r);return g2r(c,n.rowLimit??qv,n.givens,s.problems)}function RIi(t){if(!t)throw new Error("Restricted MCP mode (--restricted) requires a project directory: pass -p DIR to scope which models are exposed.");return K4.default.resolve(t)}var Fut,K4,bIi,_Ii,xIi,TIi=te(()=>{"use strict";Fut=Nr(require("node:fs")),K4=Nr(require("node:path")),bIi=Nr(Hc());Put();f2r();m2r();hU();Dy();_Ii=/^([ \t]*)##\|\(mcp-description\)[ \t]*$/,xIi=/^[ \t]*##\(mcp-description\)[ \t]?(.*)$/});function wBe(t){let{result:e,errors:r}=(0,vIi.prettify)(t);return{formatted:e,errors:r}}var vIi,y2r=te(()=>{"use strict";vIi=Nr(mX())});var DIi=m((Ln0,UPa)=>{UPa.exports={name:"@malloydata/cli",version:"0.0.56-next.2026.6.26.94fe16d",description:"Malloy CLI",bin:{"malloy-cli":"dist/index.js","malloy-packages":"scripts/malloy-packages.ts"},files:["dist/**","scripts/malloy-packages.ts"],engines:{node:">=20"},pkg:{assets:["node_modules/@duckdb/node-bindings-*/libduckdb.*","node_modules/@duckdb/node-bindings-*/duckdb.dll"]},scripts:{lint:"tsc --noEmit && eslint .",test:"NODE_ENV=test jest --projects jest.config.js --runInBand","test-silent":"NODE_ENV=test JEST_SILENT_REPORTER_SHOW_PATHS=true jest --projects jest.config.js --runInBand --reporters jest-silent-reporter","test-e2e":"npm run package-npm test > /dev/null 2>&1 && NODE_ENV=test jest --projects=jest-e2e.config.js --runInBand","test-silent-e2e":"npm run package-npm test > /dev/null 2>&1 && NODE_ENV=test JEST_SILENT_REPORTER_SHOW_PATHS=true jest --projects=jest-e2e.config.js --runInBand --reporters jest-silent-reporter",build:"ts-node scripts/build","build-action":"esbuild --platform=node --bundle ./.github/actions/permission-check/lib/index.ts --outfile=./.github/actions/permission-check/dist/index.js","build-action-dev":"npm run build-action -- --watch",cli:"npx ts-node ./dist/cli.js",watch:"ts-node scripts/build watch",package:"ts-node scripts/package","package-npm":"ts-node scripts/package-npm","npm-publish":"ts-node scripts/npm-publish",postpack:"npm run build","malloy-update-next":"npm install --no-fund --no-audit --save-exact $(./scripts/malloy-packages.ts next) && ts-node scripts/sync-duckdb.ts && npm install --no-fund --no-audit && npm run check-native","malloy-update":"npm install --no-fund --no-audit --save-exact $(./scripts/malloy-packages.ts latest) && ts-node scripts/sync-duckdb.ts && npm install --no-fund --no-audit && npm run check-native","check-native":"ts-node scripts/check-native.ts","approve-native":"ts-node scripts/approve-native.ts","malloy-link":"npm --no-fund --no-audit link $(./scripts/malloy-packages.ts)","malloy-unlink":"npm --no-fund --no-save --no-audit unlink $(./scripts/malloy-packages.ts) && npm --no-fund --no-audit install --force"},repository:{type:"git",url:"git+https://github.com/malloydata/malloy-cli.git"},author:"Malloy",license:"MIT",bugs:{url:"https://github.com/malloydata/malloy-cli/issues"},homepage:"https://github.com/malloydata/malloy-cli#readme",builtIntoPackageDependencies:["@malloydata/db-bigquery","@malloydata/db-duckdb","@malloydata/db-mysql","@malloydata/db-postgres","@malloydata/db-snowflake","@malloydata/db-presto","@malloydata/db-trino","@malloydata/malloy","@malloydata/malloy-connections","@malloydata/malloy-sql","chalk","commander","logform","winston"],optionalDependencies:{"@duckdb/node-bindings-darwin-arm64":"1.5.3-r.2","@duckdb/node-bindings-darwin-x64":"1.5.3-r.2","@duckdb/node-bindings-linux-arm64":"1.5.3-r.2","@duckdb/node-bindings-linux-arm64-musl":"1.5.3-r.2","@duckdb/node-bindings-linux-x64":"1.5.3-r.2","@duckdb/node-bindings-linux-x64-musl":"1.5.3-r.2","@duckdb/node-bindings-win32-arm64":"1.5.3-r.2","@duckdb/node-bindings-win32-x64":"1.5.3-r.2"},devDependencies:{"@actions/core":"^3.0.1","@actions/github":"^9.1.1","@commander-js/extra-typings":"^12.1.0","@duckdb/node-api":"1.5.3-r.2","@duckdb/node-bindings":"1.5.3-r.2","@malloydata/db-bigquery":"0.0.420","@malloydata/db-duckdb":"0.0.420","@malloydata/db-postgres":"0.0.420","@malloydata/db-snowflake":"0.0.420","@malloydata/db-trino":"0.0.420","@malloydata/malloy":"0.0.420","@malloydata/malloy-connections":"0.0.420","@malloydata/malloy-sql":"0.0.420","@types/jest":"^30.0.0","@types/node":"^24.13.1","@yao-pkg/pkg":"^6.20.0",ajv:"^8.12.0",axios:"^1.4.0",chalk:"^4.0.0",commander:"^12.1.0","csv-stringify":"^6.4.0",esbuild:"0.28.1",gts:"^7.0.0",jest:"^30.4.2","jest-silent-reporter":"^0.6.0",logform:"^2.5.1",prettier:"^3.0.3","ts-jest":"^29.1.0","ts-node":"^10.9.1",typescript:"^6.0.3",winston:"^3.9.0"},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0",zod:"^4.3.6"}}});function sI(t){let e={...t};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:e}}async function YF(){await u0.shutdown("idle")}function HPa(t){t.registerTool("prettify",{title:"Pretty-print Malloy source",description:"Reformat a Malloy source string. Returns the formatted source and any parse errors (lexer + parser only \u2014 semantic errors are not checked here; use `compile` for that). When `errors` is non-empty the formatted output is best-effort and may not round-trip; fix the parse errors first. Useful for cleaning up freshly-authored or machine-generated Malloy before saving.",inputSchema:{source:x2r}},async({source:r})=>sI(wBe(r))),t.registerTool("language_help",{title:"Malloy language reference (by topic)",description:"Look up a section of the Malloy language reference by topic slug or title. Call this before guessing syntax \u2014 especially for pipelines, reduction vs projection, aggregate locality, calculations/window functions, filtered aggregates, pick expressions, time ranges, tags/annotations. Also call this after any compile error whose fix is not obvious from the message \u2014 problems[] entries carry a `help_topic` field when there's a natural match. Call with no topic to list the available topics.",inputSchema:{topic:Vf.string().optional().describe("Topic slug or title to look up (case-insensitive; substrings match). Omit to list all available topics.")}},async({topic:r})=>{if(!r)return sI({topics:u2r()});let n=AIi(r);return sI(n?{slug:n.slug,title:n.title,body:n.body}:{error:`No topic matches '${r}'.`,topics:u2r()})});let e=cIi(zut());for(let r of e)t.registerPrompt(r.name,{title:r.name,description:r.description},()=>({messages:[{role:"user",content:{type:"text",text:r.body}}]})),t.registerResource(r.name,`malloy-skill://${r.name}`,{title:r.name,description:r.description,mimeType:"text/markdown"},async n=>({contents:[{uri:n.href,mimeType:"text/markdown",text:r.body}]}))}function VPa(t){t.registerTool("compile_file",{title:"Inspect a Malloy file (compile)",description:"PREFER THIS OVER READING A .malloy FILE AS TEXT. Compile a .malloy file at the given URI and return the full structured model: sources (with dimensions, measures, views, joins), named queries, top-level run: statements with their SQL, givens (model-level parameters declared with `given:`), and annotations. Each query/run carries the transitive set of given names it references \u2014 the values a caller must supply to execute it. This is the primary way to understand what is in a .malloy file \u2014 what data sources it defines, what can be queried, what the schema looks like \u2014 whether you are about to edit it, answer a question with it, or just explore it. Reading the file as text shows you syntax; compiling it shows you semantics. Joins to named sources render by reference via `source_ref` (look up the referenced source by name in the same response); pass `expand: 'inline'` to get recursive inlined fields instead.",inputSchema:{uri:C2r,expand:b2r,emit_run_sql:_2r}},async({uri:e,expand:r,emit_run_sql:n})=>{let i=await OBe({uri:e},{expand:r,emitRunSql:n});return await YF(),sI(i)}),t.registerTool("compile",{title:"Compile an inline Malloy source string",description:'Compile a Malloy source string (not backed by a file). Same output shape as compile_file. Use this when drafting new Malloy \u2014 the common pattern is `import "file.malloy"` + a new `run: ...`, which you iterate on against the `problems[]` feedback until clean. The compiler is ground truth; do not guess syntax. When in doubt about what fields / measures / views exist in the imported file, call compile_file on it first.',inputSchema:{source:x2r,base_uri:NIi,expand:b2r,emit_run_sql:_2r}},async({source:e,base_uri:r,expand:n,emit_run_sql:i})=>{let s=await OBe({source:e,baseUri:r},{expand:n,emitRunSql:i});return await YF(),sI(s)}),t.registerTool("run_file",{title:"Execute a run: from a Malloy file",description:"Execute one run: or named query from a .malloy file against the user's configured connections. Selection: `name` wins if provided, else `index` (0-based into run: statements), else the final run:. Returns the generated SQL and rows (default 10000, set row_limit to override). If the run/query references givens (model-level parameters \u2014 see `compile_file` output), supply per-call values via the `givens` map.",inputSchema:{uri:C2r,name:Vf.string().optional().describe("Name of a `query:` definition to execute. Wins over `index`."),index:Vf.number().int().optional().describe("0-based index into run: statements."),row_limit:B2r,givens:M2r}},async({uri:e,name:r,index:n,row_limit:i,givens:s})=>{let o=await h2r({uri:e},{name:r,index:n,rowLimit:i,givens:s});return await YF(),sI(o)}),t.registerTool("run",{title:"Execute inline Malloy source",description:"Compile an inline Malloy source and execute its final run: statement against the user's configured connections. Returns the generated SQL and rows (default 10000, set row_limit to override). If the source declares givens (model-level parameters), supply per-call values via the `givens` map. Use this after compile is clean to see the answer.",inputSchema:{source:x2r,base_uri:NIi,row_limit:B2r,givens:M2r}},async({source:e,base_uri:r,row_limit:n,givens:i})=>{let s=await h2r({source:e,baseUri:r},{rowLimit:n,givens:i});return await YF(),sI(s)}),t.registerTool("list_runs",{title:"List runnable queries in a Malloy file",description:"Lightweight discovery: return the runnable run: statements (with optional names and indexes) and named `query:` definitions in a file, without serializing the full model. Each entry also carries the transitive set of given names it references \u2014 the parameters a caller must supply to execute it. Use this when you only need to know what can be executed; if you need the full givens schema (types, defaults, annotations) or any source/field detail, use compile_file instead.",inputSchema:{uri:C2r}},async({uri:e})=>{let r=await yIi({uri:e});return await YF(),sI(r)})}function $Pa(t,e){t.registerTool("list_models",{title:"List published Malloy models",description:"List the models this server exposes. Each entry has a `handle` (pass it as `model` to describe_model / compile / run) and a `description` written by the model author. These are the only models you can query \u2014 you cannot open files by path or import anything else.",inputSchema:{}},async()=>sI({models:MIi(e)})),t.registerTool("describe_model",{title:"Inspect a published model",description:"Return the curated semantic surface of a published model: sources (with dimensions, measures, views, joins), named queries, and givens. Pick `model` from `list_models`. This is how you learn what is queryable before writing a restricted query \u2014 prefer it over guessing field names.",inputSchema:{model:I2r,expand:b2r,emit_run_sql:_2r}},async({model:r,expand:n,emit_run_sql:i})=>{let s=await OIi(e,r,{expand:n,emitRunSql:i});return await YF(),sI(s)}),t.registerTool("compile",{title:"Validate a restricted query against a model",description:"Compile (validate only, no execution) Malloy `query` text against the published `model`. Returns `problems[]`; iterate until clean, then `run`. Forbidden constructs (import, given: declarations, connection.table/sql, name!type(...), the sql_* functions, ##! flags) are rejected with code `restricted-construct-forbidden`.",inputSchema:{model:I2r,query:QIi}},async({model:r,query:n})=>{let i=await wIi(e,r,n);return await YF(),sI(i)}),t.registerTool("run",{title:"Run a restricted query against a model",description:"Compile `query` against the published `model` in restricted mode and execute it against the operator's configured connections. Returns the generated SQL and rows (default 10000, set row_limit to override). Supply values for any `$NAME` givens the model declares via the `givens` map. Same restrictions as `compile`.",inputSchema:{model:I2r,query:QIi,row_limit:B2r,givens:M2r}},async({model:r,query:n,row_limit:i,givens:s})=>{let o=await SIi(e,r,n,{rowLimit:i,givens:s});return await YF(),sI(o)})}async function zIi(t={}){let e=t.restricted?RIi(t.projectDir):void 0,r=new Dut({name:"malloy-cli",version:GPa.version??"development"},{instructions:t.restricted?jPa:WPa});e!==void 0?$Pa(r,e):VPa(r),HPa(r);let n=new Qut;await r.connect(n)}var GPa,b2r,_2r,C2r,x2r,B2r,M2r,NIi,I2r,QIi,WPa,jPa,LIi=te(()=>{"use strict";iIi();aIi();n2r();f2r();m2r();TIi();l2r();o2r();Fv();y2r();GPa=DIi(),b2r=Vf.enum(["ref","inline"]).optional().describe("How to render joins in the model output. 'ref' (default) references joined sources by name via `source_ref`. 'inline' recursively inlines the joined source schema (larger output, useful when the client cannot cross-reference)."),_2r=Vf.boolean().optional().describe("If true, compile each run: statement to SQL and include it as `model.runs[].sql`. Default false because run SQL is typically large and is not needed while inspecting the schema. Use run_file to execute a run: and get both SQL and rows."),C2r=Vf.string().describe("File URI (file://...) or bare filesystem path. Relative paths resolve against the server's working directory."),x2r=Vf.string().describe("Malloy source code."),B2r=Vf.number().int().optional().describe("Maximum number of rows to return. Defaults to 10000."),M2r=Vf.record(Vf.string(),Vf.unknown()).optional().describe('Per-query given values, keyed by caller-facing surface name (no `$` prefix). Override the runtime\'s defaults for this call only. Use `compile_file` (or `list_runs`) to see which givens a run/query needs \u2014 each entry carries a `givens` array of the names it references. For per-type JS shapes (date as ISO string, naive timestamp as ISO without offset, record as JS object, filter<T> as Malloy filter source string, ...) call `language_help("givens")` \u2014 the "JS shapes for supplied values" subsection is the canonical reference.'),NIi=Vf.string().optional().describe("Optional URI used to resolve relative imports in the inline source. Typically the file:// URI of the file the snippet will live next to. If omitted, imports must be absolute."),I2r=Vf.string().describe('Handle of a published model, as returned by `list_models` (a path relative to the server\'s model root, e.g. "sales/orders.malloy"). You cannot name an arbitrary file \u2014 only published models are reachable.'),QIi=Vf.string().describe("Malloy query text to compile against the chosen model. May contain `source:` / `query:` / `run:` statements and reference anything the model already defines, plus `$NAME` givens it declared. May NOT use `import`, declare `given:`, call `connection.table(...)` / `connection.sql(...)`, use the `name!type(...)` raw-SQL form or the `sql_*` functions, or set `##!` compiler flags \u2014 those are rejected with code `restricted-construct-forbidden`.");WPa=`
|
|
4524
4524
|
This server lets an agent inspect, author, and execute Malloy semantic models.
|
|
4525
4525
|
|
|
4526
4526
|
Malloy (.malloy) files are NOT plain text you should read for comprehension.
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/cli",
|
|
3
|
-
"version": "0.0.56-next.2026.6.26.
|
|
3
|
+
"version": "0.0.56-next.2026.6.26.94fe16d",
|
|
4
4
|
"description": "Malloy CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"malloy-cli": "dist/index.js",
|
|
@@ -21,9 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"lint": "tsc --noEmit && eslint .",
|
|
24
|
-
"pretest": "npm run lint",
|
|
25
24
|
"test": "NODE_ENV=test jest --projects jest.config.js --runInBand",
|
|
26
|
-
"pretest-silent": "npm run lint",
|
|
27
25
|
"test-silent": "NODE_ENV=test JEST_SILENT_REPORTER_SHOW_PATHS=true jest --projects jest.config.js --runInBand --reporters jest-silent-reporter",
|
|
28
26
|
"test-e2e": "npm run package-npm test > /dev/null 2>&1 && NODE_ENV=test jest --projects=jest-e2e.config.js --runInBand",
|
|
29
27
|
"test-silent-e2e": "npm run package-npm test > /dev/null 2>&1 && NODE_ENV=test JEST_SILENT_REPORTER_SHOW_PATHS=true jest --projects=jest-e2e.config.js --runInBand --reporters jest-silent-reporter",
|