@zuplo/core 6.65.0 → 6.65.1
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/customer.cli.minified.js +1 -1
- package/index.minified.js +1 -1
- package/package.json +4 -4
package/customer.cli.minified.js
CHANGED
|
@@ -572,7 +572,7 @@ globstar while`,s,ae,f,Ke,$e),this.matchOne(s.slice(ae),f.slice(Ke),d))return th
|
|
|
572
572
|
`),stderr:x.join(`
|
|
573
573
|
`),exitCode:P},"Tar process logs")}}t(CXt,"tarFolder");async function kXt({tarFilePath:o,outputDir:s,logger:f}){let d=[],y=[],x;try{await new Promise((P,F)=>{let J=oit("sh",["-c",`tar -xvf ${o} -C ${s};`]);J.stdout.on("data",G=>{let Se=G.toString().trim();Se.length>0&&d.push(Se.trim())}),J.stderr.on("data",G=>{let Se=G.toString().trim();Se.length>0&&y.push(Se.trim())}),J.on("close",G=>{x=G,G===0?P():F(new Error(`tar process exited with code ${G}`))}),J.on("error",G=>{F(G)})})}catch(P){throw new Error("Failed to untar file",{cause:P})}finally{f.info({stdout:d.join(`
|
|
574
574
|
`),stderr:y.join(`
|
|
575
|
-
`),exitCode:x},"Untar process logs")}}t(kXt,"untarFile");async function wXt(o){if(await hAe(o))return await KN.rm(o,{recursive:!0})}t(wXt,"deleteFolder");var tu=gAe;var _lt=Sd(Nst(),1);var rH=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(o,s,f,d,y,x){this.type=o,this.name=s,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},eer=/[$_\p{ID_Start}]/u,ter=/[$_\u200C\u200D\p{ID_Continue}]/u,XAe=".*";function rer(o,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(o)}t(rer,"Re");function Fst(o,s=!1){let f=[],d=0;for(;d<o.length;){let y=o[d],x=t(function(P){if(!s)throw new TypeError(P);f.push({type:"INVALID_CHAR",index:d,value:o[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:o[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:o[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:o[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:o[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:o[d++]});continue}if(y===":"){let P="",F=d+1;for(;F<o.length;){let J=o.substr(F,1);if(F===d+1&&eer.test(J)||F!==d+1&&ter.test(J)){P+=o[F++];continue}break}if(!P){x(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:P}),d=F;continue}if(y==="("){let P=1,F="",J=d+1,G=!1;if(o[J]==="?"){x(`Pattern cannot start with "?" at ${J}`);continue}for(;J<o.length;){if(!rer(o[J],!1)){x(`Invalid character '${o[J]}' at ${J}.`),G=!0;break}if(o[J]==="\\"){F+=o[J++]+o[J++];continue}if(o[J]===")"){if(P--,P===0){J++;break}}else if(o[J]==="("&&(P++,o[J+1]!=="?")){x(`Capturing groups are not allowed at ${J}`),G=!0;break}F+=o[J++]}if(G)continue;if(P){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=J;continue}f.push({type:"CHAR",index:d,value:o[d++]})}return f.push({type:"END",index:d,value:""}),f}t(Fst,"v");function Lst(o,s={}){let f=Fst(o);s.delimiter??="/#?",s.prefixes??="./";let d=`[^${lT(s.delimiter)}]+?`,y=[],x=0,P=0,F="",J=new Set,G=t(Fn=>{if(P<f.length&&f[P].type===Fn)return f[P++].value},"a"),Se=t(()=>G("OTHER_MODIFIER")??G("ASTERISK"),"f"),de=t(Fn=>{let sn=G(Fn);if(sn!==void 0)return sn;let{type:Un,index:Er}=f[P];throw new TypeError(`Unexpected ${Un} at ${Er}, expected ${Fn}`)},"d"),ae=t(()=>{let Fn="",sn;for(;sn=G("CHAR")??G("ESCAPED_CHAR");)Fn+=sn;return Fn},"T"),Ke=t(Fn=>Fn,"Se"),$e=s.encodePart||Ke,Fe="",Gt=t(Fn=>{Fe+=Fn},"U"),jt=t(()=>{Fe.length&&(y.push(new rH(3,"","",$e(Fe),"",3)),Fe="")},"$"),Pr=t((Fn,sn,Un,Er,vr)=>{let ls=3;switch(vr){case"?":ls=1;break;case"*":ls=0;break;case"+":ls=2;break}if(!sn&&!Un&&ls===3){Gt(Fn);return}if(jt(),!sn&&!Un){if(!Fn)return;y.push(new rH(3,"","",$e(Fn),"",ls));return}let Ni;Un?Un==="*"?Ni=XAe:Ni=Un:Ni=d;let nc=2;Ni===d?(nc=1,Ni=""):Ni===XAe&&(nc=0,Ni="");let bi;if(sn?bi=sn:Un&&(bi=x++),J.has(bi))throw new TypeError(`Duplicate name '${bi}'.`);J.add(bi),y.push(new rH(nc,bi,$e(Fn),Ni,$e(Er),ls))},"V");for(;P<f.length;){let Fn=G("CHAR"),sn=G("NAME"),Un=G("REGEX");if(!sn&&!Un&&(Un=G("ASTERISK")),sn||Un){let vr=Fn??"";s.prefixes.indexOf(vr)===-1&&(Gt(vr),vr=""),jt();let ls=Se();Pr(vr,sn,Un,"",ls);continue}let Er=Fn??G("ESCAPED_CHAR");if(Er){Gt(Er);continue}if(G("OPEN")){let vr=ae(),ls=G("NAME"),Ni=G("REGEX");!ls&&!Ni&&(Ni=G("ASTERISK"));let nc=ae();de("CLOSE");let bi=Se();Pr(vr,ls,Ni,nc,bi);continue}jt(),de("END")}return y}t(Lst,"D");function lT(o){return o.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(lT,"S");function Ist(o){return o&&o.ignoreCase?"ui":"u"}t(Ist,"X");function ner(o,s,f){return Rst(Lst(o,f),s,f)}t(ner,"Z");function iM(o){switch(o){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(iM,"k");function Rst(o,s,f={}){f.delimiter??="/#?",f.prefixes??="./",f.sensitive??=!1,f.strict??=!1,f.end??=!0,f.start??=!0,f.endsWith="";let d=f.start?"^":"";for(let F of o){if(F.type===3){F.modifier===3?d+=lT(F.value):d+=`(?:${lT(F.value)})${iM(F.modifier)}`;continue}s&&s.push(F.name);let J=`[^${lT(f.delimiter)}]+?`,G=F.value;if(F.type===1?G=J:F.type===0&&(G=XAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${iM(F.modifier)}`:d+=`((?:${G})${iM(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${lT(F.prefix)}(${G})${lT(F.suffix)})`,d+=iM(F.modifier);continue}d+=`(?:${lT(F.prefix)}`,d+=`((?:${G})(?:`,d+=lT(F.suffix),d+=lT(F.prefix),d+=`(?:${G}))*)${lT(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${lT(f.endsWith)}]|$`,x=`[${lT(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Ist(f));f.strict||(d+=`(?:${x}(?=${y}))?`);let P=!1;if(o.length){let F=o[o.length-1];F.type===3&&F.modifier===3&&(P=f.delimiter.indexOf(F)>-1)}return P||(d+=`(?=${x}|${y})`),new RegExp(d,Ist(f))}t(Rst,"F");var eI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},ier={delimiter:".",prefixes:"",sensitive:!0,strict:!0},ser={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function aer(o,s){return o.length?o[0]==="/"?!0:!s||o.length<2?!1:(o[0]=="\\"||o[0]=="{")&&o[1]=="/":!1}t(aer,"J");function Mst(o,s){return o.startsWith(s)?o.substring(s.length,o.length):o}t(Mst,"Q");function oer(o,s){return o.endsWith(s)?o.substr(0,o.length-s.length):o}t(oer,"Ee");function jst(o){return!o||o.length<2?!1:o[0]==="["||(o[0]==="\\"||o[0]==="{")&&o[1]==="["}t(jst,"W");var Bst=["ftp","file","http","https","ws","wss"];function Ust(o){if(!o)return!0;for(let s of Bst)if(o.test(s))return!0;return!1}t(Ust,"N");function cer(o,s){if(o=Mst(o,"#"),s||o==="")return o;let f=new URL("https://example.com");return f.hash=o,f.hash?f.hash.substring(1,f.hash.length):""}t(cer,"te");function ler(o,s){if(o=Mst(o,"?"),s||o==="")return o;let f=new URL("https://example.com");return f.search=o,f.search?f.search.substring(1,f.search.length):""}t(ler,"re");function uer(o,s){return s||o===""?o:jst(o)?Jst(o):$st(o)}t(uer,"ne");function fer(o,s){if(s||o==="")return o;let f=new URL("https://example.com");return f.password=o,f.password}t(fer,"se");function _er(o,s){if(s||o==="")return o;let f=new URL("https://example.com");return f.username=o,f.username}t(_er,"ie");function per(o,s,f){if(f||o==="")return o;if(s&&!Bst.includes(s))return new URL(`${s}:${o}`).pathname;let d=o[0]=="/";return o=new URL(d?o:"/-"+o,"https://example.com").pathname,d||(o=o.substring(2,o.length)),o}t(per,"ae");function der(o,s,f){return zst(s)===o&&(o=""),f||o===""?o:Wst(o)}t(der,"oe");function mer(o,s){return o=oer(o,":"),s||o===""?o:ZAe(o)}t(mer,"ce");function zst(o){switch(o){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(zst,"_");function ZAe(o){if(o==="")return o;if(/^[-+.A-Za-z0-9]*$/.test(o))return o.toLowerCase();throw new TypeError(`Invalid protocol '${o}'.`)}t(ZAe,"y");function her(o){if(o==="")return o;let s=new URL("https://example.com");return s.username=o,s.username}t(her,"le");function ger(o){if(o==="")return o;let s=new URL("https://example.com");return s.password=o,s.password}t(ger,"fe");function $st(o){if(o==="")return o;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(o))throw new TypeError(`Invalid hostname '${o}'`);let s=new URL("https://example.com");return s.hostname=o,s.hostname}t($st,"z");function Jst(o){if(o==="")return o;if(/[^0-9a-fA-F[\]:]/g.test(o))throw new TypeError(`Invalid IPv6 hostname '${o}'`);return o.toLowerCase()}t(Jst,"j");function Wst(o){if(o===""||/^[0-9]*$/.test(o)&&parseInt(o)<=65535)return o;throw new TypeError(`Invalid port '${o}'.`)}t(Wst,"K");function yer(o){if(o==="")return o;let s=new URL("https://example.com");return s.pathname=o[0]!=="/"?"/-"+o:o,o[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(yer,"he");function ver(o){return o===""?o:new URL(`data:${o}`).pathname}t(ver,"ue");function ber(o){if(o==="")return o;let s=new URL("https://example.com");return s.search=o,s.search.substring(1,s.search.length)}t(ber,"de");function Ser(o){if(o==="")return o;let s=new URL("https://example.com");return s.hash=o,s.hash.substring(1,s.hash.length)}t(Ser,"pe");var Ter=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#p=0;#o=0;#_=0;#u=0;#c=!1;constructor(o){this.#e=o}get result(){return this.#t}parse(){for(this.#n=Fst(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#o===0){this.#h(),this.#x()?this.#i(9,1):this.#v()?this.#i(8,1):this.#i(7,0);continue}else if(this.#o===2){this.#m(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#l())this.#_-=1;else continue;if(this.#A()){this.#_+=1;continue}switch(this.#o){case 0:this.#g()&&this.#m(1);break;case 1:if(this.#g()){this.#P();let o=7,s=1;this.#y()?(o=2,s=3):this.#c&&(o=2),this.#i(o,s)}break;case 2:this.#E()?this.#m(3):(this.#k()||this.#v()||this.#x())&&this.#m(5);break;case 3:this.#T()?this.#i(4,1):this.#E()&&this.#i(5,1);break;case 4:this.#E()&&this.#i(5,1);break;case 5:this.#O()?this.#u+=1:this.#w()&&(this.#u-=1),this.#C()&&!this.#u?this.#i(6,1):this.#k()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 6:this.#k()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 7:this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 8:this.#x()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#i(o,s){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#D();break;case 2:break;case 3:this.#t.username=this.#D();break;case 4:this.#t.password=this.#D();break;case 5:this.#t.hostname=this.#D();break;case 6:this.#t.port=this.#D();break;case 7:this.#t.pathname=this.#D();break;case 8:this.#t.search=this.#D();break;case 9:this.#t.hash=this.#D();break;case 10:break}this.#o!==0&&o!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(o)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(o)&&(this.#t.pathname??=this.#c?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&o===9&&(this.#t.search??="")),this.#a(o,s)}#a(o,s){this.#o=o,this.#p=this.#r+s,this.#r+=s,this.#s=0}#h(){this.#r=this.#p,this.#s=0}#m(o){this.#h(),this.#o=o}#f(o){return o<0&&(o=this.#n.length-o),o<this.#n.length?this.#n[o]:this.#n[this.#n.length-1]}#d(o,s){let f=this.#f(o);return f.value===s&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#g(){return this.#d(this.#r,":")}#y(){return this.#d(this.#r+1,"/")&&this.#d(this.#r+2,"/")}#E(){return this.#d(this.#r,"@")}#T(){return this.#d(this.#r,":")}#C(){return this.#d(this.#r,":")}#k(){return this.#d(this.#r,"/")}#v(){if(this.#d(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let o=this.#f(this.#r-1);return o.type!=="NAME"&&o.type!=="REGEX"&&o.type!=="CLOSE"&&o.type!=="ASTERISK"}#x(){return this.#d(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#d(this.#r,"[")}#w(){return this.#d(this.#r,"]")}#D(){let o=this.#n[this.#r],s=this.#f(this.#p).index;return this.#e.substring(s,o.index)}#P(){let o={};Object.assign(o,eI),o.encodePart=ZAe;let s=ner(this.#D(),void 0,o);this.#c=Ust(s)}},KAe=["protocol","username","password","hostname","port","pathname","search","hash"],QN="*";function Ost(o,s){if(typeof o!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(o,s);return{protocol:f.protocol.substring(0,f.protocol.length-1),username:f.username,password:f.password,hostname:f.hostname,port:f.port,pathname:f.pathname,search:f.search!==""?f.search.substring(1,f.search.length):void 0,hash:f.hash!==""?f.hash.substring(1,f.hash.length):void 0}}t(Ost,"ge");function qP(o,s){return s?tH(o):o}t(qP,"b");function eH(o,s,f){let d;if(typeof s.baseURL=="string")try{d=new URL(s.baseURL),s.protocol===void 0&&(o.protocol=qP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(o.username=qP(d.username,f)),!f&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(o.password=qP(d.password,f)),s.protocol===void 0&&s.hostname===void 0&&(o.hostname=qP(d.hostname,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(o.port=qP(d.port,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(o.pathname=qP(d.pathname,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(o.search=qP(d.search.substring(1,d.search.length),f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(o.hash=qP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(o.protocol=mer(s.protocol,f)),typeof s.username=="string"&&(o.username=_er(s.username,f)),typeof s.password=="string"&&(o.password=fer(s.password,f)),typeof s.hostname=="string"&&(o.hostname=uer(s.hostname,f)),typeof s.port=="string"&&(o.port=der(s.port,o.protocol,f)),typeof s.pathname=="string"){if(o.pathname=s.pathname,d&&!aer(o.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(o.pathname=qP(d.pathname.substring(0,y+1),f)+o.pathname)}o.pathname=per(o.pathname,o.protocol,f)}return typeof s.search=="string"&&(o.search=ler(s.search,f)),typeof s.hash=="string"&&(o.hash=cer(s.hash,f)),o}t(eH,"w");function tH(o){return o.replace(/([+*?:{}()\\])/g,"\\$1")}t(tH,"C");function xer(o){return o.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(xer,"Oe");function Eer(o,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let f=".*",d=`[^${xer(s.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let P=0;P<o.length;++P){let F=o[P];if(F.type===3){if(F.modifier===3){x+=tH(F.value);continue}x+=`{${tH(F.value)}}${iM(F.modifier)}`;continue}let J=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!s.prefixes.includes(F.prefix)),Se=P>0?o[P-1]:null,de=P<o.length-1?o[P+1]:null;if(!G&&J&&F.type===1&&F.modifier===3&&de&&!de.prefix.length&&!de.suffix.length)if(de.type===3){let ae=de.value.length>0?de.value[0]:"";G=y.test(ae)}else G=!de.hasCustomName();if(!G&&!F.prefix.length&&Se&&Se.type===3){let ae=Se.value[Se.value.length-1];G=s.prefixes.includes(ae)}G&&(x+="{"),x+=tH(F.prefix),J&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?J||(x+=`(${d})`):F.type===0&&(!J&&(!Se||Se.type===3||Se.modifier!==3||G||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&J&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=tH(F.suffix),G&&(x+="}"),F.modifier!==3&&(x+=iM(F.modifier))}return x}t(Eer,"ke");var qst=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#p=!1;constructor(o={},s,f){try{let d;if(typeof s=="string"?d=s:f=s,typeof o=="string"){let F=new Ter(o);if(F.parse(),o=F.result,d===void 0&&typeof o.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");o.baseURL=d}else{if(!o||typeof o!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(d)throw new TypeError("parameter 1 is not of type 'string'.")}typeof f>"u"&&(f={ignoreCase:!1});let y={ignoreCase:f.ignoreCase===!0},x={pathname:QN,protocol:QN,username:QN,password:QN,hostname:QN,port:QN,search:QN,hash:QN};this.#e=eH(x,o,!0),zst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let P;for(P of KAe){if(!(P in this.#e))continue;let F={},J=this.#e[P];switch(this.#t[P]=[],P){case"protocol":Object.assign(F,eI),F.encodePart=ZAe;break;case"username":Object.assign(F,eI),F.encodePart=her;break;case"password":Object.assign(F,eI),F.encodePart=ger;break;case"hostname":Object.assign(F,ier),jst(J)?F.encodePart=Jst:F.encodePart=$st;break;case"port":Object.assign(F,eI),F.encodePart=Wst;break;case"pathname":Ust(this.#n.protocol)?(Object.assign(F,ser,y),F.encodePart=yer):(Object.assign(F,eI,y),F.encodePart=ver);break;case"search":Object.assign(F,eI,y),F.encodePart=ber;break;case"hash":Object.assign(F,eI,y),F.encodePart=Ser;break}try{this.#s[P]=Lst(J,F),this.#n[P]=Rst(this.#s[P],this.#t[P],F),this.#r[P]=Eer(this.#s[P],F),this.#p=this.#p||this.#s[P].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${P} pattern '${this.#e[P]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(o={},s){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof o!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof o>"u")return!1;try{typeof o=="object"?f=eH(f,o,!1):f=eH(f,Ost(o,s),!1)}catch{return!1}let d;for(d of KAe)if(!this.#n[d].exec(f[d]))return!1;return!0}exec(o={},s){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof o!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof o>"u")return;try{typeof o=="object"?f=eH(f,o,!1):f=eH(f,Ost(o,s),!1)}catch{return null}let d={};s?d.inputs=[o,s]:d.inputs=[o];let y;for(y of KAe){let x=this.#n[y].exec(f[y]);if(!x)return null;let P={};for(let[F,J]of this.#t[y].entries())if(typeof J=="string"||typeof J=="number"){let G=x[F+1];P[J]=G}d[y]={input:f[y]??"",groups:P}}return d}static compareComponent(o,s,f){let d=t((F,J)=>{for(let G of["type","modifier","prefix","value","suffix"]){if(F[G]<J[G])return-1;if(F[G]!==J[G])return 1}return 0},"o"),y=new rH(3,"","","","",3),x=new rH(0,"","","","",3),P=t((F,J)=>{let G=0;for(;G<Math.min(F.length,J.length);++G){let Se=d(F[G],J[G]);if(Se)return Se}return F.length===J.length?0:d(F[G]??y,J[G]??y)},"s");return!s.#r[o]&&!f.#r[o]?0:s.#r[o]&&!f.#r[o]?P(s.#s[o],[x]):!s.#r[o]&&f.#r[o]?P([x],f.#s[o]):P(s.#s[o],f.#s[o])}get protocol(){return this.#r.protocol}get username(){return this.#r.username}get password(){return this.#r.password}get hostname(){return this.#r.hostname}get port(){return this.#r.port}get pathname(){return this.#r.pathname}get search(){return this.#r.search}get hash(){return this.#r.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=qst);import{AssertionError as Cer}from"node:assert";function VP(o,s){if(o===!1)throw new Cer({message:s})}t(VP,"assert");var Ko;(function(o){o.Object="Object",o.Property="Property",o.Array="Array",o.Literal="Literal",o.TemplateString="TemplateString",o.Identifier="Identifier",o.FunctionCall="FunctionCall",o.Raw="Raw"})(Ko||(Ko={}));function sM(o){return o.type===Ko.Object}t(sM,"isAstObject");function HP(o){return o.type===Ko.Property}t(HP,"isAstProperty");function Vst(o){return o.type===Ko.Array}t(Vst,"isAstArray");function aM(o){return o.type===Ko.Literal}t(aM,"isAstLiteral");function tI(o){if(o===void 0)throw new Error("Node is undefined");if(!sM(o))throw new Error("Node is not object")}t(tI,"assertAstObject");import{findNodeAtLocation as ker,getNodeValue as wer,printParseErrorCode as Der,visit as Per}from"jsonc-parser";var Aer={DEFAULT:{allowTrailingComma:!1}};function nH(o,s=[],f=Aer.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(J){d.type==="property"&&(d.length=J-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function x(J){return d.children?.push(J),J}t(x,"onValue"),Per(o,{onObjectBegin:t((J,G,Se)=>{d=x({type:"object",offset:J,length:-1,line:G+1,column:Se+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((J,G,Se,de,ae)=>{d=x({type:"property",offset:G,length:-1,line:de+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:J,offset:G,length:Se,line:de,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((J,G)=>{y(J+G),d.length=J+G-d.offset,d=d.parent,y(J+G)},"onObjectEnd"),onArrayBegin:t((J,G,Se,de)=>{d=x({type:"array",offset:J,length:-1,line:Se+1,column:de+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((J,G)=>{d.length=J+G-d.offset,d=d.parent,y(J+G)},"onArrayEnd"),onLiteralValue:t((J,G,Se,de,ae)=>{x({type:Ner(J),offset:G,length:Se,line:de+1,column:ae+1,parent:d,value:J}),y(G+Se)},"onLiteralValue"),onSeparator:t((J,G)=>{d.type==="property"&&(J===":"?d.colonOffset=G:J===","&&y(G))},"onSeparator"),onError:t((J,G,Se,de,ae)=>{s.push({error:J,offset:G,length:Se,line:de+1,column:ae+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(nH,"parse");function Ner(o){switch(typeof o){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(o){if(Array.isArray(o))return"array"}else return"null";return"object"}default:return"null"}}t(Ner,"getNodeType");function QAe(o,s){return ker(o,s)}t(QAe,"findNodeAtLocation");function iH(o){return wer(o)}t(iH,"getNodeValue");function Hst(o){return Der(o)}t(Hst,"printParseErrorCode");var sH=class{static{t(this,"AstAdapter")}parse(s){let d=nH(s,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,f){switch(s.type){case"object":return this.createObject(s,f);case"array":return this.createArray(s,f);case"property":return this.createProperty(s,f);case"string":return this.createLiteral(s,f);case"number":return this.createLiteral(s,f);case"boolean":return this.createLiteral(s,f);case"null":return this.createLiteral(s,f)}}createLiteral(s,f){return{type:Ko.Literal,location:{line:s.line,column:s.column},parent:f,value:s.type==="null"?null:s.value}}createObject(s,f){let d={type:Ko.Object,children:[],parent:f,location:{line:s.line,column:s.column}};return s.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(s,f){VP(s.children?.length===2,"Invalid property node");let d={type:Ko.Property,location:{line:s.line,column:s.column},parent:f,name:null,value:null};return d.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Ko.Identifier,parent:d},d.value=this.parseNode(s.children[1],d),d}createArray(s,f){let d={type:Ko.Array,location:{line:s.line,column:s.column},parent:f,children:[]};return s.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var uT={createLiteral:t((o,s)=>({type:Ko.Literal,parent:s,value:o}),"createLiteral"),createTemplateString:t((o,s)=>({type:Ko.TemplateString,parent:s,value:o}),"createTemplateString"),createIdentifier:t((o,s)=>({type:Ko.Identifier,value:o,parent:s}),"createIdentifier"),createProperty:t((o,s,f)=>{let d={type:Ko.Property,parent:f,name:null,value:s};return d.name={value:o,type:Ko.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((o,s)=>{let f={type:Ko.Array,parent:s,children:[]};for(let d of o)f.children.push(uT.createLiteral(d,f));return f},"createArrayOfLiterals")};var Ier=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,aH=class{static{t(this,"SourceGenerator")}generate(s){let f=[];return this.generateSource(f,s),f.join("")}generateSource(s,f){switch(f.type){case Ko.Array:return this.generateArray(s,f);case Ko.Object:return this.generateObject(s,f);case Ko.Property:return this.generateProperty(s,f);case Ko.Literal:return this.generateLiteral(s,f);case Ko.FunctionCall:return this.generateFunctionCall(s,f);case Ko.Identifier:return this.generateIdentifier(s,f);case Ko.Raw:return this.generateRaw(s,f);case Ko.TemplateString:return this.generateTemplateString(s,f)}}generateArray(s,f){s.push("["),f.children.map(d=>{this.generateSource(s,d),s.push(",")}),s.push("]")}generateObject(s,f){s.push("{"),f.children.forEach(d=>{this.generateSource(s,d),s.push(",")}),s.push("}")}generateProperty(s,f){this.generateIdentifier(s,f.name),s.push(":"),this.generateSource(s,f.value)}generateFunctionCall(s,f){s.push(f.name.value),s.push("("),f.children.forEach((d,y,x)=>{this.generateSource(s,d),y<x.length&&s.push(",")}),s.push(")")}generateRaw(s,f){s.push(f.value)}generateTemplateString(s,f){s.push("`"),s.push(f.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,f){if(f.value===null)return s.push("null");switch(typeof f.value){case"number":case"boolean":return s.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return s.push(`${y}`)}}}generateIdentifier(s,f){let d=Ier.test(f.value)?f.value:`'${f.value}'`;s.push(d)}};import Oer from"node:fs/promises";import{parse as Fer}from"@swc/core";var Gst=t(async o=>{let s=new Set;try{let f=await Oer.readFile(o,"utf-8");(await Fer(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?s.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?s.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&s.add(y.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var Yst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var e6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Kst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var t6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var r6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var rlt=Sd(ole(),1),nlt=Sd(tlt(),1);var fle=class o{static{t(this,"JsonValidator")}static#e=new o;static get instance(){return o.#e}ajv;constructor(){this.ajv=new rlt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,nlt.default)(this.ajv,{mode:"fast"})}addSchema(s,f){this.ajv.addSchema(s,f)}compile(s){let f=this.ajv.compile(s);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(s,f){let d=[];return s?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let x={details:{}},P=y.instancePath.split("/");if(P.length>2){let J=P[1],G=P[2]?parseInt(P[2],10):0,Se=P[3],de=Number.isNaN(G)?void 0:f[J][G][Se];x={details:{property:J,index:G,field:Se,fieldValue:de}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let J=y.instancePath.split("/"),G=J[J.length-1];y.message=`Value of property '${G}' must be '${y.params.type}'`}let F=Object.assign(y,x);d.push(F)}),d}};var fI=fle.instance;fI.addSchema(t6e,"route-configuration.schema.json");fI.addSchema(Kst,"policy-configuration.schema.json");fI.addSchema(e6e,"policies.schema.json");fI.addSchema(r6e,"open-api-route-configuration.schema.json");fI.addSchema(Yst,"fragments.schema.json");var h6r=fI.compile(t6e),ilt=fI.compile(r6e),gIe=fI.compile(e6e);var _le=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=gIe(s),this.results}};var ple=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=ilt(s),this.results}};import Wor from"node:path";var yIe=/\$import\((.*)\)/,dle=/\$env\((.*?)\)/g;var ZP=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,f,d,y){super(s),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},Jor=t(o=>{let s=[],f=o;for(;f.parent;)s.push(f),f=f.parent;return s.reverse()},"invertTree"),_I=t((o,s)=>{if(!o)return!1;let f=Jor(o);return s.split("/").every((x,P)=>{let F=f[P];return F?x==="*"||HP(F)&&F.name.value===x?!0:x==="{}"?F.type===Ko.Object:x==="[]"?F.type===Ko.Array:!1:!1})},"testPosition");var mle=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),sM(s)?s.children.forEach(f=>{this.visitor(f)}):Vst(s)?s.children.forEach(f=>{this.visitor(f)}):HP(s)&&this.visitor(s.value)}},slt=t((o,s,f)=>d=>{if(!HP(d)||!aM(d.value)||typeof d.value.value!="string")return;if(!o.some(x=>_I(d,x))){dle.test(d.value.value)&&s.push(new ZP("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=new RegExp(dle).exec(d.value.value);if(y?.length===2&&y[0]===d.value.value){let x={type:Ko.Raw,parent:null,value:`environment["${y[1]}"]`};d.value=x}else{let x=d.value.value.replaceAll(new RegExp(dle),(P,F)=>`\${environment["${F}"] ? environment["${F}"] : ""}`);x!==d.value.value&&(d.value=uT.createTemplateString(x,d))}},"getEnvStatementTransformer");var MH="config/routes.json",qor=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Vor=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],alt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Hor="handler/{}/options/{}/rewritePattern",Gor="handler/{}/options/{}/baseUrl",hle=class extends mle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let f=this.addedImports.get(s);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let s=[];return this.addedImports.forEach((f,d)=>{s.push({name:f,path:d})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!HP(s)||!aM(s.value)||typeof s.value.value!="string")&&_I(s,Hor)){if(!s.parent||!sM(s.parent)){this.errors.push(new ZP("Invalid node, expected object",MH,s.parent?s.parent.location:s.location,void 0));return}let f=s.value.value,d={type:Ko.Raw,parent:null,value:olt(f)},y=uT.createProperty("__rewriteFunction",d,s);s.parent.children.push(y)}}rewriteForwardFunction(s){if(!(!HP(s)||!aM(s.value)||typeof s.value.value!="string")&&_I(s,Gor)){if(!s.parent||!sM(s.parent)){this.errors.push(new ZP("Invalid node, expected object",MH,s.parent?s.parent.location:s.location,void 0));return}let f=s.value.value,d={type:Ko.Raw,parent:null,value:olt(f)},y=uT.createProperty("__rewriteFunction",d,s);s.parent.children.push(y)}}replaceImportStatements(s){if(!HP(s)||!aM(s.value))return;let f=s.value.value;if(typeof f!="string")return;if(!Vor.some(F=>_I(s,F))&&!alt.some(F=>_I(s,F))){if(yIe.test(f)){if(s.name.value==="$ref")return;this.errors.push(new ZP("An $import() statement is not expected at this location.",MH,s.location,f))}return}let d=yIe.exec(f);if(alt.some(F=>_I(s,F))&&!d)return;if(!d){this.errors.push(new ZP("Invalid $import() statement",MH,s.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Wor.posix.join("..",y));let x=this.getImportName(y),P={type:Ko.Identifier,parent:s.parent,value:x};s.value=P}replaceEnvStatements=slt(qor,this.errors,MH)};function olt(o){return`(request, context) => {
|
|
575
|
+
`),exitCode:x},"Untar process logs")}}t(kXt,"untarFile");async function wXt(o){if(await hAe(o))return await KN.rm(o,{recursive:!0})}t(wXt,"deleteFolder");var tu=gAe;var _lt=Sd(Nst(),1);var rH=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(o,s,f,d,y,x){this.type=o,this.name=s,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},eer=/[$_\p{ID_Start}]/u,ter=/[$_\u200C\u200D\p{ID_Continue}]/u,XAe=".*";function rer(o,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(o)}t(rer,"Re");function Fst(o,s=!1){let f=[],d=0;for(;d<o.length;){let y=o[d],x=t(function(P){if(!s)throw new TypeError(P);f.push({type:"INVALID_CHAR",index:d,value:o[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:o[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:o[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:o[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:o[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:o[d++]});continue}if(y===":"){let P="",F=d+1;for(;F<o.length;){let J=o.substr(F,1);if(F===d+1&&eer.test(J)||F!==d+1&&ter.test(J)){P+=o[F++];continue}break}if(!P){x(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:P}),d=F;continue}if(y==="("){let P=1,F="",J=d+1,G=!1;if(o[J]==="?"){x(`Pattern cannot start with "?" at ${J}`);continue}for(;J<o.length;){if(!rer(o[J],!1)){x(`Invalid character '${o[J]}' at ${J}.`),G=!0;break}if(o[J]==="\\"){F+=o[J++]+o[J++];continue}if(o[J]===")"){if(P--,P===0){J++;break}}else if(o[J]==="("&&(P++,o[J+1]!=="?")){x(`Capturing groups are not allowed at ${J}`),G=!0;break}F+=o[J++]}if(G)continue;if(P){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=J;continue}f.push({type:"CHAR",index:d,value:o[d++]})}return f.push({type:"END",index:d,value:""}),f}t(Fst,"v");function Lst(o,s={}){let f=Fst(o);s.delimiter??="/#?",s.prefixes??="./";let d=`[^${lT(s.delimiter)}]+?`,y=[],x=0,P=0,F="",J=new Set,G=t(Fn=>{if(P<f.length&&f[P].type===Fn)return f[P++].value},"a"),Se=t(()=>G("OTHER_MODIFIER")??G("ASTERISK"),"f"),de=t(Fn=>{let sn=G(Fn);if(sn!==void 0)return sn;let{type:Un,index:Er}=f[P];throw new TypeError(`Unexpected ${Un} at ${Er}, expected ${Fn}`)},"d"),ae=t(()=>{let Fn="",sn;for(;sn=G("CHAR")??G("ESCAPED_CHAR");)Fn+=sn;return Fn},"T"),Ke=t(Fn=>Fn,"Se"),$e=s.encodePart||Ke,Fe="",Gt=t(Fn=>{Fe+=Fn},"U"),jt=t(()=>{Fe.length&&(y.push(new rH(3,"","",$e(Fe),"",3)),Fe="")},"$"),Pr=t((Fn,sn,Un,Er,vr)=>{let ls=3;switch(vr){case"?":ls=1;break;case"*":ls=0;break;case"+":ls=2;break}if(!sn&&!Un&&ls===3){Gt(Fn);return}if(jt(),!sn&&!Un){if(!Fn)return;y.push(new rH(3,"","",$e(Fn),"",ls));return}let Ni;Un?Un==="*"?Ni=XAe:Ni=Un:Ni=d;let nc=2;Ni===d?(nc=1,Ni=""):Ni===XAe&&(nc=0,Ni="");let bi;if(sn?bi=sn:Un&&(bi=x++),J.has(bi))throw new TypeError(`Duplicate name '${bi}'.`);J.add(bi),y.push(new rH(nc,bi,$e(Fn),Ni,$e(Er),ls))},"V");for(;P<f.length;){let Fn=G("CHAR"),sn=G("NAME"),Un=G("REGEX");if(!sn&&!Un&&(Un=G("ASTERISK")),sn||Un){let vr=Fn??"";s.prefixes.indexOf(vr)===-1&&(Gt(vr),vr=""),jt();let ls=Se();Pr(vr,sn,Un,"",ls);continue}let Er=Fn??G("ESCAPED_CHAR");if(Er){Gt(Er);continue}if(G("OPEN")){let vr=ae(),ls=G("NAME"),Ni=G("REGEX");!ls&&!Ni&&(Ni=G("ASTERISK"));let nc=ae();de("CLOSE");let bi=Se();Pr(vr,ls,Ni,nc,bi);continue}jt(),de("END")}return y}t(Lst,"D");function lT(o){return o.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(lT,"S");function Ist(o){return o&&o.ignoreCase?"ui":"u"}t(Ist,"X");function ner(o,s,f){return Rst(Lst(o,f),s,f)}t(ner,"Z");function iM(o){switch(o){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(iM,"k");function Rst(o,s,f={}){f.delimiter??="/#?",f.prefixes??="./",f.sensitive??=!1,f.strict??=!1,f.end??=!0,f.start??=!0,f.endsWith="";let d=f.start?"^":"";for(let F of o){if(F.type===3){F.modifier===3?d+=lT(F.value):d+=`(?:${lT(F.value)})${iM(F.modifier)}`;continue}s&&s.push(F.name);let J=`[^${lT(f.delimiter)}]+?`,G=F.value;if(F.type===1?G=J:F.type===0&&(G=XAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${iM(F.modifier)}`:d+=`((?:${G})${iM(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${lT(F.prefix)}(${G})${lT(F.suffix)})`,d+=iM(F.modifier);continue}d+=`(?:${lT(F.prefix)}`,d+=`((?:${G})(?:`,d+=lT(F.suffix),d+=lT(F.prefix),d+=`(?:${G}))*)${lT(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${lT(f.endsWith)}]|$`,x=`[${lT(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Ist(f));f.strict||(d+=`(?:${x}(?=${y}))?`);let P=!1;if(o.length){let F=o[o.length-1];F.type===3&&F.modifier===3&&(P=f.delimiter.indexOf(F)>-1)}return P||(d+=`(?=${x}|${y})`),new RegExp(d,Ist(f))}t(Rst,"F");var eI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},ier={delimiter:".",prefixes:"",sensitive:!0,strict:!0},ser={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function aer(o,s){return o.length?o[0]==="/"?!0:!s||o.length<2?!1:(o[0]=="\\"||o[0]=="{")&&o[1]=="/":!1}t(aer,"J");function Mst(o,s){return o.startsWith(s)?o.substring(s.length,o.length):o}t(Mst,"Q");function oer(o,s){return o.endsWith(s)?o.substr(0,o.length-s.length):o}t(oer,"Ee");function jst(o){return!o||o.length<2?!1:o[0]==="["||(o[0]==="\\"||o[0]==="{")&&o[1]==="["}t(jst,"W");var Bst=["ftp","file","http","https","ws","wss"];function Ust(o){if(!o)return!0;for(let s of Bst)if(o.test(s))return!0;return!1}t(Ust,"N");function cer(o,s){if(o=Mst(o,"#"),s||o==="")return o;let f=new URL("https://example.com");return f.hash=o,f.hash?f.hash.substring(1,f.hash.length):""}t(cer,"te");function ler(o,s){if(o=Mst(o,"?"),s||o==="")return o;let f=new URL("https://example.com");return f.search=o,f.search?f.search.substring(1,f.search.length):""}t(ler,"re");function uer(o,s){return s||o===""?o:jst(o)?Jst(o):$st(o)}t(uer,"ne");function fer(o,s){if(s||o==="")return o;let f=new URL("https://example.com");return f.password=o,f.password}t(fer,"se");function _er(o,s){if(s||o==="")return o;let f=new URL("https://example.com");return f.username=o,f.username}t(_er,"ie");function per(o,s,f){if(f||o==="")return o;if(s&&!Bst.includes(s))return new URL(`${s}:${o}`).pathname;let d=o[0]=="/";return o=new URL(d?o:"/-"+o,"https://example.com").pathname,d||(o=o.substring(2,o.length)),o}t(per,"ae");function der(o,s,f){return zst(s)===o&&(o=""),f||o===""?o:Wst(o)}t(der,"oe");function mer(o,s){return o=oer(o,":"),s||o===""?o:ZAe(o)}t(mer,"ce");function zst(o){switch(o){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(zst,"_");function ZAe(o){if(o==="")return o;if(/^[-+.A-Za-z0-9]*$/.test(o))return o.toLowerCase();throw new TypeError(`Invalid protocol '${o}'.`)}t(ZAe,"y");function her(o){if(o==="")return o;let s=new URL("https://example.com");return s.username=o,s.username}t(her,"le");function ger(o){if(o==="")return o;let s=new URL("https://example.com");return s.password=o,s.password}t(ger,"fe");function $st(o){if(o==="")return o;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(o))throw new TypeError(`Invalid hostname '${o}'`);let s=new URL("https://example.com");return s.hostname=o,s.hostname}t($st,"z");function Jst(o){if(o==="")return o;if(/[^0-9a-fA-F[\]:]/g.test(o))throw new TypeError(`Invalid IPv6 hostname '${o}'`);return o.toLowerCase()}t(Jst,"j");function Wst(o){if(o===""||/^[0-9]*$/.test(o)&&parseInt(o)<=65535)return o;throw new TypeError(`Invalid port '${o}'.`)}t(Wst,"K");function yer(o){if(o==="")return o;let s=new URL("https://example.com");return s.pathname=o[0]!=="/"?"/-"+o:o,o[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(yer,"he");function ver(o){return o===""?o:new URL(`data:${o}`).pathname}t(ver,"ue");function ber(o){if(o==="")return o;let s=new URL("https://example.com");return s.search=o,s.search.substring(1,s.search.length)}t(ber,"de");function Ser(o){if(o==="")return o;let s=new URL("https://example.com");return s.hash=o,s.hash.substring(1,s.hash.length)}t(Ser,"pe");var Ter=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#p=0;#o=0;#_=0;#u=0;#c=!1;constructor(o){this.#e=o}get result(){return this.#t}parse(){for(this.#n=Fst(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#o===0){this.#h(),this.#x()?this.#i(9,1):this.#v()?this.#i(8,1):this.#i(7,0);continue}else if(this.#o===2){this.#m(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#l())this.#_-=1;else continue;if(this.#A()){this.#_+=1;continue}switch(this.#o){case 0:this.#g()&&this.#m(1);break;case 1:if(this.#g()){this.#P();let o=7,s=1;this.#y()?(o=2,s=3):this.#c&&(o=2),this.#i(o,s)}break;case 2:this.#E()?this.#m(3):(this.#k()||this.#v()||this.#x())&&this.#m(5);break;case 3:this.#T()?this.#i(4,1):this.#E()&&this.#i(5,1);break;case 4:this.#E()&&this.#i(5,1);break;case 5:this.#O()?this.#u+=1:this.#w()&&(this.#u-=1),this.#C()&&!this.#u?this.#i(6,1):this.#k()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 6:this.#k()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 7:this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 8:this.#x()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#i(o,s){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#D();break;case 2:break;case 3:this.#t.username=this.#D();break;case 4:this.#t.password=this.#D();break;case 5:this.#t.hostname=this.#D();break;case 6:this.#t.port=this.#D();break;case 7:this.#t.pathname=this.#D();break;case 8:this.#t.search=this.#D();break;case 9:this.#t.hash=this.#D();break;case 10:break}this.#o!==0&&o!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(o)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(o)&&(this.#t.pathname??=this.#c?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&o===9&&(this.#t.search??="")),this.#a(o,s)}#a(o,s){this.#o=o,this.#p=this.#r+s,this.#r+=s,this.#s=0}#h(){this.#r=this.#p,this.#s=0}#m(o){this.#h(),this.#o=o}#f(o){return o<0&&(o=this.#n.length-o),o<this.#n.length?this.#n[o]:this.#n[this.#n.length-1]}#d(o,s){let f=this.#f(o);return f.value===s&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#g(){return this.#d(this.#r,":")}#y(){return this.#d(this.#r+1,"/")&&this.#d(this.#r+2,"/")}#E(){return this.#d(this.#r,"@")}#T(){return this.#d(this.#r,":")}#C(){return this.#d(this.#r,":")}#k(){return this.#d(this.#r,"/")}#v(){if(this.#d(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let o=this.#f(this.#r-1);return o.type!=="NAME"&&o.type!=="REGEX"&&o.type!=="CLOSE"&&o.type!=="ASTERISK"}#x(){return this.#d(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#d(this.#r,"[")}#w(){return this.#d(this.#r,"]")}#D(){let o=this.#n[this.#r],s=this.#f(this.#p).index;return this.#e.substring(s,o.index)}#P(){let o={};Object.assign(o,eI),o.encodePart=ZAe;let s=ner(this.#D(),void 0,o);this.#c=Ust(s)}},KAe=["protocol","username","password","hostname","port","pathname","search","hash"],QN="*";function Ost(o,s){if(typeof o!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(o,s);return{protocol:f.protocol.substring(0,f.protocol.length-1),username:f.username,password:f.password,hostname:f.hostname,port:f.port,pathname:f.pathname,search:f.search!==""?f.search.substring(1,f.search.length):void 0,hash:f.hash!==""?f.hash.substring(1,f.hash.length):void 0}}t(Ost,"ge");function qP(o,s){return s?tH(o):o}t(qP,"b");function eH(o,s,f){let d;if(typeof s.baseURL=="string")try{d=new URL(s.baseURL),s.protocol===void 0&&(o.protocol=qP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(o.username=qP(d.username,f)),!f&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(o.password=qP(d.password,f)),s.protocol===void 0&&s.hostname===void 0&&(o.hostname=qP(d.hostname,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(o.port=qP(d.port,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(o.pathname=qP(d.pathname,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(o.search=qP(d.search.substring(1,d.search.length),f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(o.hash=qP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(o.protocol=mer(s.protocol,f)),typeof s.username=="string"&&(o.username=_er(s.username,f)),typeof s.password=="string"&&(o.password=fer(s.password,f)),typeof s.hostname=="string"&&(o.hostname=uer(s.hostname,f)),typeof s.port=="string"&&(o.port=der(s.port,o.protocol,f)),typeof s.pathname=="string"){if(o.pathname=s.pathname,d&&!aer(o.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(o.pathname=qP(d.pathname.substring(0,y+1),f)+o.pathname)}o.pathname=per(o.pathname,o.protocol,f)}return typeof s.search=="string"&&(o.search=ler(s.search,f)),typeof s.hash=="string"&&(o.hash=cer(s.hash,f)),o}t(eH,"w");function tH(o){return o.replace(/([+*?:{}()\\])/g,"\\$1")}t(tH,"C");function xer(o){return o.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(xer,"Oe");function Eer(o,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let f=".*",d=`[^${xer(s.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let P=0;P<o.length;++P){let F=o[P];if(F.type===3){if(F.modifier===3){x+=tH(F.value);continue}x+=`{${tH(F.value)}}${iM(F.modifier)}`;continue}let J=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!s.prefixes.includes(F.prefix)),Se=P>0?o[P-1]:null,de=P<o.length-1?o[P+1]:null;if(!G&&J&&F.type===1&&F.modifier===3&&de&&!de.prefix.length&&!de.suffix.length)if(de.type===3){let ae=de.value.length>0?de.value[0]:"";G=y.test(ae)}else G=!de.hasCustomName();if(!G&&!F.prefix.length&&Se&&Se.type===3){let ae=Se.value[Se.value.length-1];G=s.prefixes.includes(ae)}G&&(x+="{"),x+=tH(F.prefix),J&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?J||(x+=`(${d})`):F.type===0&&(!J&&(!Se||Se.type===3||Se.modifier!==3||G||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&J&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=tH(F.suffix),G&&(x+="}"),F.modifier!==3&&(x+=iM(F.modifier))}return x}t(Eer,"ke");var qst=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#p=!1;constructor(o={},s,f){try{let d;if(typeof s=="string"?d=s:f=s,typeof o=="string"){let F=new Ter(o);if(F.parse(),o=F.result,d===void 0&&typeof o.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");o.baseURL=d}else{if(!o||typeof o!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(d)throw new TypeError("parameter 1 is not of type 'string'.")}typeof f>"u"&&(f={ignoreCase:!1});let y={ignoreCase:f.ignoreCase===!0},x={pathname:QN,protocol:QN,username:QN,password:QN,hostname:QN,port:QN,search:QN,hash:QN};this.#e=eH(x,o,!0),zst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let P;for(P of KAe){if(!(P in this.#e))continue;let F={},J=this.#e[P];switch(this.#t[P]=[],P){case"protocol":Object.assign(F,eI),F.encodePart=ZAe;break;case"username":Object.assign(F,eI),F.encodePart=her;break;case"password":Object.assign(F,eI),F.encodePart=ger;break;case"hostname":Object.assign(F,ier),jst(J)?F.encodePart=Jst:F.encodePart=$st;break;case"port":Object.assign(F,eI),F.encodePart=Wst;break;case"pathname":Ust(this.#n.protocol)?(Object.assign(F,ser,y),F.encodePart=yer):(Object.assign(F,eI,y),F.encodePart=ver);break;case"search":Object.assign(F,eI,y),F.encodePart=ber;break;case"hash":Object.assign(F,eI,y),F.encodePart=Ser;break}try{this.#s[P]=Lst(J,F),this.#n[P]=Rst(this.#s[P],this.#t[P],F),this.#r[P]=Eer(this.#s[P],F),this.#p=this.#p||this.#s[P].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${P} pattern '${this.#e[P]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(o={},s){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof o!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof o>"u")return!1;try{typeof o=="object"?f=eH(f,o,!1):f=eH(f,Ost(o,s),!1)}catch{return!1}let d;for(d of KAe)if(!this.#n[d].exec(f[d]))return!1;return!0}exec(o={},s){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof o!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof o>"u")return;try{typeof o=="object"?f=eH(f,o,!1):f=eH(f,Ost(o,s),!1)}catch{return null}let d={};s?d.inputs=[o,s]:d.inputs=[o];let y;for(y of KAe){let x=this.#n[y].exec(f[y]);if(!x)return null;let P={};for(let[F,J]of this.#t[y].entries())if(typeof J=="string"||typeof J=="number"){let G=x[F+1];P[J]=G}d[y]={input:f[y]??"",groups:P}}return d}static compareComponent(o,s,f){let d=t((F,J)=>{for(let G of["type","modifier","prefix","value","suffix"]){if(F[G]<J[G])return-1;if(F[G]!==J[G])return 1}return 0},"o"),y=new rH(3,"","","","",3),x=new rH(0,"","","","",3),P=t((F,J)=>{let G=0;for(;G<Math.min(F.length,J.length);++G){let Se=d(F[G],J[G]);if(Se)return Se}return F.length===J.length?0:d(F[G]??y,J[G]??y)},"s");return!s.#r[o]&&!f.#r[o]?0:s.#r[o]&&!f.#r[o]?P(s.#s[o],[x]):!s.#r[o]&&f.#r[o]?P([x],f.#s[o]):P(s.#s[o],f.#s[o])}get protocol(){return this.#r.protocol}get username(){return this.#r.username}get password(){return this.#r.password}get hostname(){return this.#r.hostname}get port(){return this.#r.port}get pathname(){return this.#r.pathname}get search(){return this.#r.search}get hash(){return this.#r.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=qst);import{AssertionError as Cer}from"node:assert";function VP(o,s){if(o===!1)throw new Cer({message:s})}t(VP,"assert");var Ko;(function(o){o.Object="Object",o.Property="Property",o.Array="Array",o.Literal="Literal",o.TemplateString="TemplateString",o.Identifier="Identifier",o.FunctionCall="FunctionCall",o.Raw="Raw"})(Ko||(Ko={}));function sM(o){return o.type===Ko.Object}t(sM,"isAstObject");function HP(o){return o.type===Ko.Property}t(HP,"isAstProperty");function Vst(o){return o.type===Ko.Array}t(Vst,"isAstArray");function aM(o){return o.type===Ko.Literal}t(aM,"isAstLiteral");function tI(o){if(o===void 0)throw new Error("Node is undefined");if(!sM(o))throw new Error("Node is not object")}t(tI,"assertAstObject");import{findNodeAtLocation as ker,getNodeValue as wer,printParseErrorCode as Der,visit as Per}from"jsonc-parser";var Aer={DEFAULT:{allowTrailingComma:!1}};function nH(o,s=[],f=Aer.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(J){d.type==="property"&&(d.length=J-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function x(J){return d.children?.push(J),J}t(x,"onValue"),Per(o,{onObjectBegin:t((J,G,Se)=>{d=x({type:"object",offset:J,length:-1,line:G+1,column:Se+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((J,G,Se,de,ae)=>{d=x({type:"property",offset:G,length:-1,line:de+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:J,offset:G,length:Se,line:de,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((J,G)=>{y(J+G),d.length=J+G-d.offset,d=d.parent,y(J+G)},"onObjectEnd"),onArrayBegin:t((J,G,Se,de)=>{d=x({type:"array",offset:J,length:-1,line:Se+1,column:de+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((J,G)=>{d.length=J+G-d.offset,d=d.parent,y(J+G)},"onArrayEnd"),onLiteralValue:t((J,G,Se,de,ae)=>{x({type:Ner(J),offset:G,length:Se,line:de+1,column:ae+1,parent:d,value:J}),y(G+Se)},"onLiteralValue"),onSeparator:t((J,G)=>{d.type==="property"&&(J===":"?d.colonOffset=G:J===","&&y(G))},"onSeparator"),onError:t((J,G,Se,de,ae)=>{s.push({error:J,offset:G,length:Se,line:de+1,column:ae+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(nH,"parse");function Ner(o){switch(typeof o){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(o){if(Array.isArray(o))return"array"}else return"null";return"object"}default:return"null"}}t(Ner,"getNodeType");function QAe(o,s){return ker(o,s)}t(QAe,"findNodeAtLocation");function iH(o){return wer(o)}t(iH,"getNodeValue");function Hst(o){return Der(o)}t(Hst,"printParseErrorCode");var sH=class{static{t(this,"AstAdapter")}parse(s){let d=nH(s,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,f){switch(s.type){case"object":return this.createObject(s,f);case"array":return this.createArray(s,f);case"property":return this.createProperty(s,f);case"string":return this.createLiteral(s,f);case"number":return this.createLiteral(s,f);case"boolean":return this.createLiteral(s,f);case"null":return this.createLiteral(s,f)}}createLiteral(s,f){return{type:Ko.Literal,location:{line:s.line,column:s.column},parent:f,value:s.type==="null"?null:s.value}}createObject(s,f){let d={type:Ko.Object,children:[],parent:f,location:{line:s.line,column:s.column}};return s.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(s,f){VP(s.children?.length===2,"Invalid property node");let d={type:Ko.Property,location:{line:s.line,column:s.column},parent:f,name:null,value:null};return d.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Ko.Identifier,parent:d},d.value=this.parseNode(s.children[1],d),d}createArray(s,f){let d={type:Ko.Array,location:{line:s.line,column:s.column},parent:f,children:[]};return s.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var uT={createLiteral:t((o,s)=>({type:Ko.Literal,parent:s,value:o}),"createLiteral"),createTemplateString:t((o,s)=>({type:Ko.TemplateString,parent:s,value:o}),"createTemplateString"),createIdentifier:t((o,s)=>({type:Ko.Identifier,value:o,parent:s}),"createIdentifier"),createProperty:t((o,s,f)=>{let d={type:Ko.Property,parent:f,name:null,value:s};return d.name={value:o,type:Ko.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((o,s)=>{let f={type:Ko.Array,parent:s,children:[]};for(let d of o)f.children.push(uT.createLiteral(d,f));return f},"createArrayOfLiterals")};var Ier=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,aH=class{static{t(this,"SourceGenerator")}generate(s){let f=[];return this.generateSource(f,s),f.join("")}generateSource(s,f){switch(f.type){case Ko.Array:return this.generateArray(s,f);case Ko.Object:return this.generateObject(s,f);case Ko.Property:return this.generateProperty(s,f);case Ko.Literal:return this.generateLiteral(s,f);case Ko.FunctionCall:return this.generateFunctionCall(s,f);case Ko.Identifier:return this.generateIdentifier(s,f);case Ko.Raw:return this.generateRaw(s,f);case Ko.TemplateString:return this.generateTemplateString(s,f)}}generateArray(s,f){s.push("["),f.children.map(d=>{this.generateSource(s,d),s.push(",")}),s.push("]")}generateObject(s,f){s.push("{"),f.children.forEach(d=>{this.generateSource(s,d),s.push(",")}),s.push("}")}generateProperty(s,f){this.generateIdentifier(s,f.name),s.push(":"),this.generateSource(s,f.value)}generateFunctionCall(s,f){s.push(f.name.value),s.push("("),f.children.forEach((d,y,x)=>{this.generateSource(s,d),y<x.length&&s.push(",")}),s.push(")")}generateRaw(s,f){s.push(f.value)}generateTemplateString(s,f){s.push("`"),s.push(f.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,f){if(f.value===null)return s.push("null");switch(typeof f.value){case"number":case"boolean":return s.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return s.push(`${y}`)}}}generateIdentifier(s,f){let d=Ier.test(f.value)?f.value:`'${f.value}'`;s.push(d)}};import Oer from"node:fs/promises";import{parse as Fer}from"@swc/core";var Gst=t(async o=>{let s=new Set;try{let f=await Oer.readFile(o,"utf-8");(await Fer(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?s.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?s.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&s.add(y.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var Yst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var e6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Kst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var t6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var r6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var rlt=Sd(ole(),1),nlt=Sd(tlt(),1);var fle=class o{static{t(this,"JsonValidator")}static#e=new o;static get instance(){return o.#e}ajv;constructor(){this.ajv=new rlt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,nlt.default)(this.ajv,{mode:"fast"})}addSchema(s,f){this.ajv.addSchema(s,f)}compile(s){let f=this.ajv.compile(s);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(s,f){let d=[];return s?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let x={details:{}},P=y.instancePath.split("/");if(P.length>2){let J=P[1],G=P[2]?parseInt(P[2],10):0,Se=P[3],de=Number.isNaN(G)?void 0:f[J][G][Se];x={details:{property:J,index:G,field:Se,fieldValue:de}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let J=y.instancePath.split("/"),G=J[J.length-1];y.message=`Value of property '${G}' must be '${y.params.type}'`}let F=Object.assign(y,x);d.push(F)}),d}};var fI=fle.instance;fI.addSchema(t6e,"route-configuration.schema.json");fI.addSchema(Kst,"policy-configuration.schema.json");fI.addSchema(e6e,"policies.schema.json");fI.addSchema(r6e,"open-api-route-configuration.schema.json");fI.addSchema(Yst,"fragments.schema.json");var h6r=fI.compile(t6e),ilt=fI.compile(r6e),gIe=fI.compile(e6e);var _le=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=gIe(s),this.results}};var ple=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=ilt(s),this.results}};import Wor from"node:path";var yIe=/\$import\((.*)\)/,dle=/\$env\((.*?)\)/g;var ZP=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,f,d,y){super(s),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},Jor=t(o=>{let s=[],f=o;for(;f.parent;)s.push(f),f=f.parent;return s.reverse()},"invertTree"),_I=t((o,s)=>{if(!o)return!1;let f=Jor(o);return s.split("/").every((x,P)=>{let F=f[P];return F?x==="*"||HP(F)&&F.name.value===x?!0:x==="{}"?F.type===Ko.Object:x==="[]"?F.type===Ko.Array:!1:!1})},"testPosition");var mle=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),sM(s)?s.children.forEach(f=>{this.visitor(f)}):Vst(s)?s.children.forEach(f=>{this.visitor(f)}):HP(s)&&this.visitor(s.value)}},slt=t((o,s,f)=>d=>{if(!HP(d)||!aM(d.value)||typeof d.value.value!="string")return;if(!o.some(x=>_I(d,x))){dle.test(d.value.value)&&s.push(new ZP("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=new RegExp(dle).exec(d.value.value);if(y?.length===2&&y[0]===d.value.value){let x={type:Ko.Raw,parent:null,value:`environment["${y[1]}"]`};d.value=x}else{let x=d.value.value.replaceAll(new RegExp(dle),(P,F)=>`\${environment["${F}"] ? environment["${F}"] : ""}`);x!==d.value.value&&(d.value=uT.createTemplateString(x,d))}},"getEnvStatementTransformer");var MH="config/routes.json",qor=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Vor=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],alt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Hor="handler/{}/options/{}/rewritePattern",Gor="handler/{}/options/{}/baseUrl",hle=class extends mle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let f=this.addedImports.get(s);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let s=[];return this.addedImports.forEach((f,d)=>{s.push({name:f,path:d})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!HP(s)||!aM(s.value)||typeof s.value.value!="string")&&_I(s,Hor)){if(!s.parent||!sM(s.parent)){this.errors.push(new ZP("Invalid node, expected object",MH,s.parent?s.parent.location:s.location,void 0));return}let f=s.value.value,d={type:Ko.Raw,parent:null,value:olt(f)},y=uT.createProperty("__rewriteFunction",d,s);s.parent.children.push(y)}}rewriteForwardFunction(s){if(!(!HP(s)||!aM(s.value)||typeof s.value.value!="string")&&_I(s,Gor)){if(!s.parent||!sM(s.parent)){this.errors.push(new ZP("Invalid node, expected object",MH,s.parent?s.parent.location:s.location,void 0));return}let f=s.value.value,d={type:Ko.Raw,parent:null,value:olt(f)},y=uT.createProperty("__rewriteFunction",d,s);s.parent.children.push(y)}}replaceImportStatements(s){if(!HP(s)||!aM(s.value))return;let f=s.value.value;if(typeof f!="string")return;if(!Vor.some(F=>_I(s,F))&&!alt.some(F=>_I(s,F))){if(yIe.test(f)){if(s.name.value==="$ref")return;this.errors.push(new ZP("An $import() statement is not expected at this location.",MH,s.location,f))}return}let d=yIe.exec(f);if(alt.some(F=>_I(s,F))&&!d)return;if(!d){this.errors.push(new ZP("Invalid $import() statement",MH,s.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Wor.posix.join("..",y));let x=this.getImportName(y),P={type:Ko.Identifier,parent:s.parent,value:x};s.value=P}replaceEnvStatements=slt(qor,this.errors,MH)};function olt(o){return`(request, context) => {
|
|
576
576
|
const { params, url, query, method, headers } = request;
|
|
577
577
|
const { host, hostname, origin, pathname, port, search } = new URL(url);
|
|
578
578
|
const e = encodeURIComponent;
|
package/index.minified.js
CHANGED
|
@@ -572,7 +572,7 @@ globstar while`,s,ae,f,Ke,$e),this.matchOne(s.slice(ae),f.slice(Ke),d))return th
|
|
|
572
572
|
`),stderr:x.join(`
|
|
573
573
|
`),exitCode:P},"Tar process logs")}}t(YXt,"tarFolder");async function KXt({tarFilePath:o,outputDir:s,logger:f}){let d=[],y=[],x;try{await new Promise((P,F)=>{let J=mit("sh",["-c",`tar -xvf ${o} -C ${s};`]);J.stdout.on("data",G=>{let Se=G.toString().trim();Se.length>0&&d.push(Se.trim())}),J.stderr.on("data",G=>{let Se=G.toString().trim();Se.length>0&&y.push(Se.trim())}),J.on("close",G=>{x=G,G===0?P():F(new Error(`tar process exited with code ${G}`))}),J.on("error",G=>{F(G)})})}catch(P){throw new Error("Failed to untar file",{cause:P})}finally{f.info({stdout:d.join(`
|
|
574
574
|
`),stderr:y.join(`
|
|
575
|
-
`),exitCode:x},"Untar process logs")}}t(KXt,"untarFile");async function XXt(o){if(await SAe(o))return await QN.rm(o,{recursive:!0})}t(XXt,"deleteFolder");var tu=TAe;var blt=Dp(Bst(),1);var nH=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(o,s,f,d,y,x){this.type=o,this.name=s,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Eer=/[$_\p{ID_Start}]/u,Cer=/[$_\u200C\u200D\p{ID_Continue}]/u,r6e=".*";function ker(o,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(o)}t(ker,"Re");function $st(o,s=!1){let f=[],d=0;for(;d<o.length;){let y=o[d],x=t(function(P){if(!s)throw new TypeError(P);f.push({type:"INVALID_CHAR",index:d,value:o[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:o[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:o[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:o[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:o[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:o[d++]});continue}if(y===":"){let P="",F=d+1;for(;F<o.length;){let J=o.substr(F,1);if(F===d+1&&Eer.test(J)||F!==d+1&&Cer.test(J)){P+=o[F++];continue}break}if(!P){x(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:P}),d=F;continue}if(y==="("){let P=1,F="",J=d+1,G=!1;if(o[J]==="?"){x(`Pattern cannot start with "?" at ${J}`);continue}for(;J<o.length;){if(!ker(o[J],!1)){x(`Invalid character '${o[J]}' at ${J}.`),G=!0;break}if(o[J]==="\\"){F+=o[J++]+o[J++];continue}if(o[J]===")"){if(P--,P===0){J++;break}}else if(o[J]==="("&&(P++,o[J+1]!=="?")){x(`Capturing groups are not allowed at ${J}`),G=!0;break}F+=o[J++]}if(G)continue;if(P){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=J;continue}f.push({type:"CHAR",index:d,value:o[d++]})}return f.push({type:"END",index:d,value:""}),f}t($st,"v");function Jst(o,s={}){let f=$st(o);s.delimiter??="/#?",s.prefixes??="./";let d=`[^${lT(s.delimiter)}]+?`,y=[],x=0,P=0,F="",J=new Set,G=t(Fn=>{if(P<f.length&&f[P].type===Fn)return f[P++].value},"a"),Se=t(()=>G("OTHER_MODIFIER")??G("ASTERISK"),"f"),de=t(Fn=>{let sn=G(Fn);if(sn!==void 0)return sn;let{type:Un,index:Er}=f[P];throw new TypeError(`Unexpected ${Un} at ${Er}, expected ${Fn}`)},"d"),ae=t(()=>{let Fn="",sn;for(;sn=G("CHAR")??G("ESCAPED_CHAR");)Fn+=sn;return Fn},"T"),Ke=t(Fn=>Fn,"Se"),$e=s.encodePart||Ke,Fe="",Gt=t(Fn=>{Fe+=Fn},"U"),jt=t(()=>{Fe.length&&(y.push(new nH(3,"","",$e(Fe),"",3)),Fe="")},"$"),Pr=t((Fn,sn,Un,Er,vr)=>{let ls=3;switch(vr){case"?":ls=1;break;case"*":ls=0;break;case"+":ls=2;break}if(!sn&&!Un&&ls===3){Gt(Fn);return}if(jt(),!sn&&!Un){if(!Fn)return;y.push(new nH(3,"","",$e(Fn),"",ls));return}let Ni;Un?Un==="*"?Ni=r6e:Ni=Un:Ni=d;let nc=2;Ni===d?(nc=1,Ni=""):Ni===r6e&&(nc=0,Ni="");let bi;if(sn?bi=sn:Un&&(bi=x++),J.has(bi))throw new TypeError(`Duplicate name '${bi}'.`);J.add(bi),y.push(new nH(nc,bi,$e(Fn),Ni,$e(Er),ls))},"V");for(;P<f.length;){let Fn=G("CHAR"),sn=G("NAME"),Un=G("REGEX");if(!sn&&!Un&&(Un=G("ASTERISK")),sn||Un){let vr=Fn??"";s.prefixes.indexOf(vr)===-1&&(Gt(vr),vr=""),jt();let ls=Se();Pr(vr,sn,Un,"",ls);continue}let Er=Fn??G("ESCAPED_CHAR");if(Er){Gt(Er);continue}if(G("OPEN")){let vr=ae(),ls=G("NAME"),Ni=G("REGEX");!ls&&!Ni&&(Ni=G("ASTERISK"));let nc=ae();de("CLOSE");let bi=Se();Pr(vr,ls,Ni,nc,bi);continue}jt(),de("END")}return y}t(Jst,"D");function lT(o){return o.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(lT,"S");function Ust(o){return o&&o.ignoreCase?"ui":"u"}t(Ust,"X");function wer(o,s,f){return Wst(Jst(o,f),s,f)}t(wer,"Z");function iM(o){switch(o){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(iM,"k");function Wst(o,s,f={}){f.delimiter??="/#?",f.prefixes??="./",f.sensitive??=!1,f.strict??=!1,f.end??=!0,f.start??=!0,f.endsWith="";let d=f.start?"^":"";for(let F of o){if(F.type===3){F.modifier===3?d+=lT(F.value):d+=`(?:${lT(F.value)})${iM(F.modifier)}`;continue}s&&s.push(F.name);let J=`[^${lT(f.delimiter)}]+?`,G=F.value;if(F.type===1?G=J:F.type===0&&(G=r6e),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${iM(F.modifier)}`:d+=`((?:${G})${iM(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${lT(F.prefix)}(${G})${lT(F.suffix)})`,d+=iM(F.modifier);continue}d+=`(?:${lT(F.prefix)}`,d+=`((?:${G})(?:`,d+=lT(F.suffix),d+=lT(F.prefix),d+=`(?:${G}))*)${lT(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${lT(f.endsWith)}]|$`,x=`[${lT(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Ust(f));f.strict||(d+=`(?:${x}(?=${y}))?`);let P=!1;if(o.length){let F=o[o.length-1];F.type===3&&F.modifier===3&&(P=f.delimiter.indexOf(F)>-1)}return P||(d+=`(?=${x}|${y})`),new RegExp(d,Ust(f))}t(Wst,"F");var nI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Der={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Per={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Aer(o,s){return o.length?o[0]==="/"?!0:!s||o.length<2?!1:(o[0]=="\\"||o[0]=="{")&&o[1]=="/":!1}t(Aer,"J");function qst(o,s){return o.startsWith(s)?o.substring(s.length,o.length):o}t(qst,"Q");function Ner(o,s){return o.endsWith(s)?o.substr(0,o.length-s.length):o}t(Ner,"Ee");function Vst(o){return!o||o.length<2?!1:o[0]==="["||(o[0]==="\\"||o[0]==="{")&&o[1]==="["}t(Vst,"W");var Hst=["ftp","file","http","https","ws","wss"];function Gst(o){if(!o)return!0;for(let s of Hst)if(o.test(s))return!0;return!1}t(Gst,"N");function Ier(o,s){if(o=qst(o,"#"),s||o==="")return o;let f=new URL("https://example.com");return f.hash=o,f.hash?f.hash.substring(1,f.hash.length):""}t(Ier,"te");function Oer(o,s){if(o=qst(o,"?"),s||o==="")return o;let f=new URL("https://example.com");return f.search=o,f.search?f.search.substring(1,f.search.length):""}t(Oer,"re");function Fer(o,s){return s||o===""?o:Vst(o)?Xst(o):Kst(o)}t(Fer,"ne");function Ler(o,s){if(s||o==="")return o;let f=new URL("https://example.com");return f.password=o,f.password}t(Ler,"se");function Rer(o,s){if(s||o==="")return o;let f=new URL("https://example.com");return f.username=o,f.username}t(Rer,"ie");function Mer(o,s,f){if(f||o==="")return o;if(s&&!Hst.includes(s))return new URL(`${s}:${o}`).pathname;let d=o[0]=="/";return o=new URL(d?o:"/-"+o,"https://example.com").pathname,d||(o=o.substring(2,o.length)),o}t(Mer,"ae");function jer(o,s,f){return Yst(s)===o&&(o=""),f||o===""?o:Zst(o)}t(jer,"oe");function Ber(o,s){return o=Ner(o,":"),s||o===""?o:n6e(o)}t(Ber,"ce");function Yst(o){switch(o){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(Yst,"_");function n6e(o){if(o==="")return o;if(/^[-+.A-Za-z0-9]*$/.test(o))return o.toLowerCase();throw new TypeError(`Invalid protocol '${o}'.`)}t(n6e,"y");function Uer(o){if(o==="")return o;let s=new URL("https://example.com");return s.username=o,s.username}t(Uer,"le");function zer(o){if(o==="")return o;let s=new URL("https://example.com");return s.password=o,s.password}t(zer,"fe");function Kst(o){if(o==="")return o;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(o))throw new TypeError(`Invalid hostname '${o}'`);let s=new URL("https://example.com");return s.hostname=o,s.hostname}t(Kst,"z");function Xst(o){if(o==="")return o;if(/[^0-9a-fA-F[\]:]/g.test(o))throw new TypeError(`Invalid IPv6 hostname '${o}'`);return o.toLowerCase()}t(Xst,"j");function Zst(o){if(o===""||/^[0-9]*$/.test(o)&&parseInt(o)<=65535)return o;throw new TypeError(`Invalid port '${o}'.`)}t(Zst,"K");function $er(o){if(o==="")return o;let s=new URL("https://example.com");return s.pathname=o[0]!=="/"?"/-"+o:o,o[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t($er,"he");function Jer(o){return o===""?o:new URL(`data:${o}`).pathname}t(Jer,"ue");function Wer(o){if(o==="")return o;let s=new URL("https://example.com");return s.search=o,s.search.substring(1,s.search.length)}t(Wer,"de");function qer(o){if(o==="")return o;let s=new URL("https://example.com");return s.hash=o,s.hash.substring(1,s.hash.length)}t(qer,"pe");var Ver=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#p=0;#o=0;#_=0;#u=0;#c=!1;constructor(o){this.#e=o}get result(){return this.#t}parse(){for(this.#n=$st(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#o===0){this.#h(),this.#x()?this.#i(9,1):this.#v()?this.#i(8,1):this.#i(7,0);continue}else if(this.#o===2){this.#m(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#l())this.#_-=1;else continue;if(this.#A()){this.#_+=1;continue}switch(this.#o){case 0:this.#g()&&this.#m(1);break;case 1:if(this.#g()){this.#P();let o=7,s=1;this.#y()?(o=2,s=3):this.#c&&(o=2),this.#i(o,s)}break;case 2:this.#E()?this.#m(3):(this.#k()||this.#v()||this.#x())&&this.#m(5);break;case 3:this.#T()?this.#i(4,1):this.#E()&&this.#i(5,1);break;case 4:this.#E()&&this.#i(5,1);break;case 5:this.#O()?this.#u+=1:this.#w()&&(this.#u-=1),this.#C()&&!this.#u?this.#i(6,1):this.#k()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 6:this.#k()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 7:this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 8:this.#x()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#i(o,s){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#D();break;case 2:break;case 3:this.#t.username=this.#D();break;case 4:this.#t.password=this.#D();break;case 5:this.#t.hostname=this.#D();break;case 6:this.#t.port=this.#D();break;case 7:this.#t.pathname=this.#D();break;case 8:this.#t.search=this.#D();break;case 9:this.#t.hash=this.#D();break;case 10:break}this.#o!==0&&o!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(o)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(o)&&(this.#t.pathname??=this.#c?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&o===9&&(this.#t.search??="")),this.#a(o,s)}#a(o,s){this.#o=o,this.#p=this.#r+s,this.#r+=s,this.#s=0}#h(){this.#r=this.#p,this.#s=0}#m(o){this.#h(),this.#o=o}#f(o){return o<0&&(o=this.#n.length-o),o<this.#n.length?this.#n[o]:this.#n[this.#n.length-1]}#d(o,s){let f=this.#f(o);return f.value===s&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#g(){return this.#d(this.#r,":")}#y(){return this.#d(this.#r+1,"/")&&this.#d(this.#r+2,"/")}#E(){return this.#d(this.#r,"@")}#T(){return this.#d(this.#r,":")}#C(){return this.#d(this.#r,":")}#k(){return this.#d(this.#r,"/")}#v(){if(this.#d(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let o=this.#f(this.#r-1);return o.type!=="NAME"&&o.type!=="REGEX"&&o.type!=="CLOSE"&&o.type!=="ASTERISK"}#x(){return this.#d(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#d(this.#r,"[")}#w(){return this.#d(this.#r,"]")}#D(){let o=this.#n[this.#r],s=this.#f(this.#p).index;return this.#e.substring(s,o.index)}#P(){let o={};Object.assign(o,nI),o.encodePart=n6e;let s=wer(this.#D(),void 0,o);this.#c=Gst(s)}},t6e=["protocol","username","password","hostname","port","pathname","search","hash"],rI="*";function zst(o,s){if(typeof o!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(o,s);return{protocol:f.protocol.substring(0,f.protocol.length-1),username:f.username,password:f.password,hostname:f.hostname,port:f.port,pathname:f.pathname,search:f.search!==""?f.search.substring(1,f.search.length):void 0,hash:f.hash!==""?f.hash.substring(1,f.hash.length):void 0}}t(zst,"ge");function GP(o,s){return s?rH(o):o}t(GP,"b");function tH(o,s,f){let d;if(typeof s.baseURL=="string")try{d=new URL(s.baseURL),s.protocol===void 0&&(o.protocol=GP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(o.username=GP(d.username,f)),!f&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(o.password=GP(d.password,f)),s.protocol===void 0&&s.hostname===void 0&&(o.hostname=GP(d.hostname,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(o.port=GP(d.port,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(o.pathname=GP(d.pathname,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(o.search=GP(d.search.substring(1,d.search.length),f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(o.hash=GP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(o.protocol=Ber(s.protocol,f)),typeof s.username=="string"&&(o.username=Rer(s.username,f)),typeof s.password=="string"&&(o.password=Ler(s.password,f)),typeof s.hostname=="string"&&(o.hostname=Fer(s.hostname,f)),typeof s.port=="string"&&(o.port=jer(s.port,o.protocol,f)),typeof s.pathname=="string"){if(o.pathname=s.pathname,d&&!Aer(o.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(o.pathname=GP(d.pathname.substring(0,y+1),f)+o.pathname)}o.pathname=Mer(o.pathname,o.protocol,f)}return typeof s.search=="string"&&(o.search=Oer(s.search,f)),typeof s.hash=="string"&&(o.hash=Ier(s.hash,f)),o}t(tH,"w");function rH(o){return o.replace(/([+*?:{}()\\])/g,"\\$1")}t(rH,"C");function Her(o){return o.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Her,"Oe");function Ger(o,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let f=".*",d=`[^${Her(s.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let P=0;P<o.length;++P){let F=o[P];if(F.type===3){if(F.modifier===3){x+=rH(F.value);continue}x+=`{${rH(F.value)}}${iM(F.modifier)}`;continue}let J=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!s.prefixes.includes(F.prefix)),Se=P>0?o[P-1]:null,de=P<o.length-1?o[P+1]:null;if(!G&&J&&F.type===1&&F.modifier===3&&de&&!de.prefix.length&&!de.suffix.length)if(de.type===3){let ae=de.value.length>0?de.value[0]:"";G=y.test(ae)}else G=!de.hasCustomName();if(!G&&!F.prefix.length&&Se&&Se.type===3){let ae=Se.value[Se.value.length-1];G=s.prefixes.includes(ae)}G&&(x+="{"),x+=rH(F.prefix),J&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?J||(x+=`(${d})`):F.type===0&&(!J&&(!Se||Se.type===3||Se.modifier!==3||G||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&J&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=rH(F.suffix),G&&(x+="}"),F.modifier!==3&&(x+=iM(F.modifier))}return x}t(Ger,"ke");var Qst=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#p=!1;constructor(o={},s,f){try{let d;if(typeof s=="string"?d=s:f=s,typeof o=="string"){let F=new Ver(o);if(F.parse(),o=F.result,d===void 0&&typeof o.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");o.baseURL=d}else{if(!o||typeof o!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(d)throw new TypeError("parameter 1 is not of type 'string'.")}typeof f>"u"&&(f={ignoreCase:!1});let y={ignoreCase:f.ignoreCase===!0},x={pathname:rI,protocol:rI,username:rI,password:rI,hostname:rI,port:rI,search:rI,hash:rI};this.#e=tH(x,o,!0),Yst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let P;for(P of t6e){if(!(P in this.#e))continue;let F={},J=this.#e[P];switch(this.#t[P]=[],P){case"protocol":Object.assign(F,nI),F.encodePart=n6e;break;case"username":Object.assign(F,nI),F.encodePart=Uer;break;case"password":Object.assign(F,nI),F.encodePart=zer;break;case"hostname":Object.assign(F,Der),Vst(J)?F.encodePart=Xst:F.encodePart=Kst;break;case"port":Object.assign(F,nI),F.encodePart=Zst;break;case"pathname":Gst(this.#n.protocol)?(Object.assign(F,Per,y),F.encodePart=$er):(Object.assign(F,nI,y),F.encodePart=Jer);break;case"search":Object.assign(F,nI,y),F.encodePart=Wer;break;case"hash":Object.assign(F,nI,y),F.encodePart=qer;break}try{this.#s[P]=Jst(J,F),this.#n[P]=Wst(this.#s[P],this.#t[P],F),this.#r[P]=Ger(this.#s[P],F),this.#p=this.#p||this.#s[P].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${P} pattern '${this.#e[P]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(o={},s){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof o!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof o>"u")return!1;try{typeof o=="object"?f=tH(f,o,!1):f=tH(f,zst(o,s),!1)}catch{return!1}let d;for(d of t6e)if(!this.#n[d].exec(f[d]))return!1;return!0}exec(o={},s){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof o!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof o>"u")return;try{typeof o=="object"?f=tH(f,o,!1):f=tH(f,zst(o,s),!1)}catch{return null}let d={};s?d.inputs=[o,s]:d.inputs=[o];let y;for(y of t6e){let x=this.#n[y].exec(f[y]);if(!x)return null;let P={};for(let[F,J]of this.#t[y].entries())if(typeof J=="string"||typeof J=="number"){let G=x[F+1];P[J]=G}d[y]={input:f[y]??"",groups:P}}return d}static compareComponent(o,s,f){let d=t((F,J)=>{for(let G of["type","modifier","prefix","value","suffix"]){if(F[G]<J[G])return-1;if(F[G]!==J[G])return 1}return 0},"o"),y=new nH(3,"","","","",3),x=new nH(0,"","","","",3),P=t((F,J)=>{let G=0;for(;G<Math.min(F.length,J.length);++G){let Se=d(F[G],J[G]);if(Se)return Se}return F.length===J.length?0:d(F[G]??y,J[G]??y)},"s");return!s.#r[o]&&!f.#r[o]?0:s.#r[o]&&!f.#r[o]?P(s.#s[o],[x]):!s.#r[o]&&f.#r[o]?P([x],f.#s[o]):P(s.#s[o],f.#s[o])}get protocol(){return this.#r.protocol}get username(){return this.#r.username}get password(){return this.#r.password}get hostname(){return this.#r.hostname}get port(){return this.#r.port}get pathname(){return this.#r.pathname}get search(){return this.#r.search}get hash(){return this.#r.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=Qst);import{AssertionError as Yer}from"node:assert";function YP(o,s){if(o===!1)throw new Yer({message:s})}t(YP,"assert");var Ko;(function(o){o.Object="Object",o.Property="Property",o.Array="Array",o.Literal="Literal",o.TemplateString="TemplateString",o.Identifier="Identifier",o.FunctionCall="FunctionCall",o.Raw="Raw"})(Ko||(Ko={}));function sM(o){return o.type===Ko.Object}t(sM,"isAstObject");function KP(o){return o.type===Ko.Property}t(KP,"isAstProperty");function eat(o){return o.type===Ko.Array}t(eat,"isAstArray");function aM(o){return o.type===Ko.Literal}t(aM,"isAstLiteral");function iI(o){if(o===void 0)throw new Error("Node is undefined");if(!sM(o))throw new Error("Node is not object")}t(iI,"assertAstObject");import{findNodeAtLocation as Ker,getNodeValue as Xer,printParseErrorCode as Zer,visit as Qer}from"jsonc-parser";var etr={DEFAULT:{allowTrailingComma:!1}};function iH(o,s=[],f=etr.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(J){d.type==="property"&&(d.length=J-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function x(J){return d.children?.push(J),J}t(x,"onValue"),Qer(o,{onObjectBegin:t((J,G,Se)=>{d=x({type:"object",offset:J,length:-1,line:G+1,column:Se+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((J,G,Se,de,ae)=>{d=x({type:"property",offset:G,length:-1,line:de+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:J,offset:G,length:Se,line:de,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((J,G)=>{y(J+G),d.length=J+G-d.offset,d=d.parent,y(J+G)},"onObjectEnd"),onArrayBegin:t((J,G,Se,de)=>{d=x({type:"array",offset:J,length:-1,line:Se+1,column:de+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((J,G)=>{d.length=J+G-d.offset,d=d.parent,y(J+G)},"onArrayEnd"),onLiteralValue:t((J,G,Se,de,ae)=>{x({type:ttr(J),offset:G,length:Se,line:de+1,column:ae+1,parent:d,value:J}),y(G+Se)},"onLiteralValue"),onSeparator:t((J,G)=>{d.type==="property"&&(J===":"?d.colonOffset=G:J===","&&y(G))},"onSeparator"),onError:t((J,G,Se,de,ae)=>{s.push({error:J,offset:G,length:Se,line:de+1,column:ae+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(iH,"parse");function ttr(o){switch(typeof o){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(o){if(Array.isArray(o))return"array"}else return"null";return"object"}default:return"null"}}t(ttr,"getNodeType");function i6e(o,s){return Ker(o,s)}t(i6e,"findNodeAtLocation");function sH(o){return Xer(o)}t(sH,"getNodeValue");function tat(o){return Zer(o)}t(tat,"printParseErrorCode");var aH=class{static{t(this,"AstAdapter")}parse(s){let d=iH(s,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,f){switch(s.type){case"object":return this.createObject(s,f);case"array":return this.createArray(s,f);case"property":return this.createProperty(s,f);case"string":return this.createLiteral(s,f);case"number":return this.createLiteral(s,f);case"boolean":return this.createLiteral(s,f);case"null":return this.createLiteral(s,f)}}createLiteral(s,f){return{type:Ko.Literal,location:{line:s.line,column:s.column},parent:f,value:s.type==="null"?null:s.value}}createObject(s,f){let d={type:Ko.Object,children:[],parent:f,location:{line:s.line,column:s.column}};return s.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(s,f){YP(s.children?.length===2,"Invalid property node");let d={type:Ko.Property,location:{line:s.line,column:s.column},parent:f,name:null,value:null};return d.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Ko.Identifier,parent:d},d.value=this.parseNode(s.children[1],d),d}createArray(s,f){let d={type:Ko.Array,location:{line:s.line,column:s.column},parent:f,children:[]};return s.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var uT={createLiteral:t((o,s)=>({type:Ko.Literal,parent:s,value:o}),"createLiteral"),createTemplateString:t((o,s)=>({type:Ko.TemplateString,parent:s,value:o}),"createTemplateString"),createIdentifier:t((o,s)=>({type:Ko.Identifier,value:o,parent:s}),"createIdentifier"),createProperty:t((o,s,f)=>{let d={type:Ko.Property,parent:f,name:null,value:s};return d.name={value:o,type:Ko.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((o,s)=>{let f={type:Ko.Array,parent:s,children:[]};for(let d of o)f.children.push(uT.createLiteral(d,f));return f},"createArrayOfLiterals")};var rtr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,oH=class{static{t(this,"SourceGenerator")}generate(s){let f=[];return this.generateSource(f,s),f.join("")}generateSource(s,f){switch(f.type){case Ko.Array:return this.generateArray(s,f);case Ko.Object:return this.generateObject(s,f);case Ko.Property:return this.generateProperty(s,f);case Ko.Literal:return this.generateLiteral(s,f);case Ko.FunctionCall:return this.generateFunctionCall(s,f);case Ko.Identifier:return this.generateIdentifier(s,f);case Ko.Raw:return this.generateRaw(s,f);case Ko.TemplateString:return this.generateTemplateString(s,f)}}generateArray(s,f){s.push("["),f.children.map(d=>{this.generateSource(s,d),s.push(",")}),s.push("]")}generateObject(s,f){s.push("{"),f.children.forEach(d=>{this.generateSource(s,d),s.push(",")}),s.push("}")}generateProperty(s,f){this.generateIdentifier(s,f.name),s.push(":"),this.generateSource(s,f.value)}generateFunctionCall(s,f){s.push(f.name.value),s.push("("),f.children.forEach((d,y,x)=>{this.generateSource(s,d),y<x.length&&s.push(",")}),s.push(")")}generateRaw(s,f){s.push(f.value)}generateTemplateString(s,f){s.push("`"),s.push(f.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,f){if(f.value===null)return s.push("null");switch(typeof f.value){case"number":case"boolean":return s.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return s.push(`${y}`)}}}generateIdentifier(s,f){let d=rtr.test(f.value)?f.value:`'${f.value}'`;s.push(d)}};import ntr from"node:fs/promises";import{parse as itr}from"@swc/core";var rat=t(async o=>{let s=new Set;try{let f=await ntr.readFile(o,"utf-8");(await itr(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?s.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?s.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&s.add(y.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var nat={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var s6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var iat={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var a6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var o6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var ult=Dp(ole(),1),flt=Dp(llt(),1);var fle=class o{static{t(this,"JsonValidator")}static#e=new o;static get instance(){return o.#e}ajv;constructor(){this.ajv=new ult.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,flt.default)(this.ajv,{mode:"fast"})}addSchema(s,f){this.ajv.addSchema(s,f)}compile(s){let f=this.ajv.compile(s);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(s,f){let d=[];return s?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let x={details:{}},P=y.instancePath.split("/");if(P.length>2){let J=P[1],G=P[2]?parseInt(P[2],10):0,Se=P[3],de=Number.isNaN(G)?void 0:f[J][G][Se];x={details:{property:J,index:G,field:Se,fieldValue:de}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let J=y.instancePath.split("/"),G=J[J.length-1];y.message=`Value of property '${G}' must be '${y.params.type}'`}let F=Object.assign(y,x);d.push(F)}),d}};var dI=fle.instance;dI.addSchema(a6e,"route-configuration.schema.json");dI.addSchema(iat,"policy-configuration.schema.json");dI.addSchema(s6e,"policies.schema.json");dI.addSchema(o6e,"open-api-route-configuration.schema.json");dI.addSchema(nat,"fragments.schema.json");var B6r=dI.compile(a6e),_lt=dI.compile(o6e),TIe=dI.compile(s6e);var _le=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=TIe(s),this.results}};var ple=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=_lt(s),this.results}};import dcr from"node:path";var xIe=/\$import\((.*)\)/,dle=/\$env\((.*?)\)/g;var tA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,f,d,y){super(s),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},pcr=t(o=>{let s=[],f=o;for(;f.parent;)s.push(f),f=f.parent;return s.reverse()},"invertTree"),mI=t((o,s)=>{if(!o)return!1;let f=pcr(o);return s.split("/").every((x,P)=>{let F=f[P];return F?x==="*"||KP(F)&&F.name.value===x?!0:x==="{}"?F.type===Ko.Object:x==="[]"?F.type===Ko.Array:!1:!1})},"testPosition");var mle=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),sM(s)?s.children.forEach(f=>{this.visitor(f)}):eat(s)?s.children.forEach(f=>{this.visitor(f)}):KP(s)&&this.visitor(s.value)}},plt=t((o,s,f)=>d=>{if(!KP(d)||!aM(d.value)||typeof d.value.value!="string")return;if(!o.some(x=>mI(d,x))){dle.test(d.value.value)&&s.push(new tA("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=new RegExp(dle).exec(d.value.value);if(y?.length===2&&y[0]===d.value.value){let x={type:Ko.Raw,parent:null,value:`environment["${y[1]}"]`};d.value=x}else{let x=d.value.value.replaceAll(new RegExp(dle),(P,F)=>`\${environment["${F}"] ? environment["${F}"] : ""}`);x!==d.value.value&&(d.value=uT.createTemplateString(x,d))}},"getEnvStatementTransformer");var jH="config/routes.json",mcr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],hcr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],dlt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],gcr="handler/{}/options/{}/rewritePattern",ycr="handler/{}/options/{}/baseUrl",hle=class extends mle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let f=this.addedImports.get(s);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let s=[];return this.addedImports.forEach((f,d)=>{s.push({name:f,path:d})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!KP(s)||!aM(s.value)||typeof s.value.value!="string")&&mI(s,gcr)){if(!s.parent||!sM(s.parent)){this.errors.push(new tA("Invalid node, expected object",jH,s.parent?s.parent.location:s.location,void 0));return}let f=s.value.value,d={type:Ko.Raw,parent:null,value:mlt(f)},y=uT.createProperty("__rewriteFunction",d,s);s.parent.children.push(y)}}rewriteForwardFunction(s){if(!(!KP(s)||!aM(s.value)||typeof s.value.value!="string")&&mI(s,ycr)){if(!s.parent||!sM(s.parent)){this.errors.push(new tA("Invalid node, expected object",jH,s.parent?s.parent.location:s.location,void 0));return}let f=s.value.value,d={type:Ko.Raw,parent:null,value:mlt(f)},y=uT.createProperty("__rewriteFunction",d,s);s.parent.children.push(y)}}replaceImportStatements(s){if(!KP(s)||!aM(s.value))return;let f=s.value.value;if(typeof f!="string")return;if(!hcr.some(F=>mI(s,F))&&!dlt.some(F=>mI(s,F))){if(xIe.test(f)){if(s.name.value==="$ref")return;this.errors.push(new tA("An $import() statement is not expected at this location.",jH,s.location,f))}return}let d=xIe.exec(f);if(dlt.some(F=>mI(s,F))&&!d)return;if(!d){this.errors.push(new tA("Invalid $import() statement",jH,s.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=dcr.posix.join("..",y));let x=this.getImportName(y),P={type:Ko.Identifier,parent:s.parent,value:x};s.value=P}replaceEnvStatements=plt(mcr,this.errors,jH)};function mlt(o){return`(request, context) => {
|
|
575
|
+
`),exitCode:x},"Untar process logs")}}t(KXt,"untarFile");async function XXt(o){if(await SAe(o))return await QN.rm(o,{recursive:!0})}t(XXt,"deleteFolder");var tu=TAe;var blt=Dp(Bst(),1);var nH=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(o,s,f,d,y,x){this.type=o,this.name=s,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Eer=/[$_\p{ID_Start}]/u,Cer=/[$_\u200C\u200D\p{ID_Continue}]/u,r6e=".*";function ker(o,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(o)}t(ker,"Re");function $st(o,s=!1){let f=[],d=0;for(;d<o.length;){let y=o[d],x=t(function(P){if(!s)throw new TypeError(P);f.push({type:"INVALID_CHAR",index:d,value:o[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:o[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:o[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:o[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:o[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:o[d++]});continue}if(y===":"){let P="",F=d+1;for(;F<o.length;){let J=o.substr(F,1);if(F===d+1&&Eer.test(J)||F!==d+1&&Cer.test(J)){P+=o[F++];continue}break}if(!P){x(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:P}),d=F;continue}if(y==="("){let P=1,F="",J=d+1,G=!1;if(o[J]==="?"){x(`Pattern cannot start with "?" at ${J}`);continue}for(;J<o.length;){if(!ker(o[J],!1)){x(`Invalid character '${o[J]}' at ${J}.`),G=!0;break}if(o[J]==="\\"){F+=o[J++]+o[J++];continue}if(o[J]===")"){if(P--,P===0){J++;break}}else if(o[J]==="("&&(P++,o[J+1]!=="?")){x(`Capturing groups are not allowed at ${J}`),G=!0;break}F+=o[J++]}if(G)continue;if(P){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=J;continue}f.push({type:"CHAR",index:d,value:o[d++]})}return f.push({type:"END",index:d,value:""}),f}t($st,"v");function Jst(o,s={}){let f=$st(o);s.delimiter??="/#?",s.prefixes??="./";let d=`[^${lT(s.delimiter)}]+?`,y=[],x=0,P=0,F="",J=new Set,G=t(Fn=>{if(P<f.length&&f[P].type===Fn)return f[P++].value},"a"),Se=t(()=>G("OTHER_MODIFIER")??G("ASTERISK"),"f"),de=t(Fn=>{let sn=G(Fn);if(sn!==void 0)return sn;let{type:Un,index:Er}=f[P];throw new TypeError(`Unexpected ${Un} at ${Er}, expected ${Fn}`)},"d"),ae=t(()=>{let Fn="",sn;for(;sn=G("CHAR")??G("ESCAPED_CHAR");)Fn+=sn;return Fn},"T"),Ke=t(Fn=>Fn,"Se"),$e=s.encodePart||Ke,Fe="",Gt=t(Fn=>{Fe+=Fn},"U"),jt=t(()=>{Fe.length&&(y.push(new nH(3,"","",$e(Fe),"",3)),Fe="")},"$"),Pr=t((Fn,sn,Un,Er,vr)=>{let ls=3;switch(vr){case"?":ls=1;break;case"*":ls=0;break;case"+":ls=2;break}if(!sn&&!Un&&ls===3){Gt(Fn);return}if(jt(),!sn&&!Un){if(!Fn)return;y.push(new nH(3,"","",$e(Fn),"",ls));return}let Ni;Un?Un==="*"?Ni=r6e:Ni=Un:Ni=d;let nc=2;Ni===d?(nc=1,Ni=""):Ni===r6e&&(nc=0,Ni="");let bi;if(sn?bi=sn:Un&&(bi=x++),J.has(bi))throw new TypeError(`Duplicate name '${bi}'.`);J.add(bi),y.push(new nH(nc,bi,$e(Fn),Ni,$e(Er),ls))},"V");for(;P<f.length;){let Fn=G("CHAR"),sn=G("NAME"),Un=G("REGEX");if(!sn&&!Un&&(Un=G("ASTERISK")),sn||Un){let vr=Fn??"";s.prefixes.indexOf(vr)===-1&&(Gt(vr),vr=""),jt();let ls=Se();Pr(vr,sn,Un,"",ls);continue}let Er=Fn??G("ESCAPED_CHAR");if(Er){Gt(Er);continue}if(G("OPEN")){let vr=ae(),ls=G("NAME"),Ni=G("REGEX");!ls&&!Ni&&(Ni=G("ASTERISK"));let nc=ae();de("CLOSE");let bi=Se();Pr(vr,ls,Ni,nc,bi);continue}jt(),de("END")}return y}t(Jst,"D");function lT(o){return o.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(lT,"S");function Ust(o){return o&&o.ignoreCase?"ui":"u"}t(Ust,"X");function wer(o,s,f){return Wst(Jst(o,f),s,f)}t(wer,"Z");function iM(o){switch(o){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(iM,"k");function Wst(o,s,f={}){f.delimiter??="/#?",f.prefixes??="./",f.sensitive??=!1,f.strict??=!1,f.end??=!0,f.start??=!0,f.endsWith="";let d=f.start?"^":"";for(let F of o){if(F.type===3){F.modifier===3?d+=lT(F.value):d+=`(?:${lT(F.value)})${iM(F.modifier)}`;continue}s&&s.push(F.name);let J=`[^${lT(f.delimiter)}]+?`,G=F.value;if(F.type===1?G=J:F.type===0&&(G=r6e),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${iM(F.modifier)}`:d+=`((?:${G})${iM(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${lT(F.prefix)}(${G})${lT(F.suffix)})`,d+=iM(F.modifier);continue}d+=`(?:${lT(F.prefix)}`,d+=`((?:${G})(?:`,d+=lT(F.suffix),d+=lT(F.prefix),d+=`(?:${G}))*)${lT(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${lT(f.endsWith)}]|$`,x=`[${lT(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Ust(f));f.strict||(d+=`(?:${x}(?=${y}))?`);let P=!1;if(o.length){let F=o[o.length-1];F.type===3&&F.modifier===3&&(P=f.delimiter.indexOf(F)>-1)}return P||(d+=`(?=${x}|${y})`),new RegExp(d,Ust(f))}t(Wst,"F");var nI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Der={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Per={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Aer(o,s){return o.length?o[0]==="/"?!0:!s||o.length<2?!1:(o[0]=="\\"||o[0]=="{")&&o[1]=="/":!1}t(Aer,"J");function qst(o,s){return o.startsWith(s)?o.substring(s.length,o.length):o}t(qst,"Q");function Ner(o,s){return o.endsWith(s)?o.substr(0,o.length-s.length):o}t(Ner,"Ee");function Vst(o){return!o||o.length<2?!1:o[0]==="["||(o[0]==="\\"||o[0]==="{")&&o[1]==="["}t(Vst,"W");var Hst=["ftp","file","http","https","ws","wss"];function Gst(o){if(!o)return!0;for(let s of Hst)if(o.test(s))return!0;return!1}t(Gst,"N");function Ier(o,s){if(o=qst(o,"#"),s||o==="")return o;let f=new URL("https://example.com");return f.hash=o,f.hash?f.hash.substring(1,f.hash.length):""}t(Ier,"te");function Oer(o,s){if(o=qst(o,"?"),s||o==="")return o;let f=new URL("https://example.com");return f.search=o,f.search?f.search.substring(1,f.search.length):""}t(Oer,"re");function Fer(o,s){return s||o===""?o:Vst(o)?Xst(o):Kst(o)}t(Fer,"ne");function Ler(o,s){if(s||o==="")return o;let f=new URL("https://example.com");return f.password=o,f.password}t(Ler,"se");function Rer(o,s){if(s||o==="")return o;let f=new URL("https://example.com");return f.username=o,f.username}t(Rer,"ie");function Mer(o,s,f){if(f||o==="")return o;if(s&&!Hst.includes(s))return new URL(`${s}:${o}`).pathname;let d=o[0]=="/";return o=new URL(d?o:"/-"+o,"https://example.com").pathname,d||(o=o.substring(2,o.length)),o}t(Mer,"ae");function jer(o,s,f){return Yst(s)===o&&(o=""),f||o===""?o:Zst(o)}t(jer,"oe");function Ber(o,s){return o=Ner(o,":"),s||o===""?o:n6e(o)}t(Ber,"ce");function Yst(o){switch(o){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(Yst,"_");function n6e(o){if(o==="")return o;if(/^[-+.A-Za-z0-9]*$/.test(o))return o.toLowerCase();throw new TypeError(`Invalid protocol '${o}'.`)}t(n6e,"y");function Uer(o){if(o==="")return o;let s=new URL("https://example.com");return s.username=o,s.username}t(Uer,"le");function zer(o){if(o==="")return o;let s=new URL("https://example.com");return s.password=o,s.password}t(zer,"fe");function Kst(o){if(o==="")return o;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(o))throw new TypeError(`Invalid hostname '${o}'`);let s=new URL("https://example.com");return s.hostname=o,s.hostname}t(Kst,"z");function Xst(o){if(o==="")return o;if(/[^0-9a-fA-F[\]:]/g.test(o))throw new TypeError(`Invalid IPv6 hostname '${o}'`);return o.toLowerCase()}t(Xst,"j");function Zst(o){if(o===""||/^[0-9]*$/.test(o)&&parseInt(o)<=65535)return o;throw new TypeError(`Invalid port '${o}'.`)}t(Zst,"K");function $er(o){if(o==="")return o;let s=new URL("https://example.com");return s.pathname=o[0]!=="/"?"/-"+o:o,o[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t($er,"he");function Jer(o){return o===""?o:new URL(`data:${o}`).pathname}t(Jer,"ue");function Wer(o){if(o==="")return o;let s=new URL("https://example.com");return s.search=o,s.search.substring(1,s.search.length)}t(Wer,"de");function qer(o){if(o==="")return o;let s=new URL("https://example.com");return s.hash=o,s.hash.substring(1,s.hash.length)}t(qer,"pe");var Ver=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#p=0;#o=0;#_=0;#u=0;#c=!1;constructor(o){this.#e=o}get result(){return this.#t}parse(){for(this.#n=$st(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#o===0){this.#h(),this.#x()?this.#i(9,1):this.#v()?this.#i(8,1):this.#i(7,0);continue}else if(this.#o===2){this.#m(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#l())this.#_-=1;else continue;if(this.#A()){this.#_+=1;continue}switch(this.#o){case 0:this.#g()&&this.#m(1);break;case 1:if(this.#g()){this.#P();let o=7,s=1;this.#y()?(o=2,s=3):this.#c&&(o=2),this.#i(o,s)}break;case 2:this.#E()?this.#m(3):(this.#k()||this.#v()||this.#x())&&this.#m(5);break;case 3:this.#T()?this.#i(4,1):this.#E()&&this.#i(5,1);break;case 4:this.#E()&&this.#i(5,1);break;case 5:this.#O()?this.#u+=1:this.#w()&&(this.#u-=1),this.#C()&&!this.#u?this.#i(6,1):this.#k()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 6:this.#k()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 7:this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 8:this.#x()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#i(o,s){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#D();break;case 2:break;case 3:this.#t.username=this.#D();break;case 4:this.#t.password=this.#D();break;case 5:this.#t.hostname=this.#D();break;case 6:this.#t.port=this.#D();break;case 7:this.#t.pathname=this.#D();break;case 8:this.#t.search=this.#D();break;case 9:this.#t.hash=this.#D();break;case 10:break}this.#o!==0&&o!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(o)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(o)&&(this.#t.pathname??=this.#c?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&o===9&&(this.#t.search??="")),this.#a(o,s)}#a(o,s){this.#o=o,this.#p=this.#r+s,this.#r+=s,this.#s=0}#h(){this.#r=this.#p,this.#s=0}#m(o){this.#h(),this.#o=o}#f(o){return o<0&&(o=this.#n.length-o),o<this.#n.length?this.#n[o]:this.#n[this.#n.length-1]}#d(o,s){let f=this.#f(o);return f.value===s&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#g(){return this.#d(this.#r,":")}#y(){return this.#d(this.#r+1,"/")&&this.#d(this.#r+2,"/")}#E(){return this.#d(this.#r,"@")}#T(){return this.#d(this.#r,":")}#C(){return this.#d(this.#r,":")}#k(){return this.#d(this.#r,"/")}#v(){if(this.#d(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let o=this.#f(this.#r-1);return o.type!=="NAME"&&o.type!=="REGEX"&&o.type!=="CLOSE"&&o.type!=="ASTERISK"}#x(){return this.#d(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#d(this.#r,"[")}#w(){return this.#d(this.#r,"]")}#D(){let o=this.#n[this.#r],s=this.#f(this.#p).index;return this.#e.substring(s,o.index)}#P(){let o={};Object.assign(o,nI),o.encodePart=n6e;let s=wer(this.#D(),void 0,o);this.#c=Gst(s)}},t6e=["protocol","username","password","hostname","port","pathname","search","hash"],rI="*";function zst(o,s){if(typeof o!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(o,s);return{protocol:f.protocol.substring(0,f.protocol.length-1),username:f.username,password:f.password,hostname:f.hostname,port:f.port,pathname:f.pathname,search:f.search!==""?f.search.substring(1,f.search.length):void 0,hash:f.hash!==""?f.hash.substring(1,f.hash.length):void 0}}t(zst,"ge");function GP(o,s){return s?rH(o):o}t(GP,"b");function tH(o,s,f){let d;if(typeof s.baseURL=="string")try{d=new URL(s.baseURL),s.protocol===void 0&&(o.protocol=GP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(o.username=GP(d.username,f)),!f&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(o.password=GP(d.password,f)),s.protocol===void 0&&s.hostname===void 0&&(o.hostname=GP(d.hostname,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(o.port=GP(d.port,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(o.pathname=GP(d.pathname,f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(o.search=GP(d.search.substring(1,d.search.length),f)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(o.hash=GP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(o.protocol=Ber(s.protocol,f)),typeof s.username=="string"&&(o.username=Rer(s.username,f)),typeof s.password=="string"&&(o.password=Ler(s.password,f)),typeof s.hostname=="string"&&(o.hostname=Fer(s.hostname,f)),typeof s.port=="string"&&(o.port=jer(s.port,o.protocol,f)),typeof s.pathname=="string"){if(o.pathname=s.pathname,d&&!Aer(o.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(o.pathname=GP(d.pathname.substring(0,y+1),f)+o.pathname)}o.pathname=Mer(o.pathname,o.protocol,f)}return typeof s.search=="string"&&(o.search=Oer(s.search,f)),typeof s.hash=="string"&&(o.hash=Ier(s.hash,f)),o}t(tH,"w");function rH(o){return o.replace(/([+*?:{}()\\])/g,"\\$1")}t(rH,"C");function Her(o){return o.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Her,"Oe");function Ger(o,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let f=".*",d=`[^${Her(s.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let P=0;P<o.length;++P){let F=o[P];if(F.type===3){if(F.modifier===3){x+=rH(F.value);continue}x+=`{${rH(F.value)}}${iM(F.modifier)}`;continue}let J=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!s.prefixes.includes(F.prefix)),Se=P>0?o[P-1]:null,de=P<o.length-1?o[P+1]:null;if(!G&&J&&F.type===1&&F.modifier===3&&de&&!de.prefix.length&&!de.suffix.length)if(de.type===3){let ae=de.value.length>0?de.value[0]:"";G=y.test(ae)}else G=!de.hasCustomName();if(!G&&!F.prefix.length&&Se&&Se.type===3){let ae=Se.value[Se.value.length-1];G=s.prefixes.includes(ae)}G&&(x+="{"),x+=rH(F.prefix),J&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?J||(x+=`(${d})`):F.type===0&&(!J&&(!Se||Se.type===3||Se.modifier!==3||G||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&J&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=rH(F.suffix),G&&(x+="}"),F.modifier!==3&&(x+=iM(F.modifier))}return x}t(Ger,"ke");var Qst=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#p=!1;constructor(o={},s,f){try{let d;if(typeof s=="string"?d=s:f=s,typeof o=="string"){let F=new Ver(o);if(F.parse(),o=F.result,d===void 0&&typeof o.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");o.baseURL=d}else{if(!o||typeof o!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(d)throw new TypeError("parameter 1 is not of type 'string'.")}typeof f>"u"&&(f={ignoreCase:!1});let y={ignoreCase:f.ignoreCase===!0},x={pathname:rI,protocol:rI,username:rI,password:rI,hostname:rI,port:rI,search:rI,hash:rI};this.#e=tH(x,o,!0),Yst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let P;for(P of t6e){if(!(P in this.#e))continue;let F={},J=this.#e[P];switch(this.#t[P]=[],P){case"protocol":Object.assign(F,nI),F.encodePart=n6e;break;case"username":Object.assign(F,nI),F.encodePart=Uer;break;case"password":Object.assign(F,nI),F.encodePart=zer;break;case"hostname":Object.assign(F,Der),Vst(J)?F.encodePart=Xst:F.encodePart=Kst;break;case"port":Object.assign(F,nI),F.encodePart=Zst;break;case"pathname":Gst(this.#n.protocol)?(Object.assign(F,Per,y),F.encodePart=$er):(Object.assign(F,nI,y),F.encodePart=Jer);break;case"search":Object.assign(F,nI,y),F.encodePart=Wer;break;case"hash":Object.assign(F,nI,y),F.encodePart=qer;break}try{this.#s[P]=Jst(J,F),this.#n[P]=Wst(this.#s[P],this.#t[P],F),this.#r[P]=Ger(this.#s[P],F),this.#p=this.#p||this.#s[P].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${P} pattern '${this.#e[P]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(o={},s){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof o!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof o>"u")return!1;try{typeof o=="object"?f=tH(f,o,!1):f=tH(f,zst(o,s),!1)}catch{return!1}let d;for(d of t6e)if(!this.#n[d].exec(f[d]))return!1;return!0}exec(o={},s){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof o!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof o>"u")return;try{typeof o=="object"?f=tH(f,o,!1):f=tH(f,zst(o,s),!1)}catch{return null}let d={};s?d.inputs=[o,s]:d.inputs=[o];let y;for(y of t6e){let x=this.#n[y].exec(f[y]);if(!x)return null;let P={};for(let[F,J]of this.#t[y].entries())if(typeof J=="string"||typeof J=="number"){let G=x[F+1];P[J]=G}d[y]={input:f[y]??"",groups:P}}return d}static compareComponent(o,s,f){let d=t((F,J)=>{for(let G of["type","modifier","prefix","value","suffix"]){if(F[G]<J[G])return-1;if(F[G]!==J[G])return 1}return 0},"o"),y=new nH(3,"","","","",3),x=new nH(0,"","","","",3),P=t((F,J)=>{let G=0;for(;G<Math.min(F.length,J.length);++G){let Se=d(F[G],J[G]);if(Se)return Se}return F.length===J.length?0:d(F[G]??y,J[G]??y)},"s");return!s.#r[o]&&!f.#r[o]?0:s.#r[o]&&!f.#r[o]?P(s.#s[o],[x]):!s.#r[o]&&f.#r[o]?P([x],f.#s[o]):P(s.#s[o],f.#s[o])}get protocol(){return this.#r.protocol}get username(){return this.#r.username}get password(){return this.#r.password}get hostname(){return this.#r.hostname}get port(){return this.#r.port}get pathname(){return this.#r.pathname}get search(){return this.#r.search}get hash(){return this.#r.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=Qst);import{AssertionError as Yer}from"node:assert";function YP(o,s){if(o===!1)throw new Yer({message:s})}t(YP,"assert");var Ko;(function(o){o.Object="Object",o.Property="Property",o.Array="Array",o.Literal="Literal",o.TemplateString="TemplateString",o.Identifier="Identifier",o.FunctionCall="FunctionCall",o.Raw="Raw"})(Ko||(Ko={}));function sM(o){return o.type===Ko.Object}t(sM,"isAstObject");function KP(o){return o.type===Ko.Property}t(KP,"isAstProperty");function eat(o){return o.type===Ko.Array}t(eat,"isAstArray");function aM(o){return o.type===Ko.Literal}t(aM,"isAstLiteral");function iI(o){if(o===void 0)throw new Error("Node is undefined");if(!sM(o))throw new Error("Node is not object")}t(iI,"assertAstObject");import{findNodeAtLocation as Ker,getNodeValue as Xer,printParseErrorCode as Zer,visit as Qer}from"jsonc-parser";var etr={DEFAULT:{allowTrailingComma:!1}};function iH(o,s=[],f=etr.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(J){d.type==="property"&&(d.length=J-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function x(J){return d.children?.push(J),J}t(x,"onValue"),Qer(o,{onObjectBegin:t((J,G,Se)=>{d=x({type:"object",offset:J,length:-1,line:G+1,column:Se+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((J,G,Se,de,ae)=>{d=x({type:"property",offset:G,length:-1,line:de+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:J,offset:G,length:Se,line:de,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((J,G)=>{y(J+G),d.length=J+G-d.offset,d=d.parent,y(J+G)},"onObjectEnd"),onArrayBegin:t((J,G,Se,de)=>{d=x({type:"array",offset:J,length:-1,line:Se+1,column:de+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((J,G)=>{d.length=J+G-d.offset,d=d.parent,y(J+G)},"onArrayEnd"),onLiteralValue:t((J,G,Se,de,ae)=>{x({type:ttr(J),offset:G,length:Se,line:de+1,column:ae+1,parent:d,value:J}),y(G+Se)},"onLiteralValue"),onSeparator:t((J,G)=>{d.type==="property"&&(J===":"?d.colonOffset=G:J===","&&y(G))},"onSeparator"),onError:t((J,G,Se,de,ae)=>{s.push({error:J,offset:G,length:Se,line:de+1,column:ae+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(iH,"parse");function ttr(o){switch(typeof o){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(o){if(Array.isArray(o))return"array"}else return"null";return"object"}default:return"null"}}t(ttr,"getNodeType");function i6e(o,s){return Ker(o,s)}t(i6e,"findNodeAtLocation");function sH(o){return Xer(o)}t(sH,"getNodeValue");function tat(o){return Zer(o)}t(tat,"printParseErrorCode");var aH=class{static{t(this,"AstAdapter")}parse(s){let d=iH(s,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,f){switch(s.type){case"object":return this.createObject(s,f);case"array":return this.createArray(s,f);case"property":return this.createProperty(s,f);case"string":return this.createLiteral(s,f);case"number":return this.createLiteral(s,f);case"boolean":return this.createLiteral(s,f);case"null":return this.createLiteral(s,f)}}createLiteral(s,f){return{type:Ko.Literal,location:{line:s.line,column:s.column},parent:f,value:s.type==="null"?null:s.value}}createObject(s,f){let d={type:Ko.Object,children:[],parent:f,location:{line:s.line,column:s.column}};return s.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(s,f){YP(s.children?.length===2,"Invalid property node");let d={type:Ko.Property,location:{line:s.line,column:s.column},parent:f,name:null,value:null};return d.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Ko.Identifier,parent:d},d.value=this.parseNode(s.children[1],d),d}createArray(s,f){let d={type:Ko.Array,location:{line:s.line,column:s.column},parent:f,children:[]};return s.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var uT={createLiteral:t((o,s)=>({type:Ko.Literal,parent:s,value:o}),"createLiteral"),createTemplateString:t((o,s)=>({type:Ko.TemplateString,parent:s,value:o}),"createTemplateString"),createIdentifier:t((o,s)=>({type:Ko.Identifier,value:o,parent:s}),"createIdentifier"),createProperty:t((o,s,f)=>{let d={type:Ko.Property,parent:f,name:null,value:s};return d.name={value:o,type:Ko.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((o,s)=>{let f={type:Ko.Array,parent:s,children:[]};for(let d of o)f.children.push(uT.createLiteral(d,f));return f},"createArrayOfLiterals")};var rtr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,oH=class{static{t(this,"SourceGenerator")}generate(s){let f=[];return this.generateSource(f,s),f.join("")}generateSource(s,f){switch(f.type){case Ko.Array:return this.generateArray(s,f);case Ko.Object:return this.generateObject(s,f);case Ko.Property:return this.generateProperty(s,f);case Ko.Literal:return this.generateLiteral(s,f);case Ko.FunctionCall:return this.generateFunctionCall(s,f);case Ko.Identifier:return this.generateIdentifier(s,f);case Ko.Raw:return this.generateRaw(s,f);case Ko.TemplateString:return this.generateTemplateString(s,f)}}generateArray(s,f){s.push("["),f.children.map(d=>{this.generateSource(s,d),s.push(",")}),s.push("]")}generateObject(s,f){s.push("{"),f.children.forEach(d=>{this.generateSource(s,d),s.push(",")}),s.push("}")}generateProperty(s,f){this.generateIdentifier(s,f.name),s.push(":"),this.generateSource(s,f.value)}generateFunctionCall(s,f){s.push(f.name.value),s.push("("),f.children.forEach((d,y,x)=>{this.generateSource(s,d),y<x.length&&s.push(",")}),s.push(")")}generateRaw(s,f){s.push(f.value)}generateTemplateString(s,f){s.push("`"),s.push(f.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,f){if(f.value===null)return s.push("null");switch(typeof f.value){case"number":case"boolean":return s.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return s.push(`${y}`)}}}generateIdentifier(s,f){let d=rtr.test(f.value)?f.value:`'${f.value}'`;s.push(d)}};import ntr from"node:fs/promises";import{parse as itr}from"@swc/core";var rat=t(async o=>{let s=new Set;try{let f=await ntr.readFile(o,"utf-8");(await itr(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?s.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?s.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&s.add(y.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var nat={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var s6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var iat={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var a6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var o6e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var ult=Dp(ole(),1),flt=Dp(llt(),1);var fle=class o{static{t(this,"JsonValidator")}static#e=new o;static get instance(){return o.#e}ajv;constructor(){this.ajv=new ult.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,flt.default)(this.ajv,{mode:"fast"})}addSchema(s,f){this.ajv.addSchema(s,f)}compile(s){let f=this.ajv.compile(s);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(s,f){let d=[];return s?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let x={details:{}},P=y.instancePath.split("/");if(P.length>2){let J=P[1],G=P[2]?parseInt(P[2],10):0,Se=P[3],de=Number.isNaN(G)?void 0:f[J][G][Se];x={details:{property:J,index:G,field:Se,fieldValue:de}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let J=y.instancePath.split("/"),G=J[J.length-1];y.message=`Value of property '${G}' must be '${y.params.type}'`}let F=Object.assign(y,x);d.push(F)}),d}};var dI=fle.instance;dI.addSchema(a6e,"route-configuration.schema.json");dI.addSchema(iat,"policy-configuration.schema.json");dI.addSchema(s6e,"policies.schema.json");dI.addSchema(o6e,"open-api-route-configuration.schema.json");dI.addSchema(nat,"fragments.schema.json");var B6r=dI.compile(a6e),_lt=dI.compile(o6e),TIe=dI.compile(s6e);var _le=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=TIe(s),this.results}};var ple=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=_lt(s),this.results}};import dcr from"node:path";var xIe=/\$import\((.*)\)/,dle=/\$env\((.*?)\)/g;var tA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,f,d,y){super(s),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},pcr=t(o=>{let s=[],f=o;for(;f.parent;)s.push(f),f=f.parent;return s.reverse()},"invertTree"),mI=t((o,s)=>{if(!o)return!1;let f=pcr(o);return s.split("/").every((x,P)=>{let F=f[P];return F?x==="*"||KP(F)&&F.name.value===x?!0:x==="{}"?F.type===Ko.Object:x==="[]"?F.type===Ko.Array:!1:!1})},"testPosition");var mle=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),sM(s)?s.children.forEach(f=>{this.visitor(f)}):eat(s)?s.children.forEach(f=>{this.visitor(f)}):KP(s)&&this.visitor(s.value)}},plt=t((o,s,f)=>d=>{if(!KP(d)||!aM(d.value)||typeof d.value.value!="string")return;if(!o.some(x=>mI(d,x))){dle.test(d.value.value)&&s.push(new tA("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=new RegExp(dle).exec(d.value.value);if(y?.length===2&&y[0]===d.value.value){let x={type:Ko.Raw,parent:null,value:`environment["${y[1]}"]`};d.value=x}else{let x=d.value.value.replaceAll(new RegExp(dle),(P,F)=>`\${environment["${F}"] ? environment["${F}"] : ""}`);x!==d.value.value&&(d.value=uT.createTemplateString(x,d))}},"getEnvStatementTransformer");var jH="config/routes.json",mcr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],hcr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],dlt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],gcr="handler/{}/options/{}/rewritePattern",ycr="handler/{}/options/{}/baseUrl",hle=class extends mle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let f=this.addedImports.get(s);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let s=[];return this.addedImports.forEach((f,d)=>{s.push({name:f,path:d})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!KP(s)||!aM(s.value)||typeof s.value.value!="string")&&mI(s,gcr)){if(!s.parent||!sM(s.parent)){this.errors.push(new tA("Invalid node, expected object",jH,s.parent?s.parent.location:s.location,void 0));return}let f=s.value.value,d={type:Ko.Raw,parent:null,value:mlt(f)},y=uT.createProperty("__rewriteFunction",d,s);s.parent.children.push(y)}}rewriteForwardFunction(s){if(!(!KP(s)||!aM(s.value)||typeof s.value.value!="string")&&mI(s,ycr)){if(!s.parent||!sM(s.parent)){this.errors.push(new tA("Invalid node, expected object",jH,s.parent?s.parent.location:s.location,void 0));return}let f=s.value.value,d={type:Ko.Raw,parent:null,value:mlt(f)},y=uT.createProperty("__rewriteFunction",d,s);s.parent.children.push(y)}}replaceImportStatements(s){if(!KP(s)||!aM(s.value))return;let f=s.value.value;if(typeof f!="string")return;if(!hcr.some(F=>mI(s,F))&&!dlt.some(F=>mI(s,F))){if(xIe.test(f)){if(s.name.value==="$ref")return;this.errors.push(new tA("An $import() statement is not expected at this location.",jH,s.location,f))}return}let d=xIe.exec(f);if(dlt.some(F=>mI(s,F))&&!d)return;if(!d){this.errors.push(new tA("Invalid $import() statement",jH,s.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=dcr.posix.join("..",y));let x=this.getImportName(y),P={type:Ko.Identifier,parent:s.parent,value:x};s.value=P}replaceEnvStatements=plt(mcr,this.errors,jH)};function mlt(o){return`(request, context) => {
|
|
576
576
|
const { params, url, query, method, headers } = request;
|
|
577
577
|
const { host, hostname, origin, pathname, port, search } = new URL(url);
|
|
578
578
|
const e = encodeURIComponent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/core",
|
|
3
|
-
"version": "6.65.
|
|
3
|
+
"version": "6.65.1",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"source-map": "^0.7.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@zuplo/graphql": "6.65.
|
|
44
|
-
"@zuplo/otel": "6.65.
|
|
45
|
-
"@zuplo/runtime": "6.65.
|
|
43
|
+
"@zuplo/graphql": "6.65.1",
|
|
44
|
+
"@zuplo/otel": "6.65.1",
|
|
45
|
+
"@zuplo/runtime": "6.65.1",
|
|
46
46
|
"deno": "2.3.1"
|
|
47
47
|
}
|
|
48
48
|
}
|