@zuplo/runtime 6.51.30 → 6.51.32

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.
@@ -22,4 +22,4 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{a as i}from"./chunk-PPV7V43C.js";var N=(e=>(e.Build="build-data",e.CorsPreflight="cors-preflight",e.DeveloperPortal="developer-portal",e.ZudokuPortal="zudoku-portal",e.DeveloperPortalLegacy="developer-portal-legacy",e.StripePlugin="stripe-plugin",e.EmptyGatewayCatchall="empty-gateway-catchall",e.Ping="ping",e.UnmatchedPath="unmatched-path",e))(N||{});function w(t){if(t.length>=255)throw new TypeError("Alphabet too long");let r=new Uint8Array(256);for(let e=0;e<r.length;e++)r[e]=255;for(let e=0;e<t.length;e++){let o=t.charAt(e),_=o.charCodeAt(0);if(r[_]!==255)throw new TypeError(o+" is ambiguous");r[_]=e}let n=t.length,f=t.charAt(0),O=Math.log(n)/Math.log(256),P=Math.log(256)/Math.log(n);function E(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length===0)return"";let o=0,_=0,l=0,g=e.length;for(;l!==g&&e[l]===0;)l++,o++;let d=(g-l)*P+1>>>0,u=new Uint8Array(d);for(;l!==g;){let s=e[l],m=0;for(let p=d-1;(s!==0||m<_)&&p!==-1;p--,m++)s+=256*u[p]>>>0,u[p]=s%n>>>0,s=s/n>>>0;if(s!==0)throw new Error("Non-zero carry");_=m,l++}let c=d-_;for(;c!==d&&u[c]===0;)c++;let h=f.repeat(o);for(;c<d;++c)h+=t.charAt(u[c]);return h}i(E,"encode");function A(e){if(typeof e!="string")throw new TypeError("Expected String");if(e.length===0)return new Uint8Array;let o=0,_=0,l=0;for(;e[o]===f;)_++,o++;let g=(e.length-o)*O+1>>>0,d=new Uint8Array(g);for(;e[o];){let s=r[e.charCodeAt(o)];if(s===255)return;let m=0;for(let p=g-1;(s!==0||m<l)&&p!==-1;p--,m++)s+=n*d[p]>>>0,d[p]=s%256>>>0,s=s/256>>>0;if(s!==0)throw new Error("Non-zero carry");l=m,o++}let u=g-l;for(;u!==g&&d[u]===0;)u++;let c=new Uint8Array(_+(g-u)),h=_;for(;u!==g;)c[h++]=d[u++];return c}i(A,"decodeUnsafe");function C(e){let o=A(e);if(o)return o;throw new Error("Non-base"+n+" character")}return i(C,"decode"),{encode:E,decodeUnsafe:A,decode:C}}i(w,"base");var T=w;var b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",y=T(b);var U="2025-02-06",R=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 I(){return new a({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:U,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:R[U]},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:""}})}i(I,"getMockEnvironment");var a=class t{static{i(this,"Environment")}config;static#e;static#t=!1;static initialize(r){this.#e||(this.#e=new t(r),this.#t=!0)}static get instance(){return this.#t||(console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#e=I()),this.#e}constructor({build:r,runtime:n}){let f;try{if(n.ZUPLO_SYSTEM_CONFIGURATIONS){let O=new TextDecoder().decode(y.decode(n.ZUPLO_SYSTEM_CONFIGURATIONS)),P=JSON.parse(O);for(let E of Object.keys(P))n[E]||(n[E]=P[E])}if(n.__ZUPLO_CONFIG){let O=atob(n.__ZUPLO_CONFIG);f=JSON.parse(O)}}catch(O){console.error("Failed to parse runtime configuration",O)}this.config=f??{},this.build=r,this.runtime=n,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 v=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function D(t){return t.startsWith("__ZUPLO")||t.startsWith("ZUPLO_")?!v.includes(t)&&!t.startsWith("ZUPLO_PUBLIC_"):!1}i(D,"isRestrictedEnvVariableName");function S(t){return!!t.startsWith("ZUPLO_")}i(S,"isZuploReadableEnvVariableName");var K=new Proxy({},{get(t,r){let n=String(r);switch(n){case"ZUPLO_ENVIRONMENT_TYPE":return a.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return a.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return a.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return a.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return a.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return a.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return a.instance.build.COMPATIBILITY_DATE}if(!(D(n)&&!S(n)))return a.instance.runtime[n]}});function X(t,r,n){return`_${L(`${t}_${r}_${n}`)}`}i(X,"getRawOperationDataIdentifierName");function ee(t,r,n,f){return`_${L(t.toLowerCase())}_${r.toLowerCase()}_${n.toLowerCase()}_${f.toLowerCase()}`}i(ee,"getIdForParameterSchema");function te(t,r,n){return`_${L(t.toLowerCase())}_${r.toLowerCase()}_rb_${L(n.toLowerCase())}`}i(te,"getIdForRequestBodySchema");function ne(t,r){return`_${L(t)}_${L(r)}`}i(ne,"getIdForRefSchema");function L(t){let r=t.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(r)||(r="_"+r),r}i(L,"sanitizedIdentifierName");export{a,N as b,D as c,S as d,K as e,X as f,ee as g,te as h,ne as i,L as j};
25
+ import{a as i}from"./chunk-PPV7V43C.js";var N=(e=>(e.Build="build-data",e.CorsPreflight="cors-preflight",e.DeveloperPortal="developer-portal",e.ZudokuPortal="zudoku-portal",e.DeveloperPortalLegacy="developer-portal-legacy",e.StripePlugin="stripe-plugin",e.EmptyGatewayCatchall="empty-gateway-catchall",e.Ping="ping",e.UnmatchedPath="unmatched-path",e))(N||{});function w(t){if(t.length>=255)throw new TypeError("Alphabet too long");let r=new Uint8Array(256);for(let e=0;e<r.length;e++)r[e]=255;for(let e=0;e<t.length;e++){let o=t.charAt(e),_=o.charCodeAt(0);if(r[_]!==255)throw new TypeError(o+" is ambiguous");r[_]=e}let n=t.length,f=t.charAt(0),m=Math.log(n)/Math.log(256),P=Math.log(256)/Math.log(n);function E(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length===0)return"";let o=0,_=0,l=0,g=e.length;for(;l!==g&&e[l]===0;)l++,o++;let d=(g-l)*P+1>>>0,u=new Uint8Array(d);for(;l!==g;){let s=e[l],O=0;for(let p=d-1;(s!==0||O<_)&&p!==-1;p--,O++)s+=256*u[p]>>>0,u[p]=s%n>>>0,s=s/n>>>0;if(s!==0)throw new Error("Non-zero carry");_=O,l++}let c=d-_;for(;c!==d&&u[c]===0;)c++;let h=f.repeat(o);for(;c<d;++c)h+=t.charAt(u[c]);return h}i(E,"encode");function A(e){if(typeof e!="string")throw new TypeError("Expected String");if(e.length===0)return new Uint8Array;let o=0,_=0,l=0;for(;e[o]===f;)_++,o++;let g=(e.length-o)*m+1>>>0,d=new Uint8Array(g);for(;e[o];){let s=r[e.charCodeAt(o)];if(s===255)return;let O=0;for(let p=g-1;(s!==0||O<l)&&p!==-1;p--,O++)s+=n*d[p]>>>0,d[p]=s%256>>>0,s=s/256>>>0;if(s!==0)throw new Error("Non-zero carry");l=O,o++}let u=g-l;for(;u!==g&&d[u]===0;)u++;let c=new Uint8Array(_+(g-u)),h=_;for(;u!==g;)c[h++]=d[u++];return c}i(A,"decodeUnsafe");function C(e){let o=A(e);if(o)return o;throw new Error("Non-base"+n+" character")}return i(C,"decode"),{encode:E,decodeUnsafe:A,decode:C}}i(w,"base");var T=w;var b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",y=T(b);var U="2025-02-06",R=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 I(){return new a({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:U,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:R[U]},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:""}})}i(I,"getMockEnvironment");var a=class t{static{i(this,"Environment")}config;static#e;static#t=!1;static initialize(r){this.#e||(this.#e=new t(r),this.#t=!0)}static get instance(){return this.#t||(console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#e=I()),this.#e}constructor({build:r,runtime:n}){let f;try{if(n.ZUPLO_SYSTEM_CONFIGURATIONS){let m=new TextDecoder().decode(y.decode(n.ZUPLO_SYSTEM_CONFIGURATIONS)),P=JSON.parse(m);for(let E of Object.keys(P))n[E]||(n[E]=P[E])}if(n.__ZUPLO_CONFIG){let m=atob(n.__ZUPLO_CONFIG);f=JSON.parse(m)}}catch(m){console.error("Failed to parse runtime configuration",m)}this.config=f??{},this.build=r,this.runtime=n,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 v=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function D(t){return t.startsWith("__ZUPLO")||t.startsWith("ZUPLO_")?!v.includes(t)&&!t.startsWith("ZUPLO_PUBLIC_"):!1}i(D,"isRestrictedEnvVariableName");function S(t){return!!t.startsWith("ZUPLO_")}i(S,"isZuploReadableEnvVariableName");var K=new Proxy({},{get(t,r){let n=String(r);switch(n){case"ZUPLO_ENVIRONMENT_TYPE":return a.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return a.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return a.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return a.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return a.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return a.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return a.instance.build.COMPATIBILITY_DATE}if(!(D(n)&&!S(n)))return a.instance.runtime[n]}});function X(t,r,n){return`_${L(`${t}_${r}_${n}`)}`}i(X,"getRawOperationDataIdentifierName");function ee(t,r,n,f){return`_${L(t.toLowerCase())}_${r.toLowerCase()}_${n.toLowerCase()}_${f.toLowerCase()}`}i(ee,"getIdForParameterSchema");function te(t,r,n){return`_${L(t.toLowerCase())}_${r.toLowerCase()}_rb_${L(n.toLowerCase())}`}i(te,"getIdForRequestBodySchema");function ne(t,r){return`_${L(t)}_${L(r)}`}i(ne,"getIdForRefSchema");function L(t){let r=t.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(r)||(r="_"+r),r}i(L,"sanitizedIdentifierName");export{a,N as b,D as c,S as d,K as e,X as f,ee as g,te as h,ne as i,L as j};
package/out/esm/index.js CHANGED
@@ -22,7 +22,7 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{a as y,b as bt,e as Se,f as Kl,g as Ao,h as _o,i as Ql,j as Yl}from"./chunk-TL3I4MGR.js";import{a as s,b as Wl,c as Jl}from"./chunk-PPV7V43C.js";var Mc=Wl(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.parse=Hd;Gr.serialize=Fd;var Md=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,Dd=/^[\u0021-\u003A\u003C-\u007E]*$/,Zd=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,qd=/^[\u0020-\u003A\u003D-\u007E]*$/,$d=Object.prototype.toString,Ud=(()=>{let n=s(function(){},"C");return n.prototype=Object.create(null),n})();function Hd(n,e){let t=new Ud,r=n.length;if(r<2)return t;let o=e?.decode||jd,i=0;do{let a=n.indexOf("=",i);if(a===-1)break;let c=n.indexOf(";",i),u=c===-1?r:c;if(a>u){i=n.lastIndexOf(";",a-1)+1;continue}let l=Lc(n,i,a),d=Nc(n,a,l),p=n.slice(l,d);if(t[p]===void 0){let m=Lc(n,a+1,u),h=Nc(n,u,m),x=o(n.slice(m,h));t[p]=x}i=u+1}while(i<r);return t}s(Hd,"parse");function Lc(n,e,t){do{let r=n.charCodeAt(e);if(r!==32&&r!==9)return e}while(++e<t);return t}s(Lc,"startIndex");function Nc(n,e,t){for(;e>t;){let r=n.charCodeAt(--e);if(r!==32&&r!==9)return e+1}return t}s(Nc,"endIndex");function Fd(n,e,t){let r=t?.encode||encodeURIComponent;if(!Md.test(n))throw new TypeError(`argument name is invalid: ${n}`);let o=r(e);if(!Dd.test(o))throw new TypeError(`argument val is invalid: ${e}`);let i=n+"="+o;if(!t)return i;if(t.maxAge!==void 0){if(!Number.isInteger(t.maxAge))throw new TypeError(`option maxAge is invalid: ${t.maxAge}`);i+="; Max-Age="+t.maxAge}if(t.domain){if(!Zd.test(t.domain))throw new TypeError(`option domain is invalid: ${t.domain}`);i+="; Domain="+t.domain}if(t.path){if(!qd.test(t.path))throw new TypeError(`option path is invalid: ${t.path}`);i+="; Path="+t.path}if(t.expires){if(!zd(t.expires)||!Number.isFinite(t.expires.valueOf()))throw new TypeError(`option expires is invalid: ${t.expires}`);i+="; Expires="+t.expires.toUTCString()}if(t.httpOnly&&(i+="; HttpOnly"),t.secure&&(i+="; Secure"),t.partitioned&&(i+="; Partitioned"),t.priority)switch(typeof t.priority=="string"?t.priority.toLowerCase():void 0){case"low":i+="; Priority=Low";break;case"medium":i+="; Priority=Medium";break;case"high":i+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${t.priority}`)}if(t.sameSite)switch(typeof t.sameSite=="string"?t.sameSite.toLowerCase():t.sameSite){case!0:case"strict":i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"none":i+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${t.sameSite}`)}return i}s(Fd,"serialize");function jd(n){if(n.indexOf("%")===-1)return n;try{return decodeURIComponent(n)}catch{return n}}s(jd,"decode");function zd(n){return $d.call(n)==="[object Date]"}s(zd,"isDate")});var Xl=!1;function on(n,e){return{open:`\x1B[${n.join(";")}m`,close:`\x1B[${e}m`,regexp:new RegExp(`\\x1b\\[${e}m`,"g")}}s(on,"code");function sn(n,e){return Xl?`${e.open}${n.replace(e.regexp,e.open)}${e.close}`:n}s(sn,"run");function ed(n){return sn(n,on([31],39))}s(ed,"red");function td(n){return sn(n,on([32],39))}s(td,"green");function nd(n){return sn(n,on([33],39))}s(nd,"yellow");function rd(n){return sn(n,on([34],39))}s(rd,"blue");function od(n){return sn(n,on([35],39))}s(od,"magenta");function id(n){return sn(n,on([36],39))}s(id,"cyan");var xh=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 La=[ed,td,nd,rd,od,id];function sd(n){let e=0,t=n.length,r=0;if(t>0)for(;r<t;)e=(e<<5)-e+n.charCodeAt(r++)|0;return e}s(sd,"hashCode");function Na(n){let e=Math.abs(sd(n));return La[e%La.length]}s(Na,"generateColor");function Ma(n,e,...t){let r=0,o=t.length,i=String(e).replace(/%[sdjoO%]/g,a=>{if(a==="%%")return"%";if(r>=o)return a;switch(a){case"%s":return String(t[r++]);case"%d":return Number(t[r++]).toString();case"%o":return n(t[r++]).split(`
25
+ import{a as y,b as bt,e as Se,f as Kl,g as Ao,h as _o,i as Ql,j as Yl}from"./chunk-TPMH5PF5.js";import{a as s,b as Wl,c as Jl}from"./chunk-PPV7V43C.js";var Mc=Wl(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.parse=Hd;Gr.serialize=Fd;var Md=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,Dd=/^[\u0021-\u003A\u003C-\u007E]*$/,Zd=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,qd=/^[\u0020-\u003A\u003D-\u007E]*$/,$d=Object.prototype.toString,Ud=(()=>{let n=s(function(){},"C");return n.prototype=Object.create(null),n})();function Hd(n,e){let t=new Ud,r=n.length;if(r<2)return t;let o=e?.decode||jd,i=0;do{let a=n.indexOf("=",i);if(a===-1)break;let c=n.indexOf(";",i),u=c===-1?r:c;if(a>u){i=n.lastIndexOf(";",a-1)+1;continue}let l=Lc(n,i,a),d=Nc(n,a,l),p=n.slice(l,d);if(t[p]===void 0){let m=Lc(n,a+1,u),h=Nc(n,u,m),x=o(n.slice(m,h));t[p]=x}i=u+1}while(i<r);return t}s(Hd,"parse");function Lc(n,e,t){do{let r=n.charCodeAt(e);if(r!==32&&r!==9)return e}while(++e<t);return t}s(Lc,"startIndex");function Nc(n,e,t){for(;e>t;){let r=n.charCodeAt(--e);if(r!==32&&r!==9)return e+1}return t}s(Nc,"endIndex");function Fd(n,e,t){let r=t?.encode||encodeURIComponent;if(!Md.test(n))throw new TypeError(`argument name is invalid: ${n}`);let o=r(e);if(!Dd.test(o))throw new TypeError(`argument val is invalid: ${e}`);let i=n+"="+o;if(!t)return i;if(t.maxAge!==void 0){if(!Number.isInteger(t.maxAge))throw new TypeError(`option maxAge is invalid: ${t.maxAge}`);i+="; Max-Age="+t.maxAge}if(t.domain){if(!Zd.test(t.domain))throw new TypeError(`option domain is invalid: ${t.domain}`);i+="; Domain="+t.domain}if(t.path){if(!qd.test(t.path))throw new TypeError(`option path is invalid: ${t.path}`);i+="; Path="+t.path}if(t.expires){if(!zd(t.expires)||!Number.isFinite(t.expires.valueOf()))throw new TypeError(`option expires is invalid: ${t.expires}`);i+="; Expires="+t.expires.toUTCString()}if(t.httpOnly&&(i+="; HttpOnly"),t.secure&&(i+="; Secure"),t.partitioned&&(i+="; Partitioned"),t.priority)switch(typeof t.priority=="string"?t.priority.toLowerCase():void 0){case"low":i+="; Priority=Low";break;case"medium":i+="; Priority=Medium";break;case"high":i+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${t.priority}`)}if(t.sameSite)switch(typeof t.sameSite=="string"?t.sameSite.toLowerCase():t.sameSite){case!0:case"strict":i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"none":i+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${t.sameSite}`)}return i}s(Fd,"serialize");function jd(n){if(n.indexOf("%")===-1)return n;try{return decodeURIComponent(n)}catch{return n}}s(jd,"decode");function zd(n){return $d.call(n)==="[object Date]"}s(zd,"isDate")});var Xl=!1;function on(n,e){return{open:`\x1B[${n.join(";")}m`,close:`\x1B[${e}m`,regexp:new RegExp(`\\x1b\\[${e}m`,"g")}}s(on,"code");function sn(n,e){return Xl?`${e.open}${n.replace(e.regexp,e.open)}${e.close}`:n}s(sn,"run");function ed(n){return sn(n,on([31],39))}s(ed,"red");function td(n){return sn(n,on([32],39))}s(td,"green");function nd(n){return sn(n,on([33],39))}s(nd,"yellow");function rd(n){return sn(n,on([34],39))}s(rd,"blue");function od(n){return sn(n,on([35],39))}s(od,"magenta");function id(n){return sn(n,on([36],39))}s(id,"cyan");var xh=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 La=[ed,td,nd,rd,od,id];function sd(n){let e=0,t=n.length,r=0;if(t>0)for(;r<t;)e=(e<<5)-e+n.charCodeAt(r++)|0;return e}s(sd,"hashCode");function Na(n){let e=Math.abs(sd(n));return La[e%La.length]}s(Na,"generateColor");function Ma(n,e,...t){let r=0,o=t.length,i=String(e).replace(/%[sdjoO%]/g,a=>{if(a==="%%")return"%";if(r>=o)return a;switch(a){case"%s":return String(t[r++]);case"%d":return Number(t[r++]).toString();case"%o":return n(t[r++]).split(`
26
26
  `).map(c=>c.trim()).join(" ");case"%O":return n(t[r++]);case"%j":try{return JSON.stringify(t[r++])}catch{return"[Circular]"}default:return a}});for(let a of t.splice(r))a===null||!(typeof a=="object"&&a!==null)?i+=" "+a:i+=" "+n(a);return i}s(Ma,"format");function wt(n,e,t,r){let o={seen:[],stylize:ad,showHidden:e??!1,depth:t??2,colors:r??!1,customInspect:!0};return o.colors&&(o.stylize=ud),Pr(o,n,o.depth)}s(wt,"inspect");wt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};wt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function ad(n,e){return n}s(ad,"stylizeNoColor");function cd(n){return typeof n=="boolean"}s(cd,"isBoolean");function Za(n){return n===void 0}s(Za,"isUndefined");function ud(n,e){let t=wt.styles[e];return t?"\x1B["+wt.colors[t][0]+"m"+n+"\x1B["+wt.colors[t][1]+"m":n}s(ud,"stylizeWithColor");function ko(n){return typeof n=="function"}s(ko,"isFunction");function qa(n){return typeof n=="string"}s(qa,"isString");function ld(n){return typeof n=="number"}s(ld,"isNumber");function $a(n){return n===null}s($a,"isNull");function Ua(n,e){return Object.prototype.hasOwnProperty.call(n,e)}s(Ua,"hasOwn");function Lo(n){return Zo(n)&&qo(n)==="[object RegExp]"}s(Lo,"isRegExp");function Zo(n){return typeof n=="object"&&n!==null}s(Zo,"isObject");function No(n){return Zo(n)&&(qo(n)==="[object Error]"||n instanceof Error)}s(No,"isError");function Da(n){return Zo(n)&&qo(n)==="[object Date]"}s(Da,"isDate");function qo(n){return Object.prototype.toString.call(n)}s(qo,"objectToString");function dd(n){let e={};return n.forEach(function(t,r){e[t]=!0}),e}s(dd,"arrayToHash");function pd(n,e,t,r,o){let i=[];for(let a=0,c=e.length;a<c;++a)Ua(e,String(a))?i.push(Do(n,e,t,r,String(a),!0)):i.push("");return o.forEach(function(a){a.match(/^\d+$/)||i.push(Do(n,e,t,r,a,!0))}),i}s(pd,"formatArray");function Mo(n){return"["+Error.prototype.toString.call(n)+"]"}s(Mo,"formatError");function Pr(n,e,t){if(n.customInspect&&e&&ko(e.inspect)&&e.inspect!==wt&&!(e.constructor&&e.constructor.prototype===e)){let d=e.inspect(t,n);return qa(d)||(d=Pr(n,d,t)),d}let r=md(n,e);if(r)return r;let o=Object.keys(e),i=dd(o);try{n.showHidden&&Object.getOwnPropertyNames&&(o=Object.getOwnPropertyNames(e))}catch{}if(No(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Mo(e);if(o.length===0){if(ko(e)){let d=e.name?": "+e.name:"";return n.stylize("[Function"+d+"]","special")}if(Lo(e))return n.stylize(RegExp.prototype.toString.call(e),"regexp");if(Da(e))return n.stylize(Date.prototype.toString.call(e),"date");if(No(e))return Mo(e)}let a="",c=!1,u=["{","}"];if(Array.isArray(e)&&(c=!0,u=["[","]"]),ko(e)&&(a=" [Function"+(e.name?": "+e.name:"")+"]"),Lo(e)&&(a=" "+RegExp.prototype.toString.call(e)),Da(e)&&(a=" "+Date.prototype.toUTCString.call(e)),No(e)&&(a=" "+Mo(e)),o.length===0&&(!c||e.length==0))return u[0]+a+u[1];if(t<0)return Lo(e)?n.stylize(RegExp.prototype.toString.call(e),"regexp"):n.stylize("[Object]","special");n.seen.push(e);let l;return c?l=pd(n,e,t,i,o):l=o.map(function(d){return Do(n,e,t,i,d,c)}),n.seen.pop(),fd(l,a,u)}s(Pr,"formatValue");function Do(n,e,t,r,o,i){let a,c,u;u={value:void 0};try{u.value=e[o]}catch{}try{Object.getOwnPropertyDescriptor&&(u=Object.getOwnPropertyDescriptor(e,o)||u)}catch{}if(u.get?u.set?c=n.stylize("[Getter/Setter]","special"):c=n.stylize("[Getter]","special"):u.set&&(c=n.stylize("[Setter]","special")),Ua(r,o)||(a="["+o+"]"),c||(n.seen.indexOf(u.value)<0?($a(t)?c=Pr(n,u.value,null):c=Pr(n,u.value,t-1),c.indexOf(`
27
27
  `)>-1&&(i?c=c.split(`
28
28
  `).map(function(l){return" "+l}).join(`
@@ -32,7 +32,7 @@ import{a as y,b as bt,e as Se,f as Kl,g as Ao,h as _o,i as Ql,j as Yl}from"./chu
32
32
  `))):c=n.stylize("[Circular]","special")),Za(a)){if(i&&o.match(/^\d+$/))return c;a=JSON.stringify(""+o),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=n.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=n.stylize(a,"string"))}return a+": "+c}s(Do,"formatProperty");function md(n,e){if(Za(e))return n.stylize("undefined","undefined");if(qa(e)){let t="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return n.stylize(t,"string")}if(ld(e))return n.stylize(""+e,"number");if(cd(e))return n.stylize(""+e,"boolean");if($a(e))return n.stylize("null","null")}s(md,"formatPrimitive");function fd(n,e,t){let r=0;return n.reduce(function(i,a){return r++,a.indexOf(`
33
33
  `)>=0&&r++,i+a.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?t[0]+(e===""?"":e+`
34
34
  `)+" "+n.join(`,
35
- `)+" "+t[1]:t[0]+e+" "+n.join(", ")+" "+t[1]}s(fd,"reduceToSingleString");var Ha=s((n,...e)=>Ma(wt,n,e),"format");var $o=class{static{s(this,"Debugger")}manager;ns;color;last;enabled;constructor(e,t){this.manager=e,this.ns=t,this.color=Na(t),this.last=0,this.enabled=e.enabled.some(r=>r.test(t))}log(...e){if(!this.enabled)return;let t,r=e[0];typeof r=="function"?t=r():t=String(r);let o=Date.now()-(this.last||Date.now());t=Ha(t,...e);let i=`${this.color(this.ns)} ${t} ${this.color(`+${o}ms`)}`;console.log(i),this.last=Date.now()}},Uo=class{static{s(this,"DebugManager")}debuggers;enabled;constructor(e){this.debuggers=new Map,this.enabled=e??[]}};function gd(n){return!n||n.length===0?[]:(n=n.replace(/\s/g,"").replace(/\*/g,".+"),n.split(",").map(e=>new RegExp(`^${e}$`)))}s(gd,"extract");var Ir;function Ce(n){let e=globalThis.DEBUG;Ir||(Ir=new Uo(gd(e)));let t=new $o(Ir,n);return Ir.debuggers.set(n,t),Object.assign(t.log.bind(t),{self:t})}s(Ce,"debug");var ae=class extends Error{static{s(this,"SystemError")}constructor(e,t){super(e,t),this.name="InternalError"}},k=class extends Error{static{s(this,"RuntimeError")}extensionMembers;constructor(e,t){typeof e=="string"?super(e,t):(super(e.message,t),this.extensionMembers=e.extensionMembers),this.name="RuntimeError"}},f=class extends k{static{s(this,"ConfigurationError")}constructor(e,t){super(e,t),this.name="ConfigurationError"}};var Nt=Ce("zuplo:runtime:external-service");function hd(){let n,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:e}=y.instance.runtime;if(e&&e!=="undefined")try{let t=atob(e);n=JSON.parse(t)}catch{}return n}s(hd,"getServiceAuth");async function Fa(n,e){let t=hd();if(t)if(Nt(`Using external service auth. ClientId: ${t.clientId})`),typeof n=="string"){let r=new URL(n),o=r.hostname,i=e??{},a=new Headers(i.headers||{});a.set("CF-Access-Client-Id",t.clientId),a.set("CF-Access-Client-Secret",t.clientSecret),i.headers=a;let c;if(t.customServiceMapping&&t.customServiceMapping[o])c=`https://${t.customServiceMapping[o]}`;else if(y.instance.useLegacyServiceRouting)c=`https://${o}.zuptunnel.com`;else{Nt("Using sha256 service routing");let d=y.instance.build;if(d.ACCOUNT_NAME&&d.PROJECT_NAME&&d.ENVIRONMENT_TYPE){let p=await yd(o,d.ACCOUNT_NAME,d.PROJECT_NAME,d.ENVIRONMENT_TYPE),m=ja(d.ENVIRONMENT_TYPE),h=await Ho(`${d.ACCOUNT_NAME}-${d.PROJECT_NAME}-${m}`);h==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||h==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?c=`https://${p}.zuptunnel.com`:c=`https://${p}.t.zuplo.app`}else throw Nt("Cannot use sha256 service routing, missing build variables"),new k("Failed to generate fully qualified tunnel url.")}let u=new URL(`${c}${r.pathname}${r.search}`);Nt(`Calling external service: ${u.toString()}`);let l=await Er(u.toString(),i);if(l.status===403&&l.headers.get("cf-access-domain")!==null)throw console.error("403 Forbidden when calling external service.",{clientId:t.clientId,tunnelHost:c}),new k("Could not connect to secure tunnel.");return l}else throw Nt("Cannot call external service with Request object"),new k("Currently, we only support fetch(<some_string>, ...).");else throw Nt("There is no external service auth configured for this zup."),new k("There are no external services configured for this zup.")}s(Fa,"externalServiceHandler");async function yd(n,e,t,r){let o=n.toLowerCase(),i=e.toLowerCase(),a=t.toLowerCase(),c=ja(r);Nt(`Hashing service name: ${i}-${o}.${i}-${a}-${c}`);let u=await Ho(`${i}-${o}`),l=await Ho(`${i}-${a}-${c}`);return`${u}.${l}`}s(yd,"hashServiceName");async function Ho(n){let e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(i=>i.toString(16).padStart(2,"0")).join("").slice(0,-1)}s(Ho,"hashSegment");function ja(n){let e=n.toLowerCase();switch(e){case"production":case"preview":return e;default:return"working-copy"}}s(ja,"sanitizeEnvironmentType");var za=new Map;za.set("service:",Fa);var Er=globalThis.fetch;function Fo(n,e){let t=bd(e);if(typeof n=="string"){let r=new URL(n),o=za.get(r.protocol);return o?o(n,t):Er(n,t)}else return Er(n,t)}s(Fo,"internalFetch");globalThis.fetch=Fo;var bd=s(n=>{if(!n||n instanceof Request)return n;let e=n;if(!e.zuplo)return n;let t=n;return t.cf={cacheEverything:e.zuplo?.cacheEverything,cacheTtl:e.zuplo?.cacheTtlSeconds},delete n.zuplo,n},"transformInit");var wd={fetch:Fo},j=wd;Function.prototype.toString=function(){return"[native code]"};var Tr=globalThis,Ba=Tr.caches;if(Ba){let n=Ba.open;Tr.caches.open=function(e){let t=y.instance.deploymentName??y.instance.build.BUILD_ID;return n.call(this,`${t}-${e}`)},delete Tr.caches.default,Object.freeze(Tr.caches)}var Sr=new Set,Ga=new Set;function g(n){Ga.has(n)||(Ga.add(n),Sr.add(n))}s(g,"trackFeature");function Va(){let n=[...Sr];return Sr.clear(),n}s(Va,"getUnsentFeatures");function Wa(n){for(let e of n)Sr.add(e)}s(Wa,"restoreFeatures");function Xe(n,e){n.has("Authorization")||n.set("Authorization",`Bearer ${y.instance.authApiJWT}`),n.set("zp-rid",e??`global-${crypto.randomUUID()}`),n.set("zp-dn",y.instance.deploymentName??"unknown"),n.set("User-Agent",y.instance.systemUserAgent),n.set("zp-compat-date",y.instance.build.COMPATIBILITY_DATE??"none")}s(Xe,"setZuploHeaders");async function Rd(n,e={}){g("utility.zuplo-api-services");let{method:t="GET",data:r}=e,o=new URL(n,y.instance.zuploEdgeApiUrl),i=new Headers(e.headers);Xe(i),i.set("Content-Type","application/json");let a={method:t,headers:i};r&&(a.body=JSON.stringify(r));let c=await j.fetch(o,a),u;try{if(!c.ok)throw u=await c.clone().json(),new Error(`Error ${c.status}: ${JSON.stringify(u)||"Request failed"}`);if(c.status===204)return;u=await c.clone().json()}catch(l){throw new Error(l.message)}return u}s(Rd,"apiServices");var Ja=new Map,jo=class{static{s(this,"InnerCache")}constructor(e){this.#e=e.maxSize}#e;#t=0;#n=new Map;#r=[];get(e){let t=this.#n.get(e);if(!t)return;let r=Date.now();if(r>t.expiresAt){this.#n.delete(e);return}return t.lastUsed=r,this.#o(),t?.data}put(e,t,r){if(r<=0)return;if(this.#n.size>=this.#e){let a=this.#r.shift();a&&this.#n.delete(a)}let o=Date.now(),i={created:o,lastUsed:o,expiresAt:o+r*1e3,data:t};this.#r.push(e),this.#n.set(e,i)}delete(e){let t=this.#r.indexOf(e);t>=0&&this.#r.slice(t,1),this.#n.delete(e)}get size(){return this.#n.size}#o(){let e=Date.now();this.#t+1e4*1e3>e&&(this.purge(),this.#t=e)}purge(){let e=Date.now();this.#n.forEach((t,r)=>{t.expiresAt>=e&&this.#n.delete(r)})}},et=class{static{s(this,"MemoryCache")}constructor(e,t={maxSize:1e3}){this.name=e;let r=Ja.get(e);r||(r=new jo(t),Ja.set(e,r)),this.#e=r}name;#e;get(e){return this.#e.get(e)}put(e,t,r){return this.#e.put(e,t,r)}delete(e){return this.#e.delete(e)}get size(){return this.#e.size}purge(){this.#e.purge()}};var zo="__zuplo-expiry-header",$n=class{static{s(this,"ZoneCache")}constructor(e,t){this.#t=e,this.#e=t}#e;#t;#n;async#r(){return this.#n||(this.#n=await caches.open(this.#t)),this.#n}#o(e){return new Request(`https://zone-cache.zuplo.app/${encodeURIComponent(e)}`)}async get(e){try{let t=await this.#r(),r=this.#o(e),o=await t.match(r);if(!o)return;let i=o.headers.get(zo);if(!i){try{await t.delete(r)}catch(u){this.logDebug("Handled failure to delete with CF cache because of missing expiryHeader",u),await this.deleteFallback(e)}return}let a=parseInt(i);if(Date.now()>=a){try{await t.delete(r)}catch(u){this.logDebug("Handled failure to delete with CF cache because of expiration",u),await this.deleteFallback(e)}return}return await o.json()}catch(t){this.logDebug(t)}}async put(e,t,r){let o=new Headers({"cache-control":`s-maxage=${r}, must-revalidate`,"content-type":"application/json"});o.set(zo,`${Date.now()+r*1e3}`);let i=await this.#r(),a=this.#o(e),c=new Response(JSON.stringify(t),{headers:o});await i.put(a,c)}async delete(e){let t=await this.#r(),r=this.#o(e);try{await t.delete(r)}catch(o){this.logDebug("Handled failure to delete with CF cache due to explicit delete call",o),await this.deleteFallback(e)}}async deleteFallback(e){let t=new Headers({"Cache-Control":"s-maxage=0, must-revalidate"});t.set(zo,`${Date.now()}`);let r=await this.#r(),o=this.#o(e),i=new Response("",{headers:t});await r.put(o,i)}logDebug(...e){"logger"in this.#e?this.#e.logger?.debug(`Error in ZoneCache: '${this.#t}'`,e):"log"in this.#e&&this.#e.log.debug(`Error in ZoneCache: '${this.#t}'`,e)}};var me=class{static{s(this,"MemoryZoneReadThroughCache")}constructor(e,t){let r=`f6726488-fd18-4b7f-9c30-6070565e8042-${e}`;this.#e=e,this.#t=new et(r),this.#n=new $n(r,t),this.#r=t}#e;#t;#n;#r;async get(e){let t=this.#t.get(e);if(t)return t;let r=await this.#n.get(e);if(r){let o=Math.floor((r.expires-Date.now())/1e3);if(o>0)return this.#t.put(e,r.data,o),r.data}}put(e,t,r){this.#t.put(e,t,r);let o={data:t,expires:Date.now()+r*1e3},i=this.#n.put(e,o,r).catch(a=>{this.#r.log.error(`Error in MemoryZoneReadThroughCache: '${this.#e}'`,a)});this.#r.waitUntil(i)}async delete(e){this.#t.delete(e),await this.#n.delete(e)}};var Bo="__zuplo-expiry-header",Go=class{static{s(this,"StreamingZoneCache")}constructor(e,t){this.#t=e,this.#e=t}#e;#t;#n;async#r(){return this.#n||(this.#n=await caches.open(this.#t)),this.#n}#o(e){return new Request(`https://streaming-zone-cache.zuplo.app/${encodeURIComponent(e)}`)}async get(e){try{let t=await this.#r(),r=this.#o(e),o=await t.match(r);if(!o)return;let i=o.headers.get(Bo);if(!i){await t.delete(r).catch(c=>{this.logDebug(`StreamingZoneCache: error deleting missing expiry entry ${e}`,c)});return}let a=parseInt(i,10);if(Date.now()>=a){await t.delete(r).catch(c=>{this.logDebug(`StreamingZoneCache: error deleting expired entry ${e}`,c)});return}return o.body??void 0}catch(t){this.logDebug(`get(${e}) failed`,t);return}}async put(e,t,r){let o=new Headers({"cache-control":`s-maxage=${r}, must-revalidate`});o.set(Bo,`${Date.now()+r*1e3}`);let i=new Response(t,{headers:o}),a=await this.#r(),c=this.#o(e);await a.put(c,i)}async delete(e){try{await(await this.#r()).delete(this.#o(e))}catch(t){this.logDebug(`delete(${e}) fallback needed`,t),await this.deleteFallback(e)}}async deleteFallback(e){let t=new Headers({"Cache-Control":"s-maxage=0, must-revalidate",[Bo]:`${Date.now()}`}),r=new Response("",{headers:t}),o=await this.#r(),i=this.#o(e);await o.put(i,r)}logDebug(...e){"logger"in this.#e?this.#e.logger?.debug(`StreamingZoneCache(${this.#t}):`,...e):"log"in this.#e&&this.#e.log.debug(`StreamingZoneCache(${this.#t}):`,...e)}};var Ka="zuplo-request-id",an="zp-rid",Vo="zp-body-removed",Mt="cf-ray",Qa="x-real-ip",Wo="cf-ipcity",Jo="cf-ipcontinent",Ko="cf-ipcountry",Qo="cf-iplongitude",Yo="cf-iplatitude",Ya="cf-region",Xa="cf-region-code",ec="cf-metro-code",tc="cf-postal-code",nc="cf-timezone",Cr="zp-ipcity",Or="zp-ipcontinent",Ar="zp-ipcountry",_r="zp-iplongitude",kr="zp-iplatitude",rc="true-client-ip",oc="x-forwarded-for",Un="zp-asn",Xo="zp-asorg",ei="zp-colo",Hn="zp-postalcode",Fn="zp-metrocode",ti="zp-region",jn="zp-regioncode",zn="zp-timezone",ic="zp-http-protocol",ni="x-akamai-edgescape",sc=[Wo,Jo,Ko,Qo,Yo,Un,Xo,ei,Hn,Fn,ti,jn,zn,ni],ac=["zp-","cf-"],cc=[an,Mt,Vo];var Bn=Symbol("zuplo_meters"),Gn=Symbol("zuplo_dynamic_meters"),Lr="system-logger";var fe=class n{static{s(this,"ContextData")}static#e;#t;constructor(e){this.#t=e}set(e,t){n.set(e,this.#t,t)}get(e){return n.get(e,this.#t)}static set(e,t,r){n.#e||(n.#e=new WeakMap);let o=n.#e.get(e);o||(o=new Map),o.set(t,r),n.#e.set(e,o)}static get(e,t){return n.#e||(n.#e=new WeakMap),n.#e.get(e)?.get(t)}};import{trace as dp}from"@opentelemetry/api";import{SpanStatusCode as vd,trace as xd}from"@opentelemetry/api";import{SpanStatusCode as Zr,trace as qr}from"@opentelemetry/api";var uc=s(n=>(e,t)=>n(e,t),"globalRequestHandlerProxy");function lc(n){uc=n}s(lc,"setTelemetryInitFunction");var dc=s(n=>uc(n),"proxyHandler");var Rt=class{static{s(this,"RuntimePlugin")}},Ee=class extends Rt{static{s(this,"SystemRuntimePlugin")}async initialize(e){return Promise.resolve()}registerRoutes(e,t){}},Nr=class extends Ee{static{s(this,"MeteringPlugin")}},Vn=class extends Rt{static{s(this,"TelemetryPlugin")}};var Wn=class n{static{s(this,"InternalProblemResponseFormatter")}static problemResponseFormat=s(async e=>{let t=e.problem,r=JSON.stringify(t,null,2);return new Response(r,{status:e.problem.status,statusText:e.statusText,headers:{...e.additionalHeaders,"content-type":"application/problem+json"}})},"problemResponseFormat");static setProblemResponseFormat(e){e&&(g("runtime.problem-response-formatter"),n.problemResponseFormat=(t,r,o)=>{try{return e(t,r,o)}catch(i){throw new k("Error in custom 'problemResponseFormat'",{cause:i})}})}},Dt=class{static{s(this,"ProblemResponseFormatter")}static async format(e,t,r){return await Wn.problemResponseFormat(e,t,r)}};function Mr(n){for(let e in n){let t=n[e];t&&typeof t=="object"&&Mr(t)}return Object.freeze(n)}s(Mr,"deepFreeze");var ue=class n extends Request{static{s(this,"ZuploRequest")}#e=void 0;#t;constructor(e,t){super(e,t);let r=t?.params;r?this.#t=r:e instanceof n?this.#t=e.#t:this.#t={};let o=t?.user;o?this.user=o:e instanceof n&&(this.user=e.user)}get query(){if(this.#e===void 0){let e={},t=new URL(this.url).searchParams;for(let[r,o]of t.entries())e[r]=o;this.#e=e}return Mr(this.#e)}get params(){return Mr(this.#t)}user};var ai={},at=[],ri=[],oi=[],ii=[],si=[];var Dr={addPlugin(n){at.push(n)},addRequestHook(n){ri.push(n)},addResponseSendingHook(n){oi.push(n)},addResponseSendingFinalHook(n){ii.push(n)},addPreRoutingHook(n){si.push(n)}},mc=s(async(n,e)=>{if(ri.length===0)return n;let t=qr.getTracer("extension");return t.startActiveSpan("hook:onRequest",async r=>{try{let o=n;for(let i of ri){let a=await t.startActiveSpan(i.name,async c=>{let u=await i(o,e);if(u instanceof ue||u instanceof Response)return c.end(),u;{let l=new f(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof o}.`);throw c.end(),c.recordException(l),c.setStatus({code:Zr.ERROR}),l}});if(a instanceof ue)o=a;else return a}return o}finally{r.end()}})},"invokeOnRequestExtensions"),fc=s(async(n,e,t)=>{if(oi.length===0)return n;let r=qr.getTracer("extension");return r.startActiveSpan("hook:onResponseSending",async o=>{try{let i=n;for(let a of oi)await r.startActiveSpan(a.name,async c=>{let u=await a(n,e,t);if(u instanceof Response)i=u,c.end();else{let l=new f(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof i}.`);throw c.recordException(l),c.setStatus({code:Zr.ERROR}),c.end(),l}});return i}finally{o.end()}})},"invokeOnResponseSendingExtensions"),gc=s(async(n,e,t)=>{if(ii.length===0)return;let r=qr.getTracer("extension");return r.startActiveSpan("hook:onResponseSendingFinal",async o=>{try{for(let i of ii)await r.startActiveSpan(i.name,async a=>{try{await i(n,e,t)}catch(c){throw a.recordException(c),a.setStatus({code:Zr.ERROR}),a.end(),c}a.end()})}finally{o.end()}})},"invokeOnResponseSendingFinalExtensions"),hc=s(async n=>{if(si.length===0)return n;let e=qr.getTracer("extension");return e.startActiveSpan("hook:preRouting",async t=>{try{let r=n;for(let o of si)r=await e.startActiveSpan(o.name,async a=>{try{let c=await o(r);if(c instanceof Request)return c;{let u=new k(`Invalid state - the PreRouting hook must return a Request. Received ${typeof c}.`);throw a.recordException(u),a.setStatus({code:Zr.ERROR}),u}}finally{a.end()}});return r}finally{t.end()}})},"invokePreRoutingHooks"),pc=!1;async function yc(n){if(!pc){n&&(g("runtime.extensions"),await n(Dr)),ai.value=Dr;for(let e of at)if(e instanceof Vn){let{requestHandlerProxy:t}=e.instrument({accountName:y.instance.build.ACCOUNT_NAME,projectName:y.instance.build.PROJECT_NAME,buildId:y.instance.build.BUILD_ID,zuploVersion:y.instance.build.ZUPLO_VERSION,compatibilityDate:y.instance.build.COMPATIBILITY_DATE,instanceId:y.instance.instanceId,environmentType:y.instance.loggingEnvironmentType,environmentStage:y.instance.loggingEnvironmentStage,deploymentName:y.instance.deploymentName});lc(t)}await Promise.all(at.map(async e=>{e instanceof Ee&&await e.initialize(Dr)})),Wn.setProblemResponseFormat(Dr.problemResponseFormat),pc=!0}}s(yc,"initializeRuntime");var ci={Json:"application/json",Form:"application/x-www-form-urlencoded"};function ui(n,e){if(n!==null)return e&&typeof n=="string"?n:typeof n=="object"&&e?.startsWith(ci.Form)?new URLSearchParams(n).toString():typeof n=="object"&&e?.startsWith(ci.Json)||!e?JSON.stringify(n):n}s(ui,"serialize");function cn(n){return Ie.instance.runtimeSettings.developerPortal.enabled&&n.pathname.startsWith(Ie.instance.runtimeSettings.developerPortal.sitePathname)||n.pathname.startsWith("/__zuplo/")||n.pathname.startsWith("/__/zuplo/")}s(cn,"isSystemRoute");var Te=class{static{s(this,"Pipeline")}constructor(e){this.execute=this.#t(e)}execute;#e=s((e,t)=>async(r,o)=>xd.getTracer("pipeline").startActiveSpan(`handler:${o.route.handler.export}`,async a=>{try{return await e(r,o)}catch(c){let u=t.errorHandler(r,o,"Error executing request handler.",c);return a.setStatus({code:vd.ERROR}),u}finally{a.end()}}),"#errorWrappedHandler");#t=s(({processors:e,gateway:t,handler:r})=>async(o,i)=>{let a=_e.getContextExtensions(i),c=[...e],u=s(async b=>{let P=c.pop();if(!P){let A=await this.#e(async B=>{let $=await r(B,i);return Pd($)},t)(b,i);try{await a.onHandlerResponse(A,b,i)}catch(B){return t.errorHandler(o,i,"Error invoking 'context.onHandlerResponse' hook",B)}return A}return P(o,i,t,u)},"nextPipe"),d=await u(o),p=new URL(o.url);if(cn(p)&&y.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return d;let m=new Jn(o,d);i.dispatchEvent(m);let h=a.latestRequest,x;try{x=await m.mutableResponse}catch(b){return t.errorHandler(o,i,"Error retrieving mutableResponse",b)}try{x=await a.onResponseSending(x,h,i)}catch(b){return t.errorHandler(o,i,"Error invoking 'context.onResponseSending' hook",b)}try{x=await fc(x,h,i)}catch(b){return t.errorHandler(o,i,"Error invoking 'context.onResponseSending' hook",b)}i.dispatchEvent(new Kn(o,x));try{await a.onResponseSendingFinal(d,h,i)}catch(b){throw i.log.error("Error invoking 'runtime.onResponseSending' hook",b),b}try{await gc(d,h,i)}catch(b){throw i.log.error("Error invoking 'runtime.onResponseSending' hook",b),b}return x},"#toZuploPipeline")};function Pd(n){return n instanceof Response?n:typeof n>"u"?new Response:new Response(ui(n),{headers:{"content-type":"application/json"}})}s(Pd,"resultToResponse");var tt=class extends Rt{static{s(this,"MetricsPlugin")}};var ne=class n{static{s(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(e){let t=n.#e.get(e);if(!t){let r=`No system logger found for context with requestId '${e.requestId}'`;throw console.error(r),new ae(r)}return t}static addLogger(e,t){n.#e.set(e,t)}};var ie=class{static{s(this,"BatchDispatch")}constructor(e,t,r,o){this.#t=e,this.#i=t,this.#r=r,this.#n=o??console}#e=void 0;#t;#n;#r;#o=[];#i;enqueue=s(e=>{this.#o.push(e),this.#e||(this.#e=new Promise(t=>{setTimeout(()=>{if(this.#o.length>0){let r=[...this.#o];this.#o.length=0,this.#e=void 0,this.#r(r).catch(o=>{this.#n.error(`Uncaught error in BatchDispatcher named '${this.#t}'}`,o.message,o.stack)}).finally(()=>{t()})}},this.#i)}))},"enqueue");waitUntilFlushed=s(async()=>{if(this.#e)return this.#e},"waitUntilFlushed")};var $r=class{static{s(this,"ZuploMetricsTransport")}#e;#t;constructor(e){this.#e=e,this.#t=new ie("zuplo-metrics-transport",10,this.dispatchFunction,ne.getLogger(e))}pushMetrics(e,t){this.#t.enqueue(e),t.waitUntil(this.#t.waitUntilFlushed())}dispatchFunction=s(async e=>{if(e.length!==0)try{let{remoteLogURL:t,deploymentName:r}=y.instance,{ACCOUNT_NAME:o,PROJECT_NAME:i}=y.instance.build,a=e.map(p=>{let m=Object.assign({},p);return delete m.requestContentLength,delete m.responseContentLength,m}),c=Va(),u={metadata:{timestamp:new Date,accountName:o,projectName:i,deploymentName:r},metrics:a,features:c},l=new Headers({"content-type":"application/json"});Xe(l);let d=await j.fetch(`${t}/v2/runtime/metrics`,{method:"POST",body:JSON.stringify(u),headers:l});if(!d.ok){let p=await d.text();ne.getLogger(this.#e).error(`Metrics POST responded ${d.status}: ${d.statusText}`,p),Wa(c)}}catch(t){ne.getLogger(this.#e).error("Failed to send Zuplo metrics.",t)}},"dispatchFunction")};var xe=class{static{s(this,"SystemRouteConfiguration")}constructor({label:e,path:t,methods:r,systemRouteName:o,corsPolicy:i="none"}){this.label=e,this.path=t,this.methods=r,this.corsPolicy=i,this.handler={export:"SYSTEM_IGNORED",module:"SYSTEM_IGNORED"},this.systemRouteName=o}label;path;methods;handler;corsPolicy;policies;systemRouteName;raw(){return{}}};function bc(n){let e=n.headers,t=e.get(rc);if(t)return t;let r=e.get(oc);if(r)return r.split(",")[0].trim()}s(bc,"getClientIp");var ke=s(async(n,e,t,r)=>{let o=new Date,i=Date.now(),a=await r(n),c=n.headers.get(Mt)??void 0,u=bc(n),l=e.incomingRequestProperties,d;e.route instanceof xe&&(d=e.route.systemRouteName);let p=_e.getContextExtensions(e).latestRequest,m={timestamp:o,statusCode:a.status,durationMs:Date.now()-i,requestContentLength:n.headers.get("content-length")?Number(n.headers.get("content-length")):void 0,responseContentLength:a.headers.get("content-length")?Number(a.headers.get("content-length")):void 0,routePath:e.route?.path??"SYSTEM_OR_NOT_FOUND",systemRouteName:d,contextId:e.contextId,parentContextId:e.parentContext?.contextId,requestId:e.requestId,parentRequestId:e.parentContext?.requestId,method:n.method,asn:l.asn,asOrganization:l.asOrganization,colo:l.colo,continent:l.continent,country:l.country,city:l.city,latitude:l.latitude,longitude:l.longitude,rayId:c,instanceId:y.instance.instanceId,userSub:p.user?.sub,clientIp:u},h=[];return!y.instance.isLocalDevelopment&&y.instance.remoteLogURL&&y.instance.remoteLogToken&&y.instance.loggingId&&h.push(new $r(e)),at.forEach(x=>{if(x instanceof tt){let b=x.getTransport();h.push(b)}}),h.forEach(x=>{x.pushMetrics(m,e)}),a},"metricsProcessor");var li=s((n,e)=>{let t=s(async(i,a)=>{let c=new URL(i.url),u=y.instance.build,l={buildId:u.BUILD_ID,zuploVersion:u.ZUPLO_VERSION,compatibilityDate:u.COMPATIBILITY_DATE,apiVersion:u.API_VERSION,gitSha:u.GIT_SHA,timestamp:u.TIMESTAMP,isProduction:u.ENVIRONMENT_TYPE==="PRODUCTION"};if(c.searchParams.get("system_log")==="true"&&ne.getLogger(a).error("Test System Log",l),c.searchParams.get("error")==="true")throw new Error("this is an unhandled error");return new Response(JSON.stringify(l,null,2),{status:200,headers:{"content-type":"application/json"}})},"buildRouteHandler"),r=new Te({processors:[ke],handler:t,gateway:e}),o=new xe({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:"build-data"});n.addRoute(o,r.execute)},"registerBuildRoute");var Ur=(R=>(R[R.CONTINUE=100]="CONTINUE",R[R.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",R[R.PROCESSING=102]="PROCESSING",R[R.EARLY_HINTS=103]="EARLY_HINTS",R[R.OK=200]="OK",R[R.CREATED=201]="CREATED",R[R.ACCEPTED=202]="ACCEPTED",R[R.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",R[R.NO_CONTENT=204]="NO_CONTENT",R[R.RESET_CONTENT=205]="RESET_CONTENT",R[R.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",R[R.MULTI_STATUS=207]="MULTI_STATUS",R[R.ALREADY_REPORTED=208]="ALREADY_REPORTED",R[R.IM_USED=226]="IM_USED",R[R.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",R[R.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",R[R.FOUND=302]="FOUND",R[R.SEE_OTHER=303]="SEE_OTHER",R[R.NOT_MODIFIED=304]="NOT_MODIFIED",R[R.USE_PROXY=305]="USE_PROXY",R[R.SWITCH_PROXY=306]="SWITCH_PROXY",R[R.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",R[R.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",R[R.BAD_REQUEST=400]="BAD_REQUEST",R[R.UNAUTHORIZED=401]="UNAUTHORIZED",R[R.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",R[R.FORBIDDEN=403]="FORBIDDEN",R[R.NOT_FOUND=404]="NOT_FOUND",R[R.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",R[R.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",R[R.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",R[R.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",R[R.CONFLICT=409]="CONFLICT",R[R.GONE=410]="GONE",R[R.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",R[R.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",R[R.CONTENT_TOO_LARGE=413]="CONTENT_TOO_LARGE",R[R.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",R[R.URI_TOO_LONG=414]="URI_TOO_LONG",R[R.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",R[R.RANGE_NOT_SATISFIABLE=416]="RANGE_NOT_SATISFIABLE",R[R.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",R[R.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",R[R.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",R[R.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",R[R.UNPROCESSABLE_CONTENT=422]="UNPROCESSABLE_CONTENT",R[R.LOCKED=423]="LOCKED",R[R.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",R[R.TOO_EARLY=425]="TOO_EARLY",R[R.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",R[R.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",R[R.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",R[R.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",R[R.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",R[R.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",R[R.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",R[R.BAD_GATEWAY=502]="BAD_GATEWAY",R[R.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",R[R.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",R[R.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",R[R.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",R[R.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",R[R.LOOP_DETECTED=508]="LOOP_DETECTED",R[R.NOT_EXTENDED=510]="NOT_EXTENDED",R[R.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED",R))(Ur||{}),wc={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Content Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};var Id={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},di=Id;function Ed(n){return`${new URL(n.url).pathname}`}s(Ed,"instance");function Td(n,e){let t={timestamp:new Date().toISOString(),requestId:e.requestId,buildId:y.instance.build.BUILD_ID},r=n.headers.get(Mt);return r&&(t.rayId=r),t}s(Td,"trace");var Sd=s((n,e,t,r,o)=>({problem:{type:n.type,title:n.title,status:n.status,detail:n.detail,instance:Ed(e),trace:Td(e,t),...r},additionalHeaders:o,statusText:di[n.status]}),"merge"),pi=class{static{s(this,"HttpProblemsBase")}static format=s((e,t,r)=>"problem"in e?Dt.format(e,t,r):Dt.format({problem:e},t,r),"format");static getProblemFromStatus(e,t){return{type:`https://httpproblems.com/http-status/${e}`,status:e,title:wc[e],...t}}},T=class extends pi{static{s(this,"HttpProblems")}static#e(e,t,r,o,i){let a=Sd(this.getProblemFromStatus(e),t,r,o,i);return Dt.format(a,t,r)}static continue=s((e,t,r,o)=>this.#e(200,e,t,r,o),"continue");static switchingProtocols=s((e,t,r,o)=>this.#e(101,e,t,r,o),"switchingProtocols");static processing=s((e,t,r,o)=>this.#e(102,e,t,r,o),"processing");static earlyHints=s((e,t,r,o)=>this.#e(103,e,t,r,o),"earlyHints");static ok=s((e,t,r,o)=>this.#e(200,e,t,r,o),"ok");static created=s((e,t,r,o)=>this.#e(201,e,t,r,o),"created");static accepted=s((e,t,r,o)=>this.#e(202,e,t,r,o),"accepted");static nonAuthoritativeInformation=s((e,t,r,o)=>this.#e(203,e,t,r,o),"nonAuthoritativeInformation");static noContent=s((e,t,r,o)=>this.#e(204,e,t,r,o),"noContent");static resetContent=s((e,t,r,o)=>this.#e(205,e,t,r,o),"resetContent");static partialContent=s((e,t,r,o)=>this.#e(206,e,t,r,o),"partialContent");static multiStatus=s((e,t,r,o)=>this.#e(207,e,t,r,o),"multiStatus");static alreadyReported=s((e,t,r,o)=>this.#e(208,e,t,r,o),"alreadyReported");static imUsed=s((e,t,r,o)=>this.#e(226,e,t,r,o),"imUsed");static multipleChoices=s((e,t,r,o)=>this.#e(300,e,t,r,o),"multipleChoices");static movedPermanently=s((e,t,r,o)=>this.#e(301,e,t,r,o),"movedPermanently");static found=s((e,t,r,o)=>this.#e(302,e,t,r,o),"found");static seeOther=s((e,t,r,o)=>this.#e(303,e,t,r,o),"seeOther");static notModified=s((e,t,r,o)=>this.#e(304,e,t,r,o),"notModified");static useProxy=s((e,t,r,o)=>this.#e(305,e,t,r,o),"useProxy");static switchProxy=s((e,t,r,o)=>this.#e(306,e,t,r,o),"switchProxy");static temporaryRedirect=s((e,t,r,o)=>this.#e(307,e,t,r,o),"temporaryRedirect");static permanentRedirect=s((e,t,r,o)=>this.#e(308,e,t,r,o),"permanentRedirect");static badRequest=s((e,t,r,o)=>this.#e(400,e,t,r,o),"badRequest");static unauthorized=s((e,t,r,o)=>this.#e(401,e,t,r,o),"unauthorized");static paymentRequired=s((e,t,r,o)=>this.#e(402,e,t,r,o),"paymentRequired");static forbidden=s((e,t,r,o)=>this.#e(403,e,t,r,o),"forbidden");static notFound=s((e,t,r,o)=>this.#e(404,e,t,r,o),"notFound");static methodNotAllowed=s((e,t,r,o)=>this.#e(405,e,t,r,o),"methodNotAllowed");static notAcceptable=s((e,t,r,o)=>this.#e(406,e,t,r,o),"notAcceptable");static proxyAuthenticationRequired=s((e,t,r,o)=>this.#e(407,e,t,r,o),"proxyAuthenticationRequired");static requestTimeout=s((e,t,r,o)=>this.#e(408,e,t,r,o),"requestTimeout");static conflict=s((e,t,r,o)=>this.#e(409,e,t,r,o),"conflict");static gone=s((e,t,r,o)=>this.#e(410,e,t,r,o),"gone");static lengthRequired=s((e,t,r,o)=>this.#e(411,e,t,r,o),"lengthRequired");static preconditionFailed=s((e,t,r,o)=>this.#e(412,e,t,r,o),"preconditionFailed");static contentTooLarge=s((e,t,r,o)=>this.#e(413,e,t,r,o),"contentTooLarge");static uriTooLong=s((e,t,r,o)=>this.#e(414,e,t,r,o),"uriTooLong");static unsupportedMediaType=s((e,t,r,o)=>this.#e(415,e,t,r,o),"unsupportedMediaType");static rangeNotSatisfiable=s((e,t,r,o)=>this.#e(416,e,t,r,o),"rangeNotSatisfiable");static expectationFailed=s((e,t,r,o)=>this.#e(417,e,t,r,o),"expectationFailed");static imATeapot=s((e,t,r,o)=>this.#e(418,e,t,r,o),"imATeapot");static misdirectedRequest=s((e,t,r,o)=>this.#e(421,e,t,r,o),"misdirectedRequest");static unprocessableContent=s((e,t,r,o)=>this.#e(422,e,t,r,o),"unprocessableContent");static locked=s((e,t,r,o)=>this.#e(423,e,t,r,o),"locked");static failedDependency=s((e,t,r,o)=>this.#e(424,e,t,r,o),"failedDependency");static tooEarly=s((e,t,r,o)=>this.#e(425,e,t,r,o),"tooEarly");static upgradeRequired=s((e,t,r,o)=>this.#e(426,e,t,r,o),"upgradeRequired");static preconditionRequired=s((e,t,r,o)=>this.#e(428,e,t,r,o),"preconditionRequired");static tooManyRequests=s((e,t,r,o)=>this.#e(429,e,t,r,o),"tooManyRequests");static requestHeaderFieldsTooLarge=s((e,t,r,o)=>this.#e(431,e,t,r,o),"requestHeaderFieldsTooLarge");static unavailableForLegalReasons=s((e,t,r,o)=>this.#e(451,e,t,r,o),"unavailableForLegalReasons");static internalServerError=s((e,t,r,o)=>this.#e(500,e,t,r,o),"internalServerError");static notImplemented=s((e,t,r,o)=>this.#e(501,e,t,r,o),"notImplemented");static badGateway=s((e,t,r,o)=>this.#e(502,e,t,r,o),"badGateway");static serviceUnavailable=s((e,t,r,o)=>this.#e(503,e,t,r,o),"serviceUnavailable");static gatewayTimeout=s((e,t,r,o)=>this.#e(504,e,t,r,o),"gatewayTimeout");static httpVersionNotSupported=s((e,t,r,o)=>this.#e(505,e,t,r,o),"httpVersionNotSupported");static variantAlsoNegotiates=s((e,t,r,o)=>this.#e(506,e,t,r,o),"variantAlsoNegotiates");static insufficientStorage=s((e,t,r,o)=>this.#e(507,e,t,r,o),"insufficientStorage");static loopDetected=s((e,t,r,o)=>this.#e(508,e,t,r,o),"loopDetected");static notExtended=s((e,t,r,o)=>this.#e(510,e,t,r,o),"notExtended");static networkAuthenticationRequired=s((e,t,r,o)=>this.#e(511,e,t,r,o),"networkAuthenticationRequired")};var{toString:Cd}=Object.prototype,{propertyIsEnumerable:Od}=Object.prototype;function mi(n){return Cd.call(n)}s(mi,"toString");function qe(n){return typeof n=="string"}s(qe,"isString");function un(n){return qe(n)&&n!==""}s(un,"isNonEmptyString");function Rc(n){return mi(n)==="[object RegExp]"}s(Rc,"isRegexp");function vc(n){return[...Object.keys(n),...Object.getOwnPropertySymbols(n).filter(e=>Od.call(n,e))]}s(vc,"getOwnEnumerableKeys");function Zt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!(n instanceof RegExp)&&!(n instanceof Date)}s(Zt,"isObject");function fi(n){return typeof n=="number"&&!isNaN(n)}s(fi,"isNumber");function gi(n){return n===!0||n===!1}s(gi,"isBoolean");function xc(n){return typeof n>"u"}s(xc,"isUndefined");function Pc(n){return xc(n)||n===null}s(Pc,"isUndefinedOrNull");function Qn(n){return!!n&&typeof n=="object"&&"name"in n&&"message"in n&&"stack"in n}s(Qn,"isErrorLike");var Ic=new Map;function vt(n){if(Array.isArray(n)&&!n.some(o=>typeof o!="number"))return n;if(typeof n!="string")throw new Error("Input must be a string or an array of numbers");if(!/^\d+(?:-\d+)?(?:,\s*\d+(?:-\d+)?)*$/.test(n))throw new f("Malformed input string");let e=Ic.get(n);if(e)return e;let t=n.split(","),r=[];for(let o of t){let i=o.split("-");if(i.length===2){let a=parseInt(i[0],10),c=parseInt(i[1],10);for(let u=a;u<=c;u++)r.push(u)}else r.push(parseInt(o,10))}return Ic.set(n,r),r}s(vt,"statusCodesStringToNumberArray");function ct(n,e,t){if(!e.startsWith("."))throw new f(`Invalid ${t} - must start with '.' - '${e}' does not`);let r=e.split(".").splice(1),o=n;return r.forEach(i=>{if(o===void 0)throw new k(`Error applying ${t} '${e}', reading '${i}'`);o=o[i]}),`${o}`}s(ct,"getValueFromRequestUser");function ut(n){if(Array.isArray(n)){if(n.includes(t=>typeof t!="string"))throw new f("Received an array that contains non-string values.");return n}if(qe(n))return n.includes(",")?n.split(",").map(t=>t.trim()).filter(t=>t!==","&&t!==""):[n];throw new f(`Expected type of string, received type '${typeof n}'`)}s(ut,"parseValueToStringArray");function Ec(n){if(n==null)return[];if(!Array.isArray(n))throw new f(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof n}'`);return n.map(t=>{if(!Zt(t))throw new f(`Invalid custom cors policy is set. Expected an object, received '${typeof t}'`);if(!un(t.name))throw new f("Value of 'name' on custom cors policies must be a non-empty string.");if(t.maxAge!==void 0&&!fi(t.maxAge))throw new f(`Value of 'maxAge' on custom cors policies must be a non-empty string. Received type '${typeof t.maxAge}'`);if(t.allowCredentials!==void 0&&!gi(t.allowCredentials))throw new f("Value of 'allowCredentials' on custom cors policies must be a boolean or not be set. If using an environment variable, check that it is set correctly.");let r=hi(t,"allowedHeaders"),o=hi(t,"allowedMethods"),i=hi(t,"exposeHeaders"),a;try{a=ut(t.allowedOrigins)}catch(u){throw new f(`Value of 'allowedOrigins' on custom cors policies is invalid. ${u.message} If using an environment variable, check that it is set correctly.`)}return{name:t.name,allowCredentials:typeof t.allowCredentials=="boolean"?String(t.allowCredentials):void 0,allowedOrigins:a,allowedHeaders:r?r.join(", "):void 0,allowedMethods:o?o.join(", "):void 0,exposeHeaders:i?i.join(", "):void 0,maxAge:typeof t.maxAge=="number"?t.maxAge.toString():void 0}})}s(Ec,"parseCorsPolicies");function hi(n,e){let t;if(n[e]!==void 0)try{t=ut(n[e])}catch(r){throw new f(`Value of '${e}' on custom cors policies is invalid. ${r.message} If using an environment variable, check that it is set correctly.`)}return t}s(hi,"parseOptionalProperty");var Hr=s((n,e)=>{if(e===null)return;if(n.find(a=>a==="*"))return e;let r=n.map(a=>a.trim().toLowerCase()),o=e.toLowerCase();return r.find(a=>a===o)},"findMatchingOrigin"),Fr=s((n,e)=>{let t={"access-control-allow-origin":e};n.allowedHeaders&&(t["access-control-allow-headers"]=n.allowedHeaders),n.allowedMethods&&(t["access-control-allow-methods"]=n.allowedMethods),n.exposeHeaders&&(t["access-control-expose-headers"]=n.exposeHeaders);let r=n.allowCredentials;r&&(t["access-control-allow-credentials"]=r);let o=n.maxAge?.toString()??void 0;return o&&(t["access-control-max-age"]=o),t},"generateCorsHeaders");var yi=s((n,e)=>{let t=e.routeData.corsPolicies,r=s(async(a,c)=>{let u=new URL(a.url.toString()).pathname,l=a.headers.get("access-control-request-method"),d=a.headers.get("access-control-request-headers"),p=a.headers.get("origin");if(p===null||l===null)return T.badRequest(a,c,{detail:"Expect headers origin and access-control-request-method"});let m=n.lookup(u,l);if(!m)return T.notFound(a,c);let h=m.routeConfiguration,x=Ad(l,d,p,h,t);return x.isValid?new Response(void 0,{status:200,statusText:"OK",headers:x.headers}):(x.error&&c.log.warn(x.error),T.notFound(a,c))},"optionsHandler"),o=new Te({processors:[ke],handler:r,gateway:e}),i=new xe({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:"cors-preflight"});n.addRoute(i,o.execute)},"registerCorsRoute"),Ad=s((n,e,t,r,o)=>{let i={isValid:!1,headers:{}};if(r.corsPolicy==="anything-goes")return{isValid:!0,headers:{"access-control-allow-origin":t,"access-control-allow-methods":n,"access-control-allow-headers":e??"*","access-control-expose-headers":"*","access-control-allow-credentials":"true","access-control-max-age":"600"}};if(r.corsPolicy==="none")return{...i,error:`No CORS policy set for the route '${r.pathPattern}'`};let a=o?.find(l=>l.name===r.corsPolicy);if(!a)throw new f(`Invalid Configuration - corsPolicy '${r.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let c=Hr(a.allowedOrigins,t);return c?{isValid:!0,headers:Fr(a,c)}:{...i,error:`The CORS policy '${a.name}' does not allow the origin '${t}'`}},"validateAndBuildResponseHeaders");var Tc=s((n,e)=>{let t=s(async()=>new Response("You have no routes. Add a route in routes.oas.json to get started",{status:200}),"noRoutesHandler"),r=new Te({processors:[ke],handler:t,gateway:e}),o=new xe({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"empty-gateway-catchall"});n.addRoute(o,r.execute)},"registerNoRoutes");var xt=class{static{s(this,"UserRouteConfiguration")}constructor(e){this.path=e.path,this.methods=e.methods,this.label=e.label,this.key=e.key,this.handler=e.handler,this.corsPolicy=e.corsPolicy,this.custom=e.custom,this.policies=e.policies,this.excludeFromOpenApi=e.excludeFromOpenApi,this.pathPattern=e.pathPattern,this.raw=e.raw}raw;get summary(){return this.raw()?.summary}get operationId(){return this.raw()?.operationId}get tags(){return this.raw()?.tags}get parameters(){return this.raw()?.parameters}get responses(){return this.raw()?.responses}label;key;path;excludeFromOpenApi;pathPattern;custom;methods;handler;corsPolicy;policies};var _d=new xe({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"unmatched-path"}),Sc=s((n,e)=>{let t=s(async(o,i)=>{let a=ai.value?.notFoundHandler;if(a){let c=new URL(o.url);return a(o,i,{get routesMatchedByPathOnly(){return n.lookupByPathOnly(c.pathname).map(l=>l.routeConfiguration).filter(l=>l instanceof xt)}})}return T.notFound(o,i)},"notFoundHandler"),r=new Te({processors:[ke],handler:t,gateway:e});n.addRoute(_d,r.execute)},"registerNotMatchedHandler");var kd=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],Cc=s(n=>{kd.forEach(e=>n.delete(e))},"stripCorsHeaders"),jr=s(async(n,e,t,r)=>{let o=e.route;if(!o.corsPolicy||o.corsPolicy==="none"){let d=await r(n),p=new Headers(d.headers);return Cc(p),new Response(d.body,{status:d.status,statusText:d.statusText,headers:p,webSocket:d.webSocket})}let i=await r(n);if(!(i instanceof Response))throw new ae(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof i}'`);let a=Ld(o,t.routeData.corsPolicies),c=Nd(n,a),u=new Headers(i.headers);return Cc(u),Object.entries(c).forEach(([d,p])=>{u.set(d,p)}),new Response(i.body,{status:i.status,statusText:i.statusText,headers:u,webSocket:i.webSocket})},"corsProcessor"),Ld=s((n,e)=>{if(n.corsPolicy==="anything-goes")return{name:"anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:n.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};let t=e?.find(r=>r.name===n.corsPolicy);if(t===void 0)throw new f(`Invalid Configuration - no corsPolicy '${n.corsPolicy}' found in *.oas.json`);return t},"getCorsPolicy"),Nd=s((n,e)=>{let t=Hr(e.allowedOrigins,n.headers.get("origin"));return t?Fr(e,t):{}},"getCorsHeaders");var bi=s((n,e)=>{let t=s(async()=>new Response(JSON.stringify({buildId:y.instance.build.BUILD_ID}),{status:200,headers:{"content-type":"application/json"}}),"pingRouteHandler"),r=new Te({processors:[jr],handler:t,gateway:e}),o=new xe({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:"ping"});n.addRoute(o,r.execute)},"registerPingRoute");import{SpanStatusCode as Oc,trace as Ac}from"@opentelemetry/api";var lt={RoutePathPattern:"zuplo.route.path_pattern",RouteOperationId:"zuplo.route.operation_id",RouteTrace:"zuplo.route.trace",RouteSystem:"zuplo.route.system",SystemTrace:"zuplo.system",PolicyName:"zuplo.policy.name",PolicyType:"zuplo.policy.type",ZuploBuildId:"zuplo.build.id",ZuploBuildVersion:"zuplo.build.version",ZuploBuildCompatibilityDate:"zuplo.build.compatibility_date",ZuploEnvironmentType:"zuplo.environment_type"};var zr=class{static{s(this,"PolicyBase")}options;policyName;policyType;constructor(e,t){if(!qe(t))throw new k(`The name of a policy must be a string. Received '${t}' of type '${typeof t}'`);this.options=e,this.policyName=t,this.policyType=Object.getPrototypeOf(this).constructor.name}},ye=class extends zr{static{s(this,"InboundPolicy")}},Pt=class extends zr{static{s(this,"OutboundPolicy")}};var vi=class extends ye{static{s(this,"InboundFunctionOnlyPolicy")}#e;constructor(e,t,r){super(t,r),this.policyType=e.name,this.#e=e}handler(e,t){return this.#e(e,t,this.options,this.policyName)}},xi=class extends Pt{static{s(this,"OutboundFunctionOnlyPolicy")}#e;constructor(e,t,r){super(t,r),this.policyType=e.name,this.#e=e}handler(e,t,r){return this.#e(e,t,r,this.options,this.policyName)}},wi=new Map;function Yn(n,e){let t,r;return Array.isArray(n)?t=n:(t=n.policies?.inbound??[],r=n.path),t.filter(i=>!wi.has(i)).forEach(i=>{let a=e?.find(l=>l.name===i);if(!a)throw new f(`Invalid state - no Policy with the name '${i}' ${r&&`on route '${r}'`} was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export];if(typeof c!="function")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof module '${typeof c}')`);let u;if(typeof c!="function")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof module '${typeof c}')`);if(c.prototype instanceof ye)u=new c(a.handler.options,a.name);else if(typeof c=="function")u=new vi(c,a.handler.options,a.name);else throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new f(`Invalid state - invalid handler on policy '${i}' on route '${r}' (typeof handler '${typeof u.handler}')`);wi.set(a.name,u)}),t.map(i=>{let a=wi.get(i);if(a===void 0)throw new k("Internal error. Policy not found in cache.");return a})}s(Yn,"getInboundPolicyInstances");var Ri=new Map;function Xn(n,e){let t,r;return Array.isArray(n)?t=n:(t=n.policies?.outbound??[],r=n.path),t.filter(i=>!Ri.has(i)).forEach(i=>{let a=e?.find(l=>l.name===i);if(!a)throw new f(`Invalid state - no Policy with the name '${i}' on route '${r}' was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export],u;if(typeof c!="function")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof module '${typeof c}')`);if(c.prototype instanceof Pt)u=new c(a.handler.options??{},a.name);else if(typeof c=="function")u=new xi(c,a.handler.options??{},a.name);else throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new f(`Invalid state - invalid handler on policy '${i}' on route '${r}'`);Ri.set(a.name,u)}),t.map(i=>{let a=Ri.get(i);if(a===void 0)throw new k("Internal error. Policy not found in cache.");return a})}s(Xn,"getOutboundPolicyInstances");var Pi=s(n=>async(e,t)=>{let r=_e.getContextExtensions(t),o=Ac.getTracer("pipeline");return await o.startActiveSpan("policies:inbound",async i=>{try{let a=[...n],c=e;for(;a.length>0;){let u=a.shift();if(!u)return c;let l=await o.startActiveSpan(`policy:${u.policyName}`,async d=>{let p=await u.handler(c,t);if(p instanceof Request||p instanceof ue||p instanceof Response)return d.end(),p instanceof Response||p instanceof ue?p:new ue(p);{let m=new f(`Invalid state - invalid handler on policy '${u.policyName}' on route '${t.route.path}. The result of an inbound policy must be a Response or Request.`);throw d.end(),d.setStatus({code:Oc.ERROR}),d.recordException(m),m}});if(l instanceof ue)c=l;else if(l instanceof Request)c=new ue(l);else if(l instanceof Response)return l;r.latestRequest=c}return c}finally{i.end()}})},"toStackedInboundHandler"),Ii=s(n=>async(e,t,r)=>{let o=Ac.getTracer("pipeline");return await o.startActiveSpan("policies:outbound",async i=>{try{let a=[...n],c=e;for(;a.length>0;){let u=a.shift();if(!u)return c;c=await o.startActiveSpan(`policy:${u.policyName}`,async d=>{try{d.setAttribute(lt.PolicyName,u.policyName),d.setAttribute(lt.PolicyType,u.policyType);let p=await u.handler(c,t,r);if(p instanceof Response)return p;{let m=new f(`Invalid state - invalid handler on policy '${u.policyName}' on route '${r.route.path}. The result of an outbound policy must be a Response.`);throw d.setStatus({code:Oc.ERROR}),d.recordException(m),m}}finally{d.end()}})}return c}finally{i.end()}})},"toStackedOutboundHandler"),Br=s(async(n,e,t,r)=>{let o=Yn(e.route,t.routeData.policies),i=Xn(e.route,t.routeData.policies);return kc({request:n,context:e,inboundPolicies:o,outboundPolicies:i,gateway:t,next:r})},"policyProcessor");function _c({inboundPolicies:n=[],outboundPolicies:e=[]}){return s(async(r,o,i,a)=>kc({request:r,context:o,inboundPolicies:n,outboundPolicies:e,gateway:i,next:a}),"policyProcessor")}s(_c,"createInternalPolicyProcessor");async function kc({request:n,context:e,inboundPolicies:t,outboundPolicies:r,gateway:o,next:i}){let a=Pi(t);try{let c=await a(n,e);if(c instanceof Response)return c;let u=await i(c),l=Ii(r),d;return y.instance.build.COMPATIBILITY_FLAGS.runOutboundPoliciesOnHandlerOnAllStatuses?d=l(u,n,e):d=u.ok?l(u,n,e):u,d}catch(c){return o.errorHandler(n,e,"Error executing policies",c)}}s(kc,"executePolicyProcessor");var Dc=Jl(Mc(),1);function Zc(n,e){try{let t=/v\d+(-\d+)?/g,o=(0,Dc.parse)(e.get("Cookie")||"")["zp-dev-portal"];return o!==null&&o&&t.test(o)?`https://dev-portal-${o}.zuplo.com`:n}catch{}return n}s(Zc,"devPortalBaseURL");var qc="/__zuplo/dev-portal",Bd="dev-portal-id",Gd="dev-portal-host",Vd="zp-account",Wd="zp-project",Jd="dev-portal-build",Kd=`
35
+ `)+" "+t[1]:t[0]+e+" "+n.join(", ")+" "+t[1]}s(fd,"reduceToSingleString");var Ha=s((n,...e)=>Ma(wt,n,e),"format");var $o=class{static{s(this,"Debugger")}manager;ns;color;last;enabled;constructor(e,t){this.manager=e,this.ns=t,this.color=Na(t),this.last=0,this.enabled=e.enabled.some(r=>r.test(t))}log(...e){if(!this.enabled)return;let t,r=e[0];typeof r=="function"?t=r():t=String(r);let o=Date.now()-(this.last||Date.now());t=Ha(t,...e);let i=`${this.color(this.ns)} ${t} ${this.color(`+${o}ms`)}`;console.log(i),this.last=Date.now()}},Uo=class{static{s(this,"DebugManager")}debuggers;enabled;constructor(e){this.debuggers=new Map,this.enabled=e??[]}};function gd(n){return!n||n.length===0?[]:(n=n.replace(/\s/g,"").replace(/\*/g,".+"),n.split(",").map(e=>new RegExp(`^${e}$`)))}s(gd,"extract");var Ir;function Ce(n){let e=globalThis.DEBUG;Ir||(Ir=new Uo(gd(e)));let t=new $o(Ir,n);return Ir.debuggers.set(n,t),Object.assign(t.log.bind(t),{self:t})}s(Ce,"debug");var ae=class extends Error{static{s(this,"SystemError")}constructor(e,t){super(e,t),this.name="InternalError"}},k=class extends Error{static{s(this,"RuntimeError")}extensionMembers;constructor(e,t){typeof e=="string"?super(e,t):(super(e.message,t),this.extensionMembers=e.extensionMembers),this.name="RuntimeError"}},f=class extends k{static{s(this,"ConfigurationError")}constructor(e,t){super(e,t),this.name="ConfigurationError"}};var Nt=Ce("zuplo:runtime:external-service");function hd(){let n,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:e}=y.instance.runtime;if(e&&e!=="undefined")try{let t=atob(e);n=JSON.parse(t)}catch{}return n}s(hd,"getServiceAuth");async function Fa(n,e){let t=hd();if(t)if(Nt(`Using external service auth. ClientId: ${t.clientId})`),typeof n=="string"){let r=new URL(n),o=r.hostname,i=e??{},a=new Headers(i.headers||{});a.set("CF-Access-Client-Id",t.clientId),a.set("CF-Access-Client-Secret",t.clientSecret),i.headers=a;let c;if(t.customServiceMapping&&t.customServiceMapping[o])c=`https://${t.customServiceMapping[o]}`;else if(y.instance.useLegacyServiceRouting)c=`https://${o}.zuptunnel.com`;else{Nt("Using sha256 service routing");let d=y.instance.build;if(d.ACCOUNT_NAME&&d.PROJECT_NAME&&d.ENVIRONMENT_TYPE){let p=await yd(o,d.ACCOUNT_NAME,d.PROJECT_NAME,d.ENVIRONMENT_TYPE),m=ja(d.ENVIRONMENT_TYPE),h=await Ho(`${d.ACCOUNT_NAME}-${d.PROJECT_NAME}-${m}`);h==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||h==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?c=`https://${p}.zuptunnel.com`:c=`https://${p}.t.zuplo.app`}else throw Nt("Cannot use sha256 service routing, missing build variables"),new k("Failed to generate fully qualified tunnel url.")}let u=new URL(`${c}${r.pathname}${r.search}`);Nt(`Calling external service: ${u.toString()}`);let l=await Er(u.toString(),i);if(l.status===403&&l.headers.get("cf-access-domain")!==null)throw console.error("403 Forbidden when calling external service.",{clientId:t.clientId,tunnelHost:c}),new k("Could not connect to secure tunnel.");return l}else throw Nt("Cannot call external service with Request object"),new k("Currently, we only support fetch(<some_string>, ...).");else throw Nt("There is no external service auth configured for this zup."),new k("There are no external services configured for this zup.")}s(Fa,"externalServiceHandler");async function yd(n,e,t,r){let o=n.toLowerCase(),i=e.toLowerCase(),a=t.toLowerCase(),c=ja(r);Nt(`Hashing service name: ${i}-${o}.${i}-${a}-${c}`);let u=await Ho(`${i}-${o}`),l=await Ho(`${i}-${a}-${c}`);return`${u}.${l}`}s(yd,"hashServiceName");async function Ho(n){let e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(i=>i.toString(16).padStart(2,"0")).join("").slice(0,-1)}s(Ho,"hashSegment");function ja(n){let e=n.toLowerCase();switch(e){case"production":case"preview":return e;default:return"working-copy"}}s(ja,"sanitizeEnvironmentType");var za=new Map;za.set("service:",Fa);var Er=globalThis.fetch;function Fo(n,e){let t=bd(e);if(typeof n=="string"){let r=new URL(n),o=za.get(r.protocol);return o?o(n,t):Er(n,t)}else return Er(n,t)}s(Fo,"internalFetch");globalThis.fetch=Fo;var bd=s(n=>{if(!n||n instanceof Request)return n;let e=n;if(!e.zuplo)return n;let t=n;return t.cf={cacheEverything:e.zuplo?.cacheEverything,cacheTtl:e.zuplo?.cacheTtlSeconds},delete n.zuplo,n},"transformInit");var wd={fetch:Fo},j=wd;Function.prototype.toString=function(){return"[native code]"};var Tr=globalThis,Ba=Tr.caches;if(Ba){let n=Ba.open;Tr.caches.open=function(e){let t=y.instance.deploymentName??y.instance.build.BUILD_ID;return n.call(this,`${t}-${e}`)},delete Tr.caches.default,Object.freeze(Tr.caches)}var Sr=new Set,Ga=new Set;function g(n){Ga.has(n)||(Ga.add(n),Sr.add(n))}s(g,"trackFeature");function Va(){let n=[...Sr];return Sr.clear(),n}s(Va,"getUnsentFeatures");function Wa(n){for(let e of n)Sr.add(e)}s(Wa,"restoreFeatures");function Xe(n,e){n.has("Authorization")||n.set("Authorization",`Bearer ${y.instance.authApiJWT}`),n.set("zp-rid",e??`global-${crypto.randomUUID()}`),n.set("zp-dn",y.instance.deploymentName??"unknown"),n.set("User-Agent",y.instance.systemUserAgent),n.set("zp-compat-date",y.instance.build.COMPATIBILITY_DATE??"none")}s(Xe,"setZuploHeaders");async function Rd(n,e={}){g("utility.zuplo-api-services");let{method:t="GET",data:r}=e,o=new URL(n,y.instance.zuploEdgeApiUrl),i=new Headers(e.headers);Xe(i),i.set("Content-Type","application/json");let a={method:t,headers:i};r&&(a.body=JSON.stringify(r));let c=await j.fetch(o,a),u;try{if(!c.ok)throw u=await c.clone().json(),new Error(`Error ${c.status}: ${JSON.stringify(u)||"Request failed"}`);if(c.status===204)return;u=await c.clone().json()}catch(l){throw new Error(l.message)}return u}s(Rd,"apiServices");var Ja=new Map,jo=class{static{s(this,"InnerCache")}constructor(e){this.#e=e.maxSize}#e;#t=0;#n=new Map;#r=[];get(e){let t=this.#n.get(e);if(!t)return;let r=Date.now();if(r>t.expiresAt){this.#n.delete(e);return}return t.lastUsed=r,this.#o(),t?.data}put(e,t,r){if(r<=0)return;if(this.#n.size>=this.#e){let a=this.#r.shift();a&&this.#n.delete(a)}let o=Date.now(),i={created:o,lastUsed:o,expiresAt:o+r*1e3,data:t};this.#r.push(e),this.#n.set(e,i)}delete(e){let t=this.#r.indexOf(e);t>=0&&this.#r.slice(t,1),this.#n.delete(e)}get size(){return this.#n.size}#o(){let e=Date.now();this.#t+1e4*1e3>e&&(this.purge(),this.#t=e)}purge(){let e=Date.now();this.#n.forEach((t,r)=>{t.expiresAt>=e&&this.#n.delete(r)})}},et=class{static{s(this,"MemoryCache")}constructor(e,t={maxSize:1e3}){this.name=e;let r=Ja.get(e);r||(r=new jo(t),Ja.set(e,r)),this.#e=r}name;#e;get(e){return this.#e.get(e)}put(e,t,r){return this.#e.put(e,t,r)}delete(e){return this.#e.delete(e)}get size(){return this.#e.size}purge(){this.#e.purge()}};var zo="__zuplo-expiry-header",$n=class{static{s(this,"ZoneCache")}constructor(e,t){this.#t=e,this.#e=t}#e;#t;#n;async#r(){return this.#n||(this.#n=await caches.open(this.#t)),this.#n}#o(e){return new Request(`https://zone-cache.zuplo.app/${encodeURIComponent(e)}`)}async get(e){try{let t=await this.#r(),r=this.#o(e),o=await t.match(r);if(!o)return;let i=o.headers.get(zo);if(!i){try{await t.delete(r)}catch(u){this.logDebug("Handled failure to delete with CF cache because of missing expiryHeader",u),await this.deleteFallback(e)}return}let a=parseInt(i);if(Date.now()>=a){try{await t.delete(r)}catch(u){this.logDebug("Handled failure to delete with CF cache because of expiration",u),await this.deleteFallback(e)}return}return await o.json()}catch(t){this.logDebug(t)}}async put(e,t,r){let o=new Headers({"cache-control":`s-maxage=${r}, must-revalidate`,"content-type":"application/json"});o.set(zo,`${Date.now()+r*1e3}`);let i=await this.#r(),a=this.#o(e),c=new Response(JSON.stringify(t),{headers:o});await i.put(a,c)}async delete(e){let t=await this.#r(),r=this.#o(e);try{await t.delete(r)}catch(o){this.logDebug("Handled failure to delete with CF cache due to explicit delete call",o),await this.deleteFallback(e)}}async deleteFallback(e){let t=new Headers({"Cache-Control":"s-maxage=0, must-revalidate"});t.set(zo,`${Date.now()}`);let r=await this.#r(),o=this.#o(e),i=new Response("",{headers:t});await r.put(o,i)}logDebug(...e){"logger"in this.#e?this.#e.logger?.debug(`Error in ZoneCache: '${this.#t}'`,e):"log"in this.#e&&this.#e.log.debug(`Error in ZoneCache: '${this.#t}'`,e)}};var me=class{static{s(this,"MemoryZoneReadThroughCache")}constructor(e,t){let r=`f6726488-fd18-4b7f-9c30-6070565e8042-${e}`;this.#e=e,this.#t=new et(r),this.#n=new $n(r,t),this.#r=t}#e;#t;#n;#r;async get(e){let t=this.#t.get(e);if(t)return t;let r=await this.#n.get(e);if(r){let o=Math.floor((r.expires-Date.now())/1e3);if(o>0)return this.#t.put(e,r.data,o),r.data}}put(e,t,r){this.#t.put(e,t,r);let o={data:t,expires:Date.now()+r*1e3},i=this.#n.put(e,o,r).catch(a=>{this.#r.log.error(`Error in MemoryZoneReadThroughCache: '${this.#e}'`,a)});this.#r.waitUntil(i)}async delete(e){this.#t.delete(e),await this.#n.delete(e)}};var Bo="__zuplo-expiry-header",Go=class{static{s(this,"StreamingZoneCache")}constructor(e,t){this.#t=e,this.#e=t}#e;#t;#n;async#r(){return this.#n||(this.#n=await caches.open(this.#t)),this.#n}#o(e){return new Request(`https://streaming-zone-cache.zuplo.app/${encodeURIComponent(e)}`)}async get(e){try{let t=await this.#r(),r=this.#o(e),o=await t.match(r);if(!o)return;let i=o.headers.get(Bo);if(!i){await t.delete(r).catch(c=>{this.logDebug(`StreamingZoneCache: error deleting missing expiry entry ${e}`,c)});return}let a=parseInt(i,10);if(Date.now()>=a){await t.delete(r).catch(c=>{this.logDebug(`StreamingZoneCache: error deleting expired entry ${e}`,c)});return}return o.body??void 0}catch(t){this.logDebug(`get(${e}) failed`,t);return}}async put(e,t,r){let o=new Headers({"cache-control":`s-maxage=${r}, must-revalidate`});o.set(Bo,`${Date.now()+r*1e3}`);let i=new Response(t,{headers:o}),a=await this.#r(),c=this.#o(e);await a.put(c,i)}async delete(e){try{await(await this.#r()).delete(this.#o(e))}catch(t){this.logDebug(`delete(${e}) fallback needed`,t),await this.deleteFallback(e)}}async deleteFallback(e){let t=new Headers({"Cache-Control":"s-maxage=0, must-revalidate",[Bo]:`${Date.now()}`}),r=new Response("",{headers:t}),o=await this.#r(),i=this.#o(e);await o.put(i,r)}logDebug(...e){"logger"in this.#e?this.#e.logger?.debug(`StreamingZoneCache(${this.#t}):`,...e):"log"in this.#e&&this.#e.log.debug(`StreamingZoneCache(${this.#t}):`,...e)}};var Ka="zuplo-request-id",an="zp-rid",Vo="zp-body-removed",Mt="cf-ray",Qa="x-real-ip",Wo="cf-ipcity",Jo="cf-ipcontinent",Ko="cf-ipcountry",Qo="cf-iplongitude",Yo="cf-iplatitude",Ya="cf-region",Xa="cf-region-code",ec="cf-metro-code",tc="cf-postal-code",nc="cf-timezone",Cr="zp-ipcity",Or="zp-ipcontinent",Ar="zp-ipcountry",_r="zp-iplongitude",kr="zp-iplatitude",rc="true-client-ip",oc="x-forwarded-for",Un="zp-asn",Xo="zp-asorg",ei="zp-colo",Hn="zp-postalcode",Fn="zp-metrocode",ti="zp-region",jn="zp-regioncode",zn="zp-timezone",ic="zp-http-protocol",ni="x-akamai-edgescape",sc=[Wo,Jo,Ko,Qo,Yo,Un,Xo,ei,Hn,Fn,ti,jn,zn,ni],ac=["zp-","cf-"],cc=[an,Mt,Vo];var Bn=Symbol("zuplo_meters"),Gn=Symbol("zuplo_dynamic_meters"),Lr="system-logger";var fe=class n{static{s(this,"ContextData")}static#e;#t;constructor(e){this.#t=e}set(e,t){n.set(e,this.#t,t)}get(e){return n.get(e,this.#t)}static set(e,t,r){n.#e||(n.#e=new WeakMap);let o=n.#e.get(e);o||(o=new Map),o.set(t,r),n.#e.set(e,o)}static get(e,t){return n.#e||(n.#e=new WeakMap),n.#e.get(e)?.get(t)}};import{trace as dp}from"@opentelemetry/api";import{SpanStatusCode as vd,trace as xd}from"@opentelemetry/api";import{SpanStatusCode as Zr,trace as qr}from"@opentelemetry/api";var uc=s(n=>(e,t)=>n(e,t),"globalRequestHandlerProxy");function lc(n){uc=n}s(lc,"setTelemetryInitFunction");var dc=s(n=>uc(n),"proxyHandler");var Rt=class{static{s(this,"RuntimePlugin")}},Ee=class extends Rt{static{s(this,"SystemRuntimePlugin")}async initialize(e){return Promise.resolve()}registerRoutes(e,t){}},Nr=class extends Ee{static{s(this,"MeteringPlugin")}},Vn=class extends Rt{static{s(this,"TelemetryPlugin")}};var Wn=class n{static{s(this,"InternalProblemResponseFormatter")}static problemResponseFormat=s(async e=>{let t=e.problem,r=JSON.stringify(t,null,2);return new Response(r,{status:e.problem.status,statusText:e.statusText,headers:{...e.additionalHeaders,"content-type":"application/problem+json"}})},"problemResponseFormat");static setProblemResponseFormat(e){e&&(g("runtime.problem-response-formatter"),n.problemResponseFormat=(t,r,o)=>{try{return e(t,r,o)}catch(i){throw new k("Error in custom 'problemResponseFormat'",{cause:i})}})}},Dt=class{static{s(this,"ProblemResponseFormatter")}static async format(e,t,r){return await Wn.problemResponseFormat(e,t,r)}};function Mr(n){for(let e in n){let t=n[e];t&&typeof t=="object"&&Mr(t)}return Object.freeze(n)}s(Mr,"deepFreeze");var ue=class n extends Request{static{s(this,"ZuploRequest")}#e=void 0;#t;constructor(e,t){super(e,t);let r=t?.params;r?this.#t=r:e instanceof n?this.#t=e.#t:this.#t={};let o=t?.user;o?this.user=o:e instanceof n&&(this.user=e.user)}get query(){if(this.#e===void 0){let e={},t=new URL(this.url).searchParams;for(let[r,o]of t.entries())e[r]=o;this.#e=e}return Mr(this.#e)}get params(){return Mr(this.#t)}user};var ai={},at=[],ri=[],oi=[],ii=[],si=[];var Dr={addPlugin(n){at.push(n)},addRequestHook(n){ri.push(n)},addResponseSendingHook(n){oi.push(n)},addResponseSendingFinalHook(n){ii.push(n)},addPreRoutingHook(n){si.push(n)}},mc=s(async(n,e)=>{if(ri.length===0)return n;let t=qr.getTracer("extension");return t.startActiveSpan("hook:onRequest",async r=>{try{let o=n;for(let i of ri){let a=await t.startActiveSpan(i.name,async c=>{let u=await i(o,e);if(u instanceof ue||u instanceof Response)return c.end(),u;{let l=new f(`Invalid state - the OnRequest hook must return a ZuploRequest or Response. Received ${typeof o}.`);throw c.end(),c.recordException(l),c.setStatus({code:Zr.ERROR}),l}});if(a instanceof ue)o=a;else return a}return o}finally{r.end()}})},"invokeOnRequestExtensions"),fc=s(async(n,e,t)=>{if(oi.length===0)return n;let r=qr.getTracer("extension");return r.startActiveSpan("hook:onResponseSending",async o=>{try{let i=n;for(let a of oi)await r.startActiveSpan(a.name,async c=>{let u=await a(n,e,t);if(u instanceof Response)i=u,c.end();else{let l=new f(`Invalid state - the OnResponseSending hook must return a Response. Received ${typeof i}.`);throw c.recordException(l),c.setStatus({code:Zr.ERROR}),c.end(),l}});return i}finally{o.end()}})},"invokeOnResponseSendingExtensions"),gc=s(async(n,e,t)=>{if(ii.length===0)return;let r=qr.getTracer("extension");return r.startActiveSpan("hook:onResponseSendingFinal",async o=>{try{for(let i of ii)await r.startActiveSpan(i.name,async a=>{try{await i(n,e,t)}catch(c){throw a.recordException(c),a.setStatus({code:Zr.ERROR}),a.end(),c}a.end()})}finally{o.end()}})},"invokeOnResponseSendingFinalExtensions"),hc=s(async n=>{if(si.length===0)return n;let e=qr.getTracer("extension");return e.startActiveSpan("hook:preRouting",async t=>{try{let r=n;for(let o of si)r=await e.startActiveSpan(o.name,async a=>{try{let c=await o(r);if(c instanceof Request)return c;{let u=new k(`Invalid state - the PreRouting hook must return a Request. Received ${typeof c}.`);throw a.recordException(u),a.setStatus({code:Zr.ERROR}),u}}finally{a.end()}});return r}finally{t.end()}})},"invokePreRoutingHooks"),pc=!1;async function yc(n){if(!pc){n&&(g("runtime.extensions"),await n(Dr)),ai.value=Dr;for(let e of at)if(e instanceof Vn){let{requestHandlerProxy:t}=e.instrument({accountName:y.instance.build.ACCOUNT_NAME,projectName:y.instance.build.PROJECT_NAME,buildId:y.instance.build.BUILD_ID,zuploVersion:y.instance.build.ZUPLO_VERSION,compatibilityDate:y.instance.build.COMPATIBILITY_DATE,instanceId:y.instance.instanceId,environmentType:y.instance.loggingEnvironmentType,environmentStage:y.instance.loggingEnvironmentStage,deploymentName:y.instance.deploymentName});lc(t)}await Promise.all(at.map(async e=>{e instanceof Ee&&await e.initialize(Dr)})),Wn.setProblemResponseFormat(Dr.problemResponseFormat),pc=!0}}s(yc,"initializeRuntime");var ci={Json:"application/json",Form:"application/x-www-form-urlencoded"};function ui(n,e){if(n!==null)return e&&typeof n=="string"?n:typeof n=="object"&&e?.startsWith(ci.Form)?new URLSearchParams(n).toString():typeof n=="object"&&e?.startsWith(ci.Json)||!e?JSON.stringify(n):n}s(ui,"serialize");function cn(n){return Ie.instance.runtimeSettings.developerPortal.enabled&&n.pathname.startsWith(Ie.instance.runtimeSettings.developerPortal.sitePathname)||n.pathname.startsWith("/__zuplo/")||n.pathname.startsWith("/__/zuplo/")}s(cn,"isSystemRoute");var Te=class{static{s(this,"Pipeline")}constructor(e){this.execute=this.#t(e)}execute;#e=s((e,t)=>async(r,o)=>xd.getTracer("pipeline").startActiveSpan(`handler:${o.route.handler.export}`,async a=>{try{return await e(r,o)}catch(c){let u=t.errorHandler(r,o,"Error executing request handler.",c);return a.setStatus({code:vd.ERROR}),u}finally{a.end()}}),"#errorWrappedHandler");#t=s(({processors:e,gateway:t,handler:r})=>async(o,i)=>{let a=_e.getContextExtensions(i),c=[...e],u=s(async b=>{let P=c.pop();if(!P){let A=await this.#e(async B=>{let $=await r(B,i);return Pd($)},t)(b,i);try{await a.onHandlerResponse(A,b,i)}catch(B){return t.errorHandler(o,i,"Error invoking 'context.onHandlerResponse' hook",B)}return A}return P(o,i,t,u)},"nextPipe"),d=await u(o),p=new URL(o.url);if(cn(p)&&y.instance.build.COMPATIBILITY_FLAGS.doNotRunHooksOnSystemRoutes)return d;let m=new Jn(o,d);i.dispatchEvent(m);let h=a.latestRequest,x;try{x=await m.mutableResponse}catch(b){return t.errorHandler(o,i,"Error retrieving mutableResponse",b)}try{x=await a.onResponseSending(x,h,i)}catch(b){return t.errorHandler(o,i,"Error invoking 'context.onResponseSending' hook",b)}try{x=await fc(x,h,i)}catch(b){return t.errorHandler(o,i,"Error invoking 'context.onResponseSending' hook",b)}i.dispatchEvent(new Kn(o,x));try{await a.onResponseSendingFinal(d,h,i)}catch(b){throw i.log.error("Error invoking 'runtime.onResponseSending' hook",b),b}try{await gc(d,h,i)}catch(b){throw i.log.error("Error invoking 'runtime.onResponseSending' hook",b),b}return x},"#toZuploPipeline")};function Pd(n){return n instanceof Response?n:typeof n>"u"?new Response:new Response(ui(n),{headers:{"content-type":"application/json"}})}s(Pd,"resultToResponse");var tt=class extends Rt{static{s(this,"MetricsPlugin")}};var ne=class n{static{s(this,"SystemLogMap")}static#e=new WeakMap;static getLogger(e){let t=n.#e.get(e);if(!t){let r=`No system logger found for context with requestId '${e.requestId}'`;throw console.error(r),new ae(r)}return t}static addLogger(e,t){n.#e.set(e,t)}};var ie=class{static{s(this,"BatchDispatch")}constructor(e,t,r,o){this.#t=e,this.#i=t,this.#r=r,this.#n=o??console}#e=void 0;#t;#n;#r;#o=[];#i;enqueue=s(e=>{this.#o.push(e),this.#e||(this.#e=new Promise(t=>{setTimeout(()=>{if(this.#o.length>0){let r=[...this.#o];this.#o.length=0,this.#e=void 0,this.#r(r).catch(o=>{this.#n.error(`Uncaught error in BatchDispatcher named '${this.#t}'}`,o.message,o.stack)}).finally(()=>{t()})}},this.#i)}))},"enqueue");waitUntilFlushed=s(async()=>{if(this.#e)return this.#e},"waitUntilFlushed")};var $r=class{static{s(this,"ZuploMetricsTransport")}#e;#t;constructor(e){this.#e=e,this.#t=new ie("zuplo-metrics-transport",10,this.dispatchFunction,ne.getLogger(e))}pushMetrics(e,t){this.#t.enqueue(e),t.waitUntil(this.#t.waitUntilFlushed())}dispatchFunction=s(async e=>{if(e.length!==0)try{let{remoteLogURL:t,deploymentName:r}=y.instance,{ACCOUNT_NAME:o,PROJECT_NAME:i}=y.instance.build,a=e.map(p=>{let m=Object.assign({},p);return delete m.requestContentLength,delete m.responseContentLength,m}),c=Va(),u={metadata:{timestamp:new Date,accountName:o,projectName:i,deploymentName:r},metrics:a,features:c},l=new Headers({"content-type":"application/json"});Xe(l);let d=await j.fetch(`${t}/v2/runtime/metrics`,{method:"POST",body:JSON.stringify(u),headers:l});if(!d.ok){let p=await d.text();ne.getLogger(this.#e).error(`Metrics POST responded ${d.status}: ${d.statusText}`,p),Wa(c)}}catch(t){ne.getLogger(this.#e).error("Failed to send Zuplo metrics.",t)}},"dispatchFunction")};var xe=class{static{s(this,"SystemRouteConfiguration")}constructor({label:e,path:t,methods:r,systemRouteName:o,corsPolicy:i="none"}){this.label=e,this.path=t,this.methods=r,this.corsPolicy=i,this.handler={export:"SYSTEM_IGNORED",module:"SYSTEM_IGNORED"},this.systemRouteName=o}label;path;methods;handler;corsPolicy;policies;systemRouteName;metadata;raw(){return{}}};function bc(n){let e=n.headers,t=e.get(rc);if(t)return t;let r=e.get(oc);if(r)return r.split(",")[0].trim()}s(bc,"getClientIp");var ke=s(async(n,e,t,r)=>{let o=new Date,i=Date.now(),a=await r(n),c=n.headers.get(Mt)??void 0,u=bc(n),l=e.incomingRequestProperties,d;e.route instanceof xe&&(d=e.route.systemRouteName);let p=_e.getContextExtensions(e).latestRequest,m={timestamp:o,statusCode:a.status,durationMs:Date.now()-i,requestContentLength:n.headers.get("content-length")?Number(n.headers.get("content-length")):void 0,responseContentLength:a.headers.get("content-length")?Number(a.headers.get("content-length")):void 0,routePath:e.route?.path??"SYSTEM_OR_NOT_FOUND",systemRouteName:d,contextId:e.contextId,parentContextId:e.parentContext?.contextId,requestId:e.requestId,parentRequestId:e.parentContext?.requestId,method:n.method,asn:l.asn,asOrganization:l.asOrganization,colo:l.colo,continent:l.continent,country:l.country,city:l.city,latitude:l.latitude,longitude:l.longitude,rayId:c,instanceId:y.instance.instanceId,userSub:p.user?.sub,clientIp:u},h=[];return!y.instance.isLocalDevelopment&&y.instance.remoteLogURL&&y.instance.remoteLogToken&&y.instance.loggingId&&h.push(new $r(e)),at.forEach(x=>{if(x instanceof tt){let b=x.getTransport();h.push(b)}}),h.forEach(x=>{x.pushMetrics(m,e)}),a},"metricsProcessor");var li=s((n,e)=>{let t=s(async(i,a)=>{let c=new URL(i.url),u=y.instance.build,l={buildId:u.BUILD_ID,zuploVersion:u.ZUPLO_VERSION,compatibilityDate:u.COMPATIBILITY_DATE,apiVersion:u.API_VERSION,gitSha:u.GIT_SHA,timestamp:u.TIMESTAMP,isProduction:u.ENVIRONMENT_TYPE==="PRODUCTION"};if(c.searchParams.get("system_log")==="true"&&ne.getLogger(a).error("Test System Log",l),c.searchParams.get("error")==="true")throw new Error("this is an unhandled error");return new Response(JSON.stringify(l,null,2),{status:200,headers:{"content-type":"application/json"}})},"buildRouteHandler"),r=new Te({processors:[ke],handler:t,gateway:e}),o=new xe({label:"SYSTEM_BUILD_ROUTE",methods:["GET"],path:"/__zuplo/build",systemRouteName:"build-data"});n.addRoute(o,r.execute)},"registerBuildRoute");var Ur=(R=>(R[R.CONTINUE=100]="CONTINUE",R[R.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",R[R.PROCESSING=102]="PROCESSING",R[R.EARLY_HINTS=103]="EARLY_HINTS",R[R.OK=200]="OK",R[R.CREATED=201]="CREATED",R[R.ACCEPTED=202]="ACCEPTED",R[R.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",R[R.NO_CONTENT=204]="NO_CONTENT",R[R.RESET_CONTENT=205]="RESET_CONTENT",R[R.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",R[R.MULTI_STATUS=207]="MULTI_STATUS",R[R.ALREADY_REPORTED=208]="ALREADY_REPORTED",R[R.IM_USED=226]="IM_USED",R[R.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",R[R.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",R[R.FOUND=302]="FOUND",R[R.SEE_OTHER=303]="SEE_OTHER",R[R.NOT_MODIFIED=304]="NOT_MODIFIED",R[R.USE_PROXY=305]="USE_PROXY",R[R.SWITCH_PROXY=306]="SWITCH_PROXY",R[R.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",R[R.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",R[R.BAD_REQUEST=400]="BAD_REQUEST",R[R.UNAUTHORIZED=401]="UNAUTHORIZED",R[R.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",R[R.FORBIDDEN=403]="FORBIDDEN",R[R.NOT_FOUND=404]="NOT_FOUND",R[R.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",R[R.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",R[R.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",R[R.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",R[R.CONFLICT=409]="CONFLICT",R[R.GONE=410]="GONE",R[R.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",R[R.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",R[R.CONTENT_TOO_LARGE=413]="CONTENT_TOO_LARGE",R[R.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",R[R.URI_TOO_LONG=414]="URI_TOO_LONG",R[R.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",R[R.RANGE_NOT_SATISFIABLE=416]="RANGE_NOT_SATISFIABLE",R[R.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",R[R.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",R[R.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",R[R.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",R[R.UNPROCESSABLE_CONTENT=422]="UNPROCESSABLE_CONTENT",R[R.LOCKED=423]="LOCKED",R[R.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",R[R.TOO_EARLY=425]="TOO_EARLY",R[R.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",R[R.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",R[R.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",R[R.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",R[R.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",R[R.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",R[R.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",R[R.BAD_GATEWAY=502]="BAD_GATEWAY",R[R.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",R[R.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",R[R.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",R[R.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",R[R.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",R[R.LOOP_DETECTED=508]="LOOP_DETECTED",R[R.NOT_EXTENDED=510]="NOT_EXTENDED",R[R.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED",R))(Ur||{}),wc={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Content Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};var Id={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},di=Id;function Ed(n){return`${new URL(n.url).pathname}`}s(Ed,"instance");function Td(n,e){let t={timestamp:new Date().toISOString(),requestId:e.requestId,buildId:y.instance.build.BUILD_ID},r=n.headers.get(Mt);return r&&(t.rayId=r),t}s(Td,"trace");var Sd=s((n,e,t,r,o)=>({problem:{type:n.type,title:n.title,status:n.status,detail:n.detail,instance:Ed(e),trace:Td(e,t),...r},additionalHeaders:o,statusText:di[n.status]}),"merge"),pi=class{static{s(this,"HttpProblemsBase")}static format=s((e,t,r)=>"problem"in e?Dt.format(e,t,r):Dt.format({problem:e},t,r),"format");static getProblemFromStatus(e,t){return{type:`https://httpproblems.com/http-status/${e}`,status:e,title:wc[e],...t}}},T=class extends pi{static{s(this,"HttpProblems")}static#e(e,t,r,o,i){let a=Sd(this.getProblemFromStatus(e),t,r,o,i);return Dt.format(a,t,r)}static continue=s((e,t,r,o)=>this.#e(200,e,t,r,o),"continue");static switchingProtocols=s((e,t,r,o)=>this.#e(101,e,t,r,o),"switchingProtocols");static processing=s((e,t,r,o)=>this.#e(102,e,t,r,o),"processing");static earlyHints=s((e,t,r,o)=>this.#e(103,e,t,r,o),"earlyHints");static ok=s((e,t,r,o)=>this.#e(200,e,t,r,o),"ok");static created=s((e,t,r,o)=>this.#e(201,e,t,r,o),"created");static accepted=s((e,t,r,o)=>this.#e(202,e,t,r,o),"accepted");static nonAuthoritativeInformation=s((e,t,r,o)=>this.#e(203,e,t,r,o),"nonAuthoritativeInformation");static noContent=s((e,t,r,o)=>this.#e(204,e,t,r,o),"noContent");static resetContent=s((e,t,r,o)=>this.#e(205,e,t,r,o),"resetContent");static partialContent=s((e,t,r,o)=>this.#e(206,e,t,r,o),"partialContent");static multiStatus=s((e,t,r,o)=>this.#e(207,e,t,r,o),"multiStatus");static alreadyReported=s((e,t,r,o)=>this.#e(208,e,t,r,o),"alreadyReported");static imUsed=s((e,t,r,o)=>this.#e(226,e,t,r,o),"imUsed");static multipleChoices=s((e,t,r,o)=>this.#e(300,e,t,r,o),"multipleChoices");static movedPermanently=s((e,t,r,o)=>this.#e(301,e,t,r,o),"movedPermanently");static found=s((e,t,r,o)=>this.#e(302,e,t,r,o),"found");static seeOther=s((e,t,r,o)=>this.#e(303,e,t,r,o),"seeOther");static notModified=s((e,t,r,o)=>this.#e(304,e,t,r,o),"notModified");static useProxy=s((e,t,r,o)=>this.#e(305,e,t,r,o),"useProxy");static switchProxy=s((e,t,r,o)=>this.#e(306,e,t,r,o),"switchProxy");static temporaryRedirect=s((e,t,r,o)=>this.#e(307,e,t,r,o),"temporaryRedirect");static permanentRedirect=s((e,t,r,o)=>this.#e(308,e,t,r,o),"permanentRedirect");static badRequest=s((e,t,r,o)=>this.#e(400,e,t,r,o),"badRequest");static unauthorized=s((e,t,r,o)=>this.#e(401,e,t,r,o),"unauthorized");static paymentRequired=s((e,t,r,o)=>this.#e(402,e,t,r,o),"paymentRequired");static forbidden=s((e,t,r,o)=>this.#e(403,e,t,r,o),"forbidden");static notFound=s((e,t,r,o)=>this.#e(404,e,t,r,o),"notFound");static methodNotAllowed=s((e,t,r,o)=>this.#e(405,e,t,r,o),"methodNotAllowed");static notAcceptable=s((e,t,r,o)=>this.#e(406,e,t,r,o),"notAcceptable");static proxyAuthenticationRequired=s((e,t,r,o)=>this.#e(407,e,t,r,o),"proxyAuthenticationRequired");static requestTimeout=s((e,t,r,o)=>this.#e(408,e,t,r,o),"requestTimeout");static conflict=s((e,t,r,o)=>this.#e(409,e,t,r,o),"conflict");static gone=s((e,t,r,o)=>this.#e(410,e,t,r,o),"gone");static lengthRequired=s((e,t,r,o)=>this.#e(411,e,t,r,o),"lengthRequired");static preconditionFailed=s((e,t,r,o)=>this.#e(412,e,t,r,o),"preconditionFailed");static contentTooLarge=s((e,t,r,o)=>this.#e(413,e,t,r,o),"contentTooLarge");static uriTooLong=s((e,t,r,o)=>this.#e(414,e,t,r,o),"uriTooLong");static unsupportedMediaType=s((e,t,r,o)=>this.#e(415,e,t,r,o),"unsupportedMediaType");static rangeNotSatisfiable=s((e,t,r,o)=>this.#e(416,e,t,r,o),"rangeNotSatisfiable");static expectationFailed=s((e,t,r,o)=>this.#e(417,e,t,r,o),"expectationFailed");static imATeapot=s((e,t,r,o)=>this.#e(418,e,t,r,o),"imATeapot");static misdirectedRequest=s((e,t,r,o)=>this.#e(421,e,t,r,o),"misdirectedRequest");static unprocessableContent=s((e,t,r,o)=>this.#e(422,e,t,r,o),"unprocessableContent");static locked=s((e,t,r,o)=>this.#e(423,e,t,r,o),"locked");static failedDependency=s((e,t,r,o)=>this.#e(424,e,t,r,o),"failedDependency");static tooEarly=s((e,t,r,o)=>this.#e(425,e,t,r,o),"tooEarly");static upgradeRequired=s((e,t,r,o)=>this.#e(426,e,t,r,o),"upgradeRequired");static preconditionRequired=s((e,t,r,o)=>this.#e(428,e,t,r,o),"preconditionRequired");static tooManyRequests=s((e,t,r,o)=>this.#e(429,e,t,r,o),"tooManyRequests");static requestHeaderFieldsTooLarge=s((e,t,r,o)=>this.#e(431,e,t,r,o),"requestHeaderFieldsTooLarge");static unavailableForLegalReasons=s((e,t,r,o)=>this.#e(451,e,t,r,o),"unavailableForLegalReasons");static internalServerError=s((e,t,r,o)=>this.#e(500,e,t,r,o),"internalServerError");static notImplemented=s((e,t,r,o)=>this.#e(501,e,t,r,o),"notImplemented");static badGateway=s((e,t,r,o)=>this.#e(502,e,t,r,o),"badGateway");static serviceUnavailable=s((e,t,r,o)=>this.#e(503,e,t,r,o),"serviceUnavailable");static gatewayTimeout=s((e,t,r,o)=>this.#e(504,e,t,r,o),"gatewayTimeout");static httpVersionNotSupported=s((e,t,r,o)=>this.#e(505,e,t,r,o),"httpVersionNotSupported");static variantAlsoNegotiates=s((e,t,r,o)=>this.#e(506,e,t,r,o),"variantAlsoNegotiates");static insufficientStorage=s((e,t,r,o)=>this.#e(507,e,t,r,o),"insufficientStorage");static loopDetected=s((e,t,r,o)=>this.#e(508,e,t,r,o),"loopDetected");static notExtended=s((e,t,r,o)=>this.#e(510,e,t,r,o),"notExtended");static networkAuthenticationRequired=s((e,t,r,o)=>this.#e(511,e,t,r,o),"networkAuthenticationRequired")};var{toString:Cd}=Object.prototype,{propertyIsEnumerable:Od}=Object.prototype;function mi(n){return Cd.call(n)}s(mi,"toString");function qe(n){return typeof n=="string"}s(qe,"isString");function un(n){return qe(n)&&n!==""}s(un,"isNonEmptyString");function Rc(n){return mi(n)==="[object RegExp]"}s(Rc,"isRegexp");function vc(n){return[...Object.keys(n),...Object.getOwnPropertySymbols(n).filter(e=>Od.call(n,e))]}s(vc,"getOwnEnumerableKeys");function Zt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!(n instanceof RegExp)&&!(n instanceof Date)}s(Zt,"isObject");function fi(n){return typeof n=="number"&&!isNaN(n)}s(fi,"isNumber");function gi(n){return n===!0||n===!1}s(gi,"isBoolean");function xc(n){return typeof n>"u"}s(xc,"isUndefined");function Pc(n){return xc(n)||n===null}s(Pc,"isUndefinedOrNull");function Qn(n){return!!n&&typeof n=="object"&&"name"in n&&"message"in n&&"stack"in n}s(Qn,"isErrorLike");var Ic=new Map;function vt(n){if(Array.isArray(n)&&!n.some(o=>typeof o!="number"))return n;if(typeof n!="string")throw new Error("Input must be a string or an array of numbers");if(!/^\d+(?:-\d+)?(?:,\s*\d+(?:-\d+)?)*$/.test(n))throw new f("Malformed input string");let e=Ic.get(n);if(e)return e;let t=n.split(","),r=[];for(let o of t){let i=o.split("-");if(i.length===2){let a=parseInt(i[0],10),c=parseInt(i[1],10);for(let u=a;u<=c;u++)r.push(u)}else r.push(parseInt(o,10))}return Ic.set(n,r),r}s(vt,"statusCodesStringToNumberArray");function ct(n,e,t){if(!e.startsWith("."))throw new f(`Invalid ${t} - must start with '.' - '${e}' does not`);let r=e.split(".").splice(1),o=n;return r.forEach(i=>{if(o===void 0)throw new k(`Error applying ${t} '${e}', reading '${i}'`);o=o[i]}),`${o}`}s(ct,"getValueFromRequestUser");function ut(n){if(Array.isArray(n)){if(n.includes(t=>typeof t!="string"))throw new f("Received an array that contains non-string values.");return n}if(qe(n))return n.includes(",")?n.split(",").map(t=>t.trim()).filter(t=>t!==","&&t!==""):[n];throw new f(`Expected type of string, received type '${typeof n}'`)}s(ut,"parseValueToStringArray");function Ec(n){if(n==null)return[];if(!Array.isArray(n))throw new f(`Invalid corsPolicy configuration. Expected an array of objects, received '${typeof n}'`);return n.map(t=>{if(!Zt(t))throw new f(`Invalid custom cors policy is set. Expected an object, received '${typeof t}'`);if(!un(t.name))throw new f("Value of 'name' on custom cors policies must be a non-empty string.");if(t.maxAge!==void 0&&!fi(t.maxAge))throw new f(`Value of 'maxAge' on custom cors policies must be a non-empty string. Received type '${typeof t.maxAge}'`);if(t.allowCredentials!==void 0&&!gi(t.allowCredentials))throw new f("Value of 'allowCredentials' on custom cors policies must be a boolean or not be set. If using an environment variable, check that it is set correctly.");let r=hi(t,"allowedHeaders"),o=hi(t,"allowedMethods"),i=hi(t,"exposeHeaders"),a;try{a=ut(t.allowedOrigins)}catch(u){throw new f(`Value of 'allowedOrigins' on custom cors policies is invalid. ${u.message} If using an environment variable, check that it is set correctly.`)}return{name:t.name,allowCredentials:typeof t.allowCredentials=="boolean"?String(t.allowCredentials):void 0,allowedOrigins:a,allowedHeaders:r?r.join(", "):void 0,allowedMethods:o?o.join(", "):void 0,exposeHeaders:i?i.join(", "):void 0,maxAge:typeof t.maxAge=="number"?t.maxAge.toString():void 0}})}s(Ec,"parseCorsPolicies");function hi(n,e){let t;if(n[e]!==void 0)try{t=ut(n[e])}catch(r){throw new f(`Value of '${e}' on custom cors policies is invalid. ${r.message} If using an environment variable, check that it is set correctly.`)}return t}s(hi,"parseOptionalProperty");var Hr=s((n,e)=>{if(e===null)return;if(n.find(a=>a==="*"))return e;let r=n.map(a=>a.trim().toLowerCase()),o=e.toLowerCase();return r.find(a=>a===o)},"findMatchingOrigin"),Fr=s((n,e)=>{let t={"access-control-allow-origin":e};n.allowedHeaders&&(t["access-control-allow-headers"]=n.allowedHeaders),n.allowedMethods&&(t["access-control-allow-methods"]=n.allowedMethods),n.exposeHeaders&&(t["access-control-expose-headers"]=n.exposeHeaders);let r=n.allowCredentials;r&&(t["access-control-allow-credentials"]=r);let o=n.maxAge?.toString()??void 0;return o&&(t["access-control-max-age"]=o),t},"generateCorsHeaders");var yi=s((n,e)=>{let t=e.routeData.corsPolicies,r=s(async(a,c)=>{let u=new URL(a.url.toString()).pathname,l=a.headers.get("access-control-request-method"),d=a.headers.get("access-control-request-headers"),p=a.headers.get("origin");if(p===null||l===null)return T.badRequest(a,c,{detail:"Expect headers origin and access-control-request-method"});let m=n.lookup(u,l);if(!m)return T.notFound(a,c);let h=m.routeConfiguration,x=Ad(l,d,p,h,t);return x.isValid?new Response(void 0,{status:200,statusText:"OK",headers:x.headers}):(x.error&&c.log.warn(x.error),T.notFound(a,c))},"optionsHandler"),o=new Te({processors:[ke],handler:r,gateway:e}),i=new xe({label:"SYSTEM_CORS_ROUTE",methods:["OPTIONS"],path:"/(.*)",systemRouteName:"cors-preflight"});n.addRoute(i,o.execute)},"registerCorsRoute"),Ad=s((n,e,t,r,o)=>{let i={isValid:!1,headers:{}};if(r.corsPolicy==="anything-goes")return{isValid:!0,headers:{"access-control-allow-origin":t,"access-control-allow-methods":n,"access-control-allow-headers":e??"*","access-control-expose-headers":"*","access-control-allow-credentials":"true","access-control-max-age":"600"}};if(r.corsPolicy==="none")return{...i,error:`No CORS policy set for the route '${r.pathPattern}'`};let a=o?.find(l=>l.name===r.corsPolicy);if(!a)throw new f(`Invalid Configuration - corsPolicy '${r.corsPolicy}' not found in *.oas.json 'corsPolicies' section.`);let c=Hr(a.allowedOrigins,t);return c?{isValid:!0,headers:Fr(a,c)}:{...i,error:`The CORS policy '${a.name}' does not allow the origin '${t}'`}},"validateAndBuildResponseHeaders");var Tc=s((n,e)=>{let t=s(async()=>new Response("You have no routes. Add a route in routes.oas.json to get started",{status:200}),"noRoutesHandler"),r=new Te({processors:[ke],handler:t,gateway:e}),o=new xe({label:"SYSTEM_NO_ROUTES",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"empty-gateway-catchall"});n.addRoute(o,r.execute)},"registerNoRoutes");var xt=class{static{s(this,"UserRouteConfiguration")}constructor(e){this.path=e.path,this.methods=e.methods,this.label=e.label,this.key=e.key,this.handler=e.handler,this.corsPolicy=e.corsPolicy,this.custom=e.custom,this.policies=e.policies,this.excludeFromOpenApi=e.excludeFromOpenApi,this.pathPattern=e.pathPattern,this.metadata=e.metadata,this.raw=e.raw}raw;get summary(){return this.raw()?.summary}get operationId(){return this.raw()?.operationId}get tags(){return this.raw()?.tags}get parameters(){return this.raw()?.parameters}get responses(){return this.raw()?.responses}label;key;path;excludeFromOpenApi;pathPattern;metadata;custom;methods;handler;corsPolicy;policies};var _d=new xe({label:"SYSTEM_NOT_FOUND_ROUTE",methods:["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"],path:"/(.*)",systemRouteName:"unmatched-path"}),Sc=s((n,e)=>{let t=s(async(o,i)=>{let a=ai.value?.notFoundHandler;if(a){let c=new URL(o.url);return a(o,i,{get routesMatchedByPathOnly(){return n.lookupByPathOnly(c.pathname).map(l=>l.routeConfiguration).filter(l=>l instanceof xt)}})}return T.notFound(o,i)},"notFoundHandler"),r=new Te({processors:[ke],handler:t,gateway:e});n.addRoute(_d,r.execute)},"registerNotMatchedHandler");var kd=["access-control-allow-origin","access-control-allow-headers","access-control-expose-headers","access-control-allow-credentials","access-control-max-age"],Cc=s(n=>{kd.forEach(e=>n.delete(e))},"stripCorsHeaders"),jr=s(async(n,e,t,r)=>{let o=e.route;if(!o.corsPolicy||o.corsPolicy==="none"){let d=await r(n),p=new Headers(d.headers);return Cc(p),new Response(d.body,{status:d.status,statusText:d.statusText,headers:p,webSocket:d.webSocket})}let i=await r(n);if(!(i instanceof Response))throw new ae(`The CorsProcessor is in the wrong place in the pipeline. It should only receive HttpResponse type but got '${typeof i}'`);let a=Ld(o,t.routeData.corsPolicies),c=Nd(n,a),u=new Headers(i.headers);return Cc(u),Object.entries(c).forEach(([d,p])=>{u.set(d,p)}),new Response(i.body,{status:i.status,statusText:i.statusText,headers:u,webSocket:i.webSocket})},"corsProcessor"),Ld=s((n,e)=>{if(n.corsPolicy==="anything-goes")return{name:"anything-goes",allowedHeaders:"*",allowedOrigins:["*"],allowedMethods:n.methods.join(", "),exposeHeaders:"*",allowCredentials:"true",maxAge:"600"};let t=e?.find(r=>r.name===n.corsPolicy);if(t===void 0)throw new f(`Invalid Configuration - no corsPolicy '${n.corsPolicy}' found in *.oas.json`);return t},"getCorsPolicy"),Nd=s((n,e)=>{let t=Hr(e.allowedOrigins,n.headers.get("origin"));return t?Fr(e,t):{}},"getCorsHeaders");var bi=s((n,e)=>{let t=s(async()=>new Response(JSON.stringify({buildId:y.instance.build.BUILD_ID}),{status:200,headers:{"content-type":"application/json"}}),"pingRouteHandler"),r=new Te({processors:[jr],handler:t,gateway:e}),o=new xe({corsPolicy:"anything-goes",label:"SYSTEM_PING_ROUTE",methods:["GET"],path:"/__zuplo/ping",systemRouteName:"ping"});n.addRoute(o,r.execute)},"registerPingRoute");import{SpanStatusCode as Oc,trace as Ac}from"@opentelemetry/api";var lt={RoutePathPattern:"zuplo.route.path_pattern",RouteOperationId:"zuplo.route.operation_id",RouteTrace:"zuplo.route.trace",RouteSystem:"zuplo.route.system",SystemTrace:"zuplo.system",PolicyName:"zuplo.policy.name",PolicyType:"zuplo.policy.type",ZuploBuildId:"zuplo.build.id",ZuploBuildVersion:"zuplo.build.version",ZuploBuildCompatibilityDate:"zuplo.build.compatibility_date",ZuploEnvironmentType:"zuplo.environment_type"};var zr=class{static{s(this,"PolicyBase")}options;policyName;policyType;constructor(e,t){if(!qe(t))throw new k(`The name of a policy must be a string. Received '${t}' of type '${typeof t}'`);this.options=e,this.policyName=t,this.policyType=Object.getPrototypeOf(this).constructor.name}},ye=class extends zr{static{s(this,"InboundPolicy")}},Pt=class extends zr{static{s(this,"OutboundPolicy")}};var vi=class extends ye{static{s(this,"InboundFunctionOnlyPolicy")}#e;constructor(e,t,r){super(t,r),this.policyType=e.name,this.#e=e}handler(e,t){return this.#e(e,t,this.options,this.policyName)}},xi=class extends Pt{static{s(this,"OutboundFunctionOnlyPolicy")}#e;constructor(e,t,r){super(t,r),this.policyType=e.name,this.#e=e}handler(e,t,r){return this.#e(e,t,r,this.options,this.policyName)}},wi=new Map;function Yn(n,e){let t,r;return Array.isArray(n)?t=n:(t=n.policies?.inbound??[],r=n.path),t.filter(i=>!wi.has(i)).forEach(i=>{let a=e?.find(l=>l.name===i);if(!a)throw new f(`Invalid state - no Policy with the name '${i}' ${r&&`on route '${r}'`} was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export];if(typeof c!="function")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof module '${typeof c}')`);let u;if(typeof c!="function")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof module '${typeof c}')`);if(c.prototype instanceof ye)u=new c(a.handler.options,a.name);else if(typeof c=="function")u=new vi(c,a.handler.options,a.name);else throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new f(`Invalid state - invalid handler on policy '${i}' on route '${r}' (typeof handler '${typeof u.handler}')`);wi.set(a.name,u)}),t.map(i=>{let a=wi.get(i);if(a===void 0)throw new k("Internal error. Policy not found in cache.");return a})}s(Yn,"getInboundPolicyInstances");var Ri=new Map;function Xn(n,e){let t,r;return Array.isArray(n)?t=n:(t=n.policies?.outbound??[],r=n.path),t.filter(i=>!Ri.has(i)).forEach(i=>{let a=e?.find(l=>l.name===i);if(!a)throw new f(`Invalid state - no Policy with the name '${i}' on route '${r}' was found in the policies configuration (check case).`);if(typeof a.handler?.module!="object")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof policy '${typeof a.handler?.module}')`);let c=a.handler?.module[a.handler.export],u;if(typeof c!="function")throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof module '${typeof c}')`);if(c.prototype instanceof Pt)u=new c(a.handler.options??{},a.name);else if(typeof c=="function")u=new xi(c,a.handler.options??{},a.name);else throw new f(`Invalid state - invalid policy '${i}' on route '${r}' (typeof policy '${typeof c}')`);if(typeof u.handler!="function")throw new f(`Invalid state - invalid handler on policy '${i}' on route '${r}'`);Ri.set(a.name,u)}),t.map(i=>{let a=Ri.get(i);if(a===void 0)throw new k("Internal error. Policy not found in cache.");return a})}s(Xn,"getOutboundPolicyInstances");var Pi=s(n=>async(e,t)=>{let r=_e.getContextExtensions(t),o=Ac.getTracer("pipeline");return await o.startActiveSpan("policies:inbound",async i=>{try{let a=[...n],c=e;for(;a.length>0;){let u=a.shift();if(!u)return c;let l=await o.startActiveSpan(`policy:${u.policyName}`,async d=>{let p=await u.handler(c,t);if(p instanceof Request||p instanceof ue||p instanceof Response)return d.end(),p instanceof Response||p instanceof ue?p:new ue(p);{let m=new f(`Invalid state - invalid handler on policy '${u.policyName}' on route '${t.route.path}. The result of an inbound policy must be a Response or Request.`);throw d.end(),d.setStatus({code:Oc.ERROR}),d.recordException(m),m}});if(l instanceof ue)c=l;else if(l instanceof Request)c=new ue(l);else if(l instanceof Response)return l;r.latestRequest=c}return c}finally{i.end()}})},"toStackedInboundHandler"),Ii=s(n=>async(e,t,r)=>{let o=Ac.getTracer("pipeline");return await o.startActiveSpan("policies:outbound",async i=>{try{let a=[...n],c=e;for(;a.length>0;){let u=a.shift();if(!u)return c;c=await o.startActiveSpan(`policy:${u.policyName}`,async d=>{try{d.setAttribute(lt.PolicyName,u.policyName),d.setAttribute(lt.PolicyType,u.policyType);let p=await u.handler(c,t,r);if(p instanceof Response)return p;{let m=new f(`Invalid state - invalid handler on policy '${u.policyName}' on route '${r.route.path}. The result of an outbound policy must be a Response.`);throw d.setStatus({code:Oc.ERROR}),d.recordException(m),m}}finally{d.end()}})}return c}finally{i.end()}})},"toStackedOutboundHandler"),Br=s(async(n,e,t,r)=>{let o=Yn(e.route,t.routeData.policies),i=Xn(e.route,t.routeData.policies);return kc({request:n,context:e,inboundPolicies:o,outboundPolicies:i,gateway:t,next:r})},"policyProcessor");function _c({inboundPolicies:n=[],outboundPolicies:e=[]}){return s(async(r,o,i,a)=>kc({request:r,context:o,inboundPolicies:n,outboundPolicies:e,gateway:i,next:a}),"policyProcessor")}s(_c,"createInternalPolicyProcessor");async function kc({request:n,context:e,inboundPolicies:t,outboundPolicies:r,gateway:o,next:i}){let a=Pi(t);try{let c=await a(n,e);if(c instanceof Response)return c;let u=await i(c),l=Ii(r),d;return y.instance.build.COMPATIBILITY_FLAGS.runOutboundPoliciesOnHandlerOnAllStatuses?d=l(u,n,e):d=u.ok?l(u,n,e):u,d}catch(c){return o.errorHandler(n,e,"Error executing policies",c)}}s(kc,"executePolicyProcessor");var Dc=Jl(Mc(),1);function Zc(n,e){try{let t=/v\d+(-\d+)?/g,o=(0,Dc.parse)(e.get("Cookie")||"")["zp-dev-portal"];return o!==null&&o&&t.test(o)?`https://dev-portal-${o}.zuplo.com`:n}catch{}return n}s(Zc,"devPortalBaseURL");var qc="/__zuplo/dev-portal",Bd="dev-portal-id",Gd="dev-portal-host",Vd="zp-account",Wd="zp-project",Jd="dev-portal-build",Kd=`
36
36
  <!DOCTYPE html>
37
37
  <html lang="en">
38
38
  <head>
@@ -22,4 +22,4 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{c as e,d as t,f as a,g as o,h as r,i,j as n}from"../chunk-TL3I4MGR.js";import"../chunk-PPV7V43C.js";export{o as getIdForParameterSchema,i as getIdForRefSchema,r as getIdForRequestBodySchema,a as getRawOperationDataIdentifierName,e as isRestrictedEnvVariableName,t as isZuploReadableEnvVariableName,n as sanitizedIdentifierName};
25
+ import{c as e,d as t,f as a,g as o,h as r,i,j as n}from"../chunk-TPMH5PF5.js";import"../chunk-PPV7V43C.js";export{o as getIdForParameterSchema,i as getIdForRefSchema,r as getIdForRequestBodySchema,a as getRawOperationDataIdentifierName,e as isRestrictedEnvVariableName,t as isZuploReadableEnvVariableName,n as sanitizedIdentifierName};
@@ -1022,6 +1022,15 @@ declare interface BuildRouteConfiguration {
1022
1022
  */
1023
1023
  excludeFromOpenApi?: boolean;
1024
1024
  pathPattern?: string;
1025
+ /**
1026
+ * Build-time metadata for this route.
1027
+ */
1028
+ metadata?: {
1029
+ /**
1030
+ * The source file this route was generated from.
1031
+ */
1032
+ filepath: string;
1033
+ };
1025
1034
  /* Excluded from this release type: raw */
1026
1035
  }
1027
1036
 
@@ -26,6 +26,15 @@ declare interface BuildRouteConfiguration {
26
26
  */
27
27
  excludeFromOpenApi?: boolean;
28
28
  pathPattern?: string;
29
+ /**
30
+ * Build-time metadata for this route.
31
+ */
32
+ metadata?: {
33
+ /**
34
+ * The source file this route was generated from.
35
+ */
36
+ filepath: string;
37
+ };
29
38
  /* Excluded from this release type: raw */
30
39
  }
31
40
 
@@ -24,6 +24,15 @@ declare interface BuildRouteConfiguration {
24
24
  */
25
25
  excludeFromOpenApi?: boolean;
26
26
  pathPattern?: string;
27
+ /**
28
+ * Build-time metadata for this route.
29
+ */
30
+ metadata?: {
31
+ /**
32
+ * The source file this route was generated from.
33
+ */
34
+ filepath: string;
35
+ };
27
36
  /* Excluded from this release type: raw */
28
37
  }
29
38
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.51.30",
4
+ "version": "6.51.32",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {