@zuplo/core 5.2519.0 → 5.2522.0
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/index.minified.js +1 -1
- package/package.json +4 -4
package/index.minified.js
CHANGED
|
@@ -705,7 +705,7 @@ export default {
|
|
|
705
705
|
`),pluginName:P8,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}),{warnings:Sr,errors:[]}}catch(b){a.error(b);let k={message:`Error validating tsconfig.json : ${b.message}`,severity:"error",pluginName:P8};return{warnings:[],errors:[k]}}})},"validateTSConfig");import{parse as oir}from"@swc/core";import air from"vm";var{hasOwnProperty:Kv}=Object.prototype;function A8(s,a){return s=s.slice(),s.push(a),s}t(A8,"push");function nIe(s,a){return a=a.slice(),a.unshift(s),a}t(nIe,"unshift");var iIe=class extends Error{static{t(this,"NewError")}constructor(a){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=a,this.name="NewError"}};function o_(s,a,u,p,g){if(!(this instanceof o_))try{return new o_(s,a,u,p,g)}catch(k){if(!k.avoidNew)throw k;return k.value}typeof s=="string"&&(g=p,p=u,u=a,a=s,s=null);let b=s&&typeof s=="object";if(s=s||{},this.json=s.json||u,this.path=s.path||a,this.resultType=s.resultType||"value",this.flatten=s.flatten||!1,this.wrap=Kv.call(s,"wrap")?s.wrap:!0,this.sandbox=s.sandbox||{},this.preventEval=s.preventEval||!1,this.parent=s.parent||null,this.parentProperty=s.parentProperty||null,this.callback=s.callback||p||null,this.otherTypeCallback=s.otherTypeCallback||g||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},s.autostart!==!1){let k={path:b?s.path:a};b?"json"in s&&(k.json=s.json):k.json=u;let A=this.evaluate(k);if(!A||typeof A!="object")throw new iIe(A);return A}}t(o_,"JSONPath");o_.prototype.evaluate=function(s,a,u,p){let g=this.parent,b=this.parentProperty,{flatten:k,wrap:A}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,u=u||this.callback,this.currOtherTypeCallback=p||this.otherTypeCallback,a=a||this.json,s=s||this.path,s&&typeof s=="object"&&!Array.isArray(s)){if(!s.path&&s.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Kv.call(s,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:a}=s),k=Kv.call(s,"flatten")?s.flatten:k,this.currResultType=Kv.call(s,"resultType")?s.resultType:this.currResultType,this.currSandbox=Kv.call(s,"sandbox")?s.sandbox:this.currSandbox,A=Kv.call(s,"wrap")?s.wrap:A,this.currPreventEval=Kv.call(s,"preventEval")?s.preventEval:this.currPreventEval,u=Kv.call(s,"callback")?s.callback:u,this.currOtherTypeCallback=Kv.call(s,"otherTypeCallback")?s.otherTypeCallback:this.currOtherTypeCallback,g=Kv.call(s,"parent")?s.parent:g,b=Kv.call(s,"parentProperty")?s.parentProperty:b,s=s.path}if(g=g||null,b=b||null,Array.isArray(s)&&(s=o_.toPathString(s)),!s&&s!==""||!a)return;let M=o_.toPathArray(s);M[0]==="$"&&M.length>1&&M.shift(),this._hasParentSelector=null;let U=this._trace(M,a,["$"],g,b,u).filter(function(ne){return ne&&!ne.isParentSelector});return U.length?!A&&U.length===1&&!U[0].hasArrExpr?this._getPreferredOutput(U[0]):U.reduce((ne,Z)=>{let z=this._getPreferredOutput(Z);return k&&Array.isArray(z)?ne=ne.concat(z):ne.push(z),ne},[]):A?[]:void 0};o_.prototype._getPreferredOutput=function(s){let a=this.currResultType;switch(a){case"all":{let u=Array.isArray(s.path)?s.path:o_.toPathArray(s.path);return s.pointer=o_.toPointer(u),s.path=typeof s.path=="string"?s.path:o_.toPathString(s.path),s}case"value":case"parent":case"parentProperty":return s[a];case"path":return o_.toPathString(s[a]);case"pointer":return o_.toPointer(s.path);default:throw new TypeError("Unknown result type")}};o_.prototype._handleCallback=function(s,a,u){if(a){let p=this._getPreferredOutput(s);s.path=typeof s.path=="string"?s.path:o_.toPathString(s.path),a(p,u,s)}};o_.prototype._trace=function(s,a,u,p,g,b,k,A){let M;if(!s.length)return M={path:u,value:a,parent:p,parentProperty:g,hasArrExpr:k},this._handleCallback(M,b,"value"),M;let U=s[0],ne=s.slice(1),Z=[];function z(ve){Array.isArray(ve)?ve.forEach(Be=>{Z.push(Be)}):Z.push(ve)}if(t(z,"addRet"),(typeof U!="string"||A)&&a&&Kv.call(a,U))z(this._trace(ne,a[U],A8(u,U),a,U,b,k));else if(U==="*")this._walk(a,ve=>{z(this._trace(ne,a[ve],A8(u,ve),a,ve,b,!0,!0))});else if(U==="..")z(this._trace(ne,a,u,p,g,b,k)),this._walk(a,ve=>{typeof a[ve]=="object"&&z(this._trace(s.slice(),a[ve],A8(u,ve),a,ve,b,!0))});else{if(U==="^")return this._hasParentSelector=!0,{path:u.slice(0,-1),expr:ne,isParentSelector:!0};if(U==="~")return M={path:A8(u,U),value:g,parent:p,parentProperty:null},this._handleCallback(M,b,"property"),M;if(U==="$")z(this._trace(ne,a,u,null,null,b,k));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(U))z(this._slice(U,ne,a,u,p,g,b));else if(U.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let ve=U.replace(/^\?\((.*?)\)$/u,"$1");this._walk(a,Be=>{this._eval(ve,a[Be],Be,u,p,g)&&z(this._trace(ne,a[Be],A8(u,Be),a,Be,b,!0))})}else if(U[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");z(this._trace(nIe(this._eval(U,a,u[u.length-1],u.slice(0,-1),p,g),ne),a,u,p,g,b,k))}else if(U[0]==="@"){let ve=!1,Be=U.slice(1,-2);switch(Be){case"scalar":(!a||!["object","function"].includes(typeof a))&&(ve=!0);break;case"boolean":case"string":case"undefined":case"function":typeof a===Be&&(ve=!0);break;case"integer":Number.isFinite(a)&&!(a%1)&&(ve=!0);break;case"number":Number.isFinite(a)&&(ve=!0);break;case"nonFinite":typeof a=="number"&&!Number.isFinite(a)&&(ve=!0);break;case"object":a&&typeof a===Be&&(ve=!0);break;case"array":Array.isArray(a)&&(ve=!0);break;case"other":ve=this.currOtherTypeCallback(a,u,p,g);break;case"null":a===null&&(ve=!0);break;default:throw new TypeError("Unknown value type "+Be)}if(ve)return M={path:u,value:a,parent:p,parentProperty:g},this._handleCallback(M,b,"value"),M}else if(U[0]==="`"&&a&&Kv.call(a,U.slice(1))){let ve=U.slice(1);z(this._trace(ne,a[ve],A8(u,ve),a,ve,b,k,!0))}else if(U.includes(",")){let ve=U.split(",");for(let Be of ve)z(this._trace(nIe(Be,ne),a,u,p,g,b,!0))}else!A&&a&&Kv.call(a,U)&&z(this._trace(ne,a[U],A8(u,U),a,U,b,k,!0))}if(this._hasParentSelector)for(let ve=0;ve<Z.length;ve++){let Be=Z[ve];if(Be&&Be.isParentSelector){let Ee=this._trace(Be.expr,a,Be.path,p,g,b,k);if(Array.isArray(Ee)){Z[ve]=Ee[0];let Le=Ee.length;for(let xt=1;xt<Le;xt++)ve++,Z.splice(ve,0,Ee[xt])}else Z[ve]=Ee}}return Z};o_.prototype._walk=function(s,a){if(Array.isArray(s)){let u=s.length;for(let p=0;p<u;p++)a(p)}else s&&typeof s=="object"&&Object.keys(s).forEach(u=>{a(u)})};o_.prototype._slice=function(s,a,u,p,g,b,k){if(!Array.isArray(u))return;let A=u.length,M=s.split(":"),U=M[2]&&Number.parseInt(M[2])||1,ne=M[0]&&Number.parseInt(M[0])||0,Z=M[1]&&Number.parseInt(M[1])||A;ne=ne<0?Math.max(0,ne+A):Math.min(A,ne),Z=Z<0?Math.max(0,Z+A):Math.min(A,Z);let z=[];for(let ve=ne;ve<Z;ve+=U)this._trace(nIe(ve,a),u,p,g,b,k,!0).forEach(Ee=>{z.push(Ee)});return z};o_.prototype._eval=function(s,a,u,p,g,b){this.currSandbox._$_parentProperty=b,this.currSandbox._$_parent=g,this.currSandbox._$_property=u,this.currSandbox._$_root=this.json,this.currSandbox._$_v=a;let k=s.includes("@path");k&&(this.currSandbox._$_path=o_.toPathString(p.concat([u])));let A="script:"+s;if(!o_.cache[A]){let M=s.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");k&&(M=M.replace(/@path/gu,"_$_path")),o_.cache[A]=new this.vm.Script(M)}try{return o_.cache[A].runInNewContext(this.currSandbox)}catch(M){throw new Error("jsonPath: "+M.message+": "+s)}};o_.cache={};o_.toPathString=function(s){let a=s,u=a.length,p="$";for(let g=1;g<u;g++)/^(~|\^|@.*?\(\))$/u.test(a[g])||(p+=/^[0-9*]+$/u.test(a[g])?"["+a[g]+"]":"['"+a[g]+"']");return p};o_.toPointer=function(s){let a=s,u=a.length,p="";for(let g=1;g<u;g++)/^(~|\^|@.*?\(\))$/u.test(a[g])||(p+="/"+a[g].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return p};o_.toPathArray=function(s){let{cache:a}=o_;if(a[s])return a[s].concat();let u=[],g=s.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(b,k){return"[#"+(u.push(k)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(b,k){return"['"+k.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(b,k){return";"+k.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(b){let k=b.match(/#(\d+)/u);return!k||!k[1]?b:u[k[1]]});return a[s]=g,a[s].concat()};o_.prototype.vm=air;import cir from"fs/promises";import lir from"path";var iut=t(async function({outputDirectory:s,logger:a}){return Fu.timeFn("Verify Worker output",async()=>{a.debug("Verify Worker output");let u=lir.join(s,"worker.js");try{if(await pc.fileExists(u)){let p=await cir.readFile(u,"utf-8"),g=await oir(p,{syntax:"ecmascript"}),b=o_({path:"$..callee[?(@property === 'value' && (@ === 'Function'|| @ === 'eval'))]^",json:g.body});if(b&&b.length>0)return{warnings:[{message:"We do not support the use of 'eval' or 'new Function(...)'",severity:"warning",pluginName:"verify-worker-output"}],errors:[]}}}catch(p){a.error(p);let g={message:`Error validating build output : ${p.message}`,severity:"error",pluginName:"verify-worker-output"};return{warnings:[],errors:[g]}}return{warnings:[],errors:[]}})},"verifyWorkerOutput");import*as c1t from"esbuild";import{randomUUID as uir}from"crypto";var YN=class{static{t(this,"CompilerResult")}buildId;buildTime;buildTimeMs;errors;warnings;status;assets;metafile;constructor(a,u){this.buildId=u?.buildId??uir(),this.buildTime=u?.startBuildTime.toISOString(),this.buildTimeMs=u?.endBuildTime.getTime()-u?.startBuildTime.getTime(),this.errors=a.errors.map(p=>({message:p.text,severity:GW,...p})),this.warnings=a.warnings.map(p=>({message:p.text,severity:HW,...p})),a.metafile&&(this.metafile=a.metafile),this.status=d8,this.warnings&&this.warnings.length>0&&(this.status=U9),this.errors&&this.errors.length>0&&(this.status=Wv)}};var fir=!1;function fM(s,a){return{open:`\x1B[${s.join(";")}m`,close:`\x1B[${a}m`,regexp:new RegExp(`\\x1b\\[${a}m`,"g")}}t(fM,"code");function _M(s,a){return fir?`${a.open}${s.replace(a.regexp,a.open)}${a.close}`:s}t(_M,"run");function _ir(s){return _M(s,fM([31],39))}t(_ir,"red");function pir(s){return _M(s,fM([32],39))}t(pir,"green");function dir(s){return _M(s,fM([33],39))}t(dir,"yellow");function mir(s){return _M(s,fM([34],39))}t(mir,"blue");function hir(s){return _M(s,fM([35],39))}t(hir,"magenta");function gir(s){return _M(s,fM([36],39))}t(gir,"cyan");var EFr=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|"),"g");var sut=[_ir,pir,dir,mir,hir,gir];function yir(s){let a=0,u=s.length,p=0;if(u>0)for(;p<u;)a=(a<<5)-a+s.charCodeAt(p++)|0;return a}t(yir,"hashCode");function aut(s){let a=Math.abs(yir(s));return sut[a%sut.length]}t(aut,"generateColor");import{inspect as vir}from"util";function out(s,a,...u){let p=0,g=u.length,b=String(a).replace(/%[sdjoO%]/g,k=>{if(k==="%%")return"%";if(p>=g)return k;switch(k){case"%s":return String(u[p++]);case"%d":return Number(u[p++]).toString();case"%o":return s(u[p++]).split(`
|
|
706
706
|
`).map(A=>A.trim()).join(" ");case"%O":return s(u[p++]);case"%j":try{return JSON.stringify(u[p++])}catch{return"[Circular]"}default:return k}});for(let k of u.splice(p))k===null||!(typeof k=="object"&&k!==null)?b+=" "+k:b+=" "+s(k);return b}t(out,"format");var cut=t((s,...a)=>out(vir,s,a),"format");var sIe=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(a,u){this.manager=a,this.ns=u,this.color=aut(u),this.last=0,this.enabled=a.enabled.some(p=>p.test(u))}log(...a){if(!this.enabled)return;let u,p=a[0];typeof p=="function"?u=p():u=String(p);let g=Date.now()-(this.last||Date.now());u=cut(u,...a);let b=`${this.color(this.ns)} ${u} ${this.color(`+${g}ms`)}`;console.log(b),this.last=Date.now()}},aIe=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(a){this.debuggers=new Map,this.enabled=a??[]}};function bir(s){return!s||s.length===0?[]:(s=s.replace(/\s/g,"").replace(/\*/g,".+"),s.split(",").map(a=>new RegExp(`^${a}$`)))}t(bir,"extract");var Gce;function lut(s){Gce||(Gce=new aIe(bir(process.env.DEBUG)));let a=new sIe(Gce,s);return Gce.debuggers.set(s,a),Object.assign(a.log.bind(a),{self:a})}t(lut,"debug");import xfe,{dirname as s1t}from"path";import{fileURLToPath as a1t}from"url";var oIe="no-remote-module";function uut({logger:s}){return{name:oIe,async setup(a){a.onResolve({filter:/^https?:\/\//},u=>(s.error(u,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${u.path}`,detail:"InvalidRemoteModule",pluginName:oIe,location:{line:0,column:0,file:""}}],pluginName:oIe}))}}}t(uut,"blockRemoteModulePlugin");import fut from"fs/promises";import Hce from"path";import Sir from"prettier";var _ut="/docs",Tir="/__zuplo/dev-portal";function xir(s){let a=s.trim().toLowerCase();return a.endsWith("/")&&(a=a.slice(0,-1)),a}t(xir,"normalizePathname");function Eir(s){let a={sitePathname:s?.sitePathname===Tir?_ut:s?.sitePathname?xir(s.sitePathname):_ut,enabled:s?s.enabled??!0:!1};return`const devPortal = ${JSON.stringify(a)};
|
|
707
707
|
export default devPortal;`}t(Eir,"generateSource");function put(s){return{name:"dev-portal-config",setup(a){a.onResolve({filter:/dev-portal.json$/},u=>({namespace:"dev-portal-json",path:Hce.isAbsolute(u.path)?u.path:Hce.join(u.resolveDir,u.path),pluginName:"dev-portal"})),a.onLoad({filter:/.*/,namespace:"dev-portal-json"},async u=>Fu.timeFn("Generating dev-portal.json data",async()=>{let p,g,b=[];if(await pc.fileExists(u.path)){g=await fut.readFile(u.path,"utf-8");try{p=JSON.parse(g)}catch{b.push({id:"dev-portal-build-error",text:"Could not parse dev-portal.json. Ensure that the file is valid JSON.",location:{file:"dev-portal.json",namespace:"dev-portal-json",line:1,column:0,length:0,lineText:"",suggestion:""},detail:"DevPortalValidationError",pluginName:"dev-portal",notes:[{text:"Could not parse dev-portal.json. Ensure that the file is valid JSON.",location:null}]})}}if(b&&b.length>0)throw b;let k;try{if(k=Eir(p),Lm.DEBUG_BUILD_MODE&&k&&await pc.dirExists(s.sourceDirectory)){let A=await Sir.format(k,{parser:"babel"});await fut.writeFile(Hce.join(s.sourceDirectory,IN,"dev-portal.js"),A)}if(b&&b.length>0)throw b}catch(A){A.length>0?A.forEach(M=>{let U={id:"dev-portal-build-error",text:M.message,location:{file:"dev-portal.json",namespace:"dev-portal-json",line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:"dev-portal",notes:[{text:M.message,location:null}]};b.push(U)}):b.push({id:"dev-portal-build-error",text:A.message,location:{file:"dev-portal.json",namespace:"dev-portal-json",line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:"dev-portal",notes:[{text:A.message,location:null}]})}return{contents:k,errors:b,pluginName:"dev-portal",loader:"js",resolveDir:Hce.dirname(u.path),watchFiles:[u.path]}}))}}}t(put,"devPortalConfigPlugin");import dut from"path";var mut="legacy-environment",hut="legacy-environment",Cir=`import { environment } from "@zuplo/runtime";
|
|
708
|
-
export default environment;`;function gut(s){return{name:"environment",setup(a){a.onResolve({filter:/@app\/environment$/},()=>({namespace:hut,pluginName:mut,path:dut.join(s.sourceDirectory,IN,"environment.js")})),a.onLoad({filter:/.*/,namespace:hut},async u=>({contents:Cir,loader:"ts",resolveDir:dut.dirname(u.path),pluginName:mut}))}}}t(gut,"environmentPlugin");var Npt=sm(X4e(),1),Ipt=sm(Q_t(),1),Opt=sm(T3e(),1),Fpt=sm(x3e(),1);import Apt from"fs/promises";import CS from"path";import wfr from"prettier";var Ok="schemas",Nle="json-schema";function Lpt(s){return{name:Ok,async setup(a){let u=new Opt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});(0,Ipt.default)(u,{mode:"fast"}),u.opts.code.formats=Npt._`require("ajv-formats/dist/formats").fastFormats`;let p=CS.join(s.sourceDirectory,AN),g,b=[],k=[];if(await pc.dirExists(p)&&(u.addKeyword("faker"),g=await pc.listFolderContents(p,AN),await Promise.all(g.map(async A=>{try{let M=pc.safePath(s.sourceDirectory).resolve(p,A);if(!M.startsWith(p))throw new Error("All schemas must be in the schemas directory");let U=await Apt.readFile(M,"utf-8");if(U===""||U===void 0)throw new Error(`Schema 'schemas/${A}' is empty and will be ignored.`);let ne=JSON.parse(U);if(ne.$schema&&ne.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${A}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(u.$dataMetaSchema,u.addSchema(ne,A),u.errors?.length){let Z=u.errors[0];b.push({id:"json-schema-validation-error",pluginName:Ok,text:`Error: ${Z.message}`,location:{file:CS.join(AN,A)},detail:{params:Z.params,propertyName:Z.propertyName,schemaPath:Z.schemaPath,data:Z.data}})}}catch(M){if(M.message.endsWith("is empty and will be ignored.")){k.push({id:"empty-json-schema-file",pluginName:Ok,text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let U=await kNe(A,s.sourceDirectory,M.message);b.push({id:"json-schema-add-error",pluginName:Ok,text:`Error: ${M.message}`,location:U,detail:"InvalidAddSchemaError",notes:[{text:M.message}]})}})),await Promise.all(g.map(async A=>{try{let M=u.getSchema(A);M&&u.compile(M.schema).errors?.forEach(ne=>{b.push({text:`Failed to compile ${A}: ${ne.message}`})})}catch(M){let U=await kNe(A,s.sourceDirectory,M.message);b.push({id:"json-schema-compile-error",pluginName:Ok,text:`The schema file '${A}' is not valid. Error: ${M.message}`,location:U,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),Lm.DEBUG_BUILD_MODE)){let A=CS.resolve(s.outputDirectory,AN);await pc.mkdirIfNotExists(A)}a.onStart(async()=>{if(g)return{errors:b,warnings:k}}),a.onResolve({filter:/schemas\/.*\.json$/},async A=>{let M=CS.isAbsolute(A.path)?A.path:CS.join(A.resolveDir,A.path);if(A.importer&&A.importer!==CS.join(s.sourceDirectory,"config/routes.json"))return{path:M};if(!await pc.fileExists(M)){let U="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${A.path}' from ${U}`,location:{file:CS.join(A.resolveDir,U),namespace:Nle,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${U}`,suggestion:""},detail:"RouteReferenceError",pluginName:Ok,notes:[{text:`Unable to resolve reference to '${A.path}' from ${U}`,location:null}]}],namespace:Nle,path:M,pluginName:Ok}}return{path:M,namespace:Nle,pluginName:Ok}}),a.onLoad({filter:/.*/,namespace:Nle},async A=>Fu.timeFn(`Generating json schema data: ${CS.basename(A.path)}`,async()=>{let M=[],U;try{let ne=CS.relative(p,A.path),Z=u.getSchema(ne);if(!Z)throw new Error(`Could not load schema at ${A.path}`);U=Z.source?.validateCode;let z=u.compile(Z.schema);U=(0,Fpt.default)(u,z)}catch(ne){M.push({pluginName:Ok,text:`Cannot parse project's schemas/${CS.basename(A.path)} file. Error: ${ne.message}`,location:null,notes:[{text:ne.message,location:null}],detail:ne})}if(Lm.DEBUG_BUILD_MODE&&U){let ne=CS.resolve(s.outputDirectory,AN),Z=CS.relative(p,A.path),z=await wfr.format(U,{parser:"babel"}),ve=pc.safePath(s.sourceDirectory).resolve(ne,`${Z}.js`);await pc.mkdirForFilePathIfNotExits(ve),await Apt.writeFile(ve,z,"utf-8")}return{contents:U,errors:M,pluginName:Ok,resolveDir:CS.dirname(A.path),watchFiles:[A.path]}}))}}}t(Lpt,"jsonSchemaPlugin");import{relative as Dfr,resolve as Pfr}from"path";import{dirname as Afr}from"path";import{fileURLToPath as Nfr}from"url";var Rpt=["node:assert","node:async_hooks","node:buffer","node:crypto","node:diagnostics_channel","node:events","node:path","node:process","node:stream","node:string_decoder","node:util"],Ifr="nodejs-compat-plugin";function Mpt({nodeCompatEnabled:s,sourceDirectory:a}){return{name:Ifr,setup(u){let p=new Set;u.onStart(()=>{p.clear()}),u.onResolve({filter:/node:.*/},async({path:g,kind:b,resolveDir:k,...A})=>{let M=`${g}:${b}:${k}:${A.importer}`;if(p.has(M))return;if(p.add(M),!s&&g==="node:async_hooks")return{path:Pfr(Afr(Nfr(import.meta.url)),"../../../polyfills/async_hooks.js")};let U=await u.resolve(g,{kind:b,resolveDir:k,importer:A.importer});return U.errors.length>0?s&&Rpt.includes(g)||g.includes("/")&&Rpt.includes(g.split("/")[0])?{external:!0}:{external:!0,warnings:U.errors.map(Z=>({...Z,location:{file:Dfr(a,A.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${g}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:U})}}}t(Mpt,"nodejsCompatPlugin");function Ofr(s){if(s.length>=255)throw new TypeError("Alphabet too long");let a=new Uint8Array(256);for(let U=0;U<a.length;U++)a[U]=255;for(let U=0;U<s.length;U++){let ne=s.charAt(U),Z=ne.charCodeAt(0);if(a[Z]!==255)throw new TypeError(ne+" is ambiguous");a[Z]=U}let u=s.length,p=s.charAt(0),g=Math.log(u)/Math.log(256),b=Math.log(256)/Math.log(u);function k(U){if(U instanceof Uint8Array||(ArrayBuffer.isView(U)?U=new Uint8Array(U.buffer,U.byteOffset,U.byteLength):Array.isArray(U)&&(U=Uint8Array.from(U))),!(U instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(U.length===0)return"";let ne=0,Z=0,z=0,ve=U.length;for(;z!==ve&&U[z]===0;)z++,ne++;let Be=(ve-z)*b+1>>>0,Ee=new Uint8Array(Be);for(;z!==ve;){let Bt=U[z],_r=0;for(let Sr=Be-1;(Bt!==0||_r<Z)&&Sr!==-1;Sr--,_r++)Bt+=256*Ee[Sr]>>>0,Ee[Sr]=Bt%u>>>0,Bt=Bt/u>>>0;if(Bt!==0)throw new Error("Non-zero carry");Z=_r,z++}let Le=Be-Z;for(;Le!==Be&&Ee[Le]===0;)Le++;let xt=p.repeat(ne);for(;Le<Be;++Le)xt+=s.charAt(Ee[Le]);return xt}t(k,"encode");function A(U){if(typeof U!="string")throw new TypeError("Expected String");if(U.length===0)return new Uint8Array;let ne=0,Z=0,z=0;for(;U[ne]===p;)Z++,ne++;let ve=(U.length-ne)*g+1>>>0,Be=new Uint8Array(ve);for(;U[ne];){let Bt=a[U.charCodeAt(ne)];if(Bt===255)return;let _r=0;for(let Sr=ve-1;(Bt!==0||_r<z)&&Sr!==-1;Sr--,_r++)Bt+=u*Be[Sr]>>>0,Be[Sr]=Bt%256>>>0,Bt=Bt/256>>>0;if(Bt!==0)throw new Error("Non-zero carry");z=_r,ne++}let Ee=ve-z;for(;Ee!==ve&&Be[Ee]===0;)Ee++;let Le=new Uint8Array(Z+(ve-Ee)),xt=Z;for(;Ee!==ve;)Le[xt++]=Be[Ee++];return Le}t(A,"decodeUnsafe");function M(U){let ne=A(U);if(ne)return ne;throw new Error("Non-base"+u+" character")}return t(M,"decode"),{encode:k,decodeUnsafe:A,decode:M}}t(Ofr,"base");var jpt=Ofr;var Ffr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ile=jpt(Ffr);var E3e="2024-09-02",Bpt=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0}});function Upt(){return new ST({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:E3e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Bpt[E3e]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:""}})}t(Upt,"getMockEnvironment");var ST=class s{static{t(this,"Environment")}config;static#t;static#r=!1;static initialize(a){this.#t||(this.#t=new s(a),this.#r=!0)}static get instance(){return this.#r||(console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#t=Upt()),this.#t}constructor({build:a,runtime:u}){let p;try{if(u.__ZUPLO_CONFIG){let g=atob(u.__ZUPLO_CONFIG);p=JSON.parse(g)}if(u.ZUPLO_SYSTEM_CONFIGURATIONS){let g=new TextDecoder().decode(Ile.decode(u.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(g);for(let k of Object.keys(b))u[k]=b[k]}}catch(g){console.error("Failed to parse runtime configuration",g)}this.config=p??{},this.build=a,this.runtime=u,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuplo.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuplo.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuplo.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isDeno(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="deno":this.config.runtime_type?this.config.runtime_type==="deno":typeof WebSocketPair!="function"}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}};var Lfr=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function $pt(s){return s.startsWith("__ZUPLO")||s.startsWith("ZUPLO_")?!Lfr.includes(s)&&!s.startsWith("ZUPLO_PUBLIC_"):!1}t($pt,"isRestrictedEnvVariableName");function Jpt(s){return!!s.startsWith("ZUPLO_")}t(Jpt,"isZuploReadableEnvVariableName");var x9r=new Proxy({},{get(s,a){let u=String(a);switch(u){case"ZUPLO_ENVIRONMENT_TYPE":return ST.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return ST.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return ST.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return ST.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return ST.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return ST.instance.build.BUILD_ID}if(!($pt(u)&&!Jpt(u)))return ST.instance.runtime[u]}});function nH(s,a,u){return`_${PP(s+"_"+a+"_"+u)}`}t(nH,"getRawOperationDataIdentifierName");function C3e(s,a,u,p){return`_${PP(s.toLowerCase())}_`+a.toLowerCase()+"_"+u.toLowerCase()+`_${p.toLowerCase()}`}t(C3e,"getIdForParameterSchema");function k3e(s,a,u){return`_${PP(s.toLowerCase())}_`+a.toLowerCase()+`_rb_${PP(u.toLowerCase())}`}t(k3e,"getIdForRequestBodySchema");function iH(s,a){return`_${PP(s)}__${PP(a)}`}t(iH,"getIdForRefSchema");function PP(s){let a=[];for(let u=0;u<s.length;u++){let p=s.charCodeAt(u);p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122?a.push(s.charAt(u)):a.push("_")}return a.join("")}t(PP,"sanitizedIdentifierName");var G0t=sm(lmt(),1);import{findNodeAtLocation as eK,getNodeValue as Que,printParseErrorCode as Yvr}from"jsonc-parser";import D7e from"path";var gH=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,a,u,p,g,b){this.type=s,this.name=a,this.prefix=u,this.value=p,this.suffix=g,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},cdr=/[$_\p{ID_Start}]/u,ldr=/[$_\u200C\u200D\p{ID_Continue}]/u,aOe=".*";function udr(s,a){return(a?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(udr,"Re");function _mt(s,a=!1){let u=[],p=0;for(;p<s.length;){let g=s[p],b=t(function(k){if(!a)throw new TypeError(k);u.push({type:"INVALID_CHAR",index:p,value:s[p++]})},"c");if(g==="*"){u.push({type:"ASTERISK",index:p,value:s[p++]});continue}if(g==="+"||g==="?"){u.push({type:"OTHER_MODIFIER",index:p,value:s[p++]});continue}if(g==="\\"){u.push({type:"ESCAPED_CHAR",index:p++,value:s[p++]});continue}if(g==="{"){u.push({type:"OPEN",index:p,value:s[p++]});continue}if(g==="}"){u.push({type:"CLOSE",index:p,value:s[p++]});continue}if(g===":"){let k="",A=p+1;for(;A<s.length;){let M=s.substr(A,1);if(A===p+1&&cdr.test(M)||A!==p+1&&ldr.test(M)){k+=s[A++];continue}break}if(!k){b(`Missing parameter name at ${p}`);continue}u.push({type:"NAME",index:p,value:k}),p=A;continue}if(g==="("){let k=1,A="",M=p+1,U=!1;if(s[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<s.length;){if(!udr(s[M],!1)){b(`Invalid character '${s[M]}' at ${M}.`),U=!0;break}if(s[M]==="\\"){A+=s[M++]+s[M++];continue}if(s[M]===")"){if(k--,k===0){M++;break}}else if(s[M]==="("&&(k++,s[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),U=!0;break}A+=s[M++]}if(U)continue;if(k){b(`Unbalanced pattern at ${p}`);continue}if(!A){b(`Missing pattern at ${p}`);continue}u.push({type:"REGEX",index:p,value:A}),p=M;continue}u.push({type:"CHAR",index:p,value:s[p++]})}return u.push({type:"END",index:p,value:""}),u}t(_mt,"v");function pmt(s,a={}){let u=_mt(s);a.delimiter??="/#?",a.prefixes??="./";let p=`[^${ET(a.delimiter)}]+?`,g=[],b=0,k=0,A="",M=new Set,U=t(_r=>{if(k<u.length&&u[k].type===_r)return u[k++].value},"a"),ne=t(()=>U("OTHER_MODIFIER")??U("ASTERISK"),"f"),Z=t(_r=>{let Sr=U(_r);if(Sr!==void 0)return Sr;let{type:Yt,index:xn}=u[k];throw new TypeError(`Unexpected ${Yt} at ${xn}, expected ${_r}`)},"d"),z=t(()=>{let _r="",Sr;for(;Sr=U("CHAR")??U("ESCAPED_CHAR");)_r+=Sr;return _r},"T"),ve=t(_r=>_r,"Se"),Be=a.encodePart||ve,Ee="",Le=t(_r=>{Ee+=_r},"U"),xt=t(()=>{Ee.length&&(g.push(new gH(3,"","",Be(Ee),"",3)),Ee="")},"$"),Bt=t((_r,Sr,Yt,xn,mr)=>{let Zt=3;switch(mr){case"?":Zt=1;break;case"*":Zt=0;break;case"+":Zt=2;break}if(!Sr&&!Yt&&Zt===3){Le(_r);return}if(xt(),!Sr&&!Yt){if(!_r)return;g.push(new gH(3,"","",Be(_r),"",Zt));return}let Ar;Yt?Yt==="*"?Ar=aOe:Ar=Yt:Ar=p;let In=2;Ar===p?(In=1,Ar=""):Ar===aOe&&(In=0,Ar="");let ns;if(Sr?ns=Sr:Yt&&(ns=b++),M.has(ns))throw new TypeError(`Duplicate name '${ns}'.`);M.add(ns),g.push(new gH(In,ns,Be(_r),Ar,Be(xn),Zt))},"V");for(;k<u.length;){let _r=U("CHAR"),Sr=U("NAME"),Yt=U("REGEX");if(!Sr&&!Yt&&(Yt=U("ASTERISK")),Sr||Yt){let mr=_r??"";a.prefixes.indexOf(mr)===-1&&(Le(mr),mr=""),xt();let Zt=ne();Bt(mr,Sr,Yt,"",Zt);continue}let xn=_r??U("ESCAPED_CHAR");if(xn){Le(xn);continue}if(U("OPEN")){let mr=z(),Zt=U("NAME"),Ar=U("REGEX");!Zt&&!Ar&&(Ar=U("ASTERISK"));let In=z();Z("CLOSE");let ns=ne();Bt(mr,Zt,Ar,In,ns);continue}xt(),Z("END")}return g}t(pmt,"D");function ET(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(ET,"S");function umt(s){return s&&s.ignoreCase?"ui":"u"}t(umt,"X");function fdr(s,a,u){return dmt(pmt(s,u),a,u)}t(fdr,"Z");function jM(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(jM,"k");function dmt(s,a,u={}){u.delimiter??="/#?",u.prefixes??="./",u.sensitive??=!1,u.strict??=!1,u.end??=!0,u.start??=!0,u.endsWith="";let p=u.start?"^":"";for(let A of s){if(A.type===3){A.modifier===3?p+=ET(A.value):p+=`(?:${ET(A.value)})${jM(A.modifier)}`;continue}a&&a.push(A.name);let M=`[^${ET(u.delimiter)}]+?`,U=A.value;if(A.type===1?U=M:A.type===0&&(U=aOe),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?p+=`(${U})${jM(A.modifier)}`:p+=`((?:${U})${jM(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){p+=`(?:${ET(A.prefix)}(${U})${ET(A.suffix)})`,p+=jM(A.modifier);continue}p+=`(?:${ET(A.prefix)}`,p+=`((?:${U})(?:`,p+=ET(A.suffix),p+=ET(A.prefix),p+=`(?:${U}))*)${ET(A.suffix)})`,A.modifier===0&&(p+="?")}let g=`[${ET(u.endsWith)}]|$`,b=`[${ET(u.delimiter)}]`;if(u.end)return u.strict||(p+=`${b}?`),u.endsWith.length?p+=`(?=${g})`:p+="$",new RegExp(p,umt(u));u.strict||(p+=`(?:${b}(?=${g}))?`);let k=!1;if(s.length){let A=s[s.length-1];A.type===3&&A.modifier===3&&(k=u.delimiter.indexOf(A)>-1)}return k||(p+=`(?=${b}|${g})`),new RegExp(p,umt(u))}t(dmt,"F");var lI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},_dr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},pdr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function ddr(s,a){return s.length?s[0]==="/"?!0:!a||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(ddr,"J");function mmt(s,a){return s.startsWith(a)?s.substring(a.length,s.length):s}t(mmt,"Q");function mdr(s,a){return s.endsWith(a)?s.substr(0,s.length-a.length):s}t(mdr,"Ee");function hmt(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t(hmt,"W");var gmt=["ftp","file","http","https","ws","wss"];function ymt(s){if(!s)return!0;for(let a of gmt)if(s.test(a))return!0;return!1}t(ymt,"N");function hdr(s,a){if(s=mmt(s,"#"),a||s==="")return s;let u=new URL("https://example.com");return u.hash=s,u.hash?u.hash.substring(1,u.hash.length):""}t(hdr,"te");function gdr(s,a){if(s=mmt(s,"?"),a||s==="")return s;let u=new URL("https://example.com");return u.search=s,u.search?u.search.substring(1,u.search.length):""}t(gdr,"re");function ydr(s,a){return a||s===""?s:hmt(s)?Smt(s):bmt(s)}t(ydr,"ne");function vdr(s,a){if(a||s==="")return s;let u=new URL("https://example.com");return u.password=s,u.password}t(vdr,"se");function bdr(s,a){if(a||s==="")return s;let u=new URL("https://example.com");return u.username=s,u.username}t(bdr,"ie");function Sdr(s,a,u){if(u||s==="")return s;if(a&&!gmt.includes(a))return new URL(`${a}:${s}`).pathname;let p=s[0]=="/";return s=new URL(p?s:"/-"+s,"https://example.com").pathname,p||(s=s.substring(2,s.length)),s}t(Sdr,"ae");function Tdr(s,a,u){return vmt(a)===s&&(s=""),u||s===""?s:Tmt(s)}t(Tdr,"oe");function xdr(s,a){return s=mdr(s,":"),a||s===""?s:oOe(s)}t(xdr,"ce");function vmt(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(vmt,"_");function oOe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(oOe,"y");function Edr(s){if(s==="")return s;let a=new URL("https://example.com");return a.username=s,a.username}t(Edr,"le");function Cdr(s){if(s==="")return s;let a=new URL("https://example.com");return a.password=s,a.password}t(Cdr,"fe");function bmt(s){if(s==="")return s;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(s))throw new TypeError(`Invalid hostname '${s}'`);let a=new URL("https://example.com");return a.hostname=s,a.hostname}t(bmt,"z");function Smt(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(Smt,"j");function Tmt(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(Tmt,"K");function kdr(s){if(s==="")return s;let a=new URL("https://example.com");return a.pathname=s[0]!=="/"?"/-"+s:s,s[0]!=="/"?a.pathname.substring(2,a.pathname.length):a.pathname}t(kdr,"he");function wdr(s){return s===""?s:new URL(`data:${s}`).pathname}t(wdr,"ue");function Ddr(s){if(s==="")return s;let a=new URL("https://example.com");return a.search=s,a.search.substring(1,a.search.length)}t(Ddr,"de");function Pdr(s){if(s==="")return s;let a=new URL("https://example.com");return a.hash=s,a.hash.substring(1,a.hash.length)}t(Pdr,"pe");var Adr=class{static{t(this,"H")}#t;#r=[];#i={};#e=0;#a=1;#m=0;#o=0;#u=0;#c=0;#l=!1;constructor(s){this.#t=s}get result(){return this.#i}parse(){for(this.#r=_mt(this.#t,!0);this.#e<this.#r.length;this.#e+=this.#a){if(this.#a=1,this.#r[this.#e].type==="END"){if(this.#o===0){this.#y(),this.#E()?this.#n(9,1):this.#_()?this.#n(8,1):this.#n(7,0);continue}else if(this.#o===2){this.#p(5);continue}this.#n(10,0);break}if(this.#u>0)if(this.#s())this.#u-=1;else continue;if(this.#D()){this.#u+=1;continue}switch(this.#o){case 0:this.#g()&&this.#p(1);break;case 1:if(this.#g()){this.#I();let s=7,a=1;this.#w()?(s=2,a=3):this.#l&&(s=2),this.#n(s,a)}break;case 2:this.#C()?this.#p(3):(this.#x()||this.#_()||this.#E())&&this.#p(5);break;case 3:this.#T()?this.#n(4,1):this.#C()&&this.#n(5,1);break;case 4:this.#C()&&this.#n(5,1);break;case 5:this.#N()?this.#c+=1:this.#b()&&(this.#c-=1),this.#k()&&!this.#c?this.#n(6,1):this.#x()?this.#n(7,0):this.#_()?this.#n(8,1):this.#E()&&this.#n(9,1);break;case 6:this.#x()?this.#n(7,0):this.#_()?this.#n(8,1):this.#E()&&this.#n(9,1);break;case 7:this.#_()?this.#n(8,1):this.#E()&&this.#n(9,1);break;case 8:this.#E()&&this.#n(9,1);break;case 9:break;case 10:break}}this.#i.hostname!==void 0&&this.#i.port===void 0&&(this.#i.port="")}#n(s,a){switch(this.#o){case 0:break;case 1:this.#i.protocol=this.#S();break;case 2:break;case 3:this.#i.username=this.#S();break;case 4:this.#i.password=this.#S();break;case 5:this.#i.hostname=this.#S();break;case 6:this.#i.port=this.#S();break;case 7:this.#i.pathname=this.#S();break;case 8:this.#i.search=this.#S();break;case 9:this.#i.hash=this.#S();break;case 10:break}this.#o!==0&&s!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(s)&&(this.#i.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(s)&&(this.#i.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&s===9&&(this.#i.search??="")),this.#v(s,a)}#v(s,a){this.#o=s,this.#m=this.#e+a,this.#e+=a,this.#a=0}#y(){this.#e=this.#m,this.#a=0}#p(s){this.#y(),this.#o=s}#d(s){return s<0&&(s=this.#r.length-s),s<this.#r.length?this.#r[s]:this.#r[this.#r.length-1]}#h(s,a){let u=this.#d(s);return u.value===a&&(u.type==="CHAR"||u.type==="ESCAPED_CHAR"||u.type==="INVALID_CHAR")}#g(){return this.#h(this.#e,":")}#w(){return this.#h(this.#e+1,"/")&&this.#h(this.#e+2,"/")}#C(){return this.#h(this.#e,"@")}#T(){return this.#h(this.#e,":")}#k(){return this.#h(this.#e,":")}#x(){return this.#h(this.#e,"/")}#_(){if(this.#h(this.#e,"?"))return!0;if(this.#r[this.#e].value!=="?")return!1;let s=this.#d(this.#e-1);return s.type!=="NAME"&&s.type!=="REGEX"&&s.type!=="CLOSE"&&s.type!=="ASTERISK"}#E(){return this.#h(this.#e,"#")}#D(){return this.#r[this.#e].type=="OPEN"}#s(){return this.#r[this.#e].type=="CLOSE"}#N(){return this.#h(this.#e,"[")}#b(){return this.#h(this.#e,"]")}#S(){let s=this.#r[this.#e],a=this.#d(this.#m).index;return this.#t.substring(a,s.index)}#I(){let s={};Object.assign(s,lI),s.encodePart=oOe;let a=fdr(this.#S(),void 0,s);this.#l=ymt(a)}},sOe=["protocol","username","password","hostname","port","pathname","search","hash"],cI="*";function fmt(s,a){if(typeof s!="string")throw new TypeError("parameter 1 is not of type 'string'.");let u=new URL(s,a);return{protocol:u.protocol.substring(0,u.protocol.length-1),username:u.username,password:u.password,hostname:u.hostname,port:u.port,pathname:u.pathname,search:u.search!==""?u.search.substring(1,u.search.length):void 0,hash:u.hash!==""?u.hash.substring(1,u.hash.length):void 0}}t(fmt,"ge");function OP(s,a){return a?hH(s):s}t(OP,"b");function mH(s,a,u){let p;if(typeof a.baseURL=="string")try{p=new URL(a.baseURL),a.protocol===void 0&&(s.protocol=OP(p.protocol.substring(0,p.protocol.length-1),u)),!u&&a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.username===void 0&&(s.username=OP(p.username,u)),!u&&a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.username===void 0&&a.password===void 0&&(s.password=OP(p.password,u)),a.protocol===void 0&&a.hostname===void 0&&(s.hostname=OP(p.hostname,u)),a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&(s.port=OP(p.port,u)),a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.pathname===void 0&&(s.pathname=OP(p.pathname,u)),a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.pathname===void 0&&a.search===void 0&&(s.search=OP(p.search.substring(1,p.search.length),u)),a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.pathname===void 0&&a.search===void 0&&a.hash===void 0&&(s.hash=OP(p.hash.substring(1,p.hash.length),u))}catch{throw new TypeError(`invalid baseURL '${a.baseURL}'.`)}if(typeof a.protocol=="string"&&(s.protocol=xdr(a.protocol,u)),typeof a.username=="string"&&(s.username=bdr(a.username,u)),typeof a.password=="string"&&(s.password=vdr(a.password,u)),typeof a.hostname=="string"&&(s.hostname=ydr(a.hostname,u)),typeof a.port=="string"&&(s.port=Tdr(a.port,s.protocol,u)),typeof a.pathname=="string"){if(s.pathname=a.pathname,p&&!ddr(s.pathname,u)){let g=p.pathname.lastIndexOf("/");g>=0&&(s.pathname=OP(p.pathname.substring(0,g+1),u)+s.pathname)}s.pathname=Sdr(s.pathname,s.protocol,u)}return typeof a.search=="string"&&(s.search=gdr(a.search,u)),typeof a.hash=="string"&&(s.hash=hdr(a.hash,u)),s}t(mH,"w");function hH(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(hH,"C");function Ndr(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Ndr,"Oe");function Idr(s,a){a.delimiter??="/#?",a.prefixes??="./",a.sensitive??=!1,a.strict??=!1,a.end??=!0,a.start??=!0,a.endsWith="";let u=".*",p=`[^${Ndr(a.delimiter)}]+?`,g=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let k=0;k<s.length;++k){let A=s[k];if(A.type===3){if(A.modifier===3){b+=hH(A.value);continue}b+=`{${hH(A.value)}}${jM(A.modifier)}`;continue}let M=A.hasCustomName(),U=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!a.prefixes.includes(A.prefix)),ne=k>0?s[k-1]:null,Z=k<s.length-1?s[k+1]:null;if(!U&&M&&A.type===1&&A.modifier===3&&Z&&!Z.prefix.length&&!Z.suffix.length)if(Z.type===3){let z=Z.value.length>0?Z.value[0]:"";U=g.test(z)}else U=!Z.hasCustomName();if(!U&&!A.prefix.length&&ne&&ne.type===3){let z=ne.value[ne.value.length-1];U=a.prefixes.includes(z)}U&&(b+="{"),b+=hH(A.prefix),M&&(b+=`:${A.name}`),A.type===2?b+=`(${A.value})`:A.type===1?M||(b+=`(${p})`):A.type===0&&(!M&&(!ne||ne.type===3||ne.modifier!==3||U||A.prefix!=="")?b+="*":b+=`(${u})`),A.type===1&&M&&A.suffix.length&&g.test(A.suffix[0])&&(b+="\\"),b+=hH(A.suffix),U&&(b+="}"),A.modifier!==3&&(b+=jM(A.modifier))}return b}t(Idr,"ke");var xmt=class{static{t(this,"me")}#t;#r={};#i={};#e={};#a={};#m=!1;constructor(s={},a,u){try{let p;if(typeof a=="string"?p=a:u=a,typeof s=="string"){let A=new Adr(s);if(A.parse(),s=A.result,p===void 0&&typeof s.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");s.baseURL=p}else{if(!s||typeof s!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(p)throw new TypeError("parameter 1 is not of type 'string'.")}typeof u>"u"&&(u={ignoreCase:!1});let g={ignoreCase:u.ignoreCase===!0},b={pathname:cI,protocol:cI,username:cI,password:cI,hostname:cI,port:cI,search:cI,hash:cI};this.#t=mH(b,s,!0),vmt(this.#t.protocol)===this.#t.port&&(this.#t.port="");let k;for(k of sOe){if(!(k in this.#t))continue;let A={},M=this.#t[k];switch(this.#i[k]=[],k){case"protocol":Object.assign(A,lI),A.encodePart=oOe;break;case"username":Object.assign(A,lI),A.encodePart=Edr;break;case"password":Object.assign(A,lI),A.encodePart=Cdr;break;case"hostname":Object.assign(A,_dr),hmt(M)?A.encodePart=Smt:A.encodePart=bmt;break;case"port":Object.assign(A,lI),A.encodePart=Tmt;break;case"pathname":ymt(this.#r.protocol)?(Object.assign(A,pdr,g),A.encodePart=kdr):(Object.assign(A,lI,g),A.encodePart=wdr);break;case"search":Object.assign(A,lI,g),A.encodePart=Ddr;break;case"hash":Object.assign(A,lI,g),A.encodePart=Pdr;break}try{this.#a[k]=pmt(M,A),this.#r[k]=dmt(this.#a[k],this.#i[k],A),this.#e[k]=Idr(this.#a[k],A),this.#m=this.#m||this.#a[k].some(U=>U.type===2)}catch{throw new TypeError(`invalid ${k} pattern '${this.#t[k]}'.`)}}}catch(p){throw new TypeError(`Failed to construct 'URLPattern': ${p.message}`)}}test(s={},a){let u={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&a)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return!1;try{typeof s=="object"?u=mH(u,s,!1):u=mH(u,fmt(s,a),!1)}catch{return!1}let p;for(p of sOe)if(!this.#r[p].exec(u[p]))return!1;return!0}exec(s={},a){let u={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&a)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return;try{typeof s=="object"?u=mH(u,s,!1):u=mH(u,fmt(s,a),!1)}catch{return null}let p={};a?p.inputs=[s,a]:p.inputs=[s];let g;for(g of sOe){let b=this.#r[g].exec(u[g]);if(!b)return null;let k={};for(let[A,M]of this.#i[g].entries())if(typeof M=="string"||typeof M=="number"){let U=b[A+1];k[M]=U}p[g]={input:u[g]??"",groups:k}}return p}static compareComponent(s,a,u){let p=t((A,M)=>{for(let U of["type","modifier","prefix","value","suffix"]){if(A[U]<M[U])return-1;if(A[U]!==M[U])return 1}return 0},"o"),g=new gH(3,"","","","",3),b=new gH(0,"","","","",3),k=t((A,M)=>{let U=0;for(;U<Math.min(A.length,M.length);++U){let ne=p(A[U],M[U]);if(ne)return ne}return A.length===M.length?0:p(A[U]??g,M[U]??g)},"s");return!a.#e[s]&&!u.#e[s]?0:a.#e[s]&&!u.#e[s]?k(a.#a[s],[b]):!a.#e[s]&&u.#e[s]?k([b],u.#a[s]):k(a.#a[s],u.#a[s])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#m}};globalThis.URLPattern||(globalThis.URLPattern=xmt);import{AssertionError as Odr}from"assert";function W8(s,a){if(s===!1)throw new Odr({message:a})}t(W8,"assert");var hc;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.FunctionBody="FunctionBody"})(hc||(hc={}));function yH(s){return s.type===hc.Object}t(yH,"isAstObject");function FP(s){return s.type===hc.Property}t(FP,"isAstProperty");function Emt(s){return s.type===hc.Array}t(Emt,"isAstArray");function BM(s){return s.type===hc.Literal}t(BM,"isAstLiteral");import{visit as Fdr}from"jsonc-parser";var Ldr={DEFAULT:{allowTrailingComma:!1}};function vH(s,a=[],u=Ldr.DEFAULT){let p={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function g(M){p.type==="property"&&(p.length=M-p.offset,p=p.parent)}t(g,"ensurePropertyComplete");function b(M){return p.children?.push(M),M}t(b,"onValue"),Fdr(s,{onObjectBegin:t((M,U,ne)=>{p=b({type:"object",offset:M,length:-1,line:U+1,column:ne+1,parent:p,children:[]})},"onObjectBegin"),onObjectProperty:t((M,U,ne,Z,z)=>{p=b({type:"property",offset:U,length:-1,line:Z+1,column:z+1,parent:p,children:[]}),p.children?.push({type:"string",value:M,offset:U,length:ne,line:Z,column:z,parent:p})},"onObjectProperty"),onObjectEnd:t((M,U)=>{g(M+U),p.length=M+U-p.offset,p=p.parent,g(M+U)},"onObjectEnd"),onArrayBegin:t((M,U,ne,Z)=>{p=b({type:"array",offset:M,length:-1,line:ne+1,column:Z+1,parent:p,children:[]})},"onArrayBegin"),onArrayEnd:t((M,U)=>{p.length=M+U-p.offset,p=p.parent,g(M+U)},"onArrayEnd"),onLiteralValue:t((M,U,ne,Z,z)=>{b({type:Rdr(M),offset:U,length:ne,line:Z+1,column:z+1,parent:p,value:M}),g(U+ne)},"onLiteralValue"),onSeparator:t((M,U)=>{p.type==="property"&&(M===":"?p.colonOffset=U:M===","&&g(U))},"onSeparator"),onError:t((M,U,ne,Z,z)=>{a.push({error:M,offset:U,length:ne,line:Z+1,column:z+1})},"onError")},u);let A=p.children[0];return A&&delete A.parent,A}t(vH,"parse");function Rdr(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(Rdr,"getNodeType");var bH=class{static{t(this,"AstAdapter")}parse(a){let p=vH(a,[]);if(p)return this.parseNode(p,void 0);throw new Error("Failed to parse JSON")}convert(a){return this.parseNode(a,void 0)}parseNode(a,u){switch(a.type){case"object":return this.createObject(a,u);case"array":return this.createArray(a,u);case"property":return this.createProperty(a,u);case"string":return this.createLiteral(a,u);case"number":return this.createLiteral(a,u);case"boolean":return this.createLiteral(a,u);case"null":return this.createLiteral(a,u)}}createLiteral(a,u){return{type:hc.Literal,location:{line:a.line,column:a.column},parent:u,value:a.type==="null"?null:a.value}}createObject(a,u){let p={type:hc.Object,children:[],parent:u,location:{line:a.line,column:a.column}};return a.children?.forEach(g=>{p.children.push(this.parseNode(g,p))}),p}createProperty(a,u){W8(a.children?.length===2,"Invalid property node");let p={type:hc.Property,location:{line:a.line,column:a.column},parent:u,name:null,value:null};return p.name={value:a.children[0].value,location:{line:a.line,column:a.column},type:hc.Identifier,parent:p},p.value=this.parseNode(a.children[1],p),p}createArray(a,u){let p={type:hc.Array,location:{line:a.line,column:a.column},parent:u,children:[]};return a.children?.forEach(g=>p.children.push(this.parseNode(g,p))),p}};var CT={createLiteral:t((s,a)=>({type:hc.Literal,parent:a,value:s}),"createLiteral"),createTemplateString:t((s,a)=>({type:hc.TemplateString,parent:a,value:s}),"createTemplateString"),createIdentifier:t((s,a)=>({type:hc.Identifier,value:s,parent:a}),"createIdentifier"),createProperty:t((s,a,u)=>{let p={type:hc.Property,parent:u,name:null,value:a};return p.name={value:s,type:hc.Identifier,parent:p},p.value.parent=p,p},"createProperty"),createArrayOfLiterals:t((s,a)=>{let u={type:hc.Array,parent:a,children:[]};for(let p of s)u.children.push(CT.createLiteral(p,u));return u},"createArrayOfLiterals")};var SH=class{static{t(this,"SourceGenerator")}generate(a){let u=[];return this.generateSource(u,a),u.join("")}generateSource(a,u){switch(u.type){case hc.Array:return this.generateArray(a,u);case hc.Object:return this.generateObject(a,u);case hc.Property:return this.generateProperty(a,u);case hc.Literal:return this.generateLiteral(a,u);case hc.FunctionCall:return this.generateFunctionCall(a,u);case hc.Identifier:return this.generateIdentifier(a,u);case hc.FunctionBody:return this.generateFunctionBody(a,u);case hc.TemplateString:return this.generateTemplateString(a,u)}}generateArray(a,u){a.push("["),u.children.map(p=>{this.generateSource(a,p),a.push(",")}),a.push("]")}generateObject(a,u){a.push("{"),u.children.forEach(p=>{this.generateSource(a,p),a.push(",")}),a.push("}")}generateProperty(a,u){let p=u.name.value,g=p.search(/(\/|\\|-|\+|@|#|%|\^|&|\*|:|\.)/g)<0?p:`'${p}'`;a.push(g),a.push(":"),this.generateSource(a,u.value)}generateFunctionCall(a,u){a.push(u.name.value),a.push("("),u.children.forEach((p,g,b)=>{this.generateSource(a,p),g<b.length&&a.push(",")}),a.push(")")}generateFunctionBody(a,u){a.push(u.value)}generateTemplateString(a,u){a.push("`"),a.push(u.value.replaceAll("`","\\`")),a.push("`")}generateLiteral(a,u){if(u.value===null)return a.push("null");switch(typeof u.value){case"number":case"boolean":return a.push(`${u.value}`);case"string":{let p=u.value,g=JSON.stringify(p);return a.push(`${g}`)}}}generateIdentifier(a,u){a.push(u.value)}};import{parse as Mdr}from"@swc/core";import jdr from"fs/promises";var Cmt=t(async s=>{let a=new Set;try{let u=await jdr.readFile(s,"utf-8");(await Mdr(u,{syntax:"typescript"})).body.forEach(g=>{g.type==="ExportDefaultDeclaration"||g.type==="ExportDefaultExpression"?a.add("default"):g.type==="ExportDeclaration"&&g.declaration.type==="FunctionDeclaration"?a.add(g.declaration.identifier.value):g.type==="ExportDeclaration"&&g.declaration.type==="VariableDeclaration"&&g.declaration.declarations[0].id.type==="Identifier"&&a.add(g.declaration.declarations[0].id.value)})}catch{return null}return a},"getJSFileExports");var kmt={$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 cOe={$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 wmt={$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 lOe={$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:{},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 uOe={$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","version"],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:{},version:{type:"string",pattern:"^[0-9a-z-]+$"},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 Dmt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/routes.schema.json",title:"Route Config File",type:"object",additionalProperties:!1,required:["routes","versions"],$defs:{info:{type:"object",required:["title","version"],properties:{title:{type:"string"},summary:{type:"string"},description:{type:"string"},termsOfService:{type:"string",format:"uri"},version:{type:"string"}}},versionData:{type:"object",required:["name","pathPrefix"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},pathPrefix:{type:"string",pattern:"(^$|^/[^\\s]*$)"},info:{$ref:"#/$defs/info"},openApiFile:{description:"The project relative path to the OpenAPI spec.",type:"string"},excludeFromOpenApi:{type:"boolean",description:"If false, OpenAPI documentation will not be generated for this version. If openApiFile is set this setting is ignored."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."}}}},properties:{$schema:{type:"string"},versions:{type:"array",minItems:1,items:{$ref:"#/$defs/versionData"}},routes:{type:"array",minItems:0,items:{$ref:"route-configuration.schema.json"}},policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}},requestErrorHandler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"}}};var B0t=sm(c0t(),1),U0t=sm(j0t(),1);var zue=class s{static{t(this,"JsonValidator")}static#t=new s;static get instance(){return s.#t}ajv;constructor(){this.ajv=new U0t.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,B0t.default)(this.ajv,{mode:"fast"})}addSchema(a,u){this.ajv.addSchema(a,u)}compile(a){let u=this.ajv.compile(a);return t(g=>({isValid:u(g),errors:this.toSimpleErrors(u.errors,g),warnings:[]}),"validator")}toSimpleErrors(a,u){let p=[];return a?.forEach(g=>{g.keyword==="enum"&&g.params.allowedValues&&Array.isArray(g.params.allowedValues)&&(g.message+=`; ${g.params.allowedValues.join(", ")}`),g.instancePath&&(g.instancePath=g.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},k=g.instancePath.split("/");if(k.length>2){let M=k[1],U=k[2]?parseInt(k[2]):0,ne=k[3],Z=isNaN(U)?void 0:u[M][U][ne];b={details:{property:M,index:U,field:ne,fieldValue:Z}}}if(g.keyword==="required"&&g.params.missingProperty&&g.instancePath&&(g.message=`A 'path' is missing required property '${g.params.missingProperty}'`),g.keyword==="additionalProperties"&&g.params.additionalProperty&&g.instancePath&&(g.message=`A 'path' should NOT include property '${g.params.additionalProperty}'`),g.keyword==="type"&&g.params.type&&g.instancePath){let M=g.instancePath.split("/"),U=M[M.length-1];g.message=`Value of property '${U}' must be '${g.params.type}'`}let A=Object.assign(g,b);p.push(A)}),p}};var BP=zue.instance;BP.addSchema(Dmt,"routes.schema.json");BP.addSchema(uOe,"route-configuration.schema.json");BP.addSchema(wmt,"policy-configuration.schema.json");BP.addSchema(cOe,"policies.schema.json");BP.addSchema(lOe,"open-api-route-configuration.schema.json");BP.addSchema(kmt,"fragments.schema.json");var qvr=BP.compile(uOe),$0t=BP.compile(lOe),E7e=BP.compile(cOe);var Vue=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(a){return this.results=E7e(a),this.results}};var Wue=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(a){return this.results=$0t(a),this.results}};import Vvr from"path";var C7e=/\$import\((.*)\)/,Gue=/\$env\((.*?)\)/g;var UP=class extends Error{static{t(this,"CodeGenError")}location;constructor(a,u,p,g){super(a),this.location={file:u,namespace:"",line:p?p.line:0,column:p?p.column:0,length:0,lineText:g??"",suggestion:""}}},zvr=t(s=>{let a=[],u=s;for(;u.parent;)a.push(u),u=u.parent;return a.reverse()},"invertTree"),yI=t((s,a)=>{if(!s)return!1;let u=zvr(s);return a.split("/").every((b,k)=>{let A=u[k];return A?b==="*"||FP(A)&&A.name.value===b?!0:b==="{}"?A.type===hc.Object:b==="[]"?A.type===hc.Array:!1:!1})},"testPosition");var Hue=class{static{t(this,"AstTransformer")}errors=[];transform(a){return this.visitor(a),a}visitor(a){this.visit(a),yH(a)?a.children.forEach(u=>{this.visitor(u)}):Emt(a)?a.children.forEach(u=>{this.visitor(u)}):FP(a)&&this.visitor(a.value)}},J0t=t((s,a,u)=>p=>{if(!FP(p)||!BM(p.value)||typeof p.value.value!="string")return;if(!s.some(b=>yI(p,b))){Gue.test(p.value.value)&&a.push(new UP("An $env() statement is not expected at this location.",u,p.location,p.value.value));return}let g=new RegExp(Gue).exec(p.value.value);if(g?.length===2&&g[0]===p.value.value){let b={type:hc.FunctionBody,parent:null,value:`environment["${g[1]}"]`};p.value=b}else{let b=p.value.value.replaceAll(new RegExp(Gue),(k,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);b!==p.value.value&&(p.value=CT.createTemplateString(b,p))}},"getEnvStatementTransformer");var ZH="config/routes.json",Wvr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Gvr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],q0t=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Hvr="handler/{}/options/{}/rewritePattern",Kvr="handler/{}/options/{}/baseUrl",Kue=class extends Hue{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(a){this.addedImports.has(a)||this.addedImports.set(a,`__import${this.importCount++}`);let u=this.addedImports.get(a);if(!u)throw new Error("Import name is undefined. This should not happen.");return u}getImports(){let a=[];return this.addedImports.forEach((u,p)=>{a.push({name:u,path:p})}),a}visit(a){this.rewriteHandlerFunction(a),this.rewriteForwardFunction(a),this.replaceImportStatements(a),this.replaceEnvStatements(a)}rewriteHandlerFunction(a){if(!(!FP(a)||!BM(a.value)||typeof a.value.value!="string")&&yI(a,Hvr)){if(!a.parent||!yH(a.parent)){this.errors.push(new UP("Invalid node, expected object",ZH,a.parent?a.parent.location:a.location,void 0));return}let u=a.value.value,p={type:hc.FunctionBody,parent:null,value:z0t(u)},g=CT.createProperty("__rewriteFunction",p,a);a.parent.children.push(g)}}rewriteForwardFunction(a){if(!(!FP(a)||!BM(a.value)||typeof a.value.value!="string")&&yI(a,Kvr)){if(!a.parent||!yH(a.parent)){this.errors.push(new UP("Invalid node, expected object",ZH,a.parent?a.parent.location:a.location,void 0));return}let u=a.value.value,p={type:hc.FunctionBody,parent:null,value:z0t(u)},g=CT.createProperty("__rewriteFunction",p,a);a.parent.children.push(g)}}replaceImportStatements(a){if(!FP(a)||!BM(a.value))return;let u=a.value.value;if(typeof u!="string")return;if(!Gvr.some(A=>yI(a,A))&&!q0t.some(A=>yI(a,A))){if(C7e.test(u)){if(a.name.value==="$ref")return;this.errors.push(new UP("An $import() statement is not expected at this location.",ZH,a.location,u))}return}let p=C7e.exec(u);if(q0t.some(A=>yI(a,A))&&!p)return;if(!p){this.errors.push(new UP("Invalid $import() statement",ZH,a.location,u));return}let g=p[1];g.startsWith(".")&&(g=Vvr.join("..",g));let b=this.getImportName(g),k={type:hc.Identifier,parent:a.parent,value:b};a.value=k}replaceEnvStatements=J0t(Wvr,this.errors,ZH)};function z0t(s){return`(request, context) => {
|
|
708
|
+
export default environment;`;function gut(s){return{name:"environment",setup(a){a.onResolve({filter:/@app\/environment$/},()=>({namespace:hut,pluginName:mut,path:dut.join(s.sourceDirectory,IN,"environment.js")})),a.onLoad({filter:/.*/,namespace:hut},async u=>({contents:Cir,loader:"ts",resolveDir:dut.dirname(u.path),pluginName:mut}))}}}t(gut,"environmentPlugin");var Npt=sm(X4e(),1),Ipt=sm(Q_t(),1),Opt=sm(T3e(),1),Fpt=sm(x3e(),1);import Apt from"fs/promises";import CS from"path";import wfr from"prettier";var Ok="schemas",Nle="json-schema";function Lpt(s){return{name:Ok,async setup(a){let u=new Opt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});(0,Ipt.default)(u,{mode:"fast"}),u.opts.code.formats=Npt._`require("ajv-formats/dist/formats").fastFormats`;let p=CS.join(s.sourceDirectory,AN),g,b=[],k=[];if(await pc.dirExists(p)&&(u.addKeyword("faker"),g=await pc.listFolderContents(p,AN),await Promise.all(g.map(async A=>{try{let M=pc.safePath(s.sourceDirectory).resolve(p,A);if(!M.startsWith(p))throw new Error("All schemas must be in the schemas directory");let U=await Apt.readFile(M,"utf-8");if(U===""||U===void 0)throw new Error(`Schema 'schemas/${A}' is empty and will be ignored.`);let ne=JSON.parse(U);if(ne.$schema&&ne.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${A}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(u.$dataMetaSchema,u.addSchema(ne,A),u.errors?.length){let Z=u.errors[0];b.push({id:"json-schema-validation-error",pluginName:Ok,text:`Error: ${Z.message}`,location:{file:CS.join(AN,A)},detail:{params:Z.params,propertyName:Z.propertyName,schemaPath:Z.schemaPath,data:Z.data}})}}catch(M){if(M.message.endsWith("is empty and will be ignored.")){k.push({id:"empty-json-schema-file",pluginName:Ok,text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let U=await kNe(A,s.sourceDirectory,M.message);b.push({id:"json-schema-add-error",pluginName:Ok,text:`Error: ${M.message}`,location:U,detail:"InvalidAddSchemaError",notes:[{text:M.message}]})}})),await Promise.all(g.map(async A=>{try{let M=u.getSchema(A);M&&u.compile(M.schema).errors?.forEach(ne=>{b.push({text:`Failed to compile ${A}: ${ne.message}`})})}catch(M){let U=await kNe(A,s.sourceDirectory,M.message);b.push({id:"json-schema-compile-error",pluginName:Ok,text:`The schema file '${A}' is not valid. Error: ${M.message}`,location:U,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),Lm.DEBUG_BUILD_MODE)){let A=CS.resolve(s.outputDirectory,AN);await pc.mkdirIfNotExists(A)}a.onStart(async()=>{if(g)return{errors:b,warnings:k}}),a.onResolve({filter:/schemas\/.*\.json$/},async A=>{let M=CS.isAbsolute(A.path)?A.path:CS.join(A.resolveDir,A.path);if(A.importer&&A.importer!==CS.join(s.sourceDirectory,"config/routes.json"))return{path:M};if(!await pc.fileExists(M)){let U="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${A.path}' from ${U}`,location:{file:CS.join(A.resolveDir,U),namespace:Nle,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${U}`,suggestion:""},detail:"RouteReferenceError",pluginName:Ok,notes:[{text:`Unable to resolve reference to '${A.path}' from ${U}`,location:null}]}],namespace:Nle,path:M,pluginName:Ok}}return{path:M,namespace:Nle,pluginName:Ok}}),a.onLoad({filter:/.*/,namespace:Nle},async A=>Fu.timeFn(`Generating json schema data: ${CS.basename(A.path)}`,async()=>{let M=[],U;try{let ne=CS.relative(p,A.path),Z=u.getSchema(ne);if(!Z)throw new Error(`Could not load schema at ${A.path}`);U=Z.source?.validateCode;let z=u.compile(Z.schema);U=(0,Fpt.default)(u,z)}catch(ne){M.push({pluginName:Ok,text:`Cannot parse project's schemas/${CS.basename(A.path)} file. Error: ${ne.message}`,location:null,notes:[{text:ne.message,location:null}],detail:ne})}if(Lm.DEBUG_BUILD_MODE&&U){let ne=CS.resolve(s.outputDirectory,AN),Z=CS.relative(p,A.path),z=await wfr.format(U,{parser:"babel"}),ve=pc.safePath(s.sourceDirectory).resolve(ne,`${Z}.js`);await pc.mkdirForFilePathIfNotExits(ve),await Apt.writeFile(ve,z,"utf-8")}return{contents:U,errors:M,pluginName:Ok,resolveDir:CS.dirname(A.path),watchFiles:[A.path]}}))}}}t(Lpt,"jsonSchemaPlugin");import{relative as Dfr,resolve as Pfr}from"path";import{dirname as Afr}from"path";import{fileURLToPath as Nfr}from"url";var Rpt=["node:assert","node:async_hooks","node:buffer","node:crypto","node:diagnostics_channel","node:events","node:path","node:process","node:stream","node:string_decoder","node:util"],Ifr="nodejs-compat-plugin";function Mpt({nodeCompatEnabled:s,sourceDirectory:a}){return{name:Ifr,setup(u){let p=new Set;u.onStart(()=>{p.clear()}),u.onResolve({filter:/node:.*/},async({path:g,kind:b,resolveDir:k,...A})=>{let M=`${g}:${b}:${k}:${A.importer}`;if(p.has(M))return;if(p.add(M),!s&&g==="node:async_hooks")return{path:Pfr(Afr(Nfr(import.meta.url)),"../../../polyfills/async_hooks.js")};let U=await u.resolve(g,{kind:b,resolveDir:k,importer:A.importer});return U.errors.length>0?s&&Rpt.includes(g)||g.includes("/")&&Rpt.includes(g.split("/")[0])?{external:!0}:{external:!0,warnings:U.errors.map(Z=>({...Z,location:{file:Dfr(a,A.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${g}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:U})}}}t(Mpt,"nodejsCompatPlugin");function Ofr(s){if(s.length>=255)throw new TypeError("Alphabet too long");let a=new Uint8Array(256);for(let U=0;U<a.length;U++)a[U]=255;for(let U=0;U<s.length;U++){let ne=s.charAt(U),Z=ne.charCodeAt(0);if(a[Z]!==255)throw new TypeError(ne+" is ambiguous");a[Z]=U}let u=s.length,p=s.charAt(0),g=Math.log(u)/Math.log(256),b=Math.log(256)/Math.log(u);function k(U){if(U instanceof Uint8Array||(ArrayBuffer.isView(U)?U=new Uint8Array(U.buffer,U.byteOffset,U.byteLength):Array.isArray(U)&&(U=Uint8Array.from(U))),!(U instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(U.length===0)return"";let ne=0,Z=0,z=0,ve=U.length;for(;z!==ve&&U[z]===0;)z++,ne++;let Be=(ve-z)*b+1>>>0,Ee=new Uint8Array(Be);for(;z!==ve;){let Bt=U[z],_r=0;for(let Sr=Be-1;(Bt!==0||_r<Z)&&Sr!==-1;Sr--,_r++)Bt+=256*Ee[Sr]>>>0,Ee[Sr]=Bt%u>>>0,Bt=Bt/u>>>0;if(Bt!==0)throw new Error("Non-zero carry");Z=_r,z++}let Le=Be-Z;for(;Le!==Be&&Ee[Le]===0;)Le++;let xt=p.repeat(ne);for(;Le<Be;++Le)xt+=s.charAt(Ee[Le]);return xt}t(k,"encode");function A(U){if(typeof U!="string")throw new TypeError("Expected String");if(U.length===0)return new Uint8Array;let ne=0,Z=0,z=0;for(;U[ne]===p;)Z++,ne++;let ve=(U.length-ne)*g+1>>>0,Be=new Uint8Array(ve);for(;U[ne];){let Bt=a[U.charCodeAt(ne)];if(Bt===255)return;let _r=0;for(let Sr=ve-1;(Bt!==0||_r<z)&&Sr!==-1;Sr--,_r++)Bt+=u*Be[Sr]>>>0,Be[Sr]=Bt%256>>>0,Bt=Bt/256>>>0;if(Bt!==0)throw new Error("Non-zero carry");z=_r,ne++}let Ee=ve-z;for(;Ee!==ve&&Be[Ee]===0;)Ee++;let Le=new Uint8Array(Z+(ve-Ee)),xt=Z;for(;Ee!==ve;)Le[xt++]=Be[Ee++];return Le}t(A,"decodeUnsafe");function M(U){let ne=A(U);if(ne)return ne;throw new Error("Non-base"+u+" character")}return t(M,"decode"),{encode:k,decodeUnsafe:A,decode:M}}t(Ofr,"base");var jpt=Ofr;var Ffr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ile=jpt(Ffr);var E3e="2024-09-02",Bpt=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0}});function Upt(){return new ST({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:E3e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Bpt[E3e]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:""}})}t(Upt,"getMockEnvironment");var ST=class s{static{t(this,"Environment")}config;static#t;static#r=!1;static initialize(a){this.#t||(this.#t=new s(a),this.#r=!0)}static get instance(){return this.#r||(console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#t=Upt()),this.#t}constructor({build:a,runtime:u}){let p;try{if(u.__ZUPLO_CONFIG){let g=atob(u.__ZUPLO_CONFIG);p=JSON.parse(g)}if(u.ZUPLO_SYSTEM_CONFIGURATIONS){let g=new TextDecoder().decode(Ile.decode(u.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(g);for(let k of Object.keys(b))u[k]=b[k]}}catch(g){console.error("Failed to parse runtime configuration",g)}this.config=p??{},this.build=a,this.runtime=u,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isDeno(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="deno":this.config.runtime_type?this.config.runtime_type==="deno":typeof WebSocketPair!="function"}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}};var Lfr=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function $pt(s){return s.startsWith("__ZUPLO")||s.startsWith("ZUPLO_")?!Lfr.includes(s)&&!s.startsWith("ZUPLO_PUBLIC_"):!1}t($pt,"isRestrictedEnvVariableName");function Jpt(s){return!!s.startsWith("ZUPLO_")}t(Jpt,"isZuploReadableEnvVariableName");var x9r=new Proxy({},{get(s,a){let u=String(a);switch(u){case"ZUPLO_ENVIRONMENT_TYPE":return ST.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return ST.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return ST.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return ST.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return ST.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return ST.instance.build.BUILD_ID}if(!($pt(u)&&!Jpt(u)))return ST.instance.runtime[u]}});function nH(s,a,u){return`_${PP(s+"_"+a+"_"+u)}`}t(nH,"getRawOperationDataIdentifierName");function C3e(s,a,u,p){return`_${PP(s.toLowerCase())}_`+a.toLowerCase()+"_"+u.toLowerCase()+`_${p.toLowerCase()}`}t(C3e,"getIdForParameterSchema");function k3e(s,a,u){return`_${PP(s.toLowerCase())}_`+a.toLowerCase()+`_rb_${PP(u.toLowerCase())}`}t(k3e,"getIdForRequestBodySchema");function iH(s,a){return`_${PP(s)}__${PP(a)}`}t(iH,"getIdForRefSchema");function PP(s){let a=[];for(let u=0;u<s.length;u++){let p=s.charCodeAt(u);p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122?a.push(s.charAt(u)):a.push("_")}return a.join("")}t(PP,"sanitizedIdentifierName");var G0t=sm(lmt(),1);import{findNodeAtLocation as eK,getNodeValue as Que,printParseErrorCode as Yvr}from"jsonc-parser";import D7e from"path";var gH=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(s,a,u,p,g,b){this.type=s,this.name=a,this.prefix=u,this.value=p,this.suffix=g,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},cdr=/[$_\p{ID_Start}]/u,ldr=/[$_\u200C\u200D\p{ID_Continue}]/u,aOe=".*";function udr(s,a){return(a?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(s)}t(udr,"Re");function _mt(s,a=!1){let u=[],p=0;for(;p<s.length;){let g=s[p],b=t(function(k){if(!a)throw new TypeError(k);u.push({type:"INVALID_CHAR",index:p,value:s[p++]})},"c");if(g==="*"){u.push({type:"ASTERISK",index:p,value:s[p++]});continue}if(g==="+"||g==="?"){u.push({type:"OTHER_MODIFIER",index:p,value:s[p++]});continue}if(g==="\\"){u.push({type:"ESCAPED_CHAR",index:p++,value:s[p++]});continue}if(g==="{"){u.push({type:"OPEN",index:p,value:s[p++]});continue}if(g==="}"){u.push({type:"CLOSE",index:p,value:s[p++]});continue}if(g===":"){let k="",A=p+1;for(;A<s.length;){let M=s.substr(A,1);if(A===p+1&&cdr.test(M)||A!==p+1&&ldr.test(M)){k+=s[A++];continue}break}if(!k){b(`Missing parameter name at ${p}`);continue}u.push({type:"NAME",index:p,value:k}),p=A;continue}if(g==="("){let k=1,A="",M=p+1,U=!1;if(s[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<s.length;){if(!udr(s[M],!1)){b(`Invalid character '${s[M]}' at ${M}.`),U=!0;break}if(s[M]==="\\"){A+=s[M++]+s[M++];continue}if(s[M]===")"){if(k--,k===0){M++;break}}else if(s[M]==="("&&(k++,s[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),U=!0;break}A+=s[M++]}if(U)continue;if(k){b(`Unbalanced pattern at ${p}`);continue}if(!A){b(`Missing pattern at ${p}`);continue}u.push({type:"REGEX",index:p,value:A}),p=M;continue}u.push({type:"CHAR",index:p,value:s[p++]})}return u.push({type:"END",index:p,value:""}),u}t(_mt,"v");function pmt(s,a={}){let u=_mt(s);a.delimiter??="/#?",a.prefixes??="./";let p=`[^${ET(a.delimiter)}]+?`,g=[],b=0,k=0,A="",M=new Set,U=t(_r=>{if(k<u.length&&u[k].type===_r)return u[k++].value},"a"),ne=t(()=>U("OTHER_MODIFIER")??U("ASTERISK"),"f"),Z=t(_r=>{let Sr=U(_r);if(Sr!==void 0)return Sr;let{type:Yt,index:xn}=u[k];throw new TypeError(`Unexpected ${Yt} at ${xn}, expected ${_r}`)},"d"),z=t(()=>{let _r="",Sr;for(;Sr=U("CHAR")??U("ESCAPED_CHAR");)_r+=Sr;return _r},"T"),ve=t(_r=>_r,"Se"),Be=a.encodePart||ve,Ee="",Le=t(_r=>{Ee+=_r},"U"),xt=t(()=>{Ee.length&&(g.push(new gH(3,"","",Be(Ee),"",3)),Ee="")},"$"),Bt=t((_r,Sr,Yt,xn,mr)=>{let Zt=3;switch(mr){case"?":Zt=1;break;case"*":Zt=0;break;case"+":Zt=2;break}if(!Sr&&!Yt&&Zt===3){Le(_r);return}if(xt(),!Sr&&!Yt){if(!_r)return;g.push(new gH(3,"","",Be(_r),"",Zt));return}let Ar;Yt?Yt==="*"?Ar=aOe:Ar=Yt:Ar=p;let In=2;Ar===p?(In=1,Ar=""):Ar===aOe&&(In=0,Ar="");let ns;if(Sr?ns=Sr:Yt&&(ns=b++),M.has(ns))throw new TypeError(`Duplicate name '${ns}'.`);M.add(ns),g.push(new gH(In,ns,Be(_r),Ar,Be(xn),Zt))},"V");for(;k<u.length;){let _r=U("CHAR"),Sr=U("NAME"),Yt=U("REGEX");if(!Sr&&!Yt&&(Yt=U("ASTERISK")),Sr||Yt){let mr=_r??"";a.prefixes.indexOf(mr)===-1&&(Le(mr),mr=""),xt();let Zt=ne();Bt(mr,Sr,Yt,"",Zt);continue}let xn=_r??U("ESCAPED_CHAR");if(xn){Le(xn);continue}if(U("OPEN")){let mr=z(),Zt=U("NAME"),Ar=U("REGEX");!Zt&&!Ar&&(Ar=U("ASTERISK"));let In=z();Z("CLOSE");let ns=ne();Bt(mr,Zt,Ar,In,ns);continue}xt(),Z("END")}return g}t(pmt,"D");function ET(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(ET,"S");function umt(s){return s&&s.ignoreCase?"ui":"u"}t(umt,"X");function fdr(s,a,u){return dmt(pmt(s,u),a,u)}t(fdr,"Z");function jM(s){switch(s){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(jM,"k");function dmt(s,a,u={}){u.delimiter??="/#?",u.prefixes??="./",u.sensitive??=!1,u.strict??=!1,u.end??=!0,u.start??=!0,u.endsWith="";let p=u.start?"^":"";for(let A of s){if(A.type===3){A.modifier===3?p+=ET(A.value):p+=`(?:${ET(A.value)})${jM(A.modifier)}`;continue}a&&a.push(A.name);let M=`[^${ET(u.delimiter)}]+?`,U=A.value;if(A.type===1?U=M:A.type===0&&(U=aOe),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?p+=`(${U})${jM(A.modifier)}`:p+=`((?:${U})${jM(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){p+=`(?:${ET(A.prefix)}(${U})${ET(A.suffix)})`,p+=jM(A.modifier);continue}p+=`(?:${ET(A.prefix)}`,p+=`((?:${U})(?:`,p+=ET(A.suffix),p+=ET(A.prefix),p+=`(?:${U}))*)${ET(A.suffix)})`,A.modifier===0&&(p+="?")}let g=`[${ET(u.endsWith)}]|$`,b=`[${ET(u.delimiter)}]`;if(u.end)return u.strict||(p+=`${b}?`),u.endsWith.length?p+=`(?=${g})`:p+="$",new RegExp(p,umt(u));u.strict||(p+=`(?:${b}(?=${g}))?`);let k=!1;if(s.length){let A=s[s.length-1];A.type===3&&A.modifier===3&&(k=u.delimiter.indexOf(A)>-1)}return k||(p+=`(?=${b}|${g})`),new RegExp(p,umt(u))}t(dmt,"F");var lI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},_dr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},pdr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function ddr(s,a){return s.length?s[0]==="/"?!0:!a||s.length<2?!1:(s[0]=="\\"||s[0]=="{")&&s[1]=="/":!1}t(ddr,"J");function mmt(s,a){return s.startsWith(a)?s.substring(a.length,s.length):s}t(mmt,"Q");function mdr(s,a){return s.endsWith(a)?s.substr(0,s.length-a.length):s}t(mdr,"Ee");function hmt(s){return!s||s.length<2?!1:s[0]==="["||(s[0]==="\\"||s[0]==="{")&&s[1]==="["}t(hmt,"W");var gmt=["ftp","file","http","https","ws","wss"];function ymt(s){if(!s)return!0;for(let a of gmt)if(s.test(a))return!0;return!1}t(ymt,"N");function hdr(s,a){if(s=mmt(s,"#"),a||s==="")return s;let u=new URL("https://example.com");return u.hash=s,u.hash?u.hash.substring(1,u.hash.length):""}t(hdr,"te");function gdr(s,a){if(s=mmt(s,"?"),a||s==="")return s;let u=new URL("https://example.com");return u.search=s,u.search?u.search.substring(1,u.search.length):""}t(gdr,"re");function ydr(s,a){return a||s===""?s:hmt(s)?Smt(s):bmt(s)}t(ydr,"ne");function vdr(s,a){if(a||s==="")return s;let u=new URL("https://example.com");return u.password=s,u.password}t(vdr,"se");function bdr(s,a){if(a||s==="")return s;let u=new URL("https://example.com");return u.username=s,u.username}t(bdr,"ie");function Sdr(s,a,u){if(u||s==="")return s;if(a&&!gmt.includes(a))return new URL(`${a}:${s}`).pathname;let p=s[0]=="/";return s=new URL(p?s:"/-"+s,"https://example.com").pathname,p||(s=s.substring(2,s.length)),s}t(Sdr,"ae");function Tdr(s,a,u){return vmt(a)===s&&(s=""),u||s===""?s:Tmt(s)}t(Tdr,"oe");function xdr(s,a){return s=mdr(s,":"),a||s===""?s:oOe(s)}t(xdr,"ce");function vmt(s){switch(s){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(vmt,"_");function oOe(s){if(s==="")return s;if(/^[-+.A-Za-z0-9]*$/.test(s))return s.toLowerCase();throw new TypeError(`Invalid protocol '${s}'.`)}t(oOe,"y");function Edr(s){if(s==="")return s;let a=new URL("https://example.com");return a.username=s,a.username}t(Edr,"le");function Cdr(s){if(s==="")return s;let a=new URL("https://example.com");return a.password=s,a.password}t(Cdr,"fe");function bmt(s){if(s==="")return s;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(s))throw new TypeError(`Invalid hostname '${s}'`);let a=new URL("https://example.com");return a.hostname=s,a.hostname}t(bmt,"z");function Smt(s){if(s==="")return s;if(/[^0-9a-fA-F[\]:]/g.test(s))throw new TypeError(`Invalid IPv6 hostname '${s}'`);return s.toLowerCase()}t(Smt,"j");function Tmt(s){if(s===""||/^[0-9]*$/.test(s)&&parseInt(s)<=65535)return s;throw new TypeError(`Invalid port '${s}'.`)}t(Tmt,"K");function kdr(s){if(s==="")return s;let a=new URL("https://example.com");return a.pathname=s[0]!=="/"?"/-"+s:s,s[0]!=="/"?a.pathname.substring(2,a.pathname.length):a.pathname}t(kdr,"he");function wdr(s){return s===""?s:new URL(`data:${s}`).pathname}t(wdr,"ue");function Ddr(s){if(s==="")return s;let a=new URL("https://example.com");return a.search=s,a.search.substring(1,a.search.length)}t(Ddr,"de");function Pdr(s){if(s==="")return s;let a=new URL("https://example.com");return a.hash=s,a.hash.substring(1,a.hash.length)}t(Pdr,"pe");var Adr=class{static{t(this,"H")}#t;#r=[];#i={};#e=0;#a=1;#m=0;#o=0;#u=0;#c=0;#l=!1;constructor(s){this.#t=s}get result(){return this.#i}parse(){for(this.#r=_mt(this.#t,!0);this.#e<this.#r.length;this.#e+=this.#a){if(this.#a=1,this.#r[this.#e].type==="END"){if(this.#o===0){this.#y(),this.#E()?this.#n(9,1):this.#_()?this.#n(8,1):this.#n(7,0);continue}else if(this.#o===2){this.#p(5);continue}this.#n(10,0);break}if(this.#u>0)if(this.#s())this.#u-=1;else continue;if(this.#D()){this.#u+=1;continue}switch(this.#o){case 0:this.#g()&&this.#p(1);break;case 1:if(this.#g()){this.#I();let s=7,a=1;this.#w()?(s=2,a=3):this.#l&&(s=2),this.#n(s,a)}break;case 2:this.#C()?this.#p(3):(this.#x()||this.#_()||this.#E())&&this.#p(5);break;case 3:this.#T()?this.#n(4,1):this.#C()&&this.#n(5,1);break;case 4:this.#C()&&this.#n(5,1);break;case 5:this.#N()?this.#c+=1:this.#b()&&(this.#c-=1),this.#k()&&!this.#c?this.#n(6,1):this.#x()?this.#n(7,0):this.#_()?this.#n(8,1):this.#E()&&this.#n(9,1);break;case 6:this.#x()?this.#n(7,0):this.#_()?this.#n(8,1):this.#E()&&this.#n(9,1);break;case 7:this.#_()?this.#n(8,1):this.#E()&&this.#n(9,1);break;case 8:this.#E()&&this.#n(9,1);break;case 9:break;case 10:break}}this.#i.hostname!==void 0&&this.#i.port===void 0&&(this.#i.port="")}#n(s,a){switch(this.#o){case 0:break;case 1:this.#i.protocol=this.#S();break;case 2:break;case 3:this.#i.username=this.#S();break;case 4:this.#i.password=this.#S();break;case 5:this.#i.hostname=this.#S();break;case 6:this.#i.port=this.#S();break;case 7:this.#i.pathname=this.#S();break;case 8:this.#i.search=this.#S();break;case 9:this.#i.hash=this.#S();break;case 10:break}this.#o!==0&&s!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(s)&&(this.#i.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(s)&&(this.#i.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&s===9&&(this.#i.search??="")),this.#v(s,a)}#v(s,a){this.#o=s,this.#m=this.#e+a,this.#e+=a,this.#a=0}#y(){this.#e=this.#m,this.#a=0}#p(s){this.#y(),this.#o=s}#d(s){return s<0&&(s=this.#r.length-s),s<this.#r.length?this.#r[s]:this.#r[this.#r.length-1]}#h(s,a){let u=this.#d(s);return u.value===a&&(u.type==="CHAR"||u.type==="ESCAPED_CHAR"||u.type==="INVALID_CHAR")}#g(){return this.#h(this.#e,":")}#w(){return this.#h(this.#e+1,"/")&&this.#h(this.#e+2,"/")}#C(){return this.#h(this.#e,"@")}#T(){return this.#h(this.#e,":")}#k(){return this.#h(this.#e,":")}#x(){return this.#h(this.#e,"/")}#_(){if(this.#h(this.#e,"?"))return!0;if(this.#r[this.#e].value!=="?")return!1;let s=this.#d(this.#e-1);return s.type!=="NAME"&&s.type!=="REGEX"&&s.type!=="CLOSE"&&s.type!=="ASTERISK"}#E(){return this.#h(this.#e,"#")}#D(){return this.#r[this.#e].type=="OPEN"}#s(){return this.#r[this.#e].type=="CLOSE"}#N(){return this.#h(this.#e,"[")}#b(){return this.#h(this.#e,"]")}#S(){let s=this.#r[this.#e],a=this.#d(this.#m).index;return this.#t.substring(a,s.index)}#I(){let s={};Object.assign(s,lI),s.encodePart=oOe;let a=fdr(this.#S(),void 0,s);this.#l=ymt(a)}},sOe=["protocol","username","password","hostname","port","pathname","search","hash"],cI="*";function fmt(s,a){if(typeof s!="string")throw new TypeError("parameter 1 is not of type 'string'.");let u=new URL(s,a);return{protocol:u.protocol.substring(0,u.protocol.length-1),username:u.username,password:u.password,hostname:u.hostname,port:u.port,pathname:u.pathname,search:u.search!==""?u.search.substring(1,u.search.length):void 0,hash:u.hash!==""?u.hash.substring(1,u.hash.length):void 0}}t(fmt,"ge");function OP(s,a){return a?hH(s):s}t(OP,"b");function mH(s,a,u){let p;if(typeof a.baseURL=="string")try{p=new URL(a.baseURL),a.protocol===void 0&&(s.protocol=OP(p.protocol.substring(0,p.protocol.length-1),u)),!u&&a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.username===void 0&&(s.username=OP(p.username,u)),!u&&a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.username===void 0&&a.password===void 0&&(s.password=OP(p.password,u)),a.protocol===void 0&&a.hostname===void 0&&(s.hostname=OP(p.hostname,u)),a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&(s.port=OP(p.port,u)),a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.pathname===void 0&&(s.pathname=OP(p.pathname,u)),a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.pathname===void 0&&a.search===void 0&&(s.search=OP(p.search.substring(1,p.search.length),u)),a.protocol===void 0&&a.hostname===void 0&&a.port===void 0&&a.pathname===void 0&&a.search===void 0&&a.hash===void 0&&(s.hash=OP(p.hash.substring(1,p.hash.length),u))}catch{throw new TypeError(`invalid baseURL '${a.baseURL}'.`)}if(typeof a.protocol=="string"&&(s.protocol=xdr(a.protocol,u)),typeof a.username=="string"&&(s.username=bdr(a.username,u)),typeof a.password=="string"&&(s.password=vdr(a.password,u)),typeof a.hostname=="string"&&(s.hostname=ydr(a.hostname,u)),typeof a.port=="string"&&(s.port=Tdr(a.port,s.protocol,u)),typeof a.pathname=="string"){if(s.pathname=a.pathname,p&&!ddr(s.pathname,u)){let g=p.pathname.lastIndexOf("/");g>=0&&(s.pathname=OP(p.pathname.substring(0,g+1),u)+s.pathname)}s.pathname=Sdr(s.pathname,s.protocol,u)}return typeof a.search=="string"&&(s.search=gdr(a.search,u)),typeof a.hash=="string"&&(s.hash=hdr(a.hash,u)),s}t(mH,"w");function hH(s){return s.replace(/([+*?:{}()\\])/g,"\\$1")}t(hH,"C");function Ndr(s){return s.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(Ndr,"Oe");function Idr(s,a){a.delimiter??="/#?",a.prefixes??="./",a.sensitive??=!1,a.strict??=!1,a.end??=!0,a.start??=!0,a.endsWith="";let u=".*",p=`[^${Ndr(a.delimiter)}]+?`,g=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let k=0;k<s.length;++k){let A=s[k];if(A.type===3){if(A.modifier===3){b+=hH(A.value);continue}b+=`{${hH(A.value)}}${jM(A.modifier)}`;continue}let M=A.hasCustomName(),U=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!a.prefixes.includes(A.prefix)),ne=k>0?s[k-1]:null,Z=k<s.length-1?s[k+1]:null;if(!U&&M&&A.type===1&&A.modifier===3&&Z&&!Z.prefix.length&&!Z.suffix.length)if(Z.type===3){let z=Z.value.length>0?Z.value[0]:"";U=g.test(z)}else U=!Z.hasCustomName();if(!U&&!A.prefix.length&&ne&&ne.type===3){let z=ne.value[ne.value.length-1];U=a.prefixes.includes(z)}U&&(b+="{"),b+=hH(A.prefix),M&&(b+=`:${A.name}`),A.type===2?b+=`(${A.value})`:A.type===1?M||(b+=`(${p})`):A.type===0&&(!M&&(!ne||ne.type===3||ne.modifier!==3||U||A.prefix!=="")?b+="*":b+=`(${u})`),A.type===1&&M&&A.suffix.length&&g.test(A.suffix[0])&&(b+="\\"),b+=hH(A.suffix),U&&(b+="}"),A.modifier!==3&&(b+=jM(A.modifier))}return b}t(Idr,"ke");var xmt=class{static{t(this,"me")}#t;#r={};#i={};#e={};#a={};#m=!1;constructor(s={},a,u){try{let p;if(typeof a=="string"?p=a:u=a,typeof s=="string"){let A=new Adr(s);if(A.parse(),s=A.result,p===void 0&&typeof s.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");s.baseURL=p}else{if(!s||typeof s!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(p)throw new TypeError("parameter 1 is not of type 'string'.")}typeof u>"u"&&(u={ignoreCase:!1});let g={ignoreCase:u.ignoreCase===!0},b={pathname:cI,protocol:cI,username:cI,password:cI,hostname:cI,port:cI,search:cI,hash:cI};this.#t=mH(b,s,!0),vmt(this.#t.protocol)===this.#t.port&&(this.#t.port="");let k;for(k of sOe){if(!(k in this.#t))continue;let A={},M=this.#t[k];switch(this.#i[k]=[],k){case"protocol":Object.assign(A,lI),A.encodePart=oOe;break;case"username":Object.assign(A,lI),A.encodePart=Edr;break;case"password":Object.assign(A,lI),A.encodePart=Cdr;break;case"hostname":Object.assign(A,_dr),hmt(M)?A.encodePart=Smt:A.encodePart=bmt;break;case"port":Object.assign(A,lI),A.encodePart=Tmt;break;case"pathname":ymt(this.#r.protocol)?(Object.assign(A,pdr,g),A.encodePart=kdr):(Object.assign(A,lI,g),A.encodePart=wdr);break;case"search":Object.assign(A,lI,g),A.encodePart=Ddr;break;case"hash":Object.assign(A,lI,g),A.encodePart=Pdr;break}try{this.#a[k]=pmt(M,A),this.#r[k]=dmt(this.#a[k],this.#i[k],A),this.#e[k]=Idr(this.#a[k],A),this.#m=this.#m||this.#a[k].some(U=>U.type===2)}catch{throw new TypeError(`invalid ${k} pattern '${this.#t[k]}'.`)}}}catch(p){throw new TypeError(`Failed to construct 'URLPattern': ${p.message}`)}}test(s={},a){let u={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&a)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return!1;try{typeof s=="object"?u=mH(u,s,!1):u=mH(u,fmt(s,a),!1)}catch{return!1}let p;for(p of sOe)if(!this.#r[p].exec(u[p]))return!1;return!0}exec(s={},a){let u={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof s!="string"&&a)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof s>"u")return;try{typeof s=="object"?u=mH(u,s,!1):u=mH(u,fmt(s,a),!1)}catch{return null}let p={};a?p.inputs=[s,a]:p.inputs=[s];let g;for(g of sOe){let b=this.#r[g].exec(u[g]);if(!b)return null;let k={};for(let[A,M]of this.#i[g].entries())if(typeof M=="string"||typeof M=="number"){let U=b[A+1];k[M]=U}p[g]={input:u[g]??"",groups:k}}return p}static compareComponent(s,a,u){let p=t((A,M)=>{for(let U of["type","modifier","prefix","value","suffix"]){if(A[U]<M[U])return-1;if(A[U]!==M[U])return 1}return 0},"o"),g=new gH(3,"","","","",3),b=new gH(0,"","","","",3),k=t((A,M)=>{let U=0;for(;U<Math.min(A.length,M.length);++U){let ne=p(A[U],M[U]);if(ne)return ne}return A.length===M.length?0:p(A[U]??g,M[U]??g)},"s");return!a.#e[s]&&!u.#e[s]?0:a.#e[s]&&!u.#e[s]?k(a.#a[s],[b]):!a.#e[s]&&u.#e[s]?k([b],u.#a[s]):k(a.#a[s],u.#a[s])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#m}};globalThis.URLPattern||(globalThis.URLPattern=xmt);import{AssertionError as Odr}from"assert";function W8(s,a){if(s===!1)throw new Odr({message:a})}t(W8,"assert");var hc;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.FunctionBody="FunctionBody"})(hc||(hc={}));function yH(s){return s.type===hc.Object}t(yH,"isAstObject");function FP(s){return s.type===hc.Property}t(FP,"isAstProperty");function Emt(s){return s.type===hc.Array}t(Emt,"isAstArray");function BM(s){return s.type===hc.Literal}t(BM,"isAstLiteral");import{visit as Fdr}from"jsonc-parser";var Ldr={DEFAULT:{allowTrailingComma:!1}};function vH(s,a=[],u=Ldr.DEFAULT){let p={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function g(M){p.type==="property"&&(p.length=M-p.offset,p=p.parent)}t(g,"ensurePropertyComplete");function b(M){return p.children?.push(M),M}t(b,"onValue"),Fdr(s,{onObjectBegin:t((M,U,ne)=>{p=b({type:"object",offset:M,length:-1,line:U+1,column:ne+1,parent:p,children:[]})},"onObjectBegin"),onObjectProperty:t((M,U,ne,Z,z)=>{p=b({type:"property",offset:U,length:-1,line:Z+1,column:z+1,parent:p,children:[]}),p.children?.push({type:"string",value:M,offset:U,length:ne,line:Z,column:z,parent:p})},"onObjectProperty"),onObjectEnd:t((M,U)=>{g(M+U),p.length=M+U-p.offset,p=p.parent,g(M+U)},"onObjectEnd"),onArrayBegin:t((M,U,ne,Z)=>{p=b({type:"array",offset:M,length:-1,line:ne+1,column:Z+1,parent:p,children:[]})},"onArrayBegin"),onArrayEnd:t((M,U)=>{p.length=M+U-p.offset,p=p.parent,g(M+U)},"onArrayEnd"),onLiteralValue:t((M,U,ne,Z,z)=>{b({type:Rdr(M),offset:U,length:ne,line:Z+1,column:z+1,parent:p,value:M}),g(U+ne)},"onLiteralValue"),onSeparator:t((M,U)=>{p.type==="property"&&(M===":"?p.colonOffset=U:M===","&&g(U))},"onSeparator"),onError:t((M,U,ne,Z,z)=>{a.push({error:M,offset:U,length:ne,line:Z+1,column:z+1})},"onError")},u);let A=p.children[0];return A&&delete A.parent,A}t(vH,"parse");function Rdr(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(Rdr,"getNodeType");var bH=class{static{t(this,"AstAdapter")}parse(a){let p=vH(a,[]);if(p)return this.parseNode(p,void 0);throw new Error("Failed to parse JSON")}convert(a){return this.parseNode(a,void 0)}parseNode(a,u){switch(a.type){case"object":return this.createObject(a,u);case"array":return this.createArray(a,u);case"property":return this.createProperty(a,u);case"string":return this.createLiteral(a,u);case"number":return this.createLiteral(a,u);case"boolean":return this.createLiteral(a,u);case"null":return this.createLiteral(a,u)}}createLiteral(a,u){return{type:hc.Literal,location:{line:a.line,column:a.column},parent:u,value:a.type==="null"?null:a.value}}createObject(a,u){let p={type:hc.Object,children:[],parent:u,location:{line:a.line,column:a.column}};return a.children?.forEach(g=>{p.children.push(this.parseNode(g,p))}),p}createProperty(a,u){W8(a.children?.length===2,"Invalid property node");let p={type:hc.Property,location:{line:a.line,column:a.column},parent:u,name:null,value:null};return p.name={value:a.children[0].value,location:{line:a.line,column:a.column},type:hc.Identifier,parent:p},p.value=this.parseNode(a.children[1],p),p}createArray(a,u){let p={type:hc.Array,location:{line:a.line,column:a.column},parent:u,children:[]};return a.children?.forEach(g=>p.children.push(this.parseNode(g,p))),p}};var CT={createLiteral:t((s,a)=>({type:hc.Literal,parent:a,value:s}),"createLiteral"),createTemplateString:t((s,a)=>({type:hc.TemplateString,parent:a,value:s}),"createTemplateString"),createIdentifier:t((s,a)=>({type:hc.Identifier,value:s,parent:a}),"createIdentifier"),createProperty:t((s,a,u)=>{let p={type:hc.Property,parent:u,name:null,value:a};return p.name={value:s,type:hc.Identifier,parent:p},p.value.parent=p,p},"createProperty"),createArrayOfLiterals:t((s,a)=>{let u={type:hc.Array,parent:a,children:[]};for(let p of s)u.children.push(CT.createLiteral(p,u));return u},"createArrayOfLiterals")};var SH=class{static{t(this,"SourceGenerator")}generate(a){let u=[];return this.generateSource(u,a),u.join("")}generateSource(a,u){switch(u.type){case hc.Array:return this.generateArray(a,u);case hc.Object:return this.generateObject(a,u);case hc.Property:return this.generateProperty(a,u);case hc.Literal:return this.generateLiteral(a,u);case hc.FunctionCall:return this.generateFunctionCall(a,u);case hc.Identifier:return this.generateIdentifier(a,u);case hc.FunctionBody:return this.generateFunctionBody(a,u);case hc.TemplateString:return this.generateTemplateString(a,u)}}generateArray(a,u){a.push("["),u.children.map(p=>{this.generateSource(a,p),a.push(",")}),a.push("]")}generateObject(a,u){a.push("{"),u.children.forEach(p=>{this.generateSource(a,p),a.push(",")}),a.push("}")}generateProperty(a,u){let p=u.name.value,g=p.search(/(\/|\\|-|\+|@|#|%|\^|&|\*|:|\.)/g)<0?p:`'${p}'`;a.push(g),a.push(":"),this.generateSource(a,u.value)}generateFunctionCall(a,u){a.push(u.name.value),a.push("("),u.children.forEach((p,g,b)=>{this.generateSource(a,p),g<b.length&&a.push(",")}),a.push(")")}generateFunctionBody(a,u){a.push(u.value)}generateTemplateString(a,u){a.push("`"),a.push(u.value.replaceAll("`","\\`")),a.push("`")}generateLiteral(a,u){if(u.value===null)return a.push("null");switch(typeof u.value){case"number":case"boolean":return a.push(`${u.value}`);case"string":{let p=u.value,g=JSON.stringify(p);return a.push(`${g}`)}}}generateIdentifier(a,u){a.push(u.value)}};import{parse as Mdr}from"@swc/core";import jdr from"fs/promises";var Cmt=t(async s=>{let a=new Set;try{let u=await jdr.readFile(s,"utf-8");(await Mdr(u,{syntax:"typescript"})).body.forEach(g=>{g.type==="ExportDefaultDeclaration"||g.type==="ExportDefaultExpression"?a.add("default"):g.type==="ExportDeclaration"&&g.declaration.type==="FunctionDeclaration"?a.add(g.declaration.identifier.value):g.type==="ExportDeclaration"&&g.declaration.type==="VariableDeclaration"&&g.declaration.declarations[0].id.type==="Identifier"&&a.add(g.declaration.declarations[0].id.value)})}catch{return null}return a},"getJSFileExports");var kmt={$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 cOe={$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 wmt={$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 lOe={$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:{},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 uOe={$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","version"],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:{},version:{type:"string",pattern:"^[0-9a-z-]+$"},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 Dmt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/routes.schema.json",title:"Route Config File",type:"object",additionalProperties:!1,required:["routes","versions"],$defs:{info:{type:"object",required:["title","version"],properties:{title:{type:"string"},summary:{type:"string"},description:{type:"string"},termsOfService:{type:"string",format:"uri"},version:{type:"string"}}},versionData:{type:"object",required:["name","pathPrefix"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},pathPrefix:{type:"string",pattern:"(^$|^/[^\\s]*$)"},info:{$ref:"#/$defs/info"},openApiFile:{description:"The project relative path to the OpenAPI spec.",type:"string"},excludeFromOpenApi:{type:"boolean",description:"If false, OpenAPI documentation will not be generated for this version. If openApiFile is set this setting is ignored."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."}}}},properties:{$schema:{type:"string"},versions:{type:"array",minItems:1,items:{$ref:"#/$defs/versionData"}},routes:{type:"array",minItems:0,items:{$ref:"route-configuration.schema.json"}},policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}},requestErrorHandler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"}}};var B0t=sm(c0t(),1),U0t=sm(j0t(),1);var zue=class s{static{t(this,"JsonValidator")}static#t=new s;static get instance(){return s.#t}ajv;constructor(){this.ajv=new U0t.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,B0t.default)(this.ajv,{mode:"fast"})}addSchema(a,u){this.ajv.addSchema(a,u)}compile(a){let u=this.ajv.compile(a);return t(g=>({isValid:u(g),errors:this.toSimpleErrors(u.errors,g),warnings:[]}),"validator")}toSimpleErrors(a,u){let p=[];return a?.forEach(g=>{g.keyword==="enum"&&g.params.allowedValues&&Array.isArray(g.params.allowedValues)&&(g.message+=`; ${g.params.allowedValues.join(", ")}`),g.instancePath&&(g.instancePath=g.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},k=g.instancePath.split("/");if(k.length>2){let M=k[1],U=k[2]?parseInt(k[2]):0,ne=k[3],Z=isNaN(U)?void 0:u[M][U][ne];b={details:{property:M,index:U,field:ne,fieldValue:Z}}}if(g.keyword==="required"&&g.params.missingProperty&&g.instancePath&&(g.message=`A 'path' is missing required property '${g.params.missingProperty}'`),g.keyword==="additionalProperties"&&g.params.additionalProperty&&g.instancePath&&(g.message=`A 'path' should NOT include property '${g.params.additionalProperty}'`),g.keyword==="type"&&g.params.type&&g.instancePath){let M=g.instancePath.split("/"),U=M[M.length-1];g.message=`Value of property '${U}' must be '${g.params.type}'`}let A=Object.assign(g,b);p.push(A)}),p}};var BP=zue.instance;BP.addSchema(Dmt,"routes.schema.json");BP.addSchema(uOe,"route-configuration.schema.json");BP.addSchema(wmt,"policy-configuration.schema.json");BP.addSchema(cOe,"policies.schema.json");BP.addSchema(lOe,"open-api-route-configuration.schema.json");BP.addSchema(kmt,"fragments.schema.json");var qvr=BP.compile(uOe),$0t=BP.compile(lOe),E7e=BP.compile(cOe);var Vue=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(a){return this.results=E7e(a),this.results}};var Wue=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(a){return this.results=$0t(a),this.results}};import Vvr from"path";var C7e=/\$import\((.*)\)/,Gue=/\$env\((.*?)\)/g;var UP=class extends Error{static{t(this,"CodeGenError")}location;constructor(a,u,p,g){super(a),this.location={file:u,namespace:"",line:p?p.line:0,column:p?p.column:0,length:0,lineText:g??"",suggestion:""}}},zvr=t(s=>{let a=[],u=s;for(;u.parent;)a.push(u),u=u.parent;return a.reverse()},"invertTree"),yI=t((s,a)=>{if(!s)return!1;let u=zvr(s);return a.split("/").every((b,k)=>{let A=u[k];return A?b==="*"||FP(A)&&A.name.value===b?!0:b==="{}"?A.type===hc.Object:b==="[]"?A.type===hc.Array:!1:!1})},"testPosition");var Hue=class{static{t(this,"AstTransformer")}errors=[];transform(a){return this.visitor(a),a}visitor(a){this.visit(a),yH(a)?a.children.forEach(u=>{this.visitor(u)}):Emt(a)?a.children.forEach(u=>{this.visitor(u)}):FP(a)&&this.visitor(a.value)}},J0t=t((s,a,u)=>p=>{if(!FP(p)||!BM(p.value)||typeof p.value.value!="string")return;if(!s.some(b=>yI(p,b))){Gue.test(p.value.value)&&a.push(new UP("An $env() statement is not expected at this location.",u,p.location,p.value.value));return}let g=new RegExp(Gue).exec(p.value.value);if(g?.length===2&&g[0]===p.value.value){let b={type:hc.FunctionBody,parent:null,value:`environment["${g[1]}"]`};p.value=b}else{let b=p.value.value.replaceAll(new RegExp(Gue),(k,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);b!==p.value.value&&(p.value=CT.createTemplateString(b,p))}},"getEnvStatementTransformer");var ZH="config/routes.json",Wvr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Gvr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],q0t=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Hvr="handler/{}/options/{}/rewritePattern",Kvr="handler/{}/options/{}/baseUrl",Kue=class extends Hue{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(a){this.addedImports.has(a)||this.addedImports.set(a,`__import${this.importCount++}`);let u=this.addedImports.get(a);if(!u)throw new Error("Import name is undefined. This should not happen.");return u}getImports(){let a=[];return this.addedImports.forEach((u,p)=>{a.push({name:u,path:p})}),a}visit(a){this.rewriteHandlerFunction(a),this.rewriteForwardFunction(a),this.replaceImportStatements(a),this.replaceEnvStatements(a)}rewriteHandlerFunction(a){if(!(!FP(a)||!BM(a.value)||typeof a.value.value!="string")&&yI(a,Hvr)){if(!a.parent||!yH(a.parent)){this.errors.push(new UP("Invalid node, expected object",ZH,a.parent?a.parent.location:a.location,void 0));return}let u=a.value.value,p={type:hc.FunctionBody,parent:null,value:z0t(u)},g=CT.createProperty("__rewriteFunction",p,a);a.parent.children.push(g)}}rewriteForwardFunction(a){if(!(!FP(a)||!BM(a.value)||typeof a.value.value!="string")&&yI(a,Kvr)){if(!a.parent||!yH(a.parent)){this.errors.push(new UP("Invalid node, expected object",ZH,a.parent?a.parent.location:a.location,void 0));return}let u=a.value.value,p={type:hc.FunctionBody,parent:null,value:z0t(u)},g=CT.createProperty("__rewriteFunction",p,a);a.parent.children.push(g)}}replaceImportStatements(a){if(!FP(a)||!BM(a.value))return;let u=a.value.value;if(typeof u!="string")return;if(!Gvr.some(A=>yI(a,A))&&!q0t.some(A=>yI(a,A))){if(C7e.test(u)){if(a.name.value==="$ref")return;this.errors.push(new UP("An $import() statement is not expected at this location.",ZH,a.location,u))}return}let p=C7e.exec(u);if(q0t.some(A=>yI(a,A))&&!p)return;if(!p){this.errors.push(new UP("Invalid $import() statement",ZH,a.location,u));return}let g=p[1];g.startsWith(".")&&(g=Vvr.join("..",g));let b=this.getImportName(g),k={type:hc.Identifier,parent:a.parent,value:b};a.value=k}replaceEnvStatements=J0t(Wvr,this.errors,ZH)};function z0t(s){return`(request, context) => {
|
|
709
709
|
const { params, url, query, method, headers } = request;
|
|
710
710
|
const { host, hostname, origin, pathname, port, search } = new URL(url);
|
|
711
711
|
const e = encodeURIComponent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2522.0",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"prettier": "^3.3.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@zuplo/graphql": "5.
|
|
44
|
-
"@zuplo/otel": "5.
|
|
45
|
-
"@zuplo/runtime": "5.
|
|
43
|
+
"@zuplo/graphql": "5.2522.0",
|
|
44
|
+
"@zuplo/otel": "5.2522.0",
|
|
45
|
+
"@zuplo/runtime": "5.2522.0"
|
|
46
46
|
}
|
|
47
47
|
}
|