@zuplo/graphql 5.1465.0 → 5.1467.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.minified.js CHANGED
@@ -61,7 +61,7 @@ ${r}
61
61
  `)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,this.canonicalHeaders+`
62
62
  `,this.signedHeaders,await this.hexBodyHash()].join(`
63
63
  `)}async hexBodyHash(){let e=this.headers.get("X-Amz-Content-Sha256");if(e==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new gy.RuntimeError("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");e=sd(await my(this.body||""))}return e}};mn.AwsV4Signer=ks;async function yi(t,e){let r=await crypto.subtle.importKey("raw",typeof t=="string"?ad.encode(t):t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",r,ad.encode(e))}o(yi,"hmac");async function my(t){return crypto.subtle.digest("SHA-256",typeof t=="string"?ad.encode(t):t)}o(my,"hash");function sd(t){return Array.prototype.map.call(new Uint8Array(t),e=>("0"+e.toString(16)).slice(-2)).join("")}o(sd,"buf2hex");function yy(t){return t.replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())}o(yy,"encodeRfc3986");function uI(t,e){let{hostname:r,pathname:n}=t,i=r.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[s,a]=(i||["",""]).slice(1,3);if(a==="us-gov")a="us-gov-west-1";else if(a==="s3"||a==="s3-accelerate")a="us-east-1",s="s3";else if(s==="iot")r.startsWith("iot.")?s="execute-api":r.startsWith("data.jobs.iot.")?s="iot-jobs-data":s=n==="/mqtt"?"iotdevicegateway":"iotdata";else if(s==="autoscaling"){let c=(e.get("X-Amz-Target")||"").split(".")[0];c==="AnyScaleFrontendService"?s="application-autoscaling":c==="AnyScaleScalingPlannerFrontendService"&&(s="autoscaling-plans")}else a==null&&s.startsWith("s3-")?(a=s.slice(3).replace(/^fips-|^external-1/,""),s="s3"):s.endsWith("-fips")?s=s.slice(0,-5):a&&/-\d$/.test(s)&&!/-\d$/.test(a)&&([s,a]=[a,s]);return s in fy?[fy[s],a]:[s,a]}o(uI,"guessServiceRegion")});var _y=g(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.convertStringToUtf8Array=St.convertUtf8ArrayToString=St.base64Encode=St.base64Decode=void 0;function lI(t){return t>64&&t<91?t-65:t>96&&t<123?t-71:t>47&&t<58?t+4:t===43?62:t===47?63:0}o(lI,"b64ToUint6");function dI(t,e){let r=t.replace(/[^A-Za-z0-9+/]/g,""),n=r.length,i=e?Math.ceil((n*3+1>>2)/e)*e:n*3+1>>2,s=new Uint8Array(i),a,c,u=0,l=0;for(let d=0;d<n;d++)if(c=d&3,u|=lI(r.charCodeAt(d))<<6*(3-c),c===3||n-d===1){for(a=0;a<3&&l<i;)s[l]=u>>>(16>>>a&24)&255,a++,l++;u=0}return s}o(dI,"base64Decode");St.base64Decode=dI;function Fs(t){return t<26?t+65:t<52?t+71:t<62?t-4:t===62?43:t===63?47:65}o(Fs,"uint6ToB64");function pI(t){let e=2,r="",n=t.length,i=0;for(let s=0;s<n;s++)e=s%3,i|=t[s]<<(16>>>e&24),(e===2||t.length-s===1)&&(r+=String.fromCodePoint(Fs(i>>>18&63),Fs(i>>>12&63),Fs(i>>>6&63),Fs(i&63)),i=0);return r.substring(0,r.length-2+e)+(e===2?"":e===1?"=":"==")}o(pI,"base64Encode");St.base64Encode=pI;function hI(t){let e="",r,n=t.length;for(let i=0;i<n;i++)r=t[i],e+=String.fromCodePoint(r>251&&r<254&&i+5<n?(r-252)*1073741824+(t[++i]-128<<24)+(t[++i]-128<<18)+(t[++i]-128<<12)+(t[++i]-128<<6)+t[++i]-128:r>247&&r<252&&i+4<n?(r-248<<24)+(t[++i]-128<<18)+(t[++i]-128<<12)+(t[++i]-128<<6)+t[++i]-128:r>239&&r<248&&i+3<n?(r-240<<18)+(t[++i]-128<<12)+(t[++i]-128<<6)+t[++i]-128:r>223&&r<240&&i+2<n?(r-224<<12)+(t[++i]-128<<6)+t[++i]-128:r>191&&r<224&&i+1<n?(r-192<<6)+t[++i]-128:r);return e}o(hI,"convertUtf8ArrayToString");St.convertUtf8ArrayToString=hI;function fI(t){let e,r=t.length,n=0;for(let c=0;c<r;c++)e=t.codePointAt(c),e>=65536&&c++,n+=e<128?1:e<2048?2:e<65536?3:e<2097152?4:e<67108864?5:6;let i=new Uint8Array(n),s=0,a=0;for(;s<n;)e=t.codePointAt(a),e<128?i[s++]=e:e<2048?(i[s++]=192+(e>>>6),i[s++]=128+(e&63)):e<65536?(i[s++]=224+(e>>>12),i[s++]=128+(e>>>6&63),i[s++]=128+(e&63)):e<2097152?(i[s++]=240+(e>>>18),i[s++]=128+(e>>>12&63),i[s++]=128+(e>>>6&63),i[s++]=128+(e&63),a++):e<67108864?(i[s++]=248+(e>>>24),i[s++]=128+(e>>>18&63),i[s++]=128+(e>>>12&63),i[s++]=128+(e>>>6&63),i[s++]=128+(e&63),a++):(i[s++]=252+(e>>>30),i[s++]=128+(e>>>24&63),i[s++]=128+(e>>>18&63),i[s++]=128+(e>>>12&63),i[s++]=128+(e>>>6&63),i[s++]=128+(e&63),a++),a++;return i}o(fI,"convertStringToUtf8Array");St.convertStringToUtf8Array=fI});var by=g(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});Hs.toCLFDate=void 0;function yn(t){let e=t.toString();return`${e.length===1?"0":""}${e}`}o(yn,"numberToString");function mI(t){let e=t.getTimezoneOffset(),r=Math.abs(e),n=e>0?"-":"+",i=yn(Math.floor(r/60)),s=yn(r%60);return`${n}${i}${s}`}o(mI,"getCLFOffset");function yI(t=new Date){if(!(t instanceof Date))throw new Error("clf-date: invalid parameter");let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=yn(t.getDate()),n=e[t.getMonth()],i=t.getFullYear(),s=yn(t.getHours()),a=yn(t.getMinutes()),c=yn(t.getSeconds()),u=mI(t);return`${r}/${n}/${i}:${s}:${a}:${c} ${u}`}o(yI,"toCLFDate");Hs.toCLFDate=yI});var Ay=g(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.getResponse=sr.awsLambdaHandler=sr.AwsLambdaHandlerExtensions=void 0;var gI=wr(),Ey=hy(),gi=D(),_I=Nt(),bI=ud(),vy=_y(),Ty=by(),wy=(0,gI.debug)("zuplo:runtime"),EI="X-Amzn-Trace-Id",wI="x-amzn-errortype",Sy=[],vI=o(async(t,e,r)=>{let n=r;for await(let i of Sy)n=await i(t,e,r);return n},"onSendingAwsLambdaEvent"),Be=class extends gi.RuntimeError{static{o(this,"AwsLambdaError")}traceId;errorType;constructor(e,r){super(`Failed to invoke AWS Lambda function. ${e}`),this.traceId=r.get(EI)??void 0,this.errorType=r.get(wI)??void 0}};sr.AwsLambdaHandlerExtensions={addSendingAwsLambdaEventHook:t=>{Sy.push(t)}};async function TI(t,e){let{accessKeyId:r,secretAccessKey:n,region:i,functionName:s,useLambdaProxyIntegration:a=!0,useAwsResourcePathStyle:c=!1,binaryMediaTypes:u}=e.route.handler.options;if(!r)throw new gi.ConfigurationError("awsAccessKeyId is not set in the handler options");if(!n)throw new gi.ConfigurationError("secretAccessKey is not set in the handler options");if(!i)throw new gi.ConfigurationError("region is not set in the handler options");if(!s)throw new gi.ConfigurationError("functionName is not set in the handler options");let l=new bI.AwsClient({accessKeyId:r,secretAccessKey:n}),d=`https://lambda.${i}.amazonaws.com/2015-03-31/functions/${s}/invocations`;if(wy(`AWS Lambda URL: ${d}`),!a)return l.fetch(d,{body:await t.arrayBuffer()});let[p,m]=await AI(t,{binaryMediaTypes:u}),f;e.route.handler.options.payloadFormatVersion==="2.0"?f=II(t,e):f=await SI(t,e,{useAwsResourcePathStyle:c}),wy("Calling onSendingAwsLambdaEvent hook");let y=await vI(t,e,f);y.body=p,y.isBase64Encoded=m;let v=await l.fetch(d,{body:JSON.stringify(y)});try{return Iy(v)}catch(T){if(T instanceof Be){let S=e.route.handler.options.returnAmazonTraceIdHeader&&T.traceId?{AMZN_TRACE_ID_HEADER:T.traceId}:void 0;return _I.HttpProblems.internalServerError(t,e,void 0,S)}throw T}}o(TI,"awsLambdaHandler");sr.awsLambdaHandler=TI;async function Iy(t){let e;try{e=await t.json()}catch{throw new Be("Lambda response did not contain valid JSON",t.headers)}if(t.status!==200)throw e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?new Be(e.message,t.headers):new Be(`Status: ${t.statusText}`,t.headers);if(e&&typeof e=="object"&&"errorMessage"in e&&typeof e.errorMessage=="string")throw new Be(e.errorMessage,t.headers);if(!e||typeof e!="object"||!("statusCode"in e)||typeof e.statusCode!="number")return new Response(JSON.stringify(e),{status:t.status,headers:{"content-type":"application/json"}});let r=new Headers;if("headers"in e&&e.headers){if(typeof e.headers!="object")throw new Be(`Response headers must be an object. Received ${typeof e.headers}`,t.headers);for(let[i,s]of Object.entries(e.headers))r.set(i,s)}if("cookies"in e&&e.cookies){if(!Array.isArray(e.cookies))throw new Be(`Response cookies must be an array. Received ${typeof e.cookies}`,t.headers);r.set("cookie",e.cookies.join(";"))}let n;if("isBase64Encoded"in e&&typeof e.isBase64Encoded!="boolean")throw new Be(`Response property isBase64Encoded must be a boolean. Received ${typeof e.isBase64Encoded}`,t.headers);if("isBase64Encoded"in e&&e.isBase64Encoded===!0){if(!("body"in e))throw new Be("Response was set to base64 encoded but no body was set",t.headers);if(typeof e.body!="string")throw new Be("Response was set to base64 encoded but body was not a string",t.headers);n=(0,vy.base64Decode)(e.body)}else"body"in e&&typeof e.body=="string"?n=e.statusCode===204&&e.body===""?null:e.body:"body"in e&&e.body!==null&&e.body!==void 0?n=JSON.stringify(e.body):n=null;if(n!==null&&"bodyEncoding"in e){if(typeof e.bodyEncoding!="string"||!(e.bodyEncoding==="gzip"||e.bodyEncoding==="deflate"))throw new Be(`Response property bodyEncoding can only be set to 'gzip' or 'deflate'. Received ${e.bodyEncoding}`,t.headers);let i=new Blob([n]).stream().pipeThrough(new DecompressionStream(e.bodyEncoding));n=await new Response(i).arrayBuffer()}return new Response(n,{headers:r,status:e.statusCode})}o(Iy,"getResponse");sr.getResponse=Iy;async function SI(t,e,{useAwsResourcePathStyle:r}){let n={},i={};t.headers.forEach((l,d)=>{n[d]=l,i[d]=[l]});let s=t.query,a={};for(let[l,d]of Object.entries(s))a[l]=[d];let c=new URL(t.url);return{version:"1.0",resource:c.pathname,path:c.pathname,httpMethod:t.method,headers:n,multiValueHeaders:i,queryStringParameters:s,multiValueQueryStringParameters:a,requestContext:{accountId:null,apiId:null,authorizer:{claims:{},scopes:[]},domainName:c.hostname,domainPrefix:null,extendedRequestId:e.requestId,httpMethod:t.method,identity:{accessKey:null,accountId:null,caller:null,cognitoAuthenticationProvider:null,cognitoAuthenticationType:null,cognitoIdentityId:null,cognitoIdentityPoolId:null,principalOrgId:null,sourceIp:t.headers.get("CF-Connecting-IP"),user:null,userAgent:t.headers.get("user-agent"),userArn:null,clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},path:c.pathname,protocol:"HTTP/1.1",requestId:e.requestId,requestTime:(0,Ty.toCLFDate)(),requestTimeEpoch:new Date().valueOf(),resourceId:e.route.operationId??null,resourcePath:RI(e.route.path,r),stage:null},pathParameters:t.params,stageVariables:null}}o(SI,"buildEventVersion1");function II(t,e){let r={};t.headers.forEach((s,a)=>{r[a]=s});let n=new URL(t.url);return{version:"2.0",routeKey:null,rawPath:n.pathname,rawQueryString:n.search,cookies:[],headers:r,queryStringParameters:t.query,requestContext:{accountId:null,apiId:null,authentication:{clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},authorizer:{jwt:{claims:{},scopes:[]}},domainName:n.hostname,domainPrefix:null,http:{method:t.method,path:n.pathname,protocol:"HTTP/1.1",sourceIp:t.headers.get("CF-Connecting-IP"),userAgent:t.headers.get("user-agent")},requestId:e.requestId,routeKey:null,stage:null,time:(0,Ty.toCLFDate)(),timeEpoch:new Date().valueOf()},pathParameters:t.params,stageVariables:null}}o(II,"buildEventVersion2");async function AI(t,{binaryMediaTypes:e}){let r,n=!1,i=t.headers.get("content-type");if(t.method==="GET"||t.method==="HEAD")r=null;else if(e&&i&&PI(e,i)){let s=await t.arrayBuffer();r=(0,vy.base64Encode)(new Uint8Array(s)),n=!0}else r=await t.clone().text();return[r,n]}o(AI,"getBodyResult");function PI(t,e){let r=e.split(";")[0].trim().toLowerCase();return t.findIndex(n=>n==="*/*"?!0:n.toLowerCase()===r)>-1}o(PI,"matchesContentType");function RI(t,e=!1){if(!e)return t;let r=(0,Ey.parse)(t),n=(0,Ey.compile)(t),i={};return r.forEach(s=>{typeof s=="string"?i[s]=`{${s}}`:i[s.name]=`{${s.name}}`}),n(i)}o(RI,"getResourcePath")});var _n=g(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.getHandlerUserLogFunction=gn.logBadGatewayResponses=void 0;var OI=Ge(),xI=te(),NI=[502,503,504];async function CI(t,e){if(NI.includes(t.status)){let r=OI.SystemLogMap.getLogger(e),i=await t.clone().text(),s={};for(let[a,c]of t.headers)s[a]=c;r.warn(`BadGatewayResponse ${t.status}`,{status:t.status,statusText:t.statusText,body:i,headers:s})}}o(CI,"logBadGatewayResponses");gn.logBadGatewayResponses=CI;var ld;function LI(t){if(ld===void 0){let r=xI.Environment.instance.runtime.ZUPLO_HANDLER_WRITE_LOG_LEVEL;["debug","info","warn","error"].includes(r??"")||(r="debug"),ld=r}return t.log[ld]}o(LI,"getHandlerUserLogFunction");gn.getHandlerUserLogFunction=LI});var Ry=g(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.openApiSpecHandler=void 0;var Py=D(),DI=ve(),dd=te(),UI=_n();async function MI(t,e){let r=dd.Environment.instance.build.BUILD_ID,{buildAssetsUrl:n}=dd.Environment.instance,i=e.route.handler.options,{openApiFilePath:s}=i;if(!s)throw new Py.ConfigurationError("Open API Spec Handler must have 'openApiFilePath' specified");let a=kI(s);if(!a.isValid)throw new Py.ConfigurationError(a.error);let c;dd.Environment.instance.isLocalDevelopment?c=`${n}/${s.substring(1)}`:c=`${n}/${r}${s.substring(1)}`;let u=await fetch(c,{method:t.method,body:t.body,headers:t.headers});if(u.status!==200)return DI.HttpProblems.notFound(t,e,{detail:"OpenAPI file could not be found."});let l=new Response(u.body,{headers:{"content-type":"application/json"},status:u.status,statusText:u.statusText});return(0,UI.logBadGatewayResponses)(l,e),l}o(MI,"openApiSpecHandler");qs.openApiSpecHandler=MI;var kI=o(t=>t.startsWith("./")?t.startsWith("./config")?t.endsWith(".oas.json")?{isValid:!0}:{isValid:!1,error:"'openApiFilePath' must point to a file ending in '.oas.json'"}:{isValid:!1,error:"'openApiFilePath' must point to a file in your /config directory"}:{isValid:!1,error:"'openApiFilePath' must start with './'"},"validateOpenApiPath")});var Oy=g($s=>{"use strict";Object.defineProperty($s,"__esModule",{value:!0});$s.redirectHandler=void 0;var FI=D();async function HI(t,e){let r=e.route.handler.options;if(!r.location)throw new FI.ConfigurationError("Redirect Handler must have 'location' specified");let n=r.status??302;return new Response(null,{status:n,headers:{location:r.location}})}o(HI,"redirectHandler");$s.redirectHandler=HI});var Ny=g(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.urlForwardHandler=void 0;var qI=D(),xy=_n();function $I(t,e){let r=t.endsWith("/"),n=e.startsWith("/");return r&&n?`${t.substring(0,t.length-1)}${e}`:!r&&!n?`${t}/${e}`:`${t}${e}`}o($I,"join");async function jI(t,e){let r=(0,xy.getHandlerUserLogFunction)(e),n=e.route.handler.options,i=n.forwardSearch!==!1;if(!n.baseUrl)throw new Error("URL Forward Handler must have 'baseUrl' specified");if(!n||typeof n.__rewriteFunction!="function")throw new qI.ConfigurationError("Invalid options for this route");let s={incomingRequestProperties:e.incomingRequestProperties,requestId:e.requestId,route:e.route,custom:e.custom},a=new URL(t.url),c=n.__rewriteFunction(t,s),u=$I(c,a.pathname),l=i?`${u}${a.search}`:u.toString(),d=Date.now();r(`URL Forwarding to '${l}'`);let p=await fetch(l,{method:t.method,body:t.body,headers:t.headers}),m=Date.now()-d;return r(`URL Forward received response ${p.status} - ${p.statusText} in ${m}ms`),(0,xy.logBadGatewayResponses)(p,e),p}o(jI,"urlForwardHandler");js.urlForwardHandler=jI});var Ly=g(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.urlRewriteHandler=void 0;var VI=D(),Cy=_n(),GI=o((t,e)=>{let r=new URL(t),n=new URL(e);for(let[i,s]of n.searchParams.entries())r.searchParams.append(i,s);return r.toString()},"addQuery");async function BI(t,e){let r=(0,Cy.getHandlerUserLogFunction)(e),n=e.route.handler.options,i=n.forwardSearch!==!1,s=n.followRedirects??!1;if(!n||typeof n.__rewriteFunction!="function")throw new VI.ConfigurationError("Invalid options for this route");let a={incomingRequestProperties:e.incomingRequestProperties,requestId:e.requestId,route:e.route,custom:e.custom},c=n.__rewriteFunction(t,a),u=i?GI(c,t.url):c,l=Date.now();r(`URL Rewriting to '${u}'`);let d=await fetch(u.toString(),{method:t.method,body:t.body,headers:t.headers,redirect:s?"follow":"manual"}),p=Date.now()-l;return r(`URL Rewrite received response ${d.status} - ${d.statusText} in ${p}ms`),(0,Cy.logBadGatewayResponses)(d,e),d}o(BI,"urlRewriteHandler");Vs.urlRewriteHandler=BI});var Uy=g(Gs=>{"use strict";Object.defineProperty(Gs,"__esModule",{value:!0});Gs.webSocketHandler=void 0;var Dy=D(),KI=Ms(),JI=Nt(),zI=te(),WI=_n();async function QI(t,e){let r=zI.Environment.instance,n=e.route.handler.options,i=(0,WI.getHandlerUserLogFunction)(e);if(!n||!n.rewritePattern)throw new Dy.ConfigurationError("WebSocket Handler must have option 'rewritePattern' specified");let s=t.headers.get("Upgrade");if(!s||s!=="websocket")return JI.HttpProblems.badRequest(t,e,{detail:"Request must include header 'Upgrade: websocket'"});if(!n||typeof n.__rewriteFunction!="function")throw new Dy.ConfigurationError("Invalid options for this route");let a={incomingRequestProperties:e.incomingRequestProperties,requestId:e.requestId,route:e.route,custom:e.custom},c=n.__rewriteFunction(t,a),u=Date.now();if(i(`Attempting WebSocket connection to '${c}'`),r.isDeno){let p=new Headers(t.headers);if(c.startsWith("service:")){let f=await(0,KI.externalServiceTunnelConfig)(c),y=new URL(c);c=new URL(`${f.serviceBaseUrl}${y.pathname}${y.search}`).toString();for(let T in f.tunnelHeaders)p.set(T,f.tunnelHeaders[T])}c=c.replace(/^(http)/,"ws");try{if(p.get("Authorization")){let f=p.get("Authorization")?.replace("Bearer ","");c+=`?apiKey=${f}`}}catch{}let m=JSON.stringify({url:c});return new Response(m,{headers:p})}c=c.replace(/^(ws)/,"http");let l=await fetch(c,{method:t.method,headers:t.headers,body:t.body});if(l.status!==101||!l.webSocket){let p=await l.text(),m=`WebSocket connection error - ${l.status}: ${l.statusText}, content: '${p}'`;throw new Error(m)}let d=Date.now()-u;return i(`WebSocket connected, received response ${l.status} - ${l.statusText} in ${d}ms`),new Response(null,{status:101,webSocket:l.webSocket})}o(QI,"webSocketHandler");Gs.webSocketHandler=QI});var My=g(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.webSocketPolicyProcessor=bn.getWebSocketPolicyFunctions=void 0;var YI=D(),ZI=o((t,e)=>t.map((n,i)=>{let s;if(typeof n.module=="object"&&(s=n.module[n.export]),!s||typeof s!="function"){let a=e==="inbound"?"WebSocketInboundPolicy":"WebSocketOutboundPolicy",c=`policy in position: ${i+1}, export name: ${n.export}`;throw new YI.ConfigurationError(`${a} - Websocket policy must be a valid function (${c})`)}return s}),"getWebSocketPolicyFunctions");bn.getWebSocketPolicyFunctions=ZI;var XI=o(async(t,e,r,n,i,s)=>{let a=t.data;if(s&&s.length>0){let c=[...s];for(;c.length>0;){let u=c.shift();if(!u)return a;if(a=await u(a,r,e,n,i),a===void 0)return}}return a},"webSocketPolicyProcessor");bn.webSocketPolicyProcessor=XI});var Hy=g(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.webSocketPipelineHandler=void 0;var ky=D(),eA=Ms(),tA=Nt(),rA=te(),nA=_n(),pd=My();function Fy(t,e,r,n,i){t.addEventListener("close",()=>{e.close()}),t.addEventListener("error",s=>{n.log.error("WebSocket error: ",s),e.send(JSON.stringify(s))}),t.addEventListener("message",s=>{try{o(async c=>{let u=await(0,pd.webSocketPolicyProcessor)(c,t,e,r,n,i);u!==void 0&&e.send(u)},"innerPipeline")(s).catch(n.log.error)}catch(a){n.log.error(a)}})}o(Fy,"wireUpListeners");async function iA(t,e){let r=rA.Environment.instance,n=e.route.handler.options,i=(0,nA.getHandlerUserLogFunction)(e);if(!n||!n.rewritePattern)throw new ky.ConfigurationError("WebSocket Pipeline Handler must have option 'rewritePattern' specified");let s=t.headers.get("Upgrade");if(!s||s!=="websocket")return tA.HttpProblems.badRequest(t,e,{detail:"Request must include header 'Upgrade: websocket'"});if(!n||typeof n.__rewriteFunction!="function")throw new ky.ConfigurationError("Invalid options for this route");let a={incomingRequestProperties:e.incomingRequestProperties,requestId:e.requestId,route:e.route,custom:e.custom},c=n.__rewriteFunction(t,a),u=Date.now();if(i(`Attempting WebSocket connection to '${c}'`),r.isDeno){let S=new Headers(t.headers);if(c.startsWith("service:")){let H=await(0,eA.externalServiceTunnelConfig)(c),R=new URL(c);c=new URL(`${H.serviceBaseUrl}${R.pathname}${R.search}`).toString();for(let Y in H.tunnelHeaders)S.set(Y,H.tunnelHeaders[Y])}c=c.replace(/^(http)/,"ws");try{if(S.get("Authorization")){let H=S.get("Authorization")?.replace("Bearer ","");c+=`?apiKey=${H}`}}catch{}let k=JSON.stringify({url:c});return new Response(k,{headers:S})}c=c.replace(/^(ws)/,"http");let l=await fetch(c,{method:t.method,headers:t.headers,body:t.body});if(l.status!==101||!l.webSocket){let S=await l.text(),k=`WebSocket connection error - ${l.status}: ${l.statusText}, content: '${S}'`;throw new Error(k)}let d=new WebSocketPair,[p,m]=Object.values(d),f=Date.now()-u;i(`WebSocket connected, received response ${l.status} - ${l.statusText} in ${f}ms`);let y=l.webSocket;y.accept(),m.accept();let v=n.policies&&n.policies.inbound?(0,pd.getWebSocketPolicyFunctions)(n.policies.inbound,"inbound"):[],T=n.policies&&n.policies.outbound?(0,pd.getWebSocketPolicyFunctions)(n.policies.outbound,"outbound"):[];return Fy(m,y,t,e,v),Fy(y,m,t,e,T),new Response(null,{status:101,webSocket:p})}o(iA,"webSocketPipelineHandler");Bs.webSocketPipelineHandler=iA});var qy=g(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.DynaTraceLoggingPlugin=void 0;var oA=we(),hd=te(),sA=Pr(),aA=Ct(),cA=gt(),fd=class extends aA.LogPlugin{static{o(this,"DynaTraceLoggingPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new md(this.options)}};Ks.DynaTraceLoggingPlugin=fd;var md=class{static{o(this,"DynaTraceTransport")}constructor(e){this.#e=e.url,this.#t=e.apiToken,this.#n=hd.Environment.instance.loggingEnvironmentType,this.#i=hd.Environment.instance.loggingEnvironmentStage,this.#r=hd.Environment.instance.deploymentName}#e;#t;#r;#n;#i;async log(e,r){e.messages.forEach(n=>{let i={timestamp:new Date().toISOString(),message:(0,cA.stringifyNonString)((0,sA.serializeError)(n)),severity:e.level,"log.source":e.logSource,requestId:e.requestId,"custom.environment":this.#r,"custom.environmentStage":this.#i,"custom.environmentType":this.#n,"custom.loggingId":e.loggingId,"custom.rayId":e.rayId===null?void 0:e.rayId};this.batcher.enqueue(i)}),r.waitUntil(this.batcher.waitUntilFlushed())}#o=async e=>{e.length!==0&&await fetch(this.#e,{method:"POST",body:JSON.stringify(e),headers:{"content-type":"application/json; charset=utf-8",authorization:`Api-Token ${this.#t}`}})};batcher=new oA.BatchDispatch("dyna-trace-log-transport",10,this.#o)}});var $y=g(Js=>{"use strict";Object.defineProperty(Js,"__esModule",{value:!0});Js.LokiLoggingPlugin=void 0;var uA=we(),yd=te(),lA=Pr(),dA=Ct(),pA=gt(),gd=class extends dA.LogPlugin{static{o(this,"LokiLoggingPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new bd(this.options)}};Js.LokiLoggingPlugin=gd;var _d=class{static{o(this,"LokiStream")}constructor(e,r,n,i,s){this.level=e,this.environment=r,this.environmentType=n,this.environmentStage=i,this.requestId=s}job="zuplo";level;environment;environmentType;environmentStage;requestId;equals=e=>this.level===e.level&&this.requestId===e.requestId};function hA(t,e){return btoa(`${t}:${e}`)}o(hA,"createBasicDigest");var bd=class{static{o(this,"LokiTransport")}constructor(e){this.#e=e.url,this.#t=hA(e.username,e.password),this.#n=yd.Environment.instance.loggingEnvironmentType,this.#i=yd.Environment.instance.loggingEnvironmentStage,this.#r=yd.Environment.instance.deploymentName}#e;#t;#r;#n;#i;async log(e,r){let n=new _d(e.level,this.#r,this.#n,this.#i,e.requestId);e.messages.forEach(i=>{let s={stream:n,message:(0,pA.stringifyNonString)((0,lA.serializeError)(i)),nanoSecondEpoch:`${e.timestamp.getTime()}000000`};this.batcher.enqueue(s)}),r.waitUntil(this.batcher.waitUntilFlushed())}#o=e=>{let r={streams:[]};return e.forEach(n=>{let i=r.streams.find(s=>s.stream.equals(n.stream));i||(i={stream:n.stream,values:[]},r.streams.push(i)),i.values.push([n.nanoSecondEpoch,n.message])}),r};#s=async e=>{if(e.length===0)return;let r=this.#o(e);await fetch(this.#e,{method:"POST",body:JSON.stringify(r),headers:{"content-type":"application/json",authorization:`Basic ${this.#t}`}})};batcher=new uA.BatchDispatch("loki-log-transport",10,this.#s)}});var jy=g(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.SumoLogicLoggingPlugin=void 0;var fA=we(),Ed=te(),mA=Pr(),yA=Ct(),gA=gt(),wd=class extends yA.LogPlugin{static{o(this,"SumoLogicLoggingPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new vd(this.options)}};zs.SumoLogicLoggingPlugin=wd;var vd=class{static{o(this,"SumoLogicTransport")}constructor(e){this.#e=e.url,this.#i=e.category,this.#o=e.name,this.#r=Ed.Environment.instance.loggingEnvironmentType,this.#n=Ed.Environment.instance.loggingEnvironmentStage,this.#t=Ed.Environment.instance.deploymentName}#e;#t;#r;#n;#i;#o;async log(e,r){e.messages.forEach(n=>{let i={timestamp:new Date().toISOString(),message:(0,gA.stringifyNonString)((0,mA.serializeError)(n)),severity:e.level,source:e.logSource,requestId:e.requestId,environment:this.#t,environmentType:this.#r,environmentStage:this.#n,rayId:e.rayId===null?void 0:e.rayId};this.batcher.enqueue(i)}),r.waitUntil(this.batcher.waitUntilFlushed())}#s=async e=>{if(e.length===0)return;let r=e.map(i=>JSON.stringify(i)).join(`
64
- `),n=new Headers({"content-type":"application/json; charset=utf-8"});this.#o&&n.set("X-Sumo-Name",this.#o),this.#i&&n.set("X-Sumo-Category",this.#i),await fetch(this.#e,{method:"POST",body:r,headers:n})};batcher=new fA.BatchDispatch("sumo-logic-log-transport",10,this.#s)}});var Gy=g(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.VMWareLogInsightTransport=En.VMWareLogInsightLoggingPlugin=void 0;var _A=D(),bA=we(),Td=te(),EA=Ct(),Vy=gt(),wA="d3a5b78f-8236-48f5-b1df-4fe269d41172",Sd=class extends EA.LogPlugin{static{o(this,"VMWareLogInsightLoggingPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new Ws(this.options)}};En.VMWareLogInsightLoggingPlugin=Sd;var Ws=class{static{o(this,"VMWareLogInsightTransport")}constructor(e){let r;try{r=new URL(e.url)}catch{throw new _A.ConfigurationError(`Invalid option 'url' on 'VMWareLogInsightTransport' plugin. Must be a valid URL, received '${e.url}'`)}this.#e=r.origin,this.#r=Td.Environment.instance.loggingEnvironmentType,this.#n=Td.Environment.instance.loggingEnvironmentStage,this.#t=Td.Environment.instance.deploymentName,this.#i=e.onMessageSending,e.fields&&(this.#o=Object.entries(e.fields).map(([n,i])=>({name:n,content:i})))}#e;#t;#r;#n;#i;#o;async log(e,r){let n=this.buildEntry(e,r);this.batcher.enqueue(n),r.waitUntil(this.batcher.waitUntilFlushed())}buildEntry(e,r){let n=(0,Vy.messagesToMultilineText)(e.messages);this.#i&&(n=this.#i(n));let i={timestamp:Date.now(),text:n,fields:[{name:"severity",content:e.level.toUpperCase()},{name:"request_id",content:e.requestId},{name:"environment_type",content:this.#r},{name:"environment_stage",content:this.#n},{name:"log_source",content:e.logSource},{name:"atomic_counter",content:e.vectorClock}]};return e.rayId&&i.fields.push({name:"request_ray_id",content:e.rayId}),this.#t&&i.fields.push({name:"environment",content:this.#t}),this.#o&&i.fields.push(...this.#o),r.custom&&Object.entries(r.custom).forEach(([s,a])=>{let c=(0,Vy.stringifyNonStringToText)(a);c&&i.fields.push({name:s,content:c})}),i}#s=async e=>{if(e.length===0)return;let r=await fetch(`${this.#e}/api/v1/events/ingest/${wA}`,{method:"POST",body:JSON.stringify(e),headers:{"content-type":"application/json; charset=utf-8"}});if(r.status!==200)try{let n=await r.text();console.error("Error logging to Log Insight",n)}catch(n){console.error(n)}};batcher=new bA.BatchDispatch("vmware-log-insights-log-transport",10,this.#s)};En.VMWareLogInsightTransport=Ws});var Ky=g(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.AWSLogTransport=wn.AWSLoggingPlugin=void 0;var vA=we(),By=te(),TA=Pr(),SA=Ct(),IA=gt(),AA=ud(),Id=class extends SA.LogPlugin{static{o(this,"AWSLoggingPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new Qs(this.options)}};wn.AWSLoggingPlugin=Id;var Qs=class{static{o(this,"AWSLogTransport")}awsClient;environment;environmentType;logGroupName;logStreamName;region;batcher=new vA.BatchDispatch("aws-log-transport",10,async e=>{if(e.length===0)return;let r=JSON.stringify({logGroupName:this.logGroupName,logStreamName:this.logStreamName,logEvents:e});await this.awsClient.fetch(`https://logs.${this.region}.amazonaws.com`,{headers:{"Content-Type":"application/x-amz-json-1.1","x-amz-Target":"Logs_20140328.PutLogEvents"},body:r,aws:{accessKeyId:this.awsClient.accessKeyId,secretAccessKey:this.awsClient.secretAccessKey,service:this.awsClient.service,region:this.awsClient.region}})});constructor({accessKeyId:e,logStreamName:r,logGroupName:n,secretAccessKey:i,region:s}){this.awsClient=new AA.AwsClient({accessKeyId:e,secretAccessKey:i,service:"logs",region:s}),this.logGroupName=n,this.logStreamName=r,this.region=s,this.environmentType=By.Environment.instance.loggingEnvironmentType,this.environment=By.Environment.instance.deploymentName}async log(e,r){e.messages.forEach(n=>{let i={timestamp:new Date().getTime(),message:JSON.stringify({data:(0,IA.stringifyNonString)((0,TA.serializeError)(n)),severity:e.level,source:e.logSource,environment:this.environment,requestId:e.requestId,environmentType:this.environmentType,rayId:e.rayId===null?void 0:e.rayId})};this.batcher.enqueue(i)}),r.waitUntil(this.batcher.waitUntilFlushed())}};wn.AWSLogTransport=Qs});var Jy=g(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.AWSLoggingPlugin=Oe.VMWareLogInsightLoggingPlugin=Oe.SumoLogicLoggingPlugin=Oe.LokiLoggingPlugin=Oe.GoogleCloudLoggingPlugin=Oe.DynaTraceLoggingPlugin=Oe.DataDogLoggingPlugin=void 0;var PA=Ml();Object.defineProperty(Oe,"DataDogLoggingPlugin",{enumerable:!0,get:function(){return PA.DataDogLoggingPlugin}});var RA=qy();Object.defineProperty(Oe,"DynaTraceLoggingPlugin",{enumerable:!0,get:function(){return RA.DynaTraceLoggingPlugin}});var OA=gs();Object.defineProperty(Oe,"GoogleCloudLoggingPlugin",{enumerable:!0,get:function(){return OA.GoogleCloudLoggingPlugin}});var xA=$y();Object.defineProperty(Oe,"LokiLoggingPlugin",{enumerable:!0,get:function(){return xA.LokiLoggingPlugin}});var NA=jy();Object.defineProperty(Oe,"SumoLogicLoggingPlugin",{enumerable:!0,get:function(){return NA.SumoLogicLoggingPlugin}});var CA=Gy();Object.defineProperty(Oe,"VMWareLogInsightLoggingPlugin",{enumerable:!0,get:function(){return CA.VMWareLogInsightLoggingPlugin}});var LA=Ky();Object.defineProperty(Oe,"AWSLoggingPlugin",{enumerable:!0,get:function(){return LA.AWSLoggingPlugin}})});var zy=g(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.DataDogMetricsError=ar.DataDogMetricsTransport=ar.DataDogMetricsPlugin=void 0;var DA=Ge(),UA=we(),MA=po(),Ad=new WeakMap,kA={tags:[]},Pd=class extends MA.MetricsPlugin{static{o(this,"DataDogMetricsPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new Ys(this.options)}static setContext(e,r){let n=Ad.get(e);n||(n=kA);let i=Object.assign({...n},r);Ad.set(e,i)}};ar.DataDogMetricsPlugin=Pd;var Ys=class{static{o(this,"DataDogMetricsTransport")}#e;#t;#r;#n;#i;#o=void 0;constructor(e){this.#e=e.apiKey,this.#t=e.url??"https://api.datadoghq.com/api/v2/series",this.#r=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},e.metrics),this.#i=e.include??{},this.#n=e.tags??[]}pushMetrics(e,r){this.#o===void 0&&(this.#o=new UA.BatchDispatch("data-dog-metrics-transport",10,this.dispatchFunction,DA.SystemLogMap.getLogger(r)));let n=Math.floor(e.timestamp.getTime()/1e3),i=this.#n.concat(Ad.get(r)?.tags??[]);if(this.#i.country&&i.push(`country:${e.country}`),this.#i.httpMethod&&i.push(`httpMethod:${e.method}`),this.#i.statusCode&&i.push(`statusCode:${e.statusCode}`),this.#i.path){let s=e.systemRouteName||e.routePath;i.push(`path:${s}`)}this.#r.latency&&this.#o.enqueue({metric:"zuplo.request.latency",type:3,points:[{timestamp:n,value:e.durationMs}],tags:i}),this.#r.requestContentLength&&e.requestContentLength&&this.#o.enqueue({metric:"zuplo.request.content_length",type:3,points:[{timestamp:n,value:e.requestContentLength}],tags:i}),this.#r.responseContentLength&&e.responseContentLength&&this.#o.enqueue({metric:"zuplo.response.content_length",type:3,points:[{timestamp:n,value:e.responseContentLength}],tags:i}),r.waitUntil(this.#o.waitUntilFlushed())}dispatchFunction=async e=>{if(e.length===0)return;let r=JSON.stringify({series:e}),n=await fetch(this.#t,{method:"POST",body:r,headers:{"content-type":"application/json","DD-API-KEY":this.#e}});if(!n.ok)throw new Zs(await n.text())}};ar.DataDogMetricsTransport=Ys;var Zs=class t extends Error{static{o(this,"DataDogMetricsError")}constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};ar.DataDogMetricsError=Zs});var Wy=g(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.DynaTraceMetricsError=cr.DynaTraceMetricsTransport=cr.DynatraceMetricsPlugin=void 0;var FA=Ge(),HA=we(),qA=po(),Rd=new WeakMap,$A={dimensions:[]},Od=class extends qA.MetricsPlugin{static{o(this,"DynatraceMetricsPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new Xs(this.options)}static setContext(e,r){let n=Rd.get(e);n||(n=$A);let i=Object.assign({...n},r);Rd.set(e,i)}};cr.DynatraceMetricsPlugin=Od;var Xs=class{static{o(this,"DynaTraceMetricsTransport")}apiToken;#e;#t;dimensions;#r;#n=void 0;constructor(e){this.apiToken=e.apiToken,this.#e=e.url,this.#t=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},e.metrics),this.#r=e.include??{},this.dimensions=e.dimensions??[]}pushMetrics(e,r){this.#n===void 0&&(this.#n=new HA.BatchDispatch("dynatrace-metrics-transport",10,this.dispatchFunction,FA.SystemLogMap.getLogger(r)));let n=Math.floor(e.timestamp.getTime()),i=this.dimensions.concat(Rd.get(r)?.dimensions??[]);if(this.#r.country&&i.push(`country="${e.country}"`),this.#r.httpMethod&&i.push(`http_method="${e.method}"`),this.#r.statusCode&&i.push(`status_code="${e.statusCode}"`),this.#r.path){let a=e.systemRouteName||e.routePath;i.push(`path="${a}"`)}let s=i.join(",");this.#t.latency&&this.#n.enqueue(`zuplo.request.latency,${s} ${e.durationMs} ${n}`),this.#t.requestContentLength&&e.requestContentLength&&this.#n.enqueue(`zuplo.request.content_length,${s} ${e.requestContentLength} ${n}`),this.#t.responseContentLength&&e.responseContentLength&&this.#n.enqueue(`zuplo.response.content_length,${s} ${e.responseContentLength} ${n}`),r.waitUntil(this.#n.waitUntilFlushed())}dispatchFunction=async e=>{if(e.length===0)return;let r=e.join(`
64
+ `),n=new Headers({"content-type":"application/json; charset=utf-8"});this.#o&&n.set("X-Sumo-Name",this.#o),this.#i&&n.set("X-Sumo-Category",this.#i),await fetch(this.#e,{method:"POST",body:r,headers:n})};batcher=new fA.BatchDispatch("sumo-logic-log-transport",10,this.#s)}});var Gy=g(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.VMWareLogInsightTransport=En.VMWareLogInsightLoggingPlugin=void 0;var _A=D(),bA=we(),Td=te(),EA=Ct(),Vy=gt(),wA="d3a5b78f-8236-48f5-b1df-4fe269d41172",Sd=class extends EA.LogPlugin{static{o(this,"VMWareLogInsightLoggingPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new Ws(this.options)}};En.VMWareLogInsightLoggingPlugin=Sd;var Ws=class{static{o(this,"VMWareLogInsightTransport")}constructor(e){let r;try{r=new URL(e.url)}catch{throw new _A.ConfigurationError(`Invalid option 'url' on 'VMWareLogInsightTransport' plugin. Must be a valid URL, received '${e.url}'`)}this.#e=r.origin,this.#r=Td.Environment.instance.loggingEnvironmentType,this.#n=Td.Environment.instance.loggingEnvironmentStage,this.#t=Td.Environment.instance.deploymentName,this.#i=e.onMessageSending,e.fields&&(this.#o=Object.entries(e.fields).map(([n,i])=>({name:n,content:i})))}#e;#t;#r;#n;#i;#o;async log(e,r){let n=this.buildEntry(e,r);this.batcher.enqueue(n),r.waitUntil(this.batcher.waitUntilFlushed())}buildEntry(e,r){let n=(0,Vy.messagesToMultilineText)(e.messages),i={timestamp:Date.now(),text:n,fields:[{name:"severity",content:e.level.toUpperCase()},{name:"request_id",content:e.requestId},{name:"environment_type",content:this.#r},{name:"environment_stage",content:this.#n},{name:"log_source",content:e.logSource},{name:"atomic_counter",content:e.vectorClock}]};return e.rayId&&i.fields.push({name:"request_ray_id",content:e.rayId}),this.#t&&i.fields.push({name:"environment",content:this.#t}),this.#o&&i.fields.push(...this.#o),r.custom&&Object.entries(r.custom).forEach(([s,a])=>{let c=(0,Vy.stringifyNonStringToText)(a);c&&i.fields.push({name:s,content:c})}),this.#i&&(i=this.#i(i)),i}#s=async e=>{if(e.length===0)return;let r=await fetch(`${this.#e}/api/v1/events/ingest/${wA}`,{method:"POST",body:JSON.stringify(e),headers:{"content-type":"application/json; charset=utf-8"}});if(r.status!==200)try{let n=await r.text();console.error("Error logging to Log Insight",n)}catch(n){console.error(n)}};batcher=new bA.BatchDispatch("vmware-log-insights-log-transport",10,this.#s)};En.VMWareLogInsightTransport=Ws});var Ky=g(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.AWSLogTransport=wn.AWSLoggingPlugin=void 0;var vA=we(),By=te(),TA=Pr(),SA=Ct(),IA=gt(),AA=ud(),Id=class extends SA.LogPlugin{static{o(this,"AWSLoggingPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new Qs(this.options)}};wn.AWSLoggingPlugin=Id;var Qs=class{static{o(this,"AWSLogTransport")}awsClient;environment;environmentType;logGroupName;logStreamName;region;batcher=new vA.BatchDispatch("aws-log-transport",10,async e=>{if(e.length===0)return;let r=JSON.stringify({logGroupName:this.logGroupName,logStreamName:this.logStreamName,logEvents:e});await this.awsClient.fetch(`https://logs.${this.region}.amazonaws.com`,{headers:{"Content-Type":"application/x-amz-json-1.1","x-amz-Target":"Logs_20140328.PutLogEvents"},body:r,aws:{accessKeyId:this.awsClient.accessKeyId,secretAccessKey:this.awsClient.secretAccessKey,service:this.awsClient.service,region:this.awsClient.region}})});constructor({accessKeyId:e,logStreamName:r,logGroupName:n,secretAccessKey:i,region:s}){this.awsClient=new AA.AwsClient({accessKeyId:e,secretAccessKey:i,service:"logs",region:s}),this.logGroupName=n,this.logStreamName=r,this.region=s,this.environmentType=By.Environment.instance.loggingEnvironmentType,this.environment=By.Environment.instance.deploymentName}async log(e,r){e.messages.forEach(n=>{let i={timestamp:new Date().getTime(),message:JSON.stringify({data:(0,IA.stringifyNonString)((0,TA.serializeError)(n)),severity:e.level,source:e.logSource,environment:this.environment,requestId:e.requestId,environmentType:this.environmentType,rayId:e.rayId===null?void 0:e.rayId})};this.batcher.enqueue(i)}),r.waitUntil(this.batcher.waitUntilFlushed())}};wn.AWSLogTransport=Qs});var Jy=g(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.AWSLoggingPlugin=Oe.VMWareLogInsightLoggingPlugin=Oe.SumoLogicLoggingPlugin=Oe.LokiLoggingPlugin=Oe.GoogleCloudLoggingPlugin=Oe.DynaTraceLoggingPlugin=Oe.DataDogLoggingPlugin=void 0;var PA=Ml();Object.defineProperty(Oe,"DataDogLoggingPlugin",{enumerable:!0,get:function(){return PA.DataDogLoggingPlugin}});var RA=qy();Object.defineProperty(Oe,"DynaTraceLoggingPlugin",{enumerable:!0,get:function(){return RA.DynaTraceLoggingPlugin}});var OA=gs();Object.defineProperty(Oe,"GoogleCloudLoggingPlugin",{enumerable:!0,get:function(){return OA.GoogleCloudLoggingPlugin}});var xA=$y();Object.defineProperty(Oe,"LokiLoggingPlugin",{enumerable:!0,get:function(){return xA.LokiLoggingPlugin}});var NA=jy();Object.defineProperty(Oe,"SumoLogicLoggingPlugin",{enumerable:!0,get:function(){return NA.SumoLogicLoggingPlugin}});var CA=Gy();Object.defineProperty(Oe,"VMWareLogInsightLoggingPlugin",{enumerable:!0,get:function(){return CA.VMWareLogInsightLoggingPlugin}});var LA=Ky();Object.defineProperty(Oe,"AWSLoggingPlugin",{enumerable:!0,get:function(){return LA.AWSLoggingPlugin}})});var zy=g(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.DataDogMetricsError=ar.DataDogMetricsTransport=ar.DataDogMetricsPlugin=void 0;var DA=Ge(),UA=we(),MA=po(),Ad=new WeakMap,kA={tags:[]},Pd=class extends MA.MetricsPlugin{static{o(this,"DataDogMetricsPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new Ys(this.options)}static setContext(e,r){let n=Ad.get(e);n||(n=kA);let i=Object.assign({...n},r);Ad.set(e,i)}};ar.DataDogMetricsPlugin=Pd;var Ys=class{static{o(this,"DataDogMetricsTransport")}#e;#t;#r;#n;#i;#o=void 0;constructor(e){this.#e=e.apiKey,this.#t=e.url??"https://api.datadoghq.com/api/v2/series",this.#r=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},e.metrics),this.#i=e.include??{},this.#n=e.tags??[]}pushMetrics(e,r){this.#o===void 0&&(this.#o=new UA.BatchDispatch("data-dog-metrics-transport",10,this.dispatchFunction,DA.SystemLogMap.getLogger(r)));let n=Math.floor(e.timestamp.getTime()/1e3),i=this.#n.concat(Ad.get(r)?.tags??[]);if(this.#i.country&&i.push(`country:${e.country}`),this.#i.httpMethod&&i.push(`httpMethod:${e.method}`),this.#i.statusCode&&i.push(`statusCode:${e.statusCode}`),this.#i.path){let s=e.systemRouteName||e.routePath;i.push(`path:${s}`)}this.#r.latency&&this.#o.enqueue({metric:"zuplo.request.latency",type:3,points:[{timestamp:n,value:e.durationMs}],tags:i}),this.#r.requestContentLength&&e.requestContentLength&&this.#o.enqueue({metric:"zuplo.request.content_length",type:3,points:[{timestamp:n,value:e.requestContentLength}],tags:i}),this.#r.responseContentLength&&e.responseContentLength&&this.#o.enqueue({metric:"zuplo.response.content_length",type:3,points:[{timestamp:n,value:e.responseContentLength}],tags:i}),r.waitUntil(this.#o.waitUntilFlushed())}dispatchFunction=async e=>{if(e.length===0)return;let r=JSON.stringify({series:e}),n=await fetch(this.#t,{method:"POST",body:r,headers:{"content-type":"application/json","DD-API-KEY":this.#e}});if(!n.ok)throw new Zs(await n.text())}};ar.DataDogMetricsTransport=Ys;var Zs=class t extends Error{static{o(this,"DataDogMetricsError")}constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};ar.DataDogMetricsError=Zs});var Wy=g(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.DynaTraceMetricsError=cr.DynaTraceMetricsTransport=cr.DynatraceMetricsPlugin=void 0;var FA=Ge(),HA=we(),qA=po(),Rd=new WeakMap,$A={dimensions:[]},Od=class extends qA.MetricsPlugin{static{o(this,"DynatraceMetricsPlugin")}options;constructor(e){super(),this.options=e}getTransport(){return new Xs(this.options)}static setContext(e,r){let n=Rd.get(e);n||(n=$A);let i=Object.assign({...n},r);Rd.set(e,i)}};cr.DynatraceMetricsPlugin=Od;var Xs=class{static{o(this,"DynaTraceMetricsTransport")}apiToken;#e;#t;dimensions;#r;#n=void 0;constructor(e){this.apiToken=e.apiToken,this.#e=e.url,this.#t=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},e.metrics),this.#r=e.include??{},this.dimensions=e.dimensions??[]}pushMetrics(e,r){this.#n===void 0&&(this.#n=new HA.BatchDispatch("dynatrace-metrics-transport",10,this.dispatchFunction,FA.SystemLogMap.getLogger(r)));let n=Math.floor(e.timestamp.getTime()),i=this.dimensions.concat(Rd.get(r)?.dimensions??[]);if(this.#r.country&&i.push(`country="${e.country}"`),this.#r.httpMethod&&i.push(`http_method="${e.method}"`),this.#r.statusCode&&i.push(`status_code="${e.statusCode}"`),this.#r.path){let a=e.systemRouteName||e.routePath;i.push(`path="${a}"`)}let s=i.join(",");this.#t.latency&&this.#n.enqueue(`zuplo.request.latency,${s} ${e.durationMs} ${n}`),this.#t.requestContentLength&&e.requestContentLength&&this.#n.enqueue(`zuplo.request.content_length,${s} ${e.requestContentLength} ${n}`),this.#t.responseContentLength&&e.responseContentLength&&this.#n.enqueue(`zuplo.response.content_length,${s} ${e.responseContentLength} ${n}`),r.waitUntil(this.#n.waitUntilFlushed())}dispatchFunction=async e=>{if(e.length===0)return;let r=e.join(`
65
65
  `),n=await fetch(this.#e,{method:"POST",body:r,headers:{"content-type":"text/plain",Authorization:`Api-Token ${this.apiToken}`}});if(!n.ok)throw new ea(await n.text())}};cr.DynaTraceMetricsTransport=Xs;var ea=class t extends Error{static{o(this,"DynaTraceMetricsError")}constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};cr.DynaTraceMetricsError=ea});var Qy=g(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.DynatraceMetricsPlugin=vn.DataDogMetricsPlugin=void 0;var jA=zy();Object.defineProperty(vn,"DataDogMetricsPlugin",{enumerable:!0,get:function(){return jA.DataDogMetricsPlugin}});var VA=Wy();Object.defineProperty(vn,"DynatraceMetricsPlugin",{enumerable:!0,get:function(){return VA.DynatraceMetricsPlugin}})});var Yy=g(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.AuditLogDataStaxProvider=void 0;var xd=class{static{o(this,"AuditLogDataStaxProvider")}constructor(e){this.#e=e}#e;writeLogBatch=async e=>{await Promise.allSettled(e.map(async r=>{await fetch(this.#e.url,{method:"POST",headers:{"X-Cassandra-Token":this.#e.xCassandraToken,"content-type":"application/json"},body:JSON.stringify(r)})}))}};ta.AuditLogDataStaxProvider=xd});var Xy=g(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.AuditLogPlugin=void 0;var GA=xt(),BA=we(),Nd=class extends GA.InitializableRuntimePlugin{static{o(this,"AuditLogPlugin")}constructor(e,r){super(),this.#e=e,this.#t=r}#e;#t;async initialize(e){new Cd(e,this.#e,this.#t)}};ra.AuditLogPlugin=Nd;var Zy=o(t=>{let e={};return t.forEach((r,n)=>{e[n]=r}),e},"serializableHeaders"),KA={requestFilter:async()=>!0,include:{request:{headers:!0,body:!0},response:{headers:!0,body:!0}}},Cd=class{static{o(this,"AuditPluginImpl")}constructor(e,r,n){this.#t=r;let i={...KA};n?.requestFilter&&(i.requestFilter=n.requestFilter),n?.include?.request&&Object.assign(i,n.include.request),n?.include?.response&&Object.assign(i,n.include.response),this.#e=i,e.addRequestHook(this.#o),this.#r=new BA.BatchDispatch("audit-log",10,this.#n)}#e;#t;#r;#n=async e=>{await this.#t.writeLogBatch(e)};#i=async(e,r,n,i,s,a)=>{try{let c={timestamp:i,durationMs:s,routePath:n.route.path,requestId:n.requestId,userSub:a,request:{url:r.url,method:r.method,headers:this.#e.include?.request?.headers?Zy(r.headers):void 0,body:this.#e.include?.request?.body?await r.text():void 0},response:{status:e.status,statusText:e.statusText,headers:this.#e.include?.response?.headers?Zy(e.headers):void 0,body:this.#e.include?.response?.body?await e.text():void 0}};this.#r.enqueue(c),n.waitUntil(this.#r.waitUntilFlushed())}catch(c){n.log.error(c)}};#o=async(e,r)=>{try{if(!await this.#e.requestFilter(e,r))return e;let i=new Date,s=Date.now(),a=e.clone();return r.addResponseSendingFinalHook(async(c,u)=>{let l=Date.now(),d=c.clone(),p=this.#i(d,a,r,i,l-s,u.user?.sub).catch(m=>{r.log.error(m)});r.waitUntil(p)}),e}catch(n){return r.log.error(n),e}}}});var na=g(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.getValueFromRequestUser=Tn.statusCodesStringToNumberArray=void 0;var eg=D(),tg=new Map;function JA(t){if(typeof t!="string")throw new Error("Input must be a string");if(!/^\d+(?:-\d+)?(?:,\s*\d+(?:-\d+)?)*$/.test(t))throw new Error("Malformed input string");let e=tg.get(t);if(e)return e;let r=t.split(","),n=[];for(let i of r){let s=i.split("-");if(s.length===2){let a=parseInt(s[0],10),c=parseInt(s[1],10);for(let u=a;u<=c;u++)n.push(u)}else n.push(parseInt(i,10))}return tg.set(t,n),n}o(JA,"statusCodesStringToNumberArray");Tn.statusCodesStringToNumberArray=JA;function zA(t,e,r){if(!e.startsWith("."))throw new eg.ConfigurationError(`Invalid ${r} - must start with '.' - '${e}' does not`);let n=e.split(".").splice(1),i=t;return n.forEach(s=>{if(i===void 0)throw new eg.RuntimeError(`Error applying ${r} '${e}', reading '${s}'`);i=i[s]}),`${i}`}o(zA,"getValueFromRequestUser");Tn.getValueFromRequestUser=zA});var sg=g(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.AmberfloMeteringInboundPolicy=Sn.AmberfloMeteringPolicy=void 0;var rg=D(),WA=we(),ng=na(),og=new WeakMap,ig={},Ld=class{static{o(this,"AmberfloMeteringPolicy")}static setRequestProperties(e,r){og.set(e,r)}};Sn.AmberfloMeteringPolicy=Ld;async function QA(t,e,r,n){if(!r.statusCodes)throw new rg.ConfigurationError(`Invalid AmberfloMeterInboundPolicy '${n}': options.statusCodes must be an array of HTTP status code numbers`);let i=Array.isArray(r.statusCodes)?r.statusCodes:(0,ng.statusCodesStringToNumberArray)(r.statusCodes);return e.addResponseSendingFinalHook(async s=>{if(i.includes(s.status)){let a=og.get(e),c=r.customerId;if(r.customerIdPropertyPath){if(!t.user)throw new rg.RuntimeError(`Unable to apply customerIdPropertyPath '${r.customerIdPropertyPath}' as request.user is 'undefined'.`);c=(0,ng.getValueFromRequestUser)(t.user,r.customerIdPropertyPath,"customerIdPropertyPath")}let u=a?.customerId??c;if(!u){e.log.error(`Error in AmberfloMeterInboundPolicy '${n}': customerId cannot be undefined`);return}let l=a?.meterApiName??r.meterApiName;if(!l){e.log.error(`Error in AmberfloMeterInboundPolicy '${n}': meterApiName cannot be undefined`);return}let d=a?.meterValue??r.meterValue;if(!d){e.log.error(`Error in AmberfloMeterInboundPolicy '${n}': meterValue cannot be undefined`);return}let p={customerId:u,meterApiName:l,meterValue:d,meterTimeInMillis:Date.now(),dimensions:Object.apply(r.dimensions??{},a?.dimensions)},m=ig[r.apiKey];if(!m){let f=r.apiKey,y=t.headers.get("zm-test-id")??"";m=new WA.BatchDispatch("amberflo-ingest-meter",10,async v=>{try{let T=r.url??"https://app.amberflo.io/ingest",S=await fetch(T,{method:"POST",body:JSON.stringify(v),headers:{"content-type":"application/json","x-api-key":f,"zm-test-id":y}});S.ok||e.log.error(`Unexpected response in AmberfloMeteringInboundPolicy '${n}'. ${S.status}: ${await S.text()}`)}catch(T){throw e.log.error(`Error in AmberfloMeteringInboundPolicy '${n}': ${T.message}`),T}}),ig[f]=m}m.enqueue(p),e.waitUntil(m.waitUntilFlushed())}}),t}o(QA,"AmberfloMeteringInboundPolicy");Sn.AmberfloMeteringInboundPolicy=QA});var ur=g(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.getPolicyCacheName=void 0;function YA(t){return`zuplo-policy-${t}`}o(YA,"getPolicyCacheName");ia.getPolicyCacheName=YA});var lg=g(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.ApiAuthKeyInboundPolicy=In.ApiKeyInboundPolicy=void 0;var ZA=ur(),XA=br(),ag=ed(),Dd=D(),eP=Nt(),Ud=Ge(),Md=te(),tP=ms(),cg="key-metadata-cache-type";function rP(t,e){return e.authScheme===""?t:t.replace(`${e.authScheme} `,"")}o(rP,"getKeyValue");async function ug(t,e,r,n){if(!r.bucketName)if(ag.environment.ZUPLO_API_KEY_SERVICE_BUCKET_NAME)r.bucketName=ag.environment.ZUPLO_API_KEY_SERVICE_BUCKET_NAME;else throw new Dd.ConfigurationError(`ApiKeyInboundPolicy '${n}' - no bucketName property provided`);let i={authHeader:r.authHeader??"authorization",authScheme:r.authScheme??"Bearer",bucketName:r.bucketName,cacheTtlSeconds:r.cacheTtlSeconds??60,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests??!1,disableAutomaticallyAddingKeyHeaderToOpenApi:r.disableAutomaticallyAddingKeyHeaderToOpenApi??!1};if(i.cacheTtlSeconds<60)throw new Dd.ConfigurationError(`ApiKeyInboundPolicy '${n}' - minimum cacheTtlSeconds value is 60s, '${i.cacheTtlSeconds}' is invalid`);let s=o(v=>i.allowUnauthenticatedRequests?t:eP.HttpProblems.unauthorized(t,e,{detail:v}),"unauthorizedResponse"),a=t.headers.get(i.authHeader);if(!a)return s("No Authorization Header");if(!a.toLowerCase().startsWith(i.authScheme.toLowerCase()))return s("Invalid Authorization Scheme");let c=rP(a,i);if(!c||c==="")return s("No key present");let u=await nP(c),l=new XA.MemoryZoneReadThroughCache((0,ZA.getPolicyCacheName)(n),{logger:Ud.SystemLogMap.getLogger(e)}),d=await l.get(u);if(d&&d.isValid===!0)return t.user=d.user,t;if(d&&!d.isValid)return d.typeId!==cg&&Ud.SystemLogMap.getLogger(e).error(`ApiKeyInboundPolicy '${n}' - cached metadata has invalid typeId '${d.typeId}'`,d),s("Authorization Failed");let p={key:c},m=await(0,tP.fetchRetry)({retryDelayMs:5,retries:2,logger:Ud.SystemLogMap.getLogger(e)},`${Md.Environment.instance.apiKeyServiceUrl}/v1/$validate/${i.bucketName}`,{method:"POST",headers:{"content-type":"application/json","zp-rid":e.requestId,"zp-dn":Md.Environment.instance.deploymentName??"unknown","User-Agent":Md.Environment.instance.systemUserAgent},body:JSON.stringify(p)});if(m.status===401)return e.log.info(`ApiKeyInboundPolicy '${n}' - 401 response from Key Service`),s("Authorization Failed");if(m.status!==200){try{let v=await m.text(),T=JSON.parse(v);e.log.error("Unexpected response from key service",T)}catch{e.log.error("Invalid response from key service")}throw new Dd.RuntimeError(`ApiKeyInboundPolicy '${n}' - unexpected response from Key Service. Status: ${m.status}`)}let f=await m.json(),y={isValid:!0,typeId:cg,user:{sub:f.name,data:f.metadata}};return t.user=y.user,l.put(u,y,i.cacheTtlSeconds),t}o(ug,"ApiKeyInboundPolicy");In.ApiKeyInboundPolicy=ug;async function nP(t){let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}o(nP,"hashValue");In.ApiAuthKeyInboundPolicy=ug});var lr=g(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0});oa.OpenIdJwtInboundPolicy=void 0;var Fd=(hs(),Bi(ps)),Hd=D(),iP=ve(),kd={},oP=o(async(t,e)=>{if(!e.jwkUrl||typeof e.jwkUrl!="string")throw new Hd.ConfigurationError("Invalid State - jwkUrl not set");kd[e.jwkUrl]||(kd[e.jwkUrl]=(0,Fd.createRemoteJWKSet)(new URL(e.jwkUrl),e.headers?{headers:e.headers}:void 0));let{payload:r}=await(0,Fd.jwtVerify)(t,kd[e.jwkUrl],{issuer:e.issuer,audience:e.audience});return r},"jwkVerifier"),sP=o(async(t,e)=>{let r;if(e.secret===void 0)throw new Error("secretVerifier requires secret to be defined");if(typeof e.secret=="string"){let s=new TextEncoder().encode(e.secret);r=new Uint8Array(s)}else r=e.secret;let{payload:n}=await(0,Fd.jwtVerify)(t,r,{issuer:e.issuer,audience:e.audience});return n},"secretVerifier"),aP=o(async(t,e,r,n)=>{let i=t.headers.get("Authorization"),s="bearer ",a=o(m=>iP.HttpProblems.unauthorized(t,e,{detail:m}),"unauthorizedResponse");if(!r.jwkUrl&&!r.secret)throw new Hd.ConfigurationError(`OpenIdJwtInboundPolicy policy '${n}': One of 'jwkUrl' or 'secret' options are required.`);if(r.jwkUrl&&r.secret)throw new Hd.ConfigurationError(`OpenIdJwtInboundPolicy policy '${n}': Only one of 'jwkUrl' and 'secret' options should be provided.`);let c=r.jwkUrl?oP:sP,l=await o(async()=>{if(!i)return a("No authorization header");if(i.toLowerCase().indexOf(s)!==0)return a("Invalid bearer token format for authorization header");let m=i.substring(s.length);if(!m||m.length===0)return a("No bearer token on authorization header");try{return await c(m,r)}catch(f){let y=new URL(t.url);return"code"in f&&f.code==="ERR_JWT_EXPIRED"?e.log.warn(`Expired token used on url: ${y.pathname} `,f):e.log.warn(`Invalid token on: ${t.method} ${y.pathname}`,f),a("Invalid token")}},"getJwtOrRejectedResponse")();if(l instanceof Response)return r.allowUnauthenticatedRequests===!0?t:l;let d=r.subPropertyName??"sub",p=l[d];return p?(t.user={sub:p,data:l},t):a(`Token is not valid, no '${d}' property found.`)},"OpenIdJwtInboundPolicy");oa.OpenIdJwtInboundPolicy=aP});var dg=g(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.Auth0JwtInboundPolicy=void 0;var cP=lr(),uP=o(async(t,e,r,n)=>(0,cP.OpenIdJwtInboundPolicy)(t,e,{issuer:`https://${r.auth0Domain}/`,audience:r.audience,jwkUrl:`https://${r.auth0Domain}/.well-known/jwks.json`,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n),"Auth0JwtInboundPolicy");sa.Auth0JwtInboundPolicy=uP});var pg=g(aa=>{"use strict";Object.defineProperty(aa,"__esModule",{value:!0});aa.BasicAuthInboundPolicy=void 0;var lP=ve(),dP=o(async(t,e,r)=>{let n=t.headers.get("Authorization"),i="basic ",s=o(l=>lP.HttpProblems.unauthorized(t,e,{detail:l}),"unauthorizedResponse"),c=await o(async()=>{if(!n)return await s("No Authorization header");if(n.toLowerCase().indexOf(i)!==0)return await s("Invalid Basic token format for Authorization header");let l=n.substring(i.length);if(!l||l.length===0)return await s("No username:password provided");let d=atob(l).normalize(),p=d.indexOf(":");if(p===-1||/[\0-\x1F\x7F]/.test(d))return await s("Invalid basic token value - see https://tools.ietf.org/html/rfc5234#appendix-B.1");let m=d.substring(0,p),f=d.substring(p+1),y=r.accounts.find(v=>v.username===m&&v.password===f);return y||await s("Invalid username or password")},"getAccountOrRejectedResponse")();if(c instanceof Response)return r.allowUnauthenticatedRequests?t:c;let u=c.username;return t.user={sub:u,data:c.data},t},"BasicAuthInboundPolicy");aa.BasicAuthInboundPolicy=dP});var hg=g(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.CachingInboundPolicy=void 0;var pP=ur(),hP=["cdn-cache-control","cloudflare-cdn-cache-control","surrogate-control","cache-tag","expires"];async function fP(t){let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}o(fP,"digestMessage");var mP=o(async(t,e)=>{let r=[...e.dangerouslyIgnoreAuthorizationHeader===!0?[]:["authorization"],...e.headers??[]],n=[];for(let[d,p]of t.headers.entries())r.includes(d)&&n.push({key:d.toLowerCase(),value:p});n.sort((d,p)=>d.key.localeCompare(p.key));let i=await fP(JSON.stringify(n)),s=new URL(t.url),a=new URLSearchParams(s.searchParams);a.set("_z-hdr-dgst",i);let c=e.cacheHttpMethods?.includes(t.method.toUpperCase())&&t.method.toUpperCase()!=="GET";c&&a.set("_z-original-method",t.method);let u=`${s.origin}${s.pathname}?${a}`;return new Request(u,{method:c?"GET":t.method})},"createCacheKeyRequest");async function yP(t,e,r,n){let i=await caches.open(`${(0,pP.getPolicyCacheName)(n)}-${r.cacheId??""}`),s=r?.cacheHttpMethods?.map(u=>u.toUpperCase())??["GET"],a=await mP(t,r),c=await i.match(a);return c||(e.addEventListener("responseSent",u=>{try{let l=r.statusCodes??[200,206,301,302,303,404,410],d=u.response.clone();if(!l.includes(d.status)||!s.includes(t.method.toUpperCase()))return;let p=r?.expirationSecondsTtl??60,m=new Response(d.body,d);hP.forEach(f=>m.headers.delete(f)),m.headers.set("cache-control",`s-maxage=${p}`),e.waitUntil(i.put(a,m))}catch(l){e.log.error(`Error in caching-inbound-policy '${n}': "${l.message}"`,l)}}),t)}o(yP,"CachingInboundPolicy");ca.CachingInboundPolicy=yP});var fg=g(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.ChangeMethodInboundPolicy=void 0;var gP=D(),_P=Rs(),bP=o(async(t,e,r,n)=>{if(!r.method)throw new gP.ConfigurationError(`ChangeMethodInboundPolicy '${n}' options.method must be valid HttpMethod`);return new _P.ZuploRequest(t,{method:r.method})},"ChangeMethodInboundPolicy");ua.ChangeMethodInboundPolicy=bP});var mg=g(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.ClearHeadersInboundPolicy=void 0;var EP=ke(),wP=o(async(t,e,r)=>{let n=[...r.exclude??[]],i=new Headers;return n.forEach(a=>{let c=t.headers.get(a);c&&i.set(a,c)}),new EP.ZuploRequest(t,{headers:i})},"ClearHeadersInboundPolicy");la.ClearHeadersInboundPolicy=wP});var yg=g(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.ClearHeadersOutboundPolicy=void 0;var vP=o(async(t,e,r,n)=>{let i=[...n.exclude??[]],s=new Headers;return i.forEach(c=>{let u=t.headers.get(c);u&&s.set(c,u)}),new Response(t.body,{headers:s,status:t.status,statusText:t.statusText})},"ClearHeadersOutboundPolicy");da.ClearHeadersOutboundPolicy=vP});var _g=g(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.CognitoJwtInboundPolicy=void 0;var gg=D(),TP=lr(),SP=o(async(t,e,r,n)=>{if(!r.userPoolId)throw new gg.ConfigurationError("userPoolId must be set in the options for CognitoJwtInboundPolicy");if(!r.region)throw new gg.ConfigurationError("region must be set in the options for CognitoJwtInboundPolicy");return(0,TP.OpenIdJwtInboundPolicy)(t,e,{issuer:`https://cognito-idp.${r.region}.amazonaws.com/${r.userPoolId}`,jwkUrl:`https://cognito-idp.${r.region}.amazonaws.com/${r.userPoolId}/.well-known/jwks.json`,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n)},"CognitoJwtInboundPolicy");pa.CognitoJwtInboundPolicy=SP});var Eg=g(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.CompositeInboundPolicy=void 0;var IP=D(),AP=ln(),bg=Qn(),PP=o(async(t,e,r,n)=>{if(!r.policies||r.policies.length===0)throw new IP.ConfigurationError(`CompositeInboundPolicy '${n}' must have valid policies defined`);let i=AP.Gateway.instance,s=(0,bg.getInboundPolicyHandlerAndOptions)(r.policies,i?.routeData.policies);return(0,bg.toStackedInboundHandler)(s)(t,e)},"CompositeInboundPolicy");ha.CompositeInboundPolicy=PP});var dr=g(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.optionValidator=void 0;var _i=D();function RP(t,e){let r=o((s,a,c)=>{let u=t[s];if(!(c&&u===void 0)){if(u===void 0)throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${e}' is required, but no value was set. If using an environment variable, check that it is set correctly.`);if(a==="array"&&Array.isArray(u))throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${e}' must be an array. Received type ${typeof u}.`);if(typeof u!==a)throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${e}' must be of type ${a}. Received type ${typeof u}.`);if(typeof u=="string"&&u.length===0)throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${e}' must be a non-empty string. The value received is empty. If using an environment variable, check that it is set correctly.`);if(typeof u=="number"&&isNaN(u))throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${e}' must be valid number. If using an environment variable, check that it is set correctly.`)}},"validate"),n=o((s,a)=>(r(s,a,!0),{optional:n,required:i}),"optional"),i=o((s,a)=>(r(s,a,!1),{optional:n,required:i}),"required");return{optional:n,required:i}}o(RP,"optionValidator");fa.optionValidator=RP});var wg=g(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.FirebaseJwtInboundPolicy=void 0;var OP=dr(),xP=lr(),NP=o(async(t,e,r,n)=>((0,OP.optionValidator)(r,n).required("projectId","string").optional("allowUnauthenticatedRequests","boolean"),(0,xP.OpenIdJwtInboundPolicy)(t,e,{issuer:`https://securetoken.google.com/${r.projectId}`,audience:r.projectId,jwkUrl:"https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com",allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n)),"FirebaseJwtInboundPolicy");ma.FirebaseJwtInboundPolicy=NP});var vg=g(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.FormDataToJsonInboundPolicy=void 0;var CP=ke(),LP=o(async(t,e,r)=>{let n="application/x-www-form-urlencoded",i="multipart/form-data",s=t.headers.get("content-type")?.toLowerCase();if(!s||![i,n].includes(s))return r&&r.badRequestIfNotFormData?new Response(`Bad Request - expected content-type '${n}' or ${i}`,{status:400,statusText:"Bad Request"}):t;let a=await t.formData();if(r&&r.optionalHoneypotName&&a.get(r.optionalHoneypotName)!=="")return new Response("Bad Request",{status:400,statusText:"Bad Request"});let c={};for(let[d,p]of a)c[d]=p.toString();let u=new Headers(t.headers);return u.set("content-type","application/json"),u.delete("content-length"),new CP.ZuploRequest(t,{body:JSON.stringify(c),headers:u})},"FormDataToJsonInboundPolicy");ya.FormDataToJsonInboundPolicy=LP});var Tg=g(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.GeoFilterInboundPolicy=void 0;var DP=D(),UP=ve(),An="__unknown__",MP=o(async(t,e,r,n)=>{let i={allow:{countries:Rn(r.allow?.countries,"allow.countries",n),regionCodes:Rn(r.allow?.regionCodes,"allow.regionCode",n),asns:Rn(r.allow?.asns,"allow.asOrganization",n)},block:{countries:Rn(r.block?.countries,"block.countries",n),regionCodes:Rn(r.block?.regionCodes,"block.regionCode",n),asns:Rn(r.block?.asns,"block.asOrganization",n)},ignoreUnknown:r.ignoreUnknown!==!1},s=e.incomingRequestProperties.country?.toLowerCase()??An,a=e.incomingRequestProperties.regionCode?.toLowerCase()??An,c=e.incomingRequestProperties.asn?.toString()??An,u=i.ignoreUnknown&&s===An,l=i.ignoreUnknown&&a===An,d=i.ignoreUnknown&&c===An,p=i.allow.countries,m=i.allow.regionCodes,f=i.allow.asns;if(p.length>0&&!p.includes(s)&&!u||m.length>0&&!m.includes(a)&&!l||f.length>0&&!f.includes(c)&&!d)return Pn(t,e,n,s,a,c);let y=i.block.countries,v=i.block.regionCodes,T=i.block.asns;return y.length>0&&y.includes(s)&&!u||v.length>0&&v.includes(a)&&!l||T.length>0&&T.includes(c)&&!d?Pn(t,e,n,s,a,c):t},"GeoFilterInboundPolicy");ga.GeoFilterInboundPolicy=MP;function Pn(t,e,r,n,i,s){return e.log.debug(`Request blocked by GeoFilterInboundPolicy '${r}' (country: '${n}', regionCode: '${i}', asn: '${s}')`),UP.HttpProblems.forbidden(t,e,{geographicContext:{country:n,regionCode:i,asn:s}})}o(Pn,"blockedResponse");function Rn(t,e,r){if(typeof t=="string")return t.split(",").map(n=>n.trim().toLowerCase());if(typeof t>"u")return[];if(Array.isArray(t))return t.map(n=>n.trim().toLowerCase());throw new DP.ConfigurationError(`Invalid '${e}' for GeoFilterInboundPolicy '${r}': '${t}', must be a string or string[]`)}o(Rn,"toLowerStringArray")});var Sg=g(_a=>{"use strict";Object.defineProperty(_a,"__esModule",{value:!0});_a.JWTScopeValidationInboundPolicy=void 0;var kP=o(async(t,e,r)=>{let n=t.user?.data.scope.split(" ")||[];if(!o((s,a)=>a.every(c=>s.includes(c)),"scopeChecker")(n,r.scopes)){let s={code:"UNAUTHORIZED",help_url:"https://zup.fail/UNAUTHORIZED",message:`JWT must have all the following scopes: ${r.scopes}`};return new Response(JSON.stringify(s),{status:401,statusText:"Unauthorized",headers:{"content-type":"application/json"}})}return t},"JWTScopeValidationInboundPolicy");_a.JWTScopeValidationInboundPolicy=kP});var Ag=g(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.MockApiInboundPolicy=void 0;var FP=ve(),HP=o(async(t,e,r,n)=>{let i=e.route.raw().responses;if(!i)return qd(n,t,e,"No responses defined in the OpenAPI document. Add some responses with examples to use this policy.");let s=Object.keys(i),a=[];if(s.length===0)return qd(n,t,e,"No response object defined under responses in the OpenAPI document. Add some response objects with examples to use this policy.");if(s.forEach(c=>{i[c].content&&Object.keys(i[c].content).forEach(l=>{let d=i[c].content[l].examples;d&&Object.keys(d).forEach(m=>{a.push({responseName:c,contentName:l,exampleName:m,exampleValue:d[m]})})})}),a=a.filter(c=>!(r.responsePrefixFilter&&!c.responseName.startsWith(r.responsePrefixFilter)||r.contentType&&c.contentName!==r.contentType||r.exampleName&&c.exampleName!==r.exampleName)),r.random&&a.length>1){let c=Math.floor(Math.random()*a.length);return Ig(a[c])}else return a.length>0?Ig(a[0]):qd(n,t,e,"No examples matching the mocking options found in the OpenAPI document. Add examples to the OpenAPI document matching the options for this policy or change the mocking options to match the examples in the OpenAPI document.")},"MockApiInboundPolicy");ba.MockApiInboundPolicy=HP;function Ig(t){let e=JSON.stringify(t.exampleValue,null,2),r=new Headers;switch(r.append("Content-Type",t.contentName),t.responseName){case"1XX":return new Response(e,{status:100,headers:r});case"2XX":return new Response(e,{status:200,headers:r});case"3XX":return new Response(e,{status:300,headers:r});case"4XX":return new Response(e,{status:400,headers:r});case"5XX":case"default":return new Response(e,{status:500,headers:r});default:return new Response(e,{status:Number(t.responseName),headers:r})}}o(Ig,"generateResponse");var qd=o((t,e,r,n)=>{let i=`Error in policy: ${t} - On route ${e.method} ${r.route.path}. ${n}`;return FP.HttpProblems.internalServerError(e,r,{detail:i})},"getProblemDetailResponse")});var Ng=g(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.MoesifInboundPolicy=On.setMoesifContext=void 0;var qP=D(),$P=we(),jP="Incoming",VP={logRequestBody:!0,logResponseBody:!0};function Pg(t){let e={};return t.forEach((r,n)=>{e[n]=r}),e}o(Pg,"headersToObject");function Rg(){return new Date().toISOString()}o(Rg,"timestamp");var $d=new WeakMap,GP={};function BP(t,e){let r=$d.get(t);r||(r=GP);let n=Object.assign({...r},e);$d.set(t,n)}o(BP,"setMoesifContext");On.setMoesifContext=BP;async function Og(t,e){let r=t.headers.get("content-type"),n=t.clone();if(r&&r.indexOf("json")!==0)try{return await n.json()}catch(s){e.log.error(s)}let i=await n.text();return e.log.debug({textBody:i}),i}o(Og,"readBody");var KP={},jd;function xg(){if(!jd)throw new qP.RuntimeError("Invalid State - no _lastLogger");return jd}o(xg,"getLastLogger");function JP(t){let e=KP[t];return e||(e=new $P.BatchDispatch("moesif-inbound",100,async r=>{let n=JSON.stringify(r);xg().debug("posting",n);let i=await fetch("https://api.moesif.net/v1/events/batch",{method:"POST",headers:{"content-type":"application/json","X-Moesif-Application-Id":t},body:n});i.ok||xg().error({status:i.status,body:await i.text()})})),e}o(JP,"getDispatcher");async function zP(t,e,r,n){jd=e.log;let i=Rg(),s=Object.assign(VP,r);if(!s.applicationId)throw new Error(`Invalid configuration for MoesifInboundPolicy '${n}' - applicationId is required`);let a=s.logRequestBody?await Og(t,e):void 0;return e.addResponseSendingFinalHook(async(c,u)=>{let l=JP(s.applicationId),d=t.headers.get("true-client-ip"),p=$d.get(e)??{},m={time:i,uri:t.url,verb:t.method,body:a,ip_address:d??void 0,api_version:p.apiVersion,headers:Pg(t.headers)},f=s.logResponseBody?await Og(c,e):void 0,y={time:Rg(),status:c.status,headers:Pg(c.headers),body:f},v={request:m,response:y,user_id:p.userId??u.user?.sub,session_token:p.sessionToken,company_id:p.companyId,metadata:p.metadata,direction:jP};l.enqueue(v),e.waitUntil(l.waitUntilFlushed())}),t}o(zP,"MoesifInboundPolicy");On.MoesifInboundPolicy=zP});var Cg=g(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.OktaJwtInboundPolicy=void 0;var WP=lr(),QP=o(async(t,e,r,n)=>(0,WP.OpenIdJwtInboundPolicy)(t,e,{issuer:r.issuerUrl,audience:r.audience,jwkUrl:`${r.issuerUrl}/v1/keys`,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n),"OktaJwtInboundPolicy");Ea.OktaJwtInboundPolicy=QP});var Lg=g(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.PropelAuthJwtInboundPolicy=void 0;var YP=(hs(),Bi(ps)),ZP=lr(),Vd,XP=o(async(t,e,r,n)=>{if(!Vd)try{Vd=await(0,YP.importSPKI)(r.verifierKey,"RS256")}catch(i){throw e.log.error("Could not import verifier key"),i}return(0,ZP.OpenIdJwtInboundPolicy)(t,e,{issuer:r.authUrl,secret:Vd,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests,subPropertyName:"user_id"},n)},"PropelAuthJwtInboundPolicy");wa.PropelAuthJwtInboundPolicy=XP});var Dg=g(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.throwIfStateNotObject=G.throwIfStateNotNumber=G.throwIfStateNotString=G.throwIfStateUndefinedOrNull=G.throwIfStateUndefined=G.throwIfOptionNotObject=G.throwIfOptionNotNumber=G.throwIfOptionNotString=G.throwIfOptionUndefinedOrNull=G.throwIfOptionUndefined=G.OptionTypeError=G.OptionUndefinedError=G.throwIfNotNumber=G.throwIfNotString=G.throwIfUndefinedOrNull=G.throwIfUndefined=G.ArgumentTypeError=G.ArgumentUndefinedError=G.ValidationError=void 0;var $e=Kr(),et=class extends Error{static{o(this,"ValidationError")}constructor(e){super(e)}};G.ValidationError=et;var bi=class extends et{static{o(this,"ArgumentUndefinedError")}constructor(e){super(`The argument '${e}' is undefined.`)}};G.ArgumentUndefinedError=bi;var Ei=class extends et{static{o(this,"ArgumentTypeError")}constructor(e,r){super(`The argument '${e}' must be of type '${r}'.`)}};G.ArgumentTypeError=Ei;function eR(t,e){if((0,$e.isUndefined)(t))throw new bi(e)}o(eR,"throwIfUndefined");G.throwIfUndefined=eR;function Gd(t,e){if((0,$e.isUndefinedOrNull)(t))throw new bi(e)}o(Gd,"throwIfUndefinedOrNull");G.throwIfUndefinedOrNull=Gd;function tR(t,e){if(Gd(t,e),!(0,$e.isString)(t))throw new Ei(e,"string")}o(tR,"throwIfNotString");G.throwIfNotString=tR;function rR(t,e){if(Gd(t,e),!(0,$e.isNumber)(t))throw new Ei(e,"number")}o(rR,"throwIfNotNumber");G.throwIfNotNumber=rR;var wi=class extends et{static{o(this,"OptionUndefinedError")}constructor(e,r,n){super(`The option '${n}' on the ${e} named '${r}' is undefined.`)}};G.OptionUndefinedError=wi;var xn=class extends et{static{o(this,"OptionTypeError")}constructor(e,r,n,i){super(`The option '${n}' on the ${e} named '${r}' must be of type '${i}'.`)}};G.OptionTypeError=xn;function nR(t,e,r,n){if((0,$e.isUndefined)(n))throw new wi(t,e,r)}o(nR,"throwIfOptionUndefined");G.throwIfOptionUndefined=nR;function va(t,e,r,n){if((0,$e.isUndefinedOrNull)(n))throw new wi(t,e,r)}o(va,"throwIfOptionUndefinedOrNull");G.throwIfOptionUndefinedOrNull=va;function iR(t,e,r,n){if(va(t,e,r,n),!(0,$e.isString)(n))throw new xn(t,e,r,"string")}o(iR,"throwIfOptionNotString");G.throwIfOptionNotString=iR;function oR(t,e,r,n){if(va(t,e,r,n),!(0,$e.isNumber)(n))throw new xn(t,e,r,"number")}o(oR,"throwIfOptionNotNumber");G.throwIfOptionNotNumber=oR;function sR(t,e,r,n){if(va(t,e,r,n),!(0,$e.isObject)(n))throw new xn(t,e,r,"object")}o(sR,"throwIfOptionNotObject");G.throwIfOptionNotObject=sR;function aR(t,e){if((0,$e.isUndefined)(t))throw new et(e)}o(aR,"throwIfStateUndefined");G.throwIfStateUndefined=aR;function Ta(t,e){if((0,$e.isUndefinedOrNull)(t))throw new et(e)}o(Ta,"throwIfStateUndefinedOrNull");G.throwIfStateUndefinedOrNull=Ta;function cR(t,e){if(Ta(t,e),!(0,$e.isString)(t))throw new et(e);return!0}o(cR,"throwIfStateNotString");G.throwIfStateNotString=cR;function uR(t,e){if(Ta(t,e),!(0,$e.isNumber)(t))throw new et(e);return!0}o(uR,"throwIfStateNotNumber");G.throwIfStateNotNumber=uR;function lR(t,e){if(Ta(t,e),!(0,$e.isObject)(t))throw new et(e);return!0}o(lR,"throwIfStateNotObject");G.throwIfStateNotObject=lR});var Ug=g(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.InMemoryRedisClient=Nn.StandardRedisClient=void 0;var Bd=D(),Sa=Dg(),Kd=class t{static{o(this,"StandardRedisClient")}static instance;redisClientUrl;clientAuthToken;userAgent;deploymentName;constructor(e,r,n,i){this.redisClientUrl=e,this.clientAuthToken=r,this.deploymentName=n,this.userAgent=i}static initialize(e,r,n,i){return(0,Sa.throwIfNotString)(e,"redisClientUrl"),(0,Sa.throwIfNotString)(r,"clientAuthToken"),t.instance||(t.instance=new t(e,r,n,i)),t.instance}isEnabled(){return this.redisClientUrl!==void 0&&this.clientAuthToken!==void 0}async fetch({url:e,body:r,method:n,requestId:i}){(0,Sa.throwIfNotString)(e,"url");let s=await fetch(`${this.redisClientUrl}${e}`,{method:n,body:r,headers:{"content-type":"application/json",authorization:`Bearer ${this.clientAuthToken}`,"zp-rid":i,"zp-dn":this.deploymentName,"User-Agent":this.userAgent}}),a=s.headers.get("Content-Type")?.includes("application/json")?await s.json():await s.text();if(s.ok)return a;throw s.status===401?new Bd.SystemError("Redis client failed with 401: Unauthorized"):new Bd.SystemError(`Redis client failed with (${s.status}): ${typeof a=="string"?a:JSON.stringify(a,null,2)}`)}};Nn.StandardRedisClient=Kd;var Jd=class{static{o(this,"InMemoryRedisClient")}keyValueStore;constructor(){this.keyValueStore=new Map}isEnabled(){return!0}fetch({url:e,body:r,method:n}){if((0,Sa.throwIfNotString)(e,"url"),n==="POST"&&e==="/rate-limit"){let{incrBy:i,expire:s,key:a}=JSON.parse(r),c=Date.now()+s*1e3,u=this.keyValueStore.get(a);u?Date.now()>u.expiresAt?this.keyValueStore.set(a,{value:i,expiresAt:c}):this.keyValueStore.set(a,{value:u.value+i,expiresAt:u.expiresAt}):this.keyValueStore.set(a,{value:i,expiresAt:c});let l=this.keyValueStore.get(a);return Promise.resolve({count:l.value,ttlSeconds:Math.round((l.expiresAt-Date.now())/1e3)})}throw new Bd.SystemError("The in-memory redis client only supports /rate-limit calls")}};Nn.InMemoryRedisClient=Jd});var qg=g(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.RateLimitInboundPolicy=void 0;var dR=wr(),pR=ke(),hR=ur(),Mt=D(),fR=ve(),Mg=Ge(),vi=te(),kg=Ug(),Fg=Kr(),Ia=(0,dR.debug)("zuplo:policies:RateLimitInboundPolicy"),mR="strict",yR=o(t=>{let e=t.headers.get("cf-connecting-ip")??t.headers.get("true-client-ip");if(e)return e;let r=t.headers.get("x-forwarded-for");return r?r.split(",")[0]:"127.0.0.1"},"getRealIP"),gR=o(async t=>({key:`ip-${yR(t)}`}),"getIP"),_R=o(async t=>({key:`user-${t.user?.sub??"anonymous"}`}),"getUser"),bR=o(async()=>({key:"all-2d77ce9d-9a3c-4206-9ab2-668cfd271095"}),"getAll"),Aa;function ER(t,e){let r;if(Aa)return Aa;if(vi.Environment.instance.isLocalDevelopment)return e.info("Using in-memory redis client for local development."),r=new kg.InMemoryRedisClient,Aa=r,r;let{authApiJWT:n,redisURL:i}=vi.Environment.instance;if(!(0,Fg.isString)(i))throw new Mt.SystemError(`RateLimitInboundPolicy '${t}' - rate limit service URL not configured`);if(!(0,Fg.isString)(n))throw new Mt.SystemError(`RateLimitInboundPolicy '${t}' - service authentication not configured`);if(i&&(r=kg.StandardRedisClient.initialize(i,n,vi.Environment.instance.deploymentName??"unknown",vi.Environment.instance.systemUserAgent)),!r||!r.isEnabled())throw new Mt.SystemError(`RateLimitInboundPolicy '${t}' - no redis ('${r}') or redis.isEnabled ('${r?.isEnabled}) is false`);return Aa=r,r}o(ER,"getRedisClient");async function Hg(t,e,r,n,i){let s=Math.floor(e*60);return await r.fetch({url:"/rate-limit",method:"POST",body:JSON.stringify({incrBy:1,expire:s,key:t}),requestId:i})}o(Hg,"getCountAndUpdateExpiry");function wR(t,e){let r;if(t.rateLimitBy==="function"){if(!t.identifier)throw new Mt.ConfigurationError(`RateLimitInboundPolicy '${e}' - If rateLimitBy set to 'function' options.identifier must be specified`);if(!t.identifier.module)throw new Mt.ConfigurationError(`RateLimitInboundPolicy '${e}' - If rateLimitBy set to 'function' options.identifier.module must be specified`);if(!t.identifier.export)throw new Mt.ConfigurationError(`RateLimitInboundPolicy '${e}' - If rateLimitBy set to 'function' options.identifier.export must be specified`);if(r=t.identifier.module[t.identifier.export],!r||typeof r!="function")throw new Mt.ConfigurationError(`RateLimitInboundPolicy '${e}' - Custom rate limit function must be a valid function`)}return o(async(i,s,a)=>{let c=await r(i,s,a);if(!c.key){let u=`RateLimitInboundPolicy '${a}' - Custom rate limit function must return a valid key property '${JSON.stringify(c,null,2)}'`;throw s.log.error(u),new Mt.RuntimeError(u)}return c},"outerFunction")}o(wR,"wrapUserFunction");var vR="Retry-After",TR=o(async(t,e,r,n)=>{let i=Date.now(),s=Mg.SystemLogMap.getLogger(e),a=o((u,l)=>{if(r.throwOnFailure)throw new Mt.SystemError(u,{cause:l});s.error(u,l)},"throwOrLog"),c=o((u,l)=>{let d={};return(!u||u==="retry-after")&&(d[vR]=l.toString()),fR.HttpProblems.tooManyRequests(t,e,void 0,d)},"rateLimited");try{let l={function:wR(r,n),user:_R,ip:gR,all:bR}[r.rateLimitBy],d=await l(t,e,n),p=d.key,m=d.requestsAllowed??r.requestsAllowed,f=d.timeWindowMinutes??r.timeWindowMinutes,y=r.headerMode??"retry-after",v=ER(n,s),S=`bucket/${vi.Environment.instance.build.BUILD_ID}/${n}/${p}`;if((r.mode??mR)==="async"){let R=new pR.ZoneCache((0,hR.getPolicyCacheName)(n),{logger:Mg.SystemLogMap.getLogger(e)}),ne=Hg(S,f,v,s,e.requestId),Y=await R.get(S);if(Y!==void 0&&Y<=Date.now()){Ia(`RateLimitInboundPolicy '${n}' - returning 429 from cache for '${S}' (async mode)`);let fe=Math.round((Y-Date.now())/1e3);return c(y,fe)}return e.addEventListener("responseSending",fe=>{try{let Me=fe,E=Me.mutableResponse;Me.mutableResponse=(async()=>{let F=await ne;if(F.count>m){let Ye=Date.now()+F.ttlSeconds*1e3;return R.put(S,Ye,F.ttlSeconds).catch(Vi=>{throw s.error(Vi),Vi}),Ia(`RateLimitInboundPolicy '${n}' - returning 429 from redis for '${S}' (async mode)`),c(y,F.ttlSeconds)}return E})()}catch(Me){s.error(`RateLimitInboundPolicy '${n}' -error in responseSending`,Me)}}),t}let H=await Hg(S,f,v,s,e.requestId);return H.count>m?(Ia(`RateLimitInboundPolicy '${n}' - returning 429 from redis for '${S}' (strict mode)`),c(y,H.ttlSeconds)):t}catch(u){return a(u.message,u),t}finally{let u=Date.now()-i;Ia(`RateLimitInboundPolicy '${n}' - latency ${u}ms`)}},"RateLimitInboundPolicy");Pa.RateLimitInboundPolicy=TR});var Gg=g(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.ReadmeMetricsInboundPolicy=void 0;var SR=we(),zd=te(),$g=na(),Wd;function jg(t){let e=[];for(let[r,n]of t)e.push({name:r,value:n});return e}o(jg,"headersToNameValuePairs");function IR(t){let e=[];return Object.entries(t).forEach(([r,n])=>{e.push({name:r,value:n})}),e}o(IR,"queryToNameValueParis");function AR(t){if(t===null)return;let e=parseFloat(t);if(!isNaN(e))return e}o(AR,"parseIntOrUndefined");var Vg={};async function PR(t,e,r,n){let i=new Date,s=Date.now();return Wd||(Wd={name:"zuplo",version:zd.Environment.instance.build.ZUPLO_VERSION,comment:`zuplo/${zd.Environment.instance.build.ZUPLO_VERSION}`}),e.addResponseSendingFinalHook(async a=>{try{let c=r.userLabelPropertyPath&&t.user?(0,$g.getValueFromRequestUser)(t.user,r.userLabelPropertyPath,"userLabelPropertyPath"):t.user?.sub,u=r.userEmailPropertyPath&&t.user?(0,$g.getValueFromRequestUser)(t.user,r.userEmailPropertyPath,"userEmailPropertyPath"):void 0,l={clientIPAddress:t.headers.get("true-client-ip")??"",development:r.development!==void 0?r.development:zd.Environment.instance.isDeno,group:{label:c,email:u,id:t.user?.sub??"anonymous"},request:{log:{creator:Wd,entries:[{startedDateTime:i.toISOString(),time:Date.now()-s,request:{method:t.method,url:r.useFullRequestPath?new URL(t.url).pathname:e.route.path,httpVersion:"2",headers:jg(t.headers),queryString:IR(t.query)},response:{status:a.status,statusText:a.statusText,headers:jg(a.headers),content:{size:AR(t.headers.get("content-length"))}}}]}}},d=Vg[r.apiKey];if(!d){let p=r.apiKey;d=new SR.BatchDispatch("readme-metering-inbound-policy",10,async m=>{try{let f=r.url??"https://metrics.readme.io/request",y=await fetch(f,{method:"POST",body:JSON.stringify(m),headers:{"content-type":"application/json",authorization:`Basic ${btoa(p+":")}`}});y.status!==202&&e.log.error(`Unexpected response in ReadmeMeteringInboundPolicy '${n}'. ${y.status}: '${await y.text()}'`)}catch(f){throw e.log.error(`Error in ReadmeMeteringInboundPolicy '${n}': '${f.message}'`),f}}),Vg[p]=d}d.enqueue(l),e.waitUntil(d.waitUntilFlushed())}catch(c){e.log.error(c)}}),t}o(PR,"ReadmeMetricsInboundPolicy");Ra.ReadmeMetricsInboundPolicy=PR});var Bg=g(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});Oa.RemoveHeadersInboundPolicy=void 0;var RR=ke(),OR=D(),xR=o(async(t,e,r,n)=>{let i=r?.headers;if(!i||!Array.isArray(i)||i.length===0)throw new OR.ConfigurationError(`RemoveHeadersInboundPolicy '${n}' options.headers must be a non-empty string array of header names`);let s=new Headers(t.headers);return i.forEach(c=>{s.delete(c)}),new RR.ZuploRequest(t,{headers:s})},"RemoveHeadersInboundPolicy");Oa.RemoveHeadersInboundPolicy=xR});var Kg=g(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});xa.RemoveHeadersOutboundPolicy=void 0;var NR=D(),CR=o(async(t,e,r,n,i)=>{let s=n?.headers;if(!s||!Array.isArray(s)||s.length===0)throw new NR.ConfigurationError(`RemoveHeadersOutboundPolicy '${i}' options.headers must be a non-empty string array of header names`);let a=new Headers(t.headers);return s.forEach(u=>{a.delete(u)}),new Response(t.body,{headers:a,status:t.status,statusText:t.statusText})},"RemoveHeadersOutboundPolicy");xa.RemoveHeadersOutboundPolicy=CR});var Jg=g(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.RemoveQueryParamsInboundPolicy=void 0;var LR=ke(),DR=D(),UR=o(async(t,e,r,n)=>{let i=r.params;if(!i||!Array.isArray(i)||i.length===0)throw new DR.ConfigurationError(`RemoveQueryParamsInboundPolicy '${n}' options.params must be a non-empty string array of header names`);let s=new URL(t.url);return i.forEach(c=>{s.searchParams.delete(c)}),new LR.ZuploRequest(s.toString(),t)},"RemoveQueryParamsInboundPolicy");Na.RemoveQueryParamsInboundPolicy=UR});var zg=g(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.ReplaceStringOutboundPolicy=void 0;var MR=o(async(t,e,r,n)=>{let i=await t.text(),s=n.mode==="regexp"?new RegExp(n.match,"gm"):n.match,a=i.replaceAll(s,n.replaceWith);return new Response(a,{headers:t.headers,status:t.status,statusText:t.statusText})},"ReplaceStringOutboundPolicy");Ca.ReplaceStringOutboundPolicy=MR});var Qg=g(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.RequestSizeLimitInboundPolicy=void 0;var Wg=o(()=>new Response("Maximum request size exceeded",{status:413,statusText:"Payload Too Large"}),"payloadTooLarge"),kR=o(async(t,e,r)=>{let n=r.trustContentLengthHeader??!1;if(["GET","HEAD"].includes(t.method))return t;let i=t.headers.get("content-length"),s=i!==null?parseInt(i):void 0;return s&&!isNaN(s)&&s>r.maxSizeInBytes?Wg():s&&n?t:(await t.clone().text()).length>r.maxSizeInBytes?Wg():t},"RequestSizeLimitInboundPolicy");La.RequestSizeLimitInboundPolicy=kR});var Da=g(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.sanitizedIdentifierName=tt.getIdForRefSchema=tt.getIdForRequestBodySchema=tt.getIdForParameterSchema=tt.getRawOperationDataIdentifierName=void 0;function FR(t,e,r){return`_${Lr(t+"_"+e+"_"+r)}`}o(FR,"getRawOperationDataIdentifierName");tt.getRawOperationDataIdentifierName=FR;function HR(t,e,r,n){return`_${Lr(t.toLowerCase())}_`+e.toLowerCase()+"_"+r.toLowerCase()+`_${n.toLowerCase()}`}o(HR,"getIdForParameterSchema");tt.getIdForParameterSchema=HR;function qR(t,e,r){return`_${Lr(t.toLowerCase())}_`+e.toLowerCase()+`_rb_${Lr(r.toLowerCase())}`}o(qR,"getIdForRequestBodySchema");tt.getIdForRequestBodySchema=qR;function $R(t,e){return`_${Lr(t)}__${Lr(e)}`}o($R,"getIdForRefSchema");tt.getIdForRefSchema=$R;function Lr(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n>="0".charCodeAt(0)&&n<="9".charCodeAt(0)||n>="A".charCodeAt(0)&&n<="Z".charCodeAt(0)||n>="a".charCodeAt(0)&&n<="z".charCodeAt(0)?e.push(t.charAt(r)):e.push("_")}return e.join("")}o(Lr,"sanitizedIdentifierName");tt.sanitizedIdentifierName=Lr});var Ti=g(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.getErrorsFromValidator=Ce.shouldReject=Ce.shouldLog=Ce.logErrors=Ce.validateParameters=Ce.getParametersForOperation=void 0;var jR=ln(),Ua=Dr(),VR=Da(),GR=o(t=>{let e=t.route.raw();return e.parameters?e.parameters.map(n=>({name:n.name,location:n.in,required:n.required,deprecated:n.deprecated,allowEmptyValue:n.allowEmptyValue})):[]},"getParametersForOperation");Ce.getParametersForOperation=GR;var BR=o((t,e,r,n,i)=>{let s=[],a=!0,c=[];return t.forEach(u=>{if(u.required&&!e[u.name])a=!1,s.push(`Required ${i} parameter '${u.name}' not found`);else{let l=(0,VR.getIdForParameterSchema)(r,n,i,u.name),d=jR.Gateway.instance.schemaValidator[l],p=d(e[u.name]),m=(0,Ce.getErrorsFromValidator)(d.errors);p||(a=!1,c.push(`${i} parameter: ${u.name} : ${e[u.name]}`),s.push(`Invalid value for ${i} parameter: '${u.name}' ${m.join(", ")}`))}}),{isValid:a,invalidValues:c,errors:s}},"validateParameters");Ce.validateParameters=BR;var KR=o((t,e,r,n,i)=>{n?t.log[e](r,n,i):t.log[e](r,i)},"logErrors");Ce.logErrors=KR;var JR=o(t=>t===Ua.ValidationOptions.logOnly||t===Ua.ValidationOptions.rejectAndLog,"shouldLog");Ce.shouldLog=JR;var zR=o(t=>t===Ua.ValidationOptions.rejectOnly||t===Ua.ValidationOptions.rejectAndLog,"shouldReject");Ce.shouldReject=zR;var WR=o(t=>t?.map(e=>e.instancePath===void 0||e.instancePath===""?e.message??"Unknown validation error":e.instancePath.replace("/","")+" "+e.message)??["Unknown validation error"],"getErrorsFromValidator");Ce.getErrorsFromValidator=WR});var Yg=g(ka=>{"use strict";Object.defineProperty(ka,"__esModule",{value:!0});ka.handleBodyValidation=void 0;var QR=ln(),YR=Dr(),Ma=ve(),ZR=Da(),Ke=Ti();async function XR(t,e,r){if(!r.validateBody||r.validateBody===YR.ValidationOptions.none)return;let n;try{n=await e.clone().json()}catch(f){let y=`Error in request body for method : ${e.method} in route: ${t.route.path} with content-type: ${e.headers.get("Content-Type")}`,v=Ma.HttpProblems.badRequest(e,t,{detail:`${y}, see errors property for more details`,errors:`${f}`});if((0,Ke.shouldLog)(r.validateBody)&&(0,Ke.logErrors)(t,r.logLevel??"info",y,[n],f),(0,Ke.shouldReject)(r.validateBody))return v}if(!e.headers.get("Content-Type")){let f=`No content-type header defined in incoming request to ${e.method} in route: ${t.route.path}`,y=Ma.HttpProblems.badRequest(e,t,{detail:f});return(0,Ke.shouldLog)(r.validateBody)&&(0,Ke.logErrors)(t,r.logLevel??"info",f,[n],[f]),(0,Ke.shouldReject)(r.validateBody)?y:void 0}let i=e.headers.get("Content-Type"),s=i.indexOf(";");s>-1&&(i=i.substring(0,s));let a=(0,ZR.getIdForRequestBodySchema)(t.route.path,e.method,i),c=QR.Gateway.instance.schemaValidator[a];if(!c){let f=`No schema defined for method: ${e.method} in route: ${t.route.path} with content-type: ${e.headers.get("Content-Type")}`,y=Ma.HttpProblems.badRequest(e,t,{detail:f});return(0,Ke.shouldLog)(r.validateBody)&&(0,Ke.logErrors)(t,r.logLevel??"info",f,[n],[f]),(0,Ke.shouldReject)(r.validateBody)?y:void 0}if(c(n))return;let l=c.errors,d="Request body did not pass validation",p=(0,Ke.getErrorsFromValidator)(l),m=Ma.HttpProblems.badRequest(e,t,{detail:`${d}, see errors property for more details`,errors:p});if((0,Ke.shouldLog)(r.validateBody)&&(0,Ke.logErrors)(t,r.logLevel??"info",d,[n],p),(0,Ke.shouldReject)(r.validateBody))return m}o(XR,"handleBodyValidation");ka.handleBodyValidation=XR});var Zg=g(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});Fa.handleHeadersValidation=void 0;var eO=Dr(),tO=ve(),Si=Ti();function rO(t,e,r){if(!r.validateHeaders||r.validateHeaders===eO.ValidationOptions.none)return;let n={};e.headers.forEach((a,c)=>{n[c]=a});let i=(0,Si.getParametersForOperation)(t),s=(0,Si.validateParameters)(i.filter(a=>a.location==="header"),n,t.route.path,e.method.toLowerCase(),"header");if(!s.isValid){let a="Header validation failed",c=tO.HttpProblems.badRequest(e,t,{detail:`${a}, see errors property for more details`,errors:s.errors});if((0,Si.shouldLog)(r.validateHeaders)&&(0,Si.logErrors)(t,r.logLevel??"info",a,s.invalidValues,s.errors),(0,Si.shouldReject)(r.validateHeaders))return c}}o(rO,"handleHeadersValidation");Fa.handleHeadersValidation=rO});var Xg=g(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.handlePathParameterValidation=void 0;var nO=Dr(),iO=ve(),Ii=Ti();function oO(t,e,r){if(!r.validatePathParameters||r.validatePathParameters===nO.ValidationOptions.none)return;let n=(0,Ii.getParametersForOperation)(t),i=(0,Ii.validateParameters)(n.filter(s=>s.location==="path"),e.params,t.route.path,e.method.toLowerCase(),"path");if(!i.isValid){let s="Path parameters validation failed",a=iO.HttpProblems.badRequest(e,t,{detail:`${s}, see errors property for more details`,errors:i.errors});if((0,Ii.shouldLog)(r.validatePathParameters)&&(0,Ii.logErrors)(t,r.logLevel??"info",s,i.invalidValues,i.errors),(0,Ii.shouldReject)(r.validatePathParameters))return a}}o(oO,"handlePathParameterValidation");Ha.handlePathParameterValidation=oO});var e_=g(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.handleQueryParameterValidation=void 0;var sO=Dr(),aO=ve(),Ai=Ti();function cO(t,e,r){if(!r.validateQueryParameters||r.validateQueryParameters===sO.ValidationOptions.none)return;let n=(0,Ai.getParametersForOperation)(t),i=(0,Ai.validateParameters)(n.filter(s=>s.location==="query"),e.query,t.route.path,e.method.toLowerCase(),"query");if(!i.isValid){let s="Query parameters validation failed",a=aO.HttpProblems.badRequest(e,t,{detail:`${s}, see errors property for more details`,errors:i.errors});if((0,Ai.shouldLog)(r.validateQueryParameters)&&(0,Ai.logErrors)(t,r.logLevel??"info",s,i.invalidValues,i.errors),(0,Ai.shouldReject)(r.validateQueryParameters))return a}}o(cO,"handleQueryParameterValidation");qa.handleQueryParameterValidation=cO});var Dr=g(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.SchemaBasedRequestValidation=kt.RequestValidationInboundPolicy=kt.ValidationOptions=void 0;var uO=Yg(),lO=Zg(),dO=Xg(),pO=e_(),t_;(function(t){t.none="none",t.logOnly="log-only",t.rejectAndLog="reject-and-log",t.rejectOnly="reject-only"})(t_||(kt.ValidationOptions=t_={}));var hO=o(async(t,e,r)=>{let n=(0,pO.handleQueryParameterValidation)(e,t,r);if(n!==void 0||(n=(0,dO.handlePathParameterValidation)(e,t,r),n!==void 0)||(n=(0,lO.handleHeadersValidation)(e,t,r),n!==void 0))return n;let i=await(0,uO.handleBodyValidation)(e,t,r);return i!==void 0?i:t},"RequestValidationInboundPolicy");kt.RequestValidationInboundPolicy=hO;kt.SchemaBasedRequestValidation=kt.RequestValidationInboundPolicy});var r_=g($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.RequireOriginInboundPolicy=void 0;var fO=ke(),mO=D(),yO=o(async(t,e,r,n)=>{if(r.origins===void 0||r.origins.length===0)throw new mO.ConfigurationError(`RequireOriginInboundPolicy '${n}' configuration error - no allowed origins specified`);let i=typeof r.origins=="string"?r.origins.split(","):r.origins;i=i.map(a=>a.trim());let s=t.headers.get("origin");if(!s||!i.includes(s)){let a=r.failureDetail??"Forbidden";return fO.HttpProblems.forbidden(t,e,{detail:a})}return t},"RequireOriginInboundPolicy");$a.RequireOriginInboundPolicy=yO});var n_=g(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});ja.SetBodyInboundPolicy=void 0;var gO=ke(),_O=o(async(t,e,r)=>new gO.ZuploRequest(t,{body:r.body}),"SetBodyInboundPolicy");ja.SetBodyInboundPolicy=_O});var o_=g(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.SetHeadersInboundPolicy=void 0;var bO=ke(),i_=D(),EO=o(async(t,e,r,n)=>{let i=r.headers;if(!i||!Array.isArray(i)||i.length==0)throw new i_.ConfigurationError(`SetHeadersInboundPolicy '${n}' options.headers must be a valid array of { name, value }`);let s=new Headers(t.headers);return i.forEach(c=>{if(!c.name||c.name.length===0)throw new i_.ConfigurationError(`SetHeadersInboundPolicy '${n}' each option.headers[] entry must have a name property`);let u=c.overwrite===void 0?!0:c.overwrite;(!s.has(c.name)||u)&&s.set(c.name,c.value)}),new bO.ZuploRequest(t,{headers:s})},"SetHeadersInboundPolicy");Va.SetHeadersInboundPolicy=EO});var a_=g(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.SetHeadersOutboundPolicy=void 0;var s_=D(),wO=o(async(t,e,r,n,i)=>{let s=n.headers;if(!s||!Array.isArray(s)||s.length==0)throw new s_.ConfigurationError(`SetHeadersOutboundPolicy '${i}' options.headers must be a valid array of { name, value }`);let a=new Headers(t.headers);return s.forEach(u=>{if(!u.name||u.name.length===0)throw new s_.ConfigurationError(`SetHeadersOutboundPolicy '${i}' each option.headers[] entry must have a name property`);let l=u.overwrite===void 0?!0:u.overwrite;(!a.has(u.name)||l)&&a.set(u.name,u.value)}),new Response(t.body,{headers:a,status:t.status,statusText:t.statusText})},"SetHeadersOutboundPolicy");Ga.SetHeadersOutboundPolicy=wO});var u_=g(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.SetQueryParamsInboundPolicy=void 0;var vO=ke(),c_=D(),TO=o(async(t,e,r,n)=>{let i=r.params;if(!i||!Array.isArray(i)||i.length==0)throw new c_.ConfigurationError(`SetQueryParamsInboundPolicy '${n}' options.params must be a valid array of { name, value }`);let s=new URL(t.url);return i.forEach(c=>{if(!c.name||c.name.length===0)throw new c_.ConfigurationError(`SetQueryParamsInboundPolicy '${n}' each option.params[] entry must have a name property`);let u=c.overwrite===void 0?!0:c.overwrite;(!s.searchParams.has(c.name)||u)&&s.searchParams.set(c.name,c.value)}),new vO.ZuploRequest(s.toString(),t)},"SetQueryParamsInboundPolicy");Ba.SetQueryParamsInboundPolicy=TO});var l_=g(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.SetStatusOutboundPolicy=void 0;var SO=o(async(t,e,r,n,i)=>{if(!n.status||isNaN(n.status)||n.status<100||n.status>599)throw new Error(`Invalid SetStatusOutboundPolicy '${i}' - status must be a valid number between 100 and 599, not '${n.status}'`);return new Response(t.body,{headers:t.headers,status:n.status,statusText:n.statusText??t.statusText})},"SetStatusOutboundPolicy");Ka.SetStatusOutboundPolicy=SO});var d_=g(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.SleepInboundPolicy=void 0;var IO=D(),AO=o(async t=>new Promise((r,n)=>{setTimeout(r,t)}),"sleep"),PO=o(async(t,e,r,n)=>{if(!r||r.sleepInMs===void 0||isNaN(r.sleepInMs))throw new IO.ConfigurationError(`SleepInboundPolicy '${n} must have a valid options.sleepInMs value`);return await AO(r.sleepInMs),t},"SleepInboundPolicy");Ja.SleepInboundPolicy=PO});var h_=g(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.SupabaseJwtInboundPolicy=void 0;var RO=ke(),p_=D(),OO=ve(),xO=dr(),NO=lr(),CO=o(async(t,e,r,n)=>{(0,xO.optionValidator)(r,n).required("secret","string").optional("allowUnauthenticatedRequests","boolean").optional("requiredClaims","object");let i={secret:r.secret,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests??!1},s=await(0,NO.OpenIdJwtInboundPolicy)(t,e,i,n);if(s instanceof Response)return s;if(!(s instanceof RO.ZuploRequest))throw new p_.SystemError("Invalid State - SupabaseJwtInboundPolicy encountered a non-response that wasn't a ZuploRequest type')");let a=r.requiredClaims;if(!a)return s;let c=t.user?.data.app_metadata;if(!c)throw new p_.RuntimeError(`SupabaseJwtInboundPolicy policy '${n}' - has requiredClaims but the JWT token had no app_metadata property`);let u=Object.keys(a),l=[];return u.forEach(d=>{let p=a[d];Array.isArray(p)?p.includes(c[d])||l.push(d):p!==c[d]&&l.push(d)}),l.length>0?OO.HttpProblems.unauthorized(t,e,{detail:`Invalid JWT token - missing valid claims ${l.join(", ")}`}):s},"SupabaseJwtInboundPolicy");za.SupabaseJwtInboundPolicy=CO});var m_=g(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.UpstreamAzureAdServiceAuthInboundPolicy=void 0;var LO=ur(),DO=br(),f_=D(),UO=Ge(),MO=ms(),kO=dr(),FO=o(async(t,e,r,n)=>{(0,kO.optionValidator)(r,n).required("activeDirectoryTenantId","string").required("activeDirectoryClientId","string").required("activeDirectoryClientSecret","string").optional("tokenRetries","number").optional("expirationOffsetSeconds","number");let i=new DO.MemoryZoneReadThroughCache((0,LO.getPolicyCacheName)(n),{logger:UO.SystemLogMap.getLogger(e)}),s=await i.get(n);if(!s){let a=await HO(r,e);i.put(n,a.access_token,a.expires_in-(r.expirationOffsetSeconds??300)),s=a.access_token}return t.headers.set("Authorization",`Bearer ${s}`),t},"UpstreamAzureAdServiceAuthInboundPolicy");Wa.UpstreamAzureAdServiceAuthInboundPolicy=FO;async function HO(t,e){let r=new URLSearchParams({client_id:t.activeDirectoryClientId,scope:`${t.activeDirectoryClientId}/.default`,client_secret:t.activeDirectoryClientSecret,grant_type:"client_credentials"}),n=await(0,MO.fetchRetry)({retries:t.tokenRetries??3,retryDelayMs:10},`https://login.microsoftonline.com/${t.activeDirectoryTenantId}/oauth2/v2.0/token`,{headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST",body:r});if(n.status!==200){try{let s=await n.text();e.log.error("Could not get token from Azure AD",s)}catch{}throw new f_.RuntimeError("Could not get token from Azure AD")}let i=await n.json();if(i&&typeof i=="object"&&"access_token"in i&&typeof i.access_token=="string"&&"expires_in"in i&&typeof i.expires_in=="number")return{access_token:i.access_token,expires_in:i.expires_in};throw new f_.RuntimeError("Response returned from Azure AD is not in the expected format.")}o(HO,"getAccessToken")});var g_=g(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.UpstreamFirebaseAdminAuthInboundPolicy=void 0;var qO=ur(),$O=br(),jO=D(),VO=Ge(),Qd=an(),GO=dr(),y_="https://accounts.google.com/o/oauth2/token",Yd,BO=o(async(t,e,r,n)=>{(0,GO.optionValidator)(r,n).required("serviceAccountJson","string"),Yd||(Yd=await Qd.GcpServiceAccount.init(r.serviceAccountJson));let i={scope:["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/firebase.database","https://www.googleapis.com/auth/firebase.messaging","https://www.googleapis.com/auth/identitytoolkit","https://www.googleapis.com/auth/userinfo.email"].join(" ")},s=new $O.MemoryZoneReadThroughCache((0,qO.getPolicyCacheName)(n),{logger:VO.SystemLogMap.getLogger(e)}),a=await s.get(n);if(!a){let c=await(0,Qd.getTokenFromGcpServiceAccount)({serviceAccount:Yd,audience:y_,payload:i}),u=await(0,Qd.exchangeGgpJwtForIdToken)(y_,c,{retries:r.tokenRetries??3,retryDelayMs:10});if(!u.access_token)throw new jO.RuntimeError("Invalid OAuth response from Firebase");a=u.access_token,s.put(n,a,(u.expires_in??3600)-(r.expirationOffsetSeconds??300))}return t.headers.set("Authorization",`Bearer ${a}`),t},"UpstreamFirebaseAdminAuthInboundPolicy");Qa.UpstreamFirebaseAdminAuthInboundPolicy=BO});var __=g(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.sha256=void 0;async function KO(t){let e=new TextEncoder().encode(t),r=await crypto.subtle.digest({name:"SHA-256"},e);return[...new Uint8Array(r)].map(i=>i.toString(16).padStart(2,"0")).join("")}o(KO,"sha256");Ya.sha256=KO});var b_=g(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});Za.UpstreamFirebaseUserAuthInboundPolicy=void 0;var JO=ur(),zO=br(),Cn=D(),WO=Ge(),QO=__(),Zd=an(),YO=na(),ZO=dr(),XO="https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",e0=["acr","amr","at_hash","aud","auth_time","azp","cnf","c_hash","exp","iat","iss","jti","nbf","nonce"],Xd,t0=o(async(t,e,r,n)=>{if((0,ZO.optionValidator)(r,n).required("serviceAccountJson","string").required("webApiKey","string").optional("developerClaims","object").optional("userId","string").optional("userIdPropertyPath","string"),!r.userId&&!r.userIdPropertyPath)throw new Cn.ConfigurationError(`Either 'userId' or 'userIdPropertyPath' options must be set on policy '${n}'.`);let i={};if(typeof r.developerClaims<"u"){for(let d in r.developerClaims)if(Object.prototype.hasOwnProperty.call(r.developerClaims,d)){if(e0.indexOf(d)!==-1)throw new Cn.ConfigurationError(`Developer claim "${d}" is reserved and cannot be specified.`);i[d]=r.developerClaims[d]}}Xd||(Xd=await Zd.GcpServiceAccount.init(r.serviceAccountJson));let s=r.userId;if(!s&&!r.userIdPropertyPath){if(!t.user)throw new Cn.RuntimeError("Unable to set userId for upstream auth policy as request.user is 'undefined'. Do you have an authentication policy before this policy?.");s=t.user?.sub}else if(r.userIdPropertyPath){if(!t.user)throw new Cn.RuntimeError(`Unable to apply userIdPropertyPath '${r.userIdPropertyPath}' as request.user is 'undefined'. Do you have an authentication policy before this policy?`);s=(0,YO.getValueFromRequestUser)(t.user,r.userIdPropertyPath,"userIdPropertyPath")}if(!s)throw new Cn.RuntimeError(`Unable to determine user from for the policy ${n}`);let a=new zO.MemoryZoneReadThroughCache((0,JO.getPolicyCacheName)(n),{logger:WO.SystemLogMap.getLogger(e)}),c={uid:s,claims:i},u=await(0,QO.sha256)(JSON.stringify(c)),l=await a.get(u);if(!l){let d=await(0,Zd.getTokenFromGcpServiceAccount)({serviceAccount:Xd,audience:XO,payload:c}),p=`https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=${r.webApiKey}`,m=await(0,Zd.exchangeFirebaseJwtForIdToken)(p,d,{retries:r.tokenRetries??3,retryDelayMs:10});if(!m.idToken)throw new Cn.RuntimeError("Invalid token response from Firebase");l=m.idToken,a.put(u,l,(m.expiresIn?parseInt(m.expiresIn):3600)-(r.expirationOffsetSeconds??300))}return t.headers.set("Authorization",`Bearer ${l}`),t},"UpstreamFirebaseUserAuthInboundPolicy");Za.UpstreamFirebaseUserAuthInboundPolicy=t0});var w_=g(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.UpstreamGcpJwtInboundPolicy=void 0;var E_=an(),r0=dr(),ep,n0=o(async(t,e,r,n)=>{(0,r0.optionValidator)(r,n).required("audience","string").required("serviceAccountJson","string"),ep||(ep=await E_.GcpServiceAccount.init(r.serviceAccountJson));let i=await(0,E_.getTokenFromGcpServiceAccount)({serviceAccount:ep,audience:r.audience});return t.headers.set("Authorization",`Bearer ${i}`),t},"UpstreamGcpJwtInboundPolicy");Xa.UpstreamGcpJwtInboundPolicy=n0});var S_=g(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.UpstreamGcpServiceAuthInboundPolicy=void 0;var v_=ur(),i0=Jc(),o0=br(),s0=D(),tp=an(),a0=dr(),T_="https://www.googleapis.com/oauth2/v4/token",rp,c0=o(async(t,e,r,n)=>{(0,a0.optionValidator)(r,n).required("audience","string").required("serviceAccountJson","string").optional("tokenRetries","number").optional("expirationOffsetSeconds","number"),rp||(rp=await tp.GcpServiceAccount.init(r.serviceAccountJson));let i;r.useMemoryCacheOnly?i=new i0.MemoryCache((0,v_.getPolicyCacheName)(n)):i=new o0.MemoryZoneReadThroughCache((0,v_.getPolicyCacheName)(n),e);let s=await i.get(n);if(!s){let a=await(0,tp.getTokenFromGcpServiceAccount)({serviceAccount:rp,audience:T_,payload:{target_audience:`${r.audience}`}}),{id_token:c}=await(0,tp.exchangeGgpJwtForIdToken)(T_,a,{retries:r.tokenRetries??3,retryDelayMs:10});if(!c)throw new s0.RuntimeError("Invalid token response from GCP");s=c,i.put(n,s,3600-(r.expirationOffsetSeconds??300))}return t.headers.set("Authorization",`Bearer ${s}`),t},"UpstreamGcpServiceAuthInboundPolicy");ec.UpstreamGcpServiceAuthInboundPolicy=c0});var A_=g(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});tc.ValidateJsonSchemaInbound=void 0;var u0=D(),I_=ve(),l0=o(async(t,e,r)=>{let n=t.clone(),i;try{i=await n.json()}catch{return I_.HttpProblems.badRequest(t,e,{detail:"Invalid JSON body - expected well-formed JSON document"})}if(r.validator(i))return t;let{errors:a}=r.validator;if(!a)throw new u0.SystemError("Invalid state - validator error object is undefined even though validation failed.");let c=a.map(u=>u.instancePath===void 0||u.instancePath===""?"Body "+u.message:u.instancePath.replace("/","")+" "+u.message);return I_.HttpProblems.badRequest(t,e,{detail:"Incoming body did not pass schema validation",errors:c})},"ValidateJsonSchemaInbound");tc.ValidateJsonSchemaInbound=l0});var P_=g(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});pr.serialize=pr.ContentTypes=void 0;pr.ContentTypes={Json:"application/json",Form:"application/x-www-form-urlencoded"};function d0(t,e){if(t!==null)return e&&typeof t=="string"?t:typeof t=="object"&&e?.startsWith(pr.ContentTypes.Form)?new URLSearchParams(t).toString():typeof t=="object"&&e?.startsWith(pr.ContentTypes.Json)||!e?JSON.stringify(t):t}o(d0,"serialize");pr.serialize=d0});var R_=g(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.ServiceProviderImpl=void 0;var p0=D(),np=class t{static{o(this,"ServiceProviderImpl")}static#e;services=new Map;constructor(){}static getInstance(){return t.#e||(t.#e=new t),t.#e}setInstance(e){t.#e=e}addService(e,r){if(this.services.get(e))throw new p0.SystemError(`A service with the name ${e} already exists -- you cannot have duplicate services`);this.services.set(e,r)}getService(e){return this.services.get(e)}};rc.ServiceProviderImpl=np});var O_=g(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});var h0={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"};ip.default=h0});var ke=g(h=>{"use strict";var f0=h&&h.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),x_=h&&h.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&f0(e,t,r)},m0=h&&h.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(h,"__esModule",{value:!0});h.RemoveHeadersInboundPolicy=h.ReadmeMetricsInboundPolicy=h.RateLimitInboundPolicy=h.BasicRateLimitInboundPolicy=h.PropelAuthJwtInboundPolicy=h.OpenIdJwtInboundPolicy=h.OktaJwtInboundPolicy=h.setMoesifContext=h.MoesifInboundPolicy=h.MockApiInboundPolicy=h.JWTScopeValidationInboundPolicy=h.GeoFilterInboundPolicy=h.FormDataToJsonInboundPolicy=h.FirebaseJwtInboundPolicy=h.CompositeInboundPolicy=h.CognitoJwtInboundPolicy=h.ClearHeadersOutboundPolicy=h.ClearHeadersInboundPolicy=h.ChangeMethodInboundPolicy=h.CachingInboundPolicy=h.BasicAuthInboundPolicy=h.Auth0JwtInboundPolicy=h.ApiKeyInboundPolicy=h.ApiAuthKeyInboundPolicy=h.AmberfloMeteringPolicy=h.AmberfloMeteringInboundPolicy=h.ConfigurationError=h.AuditLogPlugin=h.AuditLogDataStaxProvider=h.HttpStatusCode=h.webSocketPipelineHandler=h.webSocketHandler=h.urlRewriteHandler=h.urlForwardHandler=h.redirectHandler=h.openApiSpecHandler=h.awsLambdaHandler=h.AwsLambdaHandlerExtensions=h.SystemLogMap=h.purgeGatewayCache=h.Handler=h.originalFetch=h.isZuploReadableEnvVariableName=h.isRestrictedEnvVariableName=h.environment=h.ResponseSentEvent=h.ResponseSendingEvent=h.VALID_COMPATIBILITY_DATES=h.ZoneCache=h.MemoryZoneReadThroughCache=void 0;h.sanitizedIdentifierName=h.getRawOperationDataIdentifierName=h.getIdForRequestBodySchema=h.getIdForRefSchema=h.getIdForParameterSchema=h.httpStatuses=h.SYSTEM_LOGGER=h.API_KEY=h.ServiceProviderImpl=h.serialize=h.ContentTypes=h.Router=h.LookupResult=h.SystemRouteName=h.ZuploRequest=h.ProblemResponseFormatter=h.HttpProblems=h.ValidateJsonSchemaInbound=h.UpstreamGcpServiceAuthInboundPolicy=h.UpstreamGcpJwtInboundPolicy=h.UpstreamFirebaseUserAuthInboundPolicy=h.UpstreamFirebaseAdminAuthInboundPolicy=h.UpstreamAzureAdServiceAuthInboundPolicy=h.SupabaseJwtInboundPolicy=h.SleepInboundPolicy=h.SetStatusOutboundPolicy=h.SetQueryParamsInboundPolicy=h.SetHeadersOutboundPolicy=h.SetHeadersInboundPolicy=h.SetBodyInboundPolicy=h.RequireOriginInboundPolicy=h.SchemaBasedRequestValidation=h.RequestValidationInboundPolicy=h.RequestSizeLimitInboundPolicy=h.ReplaceStringOutboundPolicy=h.RemoveQueryParamsInboundPolicy=h.RemoveHeadersOutboundPolicy=void 0;Hp();var y0=br();Object.defineProperty(h,"MemoryZoneReadThroughCache",{enumerable:!0,get:function(){return y0.MemoryZoneReadThroughCache}});var g0=Qc();Object.defineProperty(h,"ZoneCache",{enumerable:!0,get:function(){return g0.ZoneCache}});var _0=$p();Object.defineProperty(h,"VALID_COMPATIBILITY_DATES",{enumerable:!0,get:function(){return _0.VALID_COMPATIBILITY_DATES}});var N_=vr();Object.defineProperty(h,"ResponseSendingEvent",{enumerable:!0,get:function(){return N_.ResponseSendingEvent}});Object.defineProperty(h,"ResponseSentEvent",{enumerable:!0,get:function(){return N_.ResponseSentEvent}});var op=ed();Object.defineProperty(h,"environment",{enumerable:!0,get:function(){return op.environment}});Object.defineProperty(h,"isRestrictedEnvVariableName",{enumerable:!0,get:function(){return op.isRestrictedEnvVariableName}});Object.defineProperty(h,"isZuploReadableEnvVariableName",{enumerable:!0,get:function(){return op.isZuploReadableEnvVariableName}});var b0=td();Object.defineProperty(h,"originalFetch",{enumerable:!0,get:function(){return b0.originalFetch}});var C_=uy();Object.defineProperty(h,"Handler",{enumerable:!0,get:function(){return C_.Handler}});Object.defineProperty(h,"purgeGatewayCache",{enumerable:!0,get:function(){return C_.purgeGatewayCache}});var E0=Ge();Object.defineProperty(h,"SystemLogMap",{enumerable:!0,get:function(){return E0.SystemLogMap}});var L_=Ay();Object.defineProperty(h,"AwsLambdaHandlerExtensions",{enumerable:!0,get:function(){return L_.AwsLambdaHandlerExtensions}});Object.defineProperty(h,"awsLambdaHandler",{enumerable:!0,get:function(){return L_.awsLambdaHandler}});var w0=Ry();Object.defineProperty(h,"openApiSpecHandler",{enumerable:!0,get:function(){return w0.openApiSpecHandler}});var v0=Oy();Object.defineProperty(h,"redirectHandler",{enumerable:!0,get:function(){return v0.redirectHandler}});var T0=Ny();Object.defineProperty(h,"urlForwardHandler",{enumerable:!0,get:function(){return T0.urlForwardHandler}});var S0=Ly();Object.defineProperty(h,"urlRewriteHandler",{enumerable:!0,get:function(){return S0.urlRewriteHandler}});var I0=Uy();Object.defineProperty(h,"webSocketHandler",{enumerable:!0,get:function(){return I0.webSocketHandler}});var A0=Hy();Object.defineProperty(h,"webSocketPipelineHandler",{enumerable:!0,get:function(){return A0.webSocketPipelineHandler}});var P0=mu();Object.defineProperty(h,"HttpStatusCode",{enumerable:!0,get:function(){return P0.HttpStatusCode}});x_(Jy(),h);x_(Qy(),h);var R0=Yy();Object.defineProperty(h,"AuditLogDataStaxProvider",{enumerable:!0,get:function(){return R0.AuditLogDataStaxProvider}});var O0=Xy();Object.defineProperty(h,"AuditLogPlugin",{enumerable:!0,get:function(){return O0.AuditLogPlugin}});var x0=D();Object.defineProperty(h,"ConfigurationError",{enumerable:!0,get:function(){return x0.ConfigurationError}});var D_=sg();Object.defineProperty(h,"AmberfloMeteringInboundPolicy",{enumerable:!0,get:function(){return D_.AmberfloMeteringInboundPolicy}});Object.defineProperty(h,"AmberfloMeteringPolicy",{enumerable:!0,get:function(){return D_.AmberfloMeteringPolicy}});var U_=lg();Object.defineProperty(h,"ApiAuthKeyInboundPolicy",{enumerable:!0,get:function(){return U_.ApiAuthKeyInboundPolicy}});Object.defineProperty(h,"ApiKeyInboundPolicy",{enumerable:!0,get:function(){return U_.ApiKeyInboundPolicy}});var N0=dg();Object.defineProperty(h,"Auth0JwtInboundPolicy",{enumerable:!0,get:function(){return N0.Auth0JwtInboundPolicy}});var C0=pg();Object.defineProperty(h,"BasicAuthInboundPolicy",{enumerable:!0,get:function(){return C0.BasicAuthInboundPolicy}});var L0=hg();Object.defineProperty(h,"CachingInboundPolicy",{enumerable:!0,get:function(){return L0.CachingInboundPolicy}});var D0=fg();Object.defineProperty(h,"ChangeMethodInboundPolicy",{enumerable:!0,get:function(){return D0.ChangeMethodInboundPolicy}});var U0=mg();Object.defineProperty(h,"ClearHeadersInboundPolicy",{enumerable:!0,get:function(){return U0.ClearHeadersInboundPolicy}});var M0=yg();Object.defineProperty(h,"ClearHeadersOutboundPolicy",{enumerable:!0,get:function(){return M0.ClearHeadersOutboundPolicy}});var k0=_g();Object.defineProperty(h,"CognitoJwtInboundPolicy",{enumerable:!0,get:function(){return k0.CognitoJwtInboundPolicy}});var F0=Eg();Object.defineProperty(h,"CompositeInboundPolicy",{enumerable:!0,get:function(){return F0.CompositeInboundPolicy}});var H0=wg();Object.defineProperty(h,"FirebaseJwtInboundPolicy",{enumerable:!0,get:function(){return H0.FirebaseJwtInboundPolicy}});var q0=vg();Object.defineProperty(h,"FormDataToJsonInboundPolicy",{enumerable:!0,get:function(){return q0.FormDataToJsonInboundPolicy}});var $0=Tg();Object.defineProperty(h,"GeoFilterInboundPolicy",{enumerable:!0,get:function(){return $0.GeoFilterInboundPolicy}});var j0=Sg();Object.defineProperty(h,"JWTScopeValidationInboundPolicy",{enumerable:!0,get:function(){return j0.JWTScopeValidationInboundPolicy}});var V0=Ag();Object.defineProperty(h,"MockApiInboundPolicy",{enumerable:!0,get:function(){return V0.MockApiInboundPolicy}});var M_=Ng();Object.defineProperty(h,"MoesifInboundPolicy",{enumerable:!0,get:function(){return M_.MoesifInboundPolicy}});Object.defineProperty(h,"setMoesifContext",{enumerable:!0,get:function(){return M_.setMoesifContext}});var G0=Cg();Object.defineProperty(h,"OktaJwtInboundPolicy",{enumerable:!0,get:function(){return G0.OktaJwtInboundPolicy}});var B0=lr();Object.defineProperty(h,"OpenIdJwtInboundPolicy",{enumerable:!0,get:function(){return B0.OpenIdJwtInboundPolicy}});var K0=Lg();Object.defineProperty(h,"PropelAuthJwtInboundPolicy",{enumerable:!0,get:function(){return K0.PropelAuthJwtInboundPolicy}});var k_=qg();Object.defineProperty(h,"BasicRateLimitInboundPolicy",{enumerable:!0,get:function(){return k_.RateLimitInboundPolicy}});Object.defineProperty(h,"RateLimitInboundPolicy",{enumerable:!0,get:function(){return k_.RateLimitInboundPolicy}});var J0=Gg();Object.defineProperty(h,"ReadmeMetricsInboundPolicy",{enumerable:!0,get:function(){return J0.ReadmeMetricsInboundPolicy}});var z0=Bg();Object.defineProperty(h,"RemoveHeadersInboundPolicy",{enumerable:!0,get:function(){return z0.RemoveHeadersInboundPolicy}});var W0=Kg();Object.defineProperty(h,"RemoveHeadersOutboundPolicy",{enumerable:!0,get:function(){return W0.RemoveHeadersOutboundPolicy}});var Q0=Jg();Object.defineProperty(h,"RemoveQueryParamsInboundPolicy",{enumerable:!0,get:function(){return Q0.RemoveQueryParamsInboundPolicy}});var Y0=zg();Object.defineProperty(h,"ReplaceStringOutboundPolicy",{enumerable:!0,get:function(){return Y0.ReplaceStringOutboundPolicy}});var Z0=Qg();Object.defineProperty(h,"RequestSizeLimitInboundPolicy",{enumerable:!0,get:function(){return Z0.RequestSizeLimitInboundPolicy}});var F_=Dr();Object.defineProperty(h,"RequestValidationInboundPolicy",{enumerable:!0,get:function(){return F_.RequestValidationInboundPolicy}});Object.defineProperty(h,"SchemaBasedRequestValidation",{enumerable:!0,get:function(){return F_.SchemaBasedRequestValidation}});var X0=r_();Object.defineProperty(h,"RequireOriginInboundPolicy",{enumerable:!0,get:function(){return X0.RequireOriginInboundPolicy}});var ex=n_();Object.defineProperty(h,"SetBodyInboundPolicy",{enumerable:!0,get:function(){return ex.SetBodyInboundPolicy}});var tx=o_();Object.defineProperty(h,"SetHeadersInboundPolicy",{enumerable:!0,get:function(){return tx.SetHeadersInboundPolicy}});var rx=a_();Object.defineProperty(h,"SetHeadersOutboundPolicy",{enumerable:!0,get:function(){return rx.SetHeadersOutboundPolicy}});var nx=u_();Object.defineProperty(h,"SetQueryParamsInboundPolicy",{enumerable:!0,get:function(){return nx.SetQueryParamsInboundPolicy}});var ix=l_();Object.defineProperty(h,"SetStatusOutboundPolicy",{enumerable:!0,get:function(){return ix.SetStatusOutboundPolicy}});var ox=d_();Object.defineProperty(h,"SleepInboundPolicy",{enumerable:!0,get:function(){return ox.SleepInboundPolicy}});var sx=h_();Object.defineProperty(h,"SupabaseJwtInboundPolicy",{enumerable:!0,get:function(){return sx.SupabaseJwtInboundPolicy}});var ax=m_();Object.defineProperty(h,"UpstreamAzureAdServiceAuthInboundPolicy",{enumerable:!0,get:function(){return ax.UpstreamAzureAdServiceAuthInboundPolicy}});var cx=g_();Object.defineProperty(h,"UpstreamFirebaseAdminAuthInboundPolicy",{enumerable:!0,get:function(){return cx.UpstreamFirebaseAdminAuthInboundPolicy}});var ux=b_();Object.defineProperty(h,"UpstreamFirebaseUserAuthInboundPolicy",{enumerable:!0,get:function(){return ux.UpstreamFirebaseUserAuthInboundPolicy}});var lx=w_();Object.defineProperty(h,"UpstreamGcpJwtInboundPolicy",{enumerable:!0,get:function(){return lx.UpstreamGcpJwtInboundPolicy}});var dx=S_();Object.defineProperty(h,"UpstreamGcpServiceAuthInboundPolicy",{enumerable:!0,get:function(){return dx.UpstreamGcpServiceAuthInboundPolicy}});var px=A_();Object.defineProperty(h,"ValidateJsonSchemaInbound",{enumerable:!0,get:function(){return px.ValidateJsonSchemaInbound}});var hx=ve();Object.defineProperty(h,"HttpProblems",{enumerable:!0,get:function(){return hx.HttpProblems}});var fx=oo();Object.defineProperty(h,"ProblemResponseFormatter",{enumerable:!0,get:function(){return fx.ProblemResponseFormatter}});var mx=Rs();Object.defineProperty(h,"ZuploRequest",{enumerable:!0,get:function(){return mx.ZuploRequest}});var yx=Ir();Object.defineProperty(h,"SystemRouteName",{enumerable:!0,get:function(){return yx.SystemRouteName}});var H_=Kl();Object.defineProperty(h,"LookupResult",{enumerable:!0,get:function(){return H_.LookupResult}});Object.defineProperty(h,"Router",{enumerable:!0,get:function(){return H_.Router}});var q_=P_();Object.defineProperty(h,"ContentTypes",{enumerable:!0,get:function(){return q_.ContentTypes}});Object.defineProperty(h,"serialize",{enumerable:!0,get:function(){return q_.serialize}});var gx=R_();Object.defineProperty(h,"ServiceProviderImpl",{enumerable:!0,get:function(){return gx.ServiceProviderImpl}});var $_=Su();Object.defineProperty(h,"API_KEY",{enumerable:!0,get:function(){return $_.API_KEY}});Object.defineProperty(h,"SYSTEM_LOGGER",{enumerable:!0,get:function(){return $_.SYSTEM_LOGGER}});var _x=O_();Object.defineProperty(h,"httpStatuses",{enumerable:!0,get:function(){return m0(_x).default}});var Pi=Da();Object.defineProperty(h,"getIdForParameterSchema",{enumerable:!0,get:function(){return Pi.getIdForParameterSchema}});Object.defineProperty(h,"getIdForRefSchema",{enumerable:!0,get:function(){return Pi.getIdForRefSchema}});Object.defineProperty(h,"getIdForRequestBodySchema",{enumerable:!0,get:function(){return Pi.getIdForRequestBodySchema}});Object.defineProperty(h,"getRawOperationDataIdentifierName",{enumerable:!0,get:function(){return Pi.getRawOperationDataIdentifierName}});Object.defineProperty(h,"sanitizedIdentifierName",{enumerable:!0,get:function(){return Pi.sanitizedIdentifierName}})});var j_=g(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.BaseCryptoBeta=Ln.supportedDigests=void 0;Ln.supportedDigests=["sha-1","sha-256","sha-384","sha-512"];var sp=class{static{o(this,"BaseCryptoBeta")}};Ln.BaseCryptoBeta=sp});var V_=g(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.WorkerCryptoBeta=void 0;var ap=j_(),bx=D(),cp=class extends ap.BaseCryptoBeta{static{o(this,"WorkerCryptoBeta")}async digest(e,r){if(!ap.supportedDigests.includes(e.toLowerCase()))throw new bx.RuntimeError(`Algorithm ${e} is not supported. Try using ${ap.supportedDigests.join(", ")}`);let n=new TextEncoder().encode(r),i=await crypto.subtle.digest(e,n);return Array.from(new Uint8Array(i)).map(c=>c.toString(16).padStart(2,"0")).join("")}};nc.WorkerCryptoBeta=cp});var G_=g(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.BaseKeyValueStore=void 0;var up=class{static{o(this,"BaseKeyValueStore")}context;constructor(e){this.context=e}};ic.BaseKeyValueStore=up});var K_=g(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.WorkerKeyValueStore=void 0;var B_=D(),Ex=G_(),lp=class extends Ex.BaseKeyValueStore{static{o(this,"WorkerKeyValueStore")}#e;constructor(e){super(e);let n=globalThis.ZUPLO_KV;if(!n)throw new B_.FeatureNotEnabledError("The Key Value Store feature is not enabled for this project.");this.#e=n}put(e,r,n){if(typeof e!="string")throw new B_.ConfigurationError("value must be of type string");return this.#e.put(e,r,n?{expirationTtl:n.expirationSecondsTtl}:void 0)}get(e,r){return this.#e.get(e,{type:"text",cacheTtl:r?.cacheSecondsTtl})}delete(e){return this.#e.delete(e)}};oc.WorkerKeyValueStore=lp});var Nt=g(ct=>{"use strict";var wx=ct&&ct.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),vx=ct&&ct.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&wx(e,t,r)};Object.defineProperty(ct,"__esModule",{value:!0});ct.KeyValueStore=ct.CryptoBeta=void 0;vx(ke(),ct);var Tx=V_();Object.defineProperty(ct,"CryptoBeta",{enumerable:!0,get:function(){return Tx.WorkerCryptoBeta}});var Sx=K_();Object.defineProperty(ct,"KeyValueStore",{enumerable:!0,get:function(){return Sx.WorkerKeyValueStore}})});var NN={};Gi(NN,{GraphQLComplexityLimitInboundPolicy:()=>Sb,GraphQLDisableIntrospectionInboundPolicy:()=>Ab});module.exports=Bi(NN);var Bn=Up(Nt());function B(t,e){if(!!!t)throw new Error(e)}o(B,"devAssert");function be(t){return typeof t=="object"&&t!==null}o(be,"isObjectLike");function It(t,e){if(!!!t)throw new Error(e??"Unexpected invariant triggered.")}o(It,"invariant");var Ix=/\r\n|[\n\r]/g;function Dn(t,e){let r=0,n=1;for(let i of t.body.matchAll(Ix)){if(typeof i.index=="number"||It(!1),i.index>=e)break;r=i.index+i[0].length,n+=1}return{line:n,column:e+1-r}}o(Dn,"getLocation");function dp(t){return sc(t.source,Dn(t.source,t.start))}o(dp,"printLocation");function sc(t,e){let r=t.locationOffset.column-1,n="".padStart(r)+t.body,i=e.line-1,s=t.locationOffset.line-1,a=e.line+s,c=e.line===1?r:0,u=e.column+c,l=`${t.name}:${a}:${u}
66
66
  `,d=n.split(/\r\n|[\n\r]/g),p=d[i];if(p.length>120){let m=Math.floor(u/80),f=u%80,y=[];for(let v=0;v<p.length;v+=80)y.push(p.slice(v,v+80));return l+J_([[`${a} |`,y[0]],...y.slice(1,m+1).map(v=>["|",v]),["|","^".padStart(f)],["|",y[m+1]]])}return l+J_([[`${a-1} |`,d[i-1]],[`${a} |`,p],["|","^".padStart(u)],[`${a+1} |`,d[i+1]]])}o(sc,"printSourceLocation");function J_(t){let e=t.filter(([n,i])=>i!==void 0),r=Math.max(...e.map(([n])=>n.length));return e.map(([n,i])=>n.padStart(r)+(i?" "+i:"")).join(`
67
67
  `)}o(J_,"printPrefixedLines");function Ax(t){let e=t[0];return e==null||"kind"in e||"length"in e?{nodes:e,source:t[1],positions:t[2],path:t[3],originalError:t[4],extensions:t[5]}:e}o(Ax,"toNormalizedOptions");var C=class t extends Error{static{o(this,"GraphQLError")}constructor(e,...r){var n,i,s;let{nodes:a,source:c,positions:u,path:l,originalError:d,extensions:p}=Ax(r);super(e),this.name="GraphQLError",this.path=l??void 0,this.originalError=d??void 0,this.nodes=z_(Array.isArray(a)?a:a?[a]:void 0);let m=z_((n=this.nodes)===null||n===void 0?void 0:n.map(y=>y.loc).filter(y=>y!=null));this.source=c??(m==null||(i=m[0])===null||i===void 0?void 0:i.source),this.positions=u??m?.map(y=>y.start),this.locations=u&&c?u.map(y=>Dn(c,y)):m?.map(y=>Dn(y.source,y.start));let f=be(d?.extensions)?d?.extensions:void 0;this.extensions=(s=p??f)!==null&&s!==void 0?s:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),d!=null&&d.stack?Object.defineProperty(this,"stack",{value:d.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(let r of this.nodes)r.loc&&(e+=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/graphql",
3
- "version": "5.1465.0",
3
+ "version": "5.1467.0",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "exports": {