@zuplo/cli 6.73.20 → 6.73.22
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/@fastify/forwarded/LICENSE +1 -3
- package/node_modules/@fastify/forwarded/index.js +1 -1
- package/node_modules/@fastify/forwarded/package.json +6 -6
- 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/out/esm/chunk-6IEB7H3W.js +26 -0
- package/node_modules/@zuplo/otel/out/esm/chunk-6IEB7H3W.js.map +1 -0
- package/node_modules/@zuplo/otel/out/esm/index.js +1 -1
- package/node_modules/@zuplo/otel/out/types/index.d.ts +2 -0
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-DBFG5V2I.js → chunk-6QCPRMBS.js} +77 -77
- package/node_modules/@zuplo/runtime/out/esm/chunk-6QCPRMBS.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +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 +73 -46
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +6 -6
- package/node_modules/@zuplo/otel/out/esm/chunk-JYT2Q52R.js +0 -26
- package/node_modules/@zuplo/otel/out/esm/chunk-JYT2Q52R.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-DBFG5V2I.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-DBFG5V2I.js.LEGAL.txt → chunk-6QCPRMBS.js.LEGAL.txt} +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2014-2017 Douglas Christopher Wilson
|
|
4
|
-
Copyright (c) 2021-present The Fastify team
|
|
5
|
-
|
|
6
|
-
The Fastify team members are listed at https://github.com/fastify/fastify#team.
|
|
4
|
+
Copyright (c) 2021-present The Fastify team <https://github.com/fastify/fastify#team>
|
|
7
5
|
|
|
8
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
7
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -39,7 +39,7 @@ function parse (header, socketAddr) {
|
|
|
39
39
|
|
|
40
40
|
for (i = end - 1; i >= 0; --i) {
|
|
41
41
|
char = header[i]
|
|
42
|
-
if (char === ' ') {
|
|
42
|
+
if (char === ' ' || char === '\t') {
|
|
43
43
|
(start === end) && (start = end = i)
|
|
44
44
|
} else if (char === ',') {
|
|
45
45
|
(start !== end) && result.push(header.slice(start, end))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastify/forwarded",
|
|
3
3
|
"description": "Parse HTTP X-Forwarded-For header",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.2",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
7
7
|
"contributors": [
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
}
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@types/node": "^
|
|
51
|
+
"@types/node": "^26.0.1",
|
|
52
52
|
"benchmark": "2.1.4",
|
|
53
|
-
"c8": "^
|
|
53
|
+
"c8": "^12.0.0",
|
|
54
54
|
"eslint": "^9.17.0",
|
|
55
|
-
"neostandard": "^0.
|
|
56
|
-
"
|
|
55
|
+
"neostandard": "^0.13.0",
|
|
56
|
+
"tstyche": "^7.0.0"
|
|
57
57
|
},
|
|
58
58
|
"types": "types/index.d.ts",
|
|
59
59
|
"files": [
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"lint:fix": "eslint --fix",
|
|
70
70
|
"test": "npm run test:unit && npm run test:typescript",
|
|
71
71
|
"test:unit": "c8 --100 node --test",
|
|
72
|
-
"test:typescript": "
|
|
72
|
+
"test:typescript": "tstyche"
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -572,7 +572,7 @@ globstar while`,s,de,o,se,Xe),this.matchOne(s.slice(de),o.slice(se),f))return th
|
|
|
572
572
|
`),stderr:x.join(`
|
|
573
573
|
`),exitCode:A},"Tar process logs")}}t(fZt,"tarFolder");async function _Zt({tarFilePath:s,outputDir:o,logger:f}){let d=[],y=[],x;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=>{x=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:x},"Untar process logs")}}t(_Zt,"untarFile");async function pZt(s){if(await iAe(s))return await XN.rm(s,{recursive:!0})}t(pZt,"deleteFolder");var eu=sAe;var Slt=Pp(Bst(),1);var Ust=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-fallback-model-v2","ai-gateway-model-filtering-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 HV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,x){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Uer=/[$_\p{ID_Start}]/u,zer=/[$_\u200C\u200D\p{ID_Continue}]/u,BAe=".*";function $er(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t($er,"Re");function Jst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],x=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&&Uer.test(W)||F!==d+1&&zer.test(W)){A+=s[F++];continue}break}if(!A){x(`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]==="?"){x(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!$er(s[W],!1)){x(`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]!=="?")){x(`Capturing groups are not allowed at ${W}`),G=!0;break}F+=s[W++]}if(G)continue;if(A){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`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=`[^${fT(o.delimiter)}]+?`,y=[],x=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"),Xe=t(wn=>wn,"Se"),Ue=o.encodePart||Xe,je="",Vt=t(wn=>{je+=wn},"U"),Ut=t(()=>{je.length&&(y.push(new HV(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 HV(3,"","",Ue(wn),"",xs));return}let bi;Jn?Jn==="*"?bi=BAe:bi=Jn:bi=d;let fc=2;bi===d?(fc=1,bi=""):bi===BAe&&(fc=0,bi="");let Ci;if(sn?Ci=sn:Jn&&(Ci=x++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new HV(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 fT(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(fT,"S");function zst(s){return s&&s.ignoreCase?"ui":"u"}t(zst,"X");function Jer(s,o,f){return qst(Wst(s,f),o,f)}t(Jer,"Z");function Q9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(Q9,"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+=fT(F.value):d+=`(?:${fT(F.value)})${Q9(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=BAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${Q9(F.modifier)}`:d+=`((?:${G})${Q9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${fT(F.prefix)}(${G})${fT(F.suffix)})`,d+=Q9(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)}]|$`,x=`[${fT(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,zst(f));f.strict||(d+=`(?:${x}(?=${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+=`(?=${x}|${y})`),new RegExp(d,zst(f))}t(qst,"F");var tI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Wer={delimiter:".",prefixes:"",sensitive:!0,strict:!0},qer={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Ver(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(Ver,"J");function Vst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(Vst,"Q");function Her(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t(Her,"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 Ger(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(Ger,"te");function Yer(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(Yer,"re");function Ker(s,o){return o||s===""?s:Hst(s)?Zst(s):Xst(s)}t(Ker,"ne");function Xer(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(Xer,"se");function Zer(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(Zer,"ie");function Qer(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(Qer,"ae");function etr(s,o,f){return Kst(o)===s&&(s=""),f||s===""?s:Qst(s)}t(etr,"oe");function ttr(s,o){return s=Her(s,":"),o||s===""?s:UAe(s)}t(ttr,"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 UAe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(UAe,"y");function rtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(rtr,"le");function ntr(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(ntr,"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 itr(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(itr,"he");function str(s){return s===""?s:new URL(`data:${s}`).pathname}t(str,"ue");function atr(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(atr,"de");function otr(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(otr,"pe");var ctr=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,tI),s.encodePart=UAe;let o=Jer(this.#w(),void 0,s);this.#p=Yst(o)}},jAe=["protocol","username","password","hostname","port","pathname","search","hash"],eI="*";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 qP(s,o){return o?VV(s):s}t(qP,"b");function qV(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=ttr(o.protocol,f)),typeof o.username=="string"&&(s.username=Zer(o.username,f)),typeof o.password=="string"&&(s.password=Xer(o.password,f)),typeof o.hostname=="string"&&(s.hostname=Ker(o.hostname,f)),typeof o.port=="string"&&(s.port=etr(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!Ver(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=qP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=Qer(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=Yer(o.search,f)),typeof o.hash=="string"&&(s.hash=Ger(o.hash,f)),s}t(qV,"w");function VV(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(VV,"C");function ltr(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(ltr,"Oe");function utr(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${ltr(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let A=0;A<s.length;++A){let F=s[A];if(F.type===3){if(F.modifier===3){x+=VV(F.value);continue}x+=`{${VV(F.value)}}${Q9(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&&(x+="{"),x+=VV(F.prefix),W&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?W||(x+=`(${d})`):F.type===0&&(!W&&(!be||be.type===3||be.modifier!==3||G||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=VV(F.suffix),G&&(x+="}"),F.modifier!==3&&(x+=Q9(F.modifier))}return x}t(utr,"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 ctr(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},x={pathname:eI,protocol:eI,username:eI,password:eI,hostname:eI,port:eI,search:eI,hash:eI};this.#e=qV(x,s,!0),Kst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let A;for(A of jAe){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=UAe;break;case"username":Object.assign(F,tI),F.encodePart=rtr;break;case"password":Object.assign(F,tI),F.encodePart=ntr;break;case"hostname":Object.assign(F,Wer),Hst(W)?F.encodePart=Zst:F.encodePart=Xst;break;case"port":Object.assign(F,tI),F.encodePart=Qst;break;case"pathname":Yst(this.#n.protocol)?(Object.assign(F,qer,y),F.encodePart=itr):(Object.assign(F,tI,y),F.encodePart=str);break;case"search":Object.assign(F,tI,y),F.encodePart=atr;break;case"hash":Object.assign(F,tI,y),F.encodePart=otr;break}try{this.#s[A]=Wst(W,F),this.#n[A]=qst(this.#s[A],this.#t[A],F),this.#r[A]=utr(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=qV(f,s,!1):f=qV(f,$st(s,o),!1)}catch{return!1}let d;for(d of jAe)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=qV(f,s,!1):f=qV(f,$st(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of jAe){let x=this.#n[y].exec(f[y]);if(!x)return null;let A={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let G=x[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 HV(3,"","","","",3),x=new HV(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],[x]):!o.#r[s]&&f.#r[s]?A([x],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 ftr}from"node:assert";function VP(s,o){if(s===!1)throw new ftr({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 eM(s){return s.type===Wo.Object}t(eM,"isAstObject");function HP(s){return s.type===Wo.Property}t(HP,"isAstProperty");function zAe(s){return s.type===Wo.Array}t(zAe,"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(!eM(s))throw new Error("Node is not object")}t(rI,"assertAstObject");import{findNodeAtLocation as _tr,getNodeValue as ptr,printParseErrorCode as dtr,visit as mtr}from"jsonc-parser";var htr={DEFAULT:{allowTrailingComma:!1}};function GV(s,o=[],f=htr.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 x(W){return d.children?.push(W),W}t(x,"onValue"),mtr(s,{onObjectBegin:t((W,G,be)=>{d=x({type:"object",offset:W,length:-1,line:G+1,column:be+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,G,be,de,se)=>{d=x({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=x({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)=>{x({type:gtr(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(GV,"parse");function gtr(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(gtr,"getNodeType");function $Ae(s,o){return _tr(s,o)}t($Ae,"findNodeAtLocation");function YV(s){return ptr(s)}t(YV,"getNodeValue");function tat(s){return dtr(s)}t(tat,"printParseErrorCode");var KV=class{static{t(this,"AstAdapter")}parse(o){let d=GV(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 ytr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,XV=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,x)=>{this.generateSource(o,d),y<x.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=ytr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import vtr from"node:fs/promises";import{parse as btr}from"@swc/core";var rat=t(async s=>{let o=new Set;try{let f=await vtr.readFile(s,"utf-8");(await btr(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 JAe={$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 WAe={$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 qAe={$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=Pp(ele(),1),flt=Pp(llt(),1);var nle=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 x={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];x={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,x);d.push(F)}),d}};var _I=nle.instance;_I.addSchema(WAe,"route-configuration.schema.json");_I.addSchema(iat,"policy-configuration.schema.json");_I.addSchema(JAe,"policies.schema.json");_I.addSchema(qAe,"open-api-route-configuration.schema.json");_I.addSchema(nat,"fragments.schema.json");var C6r=_I.compile(WAe),_lt=_I.compile(qAe),aIe=_I.compile(JAe);var ile=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=aIe(o),this.results}};var sle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=_lt(o),this.results}};import Acr from"node:path";var oIe=/\$import\((.*)\)/,PH=/\$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:""}}},Pcr=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=Pcr(s);return o.split("/").every((x,A)=>{let F=f[A];return F?x==="*"||HP(F)&&F.name.value===x?!0:x==="{}"?F.type===Wo.Object:x==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var ale=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),eM(o)?o.children.forEach(f=>{this.visitor(f)}):zAe(o)?o.children.forEach(f=>{this.visitor(f)}):HP(o)&&this.visitor(o.value)}},plt=t(s=>{let o=new RegExp(PH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(PH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),dlt=t((s,o,f)=>d=>{if(SO(d)&&typeof d.value=="string"&&d.parent&&zAe(d.parent)){if(!s.some(A=>ZP(d.parent,A))){PH.test(d.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let x=plt(d.value);if(x){let A=d.parent,F=A.children.indexOf(d);if(F!==-1)if(x.type==="raw"){let W={type:Wo.Raw,parent:A,value:x.value};A.children[F]=W}else A.children[F]=DS.createTemplateString(x.value,d)}return}if(!HP(d)||!SO(d.value)||typeof d.value.value!="string")return;if(!s.some(x=>ZP(d,x))){PH.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=plt(d.value.value);if(y)if(y.type==="raw"){let x={type:Wo.Raw,parent:null,value:y.value};d.value=x}else d.value=DS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var AH="config/routes.json",Ncr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Icr=["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/*"],Ocr="handler/{}/options/{}/rewritePattern",Fcr="handler/{}/options/{}/baseUrl",ole=class extends ale{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,Ocr)){if(!o.parent||!eM(o.parent)){this.errors.push(new Uk("Invalid node, expected object",AH,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(!(!HP(o)||!SO(o.value)||typeof o.value.value!="string")&&ZP(o,Fcr)){if(!o.parent||!eM(o.parent)){this.errors.push(new Uk("Invalid node, expected object",AH,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(!HP(o)||!SO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!Icr.some(F=>ZP(o,F))&&!mlt.some(F=>ZP(o,F))){if(oIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Uk("An $import() statement is not expected at this location.",AH,o.location,f))}return}let d=oIe.exec(f);if(mlt.some(F=>ZP(o,F))&&!d)return;if(!d){this.errors.push(new Uk("Invalid $import() statement",AH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Acr.posix.join("..",y));let x=this.getImportName(y),A={type:Wo.Identifier,parent:o.parent,value:x};o.value=A}replaceEnvStatements=dlt(Ncr,this.errors,AH)};function hlt(s){return`(request, context) => {
|
|
575
|
+
`),exitCode:x},"Untar process logs")}}t(_Zt,"untarFile");async function pZt(s){if(await iAe(s))return await XN.rm(s,{recursive:!0})}t(pZt,"deleteFolder");var eu=sAe;var Slt=Pp(Bst(),1);var Ust=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-fallback-model-v2","ai-gateway-model-filtering-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 HV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,x){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Uer=/[$_\p{ID_Start}]/u,zer=/[$_\u200C\u200D\p{ID_Continue}]/u,BAe=".*";function $er(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t($er,"Re");function Jst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],x=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&&Uer.test(W)||F!==d+1&&zer.test(W)){A+=s[F++];continue}break}if(!A){x(`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]==="?"){x(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!$er(s[W],!1)){x(`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]!=="?")){x(`Capturing groups are not allowed at ${W}`),G=!0;break}F+=s[W++]}if(G)continue;if(A){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`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=`[^${fT(o.delimiter)}]+?`,y=[],x=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"),Xe=t(wn=>wn,"Se"),Ue=o.encodePart||Xe,je="",Vt=t(wn=>{je+=wn},"U"),Ut=t(()=>{je.length&&(y.push(new HV(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 HV(3,"","",Ue(wn),"",xs));return}let bi;Jn?Jn==="*"?bi=BAe:bi=Jn:bi=d;let fc=2;bi===d?(fc=1,bi=""):bi===BAe&&(fc=0,bi="");let Ci;if(sn?Ci=sn:Jn&&(Ci=x++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new HV(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 fT(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(fT,"S");function zst(s){return s&&s.ignoreCase?"ui":"u"}t(zst,"X");function Jer(s,o,f){return qst(Wst(s,f),o,f)}t(Jer,"Z");function Q9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(Q9,"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+=fT(F.value):d+=`(?:${fT(F.value)})${Q9(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=BAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${Q9(F.modifier)}`:d+=`((?:${G})${Q9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${fT(F.prefix)}(${G})${fT(F.suffix)})`,d+=Q9(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)}]|$`,x=`[${fT(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,zst(f));f.strict||(d+=`(?:${x}(?=${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+=`(?=${x}|${y})`),new RegExp(d,zst(f))}t(qst,"F");var tI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Wer={delimiter:".",prefixes:"",sensitive:!0,strict:!0},qer={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Ver(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(Ver,"J");function Vst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(Vst,"Q");function Her(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t(Her,"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 Ger(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(Ger,"te");function Yer(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(Yer,"re");function Ker(s,o){return o||s===""?s:Hst(s)?Zst(s):Xst(s)}t(Ker,"ne");function Xer(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(Xer,"se");function Zer(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(Zer,"ie");function Qer(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(Qer,"ae");function etr(s,o,f){return Kst(o)===s&&(s=""),f||s===""?s:Qst(s)}t(etr,"oe");function ttr(s,o){return s=Her(s,":"),o||s===""?s:UAe(s)}t(ttr,"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 UAe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(UAe,"y");function rtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(rtr,"le");function ntr(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(ntr,"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 itr(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(itr,"he");function str(s){return s===""?s:new URL(`data:${s}`).pathname}t(str,"ue");function atr(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(atr,"de");function otr(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(otr,"pe");var ctr=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,tI),s.encodePart=UAe;let o=Jer(this.#w(),void 0,s);this.#p=Yst(o)}},jAe=["protocol","username","password","hostname","port","pathname","search","hash"],eI="*";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 qP(s,o){return o?VV(s):s}t(qP,"b");function qV(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=ttr(o.protocol,f)),typeof o.username=="string"&&(s.username=Zer(o.username,f)),typeof o.password=="string"&&(s.password=Xer(o.password,f)),typeof o.hostname=="string"&&(s.hostname=Ker(o.hostname,f)),typeof o.port=="string"&&(s.port=etr(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!Ver(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=qP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=Qer(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=Yer(o.search,f)),typeof o.hash=="string"&&(s.hash=Ger(o.hash,f)),s}t(qV,"w");function VV(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(VV,"C");function ltr(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(ltr,"Oe");function utr(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${ltr(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let A=0;A<s.length;++A){let F=s[A];if(F.type===3){if(F.modifier===3){x+=VV(F.value);continue}x+=`{${VV(F.value)}}${Q9(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&&(x+="{"),x+=VV(F.prefix),W&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?W||(x+=`(${d})`):F.type===0&&(!W&&(!be||be.type===3||be.modifier!==3||G||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=VV(F.suffix),G&&(x+="}"),F.modifier!==3&&(x+=Q9(F.modifier))}return x}t(utr,"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 ctr(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},x={pathname:eI,protocol:eI,username:eI,password:eI,hostname:eI,port:eI,search:eI,hash:eI};this.#e=qV(x,s,!0),Kst(this.#e.protocol)===this.#e.port&&(this.#e.port="");let A;for(A of jAe){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=UAe;break;case"username":Object.assign(F,tI),F.encodePart=rtr;break;case"password":Object.assign(F,tI),F.encodePart=ntr;break;case"hostname":Object.assign(F,Wer),Hst(W)?F.encodePart=Zst:F.encodePart=Xst;break;case"port":Object.assign(F,tI),F.encodePart=Qst;break;case"pathname":Yst(this.#n.protocol)?(Object.assign(F,qer,y),F.encodePart=itr):(Object.assign(F,tI,y),F.encodePart=str);break;case"search":Object.assign(F,tI,y),F.encodePart=atr;break;case"hash":Object.assign(F,tI,y),F.encodePart=otr;break}try{this.#s[A]=Wst(W,F),this.#n[A]=qst(this.#s[A],this.#t[A],F),this.#r[A]=utr(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=qV(f,s,!1):f=qV(f,$st(s,o),!1)}catch{return!1}let d;for(d of jAe)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=qV(f,s,!1):f=qV(f,$st(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of jAe){let x=this.#n[y].exec(f[y]);if(!x)return null;let A={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let G=x[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 HV(3,"","","","",3),x=new HV(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],[x]):!o.#r[s]&&f.#r[s]?A([x],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 ftr}from"node:assert";function VP(s,o){if(s===!1)throw new ftr({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 eM(s){return s.type===Wo.Object}t(eM,"isAstObject");function HP(s){return s.type===Wo.Property}t(HP,"isAstProperty");function zAe(s){return s.type===Wo.Array}t(zAe,"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(!eM(s))throw new Error("Node is not object")}t(rI,"assertAstObject");import{findNodeAtLocation as _tr,getNodeValue as ptr,printParseErrorCode as dtr,visit as mtr}from"jsonc-parser";var htr={DEFAULT:{allowTrailingComma:!1}};function GV(s,o=[],f=htr.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 x(W){return d.children?.push(W),W}t(x,"onValue"),mtr(s,{onObjectBegin:t((W,G,be)=>{d=x({type:"object",offset:W,length:-1,line:G+1,column:be+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,G,be,de,se)=>{d=x({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=x({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)=>{x({type:gtr(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(GV,"parse");function gtr(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(gtr,"getNodeType");function $Ae(s,o){return _tr(s,o)}t($Ae,"findNodeAtLocation");function YV(s){return ptr(s)}t(YV,"getNodeValue");function tat(s){return dtr(s)}t(tat,"printParseErrorCode");var KV=class{static{t(this,"AstAdapter")}parse(o){let d=GV(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 ytr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,XV=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,x)=>{this.generateSource(o,d),y<x.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=ytr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import vtr from"node:fs/promises";import{parse as btr}from"@swc/core";var rat=t(async s=>{let o=new Set;try{let f=await vtr.readFile(s,"utf-8");(await btr(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 JAe={$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 WAe={$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 qAe={$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=Pp(ele(),1),flt=Pp(llt(),1);var nle=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 x={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];x={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,x);d.push(F)}),d}};var _I=nle.instance;_I.addSchema(WAe,"route-configuration.schema.json");_I.addSchema(iat,"policy-configuration.schema.json");_I.addSchema(JAe,"policies.schema.json");_I.addSchema(qAe,"open-api-route-configuration.schema.json");_I.addSchema(nat,"fragments.schema.json");var C6r=_I.compile(WAe),_lt=_I.compile(qAe),aIe=_I.compile(JAe);var ile=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=aIe(o),this.results}};var sle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=_lt(o),this.results}};import Acr from"node:path";var oIe=/\$import\((.*)\)/,PH=/\$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:""}}},Pcr=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=Pcr(s);return o.split("/").every((x,A)=>{let F=f[A];return F?x==="*"||HP(F)&&F.name.value===x?!0:x==="{}"?F.type===Wo.Object:x==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var ale=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),eM(o)?o.children.forEach(f=>{this.visitor(f)}):zAe(o)?o.children.forEach(f=>{this.visitor(f)}):HP(o)&&this.visitor(o.value)}},plt=t(s=>{let o=new RegExp(PH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(PH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),dlt=t((s,o,f)=>d=>{if(SO(d)&&typeof d.value=="string"&&d.parent&&zAe(d.parent)){if(!s.some(A=>ZP(d.parent,A))){PH.test(d.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let x=plt(d.value);if(x){let A=d.parent,F=A.children.indexOf(d);if(F!==-1)if(x.type==="raw"){let W={type:Wo.Raw,parent:A,value:x.value};A.children[F]=W}else A.children[F]=DS.createTemplateString(x.value,d)}return}if(!HP(d)||!SO(d.value)||typeof d.value.value!="string")return;if(!s.some(x=>ZP(d,x))){PH.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=plt(d.value.value);if(y)if(y.type==="raw"){let x={type:Wo.Raw,parent:null,value:y.value};d.value=x}else d.value=DS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var AH="config/routes.json",Ncr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Icr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","handler/{}/options/{}/onOpen/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],mlt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Ocr="handler/{}/options/{}/rewritePattern",Fcr="handler/{}/options/{}/baseUrl",ole=class extends ale{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,Ocr)){if(!o.parent||!eM(o.parent)){this.errors.push(new Uk("Invalid node, expected object",AH,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(!(!HP(o)||!SO(o.value)||typeof o.value.value!="string")&&ZP(o,Fcr)){if(!o.parent||!eM(o.parent)){this.errors.push(new Uk("Invalid node, expected object",AH,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(!HP(o)||!SO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!Icr.some(F=>ZP(o,F))&&!mlt.some(F=>ZP(o,F))){if(oIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Uk("An $import() statement is not expected at this location.",AH,o.location,f))}return}let d=oIe.exec(f);if(mlt.some(F=>ZP(o,F))&&!d)return;if(!d){this.errors.push(new Uk("Invalid $import() statement",AH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Acr.posix.join("..",y));let x=this.getImportName(y),A={type:Wo.Identifier,parent:o.parent,value:x};o.value=A}replaceEnvStatements=dlt(Ncr,this.errors,AH)};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;
|
|
@@ -572,7 +572,7 @@ globstar while`,s,de,o,se,Xe),this.matchOne(s.slice(de),o.slice(se),f))return th
|
|
|
572
572
|
`),stderr:x.join(`
|
|
573
573
|
`),exitCode:P},"Tar process logs")}}t(LZt,"tarFolder");async function RZt({tarFilePath:s,outputDir:o,logger:f}){let d=[],y=[],x;try{await new Promise((P,F)=>{let W=Tit("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=>{x=G,G===0?P():F(new Error(`tar process exited with code ${G}`))}),W.on("error",G=>{F(G)})})}catch(P){throw new Error("Failed to untar file",{cause:P})}finally{f.info({stdout:d.join(`
|
|
574
574
|
`),stderr:y.join(`
|
|
575
|
-
`),exitCode:x},"Untar process logs")}}t(RZt,"untarFile");async function MZt(s){if(await lAe(s))return await eI.rm(s,{recursive:!0})}t(MZt,"deleteFolder");var eu=uAe;var Dlt=B_(Vst(),1);var Hst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-fallback-model-v2","ai-gateway-model-filtering-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 GV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,x){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},utr=/[$_\p{ID_Start}]/u,ftr=/[$_\u200C\u200D\p{ID_Continue}]/u,WAe=".*";function _tr(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(_tr,"Re");function Kst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],x=t(function(P){if(!o)throw new TypeError(P);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 P="",F=d+1;for(;F<s.length;){let W=s.substr(F,1);if(F===d+1&&utr.test(W)||F!==d+1&&ftr.test(W)){P+=s[F++];continue}break}if(!P){x(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:P}),d=F;continue}if(y==="("){let P=1,F="",W=d+1,G=!1;if(s[W]==="?"){x(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!_tr(s[W],!1)){x(`Invalid character '${s[W]}' at ${W}.`),G=!0;break}if(s[W]==="\\"){F+=s[W++]+s[W++];continue}if(s[W]===")"){if(P--,P===0){W++;break}}else if(s[W]==="("&&(P++,s[W+1]!=="?")){x(`Capturing groups are not allowed at ${W}`),G=!0;break}F+=s[W++]}if(G)continue;if(P){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=W;continue}f.push({type:"CHAR",index:d,value:s[d++]})}return f.push({type:"END",index:d,value:""}),f}t(Kst,"v");function Xst(s,o={}){let f=Kst(s);o.delimiter??="/#?",o.prefixes??="./";let d=`[^${_T(o.delimiter)}]+?`,y=[],x=0,P=0,F="",W=new Set,G=t(wn=>{if(P<f.length&&f[P].type===wn)return f[P++].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[P];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"),Xe=t(wn=>wn,"Se"),Ue=o.encodePart||Xe,je="",Vt=t(wn=>{je+=wn},"U"),Ut=t(()=>{je.length&&(y.push(new GV(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 GV(3,"","",Ue(wn),"",xs));return}let bi;Jn?Jn==="*"?bi=WAe:bi=Jn:bi=d;let fc=2;bi===d?(fc=1,bi=""):bi===WAe&&(fc=0,bi="");let Ci;if(sn?Ci=sn:Jn&&(Ci=x++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new GV(fc,Ci,Ue(wn),bi,Ue(kr),xs))},"V");for(;P<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(Xst,"D");function _T(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(_T,"S");function Gst(s){return s&&s.ignoreCase?"ui":"u"}t(Gst,"X");function ptr(s,o,f){return Zst(Xst(s,f),o,f)}t(ptr,"Z");function Q9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(Q9,"k");function Zst(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)})${Q9(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=WAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${Q9(F.modifier)}`:d+=`((?:${G})${Q9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${_T(F.prefix)}(${G})${_T(F.suffix)})`,d+=Q9(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)}]|$`,x=`[${_T(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Gst(f));f.strict||(d+=`(?:${x}(?=${y}))?`);let P=!1;if(s.length){let F=s[s.length-1];F.type===3&&F.modifier===3&&(P=f.delimiter.indexOf(F)>-1)}return P||(d+=`(?=${x}|${y})`),new RegExp(d,Gst(f))}t(Zst,"F");var iI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},dtr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},mtr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function htr(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(htr,"J");function Qst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(Qst,"Q");function gtr(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t(gtr,"Ee");function eat(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t(eat,"W");var tat=["ftp","file","http","https","ws","wss"];function rat(s){if(!s)return!0;for(let o of tat)if(s.test(o))return!0;return!1}t(rat,"N");function ytr(s,o){if(s=Qst(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(ytr,"te");function vtr(s,o){if(s=Qst(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(vtr,"re");function btr(s,o){return o||s===""?s:eat(s)?sat(s):iat(s)}t(btr,"ne");function Str(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(Str,"se");function Ttr(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(Ttr,"ie");function xtr(s,o,f){if(f||s==="")return s;if(o&&!tat.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(xtr,"ae");function Etr(s,o,f){return nat(o)===s&&(s=""),f||s===""?s:aat(s)}t(Etr,"oe");function Ctr(s,o){return s=gtr(s,":"),o||s===""?s:qAe(s)}t(Ctr,"ce");function nat(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(nat,"_");function qAe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(qAe,"y");function ktr(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(ktr,"le");function wtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(wtr,"fe");function iat(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(iat,"z");function sat(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(sat,"j");function aat(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(aat,"K");function Dtr(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(Dtr,"he");function Ptr(s){return s===""?s:new URL(`data:${s}`).pathname}t(Ptr,"ue");function Atr(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(Atr,"de");function Ntr(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(Ntr,"pe");var Itr=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=Kst(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=qAe;let o=ptr(this.#w(),void 0,s);this.#p=rat(o)}},JAe=["protocol","username","password","hostname","port","pathname","search","hash"],nI="*";function Yst(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(Yst,"ge");function GP(s,o){return o?HV(s):s}t(GP,"b");function VV(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=Ctr(o.protocol,f)),typeof o.username=="string"&&(s.username=Ttr(o.username,f)),typeof o.password=="string"&&(s.password=Str(o.password,f)),typeof o.hostname=="string"&&(s.hostname=btr(o.hostname,f)),typeof o.port=="string"&&(s.port=Etr(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!htr(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=GP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=xtr(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=vtr(o.search,f)),typeof o.hash=="string"&&(s.hash=ytr(o.hash,f)),s}t(VV,"w");function HV(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(HV,"C");function Otr(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Otr,"Oe");function Ftr(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${Otr(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let P=0;P<s.length;++P){let F=s[P];if(F.type===3){if(F.modifier===3){x+=HV(F.value);continue}x+=`{${HV(F.value)}}${Q9(F.modifier)}`;continue}let W=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!o.prefixes.includes(F.prefix)),be=P>0?s[P-1]:null,de=P<s.length-1?s[P+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&&(x+="{"),x+=HV(F.prefix),W&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?W||(x+=`(${d})`):F.type===0&&(!W&&(!be||be.type===3||be.modifier!==3||G||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=HV(F.suffix),G&&(x+="}"),F.modifier!==3&&(x+=Q9(F.modifier))}return x}t(Ftr,"ke");var oat=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 Itr(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},x={pathname:nI,protocol:nI,username:nI,password:nI,hostname:nI,port:nI,search:nI,hash:nI};this.#e=VV(x,s,!0),nat(this.#e.protocol)===this.#e.port&&(this.#e.port="");let P;for(P of JAe){if(!(P in this.#e))continue;let F={},W=this.#e[P];switch(this.#t[P]=[],P){case"protocol":Object.assign(F,iI),F.encodePart=qAe;break;case"username":Object.assign(F,iI),F.encodePart=ktr;break;case"password":Object.assign(F,iI),F.encodePart=wtr;break;case"hostname":Object.assign(F,dtr),eat(W)?F.encodePart=sat:F.encodePart=iat;break;case"port":Object.assign(F,iI),F.encodePart=aat;break;case"pathname":rat(this.#n.protocol)?(Object.assign(F,mtr,y),F.encodePart=Dtr):(Object.assign(F,iI,y),F.encodePart=Ptr);break;case"search":Object.assign(F,iI,y),F.encodePart=Atr;break;case"hash":Object.assign(F,iI,y),F.encodePart=Ntr;break}try{this.#s[P]=Xst(W,F),this.#n[P]=Zst(this.#s[P],this.#t[P],F),this.#r[P]=Ftr(this.#s[P],F),this.#m=this.#m||this.#s[P].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${P} pattern '${this.#e[P]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(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=VV(f,s,!1):f=VV(f,Yst(s,o),!1)}catch{return!1}let d;for(d of JAe)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=VV(f,s,!1):f=VV(f,Yst(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of JAe){let x=this.#n[y].exec(f[y]);if(!x)return null;let P={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let G=x[F+1];P[W]=G}d[y]={input:f[y]??"",groups:P}}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 GV(3,"","","","",3),x=new GV(0,"","","","",3),P=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]?P(o.#s[s],[x]):!o.#r[s]&&f.#r[s]?P([x],f.#s[s]):P(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=oat);import{AssertionError as Ltr}from"node:assert";function YP(s,o){if(s===!1)throw new Ltr({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 eM(s){return s.type===Wo.Object}t(eM,"isAstObject");function KP(s){return s.type===Wo.Property}t(KP,"isAstProperty");function VAe(s){return s.type===Wo.Array}t(VAe,"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(!eM(s))throw new Error("Node is not object")}t(sI,"assertAstObject");import{findNodeAtLocation as Rtr,getNodeValue as Mtr,printParseErrorCode as jtr,visit as Btr}from"jsonc-parser";var Utr={DEFAULT:{allowTrailingComma:!1}};function YV(s,o=[],f=Utr.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 x(W){return d.children?.push(W),W}t(x,"onValue"),Btr(s,{onObjectBegin:t((W,G,be)=>{d=x({type:"object",offset:W,length:-1,line:G+1,column:be+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,G,be,de,se)=>{d=x({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=x({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)=>{x({type:ztr(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(YV,"parse");function ztr(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(ztr,"getNodeType");function HAe(s,o){return Rtr(s,o)}t(HAe,"findNodeAtLocation");function KV(s){return Mtr(s)}t(KV,"getNodeValue");function cat(s){return jtr(s)}t(cat,"printParseErrorCode");var XV=class{static{t(this,"AstAdapter")}parse(o){let d=YV(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 $tr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,ZV=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,x)=>{this.generateSource(o,d),y<x.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=$tr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Jtr from"node:fs/promises";import{parse as Wtr}from"@swc/core";var lat=t(async s=>{let o=new Set;try{let f=await Jtr.readFile(s,"utf-8");(await Wtr(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 uat={$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 GAe={$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 fat={$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 YAe={$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 KAe={$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 glt=B_(tle(),1),ylt=B_(hlt(),1);var ile=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new glt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,ylt.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 x={details:{}},P=y.instancePath.split("/");if(P.length>2){let W=P[1],G=P[2]?parseInt(P[2],10):0,be=P[3],de=Number.isNaN(G)?void 0:f[W][G][be];x={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,x);d.push(F)}),d}};var mI=ile.instance;mI.addSchema(YAe,"route-configuration.schema.json");mI.addSchema(fat,"policy-configuration.schema.json");mI.addSchema(GAe,"policies.schema.json");mI.addSchema(KAe,"open-api-route-configuration.schema.json");mI.addSchema(uat,"fragments.schema.json");var Y6r=mI.compile(YAe),vlt=mI.compile(KAe),fIe=mI.compile(GAe);var sle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=fIe(o),this.results}};var ale=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=vlt(o),this.results}};import elr from"node:path";var _Ie=/\$import\((.*)\)/,AH=/\$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:""}}},Qcr=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=Qcr(s);return o.split("/").every((x,P)=>{let F=f[P];return F?x==="*"||KP(F)&&F.name.value===x?!0:x==="{}"?F.type===Wo.Object:x==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var ole=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),eM(o)?o.children.forEach(f=>{this.visitor(f)}):VAe(o)?o.children.forEach(f=>{this.visitor(f)}):KP(o)&&this.visitor(o.value)}},blt=t(s=>{let o=new RegExp(AH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(AH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),Slt=t((s,o,f)=>d=>{if(xO(d)&&typeof d.value=="string"&&d.parent&&VAe(d.parent)){if(!s.some(P=>tA(d.parent,P))){AH.test(d.value)&&o.push(new $k("An $env() statement is not expected at this location.",f,d.location,d.value));return}let x=blt(d.value);if(x){let P=d.parent,F=P.children.indexOf(d);if(F!==-1)if(x.type==="raw"){let W={type:Wo.Raw,parent:P,value:x.value};P.children[F]=W}else P.children[F]=DS.createTemplateString(x.value,d)}return}if(!KP(d)||!xO(d.value)||typeof d.value.value!="string")return;if(!s.some(x=>tA(d,x))){AH.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=blt(d.value.value);if(y)if(y.type==="raw"){let x={type:Wo.Raw,parent:null,value:y.value};d.value=x}else d.value=DS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var NH="config/routes.json",tlr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],rlr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Tlt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],nlr="handler/{}/options/{}/rewritePattern",ilr="handler/{}/options/{}/baseUrl",cle=class extends ole{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,nlr)){if(!o.parent||!eM(o.parent)){this.errors.push(new $k("Invalid node, expected object",NH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:xlt(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,ilr)){if(!o.parent||!eM(o.parent)){this.errors.push(new $k("Invalid node, expected object",NH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:xlt(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(!rlr.some(F=>tA(o,F))&&!Tlt.some(F=>tA(o,F))){if(_Ie.test(f)){if(o.name.value==="$ref")return;this.errors.push(new $k("An $import() statement is not expected at this location.",NH,o.location,f))}return}let d=_Ie.exec(f);if(Tlt.some(F=>tA(o,F))&&!d)return;if(!d){this.errors.push(new $k("Invalid $import() statement",NH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=elr.posix.join("..",y));let x=this.getImportName(y),P={type:Wo.Identifier,parent:o.parent,value:x};o.value=P}replaceEnvStatements=Slt(tlr,this.errors,NH)};function xlt(s){return`(request, context) => {
|
|
575
|
+
`),exitCode:x},"Untar process logs")}}t(RZt,"untarFile");async function MZt(s){if(await lAe(s))return await eI.rm(s,{recursive:!0})}t(MZt,"deleteFolder");var eu=uAe;var Dlt=B_(Vst(),1);var Hst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-fallback-model-v2","ai-gateway-model-filtering-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 GV=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,o,f,d,y,x){this.type=s,this.name=o,this.prefix=f,this.value=d,this.suffix=y,this.modifier=x}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},utr=/[$_\p{ID_Start}]/u,ftr=/[$_\u200C\u200D\p{ID_Continue}]/u,WAe=".*";function _tr(s,o){return(o?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(_tr,"Re");function Kst(s,o=!1){let f=[],d=0;for(;d<s.length;){let y=s[d],x=t(function(P){if(!o)throw new TypeError(P);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 P="",F=d+1;for(;F<s.length;){let W=s.substr(F,1);if(F===d+1&&utr.test(W)||F!==d+1&&ftr.test(W)){P+=s[F++];continue}break}if(!P){x(`Missing parameter name at ${d}`);continue}f.push({type:"NAME",index:d,value:P}),d=F;continue}if(y==="("){let P=1,F="",W=d+1,G=!1;if(s[W]==="?"){x(`Pattern cannot start with "?" at ${W}`);continue}for(;W<s.length;){if(!_tr(s[W],!1)){x(`Invalid character '${s[W]}' at ${W}.`),G=!0;break}if(s[W]==="\\"){F+=s[W++]+s[W++];continue}if(s[W]===")"){if(P--,P===0){W++;break}}else if(s[W]==="("&&(P++,s[W+1]!=="?")){x(`Capturing groups are not allowed at ${W}`),G=!0;break}F+=s[W++]}if(G)continue;if(P){x(`Unbalanced pattern at ${d}`);continue}if(!F){x(`Missing pattern at ${d}`);continue}f.push({type:"REGEX",index:d,value:F}),d=W;continue}f.push({type:"CHAR",index:d,value:s[d++]})}return f.push({type:"END",index:d,value:""}),f}t(Kst,"v");function Xst(s,o={}){let f=Kst(s);o.delimiter??="/#?",o.prefixes??="./";let d=`[^${_T(o.delimiter)}]+?`,y=[],x=0,P=0,F="",W=new Set,G=t(wn=>{if(P<f.length&&f[P].type===wn)return f[P++].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[P];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"),Xe=t(wn=>wn,"Se"),Ue=o.encodePart||Xe,je="",Vt=t(wn=>{je+=wn},"U"),Ut=t(()=>{je.length&&(y.push(new GV(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 GV(3,"","",Ue(wn),"",xs));return}let bi;Jn?Jn==="*"?bi=WAe:bi=Jn:bi=d;let fc=2;bi===d?(fc=1,bi=""):bi===WAe&&(fc=0,bi="");let Ci;if(sn?Ci=sn:Jn&&(Ci=x++),W.has(Ci))throw new TypeError(`Duplicate name '${Ci}'.`);W.add(Ci),y.push(new GV(fc,Ci,Ue(wn),bi,Ue(kr),xs))},"V");for(;P<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(Xst,"D");function _T(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(_T,"S");function Gst(s){return s&&s.ignoreCase?"ui":"u"}t(Gst,"X");function ptr(s,o,f){return Zst(Xst(s,f),o,f)}t(ptr,"Z");function Q9(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(Q9,"k");function Zst(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)})${Q9(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=WAe),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?d+=`(${G})${Q9(F.modifier)}`:d+=`((?:${G})${Q9(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){d+=`(?:${_T(F.prefix)}(${G})${_T(F.suffix)})`,d+=Q9(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)}]|$`,x=`[${_T(f.delimiter)}]`;if(f.end)return f.strict||(d+=`${x}?`),f.endsWith.length?d+=`(?=${y})`:d+="$",new RegExp(d,Gst(f));f.strict||(d+=`(?:${x}(?=${y}))?`);let P=!1;if(s.length){let F=s[s.length-1];F.type===3&&F.modifier===3&&(P=f.delimiter.indexOf(F)>-1)}return P||(d+=`(?=${x}|${y})`),new RegExp(d,Gst(f))}t(Zst,"F");var iI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},dtr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},mtr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function htr(s,o){return s.length?s[0]==="/"?!0:!o||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(htr,"J");function Qst(s,o){return s.startsWith(o)?s.substring(o.length,s.length):s}t(Qst,"Q");function gtr(s,o){return s.endsWith(o)?s.substr(0,s.length-o.length):s}t(gtr,"Ee");function eat(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t(eat,"W");var tat=["ftp","file","http","https","ws","wss"];function rat(s){if(!s)return!0;for(let o of tat)if(s.test(o))return!0;return!1}t(rat,"N");function ytr(s,o){if(s=Qst(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(ytr,"te");function vtr(s,o){if(s=Qst(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(vtr,"re");function btr(s,o){return o||s===""?s:eat(s)?sat(s):iat(s)}t(btr,"ne");function Str(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.password=s,f.password}t(Str,"se");function Ttr(s,o){if(o||s==="")return s;let f=new URL("https://example.com");return f.username=s,f.username}t(Ttr,"ie");function xtr(s,o,f){if(f||s==="")return s;if(o&&!tat.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(xtr,"ae");function Etr(s,o,f){return nat(o)===s&&(s=""),f||s===""?s:aat(s)}t(Etr,"oe");function Ctr(s,o){return s=gtr(s,":"),o||s===""?s:qAe(s)}t(Ctr,"ce");function nat(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(nat,"_");function qAe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(qAe,"y");function ktr(s){if(s==="")return s;let o=new URL("https://example.com");return o.username=s,o.username}t(ktr,"le");function wtr(s){if(s==="")return s;let o=new URL("https://example.com");return o.password=s,o.password}t(wtr,"fe");function iat(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(iat,"z");function sat(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(sat,"j");function aat(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(aat,"K");function Dtr(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(Dtr,"he");function Ptr(s){return s===""?s:new URL(`data:${s}`).pathname}t(Ptr,"ue");function Atr(s){if(s==="")return s;let o=new URL("https://example.com");return o.search=s,o.search.substring(1,o.search.length)}t(Atr,"de");function Ntr(s){if(s==="")return s;let o=new URL("https://example.com");return o.hash=s,o.hash.substring(1,o.hash.length)}t(Ntr,"pe");var Itr=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=Kst(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=qAe;let o=ptr(this.#w(),void 0,s);this.#p=rat(o)}},JAe=["protocol","username","password","hostname","port","pathname","search","hash"],nI="*";function Yst(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(Yst,"ge");function GP(s,o){return o?HV(s):s}t(GP,"b");function VV(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=Ctr(o.protocol,f)),typeof o.username=="string"&&(s.username=Ttr(o.username,f)),typeof o.password=="string"&&(s.password=Str(o.password,f)),typeof o.hostname=="string"&&(s.hostname=btr(o.hostname,f)),typeof o.port=="string"&&(s.port=Etr(o.port,s.protocol,f)),typeof o.pathname=="string"){if(s.pathname=o.pathname,d&&!htr(s.pathname,f)){let y=d.pathname.lastIndexOf("/");y>=0&&(s.pathname=GP(d.pathname.substring(0,y+1),f)+s.pathname)}s.pathname=xtr(s.pathname,s.protocol,f)}return typeof o.search=="string"&&(s.search=vtr(o.search,f)),typeof o.hash=="string"&&(s.hash=ytr(o.hash,f)),s}t(VV,"w");function HV(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(HV,"C");function Otr(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Otr,"Oe");function Ftr(s,o){o.delimiter??="/#?",o.prefixes??="./",o.sensitive??=!1,o.strict??=!1,o.end??=!0,o.start??=!0,o.endsWith="";let f=".*",d=`[^${Otr(o.delimiter)}]+?`,y=/[$_\u200C\u200D\p{ID_Continue}]/u,x="";for(let P=0;P<s.length;++P){let F=s[P];if(F.type===3){if(F.modifier===3){x+=HV(F.value);continue}x+=`{${HV(F.value)}}${Q9(F.modifier)}`;continue}let W=F.hasCustomName(),G=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!o.prefixes.includes(F.prefix)),be=P>0?s[P-1]:null,de=P<s.length-1?s[P+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&&(x+="{"),x+=HV(F.prefix),W&&(x+=`:${F.name}`),F.type===2?x+=`(${F.value})`:F.type===1?W||(x+=`(${d})`):F.type===0&&(!W&&(!be||be.type===3||be.modifier!==3||G||F.prefix!=="")?x+="*":x+=`(${f})`),F.type===1&&W&&F.suffix.length&&y.test(F.suffix[0])&&(x+="\\"),x+=HV(F.suffix),G&&(x+="}"),F.modifier!==3&&(x+=Q9(F.modifier))}return x}t(Ftr,"ke");var oat=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 Itr(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},x={pathname:nI,protocol:nI,username:nI,password:nI,hostname:nI,port:nI,search:nI,hash:nI};this.#e=VV(x,s,!0),nat(this.#e.protocol)===this.#e.port&&(this.#e.port="");let P;for(P of JAe){if(!(P in this.#e))continue;let F={},W=this.#e[P];switch(this.#t[P]=[],P){case"protocol":Object.assign(F,iI),F.encodePart=qAe;break;case"username":Object.assign(F,iI),F.encodePart=ktr;break;case"password":Object.assign(F,iI),F.encodePart=wtr;break;case"hostname":Object.assign(F,dtr),eat(W)?F.encodePart=sat:F.encodePart=iat;break;case"port":Object.assign(F,iI),F.encodePart=aat;break;case"pathname":rat(this.#n.protocol)?(Object.assign(F,mtr,y),F.encodePart=Dtr):(Object.assign(F,iI,y),F.encodePart=Ptr);break;case"search":Object.assign(F,iI,y),F.encodePart=Atr;break;case"hash":Object.assign(F,iI,y),F.encodePart=Ntr;break}try{this.#s[P]=Xst(W,F),this.#n[P]=Zst(this.#s[P],this.#t[P],F),this.#r[P]=Ftr(this.#s[P],F),this.#m=this.#m||this.#s[P].some(G=>G.type===2)}catch{throw new TypeError(`invalid ${P} pattern '${this.#e[P]}'.`)}}}catch(d){throw new TypeError(`Failed to construct 'URLPattern': ${d.message}`)}}test(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=VV(f,s,!1):f=VV(f,Yst(s,o),!1)}catch{return!1}let d;for(d of JAe)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=VV(f,s,!1):f=VV(f,Yst(s,o),!1)}catch{return null}let d={};o?d.inputs=[s,o]:d.inputs=[s];let y;for(y of JAe){let x=this.#n[y].exec(f[y]);if(!x)return null;let P={};for(let[F,W]of this.#t[y].entries())if(typeof W=="string"||typeof W=="number"){let G=x[F+1];P[W]=G}d[y]={input:f[y]??"",groups:P}}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 GV(3,"","","","",3),x=new GV(0,"","","","",3),P=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]?P(o.#s[s],[x]):!o.#r[s]&&f.#r[s]?P([x],f.#s[s]):P(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=oat);import{AssertionError as Ltr}from"node:assert";function YP(s,o){if(s===!1)throw new Ltr({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 eM(s){return s.type===Wo.Object}t(eM,"isAstObject");function KP(s){return s.type===Wo.Property}t(KP,"isAstProperty");function VAe(s){return s.type===Wo.Array}t(VAe,"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(!eM(s))throw new Error("Node is not object")}t(sI,"assertAstObject");import{findNodeAtLocation as Rtr,getNodeValue as Mtr,printParseErrorCode as jtr,visit as Btr}from"jsonc-parser";var Utr={DEFAULT:{allowTrailingComma:!1}};function YV(s,o=[],f=Utr.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 x(W){return d.children?.push(W),W}t(x,"onValue"),Btr(s,{onObjectBegin:t((W,G,be)=>{d=x({type:"object",offset:W,length:-1,line:G+1,column:be+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((W,G,be,de,se)=>{d=x({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=x({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)=>{x({type:ztr(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(YV,"parse");function ztr(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(ztr,"getNodeType");function HAe(s,o){return Rtr(s,o)}t(HAe,"findNodeAtLocation");function KV(s){return Mtr(s)}t(KV,"getNodeValue");function cat(s){return jtr(s)}t(cat,"printParseErrorCode");var XV=class{static{t(this,"AstAdapter")}parse(o){let d=YV(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 $tr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,ZV=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,x)=>{this.generateSource(o,d),y<x.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=$tr.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Jtr from"node:fs/promises";import{parse as Wtr}from"@swc/core";var lat=t(async s=>{let o=new Set;try{let f=await Jtr.readFile(s,"utf-8");(await Wtr(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 uat={$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 GAe={$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 fat={$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 YAe={$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 KAe={$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 glt=B_(tle(),1),ylt=B_(hlt(),1);var ile=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new glt.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,ylt.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 x={details:{}},P=y.instancePath.split("/");if(P.length>2){let W=P[1],G=P[2]?parseInt(P[2],10):0,be=P[3],de=Number.isNaN(G)?void 0:f[W][G][be];x={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,x);d.push(F)}),d}};var mI=ile.instance;mI.addSchema(YAe,"route-configuration.schema.json");mI.addSchema(fat,"policy-configuration.schema.json");mI.addSchema(GAe,"policies.schema.json");mI.addSchema(KAe,"open-api-route-configuration.schema.json");mI.addSchema(uat,"fragments.schema.json");var Y6r=mI.compile(YAe),vlt=mI.compile(KAe),fIe=mI.compile(GAe);var sle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=fIe(o),this.results}};var ale=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=vlt(o),this.results}};import elr from"node:path";var _Ie=/\$import\((.*)\)/,AH=/\$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:""}}},Qcr=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=Qcr(s);return o.split("/").every((x,P)=>{let F=f[P];return F?x==="*"||KP(F)&&F.name.value===x?!0:x==="{}"?F.type===Wo.Object:x==="[]"?F.type===Wo.Array:!1:!1})},"testPosition");var ole=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),eM(o)?o.children.forEach(f=>{this.visitor(f)}):VAe(o)?o.children.forEach(f=>{this.visitor(f)}):KP(o)&&this.visitor(o.value)}},blt=t(s=>{let o=new RegExp(AH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(AH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),Slt=t((s,o,f)=>d=>{if(xO(d)&&typeof d.value=="string"&&d.parent&&VAe(d.parent)){if(!s.some(P=>tA(d.parent,P))){AH.test(d.value)&&o.push(new $k("An $env() statement is not expected at this location.",f,d.location,d.value));return}let x=blt(d.value);if(x){let P=d.parent,F=P.children.indexOf(d);if(F!==-1)if(x.type==="raw"){let W={type:Wo.Raw,parent:P,value:x.value};P.children[F]=W}else P.children[F]=DS.createTemplateString(x.value,d)}return}if(!KP(d)||!xO(d.value)||typeof d.value.value!="string")return;if(!s.some(x=>tA(d,x))){AH.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=blt(d.value.value);if(y)if(y.type==="raw"){let x={type:Wo.Raw,parent:null,value:y.value};d.value=x}else d.value=DS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var NH="config/routes.json",tlr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],rlr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","handler/{}/options/{}/onOpen/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Tlt=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],nlr="handler/{}/options/{}/rewritePattern",ilr="handler/{}/options/{}/baseUrl",cle=class extends ole{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,nlr)){if(!o.parent||!eM(o.parent)){this.errors.push(new $k("Invalid node, expected object",NH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:xlt(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,ilr)){if(!o.parent||!eM(o.parent)){this.errors.push(new $k("Invalid node, expected object",NH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:Wo.Raw,parent:null,value:xlt(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(!rlr.some(F=>tA(o,F))&&!Tlt.some(F=>tA(o,F))){if(_Ie.test(f)){if(o.name.value==="$ref")return;this.errors.push(new $k("An $import() statement is not expected at this location.",NH,o.location,f))}return}let d=_Ie.exec(f);if(Tlt.some(F=>tA(o,F))&&!d)return;if(!d){this.errors.push(new $k("Invalid $import() statement",NH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=elr.posix.join("..",y));let x=this.getImportName(y),P={type:Wo.Identifier,parent:o.parent,value:x};o.value=P}replaceEnvStatements=Slt(tlr,this.errors,NH)};function xlt(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;
|