@zuplo/core 6.54.12 → 6.54.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/customer.cli.minified.js +3 -3
- package/index.minified.js +3 -3
- package/package.json +4 -4
package/customer.cli.minified.js
CHANGED
|
@@ -580,7 +580,7 @@ globstar while`,s,Q,l,Re,Ie),this.matchOne(s.slice(Q),l.slice(Re),_))return this
|
|
|
580
580
|
`),exitCode:D},"Tar process logs")}}t(Ear,"tarFolder");async function Car({tarFilePath:a,outputDir:s,logger:l}){let _=[],h=[],b;try{await new Promise((D,N)=>{let M=Kut("sh",["-c",`tar -xvf ${a} -C ${s};`]);M.stdout.on("data",z=>{let re=z.toString().trim();re.length>0&&_.push(re.trim())}),M.stderr.on("data",z=>{let re=z.toString().trim();re.length>0&&h.push(re.trim())}),M.on("close",z=>{b=z,z===0?D():N(new Error(`tar process exited with code ${z}`))}),M.on("error",z=>{N(z)})})}catch(D){throw new Error("Failed to untar file",{cause:D})}finally{l.info({stdout:_.join(`
|
|
581
581
|
`),stderr:h.join(`
|
|
582
582
|
`),exitCode:b},"Untar process logs")}}t(Car,"untarFile");async function Dar(a){if(await H3e(a))return await j3.rm(a,{recursive:!0})}t(Dar,"deleteFolder");var ou=G3e;var OT=ap(W3e(),1);var cF=class extends Error{static{t(this,"CustomResolveError")}},B3=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return TG.$RefParser.dereference(s,{resolve:{json:!0,file:due(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return TG.$RefParser.bundle(s,{resolve:{file:due(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return TG.$RefParser.parse(s,{resolve:{file:due(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return TG.$RefParser.resolve(s,{resolve:{file:due(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function due(a,s){return{order:100,canRead(l){let _=Aar(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=Zut(l.url)}catch(D){throw new cF(`Malformed URI: ${l.url}`,{cause:D})}try{ou.safePath(a).resolve(b)}catch(D){return s?.warn(D),!1}return!0},async read(l){let _;try{_=Zut(l.url)}catch(h){throw new cF(`Malformed URI: ${l.url}`,{cause:h})}try{return await kar(_)}catch(h){throw new cF(`Error opening file "${_}"`,{cause:h})}}}}t(due,"customResolver");var sj=/^win/.test(globalThis.process?globalThis.process.platform:""),war=/\//g,Par=/^(\w{2,}):\/\//i,K3e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function Aar(a){let s=Par.exec(a);if(s)return s[1].toLowerCase()}t(Aar,"getProtocol");function Zut(a,s){a=decodeURI(a);for(let _=0;_<K3e.length;_+=2)a=a.replace(K3e[_],K3e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";if(l&&(a=a[7]==="/"?a.substr(8):a.substr(7),sj&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=sj?a:"/"+a)),!l){let _=a.split(sj?"\\":"/"),h=[];for(let b of _)b===".."?h.length&&h[h.length-1]!==""&&h.pop():(b!==""||h.length===0)&&h.push(b);a=h.join(sj?"\\":"/"),!sj&&h[0]===""&&(a="/"+a.substring(1))}return sj&&!l&&(a=a.replace(war,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(Zut,"toFileSystemPath");var eft="YOUR_KEY_HERE";async function tft(a){let l=await new B3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return Nar({...a,relativeOpenApiPath:_},l)}t(tft,"buildPublicOpenApiFile");async function Nar(a,s){Lar({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=Oar(l),Iar(l,a.urls?.api?.defaultUrl),l=Far(l,a),rft(l,"x-zuplo"),l}t(Nar,"buildRawOpenApiFile");function Iar(a,s){s?a.servers=[{url:s}]:a.servers=[]}t(Iar,"addServerHost");function Oar(a){if(!a.paths)return a;let{components:s}=a,l=s?{...s}:void 0,_=[];l&&l.parameters&&(_=Object.entries(l.parameters).reduce((b,[D,N])=>(AM in N&&ale(N[AM])&&(b.push(D),l.parameters&&delete l.parameters[D]),b),[]));let h=Object.entries(a.paths).reduce((b,[D,N])=>{if(!N)return b;let M={...N},z=["delete","get","head","patch","post","put","trace","options"];return z.forEach(re=>{let ie=N[re];if(!ie)return;if(ale(ie[AM])){delete M[re];return}let{parameters:Q}=ie;if(!Q)return;let Re=Q.filter(Ie=>{if(AM in Ie&&ale(Ie[AM]))return!1;if("$ref"in Ie){let we=Ie.$ref.split("/").pop();return we?!_.includes(we):!0}return!0});M[re]={...ie,parameters:Re}}),z.some(re=>!!M[re])&&(b[D]=M),b},{});return{...a,paths:h,components:l}}t(Oar,"removeHiddenRoutesAndParams");function Far(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[h,b])=>{if(!b)return _;let D={...b};return[D.delete,D.get,D.head,D.patch,D.post,D.put,D.trace,D.options].forEach(N=>{if(!N)return;let M=N["x-zuplo-route"]?.policies?.inbound?.reduce((ie,Q)=>{let Re=s.policies?.find(({name:wt})=>wt===Q);if(!Re)return ie;if(!(Re.handler.export==="CompositeInboundPolicy"))return ie.concat(Q);let we=Re.handler.options?.policies;return we?ie.concat(we):ie},[]),z=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="ApiAuthKeyInboundPolicy"||Q.handler.export==="ApiKeyInboundPolicy")&&!Q.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&z.push(Q)})}),z.length>0){let ie=z.length>0&&z[0].handler&&z[0].handler.options&&z[0].handler.options.authHeader?z[0].handler.options.authHeader:"Authorization",Q=z.length>0&&z[0].handler&&z[0].handler.options&&(z[0].handler.options.authScheme||z[0].handler.options.authScheme==="")?z[0].handler.options.authScheme:"Bearer",Re=Q!==""?`${Q} ${eft}`:eft,Ie={name:ie,in:"header",required:!0,example:Re,schema:{type:"string"},description:`The \`${ie}\` header is used to authenticate with the API using your API key. Value is of the format \`${Re}\`.`};N.parameters?N.parameters.some(Tr=>"name"in Tr&&Tr.name===Ie.name)||N.parameters.unshift(Ie):N.parameters=[Ie];let we={type:"http",scheme:Q.toLowerCase()},wt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(Tr=>"name"in Tr&&Tr.type==="apiKey"||"type"in Tr&&Tr.type==="http"&&Tr.scheme===Q)||(a.components.securitySchemes={...a.components.securitySchemes,[wt]:we}):(a.components||(a.components={}),a.components.securitySchemes={[wt]:we});let xt={[wt]:[]};N.security?N.security.some(Tr=>Tr[wt]!==void 0)||N.security.unshift(xt):N.security=[xt]}let re=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="RateLimitInboundPolicy"||Q.handler.export==="ComplexRateLimitInboundPolicy")&&re.push(Q)})}),re.length>0){let ie={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},Q={...ie,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};a.components?.responses||a.components||(a.components={}),a.components.responses={...a.components.responses,RateLimitNoRetryAfter:ie,RateLimitWithRetryAfter:Q},N.responses||(N.responses={});let Re=re.some(Ie=>Ie.handler.options?.headerMode!=="none");N.responses[429]||(N.responses[429]={$ref:Re?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[h]=D,_},{});return{...a,paths:l}}t(Far,"enrichSpecWithZuploData");function rft(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&rft(a[l],s)}t(rft,"removePropertiesByPrefix");function Lar({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new q1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new q1({message:"The OpenAPI document does not have the required 'info' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in s.info)||typeof s.info.title!="string")throw new q1({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(Lar,"assertIsZuploOpenApiSpec");import DK from"node:path";function Rar(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let z=0;z<s.length;z++)s[z]=255;for(let z=0;z<a.length;z++){let re=a.charAt(z),ie=re.charCodeAt(0);if(s[ie]!==255)throw new TypeError(re+" is ambiguous");s[ie]=z}let l=a.length,_=a.charAt(0),h=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function D(z){if(z instanceof Uint8Array||(ArrayBuffer.isView(z)?z=new Uint8Array(z.buffer,z.byteOffset,z.byteLength):Array.isArray(z)&&(z=Uint8Array.from(z))),!(z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(z.length===0)return"";let re=0,ie=0,Q=0,Re=z.length;for(;Q!==Re&&z[Q]===0;)Q++,re++;let Ie=(Re-Q)*b+1>>>0,we=new Uint8Array(Ie);for(;Q!==Re;){let Tr=z[Q],fn=0;for(let tn=Ie-1;(Tr!==0||fn<ie)&&tn!==-1;tn--,fn++)Tr+=256*we[tn]>>>0,we[tn]=Tr%l>>>0,Tr=Tr/l>>>0;if(Tr!==0)throw new Error("Non-zero carry");ie=fn,Q++}let wt=Ie-ie;for(;wt!==Ie&&we[wt]===0;)wt++;let xt=_.repeat(re);for(;wt<Ie;++wt)xt+=a.charAt(we[wt]);return xt}t(D,"encode");function N(z){if(typeof z!="string")throw new TypeError("Expected String");if(z.length===0)return new Uint8Array;let re=0,ie=0,Q=0;for(;z[re]===_;)ie++,re++;let Re=(z.length-re)*h+1>>>0,Ie=new Uint8Array(Re);for(;z[re];){let Tr=s[z.charCodeAt(re)];if(Tr===255)return;let fn=0;for(let tn=Re-1;(Tr!==0||fn<Q)&&tn!==-1;tn--,fn++)Tr+=l*Ie[tn]>>>0,Ie[tn]=Tr%256>>>0,Tr=Tr/256>>>0;if(Tr!==0)throw new Error("Non-zero carry");Q=fn,re++}let we=Re-Q;for(;we!==Re&&Ie[we]===0;)we++;let wt=new Uint8Array(ie+(Re-we)),xt=ie;for(;we!==Re;)wt[xt++]=Ie[we++];return wt}t(N,"decodeUnsafe");function M(z){let re=N(z);if(re)return re;throw new Error("Non-base"+l+" character")}return t(M,"decode"),{encode:D,decodeUnsafe:N,decode:M}}t(Rar,"base");var nft=Rar;var Mar="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",mue=nft(Mar);var jar=!1;function aj(a,s){return{open:`\x1B[${a.join(";")}m`,close:`\x1B[${s}m`,regexp:new RegExp(`\\x1b\\[${s}m`,"g")}}t(aj,"code");function oj(a,s){return jar?`${s.open}${a.replace(s.regexp,s.open)}${s.close}`:a}t(oj,"run");function Bar(a){return oj(a,aj([31],39))}t(Bar,"red");function Uar(a){return oj(a,aj([32],39))}t(Uar,"green");function $ar(a){return oj(a,aj([33],39))}t($ar,"yellow");function zar(a){return oj(a,aj([34],39))}t(zar,"blue");function Jar(a){return oj(a,aj([35],39))}t(Jar,"magenta");function qar(a){return oj(a,aj([36],39))}t(qar,"cyan");var Q8r=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 ift=[Bar,Uar,$ar,zar,Jar,qar];function Var(a){let s=0,l=a.length,_=0;if(l>0)for(;_<l;)s=(s<<5)-s+a.charCodeAt(_++)|0;return s}t(Var,"hashCode");function sft(a){let s=Math.abs(Var(a));return ift[s%ift.length]}t(sft,"generateColor");import{inspect as War}from"node:util";function aft(a,s,...l){let _=0,h=l.length,b=String(s).replace(/%[sdjoO%]/g,D=>{if(D==="%%")return"%";if(_>=h)return D;switch(D){case"%s":return String(l[_++]);case"%d":return Number(l[_++]).toString();case"%o":return a(l[_++]).split(`
|
|
583
|
-
`).map(N=>N.trim()).join(" ");case"%O":return a(l[_++]);case"%j":try{return JSON.stringify(l[_++])}catch{return"[Circular]"}default:return D}});for(let D of l.splice(_))D===null||!(typeof D=="object"&&D!==null)?b+=" "+D:b+=" "+a(D);return b}t(aft,"format");var oft=t((a,...s)=>aft(War,a,s),"format");var Y3e=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(s,l){this.manager=s,this.ns=l,this.color=sft(l),this.last=0,this.enabled=s.enabled.some(_=>_.test(l))}log(...s){if(!this.enabled)return;let l,_=s[0];typeof _=="function"?l=_():l=String(_);let h=Date.now()-(this.last||Date.now());l=oft(l,...s);let b=`${this.color(this.ns)} ${l} ${this.color(`+${h}ms`)}`;console.log(b),this.last=Date.now()}},X3e=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(s){this.debuggers=new Map,this.enabled=s??[]}};function Har(a){return!a||a.length===0?[]:(a=a.replace(/\s/g,"").replace(/\*/g,".+"),a.split(",").map(s=>new RegExp(`^${s}$`)))}t(Har,"extract");var hue;function gue(a){hue||(hue=new X3e(Har(process.env.DEBUG)));let s=new Y3e(hue,a);return hue.debuggers.set(a,s),Object.assign(s.log.bind(s),{self:s})}t(gue,"debug");var U3=class extends Error{static{t(this,"RuntimeError")}extensionMembers;constructor(s,l){typeof s=="string"?super(s,l):(super(s.message,l),this.extensionMembers=s.extensionMembers),this.name="RuntimeError"}};var cft="zp-local-service";var dOr=Symbol("zuplo_meters"),mOr=Symbol("zuplo_dynamic_meters");var lF=gue("zuplo:runtime:external-service");function Gar(){let a,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:s}=F0.instance.runtime;if(s&&s!=="undefined")try{let l=atob(s);a=JSON.parse(l)}catch{}return a}t(Gar,"getServiceAuth");async function lft(a,s){let l=Gar();if(l)if(lF(`Using external service auth. ClientId: ${l.clientId})`),typeof a=="string"){let _=new URL(a),h=_.hostname,b=s??{},D=new Headers(b.headers||{});D.set("CF-Access-Client-Id",l.clientId),D.set("CF-Access-Client-Secret",l.clientSecret),b.headers=D;let N;if(l.customServiceMapping&&l.customServiceMapping[h])N=`https://${l.customServiceMapping[h]}`;else if(F0.instance.useLegacyServiceRouting)N=`https://${h}.zuptunnel.com`;else{lF("Using sha256 service routing");let re=F0.instance.build;if(re.ACCOUNT_NAME&&re.PROJECT_NAME&&re.ENVIRONMENT_TYPE){let ie=await Kar(h,re.ACCOUNT_NAME,re.PROJECT_NAME,re.ENVIRONMENT_TYPE),Q=fft(re.ENVIRONMENT_TYPE),Re=await Q3e(`${re.ACCOUNT_NAME}-${re.PROJECT_NAME}-${Q}`);Re==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||Re==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?N=`https://${ie}.zuptunnel.com`:N=`https://${ie}.t.zuplo.app`}else throw lF("Cannot use sha256 service routing, missing build variables"),new U3("Failed to generate fully qualified tunnel url.")}let M=new URL(`${N}${_.pathname}${_.search}`);lF(`Calling external service: ${M.toString()}`);let z=await xG(M.toString(),b);if(z.status===403&&z.headers.get("cf-access-domain")!==null)throw EG.console.error("403 Forbidden when calling external service.",{clientId:l.clientId,tunnelHost:N}),new U3("Could not connect to secure tunnel.");return z}else throw lF("Cannot call external service with Request object"),new U3("Currently, we only support fetch(<some_string>, ...).");else throw lF("There is no external service auth configured for this zup."),new U3("There are no external services configured for this zup.")}t(lft,"externalServiceHandler");async function uft(a,s){if(typeof a=="string"){let l=new URL(a),_=l.hostname,h=s??{},b=`http://${_}.zuplo.svc.cluster.local:9000`,D=new URL(`${b}${l.pathname}${l.search}`),N=new Headers(h.headers||{});return N.set(cft,_),h.headers=N,await xG(D.toString(),h)}else throw new U3("Currently, we only support fetch(<some_string>, ...).")}t(uft,"clusterServiceHandler");async function Kar(a,s,l,_){let h=a.toLowerCase(),b=s.toLowerCase(),D=l.toLowerCase(),N=fft(_);lF(`Hashing service name: ${b}-${h}.${b}-${D}-${N}`);let M=await Q3e(`${b}-${h}`),z=await Q3e(`${b}-${D}-${N}`);return`${M}.${z}`}t(Kar,"hashServiceName");async function Q3e(a){let s=new TextEncoder().encode(a),l=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(l)).map(b=>b.toString(16).padStart(2,"0")).join("").slice(0,-1)}t(Q3e,"hashSegment");function fft(a){let s=a.toLowerCase();switch(s){case"production":case"preview":return s;default:return"working-copy"}}t(fft,"sanitizeEnvironmentType");var Z3e=new Map;Z3e.set("service:",lft);Z3e.set("local:",uft);var xG=globalThis.fetch;function eNe(a,s){let l=Yar(s);if(typeof a=="string"){let _=new URL(a),h=Z3e.get(_.protocol);return h?h(a,l):xG(a,l)}else return xG(a,l)}t(eNe,"internalFetch");globalThis.fetch=eNe;var Yar=t(a=>{if(!a||a instanceof Request)return a;let s=a;if(!s.zuplo)return a;let l=a;return l.cf={cacheEverything:s.zuplo?.cacheEverything,cacheTtl:s.zuplo?.cacheTtlSeconds},delete a.zuplo,a},"transformInit");var Xar={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:eNe},EG=Xar;var tNe="2025-02-06",_ft=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function pft(){return new F0({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:tNe,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:_ft[tNe]},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(pft,"getMockEnvironment");var F0=class a{static{t(this,"Environment")}config;static#r;static#n=!1;static initialize(s){this.#r||(this.#r=new a(s),this.#n=!0)}static get instance(){return this.#n||(EG.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#r=pft()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(mue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let D of Object.keys(b))l[D]||(l[D]=b[D])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){EG.console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,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 zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.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 Qar=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function dft(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!Qar.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(dft,"isRestrictedEnvVariableName");function mft(a){return!!a.startsWith("ZUPLO_")}t(mft,"isZuploReadableEnvVariableName");var $Or=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return F0.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return F0.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return F0.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return F0.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return F0.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return F0.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return F0.instance.build.COMPATIBILITY_DATE}if(!(dft(l)&&!mft(l)))return F0.instance.runtime[l]}});function CG(a,s,l){return`_${DA(`${a}_${s}_${l}`)}`}t(CG,"getRawOperationDataIdentifierName");function rNe(a,s,l,_){return`_${DA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(rNe,"getIdForParameterSchema");function nNe(a,s,l){return`_${DA(a.toLowerCase())}_${s.toLowerCase()}_rb_${DA(l.toLowerCase())}`}t(nNe,"getIdForRequestBodySchema");function DG(a,s){return`_${DA(a)}_${DA(s)}`}t(DG,"getIdForRefSchema");function DA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s="_"+s),s}t(DA,"sanitizedIdentifierName");var Hht=ap(spt(),1);var zG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Vlr=/[$_\p{ID_Start}]/u,Wlr=/[$_\u200C\u200D\p{ID_Continue}]/u,XNe=".*";function Hlr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(Hlr,"Re");function cpt(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let D="",N=_+1;for(;N<a.length;){let M=a.substr(N,1);if(N===_+1&&Vlr.test(M)||N!==_+1&&Wlr.test(M)){D+=a[N++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=N;continue}if(h==="("){let D=1,N="",M=_+1,z=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!Hlr(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),z=!0;break}if(a[M]==="\\"){N+=a[M++]+a[M++];continue}if(a[M]===")"){if(D--,D===0){M++;break}}else if(a[M]==="("&&(D++,a[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),z=!0;break}N+=a[M++]}if(z)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!N){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:N}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(cpt,"v");function lpt(a,s={}){let l=cpt(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${MT(s.delimiter)}]+?`,h=[],b=0,D=0,N="",M=new Set,z=t(fn=>{if(D<l.length&&l[D].type===fn)return l[D++].value},"a"),re=t(()=>z("OTHER_MODIFIER")??z("ASTERISK"),"f"),ie=t(fn=>{let tn=z(fn);if(tn!==void 0)return tn;let{type:cn,index:Er}=l[D];throw new TypeError(`Unexpected ${cn} at ${Er}, expected ${fn}`)},"d"),Q=t(()=>{let fn="",tn;for(;tn=z("CHAR")??z("ESCAPED_CHAR");)fn+=tn;return fn},"T"),Re=t(fn=>fn,"Se"),Ie=s.encodePart||Re,we="",wt=t(fn=>{we+=fn},"U"),xt=t(()=>{we.length&&(h.push(new zG(3,"","",Ie(we),"",3)),we="")},"$"),Tr=t((fn,tn,cn,Er,vr)=>{let fs=3;switch(vr){case"?":fs=1;break;case"*":fs=0;break;case"+":fs=2;break}if(!tn&&!cn&&fs===3){wt(fn);return}if(xt(),!tn&&!cn){if(!fn)return;h.push(new zG(3,"","",Ie(fn),"",fs));return}let Oi;cn?cn==="*"?Oi=XNe:Oi=cn:Oi=_;let Ho=2;Oi===_?(Ho=1,Oi=""):Oi===XNe&&(Ho=0,Oi="");let di;if(tn?di=tn:cn&&(di=b++),M.has(di))throw new TypeError(`Duplicate name '${di}'.`);M.add(di),h.push(new zG(Ho,di,Ie(fn),Oi,Ie(Er),fs))},"V");for(;D<l.length;){let fn=z("CHAR"),tn=z("NAME"),cn=z("REGEX");if(!tn&&!cn&&(cn=z("ASTERISK")),tn||cn){let vr=fn??"";s.prefixes.indexOf(vr)===-1&&(wt(vr),vr=""),xt();let fs=re();Tr(vr,tn,cn,"",fs);continue}let Er=fn??z("ESCAPED_CHAR");if(Er){wt(Er);continue}if(z("OPEN")){let vr=Q(),fs=z("NAME"),Oi=z("REGEX");!fs&&!Oi&&(Oi=z("ASTERISK"));let Ho=Q();ie("CLOSE");let di=re();Tr(vr,fs,Oi,Ho,di);continue}xt(),ie("END")}return h}t(lpt,"D");function MT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(MT,"S");function apt(a){return a&&a.ignoreCase?"ui":"u"}t(apt,"X");function Glr(a,s,l){return upt(lpt(a,l),s,l)}t(Glr,"Z");function gj(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(gj,"k");function upt(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let N of a){if(N.type===3){N.modifier===3?_+=MT(N.value):_+=`(?:${MT(N.value)})${gj(N.modifier)}`;continue}s&&s.push(N.name);let M=`[^${MT(l.delimiter)}]+?`,z=N.value;if(N.type===1?z=M:N.type===0&&(z=XNe),!N.prefix.length&&!N.suffix.length){N.modifier===3||N.modifier===1?_+=`(${z})${gj(N.modifier)}`:_+=`((?:${z})${gj(N.modifier)})`;continue}if(N.modifier===3||N.modifier===1){_+=`(?:${MT(N.prefix)}(${z})${MT(N.suffix)})`,_+=gj(N.modifier);continue}_+=`(?:${MT(N.prefix)}`,_+=`((?:${z})(?:`,_+=MT(N.suffix),_+=MT(N.prefix),_+=`(?:${z}))*)${MT(N.suffix)})`,N.modifier===0&&(_+="?")}let h=`[${MT(l.endsWith)}]|$`,b=`[${MT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,apt(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let D=!1;if(a.length){let N=a[a.length-1];N.type===3&&N.modifier===3&&(D=l.delimiter.indexOf(N)>-1)}return D||(_+=`(?=${b}|${h})`),new RegExp(_,apt(l))}t(upt,"F");var q3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Klr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Ylr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Xlr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Xlr,"J");function fpt(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(fpt,"Q");function Qlr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(Qlr,"Ee");function _pt(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(_pt,"W");var ppt=["ftp","file","http","https","ws","wss"];function dpt(a){if(!a)return!0;for(let s of ppt)if(a.test(s))return!0;return!1}t(dpt,"N");function Zlr(a,s){if(a=fpt(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t(Zlr,"te");function eur(a,s){if(a=fpt(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(eur,"re");function tur(a,s){return s||a===""?a:_pt(a)?gpt(a):hpt(a)}t(tur,"ne");function rur(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(rur,"se");function nur(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(nur,"ie");function iur(a,s,l){if(l||a==="")return a;if(s&&!ppt.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(iur,"ae");function sur(a,s,l){return mpt(s)===a&&(a=""),l||a===""?a:ypt(a)}t(sur,"oe");function aur(a,s){return a=Qlr(a,":"),s||a===""?a:QNe(a)}t(aur,"ce");function mpt(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(mpt,"_");function QNe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(QNe,"y");function our(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(our,"le");function cur(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(cur,"fe");function hpt(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(hpt,"z");function gpt(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(gpt,"j");function ypt(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(ypt,"K");function lur(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(lur,"he");function uur(a){return a===""?a:new URL(`data:${a}`).pathname}t(uur,"ue");function fur(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(fur,"de");function _ur(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(_ur,"pe");var pur=class{static{t(this,"H")}#r;#n=[];#e={};#t=0;#s=1;#p=0;#a=0;#_=0;#c=0;#l=!1;constructor(a){this.#r=a}get result(){return this.#e}parse(){for(this.#n=cpt(this.#r,!0);this.#t<this.#n.length;this.#t+=this.#s){if(this.#s=1,this.#n[this.#t].type==="END"){if(this.#a===0){this.#v(),this.#D()?this.#i(9,1):this.#y()?this.#i(8,1):this.#i(7,0);continue}else if(this.#a===2){this.#d(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#o())this.#_-=1;else continue;if(this.#w()){this.#_+=1;continue}switch(this.#a){case 0:this.#g()&&this.#d(1);break;case 1:if(this.#g()){this.#I();let a=7,s=1;this.#C()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#E()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#x()&&this.#i(5,1);break;case 4:this.#x()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#k()&&!this.#c?this.#i(6,1):this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let l=this.#u(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#C(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#x(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#k(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#w(){return this.#n[this.#t].type=="OPEN"}#o(){return this.#n[this.#t].type=="CLOSE"}#N(){return this.#m(this.#t,"[")}#S(){return this.#m(this.#t,"]")}#T(){let a=this.#n[this.#t],s=this.#u(this.#p).index;return this.#r.substring(s,a.index)}#I(){let a={};Object.assign(a,q3),a.encodePart=QNe;let s=Glr(this.#T(),void 0,a);this.#l=dpt(s)}},YNe=["protocol","username","password","hostname","port","pathname","search","hash"],J3="*";function opt(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(opt,"ge");function NA(a,s){return s?$G(a):a}t(NA,"b");function UG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=NA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=NA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=NA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=NA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=NA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=NA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=NA(_.search.substring(1,_.search.length),l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=NA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=aur(s.protocol,l)),typeof s.username=="string"&&(a.username=nur(s.username,l)),typeof s.password=="string"&&(a.password=rur(s.password,l)),typeof s.hostname=="string"&&(a.hostname=tur(s.hostname,l)),typeof s.port=="string"&&(a.port=sur(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!Xlr(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=NA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=iur(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=eur(s.search,l)),typeof s.hash=="string"&&(a.hash=Zlr(s.hash,l)),a}t(UG,"w");function $G(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t($G,"C");function dur(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(dur,"Oe");function mur(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${dur(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let N=a[D];if(N.type===3){if(N.modifier===3){b+=$G(N.value);continue}b+=`{${$G(N.value)}}${gj(N.modifier)}`;continue}let M=N.hasCustomName(),z=!!N.suffix.length||!!N.prefix.length&&(N.prefix.length!==1||!s.prefixes.includes(N.prefix)),re=D>0?a[D-1]:null,ie=D<a.length-1?a[D+1]:null;if(!z&&M&&N.type===1&&N.modifier===3&&ie&&!ie.prefix.length&&!ie.suffix.length)if(ie.type===3){let Q=ie.value.length>0?ie.value[0]:"";z=h.test(Q)}else z=!ie.hasCustomName();if(!z&&!N.prefix.length&&re&&re.type===3){let Q=re.value[re.value.length-1];z=s.prefixes.includes(Q)}z&&(b+="{"),b+=$G(N.prefix),M&&(b+=`:${N.name}`),N.type===2?b+=`(${N.value})`:N.type===1?M||(b+=`(${_})`):N.type===0&&(!M&&(!re||re.type===3||re.modifier!==3||z||N.prefix!=="")?b+="*":b+=`(${l})`),N.type===1&&M&&N.suffix.length&&h.test(N.suffix[0])&&(b+="\\"),b+=$G(N.suffix),z&&(b+="}"),N.modifier!==3&&(b+=gj(N.modifier))}return b}t(mur,"ke");var vpt=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let N=new pur(a);if(N.parse(),a=N.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:J3,protocol:J3,username:J3,password:J3,hostname:J3,port:J3,search:J3,hash:J3};this.#r=UG(b,a,!0),mpt(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of YNe){if(!(D in this.#r))continue;let N={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(N,q3),N.encodePart=QNe;break;case"username":Object.assign(N,q3),N.encodePart=our;break;case"password":Object.assign(N,q3),N.encodePart=cur;break;case"hostname":Object.assign(N,Klr),_pt(M)?N.encodePart=gpt:N.encodePart=hpt;break;case"port":Object.assign(N,q3),N.encodePart=ypt;break;case"pathname":dpt(this.#n.protocol)?(Object.assign(N,Ylr,h),N.encodePart=lur):(Object.assign(N,q3,h),N.encodePart=uur);break;case"search":Object.assign(N,q3,h),N.encodePart=fur;break;case"hash":Object.assign(N,q3,h),N.encodePart=_ur;break}try{this.#s[D]=lpt(M,N),this.#n[D]=upt(this.#s[D],this.#e[D],N),this.#t[D]=mur(this.#s[D],N),this.#p=this.#p||this.#s[D].some(z=>z.type===2)}catch{throw new TypeError(`invalid ${D} pattern '${this.#r[D]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?l=UG(l,a,!1):l=UG(l,opt(a,s),!1)}catch{return!1}let _;for(_ of YNe)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?l=UG(l,a,!1):l=UG(l,opt(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of YNe){let b=this.#n[h].exec(l[h]);if(!b)return null;let D={};for(let[N,M]of this.#e[h].entries())if(typeof M=="string"||typeof M=="number"){let z=b[N+1];D[M]=z}_[h]={input:l[h]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((N,M)=>{for(let z of["type","modifier","prefix","value","suffix"]){if(N[z]<M[z])return-1;if(N[z]!==M[z])return 1}return 0},"o"),h=new zG(3,"","","","",3),b=new zG(0,"","","","",3),D=t((N,M)=>{let z=0;for(;z<Math.min(N.length,M.length);++z){let re=_(N[z],M[z]);if(re)return re}return N.length===M.length?0:_(N[z]??h,M[z]??h)},"s");return!s.#t[a]&&!l.#t[a]?0:s.#t[a]&&!l.#t[a]?D(s.#s[a],[b]):!s.#t[a]&&l.#t[a]?D([b],l.#s[a]):D(s.#s[a],l.#s[a])}get protocol(){return this.#t.protocol}get username(){return this.#t.username}get password(){return this.#t.password}get hostname(){return this.#t.hostname}get port(){return this.#t.port}get pathname(){return this.#t.pathname}get search(){return this.#t.search}get hash(){return this.#t.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=vpt);import{AssertionError as hur}from"node:assert";function IA(a,s){if(a===!1)throw new hur({message:s})}t(IA,"assert");var ec;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(ec||(ec={}));function yj(a){return a.type===ec.Object}t(yj,"isAstObject");function OA(a){return a.type===ec.Property}t(OA,"isAstProperty");function bpt(a){return a.type===ec.Array}t(bpt,"isAstArray");function vj(a){return a.type===ec.Literal}t(vj,"isAstLiteral");function V3(a){if(a===void 0)throw new Error("Node is undefined");if(!yj(a))throw new Error("Node is not object")}t(V3,"assertAstObject");import{findNodeAtLocation as gur,getNodeValue as yur,printParseErrorCode as vur,visit as bur}from"jsonc-parser";var Sur={DEFAULT:{allowTrailingComma:!1}};function JG(a,s=[],l=Sur.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),bur(a,{onObjectBegin:t((M,z,re)=>{_=b({type:"object",offset:M,length:-1,line:z+1,column:re+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,z,re,ie,Q)=>{_=b({type:"property",offset:z,length:-1,line:ie+1,column:Q+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:z,length:re,line:ie,column:Q,parent:_})},"onObjectProperty"),onObjectEnd:t((M,z)=>{h(M+z),_.length=M+z-_.offset,_=_.parent,h(M+z)},"onObjectEnd"),onArrayBegin:t((M,z,re,ie)=>{_=b({type:"array",offset:M,length:-1,line:re+1,column:ie+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,z)=>{_.length=M+z-_.offset,_=_.parent,h(M+z)},"onArrayEnd"),onLiteralValue:t((M,z,re,ie,Q)=>{b({type:Tur(M),offset:z,length:re,line:ie+1,column:Q+1,parent:_,value:M}),h(z+re)},"onLiteralValue"),onSeparator:t((M,z)=>{_.type==="property"&&(M===":"?_.colonOffset=z:M===","&&h(z))},"onSeparator"),onError:t((M,z,re,ie,Q)=>{s.push({error:M,offset:z,length:re,line:ie+1,column:Q+1})},"onError")},l);let N=_.children[0];return N&&delete N.parent,N}t(JG,"parse");function Tur(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(Tur,"getNodeType");function ZNe(a,s){return gur(a,s)}t(ZNe,"findNodeAtLocation");function qG(a){return yur(a)}t(qG,"getNodeValue");function Spt(a){return vur(a)}t(Spt,"printParseErrorCode");var VG=class{static{t(this,"AstAdapter")}parse(s){let _=JG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:ec.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:ec.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){IA(s.children?.length===2,"Invalid property node");let _={type:ec.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:ec.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:ec.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var jT={createLiteral:t((a,s)=>({type:ec.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:ec.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:ec.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:ec.Property,parent:l,name:null,value:s};return _.name={value:a,type:ec.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:ec.Array,parent:s,children:[]};for(let _ of a)l.children.push(jT.createLiteral(_,l));return l},"createArrayOfLiterals")};var xur=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,WG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case ec.Array:return this.generateArray(s,l);case ec.Object:return this.generateObject(s,l);case ec.Property:return this.generateProperty(s,l);case ec.Literal:return this.generateLiteral(s,l);case ec.FunctionCall:return this.generateFunctionCall(s,l);case ec.Identifier:return this.generateIdentifier(s,l);case ec.Raw:return this.generateRaw(s,l);case ec.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=xur.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import Eur from"node:fs/promises";import{parse as Cur}from"@swc/core";var Tpt=t(async a=>{let s=new Set;try{let l=await Eur.readFile(a,"utf-8");(await Cur(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var xpt={$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 eIe={$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 Ept={$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 tIe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var rIe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var Mht=ap(aht(),1),jht=ap(Rht(),1);var Lfe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new jht.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Mht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=h.instancePath.split("/");if(D.length>2){let M=D[1],z=D[2]?parseInt(D[2]):0,re=D[3],ie=isNaN(z)?void 0:l[M][z][re];b={details:{property:M,index:z,field:re,fieldValue:ie}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let M=h.instancePath.split("/"),z=M[M.length-1];h.message=`Value of property '${z}' must be '${h.params.type}'`}let N=Object.assign(h,b);_.push(N)}),_}};var tN=Lfe.instance;tN.addSchema(rIe,"route-configuration.schema.json");tN.addSchema(Ept,"policy-configuration.schema.json");tN.addSchema(eIe,"policies.schema.json");tN.addSchema(tIe,"open-api-route-configuration.schema.json");tN.addSchema(xpt,"fragments.schema.json");var ULr=tN.compile(rIe),Bht=tN.compile(tIe),gOe=tN.compile(eIe);var Rfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=gOe(s),this.results}};var Mfe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Bht(s),this.results}};import Igr from"node:path";var yOe=/\$import\((.*)\)/,jfe=/\$env\((.*?)\)/g;var jA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},Ngr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),rN=t((a,s)=>{if(!a)return!1;let l=Ngr(a);return s.split("/").every((b,D)=>{let N=l[D];return N?b==="*"||OA(N)&&N.name.value===b?!0:b==="{}"?N.type===ec.Object:b==="[]"?N.type===ec.Array:!1:!1})},"testPosition");var Bfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),yj(s)?s.children.forEach(l=>{this.visitor(l)}):bpt(s)?s.children.forEach(l=>{this.visitor(l)}):OA(s)&&this.visitor(s.value)}},Uht=t((a,s,l)=>_=>{if(!OA(_)||!vj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>rN(_,b))){jfe.test(_.value.value)&&s.push(new jA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(jfe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:ec.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(jfe),(D,N)=>`\${environment["${N}"] ? environment["${N}"] : ""}`);b!==_.value.value&&(_.value=jT.createTemplateString(b,_))}},"getEnvStatementTransformer");var CK="config/routes.json",Ogr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Fgr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],$ht=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Lgr="handler/{}/options/{}/rewritePattern",Rgr="handler/{}/options/{}/baseUrl",Ufe=class extends Bfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!OA(s)||!vj(s.value)||typeof s.value.value!="string")&&rN(s,Lgr)){if(!s.parent||!yj(s.parent)){this.errors.push(new jA("Invalid node, expected object",CK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:zht(l)},h=jT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!OA(s)||!vj(s.value)||typeof s.value.value!="string")&&rN(s,Rgr)){if(!s.parent||!yj(s.parent)){this.errors.push(new jA("Invalid node, expected object",CK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:zht(l)},h=jT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!OA(s)||!vj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Fgr.some(N=>rN(s,N))&&!$ht.some(N=>rN(s,N))){if(yOe.test(l)){if(s.name.value==="$ref")return;this.errors.push(new jA("An $import() statement is not expected at this location.",CK,s.location,l))}return}let _=yOe.exec(l);if($ht.some(N=>rN(s,N))&&!_)return;if(!_){this.errors.push(new jA("Invalid $import() statement",CK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=Igr.posix.join("..",h));let b=this.getImportName(h),D={type:ec.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=Uht(Ogr,this.errors,CK)};function zht(a){return`(request, context) => {
|
|
583
|
+
`).map(N=>N.trim()).join(" ");case"%O":return a(l[_++]);case"%j":try{return JSON.stringify(l[_++])}catch{return"[Circular]"}default:return D}});for(let D of l.splice(_))D===null||!(typeof D=="object"&&D!==null)?b+=" "+D:b+=" "+a(D);return b}t(aft,"format");var oft=t((a,...s)=>aft(War,a,s),"format");var Y3e=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(s,l){this.manager=s,this.ns=l,this.color=sft(l),this.last=0,this.enabled=s.enabled.some(_=>_.test(l))}log(...s){if(!this.enabled)return;let l,_=s[0];typeof _=="function"?l=_():l=String(_);let h=Date.now()-(this.last||Date.now());l=oft(l,...s);let b=`${this.color(this.ns)} ${l} ${this.color(`+${h}ms`)}`;console.log(b),this.last=Date.now()}},X3e=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(s){this.debuggers=new Map,this.enabled=s??[]}};function Har(a){return!a||a.length===0?[]:(a=a.replace(/\s/g,"").replace(/\*/g,".+"),a.split(",").map(s=>new RegExp(`^${s}$`)))}t(Har,"extract");var hue;function gue(a){hue||(hue=new X3e(Har(process.env.DEBUG)));let s=new Y3e(hue,a);return hue.debuggers.set(a,s),Object.assign(s.log.bind(s),{self:s})}t(gue,"debug");var U3=class extends Error{static{t(this,"RuntimeError")}extensionMembers;constructor(s,l){typeof s=="string"?super(s,l):(super(s.message,l),this.extensionMembers=s.extensionMembers),this.name="RuntimeError"}};var cft="zp-local-service";var dOr=Symbol("zuplo_meters"),mOr=Symbol("zuplo_dynamic_meters");var lF=gue("zuplo:runtime:external-service");function Gar(){let a,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:s}=F0.instance.runtime;if(s&&s!=="undefined")try{let l=atob(s);a=JSON.parse(l)}catch{}return a}t(Gar,"getServiceAuth");async function lft(a,s){let l=Gar();if(l)if(lF(`Using external service auth. ClientId: ${l.clientId})`),typeof a=="string"){let _=new URL(a),h=_.hostname,b=s??{},D=new Headers(b.headers||{});D.set("CF-Access-Client-Id",l.clientId),D.set("CF-Access-Client-Secret",l.clientSecret),b.headers=D;let N;if(l.customServiceMapping&&l.customServiceMapping[h])N=`https://${l.customServiceMapping[h]}`;else if(F0.instance.useLegacyServiceRouting)N=`https://${h}.zuptunnel.com`;else{lF("Using sha256 service routing");let re=F0.instance.build;if(re.ACCOUNT_NAME&&re.PROJECT_NAME&&re.ENVIRONMENT_TYPE){let ie=await Kar(h,re.ACCOUNT_NAME,re.PROJECT_NAME,re.ENVIRONMENT_TYPE),Q=fft(re.ENVIRONMENT_TYPE),Re=await Q3e(`${re.ACCOUNT_NAME}-${re.PROJECT_NAME}-${Q}`);Re==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||Re==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?N=`https://${ie}.zuptunnel.com`:N=`https://${ie}.t.zuplo.app`}else throw lF("Cannot use sha256 service routing, missing build variables"),new U3("Failed to generate fully qualified tunnel url.")}let M=new URL(`${N}${_.pathname}${_.search}`);lF(`Calling external service: ${M.toString()}`);let z=await xG(M.toString(),b);if(z.status===403&&z.headers.get("cf-access-domain")!==null)throw EG.console.error("403 Forbidden when calling external service.",{clientId:l.clientId,tunnelHost:N}),new U3("Could not connect to secure tunnel.");return z}else throw lF("Cannot call external service with Request object"),new U3("Currently, we only support fetch(<some_string>, ...).");else throw lF("There is no external service auth configured for this zup."),new U3("There are no external services configured for this zup.")}t(lft,"externalServiceHandler");async function uft(a,s){if(typeof a=="string"){let l=new URL(a),_=l.hostname,h=s??{},b=`http://${_}.zuplo.svc.cluster.local:9000`,D=new URL(`${b}${l.pathname}${l.search}`),N=new Headers(h.headers||{});return N.set(cft,_),h.headers=N,await xG(D.toString(),h)}else throw new U3("Currently, we only support fetch(<some_string>, ...).")}t(uft,"clusterServiceHandler");async function Kar(a,s,l,_){let h=a.toLowerCase(),b=s.toLowerCase(),D=l.toLowerCase(),N=fft(_);lF(`Hashing service name: ${b}-${h}.${b}-${D}-${N}`);let M=await Q3e(`${b}-${h}`),z=await Q3e(`${b}-${D}-${N}`);return`${M}.${z}`}t(Kar,"hashServiceName");async function Q3e(a){let s=new TextEncoder().encode(a),l=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(l)).map(b=>b.toString(16).padStart(2,"0")).join("").slice(0,-1)}t(Q3e,"hashSegment");function fft(a){let s=a.toLowerCase();switch(s){case"production":case"preview":return s;default:return"working-copy"}}t(fft,"sanitizeEnvironmentType");var Z3e=new Map;Z3e.set("service:",lft);Z3e.set("local:",uft);var xG=globalThis.fetch;function eNe(a,s){let l=Yar(s);if(typeof a=="string"){let _=new URL(a),h=Z3e.get(_.protocol);return h?h(a,l):xG(a,l)}else return xG(a,l)}t(eNe,"internalFetch");globalThis.fetch=eNe;var Yar=t(a=>{if(!a||a instanceof Request)return a;let s=a;if(!s.zuplo)return a;let l=a;return l.cf={cacheEverything:s.zuplo?.cacheEverything,cacheTtl:s.zuplo?.cacheTtlSeconds},delete a.zuplo,a},"transformInit");var Xar={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:eNe},EG=Xar;var tNe="2025-02-06",_ft=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function pft(){return new F0({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:tNe,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:_ft[tNe]},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(pft,"getMockEnvironment");var F0=class a{static{t(this,"Environment")}config;static#r;static#n=!1;static initialize(s){this.#r||(this.#r=new a(s),this.#n=!0)}static get instance(){return this.#n||(EG.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#r=pft()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(mue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let D of Object.keys(b))l[D]||(l[D]=b[D])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){EG.console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,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 zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.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.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}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 Qar=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function dft(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!Qar.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(dft,"isRestrictedEnvVariableName");function mft(a){return!!a.startsWith("ZUPLO_")}t(mft,"isZuploReadableEnvVariableName");var $Or=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return F0.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return F0.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return F0.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return F0.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return F0.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return F0.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return F0.instance.build.COMPATIBILITY_DATE}if(!(dft(l)&&!mft(l)))return F0.instance.runtime[l]}});function CG(a,s,l){return`_${DA(`${a}_${s}_${l}`)}`}t(CG,"getRawOperationDataIdentifierName");function rNe(a,s,l,_){return`_${DA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(rNe,"getIdForParameterSchema");function nNe(a,s,l){return`_${DA(a.toLowerCase())}_${s.toLowerCase()}_rb_${DA(l.toLowerCase())}`}t(nNe,"getIdForRequestBodySchema");function DG(a,s){return`_${DA(a)}_${DA(s)}`}t(DG,"getIdForRefSchema");function DA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s="_"+s),s}t(DA,"sanitizedIdentifierName");var Hht=ap(spt(),1);var zG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Vlr=/[$_\p{ID_Start}]/u,Wlr=/[$_\u200C\u200D\p{ID_Continue}]/u,XNe=".*";function Hlr(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(Hlr,"Re");function cpt(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let D="",N=_+1;for(;N<a.length;){let M=a.substr(N,1);if(N===_+1&&Vlr.test(M)||N!==_+1&&Wlr.test(M)){D+=a[N++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=N;continue}if(h==="("){let D=1,N="",M=_+1,z=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!Hlr(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),z=!0;break}if(a[M]==="\\"){N+=a[M++]+a[M++];continue}if(a[M]===")"){if(D--,D===0){M++;break}}else if(a[M]==="("&&(D++,a[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),z=!0;break}N+=a[M++]}if(z)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!N){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:N}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(cpt,"v");function lpt(a,s={}){let l=cpt(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${MT(s.delimiter)}]+?`,h=[],b=0,D=0,N="",M=new Set,z=t(fn=>{if(D<l.length&&l[D].type===fn)return l[D++].value},"a"),re=t(()=>z("OTHER_MODIFIER")??z("ASTERISK"),"f"),ie=t(fn=>{let tn=z(fn);if(tn!==void 0)return tn;let{type:cn,index:Er}=l[D];throw new TypeError(`Unexpected ${cn} at ${Er}, expected ${fn}`)},"d"),Q=t(()=>{let fn="",tn;for(;tn=z("CHAR")??z("ESCAPED_CHAR");)fn+=tn;return fn},"T"),Re=t(fn=>fn,"Se"),Ie=s.encodePart||Re,we="",wt=t(fn=>{we+=fn},"U"),xt=t(()=>{we.length&&(h.push(new zG(3,"","",Ie(we),"",3)),we="")},"$"),Tr=t((fn,tn,cn,Er,vr)=>{let fs=3;switch(vr){case"?":fs=1;break;case"*":fs=0;break;case"+":fs=2;break}if(!tn&&!cn&&fs===3){wt(fn);return}if(xt(),!tn&&!cn){if(!fn)return;h.push(new zG(3,"","",Ie(fn),"",fs));return}let Oi;cn?cn==="*"?Oi=XNe:Oi=cn:Oi=_;let Ho=2;Oi===_?(Ho=1,Oi=""):Oi===XNe&&(Ho=0,Oi="");let di;if(tn?di=tn:cn&&(di=b++),M.has(di))throw new TypeError(`Duplicate name '${di}'.`);M.add(di),h.push(new zG(Ho,di,Ie(fn),Oi,Ie(Er),fs))},"V");for(;D<l.length;){let fn=z("CHAR"),tn=z("NAME"),cn=z("REGEX");if(!tn&&!cn&&(cn=z("ASTERISK")),tn||cn){let vr=fn??"";s.prefixes.indexOf(vr)===-1&&(wt(vr),vr=""),xt();let fs=re();Tr(vr,tn,cn,"",fs);continue}let Er=fn??z("ESCAPED_CHAR");if(Er){wt(Er);continue}if(z("OPEN")){let vr=Q(),fs=z("NAME"),Oi=z("REGEX");!fs&&!Oi&&(Oi=z("ASTERISK"));let Ho=Q();ie("CLOSE");let di=re();Tr(vr,fs,Oi,Ho,di);continue}xt(),ie("END")}return h}t(lpt,"D");function MT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(MT,"S");function apt(a){return a&&a.ignoreCase?"ui":"u"}t(apt,"X");function Glr(a,s,l){return upt(lpt(a,l),s,l)}t(Glr,"Z");function gj(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(gj,"k");function upt(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let N of a){if(N.type===3){N.modifier===3?_+=MT(N.value):_+=`(?:${MT(N.value)})${gj(N.modifier)}`;continue}s&&s.push(N.name);let M=`[^${MT(l.delimiter)}]+?`,z=N.value;if(N.type===1?z=M:N.type===0&&(z=XNe),!N.prefix.length&&!N.suffix.length){N.modifier===3||N.modifier===1?_+=`(${z})${gj(N.modifier)}`:_+=`((?:${z})${gj(N.modifier)})`;continue}if(N.modifier===3||N.modifier===1){_+=`(?:${MT(N.prefix)}(${z})${MT(N.suffix)})`,_+=gj(N.modifier);continue}_+=`(?:${MT(N.prefix)}`,_+=`((?:${z})(?:`,_+=MT(N.suffix),_+=MT(N.prefix),_+=`(?:${z}))*)${MT(N.suffix)})`,N.modifier===0&&(_+="?")}let h=`[${MT(l.endsWith)}]|$`,b=`[${MT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,apt(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let D=!1;if(a.length){let N=a[a.length-1];N.type===3&&N.modifier===3&&(D=l.delimiter.indexOf(N)>-1)}return D||(_+=`(?=${b}|${h})`),new RegExp(_,apt(l))}t(upt,"F");var q3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Klr={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Ylr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Xlr(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Xlr,"J");function fpt(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(fpt,"Q");function Qlr(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(Qlr,"Ee");function _pt(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(_pt,"W");var ppt=["ftp","file","http","https","ws","wss"];function dpt(a){if(!a)return!0;for(let s of ppt)if(a.test(s))return!0;return!1}t(dpt,"N");function Zlr(a,s){if(a=fpt(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t(Zlr,"te");function eur(a,s){if(a=fpt(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(eur,"re");function tur(a,s){return s||a===""?a:_pt(a)?gpt(a):hpt(a)}t(tur,"ne");function rur(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(rur,"se");function nur(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(nur,"ie");function iur(a,s,l){if(l||a==="")return a;if(s&&!ppt.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(iur,"ae");function sur(a,s,l){return mpt(s)===a&&(a=""),l||a===""?a:ypt(a)}t(sur,"oe");function aur(a,s){return a=Qlr(a,":"),s||a===""?a:QNe(a)}t(aur,"ce");function mpt(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(mpt,"_");function QNe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(QNe,"y");function our(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(our,"le");function cur(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(cur,"fe");function hpt(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(hpt,"z");function gpt(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(gpt,"j");function ypt(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(ypt,"K");function lur(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(lur,"he");function uur(a){return a===""?a:new URL(`data:${a}`).pathname}t(uur,"ue");function fur(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(fur,"de");function _ur(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(_ur,"pe");var pur=class{static{t(this,"H")}#r;#n=[];#e={};#t=0;#s=1;#p=0;#a=0;#_=0;#c=0;#l=!1;constructor(a){this.#r=a}get result(){return this.#e}parse(){for(this.#n=cpt(this.#r,!0);this.#t<this.#n.length;this.#t+=this.#s){if(this.#s=1,this.#n[this.#t].type==="END"){if(this.#a===0){this.#v(),this.#D()?this.#i(9,1):this.#y()?this.#i(8,1):this.#i(7,0);continue}else if(this.#a===2){this.#d(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#o())this.#_-=1;else continue;if(this.#w()){this.#_+=1;continue}switch(this.#a){case 0:this.#g()&&this.#d(1);break;case 1:if(this.#g()){this.#I();let a=7,s=1;this.#C()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#E()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#x()&&this.#i(5,1);break;case 4:this.#x()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#k()&&!this.#c?this.#i(6,1):this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let l=this.#u(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#C(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#x(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#k(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#w(){return this.#n[this.#t].type=="OPEN"}#o(){return this.#n[this.#t].type=="CLOSE"}#N(){return this.#m(this.#t,"[")}#S(){return this.#m(this.#t,"]")}#T(){let a=this.#n[this.#t],s=this.#u(this.#p).index;return this.#r.substring(s,a.index)}#I(){let a={};Object.assign(a,q3),a.encodePart=QNe;let s=Glr(this.#T(),void 0,a);this.#l=dpt(s)}},YNe=["protocol","username","password","hostname","port","pathname","search","hash"],J3="*";function opt(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(opt,"ge");function NA(a,s){return s?$G(a):a}t(NA,"b");function UG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=NA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=NA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=NA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=NA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=NA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=NA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=NA(_.search.substring(1,_.search.length),l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=NA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=aur(s.protocol,l)),typeof s.username=="string"&&(a.username=nur(s.username,l)),typeof s.password=="string"&&(a.password=rur(s.password,l)),typeof s.hostname=="string"&&(a.hostname=tur(s.hostname,l)),typeof s.port=="string"&&(a.port=sur(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!Xlr(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=NA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=iur(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=eur(s.search,l)),typeof s.hash=="string"&&(a.hash=Zlr(s.hash,l)),a}t(UG,"w");function $G(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t($G,"C");function dur(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(dur,"Oe");function mur(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${dur(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let N=a[D];if(N.type===3){if(N.modifier===3){b+=$G(N.value);continue}b+=`{${$G(N.value)}}${gj(N.modifier)}`;continue}let M=N.hasCustomName(),z=!!N.suffix.length||!!N.prefix.length&&(N.prefix.length!==1||!s.prefixes.includes(N.prefix)),re=D>0?a[D-1]:null,ie=D<a.length-1?a[D+1]:null;if(!z&&M&&N.type===1&&N.modifier===3&&ie&&!ie.prefix.length&&!ie.suffix.length)if(ie.type===3){let Q=ie.value.length>0?ie.value[0]:"";z=h.test(Q)}else z=!ie.hasCustomName();if(!z&&!N.prefix.length&&re&&re.type===3){let Q=re.value[re.value.length-1];z=s.prefixes.includes(Q)}z&&(b+="{"),b+=$G(N.prefix),M&&(b+=`:${N.name}`),N.type===2?b+=`(${N.value})`:N.type===1?M||(b+=`(${_})`):N.type===0&&(!M&&(!re||re.type===3||re.modifier!==3||z||N.prefix!=="")?b+="*":b+=`(${l})`),N.type===1&&M&&N.suffix.length&&h.test(N.suffix[0])&&(b+="\\"),b+=$G(N.suffix),z&&(b+="}"),N.modifier!==3&&(b+=gj(N.modifier))}return b}t(mur,"ke");var vpt=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let N=new pur(a);if(N.parse(),a=N.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:J3,protocol:J3,username:J3,password:J3,hostname:J3,port:J3,search:J3,hash:J3};this.#r=UG(b,a,!0),mpt(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of YNe){if(!(D in this.#r))continue;let N={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(N,q3),N.encodePart=QNe;break;case"username":Object.assign(N,q3),N.encodePart=our;break;case"password":Object.assign(N,q3),N.encodePart=cur;break;case"hostname":Object.assign(N,Klr),_pt(M)?N.encodePart=gpt:N.encodePart=hpt;break;case"port":Object.assign(N,q3),N.encodePart=ypt;break;case"pathname":dpt(this.#n.protocol)?(Object.assign(N,Ylr,h),N.encodePart=lur):(Object.assign(N,q3,h),N.encodePart=uur);break;case"search":Object.assign(N,q3,h),N.encodePart=fur;break;case"hash":Object.assign(N,q3,h),N.encodePart=_ur;break}try{this.#s[D]=lpt(M,N),this.#n[D]=upt(this.#s[D],this.#e[D],N),this.#t[D]=mur(this.#s[D],N),this.#p=this.#p||this.#s[D].some(z=>z.type===2)}catch{throw new TypeError(`invalid ${D} pattern '${this.#r[D]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?l=UG(l,a,!1):l=UG(l,opt(a,s),!1)}catch{return!1}let _;for(_ of YNe)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?l=UG(l,a,!1):l=UG(l,opt(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of YNe){let b=this.#n[h].exec(l[h]);if(!b)return null;let D={};for(let[N,M]of this.#e[h].entries())if(typeof M=="string"||typeof M=="number"){let z=b[N+1];D[M]=z}_[h]={input:l[h]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((N,M)=>{for(let z of["type","modifier","prefix","value","suffix"]){if(N[z]<M[z])return-1;if(N[z]!==M[z])return 1}return 0},"o"),h=new zG(3,"","","","",3),b=new zG(0,"","","","",3),D=t((N,M)=>{let z=0;for(;z<Math.min(N.length,M.length);++z){let re=_(N[z],M[z]);if(re)return re}return N.length===M.length?0:_(N[z]??h,M[z]??h)},"s");return!s.#t[a]&&!l.#t[a]?0:s.#t[a]&&!l.#t[a]?D(s.#s[a],[b]):!s.#t[a]&&l.#t[a]?D([b],l.#s[a]):D(s.#s[a],l.#s[a])}get protocol(){return this.#t.protocol}get username(){return this.#t.username}get password(){return this.#t.password}get hostname(){return this.#t.hostname}get port(){return this.#t.port}get pathname(){return this.#t.pathname}get search(){return this.#t.search}get hash(){return this.#t.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=vpt);import{AssertionError as hur}from"node:assert";function IA(a,s){if(a===!1)throw new hur({message:s})}t(IA,"assert");var ec;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(ec||(ec={}));function yj(a){return a.type===ec.Object}t(yj,"isAstObject");function OA(a){return a.type===ec.Property}t(OA,"isAstProperty");function bpt(a){return a.type===ec.Array}t(bpt,"isAstArray");function vj(a){return a.type===ec.Literal}t(vj,"isAstLiteral");function V3(a){if(a===void 0)throw new Error("Node is undefined");if(!yj(a))throw new Error("Node is not object")}t(V3,"assertAstObject");import{findNodeAtLocation as gur,getNodeValue as yur,printParseErrorCode as vur,visit as bur}from"jsonc-parser";var Sur={DEFAULT:{allowTrailingComma:!1}};function JG(a,s=[],l=Sur.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),bur(a,{onObjectBegin:t((M,z,re)=>{_=b({type:"object",offset:M,length:-1,line:z+1,column:re+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,z,re,ie,Q)=>{_=b({type:"property",offset:z,length:-1,line:ie+1,column:Q+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:z,length:re,line:ie,column:Q,parent:_})},"onObjectProperty"),onObjectEnd:t((M,z)=>{h(M+z),_.length=M+z-_.offset,_=_.parent,h(M+z)},"onObjectEnd"),onArrayBegin:t((M,z,re,ie)=>{_=b({type:"array",offset:M,length:-1,line:re+1,column:ie+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,z)=>{_.length=M+z-_.offset,_=_.parent,h(M+z)},"onArrayEnd"),onLiteralValue:t((M,z,re,ie,Q)=>{b({type:Tur(M),offset:z,length:re,line:ie+1,column:Q+1,parent:_,value:M}),h(z+re)},"onLiteralValue"),onSeparator:t((M,z)=>{_.type==="property"&&(M===":"?_.colonOffset=z:M===","&&h(z))},"onSeparator"),onError:t((M,z,re,ie,Q)=>{s.push({error:M,offset:z,length:re,line:ie+1,column:Q+1})},"onError")},l);let N=_.children[0];return N&&delete N.parent,N}t(JG,"parse");function Tur(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(Tur,"getNodeType");function ZNe(a,s){return gur(a,s)}t(ZNe,"findNodeAtLocation");function qG(a){return yur(a)}t(qG,"getNodeValue");function Spt(a){return vur(a)}t(Spt,"printParseErrorCode");var VG=class{static{t(this,"AstAdapter")}parse(s){let _=JG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:ec.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:ec.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){IA(s.children?.length===2,"Invalid property node");let _={type:ec.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:ec.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:ec.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var jT={createLiteral:t((a,s)=>({type:ec.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:ec.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:ec.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:ec.Property,parent:l,name:null,value:s};return _.name={value:a,type:ec.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:ec.Array,parent:s,children:[]};for(let _ of a)l.children.push(jT.createLiteral(_,l));return l},"createArrayOfLiterals")};var xur=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,WG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case ec.Array:return this.generateArray(s,l);case ec.Object:return this.generateObject(s,l);case ec.Property:return this.generateProperty(s,l);case ec.Literal:return this.generateLiteral(s,l);case ec.FunctionCall:return this.generateFunctionCall(s,l);case ec.Identifier:return this.generateIdentifier(s,l);case ec.Raw:return this.generateRaw(s,l);case ec.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=xur.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import Eur from"node:fs/promises";import{parse as Cur}from"@swc/core";var Tpt=t(async a=>{let s=new Set;try{let l=await Eur.readFile(a,"utf-8");(await Cur(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var xpt={$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 eIe={$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 Ept={$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 tIe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var rIe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var Mht=ap(aht(),1),jht=ap(Rht(),1);var Lfe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new jht.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Mht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=h.instancePath.split("/");if(D.length>2){let M=D[1],z=D[2]?parseInt(D[2]):0,re=D[3],ie=isNaN(z)?void 0:l[M][z][re];b={details:{property:M,index:z,field:re,fieldValue:ie}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let M=h.instancePath.split("/"),z=M[M.length-1];h.message=`Value of property '${z}' must be '${h.params.type}'`}let N=Object.assign(h,b);_.push(N)}),_}};var tN=Lfe.instance;tN.addSchema(rIe,"route-configuration.schema.json");tN.addSchema(Ept,"policy-configuration.schema.json");tN.addSchema(eIe,"policies.schema.json");tN.addSchema(tIe,"open-api-route-configuration.schema.json");tN.addSchema(xpt,"fragments.schema.json");var ULr=tN.compile(rIe),Bht=tN.compile(tIe),gOe=tN.compile(eIe);var Rfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=gOe(s),this.results}};var Mfe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Bht(s),this.results}};import Igr from"node:path";var yOe=/\$import\((.*)\)/,jfe=/\$env\((.*?)\)/g;var jA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},Ngr=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),rN=t((a,s)=>{if(!a)return!1;let l=Ngr(a);return s.split("/").every((b,D)=>{let N=l[D];return N?b==="*"||OA(N)&&N.name.value===b?!0:b==="{}"?N.type===ec.Object:b==="[]"?N.type===ec.Array:!1:!1})},"testPosition");var Bfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),yj(s)?s.children.forEach(l=>{this.visitor(l)}):bpt(s)?s.children.forEach(l=>{this.visitor(l)}):OA(s)&&this.visitor(s.value)}},Uht=t((a,s,l)=>_=>{if(!OA(_)||!vj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>rN(_,b))){jfe.test(_.value.value)&&s.push(new jA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(jfe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:ec.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(jfe),(D,N)=>`\${environment["${N}"] ? environment["${N}"] : ""}`);b!==_.value.value&&(_.value=jT.createTemplateString(b,_))}},"getEnvStatementTransformer");var CK="config/routes.json",Ogr=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],Fgr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],$ht=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Lgr="handler/{}/options/{}/rewritePattern",Rgr="handler/{}/options/{}/baseUrl",Ufe=class extends Bfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!OA(s)||!vj(s.value)||typeof s.value.value!="string")&&rN(s,Lgr)){if(!s.parent||!yj(s.parent)){this.errors.push(new jA("Invalid node, expected object",CK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:zht(l)},h=jT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!OA(s)||!vj(s.value)||typeof s.value.value!="string")&&rN(s,Rgr)){if(!s.parent||!yj(s.parent)){this.errors.push(new jA("Invalid node, expected object",CK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:zht(l)},h=jT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!OA(s)||!vj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!Fgr.some(N=>rN(s,N))&&!$ht.some(N=>rN(s,N))){if(yOe.test(l)){if(s.name.value==="$ref")return;this.errors.push(new jA("An $import() statement is not expected at this location.",CK,s.location,l))}return}let _=yOe.exec(l);if($ht.some(N=>rN(s,N))&&!_)return;if(!_){this.errors.push(new jA("Invalid $import() statement",CK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=Igr.posix.join("..",h));let b=this.getImportName(h),D={type:ec.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=Uht(Ogr,this.errors,CK)};function zht(a){return`(request, context) => {
|
|
584
584
|
const { params, url, query, method, headers } = request;
|
|
585
585
|
const { host, hostname, origin, pathname, port, search } = new URL(url);
|
|
586
586
|
const e = encodeURIComponent;
|
|
@@ -646,11 +646,11 @@ export default {
|
|
|
646
646
|
},
|
|
647
647
|
};
|
|
648
648
|
`,fvt=t(async function({systemDirectory:a,logger:s}){return Uu.timeFn("Generating Worker shim",async()=>{s.debug("Generating Worker shim");let l=ixr.join(a,_le);try{await nxr.writeFile(l,sxr,"utf-8")}catch(_){s.error(_);let h={message:`Error creating file at ${l}`,pluginName:"generate-worker-entry",severity:"error"};return{warnings:[],errors:[h]}}return{warnings:[],errors:[]}})},"generateWorker");import{readFile as axr,readdir as oxr}from"node:fs/promises";import _vt from"node:path";var O_e="validate-open-api-files",pvt=t(async function({sourceDirectory:a,logger:s}){return Uu.timeFn("Validating OpenAPI files",async()=>{s.debug("Validating OpenAPI files");let l=_vt.join(a,V1),_=[];try{if(!await qM(a))return new YT({message:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:O_e,severity:"error"});let D=(await oxr(l)).filter(M=>M.endsWith(".oas.json")),N=t(async M=>{let z=_vt.join(l,M);try{M==="zp.oas.json"&&_.push({message:"Open API files cannot be named 'zp.oas.json' since 'zp' is a reserved prefix. Update the file name to solve this build issue.",pluginName:O_e,severity:"error"});let re=await axr(z,"utf-8"),ie=JSON.parse(re);if(ie&&ie.paths){let Q=Object.entries(ie.paths).filter(Re=>Re[0]==="zp"||Re[0]==="/zp");if(Q.length>0){let Re=Q.length===1?"includes one route path":`includes '${Q.length}' routes`;_.push({message:`Open API file '${M}' ${Re} that's named '/zp' which is a reserved route name. Updating the route to something other than '/zp' will solve this build issue.`,pluginName:O_e,severity:"error"})}}}catch(re){s.error(re)}},"validateOpenApiFile");await Promise.all(D.map(N))}catch(h){return s.error(h),_.length>0?{errors:_,warnings:[]}:new YT({message:"Failed while validating the open api files in the project",pluginName:O_e,severity:"warning"})}return{errors:_,warnings:[]}})},"validateOpenAPIFiles");import{readFile as kxr,writeFile as Ovt}from"node:fs/promises";import wxr from"node:path";var pB=ap(u5e(),1);import{parse as Pxr}from"jsonc-parser";var _B=ap(u5e(),1);var Ivt=t(()=>({include:["modules/**/*",".zuplo/**/*","tests/**/*"],exclude:["./node_modules","./dist"],compilerOptions:{module:_B.ModuleKind.ESNext,target:_B.ScriptTarget.ES2022,moduleResolution:_B.ModuleResolutionKind.Bundler,lib:["ESNext","WebWorker","Webworker.Iterable"],preserveConstEnums:!0,useUnknownInCatchVariables:!1,forceConsistentCasingInFileNames:!0,importHelpers:!0,esModuleInterop:!0,strictNullChecks:!0,noEmit:!0}}),"getZuploTsConfigTemplate");var JF="validate-tsconfig",Fvt=t(async function({sourceDirectory:a,logger:s,command:l,environmentType:_}){return Uu.timeFn("Validate TSConfig",async()=>{s.debug("Validate TSConfig");let h=_==="WORKING_COPY"||l==="dev";try{let b=Ivt(),D=wxr.join(a,"tsconfig.json");if(!await ou.fileExists(D))return h?(await Ovt(D,JSON.stringify(b,null,2)),{warnings:[{message:"This project does not have a tsconfig.json file. The file has been created for you.",severity:"warning",pluginName:JF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project does not have a tsconfig.json file.",severity:"error",pluginName:JF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let N=await kxr(D,"utf-8"),M=Pxr(N);if(!(M&&typeof M=="object"&&"compilerOptions"in M))return h?(await Ovt(D,JSON.stringify(b,null,2)),{warnings:[{message:"This project's tsconfig.json file was invalid. A valid file has been written for you.",severity:"warning",pluginName:JF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project's tsconfig.json file is invalid. It must have a compilerOptions.",severity:"error",pluginName:JF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let z=pB.default.convertCompilerOptionsFromJson(M.compilerOptions,a);if(z.errors.length>0)return{warnings:[],errors:z.errors.map(cn=>({severity:"error",pluginName:JF,message:cn.messageText.toString(),detail:"You will need to modify your tsconfig.json file to build this project.",helpUrl:"https://zuplo.com/docs/articles/tsconfig",location:cn.file?{line:cn.file.getLineStarts()[0],length:cn.file.getWidth(),file:cn.file.fileName,column:cn.file.getStart(),lineText:"",namespace:"",suggestion:""}:void 0}))};if(!M||typeof M!="object")throw new TypeError("The userConfigRaw is not an object, this should not happen.");if(!("compilerOptions"in M)||M.compilerOptions===null||M.compilerOptions===void 0||typeof M.compilerOptions!="object")throw new TypeError("The userConfigRaw.compilerOptions property is not an object, this should not happen.");let re=t((cn,Er,vr)=>`The compiler option '${cn}' should ${Er===void 0?"not be set":`be set to '${typeof Er=="string"?Er:JSON.stringify(Er)}'`}, it was ${vr===void 0?"not set":`set to '${typeof vr=="string"?vr:JSON.stringify(vr)}'`}`,"getMessage"),ie="ESNext",Q=pB.ModuleKind.ESNext,Re=[];z.options.module!==Q&&Re.push(re("module",ie,M.compilerOptions.module));let Ie="ES2022",we=pB.default.ScriptTarget.ES2022;z.options.target!==we&&Re.push(re("target",Ie,M.compilerOptions.target));let wt="Bundler",xt=pB.default.ModuleResolutionKind.Bundler;z.options.moduleResolution!==xt&&Re.push(re("moduleResolution",wt,M.compilerOptions.moduleResolution));let Tr=["ESNext","WebWorker","Webworker.Iterable"];t(cn=>{let Er=Tr.map(fs=>fs.toLowerCase()),vr=cn.map(fs=>fs.toLowerCase());return Er.every(fs=>vr.includes(fs))},"includesAllLibs")(M.compilerOptions.lib??[])||Re.push(re("lib",Tr,M.compilerOptions.lib)),z.options.baseUrl&&Re.push(re("baseUrl",void 0,M.compilerOptions.baseUrl));let tn=[];return Re.length>0&&tn.push({message:"This project's tsconfig.json was not set to the recommended settings. Custom settings may cause build issues. For guidance on how to adjust your settings, please visit: https://zuplo.com/docs/articles/tsconfig",severity:"warning",detail:Re.join(`
|
|
649
|
-
`),pluginName:JF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}),{warnings:tn,errors:[]}}catch(b){s.error(b);let D={message:`Error validating tsconfig.json : ${b.message}`,severity:"error",pluginName:JF};return{warnings:[],errors:[D]}}})},"validateTSConfig");var dB;try{let a=Axr(new URL("../../package.json",import.meta.url),"utf-8");dB=JSON.parse(a).version}catch{dB="0.0.0"}function Nxr(a){let{ZUPLO:s,ZUPLO_BUILD_ID:l,ZUPLO_BUILD_CONFIG:_}=process.env;if(s&&l&&_){let h;try{h=JSON.parse(_)}catch{throw new Error("Couuld not parse ZUPLO_BUILD_CONFIG")}let b={ZUPLO_PROJECT_ID:h.projectId,ZUPLO_ACCOUNT_NAME:h.accountName,ZUPLO_PROJECT_NAME:h.projectName,ZUPLO_ENVIRONMENT_TYPE:h.environmentType};for(let[D,N]of Object.entries(process.env))D.startsWith("ZUPLO_PUBLIC_")&&(b[D]=N??"");return{...a,buildId:l,...h,publicZuploEnvironmentVariables:b}}return a}t(Nxr,"getBuildConfig");async function f5e(a){let s=performance.now(),{buildId:l,sourceDirectory:_,deploymentName:h=M_e.basename(_),command:b,minify:D,entitlements:N,environmentType:M,logger:z,output:re,noCompile:ie=!1,projectId:Q,urls:Re,publicZuploEnvironmentVariables:Ie}=Nxr(a),we=await uB(_),wt=M_e.join(_,OM),xt;if("errors"in we)K7e({output:re.child("api"),buildId:l,runtimeVersion:dB}),xt={status:"Failed",flags:void 0,compatibilityDate:void 0,runtimeVersion:dB,outputPath:wt,buildTime:new Date().toISOString(),buildTimeMs:0,buildId:l,warnings:[],errors:we.errors,metafile:void 0};else{ie||K7e({output:re.child("api"),buildId:l,runtimeVersion:dB,compatibilityDate:we.config.compatibilityDate});let tn={command:b,minify:D,deploymentName:h,sourceDirectory:_,outputDirectory:wt,systemDirectory:M_e.join(_,zg),cacheDirectory:M_e.join(_,"node_modules",zg),buildId:l,logger:z,output:re,config:we.config,publicZuploEnvironmentVariables:Ie,projectId:Q,entitlements:N,environmentType:M,urls:Re},cn=[];cn.push(avt),cn.push(cvt),cn.push(lvt),cn.push(uvt),cn.push(Fvt),cn.push(pvt),cn.push(fvt),ie||cn.push(X1t),cn.push(svt);let Er=await rvt(cn,tn),vr=Er.errors.length>0?GO:Er.warnings.length>0?J6e:gA,fs=Er.data.get("metafile");xt={status:vr,compatibilityDate:we.config.compatibilityDate,runtimeVersion:dB,outputPath:wt,buildTime:new Date().toISOString(),buildTimeMs:0,metafile:fs,buildId:l,warnings:Er.warnings,errors:Er.errors,flags:we.config.flags}}xt.warnings.length>0&&xt.warnings.forEach(tn=>{z.warn(tn)}),xt.errors.length>0&&xt.errors.forEach(tn=>{z.error(tn)});let{metafile:Tr,...fn}=xt;if(z.debug(fn,"Compiler completed"),xt.buildTimeMs=performance.now()-s,ie||await I_e(_,re.child("api"),xt),process.env.ZUPLO_SHOW_PERF){console.log();let tn=xt.buildTimeMs<2e3?"green":xt.buildTimeMs<5e3?"yellow":"red";console.log(Jf[tn](`Build time: ${xt.buildTimeMs.toFixed(0)}ms`)),Uu.report()}return Uu.clear(),xt}t(f5e,"build");import{existsSync as cAr}from"node:fs";import{mkdir as lAr,readFile as uAr}from"node:fs/promises";import AY from"node:path";var Rxt=ap(T9e(),1);import{randomUUID as eTt}from"node:crypto";import wwr from"node:events";import HB from"node:path";import Pwr from"chokidar";import*as tTt from"esbuild";var x9e=class extends wwr{static{t(this,"WatchEmitter")}},kN=class{static{t(this,"BuildWatcher")}esbuildContext;emitter=new x9e;envFilesWatcher;outputDirectory;sourceDirectory;command;logger;publicZuploEnvironmentVariables;projectName;buildId;output;constructor({sourceDirectory:s,command:l,logger:_,publicZuploEnvironmentVariables:h={},buildId:b,output:D}){this.sourceDirectory=s,this.command=l,this.outputDirectory=HB.join(s,OM),this.logger=_,this.publicZuploEnvironmentVariables=h,this.projectName=HB.basename(s),this.buildId=b,this.output=D,this.envFilesWatcher=Pwr.watch([HB.join(s,".env"),HB.join(s,".env.zuplo")])}watchEnvFiles(){this.envFilesWatcher.on("change",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("add",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("unlink",()=>{this.emitter.emit("reload",null,null)})}onReload=t(s=>{this.emitter.on("reload",s)},"onReload");async start(){let{sourceDirectory:s}=this;if(this.esbuildContext!==void 0)throw new Error("Watcher cannot be started more than once");let l=await f5e({buildId:this.buildId,output:this.output,sourceDirectory:s,noCompile:!0,command:this.command,publicZuploEnvironmentVariables:this.publicZuploEnvironmentVariables,logger:this.logger,urls:
|
|
649
|
+
`),pluginName:JF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}),{warnings:tn,errors:[]}}catch(b){s.error(b);let D={message:`Error validating tsconfig.json : ${b.message}`,severity:"error",pluginName:JF};return{warnings:[],errors:[D]}}})},"validateTSConfig");var dB;try{let a=Axr(new URL("../../package.json",import.meta.url),"utf-8");dB=JSON.parse(a).version}catch{dB="0.0.0"}function Nxr(a){let{ZUPLO:s,ZUPLO_BUILD_ID:l,ZUPLO_BUILD_CONFIG:_}=process.env;if(s&&l&&_){let h;try{h=JSON.parse(_)}catch{throw new Error("Couuld not parse ZUPLO_BUILD_CONFIG")}let b={ZUPLO_PROJECT_ID:h.projectId,ZUPLO_ACCOUNT_NAME:h.accountName,ZUPLO_PROJECT_NAME:h.projectName,ZUPLO_ENVIRONMENT_TYPE:h.environmentType};for(let[D,N]of Object.entries(process.env))D.startsWith("ZUPLO_PUBLIC_")&&(b[D]=N??"");return{...a,buildId:l,...h,publicZuploEnvironmentVariables:b}}return a}t(Nxr,"getBuildConfig");async function f5e(a){let s=performance.now(),{buildId:l,sourceDirectory:_,deploymentName:h=M_e.basename(_),command:b,minify:D,entitlements:N,environmentType:M,logger:z,output:re,noCompile:ie=!1,projectId:Q,urls:Re,publicZuploEnvironmentVariables:Ie}=Nxr(a),we=await uB(_),wt=M_e.join(_,OM),xt;if("errors"in we)K7e({output:re.child("api"),buildId:l,runtimeVersion:dB}),xt={status:"Failed",flags:void 0,compatibilityDate:void 0,runtimeVersion:dB,outputPath:wt,buildTime:new Date().toISOString(),buildTimeMs:0,buildId:l,warnings:[],errors:we.errors,metafile:void 0};else{ie||K7e({output:re.child("api"),buildId:l,runtimeVersion:dB,compatibilityDate:we.config.compatibilityDate});let tn={command:b,minify:D,deploymentName:h,sourceDirectory:_,outputDirectory:wt,systemDirectory:M_e.join(_,zg),cacheDirectory:M_e.join(_,"node_modules",zg),buildId:l,logger:z,output:re,config:we.config,publicZuploEnvironmentVariables:Ie,projectId:Q,entitlements:N,environmentType:M,urls:Re},cn=[];cn.push(avt),cn.push(cvt),cn.push(lvt),cn.push(uvt),cn.push(Fvt),cn.push(pvt),cn.push(fvt),ie||cn.push(X1t),cn.push(svt);let Er=await rvt(cn,tn),vr=Er.errors.length>0?GO:Er.warnings.length>0?J6e:gA,fs=Er.data.get("metafile");xt={status:vr,compatibilityDate:we.config.compatibilityDate,runtimeVersion:dB,outputPath:wt,buildTime:new Date().toISOString(),buildTimeMs:0,metafile:fs,buildId:l,warnings:Er.warnings,errors:Er.errors,flags:we.config.flags}}xt.warnings.length>0&&xt.warnings.forEach(tn=>{z.warn(tn)}),xt.errors.length>0&&xt.errors.forEach(tn=>{z.error(tn)});let{metafile:Tr,...fn}=xt;if(z.debug(fn,"Compiler completed"),xt.buildTimeMs=performance.now()-s,ie||await I_e(_,re.child("api"),xt),process.env.ZUPLO_SHOW_PERF){console.log();let tn=xt.buildTimeMs<2e3?"green":xt.buildTimeMs<5e3?"yellow":"red";console.log(Jf[tn](`Build time: ${xt.buildTimeMs.toFixed(0)}ms`)),Uu.report()}return Uu.clear(),xt}t(f5e,"build");import{existsSync as cAr}from"node:fs";import{mkdir as lAr,readFile as uAr}from"node:fs/promises";import AY from"node:path";var Rxt=ap(T9e(),1);import{randomUUID as eTt}from"node:crypto";import wwr from"node:events";import HB from"node:path";import Pwr from"chokidar";import*as tTt from"esbuild";var x9e=class extends wwr{static{t(this,"WatchEmitter")}},kN=class{static{t(this,"BuildWatcher")}esbuildContext;emitter=new x9e;envFilesWatcher;outputDirectory;sourceDirectory;command;logger;publicZuploEnvironmentVariables;projectName;buildId;output;urls;constructor({sourceDirectory:s,command:l,logger:_,publicZuploEnvironmentVariables:h={},buildId:b,output:D,urls:N}){this.sourceDirectory=s,this.command=l,this.outputDirectory=HB.join(s,OM),this.logger=_,this.publicZuploEnvironmentVariables=h,this.projectName=HB.basename(s),this.buildId=b,this.output=D,this.urls=N,this.envFilesWatcher=Pwr.watch([HB.join(s,".env"),HB.join(s,".env.zuplo")])}watchEnvFiles(){this.envFilesWatcher.on("change",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("add",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("unlink",()=>{this.emitter.emit("reload",null,null)})}onReload=t(s=>{this.emitter.on("reload",s)},"onReload");async start(){let{sourceDirectory:s}=this;if(this.esbuildContext!==void 0)throw new Error("Watcher cannot be started more than once");let l=await f5e({buildId:this.buildId,output:this.output,sourceDirectory:s,noCompile:!0,command:this.command,publicZuploEnvironmentVariables:this.publicZuploEnvironmentVariables,logger:this.logger,urls:this.urls}),_=await lY({command:this.command,systemDirectory:HB.join(s,zg),cacheDirectory:HB.join(s,"node_modules",zg),outputDirectory:this.outputDirectory,sourceDirectory:s,config:{compatibilityDate:l.compatibilityDate,flags:l.flags??{}},logger:this.logger,urls:this.urls}),h=this;_.plugins?.push({name:"on-end",setup(b){b.onEnd(D=>{h.logger.debug("Watcher (build) reloaded");let N=H7e({buildId:eTt(),result:D});N.errors.length>0?h.logger.error(N.errors,"Build errors"):h.logger.debug(`Successfully rebuilt watched project. Build id ${N.buildId}`);let M={...N,compatibilityDate:l.compatibilityDate,flags:l.flags};h.emitter.emit("reload",M,null)})}}),this.esbuildContext=await tTt.context(_);try{if((await this.esbuildContext.rebuild()).errors.length>0){let D={status:"Failed",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:eTt(),warnings:[],errors:[],metafile:void 0};await I_e(s,h.output.child("api"),D),this.logger.error(D.errors,"Build errors")}}catch(b){throw await this.close(),b}await this.esbuildContext.watch()}async close(){try{await this.envFilesWatcher.close(),this.esbuildContext&&(await this.esbuildContext.dispose(),this.logger.debug("ESBuild watcher closed"))}catch(s){this.logger.error(s)}}};import{existsSync as Fxt,readFileSync as Lxt}from"node:fs";import Sde from"node:path";var G9e=ap(oTt(),1);var Ixt=ap(KTt(),1);import{Buffer as rAr}from"node:buffer";import nAr from"node:path";import Nxt from"node:child_process";import bde from"node:process";function L9e(a){let s=typeof a=="string"?`
|
|
650
650
|
`:10,l=typeof a=="string"?"\r":13;return a[a.length-1]===s&&(a=a.slice(0,-1)),a[a.length-1]===l&&(a=a.slice(0,-1)),a}t(L9e,"stripFinalNewline");import _de from"node:process";import kY from"node:path";import{fileURLToPath as YTt}from"node:url";function fde(a={}){let{env:s=process.env,platform:l=process.platform}=a;return l!=="win32"?"PATH":Object.keys(s).reverse().find(_=>_.toUpperCase()==="PATH")||"Path"}t(fde,"pathKey");var hPr=t(({cwd:a=_de.cwd(),path:s=_de.env[fde()],preferLocal:l=!0,execPath:_=_de.execPath,addExecPath:h=!0}={})=>{let b=a instanceof URL?YTt(a):a,D=kY.resolve(b),N=[];return l&&gPr(N,D),h&&yPr(N,_,D),[...N,s].join(kY.delimiter)},"npmRunPath"),gPr=t((a,s)=>{let l;for(;l!==s;)a.push(kY.join(s,"node_modules/.bin")),l=s,s=kY.resolve(s,"..")},"applyPreferLocal"),yPr=t((a,s,l)=>{let _=s instanceof URL?YTt(s):s;a.push(kY.resolve(l,_,".."))},"applyExecPath"),XTt=t(({env:a=_de.env,...s}={})=>{a={...a};let l=fde({env:a});return s.path=a[l],a[l]=hPr(s),a},"npmRunPathEnv");var vPr=t((a,s,l,_)=>{if(l==="length"||l==="prototype"||l==="arguments"||l==="caller")return;let h=Object.getOwnPropertyDescriptor(a,l),b=Object.getOwnPropertyDescriptor(s,l);!bPr(h,b)&&_||Object.defineProperty(a,l,b)},"copyProperty"),bPr=t(function(a,s){return a===void 0||a.configurable||a.writable===s.writable&&a.enumerable===s.enumerable&&a.configurable===s.configurable&&(a.writable||a.value===s.value)},"canCopyProperty"),SPr=t((a,s)=>{let l=Object.getPrototypeOf(s);l!==Object.getPrototypeOf(a)&&Object.setPrototypeOf(a,l)},"changePrototype"),TPr=t((a,s)=>`/* Wrapped ${a}*/
|
|
651
651
|
${s}`,"wrappedToString"),xPr=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),EPr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),CPr=t((a,s,l)=>{let _=l===""?"":`with ${l.trim()}() `,h=TPr.bind(null,_,s.toString());Object.defineProperty(h,"name",EPr),Object.defineProperty(a,"toString",{...xPr,value:h})},"changeToString");function R9e(a,s,{ignoreNonConfigurable:l=!1}={}){let{name:_}=a;for(let h of Reflect.ownKeys(s))vPr(a,s,h,l);return SPr(a,s),CPr(a,s,_),a}t(R9e,"mimicFunction");var pde=new WeakMap,QTt=t((a,s={})=>{if(typeof a!="function")throw new TypeError("Expected a function");let l,_=0,h=a.displayName||a.name||"<anonymous>",b=t(function(...D){if(pde.set(b,++_),_===1)l=a.apply(this,D),a=null;else if(s.throw===!0)throw new Error(`Function \`${h}\` can only be called once`);return l},"onetime");return R9e(b,a),pde.set(b,_),b},"onetime");QTt.callCount=a=>{if(!pde.has(a))throw new Error(`The given function \`${a.name}\` is not wrapped by the \`onetime\` package`);return pde.get(a)};var ZTt=QTt;import{constants as PPr}from"os";var ext=t(function(){let a=M9e-txt+1;return Array.from({length:a},DPr)},"getRealtimeSignals"),DPr=t(function(a,s){return{name:`SIGRT${s+1}`,number:txt+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),txt=34,M9e=64;import{constants as kPr}from"os";var rxt=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var j9e=t(function(){let a=ext();return[...rxt,...a].map(wPr)},"getSignals"),wPr=t(function({name:a,number:s,description:l,action:_,forced:h=!1,standard:b}){let{signals:{[a]:D}}=kPr,N=D!==void 0;return{name:a,number:N?D:s,description:l,supported:N,action:_,forced:h,standard:b}},"normalizeSignal");var APr=t(function(){return j9e().reduce(NPr,{})},"getSignalsByName"),NPr=t(function(a,{name:s,number:l,description:_,supported:h,action:b,forced:D,standard:N}){return{...a,[s]:{name:s,number:l,description:_,supported:h,action:b,forced:D,standard:N}}},"getSignalByName"),nxt=APr(),IPr=t(function(){let a=j9e(),s=M9e+1,l=Array.from({length:s},(_,h)=>OPr(h,a));return Object.assign({},...l)},"getSignalsByNumber"),OPr=t(function(a,s){let l=FPr(a,s);if(l===void 0)return{};let{name:_,description:h,supported:b,action:D,forced:N,standard:M}=l;return{[a]:{name:_,number:a,description:h,supported:b,action:D,forced:N,standard:M}}},"getSignalByNumber"),FPr=t(function(a,s){let l=s.find(({name:_})=>PPr.signals[_]===a);return l!==void 0?l:s.find(_=>_.number===a)},"findSignalByNumber"),OHr=IPr();var LPr=t(({timedOut:a,timeout:s,errorCode:l,signal:_,signalDescription:h,exitCode:b,isCanceled:D})=>a?`timed out after ${s} milliseconds`:D?"was canceled":l!==void 0?`failed with ${l}`:_!==void 0?`was killed with ${_} (${h})`:b!==void 0?`failed with exit code ${b}`:"failed","getErrorPrefix"),B9e=t(({stdout:a,stderr:s,all:l,error:_,signal:h,exitCode:b,command:D,escapedCommand:N,timedOut:M,isCanceled:z,killed:re,parsed:{options:{timeout:ie}}})=>{b=b===null?void 0:b,h=h===null?void 0:h;let Q=h===void 0?void 0:nxt[h].description,Re=_&&_.code,we=`Command ${LPr({timedOut:M,timeout:ie,errorCode:Re,signal:h,signalDescription:Q,exitCode:b,isCanceled:z})}: ${D}`,wt=Object.prototype.toString.call(_)==="[object Error]",xt=wt?`${we}
|
|
652
652
|
${_.message}`:we,Tr=[xt,s,a].filter(Boolean).join(`
|
|
653
|
-
`);return wt?(_.originalMessage=_.message,_.message=Tr):_=new Error(Tr),_.shortMessage=xt,_.command=D,_.escapedCommand=N,_.exitCode=b,_.signal=h,_.signalDescription=Q,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=z,_.killed=re&&!M,_},"makeError");var dde=["stdin","stdout","stderr"],RPr=t(a=>dde.some(s=>a[s]!==void 0),"hasAlias"),ixt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return dde.map(_=>a[_]);if(RPr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${dde.map(_=>`\`${_}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let l=Math.max(s.length,dde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var fxt=ap(uxt(),1);import MPr from"node:os";var jPr=1e3*5,_xt=t((a,s="SIGTERM",l={})=>{let _=a(s);return BPr(a,s,l,_),_},"spawnedKill"),BPr=t((a,s,l,_)=>{if(!UPr(s,l,_))return;let h=zPr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),UPr=t((a,{forceKillAfterTimeout:s},l)=>$Pr(a)&&s!==!1&&l,"shouldForceKill"),$Pr=t(a=>a===MPr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),zPr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return jPr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),pxt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),JPr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),dxt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((N,M)=>{h=setTimeout(()=>{JPr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(h)});return Promise.race([b,D])},"setupTimeout"),mxt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),hxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,fxt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function gxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(gxt,"isStream");var V9e=ap(bxt(),1),xxt=ap(Txt(),1);var Ext=t((a,s)=>{s===void 0||a.stdin===void 0||(gxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),Cxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,xxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),J9e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),q9e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,V9e.default)(a,{encoding:s,maxBuffer:_}):V9e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),Dxt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},D)=>{let N=q9e(a,{encoding:_,buffer:h,maxBuffer:b}),M=q9e(s,{encoding:_,buffer:h,maxBuffer:b}),z=q9e(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([D,N,M,z])}catch(re){return Promise.all([{error:re,signal:re.signal,timedOut:re.timedOut},J9e(a,N),J9e(s,M),J9e(l,z)])}},"getSpawnedResult");var XPr=(async()=>{})().constructor.prototype,QPr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(XPr,a)]),W9e=t((a,s)=>{for(let[l,_]of QPr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),kxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var wxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),ZPr=/^[\w.-]+$/,eAr=/"/g,tAr=t(a=>typeof a!="string"||ZPr.test(a)?a:`"${a.replace(eAr,'\\"')}"`,"escapeArg"),Pxt=t((a,s)=>wxt(a,s).join(" "),"joinCommand"),Axt=t((a,s)=>wxt(a,s).map(l=>tAr(l)).join(" "),"getEscapedCommand");var iAr=1e3*1e3*100,sAr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...bde.env,...a}:a;return l?XTt({env:b,cwd:_,execPath:h}):b},"getEnv"),aAr=t((a,s,l={})=>{let _=Ixt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:iAr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||bde.cwd(),execPath:bde.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=sAr(l),l.stdio=ixt(l),bde.platform==="win32"&&nAr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),H9e=t((a,s,l)=>typeof s!="string"&&!rAr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?L9e(s):s,"handleOutput");function Oxt(a,s,l){let _=aAr(a,s,l),h=Pxt(a,s),b=Axt(a,s);mxt(_.options);let D;try{D=Nxt.spawn(_.file,_.args,_.options)}catch(Re){let Ie=new Nxt.ChildProcess,we=Promise.reject(B9e({error:Re,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return W9e(Ie,we)}let N=kxt(D),M=dxt(D,_.options,N),z=hxt(D,_.options,M),re={isCanceled:!1};D.kill=_xt.bind(null,D.kill.bind(D)),D.cancel=pxt.bind(null,D,re);let Q=ZTt(t(async()=>{let[{error:Re,exitCode:Ie,signal:we,timedOut:wt},xt,Tr,fn]=await Dxt(D,_.options,z),tn=H9e(_.options,xt),cn=H9e(_.options,Tr),Er=H9e(_.options,fn);if(Re||Ie!==0||we!==null){let vr=B9e({error:Re,exitCode:Ie,signal:we,stdout:tn,stderr:cn,all:Er,command:h,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:re.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return vr;throw vr}return{command:h,escapedCommand:b,exitCode:0,stdout:tn,stderr:cn,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return Ext(D,_.options.input),D.all=Cxt(D,_.options),W9e(D,Q)}t(Oxt,"execa");async function Tde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await oAr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),Fxt(Sde.join(s,".env.zuplo"))){let l=Lxt(Sde.join(s,".env.zuplo"),"utf8"),_=G9e.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(mue.decode(_[h])).toString(),D=JSON.parse(b);for(let N of Object.keys(D))a[N]=D[N]}}if(Fxt(Sde.join(s,".env"))){let l=Lxt(Sde.join(s,".env"),"utf8"),_=G9e.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Tde,"setEnvironment");async function oAr(a){let s="unknown";try{let{stdout:l}=await Oxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(oAr,"getGitSha");async function fAr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:D,logger:N,handleRuntimeStdio:M}){if(_){let re=AY.join(l,_,"modules.json");if(!cAr(re))throw new Error("The bundled-dir does not contain a modules.json file.");let ie=await uAr(re,"utf-8").then(JSON.parse),Q=await uB(l);return Q.status===gA?new Promise((Re,Ie)=>{z(Q.config.compatibilityDate,AY.join(l,_),ie,Re,M)().catch(we=>{N.error(we),Ie(we)})}):(N.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Ie)=>{z(void 0,l,ie,Re,M)().catch(we=>{N.error(we),Ie(we)})}))}else{let re=new kN({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:N,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await re.start()}catch{N.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((ie,Q)=>{re.onReload((Re,Ie)=>{(Ie||Re&&Re.errors&&Re.errors.length>0)&&Q(Ie??Re?.errors),z(Re?.compatibilityDate,AY.join(l,"dist"),lB(l,Re?.metafile),ie,M)().catch(we=>{N.error(we),Q(we)})})})}function z(re,ie,Q,Re,Ie){return async()=>{let we={};await Tde(we,l);let wt=new Rxt.ZuploWorkerd({compatibilityDate:re,scriptDirectory:ie,modules:Q,port:h??ih.DEV_SERVER_PORT,bindings:we,handleRuntimeStdio:Ie}),xt=b??"compiled-zup",Tr=AY.join(l,"dist");await lAr(Tr,{recursive:!0}),await wt.compileBinary({binaryPath:AY.join(l,"dist",xt)}),await wt.dispose(),Re(void 0)}}t(z,"compile")}t(fAr,"compileWorkerdServer");var Mxt=ap(T9e(),1);import pAr from"node:path";import _Ar from"node:net";function NY(a,s){return new Promise(l=>{let _=new _Ar.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(NY,"isPortAvailable");var xde=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){this.sourceDirectory=s.sourceDirectory,this.port=s.port??ih.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,s.zupTestMode||(this.buildWatcher=new kN({...s,logger:this.logger,publicZuploEnvironmentVariables:s.publicZuploEnvironmentVariables??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0}),this.buildWatcher.watchEnvFiles())}async start(){if(!await NY("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await Tde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new Mxt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:pAr.join(this.sourceDirectory,"dist"),modules:lB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as zxt}from"node:url";import{Readable as jxt}from"node:stream";import Bxt from"node:assert";import dAr from"node:child_process";import mAr from"node:fs";import Ede from"node:os";import hAr from"node:path";function Uxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(mAr.existsSync(h))return zxt(h)}t(Uxt,"getValidExecutablePath");function gAr(){let a=Ede.platform()==="win32"?"deno.exe":"deno",s=Uxt("deno/package.json",a);if(s)return s;let l=yAr(),_=Uxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(gAr,"locateDenoExecutable");function yAr(){let a=Ede.platform();return a==="linux"?a+"-"+$xt()+"-glibc":a+"-"+$xt()}t(yAr,"getTarget");function $xt(){let a=Ede.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Ede.arch()+". Only x64 and aarch64 binaries are available.");return a}t($xt,"getArch");var Cde=class{static{t(this,"ZenoServer")}serverProcess;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;constructor(s){this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,s.zupTestMode||(this.buildWatcher=new kN({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:s.publicZuploEnvironmentVariables??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:void 0}),this.buildWatcher.watchEnvFiles()),this.denoExecutablePath=gAr()}getServeArgs(){let s=`${hAr.dirname(zxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write"];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NY("127.0.0.1",9e3)||s.push(9e3),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error("The following ports are not available: "+s.join(", "));if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=dAr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Bxt(this.serverProcess.stdout instanceof jxt),Bxt(this.serverProcess.stderr instanceof jxt),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};async function vAr(a){let s=await uB(a),l=!1;return s.status===gA&&(l=s.config.flags?.managedDedicatedFlags?.useZeno??!1),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(vAr,"useZeno");async function bAr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:N,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let z;await vAr(a)?(h.debug("Starting managed-dedicated local dev server."),z=new Cde({sourceDirectory:a,debugPort:l,logger:h,output:b,publicZuploEnvironmentVariables:_,onReload:N,handleRuntimeStdio:M})):(h.debug("Starting edge local dev server."),z=new xde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:N,handleRuntimeStdio:M})),await z.start();async function re(){await z.stop()}t(re,"handle"),process.on("SIGTERM",re),process.on("SIGINT",re)}t(bAr,"startDevServer");var hEt=ap(Vxt(),1),gEt=ap(dEt(),1);import{readFile as t6r}from"node:fs/promises";import MY from"node:path";var ZAr=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),e6r={concat(a,s){return MY.join(a,s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=MY.normalize(a),l=MY.sep,_=[],h=0;return s.split(l).reverse().filter(D=>D!==".").forEach(D=>{D===".."?h++:h===0?_.push(D):h--}),_.reverse().join(l)},isData(a){return a.startsWith("data:")},isURL(a){return ZAr.test(a)},isAbsolute(a){return MY.isAbsolute(a)},relativeToFile(a,s){if(this.isData(a)||this.isAbsolute(s))return this.normalize(s);{let l=MY.dirname(a);return this.normalize(this.concat(l,s))}}},Lde=e6r;var mEt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function aLe(a){let s=mEt(async D=>await l(D,await a(D)));async function l(D,N){if(N===void 0)return s(Lde.resolve(D));let M,z,re=t(async Q=>(z=z||await _(ie))(Q),"_resolve"),ie={path:D,text:N,get lines(){return M=M||N.split(`
|
|
653
|
+
`);return wt?(_.originalMessage=_.message,_.message=Tr):_=new Error(Tr),_.shortMessage=xt,_.command=D,_.escapedCommand=N,_.exitCode=b,_.signal=h,_.signalDescription=Q,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=z,_.killed=re&&!M,_},"makeError");var dde=["stdin","stdout","stderr"],RPr=t(a=>dde.some(s=>a[s]!==void 0),"hasAlias"),ixt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return dde.map(_=>a[_]);if(RPr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${dde.map(_=>`\`${_}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let l=Math.max(s.length,dde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var fxt=ap(uxt(),1);import MPr from"node:os";var jPr=1e3*5,_xt=t((a,s="SIGTERM",l={})=>{let _=a(s);return BPr(a,s,l,_),_},"spawnedKill"),BPr=t((a,s,l,_)=>{if(!UPr(s,l,_))return;let h=zPr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),UPr=t((a,{forceKillAfterTimeout:s},l)=>$Pr(a)&&s!==!1&&l,"shouldForceKill"),$Pr=t(a=>a===MPr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),zPr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return jPr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),pxt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),JPr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),dxt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((N,M)=>{h=setTimeout(()=>{JPr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(h)});return Promise.race([b,D])},"setupTimeout"),mxt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),hxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,fxt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function gxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(gxt,"isStream");var V9e=ap(bxt(),1),xxt=ap(Txt(),1);var Ext=t((a,s)=>{s===void 0||a.stdin===void 0||(gxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),Cxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,xxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),J9e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),q9e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,V9e.default)(a,{encoding:s,maxBuffer:_}):V9e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),Dxt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},D)=>{let N=q9e(a,{encoding:_,buffer:h,maxBuffer:b}),M=q9e(s,{encoding:_,buffer:h,maxBuffer:b}),z=q9e(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([D,N,M,z])}catch(re){return Promise.all([{error:re,signal:re.signal,timedOut:re.timedOut},J9e(a,N),J9e(s,M),J9e(l,z)])}},"getSpawnedResult");var XPr=(async()=>{})().constructor.prototype,QPr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(XPr,a)]),W9e=t((a,s)=>{for(let[l,_]of QPr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),kxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var wxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),ZPr=/^[\w.-]+$/,eAr=/"/g,tAr=t(a=>typeof a!="string"||ZPr.test(a)?a:`"${a.replace(eAr,'\\"')}"`,"escapeArg"),Pxt=t((a,s)=>wxt(a,s).join(" "),"joinCommand"),Axt=t((a,s)=>wxt(a,s).map(l=>tAr(l)).join(" "),"getEscapedCommand");var iAr=1e3*1e3*100,sAr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...bde.env,...a}:a;return l?XTt({env:b,cwd:_,execPath:h}):b},"getEnv"),aAr=t((a,s,l={})=>{let _=Ixt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:iAr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||bde.cwd(),execPath:bde.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=sAr(l),l.stdio=ixt(l),bde.platform==="win32"&&nAr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),H9e=t((a,s,l)=>typeof s!="string"&&!rAr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?L9e(s):s,"handleOutput");function Oxt(a,s,l){let _=aAr(a,s,l),h=Pxt(a,s),b=Axt(a,s);mxt(_.options);let D;try{D=Nxt.spawn(_.file,_.args,_.options)}catch(Re){let Ie=new Nxt.ChildProcess,we=Promise.reject(B9e({error:Re,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return W9e(Ie,we)}let N=kxt(D),M=dxt(D,_.options,N),z=hxt(D,_.options,M),re={isCanceled:!1};D.kill=_xt.bind(null,D.kill.bind(D)),D.cancel=pxt.bind(null,D,re);let Q=ZTt(t(async()=>{let[{error:Re,exitCode:Ie,signal:we,timedOut:wt},xt,Tr,fn]=await Dxt(D,_.options,z),tn=H9e(_.options,xt),cn=H9e(_.options,Tr),Er=H9e(_.options,fn);if(Re||Ie!==0||we!==null){let vr=B9e({error:Re,exitCode:Ie,signal:we,stdout:tn,stderr:cn,all:Er,command:h,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:re.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return vr;throw vr}return{command:h,escapedCommand:b,exitCode:0,stdout:tn,stderr:cn,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return Ext(D,_.options.input),D.all=Cxt(D,_.options),W9e(D,Q)}t(Oxt,"execa");async function Tde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await oAr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),Fxt(Sde.join(s,".env.zuplo"))){let l=Lxt(Sde.join(s,".env.zuplo"),"utf8"),_=G9e.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(mue.decode(_[h])).toString(),D=JSON.parse(b);for(let N of Object.keys(D))a[N]=D[N]}}if(Fxt(Sde.join(s,".env"))){let l=Lxt(Sde.join(s,".env"),"utf8"),_=G9e.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Tde,"setEnvironment");async function oAr(a){let s="unknown";try{let{stdout:l}=await Oxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(oAr,"getGitSha");async function fAr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:D,logger:N,handleRuntimeStdio:M}){if(_){let re=AY.join(l,_,"modules.json");if(!cAr(re))throw new Error("The bundled-dir does not contain a modules.json file.");let ie=await uAr(re,"utf-8").then(JSON.parse),Q=await uB(l);return Q.status===gA?new Promise((Re,Ie)=>{z(Q.config.compatibilityDate,AY.join(l,_),ie,Re,M)().catch(we=>{N.error(we),Ie(we)})}):(N.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Ie)=>{z(void 0,l,ie,Re,M)().catch(we=>{N.error(we),Ie(we)})}))}else{let re=new kN({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:N,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await re.start()}catch{N.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((ie,Q)=>{re.onReload((Re,Ie)=>{(Ie||Re&&Re.errors&&Re.errors.length>0)&&Q(Ie??Re?.errors),z(Re?.compatibilityDate,AY.join(l,"dist"),lB(l,Re?.metafile),ie,M)().catch(we=>{N.error(we),Q(we)})})})}function z(re,ie,Q,Re,Ie){return async()=>{let we={};await Tde(we,l);let wt=new Rxt.ZuploWorkerd({compatibilityDate:re,scriptDirectory:ie,modules:Q,port:h??ih.DEV_SERVER_PORT,bindings:we,handleRuntimeStdio:Ie}),xt=b??"compiled-zup",Tr=AY.join(l,"dist");await lAr(Tr,{recursive:!0}),await wt.compileBinary({binaryPath:AY.join(l,"dist",xt)}),await wt.dispose(),Re(void 0)}}t(z,"compile")}t(fAr,"compileWorkerdServer");var Mxt=ap(T9e(),1);import pAr from"node:path";import _Ar from"node:net";function NY(a,s){return new Promise(l=>{let _=new _Ar.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(NY,"isPortAvailable");var xde=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){if(this.sourceDirectory=s.sourceDirectory,this.port=s.port??ih.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new kN({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NY("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await Tde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new Mxt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:pAr.join(this.sourceDirectory,"dist"),modules:lB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as zxt}from"node:url";import{Readable as jxt}from"node:stream";import Bxt from"node:assert";import dAr from"node:child_process";import mAr from"node:fs";import Ede from"node:os";import hAr from"node:path";function Uxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(mAr.existsSync(h))return zxt(h)}t(Uxt,"getValidExecutablePath");function gAr(){let a=Ede.platform()==="win32"?"deno.exe":"deno",s=Uxt("deno/package.json",a);if(s)return s;let l=yAr(),_=Uxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(gAr,"locateDenoExecutable");function yAr(){let a=Ede.platform();return a==="linux"?a+"-"+$xt()+"-glibc":a+"-"+$xt()}t(yAr,"getTarget");function $xt(){let a=Ede.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Ede.arch()+". Only x64 and aarch64 binaries are available.");return a}t($xt,"getArch");var Cde=class{static{t(this,"ZenoServer")}serverProcess;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;port=9e3;constructor(s){if(this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new kN({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=gAr()}getServeArgs(){let s=`${hAr.dirname(zxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write"];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NY("127.0.0.1",this.port)||s.push(this.port),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error("The following ports are not available: "+s.join(", "));if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=dAr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Bxt(this.serverProcess.stdout instanceof jxt),Bxt(this.serverProcess.stderr instanceof jxt),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};async function vAr(a){let s=await uB(a),l=!1;return s.status===gA&&(l=s.config.flags?.managedDedicatedFlags?.useZeno??!1),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(vAr,"useZeno");async function bAr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:N,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let z;await vAr(a)?(h.debug("Starting managed-dedicated local dev server."),z=new Cde({sourceDirectory:a,debugPort:l,logger:h,output:b,publicZuploEnvironmentVariables:_,onReload:N,handleRuntimeStdio:M})):(h.debug("Starting edge local dev server."),z=new xde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:N,handleRuntimeStdio:M})),await z.start();async function re(){await z.stop()}t(re,"handle"),process.on("SIGTERM",re),process.on("SIGINT",re)}t(bAr,"startDevServer");var hEt=ap(Vxt(),1),gEt=ap(dEt(),1);import{readFile as t6r}from"node:fs/promises";import MY from"node:path";var ZAr=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),e6r={concat(a,s){return MY.join(a,s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=MY.normalize(a),l=MY.sep,_=[],h=0;return s.split(l).reverse().filter(D=>D!==".").forEach(D=>{D===".."?h++:h===0?_.push(D):h--}),_.reverse().join(l)},isData(a){return a.startsWith("data:")},isURL(a){return ZAr.test(a)},isAbsolute(a){return MY.isAbsolute(a)},relativeToFile(a,s){if(this.isData(a)||this.isAbsolute(s))return this.normalize(s);{let l=MY.dirname(a);return this.normalize(this.concat(l,s))}}},Lde=e6r;var mEt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function aLe(a){let s=mEt(async D=>await l(D,await a(D)));async function l(D,N){if(N===void 0)return s(Lde.resolve(D));let M,z,re=t(async Q=>(z=z||await _(ie))(Q),"_resolve"),ie={path:D,text:N,get lines(){return M=M||N.split(`
|
|
654
654
|
`)},async resolve(Q){try{return await re(Q)}catch(Re){return Object.assign({},Q,{error:Re})}},_resolve:re};return ie}t(l,"SourceFile");async function _(D){let N=/\u0023 sourceMappingURL=(.+)\n?/g,M;for(;;){let ie=N.exec(D.text);if(ie)M=ie;else break}let z=M&&M[1],re=t(async ie=>Object.assign({},ie,{sourceFile:D,sourceLine:D.lines[ie.line-1]||""}),"defaultResolver");return z?await h(D.path,z,re):re}t(_,"SourceMapResolverFromFetchedFile");async function h(D,N,M){let z=N.startsWith("data:")?await l(D,(0,hEt.dataUriToBuffer)(N).toString()):await l(Lde.relativeToFile(D,N)),re=await new gEt.SourceMapConsumer(JSON.parse(z.text)),ie=mEt(async Q=>{let Re=Lde.relativeToFile(z.path,Q),Ie=re.sourceContentFor(Q,!0)||void 0;return await l(Re,Ie)});return async Q=>{try{let Re=re.originalPositionFor(Q);return Re.source?await(await ie(Re.source))._resolve(Object.assign({},Q,{line:Re.line,column:(Re.column??0)+1,name:Re.name})):M(Q)}catch(Re){return Object.assign(M(Q),{sourceMapError:Re})}}}t(h,"SourceMapResolver");let b=t(async function(N){try{return await l(N)}catch(M){let z={path:N,text:"",lines:[],error:M,async resolve(re){return Object.assign({},re,{error:M,sourceLine:"",sourceFile:z})},_resolve(re){return this.resolve(re)}};return z}},"getSource");return b.resetCache=()=>s.forgetEverything(),b.getCache=()=>s.cache,b}t(aLe,"buildGetSourceFunction");var r6r=t(async a=>t6r(a,{encoding:"utf8"}),"fetchFile"),yEt=aLe(r6r);import n6r from"node:path";import i6r from"node:util";var vEt=t(a=>a[a.length-1],"lastOf"),jY=t(a=>a.replace(/\\/g,"/"),"nixSlashes"),s6r=t((a,s)=>{let l=a||[],_=[],h={label:void 0,items:[l[0]]};return l.forEach(b=>{let D=s(b);h.label!==D&&h.items.length?_.push(h={label:D,items:[b]}):h.items.push(b)}),_},"partition"),BY=class a{static{t(this,"StackTracey")}items;getSource;pathRoot;constructor(s,{offset:l,getSource:_}){this.getSource=_,this.pathRoot=`${jY(process.cwd())}/`;let h=s,b=s instanceof SyntaxError;if(l=l||0,s instanceof Error&&(s=s.stack||""),typeof s=="string"&&(s=this.rawParse(s).slice(l).map(D=>this.extractEntryMetadata(D))),Array.isArray(s)){if(b){let D=i6r.inspect(h).split(`
|
|
655
655
|
`),N=D[0].split(":"),M=N.pop(),z=N.join(":");z&&s.unshift({file:jY(z),line:parseInt(M||"0",10),column:(D[2]||"").indexOf("^")+1,sourceLine:D[1],callee:"(syntax error)",syntaxError:!0,beforeParse:"",index:!1,native:!1,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1})}this.items=s}else this.items=[]}extractEntryMetadata(s){let l=this.decomposePath(s.file||""),_=l[0],h=l[1];return Object.assign(s,{calleeShort:s.calleeShort||vEt((s.callee||"").split(".")),fileRelative:_,fileShort:this.shortenPath(_),fileName:vEt((s.file||"").split("/")),thirdParty:this.isThirdParty(_,h)&&!s.index,externalDomain:h})}shortenPath(s){return s.replace(/^node_modules\//,"").replace(/^webpack\/bootstrap\//,"").replace(/^__parcel_source_root\//,"")}decomposePath(s){let l=s,_=l.match(/^(http|https):\/\/([^\/]+)\/(.*)/),h=_?_[2]:void 0;return l=_?_[3]:l,l=n6r.relative(this.pathRoot,l),[jY(l).replace(/^.*:\/\/?\/?/,""),h]}isThirdParty(s,l){return!!l||s[0]==="~"||s[0]==="/"||s.indexOf("node_modules")===0||s.indexOf("webpack/bootstrap")===0}rawParse(s){return(s||"").split(`
|
|
656
656
|
`).map(h=>{h=h.trim();let b,D=[],N,M,z;if((M=h.match(/at (.+) \(eval at .+ \((.+)\), .+\)/))||(M=h.match(/at (.+) \((.+)\)/))||h.slice(0,3)!=="at "&&(M=h.match(/(.*)@(.*)/)))b=M[1],N=M[2]==="native",D=(M[2].match(/(.*):(\d+):(\d+)/)||M[2].match(/(.*):(\d+)/)||[]).slice(1);else if(z=h.match(/^(at\s+)*(.+):(\d+):(\d+)/))D=z.slice(2);else return;return b&&!D[0]&&b.split(".")[0]==="Array"&&(N=!0),{beforeParse:h,callee:b||"",index:D[0]==="/",native:N||!1,file:jY(D[0]||""),line:parseInt(D[1]||"",10)||void 0,column:parseInt(D[2]||"",10)||void 0,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1}}).filter(h=>h!==void 0)}async withSourceAsyncAt(s){return this.items[s]&&this.withSourceAsync(this.items[s])}async withSourceAsync(s){if(this.shouldSkipResolving(s))return s;{let l=(s.file||"").replace("file://","");try{let h=await(await this.getSource(l)).resolve(s);return this.withSourceResolved(s,h)}catch(_){return this.withSourceResolved(s,{error:_,sourceLine:""})}}}shouldSkipResolving(s){return!!s.sourceFile||!!s.error||!!s.file&&s.file.indexOf("<")>=0}withSourceResolved(s,l){return l.sourceFile&&!l.sourceFile.error&&(l.file=jY(l.sourceFile.path),l=this.extractEntryMetadata(l)),l.sourceLine?.includes("// @hide")&&(l.sourceLine=l.sourceLine.replace("// @hide",""),l.hide=!0),(l.sourceLine?.includes("__webpack_require__")||l.sourceLine?.includes("/******/ ({"))&&(l.thirdParty=!0),Object.assign({sourceLine:""},s,l)}async withSourcesAsync(){let s=await Promise.all(this.items.map(l=>this.withSourceAsync(l)));return new a(s,{getSource:this.getSource})}mergeRepeatedLines(){return new a(s6r(this.items,s=>s.file+s.line).map(s=>s.items.slice(1).reduce((l,_)=>(l.callee=(l.callee||"<anonymous>")+" \u2192 "+(_.callee||"<anonymous>"),l.calleeShort=(l.calleeShort||"<anonymous>")+" \u2192 "+(_.calleeShort||"<anonymous>"),l),Object.assign({},s.items[0]))),{getSource:this.getSource})}async cleanAsync(){let s=await this.withSourcesAsync();return s.mergeRepeatedLines().filter((l,_)=>s.isClean(l,_))}isClean(s,l){return l===0||!(s.thirdParty||s.hide||s.native)}at(s){return Object.assign({beforeParse:"",callee:"<???>",index:!1,native:!1,file:"<???>",line:0,column:0},this.items[s])}map(s,l){return new a(this.items.map(s,l),{getSource:this.getSource})}filter(s,l){return new a(this.items.filter(s,l),{getSource:this.getSource})}slice(s,l){return new a(this.items.slice(s,l),{getSource:this.getSource})}concat(...s){return new a(this.items.concat(...s),{getSource:this.getSource})}maxColumnWidths(){return{callee:30,file:60,sourceLine:80}}static locationsEqual(s,l){return s.file===l.file&&s.line===l.line&&s.column===l.column}};import{relative as f6r}from"node:path";import{fileURLToPath as _6r}from"node:url";import{inspect as p6r}from"node:util";function oLe({onlyFirst:a=!1}={}){let l=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(l,a?void 0:"g")}t(oLe,"ansiRegex");var a6r=oLe();function cLe(a){if(typeof a!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof a}\``);return a.replace(a6r,"")}t(cLe,"stripAnsi");function bEt(a){return a===161||a===164||a===167||a===168||a===170||a===173||a===174||a>=176&&a<=180||a>=182&&a<=186||a>=188&&a<=191||a===198||a===208||a===215||a===216||a>=222&&a<=225||a===230||a>=232&&a<=234||a===236||a===237||a===240||a===242||a===243||a>=247&&a<=250||a===252||a===254||a===257||a===273||a===275||a===283||a===294||a===295||a===299||a>=305&&a<=307||a===312||a>=319&&a<=322||a===324||a>=328&&a<=331||a===333||a===338||a===339||a===358||a===359||a===363||a===462||a===464||a===466||a===468||a===470||a===472||a===474||a===476||a===593||a===609||a===708||a===711||a>=713&&a<=715||a===717||a===720||a>=728&&a<=731||a===733||a===735||a>=768&&a<=879||a>=913&&a<=929||a>=931&&a<=937||a>=945&&a<=961||a>=963&&a<=969||a===1025||a>=1040&&a<=1103||a===1105||a===8208||a>=8211&&a<=8214||a===8216||a===8217||a===8220||a===8221||a>=8224&&a<=8226||a>=8228&&a<=8231||a===8240||a===8242||a===8243||a===8245||a===8251||a===8254||a===8308||a===8319||a>=8321&&a<=8324||a===8364||a===8451||a===8453||a===8457||a===8467||a===8470||a===8481||a===8482||a===8486||a===8491||a===8531||a===8532||a>=8539&&a<=8542||a>=8544&&a<=8555||a>=8560&&a<=8569||a===8585||a>=8592&&a<=8601||a===8632||a===8633||a===8658||a===8660||a===8679||a===8704||a===8706||a===8707||a===8711||a===8712||a===8715||a===8719||a===8721||a===8725||a===8730||a>=8733&&a<=8736||a===8739||a===8741||a>=8743&&a<=8748||a===8750||a>=8756&&a<=8759||a===8764||a===8765||a===8776||a===8780||a===8786||a===8800||a===8801||a>=8804&&a<=8807||a===8810||a===8811||a===8814||a===8815||a===8834||a===8835||a===8838||a===8839||a===8853||a===8857||a===8869||a===8895||a===8978||a>=9312&&a<=9449||a>=9451&&a<=9547||a>=9552&&a<=9587||a>=9600&&a<=9615||a>=9618&&a<=9621||a===9632||a===9633||a>=9635&&a<=9641||a===9650||a===9651||a===9654||a===9655||a===9660||a===9661||a===9664||a===9665||a>=9670&&a<=9672||a===9675||a>=9678&&a<=9681||a>=9698&&a<=9701||a===9711||a===9733||a===9734||a===9737||a===9742||a===9743||a===9756||a===9758||a===9792||a===9794||a===9824||a===9825||a>=9827&&a<=9829||a>=9831&&a<=9834||a===9836||a===9837||a===9839||a===9886||a===9887||a===9919||a>=9926&&a<=9933||a>=9935&&a<=9939||a>=9941&&a<=9953||a===9955||a===9960||a===9961||a>=9963&&a<=9969||a===9972||a>=9974&&a<=9977||a===9979||a===9980||a===9982||a===9983||a===10045||a>=10102&&a<=10111||a>=11094&&a<=11097||a>=12872&&a<=12879||a>=57344&&a<=63743||a>=65024&&a<=65039||a===65533||a>=127232&&a<=127242||a>=127248&&a<=127277||a>=127280&&a<=127337||a>=127344&&a<=127373||a===127375||a===127376||a>=127387&&a<=127404||a>=917760&&a<=917999||a>=983040&&a<=1048573||a>=1048576&&a<=1114109}t(bEt,"isAmbiguous");function SEt(a){return a===12288||a>=65281&&a<=65376||a>=65504&&a<=65510}t(SEt,"isFullWidth");function TEt(a){return a>=4352&&a<=4447||a===8986||a===8987||a===9001||a===9002||a>=9193&&a<=9196||a===9200||a===9203||a===9725||a===9726||a===9748||a===9749||a>=9800&&a<=9811||a===9855||a===9875||a===9889||a===9898||a===9899||a===9917||a===9918||a===9924||a===9925||a===9934||a===9940||a===9962||a===9970||a===9971||a===9973||a===9978||a===9981||a===9989||a===9994||a===9995||a===10024||a===10060||a===10062||a>=10067&&a<=10069||a===10071||a>=10133&&a<=10135||a===10160||a===10175||a===11035||a===11036||a===11088||a===11093||a>=11904&&a<=11929||a>=11931&&a<=12019||a>=12032&&a<=12245||a>=12272&&a<=12287||a>=12289&&a<=12350||a>=12353&&a<=12438||a>=12441&&a<=12543||a>=12549&&a<=12591||a>=12593&&a<=12686||a>=12688&&a<=12771||a>=12783&&a<=12830||a>=12832&&a<=12871||a>=12880&&a<=19903||a>=19968&&a<=42124||a>=42128&&a<=42182||a>=43360&&a<=43388||a>=44032&&a<=55203||a>=63744&&a<=64255||a>=65040&&a<=65049||a>=65072&&a<=65106||a>=65108&&a<=65126||a>=65128&&a<=65131||a>=94176&&a<=94180||a===94192||a===94193||a>=94208&&a<=100343||a>=100352&&a<=101589||a>=101632&&a<=101640||a>=110576&&a<=110579||a>=110581&&a<=110587||a===110589||a===110590||a>=110592&&a<=110882||a===110898||a>=110928&&a<=110930||a===110933||a>=110948&&a<=110951||a>=110960&&a<=111355||a===126980||a===127183||a===127374||a>=127377&&a<=127386||a>=127488&&a<=127490||a>=127504&&a<=127547||a>=127552&&a<=127560||a===127568||a===127569||a>=127584&&a<=127589||a>=127744&&a<=127776||a>=127789&&a<=127797||a>=127799&&a<=127868||a>=127870&&a<=127891||a>=127904&&a<=127946||a>=127951&&a<=127955||a>=127968&&a<=127984||a===127988||a>=127992&&a<=128062||a===128064||a>=128066&&a<=128252||a>=128255&&a<=128317||a>=128331&&a<=128334||a>=128336&&a<=128359||a===128378||a===128405||a===128406||a===128420||a>=128507&&a<=128591||a>=128640&&a<=128709||a===128716||a>=128720&&a<=128722||a>=128725&&a<=128727||a>=128732&&a<=128735||a===128747||a===128748||a>=128756&&a<=128764||a>=128992&&a<=129003||a===129008||a>=129292&&a<=129338||a>=129340&&a<=129349||a>=129351&&a<=129535||a>=129648&&a<=129660||a>=129664&&a<=129672||a>=129680&&a<=129725||a>=129727&&a<=129733||a>=129742&&a<=129755||a>=129760&&a<=129768||a>=129776&&a<=129784||a>=131072&&a<=196605||a>=196608&&a<=262141}t(TEt,"isWide");function o6r(a){if(!Number.isSafeInteger(a))throw new TypeError(`Expected a code point, got \`${typeof a}\`.`)}t(o6r,"validate");function xEt(a,{ambiguousAsWide:s=!1}={}){return o6r(a),SEt(a)||TEt(a)||s&&bEt(a)?2:1}t(xEt,"eastAsianWidth");var DEt=ap(CEt(),1);var c6r=new Intl.Segmenter,l6r=/^\p{Default_Ignorable_Code_Point}$/u;function Rde(a,s={}){if(typeof a!="string"||a.length===0)return 0;let{ambiguousIsNarrow:l=!0,countAnsiEscapeCodes:_=!1}=s;if(_||(a=cLe(a)),a.length===0)return 0;let h=0,b={ambiguousAsWide:!l};for(let{segment:D}of c6r.segment(a)){let N=D.codePointAt(0);if(!(N<=31||N>=127&&N<=159)&&!(N>=8203&&N<=8207||N===65279)&&!(N>=768&&N<=879||N>=6832&&N<=6911||N>=7616&&N<=7679||N>=8400&&N<=8447||N>=65056&&N<=65071)&&!(N>=55296&&N<=57343)&&!(N>=65024&&N<=65039)&&!l6r.test(D)){if((0,DEt.default)().test(D)){h+=2;continue}h+=xEt(N,b)}}return h}t(Rde,"stringWidth");var fLe=ap(wEt(),1);var{platform:PEt,cwd:u6r}=process,{red:nU,yellow:AEt,green:jde,cyan:UY,dim:lLe}=Jf,NEt=process.stdout.columns,d6r=PEt==="win32"&&!process.env.WT_SESSION?">":"\u276F",m6r=(PEt==="win32"&&!process.env.WT_SESSION,"\u2043"),h6r=u6r();function IEt(a){return a=a.replace("async file:","file:"),f6r(h6r,a.startsWith("file:")?_6r(a):a)}t(IEt,"getRelativePath");function g6r(a){return a.find(s=>s.isApp)||null}t(g6r,"mainFrame");function y6r(a,s){return a.filter(l=>(l.isApp||l.isModule)&&(!s||l.file!==s.file||l.line!==s.line))}t(y6r,"filterNativeFrames");function OEt(a){return a.callee||"anonymous"}t(OEt,"frameMethod");function FEt(a,s){let l="",_=a.length-s.length;for(let h=0;h<=_;h++)l+=" ";return l}t(FEt,"whiteSpace");function uLe(a,s,l,_,h){let b=FEt(String(l),String(s));return _?`${h}${nU(d6r)}${b}${nU(s)}${nU("|")}${b} ${nU(a)}`:`${h} ${b}${lLe(s)}${lLe("|")}${b} ${lLe(a)}`}t(uLe,"codeLine");function v6r(a,s,l){let _,h=(0,fLe.default)(Rde(s)+2,NEt);return l?_=`${s} ${nU(h(`${a.message}`).trim())}`:_=`${s} ${nU(h(`${a.name}: ${a.message}`).trim())}`,[_,s]}t(v6r,"getMessage");function b6r(a,s){let l=a.help;if(!l)return[];let _=(0,fLe.default)(Rde(s)+4,NEt);return Array.isArray(l)?l.map(h=>`${s} ${UY(_(`- ${h}`).trim())}`).concat([s]):[`${s} ${UY(l)}`,s]}t(b6r,"getHelpText");function S6r(a,s,l){if(!a)return[];let _=l?IEt(a.filePath):a.filePath;return[`${s} at ${AEt(`${OEt(a)}`)} ${jde(_)}:${jde(a.line)}`]}t(S6r,"getMainFrameLocation");function T6r(a,s){if(!a||!a.context||!a.context.line)return[];let l=a.context.start-1,_=a.context.pre.split(`
|
package/index.minified.js
CHANGED
|
@@ -580,7 +580,7 @@ globstar while`,s,Q,l,Re,Ie),this.matchOne(s.slice(Q),l.slice(Re),_))return this
|
|
|
580
580
|
`),exitCode:D},"Tar process logs")}}t(Gar,"tarFolder");async function Kar({tarFilePath:a,outputDir:s,logger:l}){let _=[],h=[],b;try{await new Promise((D,A)=>{let M=rft("sh",["-c",`tar -xvf ${a} -C ${s};`]);M.stdout.on("data",z=>{let re=z.toString().trim();re.length>0&&_.push(re.trim())}),M.stderr.on("data",z=>{let re=z.toString().trim();re.length>0&&h.push(re.trim())}),M.on("close",z=>{b=z,z===0?D():A(new Error(`tar process exited with code ${z}`))}),M.on("error",z=>{A(z)})})}catch(D){throw new Error("Failed to untar file",{cause:D})}finally{l.info({stdout:_.join(`
|
|
581
581
|
`),stderr:h.join(`
|
|
582
582
|
`),exitCode:b},"Untar process logs")}}t(Kar,"untarFile");async function Yar(a){if(await Q3e(a))return await $3.rm(a,{recursive:!0})}t(Yar,"deleteFolder");var ou=Z3e;var OT=x_(X3e(),1);var uF=class extends Error{static{t(this,"CustomResolveError")}},z3=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return xG.$RefParser.dereference(s,{resolve:{json:!0,file:due(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return xG.$RefParser.bundle(s,{resolve:{file:due(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return xG.$RefParser.parse(s,{resolve:{file:due(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return xG.$RefParser.resolve(s,{resolve:{file:due(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function due(a,s){return{order:100,canRead(l){let _=eor(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=aft(l.url)}catch(D){throw new uF(`Malformed URI: ${l.url}`,{cause:D})}try{ou.safePath(a).resolve(b)}catch(D){return s?.warn(D),!1}return!0},async read(l){let _;try{_=aft(l.url)}catch(h){throw new uF(`Malformed URI: ${l.url}`,{cause:h})}try{return await Xar(_)}catch(h){throw new uF(`Error opening file "${_}"`,{cause:h})}}}}t(due,"customResolver");var sj=/^win/.test(globalThis.process?globalThis.process.platform:""),Qar=/\//g,Zar=/^(\w{2,}):\/\//i,eNe=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function eor(a){let s=Zar.exec(a);if(s)return s[1].toLowerCase()}t(eor,"getProtocol");function aft(a,s){a=decodeURI(a);for(let _=0;_<eNe.length;_+=2)a=a.replace(eNe[_],eNe[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";if(l&&(a=a[7]==="/"?a.substr(8):a.substr(7),sj&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=sj?a:"/"+a)),!l){let _=a.split(sj?"\\":"/"),h=[];for(let b of _)b===".."?h.length&&h[h.length-1]!==""&&h.pop():(b!==""||h.length===0)&&h.push(b);a=h.join(sj?"\\":"/"),!sj&&h[0]===""&&(a="/"+a.substring(1))}return sj&&!l&&(a=a.replace(Qar,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(aft,"toFileSystemPath");var oft="YOUR_KEY_HERE";async function cft(a){let l=await new z3(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return tor({...a,relativeOpenApiPath:_},l)}t(cft,"buildPublicOpenApiFile");async function tor(a,s){sor({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=nor(l),ror(l,a.urls?.api?.defaultUrl),l=ior(l,a),lft(l,"x-zuplo"),l}t(tor,"buildRawOpenApiFile");function ror(a,s){s?a.servers=[{url:s}]:a.servers=[]}t(ror,"addServerHost");function nor(a){if(!a.paths)return a;let{components:s}=a,l=s?{...s}:void 0,_=[];l&&l.parameters&&(_=Object.entries(l.parameters).reduce((b,[D,A])=>(NM in A&&ale(A[NM])&&(b.push(D),l.parameters&&delete l.parameters[D]),b),[]));let h=Object.entries(a.paths).reduce((b,[D,A])=>{if(!A)return b;let M={...A},z=["delete","get","head","patch","post","put","trace","options"];return z.forEach(re=>{let ie=A[re];if(!ie)return;if(ale(ie[NM])){delete M[re];return}let{parameters:Q}=ie;if(!Q)return;let Re=Q.filter(Ie=>{if(NM in Ie&&ale(Ie[NM]))return!1;if("$ref"in Ie){let we=Ie.$ref.split("/").pop();return we?!_.includes(we):!0}return!0});M[re]={...ie,parameters:Re}}),z.some(re=>!!M[re])&&(b[D]=M),b},{});return{...a,paths:h,components:l}}t(nor,"removeHiddenRoutesAndParams");function ior(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[h,b])=>{if(!b)return _;let D={...b};return[D.delete,D.get,D.head,D.patch,D.post,D.put,D.trace,D.options].forEach(A=>{if(!A)return;let M=A["x-zuplo-route"]?.policies?.inbound?.reduce((ie,Q)=>{let Re=s.policies?.find(({name:wt})=>wt===Q);if(!Re)return ie;if(!(Re.handler.export==="CompositeInboundPolicy"))return ie.concat(Q);let we=Re.handler.options?.policies;return we?ie.concat(we):ie},[]),z=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="ApiAuthKeyInboundPolicy"||Q.handler.export==="ApiKeyInboundPolicy")&&!Q.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&z.push(Q)})}),z.length>0){let ie=z.length>0&&z[0].handler&&z[0].handler.options&&z[0].handler.options.authHeader?z[0].handler.options.authHeader:"Authorization",Q=z.length>0&&z[0].handler&&z[0].handler.options&&(z[0].handler.options.authScheme||z[0].handler.options.authScheme==="")?z[0].handler.options.authScheme:"Bearer",Re=Q!==""?`${Q} ${oft}`:oft,Ie={name:ie,in:"header",required:!0,example:Re,schema:{type:"string"},description:`The \`${ie}\` header is used to authenticate with the API using your API key. Value is of the format \`${Re}\`.`};A.parameters?A.parameters.some(Tr=>"name"in Tr&&Tr.name===Ie.name)||A.parameters.unshift(Ie):A.parameters=[Ie];let we={type:"http",scheme:Q.toLowerCase()},wt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(Tr=>"name"in Tr&&Tr.type==="apiKey"||"type"in Tr&&Tr.type==="http"&&Tr.scheme===Q)||(a.components.securitySchemes={...a.components.securitySchemes,[wt]:we}):(a.components||(a.components={}),a.components.securitySchemes={[wt]:we});let xt={[wt]:[]};A.security?A.security.some(Tr=>Tr[wt]!==void 0)||A.security.unshift(xt):A.security=[xt]}let re=[];if(M&&M.forEach(ie=>{s.policies?.forEach(Q=>{Q.name===ie&&(Q.handler.export==="RateLimitInboundPolicy"||Q.handler.export==="ComplexRateLimitInboundPolicy")&&re.push(Q)})}),re.length>0){let ie={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},Q={...ie,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};a.components?.responses||a.components||(a.components={}),a.components.responses={...a.components.responses,RateLimitNoRetryAfter:ie,RateLimitWithRetryAfter:Q},A.responses||(A.responses={});let Re=re.some(Ie=>Ie.handler.options?.headerMode!=="none");A.responses[429]||(A.responses[429]={$ref:Re?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[h]=D,_},{});return{...a,paths:l}}t(ior,"enrichSpecWithZuploData");function lft(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&lft(a[l],s)}t(lft,"removePropertiesByPrefix");function sor({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new V1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new V1({message:"The OpenAPI document does not have the required 'info' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in s.info)||typeof s.info.title!="string")throw new V1({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(sor,"assertIsZuploOpenApiSpec");import kK from"node:path";function aor(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let z=0;z<s.length;z++)s[z]=255;for(let z=0;z<a.length;z++){let re=a.charAt(z),ie=re.charCodeAt(0);if(s[ie]!==255)throw new TypeError(re+" is ambiguous");s[ie]=z}let l=a.length,_=a.charAt(0),h=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function D(z){if(z instanceof Uint8Array||(ArrayBuffer.isView(z)?z=new Uint8Array(z.buffer,z.byteOffset,z.byteLength):Array.isArray(z)&&(z=Uint8Array.from(z))),!(z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(z.length===0)return"";let re=0,ie=0,Q=0,Re=z.length;for(;Q!==Re&&z[Q]===0;)Q++,re++;let Ie=(Re-Q)*b+1>>>0,we=new Uint8Array(Ie);for(;Q!==Re;){let Tr=z[Q],fn=0;for(let tn=Ie-1;(Tr!==0||fn<ie)&&tn!==-1;tn--,fn++)Tr+=256*we[tn]>>>0,we[tn]=Tr%l>>>0,Tr=Tr/l>>>0;if(Tr!==0)throw new Error("Non-zero carry");ie=fn,Q++}let wt=Ie-ie;for(;wt!==Ie&&we[wt]===0;)wt++;let xt=_.repeat(re);for(;wt<Ie;++wt)xt+=a.charAt(we[wt]);return xt}t(D,"encode");function A(z){if(typeof z!="string")throw new TypeError("Expected String");if(z.length===0)return new Uint8Array;let re=0,ie=0,Q=0;for(;z[re]===_;)ie++,re++;let Re=(z.length-re)*h+1>>>0,Ie=new Uint8Array(Re);for(;z[re];){let Tr=s[z.charCodeAt(re)];if(Tr===255)return;let fn=0;for(let tn=Re-1;(Tr!==0||fn<Q)&&tn!==-1;tn--,fn++)Tr+=l*Ie[tn]>>>0,Ie[tn]=Tr%256>>>0,Tr=Tr/256>>>0;if(Tr!==0)throw new Error("Non-zero carry");Q=fn,re++}let we=Re-Q;for(;we!==Re&&Ie[we]===0;)we++;let wt=new Uint8Array(ie+(Re-we)),xt=ie;for(;we!==Re;)wt[xt++]=Ie[we++];return wt}t(A,"decodeUnsafe");function M(z){let re=A(z);if(re)return re;throw new Error("Non-base"+l+" character")}return t(M,"decode"),{encode:D,decodeUnsafe:A,decode:M}}t(aor,"base");var uft=aor;var oor="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",mue=uft(oor);var cor=!1;function aj(a,s){return{open:`\x1B[${a.join(";")}m`,close:`\x1B[${s}m`,regexp:new RegExp(`\\x1b\\[${s}m`,"g")}}t(aj,"code");function oj(a,s){return cor?`${s.open}${a.replace(s.regexp,s.open)}${s.close}`:a}t(oj,"run");function lor(a){return oj(a,aj([31],39))}t(lor,"red");function uor(a){return oj(a,aj([32],39))}t(uor,"green");function _or(a){return oj(a,aj([33],39))}t(_or,"yellow");function por(a){return oj(a,aj([34],39))}t(por,"blue");function dor(a){return oj(a,aj([35],39))}t(dor,"magenta");function mor(a){return oj(a,aj([36],39))}t(mor,"cyan");var SOr=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 fft=[lor,uor,_or,por,dor,mor];function hor(a){let s=0,l=a.length,_=0;if(l>0)for(;_<l;)s=(s<<5)-s+a.charCodeAt(_++)|0;return s}t(hor,"hashCode");function _ft(a){let s=Math.abs(hor(a));return fft[s%fft.length]}t(_ft,"generateColor");import{inspect as gor}from"node:util";function pft(a,s,...l){let _=0,h=l.length,b=String(s).replace(/%[sdjoO%]/g,D=>{if(D==="%%")return"%";if(_>=h)return D;switch(D){case"%s":return String(l[_++]);case"%d":return Number(l[_++]).toString();case"%o":return a(l[_++]).split(`
|
|
583
|
-
`).map(A=>A.trim()).join(" ");case"%O":return a(l[_++]);case"%j":try{return JSON.stringify(l[_++])}catch{return"[Circular]"}default:return D}});for(let D of l.splice(_))D===null||!(typeof D=="object"&&D!==null)?b+=" "+D:b+=" "+a(D);return b}t(pft,"format");var dft=t((a,...s)=>pft(gor,a,s),"format");var tNe=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(s,l){this.manager=s,this.ns=l,this.color=_ft(l),this.last=0,this.enabled=s.enabled.some(_=>_.test(l))}log(...s){if(!this.enabled)return;let l,_=s[0];typeof _=="function"?l=_():l=String(_);let h=Date.now()-(this.last||Date.now());l=dft(l,...s);let b=`${this.color(this.ns)} ${l} ${this.color(`+${h}ms`)}`;console.log(b),this.last=Date.now()}},rNe=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(s){this.debuggers=new Map,this.enabled=s??[]}};function yor(a){return!a||a.length===0?[]:(a=a.replace(/\s/g,"").replace(/\*/g,".+"),a.split(",").map(s=>new RegExp(`^${s}$`)))}t(yor,"extract");var hue;function gue(a){hue||(hue=new rNe(yor(process.env.DEBUG)));let s=new tNe(hue,a);return hue.debuggers.set(a,s),Object.assign(s.log.bind(s),{self:s})}t(gue,"debug");var J3=class extends Error{static{t(this,"RuntimeError")}extensionMembers;constructor(s,l){typeof s=="string"?super(s,l):(super(s.message,l),this.extensionMembers=s.extensionMembers),this.name="RuntimeError"}};var mft="zp-local-service";var MOr=Symbol("zuplo_meters"),jOr=Symbol("zuplo_dynamic_meters");var fF=gue("zuplo:runtime:external-service");function vor(){let a,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:s}=F0.instance.runtime;if(s&&s!=="undefined")try{let l=atob(s);a=JSON.parse(l)}catch{}return a}t(vor,"getServiceAuth");async function hft(a,s){let l=vor();if(l)if(fF(`Using external service auth. ClientId: ${l.clientId})`),typeof a=="string"){let _=new URL(a),h=_.hostname,b=s??{},D=new Headers(b.headers||{});D.set("CF-Access-Client-Id",l.clientId),D.set("CF-Access-Client-Secret",l.clientSecret),b.headers=D;let A;if(l.customServiceMapping&&l.customServiceMapping[h])A=`https://${l.customServiceMapping[h]}`;else if(F0.instance.useLegacyServiceRouting)A=`https://${h}.zuptunnel.com`;else{fF("Using sha256 service routing");let re=F0.instance.build;if(re.ACCOUNT_NAME&&re.PROJECT_NAME&&re.ENVIRONMENT_TYPE){let ie=await bor(h,re.ACCOUNT_NAME,re.PROJECT_NAME,re.ENVIRONMENT_TYPE),Q=yft(re.ENVIRONMENT_TYPE),Re=await nNe(`${re.ACCOUNT_NAME}-${re.PROJECT_NAME}-${Q}`);Re==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||Re==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?A=`https://${ie}.zuptunnel.com`:A=`https://${ie}.t.zuplo.app`}else throw fF("Cannot use sha256 service routing, missing build variables"),new J3("Failed to generate fully qualified tunnel url.")}let M=new URL(`${A}${_.pathname}${_.search}`);fF(`Calling external service: ${M.toString()}`);let z=await EG(M.toString(),b);if(z.status===403&&z.headers.get("cf-access-domain")!==null)throw CG.console.error("403 Forbidden when calling external service.",{clientId:l.clientId,tunnelHost:A}),new J3("Could not connect to secure tunnel.");return z}else throw fF("Cannot call external service with Request object"),new J3("Currently, we only support fetch(<some_string>, ...).");else throw fF("There is no external service auth configured for this zup."),new J3("There are no external services configured for this zup.")}t(hft,"externalServiceHandler");async function gft(a,s){if(typeof a=="string"){let l=new URL(a),_=l.hostname,h=s??{},b=`http://${_}.zuplo.svc.cluster.local:9000`,D=new URL(`${b}${l.pathname}${l.search}`),A=new Headers(h.headers||{});return A.set(mft,_),h.headers=A,await EG(D.toString(),h)}else throw new J3("Currently, we only support fetch(<some_string>, ...).")}t(gft,"clusterServiceHandler");async function bor(a,s,l,_){let h=a.toLowerCase(),b=s.toLowerCase(),D=l.toLowerCase(),A=yft(_);fF(`Hashing service name: ${b}-${h}.${b}-${D}-${A}`);let M=await nNe(`${b}-${h}`),z=await nNe(`${b}-${D}-${A}`);return`${M}.${z}`}t(bor,"hashServiceName");async function nNe(a){let s=new TextEncoder().encode(a),l=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(l)).map(b=>b.toString(16).padStart(2,"0")).join("").slice(0,-1)}t(nNe,"hashSegment");function yft(a){let s=a.toLowerCase();switch(s){case"production":case"preview":return s;default:return"working-copy"}}t(yft,"sanitizeEnvironmentType");var iNe=new Map;iNe.set("service:",hft);iNe.set("local:",gft);var EG=globalThis.fetch;function sNe(a,s){let l=Sor(s);if(typeof a=="string"){let _=new URL(a),h=iNe.get(_.protocol);return h?h(a,l):EG(a,l)}else return EG(a,l)}t(sNe,"internalFetch");globalThis.fetch=sNe;var Sor=t(a=>{if(!a||a instanceof Request)return a;let s=a;if(!s.zuplo)return a;let l=a;return l.cf={cacheEverything:s.zuplo?.cacheEverything,cacheTtl:s.zuplo?.cacheTtlSeconds},delete a.zuplo,a},"transformInit");var Tor={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:sNe},CG=Tor;var aNe="2025-02-06",vft=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function bft(){return new F0({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:aNe,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:vft[aNe]},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(bft,"getMockEnvironment");var F0=class a{static{t(this,"Environment")}config;static#r;static#n=!1;static initialize(s){this.#r||(this.#r=new a(s),this.#n=!0)}static get instance(){return this.#n||(CG.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#r=bft()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(mue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let D of Object.keys(b))l[D]||(l[D]=b[D])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){CG.console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,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 zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.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 xor=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function Sft(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!xor.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(Sft,"isRestrictedEnvVariableName");function Tft(a){return!!a.startsWith("ZUPLO_")}t(Tft,"isZuploReadableEnvVariableName");var uFr=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return F0.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return F0.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return F0.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return F0.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return F0.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return F0.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return F0.instance.build.COMPATIBILITY_DATE}if(!(Sft(l)&&!Tft(l)))return F0.instance.runtime[l]}});function DG(a,s,l){return`_${PA(`${a}_${s}_${l}`)}`}t(DG,"getRawOperationDataIdentifierName");function oNe(a,s,l,_){return`_${PA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(oNe,"getIdForParameterSchema");function cNe(a,s,l){return`_${PA(a.toLowerCase())}_${s.toLowerCase()}_rb_${PA(l.toLowerCase())}`}t(cNe,"getIdForRequestBodySchema");function kG(a,s){return`_${PA(a)}_${PA(s)}`}t(kG,"getIdForRefSchema");function PA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s="_"+s),s}t(PA,"sanitizedIdentifierName");var egt=x_(_pt(),1);var JG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},mur=/[$_\p{ID_Start}]/u,hur=/[$_\u200C\u200D\p{ID_Continue}]/u,rIe=".*";function gur(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(gur,"Re");function mpt(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let D="",A=_+1;for(;A<a.length;){let M=a.substr(A,1);if(A===_+1&&mur.test(M)||A!==_+1&&hur.test(M)){D+=a[A++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=A;continue}if(h==="("){let D=1,A="",M=_+1,z=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!gur(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),z=!0;break}if(a[M]==="\\"){A+=a[M++]+a[M++];continue}if(a[M]===")"){if(D--,D===0){M++;break}}else if(a[M]==="("&&(D++,a[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),z=!0;break}A+=a[M++]}if(z)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!A){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:A}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(mpt,"v");function hpt(a,s={}){let l=mpt(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${MT(s.delimiter)}]+?`,h=[],b=0,D=0,A="",M=new Set,z=t(fn=>{if(D<l.length&&l[D].type===fn)return l[D++].value},"a"),re=t(()=>z("OTHER_MODIFIER")??z("ASTERISK"),"f"),ie=t(fn=>{let tn=z(fn);if(tn!==void 0)return tn;let{type:cn,index:Er}=l[D];throw new TypeError(`Unexpected ${cn} at ${Er}, expected ${fn}`)},"d"),Q=t(()=>{let fn="",tn;for(;tn=z("CHAR")??z("ESCAPED_CHAR");)fn+=tn;return fn},"T"),Re=t(fn=>fn,"Se"),Ie=s.encodePart||Re,we="",wt=t(fn=>{we+=fn},"U"),xt=t(()=>{we.length&&(h.push(new JG(3,"","",Ie(we),"",3)),we="")},"$"),Tr=t((fn,tn,cn,Er,vr)=>{let fs=3;switch(vr){case"?":fs=1;break;case"*":fs=0;break;case"+":fs=2;break}if(!tn&&!cn&&fs===3){wt(fn);return}if(xt(),!tn&&!cn){if(!fn)return;h.push(new JG(3,"","",Ie(fn),"",fs));return}let Oi;cn?cn==="*"?Oi=rIe:Oi=cn:Oi=_;let Ho=2;Oi===_?(Ho=1,Oi=""):Oi===rIe&&(Ho=0,Oi="");let di;if(tn?di=tn:cn&&(di=b++),M.has(di))throw new TypeError(`Duplicate name '${di}'.`);M.add(di),h.push(new JG(Ho,di,Ie(fn),Oi,Ie(Er),fs))},"V");for(;D<l.length;){let fn=z("CHAR"),tn=z("NAME"),cn=z("REGEX");if(!tn&&!cn&&(cn=z("ASTERISK")),tn||cn){let vr=fn??"";s.prefixes.indexOf(vr)===-1&&(wt(vr),vr=""),xt();let fs=re();Tr(vr,tn,cn,"",fs);continue}let Er=fn??z("ESCAPED_CHAR");if(Er){wt(Er);continue}if(z("OPEN")){let vr=Q(),fs=z("NAME"),Oi=z("REGEX");!fs&&!Oi&&(Oi=z("ASTERISK"));let Ho=Q();ie("CLOSE");let di=re();Tr(vr,fs,Oi,Ho,di);continue}xt(),ie("END")}return h}t(hpt,"D");function MT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(MT,"S");function ppt(a){return a&&a.ignoreCase?"ui":"u"}t(ppt,"X");function yur(a,s,l){return gpt(hpt(a,l),s,l)}t(yur,"Z");function gj(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(gj,"k");function gpt(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let A of a){if(A.type===3){A.modifier===3?_+=MT(A.value):_+=`(?:${MT(A.value)})${gj(A.modifier)}`;continue}s&&s.push(A.name);let M=`[^${MT(l.delimiter)}]+?`,z=A.value;if(A.type===1?z=M:A.type===0&&(z=rIe),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?_+=`(${z})${gj(A.modifier)}`:_+=`((?:${z})${gj(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){_+=`(?:${MT(A.prefix)}(${z})${MT(A.suffix)})`,_+=gj(A.modifier);continue}_+=`(?:${MT(A.prefix)}`,_+=`((?:${z})(?:`,_+=MT(A.suffix),_+=MT(A.prefix),_+=`(?:${z}))*)${MT(A.suffix)})`,A.modifier===0&&(_+="?")}let h=`[${MT(l.endsWith)}]|$`,b=`[${MT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,ppt(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let D=!1;if(a.length){let A=a[a.length-1];A.type===3&&A.modifier===3&&(D=l.delimiter.indexOf(A)>-1)}return D||(_+=`(?=${b}|${h})`),new RegExp(_,ppt(l))}t(gpt,"F");var H3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},vur={delimiter:".",prefixes:"",sensitive:!0,strict:!0},bur={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Sur(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Sur,"J");function ypt(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(ypt,"Q");function Tur(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(Tur,"Ee");function vpt(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(vpt,"W");var bpt=["ftp","file","http","https","ws","wss"];function Spt(a){if(!a)return!0;for(let s of bpt)if(a.test(s))return!0;return!1}t(Spt,"N");function xur(a,s){if(a=ypt(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t(xur,"te");function Eur(a,s){if(a=ypt(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(Eur,"re");function Cur(a,s){return s||a===""?a:vpt(a)?Ept(a):xpt(a)}t(Cur,"ne");function Dur(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(Dur,"se");function kur(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(kur,"ie");function wur(a,s,l){if(l||a==="")return a;if(s&&!bpt.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(wur,"ae");function Pur(a,s,l){return Tpt(s)===a&&(a=""),l||a===""?a:Cpt(a)}t(Pur,"oe");function Aur(a,s){return a=Tur(a,":"),s||a===""?a:nIe(a)}t(Aur,"ce");function Tpt(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(Tpt,"_");function nIe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(nIe,"y");function Nur(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Nur,"le");function Iur(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Iur,"fe");function xpt(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(xpt,"z");function Ept(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(Ept,"j");function Cpt(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(Cpt,"K");function Our(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(Our,"he");function Fur(a){return a===""?a:new URL(`data:${a}`).pathname}t(Fur,"ue");function Lur(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Lur,"de");function Rur(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(Rur,"pe");var Mur=class{static{t(this,"H")}#r;#n=[];#e={};#t=0;#s=1;#p=0;#a=0;#_=0;#c=0;#l=!1;constructor(a){this.#r=a}get result(){return this.#e}parse(){for(this.#n=mpt(this.#r,!0);this.#t<this.#n.length;this.#t+=this.#s){if(this.#s=1,this.#n[this.#t].type==="END"){if(this.#a===0){this.#v(),this.#D()?this.#i(9,1):this.#y()?this.#i(8,1):this.#i(7,0);continue}else if(this.#a===2){this.#d(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#o())this.#_-=1;else continue;if(this.#w()){this.#_+=1;continue}switch(this.#a){case 0:this.#g()&&this.#d(1);break;case 1:if(this.#g()){this.#I();let a=7,s=1;this.#C()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#E()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#x()&&this.#i(5,1);break;case 4:this.#x()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#k()&&!this.#c?this.#i(6,1):this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let l=this.#u(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#C(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#x(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#k(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#w(){return this.#n[this.#t].type=="OPEN"}#o(){return this.#n[this.#t].type=="CLOSE"}#N(){return this.#m(this.#t,"[")}#S(){return this.#m(this.#t,"]")}#T(){let a=this.#n[this.#t],s=this.#u(this.#p).index;return this.#r.substring(s,a.index)}#I(){let a={};Object.assign(a,H3),a.encodePart=nIe;let s=yur(this.#T(),void 0,a);this.#l=Spt(s)}},tIe=["protocol","username","password","hostname","port","pathname","search","hash"],W3="*";function dpt(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(dpt,"ge");function FA(a,s){return s?zG(a):a}t(FA,"b");function $G(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=FA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=FA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=FA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=FA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=FA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=FA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=FA(_.search.substring(1,_.search.length),l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=FA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Aur(s.protocol,l)),typeof s.username=="string"&&(a.username=kur(s.username,l)),typeof s.password=="string"&&(a.password=Dur(s.password,l)),typeof s.hostname=="string"&&(a.hostname=Cur(s.hostname,l)),typeof s.port=="string"&&(a.port=Pur(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!Sur(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=FA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=wur(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=Eur(s.search,l)),typeof s.hash=="string"&&(a.hash=xur(s.hash,l)),a}t($G,"w");function zG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(zG,"C");function jur(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(jur,"Oe");function Bur(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${jur(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let A=a[D];if(A.type===3){if(A.modifier===3){b+=zG(A.value);continue}b+=`{${zG(A.value)}}${gj(A.modifier)}`;continue}let M=A.hasCustomName(),z=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!s.prefixes.includes(A.prefix)),re=D>0?a[D-1]:null,ie=D<a.length-1?a[D+1]:null;if(!z&&M&&A.type===1&&A.modifier===3&&ie&&!ie.prefix.length&&!ie.suffix.length)if(ie.type===3){let Q=ie.value.length>0?ie.value[0]:"";z=h.test(Q)}else z=!ie.hasCustomName();if(!z&&!A.prefix.length&&re&&re.type===3){let Q=re.value[re.value.length-1];z=s.prefixes.includes(Q)}z&&(b+="{"),b+=zG(A.prefix),M&&(b+=`:${A.name}`),A.type===2?b+=`(${A.value})`:A.type===1?M||(b+=`(${_})`):A.type===0&&(!M&&(!re||re.type===3||re.modifier!==3||z||A.prefix!=="")?b+="*":b+=`(${l})`),A.type===1&&M&&A.suffix.length&&h.test(A.suffix[0])&&(b+="\\"),b+=zG(A.suffix),z&&(b+="}"),A.modifier!==3&&(b+=gj(A.modifier))}return b}t(Bur,"ke");var Dpt=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let A=new Mur(a);if(A.parse(),a=A.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:W3,protocol:W3,username:W3,password:W3,hostname:W3,port:W3,search:W3,hash:W3};this.#r=$G(b,a,!0),Tpt(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of tIe){if(!(D in this.#r))continue;let A={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(A,H3),A.encodePart=nIe;break;case"username":Object.assign(A,H3),A.encodePart=Nur;break;case"password":Object.assign(A,H3),A.encodePart=Iur;break;case"hostname":Object.assign(A,vur),vpt(M)?A.encodePart=Ept:A.encodePart=xpt;break;case"port":Object.assign(A,H3),A.encodePart=Cpt;break;case"pathname":Spt(this.#n.protocol)?(Object.assign(A,bur,h),A.encodePart=Our):(Object.assign(A,H3,h),A.encodePart=Fur);break;case"search":Object.assign(A,H3,h),A.encodePart=Lur;break;case"hash":Object.assign(A,H3,h),A.encodePart=Rur;break}try{this.#s[D]=hpt(M,A),this.#n[D]=gpt(this.#s[D],this.#e[D],A),this.#t[D]=Bur(this.#s[D],A),this.#p=this.#p||this.#s[D].some(z=>z.type===2)}catch{throw new TypeError(`invalid ${D} pattern '${this.#r[D]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?l=$G(l,a,!1):l=$G(l,dpt(a,s),!1)}catch{return!1}let _;for(_ of tIe)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?l=$G(l,a,!1):l=$G(l,dpt(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of tIe){let b=this.#n[h].exec(l[h]);if(!b)return null;let D={};for(let[A,M]of this.#e[h].entries())if(typeof M=="string"||typeof M=="number"){let z=b[A+1];D[M]=z}_[h]={input:l[h]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((A,M)=>{for(let z of["type","modifier","prefix","value","suffix"]){if(A[z]<M[z])return-1;if(A[z]!==M[z])return 1}return 0},"o"),h=new JG(3,"","","","",3),b=new JG(0,"","","","",3),D=t((A,M)=>{let z=0;for(;z<Math.min(A.length,M.length);++z){let re=_(A[z],M[z]);if(re)return re}return A.length===M.length?0:_(A[z]??h,M[z]??h)},"s");return!s.#t[a]&&!l.#t[a]?0:s.#t[a]&&!l.#t[a]?D(s.#s[a],[b]):!s.#t[a]&&l.#t[a]?D([b],l.#s[a]):D(s.#s[a],l.#s[a])}get protocol(){return this.#t.protocol}get username(){return this.#t.username}get password(){return this.#t.password}get hostname(){return this.#t.hostname}get port(){return this.#t.port}get pathname(){return this.#t.pathname}get search(){return this.#t.search}get hash(){return this.#t.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=Dpt);import{AssertionError as Uur}from"node:assert";function LA(a,s){if(a===!1)throw new Uur({message:s})}t(LA,"assert");var ec;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(ec||(ec={}));function yj(a){return a.type===ec.Object}t(yj,"isAstObject");function RA(a){return a.type===ec.Property}t(RA,"isAstProperty");function kpt(a){return a.type===ec.Array}t(kpt,"isAstArray");function vj(a){return a.type===ec.Literal}t(vj,"isAstLiteral");function G3(a){if(a===void 0)throw new Error("Node is undefined");if(!yj(a))throw new Error("Node is not object")}t(G3,"assertAstObject");import{findNodeAtLocation as $ur,getNodeValue as zur,printParseErrorCode as Jur,visit as qur}from"jsonc-parser";var Vur={DEFAULT:{allowTrailingComma:!1}};function qG(a,s=[],l=Vur.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),qur(a,{onObjectBegin:t((M,z,re)=>{_=b({type:"object",offset:M,length:-1,line:z+1,column:re+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,z,re,ie,Q)=>{_=b({type:"property",offset:z,length:-1,line:ie+1,column:Q+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:z,length:re,line:ie,column:Q,parent:_})},"onObjectProperty"),onObjectEnd:t((M,z)=>{h(M+z),_.length=M+z-_.offset,_=_.parent,h(M+z)},"onObjectEnd"),onArrayBegin:t((M,z,re,ie)=>{_=b({type:"array",offset:M,length:-1,line:re+1,column:ie+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,z)=>{_.length=M+z-_.offset,_=_.parent,h(M+z)},"onArrayEnd"),onLiteralValue:t((M,z,re,ie,Q)=>{b({type:Wur(M),offset:z,length:re,line:ie+1,column:Q+1,parent:_,value:M}),h(z+re)},"onLiteralValue"),onSeparator:t((M,z)=>{_.type==="property"&&(M===":"?_.colonOffset=z:M===","&&h(z))},"onSeparator"),onError:t((M,z,re,ie,Q)=>{s.push({error:M,offset:z,length:re,line:ie+1,column:Q+1})},"onError")},l);let A=_.children[0];return A&&delete A.parent,A}t(qG,"parse");function Wur(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(Wur,"getNodeType");function iIe(a,s){return $ur(a,s)}t(iIe,"findNodeAtLocation");function VG(a){return zur(a)}t(VG,"getNodeValue");function wpt(a){return Jur(a)}t(wpt,"printParseErrorCode");var WG=class{static{t(this,"AstAdapter")}parse(s){let _=qG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:ec.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:ec.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){LA(s.children?.length===2,"Invalid property node");let _={type:ec.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:ec.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:ec.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var jT={createLiteral:t((a,s)=>({type:ec.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:ec.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:ec.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:ec.Property,parent:l,name:null,value:s};return _.name={value:a,type:ec.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:ec.Array,parent:s,children:[]};for(let _ of a)l.children.push(jT.createLiteral(_,l));return l},"createArrayOfLiterals")};var Hur=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,HG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case ec.Array:return this.generateArray(s,l);case ec.Object:return this.generateObject(s,l);case ec.Property:return this.generateProperty(s,l);case ec.Literal:return this.generateLiteral(s,l);case ec.FunctionCall:return this.generateFunctionCall(s,l);case ec.Identifier:return this.generateIdentifier(s,l);case ec.Raw:return this.generateRaw(s,l);case ec.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=Hur.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import Gur from"node:fs/promises";import{parse as Kur}from"@swc/core";var Ppt=t(async a=>{let s=new Set;try{let l=await Gur.readFile(a,"utf-8");(await Kur(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var Apt={$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 sIe={$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 Npt={$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 aIe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var oIe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var qht=x_(pht(),1),Vht=x_(Jht(),1);var Lfe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new Vht.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,qht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=h.instancePath.split("/");if(D.length>2){let M=D[1],z=D[2]?parseInt(D[2]):0,re=D[3],ie=isNaN(z)?void 0:l[M][z][re];b={details:{property:M,index:z,field:re,fieldValue:ie}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let M=h.instancePath.split("/"),z=M[M.length-1];h.message=`Value of property '${z}' must be '${h.params.type}'`}let A=Object.assign(h,b);_.push(A)}),_}};var iN=Lfe.instance;iN.addSchema(oIe,"route-configuration.schema.json");iN.addSchema(Npt,"policy-configuration.schema.json");iN.addSchema(sIe,"policies.schema.json");iN.addSchema(aIe,"open-api-route-configuration.schema.json");iN.addSchema(Apt,"fragments.schema.json");var lRr=iN.compile(oIe),Wht=iN.compile(aIe),TOe=iN.compile(sIe);var Rfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=TOe(s),this.results}};var Mfe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Wht(s),this.results}};import r0r from"node:path";var xOe=/\$import\((.*)\)/,jfe=/\$env\((.*?)\)/g;var $A=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},t0r=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),sN=t((a,s)=>{if(!a)return!1;let l=t0r(a);return s.split("/").every((b,D)=>{let A=l[D];return A?b==="*"||RA(A)&&A.name.value===b?!0:b==="{}"?A.type===ec.Object:b==="[]"?A.type===ec.Array:!1:!1})},"testPosition");var Bfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),yj(s)?s.children.forEach(l=>{this.visitor(l)}):kpt(s)?s.children.forEach(l=>{this.visitor(l)}):RA(s)&&this.visitor(s.value)}},Hht=t((a,s,l)=>_=>{if(!RA(_)||!vj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>sN(_,b))){jfe.test(_.value.value)&&s.push(new $A("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(jfe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:ec.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(jfe),(D,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);b!==_.value.value&&(_.value=jT.createTemplateString(b,_))}},"getEnvStatementTransformer");var DK="config/routes.json",n0r=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],i0r=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Ght=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],s0r="handler/{}/options/{}/rewritePattern",a0r="handler/{}/options/{}/baseUrl",Ufe=class extends Bfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!RA(s)||!vj(s.value)||typeof s.value.value!="string")&&sN(s,s0r)){if(!s.parent||!yj(s.parent)){this.errors.push(new $A("Invalid node, expected object",DK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:Kht(l)},h=jT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!RA(s)||!vj(s.value)||typeof s.value.value!="string")&&sN(s,a0r)){if(!s.parent||!yj(s.parent)){this.errors.push(new $A("Invalid node, expected object",DK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:Kht(l)},h=jT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!RA(s)||!vj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!i0r.some(A=>sN(s,A))&&!Ght.some(A=>sN(s,A))){if(xOe.test(l)){if(s.name.value==="$ref")return;this.errors.push(new $A("An $import() statement is not expected at this location.",DK,s.location,l))}return}let _=xOe.exec(l);if(Ght.some(A=>sN(s,A))&&!_)return;if(!_){this.errors.push(new $A("Invalid $import() statement",DK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=r0r.posix.join("..",h));let b=this.getImportName(h),D={type:ec.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=Hht(n0r,this.errors,DK)};function Kht(a){return`(request, context) => {
|
|
583
|
+
`).map(A=>A.trim()).join(" ");case"%O":return a(l[_++]);case"%j":try{return JSON.stringify(l[_++])}catch{return"[Circular]"}default:return D}});for(let D of l.splice(_))D===null||!(typeof D=="object"&&D!==null)?b+=" "+D:b+=" "+a(D);return b}t(pft,"format");var dft=t((a,...s)=>pft(gor,a,s),"format");var tNe=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(s,l){this.manager=s,this.ns=l,this.color=_ft(l),this.last=0,this.enabled=s.enabled.some(_=>_.test(l))}log(...s){if(!this.enabled)return;let l,_=s[0];typeof _=="function"?l=_():l=String(_);let h=Date.now()-(this.last||Date.now());l=dft(l,...s);let b=`${this.color(this.ns)} ${l} ${this.color(`+${h}ms`)}`;console.log(b),this.last=Date.now()}},rNe=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(s){this.debuggers=new Map,this.enabled=s??[]}};function yor(a){return!a||a.length===0?[]:(a=a.replace(/\s/g,"").replace(/\*/g,".+"),a.split(",").map(s=>new RegExp(`^${s}$`)))}t(yor,"extract");var hue;function gue(a){hue||(hue=new rNe(yor(process.env.DEBUG)));let s=new tNe(hue,a);return hue.debuggers.set(a,s),Object.assign(s.log.bind(s),{self:s})}t(gue,"debug");var J3=class extends Error{static{t(this,"RuntimeError")}extensionMembers;constructor(s,l){typeof s=="string"?super(s,l):(super(s.message,l),this.extensionMembers=s.extensionMembers),this.name="RuntimeError"}};var mft="zp-local-service";var MOr=Symbol("zuplo_meters"),jOr=Symbol("zuplo_dynamic_meters");var fF=gue("zuplo:runtime:external-service");function vor(){let a,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:s}=F0.instance.runtime;if(s&&s!=="undefined")try{let l=atob(s);a=JSON.parse(l)}catch{}return a}t(vor,"getServiceAuth");async function hft(a,s){let l=vor();if(l)if(fF(`Using external service auth. ClientId: ${l.clientId})`),typeof a=="string"){let _=new URL(a),h=_.hostname,b=s??{},D=new Headers(b.headers||{});D.set("CF-Access-Client-Id",l.clientId),D.set("CF-Access-Client-Secret",l.clientSecret),b.headers=D;let A;if(l.customServiceMapping&&l.customServiceMapping[h])A=`https://${l.customServiceMapping[h]}`;else if(F0.instance.useLegacyServiceRouting)A=`https://${h}.zuptunnel.com`;else{fF("Using sha256 service routing");let re=F0.instance.build;if(re.ACCOUNT_NAME&&re.PROJECT_NAME&&re.ENVIRONMENT_TYPE){let ie=await bor(h,re.ACCOUNT_NAME,re.PROJECT_NAME,re.ENVIRONMENT_TYPE),Q=yft(re.ENVIRONMENT_TYPE),Re=await nNe(`${re.ACCOUNT_NAME}-${re.PROJECT_NAME}-${Q}`);Re==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||Re==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?A=`https://${ie}.zuptunnel.com`:A=`https://${ie}.t.zuplo.app`}else throw fF("Cannot use sha256 service routing, missing build variables"),new J3("Failed to generate fully qualified tunnel url.")}let M=new URL(`${A}${_.pathname}${_.search}`);fF(`Calling external service: ${M.toString()}`);let z=await EG(M.toString(),b);if(z.status===403&&z.headers.get("cf-access-domain")!==null)throw CG.console.error("403 Forbidden when calling external service.",{clientId:l.clientId,tunnelHost:A}),new J3("Could not connect to secure tunnel.");return z}else throw fF("Cannot call external service with Request object"),new J3("Currently, we only support fetch(<some_string>, ...).");else throw fF("There is no external service auth configured for this zup."),new J3("There are no external services configured for this zup.")}t(hft,"externalServiceHandler");async function gft(a,s){if(typeof a=="string"){let l=new URL(a),_=l.hostname,h=s??{},b=`http://${_}.zuplo.svc.cluster.local:9000`,D=new URL(`${b}${l.pathname}${l.search}`),A=new Headers(h.headers||{});return A.set(mft,_),h.headers=A,await EG(D.toString(),h)}else throw new J3("Currently, we only support fetch(<some_string>, ...).")}t(gft,"clusterServiceHandler");async function bor(a,s,l,_){let h=a.toLowerCase(),b=s.toLowerCase(),D=l.toLowerCase(),A=yft(_);fF(`Hashing service name: ${b}-${h}.${b}-${D}-${A}`);let M=await nNe(`${b}-${h}`),z=await nNe(`${b}-${D}-${A}`);return`${M}.${z}`}t(bor,"hashServiceName");async function nNe(a){let s=new TextEncoder().encode(a),l=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(l)).map(b=>b.toString(16).padStart(2,"0")).join("").slice(0,-1)}t(nNe,"hashSegment");function yft(a){let s=a.toLowerCase();switch(s){case"production":case"preview":return s;default:return"working-copy"}}t(yft,"sanitizeEnvironmentType");var iNe=new Map;iNe.set("service:",hft);iNe.set("local:",gft);var EG=globalThis.fetch;function sNe(a,s){let l=Sor(s);if(typeof a=="string"){let _=new URL(a),h=iNe.get(_.protocol);return h?h(a,l):EG(a,l)}else return EG(a,l)}t(sNe,"internalFetch");globalThis.fetch=sNe;var Sor=t(a=>{if(!a||a instanceof Request)return a;let s=a;if(!s.zuplo)return a;let l=a;return l.cf={cacheEverything:s.zuplo?.cacheEverything,cacheTtl:s.zuplo?.cacheTtlSeconds},delete a.zuplo,a},"transformInit");var Tor={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:sNe},CG=Tor;var aNe="2025-02-06",vft=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function bft(){return new F0({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:aNe,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:vft[aNe]},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(bft,"getMockEnvironment");var F0=class a{static{t(this,"Environment")}config;static#r;static#n=!1;static initialize(s){this.#r||(this.#r=new a(s),this.#n=!0)}static get instance(){return this.#n||(CG.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#r=bft()),this.#r}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(mue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let D of Object.keys(b))l[D]||(l[D]=b[D])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){CG.console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,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 zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.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.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}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 xor=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function Sft(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!xor.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):!1}t(Sft,"isRestrictedEnvVariableName");function Tft(a){return!!a.startsWith("ZUPLO_")}t(Tft,"isZuploReadableEnvVariableName");var uFr=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return F0.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return F0.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return F0.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return F0.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return F0.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return F0.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return F0.instance.build.COMPATIBILITY_DATE}if(!(Sft(l)&&!Tft(l)))return F0.instance.runtime[l]}});function DG(a,s,l){return`_${PA(`${a}_${s}_${l}`)}`}t(DG,"getRawOperationDataIdentifierName");function oNe(a,s,l,_){return`_${PA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(oNe,"getIdForParameterSchema");function cNe(a,s,l){return`_${PA(a.toLowerCase())}_${s.toLowerCase()}_rb_${PA(l.toLowerCase())}`}t(cNe,"getIdForRequestBodySchema");function kG(a,s){return`_${PA(a)}_${PA(s)}`}t(kG,"getIdForRefSchema");function PA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s="_"+s),s}t(PA,"sanitizedIdentifierName");var egt=x_(_pt(),1);var JG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},mur=/[$_\p{ID_Start}]/u,hur=/[$_\u200C\u200D\p{ID_Continue}]/u,rIe=".*";function gur(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(gur,"Re");function mpt(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(D){if(!s)throw new TypeError(D);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let D="",A=_+1;for(;A<a.length;){let M=a.substr(A,1);if(A===_+1&&mur.test(M)||A!==_+1&&hur.test(M)){D+=a[A++];continue}break}if(!D){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:D}),_=A;continue}if(h==="("){let D=1,A="",M=_+1,z=!1;if(a[M]==="?"){b(`Pattern cannot start with "?" at ${M}`);continue}for(;M<a.length;){if(!gur(a[M],!1)){b(`Invalid character '${a[M]}' at ${M}.`),z=!0;break}if(a[M]==="\\"){A+=a[M++]+a[M++];continue}if(a[M]===")"){if(D--,D===0){M++;break}}else if(a[M]==="("&&(D++,a[M+1]!=="?")){b(`Capturing groups are not allowed at ${M}`),z=!0;break}A+=a[M++]}if(z)continue;if(D){b(`Unbalanced pattern at ${_}`);continue}if(!A){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:A}),_=M;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(mpt,"v");function hpt(a,s={}){let l=mpt(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${MT(s.delimiter)}]+?`,h=[],b=0,D=0,A="",M=new Set,z=t(fn=>{if(D<l.length&&l[D].type===fn)return l[D++].value},"a"),re=t(()=>z("OTHER_MODIFIER")??z("ASTERISK"),"f"),ie=t(fn=>{let tn=z(fn);if(tn!==void 0)return tn;let{type:cn,index:Er}=l[D];throw new TypeError(`Unexpected ${cn} at ${Er}, expected ${fn}`)},"d"),Q=t(()=>{let fn="",tn;for(;tn=z("CHAR")??z("ESCAPED_CHAR");)fn+=tn;return fn},"T"),Re=t(fn=>fn,"Se"),Ie=s.encodePart||Re,we="",wt=t(fn=>{we+=fn},"U"),xt=t(()=>{we.length&&(h.push(new JG(3,"","",Ie(we),"",3)),we="")},"$"),Tr=t((fn,tn,cn,Er,vr)=>{let fs=3;switch(vr){case"?":fs=1;break;case"*":fs=0;break;case"+":fs=2;break}if(!tn&&!cn&&fs===3){wt(fn);return}if(xt(),!tn&&!cn){if(!fn)return;h.push(new JG(3,"","",Ie(fn),"",fs));return}let Oi;cn?cn==="*"?Oi=rIe:Oi=cn:Oi=_;let Ho=2;Oi===_?(Ho=1,Oi=""):Oi===rIe&&(Ho=0,Oi="");let di;if(tn?di=tn:cn&&(di=b++),M.has(di))throw new TypeError(`Duplicate name '${di}'.`);M.add(di),h.push(new JG(Ho,di,Ie(fn),Oi,Ie(Er),fs))},"V");for(;D<l.length;){let fn=z("CHAR"),tn=z("NAME"),cn=z("REGEX");if(!tn&&!cn&&(cn=z("ASTERISK")),tn||cn){let vr=fn??"";s.prefixes.indexOf(vr)===-1&&(wt(vr),vr=""),xt();let fs=re();Tr(vr,tn,cn,"",fs);continue}let Er=fn??z("ESCAPED_CHAR");if(Er){wt(Er);continue}if(z("OPEN")){let vr=Q(),fs=z("NAME"),Oi=z("REGEX");!fs&&!Oi&&(Oi=z("ASTERISK"));let Ho=Q();ie("CLOSE");let di=re();Tr(vr,fs,Oi,Ho,di);continue}xt(),ie("END")}return h}t(hpt,"D");function MT(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(MT,"S");function ppt(a){return a&&a.ignoreCase?"ui":"u"}t(ppt,"X");function yur(a,s,l){return gpt(hpt(a,l),s,l)}t(yur,"Z");function gj(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(gj,"k");function gpt(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let A of a){if(A.type===3){A.modifier===3?_+=MT(A.value):_+=`(?:${MT(A.value)})${gj(A.modifier)}`;continue}s&&s.push(A.name);let M=`[^${MT(l.delimiter)}]+?`,z=A.value;if(A.type===1?z=M:A.type===0&&(z=rIe),!A.prefix.length&&!A.suffix.length){A.modifier===3||A.modifier===1?_+=`(${z})${gj(A.modifier)}`:_+=`((?:${z})${gj(A.modifier)})`;continue}if(A.modifier===3||A.modifier===1){_+=`(?:${MT(A.prefix)}(${z})${MT(A.suffix)})`,_+=gj(A.modifier);continue}_+=`(?:${MT(A.prefix)}`,_+=`((?:${z})(?:`,_+=MT(A.suffix),_+=MT(A.prefix),_+=`(?:${z}))*)${MT(A.suffix)})`,A.modifier===0&&(_+="?")}let h=`[${MT(l.endsWith)}]|$`,b=`[${MT(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,ppt(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let D=!1;if(a.length){let A=a[a.length-1];A.type===3&&A.modifier===3&&(D=l.delimiter.indexOf(A)>-1)}return D||(_+=`(?=${b}|${h})`),new RegExp(_,ppt(l))}t(gpt,"F");var H3={delimiter:"",prefixes:"",sensitive:!0,strict:!0},vur={delimiter:".",prefixes:"",sensitive:!0,strict:!0},bur={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Sur(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(Sur,"J");function ypt(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(ypt,"Q");function Tur(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(Tur,"Ee");function vpt(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(vpt,"W");var bpt=["ftp","file","http","https","ws","wss"];function Spt(a){if(!a)return!0;for(let s of bpt)if(a.test(s))return!0;return!1}t(Spt,"N");function xur(a,s){if(a=ypt(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t(xur,"te");function Eur(a,s){if(a=ypt(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(Eur,"re");function Cur(a,s){return s||a===""?a:vpt(a)?Ept(a):xpt(a)}t(Cur,"ne");function Dur(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(Dur,"se");function kur(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(kur,"ie");function wur(a,s,l){if(l||a==="")return a;if(s&&!bpt.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(wur,"ae");function Pur(a,s,l){return Tpt(s)===a&&(a=""),l||a===""?a:Cpt(a)}t(Pur,"oe");function Aur(a,s){return a=Tur(a,":"),s||a===""?a:nIe(a)}t(Aur,"ce");function Tpt(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(Tpt,"_");function nIe(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(nIe,"y");function Nur(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(Nur,"le");function Iur(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Iur,"fe");function xpt(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(xpt,"z");function Ept(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(Ept,"j");function Cpt(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(Cpt,"K");function Our(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(Our,"he");function Fur(a){return a===""?a:new URL(`data:${a}`).pathname}t(Fur,"ue");function Lur(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(Lur,"de");function Rur(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(Rur,"pe");var Mur=class{static{t(this,"H")}#r;#n=[];#e={};#t=0;#s=1;#p=0;#a=0;#_=0;#c=0;#l=!1;constructor(a){this.#r=a}get result(){return this.#e}parse(){for(this.#n=mpt(this.#r,!0);this.#t<this.#n.length;this.#t+=this.#s){if(this.#s=1,this.#n[this.#t].type==="END"){if(this.#a===0){this.#v(),this.#D()?this.#i(9,1):this.#y()?this.#i(8,1):this.#i(7,0);continue}else if(this.#a===2){this.#d(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#o())this.#_-=1;else continue;if(this.#w()){this.#_+=1;continue}switch(this.#a){case 0:this.#g()&&this.#d(1);break;case 1:if(this.#g()){this.#I();let a=7,s=1;this.#C()?(a=2,s=3):this.#l&&(a=2),this.#i(a,s)}break;case 2:this.#x()?this.#d(3):(this.#E()||this.#y()||this.#D())&&this.#d(5);break;case 3:this.#b()?this.#i(4,1):this.#x()&&this.#i(5,1);break;case 4:this.#x()&&this.#i(5,1);break;case 5:this.#N()?this.#c+=1:this.#S()&&(this.#c-=1),this.#k()&&!this.#c?this.#i(6,1):this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 6:this.#E()?this.#i(7,0):this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 7:this.#y()?this.#i(8,1):this.#D()&&this.#i(9,1);break;case 8:this.#D()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#e.hostname!==void 0&&this.#e.port===void 0&&(this.#e.port="")}#i(a,s){switch(this.#a){case 0:break;case 1:this.#e.protocol=this.#T();break;case 2:break;case 3:this.#e.username=this.#T();break;case 4:this.#e.password=this.#T();break;case 5:this.#e.hostname=this.#T();break;case 6:this.#e.port=this.#T();break;case 7:this.#e.pathname=this.#T();break;case 8:this.#e.search=this.#T();break;case 9:this.#e.hash=this.#T();break;case 10:break}this.#a!==0&&a!==10&&([1,2,3,4].includes(this.#a)&&[6,7,8,9].includes(a)&&(this.#e.hostname??=""),[1,2,3,4,5,6].includes(this.#a)&&[8,9].includes(a)&&(this.#e.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#a)&&a===9&&(this.#e.search??="")),this.#f(a,s)}#f(a,s){this.#a=a,this.#p=this.#t+s,this.#t+=s,this.#s=0}#v(){this.#t=this.#p,this.#s=0}#d(a){this.#v(),this.#a=a}#u(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#m(a,s){let l=this.#u(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#m(this.#t,":")}#C(){return this.#m(this.#t+1,"/")&&this.#m(this.#t+2,"/")}#x(){return this.#m(this.#t,"@")}#b(){return this.#m(this.#t,":")}#k(){return this.#m(this.#t,":")}#E(){return this.#m(this.#t,"/")}#y(){if(this.#m(this.#t,"?"))return!0;if(this.#n[this.#t].value!=="?")return!1;let a=this.#u(this.#t-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#D(){return this.#m(this.#t,"#")}#w(){return this.#n[this.#t].type=="OPEN"}#o(){return this.#n[this.#t].type=="CLOSE"}#N(){return this.#m(this.#t,"[")}#S(){return this.#m(this.#t,"]")}#T(){let a=this.#n[this.#t],s=this.#u(this.#p).index;return this.#r.substring(s,a.index)}#I(){let a={};Object.assign(a,H3),a.encodePart=nIe;let s=yur(this.#T(),void 0,a);this.#l=Spt(s)}},tIe=["protocol","username","password","hostname","port","pathname","search","hash"],W3="*";function dpt(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(dpt,"ge");function FA(a,s){return s?zG(a):a}t(FA,"b");function $G(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=FA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=FA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=FA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=FA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=FA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=FA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=FA(_.search.substring(1,_.search.length),l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=FA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Aur(s.protocol,l)),typeof s.username=="string"&&(a.username=kur(s.username,l)),typeof s.password=="string"&&(a.password=Dur(s.password,l)),typeof s.hostname=="string"&&(a.hostname=Cur(s.hostname,l)),typeof s.port=="string"&&(a.port=Pur(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!Sur(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=FA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=wur(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=Eur(s.search,l)),typeof s.hash=="string"&&(a.hash=xur(s.hash,l)),a}t($G,"w");function zG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(zG,"C");function jur(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(jur,"Oe");function Bur(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${jur(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let D=0;D<a.length;++D){let A=a[D];if(A.type===3){if(A.modifier===3){b+=zG(A.value);continue}b+=`{${zG(A.value)}}${gj(A.modifier)}`;continue}let M=A.hasCustomName(),z=!!A.suffix.length||!!A.prefix.length&&(A.prefix.length!==1||!s.prefixes.includes(A.prefix)),re=D>0?a[D-1]:null,ie=D<a.length-1?a[D+1]:null;if(!z&&M&&A.type===1&&A.modifier===3&&ie&&!ie.prefix.length&&!ie.suffix.length)if(ie.type===3){let Q=ie.value.length>0?ie.value[0]:"";z=h.test(Q)}else z=!ie.hasCustomName();if(!z&&!A.prefix.length&&re&&re.type===3){let Q=re.value[re.value.length-1];z=s.prefixes.includes(Q)}z&&(b+="{"),b+=zG(A.prefix),M&&(b+=`:${A.name}`),A.type===2?b+=`(${A.value})`:A.type===1?M||(b+=`(${_})`):A.type===0&&(!M&&(!re||re.type===3||re.modifier!==3||z||A.prefix!=="")?b+="*":b+=`(${l})`),A.type===1&&M&&A.suffix.length&&h.test(A.suffix[0])&&(b+="\\"),b+=zG(A.suffix),z&&(b+="}"),A.modifier!==3&&(b+=gj(A.modifier))}return b}t(Bur,"ke");var Dpt=class{static{t(this,"me")}#r;#n={};#e={};#t={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let A=new Mur(a);if(A.parse(),a=A.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:W3,protocol:W3,username:W3,password:W3,hostname:W3,port:W3,search:W3,hash:W3};this.#r=$G(b,a,!0),Tpt(this.#r.protocol)===this.#r.port&&(this.#r.port="");let D;for(D of tIe){if(!(D in this.#r))continue;let A={},M=this.#r[D];switch(this.#e[D]=[],D){case"protocol":Object.assign(A,H3),A.encodePart=nIe;break;case"username":Object.assign(A,H3),A.encodePart=Nur;break;case"password":Object.assign(A,H3),A.encodePart=Iur;break;case"hostname":Object.assign(A,vur),vpt(M)?A.encodePart=Ept:A.encodePart=xpt;break;case"port":Object.assign(A,H3),A.encodePart=Cpt;break;case"pathname":Spt(this.#n.protocol)?(Object.assign(A,bur,h),A.encodePart=Our):(Object.assign(A,H3,h),A.encodePart=Fur);break;case"search":Object.assign(A,H3,h),A.encodePart=Lur;break;case"hash":Object.assign(A,H3,h),A.encodePart=Rur;break}try{this.#s[D]=hpt(M,A),this.#n[D]=gpt(this.#s[D],this.#e[D],A),this.#t[D]=Bur(this.#s[D],A),this.#p=this.#p||this.#s[D].some(z=>z.type===2)}catch{throw new TypeError(`invalid ${D} pattern '${this.#r[D]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?l=$G(l,a,!1):l=$G(l,dpt(a,s),!1)}catch{return!1}let _;for(_ of tIe)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?l=$G(l,a,!1):l=$G(l,dpt(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of tIe){let b=this.#n[h].exec(l[h]);if(!b)return null;let D={};for(let[A,M]of this.#e[h].entries())if(typeof M=="string"||typeof M=="number"){let z=b[A+1];D[M]=z}_[h]={input:l[h]??"",groups:D}}return _}static compareComponent(a,s,l){let _=t((A,M)=>{for(let z of["type","modifier","prefix","value","suffix"]){if(A[z]<M[z])return-1;if(A[z]!==M[z])return 1}return 0},"o"),h=new JG(3,"","","","",3),b=new JG(0,"","","","",3),D=t((A,M)=>{let z=0;for(;z<Math.min(A.length,M.length);++z){let re=_(A[z],M[z]);if(re)return re}return A.length===M.length?0:_(A[z]??h,M[z]??h)},"s");return!s.#t[a]&&!l.#t[a]?0:s.#t[a]&&!l.#t[a]?D(s.#s[a],[b]):!s.#t[a]&&l.#t[a]?D([b],l.#s[a]):D(s.#s[a],l.#s[a])}get protocol(){return this.#t.protocol}get username(){return this.#t.username}get password(){return this.#t.password}get hostname(){return this.#t.hostname}get port(){return this.#t.port}get pathname(){return this.#t.pathname}get search(){return this.#t.search}get hash(){return this.#t.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=Dpt);import{AssertionError as Uur}from"node:assert";function LA(a,s){if(a===!1)throw new Uur({message:s})}t(LA,"assert");var ec;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(ec||(ec={}));function yj(a){return a.type===ec.Object}t(yj,"isAstObject");function RA(a){return a.type===ec.Property}t(RA,"isAstProperty");function kpt(a){return a.type===ec.Array}t(kpt,"isAstArray");function vj(a){return a.type===ec.Literal}t(vj,"isAstLiteral");function G3(a){if(a===void 0)throw new Error("Node is undefined");if(!yj(a))throw new Error("Node is not object")}t(G3,"assertAstObject");import{findNodeAtLocation as $ur,getNodeValue as zur,printParseErrorCode as Jur,visit as qur}from"jsonc-parser";var Vur={DEFAULT:{allowTrailingComma:!1}};function qG(a,s=[],l=Vur.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(M){_.type==="property"&&(_.length=M-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(M){return _.children?.push(M),M}t(b,"onValue"),qur(a,{onObjectBegin:t((M,z,re)=>{_=b({type:"object",offset:M,length:-1,line:z+1,column:re+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((M,z,re,ie,Q)=>{_=b({type:"property",offset:z,length:-1,line:ie+1,column:Q+1,parent:_,children:[]}),_.children?.push({type:"string",value:M,offset:z,length:re,line:ie,column:Q,parent:_})},"onObjectProperty"),onObjectEnd:t((M,z)=>{h(M+z),_.length=M+z-_.offset,_=_.parent,h(M+z)},"onObjectEnd"),onArrayBegin:t((M,z,re,ie)=>{_=b({type:"array",offset:M,length:-1,line:re+1,column:ie+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((M,z)=>{_.length=M+z-_.offset,_=_.parent,h(M+z)},"onArrayEnd"),onLiteralValue:t((M,z,re,ie,Q)=>{b({type:Wur(M),offset:z,length:re,line:ie+1,column:Q+1,parent:_,value:M}),h(z+re)},"onLiteralValue"),onSeparator:t((M,z)=>{_.type==="property"&&(M===":"?_.colonOffset=z:M===","&&h(z))},"onSeparator"),onError:t((M,z,re,ie,Q)=>{s.push({error:M,offset:z,length:re,line:ie+1,column:Q+1})},"onError")},l);let A=_.children[0];return A&&delete A.parent,A}t(qG,"parse");function Wur(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(Wur,"getNodeType");function iIe(a,s){return $ur(a,s)}t(iIe,"findNodeAtLocation");function VG(a){return zur(a)}t(VG,"getNodeValue");function wpt(a){return Jur(a)}t(wpt,"printParseErrorCode");var WG=class{static{t(this,"AstAdapter")}parse(s){let _=qG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:ec.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:ec.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){LA(s.children?.length===2,"Invalid property node");let _={type:ec.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:ec.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:ec.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var jT={createLiteral:t((a,s)=>({type:ec.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:ec.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:ec.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:ec.Property,parent:l,name:null,value:s};return _.name={value:a,type:ec.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:ec.Array,parent:s,children:[]};for(let _ of a)l.children.push(jT.createLiteral(_,l));return l},"createArrayOfLiterals")};var Hur=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,HG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case ec.Array:return this.generateArray(s,l);case ec.Object:return this.generateObject(s,l);case ec.Property:return this.generateProperty(s,l);case ec.Literal:return this.generateLiteral(s,l);case ec.FunctionCall:return this.generateFunctionCall(s,l);case ec.Identifier:return this.generateIdentifier(s,l);case ec.Raw:return this.generateRaw(s,l);case ec.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=Hur.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import Gur from"node:fs/promises";import{parse as Kur}from"@swc/core";var Ppt=t(async a=>{let s=new Set;try{let l=await Gur.readFile(a,"utf-8");(await Kur(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var Apt={$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 sIe={$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 Npt={$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 aIe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var oIe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var qht=x_(pht(),1),Vht=x_(Jht(),1);var Lfe=class a{static{t(this,"JsonValidator")}static#r=new a;static get instance(){return a.#r}ajv;constructor(){this.ajv=new Vht.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,qht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},D=h.instancePath.split("/");if(D.length>2){let M=D[1],z=D[2]?parseInt(D[2]):0,re=D[3],ie=isNaN(z)?void 0:l[M][z][re];b={details:{property:M,index:z,field:re,fieldValue:ie}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let M=h.instancePath.split("/"),z=M[M.length-1];h.message=`Value of property '${z}' must be '${h.params.type}'`}let A=Object.assign(h,b);_.push(A)}),_}};var iN=Lfe.instance;iN.addSchema(oIe,"route-configuration.schema.json");iN.addSchema(Npt,"policy-configuration.schema.json");iN.addSchema(sIe,"policies.schema.json");iN.addSchema(aIe,"open-api-route-configuration.schema.json");iN.addSchema(Apt,"fragments.schema.json");var lRr=iN.compile(oIe),Wht=iN.compile(aIe),TOe=iN.compile(sIe);var Rfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=TOe(s),this.results}};var Mfe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Wht(s),this.results}};import r0r from"node:path";var xOe=/\$import\((.*)\)/,jfe=/\$env\((.*?)\)/g;var $A=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},t0r=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),sN=t((a,s)=>{if(!a)return!1;let l=t0r(a);return s.split("/").every((b,D)=>{let A=l[D];return A?b==="*"||RA(A)&&A.name.value===b?!0:b==="{}"?A.type===ec.Object:b==="[]"?A.type===ec.Array:!1:!1})},"testPosition");var Bfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),yj(s)?s.children.forEach(l=>{this.visitor(l)}):kpt(s)?s.children.forEach(l=>{this.visitor(l)}):RA(s)&&this.visitor(s.value)}},Hht=t((a,s,l)=>_=>{if(!RA(_)||!vj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>sN(_,b))){jfe.test(_.value.value)&&s.push(new $A("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(jfe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:ec.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(jfe),(D,A)=>`\${environment["${A}"] ? environment["${A}"] : ""}`);b!==_.value.value&&(_.value=jT.createTemplateString(b,_))}},"getEnvStatementTransformer");var DK="config/routes.json",n0r=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],i0r=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Ght=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],s0r="handler/{}/options/{}/rewritePattern",a0r="handler/{}/options/{}/baseUrl",Ufe=class extends Bfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!RA(s)||!vj(s.value)||typeof s.value.value!="string")&&sN(s,s0r)){if(!s.parent||!yj(s.parent)){this.errors.push(new $A("Invalid node, expected object",DK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:Kht(l)},h=jT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!RA(s)||!vj(s.value)||typeof s.value.value!="string")&&sN(s,a0r)){if(!s.parent||!yj(s.parent)){this.errors.push(new $A("Invalid node, expected object",DK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:ec.Raw,parent:null,value:Kht(l)},h=jT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!RA(s)||!vj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!i0r.some(A=>sN(s,A))&&!Ght.some(A=>sN(s,A))){if(xOe.test(l)){if(s.name.value==="$ref")return;this.errors.push(new $A("An $import() statement is not expected at this location.",DK,s.location,l))}return}let _=xOe.exec(l);if(Ght.some(A=>sN(s,A))&&!_)return;if(!_){this.errors.push(new $A("Invalid $import() statement",DK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=r0r.posix.join("..",h));let b=this.getImportName(h),D={type:ec.Identifier,parent:s.parent,value:b};s.value=D}replaceEnvStatements=Hht(n0r,this.errors,DK)};function Kht(a){return`(request, context) => {
|
|
584
584
|
const { params, url, query, method, headers } = request;
|
|
585
585
|
const { host, hostname, origin, pathname, port, search } = new URL(url);
|
|
586
586
|
const e = encodeURIComponent;
|
|
@@ -651,11 +651,11 @@ export default {
|
|
|
651
651
|
},
|
|
652
652
|
};
|
|
653
653
|
`,gvt=t(async function({systemDirectory:a,logger:s}){return Uu.timeFn("Generating Worker shim",async()=>{s.debug("Generating Worker shim");let l=wxr.join(a,_le);try{await kxr.writeFile(l,Pxr,"utf-8")}catch(_){s.error(_);let h={message:`Error creating file at ${l}`,pluginName:"generate-worker-entry",severity:"error"};return{warnings:[],errors:[h]}}return{warnings:[],errors:[]}})},"generateWorker");import{readFile as Axr,readdir as Nxr}from"node:fs/promises";import yvt from"node:path";var O_e="validate-open-api-files",vvt=t(async function({sourceDirectory:a,logger:s}){return Uu.timeFn("Validating OpenAPI files",async()=>{s.debug("Validating OpenAPI files");let l=yvt.join(a,jy),_=[];try{if(!await qM(a))return new XT({message:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:O_e,severity:"error"});let D=(await Nxr(l)).filter(M=>M.endsWith(".oas.json")),A=t(async M=>{let z=yvt.join(l,M);try{M==="zp.oas.json"&&_.push({message:"Open API files cannot be named 'zp.oas.json' since 'zp' is a reserved prefix. Update the file name to solve this build issue.",pluginName:O_e,severity:"error"});let re=await Axr(z,"utf-8"),ie=JSON.parse(re);if(ie&&ie.paths){let Q=Object.entries(ie.paths).filter(Re=>Re[0]==="zp"||Re[0]==="/zp");if(Q.length>0){let Re=Q.length===1?"includes one route path":`includes '${Q.length}' routes`;_.push({message:`Open API file '${M}' ${Re} that's named '/zp' which is a reserved route name. Updating the route to something other than '/zp' will solve this build issue.`,pluginName:O_e,severity:"error"})}}}catch(re){s.error(re)}},"validateOpenApiFile");await Promise.all(D.map(A))}catch(h){return s.error(h),_.length>0?{errors:_,warnings:[]}:new XT({message:"Failed while validating the open api files in the project",pluginName:O_e,severity:"warning"})}return{errors:_,warnings:[]}})},"validateOpenAPIFiles");import{readFile as Xxr,writeFile as Bvt}from"node:fs/promises";import Qxr from"node:path";var pB=x_(h5e(),1);import{parse as Zxr}from"jsonc-parser";var _B=x_(h5e(),1);var jvt=t(()=>({include:["modules/**/*",".zuplo/**/*","tests/**/*"],exclude:["./node_modules","./dist"],compilerOptions:{module:_B.ModuleKind.ESNext,target:_B.ScriptTarget.ES2022,moduleResolution:_B.ModuleResolutionKind.Bundler,lib:["ESNext","WebWorker","Webworker.Iterable"],preserveConstEnums:!0,useUnknownInCatchVariables:!1,forceConsistentCasingInFileNames:!0,importHelpers:!0,esModuleInterop:!0,strictNullChecks:!0,noEmit:!0}}),"getZuploTsConfigTemplate");var qF="validate-tsconfig",Uvt=t(async function({sourceDirectory:a,logger:s,command:l,environmentType:_}){return Uu.timeFn("Validate TSConfig",async()=>{s.debug("Validate TSConfig");let h=_==="WORKING_COPY"||l==="dev";try{let b=jvt(),D=Qxr.join(a,"tsconfig.json");if(!await ou.fileExists(D))return h?(await Bvt(D,JSON.stringify(b,null,2)),{warnings:[{message:"This project does not have a tsconfig.json file. The file has been created for you.",severity:"warning",pluginName:qF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project does not have a tsconfig.json file.",severity:"error",pluginName:qF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let A=await Xxr(D,"utf-8"),M=Zxr(A);if(!(M&&typeof M=="object"&&"compilerOptions"in M))return h?(await Bvt(D,JSON.stringify(b,null,2)),{warnings:[{message:"This project's tsconfig.json file was invalid. A valid file has been written for you.",severity:"warning",pluginName:qF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project's tsconfig.json file is invalid. It must have a compilerOptions.",severity:"error",pluginName:qF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let z=pB.default.convertCompilerOptionsFromJson(M.compilerOptions,a);if(z.errors.length>0)return{warnings:[],errors:z.errors.map(cn=>({severity:"error",pluginName:qF,message:cn.messageText.toString(),detail:"You will need to modify your tsconfig.json file to build this project.",helpUrl:"https://zuplo.com/docs/articles/tsconfig",location:cn.file?{line:cn.file.getLineStarts()[0],length:cn.file.getWidth(),file:cn.file.fileName,column:cn.file.getStart(),lineText:"",namespace:"",suggestion:""}:void 0}))};if(!M||typeof M!="object")throw new TypeError("The userConfigRaw is not an object, this should not happen.");if(!("compilerOptions"in M)||M.compilerOptions===null||M.compilerOptions===void 0||typeof M.compilerOptions!="object")throw new TypeError("The userConfigRaw.compilerOptions property is not an object, this should not happen.");let re=t((cn,Er,vr)=>`The compiler option '${cn}' should ${Er===void 0?"not be set":`be set to '${typeof Er=="string"?Er:JSON.stringify(Er)}'`}, it was ${vr===void 0?"not set":`set to '${typeof vr=="string"?vr:JSON.stringify(vr)}'`}`,"getMessage"),ie="ESNext",Q=pB.ModuleKind.ESNext,Re=[];z.options.module!==Q&&Re.push(re("module",ie,M.compilerOptions.module));let Ie="ES2022",we=pB.default.ScriptTarget.ES2022;z.options.target!==we&&Re.push(re("target",Ie,M.compilerOptions.target));let wt="Bundler",xt=pB.default.ModuleResolutionKind.Bundler;z.options.moduleResolution!==xt&&Re.push(re("moduleResolution",wt,M.compilerOptions.moduleResolution));let Tr=["ESNext","WebWorker","Webworker.Iterable"];t(cn=>{let Er=Tr.map(fs=>fs.toLowerCase()),vr=cn.map(fs=>fs.toLowerCase());return Er.every(fs=>vr.includes(fs))},"includesAllLibs")(M.compilerOptions.lib??[])||Re.push(re("lib",Tr,M.compilerOptions.lib)),z.options.baseUrl&&Re.push(re("baseUrl",void 0,M.compilerOptions.baseUrl));let tn=[];return Re.length>0&&tn.push({message:"This project's tsconfig.json was not set to the recommended settings. Custom settings may cause build issues. For guidance on how to adjust your settings, please visit: https://zuplo.com/docs/articles/tsconfig",severity:"warning",detail:Re.join(`
|
|
654
|
-
`),pluginName:qF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}),{warnings:tn,errors:[]}}catch(b){s.error(b);let D={message:`Error validating tsconfig.json : ${b.message}`,severity:"error",pluginName:qF};return{warnings:[],errors:[D]}}})},"validateTSConfig");var dB;try{let a=eEr(new URL("../../package.json",import.meta.url),"utf-8");dB=JSON.parse(a).version}catch{dB="0.0.0"}function tEr(a){let{ZUPLO:s,ZUPLO_BUILD_ID:l,ZUPLO_BUILD_CONFIG:_}=process.env;if(s&&l&&_){let h;try{h=JSON.parse(_)}catch{throw new Error("Couuld not parse ZUPLO_BUILD_CONFIG")}let b={ZUPLO_PROJECT_ID:h.projectId,ZUPLO_ACCOUNT_NAME:h.accountName,ZUPLO_PROJECT_NAME:h.projectName,ZUPLO_ENVIRONMENT_TYPE:h.environmentType};for(let[D,A]of Object.entries(process.env))D.startsWith("ZUPLO_PUBLIC_")&&(b[D]=A??"");return{...a,buildId:l,...h,publicZuploEnvironmentVariables:b}}return a}t(tEr,"getBuildConfig");async function g5e(a){let s=performance.now(),{buildId:l,sourceDirectory:_,deploymentName:h=M_e.basename(_),command:b,minify:D,entitlements:A,environmentType:M,logger:z,output:re,noCompile:ie=!1,projectId:Q,urls:Re,publicZuploEnvironmentVariables:Ie}=tEr(a),we=await uB(_),wt=M_e.join(_,YO),xt;if("errors"in we)t5e({output:re.child("api"),buildId:l,runtimeVersion:dB}),xt={status:"Failed",flags:void 0,compatibilityDate:void 0,runtimeVersion:dB,outputPath:wt,buildTime:new Date().toISOString(),buildTimeMs:0,buildId:l,warnings:[],errors:we.errors,metafile:void 0};else{ie||t5e({output:re.child("api"),buildId:l,runtimeVersion:dB,compatibilityDate:we.config.compatibilityDate});let tn={command:b,minify:D,deploymentName:h,sourceDirectory:_,outputDirectory:wt,systemDirectory:M_e.join(_,zg),cacheDirectory:M_e.join(_,"node_modules",zg),buildId:l,logger:z,output:re,config:we.config,publicZuploEnvironmentVariables:Ie,projectId:Q,entitlements:A,environmentType:M,urls:Re},cn=[];cn.push(_vt),cn.push(dvt),cn.push(mvt),cn.push(hvt),cn.push(Uvt),cn.push(vvt),cn.push(gvt),ie||cn.push(nvt),cn.push(fvt);let Er=await cvt(cn,tn),vr=Er.errors.length>0?KO:Er.warnings.length>0?W6e:bA,fs=Er.data.get("metafile");xt={status:vr,compatibilityDate:we.config.compatibilityDate,runtimeVersion:dB,outputPath:wt,buildTime:new Date().toISOString(),buildTimeMs:0,metafile:fs,buildId:l,warnings:Er.warnings,errors:Er.errors,flags:we.config.flags}}xt.warnings.length>0&&xt.warnings.forEach(tn=>{z.warn(tn)}),xt.errors.length>0&&xt.errors.forEach(tn=>{z.error(tn)});let{metafile:Tr,...fn}=xt;if(z.debug(fn,"Compiler completed"),xt.buildTimeMs=performance.now()-s,ie||await I_e(_,re.child("api"),xt),process.env.ZUPLO_SHOW_PERF){console.log();let tn=xt.buildTimeMs<2e3?"green":xt.buildTimeMs<5e3?"yellow":"red";console.log(Jf[tn](`Build time: ${xt.buildTimeMs.toFixed(0)}ms`)),Uu.report()}return Uu.clear(),xt}t(g5e,"build");import{randomUUID as $vt}from"node:crypto";import rEr from"node:events";import mB from"node:path";import nEr from"chokidar";import*as zvt from"esbuild";var y5e=class extends rEr{static{t(this,"WatchEmitter")}},WA=class{static{t(this,"BuildWatcher")}esbuildContext;emitter=new y5e;envFilesWatcher;outputDirectory;sourceDirectory;command;logger;publicZuploEnvironmentVariables;projectName;buildId;output;constructor({sourceDirectory:s,command:l,logger:_,publicZuploEnvironmentVariables:h={},buildId:b,output:D}){this.sourceDirectory=s,this.command=l,this.outputDirectory=mB.join(s,YO),this.logger=_,this.publicZuploEnvironmentVariables=h,this.projectName=mB.basename(s),this.buildId=b,this.output=D,this.envFilesWatcher=nEr.watch([mB.join(s,".env"),mB.join(s,".env.zuplo")])}watchEnvFiles(){this.envFilesWatcher.on("change",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("add",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("unlink",()=>{this.emitter.emit("reload",null,null)})}onReload=t(s=>{this.emitter.on("reload",s)},"onReload");async start(){let{sourceDirectory:s}=this;if(this.esbuildContext!==void 0)throw new Error("Watcher cannot be started more than once");let l=await g5e({buildId:this.buildId,output:this.output,sourceDirectory:s,noCompile:!0,command:this.command,publicZuploEnvironmentVariables:this.publicZuploEnvironmentVariables,logger:this.logger,urls:
|
|
654
|
+
`),pluginName:qF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}),{warnings:tn,errors:[]}}catch(b){s.error(b);let D={message:`Error validating tsconfig.json : ${b.message}`,severity:"error",pluginName:qF};return{warnings:[],errors:[D]}}})},"validateTSConfig");var dB;try{let a=eEr(new URL("../../package.json",import.meta.url),"utf-8");dB=JSON.parse(a).version}catch{dB="0.0.0"}function tEr(a){let{ZUPLO:s,ZUPLO_BUILD_ID:l,ZUPLO_BUILD_CONFIG:_}=process.env;if(s&&l&&_){let h;try{h=JSON.parse(_)}catch{throw new Error("Couuld not parse ZUPLO_BUILD_CONFIG")}let b={ZUPLO_PROJECT_ID:h.projectId,ZUPLO_ACCOUNT_NAME:h.accountName,ZUPLO_PROJECT_NAME:h.projectName,ZUPLO_ENVIRONMENT_TYPE:h.environmentType};for(let[D,A]of Object.entries(process.env))D.startsWith("ZUPLO_PUBLIC_")&&(b[D]=A??"");return{...a,buildId:l,...h,publicZuploEnvironmentVariables:b}}return a}t(tEr,"getBuildConfig");async function g5e(a){let s=performance.now(),{buildId:l,sourceDirectory:_,deploymentName:h=M_e.basename(_),command:b,minify:D,entitlements:A,environmentType:M,logger:z,output:re,noCompile:ie=!1,projectId:Q,urls:Re,publicZuploEnvironmentVariables:Ie}=tEr(a),we=await uB(_),wt=M_e.join(_,YO),xt;if("errors"in we)t5e({output:re.child("api"),buildId:l,runtimeVersion:dB}),xt={status:"Failed",flags:void 0,compatibilityDate:void 0,runtimeVersion:dB,outputPath:wt,buildTime:new Date().toISOString(),buildTimeMs:0,buildId:l,warnings:[],errors:we.errors,metafile:void 0};else{ie||t5e({output:re.child("api"),buildId:l,runtimeVersion:dB,compatibilityDate:we.config.compatibilityDate});let tn={command:b,minify:D,deploymentName:h,sourceDirectory:_,outputDirectory:wt,systemDirectory:M_e.join(_,zg),cacheDirectory:M_e.join(_,"node_modules",zg),buildId:l,logger:z,output:re,config:we.config,publicZuploEnvironmentVariables:Ie,projectId:Q,entitlements:A,environmentType:M,urls:Re},cn=[];cn.push(_vt),cn.push(dvt),cn.push(mvt),cn.push(hvt),cn.push(Uvt),cn.push(vvt),cn.push(gvt),ie||cn.push(nvt),cn.push(fvt);let Er=await cvt(cn,tn),vr=Er.errors.length>0?KO:Er.warnings.length>0?W6e:bA,fs=Er.data.get("metafile");xt={status:vr,compatibilityDate:we.config.compatibilityDate,runtimeVersion:dB,outputPath:wt,buildTime:new Date().toISOString(),buildTimeMs:0,metafile:fs,buildId:l,warnings:Er.warnings,errors:Er.errors,flags:we.config.flags}}xt.warnings.length>0&&xt.warnings.forEach(tn=>{z.warn(tn)}),xt.errors.length>0&&xt.errors.forEach(tn=>{z.error(tn)});let{metafile:Tr,...fn}=xt;if(z.debug(fn,"Compiler completed"),xt.buildTimeMs=performance.now()-s,ie||await I_e(_,re.child("api"),xt),process.env.ZUPLO_SHOW_PERF){console.log();let tn=xt.buildTimeMs<2e3?"green":xt.buildTimeMs<5e3?"yellow":"red";console.log(Jf[tn](`Build time: ${xt.buildTimeMs.toFixed(0)}ms`)),Uu.report()}return Uu.clear(),xt}t(g5e,"build");import{randomUUID as $vt}from"node:crypto";import rEr from"node:events";import mB from"node:path";import nEr from"chokidar";import*as zvt from"esbuild";var y5e=class extends rEr{static{t(this,"WatchEmitter")}},WA=class{static{t(this,"BuildWatcher")}esbuildContext;emitter=new y5e;envFilesWatcher;outputDirectory;sourceDirectory;command;logger;publicZuploEnvironmentVariables;projectName;buildId;output;urls;constructor({sourceDirectory:s,command:l,logger:_,publicZuploEnvironmentVariables:h={},buildId:b,output:D,urls:A}){this.sourceDirectory=s,this.command=l,this.outputDirectory=mB.join(s,YO),this.logger=_,this.publicZuploEnvironmentVariables=h,this.projectName=mB.basename(s),this.buildId=b,this.output=D,this.urls=A,this.envFilesWatcher=nEr.watch([mB.join(s,".env"),mB.join(s,".env.zuplo")])}watchEnvFiles(){this.envFilesWatcher.on("change",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("add",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("unlink",()=>{this.emitter.emit("reload",null,null)})}onReload=t(s=>{this.emitter.on("reload",s)},"onReload");async start(){let{sourceDirectory:s}=this;if(this.esbuildContext!==void 0)throw new Error("Watcher cannot be started more than once");let l=await g5e({buildId:this.buildId,output:this.output,sourceDirectory:s,noCompile:!0,command:this.command,publicZuploEnvironmentVariables:this.publicZuploEnvironmentVariables,logger:this.logger,urls:this.urls}),_=await uY({command:this.command,systemDirectory:mB.join(s,zg),cacheDirectory:mB.join(s,"node_modules",zg),outputDirectory:this.outputDirectory,sourceDirectory:s,config:{compatibilityDate:l.compatibilityDate,flags:l.flags??{}},logger:this.logger,urls:this.urls}),h=this;_.plugins?.push({name:"on-end",setup(b){b.onEnd(D=>{h.logger.debug("Watcher (build) reloaded");let A=Z7e({buildId:$vt(),result:D});A.errors.length>0?h.logger.error(A.errors,"Build errors"):h.logger.debug(`Successfully rebuilt watched project. Build id ${A.buildId}`);let M={...A,compatibilityDate:l.compatibilityDate,flags:l.flags};h.emitter.emit("reload",M,null)})}}),this.esbuildContext=await zvt.context(_);try{if((await this.esbuildContext.rebuild()).errors.length>0){let D={status:"Failed",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:$vt(),warnings:[],errors:[],metafile:void 0};await I_e(s,h.output.child("api"),D),this.logger.error(D.errors,"Build errors")}}catch(b){throw await this.close(),b}await this.esbuildContext.watch()}async close(){try{await this.envFilesWatcher.close(),this.esbuildContext&&(await this.esbuildContext.dispose(),this.logger.debug("ESBuild watcher closed"))}catch(s){this.logger.error(s)}}};import{existsSync as yAr}from"node:fs";import{mkdir as vAr,readFile as bAr}from"node:fs/promises";import AY from"node:path";var Rxt=x_(P9e(),1);import{existsSync as Fxt,readFileSync as Lxt}from"node:fs";import Sde from"node:path";var Q9e=x_(V6e(),1);var Ixt=x_(KTt(),1);import{Buffer as _Ar}from"node:buffer";import pAr from"node:path";import Nxt from"node:child_process";import bde from"node:process";function B9e(a){let s=typeof a=="string"?`
|
|
655
655
|
`:10,l=typeof a=="string"?"\r":13;return a[a.length-1]===s&&(a=a.slice(0,-1)),a[a.length-1]===l&&(a=a.slice(0,-1)),a}t(B9e,"stripFinalNewline");import _de from"node:process";import kY from"node:path";import{fileURLToPath as YTt}from"node:url";function fde(a={}){let{env:s=process.env,platform:l=process.platform}=a;return l!=="win32"?"PATH":Object.keys(s).reverse().find(_=>_.toUpperCase()==="PATH")||"Path"}t(fde,"pathKey");var DPr=t(({cwd:a=_de.cwd(),path:s=_de.env[fde()],preferLocal:l=!0,execPath:_=_de.execPath,addExecPath:h=!0}={})=>{let b=a instanceof URL?YTt(a):a,D=kY.resolve(b),A=[];return l&&kPr(A,D),h&&wPr(A,_,D),[...A,s].join(kY.delimiter)},"npmRunPath"),kPr=t((a,s)=>{let l;for(;l!==s;)a.push(kY.join(s,"node_modules/.bin")),l=s,s=kY.resolve(s,"..")},"applyPreferLocal"),wPr=t((a,s,l)=>{let _=s instanceof URL?YTt(s):s;a.push(kY.resolve(l,_,".."))},"applyExecPath"),XTt=t(({env:a=_de.env,...s}={})=>{a={...a};let l=fde({env:a});return s.path=a[l],a[l]=DPr(s),a},"npmRunPathEnv");var PPr=t((a,s,l,_)=>{if(l==="length"||l==="prototype"||l==="arguments"||l==="caller")return;let h=Object.getOwnPropertyDescriptor(a,l),b=Object.getOwnPropertyDescriptor(s,l);!APr(h,b)&&_||Object.defineProperty(a,l,b)},"copyProperty"),APr=t(function(a,s){return a===void 0||a.configurable||a.writable===s.writable&&a.enumerable===s.enumerable&&a.configurable===s.configurable&&(a.writable||a.value===s.value)},"canCopyProperty"),NPr=t((a,s)=>{let l=Object.getPrototypeOf(s);l!==Object.getPrototypeOf(a)&&Object.setPrototypeOf(a,l)},"changePrototype"),IPr=t((a,s)=>`/* Wrapped ${a}*/
|
|
656
656
|
${s}`,"wrappedToString"),OPr=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),FPr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),LPr=t((a,s,l)=>{let _=l===""?"":`with ${l.trim()}() `,h=IPr.bind(null,_,s.toString());Object.defineProperty(h,"name",FPr),Object.defineProperty(a,"toString",{...OPr,value:h})},"changeToString");function U9e(a,s,{ignoreNonConfigurable:l=!1}={}){let{name:_}=a;for(let h of Reflect.ownKeys(s))PPr(a,s,h,l);return NPr(a,s),LPr(a,s,_),a}t(U9e,"mimicFunction");var pde=new WeakMap,QTt=t((a,s={})=>{if(typeof a!="function")throw new TypeError("Expected a function");let l,_=0,h=a.displayName||a.name||"<anonymous>",b=t(function(...D){if(pde.set(b,++_),_===1)l=a.apply(this,D),a=null;else if(s.throw===!0)throw new Error(`Function \`${h}\` can only be called once`);return l},"onetime");return U9e(b,a),pde.set(b,_),b},"onetime");QTt.callCount=a=>{if(!pde.has(a))throw new Error(`The given function \`${a.name}\` is not wrapped by the \`onetime\` package`);return pde.get(a)};var ZTt=QTt;import{constants as BPr}from"os";var ext=t(function(){let a=$9e-txt+1;return Array.from({length:a},RPr)},"getRealtimeSignals"),RPr=t(function(a,s){return{name:`SIGRT${s+1}`,number:txt+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),txt=34,$9e=64;import{constants as MPr}from"os";var rxt=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var z9e=t(function(){let a=ext();return[...rxt,...a].map(jPr)},"getSignals"),jPr=t(function({name:a,number:s,description:l,action:_,forced:h=!1,standard:b}){let{signals:{[a]:D}}=MPr,A=D!==void 0;return{name:a,number:A?D:s,description:l,supported:A,action:_,forced:h,standard:b}},"normalizeSignal");var UPr=t(function(){return z9e().reduce($Pr,{})},"getSignalsByName"),$Pr=t(function(a,{name:s,number:l,description:_,supported:h,action:b,forced:D,standard:A}){return{...a,[s]:{name:s,number:l,description:_,supported:h,action:b,forced:D,standard:A}}},"getSignalByName"),nxt=UPr(),zPr=t(function(){let a=z9e(),s=$9e+1,l=Array.from({length:s},(_,h)=>JPr(h,a));return Object.assign({},...l)},"getSignalsByNumber"),JPr=t(function(a,s){let l=qPr(a,s);if(l===void 0)return{};let{name:_,description:h,supported:b,action:D,forced:A,standard:M}=l;return{[a]:{name:_,number:a,description:h,supported:b,action:D,forced:A,standard:M}}},"getSignalByNumber"),qPr=t(function(a,s){let l=s.find(({name:_})=>BPr.signals[_]===a);return l!==void 0?l:s.find(_=>_.number===a)},"findSignalByNumber"),sGr=zPr();var VPr=t(({timedOut:a,timeout:s,errorCode:l,signal:_,signalDescription:h,exitCode:b,isCanceled:D})=>a?`timed out after ${s} milliseconds`:D?"was canceled":l!==void 0?`failed with ${l}`:_!==void 0?`was killed with ${_} (${h})`:b!==void 0?`failed with exit code ${b}`:"failed","getErrorPrefix"),J9e=t(({stdout:a,stderr:s,all:l,error:_,signal:h,exitCode:b,command:D,escapedCommand:A,timedOut:M,isCanceled:z,killed:re,parsed:{options:{timeout:ie}}})=>{b=b===null?void 0:b,h=h===null?void 0:h;let Q=h===void 0?void 0:nxt[h].description,Re=_&&_.code,we=`Command ${VPr({timedOut:M,timeout:ie,errorCode:Re,signal:h,signalDescription:Q,exitCode:b,isCanceled:z})}: ${D}`,wt=Object.prototype.toString.call(_)==="[object Error]",xt=wt?`${we}
|
|
657
657
|
${_.message}`:we,Tr=[xt,s,a].filter(Boolean).join(`
|
|
658
|
-
`);return wt?(_.originalMessage=_.message,_.message=Tr):_=new Error(Tr),_.shortMessage=xt,_.command=D,_.escapedCommand=A,_.exitCode=b,_.signal=h,_.signalDescription=Q,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=z,_.killed=re&&!M,_},"makeError");var dde=["stdin","stdout","stderr"],WPr=t(a=>dde.some(s=>a[s]!==void 0),"hasAlias"),ixt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return dde.map(_=>a[_]);if(WPr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${dde.map(_=>`\`${_}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let l=Math.max(s.length,dde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var fxt=x_(uxt(),1);import HPr from"node:os";var GPr=1e3*5,_xt=t((a,s="SIGTERM",l={})=>{let _=a(s);return KPr(a,s,l,_),_},"spawnedKill"),KPr=t((a,s,l,_)=>{if(!YPr(s,l,_))return;let h=QPr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),YPr=t((a,{forceKillAfterTimeout:s},l)=>XPr(a)&&s!==!1&&l,"shouldForceKill"),XPr=t(a=>a===HPr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),QPr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return GPr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),pxt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),ZPr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),dxt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((A,M)=>{h=setTimeout(()=>{ZPr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(h)});return Promise.race([b,D])},"setupTimeout"),mxt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),hxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,fxt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function gxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(gxt,"isStream");var K9e=x_(bxt(),1),xxt=x_(Txt(),1);var Ext=t((a,s)=>{s===void 0||a.stdin===void 0||(gxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),Cxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,xxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),H9e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),G9e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,K9e.default)(a,{encoding:s,maxBuffer:_}):K9e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),Dxt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},D)=>{let A=G9e(a,{encoding:_,buffer:h,maxBuffer:b}),M=G9e(s,{encoding:_,buffer:h,maxBuffer:b}),z=G9e(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([D,A,M,z])}catch(re){return Promise.all([{error:re,signal:re.signal,timedOut:re.timedOut},H9e(a,A),H9e(s,M),H9e(l,z)])}},"getSpawnedResult");var oAr=(async()=>{})().constructor.prototype,cAr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(oAr,a)]),Y9e=t((a,s)=>{for(let[l,_]of cAr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),kxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var wxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),lAr=/^[\w.-]+$/,uAr=/"/g,fAr=t(a=>typeof a!="string"||lAr.test(a)?a:`"${a.replace(uAr,'\\"')}"`,"escapeArg"),Pxt=t((a,s)=>wxt(a,s).join(" "),"joinCommand"),Axt=t((a,s)=>wxt(a,s).map(l=>fAr(l)).join(" "),"getEscapedCommand");var dAr=1e3*1e3*100,mAr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...bde.env,...a}:a;return l?XTt({env:b,cwd:_,execPath:h}):b},"getEnv"),hAr=t((a,s,l={})=>{let _=Ixt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:dAr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||bde.cwd(),execPath:bde.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=mAr(l),l.stdio=ixt(l),bde.platform==="win32"&&pAr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),X9e=t((a,s,l)=>typeof s!="string"&&!_Ar.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?B9e(s):s,"handleOutput");function Oxt(a,s,l){let _=hAr(a,s,l),h=Pxt(a,s),b=Axt(a,s);mxt(_.options);let D;try{D=Nxt.spawn(_.file,_.args,_.options)}catch(Re){let Ie=new Nxt.ChildProcess,we=Promise.reject(J9e({error:Re,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return Y9e(Ie,we)}let A=kxt(D),M=dxt(D,_.options,A),z=hxt(D,_.options,M),re={isCanceled:!1};D.kill=_xt.bind(null,D.kill.bind(D)),D.cancel=pxt.bind(null,D,re);let Q=ZTt(t(async()=>{let[{error:Re,exitCode:Ie,signal:we,timedOut:wt},xt,Tr,fn]=await Dxt(D,_.options,z),tn=X9e(_.options,xt),cn=X9e(_.options,Tr),Er=X9e(_.options,fn);if(Re||Ie!==0||we!==null){let vr=J9e({error:Re,exitCode:Ie,signal:we,stdout:tn,stderr:cn,all:Er,command:h,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:re.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return vr;throw vr}return{command:h,escapedCommand:b,exitCode:0,stdout:tn,stderr:cn,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return Ext(D,_.options.input),D.all=Cxt(D,_.options),Y9e(D,Q)}t(Oxt,"execa");async function Tde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await gAr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),Fxt(Sde.join(s,".env.zuplo"))){let l=Lxt(Sde.join(s,".env.zuplo"),"utf8"),_=Q9e.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(mue.decode(_[h])).toString(),D=JSON.parse(b);for(let A of Object.keys(D))a[A]=D[A]}}if(Fxt(Sde.join(s,".env"))){let l=Lxt(Sde.join(s,".env"),"utf8"),_=Q9e.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Tde,"setEnvironment");async function gAr(a){let s="unknown";try{let{stdout:l}=await Oxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(gAr,"getGitSha");async function SAr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:D,logger:A,handleRuntimeStdio:M}){if(_){let re=AY.join(l,_,"modules.json");if(!yAr(re))throw new Error("The bundled-dir does not contain a modules.json file.");let ie=await bAr(re,"utf-8").then(JSON.parse),Q=await uB(l);return Q.status===bA?new Promise((Re,Ie)=>{z(Q.config.compatibilityDate,AY.join(l,_),ie,Re,M)().catch(we=>{A.error(we),Ie(we)})}):(A.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Ie)=>{z(void 0,l,ie,Re,M)().catch(we=>{A.error(we),Ie(we)})}))}else{let re=new WA({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:A,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await re.start()}catch{A.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((ie,Q)=>{re.onReload((Re,Ie)=>{(Ie||Re&&Re.errors&&Re.errors.length>0)&&Q(Ie??Re?.errors),z(Re?.compatibilityDate,AY.join(l,"dist"),lB(l,Re?.metafile),ie,M)().catch(we=>{A.error(we),Q(we)})})})}function z(re,ie,Q,Re,Ie){return async()=>{let we={};await Tde(we,l);let wt=new Rxt.ZuploWorkerd({compatibilityDate:re,scriptDirectory:ie,modules:Q,port:h??Fm.DEV_SERVER_PORT,bindings:we,handleRuntimeStdio:Ie}),xt=b??"compiled-zup",Tr=AY.join(l,"dist");await vAr(Tr,{recursive:!0}),await wt.compileBinary({binaryPath:AY.join(l,"dist",xt)}),await wt.dispose(),Re(void 0)}}t(z,"compile")}t(SAr,"compileWorkerdServer");var Mxt=x_(P9e(),1);import xAr from"node:path";import TAr from"node:net";function NY(a,s){return new Promise(l=>{let _=new TAr.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(NY,"isPortAvailable");var xde=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){this.sourceDirectory=s.sourceDirectory,this.port=s.port??Fm.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,s.zupTestMode||(this.buildWatcher=new WA({...s,logger:this.logger,publicZuploEnvironmentVariables:s.publicZuploEnvironmentVariables??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0}),this.buildWatcher.watchEnvFiles())}async start(){if(!await NY("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await Tde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new Mxt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:xAr.join(this.sourceDirectory,"dist"),modules:lB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as zxt}from"node:url";import{Readable as jxt}from"node:stream";import Bxt from"node:assert";import EAr from"node:child_process";import CAr from"node:fs";import Ede from"node:os";import DAr from"node:path";function Uxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(CAr.existsSync(h))return zxt(h)}t(Uxt,"getValidExecutablePath");function kAr(){let a=Ede.platform()==="win32"?"deno.exe":"deno",s=Uxt("deno/package.json",a);if(s)return s;let l=wAr(),_=Uxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(kAr,"locateDenoExecutable");function wAr(){let a=Ede.platform();return a==="linux"?a+"-"+$xt()+"-glibc":a+"-"+$xt()}t(wAr,"getTarget");function $xt(){let a=Ede.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Ede.arch()+". Only x64 and aarch64 binaries are available.");return a}t($xt,"getArch");var Cde=class{static{t(this,"ZenoServer")}serverProcess;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;constructor(s){this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,s.zupTestMode||(this.buildWatcher=new WA({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:s.publicZuploEnvironmentVariables??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:void 0}),this.buildWatcher.watchEnvFiles()),this.denoExecutablePath=kAr()}getServeArgs(){let s=`${DAr.dirname(zxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write"];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NY("127.0.0.1",9e3)||s.push(9e3),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error("The following ports are not available: "+s.join(", "));if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=EAr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Bxt(this.serverProcess.stdout instanceof jxt),Bxt(this.serverProcess.stderr instanceof jxt),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};async function PAr(a){let s=await uB(a),l=!1;return s.status===bA&&(l=s.config.flags?.managedDedicatedFlags?.useZeno??!1),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(PAr,"useZeno");async function AAr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:A,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let z;await PAr(a)?(h.debug("Starting managed-dedicated local dev server."),z=new Cde({sourceDirectory:a,debugPort:l,logger:h,output:b,publicZuploEnvironmentVariables:_,onReload:A,handleRuntimeStdio:M})):(h.debug("Starting edge local dev server."),z=new xde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:A,handleRuntimeStdio:M})),await z.start();async function re(){await z.stop()}t(re,"handle"),process.on("SIGTERM",re),process.on("SIGINT",re)}t(AAr,"startDevServer");var hEt=x_(Vxt(),1),gEt=x_(dEt(),1);import{readFile as f6r}from"node:fs/promises";import MY from"node:path";var l6r=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),u6r={concat(a,s){return MY.join(a,s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=MY.normalize(a),l=MY.sep,_=[],h=0;return s.split(l).reverse().filter(D=>D!==".").forEach(D=>{D===".."?h++:h===0?_.push(D):h--}),_.reverse().join(l)},isData(a){return a.startsWith("data:")},isURL(a){return l6r.test(a)},isAbsolute(a){return MY.isAbsolute(a)},relativeToFile(a,s){if(this.isData(a)||this.isAbsolute(s))return this.normalize(s);{let l=MY.dirname(a);return this.normalize(this.concat(l,s))}}},Lde=u6r;var mEt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function uLe(a){let s=mEt(async D=>await l(D,await a(D)));async function l(D,A){if(A===void 0)return s(Lde.resolve(D));let M,z,re=t(async Q=>(z=z||await _(ie))(Q),"_resolve"),ie={path:D,text:A,get lines(){return M=M||A.split(`
|
|
658
|
+
`);return wt?(_.originalMessage=_.message,_.message=Tr):_=new Error(Tr),_.shortMessage=xt,_.command=D,_.escapedCommand=A,_.exitCode=b,_.signal=h,_.signalDescription=Q,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=z,_.killed=re&&!M,_},"makeError");var dde=["stdin","stdout","stderr"],WPr=t(a=>dde.some(s=>a[s]!==void 0),"hasAlias"),ixt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return dde.map(_=>a[_]);if(WPr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${dde.map(_=>`\`${_}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let l=Math.max(s.length,dde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var fxt=x_(uxt(),1);import HPr from"node:os";var GPr=1e3*5,_xt=t((a,s="SIGTERM",l={})=>{let _=a(s);return KPr(a,s,l,_),_},"spawnedKill"),KPr=t((a,s,l,_)=>{if(!YPr(s,l,_))return;let h=QPr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),YPr=t((a,{forceKillAfterTimeout:s},l)=>XPr(a)&&s!==!1&&l,"shouldForceKill"),XPr=t(a=>a===HPr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),QPr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return GPr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),pxt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),ZPr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),dxt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((A,M)=>{h=setTimeout(()=>{ZPr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(h)});return Promise.race([b,D])},"setupTimeout"),mxt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),hxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,fxt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function gxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(gxt,"isStream");var K9e=x_(bxt(),1),xxt=x_(Txt(),1);var Ext=t((a,s)=>{s===void 0||a.stdin===void 0||(gxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),Cxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,xxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),H9e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),G9e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,K9e.default)(a,{encoding:s,maxBuffer:_}):K9e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),Dxt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},D)=>{let A=G9e(a,{encoding:_,buffer:h,maxBuffer:b}),M=G9e(s,{encoding:_,buffer:h,maxBuffer:b}),z=G9e(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([D,A,M,z])}catch(re){return Promise.all([{error:re,signal:re.signal,timedOut:re.timedOut},H9e(a,A),H9e(s,M),H9e(l,z)])}},"getSpawnedResult");var oAr=(async()=>{})().constructor.prototype,cAr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(oAr,a)]),Y9e=t((a,s)=>{for(let[l,_]of cAr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),kxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var wxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),lAr=/^[\w.-]+$/,uAr=/"/g,fAr=t(a=>typeof a!="string"||lAr.test(a)?a:`"${a.replace(uAr,'\\"')}"`,"escapeArg"),Pxt=t((a,s)=>wxt(a,s).join(" "),"joinCommand"),Axt=t((a,s)=>wxt(a,s).map(l=>fAr(l)).join(" "),"getEscapedCommand");var dAr=1e3*1e3*100,mAr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...bde.env,...a}:a;return l?XTt({env:b,cwd:_,execPath:h}):b},"getEnv"),hAr=t((a,s,l={})=>{let _=Ixt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:dAr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||bde.cwd(),execPath:bde.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=mAr(l),l.stdio=ixt(l),bde.platform==="win32"&&pAr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),X9e=t((a,s,l)=>typeof s!="string"&&!_Ar.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?B9e(s):s,"handleOutput");function Oxt(a,s,l){let _=hAr(a,s,l),h=Pxt(a,s),b=Axt(a,s);mxt(_.options);let D;try{D=Nxt.spawn(_.file,_.args,_.options)}catch(Re){let Ie=new Nxt.ChildProcess,we=Promise.reject(J9e({error:Re,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return Y9e(Ie,we)}let A=kxt(D),M=dxt(D,_.options,A),z=hxt(D,_.options,M),re={isCanceled:!1};D.kill=_xt.bind(null,D.kill.bind(D)),D.cancel=pxt.bind(null,D,re);let Q=ZTt(t(async()=>{let[{error:Re,exitCode:Ie,signal:we,timedOut:wt},xt,Tr,fn]=await Dxt(D,_.options,z),tn=X9e(_.options,xt),cn=X9e(_.options,Tr),Er=X9e(_.options,fn);if(Re||Ie!==0||we!==null){let vr=J9e({error:Re,exitCode:Ie,signal:we,stdout:tn,stderr:cn,all:Er,command:h,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:re.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return vr;throw vr}return{command:h,escapedCommand:b,exitCode:0,stdout:tn,stderr:cn,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return Ext(D,_.options.input),D.all=Cxt(D,_.options),Y9e(D,Q)}t(Oxt,"execa");async function Tde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await gAr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),Fxt(Sde.join(s,".env.zuplo"))){let l=Lxt(Sde.join(s,".env.zuplo"),"utf8"),_=Q9e.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(mue.decode(_[h])).toString(),D=JSON.parse(b);for(let A of Object.keys(D))a[A]=D[A]}}if(Fxt(Sde.join(s,".env"))){let l=Lxt(Sde.join(s,".env"),"utf8"),_=Q9e.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Tde,"setEnvironment");async function gAr(a){let s="unknown";try{let{stdout:l}=await Oxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(gAr,"getGitSha");async function SAr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:D,logger:A,handleRuntimeStdio:M}){if(_){let re=AY.join(l,_,"modules.json");if(!yAr(re))throw new Error("The bundled-dir does not contain a modules.json file.");let ie=await bAr(re,"utf-8").then(JSON.parse),Q=await uB(l);return Q.status===bA?new Promise((Re,Ie)=>{z(Q.config.compatibilityDate,AY.join(l,_),ie,Re,M)().catch(we=>{A.error(we),Ie(we)})}):(A.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Ie)=>{z(void 0,l,ie,Re,M)().catch(we=>{A.error(we),Ie(we)})}))}else{let re=new WA({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:A,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await re.start()}catch{A.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((ie,Q)=>{re.onReload((Re,Ie)=>{(Ie||Re&&Re.errors&&Re.errors.length>0)&&Q(Ie??Re?.errors),z(Re?.compatibilityDate,AY.join(l,"dist"),lB(l,Re?.metafile),ie,M)().catch(we=>{A.error(we),Q(we)})})})}function z(re,ie,Q,Re,Ie){return async()=>{let we={};await Tde(we,l);let wt=new Rxt.ZuploWorkerd({compatibilityDate:re,scriptDirectory:ie,modules:Q,port:h??Fm.DEV_SERVER_PORT,bindings:we,handleRuntimeStdio:Ie}),xt=b??"compiled-zup",Tr=AY.join(l,"dist");await vAr(Tr,{recursive:!0}),await wt.compileBinary({binaryPath:AY.join(l,"dist",xt)}),await wt.dispose(),Re(void 0)}}t(z,"compile")}t(SAr,"compileWorkerdServer");var Mxt=x_(P9e(),1);import xAr from"node:path";import TAr from"node:net";function NY(a,s){return new Promise(l=>{let _=new TAr.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(NY,"isPortAvailable");var xde=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){if(this.sourceDirectory=s.sourceDirectory,this.port=s.port??Fm.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new WA({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NY("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await Tde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new Mxt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:xAr.join(this.sourceDirectory,"dist"),modules:lB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as zxt}from"node:url";import{Readable as jxt}from"node:stream";import Bxt from"node:assert";import EAr from"node:child_process";import CAr from"node:fs";import Ede from"node:os";import DAr from"node:path";function Uxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(CAr.existsSync(h))return zxt(h)}t(Uxt,"getValidExecutablePath");function kAr(){let a=Ede.platform()==="win32"?"deno.exe":"deno",s=Uxt("deno/package.json",a);if(s)return s;let l=wAr(),_=Uxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(kAr,"locateDenoExecutable");function wAr(){let a=Ede.platform();return a==="linux"?a+"-"+$xt()+"-glibc":a+"-"+$xt()}t(wAr,"getTarget");function $xt(){let a=Ede.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Ede.arch()+". Only x64 and aarch64 binaries are available.");return a}t($xt,"getArch");var Cde=class{static{t(this,"ZenoServer")}serverProcess;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;port=9e3;constructor(s){if(this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new WA({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=kAr()}getServeArgs(){let s=`${DAr.dirname(zxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write"];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NY("127.0.0.1",this.port)||s.push(this.port),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error("The following ports are not available: "+s.join(", "));if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=EAr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Bxt(this.serverProcess.stdout instanceof jxt),Bxt(this.serverProcess.stderr instanceof jxt),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};async function PAr(a){let s=await uB(a),l=!1;return s.status===bA&&(l=s.config.flags?.managedDedicatedFlags?.useZeno??!1),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(PAr,"useZeno");async function AAr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:A,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let z;await PAr(a)?(h.debug("Starting managed-dedicated local dev server."),z=new Cde({sourceDirectory:a,debugPort:l,logger:h,output:b,publicZuploEnvironmentVariables:_,onReload:A,handleRuntimeStdio:M})):(h.debug("Starting edge local dev server."),z=new xde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:A,handleRuntimeStdio:M})),await z.start();async function re(){await z.stop()}t(re,"handle"),process.on("SIGTERM",re),process.on("SIGINT",re)}t(AAr,"startDevServer");var hEt=x_(Vxt(),1),gEt=x_(dEt(),1);import{readFile as f6r}from"node:fs/promises";import MY from"node:path";var l6r=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),u6r={concat(a,s){return MY.join(a,s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=MY.normalize(a),l=MY.sep,_=[],h=0;return s.split(l).reverse().filter(D=>D!==".").forEach(D=>{D===".."?h++:h===0?_.push(D):h--}),_.reverse().join(l)},isData(a){return a.startsWith("data:")},isURL(a){return l6r.test(a)},isAbsolute(a){return MY.isAbsolute(a)},relativeToFile(a,s){if(this.isData(a)||this.isAbsolute(s))return this.normalize(s);{let l=MY.dirname(a);return this.normalize(this.concat(l,s))}}},Lde=u6r;var mEt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function uLe(a){let s=mEt(async D=>await l(D,await a(D)));async function l(D,A){if(A===void 0)return s(Lde.resolve(D));let M,z,re=t(async Q=>(z=z||await _(ie))(Q),"_resolve"),ie={path:D,text:A,get lines(){return M=M||A.split(`
|
|
659
659
|
`)},async resolve(Q){try{return await re(Q)}catch(Re){return Object.assign({},Q,{error:Re})}},_resolve:re};return ie}t(l,"SourceFile");async function _(D){let A=/\u0023 sourceMappingURL=(.+)\n?/g,M;for(;;){let ie=A.exec(D.text);if(ie)M=ie;else break}let z=M&&M[1],re=t(async ie=>Object.assign({},ie,{sourceFile:D,sourceLine:D.lines[ie.line-1]||""}),"defaultResolver");return z?await h(D.path,z,re):re}t(_,"SourceMapResolverFromFetchedFile");async function h(D,A,M){let z=A.startsWith("data:")?await l(D,(0,hEt.dataUriToBuffer)(A).toString()):await l(Lde.relativeToFile(D,A)),re=await new gEt.SourceMapConsumer(JSON.parse(z.text)),ie=mEt(async Q=>{let Re=Lde.relativeToFile(z.path,Q),Ie=re.sourceContentFor(Q,!0)||void 0;return await l(Re,Ie)});return async Q=>{try{let Re=re.originalPositionFor(Q);return Re.source?await(await ie(Re.source))._resolve(Object.assign({},Q,{line:Re.line,column:(Re.column??0)+1,name:Re.name})):M(Q)}catch(Re){return Object.assign(M(Q),{sourceMapError:Re})}}}t(h,"SourceMapResolver");let b=t(async function(A){try{return await l(A)}catch(M){let z={path:A,text:"",lines:[],error:M,async resolve(re){return Object.assign({},re,{error:M,sourceLine:"",sourceFile:z})},_resolve(re){return this.resolve(re)}};return z}},"getSource");return b.resetCache=()=>s.forgetEverything(),b.getCache=()=>s.cache,b}t(uLe,"buildGetSourceFunction");var _6r=t(async a=>f6r(a,{encoding:"utf8"}),"fetchFile"),yEt=uLe(_6r);import p6r from"node:path";import d6r from"node:util";var vEt=t(a=>a[a.length-1],"lastOf"),jY=t(a=>a.replace(/\\/g,"/"),"nixSlashes"),m6r=t((a,s)=>{let l=a||[],_=[],h={label:void 0,items:[l[0]]};return l.forEach(b=>{let D=s(b);h.label!==D&&h.items.length?_.push(h={label:D,items:[b]}):h.items.push(b)}),_},"partition"),BY=class a{static{t(this,"StackTracey")}items;getSource;pathRoot;constructor(s,{offset:l,getSource:_}){this.getSource=_,this.pathRoot=`${jY(process.cwd())}/`;let h=s,b=s instanceof SyntaxError;if(l=l||0,s instanceof Error&&(s=s.stack||""),typeof s=="string"&&(s=this.rawParse(s).slice(l).map(D=>this.extractEntryMetadata(D))),Array.isArray(s)){if(b){let D=d6r.inspect(h).split(`
|
|
660
660
|
`),A=D[0].split(":"),M=A.pop(),z=A.join(":");z&&s.unshift({file:jY(z),line:parseInt(M||"0",10),column:(D[2]||"").indexOf("^")+1,sourceLine:D[1],callee:"(syntax error)",syntaxError:!0,beforeParse:"",index:!1,native:!1,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1})}this.items=s}else this.items=[]}extractEntryMetadata(s){let l=this.decomposePath(s.file||""),_=l[0],h=l[1];return Object.assign(s,{calleeShort:s.calleeShort||vEt((s.callee||"").split(".")),fileRelative:_,fileShort:this.shortenPath(_),fileName:vEt((s.file||"").split("/")),thirdParty:this.isThirdParty(_,h)&&!s.index,externalDomain:h})}shortenPath(s){return s.replace(/^node_modules\//,"").replace(/^webpack\/bootstrap\//,"").replace(/^__parcel_source_root\//,"")}decomposePath(s){let l=s,_=l.match(/^(http|https):\/\/([^\/]+)\/(.*)/),h=_?_[2]:void 0;return l=_?_[3]:l,l=p6r.relative(this.pathRoot,l),[jY(l).replace(/^.*:\/\/?\/?/,""),h]}isThirdParty(s,l){return!!l||s[0]==="~"||s[0]==="/"||s.indexOf("node_modules")===0||s.indexOf("webpack/bootstrap")===0}rawParse(s){return(s||"").split(`
|
|
661
661
|
`).map(h=>{h=h.trim();let b,D=[],A,M,z;if((M=h.match(/at (.+) \(eval at .+ \((.+)\), .+\)/))||(M=h.match(/at (.+) \((.+)\)/))||h.slice(0,3)!=="at "&&(M=h.match(/(.*)@(.*)/)))b=M[1],A=M[2]==="native",D=(M[2].match(/(.*):(\d+):(\d+)/)||M[2].match(/(.*):(\d+)/)||[]).slice(1);else if(z=h.match(/^(at\s+)*(.+):(\d+):(\d+)/))D=z.slice(2);else return;return b&&!D[0]&&b.split(".")[0]==="Array"&&(A=!0),{beforeParse:h,callee:b||"",index:D[0]==="/",native:A||!1,file:jY(D[0]||""),line:parseInt(D[1]||"",10)||void 0,column:parseInt(D[2]||"",10)||void 0,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1}}).filter(h=>h!==void 0)}async withSourceAsyncAt(s){return this.items[s]&&this.withSourceAsync(this.items[s])}async withSourceAsync(s){if(this.shouldSkipResolving(s))return s;{let l=(s.file||"").replace("file://","");try{let h=await(await this.getSource(l)).resolve(s);return this.withSourceResolved(s,h)}catch(_){return this.withSourceResolved(s,{error:_,sourceLine:""})}}}shouldSkipResolving(s){return!!s.sourceFile||!!s.error||!!s.file&&s.file.indexOf("<")>=0}withSourceResolved(s,l){return l.sourceFile&&!l.sourceFile.error&&(l.file=jY(l.sourceFile.path),l=this.extractEntryMetadata(l)),l.sourceLine?.includes("// @hide")&&(l.sourceLine=l.sourceLine.replace("// @hide",""),l.hide=!0),(l.sourceLine?.includes("__webpack_require__")||l.sourceLine?.includes("/******/ ({"))&&(l.thirdParty=!0),Object.assign({sourceLine:""},s,l)}async withSourcesAsync(){let s=await Promise.all(this.items.map(l=>this.withSourceAsync(l)));return new a(s,{getSource:this.getSource})}mergeRepeatedLines(){return new a(m6r(this.items,s=>s.file+s.line).map(s=>s.items.slice(1).reduce((l,_)=>(l.callee=(l.callee||"<anonymous>")+" \u2192 "+(_.callee||"<anonymous>"),l.calleeShort=(l.calleeShort||"<anonymous>")+" \u2192 "+(_.calleeShort||"<anonymous>"),l),Object.assign({},s.items[0]))),{getSource:this.getSource})}async cleanAsync(){let s=await this.withSourcesAsync();return s.mergeRepeatedLines().filter((l,_)=>s.isClean(l,_))}isClean(s,l){return l===0||!(s.thirdParty||s.hide||s.native)}at(s){return Object.assign({beforeParse:"",callee:"<???>",index:!1,native:!1,file:"<???>",line:0,column:0},this.items[s])}map(s,l){return new a(this.items.map(s,l),{getSource:this.getSource})}filter(s,l){return new a(this.items.filter(s,l),{getSource:this.getSource})}slice(s,l){return new a(this.items.slice(s,l),{getSource:this.getSource})}concat(...s){return new a(this.items.concat(...s),{getSource:this.getSource})}maxColumnWidths(){return{callee:30,file:60,sourceLine:80}}static locationsEqual(s,l){return s.file===l.file&&s.line===l.line&&s.column===l.column}};import{relative as S6r}from"node:path";import{fileURLToPath as T6r}from"node:url";import{inspect as x6r}from"node:util";function fLe({onlyFirst:a=!1}={}){let l=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(l,a?void 0:"g")}t(fLe,"ansiRegex");var h6r=fLe();function _Le(a){if(typeof a!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof a}\``);return a.replace(h6r,"")}t(_Le,"stripAnsi");function bEt(a){return a===161||a===164||a===167||a===168||a===170||a===173||a===174||a>=176&&a<=180||a>=182&&a<=186||a>=188&&a<=191||a===198||a===208||a===215||a===216||a>=222&&a<=225||a===230||a>=232&&a<=234||a===236||a===237||a===240||a===242||a===243||a>=247&&a<=250||a===252||a===254||a===257||a===273||a===275||a===283||a===294||a===295||a===299||a>=305&&a<=307||a===312||a>=319&&a<=322||a===324||a>=328&&a<=331||a===333||a===338||a===339||a===358||a===359||a===363||a===462||a===464||a===466||a===468||a===470||a===472||a===474||a===476||a===593||a===609||a===708||a===711||a>=713&&a<=715||a===717||a===720||a>=728&&a<=731||a===733||a===735||a>=768&&a<=879||a>=913&&a<=929||a>=931&&a<=937||a>=945&&a<=961||a>=963&&a<=969||a===1025||a>=1040&&a<=1103||a===1105||a===8208||a>=8211&&a<=8214||a===8216||a===8217||a===8220||a===8221||a>=8224&&a<=8226||a>=8228&&a<=8231||a===8240||a===8242||a===8243||a===8245||a===8251||a===8254||a===8308||a===8319||a>=8321&&a<=8324||a===8364||a===8451||a===8453||a===8457||a===8467||a===8470||a===8481||a===8482||a===8486||a===8491||a===8531||a===8532||a>=8539&&a<=8542||a>=8544&&a<=8555||a>=8560&&a<=8569||a===8585||a>=8592&&a<=8601||a===8632||a===8633||a===8658||a===8660||a===8679||a===8704||a===8706||a===8707||a===8711||a===8712||a===8715||a===8719||a===8721||a===8725||a===8730||a>=8733&&a<=8736||a===8739||a===8741||a>=8743&&a<=8748||a===8750||a>=8756&&a<=8759||a===8764||a===8765||a===8776||a===8780||a===8786||a===8800||a===8801||a>=8804&&a<=8807||a===8810||a===8811||a===8814||a===8815||a===8834||a===8835||a===8838||a===8839||a===8853||a===8857||a===8869||a===8895||a===8978||a>=9312&&a<=9449||a>=9451&&a<=9547||a>=9552&&a<=9587||a>=9600&&a<=9615||a>=9618&&a<=9621||a===9632||a===9633||a>=9635&&a<=9641||a===9650||a===9651||a===9654||a===9655||a===9660||a===9661||a===9664||a===9665||a>=9670&&a<=9672||a===9675||a>=9678&&a<=9681||a>=9698&&a<=9701||a===9711||a===9733||a===9734||a===9737||a===9742||a===9743||a===9756||a===9758||a===9792||a===9794||a===9824||a===9825||a>=9827&&a<=9829||a>=9831&&a<=9834||a===9836||a===9837||a===9839||a===9886||a===9887||a===9919||a>=9926&&a<=9933||a>=9935&&a<=9939||a>=9941&&a<=9953||a===9955||a===9960||a===9961||a>=9963&&a<=9969||a===9972||a>=9974&&a<=9977||a===9979||a===9980||a===9982||a===9983||a===10045||a>=10102&&a<=10111||a>=11094&&a<=11097||a>=12872&&a<=12879||a>=57344&&a<=63743||a>=65024&&a<=65039||a===65533||a>=127232&&a<=127242||a>=127248&&a<=127277||a>=127280&&a<=127337||a>=127344&&a<=127373||a===127375||a===127376||a>=127387&&a<=127404||a>=917760&&a<=917999||a>=983040&&a<=1048573||a>=1048576&&a<=1114109}t(bEt,"isAmbiguous");function SEt(a){return a===12288||a>=65281&&a<=65376||a>=65504&&a<=65510}t(SEt,"isFullWidth");function TEt(a){return a>=4352&&a<=4447||a===8986||a===8987||a===9001||a===9002||a>=9193&&a<=9196||a===9200||a===9203||a===9725||a===9726||a===9748||a===9749||a>=9800&&a<=9811||a===9855||a===9875||a===9889||a===9898||a===9899||a===9917||a===9918||a===9924||a===9925||a===9934||a===9940||a===9962||a===9970||a===9971||a===9973||a===9978||a===9981||a===9989||a===9994||a===9995||a===10024||a===10060||a===10062||a>=10067&&a<=10069||a===10071||a>=10133&&a<=10135||a===10160||a===10175||a===11035||a===11036||a===11088||a===11093||a>=11904&&a<=11929||a>=11931&&a<=12019||a>=12032&&a<=12245||a>=12272&&a<=12287||a>=12289&&a<=12350||a>=12353&&a<=12438||a>=12441&&a<=12543||a>=12549&&a<=12591||a>=12593&&a<=12686||a>=12688&&a<=12771||a>=12783&&a<=12830||a>=12832&&a<=12871||a>=12880&&a<=19903||a>=19968&&a<=42124||a>=42128&&a<=42182||a>=43360&&a<=43388||a>=44032&&a<=55203||a>=63744&&a<=64255||a>=65040&&a<=65049||a>=65072&&a<=65106||a>=65108&&a<=65126||a>=65128&&a<=65131||a>=94176&&a<=94180||a===94192||a===94193||a>=94208&&a<=100343||a>=100352&&a<=101589||a>=101632&&a<=101640||a>=110576&&a<=110579||a>=110581&&a<=110587||a===110589||a===110590||a>=110592&&a<=110882||a===110898||a>=110928&&a<=110930||a===110933||a>=110948&&a<=110951||a>=110960&&a<=111355||a===126980||a===127183||a===127374||a>=127377&&a<=127386||a>=127488&&a<=127490||a>=127504&&a<=127547||a>=127552&&a<=127560||a===127568||a===127569||a>=127584&&a<=127589||a>=127744&&a<=127776||a>=127789&&a<=127797||a>=127799&&a<=127868||a>=127870&&a<=127891||a>=127904&&a<=127946||a>=127951&&a<=127955||a>=127968&&a<=127984||a===127988||a>=127992&&a<=128062||a===128064||a>=128066&&a<=128252||a>=128255&&a<=128317||a>=128331&&a<=128334||a>=128336&&a<=128359||a===128378||a===128405||a===128406||a===128420||a>=128507&&a<=128591||a>=128640&&a<=128709||a===128716||a>=128720&&a<=128722||a>=128725&&a<=128727||a>=128732&&a<=128735||a===128747||a===128748||a>=128756&&a<=128764||a>=128992&&a<=129003||a===129008||a>=129292&&a<=129338||a>=129340&&a<=129349||a>=129351&&a<=129535||a>=129648&&a<=129660||a>=129664&&a<=129672||a>=129680&&a<=129725||a>=129727&&a<=129733||a>=129742&&a<=129755||a>=129760&&a<=129768||a>=129776&&a<=129784||a>=131072&&a<=196605||a>=196608&&a<=262141}t(TEt,"isWide");function g6r(a){if(!Number.isSafeInteger(a))throw new TypeError(`Expected a code point, got \`${typeof a}\`.`)}t(g6r,"validate");function xEt(a,{ambiguousAsWide:s=!1}={}){return g6r(a),SEt(a)||TEt(a)||s&&bEt(a)?2:1}t(xEt,"eastAsianWidth");var DEt=x_(CEt(),1);var y6r=new Intl.Segmenter,v6r=/^\p{Default_Ignorable_Code_Point}$/u;function Rde(a,s={}){if(typeof a!="string"||a.length===0)return 0;let{ambiguousIsNarrow:l=!0,countAnsiEscapeCodes:_=!1}=s;if(_||(a=_Le(a)),a.length===0)return 0;let h=0,b={ambiguousAsWide:!l};for(let{segment:D}of y6r.segment(a)){let A=D.codePointAt(0);if(!(A<=31||A>=127&&A<=159)&&!(A>=8203&&A<=8207||A===65279)&&!(A>=768&&A<=879||A>=6832&&A<=6911||A>=7616&&A<=7679||A>=8400&&A<=8447||A>=65056&&A<=65071)&&!(A>=55296&&A<=57343)&&!(A>=65024&&A<=65039)&&!v6r.test(D)){if((0,DEt.default)().test(D)){h+=2;continue}h+=xEt(A,b)}}return h}t(Rde,"stringWidth");var mLe=x_(wEt(),1);var{platform:PEt,cwd:b6r}=process,{red:nU,yellow:AEt,green:jde,cyan:UY,dim:pLe}=Jf,NEt=process.stdout.columns,E6r=PEt==="win32"&&!process.env.WT_SESSION?">":"\u276F",C6r=(PEt==="win32"&&!process.env.WT_SESSION,"\u2043"),D6r=b6r();function IEt(a){return a=a.replace("async file:","file:"),S6r(D6r,a.startsWith("file:")?T6r(a):a)}t(IEt,"getRelativePath");function k6r(a){return a.find(s=>s.isApp)||null}t(k6r,"mainFrame");function w6r(a,s){return a.filter(l=>(l.isApp||l.isModule)&&(!s||l.file!==s.file||l.line!==s.line))}t(w6r,"filterNativeFrames");function OEt(a){return a.callee||"anonymous"}t(OEt,"frameMethod");function FEt(a,s){let l="",_=a.length-s.length;for(let h=0;h<=_;h++)l+=" ";return l}t(FEt,"whiteSpace");function dLe(a,s,l,_,h){let b=FEt(String(l),String(s));return _?`${h}${nU(E6r)}${b}${nU(s)}${nU("|")}${b} ${nU(a)}`:`${h} ${b}${pLe(s)}${pLe("|")}${b} ${pLe(a)}`}t(dLe,"codeLine");function P6r(a,s,l){let _,h=(0,mLe.default)(Rde(s)+2,NEt);return l?_=`${s} ${nU(h(`${a.message}`).trim())}`:_=`${s} ${nU(h(`${a.name}: ${a.message}`).trim())}`,[_,s]}t(P6r,"getMessage");function A6r(a,s){let l=a.help;if(!l)return[];let _=(0,mLe.default)(Rde(s)+4,NEt);return Array.isArray(l)?l.map(h=>`${s} ${UY(_(`- ${h}`).trim())}`).concat([s]):[`${s} ${UY(l)}`,s]}t(A6r,"getHelpText");function N6r(a,s,l){if(!a)return[];let _=l?IEt(a.filePath):a.filePath;return[`${s} at ${AEt(`${OEt(a)}`)} ${jde(_)}:${jde(a.line)}`]}t(N6r,"getMainFrameLocation");function I6r(a,s){if(!a||!a.context||!a.context.line)return[];let l=a.context.start-1,_=a.context.pre.split(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/core",
|
|
3
|
-
"version": "6.54.
|
|
3
|
+
"version": "6.54.14",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"prettier": "^3.5.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@zuplo/graphql": "6.54.
|
|
45
|
-
"@zuplo/otel": "6.54.
|
|
46
|
-
"@zuplo/runtime": "6.54.
|
|
44
|
+
"@zuplo/graphql": "6.54.14",
|
|
45
|
+
"@zuplo/otel": "6.54.14",
|
|
46
|
+
"@zuplo/runtime": "6.54.14",
|
|
47
47
|
"deno": "2.3.1"
|
|
48
48
|
}
|
|
49
49
|
}
|