@zuplo/cli 6.73.13 → 6.73.14
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/node_modules/@zuplo/core/customer.cli.minified.js +1 -1
- package/node_modules/@zuplo/core/index.minified.js +1 -1
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-7Z5GGYF5.js → chunk-2MF7LQVX.js} +126 -126
- package/node_modules/@zuplo/runtime/out/esm/chunk-2MF7LQVX.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +118 -3
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +6 -6
- package/node_modules/@zuplo/runtime/out/esm/chunk-7Z5GGYF5.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-7Z5GGYF5.js.LEGAL.txt → chunk-2MF7LQVX.js.LEGAL.txt} +0 -0
|
@@ -572,7 +572,7 @@ globstar while`,s,de,o,se,Ze),this.matchOne(s.slice(de),o.slice(se),f))return th
|
|
|
572
572
|
`),stderr:E.join(`
|
|
573
573
|
`),exitCode:A},"Tar process logs")}}t(QXt,"tarFolder");async function eZt({tarFilePath:s,outputDir:o,logger:f}){let d=[],y=[],E;try{await new Promise((A,F)=>{let W=oit("sh",["-c",`tar -xvf ${s} -C ${o};`]);W.stdout.on("data",G=>{let be=G.toString().trim();be.length>0&&d.push(be.trim())}),W.stderr.on("data",G=>{let be=G.toString().trim();be.length>0&&y.push(be.trim())}),W.on("close",G=>{E=G,G===0?A():F(new Error(`tar process exited with code ${G}`))}),W.on("error",G=>{F(G)})})}catch(A){throw new Error("Failed to untar file",{cause:A})}finally{f.info({stdout:d.join(`
|
|
574
574
|
`),stderr:y.join(`
|
|
575
|
-
`),exitCode:E},"Untar process logs")}}t(eZt,"untarFile");async function tZt(s){if(await eAe(s))return await XN.rm(s,{recursive:!0})}t(tZt,"deleteFolder");var eu=tAe;var plt=Hp(Nst(),1);var Ist=["ai-gateway-model-routing-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"];var WV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,E){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=E}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Der=/[$_\p{ID_Start}]/u,Per=/[$_\u200C\u200D\p{ID_Continue}]/u,LAe=".*";function Aer(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(Aer,"Re");function Lst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],E=t(function(A){if(!o)throw new TypeError(A);f.push({type:"INVALID_CHAR",index:d,value:s[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:s[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:s[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:s[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:s[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:s[d++]});continue}if(y===":"){let A="",F=d+1;for(;F<s.length;){let W=s.substr(F,1);if(F===d+1&&Der.test(W)||F!==d+1&&Per.test(W)){A+=s[F++];continue}break}if(!A){E(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:A}),d=F;continue}if(y==="("){let A=1,F="",W=d+1,G=!1;if(s[W]==="?"){E(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!Aer(s[W],!1)){E(`Invalid character '${s[W]}' at ${W}.`),G=!0;break}if(s[W]==="\\"){F+=s[W++]+s[W++];continue}if(s[W]===")"){if(A--,A===0){W++;break}}else if(s[W]==="("&&(A++,s[W+1]!=="?")){E(`Capturing groups are not allowed at ${W}`),G=!0;break}F+=s[W++]}if(G)continue;if(A){E(`Unbalanced pattern at ${d}`);continue}if(!F){E(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=W;continue}f.push({type:"CHAR",index:d,value:s[d++]})}return f.push({type:"END",index:d,value:""}),f}t(Lst,"v");function Rst(s,o={}){let f=Lst(s);o.delimiter??="/#?",o.prefixes??="./";let d=`[^${fT(o.delimiter)}]+?`,y=[],E=0,A=0,F="",W=new Set,G=t(wn=>{if(A<f.length&&f[A].type===wn)return f[A++].value},"a"),be=t(()=>G("OTHER_MODIFIER")??G("ASTERISK"),"f"),de=t(wn=>{let sn=G(wn);if(sn!==void 0)return sn;let{type:Jn,index:kr}=f[A];throw new TypeError(`Unexpected ${Jn} at ${kr}, expected ${wn}`)},"d"),se=t(()=>{let wn="",sn;for(;sn=G("CHAR")??G("ESCAPED_CHAR");)wn+=sn;return wn},"T"),Ze=t(wn=>wn,"Se"),Ue=o.encodePart||Ze,je="",Vt=t(wn=>{je+=wn},"U"),Ut=t(()=>{je.length&&(y.push(new WV(3,"","",Ue(je),"",3)),je="")},"$"),Ir=t((wn,sn,Jn,kr,yr)=>{let xs=3;switch(yr){case"?":xs=1;break;case"*":xs=0;break;case"+":xs=2;break}if(!sn&&!Jn&&xs===3){Vt(wn);return}if(Ut(),!sn&&!Jn){if(!wn)return;y.push(new WV(3,"","",Ue(wn),"",xs));return}let bi;Jn?Jn==="*"?bi=LAe:bi=Jn:bi=d;let fc=2;bi===d?(fc=1,bi=""):bi===LAe&&(fc=0,bi="");let Ci;if(sn?Ci=sn:Jn&&(Ci=E++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new WV(fc,Ci,Ue(wn),bi,Ue(kr),xs))},"V");for(;A<f.length;){let wn=G("CHAR"),sn=G("NAME"),Jn=G("REGEX");if(!sn&&!Jn&&(Jn=G("ASTERISK")),sn||Jn){let yr=wn??"";o.prefixes.indexOf(yr)===-1&&(Vt(yr),yr=""),Ut();let xs=be();Ir(yr,sn,Jn,"",xs);continue}let kr=wn??G("ESCAPED_CHAR");if(kr){Vt(kr);continue}if(G("OPEN")){let yr=se(),xs=G("NAME"),bi=G("REGEX");!xs&&!bi&&(bi=G("ASTERISK"));let fc=se();de("CLOSE");let Ci=be();Ir(yr,xs,bi,fc,Ci);continue}Ut(),de("END")}return y}t(Rst,"D");function fT(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(fT,"S");function Ost(s){return s&&s.ignoreCase?"ui":"u"}t(Ost,"X");function Ner(s,o,f){return Mst(Rst(s,f),o,f)}t(Ner,"Z");function X9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(X9,"k");function Mst(s,o,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 s){if(F.type===3){F.modifier===3?d+=fT(F.value):d+=`(?:${fT(F.value)})${X9(F.modifier)}`;continue}o&&o.push(F.name);let W=`[^${fT(f.delimiter)}]+?`,G=F.value;if(F.type===1?G=W:F.type===0&&(G=LAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${X9(F.modifier)}`:d+=`((?:${G})${X9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${fT(F.prefix)}(${G})${fT(F.suffix)})`,d+=X9(F.modifier);continue}d+=`(?:${fT(F.prefix)}`,d+=`((?:${G})(?:`,d+=fT(F.suffix),d+=fT(F.prefix),d+=`(?:${G}))*)${fT(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${fT(f.endsWith)}]|$`,E=`[${fT(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${E}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Ost(f));f.strict||(d+=`(?:${E}(?=${y}))?`);let A=!1;if(s.length){let F=s[s.length-1];F.type===3&&F.modifier===3&&(A=f.delimiter.indexOf(F)>-1)}return A||(d+=`(?=${E}|${y})`),new RegExp(d,Ost(f))}t(Mst,"F");var tI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Ier={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Oer={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Fer(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(Fer,"J");function jst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(jst,"Q");function Ler(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t(Ler,"Ee");function Bst(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t(Bst,"W");var Ust=["ftp","file","http","https","ws","wss"];function zst(s){if(!s)return!0;for(let o of Ust)if(s.test(o))return!0;return!1}t(zst,"N");function Rer(s,o){if(s=jst(s,"#"),o||s==="")return s;let f=new URL("https://example.com");return f.hash=s,f.hash?f.hash.substring(1,f.hash.length):""}t(Rer,"te");function Mer(s,o){if(s=jst(s,"?"),o||s==="")return s;let f=new URL("https://example.com");return f.search=s,f.search?f.search.substring(1,f.search.length):""}t(Mer,"re");function jer(s,o){return o||s===""?s:Bst(s)?Wst(s):Jst(s)}t(jer,"ne");function Ber(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(Ber,"se");function Uer(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(Uer,"ie");function zer(s,o,f){if(f||s==="")return s;if(o&&!Ust.includes(o))return new URL(`${o}:${s}`).pathname;let d=s[0]=="/";return s=new URL(d?s:"/-"+s,"https://example.com").pathname,d||(s=s.substring(2,s.length)),s}t(zer,"ae");function $er(s,o,f){return $st(o)===s&&(s=""),f||s===""?s:qst(s)}t($er,"oe");function Jer(s,o){return s=Ler(s,":"),o||s===""?s:RAe(s)}t(Jer,"ce");function $st(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t($st,"_");function RAe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(RAe,"y");function Wer(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(Wer,"le");function qer(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(qer,"fe");function Jst(s){if(s==="")return s;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(s))throw new TypeError(`Invalid hostname '${s}'`);let o=new URL("https://example.com");return o.hostname=s,o.hostname}t(Jst,"z");function Wst(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(Wst,"j");function qst(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(qst,"K");function Ver(s){if(s==="")return s;let o=new URL("https://example.com");return o.pathname=s[0]!=="/"?"/-"+s:s,s[0]!=="/"?o.pathname.substring(2,o.pathname.length):o.pathname}t(Ver,"he");function Her(s){return s===""?s:new URL(`data:${s}`).pathname}t(Her,"ue");function Ger(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(Ger,"de");function Yer(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(Yer,"pe");var Ker=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#m=0;#c=0;#u=0;#f=0;#p=!1;constructor(s){this.#e=s}get result(){return this.#t}parse(){for(this.#n=Lst(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#c===0){this.#o(),this.#g()?this.#a(9,1):this.#E()?this.#a(8,1):this.#a(7,0);continue}else if(this.#c===2){this.#h(5);continue}this.#a(10,0);break}if(this.#u>0)if(this.#l())this.#u-=1;else continue;if(this.#A()){this.#u+=1;continue}switch(this.#c){case 0:this.#y()&&this.#h(1);break;case 1:if(this.#y()){this.#D();let s=7,o=1;this.#b()?(s=2,o=3):this.#p&&(s=2),this.#a(s,o)}break;case 2:this.#v()?this.#h(3):(this.#S()||this.#E()||this.#g())&&this.#h(5);break;case 3:this.#C()?this.#a(4,1):this.#v()&&this.#a(5,1);break;case 4:this.#v()&&this.#a(5,1);break;case 5:this.#O()?this.#f+=1:this.#N()&&(this.#f-=1),this.#k()&&!this.#f?this.#a(6,1):this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 6:this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 7:this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 8:this.#g()&&this.#a(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#a(s,o){switch(this.#c){case 0:break;case 1:this.#t.protocol=this.#w();break;case 2:break;case 3:this.#t.username=this.#w();break;case 4:this.#t.password=this.#w();break;case 5:this.#t.hostname=this.#w();break;case 6:this.#t.port=this.#w();break;case 7:this.#t.pathname=this.#w();break;case 8:this.#t.search=this.#w();break;case 9:this.#t.hash=this.#w();break;case 10:break}this.#c!==0&&s!==10&&([1,2,3,4].includes(this.#c)&&[6,7,8,9].includes(s)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#c)&&[8,9].includes(s)&&(this.#t.pathname??=this.#p?"/":""),[1,2,3,4,5,6,7].includes(this.#c)&&s===9&&(this.#t.search??="")),this.#i(s,o)}#i(s,o){this.#c=s,this.#m=this.#r+o,this.#r+=o,this.#s=0}#o(){this.#r=this.#m,this.#s=0}#h(s){this.#o(),this.#c=s}#d(s){return s<0&&(s=this.#n.length-s),s<this.#n.length?this.#n[s]:this.#n[this.#n.length-1]}#_(s,o){let f=this.#d(s);return f.value===o&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#y(){return this.#_(this.#r,":")}#b(){return this.#_(this.#r+1,"/")&&this.#_(this.#r+2,"/")}#v(){return this.#_(this.#r,"@")}#C(){return this.#_(this.#r,":")}#k(){return this.#_(this.#r,":")}#S(){return this.#_(this.#r,"/")}#E(){if(this.#_(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let s=this.#d(this.#r-1);return s.type!=="NAME"&&s.type!=="REGEX"&&s.type!=="CLOSE"&&s.type!=="ASTERISK"}#g(){return this.#_(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#_(this.#r,"[")}#N(){return this.#_(this.#r,"]")}#w(){let s=this.#n[this.#r],o=this.#d(this.#m).index;return this.#e.substring(o,s.index)}#D(){let s={};Object.assign(s,tI),s.encodePart=RAe;let o=Ner(this.#w(),void 0,s);this.#p=zst(o)}},FAe=["protocol","username","password","hostname","port","pathname","search","hash"],eI="*";function Fst(s,o){if(typeof s!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(s,o);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(Fst,"ge");function qP(s,o){return o?JV(s):s}t(qP,"b");function $V(s,o,f){let d;if(typeof o.baseURL=="string")try{d=new URL(o.baseURL),o.protocol===void 0&&(s.protocol=qP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&(s.username=qP(d.username,f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&o.password===void 0&&(s.password=qP(d.password,f)),o.protocol===void 0&&o.hostname===void 0&&(s.hostname=qP(d.hostname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&(s.port=qP(d.port,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&(s.pathname=qP(d.pathname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&(s.search=qP(d.search.substring(1,d.search.length),f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&o.hash===void 0&&(s.hash=qP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${o.baseURL}'.`)}if(typeof o.protocol=="string"&&(s.protocol=Jer(o.protocol,f)),typeof o.username=="string"&&(s.username=Uer(o.username,f)),typeof o.password=="string"&&(s.password=Ber(o.password,f)),typeof o.hostname=="string"&&(s.hostname=jer(o.hostname,f)),typeof o.port=="string"&&(s.port=$er(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!Fer(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=qP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=zer(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=Mer(o.search,f)),typeof o.hash=="string"&&(s.hash=Rer(o.hash,f)),s}t($V,"w");function JV(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(JV,"C");function Xer(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Xer,"Oe");function Zer(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${Xer(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,E="";for(let A=0;A<s.length;++A){let F=s[A];if(F.type===3){if(F.modifier===3){E+=JV(F.value);continue}E+=`{${JV(F.value)}}${X9(F.modifier)}`;continue}let W=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!o.prefixes.includes(F.prefix)),be=A>0?s[A-1]:null,de=A<s.length-1?s[A+1]:null;if(!G&&W&&F.type===1&&F.modifier===3&&de&&!de.prefix.length&&!de.suffix.length)if(de.type===3){let se=de.value.length>0?de.value[0]:"";G=y.test(se)}else G=!de.hasCustomName();if(!G&&!F.prefix.length&&be&&be.type===3){let se=be.value[be.value.length-1];G=o.prefixes.includes(se)}G&&(E+="{"),E+=JV(F.prefix),W&&(E+=`:${F.name}`),F.type===2?E+=`(${F.value})`:F.type===1?W||(E+=`(${d})`):F.type===0&&(!W&&(!be||be.type===3||be.modifier!==3||G||F.prefix!=="")?E+="*":E+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(E+="\\"),E+=JV(F.suffix),G&&(E+="}"),F.modifier!==3&&(E+=X9(F.modifier))}return E}t(Zer,"ke");var Vst=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#m=!1;constructor(s={},o,f){try{let d;if(typeof o=="string"?d=o:f=o,typeof s=="string"){let F=new Ker(s);if(F.parse(),s=F.result,d===void 0&&typeof s.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");s.baseURL=d}else{if(!s||typeof s!="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},E={pathname:eI,protocol:eI,username:eI,password:eI,hostname:eI,port:eI,search:eI,hash:eI};this.#e=$V(E,s,!0),$st(this.#e.protocol)===this.#e.port&&(this.#e.port="");let A;for(A of FAe){if(!(A in this.#e))continue;let F={},W=this.#e[A];switch(this.#t[A]=[],A){case"protocol":Object.assign(F,tI),F.encodePart=RAe;break;case"username":Object.assign(F,tI),F.encodePart=Wer;break;case"password":Object.assign(F,tI),F.encodePart=qer;break;case"hostname":Object.assign(F,Ier),Bst(W)?F.encodePart=Wst:F.encodePart=Jst;break;case"port":Object.assign(F,tI),F.encodePart=qst;break;case"pathname":zst(this.#n.protocol)?(Object.assign(F,Oer,y),F.encodePart=Ver):(Object.assign(F,tI,y),F.encodePart=Her);break;case"search":Object.assign(F,tI,y),F.encodePart=Ger;break;case"hash":Object.assign(F,tI,y),F.encodePart=Yer;break}try{this.#s[A]=Rst(W,F),this.#n[A]=Mst(this.#s[A],this.#t[A],F),this.#r[A]=Zer(this.#s[A],F),this.#m=this.#m||this.#s[A].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${A} pattern '${this.#e[A]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return!1;try{typeof s=="object"?f=$V(f,s,!1):f=$V(f,Fst(s,o),!1)}catch{return!1}let d;for(d of FAe)if(!this.#n[d].exec(f[d]))return!1;return!0}exec(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return;try{typeof s=="object"?f=$V(f,s,!1):f=$V(f,Fst(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of FAe){let E=this.#n[y].exec(f[y]);if(!E)return null;let A={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let G=E[F+1];A[W]=G}d[y]={input:f[y]??"",groups:A}}return d}static compareComponent(s,o,f){let d=t((F,W)=>{for(let G of["type","modifier","prefix","value","suffix"]){if(F[G]<W[G])return-1;if(F[G]!==W[G])return 1}return 0},"o"),y=new WV(3,"","","","",3),E=new WV(0,"","","","",3),A=t((F,W)=>{let G=0;for(;G<Math.min(F.length,W.length);++G){let be=d(F[G],W[G]);if(be)return be}return F.length===W.length?0:d(F[G]??y,W[G]??y)},"s");return!o.#r[s]&&!f.#r[s]?0:o.#r[s]&&!f.#r[s]?A(o.#s[s],[E]):!o.#r[s]&&f.#r[s]?A([E],f.#s[s]):A(o.#s[s],f.#s[s])}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.#m}};globalThis.URLPattern||(globalThis.URLPattern=Vst);import{AssertionError as Qer}from"node:assert";function VP(s,o){if(s===!1)throw new Qer({message:o})}t(VP,"assert");var Wo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(Wo||(Wo={}));function Z9(s){return s.type===Wo.Object}t(Z9,"isAstObject");function HP(s){return s.type===Wo.Property}t(HP,"isAstProperty");function MAe(s){return s.type===Wo.Array}t(MAe,"isAstArray");function SO(s){return s.type===Wo.Literal}t(SO,"isAstLiteral");function rI(s){if(s===void 0)throw new Error("Node is undefined");if(!Z9(s))throw new Error("Node is not object")}t(rI,"assertAstObject");import{findNodeAtLocation as etr,getNodeValue as ttr,printParseErrorCode as rtr,visit as ntr}from"jsonc-parser";var itr={DEFAULT:{allowTrailingComma:!1}};function qV(s,o=[],f=itr.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(W){d.type==="property"&&(d.length=W-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function E(W){return d.children?.push(W),W}t(E,"onValue"),ntr(s,{onObjectBegin:t((W,G,be)=>{d=E({type:"object",offset:W,length:-1,line:G+1,column:be+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,G,be,de,se)=>{d=E({type:"property",offset:G,length:-1,line:de+1,column:se+1,parent:d,children:[]}),d.children?.push({type:"string",value:W,offset:G,length:be,line:de,column:se,parent:d})},"onObjectProperty"),onObjectEnd:t((W,G)=>{y(W+G),d.length=W+G-d.offset,d=d.parent,y(W+G)},"onObjectEnd"),onArrayBegin:t((W,G,be,de)=>{d=E({type:"array",offset:W,length:-1,line:be+1,column:de+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((W,G)=>{d.length=W+G-d.offset,d=d.parent,y(W+G)},"onArrayEnd"),onLiteralValue:t((W,G,be,de,se)=>{E({type:str(W),offset:G,length:be,line:de+1,column:se+1,parent:d,value:W}),y(G+be)},"onLiteralValue"),onSeparator:t((W,G)=>{d.type==="property"&&(W===":"?d.colonOffset=G:W===","&&y(G))},"onSeparator"),onError:t((W,G,be,de,se)=>{o.push({error:W,offset:G,length:be,line:de+1,column:se+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(qV,"parse");function str(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(str,"getNodeType");function jAe(s,o){return etr(s,o)}t(jAe,"findNodeAtLocation");function VV(s){return ttr(s)}t(VV,"getNodeValue");function Hst(s){return rtr(s)}t(Hst,"printParseErrorCode");var HV=class{static{t(this,"AstAdapter")}parse(o){let d=qV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:Wo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:Wo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){VP(o.children?.length===2,"Invalid property node");let d={type:Wo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:Wo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:Wo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var DS={createLiteral:t((s,o)=>({type:Wo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:Wo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:Wo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:Wo.Property,parent:f,name:null,value:o};return d.name={value:s,type:Wo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:Wo.Array,parent:o,children:[]};for(let d of s)f.children.push(DS.createLiteral(d,f));return f},"createArrayOfLiterals")};var atr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,GV=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case Wo.Array:return this.generateArray(o,f);case Wo.Object:return this.generateObject(o,f);case Wo.Property:return this.generateProperty(o,f);case Wo.Literal:return this.generateLiteral(o,f);case Wo.FunctionCall:return this.generateFunctionCall(o,f);case Wo.Identifier:return this.generateIdentifier(o,f);case Wo.Raw:return this.generateRaw(o,f);case Wo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,E)=>{this.generateSource(o,d),y<E.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=atr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import otr from"node:fs/promises";import{parse as ctr}from"@swc/core";var Gst=t(async s=>{let o=new Set;try{let f=await otr.readFile(s,"utf-8");(await ctr(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"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 BAe={$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 UAe={$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 zAe={$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=Hp(Xce(),1),nlt=Hp(tlt(),1);var ele=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new rlt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,nlt.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.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 E={details:{}},A=y.instancePath.split("/");if(A.length>2){let W=A[1],G=A[2]?parseInt(A[2],10):0,be=A[3],de=Number.isNaN(G)?void 0:f[W][G][be];E={details:{property:W,index:G,field:be,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 W=y.instancePath.split("/"),G=W[W.length-1];y.message=`Value of property '${G}' must be '${y.params.type}'`}let F=Object.assign(y,E);d.push(F)}),d}};var _I=ele.instance;_I.addSchema(UAe,"route-configuration.schema.json");_I.addSchema(Kst,"policy-configuration.schema.json");_I.addSchema(BAe,"policies.schema.json");_I.addSchema(zAe,"open-api-route-configuration.schema.json");_I.addSchema(Yst,"fragments.schema.json");var o6r=_I.compile(UAe),ilt=_I.compile(zAe),rIe=_I.compile(BAe);var tle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=rIe(o),this.results}};var rle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=ilt(o),this.results}};import ycr from"node:path";var nIe=/\$import\((.*)\)/,kH=/\$env\((.*?)\)/g;var Uk=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},gcr=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),ZP=t((s,o)=>{if(!s)return!1;let f=gcr(s);return o.split("/").every((E,A)=>{let F=f[A];return F?E==="*"||HP(F)&&F.name.value===E?!0:E==="{}"?F.type===Wo.Object:E==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var nle=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),Z9(o)?o.children.forEach(f=>{this.visitor(f)}):MAe(o)?o.children.forEach(f=>{this.visitor(f)}):HP(o)&&this.visitor(o.value)}},slt=t(s=>{let o=new RegExp(kH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(kH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),alt=t((s,o,f)=>d=>{if(SO(d)&&typeof d.value=="string"&&d.parent&&MAe(d.parent)){if(!s.some(A=>ZP(d.parent,A))){kH.test(d.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=slt(d.value);if(E){let A=d.parent,F=A.children.indexOf(d);if(F!==-1)if(E.type==="raw"){let W={type:Wo.Raw,parent:A,value:E.value};A.children[F]=W}else A.children[F]=DS.createTemplateString(E.value,d)}return}if(!HP(d)||!SO(d.value)||typeof d.value.value!="string")return;if(!s.some(E=>ZP(d,E))){kH.test(d.value.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=slt(d.value.value);if(y)if(y.type==="raw"){let E={type:Wo.Raw,parent:null,value:y.value};d.value=E}else d.value=DS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var wH="config/routes.json",vcr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],bcr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],olt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Scr="handler/{}/options/{}/rewritePattern",Tcr="handler/{}/options/{}/baseUrl",ile=class extends nle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!HP(o)||!SO(o.value)||typeof o.value.value!="string")&&ZP(o,Scr)){if(!o.parent||!Z9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",wH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:clt(f)},y=DS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!HP(o)||!SO(o.value)||typeof o.value.value!="string")&&ZP(o,Tcr)){if(!o.parent||!Z9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",wH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:clt(f)},y=DS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!HP(o)||!SO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!bcr.some(F=>ZP(o,F))&&!olt.some(F=>ZP(o,F))){if(nIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Uk("An $import() statement is not expected at this location.",wH,o.location,f))}return}let d=nIe.exec(f);if(olt.some(F=>ZP(o,F))&&!d)return;if(!d){this.errors.push(new Uk("Invalid $import() statement",wH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=ycr.posix.join("..",y));let E=this.getImportName(y),A={type:Wo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=alt(vcr,this.errors,wH)};function clt(s){return`(request, context) => {
|
|
575
|
+
`),exitCode:E},"Untar process logs")}}t(eZt,"untarFile");async function tZt(s){if(await eAe(s))return await XN.rm(s,{recursive:!0})}t(tZt,"deleteFolder");var eu=tAe;var plt=Hp(Nst(),1);var Ist=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-model-routing-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"];var WV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,E){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=E}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Der=/[$_\p{ID_Start}]/u,Per=/[$_\u200C\u200D\p{ID_Continue}]/u,LAe=".*";function Aer(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(Aer,"Re");function Lst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],E=t(function(A){if(!o)throw new TypeError(A);f.push({type:"INVALID_CHAR",index:d,value:s[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:s[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:s[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:s[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:s[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:s[d++]});continue}if(y===":"){let A="",F=d+1;for(;F<s.length;){let W=s.substr(F,1);if(F===d+1&&Der.test(W)||F!==d+1&&Per.test(W)){A+=s[F++];continue}break}if(!A){E(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:A}),d=F;continue}if(y==="("){let A=1,F="",W=d+1,G=!1;if(s[W]==="?"){E(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!Aer(s[W],!1)){E(`Invalid character '${s[W]}' at ${W}.`),G=!0;break}if(s[W]==="\\"){F+=s[W++]+s[W++];continue}if(s[W]===")"){if(A--,A===0){W++;break}}else if(s[W]==="("&&(A++,s[W+1]!=="?")){E(`Capturing groups are not allowed at ${W}`),G=!0;break}F+=s[W++]}if(G)continue;if(A){E(`Unbalanced pattern at ${d}`);continue}if(!F){E(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=W;continue}f.push({type:"CHAR",index:d,value:s[d++]})}return f.push({type:"END",index:d,value:""}),f}t(Lst,"v");function Rst(s,o={}){let f=Lst(s);o.delimiter??="/#?",o.prefixes??="./";let d=`[^${fT(o.delimiter)}]+?`,y=[],E=0,A=0,F="",W=new Set,G=t(wn=>{if(A<f.length&&f[A].type===wn)return f[A++].value},"a"),be=t(()=>G("OTHER_MODIFIER")??G("ASTERISK"),"f"),de=t(wn=>{let sn=G(wn);if(sn!==void 0)return sn;let{type:Jn,index:kr}=f[A];throw new TypeError(`Unexpected ${Jn} at ${kr}, expected ${wn}`)},"d"),se=t(()=>{let wn="",sn;for(;sn=G("CHAR")??G("ESCAPED_CHAR");)wn+=sn;return wn},"T"),Ze=t(wn=>wn,"Se"),Ue=o.encodePart||Ze,je="",Vt=t(wn=>{je+=wn},"U"),Ut=t(()=>{je.length&&(y.push(new WV(3,"","",Ue(je),"",3)),je="")},"$"),Ir=t((wn,sn,Jn,kr,yr)=>{let xs=3;switch(yr){case"?":xs=1;break;case"*":xs=0;break;case"+":xs=2;break}if(!sn&&!Jn&&xs===3){Vt(wn);return}if(Ut(),!sn&&!Jn){if(!wn)return;y.push(new WV(3,"","",Ue(wn),"",xs));return}let bi;Jn?Jn==="*"?bi=LAe:bi=Jn:bi=d;let fc=2;bi===d?(fc=1,bi=""):bi===LAe&&(fc=0,bi="");let Ci;if(sn?Ci=sn:Jn&&(Ci=E++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new WV(fc,Ci,Ue(wn),bi,Ue(kr),xs))},"V");for(;A<f.length;){let wn=G("CHAR"),sn=G("NAME"),Jn=G("REGEX");if(!sn&&!Jn&&(Jn=G("ASTERISK")),sn||Jn){let yr=wn??"";o.prefixes.indexOf(yr)===-1&&(Vt(yr),yr=""),Ut();let xs=be();Ir(yr,sn,Jn,"",xs);continue}let kr=wn??G("ESCAPED_CHAR");if(kr){Vt(kr);continue}if(G("OPEN")){let yr=se(),xs=G("NAME"),bi=G("REGEX");!xs&&!bi&&(bi=G("ASTERISK"));let fc=se();de("CLOSE");let Ci=be();Ir(yr,xs,bi,fc,Ci);continue}Ut(),de("END")}return y}t(Rst,"D");function fT(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(fT,"S");function Ost(s){return s&&s.ignoreCase?"ui":"u"}t(Ost,"X");function Ner(s,o,f){return Mst(Rst(s,f),o,f)}t(Ner,"Z");function X9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(X9,"k");function Mst(s,o,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 s){if(F.type===3){F.modifier===3?d+=fT(F.value):d+=`(?:${fT(F.value)})${X9(F.modifier)}`;continue}o&&o.push(F.name);let W=`[^${fT(f.delimiter)}]+?`,G=F.value;if(F.type===1?G=W:F.type===0&&(G=LAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${X9(F.modifier)}`:d+=`((?:${G})${X9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${fT(F.prefix)}(${G})${fT(F.suffix)})`,d+=X9(F.modifier);continue}d+=`(?:${fT(F.prefix)}`,d+=`((?:${G})(?:`,d+=fT(F.suffix),d+=fT(F.prefix),d+=`(?:${G}))*)${fT(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${fT(f.endsWith)}]|$`,E=`[${fT(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${E}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Ost(f));f.strict||(d+=`(?:${E}(?=${y}))?`);let A=!1;if(s.length){let F=s[s.length-1];F.type===3&&F.modifier===3&&(A=f.delimiter.indexOf(F)>-1)}return A||(d+=`(?=${E}|${y})`),new RegExp(d,Ost(f))}t(Mst,"F");var tI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Ier={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Oer={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Fer(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(Fer,"J");function jst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(jst,"Q");function Ler(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t(Ler,"Ee");function Bst(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t(Bst,"W");var Ust=["ftp","file","http","https","ws","wss"];function zst(s){if(!s)return!0;for(let o of Ust)if(s.test(o))return!0;return!1}t(zst,"N");function Rer(s,o){if(s=jst(s,"#"),o||s==="")return s;let f=new URL("https://example.com");return f.hash=s,f.hash?f.hash.substring(1,f.hash.length):""}t(Rer,"te");function Mer(s,o){if(s=jst(s,"?"),o||s==="")return s;let f=new URL("https://example.com");return f.search=s,f.search?f.search.substring(1,f.search.length):""}t(Mer,"re");function jer(s,o){return o||s===""?s:Bst(s)?Wst(s):Jst(s)}t(jer,"ne");function Ber(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(Ber,"se");function Uer(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(Uer,"ie");function zer(s,o,f){if(f||s==="")return s;if(o&&!Ust.includes(o))return new URL(`${o}:${s}`).pathname;let d=s[0]=="/";return s=new URL(d?s:"/-"+s,"https://example.com").pathname,d||(s=s.substring(2,s.length)),s}t(zer,"ae");function $er(s,o,f){return $st(o)===s&&(s=""),f||s===""?s:qst(s)}t($er,"oe");function Jer(s,o){return s=Ler(s,":"),o||s===""?s:RAe(s)}t(Jer,"ce");function $st(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t($st,"_");function RAe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(RAe,"y");function Wer(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(Wer,"le");function qer(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(qer,"fe");function Jst(s){if(s==="")return s;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(s))throw new TypeError(`Invalid hostname '${s}'`);let o=new URL("https://example.com");return o.hostname=s,o.hostname}t(Jst,"z");function Wst(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(Wst,"j");function qst(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(qst,"K");function Ver(s){if(s==="")return s;let o=new URL("https://example.com");return o.pathname=s[0]!=="/"?"/-"+s:s,s[0]!=="/"?o.pathname.substring(2,o.pathname.length):o.pathname}t(Ver,"he");function Her(s){return s===""?s:new URL(`data:${s}`).pathname}t(Her,"ue");function Ger(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(Ger,"de");function Yer(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(Yer,"pe");var Ker=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#m=0;#c=0;#u=0;#f=0;#p=!1;constructor(s){this.#e=s}get result(){return this.#t}parse(){for(this.#n=Lst(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#c===0){this.#o(),this.#g()?this.#a(9,1):this.#E()?this.#a(8,1):this.#a(7,0);continue}else if(this.#c===2){this.#h(5);continue}this.#a(10,0);break}if(this.#u>0)if(this.#l())this.#u-=1;else continue;if(this.#A()){this.#u+=1;continue}switch(this.#c){case 0:this.#y()&&this.#h(1);break;case 1:if(this.#y()){this.#D();let s=7,o=1;this.#b()?(s=2,o=3):this.#p&&(s=2),this.#a(s,o)}break;case 2:this.#v()?this.#h(3):(this.#S()||this.#E()||this.#g())&&this.#h(5);break;case 3:this.#C()?this.#a(4,1):this.#v()&&this.#a(5,1);break;case 4:this.#v()&&this.#a(5,1);break;case 5:this.#O()?this.#f+=1:this.#N()&&(this.#f-=1),this.#k()&&!this.#f?this.#a(6,1):this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 6:this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 7:this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 8:this.#g()&&this.#a(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#a(s,o){switch(this.#c){case 0:break;case 1:this.#t.protocol=this.#w();break;case 2:break;case 3:this.#t.username=this.#w();break;case 4:this.#t.password=this.#w();break;case 5:this.#t.hostname=this.#w();break;case 6:this.#t.port=this.#w();break;case 7:this.#t.pathname=this.#w();break;case 8:this.#t.search=this.#w();break;case 9:this.#t.hash=this.#w();break;case 10:break}this.#c!==0&&s!==10&&([1,2,3,4].includes(this.#c)&&[6,7,8,9].includes(s)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#c)&&[8,9].includes(s)&&(this.#t.pathname??=this.#p?"/":""),[1,2,3,4,5,6,7].includes(this.#c)&&s===9&&(this.#t.search??="")),this.#i(s,o)}#i(s,o){this.#c=s,this.#m=this.#r+o,this.#r+=o,this.#s=0}#o(){this.#r=this.#m,this.#s=0}#h(s){this.#o(),this.#c=s}#d(s){return s<0&&(s=this.#n.length-s),s<this.#n.length?this.#n[s]:this.#n[this.#n.length-1]}#_(s,o){let f=this.#d(s);return f.value===o&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#y(){return this.#_(this.#r,":")}#b(){return this.#_(this.#r+1,"/")&&this.#_(this.#r+2,"/")}#v(){return this.#_(this.#r,"@")}#C(){return this.#_(this.#r,":")}#k(){return this.#_(this.#r,":")}#S(){return this.#_(this.#r,"/")}#E(){if(this.#_(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let s=this.#d(this.#r-1);return s.type!=="NAME"&&s.type!=="REGEX"&&s.type!=="CLOSE"&&s.type!=="ASTERISK"}#g(){return this.#_(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#_(this.#r,"[")}#N(){return this.#_(this.#r,"]")}#w(){let s=this.#n[this.#r],o=this.#d(this.#m).index;return this.#e.substring(o,s.index)}#D(){let s={};Object.assign(s,tI),s.encodePart=RAe;let o=Ner(this.#w(),void 0,s);this.#p=zst(o)}},FAe=["protocol","username","password","hostname","port","pathname","search","hash"],eI="*";function Fst(s,o){if(typeof s!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(s,o);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(Fst,"ge");function qP(s,o){return o?JV(s):s}t(qP,"b");function $V(s,o,f){let d;if(typeof o.baseURL=="string")try{d=new URL(o.baseURL),o.protocol===void 0&&(s.protocol=qP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&(s.username=qP(d.username,f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&o.password===void 0&&(s.password=qP(d.password,f)),o.protocol===void 0&&o.hostname===void 0&&(s.hostname=qP(d.hostname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&(s.port=qP(d.port,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&(s.pathname=qP(d.pathname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&(s.search=qP(d.search.substring(1,d.search.length),f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&o.hash===void 0&&(s.hash=qP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${o.baseURL}'.`)}if(typeof o.protocol=="string"&&(s.protocol=Jer(o.protocol,f)),typeof o.username=="string"&&(s.username=Uer(o.username,f)),typeof o.password=="string"&&(s.password=Ber(o.password,f)),typeof o.hostname=="string"&&(s.hostname=jer(o.hostname,f)),typeof o.port=="string"&&(s.port=$er(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!Fer(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=qP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=zer(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=Mer(o.search,f)),typeof o.hash=="string"&&(s.hash=Rer(o.hash,f)),s}t($V,"w");function JV(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(JV,"C");function Xer(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Xer,"Oe");function Zer(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${Xer(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,E="";for(let A=0;A<s.length;++A){let F=s[A];if(F.type===3){if(F.modifier===3){E+=JV(F.value);continue}E+=`{${JV(F.value)}}${X9(F.modifier)}`;continue}let W=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!o.prefixes.includes(F.prefix)),be=A>0?s[A-1]:null,de=A<s.length-1?s[A+1]:null;if(!G&&W&&F.type===1&&F.modifier===3&&de&&!de.prefix.length&&!de.suffix.length)if(de.type===3){let se=de.value.length>0?de.value[0]:"";G=y.test(se)}else G=!de.hasCustomName();if(!G&&!F.prefix.length&&be&&be.type===3){let se=be.value[be.value.length-1];G=o.prefixes.includes(se)}G&&(E+="{"),E+=JV(F.prefix),W&&(E+=`:${F.name}`),F.type===2?E+=`(${F.value})`:F.type===1?W||(E+=`(${d})`):F.type===0&&(!W&&(!be||be.type===3||be.modifier!==3||G||F.prefix!=="")?E+="*":E+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(E+="\\"),E+=JV(F.suffix),G&&(E+="}"),F.modifier!==3&&(E+=X9(F.modifier))}return E}t(Zer,"ke");var Vst=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#m=!1;constructor(s={},o,f){try{let d;if(typeof o=="string"?d=o:f=o,typeof s=="string"){let F=new Ker(s);if(F.parse(),s=F.result,d===void 0&&typeof s.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");s.baseURL=d}else{if(!s||typeof s!="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},E={pathname:eI,protocol:eI,username:eI,password:eI,hostname:eI,port:eI,search:eI,hash:eI};this.#e=$V(E,s,!0),$st(this.#e.protocol)===this.#e.port&&(this.#e.port="");let A;for(A of FAe){if(!(A in this.#e))continue;let F={},W=this.#e[A];switch(this.#t[A]=[],A){case"protocol":Object.assign(F,tI),F.encodePart=RAe;break;case"username":Object.assign(F,tI),F.encodePart=Wer;break;case"password":Object.assign(F,tI),F.encodePart=qer;break;case"hostname":Object.assign(F,Ier),Bst(W)?F.encodePart=Wst:F.encodePart=Jst;break;case"port":Object.assign(F,tI),F.encodePart=qst;break;case"pathname":zst(this.#n.protocol)?(Object.assign(F,Oer,y),F.encodePart=Ver):(Object.assign(F,tI,y),F.encodePart=Her);break;case"search":Object.assign(F,tI,y),F.encodePart=Ger;break;case"hash":Object.assign(F,tI,y),F.encodePart=Yer;break}try{this.#s[A]=Rst(W,F),this.#n[A]=Mst(this.#s[A],this.#t[A],F),this.#r[A]=Zer(this.#s[A],F),this.#m=this.#m||this.#s[A].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${A} pattern '${this.#e[A]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return!1;try{typeof s=="object"?f=$V(f,s,!1):f=$V(f,Fst(s,o),!1)}catch{return!1}let d;for(d of FAe)if(!this.#n[d].exec(f[d]))return!1;return!0}exec(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return;try{typeof s=="object"?f=$V(f,s,!1):f=$V(f,Fst(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of FAe){let E=this.#n[y].exec(f[y]);if(!E)return null;let A={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let G=E[F+1];A[W]=G}d[y]={input:f[y]??"",groups:A}}return d}static compareComponent(s,o,f){let d=t((F,W)=>{for(let G of["type","modifier","prefix","value","suffix"]){if(F[G]<W[G])return-1;if(F[G]!==W[G])return 1}return 0},"o"),y=new WV(3,"","","","",3),E=new WV(0,"","","","",3),A=t((F,W)=>{let G=0;for(;G<Math.min(F.length,W.length);++G){let be=d(F[G],W[G]);if(be)return be}return F.length===W.length?0:d(F[G]??y,W[G]??y)},"s");return!o.#r[s]&&!f.#r[s]?0:o.#r[s]&&!f.#r[s]?A(o.#s[s],[E]):!o.#r[s]&&f.#r[s]?A([E],f.#s[s]):A(o.#s[s],f.#s[s])}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.#m}};globalThis.URLPattern||(globalThis.URLPattern=Vst);import{AssertionError as Qer}from"node:assert";function VP(s,o){if(s===!1)throw new Qer({message:o})}t(VP,"assert");var Wo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(Wo||(Wo={}));function Z9(s){return s.type===Wo.Object}t(Z9,"isAstObject");function HP(s){return s.type===Wo.Property}t(HP,"isAstProperty");function MAe(s){return s.type===Wo.Array}t(MAe,"isAstArray");function SO(s){return s.type===Wo.Literal}t(SO,"isAstLiteral");function rI(s){if(s===void 0)throw new Error("Node is undefined");if(!Z9(s))throw new Error("Node is not object")}t(rI,"assertAstObject");import{findNodeAtLocation as etr,getNodeValue as ttr,printParseErrorCode as rtr,visit as ntr}from"jsonc-parser";var itr={DEFAULT:{allowTrailingComma:!1}};function qV(s,o=[],f=itr.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(W){d.type==="property"&&(d.length=W-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function E(W){return d.children?.push(W),W}t(E,"onValue"),ntr(s,{onObjectBegin:t((W,G,be)=>{d=E({type:"object",offset:W,length:-1,line:G+1,column:be+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,G,be,de,se)=>{d=E({type:"property",offset:G,length:-1,line:de+1,column:se+1,parent:d,children:[]}),d.children?.push({type:"string",value:W,offset:G,length:be,line:de,column:se,parent:d})},"onObjectProperty"),onObjectEnd:t((W,G)=>{y(W+G),d.length=W+G-d.offset,d=d.parent,y(W+G)},"onObjectEnd"),onArrayBegin:t((W,G,be,de)=>{d=E({type:"array",offset:W,length:-1,line:be+1,column:de+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((W,G)=>{d.length=W+G-d.offset,d=d.parent,y(W+G)},"onArrayEnd"),onLiteralValue:t((W,G,be,de,se)=>{E({type:str(W),offset:G,length:be,line:de+1,column:se+1,parent:d,value:W}),y(G+be)},"onLiteralValue"),onSeparator:t((W,G)=>{d.type==="property"&&(W===":"?d.colonOffset=G:W===","&&y(G))},"onSeparator"),onError:t((W,G,be,de,se)=>{o.push({error:W,offset:G,length:be,line:de+1,column:se+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(qV,"parse");function str(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(str,"getNodeType");function jAe(s,o){return etr(s,o)}t(jAe,"findNodeAtLocation");function VV(s){return ttr(s)}t(VV,"getNodeValue");function Hst(s){return rtr(s)}t(Hst,"printParseErrorCode");var HV=class{static{t(this,"AstAdapter")}parse(o){let d=qV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:Wo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:Wo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){VP(o.children?.length===2,"Invalid property node");let d={type:Wo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:Wo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:Wo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var DS={createLiteral:t((s,o)=>({type:Wo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:Wo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:Wo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:Wo.Property,parent:f,name:null,value:o};return d.name={value:s,type:Wo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:Wo.Array,parent:o,children:[]};for(let d of s)f.children.push(DS.createLiteral(d,f));return f},"createArrayOfLiterals")};var atr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,GV=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case Wo.Array:return this.generateArray(o,f);case Wo.Object:return this.generateObject(o,f);case Wo.Property:return this.generateProperty(o,f);case Wo.Literal:return this.generateLiteral(o,f);case Wo.FunctionCall:return this.generateFunctionCall(o,f);case Wo.Identifier:return this.generateIdentifier(o,f);case Wo.Raw:return this.generateRaw(o,f);case Wo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,E)=>{this.generateSource(o,d),y<E.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=atr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import otr from"node:fs/promises";import{parse as ctr}from"@swc/core";var Gst=t(async s=>{let o=new Set;try{let f=await otr.readFile(s,"utf-8");(await ctr(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"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 BAe={$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 UAe={$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 zAe={$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=Hp(Xce(),1),nlt=Hp(tlt(),1);var ele=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new rlt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,nlt.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.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 E={details:{}},A=y.instancePath.split("/");if(A.length>2){let W=A[1],G=A[2]?parseInt(A[2],10):0,be=A[3],de=Number.isNaN(G)?void 0:f[W][G][be];E={details:{property:W,index:G,field:be,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 W=y.instancePath.split("/"),G=W[W.length-1];y.message=`Value of property '${G}' must be '${y.params.type}'`}let F=Object.assign(y,E);d.push(F)}),d}};var _I=ele.instance;_I.addSchema(UAe,"route-configuration.schema.json");_I.addSchema(Kst,"policy-configuration.schema.json");_I.addSchema(BAe,"policies.schema.json");_I.addSchema(zAe,"open-api-route-configuration.schema.json");_I.addSchema(Yst,"fragments.schema.json");var o6r=_I.compile(UAe),ilt=_I.compile(zAe),rIe=_I.compile(BAe);var tle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=rIe(o),this.results}};var rle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=ilt(o),this.results}};import ycr from"node:path";var nIe=/\$import\((.*)\)/,kH=/\$env\((.*?)\)/g;var Uk=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},gcr=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),ZP=t((s,o)=>{if(!s)return!1;let f=gcr(s);return o.split("/").every((E,A)=>{let F=f[A];return F?E==="*"||HP(F)&&F.name.value===E?!0:E==="{}"?F.type===Wo.Object:E==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var nle=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),Z9(o)?o.children.forEach(f=>{this.visitor(f)}):MAe(o)?o.children.forEach(f=>{this.visitor(f)}):HP(o)&&this.visitor(o.value)}},slt=t(s=>{let o=new RegExp(kH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(kH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),alt=t((s,o,f)=>d=>{if(SO(d)&&typeof d.value=="string"&&d.parent&&MAe(d.parent)){if(!s.some(A=>ZP(d.parent,A))){kH.test(d.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=slt(d.value);if(E){let A=d.parent,F=A.children.indexOf(d);if(F!==-1)if(E.type==="raw"){let W={type:Wo.Raw,parent:A,value:E.value};A.children[F]=W}else A.children[F]=DS.createTemplateString(E.value,d)}return}if(!HP(d)||!SO(d.value)||typeof d.value.value!="string")return;if(!s.some(E=>ZP(d,E))){kH.test(d.value.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=slt(d.value.value);if(y)if(y.type==="raw"){let E={type:Wo.Raw,parent:null,value:y.value};d.value=E}else d.value=DS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var wH="config/routes.json",vcr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],bcr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],olt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Scr="handler/{}/options/{}/rewritePattern",Tcr="handler/{}/options/{}/baseUrl",ile=class extends nle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!HP(o)||!SO(o.value)||typeof o.value.value!="string")&&ZP(o,Scr)){if(!o.parent||!Z9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",wH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:clt(f)},y=DS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!HP(o)||!SO(o.value)||typeof o.value.value!="string")&&ZP(o,Tcr)){if(!o.parent||!Z9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",wH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:clt(f)},y=DS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!HP(o)||!SO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!bcr.some(F=>ZP(o,F))&&!olt.some(F=>ZP(o,F))){if(nIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Uk("An $import() statement is not expected at this location.",wH,o.location,f))}return}let d=nIe.exec(f);if(olt.some(F=>ZP(o,F))&&!d)return;if(!d){this.errors.push(new Uk("Invalid $import() statement",wH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=ycr.posix.join("..",y));let E=this.getImportName(y),A={type:Wo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=alt(vcr,this.errors,wH)};function clt(s){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;
|
|
@@ -572,7 +572,7 @@ globstar while`,s,de,o,se,Ze),this.matchOne(s.slice(de),o.slice(se),f))return th
|
|
|
572
572
|
`),stderr:E.join(`
|
|
573
573
|
`),exitCode:A},"Tar process logs")}}t(xZt,"tarFolder");async function EZt({tarFilePath:s,outputDir:o,logger:f}){let d=[],y=[],E;try{await new Promise((A,F)=>{let W=mit("sh",["-c",`tar -xvf ${s} -C ${o};`]);W.stdout.on("data",G=>{let be=G.toString().trim();be.length>0&&d.push(be.trim())}),W.stderr.on("data",G=>{let be=G.toString().trim();be.length>0&&y.push(be.trim())}),W.on("close",G=>{E=G,G===0?A():F(new Error(`tar process exited with code ${G}`))}),W.on("error",G=>{F(G)})})}catch(A){throw new Error("Failed to untar file",{cause:A})}finally{f.info({stdout:d.join(`
|
|
574
574
|
`),stderr:y.join(`
|
|
575
|
-
`),exitCode:E},"Untar process logs")}}t(EZt,"untarFile");async function CZt(s){if(await sAe(s))return await eI.rm(s,{recursive:!0})}t(CZt,"deleteFolder");var eu=aAe;var Slt=tp(Bst(),1);var Ust=["ai-gateway-model-routing-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"];var qV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,E){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=E}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Zer=/[$_\p{ID_Start}]/u,Qer=/[$_\u200C\u200D\p{ID_Continue}]/u,UAe=".*";function etr(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(etr,"Re");function Jst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],E=t(function(A){if(!o)throw new TypeError(A);f.push({type:"INVALID_CHAR",index:d,value:s[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:s[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:s[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:s[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:s[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:s[d++]});continue}if(y===":"){let A="",F=d+1;for(;F<s.length;){let W=s.substr(F,1);if(F===d+1&&Zer.test(W)||F!==d+1&&Qer.test(W)){A+=s[F++];continue}break}if(!A){E(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:A}),d=F;continue}if(y==="("){let A=1,F="",W=d+1,G=!1;if(s[W]==="?"){E(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!etr(s[W],!1)){E(`Invalid character '${s[W]}' at ${W}.`),G=!0;break}if(s[W]==="\\"){F+=s[W++]+s[W++];continue}if(s[W]===")"){if(A--,A===0){W++;break}}else if(s[W]==="("&&(A++,s[W+1]!=="?")){E(`Capturing groups are not allowed at ${W}`),G=!0;break}F+=s[W++]}if(G)continue;if(A){E(`Unbalanced pattern at ${d}`);continue}if(!F){E(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=W;continue}f.push({type:"CHAR",index:d,value:s[d++]})}return f.push({type:"END",index:d,value:""}),f}t(Jst,"v");function Wst(s,o={}){let f=Jst(s);o.delimiter??="/#?",o.prefixes??="./";let d=`[^${_T(o.delimiter)}]+?`,y=[],E=0,A=0,F="",W=new Set,G=t(wn=>{if(A<f.length&&f[A].type===wn)return f[A++].value},"a"),be=t(()=>G("OTHER_MODIFIER")??G("ASTERISK"),"f"),de=t(wn=>{let sn=G(wn);if(sn!==void 0)return sn;let{type:Jn,index:kr}=f[A];throw new TypeError(`Unexpected ${Jn} at ${kr}, expected ${wn}`)},"d"),se=t(()=>{let wn="",sn;for(;sn=G("CHAR")??G("ESCAPED_CHAR");)wn+=sn;return wn},"T"),Ze=t(wn=>wn,"Se"),Ue=o.encodePart||Ze,je="",Vt=t(wn=>{je+=wn},"U"),Ut=t(()=>{je.length&&(y.push(new qV(3,"","",Ue(je),"",3)),je="")},"$"),Ir=t((wn,sn,Jn,kr,yr)=>{let xs=3;switch(yr){case"?":xs=1;break;case"*":xs=0;break;case"+":xs=2;break}if(!sn&&!Jn&&xs===3){Vt(wn);return}if(Ut(),!sn&&!Jn){if(!wn)return;y.push(new qV(3,"","",Ue(wn),"",xs));return}let bi;Jn?Jn==="*"?bi=UAe:bi=Jn:bi=d;let fc=2;bi===d?(fc=1,bi=""):bi===UAe&&(fc=0,bi="");let Ci;if(sn?Ci=sn:Jn&&(Ci=E++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new qV(fc,Ci,Ue(wn),bi,Ue(kr),xs))},"V");for(;A<f.length;){let wn=G("CHAR"),sn=G("NAME"),Jn=G("REGEX");if(!sn&&!Jn&&(Jn=G("ASTERISK")),sn||Jn){let yr=wn??"";o.prefixes.indexOf(yr)===-1&&(Vt(yr),yr=""),Ut();let xs=be();Ir(yr,sn,Jn,"",xs);continue}let kr=wn??G("ESCAPED_CHAR");if(kr){Vt(kr);continue}if(G("OPEN")){let yr=se(),xs=G("NAME"),bi=G("REGEX");!xs&&!bi&&(bi=G("ASTERISK"));let fc=se();de("CLOSE");let Ci=be();Ir(yr,xs,bi,fc,Ci);continue}Ut(),de("END")}return y}t(Wst,"D");function _T(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(_T,"S");function zst(s){return s&&s.ignoreCase?"ui":"u"}t(zst,"X");function ttr(s,o,f){return qst(Wst(s,f),o,f)}t(ttr,"Z");function X9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(X9,"k");function qst(s,o,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 s){if(F.type===3){F.modifier===3?d+=_T(F.value):d+=`(?:${_T(F.value)})${X9(F.modifier)}`;continue}o&&o.push(F.name);let W=`[^${_T(f.delimiter)}]+?`,G=F.value;if(F.type===1?G=W:F.type===0&&(G=UAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${X9(F.modifier)}`:d+=`((?:${G})${X9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${_T(F.prefix)}(${G})${_T(F.suffix)})`,d+=X9(F.modifier);continue}d+=`(?:${_T(F.prefix)}`,d+=`((?:${G})(?:`,d+=_T(F.suffix),d+=_T(F.prefix),d+=`(?:${G}))*)${_T(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${_T(f.endsWith)}]|$`,E=`[${_T(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${E}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,zst(f));f.strict||(d+=`(?:${E}(?=${y}))?`);let A=!1;if(s.length){let F=s[s.length-1];F.type===3&&F.modifier===3&&(A=f.delimiter.indexOf(F)>-1)}return A||(d+=`(?=${E}|${y})`),new RegExp(d,zst(f))}t(qst,"F");var iI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},rtr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},ntr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function itr(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(itr,"J");function Vst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(Vst,"Q");function str(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t(str,"Ee");function Hst(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t(Hst,"W");var Gst=["ftp","file","http","https","ws","wss"];function Yst(s){if(!s)return!0;for(let o of Gst)if(s.test(o))return!0;return!1}t(Yst,"N");function atr(s,o){if(s=Vst(s,"#"),o||s==="")return s;let f=new URL("https://example.com");return f.hash=s,f.hash?f.hash.substring(1,f.hash.length):""}t(atr,"te");function otr(s,o){if(s=Vst(s,"?"),o||s==="")return s;let f=new URL("https://example.com");return f.search=s,f.search?f.search.substring(1,f.search.length):""}t(otr,"re");function ctr(s,o){return o||s===""?s:Hst(s)?Zst(s):Xst(s)}t(ctr,"ne");function ltr(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(ltr,"se");function utr(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(utr,"ie");function ftr(s,o,f){if(f||s==="")return s;if(o&&!Gst.includes(o))return new URL(`${o}:${s}`).pathname;let d=s[0]=="/";return s=new URL(d?s:"/-"+s,"https://example.com").pathname,d||(s=s.substring(2,s.length)),s}t(ftr,"ae");function _tr(s,o,f){return Kst(o)===s&&(s=""),f||s===""?s:Qst(s)}t(_tr,"oe");function ptr(s,o){return s=str(s,":"),o||s===""?s:zAe(s)}t(ptr,"ce");function Kst(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(Kst,"_");function zAe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(zAe,"y");function dtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(dtr,"le");function mtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(mtr,"fe");function Xst(s){if(s==="")return s;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(s))throw new TypeError(`Invalid hostname '${s}'`);let o=new URL("https://example.com");return o.hostname=s,o.hostname}t(Xst,"z");function Zst(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(Zst,"j");function Qst(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(Qst,"K");function htr(s){if(s==="")return s;let o=new URL("https://example.com");return o.pathname=s[0]!=="/"?"/-"+s:s,s[0]!=="/"?o.pathname.substring(2,o.pathname.length):o.pathname}t(htr,"he");function gtr(s){return s===""?s:new URL(`data:${s}`).pathname}t(gtr,"ue");function ytr(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(ytr,"de");function vtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(vtr,"pe");var btr=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#m=0;#c=0;#u=0;#f=0;#p=!1;constructor(s){this.#e=s}get result(){return this.#t}parse(){for(this.#n=Jst(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#c===0){this.#o(),this.#g()?this.#a(9,1):this.#E()?this.#a(8,1):this.#a(7,0);continue}else if(this.#c===2){this.#h(5);continue}this.#a(10,0);break}if(this.#u>0)if(this.#l())this.#u-=1;else continue;if(this.#A()){this.#u+=1;continue}switch(this.#c){case 0:this.#y()&&this.#h(1);break;case 1:if(this.#y()){this.#D();let s=7,o=1;this.#b()?(s=2,o=3):this.#p&&(s=2),this.#a(s,o)}break;case 2:this.#v()?this.#h(3):(this.#S()||this.#E()||this.#g())&&this.#h(5);break;case 3:this.#C()?this.#a(4,1):this.#v()&&this.#a(5,1);break;case 4:this.#v()&&this.#a(5,1);break;case 5:this.#O()?this.#f+=1:this.#N()&&(this.#f-=1),this.#k()&&!this.#f?this.#a(6,1):this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 6:this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 7:this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 8:this.#g()&&this.#a(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#a(s,o){switch(this.#c){case 0:break;case 1:this.#t.protocol=this.#w();break;case 2:break;case 3:this.#t.username=this.#w();break;case 4:this.#t.password=this.#w();break;case 5:this.#t.hostname=this.#w();break;case 6:this.#t.port=this.#w();break;case 7:this.#t.pathname=this.#w();break;case 8:this.#t.search=this.#w();break;case 9:this.#t.hash=this.#w();break;case 10:break}this.#c!==0&&s!==10&&([1,2,3,4].includes(this.#c)&&[6,7,8,9].includes(s)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#c)&&[8,9].includes(s)&&(this.#t.pathname??=this.#p?"/":""),[1,2,3,4,5,6,7].includes(this.#c)&&s===9&&(this.#t.search??="")),this.#i(s,o)}#i(s,o){this.#c=s,this.#m=this.#r+o,this.#r+=o,this.#s=0}#o(){this.#r=this.#m,this.#s=0}#h(s){this.#o(),this.#c=s}#d(s){return s<0&&(s=this.#n.length-s),s<this.#n.length?this.#n[s]:this.#n[this.#n.length-1]}#_(s,o){let f=this.#d(s);return f.value===o&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#y(){return this.#_(this.#r,":")}#b(){return this.#_(this.#r+1,"/")&&this.#_(this.#r+2,"/")}#v(){return this.#_(this.#r,"@")}#C(){return this.#_(this.#r,":")}#k(){return this.#_(this.#r,":")}#S(){return this.#_(this.#r,"/")}#E(){if(this.#_(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let s=this.#d(this.#r-1);return s.type!=="NAME"&&s.type!=="REGEX"&&s.type!=="CLOSE"&&s.type!=="ASTERISK"}#g(){return this.#_(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#_(this.#r,"[")}#N(){return this.#_(this.#r,"]")}#w(){let s=this.#n[this.#r],o=this.#d(this.#m).index;return this.#e.substring(o,s.index)}#D(){let s={};Object.assign(s,iI),s.encodePart=zAe;let o=ttr(this.#w(),void 0,s);this.#p=Yst(o)}},BAe=["protocol","username","password","hostname","port","pathname","search","hash"],nI="*";function $st(s,o){if(typeof s!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(s,o);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($st,"ge");function GP(s,o){return o?WV(s):s}t(GP,"b");function JV(s,o,f){let d;if(typeof o.baseURL=="string")try{d=new URL(o.baseURL),o.protocol===void 0&&(s.protocol=GP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&(s.username=GP(d.username,f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&o.password===void 0&&(s.password=GP(d.password,f)),o.protocol===void 0&&o.hostname===void 0&&(s.hostname=GP(d.hostname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&(s.port=GP(d.port,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&(s.pathname=GP(d.pathname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&(s.search=GP(d.search.substring(1,d.search.length),f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&o.hash===void 0&&(s.hash=GP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${o.baseURL}'.`)}if(typeof o.protocol=="string"&&(s.protocol=ptr(o.protocol,f)),typeof o.username=="string"&&(s.username=utr(o.username,f)),typeof o.password=="string"&&(s.password=ltr(o.password,f)),typeof o.hostname=="string"&&(s.hostname=ctr(o.hostname,f)),typeof o.port=="string"&&(s.port=_tr(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!itr(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=GP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=ftr(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=otr(o.search,f)),typeof o.hash=="string"&&(s.hash=atr(o.hash,f)),s}t(JV,"w");function WV(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(WV,"C");function Str(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Str,"Oe");function Ttr(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${Str(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,E="";for(let A=0;A<s.length;++A){let F=s[A];if(F.type===3){if(F.modifier===3){E+=WV(F.value);continue}E+=`{${WV(F.value)}}${X9(F.modifier)}`;continue}let W=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!o.prefixes.includes(F.prefix)),be=A>0?s[A-1]:null,de=A<s.length-1?s[A+1]:null;if(!G&&W&&F.type===1&&F.modifier===3&&de&&!de.prefix.length&&!de.suffix.length)if(de.type===3){let se=de.value.length>0?de.value[0]:"";G=y.test(se)}else G=!de.hasCustomName();if(!G&&!F.prefix.length&&be&&be.type===3){let se=be.value[be.value.length-1];G=o.prefixes.includes(se)}G&&(E+="{"),E+=WV(F.prefix),W&&(E+=`:${F.name}`),F.type===2?E+=`(${F.value})`:F.type===1?W||(E+=`(${d})`):F.type===0&&(!W&&(!be||be.type===3||be.modifier!==3||G||F.prefix!=="")?E+="*":E+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(E+="\\"),E+=WV(F.suffix),G&&(E+="}"),F.modifier!==3&&(E+=X9(F.modifier))}return E}t(Ttr,"ke");var eat=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#m=!1;constructor(s={},o,f){try{let d;if(typeof o=="string"?d=o:f=o,typeof s=="string"){let F=new btr(s);if(F.parse(),s=F.result,d===void 0&&typeof s.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");s.baseURL=d}else{if(!s||typeof s!="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},E={pathname:nI,protocol:nI,username:nI,password:nI,hostname:nI,port:nI,search:nI,hash:nI};this.#e=JV(E,s,!0),Kst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let A;for(A of BAe){if(!(A in this.#e))continue;let F={},W=this.#e[A];switch(this.#t[A]=[],A){case"protocol":Object.assign(F,iI),F.encodePart=zAe;break;case"username":Object.assign(F,iI),F.encodePart=dtr;break;case"password":Object.assign(F,iI),F.encodePart=mtr;break;case"hostname":Object.assign(F,rtr),Hst(W)?F.encodePart=Zst:F.encodePart=Xst;break;case"port":Object.assign(F,iI),F.encodePart=Qst;break;case"pathname":Yst(this.#n.protocol)?(Object.assign(F,ntr,y),F.encodePart=htr):(Object.assign(F,iI,y),F.encodePart=gtr);break;case"search":Object.assign(F,iI,y),F.encodePart=ytr;break;case"hash":Object.assign(F,iI,y),F.encodePart=vtr;break}try{this.#s[A]=Wst(W,F),this.#n[A]=qst(this.#s[A],this.#t[A],F),this.#r[A]=Ttr(this.#s[A],F),this.#m=this.#m||this.#s[A].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${A} pattern '${this.#e[A]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return!1;try{typeof s=="object"?f=JV(f,s,!1):f=JV(f,$st(s,o),!1)}catch{return!1}let d;for(d of BAe)if(!this.#n[d].exec(f[d]))return!1;return!0}exec(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return;try{typeof s=="object"?f=JV(f,s,!1):f=JV(f,$st(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of BAe){let E=this.#n[y].exec(f[y]);if(!E)return null;let A={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let G=E[F+1];A[W]=G}d[y]={input:f[y]??"",groups:A}}return d}static compareComponent(s,o,f){let d=t((F,W)=>{for(let G of["type","modifier","prefix","value","suffix"]){if(F[G]<W[G])return-1;if(F[G]!==W[G])return 1}return 0},"o"),y=new qV(3,"","","","",3),E=new qV(0,"","","","",3),A=t((F,W)=>{let G=0;for(;G<Math.min(F.length,W.length);++G){let be=d(F[G],W[G]);if(be)return be}return F.length===W.length?0:d(F[G]??y,W[G]??y)},"s");return!o.#r[s]&&!f.#r[s]?0:o.#r[s]&&!f.#r[s]?A(o.#s[s],[E]):!o.#r[s]&&f.#r[s]?A([E],f.#s[s]):A(o.#s[s],f.#s[s])}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.#m}};globalThis.URLPattern||(globalThis.URLPattern=eat);import{AssertionError as xtr}from"node:assert";function YP(s,o){if(s===!1)throw new xtr({message:o})}t(YP,"assert");var Wo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(Wo||(Wo={}));function Z9(s){return s.type===Wo.Object}t(Z9,"isAstObject");function KP(s){return s.type===Wo.Property}t(KP,"isAstProperty");function $Ae(s){return s.type===Wo.Array}t($Ae,"isAstArray");function xO(s){return s.type===Wo.Literal}t(xO,"isAstLiteral");function sI(s){if(s===void 0)throw new Error("Node is undefined");if(!Z9(s))throw new Error("Node is not object")}t(sI,"assertAstObject");import{findNodeAtLocation as Etr,getNodeValue as Ctr,printParseErrorCode as ktr,visit as wtr}from"jsonc-parser";var Dtr={DEFAULT:{allowTrailingComma:!1}};function VV(s,o=[],f=Dtr.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(W){d.type==="property"&&(d.length=W-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function E(W){return d.children?.push(W),W}t(E,"onValue"),wtr(s,{onObjectBegin:t((W,G,be)=>{d=E({type:"object",offset:W,length:-1,line:G+1,column:be+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,G,be,de,se)=>{d=E({type:"property",offset:G,length:-1,line:de+1,column:se+1,parent:d,children:[]}),d.children?.push({type:"string",value:W,offset:G,length:be,line:de,column:se,parent:d})},"onObjectProperty"),onObjectEnd:t((W,G)=>{y(W+G),d.length=W+G-d.offset,d=d.parent,y(W+G)},"onObjectEnd"),onArrayBegin:t((W,G,be,de)=>{d=E({type:"array",offset:W,length:-1,line:be+1,column:de+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((W,G)=>{d.length=W+G-d.offset,d=d.parent,y(W+G)},"onArrayEnd"),onLiteralValue:t((W,G,be,de,se)=>{E({type:Ptr(W),offset:G,length:be,line:de+1,column:se+1,parent:d,value:W}),y(G+be)},"onLiteralValue"),onSeparator:t((W,G)=>{d.type==="property"&&(W===":"?d.colonOffset=G:W===","&&y(G))},"onSeparator"),onError:t((W,G,be,de,se)=>{o.push({error:W,offset:G,length:be,line:de+1,column:se+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(VV,"parse");function Ptr(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(Ptr,"getNodeType");function JAe(s,o){return Etr(s,o)}t(JAe,"findNodeAtLocation");function HV(s){return Ctr(s)}t(HV,"getNodeValue");function tat(s){return ktr(s)}t(tat,"printParseErrorCode");var GV=class{static{t(this,"AstAdapter")}parse(o){let d=VV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:Wo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:Wo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){YP(o.children?.length===2,"Invalid property node");let d={type:Wo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:Wo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:Wo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var DS={createLiteral:t((s,o)=>({type:Wo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:Wo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:Wo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:Wo.Property,parent:f,name:null,value:o};return d.name={value:s,type:Wo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:Wo.Array,parent:o,children:[]};for(let d of s)f.children.push(DS.createLiteral(d,f));return f},"createArrayOfLiterals")};var Atr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,YV=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case Wo.Array:return this.generateArray(o,f);case Wo.Object:return this.generateObject(o,f);case Wo.Property:return this.generateProperty(o,f);case Wo.Literal:return this.generateLiteral(o,f);case Wo.FunctionCall:return this.generateFunctionCall(o,f);case Wo.Identifier:return this.generateIdentifier(o,f);case Wo.Raw:return this.generateRaw(o,f);case Wo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,E)=>{this.generateSource(o,d),y<E.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=Atr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Ntr from"node:fs/promises";import{parse as Itr}from"@swc/core";var rat=t(async s=>{let o=new Set;try{let f=await Ntr.readFile(s,"utf-8");(await Itr(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"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 WAe={$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 qAe={$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 VAe={$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=tp(Xce(),1),flt=tp(llt(),1);var ele=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new ult.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,flt.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.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 E={details:{}},A=y.instancePath.split("/");if(A.length>2){let W=A[1],G=A[2]?parseInt(A[2],10):0,be=A[3],de=Number.isNaN(G)?void 0:f[W][G][be];E={details:{property:W,index:G,field:be,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 W=y.instancePath.split("/"),G=W[W.length-1];y.message=`Value of property '${G}' must be '${y.params.type}'`}let F=Object.assign(y,E);d.push(F)}),d}};var mI=ele.instance;mI.addSchema(qAe,"route-configuration.schema.json");mI.addSchema(iat,"policy-configuration.schema.json");mI.addSchema(WAe,"policies.schema.json");mI.addSchema(VAe,"open-api-route-configuration.schema.json");mI.addSchema(nat,"fragments.schema.json");var N6r=mI.compile(qAe),_lt=mI.compile(VAe),oIe=mI.compile(WAe);var tle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=oIe(o),this.results}};var rle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=_lt(o),this.results}};import $cr from"node:path";var cIe=/\$import\((.*)\)/,wH=/\$env\((.*?)\)/g;var $k=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},zcr=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),tA=t((s,o)=>{if(!s)return!1;let f=zcr(s);return o.split("/").every((E,A)=>{let F=f[A];return F?E==="*"||KP(F)&&F.name.value===E?!0:E==="{}"?F.type===Wo.Object:E==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var nle=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),Z9(o)?o.children.forEach(f=>{this.visitor(f)}):$Ae(o)?o.children.forEach(f=>{this.visitor(f)}):KP(o)&&this.visitor(o.value)}},plt=t(s=>{let o=new RegExp(wH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(wH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),dlt=t((s,o,f)=>d=>{if(xO(d)&&typeof d.value=="string"&&d.parent&&$Ae(d.parent)){if(!s.some(A=>tA(d.parent,A))){wH.test(d.value)&&o.push(new $k("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=plt(d.value);if(E){let A=d.parent,F=A.children.indexOf(d);if(F!==-1)if(E.type==="raw"){let W={type:Wo.Raw,parent:A,value:E.value};A.children[F]=W}else A.children[F]=DS.createTemplateString(E.value,d)}return}if(!KP(d)||!xO(d.value)||typeof d.value.value!="string")return;if(!s.some(E=>tA(d,E))){wH.test(d.value.value)&&o.push(new $k("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=plt(d.value.value);if(y)if(y.type==="raw"){let E={type:Wo.Raw,parent:null,value:y.value};d.value=E}else d.value=DS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var DH="config/routes.json",Jcr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Wcr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],mlt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],qcr="handler/{}/options/{}/rewritePattern",Vcr="handler/{}/options/{}/baseUrl",ile=class extends nle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!KP(o)||!xO(o.value)||typeof o.value.value!="string")&&tA(o,qcr)){if(!o.parent||!Z9(o.parent)){this.errors.push(new $k("Invalid node, expected object",DH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:hlt(f)},y=DS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!KP(o)||!xO(o.value)||typeof o.value.value!="string")&&tA(o,Vcr)){if(!o.parent||!Z9(o.parent)){this.errors.push(new $k("Invalid node, expected object",DH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:hlt(f)},y=DS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!KP(o)||!xO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!Wcr.some(F=>tA(o,F))&&!mlt.some(F=>tA(o,F))){if(cIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new $k("An $import() statement is not expected at this location.",DH,o.location,f))}return}let d=cIe.exec(f);if(mlt.some(F=>tA(o,F))&&!d)return;if(!d){this.errors.push(new $k("Invalid $import() statement",DH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=$cr.posix.join("..",y));let E=this.getImportName(y),A={type:Wo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=dlt(Jcr,this.errors,DH)};function hlt(s){return`(request, context) => {
|
|
575
|
+
`),exitCode:E},"Untar process logs")}}t(EZt,"untarFile");async function CZt(s){if(await sAe(s))return await eI.rm(s,{recursive:!0})}t(CZt,"deleteFolder");var eu=aAe;var Slt=tp(Bst(),1);var Ust=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-model-routing-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"];var qV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,E){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=E}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Zer=/[$_\p{ID_Start}]/u,Qer=/[$_\u200C\u200D\p{ID_Continue}]/u,UAe=".*";function etr(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(etr,"Re");function Jst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],E=t(function(A){if(!o)throw new TypeError(A);f.push({type:"INVALID_CHAR",index:d,value:s[d++]})},"c");if(y==="*"){f.push({type:"ASTERISK",index:d,value:s[d++]});continue}if(y==="+"||y==="?"){f.push({type:"OTHER_MODIFIER",index:d,value:s[d++]});continue}if(y==="\\"){f.push({type:"ESCAPED_CHAR",index:d++,value:s[d++]});continue}if(y==="{"){f.push({type:"OPEN",index:d,value:s[d++]});continue}if(y==="}"){f.push({type:"CLOSE",index:d,value:s[d++]});continue}if(y===":"){let A="",F=d+1;for(;F<s.length;){let W=s.substr(F,1);if(F===d+1&&Zer.test(W)||F!==d+1&&Qer.test(W)){A+=s[F++];continue}break}if(!A){E(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:A}),d=F;continue}if(y==="("){let A=1,F="",W=d+1,G=!1;if(s[W]==="?"){E(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!etr(s[W],!1)){E(`Invalid character '${s[W]}' at ${W}.`),G=!0;break}if(s[W]==="\\"){F+=s[W++]+s[W++];continue}if(s[W]===")"){if(A--,A===0){W++;break}}else if(s[W]==="("&&(A++,s[W+1]!=="?")){E(`Capturing groups are not allowed at ${W}`),G=!0;break}F+=s[W++]}if(G)continue;if(A){E(`Unbalanced pattern at ${d}`);continue}if(!F){E(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=W;continue}f.push({type:"CHAR",index:d,value:s[d++]})}return f.push({type:"END",index:d,value:""}),f}t(Jst,"v");function Wst(s,o={}){let f=Jst(s);o.delimiter??="/#?",o.prefixes??="./";let d=`[^${_T(o.delimiter)}]+?`,y=[],E=0,A=0,F="",W=new Set,G=t(wn=>{if(A<f.length&&f[A].type===wn)return f[A++].value},"a"),be=t(()=>G("OTHER_MODIFIER")??G("ASTERISK"),"f"),de=t(wn=>{let sn=G(wn);if(sn!==void 0)return sn;let{type:Jn,index:kr}=f[A];throw new TypeError(`Unexpected ${Jn} at ${kr}, expected ${wn}`)},"d"),se=t(()=>{let wn="",sn;for(;sn=G("CHAR")??G("ESCAPED_CHAR");)wn+=sn;return wn},"T"),Ze=t(wn=>wn,"Se"),Ue=o.encodePart||Ze,je="",Vt=t(wn=>{je+=wn},"U"),Ut=t(()=>{je.length&&(y.push(new qV(3,"","",Ue(je),"",3)),je="")},"$"),Ir=t((wn,sn,Jn,kr,yr)=>{let xs=3;switch(yr){case"?":xs=1;break;case"*":xs=0;break;case"+":xs=2;break}if(!sn&&!Jn&&xs===3){Vt(wn);return}if(Ut(),!sn&&!Jn){if(!wn)return;y.push(new qV(3,"","",Ue(wn),"",xs));return}let bi;Jn?Jn==="*"?bi=UAe:bi=Jn:bi=d;let fc=2;bi===d?(fc=1,bi=""):bi===UAe&&(fc=0,bi="");let Ci;if(sn?Ci=sn:Jn&&(Ci=E++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new qV(fc,Ci,Ue(wn),bi,Ue(kr),xs))},"V");for(;A<f.length;){let wn=G("CHAR"),sn=G("NAME"),Jn=G("REGEX");if(!sn&&!Jn&&(Jn=G("ASTERISK")),sn||Jn){let yr=wn??"";o.prefixes.indexOf(yr)===-1&&(Vt(yr),yr=""),Ut();let xs=be();Ir(yr,sn,Jn,"",xs);continue}let kr=wn??G("ESCAPED_CHAR");if(kr){Vt(kr);continue}if(G("OPEN")){let yr=se(),xs=G("NAME"),bi=G("REGEX");!xs&&!bi&&(bi=G("ASTERISK"));let fc=se();de("CLOSE");let Ci=be();Ir(yr,xs,bi,fc,Ci);continue}Ut(),de("END")}return y}t(Wst,"D");function _T(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(_T,"S");function zst(s){return s&&s.ignoreCase?"ui":"u"}t(zst,"X");function ttr(s,o,f){return qst(Wst(s,f),o,f)}t(ttr,"Z");function X9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(X9,"k");function qst(s,o,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 s){if(F.type===3){F.modifier===3?d+=_T(F.value):d+=`(?:${_T(F.value)})${X9(F.modifier)}`;continue}o&&o.push(F.name);let W=`[^${_T(f.delimiter)}]+?`,G=F.value;if(F.type===1?G=W:F.type===0&&(G=UAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${X9(F.modifier)}`:d+=`((?:${G})${X9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${_T(F.prefix)}(${G})${_T(F.suffix)})`,d+=X9(F.modifier);continue}d+=`(?:${_T(F.prefix)}`,d+=`((?:${G})(?:`,d+=_T(F.suffix),d+=_T(F.prefix),d+=`(?:${G}))*)${_T(F.suffix)})`,F.modifier===0&&(d+="?")}let y=`[${_T(f.endsWith)}]|$`,E=`[${_T(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${E}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,zst(f));f.strict||(d+=`(?:${E}(?=${y}))?`);let A=!1;if(s.length){let F=s[s.length-1];F.type===3&&F.modifier===3&&(A=f.delimiter.indexOf(F)>-1)}return A||(d+=`(?=${E}|${y})`),new RegExp(d,zst(f))}t(qst,"F");var iI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},rtr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},ntr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function itr(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(itr,"J");function Vst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(Vst,"Q");function str(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t(str,"Ee");function Hst(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t(Hst,"W");var Gst=["ftp","file","http","https","ws","wss"];function Yst(s){if(!s)return!0;for(let o of Gst)if(s.test(o))return!0;return!1}t(Yst,"N");function atr(s,o){if(s=Vst(s,"#"),o||s==="")return s;let f=new URL("https://example.com");return f.hash=s,f.hash?f.hash.substring(1,f.hash.length):""}t(atr,"te");function otr(s,o){if(s=Vst(s,"?"),o||s==="")return s;let f=new URL("https://example.com");return f.search=s,f.search?f.search.substring(1,f.search.length):""}t(otr,"re");function ctr(s,o){return o||s===""?s:Hst(s)?Zst(s):Xst(s)}t(ctr,"ne");function ltr(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(ltr,"se");function utr(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(utr,"ie");function ftr(s,o,f){if(f||s==="")return s;if(o&&!Gst.includes(o))return new URL(`${o}:${s}`).pathname;let d=s[0]=="/";return s=new URL(d?s:"/-"+s,"https://example.com").pathname,d||(s=s.substring(2,s.length)),s}t(ftr,"ae");function _tr(s,o,f){return Kst(o)===s&&(s=""),f||s===""?s:Qst(s)}t(_tr,"oe");function ptr(s,o){return s=str(s,":"),o||s===""?s:zAe(s)}t(ptr,"ce");function Kst(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(Kst,"_");function zAe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(zAe,"y");function dtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(dtr,"le");function mtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(mtr,"fe");function Xst(s){if(s==="")return s;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(s))throw new TypeError(`Invalid hostname '${s}'`);let o=new URL("https://example.com");return o.hostname=s,o.hostname}t(Xst,"z");function Zst(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(Zst,"j");function Qst(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(Qst,"K");function htr(s){if(s==="")return s;let o=new URL("https://example.com");return o.pathname=s[0]!=="/"?"/-"+s:s,s[0]!=="/"?o.pathname.substring(2,o.pathname.length):o.pathname}t(htr,"he");function gtr(s){return s===""?s:new URL(`data:${s}`).pathname}t(gtr,"ue");function ytr(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(ytr,"de");function vtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(vtr,"pe");var btr=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#m=0;#c=0;#u=0;#f=0;#p=!1;constructor(s){this.#e=s}get result(){return this.#t}parse(){for(this.#n=Jst(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#c===0){this.#o(),this.#g()?this.#a(9,1):this.#E()?this.#a(8,1):this.#a(7,0);continue}else if(this.#c===2){this.#h(5);continue}this.#a(10,0);break}if(this.#u>0)if(this.#l())this.#u-=1;else continue;if(this.#A()){this.#u+=1;continue}switch(this.#c){case 0:this.#y()&&this.#h(1);break;case 1:if(this.#y()){this.#D();let s=7,o=1;this.#b()?(s=2,o=3):this.#p&&(s=2),this.#a(s,o)}break;case 2:this.#v()?this.#h(3):(this.#S()||this.#E()||this.#g())&&this.#h(5);break;case 3:this.#C()?this.#a(4,1):this.#v()&&this.#a(5,1);break;case 4:this.#v()&&this.#a(5,1);break;case 5:this.#O()?this.#f+=1:this.#N()&&(this.#f-=1),this.#k()&&!this.#f?this.#a(6,1):this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 6:this.#S()?this.#a(7,0):this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 7:this.#E()?this.#a(8,1):this.#g()&&this.#a(9,1);break;case 8:this.#g()&&this.#a(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#a(s,o){switch(this.#c){case 0:break;case 1:this.#t.protocol=this.#w();break;case 2:break;case 3:this.#t.username=this.#w();break;case 4:this.#t.password=this.#w();break;case 5:this.#t.hostname=this.#w();break;case 6:this.#t.port=this.#w();break;case 7:this.#t.pathname=this.#w();break;case 8:this.#t.search=this.#w();break;case 9:this.#t.hash=this.#w();break;case 10:break}this.#c!==0&&s!==10&&([1,2,3,4].includes(this.#c)&&[6,7,8,9].includes(s)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#c)&&[8,9].includes(s)&&(this.#t.pathname??=this.#p?"/":""),[1,2,3,4,5,6,7].includes(this.#c)&&s===9&&(this.#t.search??="")),this.#i(s,o)}#i(s,o){this.#c=s,this.#m=this.#r+o,this.#r+=o,this.#s=0}#o(){this.#r=this.#m,this.#s=0}#h(s){this.#o(),this.#c=s}#d(s){return s<0&&(s=this.#n.length-s),s<this.#n.length?this.#n[s]:this.#n[this.#n.length-1]}#_(s,o){let f=this.#d(s);return f.value===o&&(f.type==="CHAR"||f.type==="ESCAPED_CHAR"||f.type==="INVALID_CHAR")}#y(){return this.#_(this.#r,":")}#b(){return this.#_(this.#r+1,"/")&&this.#_(this.#r+2,"/")}#v(){return this.#_(this.#r,"@")}#C(){return this.#_(this.#r,":")}#k(){return this.#_(this.#r,":")}#S(){return this.#_(this.#r,"/")}#E(){if(this.#_(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let s=this.#d(this.#r-1);return s.type!=="NAME"&&s.type!=="REGEX"&&s.type!=="CLOSE"&&s.type!=="ASTERISK"}#g(){return this.#_(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#_(this.#r,"[")}#N(){return this.#_(this.#r,"]")}#w(){let s=this.#n[this.#r],o=this.#d(this.#m).index;return this.#e.substring(o,s.index)}#D(){let s={};Object.assign(s,iI),s.encodePart=zAe;let o=ttr(this.#w(),void 0,s);this.#p=Yst(o)}},BAe=["protocol","username","password","hostname","port","pathname","search","hash"],nI="*";function $st(s,o){if(typeof s!="string")throw new TypeError("parameter 1 is not of type 'string'.");let f=new URL(s,o);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($st,"ge");function GP(s,o){return o?WV(s):s}t(GP,"b");function JV(s,o,f){let d;if(typeof o.baseURL=="string")try{d=new URL(o.baseURL),o.protocol===void 0&&(s.protocol=GP(d.protocol.substring(0,d.protocol.length-1),f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&(s.username=GP(d.username,f)),!f&&o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.username===void 0&&o.password===void 0&&(s.password=GP(d.password,f)),o.protocol===void 0&&o.hostname===void 0&&(s.hostname=GP(d.hostname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&(s.port=GP(d.port,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&(s.pathname=GP(d.pathname,f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&(s.search=GP(d.search.substring(1,d.search.length),f)),o.protocol===void 0&&o.hostname===void 0&&o.port===void 0&&o.pathname===void 0&&o.search===void 0&&o.hash===void 0&&(s.hash=GP(d.hash.substring(1,d.hash.length),f))}catch{throw new TypeError(`invalid baseURL '${o.baseURL}'.`)}if(typeof o.protocol=="string"&&(s.protocol=ptr(o.protocol,f)),typeof o.username=="string"&&(s.username=utr(o.username,f)),typeof o.password=="string"&&(s.password=ltr(o.password,f)),typeof o.hostname=="string"&&(s.hostname=ctr(o.hostname,f)),typeof o.port=="string"&&(s.port=_tr(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!itr(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=GP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=ftr(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=otr(o.search,f)),typeof o.hash=="string"&&(s.hash=atr(o.hash,f)),s}t(JV,"w");function WV(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(WV,"C");function Str(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Str,"Oe");function Ttr(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${Str(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,E="";for(let A=0;A<s.length;++A){let F=s[A];if(F.type===3){if(F.modifier===3){E+=WV(F.value);continue}E+=`{${WV(F.value)}}${X9(F.modifier)}`;continue}let W=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!o.prefixes.includes(F.prefix)),be=A>0?s[A-1]:null,de=A<s.length-1?s[A+1]:null;if(!G&&W&&F.type===1&&F.modifier===3&&de&&!de.prefix.length&&!de.suffix.length)if(de.type===3){let se=de.value.length>0?de.value[0]:"";G=y.test(se)}else G=!de.hasCustomName();if(!G&&!F.prefix.length&&be&&be.type===3){let se=be.value[be.value.length-1];G=o.prefixes.includes(se)}G&&(E+="{"),E+=WV(F.prefix),W&&(E+=`:${F.name}`),F.type===2?E+=`(${F.value})`:F.type===1?W||(E+=`(${d})`):F.type===0&&(!W&&(!be||be.type===3||be.modifier!==3||G||F.prefix!=="")?E+="*":E+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(E+="\\"),E+=WV(F.suffix),G&&(E+="}"),F.modifier!==3&&(E+=X9(F.modifier))}return E}t(Ttr,"ke");var eat=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#m=!1;constructor(s={},o,f){try{let d;if(typeof o=="string"?d=o:f=o,typeof s=="string"){let F=new btr(s);if(F.parse(),s=F.result,d===void 0&&typeof s.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");s.baseURL=d}else{if(!s||typeof s!="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},E={pathname:nI,protocol:nI,username:nI,password:nI,hostname:nI,port:nI,search:nI,hash:nI};this.#e=JV(E,s,!0),Kst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let A;for(A of BAe){if(!(A in this.#e))continue;let F={},W=this.#e[A];switch(this.#t[A]=[],A){case"protocol":Object.assign(F,iI),F.encodePart=zAe;break;case"username":Object.assign(F,iI),F.encodePart=dtr;break;case"password":Object.assign(F,iI),F.encodePart=mtr;break;case"hostname":Object.assign(F,rtr),Hst(W)?F.encodePart=Zst:F.encodePart=Xst;break;case"port":Object.assign(F,iI),F.encodePart=Qst;break;case"pathname":Yst(this.#n.protocol)?(Object.assign(F,ntr,y),F.encodePart=htr):(Object.assign(F,iI,y),F.encodePart=gtr);break;case"search":Object.assign(F,iI,y),F.encodePart=ytr;break;case"hash":Object.assign(F,iI,y),F.encodePart=vtr;break}try{this.#s[A]=Wst(W,F),this.#n[A]=qst(this.#s[A],this.#t[A],F),this.#r[A]=Ttr(this.#s[A],F),this.#m=this.#m||this.#s[A].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${A} pattern '${this.#e[A]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return!1;try{typeof s=="object"?f=JV(f,s,!1):f=JV(f,$st(s,o),!1)}catch{return!1}let d;for(d of BAe)if(!this.#n[d].exec(f[d]))return!1;return!0}exec(s={},o){let f={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&o)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return;try{typeof s=="object"?f=JV(f,s,!1):f=JV(f,$st(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of BAe){let E=this.#n[y].exec(f[y]);if(!E)return null;let A={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let G=E[F+1];A[W]=G}d[y]={input:f[y]??"",groups:A}}return d}static compareComponent(s,o,f){let d=t((F,W)=>{for(let G of["type","modifier","prefix","value","suffix"]){if(F[G]<W[G])return-1;if(F[G]!==W[G])return 1}return 0},"o"),y=new qV(3,"","","","",3),E=new qV(0,"","","","",3),A=t((F,W)=>{let G=0;for(;G<Math.min(F.length,W.length);++G){let be=d(F[G],W[G]);if(be)return be}return F.length===W.length?0:d(F[G]??y,W[G]??y)},"s");return!o.#r[s]&&!f.#r[s]?0:o.#r[s]&&!f.#r[s]?A(o.#s[s],[E]):!o.#r[s]&&f.#r[s]?A([E],f.#s[s]):A(o.#s[s],f.#s[s])}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.#m}};globalThis.URLPattern||(globalThis.URLPattern=eat);import{AssertionError as xtr}from"node:assert";function YP(s,o){if(s===!1)throw new xtr({message:o})}t(YP,"assert");var Wo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(Wo||(Wo={}));function Z9(s){return s.type===Wo.Object}t(Z9,"isAstObject");function KP(s){return s.type===Wo.Property}t(KP,"isAstProperty");function $Ae(s){return s.type===Wo.Array}t($Ae,"isAstArray");function xO(s){return s.type===Wo.Literal}t(xO,"isAstLiteral");function sI(s){if(s===void 0)throw new Error("Node is undefined");if(!Z9(s))throw new Error("Node is not object")}t(sI,"assertAstObject");import{findNodeAtLocation as Etr,getNodeValue as Ctr,printParseErrorCode as ktr,visit as wtr}from"jsonc-parser";var Dtr={DEFAULT:{allowTrailingComma:!1}};function VV(s,o=[],f=Dtr.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(W){d.type==="property"&&(d.length=W-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function E(W){return d.children?.push(W),W}t(E,"onValue"),wtr(s,{onObjectBegin:t((W,G,be)=>{d=E({type:"object",offset:W,length:-1,line:G+1,column:be+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,G,be,de,se)=>{d=E({type:"property",offset:G,length:-1,line:de+1,column:se+1,parent:d,children:[]}),d.children?.push({type:"string",value:W,offset:G,length:be,line:de,column:se,parent:d})},"onObjectProperty"),onObjectEnd:t((W,G)=>{y(W+G),d.length=W+G-d.offset,d=d.parent,y(W+G)},"onObjectEnd"),onArrayBegin:t((W,G,be,de)=>{d=E({type:"array",offset:W,length:-1,line:be+1,column:de+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((W,G)=>{d.length=W+G-d.offset,d=d.parent,y(W+G)},"onArrayEnd"),onLiteralValue:t((W,G,be,de,se)=>{E({type:Ptr(W),offset:G,length:be,line:de+1,column:se+1,parent:d,value:W}),y(G+be)},"onLiteralValue"),onSeparator:t((W,G)=>{d.type==="property"&&(W===":"?d.colonOffset=G:W===","&&y(G))},"onSeparator"),onError:t((W,G,be,de,se)=>{o.push({error:W,offset:G,length:be,line:de+1,column:se+1})},"onError")},f);let F=d.children?.[0];return F&&delete F.parent,F}t(VV,"parse");function Ptr(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(Ptr,"getNodeType");function JAe(s,o){return Etr(s,o)}t(JAe,"findNodeAtLocation");function HV(s){return Ctr(s)}t(HV,"getNodeValue");function tat(s){return ktr(s)}t(tat,"printParseErrorCode");var GV=class{static{t(this,"AstAdapter")}parse(o){let d=VV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:Wo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:Wo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){YP(o.children?.length===2,"Invalid property node");let d={type:Wo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:Wo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:Wo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var DS={createLiteral:t((s,o)=>({type:Wo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:Wo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:Wo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:Wo.Property,parent:f,name:null,value:o};return d.name={value:s,type:Wo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:Wo.Array,parent:o,children:[]};for(let d of s)f.children.push(DS.createLiteral(d,f));return f},"createArrayOfLiterals")};var Atr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,YV=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case Wo.Array:return this.generateArray(o,f);case Wo.Object:return this.generateObject(o,f);case Wo.Property:return this.generateProperty(o,f);case Wo.Literal:return this.generateLiteral(o,f);case Wo.FunctionCall:return this.generateFunctionCall(o,f);case Wo.Identifier:return this.generateIdentifier(o,f);case Wo.Raw:return this.generateRaw(o,f);case Wo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,E)=>{this.generateSource(o,d),y<E.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=Atr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Ntr from"node:fs/promises";import{parse as Itr}from"@swc/core";var rat=t(async s=>{let o=new Set;try{let f=await Ntr.readFile(s,"utf-8");(await Itr(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"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 WAe={$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 qAe={$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 VAe={$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=tp(Xce(),1),flt=tp(llt(),1);var ele=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new ult.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,flt.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.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 E={details:{}},A=y.instancePath.split("/");if(A.length>2){let W=A[1],G=A[2]?parseInt(A[2],10):0,be=A[3],de=Number.isNaN(G)?void 0:f[W][G][be];E={details:{property:W,index:G,field:be,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 W=y.instancePath.split("/"),G=W[W.length-1];y.message=`Value of property '${G}' must be '${y.params.type}'`}let F=Object.assign(y,E);d.push(F)}),d}};var mI=ele.instance;mI.addSchema(qAe,"route-configuration.schema.json");mI.addSchema(iat,"policy-configuration.schema.json");mI.addSchema(WAe,"policies.schema.json");mI.addSchema(VAe,"open-api-route-configuration.schema.json");mI.addSchema(nat,"fragments.schema.json");var N6r=mI.compile(qAe),_lt=mI.compile(VAe),oIe=mI.compile(WAe);var tle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=oIe(o),this.results}};var rle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=_lt(o),this.results}};import $cr from"node:path";var cIe=/\$import\((.*)\)/,wH=/\$env\((.*?)\)/g;var $k=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},zcr=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),tA=t((s,o)=>{if(!s)return!1;let f=zcr(s);return o.split("/").every((E,A)=>{let F=f[A];return F?E==="*"||KP(F)&&F.name.value===E?!0:E==="{}"?F.type===Wo.Object:E==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var nle=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),Z9(o)?o.children.forEach(f=>{this.visitor(f)}):$Ae(o)?o.children.forEach(f=>{this.visitor(f)}):KP(o)&&this.visitor(o.value)}},plt=t(s=>{let o=new RegExp(wH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(wH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),dlt=t((s,o,f)=>d=>{if(xO(d)&&typeof d.value=="string"&&d.parent&&$Ae(d.parent)){if(!s.some(A=>tA(d.parent,A))){wH.test(d.value)&&o.push(new $k("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=plt(d.value);if(E){let A=d.parent,F=A.children.indexOf(d);if(F!==-1)if(E.type==="raw"){let W={type:Wo.Raw,parent:A,value:E.value};A.children[F]=W}else A.children[F]=DS.createTemplateString(E.value,d)}return}if(!KP(d)||!xO(d.value)||typeof d.value.value!="string")return;if(!s.some(E=>tA(d,E))){wH.test(d.value.value)&&o.push(new $k("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=plt(d.value.value);if(y)if(y.type==="raw"){let E={type:Wo.Raw,parent:null,value:y.value};d.value=E}else d.value=DS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var DH="config/routes.json",Jcr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Wcr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],mlt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],qcr="handler/{}/options/{}/rewritePattern",Vcr="handler/{}/options/{}/baseUrl",ile=class extends nle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!KP(o)||!xO(o.value)||typeof o.value.value!="string")&&tA(o,qcr)){if(!o.parent||!Z9(o.parent)){this.errors.push(new $k("Invalid node, expected object",DH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:hlt(f)},y=DS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!KP(o)||!xO(o.value)||typeof o.value.value!="string")&&tA(o,Vcr)){if(!o.parent||!Z9(o.parent)){this.errors.push(new $k("Invalid node, expected object",DH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:hlt(f)},y=DS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!KP(o)||!xO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!Wcr.some(F=>tA(o,F))&&!mlt.some(F=>tA(o,F))){if(cIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new $k("An $import() statement is not expected at this location.",DH,o.location,f))}return}let d=cIe.exec(f);if(mlt.some(F=>tA(o,F))&&!d)return;if(!d){this.errors.push(new $k("Invalid $import() statement",DH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=$cr.posix.join("..",y));let E=this.getImportName(y),A={type:Wo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=dlt(Jcr,this.errors,DH)};function hlt(s){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;
|