@zuplo/runtime 6.66.6 → 6.66.8

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.
@@ -0,0 +1,26 @@
1
+
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Zuplo, Inc. All rights reserved.
4
+ *
5
+ * This software and associated documentation files (the "Software") is intended to be used
6
+ * only by Zuplo customers solely to develop and test applications that will be deployed
7
+ * to Zuplo hosted services. You and others in your organization may use these files on your
8
+ * Development Devices solely for the above stated purpose.
9
+ *
10
+ * Outside of uses stated above, no license is granted for any other purpose including
11
+ * without limitation the rights to use, copy, modify, merge, publish, distribute,
12
+ * sublicense, host, and/or sell copies of the Software.
13
+ *
14
+ * The software may include third party components with separate legal notices or governed by
15
+ * other agreements, as described in licenses either embedded in or accompanying the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19
+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
20
+ * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
+ * DEALINGS IN THE SOFTWARE.
23
+ *--------------------------------------------------------------------------------------------*/
24
+
25
+ import{W as i,a as n}from"./chunk-OVTOTSXZ.js";var g=(o=>(o.Build="build-data",o.CorsPreflight="cors-preflight",o.DeveloperPortal="developer-portal",o.ZudokuPortal="zudoku-portal",o.DeveloperPortalLegacy="developer-portal-legacy",o.EmptyGatewayCatchall="empty-gateway-catchall",o.Ping="ping",o.UnmatchedPath="unmatched-path",o))(g||{});var p=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function l(e){return e.startsWith("__ZUPLO")||e.startsWith("ZUPLO_")?!p.includes(e)&&!e.startsWith("ZUPLO_PUBLIC_"):e.startsWith("ZUDOKU_")?!e.startsWith("ZUDOKU_PUBLIC_"):!1}n(l,"isRestrictedEnvVariableName");function _(e){return!!e.startsWith("ZUPLO_")}n(_,"isZuploReadableEnvVariableName");var u=new Proxy({},{get(e,t){let r=String(t);switch(r){case"ZUPLO_ENVIRONMENT_TYPE":return i.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return i.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return i.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return i.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return i.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return i.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return i.instance.build.COMPATIBILITY_DATE}if(!(l(r)&&!_(r)))return i.instance.runtime[r]}});function f(e,t,r){return`_${a(`${e}_${t}_${r}`)}`}n(f,"getRawOperationDataIdentifierName");function L(e,t,r,s){return`_${a(e.toLowerCase())}_${t.toLowerCase()}_${r.toLowerCase()}_${s.toLowerCase()}`}n(L,"getIdForParameterSchema");function E(e,t,r){return`_${a(e.toLowerCase())}_${t.toLowerCase()}_rb_${a(r.toLowerCase())}`}n(E,"getIdForRequestBodySchema");function C(e,t){return`_${a(e)}_${a(t)}`}n(C,"getIdForRefSchema");function a(e){let t=e.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(t)||(t=`_${t}`),t}n(a,"sanitizedIdentifierName");export{g as a,l as b,_ as c,u as d,f as e,L as f,E as g,C as h,a as i};
26
+ //# sourceMappingURL=chunk-I34NBXTA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@zuplo/runtime/router/interfaces.ts","@zuplo/runtime/environment.ts","@zuplo/runtime/utils/open-api-utils.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;+CA0CO,IAAKA,OACVA,EAAA,MAAQ,aACRA,EAAA,cAAgB,iBAChBA,EAAA,gBAAkB,mBAClBA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,qBAAuB,yBACvBA,EAAA,KAAO,OACPA,EAAA,cAAgB,iBARNA,OAAA,ICxCZ,IAAMC,EAAmC,CACvC,qCACA,iCACA,kBACA,+BACF,EASO,SAASC,EAA4BC,EAAc,CAExD,OAAIA,EAAK,WAAW,SAAS,GAAKA,EAAK,WAAW,QAAQ,EAItD,CAACF,EAAiC,SAASE,CAAI,GAC/C,CAACA,EAAK,WAAW,eAAe,EAIhCA,EAAK,WAAW,SAAS,EACpB,CAACA,EAAK,WAAW,gBAAgB,EAEnC,EACT,CAfgBC,EAAAF,EAAA,+BAoBT,SAASG,EAA+BF,EAAc,CAC3D,MAAI,EAAAA,EAAK,WAAW,QAAQ,CAI9B,CALgBC,EAAAC,EAAA,kCAWhB,IAAMC,EAAc,IAAI,MACtB,CAAC,EACD,CACE,IAAIC,EAAQC,EAAM,CAChB,IAAMC,EAAU,OAAOD,CAAI,EAG3B,OAAQC,EAAS,CACf,IAAK,yBACH,OAAOC,EAAY,SAAS,uBAC9B,IAAK,0BACH,OAAOA,EAAY,SAAS,wBAC9B,IAAK,yBACH,OAAOA,EAAY,SAAS,QAAQ,wBACtC,IAAK,qBACH,OAAOA,EAAY,SAAS,MAAM,aACpC,IAAK,qBACH,OAAOA,EAAY,SAAS,MAAM,aACpC,IAAK,iBACH,OAAOA,EAAY,SAAS,MAAM,SACpC,IAAK,2BACH,OAAOA,EAAY,SAAS,MAAM,kBACtC,CAEA,GACE,EAAAR,EAA4BO,CAAO,GACnC,CAACJ,EAA+BI,CAAO,GAKzC,OAAOC,EAAY,SAAS,QAAQD,CAAO,CAC7C,CACF,CACF,ECzEO,SAASE,EACdC,EACAC,EACAC,EACQ,CACR,MAAO,IAAIC,EAAwB,GAAGH,CAAW,IAAIC,CAAI,IAAIC,CAAS,EAAE,CAAC,EAC3E,CANgBE,EAAAL,EAAA,qCAiBT,SAASM,EACdJ,EACAC,EACAI,EACAC,EACQ,CACR,MAAO,IAAIJ,EAAwBF,EAAK,YAAY,CAAC,CAAC,IAAIC,EAAU,YAAY,CAAC,IAAII,EAAK,YAAY,CAAC,IAAIC,EAAK,YAAY,CAAC,EAC/H,CAPgBH,EAAAC,EAAA,2BAiBT,SAASG,EACdP,EACAC,EACAO,EACQ,CACR,MAAO,IAAIN,EAAwBF,EAAK,YAAY,CAAC,CAAC,IAAIC,EAAU,YAAY,CAAC,OAAOC,EAAwBM,EAAY,YAAY,CAAC,CAAC,EAC5I,CANgBL,EAAAI,EAAA,6BAeT,SAASE,EAAkBV,EAAqBW,EAAqB,CAC1E,MAAO,IAAIR,EAAwBH,CAAW,CAAC,IAAIG,EAAwBQ,CAAG,CAAC,EACjF,CAFgBP,EAAAM,EAAA,qBAUT,SAASP,EAAwBI,EAAsB,CAE5D,IAAIK,EAAcL,EAEf,QAAQ,MAAO,YAAY,EAC3B,QAAQ,MAAO,YAAY,EAC3B,QAAQ,MAAO,UAAU,EACzB,QAAQ,MAAO,UAAU,EACzB,QAAQ,MAAO,SAAS,EACxB,QAAQ,KAAM,QAAQ,EAEtB,QAAQ,MAAO,OAAO,EACtB,QAAQ,MAAO,QAAQ,EACvB,QAAQ,KAAM,SAAS,EACvB,QAAQ,KAAM,MAAM,EACpB,QAAQ,MAAO,UAAU,EAEzB,QAAQ,iBAAkB,GAAG,EAGhC,MAAK,aAAa,KAAKK,CAAW,IAChCA,EAAc,IAAIA,CAAW,IAGxBA,CACT,CAzBgBR,EAAAD,EAAA","names":["SystemRouteName","ALLOWED_WRITABLE_ZUPLO_VARIABLES","isRestrictedEnvVariableName","name","__name","isZuploReadableEnvVariableName","environment","target","prop","envName","Environment","getRawOperationDataIdentifierName","oasFileName","path","operation","sanitizedIdentifierName","__name","getIdForParameterSchema","type","name","getIdForRequestBodySchema","contentType","getIdForRefSchema","ref","encodedName"]}
@@ -22,5 +22,5 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{Y as s,a}from"./chunk-TCQULLXT.js";var e={MCP_TOOL_USAGE:"mcp_tool_usage",AI_GATEWAY_COST_SUM:"ai_gateway_cost_sum",AI_GATEWAY_REQUEST_COUNT:"ai_gateway_request_count",AI_GATEWAY_TOKEN_SUM:"ai_gateway_token_sum",AI_GATEWAY_LATENCY_HISTOGRAM:"ai_gateway_latency_histogram",AI_GATEWAY_WARNING_COUNT:"ai_gateway_warning_count",AI_GATEWAY_BLOCKED_COUNT:"ai_gateway_blocked_count"};var n=class{static{a(this,"BaseAnalyticsEvent")}eventId;requestId;timestamp;accountName;projectName;deploymentName;unit;value;constructor(t){this.eventId=t.eventId,this.requestId=t.requestId,this.timestamp=t.timestamp??new Date,this.accountName=t.accountName,this.projectName=t.projectName,this.deploymentName=t.deploymentName,this.unit=t.unit,this.value=t.value}};var r=class extends n{static{a(this,"AiGatewayBlockedCountEvent")}eventType=e.AI_GATEWAY_BLOCKED_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.type||!this.metadata.type.trim())&&(this.metadata.type="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var m=class extends n{static{a(this,"AiGatewayCostSumEvent")}eventType=e.AI_GATEWAY_COST_SUM;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var d=class extends n{static{a(this,"AiGatewayLatencyHistogramEvent")}eventType=e.AI_GATEWAY_LATENCY_HISTOGRAM;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var p=class extends n{static{a(this,"AiGatewayRequestCountEvent")}eventType=e.AI_GATEWAY_REQUEST_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var c=class extends n{static{a(this,"AiGatewayTokenSumEvent")}eventType=e.AI_GATEWAY_TOKEN_SUM;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var y=class extends n{static{a(this,"AiGatewayWarningCountEvent")}eventType=e.AI_GATEWAY_WARNING_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.type||!this.metadata.type.trim())&&(this.metadata.type="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var A=class extends n{static{a(this,"McpToolUsageEvent")}eventType=e.MCP_TOOL_USAGE;metadata;constructor(t){t.metadata.toolName.trim()||(t.metadata.toolName="unknown"),t.metadata.toolPath.trim()||(t.metadata.toolPath="unknown"),t.metadata.toolMethod.trim()||(t.metadata.toolMethod="unknown"),t.metadata.toolOperationId.trim()||(t.metadata.toolOperationId="unknown"),super(t),this.metadata=t.metadata}};var f={[e.MCP_TOOL_USAGE]:A,[e.AI_GATEWAY_COST_SUM]:m,[e.AI_GATEWAY_REQUEST_COUNT]:p,[e.AI_GATEWAY_TOKEN_SUM]:c,[e.AI_GATEWAY_LATENCY_HISTOGRAM]:d,[e.AI_GATEWAY_WARNING_COUNT]:y,[e.AI_GATEWAY_BLOCKED_COUNT]:r};function l(o,t){let i=f[o];return new i(t)}a(l,"createAnalyticsEvent");var E=class{static{a(this,"ZuploGatewayAnalyticsContext")}#t;#e;constructor(t){this.#t=[],this.#e=t}addAnalyticsEvent(t,i,u,v){let T=this.createAnalyticsEvent(t,i,u,v);this.#t.push(T)}flushAnalyticsEvents(){let t=[...this.#t];return this.#t.length=0,t}getAnalyticsEvents(){return[...this.#t]}createAnalyticsEvent(t,i,u,v){return l(i,{eventId:crypto.randomUUID(),requestId:this.#e,accountName:s.instance.build.ACCOUNT_NAME??"unknown",projectName:s.instance.build.PROJECT_NAME??"unknown",deploymentName:s.instance.deploymentName??"unknown",metadata:u,unit:v,value:t})}};export{e as a,E as b};
26
- //# sourceMappingURL=chunk-B2VZ5MPO.js.map
25
+ import{W as s,a}from"./chunk-OVTOTSXZ.js";var e={MCP_TOOL_USAGE:"mcp_tool_usage",AI_GATEWAY_COST_SUM:"ai_gateway_cost_sum",AI_GATEWAY_REQUEST_COUNT:"ai_gateway_request_count",AI_GATEWAY_TOKEN_SUM:"ai_gateway_token_sum",AI_GATEWAY_LATENCY_HISTOGRAM:"ai_gateway_latency_histogram",AI_GATEWAY_WARNING_COUNT:"ai_gateway_warning_count",AI_GATEWAY_BLOCKED_COUNT:"ai_gateway_blocked_count"};var n=class{static{a(this,"BaseAnalyticsEvent")}eventId;requestId;timestamp;accountName;projectName;deploymentName;unit;value;constructor(t){this.eventId=t.eventId,this.requestId=t.requestId,this.timestamp=t.timestamp??new Date,this.accountName=t.accountName,this.projectName=t.projectName,this.deploymentName=t.deploymentName,this.unit=t.unit,this.value=t.value}};var r=class extends n{static{a(this,"AiGatewayBlockedCountEvent")}eventType=e.AI_GATEWAY_BLOCKED_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.type||!this.metadata.type.trim())&&(this.metadata.type="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var m=class extends n{static{a(this,"AiGatewayCostSumEvent")}eventType=e.AI_GATEWAY_COST_SUM;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var d=class extends n{static{a(this,"AiGatewayLatencyHistogramEvent")}eventType=e.AI_GATEWAY_LATENCY_HISTOGRAM;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var p=class extends n{static{a(this,"AiGatewayRequestCountEvent")}eventType=e.AI_GATEWAY_REQUEST_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var c=class extends n{static{a(this,"AiGatewayTokenSumEvent")}eventType=e.AI_GATEWAY_TOKEN_SUM;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.model||!this.metadata.model.trim())&&(this.metadata.model="unknown"),(!this.metadata.provider||!this.metadata.provider.trim())&&(this.metadata.provider="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var y=class extends n{static{a(this,"AiGatewayWarningCountEvent")}eventType=e.AI_GATEWAY_WARNING_COUNT;metadata;constructor(t){super(t),this.metadata=t.metadata,(!this.metadata.type||!this.metadata.type.trim())&&(this.metadata.type="unknown"),(!this.metadata.configId||!this.metadata.configId.trim())&&(this.metadata.configId="unknown")}};var A=class extends n{static{a(this,"McpToolUsageEvent")}eventType=e.MCP_TOOL_USAGE;metadata;constructor(t){t.metadata.toolName.trim()||(t.metadata.toolName="unknown"),t.metadata.toolPath.trim()||(t.metadata.toolPath="unknown"),t.metadata.toolMethod.trim()||(t.metadata.toolMethod="unknown"),t.metadata.toolOperationId.trim()||(t.metadata.toolOperationId="unknown"),super(t),this.metadata=t.metadata}};var f={[e.MCP_TOOL_USAGE]:A,[e.AI_GATEWAY_COST_SUM]:m,[e.AI_GATEWAY_REQUEST_COUNT]:p,[e.AI_GATEWAY_TOKEN_SUM]:c,[e.AI_GATEWAY_LATENCY_HISTOGRAM]:d,[e.AI_GATEWAY_WARNING_COUNT]:y,[e.AI_GATEWAY_BLOCKED_COUNT]:r};function l(o,t){let i=f[o];return new i(t)}a(l,"createAnalyticsEvent");var E=class{static{a(this,"ZuploGatewayAnalyticsContext")}#t;#e;constructor(t){this.#t=[],this.#e=t}addAnalyticsEvent(t,i,u,v){let T=this.createAnalyticsEvent(t,i,u,v);this.#t.push(T)}flushAnalyticsEvents(){let t=[...this.#t];return this.#t.length=0,t}getAnalyticsEvents(){return[...this.#t]}createAnalyticsEvent(t,i,u,v){return l(i,{eventId:crypto.randomUUID(),requestId:this.#e,accountName:s.instance.build.ACCOUNT_NAME??"unknown",projectName:s.instance.build.PROJECT_NAME??"unknown",deploymentName:s.instance.deploymentName??"unknown",metadata:u,unit:v,value:t})}};export{e as a,E as b};
26
+ //# sourceMappingURL=chunk-JBGSMWP6.js.map
@@ -32,6 +32,6 @@ var ge=Object.create;var S=Object.defineProperty;var _e=Object.getOwnPropertyDes
32
32
  `))):l=e.stylize("[Circular]","special")),ee(s)){if(u&&o.match(/^\d+$/))return l;s=JSON.stringify(""+o),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+l}r(z,"formatProperty");function Je(e,t){if(ee(t))return e.stylize("undefined","undefined");if(te(t)){let n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(je(t))return e.stylize(""+t,"number");if(Be(t))return e.stylize(""+t,"boolean");if(ne(t))return e.stylize("null","null")}r(Je,"formatPrimitive");function Ke(e,t,n){let i=0;return e.reduce(function(u,s){return i++,s.indexOf(`
33
33
  `)>=0&&i++,u+s.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(t===""?"":t+`
34
34
  `)+" "+e.join(`,
35
- `)+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}r(Ke,"reduceToSingleString");var oe=r((e,...t)=>X(x,e,t),"format");var k=class{static{r(this,"Debugger")}manager;ns;color;last;enabled;constructor(t,n){this.manager=t,this.ns=n,this.color=K(n),this.last=0,this.enabled=t.enabled.some(i=>i.test(n))}log(...t){if(!this.enabled)return;let n,i=t[0];typeof i=="function"?n=i():n=String(i);let o=Date.now()-(this.last||Date.now());n=oe(n,...t);let u=`${this.color(this.ns)} ${n} ${this.color(`+${o}ms`)}`;console.log(u),this.last=Date.now()}},$=class{static{r(this,"DebugManager")}debuggers;enabled;constructor(t){this.debuggers=new Map,this.enabled=t??[]}};function Xe(e){return!e||e.length===0?[]:(e=e.replace(/\s/g,"").replace(/\*/g,".+"),e.split(",").map(t=>new RegExp(`^${t}$`)))}r(Xe,"extract");var U;function ie(e){let t=globalThis.DEBUG;U||(U=new $(Xe(t)));let n=new k(U,e);return U.debuggers.set(e,n),Object.assign(n.log.bind(n),{self:n})}r(ie,"debug");function Qe(e){if(e.length>=255)throw new TypeError("Alphabet too long");let t=new Uint8Array(256);for(let c=0;c<t.length;c++)t[c]=255;for(let c=0;c<e.length;c++){let a=e.charAt(c),m=a.charCodeAt(0);if(t[m]!==255)throw new TypeError(a+" is ambiguous");t[m]=c}let n=e.length,i=e.charAt(0),o=Math.log(n)/Math.log(256),u=Math.log(256)/Math.log(n);function s(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let a=0,m=0,_=0,g=c.length;for(;_!==g&&c[_]===0;)_++,a++;let E=(g-_)*u+1>>>0,h=new Uint8Array(E);for(;_!==g;){let d=c[_],y=0;for(let A=E-1;(d!==0||y<m)&&A!==-1;A--,y++)d+=256*h[A]>>>0,h[A]=d%n>>>0,d=d/n>>>0;if(d!==0)throw new Error("Non-zero carry");m=y,_++}let p=E-m;for(;p!==E&&h[p]===0;)p++;let R=i.repeat(a);for(;p<E;++p)R+=e.charAt(h[p]);return R}r(s,"encode");function l(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let a=0,m=0,_=0;for(;c[a]===i;)m++,a++;let g=(c.length-a)*o+1>>>0,E=new Uint8Array(g);for(;c[a];){let d=t[c.charCodeAt(a)];if(d===255)return;let y=0;for(let A=g-1;(d!==0||y<_)&&A!==-1;A--,y++)d+=n*E[A]>>>0,E[A]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");_=y,a++}let h=g-_;for(;h!==g&&E[h]===0;)h++;let p=new Uint8Array(m+(g-h)),R=m;for(;h!==g;)p[R++]=E[h++];return p}r(l,"decodeUnsafe");function f(c){let a=l(c);if(a)return a;throw new Error("Non-base"+n+" character")}return r(f,"decode"),{encode:s,decodeUnsafe:l,decode:f}}r(Qe,"base");var se=Qe;var et="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ce=se(et);var L=ie("zuplo:runtime:external-service");function tt(){let e,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:t}=O.instance.runtime;if(t&&t!=="undefined")try{let n=atob(t);e=JSON.parse(n)}catch{}return e}r(tt,"getServiceAuth");async function ue(e,t){let n=".proxy",i=".tunnel";if(typeof e=="string"){let o=new URL(e),u=o.hostname;if(u.endsWith(n)){let p=u.slice(0,-n.length),R=new URL(`http://${p}${o.pathname}${o.search}`);L(`Routing to proxy: ${R.toString()}`);let d=t??{};return P(R.toString(),d)}let s=u.endsWith(i),l=u.indexOf(".")===-1;if(!(s||l))throw new b(`Invalid service hostname suffix: ${u}. Use .proxy for proxy routing, .tunnel for explicit tunnel routing, or no suffix for default tunnel routing.`);let c=s?u.slice(0,-i.length):u,a=tt();if(!a)throw L("There is no external service auth configured for this zup."),new b("There are no external services configured for this zup.");L(`Using external service auth. ClientId: ${a.clientId})`);let m=t??{},_=new Headers(m.headers||{});_.set("CF-Access-Client-Id",a.clientId),_.set("CF-Access-Client-Secret",a.clientSecret),m.headers=_;let g;if(a.customServiceMapping?.[c])g=`https://${a.customServiceMapping[c]}`;else if(O.instance.useLegacyServiceRouting)g=`https://${c}.zuptunnel.com`;else{L("Using sha256 service routing");let p=O.instance.build;if(p.ACCOUNT_NAME&&p.PROJECT_NAME&&p.ENVIRONMENT_TYPE){let R=await nt(c,p.ACCOUNT_NAME,p.PROJECT_NAME,p.ENVIRONMENT_TYPE),d=ae(p.ENVIRONMENT_TYPE),y=await G(`${p.ACCOUNT_NAME}-${p.PROJECT_NAME}-${d}`);y==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||y==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?g=`https://${R}.zuptunnel.com`:g=`https://${R}.t.zuplo.app`}else throw L("Cannot use sha256 service routing, missing build variables"),new b("Failed to generate fully qualified tunnel url.")}let E=new URL(`${g}${o.pathname}${o.search}`);L(`Calling external service: ${E.toString()}`);let h=await P(E.toString(),m);if(h.status===403&&h.headers.get("cf-access-domain")!==null)throw C.console.error("403 Forbidden when calling external service.",{clientId:a.clientId,tunnelHost:g}),new b("Could not connect to secure tunnel.");return h}else throw L("Cannot call external service with Request object"),new b("Currently, we only support fetch(<some_string>, ...).")}r(ue,"externalServiceHandler");async function le(e,t){if(typeof e=="string"){let n=new URL(e),i=n.hostname,o=t??{},u=`http://${i}.zuplo.svc.cluster.local:9000`,s=new URL(`${u}${n.pathname}${n.search}`),l=new Headers(o.headers||{});return l.set(N,i),o.headers=l,await P(s.toString(),o)}else throw new b("Currently, we only support fetch(<some_string>, ...).")}r(le,"clusterServiceHandler");async function nt(e,t,n,i){let o=e.toLowerCase(),u=t.toLowerCase(),s=n.toLowerCase(),l=ae(i);L(`Hashing service name: ${u}-${o}.${u}-${s}-${l}`);let f=await G(`${u}-${o}`),c=await G(`${u}-${s}-${l}`);return`${f}.${c}`}r(nt,"hashServiceName");async function G(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(u=>u.toString(16).padStart(2,"0")).join("").slice(0,-1)}r(G,"hashSegment");function ae(e){let t=e.toLowerCase();switch(t){case"production":case"preview":return t;default:return"working-copy"}}r(ae,"sanitizeEnvironmentType");var V=new Map;V.set("service:",ue);V.set("local:",le);var P=globalThis.fetch;function B(e,t){let{transformedInit:n,mtlsCertificate:i}=rt(t);if(typeof e=="string"){let o=new URL(e),u=V.get(o.protocol);return u?u(e,n):fe(e,n,i)}else return fe(e,n,i)}r(B,"internalFetch");globalThis.fetch=B;function fe(e,t,n){if(!n)return P(e,t);if(O.instance.isCloudflare){let o=O.instance.runtime[n];if(!o)throw new Error(`mTLS certificate binding '${n}' not found. Ensure the certificate is uploaded and properly configured.`);if(typeof o!="object"||typeof o.fetch!="function")throw new Error(`mTLS certificate binding '${n}' is not a valid mTLS certificate binding. Make sure it's configured as an mTLS certificate, not an environment variable.`);return o.fetch(e,t)}else throw O.instance.isDeno?new Error("mTLS client certificates are not yet supported in Deno runtime. This will be added in a future update."):new Error("mTLS client certificates are not supported in this runtime environment")}r(fe,"performFetch");var rt=r(e=>{if(!e||e instanceof Request)return{transformedInit:e,mtlsCertificate:void 0};let t=e;if(!t.zuplo)return{transformedInit:e,mtlsCertificate:void 0};let n=t.zuplo.mtlsCertificate,i=e;return i.cf={cacheEverything:t.zuplo?.cacheEverything,cacheTtl:t.zuplo?.cacheTtlSeconds},delete e.zuplo,{transformedInit:e,mtlsCertificate:n}},"transformInit");var ot={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:B},C=ot;var Y="2025-02-06",pe=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2026-03-01":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,chainResponseSendingHooks:!0,return501ForUnsupportedHttpMethods:!0}});function de(){return new O({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:Y,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:pe[Y]},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:"",ZUPLO_SERVICE_BUCKET_ID:"mock-bucket-id"}})}r(de,"getMockEnvironment");var O=class e{static{r(this,"Environment")}config;static#e;static#t=!1;static initialize(t){e.#e||(e.#e=new e(t),e.#t=!0)}static get instance(){return e.#t||(C.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),e.#e=de()),e.#e}constructor({build:t,runtime:n}){let i;try{if(n.ZUPLO_SYSTEM_CONFIGURATIONS){let o=new TextDecoder().decode(ce.decode(n.ZUPLO_SYSTEM_CONFIGURATIONS)),u=JSON.parse(o);for(let s of Object.keys(u))n[s]||(n[s]=u[s])}if(n.__ZUPLO_CONFIG){let o=atob(n.__ZUPLO_CONFIG);i=JSON.parse(o)}}catch(o){C.console.error("Failed to parse runtime configuration",o)}this.config=i??{},this.build=t,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.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isManagedDedicated(){return this.runtime.__ZUPLO_IS_MANAGED_DEDICATED==="true"}get isDeno(){if(this.runtime.__ZUPLO_RUNTIME_TYPE)return this.runtime.__ZUPLO_RUNTIME_TYPE==="deno";if(this.config.runtime_type)return this.config.runtime_type==="deno";{let t=globalThis.Deno?.version?.deno;return typeof WebSocketPair!="function"&&t}}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"}get rateLimitServiceTimeoutMs(){let t=this.runtime.__ZUPLO_RATE_LIMIT_TIMEOUT_MS,n=this.config.rate_limit_service_timeout_ms,i=t??n;if(!i)return 500;let o=Number(i);return Number.isFinite(o)&&o>0?o:500}};export{r as a,it as b,st as c,ct as d,ut as e,lt as f,ie as g,ft as h,Oe as i,Re as j,ye as k,pt as l,dt as m,gt as n,be as o,Ae as p,xe as q,Le as r,Te as s,_t as t,ht as u,mt as v,Et as w,Ot as x,Rt as y,yt as z,bt as A,At as B,xt as C,Ie as D,Se as E,Pe as F,Ce as G,we as H,Ue as I,Ne as J,De as K,Lt as L,N as M,He as N,Tt as O,It as P,St as Q,Pt as R,Ct as S,wt as T,Ut as U,q as V,b as W,W as X,O as Y,C as Z};
36
- /*! For license information please see chunk-TCQULLXT.js.LEGAL.txt */
37
- //# sourceMappingURL=chunk-TCQULLXT.js.map
35
+ `)+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}r(Ke,"reduceToSingleString");var oe=r((e,...t)=>X(x,e,t),"format");var k=class{static{r(this,"Debugger")}manager;ns;color;last;enabled;constructor(t,n){this.manager=t,this.ns=n,this.color=K(n),this.last=0,this.enabled=t.enabled.some(i=>i.test(n))}log(...t){if(!this.enabled)return;let n,i=t[0];typeof i=="function"?n=i():n=String(i);let o=Date.now()-(this.last||Date.now());n=oe(n,...t);let u=`${this.color(this.ns)} ${n} ${this.color(`+${o}ms`)}`;console.log(u),this.last=Date.now()}},$=class{static{r(this,"DebugManager")}debuggers;enabled;constructor(t){this.debuggers=new Map,this.enabled=t??[]}};function Xe(e){return!e||e.length===0?[]:(e=e.replace(/\s/g,"").replace(/\*/g,".+"),e.split(",").map(t=>new RegExp(`^${t}$`)))}r(Xe,"extract");var U;function ie(e){let t=globalThis.DEBUG;U||(U=new $(Xe(t)));let n=new k(U,e);return U.debuggers.set(e,n),Object.assign(n.log.bind(n),{self:n})}r(ie,"debug");function Qe(e){if(e.length>=255)throw new TypeError("Alphabet too long");let t=new Uint8Array(256);for(let c=0;c<t.length;c++)t[c]=255;for(let c=0;c<e.length;c++){let a=e.charAt(c),m=a.charCodeAt(0);if(t[m]!==255)throw new TypeError(a+" is ambiguous");t[m]=c}let n=e.length,i=e.charAt(0),o=Math.log(n)/Math.log(256),u=Math.log(256)/Math.log(n);function s(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let a=0,m=0,_=0,g=c.length;for(;_!==g&&c[_]===0;)_++,a++;let E=(g-_)*u+1>>>0,h=new Uint8Array(E);for(;_!==g;){let d=c[_],y=0;for(let A=E-1;(d!==0||y<m)&&A!==-1;A--,y++)d+=256*h[A]>>>0,h[A]=d%n>>>0,d=d/n>>>0;if(d!==0)throw new Error("Non-zero carry");m=y,_++}let p=E-m;for(;p!==E&&h[p]===0;)p++;let R=i.repeat(a);for(;p<E;++p)R+=e.charAt(h[p]);return R}r(s,"encode");function l(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let a=0,m=0,_=0;for(;c[a]===i;)m++,a++;let g=(c.length-a)*o+1>>>0,E=new Uint8Array(g);for(;c[a];){let d=t[c.charCodeAt(a)];if(d===255)return;let y=0;for(let A=g-1;(d!==0||y<_)&&A!==-1;A--,y++)d+=n*E[A]>>>0,E[A]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");_=y,a++}let h=g-_;for(;h!==g&&E[h]===0;)h++;let p=new Uint8Array(m+(g-h)),R=m;for(;h!==g;)p[R++]=E[h++];return p}r(l,"decodeUnsafe");function f(c){let a=l(c);if(a)return a;throw new Error("Non-base"+n+" character")}return r(f,"decode"),{encode:s,decodeUnsafe:l,decode:f}}r(Qe,"base");var se=Qe;var et="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ce=se(et);var L=ie("zuplo:runtime:external-service");function tt(){let e,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:t}=O.instance.runtime;if(t&&t!=="undefined")try{let n=atob(t);e=JSON.parse(n)}catch{}return e}r(tt,"getServiceAuth");async function ue(e,t){let n=".proxy",i=".tunnel";if(typeof e=="string"){let o=new URL(e),u=o.hostname;if(u.endsWith(n)){let p=u.slice(0,-n.length),R=new URL(`http://${p}${o.pathname}${o.search}`);L(`Routing to proxy: ${R.toString()}`);let d=t??{};return P(R.toString(),d)}let s=u.endsWith(i),l=u.indexOf(".")===-1;if(!(s||l))throw new b(`Invalid service hostname suffix: ${u}. Use .proxy for proxy routing, .tunnel for explicit tunnel routing, or no suffix for default tunnel routing.`);let c=s?u.slice(0,-i.length):u,a=tt();if(!a)throw L("There is no external service auth configured for this zup."),new b("There are no external services configured for this zup.");L(`Using external service auth. ClientId: ${a.clientId})`);let m=t??{},_=new Headers(m.headers||{});_.set("CF-Access-Client-Id",a.clientId),_.set("CF-Access-Client-Secret",a.clientSecret),m.headers=_;let g;if(a.customServiceMapping?.[c])g=`https://${a.customServiceMapping[c]}`;else if(O.instance.useLegacyServiceRouting)g=`https://${c}.zuptunnel.com`;else{L("Using sha256 service routing");let p=O.instance.build;if(p.ACCOUNT_NAME&&p.PROJECT_NAME&&p.ENVIRONMENT_TYPE){let R=await nt(c,p.ACCOUNT_NAME,p.PROJECT_NAME,p.ENVIRONMENT_TYPE),d=ae(p.ENVIRONMENT_TYPE),y=await G(`${p.ACCOUNT_NAME}-${p.PROJECT_NAME}-${d}`);y==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||y==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?g=`https://${R}.zuptunnel.com`:g=`https://${R}.t.zuplo.app`}else throw L("Cannot use sha256 service routing, missing build variables"),new b("Failed to generate fully qualified tunnel url.")}let E=new URL(`${g}${o.pathname}${o.search}`);L(`Calling external service: ${E.toString()}`);let h=await P(E.toString(),m);if(h.status===403&&h.headers.get("cf-access-domain")!==null)throw C.console.error("403 Forbidden when calling external service.",{clientId:a.clientId,tunnelHost:g}),new b("Could not connect to secure tunnel.");return h}else throw L("Cannot call external service with Request object"),new b("Currently, we only support fetch(<some_string>, ...).")}r(ue,"externalServiceHandler");async function le(e,t){if(typeof e=="string"){let n=new URL(e),i=n.hostname,o=t??{},u=`http://${i}.zuplo.svc.cluster.local:9000`,s=new URL(`${u}${n.pathname}${n.search}`),l=new Headers(o.headers||{});return l.set(N,i),o.headers=l,await P(s.toString(),o)}else throw new b("Currently, we only support fetch(<some_string>, ...).")}r(le,"clusterServiceHandler");async function nt(e,t,n,i){let o=e.toLowerCase(),u=t.toLowerCase(),s=n.toLowerCase(),l=ae(i);L(`Hashing service name: ${u}-${o}.${u}-${s}-${l}`);let f=await G(`${u}-${o}`),c=await G(`${u}-${s}-${l}`);return`${f}.${c}`}r(nt,"hashServiceName");async function G(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(u=>u.toString(16).padStart(2,"0")).join("").slice(0,-1)}r(G,"hashSegment");function ae(e){let t=e.toLowerCase();switch(t){case"production":case"preview":return t;default:return"working-copy"}}r(ae,"sanitizeEnvironmentType");var V=new Map;V.set("service:",ue);V.set("local:",le);var P=globalThis.fetch;function B(e,t){let{transformedInit:n,mtlsCertificate:i}=rt(t);if(typeof e=="string"){let o=new URL(e),u=V.get(o.protocol);return u?u(e,n):fe(e,n,i)}else return fe(e,n,i)}r(B,"internalFetch");globalThis.fetch=B;function fe(e,t,n){if(!n)return P(e,t);if(O.instance.isCloudflare){let o=O.instance.runtime[n];if(!o)throw new Error(`mTLS certificate binding '${n}' not found. Ensure the certificate is uploaded and properly configured.`);if(typeof o!="object"||typeof o.fetch!="function")throw new Error(`mTLS certificate binding '${n}' is not a valid mTLS certificate binding. Make sure it's configured as an mTLS certificate, not an environment variable.`);return o.fetch(e,t)}else throw O.instance.isDeno?new Error("mTLS client certificates are not yet supported in Deno runtime. This will be added in a future update."):new Error("mTLS client certificates are not supported in this runtime environment")}r(fe,"performFetch");var rt=r(e=>{if(!e||e instanceof Request)return{transformedInit:e,mtlsCertificate:void 0};let t=e;if(!t.zuplo)return{transformedInit:e,mtlsCertificate:void 0};let n=t.zuplo.mtlsCertificate,i=e;return i.cf={cacheEverything:t.zuplo?.cacheEverything,cacheTtl:t.zuplo?.cacheTtlSeconds},delete e.zuplo,{transformedInit:e,mtlsCertificate:n}},"transformInit");var ot={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:B},C=ot;var Y="2025-02-06",pe=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1},"2026-03-01":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,chainResponseSendingHooks:!0,return501ForUnsupportedHttpMethods:!0}});function de(){return new O({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:Y,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:pe[Y]},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:"",ZUPLO_SERVICE_BUCKET_ID:"mock-bucket-id"}})}r(de,"getMockEnvironment");var O=class e{static{r(this,"Environment")}config;static#e;static#t=!1;static initialize(t){e.#e||(e.#e=new e(t),e.#t=!0)}static get instance(){return e.#t||(C.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),e.#e=de()),e.#e}constructor({build:t,runtime:n}){let i;try{if(n.ZUPLO_SYSTEM_CONFIGURATIONS){let o=new TextDecoder().decode(ce.decode(n.ZUPLO_SYSTEM_CONFIGURATIONS)),u=JSON.parse(o);for(let s of Object.keys(u))n[s]||(n[s]=u[s])}if(n.__ZUPLO_CONFIG){let o=atob(n.__ZUPLO_CONFIG);i=JSON.parse(o)}}catch(o){C.console.error("Failed to parse runtime configuration",o)}this.config=i??{},this.build=t,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.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isManagedDedicated(){return this.runtime.__ZUPLO_IS_MANAGED_DEDICATED==="true"}get isDeno(){if(this.runtime.__ZUPLO_RUNTIME_TYPE)return this.runtime.__ZUPLO_RUNTIME_TYPE==="deno";if(this.config.runtime_type)return this.config.runtime_type==="deno";{let t=globalThis.Deno?.version?.deno;return typeof WebSocketPair!="function"&&t}}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"}get rateLimitServiceTimeoutMs(){let t=this.runtime.__ZUPLO_RATE_LIMIT_TIMEOUT_MS,n=this.config.rate_limit_service_timeout_ms,i=t??n;if(!i)return 500;let o=Number(i);return Number.isFinite(o)&&o>0?o:500}};export{r as a,it as b,st as c,ct as d,ut as e,lt as f,ie as g,ft as h,Oe as i,Re as j,ye as k,pt as l,dt as m,gt as n,be as o,Ae as p,xe as q,Le as r,Te as s,_t as t,ht as u,mt as v,Et as w,Ot as x,Rt as y,yt as z,bt as A,At as B,xt as C,Ie as D,Se as E,Pe as F,Ce as G,we as H,Ue as I,Ne as J,De as K,Lt as L,N as M,He as N,Tt as O,It as P,St as Q,Pt as R,Ut as S,q as T,b as U,W as V,O as W,C as X};
36
+ /*! For license information please see chunk-OVTOTSXZ.js.LEGAL.txt */
37
+ //# sourceMappingURL=chunk-OVTOTSXZ.js.map