@zuplo/core 6.69.11 → 6.70.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.
@@ -596,7 +596,7 @@ globstar while`,s,de,o,ae,Ye),this.matchOne(s.slice(de),o.slice(ae),f))return th
596
596
  };
597
597
  }
598
598
  export default routes;
599
- `),dcr=["2023-03-14","2024-01-15","2024-03-14","2024-09-02"];function clt(s){return!s||dcr.includes(s)}t(clt,"isLegacyPathBehavior");async function t4e(s){try{let{content:o,warnings:f}=await mcr(s);return{content:o,errors:[],warnings:f}}catch(o){if(o instanceof A1)return o.toBuildResult();throw o}}t(t4e,"compileRoutes");async function mcr({sourceDirectory:s,policiesContent:o,oasContent:f,compatibilityDate:d,allowDuplicateRoutes:y}){let E=[],P=[],F=new tle,J=new HV,{policiesNode:G,policiesData:Te}=ycr(o),{generatedPolicies:de,policyNames:ae}=vcr(F,J,G,Te),{generatedCorsPolicies:Ye,corsPoliciesNames:Ue}=bcr(F,J,G,Te),je=Scr(s,f),Kt=[],Ut=new Map;for(let Pn of je){let{node:wr,oas:Sr,oasProjectRelativePath:us}=Pn,Fi=FAe(wr,["paths"]);if(!Fi)continue;let cc=sle.basename(Sr.fileName,".oas.json");for(let bi of Fi.children??[])if(bi.children){let Qf=wcr(bi),S_=Qf[nlt]?.pathMode;if(S_){if(S_!==nle&&S_!==e4e)throw new A1({text:`Unknown path mode ${S_}`,location:{line:0,column:0,file:us}})}else S_=nle;for(let[Rn,BE]of Object.entries(Qf)){if(!ile(Rn))continue;let Fl=Rn,Ar=Fl.split(/,/).map(Hs=>Hs.trim().toUpperCase()),DT=BE,bc=DT[rle];if(bc){let Oh=new Qce().validate(bc);if(Oh.isValid){let k0=ilt(bi);if(!Ut.has(k0)&&(Ut.set(k0,new Set),clt(d)))try{new URLPattern({pathname:k0})}catch{P.push({text:`Path '${k0}' contains invalid characters. The value must be a valid URLPattern.`,location:{line:bi.line,column:bi.column,file:us}})}if(!y){let w0=Ut.get(k0);Ar.forEach(PT=>{w0.has(PT)?P.push({text:`Cannot have duplicate routes declared. Route '${PT.toUpperCase()} ${k0}' declared more than once.`,location:{line:bi.line,column:bi.column,file:us}}):w0.add(PT)})}let v7=slt(bi,[k0,Fl,rle]),nw=await Pcr(v7,Sr);if(!nw.valid)throw new A1({text:nw.errorMsg??`Unknown error on handler for path '${k0}'`,location:{line:nw.line??0,column:nw.column??0,file:us}});let Wi=Ncr(v7,Sr);if(!Wi.valid)throw new A1(Wi.errors);Wi.warnings&&E.push(...Wi.warnings),Kt.push({path:k0,pathPattern:k0,pathMode:S_,httpMethods:Ar,rawOperation:Fl,rawOpenAPI:DT,oasFileName:cc,oasProjectRelativePath:us,config:slt(bi,[k0,Fl,rle])})}else throw new A1({text:JSON.stringify(Oh.errors),location:{line:0,column:0,file:us}})}else{let Hs=ilt(bi),Oh={corsPolicy:"none",handler:Dcr(Hs,wr)};Kt.push({path:Hs,pathPattern:Hs,pathMode:nle,rawOpenAPI:DT,oasFileName:cc,oasProjectRelativePath:us,httpMethods:Ar,rawOperation:Fl,config:WV(JSON.stringify(Oh))})}if(bc&&"policies"in bc){let Hs=bc.policies;Hs.inbound?.forEach(Oh=>{ae.includes(Oh)||P.push({text:`Policy '${Oh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})}),Hs.outbound?.forEach(Oh=>{ae.includes(Oh)||P.push({text:`Policy '${Oh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})})}if(P.length>0)throw new A1(P);let Qp=["none","anything-goes"];if(bc&&"corsPolicy"in bc){let Hs=bc.corsPolicy;if(Qp.includes(Hs))continue;Ue.includes(Hs)||P.push({text:`Cors policy '${Hs}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})}}}if(P.length>0)throw new A1(P)}let kr=[];for(let Pn of Kt){let wr=new VV().convert(Pn.config);Tcr(wr,Pn),xcr(wr,Pn,d),Ecr(wr,Pn),Ccr(wr,Pn),kcr(wr,Pn);let Sr=F.transform(wr),us=F.errors;if(us.length>0)throw new A1({text:JSON.stringify(us),location:{line:0,column:0,file:Pn.oasProjectRelativePath}});let cc=new HV().generate(Sr);kr.push(cc)}if(qP(je.length===f.length,"Tree length should match OAS file length"),qP(Kt.length===kr.length,`The number of validated nodes should match the number of generated fragments. There were ${Kt.length} validated nodes and ${kr.length} generated fragments.`),P.length>0)throw new A1(P);let An={routes:kr,imports:F.getImports(),policies:de,corsPolicies:Ye};return{content:pcr(An),warnings:E}}t(mcr,"generateSourceCode");var hcr=0,gcr=1;function ycr(s){let o=new Zce,f=JSON.parse(s.content),d=o.validate(f);if(!d.isValid)throw new A1({text:JSON.stringify(d.errors),location:{line:0,column:0,file:"/config/policies.json"}});let y=new VV().parse(JSON.stringify(f));return{policiesData:f,policiesNode:y}}t(ycr,"getPolicyData");function vcr(s,o,f,d){let y=[],E;e4(f);let P=f.children.find(F=>F.name.value==="policies");if(P){let F=s.transform(P);E=o.generate(F),y=d.policies.map(({name:J})=>J)}else E="policies: []";return{generatedPolicies:E,policyNames:y}}t(vcr,"generatePolicies");function bcr(s,o,f,d){let y,E;e4(f);let P=f.children.find(F=>F.name.value==="corsPolicies");if(P){let F=s.transform(P);E=o.generate(F),y=d.corsPolicies.map(({name:J})=>J)}else E="corsPolicies: []",y=[];return{generatedCorsPolicies:E,corsPoliciesNames:y}}t(bcr,"generateCorsPolicies");function Scr(s,o){let f=[];for(let d of o){let y=[],E=WV(d.content,y),P=`./${sle.posix.relative(s.replace(/\\/g,"/"),d.fileName.replace(/\\/g,"/"))}`;if(y.length>0)throw new A1(y.map(F=>({text:zst(F.error),location:{file:P,line:F.line,column:F.column}})));if(!E)throw new A1({text:"Error parsing the OpenAPI file. Check the contents of the file.",location:{file:P,line:0,column:0}});f.push({node:E,oas:d,oasProjectRelativePath:P})}return f}t(Scr,"getOasTrees");function Tcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"path",type:Wo.Identifier,parent:f},f.value=wS.createLiteral(o.path,f),e4(s),s.children.unshift(f)}t(Tcr,"embellishWithPath");function xcr(s,o,f){let d={type:Wo.Property,parent:s,name:null,value:null};if(d.name={value:"pathPattern",type:Wo.Identifier,parent:d},o.pathMode===e4e)d.value=wS.createLiteral(o.path,d);else{let y=/{(\S+?)}/gm,E=":$1",P=clt(f)?o.path:o.path.replace(/([*+?()[\].|^$\\:])/g,"\\$1");P=P.replace(y,E),o.path.endsWith("/")||(P=`${P}{/}?`),d.value=wS.createLiteral(P,d)}e4(s),s.children.unshift(d)}t(xcr,"embellishWithPathPattern");function Ecr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"methods",type:Wo.Identifier,parent:f},f.value=wS.createArrayOfLiterals(o.httpMethods,f),e4(s),s.children.unshift(f)}t(Ecr,"embellishWithMethods");function Ccr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"raw",type:Wo.Identifier,parent:s};let d=PV(o.oasFileName,o.path,o.rawOperation);f.value={type:Wo.Raw,parent:f,value:`() => {return rawRouteData.${d};}`},e4(s),s.children.unshift(f)}t(Ccr,"embellishWithRawOpenApi");function kcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"metadata",type:Wo.Identifier,parent:s};let d={type:Wo.Property,parent:f,name:null,value:null};d.name={value:"filepath",type:Wo.Identifier,parent:d},d.value=wS.createLiteral(o.oasProjectRelativePath,d),f.value={type:Wo.Object,parent:f,children:[d]},e4(s),s.children.unshift(f)}t(kcr,"embellishWithMetadata");function wcr(s){return qP(s.type==="property"),qP(Array.isArray(s.children)),qV(s.children[gcr])}t(wcr,"evaluatePathItem");function ilt(s){return qP(s.type==="property"),qP(Array.isArray(s.children)),qV(s.children[hcr])}t(ilt,"evaluatePath");function slt(s,o){return FAe(s.parent,o)}t(slt,"extractZuploRouteNode");function llt(s){return qV(s)}t(llt,"evaluateZuploRouteNode");function Dcr(s,o){let f=/{(\S+?)}/gm,y=s.replace(f,"${params.$1}"),E=qV(o);return{export:"urlRewriteHandler",module:"$import(@zuplo/runtime)",options:{rewritePattern:`${E.servers&&E.servers.length>0?E.servers[0].url:"http://example.com"}${y}`,forwardSearch:!0}}}t(Dcr,"addDefaultUrlRewriteHandler");async function Pcr(s,o){let f=llt(s),d=f.handler.module.replace(/^\$import\(/,"").replace(/\)$/,""),y=sle.join(sle.dirname(o.fileName),"..",`${d}.ts`),E=f.handler.export;if(d==="@zuplo/runtime")return{valid:!0};if(await tu.fileExists(y)){let P=await $st(y);if(P===null)return{valid:!1,errorMsg:`Could not find any export due to a compile error in '${tu.getParentDirFilename(y)}'`};if(!P.has(E)){let F=`Could not find export "${E}" in '${tu.getParentDirFilename(y)}'`,J=0,G=0;if(s.children)for(let Te of s.children)Te.children&&Te.children.forEach(de=>{de.value==="handler"&&(J=de.line,G=de.column)});return{valid:!1,errorMsg:F,line:J,column:G}}return{valid:!0}}else return{valid:!1,errorMsg:`Could not find module '${d}'`}}t(Pcr,"checkModuleIsValid");var alt=t((s,o)=>{let f=0,d=0;if(s.children)for(let y of s.children)y.children&&y.children.forEach(E=>{E.value==="options"&&E.children?.forEach(P=>{E.value===o&&(f=P.line,d=P.column)})});return{line:f,column:d}},"getHandlerOptionLocation"),Acr="$env(";function Ncr(s,o){let f=llt(s),d=f.handler.export;if(d!=="urlForwardHandler"&&d!=="urlRewriteHandler")return{valid:!0};let y="rewritePattern";d==="urlForwardHandler"&&(y="baseUrl");let E=f.handler.options[y];if(!E){let P=alt(s,y);return{valid:!1,errors:[{text:`Invalid request handler configuration. handler.options.${y} is required but was not provided.`,location:{file:o.fileName,line:P.line,column:P.column}}]}}if(E.includes(Acr)){let P=alt(s,y);return{valid:!0,warnings:[{text:`Invalid environment variable access syntax detected. Use \${env.VAR_NAME} instead of $env(VAR_NAME) for handler.options.${y}.`,location:{file:o.fileName,line:P.line,column:P.column}}]}}return{valid:!0}}t(Ncr,"checkHandlerIsValid");var JH=Vp(hIe(),1);import{readFile as mpr}from"node:fs/promises";var vT=Vp(hIe(),1);var BO=class extends Error{static{t(this,"CustomResolveError")}},g4=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(o,f){this.sourceDirectory=o,this.logger=f}dereference(o,f){return JH.$RefParser.dereference(o,{resolve:{json:!0,file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:f?.onDereference}})}bundle(o){return JH.$RefParser.bundle(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(o){return JH.$RefParser.parse(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(o){return JH.$RefParser.resolve(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Ile(s,o){return{order:100,canRead(f){let d=ypr(f.url);if(!(d===void 0||d==="file"))return!1;let E;try{E=Lft(f.url)}catch(P){throw new BO(`Malformed URI: ${f.url}`,{cause:P})}try{tu.safePath(s).resolve(E)}catch(P){return o?.warn(P),!1}return!0},async read(f){let d;try{d=Lft(f.url)}catch(y){throw new BO(`Malformed URI: ${f.url}`,{cause:y})}try{return await mpr(d)}catch(y){throw new BO(`Error opening file "${d}"`,{cause:y})}}}}t(Ile,"customResolver");var FM=/^win/.test(globalThis.process?globalThis.process.platform:""),hpr=/\//g,gpr=/^(\w{2,}):\/\//i,gIe=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function ypr(s){let o=gpr.exec(s);if(o)return o[1].toLowerCase()}t(ypr,"getProtocol");function Lft(s,o){s=decodeURI(s);for(let d=0;d<gIe.length;d+=2)s=s.replace(gIe[d],gIe[d+1]);let f=s.substr(0,7).toLowerCase()==="file://";if(f&&(s=s[7]==="/"?s.substr(8):s.substr(7),FM&&s[1]==="/"&&(s=`${s[0]}:${s.substr(1)}`),o?s=`file:///${s}`:(f=!1,s=FM?s:`/${s}`)),!f){let d=s.split(FM?"\\":"/"),y=[];for(let E of d)E===".."?y.length&&y[y.length-1]!==""&&y.pop():(E!==""||y.length===0)&&y.push(E);s=y.join(FM?"\\":"/"),!FM&&y[0]===""&&(s=`/${s.substring(1)}`)}return FM&&!f&&(s=s.replace(hpr,"\\"),s.substr(1,2)===":\\"&&(s=s[0].toUpperCase()+s.substr(1))),s}t(Lft,"toFileSystemPath");var Rft="YOUR_KEY_HERE";async function Mft(s){let f=await new g4(s.sourceDirectory,s.logger).bundle(s.openApiDocPath),d=s.openApiDocPath.replace(s.sourceDirectory,"");return vpr({...s,relativeOpenApiPath:d},f)}t(Mft,"buildPublicOpenApiFile");async function vpr(s,o){xpr({relativeOpenApiPath:s.relativeOpenApiPath},o);let f=o;return f=Spr(f),bpr(f,s.urls?.api?.defaultUrl),f=Tpr(f,s),jft(f,"x-zuplo"),f}t(vpr,"buildRawOpenApiFile");function bpr(s,o){o?s.servers=[{url:o}]:s.servers=[]}t(bpr,"addServerHost");function Spr(s){if(!s.paths)return s;let{components:o}=s,f=o?{...o}:void 0,d=[];f&&f.parameters&&(d=Object.entries(f.parameters).reduce((E,[P,F])=>(M9 in F&&Qae(F[M9])&&(E.push(P),f.parameters&&delete f.parameters[P]),E),[]));let y=Object.entries(s.paths).reduce((E,[P,F])=>{if(!F)return E;let J={...F},G=["delete","get","head","patch","post","put","trace","options"];return G.forEach(Te=>{let de=F[Te];if(!de)return;if(Qae(de[M9])){delete J[Te];return}let{parameters:ae}=de;if(!ae)return;let Ye=ae.filter(Ue=>{if(M9 in Ue&&Qae(Ue[M9]))return!1;if("$ref"in Ue){let je=Ue.$ref.split("/").pop();return je?!d.includes(je):!0}return!0});J[Te]={...de,parameters:Ye}}),G.some(Te=>!!J[Te])&&(E[P]=J),E},{});return{...s,paths:y,components:f}}t(Spr,"removeHiddenRoutesAndParams");function Tpr(s,{policiesConfig:o}){if(!s.paths)return s;let f=Object.entries(s.paths).reduce((d,[y,E])=>{if(!E)return d;let P={...E};return[P.delete,P.get,P.head,P.patch,P.post,P.put,P.trace,P.options].forEach(F=>{if(!F)return;let J=F["x-zuplo-route"]?.policies?.inbound?.reduce((de,ae)=>{let Ye=o.policies?.find(({name:Kt})=>Kt===ae);if(!Ye)return de;if(!(Ye.handler.export==="CompositeInboundPolicy"))return de.concat(ae);let je=Ye.handler.options?.policies;return je?de.concat(je):de},[]),G=[];if(J&&J.forEach(de=>{o.policies?.forEach(ae=>{ae.name===de&&(ae.handler.export==="ApiAuthKeyInboundPolicy"||ae.handler.export==="ApiKeyInboundPolicy")&&!ae.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&G.push(ae)})}),G.length>0){let de=G.length>0&&G[0].handler&&G[0].handler.options&&G[0].handler.options.authHeader?G[0].handler.options.authHeader:"Authorization",ae=G.length>0&&G[0].handler&&G[0].handler.options&&(G[0].handler.options.authScheme||G[0].handler.options.authScheme==="")?G[0].handler.options.authScheme:"Bearer",Ye=ae!==""?`${ae} ${Rft}`:Rft,Ue={name:de,in:"header",required:!0,example:Ye,schema:{type:"string"},description:`The \`${de}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ye}\`.`};F.parameters?F.parameters.some(kr=>"name"in kr&&kr.name===Ue.name)||F.parameters.unshift(Ue):F.parameters=[Ue];let je={type:"http",scheme:ae.toLowerCase()},Kt="api_key";s.components?.securitySchemes?Object.values(s.components?.securitySchemes).some(kr=>"name"in kr&&kr.type==="apiKey"||"type"in kr&&kr.type==="http"&&kr.scheme===ae)||(s.components.securitySchemes={...s.components.securitySchemes,[Kt]:je}):(s.components||(s.components={}),s.components.securitySchemes={[Kt]:je});let Ut={[Kt]:[]};F.security?F.security.some(kr=>kr[Kt]!==void 0)||F.security.unshift(Ut):F.security=[Ut]}let Te=[];if(J&&J.forEach(de=>{o.policies?.forEach(ae=>{ae.name===de&&(ae.handler.export==="RateLimitInboundPolicy"||ae.handler.export==="ComplexRateLimitInboundPolicy")&&Te.push(ae)})}),Te.length>0){let de={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},ae={...de,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};s.components?.responses||s.components||(s.components={}),s.components.responses={...s.components.responses,RateLimitNoRetryAfter:de,RateLimitWithRetryAfter:ae},F.responses||(F.responses={});let Ye=Te.some(Ue=>Ue.handler.options?.headerMode!=="none");F.responses[429]||(F.responses[429]={$ref:Ye?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),d[y]=P,d},{});return{...s,paths:f}}t(Tpr,"enrichSpecWithZuploData");function jft(s,o){for(let f in s)f.startsWith(o)?delete s[f]:typeof s[f]=="object"&&jft(s[f],o)}t(jft,"removePropertiesByPrefix");function xpr({relativeOpenApiPath:s},o){if(!o||typeof o!="object")throw new C1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in o)||typeof o.info!="object"||!o.info)throw new C1({message:"The OpenAPI document does not have the required 'info' property.",location:{file:s,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in o.info)||typeof o.info.title!="string")throw new C1({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:s,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(xpr,"assertIsZuploOpenApiSpec");import Apr from"node:fs/promises";import Npr from"node:path";var{stringify:Epr}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");var Ole={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},OE=17,Cpr={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:OE,ClassExpression:OE,FunctionExpression:OE,ObjectExpression:OE,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function LM(s,o){let{generator:f}=s;if(s.write("("),o!=null&&o.length>0){f[o[0].type](o[0],s);let{length:d}=o;for(let y=1;y<d;y++){let E=o[y];s.write(", "),f[E.type](E,s)}}s.write(")")}t(LM,"formatSequence");function qft(s,o,f,d){let y=s.expressionsPrecedence[o.type];if(y===OE)return!0;let E=s.expressionsPrecedence[f.type];return y!==E?!d&&y===15&&E===14&&f.operator==="**"||y<E:y!==13&&y!==14?!1:o.operator==="**"&&f.operator==="**"?!d:y===13&&E===13&&(o.operator==="??"||f.operator==="??")?!0:d?Ole[o.operator]<=Ole[f.operator]:Ole[o.operator]<Ole[f.operator]}t(qft,"expressionNeedsParenthesis");function Fle(s,o,f,d){let{generator:y}=s;qft(s,o,f,d)?(s.write("("),y[o.type](o,s),s.write(")")):y[o.type](o,s)}t(Fle,"formatExpression");function kpr(s,o,f,d){let y=o.split(`
599
+ `),dcr=["2023-03-14","2024-01-15","2024-03-14","2024-09-02"];function clt(s){return!s||dcr.includes(s)}t(clt,"isLegacyPathBehavior");async function t4e(s){try{let{content:o,warnings:f}=await mcr(s);return{content:o,errors:[],warnings:f}}catch(o){if(o instanceof A1)return o.toBuildResult();throw o}}t(t4e,"compileRoutes");async function mcr({sourceDirectory:s,policiesContent:o,oasContent:f,compatibilityDate:d,allowDuplicateRoutes:y}){let E=[],P=[],F=new tle,J=new HV,{policiesNode:G,policiesData:Te}=ycr(o),{generatedPolicies:de,policyNames:ae}=vcr(F,J,G,Te),{generatedCorsPolicies:Ye,corsPoliciesNames:Ue}=bcr(F,J,G,Te),je=Scr(s,f),Kt=[],Ut=new Map;for(let Pn of je){let{node:wr,oas:Sr,oasProjectRelativePath:us}=Pn,Fi=FAe(wr,["paths"]);if(!Fi)continue;let cc=sle.basename(Sr.fileName,".oas.json");for(let bi of Fi.children??[])if(bi.children){let Qf=wcr(bi),S_=Qf[nlt]?.pathMode;if(S_){if(S_!==nle&&S_!==e4e)throw new A1({text:`Unknown path mode ${S_}`,location:{line:0,column:0,file:us}})}else S_=nle;for(let[Rn,BE]of Object.entries(Qf)){if(!ile(Rn))continue;let Fl=Rn,Ar=Fl.split(/,/).map(Hs=>Hs.trim().toUpperCase()),DT=BE,bc=DT[rle];if(bc){let Oh=new Qce().validate(bc);if(Oh.isValid){let k0=ilt(bi);if(!Ut.has(k0)&&(Ut.set(k0,new Set),clt(d)))try{new URLPattern({pathname:k0})}catch{P.push({text:`Path '${k0}' contains invalid characters. The value must be a valid URLPattern.`,location:{line:bi.line,column:bi.column,file:us}})}if(!y){let w0=Ut.get(k0);Ar.forEach(PT=>{w0.has(PT)?P.push({text:`Cannot have duplicate routes declared. Route '${PT.toUpperCase()} ${k0}' declared more than once.`,location:{line:bi.line,column:bi.column,file:us}}):w0.add(PT)})}let v7=slt(bi,[k0,Fl,rle]),nw=await Pcr(v7,Sr);if(!nw.valid)throw new A1({text:nw.errorMsg??`Unknown error on handler for path '${k0}'`,location:{line:nw.line??0,column:nw.column??0,file:us}});let Wi=Ncr(v7,Sr);if(!Wi.valid)throw new A1(Wi.errors);Wi.warnings&&E.push(...Wi.warnings),Kt.push({path:k0,pathPattern:k0,pathMode:S_,httpMethods:Ar,rawOperation:Fl,rawOpenAPI:DT,oasFileName:cc,oasProjectRelativePath:us,config:slt(bi,[k0,Fl,rle])})}else throw new A1({text:JSON.stringify(Oh.errors),location:{line:0,column:0,file:us}})}else{let Hs=ilt(bi),Oh={corsPolicy:"none",handler:Dcr(Hs,wr)};Kt.push({path:Hs,pathPattern:Hs,pathMode:nle,rawOpenAPI:DT,oasFileName:cc,oasProjectRelativePath:us,httpMethods:Ar,rawOperation:Fl,config:WV(JSON.stringify(Oh))})}if(bc&&"policies"in bc){let Hs=bc.policies;Hs.inbound?.forEach(Oh=>{ae.includes(Oh)||P.push({text:`Policy '${Oh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})}),Hs.outbound?.forEach(Oh=>{ae.includes(Oh)||P.push({text:`Policy '${Oh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})})}if(P.length>0)throw new A1(P);let Qp=["none","anything-goes"];if(bc&&"corsPolicy"in bc){let Hs=bc.corsPolicy;if(Qp.includes(Hs))continue;Ue.includes(Hs)||P.push({text:`Cors policy '${Hs}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})}}}if(P.length>0)throw new A1(P)}let kr=[];for(let Pn of Kt){let wr=new VV().convert(Pn.config);Tcr(wr,Pn),xcr(wr,Pn,d),Ecr(wr,Pn),Ccr(wr,Pn),kcr(wr,Pn);let Sr=F.transform(wr),us=F.errors;if(us.length>0)throw new A1({text:JSON.stringify(us),location:{line:0,column:0,file:Pn.oasProjectRelativePath}});let cc=new HV().generate(Sr);kr.push(cc)}if(qP(je.length===f.length,"Tree length should match OAS file length"),qP(Kt.length===kr.length,`The number of validated nodes should match the number of generated fragments. There were ${Kt.length} validated nodes and ${kr.length} generated fragments.`),P.length>0)throw new A1(P);let An={routes:kr,imports:F.getImports(),policies:de,corsPolicies:Ye};return{content:pcr(An),warnings:E}}t(mcr,"generateSourceCode");var hcr=0,gcr=1;function ycr(s){let o=new Zce,f=JSON.parse(s.content),d=o.validate(f);if(!d.isValid)throw new A1({text:JSON.stringify(d.errors),location:{line:0,column:0,file:"/config/policies.json"}});let y=new VV().parse(JSON.stringify(f));return{policiesData:f,policiesNode:y}}t(ycr,"getPolicyData");function vcr(s,o,f,d){let y=[],E;e4(f);let P=f.children.find(F=>F.name.value==="policies");if(P){let F=s.transform(P);E=o.generate(F),y=d.policies.map(({name:J})=>J)}else E="policies: []";return{generatedPolicies:E,policyNames:y}}t(vcr,"generatePolicies");function bcr(s,o,f,d){let y,E;e4(f);let P=f.children.find(F=>F.name.value==="corsPolicies");if(P){let F=s.transform(P);E=o.generate(F),y=d.corsPolicies.map(({name:J})=>J)}else E="corsPolicies: []",y=[];return{generatedCorsPolicies:E,corsPoliciesNames:y}}t(bcr,"generateCorsPolicies");function Scr(s,o){let f=[];for(let d of o){let y=[],E=WV(d.content,y),P=`./${sle.posix.relative(s.replace(/\\/g,"/"),d.fileName.replace(/\\/g,"/"))}`;if(y.length>0)throw new A1(y.map(F=>({text:zst(F.error),location:{file:P,line:F.line,column:F.column}})));if(!E)throw new A1({text:"Error parsing the OpenAPI file. Check the contents of the file.",location:{file:P,line:0,column:0}});f.push({node:E,oas:d,oasProjectRelativePath:P})}return f}t(Scr,"getOasTrees");function Tcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"path",type:Wo.Identifier,parent:f},f.value=wS.createLiteral(o.path,f),e4(s),s.children.unshift(f)}t(Tcr,"embellishWithPath");function xcr(s,o,f){let d={type:Wo.Property,parent:s,name:null,value:null};if(d.name={value:"pathPattern",type:Wo.Identifier,parent:d},o.pathMode===e4e)d.value=wS.createLiteral(o.path,d);else{let y=/{(\S+?)}/gm,E=":$1",P=clt(f)?o.path:o.path.replace(/([*+?()[\].|^$\\:])/g,"\\$1");P=P.replace(y,E),o.path.endsWith("/")||(P=`${P}{/}?`),d.value=wS.createLiteral(P,d)}e4(s),s.children.unshift(d)}t(xcr,"embellishWithPathPattern");function Ecr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"methods",type:Wo.Identifier,parent:f},f.value=wS.createArrayOfLiterals(o.httpMethods,f),e4(s),s.children.unshift(f)}t(Ecr,"embellishWithMethods");function Ccr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"raw",type:Wo.Identifier,parent:s};let d=PV(o.oasFileName,o.path,o.rawOperation);f.value={type:Wo.Raw,parent:f,value:`() => {return rawRouteData.${d};}`},e4(s),s.children.unshift(f)}t(Ccr,"embellishWithRawOpenApi");function kcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"metadata",type:Wo.Identifier,parent:s};let d={type:Wo.Property,parent:f,name:null,value:null};d.name={value:"filepath",type:Wo.Identifier,parent:d},d.value=wS.createLiteral(o.oasProjectRelativePath,d),f.value={type:Wo.Object,parent:f,children:[d]},e4(s),s.children.unshift(f)}t(kcr,"embellishWithMetadata");function wcr(s){return qP(s.type==="property"),qP(Array.isArray(s.children)),qV(s.children[gcr])}t(wcr,"evaluatePathItem");function ilt(s){return qP(s.type==="property"),qP(Array.isArray(s.children)),qV(s.children[hcr])}t(ilt,"evaluatePath");function slt(s,o){return FAe(s.parent,o)}t(slt,"extractZuploRouteNode");function llt(s){return qV(s)}t(llt,"evaluateZuploRouteNode");function Dcr(s,o){let f=/{(\S+?)}/gm,y=s.replace(f,"${params.$1}"),E=qV(o);return{export:"urlRewriteHandler",module:"$import(@zuplo/runtime)",options:{rewritePattern:`${E.servers&&E.servers.length>0?E.servers[0].url:"http://example.com"}${y}`,forwardSearch:!0}}}t(Dcr,"addDefaultUrlRewriteHandler");async function Pcr(s,o){let f=llt(s),d=f.handler.module.replace(/^\$import\(/,"").replace(/\)$/,""),y=sle.join(sle.dirname(o.fileName),"..",`${d}.ts`),E=f.handler.export;if(d==="@zuplo/runtime"||d.startsWith("@zuplo/runtime/"))return{valid:!0};if(await tu.fileExists(y)){let P=await $st(y);if(P===null)return{valid:!1,errorMsg:`Could not find any export due to a compile error in '${tu.getParentDirFilename(y)}'`};if(!P.has(E)){let F=`Could not find export "${E}" in '${tu.getParentDirFilename(y)}'`,J=0,G=0;if(s.children)for(let Te of s.children)Te.children&&Te.children.forEach(de=>{de.value==="handler"&&(J=de.line,G=de.column)});return{valid:!1,errorMsg:F,line:J,column:G}}return{valid:!0}}else return{valid:!1,errorMsg:`Could not find module '${d}'`}}t(Pcr,"checkModuleIsValid");var alt=t((s,o)=>{let f=0,d=0;if(s.children)for(let y of s.children)y.children&&y.children.forEach(E=>{E.value==="options"&&E.children?.forEach(P=>{E.value===o&&(f=P.line,d=P.column)})});return{line:f,column:d}},"getHandlerOptionLocation"),Acr="$env(";function Ncr(s,o){let f=llt(s),d=f.handler.export;if(d!=="urlForwardHandler"&&d!=="urlRewriteHandler")return{valid:!0};let y="rewritePattern";d==="urlForwardHandler"&&(y="baseUrl");let E=f.handler.options[y];if(!E){let P=alt(s,y);return{valid:!1,errors:[{text:`Invalid request handler configuration. handler.options.${y} is required but was not provided.`,location:{file:o.fileName,line:P.line,column:P.column}}]}}if(E.includes(Acr)){let P=alt(s,y);return{valid:!0,warnings:[{text:`Invalid environment variable access syntax detected. Use \${env.VAR_NAME} instead of $env(VAR_NAME) for handler.options.${y}.`,location:{file:o.fileName,line:P.line,column:P.column}}]}}return{valid:!0}}t(Ncr,"checkHandlerIsValid");var JH=Vp(hIe(),1);import{readFile as mpr}from"node:fs/promises";var vT=Vp(hIe(),1);var BO=class extends Error{static{t(this,"CustomResolveError")}},g4=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(o,f){this.sourceDirectory=o,this.logger=f}dereference(o,f){return JH.$RefParser.dereference(o,{resolve:{json:!0,file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:f?.onDereference}})}bundle(o){return JH.$RefParser.bundle(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(o){return JH.$RefParser.parse(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(o){return JH.$RefParser.resolve(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Ile(s,o){return{order:100,canRead(f){let d=ypr(f.url);if(!(d===void 0||d==="file"))return!1;let E;try{E=Lft(f.url)}catch(P){throw new BO(`Malformed URI: ${f.url}`,{cause:P})}try{tu.safePath(s).resolve(E)}catch(P){return o?.warn(P),!1}return!0},async read(f){let d;try{d=Lft(f.url)}catch(y){throw new BO(`Malformed URI: ${f.url}`,{cause:y})}try{return await mpr(d)}catch(y){throw new BO(`Error opening file "${d}"`,{cause:y})}}}}t(Ile,"customResolver");var FM=/^win/.test(globalThis.process?globalThis.process.platform:""),hpr=/\//g,gpr=/^(\w{2,}):\/\//i,gIe=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function ypr(s){let o=gpr.exec(s);if(o)return o[1].toLowerCase()}t(ypr,"getProtocol");function Lft(s,o){s=decodeURI(s);for(let d=0;d<gIe.length;d+=2)s=s.replace(gIe[d],gIe[d+1]);let f=s.substr(0,7).toLowerCase()==="file://";if(f&&(s=s[7]==="/"?s.substr(8):s.substr(7),FM&&s[1]==="/"&&(s=`${s[0]}:${s.substr(1)}`),o?s=`file:///${s}`:(f=!1,s=FM?s:`/${s}`)),!f){let d=s.split(FM?"\\":"/"),y=[];for(let E of d)E===".."?y.length&&y[y.length-1]!==""&&y.pop():(E!==""||y.length===0)&&y.push(E);s=y.join(FM?"\\":"/"),!FM&&y[0]===""&&(s=`/${s.substring(1)}`)}return FM&&!f&&(s=s.replace(hpr,"\\"),s.substr(1,2)===":\\"&&(s=s[0].toUpperCase()+s.substr(1))),s}t(Lft,"toFileSystemPath");var Rft="YOUR_KEY_HERE";async function Mft(s){let f=await new g4(s.sourceDirectory,s.logger).bundle(s.openApiDocPath),d=s.openApiDocPath.replace(s.sourceDirectory,"");return vpr({...s,relativeOpenApiPath:d},f)}t(Mft,"buildPublicOpenApiFile");async function vpr(s,o){xpr({relativeOpenApiPath:s.relativeOpenApiPath},o);let f=o;return f=Spr(f),bpr(f,s.urls?.api?.defaultUrl),f=Tpr(f,s),jft(f,"x-zuplo"),f}t(vpr,"buildRawOpenApiFile");function bpr(s,o){o?s.servers=[{url:o}]:s.servers=[]}t(bpr,"addServerHost");function Spr(s){if(!s.paths)return s;let{components:o}=s,f=o?{...o}:void 0,d=[];f&&f.parameters&&(d=Object.entries(f.parameters).reduce((E,[P,F])=>(M9 in F&&Qae(F[M9])&&(E.push(P),f.parameters&&delete f.parameters[P]),E),[]));let y=Object.entries(s.paths).reduce((E,[P,F])=>{if(!F)return E;let J={...F},G=["delete","get","head","patch","post","put","trace","options"];return G.forEach(Te=>{let de=F[Te];if(!de)return;if(Qae(de[M9])){delete J[Te];return}let{parameters:ae}=de;if(!ae)return;let Ye=ae.filter(Ue=>{if(M9 in Ue&&Qae(Ue[M9]))return!1;if("$ref"in Ue){let je=Ue.$ref.split("/").pop();return je?!d.includes(je):!0}return!0});J[Te]={...de,parameters:Ye}}),G.some(Te=>!!J[Te])&&(E[P]=J),E},{});return{...s,paths:y,components:f}}t(Spr,"removeHiddenRoutesAndParams");function Tpr(s,{policiesConfig:o}){if(!s.paths)return s;let f=Object.entries(s.paths).reduce((d,[y,E])=>{if(!E)return d;let P={...E};return[P.delete,P.get,P.head,P.patch,P.post,P.put,P.trace,P.options].forEach(F=>{if(!F)return;let J=F["x-zuplo-route"]?.policies?.inbound?.reduce((de,ae)=>{let Ye=o.policies?.find(({name:Kt})=>Kt===ae);if(!Ye)return de;if(!(Ye.handler.export==="CompositeInboundPolicy"))return de.concat(ae);let je=Ye.handler.options?.policies;return je?de.concat(je):de},[]),G=[];if(J&&J.forEach(de=>{o.policies?.forEach(ae=>{ae.name===de&&(ae.handler.export==="ApiAuthKeyInboundPolicy"||ae.handler.export==="ApiKeyInboundPolicy")&&!ae.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&G.push(ae)})}),G.length>0){let de=G.length>0&&G[0].handler&&G[0].handler.options&&G[0].handler.options.authHeader?G[0].handler.options.authHeader:"Authorization",ae=G.length>0&&G[0].handler&&G[0].handler.options&&(G[0].handler.options.authScheme||G[0].handler.options.authScheme==="")?G[0].handler.options.authScheme:"Bearer",Ye=ae!==""?`${ae} ${Rft}`:Rft,Ue={name:de,in:"header",required:!0,example:Ye,schema:{type:"string"},description:`The \`${de}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ye}\`.`};F.parameters?F.parameters.some(kr=>"name"in kr&&kr.name===Ue.name)||F.parameters.unshift(Ue):F.parameters=[Ue];let je={type:"http",scheme:ae.toLowerCase()},Kt="api_key";s.components?.securitySchemes?Object.values(s.components?.securitySchemes).some(kr=>"name"in kr&&kr.type==="apiKey"||"type"in kr&&kr.type==="http"&&kr.scheme===ae)||(s.components.securitySchemes={...s.components.securitySchemes,[Kt]:je}):(s.components||(s.components={}),s.components.securitySchemes={[Kt]:je});let Ut={[Kt]:[]};F.security?F.security.some(kr=>kr[Kt]!==void 0)||F.security.unshift(Ut):F.security=[Ut]}let Te=[];if(J&&J.forEach(de=>{o.policies?.forEach(ae=>{ae.name===de&&(ae.handler.export==="RateLimitInboundPolicy"||ae.handler.export==="ComplexRateLimitInboundPolicy")&&Te.push(ae)})}),Te.length>0){let de={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},ae={...de,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};s.components?.responses||s.components||(s.components={}),s.components.responses={...s.components.responses,RateLimitNoRetryAfter:de,RateLimitWithRetryAfter:ae},F.responses||(F.responses={});let Ye=Te.some(Ue=>Ue.handler.options?.headerMode!=="none");F.responses[429]||(F.responses[429]={$ref:Ye?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),d[y]=P,d},{});return{...s,paths:f}}t(Tpr,"enrichSpecWithZuploData");function jft(s,o){for(let f in s)f.startsWith(o)?delete s[f]:typeof s[f]=="object"&&jft(s[f],o)}t(jft,"removePropertiesByPrefix");function xpr({relativeOpenApiPath:s},o){if(!o||typeof o!="object")throw new C1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in o)||typeof o.info!="object"||!o.info)throw new C1({message:"The OpenAPI document does not have the required 'info' property.",location:{file:s,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in o.info)||typeof o.info.title!="string")throw new C1({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:s,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(xpr,"assertIsZuploOpenApiSpec");import Apr from"node:fs/promises";import Npr from"node:path";var{stringify:Epr}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");var Ole={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},OE=17,Cpr={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:OE,ClassExpression:OE,FunctionExpression:OE,ObjectExpression:OE,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function LM(s,o){let{generator:f}=s;if(s.write("("),o!=null&&o.length>0){f[o[0].type](o[0],s);let{length:d}=o;for(let y=1;y<d;y++){let E=o[y];s.write(", "),f[E.type](E,s)}}s.write(")")}t(LM,"formatSequence");function qft(s,o,f,d){let y=s.expressionsPrecedence[o.type];if(y===OE)return!0;let E=s.expressionsPrecedence[f.type];return y!==E?!d&&y===15&&E===14&&f.operator==="**"||y<E:y!==13&&y!==14?!1:o.operator==="**"&&f.operator==="**"?!d:y===13&&E===13&&(o.operator==="??"||f.operator==="??")?!0:d?Ole[o.operator]<=Ole[f.operator]:Ole[o.operator]<Ole[f.operator]}t(qft,"expressionNeedsParenthesis");function Fle(s,o,f,d){let{generator:y}=s;qft(s,o,f,d)?(s.write("("),y[o.type](o,s),s.write(")")):y[o.type](o,s)}t(Fle,"formatExpression");function kpr(s,o,f,d){let y=o.split(`
600
600
  `),E=y.length-1;if(s.write(y[0].trim()),E>0){s.write(d);for(let P=1;P<E;P++)s.write(f+y[P].trim()+d);s.write(f+y[E].trim())}}t(kpr,"reindent");function R1(s,o,f,d){let{length:y}=o;for(let E=0;E<y;E++){let P=o[E];s.write(f),P.type[0]==="L"?s.write("// "+P.value.trim()+`
601
601
  `,P):(s.write("/*"),kpr(s,P.value,f,d),s.write("*/"+d))}}t(R1,"formatComments");function wpr(s){let o=s;for(;o!=null;){let{type:f}=o;if(f[0]==="C"&&f[1]==="a")return!0;if(f[0]==="M"&&f[1]==="e"&&f[2]==="m")o=o.object;else return!1}}t(wpr,"hasCallExpression");function yIe(s,o){let{generator:f}=s,{declarations:d}=o;s.write(o.kind+" ");let{length:y}=d;if(y>0){f.VariableDeclarator(d[0],s);for(let E=1;E<y;E++)s.write(", "),f.VariableDeclarator(d[E],s)}}t(yIe,"formatVariableDeclaration");var Bft,Uft,zft,$ft,Jft,Wft,Dpr={Program(s,o){let f=o.indent.repeat(o.indentLevel),{lineEnd:d,writeComments:y}=o;y&&s.comments!=null&&R1(o,s.comments,f,d);let E=s.body,{length:P}=E;for(let F=0;F<P;F++){let J=E[F];y&&J.comments!=null&&R1(o,J.comments,f,d),o.write(f),this[J.type](J,o),o.write(d)}y&&s.trailingComments!=null&&R1(o,s.trailingComments,f,d)},BlockStatement:Wft=t(function(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o,E=f+o.indent;o.write("{");let P=s.body;if(P!=null&&P.length>0){o.write(d),y&&s.comments!=null&&R1(o,s.comments,E,d);let{length:F}=P;for(let J=0;J<F;J++){let G=P[J];y&&G.comments!=null&&R1(o,G.comments,E,d),o.write(E),this[G.type](G,o),o.write(d)}o.write(f)}else y&&s.comments!=null&&(o.write(d),R1(o,s.comments,E,d),o.write(f));y&&s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write("}"),o.indentLevel--},"BlockStatement"),ClassBody:Wft,StaticBlock(s,o){o.write("static "),this.BlockStatement(s,o)},EmptyStatement(s,o){o.write(";")},ExpressionStatement(s,o){let f=o.expressionsPrecedence[s.expression.type];f===OE||f===3&&s.expression.left.type[0]==="O"?(o.write("("),this[s.expression.type](s.expression,o),o.write(")")):this[s.expression.type](s.expression,o),o.write(";")},IfStatement(s,o){o.write("if ("),this[s.test.type](s.test,o),o.write(") "),this[s.consequent.type](s.consequent,o),s.alternate!=null&&(o.write(" else "),this[s.alternate.type](s.alternate,o))},LabeledStatement(s,o){this[s.label.type](s.label,o),o.write(": "),this[s.body.type](s.body,o)},BreakStatement(s,o){o.write("break"),s.label!=null&&(o.write(" "),this[s.label.type](s.label,o)),o.write(";")},ContinueStatement(s,o){o.write("continue"),s.label!=null&&(o.write(" "),this[s.label.type](s.label,o)),o.write(";")},WithStatement(s,o){o.write("with ("),this[s.object.type](s.object,o),o.write(") "),this[s.body.type](s.body,o)},SwitchStatement(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o;o.indentLevel++;let E=f+o.indent,P=E+o.indent;o.write("switch ("),this[s.discriminant.type](s.discriminant,o),o.write(") {"+d);let{cases:F}=s,{length:J}=F;for(let G=0;G<J;G++){let Te=F[G];y&&Te.comments!=null&&R1(o,Te.comments,E,d),Te.test?(o.write(E+"case "),this[Te.test.type](Te.test,o),o.write(":"+d)):o.write(E+"default:"+d);let{consequent:de}=Te,{length:ae}=de;for(let Ye=0;Ye<ae;Ye++){let Ue=de[Ye];y&&Ue.comments!=null&&R1(o,Ue.comments,P,d),o.write(P),this[Ue.type](Ue,o),o.write(d)}}o.indentLevel-=2,o.write(f+"}")},ReturnStatement(s,o){o.write("return"),s.argument&&(o.write(" "),this[s.argument.type](s.argument,o)),o.write(";")},ThrowStatement(s,o){o.write("throw "),this[s.argument.type](s.argument,o),o.write(";")},TryStatement(s,o){if(o.write("try "),this[s.block.type](s.block,o),s.handler){let{handler:f}=s;f.param==null?o.write(" catch "):(o.write(" catch ("),this[f.param.type](f.param,o),o.write(") ")),this[f.body.type](f.body,o)}s.finalizer&&(o.write(" finally "),this[s.finalizer.type](s.finalizer,o))},WhileStatement(s,o){o.write("while ("),this[s.test.type](s.test,o),o.write(") "),this[s.body.type](s.body,o)},DoWhileStatement(s,o){o.write("do "),this[s.body.type](s.body,o),o.write(" while ("),this[s.test.type](s.test,o),o.write(");")},ForStatement(s,o){if(o.write("for ("),s.init!=null){let{init:f}=s;f.type[0]==="V"?yIe(o,f):this[f.type](f,o)}o.write("; "),s.test&&this[s.test.type](s.test,o),o.write("; "),s.update&&this[s.update.type](s.update,o),o.write(") "),this[s.body.type](s.body,o)},ForInStatement:Bft=t(function(s,o){o.write(`for ${s.await?"await ":""}(`);let{left:f}=s;f.type[0]==="V"?yIe(o,f):this[f.type](f,o),o.write(s.type[3]==="I"?" in ":" of "),this[s.right.type](s.right,o),o.write(") "),this[s.body.type](s.body,o)},"ForInStatement"),ForOfStatement:Bft,DebuggerStatement(s,o){o.write("debugger;",s)},FunctionDeclaration:Uft=t(function(s,o){o.write((s.async?"async ":"")+(s.generator?"function* ":"function ")+(s.id?s.id.name:""),s),LM(o,s.params),o.write(" "),this[s.body.type](s.body,o)},"FunctionDeclaration"),FunctionExpression:Uft,VariableDeclaration(s,o){yIe(o,s),o.write(";")},VariableDeclarator(s,o){this[s.id.type](s.id,o),s.init!=null&&(o.write(" = "),this[s.init.type](s.init,o))},ClassDeclaration(s,o){if(o.write("class "+(s.id?`${s.id.name} `:""),s),s.superClass){o.write("extends ");let{superClass:f}=s,{type:d}=f,y=o.expressionsPrecedence[d];(d[0]!=="C"||d[1]!=="l"||d[5]!=="E")&&(y===OE||y<o.expressionsPrecedence.ClassExpression)?(o.write("("),this[s.superClass.type](f,o),o.write(")")):this[f.type](f,o),o.write(" ")}this.ClassBody(s.body,o)},ImportDeclaration(s,o){o.write("import ");let{specifiers:f,attributes:d}=s,{length:y}=f,E=0;if(y>0){for(;E<y;){E>0&&o.write(", ");let P=f[E],F=P.type[6];if(F==="D")o.write(P.local.name,P),E++;else if(F==="N")o.write("* as "+P.local.name,P),E++;else break}if(E<y){for(o.write("{");;){let P=f[E],{name:F}=P.imported;if(o.write(F,P),F!==P.local.name&&o.write(" as "+P.local.name),++E<y)o.write(", ");else break}o.write("}")}o.write(" from ")}if(this.Literal(s.source,o),d&&d.length>0){o.write(" with { ");for(let P=0;P<d.length;P++)this.ImportAttribute(d[P],o),P<d.length-1&&o.write(", ");o.write(" }")}o.write(";")},ImportAttribute(s,o){this.Identifier(s.key,o),o.write(": "),this.Literal(s.value,o)},ImportExpression(s,o){o.write("import("),this[s.source.type](s.source,o),o.write(")")},ExportDefaultDeclaration(s,o){o.write("export default "),this[s.declaration.type](s.declaration,o),o.expressionsPrecedence[s.declaration.type]!=null&&s.declaration.type[0]!=="F"&&o.write(";")},ExportNamedDeclaration(s,o){if(o.write("export "),s.declaration)this[s.declaration.type](s.declaration,o);else{o.write("{");let{specifiers:f}=s,{length:d}=f;if(d>0)for(let y=0;;){let E=f[y],{name:P}=E.local;if(o.write(P,E),P!==E.exported.name&&o.write(" as "+E.exported.name),++y<d)o.write(", ");else break}if(o.write("}"),s.source&&(o.write(" from "),this.Literal(s.source,o)),s.attributes&&s.attributes.length>0){o.write(" with { ");for(let y=0;y<s.attributes.length;y++)this.ImportAttribute(s.attributes[y],o),y<s.attributes.length-1&&o.write(", ");o.write(" }")}o.write(";")}},ExportAllDeclaration(s,o){if(s.exported!=null?o.write("export * as "+s.exported.name+" from "):o.write("export * from "),this.Literal(s.source,o),s.attributes&&s.attributes.length>0){o.write(" with { ");for(let f=0;f<s.attributes.length;f++)this.ImportAttribute(s.attributes[f],o),f<s.attributes.length-1&&o.write(", ");o.write(" }")}o.write(";")},MethodDefinition(s,o){s.static&&o.write("static ");let f=s.kind[0];(f==="g"||f==="s")&&o.write(s.kind+" "),s.value.async&&o.write("async "),s.value.generator&&o.write("*"),s.computed?(o.write("["),this[s.key.type](s.key,o),o.write("]")):this[s.key.type](s.key,o),LM(o,s.value.params),o.write(" "),this[s.value.body.type](s.value.body,o)},ClassExpression(s,o){this.ClassDeclaration(s,o)},ArrowFunctionExpression(s,o){o.write(s.async?"async ":"",s);let{params:f}=s;f!=null&&(f.length===1&&f[0].type[0]==="I"?o.write(f[0].name,f[0]):LM(o,s.params)),o.write(" => "),s.body.type[0]==="O"?(o.write("("),this.ObjectExpression(s.body,o),o.write(")")):this[s.body.type](s.body,o)},ThisExpression(s,o){o.write("this",s)},Super(s,o){o.write("super",s)},RestElement:zft=t(function(s,o){o.write("..."),this[s.argument.type](s.argument,o)},"RestElement"),SpreadElement:zft,YieldExpression(s,o){o.write(s.delegate?"yield*":"yield"),s.argument&&(o.write(" "),this[s.argument.type](s.argument,o))},AwaitExpression(s,o){o.write("await ",s),Fle(o,s.argument,s)},TemplateLiteral(s,o){let{quasis:f,expressions:d}=s;o.write("`");let{length:y}=d;for(let P=0;P<y;P++){let F=d[P],J=f[P];o.write(J.value.raw,J),o.write("${"),this[F.type](F,o),o.write("}")}let E=f[f.length-1];o.write(E.value.raw,E),o.write("`")},TemplateElement(s,o){o.write(s.value.raw,s)},TaggedTemplateExpression(s,o){Fle(o,s.tag,s),this[s.quasi.type](s.quasi,o)},ArrayExpression:Jft=t(function(s,o){if(o.write("["),s.elements.length>0){let{elements:f}=s,{length:d}=f;for(let y=0;;){let E=f[y];if(E!=null&&this[E.type](E,o),++y<d)o.write(", ");else{E==null&&o.write(", ");break}}}o.write("]")},"ArrayExpression"),ArrayPattern:Jft,ObjectExpression(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o,E=f+o.indent;if(o.write("{"),s.properties.length>0){o.write(d),y&&s.comments!=null&&R1(o,s.comments,E,d);let P=","+d,{properties:F}=s,{length:J}=F;for(let G=0;;){let Te=F[G];if(y&&Te.comments!=null&&R1(o,Te.comments,E,d),o.write(E),this[Te.type](Te,o),++G<J)o.write(P);else break}o.write(d),y&&s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write(f+"}")}else y?s.comments!=null?(o.write(d),R1(o,s.comments,E,d),s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write(f+"}")):s.trailingComments!=null?(o.write(d),R1(o,s.trailingComments,E,d),o.write(f+"}")):o.write("}"):o.write("}");o.indentLevel--},Property(s,o){s.method||s.kind[0]!=="i"?this.MethodDefinition(s,o):(s.shorthand||(s.computed?(o.write("["),this[s.key.type](s.key,o),o.write("]")):this[s.key.type](s.key,o),o.write(": ")),this[s.value.type](s.value,o))},PropertyDefinition(s,o){if(s.static&&o.write("static "),s.computed&&o.write("["),this[s.key.type](s.key,o),s.computed&&o.write("]"),s.value==null){s.key.type[0]!=="F"&&o.write(";");return}o.write(" = "),this[s.value.type](s.value,o),o.write(";")},ObjectPattern(s,o){if(o.write("{"),s.properties.length>0){let{properties:f}=s,{length:d}=f;for(let y=0;this[f[y].type](f[y],o),++y<d;)o.write(", ")}o.write("}")},SequenceExpression(s,o){LM(o,s.expressions)},UnaryExpression(s,o){if(s.prefix){let{operator:f,argument:d,argument:{type:y}}=s;o.write(f);let E=qft(o,d,s);!E&&(f.length>1||y[0]==="U"&&(y[1]==="n"||y[1]==="p")&&d.prefix&&d.operator[0]===f&&(f==="+"||f==="-"))&&o.write(" "),E?(o.write(f.length>1?" (":"("),this[y](d,o),o.write(")")):this[y](d,o)}else this[s.argument.type](s.argument,o),o.write(s.operator)},UpdateExpression(s,o){s.prefix?(o.write(s.operator),this[s.argument.type](s.argument,o)):(this[s.argument.type](s.argument,o),o.write(s.operator))},AssignmentExpression(s,o){this[s.left.type](s.left,o),o.write(" "+s.operator+" "),this[s.right.type](s.right,o)},AssignmentPattern(s,o){this[s.left.type](s.left,o),o.write(" = "),this[s.right.type](s.right,o)},BinaryExpression:$ft=t(function(s,o){let f=s.operator==="in";f&&o.write("("),Fle(o,s.left,s,!1),o.write(" "+s.operator+" "),Fle(o,s.right,s,!0),f&&o.write(")")},"BinaryExpression"),LogicalExpression:$ft,ConditionalExpression(s,o){let{test:f}=s,d=o.expressionsPrecedence[f.type];d===OE||d<=o.expressionsPrecedence.ConditionalExpression?(o.write("("),this[f.type](f,o),o.write(")")):this[f.type](f,o),o.write(" ? "),this[s.consequent.type](s.consequent,o),o.write(" : "),this[s.alternate.type](s.alternate,o)},NewExpression(s,o){o.write("new ");let f=o.expressionsPrecedence[s.callee.type];f===OE||f<o.expressionsPrecedence.CallExpression||wpr(s.callee)?(o.write("("),this[s.callee.type](s.callee,o),o.write(")")):this[s.callee.type](s.callee,o),LM(o,s.arguments)},CallExpression(s,o){let f=o.expressionsPrecedence[s.callee.type];f===OE||f<o.expressionsPrecedence.CallExpression?(o.write("("),this[s.callee.type](s.callee,o),o.write(")")):this[s.callee.type](s.callee,o),s.optional&&o.write("?."),LM(o,s.arguments)},ChainExpression(s,o){this[s.expression.type](s.expression,o)},MemberExpression(s,o){let f=o.expressionsPrecedence[s.object.type];f===OE||f<o.expressionsPrecedence.MemberExpression?(o.write("("),this[s.object.type](s.object,o),o.write(")")):this[s.object.type](s.object,o),s.computed?(s.optional&&o.write("?."),o.write("["),this[s.property.type](s.property,o),o.write("]")):(s.optional?o.write("?."):o.write("."),this[s.property.type](s.property,o))},MetaProperty(s,o){o.write(s.meta.name+"."+s.property.name,s)},Identifier(s,o){o.write(s.name,s)},PrivateIdentifier(s,o){o.write(`#${s.name}`,s)},Literal(s,o){s.raw!=null?o.write(s.raw,s):s.regex!=null?this.RegExpLiteral(s,o):s.bigint!=null?o.write(s.bigint+"n",s):o.write(Epr(s.value),s)},RegExpLiteral(s,o){let{regex:f}=s;o.write(`/${f.pattern}/${f.flags}`,s)}},Ppr={};var vIe=class{static{t(this,"State")}constructor(o){let f=o??Ppr;this.output="",f.output!=null?(this.output=f.output,this.write=this.writeToStream):this.output="",this.generator=f.generator!=null?f.generator:Dpr,this.expressionsPrecedence=f.expressionsPrecedence!=null?f.expressionsPrecedence:Cpr,this.indent=f.indent!=null?f.indent:" ",this.lineEnd=f.lineEnd!=null?f.lineEnd:`
602
602
  `,this.indentLevel=f.startingIndentLevel!=null?f.startingIndentLevel:0,this.writeComments=f.comments?f.comments:!1,f.sourceMap!=null&&(this.write=f.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=f.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
package/index.minified.js CHANGED
@@ -596,7 +596,7 @@ globstar while`,s,de,o,ae,Ye),this.matchOne(s.slice(de),o.slice(ae),f))return th
596
596
  };
597
597
  }
598
598
  export default routes;
599
- `),jcr=["2023-03-14","2024-01-15","2024-03-14","2024-09-02"];function hlt(s){return!s||jcr.includes(s)}t(hlt,"isLegacyPathBehavior");async function aIe(s){try{let{content:o,warnings:f}=await Bcr(s);return{content:o,errors:[],warnings:f}}catch(o){if(o instanceof A1)return o.toBuildResult();throw o}}t(aIe,"compileRoutes");async function Bcr({sourceDirectory:s,policiesContent:o,oasContent:f,compatibilityDate:d,allowDuplicateRoutes:y}){let E=[],P=[],F=new tle,J=new GV,{policiesNode:V,policiesData:Te}=$cr(o),{generatedPolicies:de,policyNames:ae}=Jcr(F,J,V,Te),{generatedCorsPolicies:Ye,corsPoliciesNames:Ue}=Wcr(F,J,V,Te),je=qcr(s,f),Kt=[],Ut=new Map;for(let Pn of je){let{node:wr,oas:Sr,oasProjectRelativePath:us}=Pn,Fi=BAe(wr,["paths"]);if(!Fi)continue;let cc=sle.basename(Sr.fileName,".oas.json");for(let bi of Fi.children??[])if(bi.children){let Qf=Xcr(bi),S_=Qf[flt]?.pathMode;if(S_){if(S_!==nle&&S_!==sIe)throw new A1({text:`Unknown path mode ${S_}`,location:{line:0,column:0,file:us}})}else S_=nle;for(let[Rn,zE]of Object.entries(Qf)){if(!ile(Rn))continue;let Fl=Rn,Ar=Fl.split(/,/).map(Hs=>Hs.trim().toUpperCase()),AT=zE,bc=AT[rle];if(bc){let Oh=new Qce().validate(bc);if(Oh.isValid){let k0=_lt(bi);if(!Ut.has(k0)&&(Ut.set(k0,new Set),hlt(d)))try{new URLPattern({pathname:k0})}catch{P.push({text:`Path '${k0}' contains invalid characters. The value must be a valid URLPattern.`,location:{line:bi.line,column:bi.column,file:us}})}if(!y){let w0=Ut.get(k0);Ar.forEach(NT=>{w0.has(NT)?P.push({text:`Cannot have duplicate routes declared. Route '${NT.toUpperCase()} ${k0}' declared more than once.`,location:{line:bi.line,column:bi.column,file:us}}):w0.add(NT)})}let b7=plt(bi,[k0,Fl,rle]),sw=await Qcr(b7,Sr);if(!sw.valid)throw new A1({text:sw.errorMsg??`Unknown error on handler for path '${k0}'`,location:{line:sw.line??0,column:sw.column??0,file:us}});let Wi=tlr(b7,Sr);if(!Wi.valid)throw new A1(Wi.errors);Wi.warnings&&E.push(...Wi.warnings),Kt.push({path:k0,pathPattern:k0,pathMode:S_,httpMethods:Ar,rawOperation:Fl,rawOpenAPI:AT,oasFileName:cc,oasProjectRelativePath:us,config:plt(bi,[k0,Fl,rle])})}else throw new A1({text:JSON.stringify(Oh.errors),location:{line:0,column:0,file:us}})}else{let Hs=_lt(bi),Oh={corsPolicy:"none",handler:Zcr(Hs,wr)};Kt.push({path:Hs,pathPattern:Hs,pathMode:nle,rawOpenAPI:AT,oasFileName:cc,oasProjectRelativePath:us,httpMethods:Ar,rawOperation:Fl,config:qV(JSON.stringify(Oh))})}if(bc&&"policies"in bc){let Hs=bc.policies;Hs.inbound?.forEach(Oh=>{ae.includes(Oh)||P.push({text:`Policy '${Oh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})}),Hs.outbound?.forEach(Oh=>{ae.includes(Oh)||P.push({text:`Policy '${Oh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})})}if(P.length>0)throw new A1(P);let Qp=["none","anything-goes"];if(bc&&"corsPolicy"in bc){let Hs=bc.corsPolicy;if(Qp.includes(Hs))continue;Ue.includes(Hs)||P.push({text:`Cors policy '${Hs}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})}}}if(P.length>0)throw new A1(P)}let kr=[];for(let Pn of Kt){let wr=new HV().convert(Pn.config);Vcr(wr,Pn),Hcr(wr,Pn,d),Gcr(wr,Pn),Ycr(wr,Pn),Kcr(wr,Pn);let Sr=F.transform(wr),us=F.errors;if(us.length>0)throw new A1({text:JSON.stringify(us),location:{line:0,column:0,file:Pn.oasProjectRelativePath}});let cc=new GV().generate(Sr);kr.push(cc)}if(GP(je.length===f.length,"Tree length should match OAS file length"),GP(Kt.length===kr.length,`The number of validated nodes should match the number of generated fragments. There were ${Kt.length} validated nodes and ${kr.length} generated fragments.`),P.length>0)throw new A1(P);let An={routes:kr,imports:F.getImports(),policies:de,corsPolicies:Ye};return{content:Mcr(An),warnings:E}}t(Bcr,"generateSourceCode");var Ucr=0,zcr=1;function $cr(s){let o=new Zce,f=JSON.parse(s.content),d=o.validate(f);if(!d.isValid)throw new A1({text:JSON.stringify(d.errors),location:{line:0,column:0,file:"/config/policies.json"}});let y=new HV().parse(JSON.stringify(f));return{policiesData:f,policiesNode:y}}t($cr,"getPolicyData");function Jcr(s,o,f,d){let y=[],E;nI(f);let P=f.children.find(F=>F.name.value==="policies");if(P){let F=s.transform(P);E=o.generate(F),y=d.policies.map(({name:J})=>J)}else E="policies: []";return{generatedPolicies:E,policyNames:y}}t(Jcr,"generatePolicies");function Wcr(s,o,f,d){let y,E;nI(f);let P=f.children.find(F=>F.name.value==="corsPolicies");if(P){let F=s.transform(P);E=o.generate(F),y=d.corsPolicies.map(({name:J})=>J)}else E="corsPolicies: []",y=[];return{generatedCorsPolicies:E,corsPoliciesNames:y}}t(Wcr,"generateCorsPolicies");function qcr(s,o){let f=[];for(let d of o){let y=[],E=qV(d.content,y),P=`./${sle.posix.relative(s.replace(/\\/g,"/"),d.fileName.replace(/\\/g,"/"))}`;if(y.length>0)throw new A1(y.map(F=>({text:Yst(F.error),location:{file:P,line:F.line,column:F.column}})));if(!E)throw new A1({text:"Error parsing the OpenAPI file. Check the contents of the file.",location:{file:P,line:0,column:0}});f.push({node:E,oas:d,oasProjectRelativePath:P})}return f}t(qcr,"getOasTrees");function Vcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"path",type:Wo.Identifier,parent:f},f.value=wS.createLiteral(o.path,f),nI(s),s.children.unshift(f)}t(Vcr,"embellishWithPath");function Hcr(s,o,f){let d={type:Wo.Property,parent:s,name:null,value:null};if(d.name={value:"pathPattern",type:Wo.Identifier,parent:d},o.pathMode===sIe)d.value=wS.createLiteral(o.path,d);else{let y=/{(\S+?)}/gm,E=":$1",P=hlt(f)?o.path:o.path.replace(/([*+?()[\].|^$\\:])/g,"\\$1");P=P.replace(y,E),o.path.endsWith("/")||(P=`${P}{/}?`),d.value=wS.createLiteral(P,d)}nI(s),s.children.unshift(d)}t(Hcr,"embellishWithPathPattern");function Gcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"methods",type:Wo.Identifier,parent:f},f.value=wS.createArrayOfLiterals(o.httpMethods,f),nI(s),s.children.unshift(f)}t(Gcr,"embellishWithMethods");function Ycr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"raw",type:Wo.Identifier,parent:s};let d=AV(o.oasFileName,o.path,o.rawOperation);f.value={type:Wo.Raw,parent:f,value:`() => {return rawRouteData.${d};}`},nI(s),s.children.unshift(f)}t(Ycr,"embellishWithRawOpenApi");function Kcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"metadata",type:Wo.Identifier,parent:s};let d={type:Wo.Property,parent:f,name:null,value:null};d.name={value:"filepath",type:Wo.Identifier,parent:d},d.value=wS.createLiteral(o.oasProjectRelativePath,d),f.value={type:Wo.Object,parent:f,children:[d]},nI(s),s.children.unshift(f)}t(Kcr,"embellishWithMetadata");function Xcr(s){return GP(s.type==="property"),GP(Array.isArray(s.children)),VV(s.children[zcr])}t(Xcr,"evaluatePathItem");function _lt(s){return GP(s.type==="property"),GP(Array.isArray(s.children)),VV(s.children[Ucr])}t(_lt,"evaluatePath");function plt(s,o){return BAe(s.parent,o)}t(plt,"extractZuploRouteNode");function glt(s){return VV(s)}t(glt,"evaluateZuploRouteNode");function Zcr(s,o){let f=/{(\S+?)}/gm,y=s.replace(f,"${params.$1}"),E=VV(o);return{export:"urlRewriteHandler",module:"$import(@zuplo/runtime)",options:{rewritePattern:`${E.servers&&E.servers.length>0?E.servers[0].url:"http://example.com"}${y}`,forwardSearch:!0}}}t(Zcr,"addDefaultUrlRewriteHandler");async function Qcr(s,o){let f=glt(s),d=f.handler.module.replace(/^\$import\(/,"").replace(/\)$/,""),y=sle.join(sle.dirname(o.fileName),"..",`${d}.ts`),E=f.handler.export;if(d==="@zuplo/runtime")return{valid:!0};if(await tu.fileExists(y)){let P=await Kst(y);if(P===null)return{valid:!1,errorMsg:`Could not find any export due to a compile error in '${tu.getParentDirFilename(y)}'`};if(!P.has(E)){let F=`Could not find export "${E}" in '${tu.getParentDirFilename(y)}'`,J=0,V=0;if(s.children)for(let Te of s.children)Te.children&&Te.children.forEach(de=>{de.value==="handler"&&(J=de.line,V=de.column)});return{valid:!1,errorMsg:F,line:J,column:V}}return{valid:!0}}else return{valid:!1,errorMsg:`Could not find module '${d}'`}}t(Qcr,"checkModuleIsValid");var dlt=t((s,o)=>{let f=0,d=0;if(s.children)for(let y of s.children)y.children&&y.children.forEach(E=>{E.value==="options"&&E.children?.forEach(P=>{E.value===o&&(f=P.line,d=P.column)})});return{line:f,column:d}},"getHandlerOptionLocation"),elr="$env(";function tlr(s,o){let f=glt(s),d=f.handler.export;if(d!=="urlForwardHandler"&&d!=="urlRewriteHandler")return{valid:!0};let y="rewritePattern";d==="urlForwardHandler"&&(y="baseUrl");let E=f.handler.options[y];if(!E){let P=dlt(s,y);return{valid:!1,errors:[{text:`Invalid request handler configuration. handler.options.${y} is required but was not provided.`,location:{file:o.fileName,line:P.line,column:P.column}}]}}if(E.includes(elr)){let P=dlt(s,y);return{valid:!0,warnings:[{text:`Invalid environment variable access syntax detected. Use \${env.VAR_NAME} instead of $env(VAR_NAME) for handler.options.${y}.`,location:{file:o.fileName,line:P.line,column:P.column}}]}}return{valid:!0}}t(tlr,"checkHandlerIsValid");var WH=ep(S4e(),1);import{readFile as Bpr}from"node:fs/promises";var bT=ep(S4e(),1);var zO=class extends Error{static{t(this,"CustomResolveError")}},bI=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(o,f){this.sourceDirectory=o,this.logger=f}dereference(o,f){return WH.$RefParser.dereference(o,{resolve:{json:!0,file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:f?.onDereference}})}bundle(o){return WH.$RefParser.bundle(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(o){return WH.$RefParser.parse(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(o){return WH.$RefParser.resolve(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Ile(s,o){return{order:100,canRead(f){let d=$pr(f.url);if(!(d===void 0||d==="file"))return!1;let E;try{E=Jft(f.url)}catch(P){throw new zO(`Malformed URI: ${f.url}`,{cause:P})}try{tu.safePath(s).resolve(E)}catch(P){return o?.warn(P),!1}return!0},async read(f){let d;try{d=Jft(f.url)}catch(y){throw new zO(`Malformed URI: ${f.url}`,{cause:y})}try{return await Bpr(d)}catch(y){throw new zO(`Error opening file "${d}"`,{cause:y})}}}}t(Ile,"customResolver");var FM=/^win/.test(globalThis.process?globalThis.process.platform:""),Upr=/\//g,zpr=/^(\w{2,}):\/\//i,T4e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function $pr(s){let o=zpr.exec(s);if(o)return o[1].toLowerCase()}t($pr,"getProtocol");function Jft(s,o){s=decodeURI(s);for(let d=0;d<T4e.length;d+=2)s=s.replace(T4e[d],T4e[d+1]);let f=s.substr(0,7).toLowerCase()==="file://";if(f&&(s=s[7]==="/"?s.substr(8):s.substr(7),FM&&s[1]==="/"&&(s=`${s[0]}:${s.substr(1)}`),o?s=`file:///${s}`:(f=!1,s=FM?s:`/${s}`)),!f){let d=s.split(FM?"\\":"/"),y=[];for(let E of d)E===".."?y.length&&y[y.length-1]!==""&&y.pop():(E!==""||y.length===0)&&y.push(E);s=y.join(FM?"\\":"/"),!FM&&y[0]===""&&(s=`/${s.substring(1)}`)}return FM&&!f&&(s=s.replace(Upr,"\\"),s.substr(1,2)===":\\"&&(s=s[0].toUpperCase()+s.substr(1))),s}t(Jft,"toFileSystemPath");var Wft="YOUR_KEY_HERE";async function qft(s){let f=await new bI(s.sourceDirectory,s.logger).bundle(s.openApiDocPath),d=s.openApiDocPath.replace(s.sourceDirectory,"");return Jpr({...s,relativeOpenApiPath:d},f)}t(qft,"buildPublicOpenApiFile");async function Jpr(s,o){Hpr({relativeOpenApiPath:s.relativeOpenApiPath},o);let f=o;return f=qpr(f),Wpr(f,s.urls?.api?.defaultUrl),f=Vpr(f,s),Vft(f,"x-zuplo"),f}t(Jpr,"buildRawOpenApiFile");function Wpr(s,o){o?s.servers=[{url:o}]:s.servers=[]}t(Wpr,"addServerHost");function qpr(s){if(!s.paths)return s;let{components:o}=s,f=o?{...o}:void 0,d=[];f&&f.parameters&&(d=Object.entries(f.parameters).reduce((E,[P,F])=>(j9 in F&&Qae(F[j9])&&(E.push(P),f.parameters&&delete f.parameters[P]),E),[]));let y=Object.entries(s.paths).reduce((E,[P,F])=>{if(!F)return E;let J={...F},V=["delete","get","head","patch","post","put","trace","options"];return V.forEach(Te=>{let de=F[Te];if(!de)return;if(Qae(de[j9])){delete J[Te];return}let{parameters:ae}=de;if(!ae)return;let Ye=ae.filter(Ue=>{if(j9 in Ue&&Qae(Ue[j9]))return!1;if("$ref"in Ue){let je=Ue.$ref.split("/").pop();return je?!d.includes(je):!0}return!0});J[Te]={...de,parameters:Ye}}),V.some(Te=>!!J[Te])&&(E[P]=J),E},{});return{...s,paths:y,components:f}}t(qpr,"removeHiddenRoutesAndParams");function Vpr(s,{policiesConfig:o}){if(!s.paths)return s;let f=Object.entries(s.paths).reduce((d,[y,E])=>{if(!E)return d;let P={...E};return[P.delete,P.get,P.head,P.patch,P.post,P.put,P.trace,P.options].forEach(F=>{if(!F)return;let J=F["x-zuplo-route"]?.policies?.inbound?.reduce((de,ae)=>{let Ye=o.policies?.find(({name:Kt})=>Kt===ae);if(!Ye)return de;if(!(Ye.handler.export==="CompositeInboundPolicy"))return de.concat(ae);let je=Ye.handler.options?.policies;return je?de.concat(je):de},[]),V=[];if(J&&J.forEach(de=>{o.policies?.forEach(ae=>{ae.name===de&&(ae.handler.export==="ApiAuthKeyInboundPolicy"||ae.handler.export==="ApiKeyInboundPolicy")&&!ae.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&V.push(ae)})}),V.length>0){let de=V.length>0&&V[0].handler&&V[0].handler.options&&V[0].handler.options.authHeader?V[0].handler.options.authHeader:"Authorization",ae=V.length>0&&V[0].handler&&V[0].handler.options&&(V[0].handler.options.authScheme||V[0].handler.options.authScheme==="")?V[0].handler.options.authScheme:"Bearer",Ye=ae!==""?`${ae} ${Wft}`:Wft,Ue={name:de,in:"header",required:!0,example:Ye,schema:{type:"string"},description:`The \`${de}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ye}\`.`};F.parameters?F.parameters.some(kr=>"name"in kr&&kr.name===Ue.name)||F.parameters.unshift(Ue):F.parameters=[Ue];let je={type:"http",scheme:ae.toLowerCase()},Kt="api_key";s.components?.securitySchemes?Object.values(s.components?.securitySchemes).some(kr=>"name"in kr&&kr.type==="apiKey"||"type"in kr&&kr.type==="http"&&kr.scheme===ae)||(s.components.securitySchemes={...s.components.securitySchemes,[Kt]:je}):(s.components||(s.components={}),s.components.securitySchemes={[Kt]:je});let Ut={[Kt]:[]};F.security?F.security.some(kr=>kr[Kt]!==void 0)||F.security.unshift(Ut):F.security=[Ut]}let Te=[];if(J&&J.forEach(de=>{o.policies?.forEach(ae=>{ae.name===de&&(ae.handler.export==="RateLimitInboundPolicy"||ae.handler.export==="ComplexRateLimitInboundPolicy")&&Te.push(ae)})}),Te.length>0){let de={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},ae={...de,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};s.components?.responses||s.components||(s.components={}),s.components.responses={...s.components.responses,RateLimitNoRetryAfter:de,RateLimitWithRetryAfter:ae},F.responses||(F.responses={});let Ye=Te.some(Ue=>Ue.handler.options?.headerMode!=="none");F.responses[429]||(F.responses[429]={$ref:Ye?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),d[y]=P,d},{});return{...s,paths:f}}t(Vpr,"enrichSpecWithZuploData");function Vft(s,o){for(let f in s)f.startsWith(o)?delete s[f]:typeof s[f]=="object"&&Vft(s[f],o)}t(Vft,"removePropertiesByPrefix");function Hpr({relativeOpenApiPath:s},o){if(!o||typeof o!="object")throw new k1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in o)||typeof o.info!="object"||!o.info)throw new k1({message:"The OpenAPI document does not have the required 'info' property.",location:{file:s,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in o.info)||typeof o.info.title!="string")throw new k1({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:s,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(Hpr,"assertIsZuploOpenApiSpec");import edr from"node:fs/promises";import tdr from"node:path";var{stringify:Gpr}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");var Ole={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},LE=17,Ypr={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:LE,ClassExpression:LE,FunctionExpression:LE,ObjectExpression:LE,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function LM(s,o){let{generator:f}=s;if(s.write("("),o!=null&&o.length>0){f[o[0].type](o[0],s);let{length:d}=o;for(let y=1;y<d;y++){let E=o[y];s.write(", "),f[E.type](E,s)}}s.write(")")}t(LM,"formatSequence");function Qft(s,o,f,d){let y=s.expressionsPrecedence[o.type];if(y===LE)return!0;let E=s.expressionsPrecedence[f.type];return y!==E?!d&&y===15&&E===14&&f.operator==="**"||y<E:y!==13&&y!==14?!1:o.operator==="**"&&f.operator==="**"?!d:y===13&&E===13&&(o.operator==="??"||f.operator==="??")?!0:d?Ole[o.operator]<=Ole[f.operator]:Ole[o.operator]<Ole[f.operator]}t(Qft,"expressionNeedsParenthesis");function Fle(s,o,f,d){let{generator:y}=s;Qft(s,o,f,d)?(s.write("("),y[o.type](o,s),s.write(")")):y[o.type](o,s)}t(Fle,"formatExpression");function Kpr(s,o,f,d){let y=o.split(`
599
+ `),jcr=["2023-03-14","2024-01-15","2024-03-14","2024-09-02"];function hlt(s){return!s||jcr.includes(s)}t(hlt,"isLegacyPathBehavior");async function aIe(s){try{let{content:o,warnings:f}=await Bcr(s);return{content:o,errors:[],warnings:f}}catch(o){if(o instanceof A1)return o.toBuildResult();throw o}}t(aIe,"compileRoutes");async function Bcr({sourceDirectory:s,policiesContent:o,oasContent:f,compatibilityDate:d,allowDuplicateRoutes:y}){let E=[],P=[],F=new tle,J=new GV,{policiesNode:V,policiesData:Te}=$cr(o),{generatedPolicies:de,policyNames:ae}=Jcr(F,J,V,Te),{generatedCorsPolicies:Ye,corsPoliciesNames:Ue}=Wcr(F,J,V,Te),je=qcr(s,f),Kt=[],Ut=new Map;for(let Pn of je){let{node:wr,oas:Sr,oasProjectRelativePath:us}=Pn,Fi=BAe(wr,["paths"]);if(!Fi)continue;let cc=sle.basename(Sr.fileName,".oas.json");for(let bi of Fi.children??[])if(bi.children){let Qf=Xcr(bi),S_=Qf[flt]?.pathMode;if(S_){if(S_!==nle&&S_!==sIe)throw new A1({text:`Unknown path mode ${S_}`,location:{line:0,column:0,file:us}})}else S_=nle;for(let[Rn,zE]of Object.entries(Qf)){if(!ile(Rn))continue;let Fl=Rn,Ar=Fl.split(/,/).map(Hs=>Hs.trim().toUpperCase()),AT=zE,bc=AT[rle];if(bc){let Oh=new Qce().validate(bc);if(Oh.isValid){let k0=_lt(bi);if(!Ut.has(k0)&&(Ut.set(k0,new Set),hlt(d)))try{new URLPattern({pathname:k0})}catch{P.push({text:`Path '${k0}' contains invalid characters. The value must be a valid URLPattern.`,location:{line:bi.line,column:bi.column,file:us}})}if(!y){let w0=Ut.get(k0);Ar.forEach(NT=>{w0.has(NT)?P.push({text:`Cannot have duplicate routes declared. Route '${NT.toUpperCase()} ${k0}' declared more than once.`,location:{line:bi.line,column:bi.column,file:us}}):w0.add(NT)})}let b7=plt(bi,[k0,Fl,rle]),sw=await Qcr(b7,Sr);if(!sw.valid)throw new A1({text:sw.errorMsg??`Unknown error on handler for path '${k0}'`,location:{line:sw.line??0,column:sw.column??0,file:us}});let Wi=tlr(b7,Sr);if(!Wi.valid)throw new A1(Wi.errors);Wi.warnings&&E.push(...Wi.warnings),Kt.push({path:k0,pathPattern:k0,pathMode:S_,httpMethods:Ar,rawOperation:Fl,rawOpenAPI:AT,oasFileName:cc,oasProjectRelativePath:us,config:plt(bi,[k0,Fl,rle])})}else throw new A1({text:JSON.stringify(Oh.errors),location:{line:0,column:0,file:us}})}else{let Hs=_lt(bi),Oh={corsPolicy:"none",handler:Zcr(Hs,wr)};Kt.push({path:Hs,pathPattern:Hs,pathMode:nle,rawOpenAPI:AT,oasFileName:cc,oasProjectRelativePath:us,httpMethods:Ar,rawOperation:Fl,config:qV(JSON.stringify(Oh))})}if(bc&&"policies"in bc){let Hs=bc.policies;Hs.inbound?.forEach(Oh=>{ae.includes(Oh)||P.push({text:`Policy '${Oh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})}),Hs.outbound?.forEach(Oh=>{ae.includes(Oh)||P.push({text:`Policy '${Oh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})})}if(P.length>0)throw new A1(P);let Qp=["none","anything-goes"];if(bc&&"corsPolicy"in bc){let Hs=bc.corsPolicy;if(Qp.includes(Hs))continue;Ue.includes(Hs)||P.push({text:`Cors policy '${Hs}' does not exist in policies.json. Please add it and rebuild.`,location:{line:Qf.line,column:Qf.column,file:us}})}}}if(P.length>0)throw new A1(P)}let kr=[];for(let Pn of Kt){let wr=new HV().convert(Pn.config);Vcr(wr,Pn),Hcr(wr,Pn,d),Gcr(wr,Pn),Ycr(wr,Pn),Kcr(wr,Pn);let Sr=F.transform(wr),us=F.errors;if(us.length>0)throw new A1({text:JSON.stringify(us),location:{line:0,column:0,file:Pn.oasProjectRelativePath}});let cc=new GV().generate(Sr);kr.push(cc)}if(GP(je.length===f.length,"Tree length should match OAS file length"),GP(Kt.length===kr.length,`The number of validated nodes should match the number of generated fragments. There were ${Kt.length} validated nodes and ${kr.length} generated fragments.`),P.length>0)throw new A1(P);let An={routes:kr,imports:F.getImports(),policies:de,corsPolicies:Ye};return{content:Mcr(An),warnings:E}}t(Bcr,"generateSourceCode");var Ucr=0,zcr=1;function $cr(s){let o=new Zce,f=JSON.parse(s.content),d=o.validate(f);if(!d.isValid)throw new A1({text:JSON.stringify(d.errors),location:{line:0,column:0,file:"/config/policies.json"}});let y=new HV().parse(JSON.stringify(f));return{policiesData:f,policiesNode:y}}t($cr,"getPolicyData");function Jcr(s,o,f,d){let y=[],E;nI(f);let P=f.children.find(F=>F.name.value==="policies");if(P){let F=s.transform(P);E=o.generate(F),y=d.policies.map(({name:J})=>J)}else E="policies: []";return{generatedPolicies:E,policyNames:y}}t(Jcr,"generatePolicies");function Wcr(s,o,f,d){let y,E;nI(f);let P=f.children.find(F=>F.name.value==="corsPolicies");if(P){let F=s.transform(P);E=o.generate(F),y=d.corsPolicies.map(({name:J})=>J)}else E="corsPolicies: []",y=[];return{generatedCorsPolicies:E,corsPoliciesNames:y}}t(Wcr,"generateCorsPolicies");function qcr(s,o){let f=[];for(let d of o){let y=[],E=qV(d.content,y),P=`./${sle.posix.relative(s.replace(/\\/g,"/"),d.fileName.replace(/\\/g,"/"))}`;if(y.length>0)throw new A1(y.map(F=>({text:Yst(F.error),location:{file:P,line:F.line,column:F.column}})));if(!E)throw new A1({text:"Error parsing the OpenAPI file. Check the contents of the file.",location:{file:P,line:0,column:0}});f.push({node:E,oas:d,oasProjectRelativePath:P})}return f}t(qcr,"getOasTrees");function Vcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"path",type:Wo.Identifier,parent:f},f.value=wS.createLiteral(o.path,f),nI(s),s.children.unshift(f)}t(Vcr,"embellishWithPath");function Hcr(s,o,f){let d={type:Wo.Property,parent:s,name:null,value:null};if(d.name={value:"pathPattern",type:Wo.Identifier,parent:d},o.pathMode===sIe)d.value=wS.createLiteral(o.path,d);else{let y=/{(\S+?)}/gm,E=":$1",P=hlt(f)?o.path:o.path.replace(/([*+?()[\].|^$\\:])/g,"\\$1");P=P.replace(y,E),o.path.endsWith("/")||(P=`${P}{/}?`),d.value=wS.createLiteral(P,d)}nI(s),s.children.unshift(d)}t(Hcr,"embellishWithPathPattern");function Gcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"methods",type:Wo.Identifier,parent:f},f.value=wS.createArrayOfLiterals(o.httpMethods,f),nI(s),s.children.unshift(f)}t(Gcr,"embellishWithMethods");function Ycr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"raw",type:Wo.Identifier,parent:s};let d=AV(o.oasFileName,o.path,o.rawOperation);f.value={type:Wo.Raw,parent:f,value:`() => {return rawRouteData.${d};}`},nI(s),s.children.unshift(f)}t(Ycr,"embellishWithRawOpenApi");function Kcr(s,o){let f={type:Wo.Property,parent:s,name:null,value:null};f.name={value:"metadata",type:Wo.Identifier,parent:s};let d={type:Wo.Property,parent:f,name:null,value:null};d.name={value:"filepath",type:Wo.Identifier,parent:d},d.value=wS.createLiteral(o.oasProjectRelativePath,d),f.value={type:Wo.Object,parent:f,children:[d]},nI(s),s.children.unshift(f)}t(Kcr,"embellishWithMetadata");function Xcr(s){return GP(s.type==="property"),GP(Array.isArray(s.children)),VV(s.children[zcr])}t(Xcr,"evaluatePathItem");function _lt(s){return GP(s.type==="property"),GP(Array.isArray(s.children)),VV(s.children[Ucr])}t(_lt,"evaluatePath");function plt(s,o){return BAe(s.parent,o)}t(plt,"extractZuploRouteNode");function glt(s){return VV(s)}t(glt,"evaluateZuploRouteNode");function Zcr(s,o){let f=/{(\S+?)}/gm,y=s.replace(f,"${params.$1}"),E=VV(o);return{export:"urlRewriteHandler",module:"$import(@zuplo/runtime)",options:{rewritePattern:`${E.servers&&E.servers.length>0?E.servers[0].url:"http://example.com"}${y}`,forwardSearch:!0}}}t(Zcr,"addDefaultUrlRewriteHandler");async function Qcr(s,o){let f=glt(s),d=f.handler.module.replace(/^\$import\(/,"").replace(/\)$/,""),y=sle.join(sle.dirname(o.fileName),"..",`${d}.ts`),E=f.handler.export;if(d==="@zuplo/runtime"||d.startsWith("@zuplo/runtime/"))return{valid:!0};if(await tu.fileExists(y)){let P=await Kst(y);if(P===null)return{valid:!1,errorMsg:`Could not find any export due to a compile error in '${tu.getParentDirFilename(y)}'`};if(!P.has(E)){let F=`Could not find export "${E}" in '${tu.getParentDirFilename(y)}'`,J=0,V=0;if(s.children)for(let Te of s.children)Te.children&&Te.children.forEach(de=>{de.value==="handler"&&(J=de.line,V=de.column)});return{valid:!1,errorMsg:F,line:J,column:V}}return{valid:!0}}else return{valid:!1,errorMsg:`Could not find module '${d}'`}}t(Qcr,"checkModuleIsValid");var dlt=t((s,o)=>{let f=0,d=0;if(s.children)for(let y of s.children)y.children&&y.children.forEach(E=>{E.value==="options"&&E.children?.forEach(P=>{E.value===o&&(f=P.line,d=P.column)})});return{line:f,column:d}},"getHandlerOptionLocation"),elr="$env(";function tlr(s,o){let f=glt(s),d=f.handler.export;if(d!=="urlForwardHandler"&&d!=="urlRewriteHandler")return{valid:!0};let y="rewritePattern";d==="urlForwardHandler"&&(y="baseUrl");let E=f.handler.options[y];if(!E){let P=dlt(s,y);return{valid:!1,errors:[{text:`Invalid request handler configuration. handler.options.${y} is required but was not provided.`,location:{file:o.fileName,line:P.line,column:P.column}}]}}if(E.includes(elr)){let P=dlt(s,y);return{valid:!0,warnings:[{text:`Invalid environment variable access syntax detected. Use \${env.VAR_NAME} instead of $env(VAR_NAME) for handler.options.${y}.`,location:{file:o.fileName,line:P.line,column:P.column}}]}}return{valid:!0}}t(tlr,"checkHandlerIsValid");var WH=ep(S4e(),1);import{readFile as Bpr}from"node:fs/promises";var bT=ep(S4e(),1);var zO=class extends Error{static{t(this,"CustomResolveError")}},bI=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(o,f){this.sourceDirectory=o,this.logger=f}dereference(o,f){return WH.$RefParser.dereference(o,{resolve:{json:!0,file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:f?.onDereference}})}bundle(o){return WH.$RefParser.bundle(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(o){return WH.$RefParser.parse(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(o){return WH.$RefParser.resolve(o,{resolve:{file:Ile(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Ile(s,o){return{order:100,canRead(f){let d=$pr(f.url);if(!(d===void 0||d==="file"))return!1;let E;try{E=Jft(f.url)}catch(P){throw new zO(`Malformed URI: ${f.url}`,{cause:P})}try{tu.safePath(s).resolve(E)}catch(P){return o?.warn(P),!1}return!0},async read(f){let d;try{d=Jft(f.url)}catch(y){throw new zO(`Malformed URI: ${f.url}`,{cause:y})}try{return await Bpr(d)}catch(y){throw new zO(`Error opening file "${d}"`,{cause:y})}}}}t(Ile,"customResolver");var FM=/^win/.test(globalThis.process?globalThis.process.platform:""),Upr=/\//g,zpr=/^(\w{2,}):\/\//i,T4e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function $pr(s){let o=zpr.exec(s);if(o)return o[1].toLowerCase()}t($pr,"getProtocol");function Jft(s,o){s=decodeURI(s);for(let d=0;d<T4e.length;d+=2)s=s.replace(T4e[d],T4e[d+1]);let f=s.substr(0,7).toLowerCase()==="file://";if(f&&(s=s[7]==="/"?s.substr(8):s.substr(7),FM&&s[1]==="/"&&(s=`${s[0]}:${s.substr(1)}`),o?s=`file:///${s}`:(f=!1,s=FM?s:`/${s}`)),!f){let d=s.split(FM?"\\":"/"),y=[];for(let E of d)E===".."?y.length&&y[y.length-1]!==""&&y.pop():(E!==""||y.length===0)&&y.push(E);s=y.join(FM?"\\":"/"),!FM&&y[0]===""&&(s=`/${s.substring(1)}`)}return FM&&!f&&(s=s.replace(Upr,"\\"),s.substr(1,2)===":\\"&&(s=s[0].toUpperCase()+s.substr(1))),s}t(Jft,"toFileSystemPath");var Wft="YOUR_KEY_HERE";async function qft(s){let f=await new bI(s.sourceDirectory,s.logger).bundle(s.openApiDocPath),d=s.openApiDocPath.replace(s.sourceDirectory,"");return Jpr({...s,relativeOpenApiPath:d},f)}t(qft,"buildPublicOpenApiFile");async function Jpr(s,o){Hpr({relativeOpenApiPath:s.relativeOpenApiPath},o);let f=o;return f=qpr(f),Wpr(f,s.urls?.api?.defaultUrl),f=Vpr(f,s),Vft(f,"x-zuplo"),f}t(Jpr,"buildRawOpenApiFile");function Wpr(s,o){o?s.servers=[{url:o}]:s.servers=[]}t(Wpr,"addServerHost");function qpr(s){if(!s.paths)return s;let{components:o}=s,f=o?{...o}:void 0,d=[];f&&f.parameters&&(d=Object.entries(f.parameters).reduce((E,[P,F])=>(j9 in F&&Qae(F[j9])&&(E.push(P),f.parameters&&delete f.parameters[P]),E),[]));let y=Object.entries(s.paths).reduce((E,[P,F])=>{if(!F)return E;let J={...F},V=["delete","get","head","patch","post","put","trace","options"];return V.forEach(Te=>{let de=F[Te];if(!de)return;if(Qae(de[j9])){delete J[Te];return}let{parameters:ae}=de;if(!ae)return;let Ye=ae.filter(Ue=>{if(j9 in Ue&&Qae(Ue[j9]))return!1;if("$ref"in Ue){let je=Ue.$ref.split("/").pop();return je?!d.includes(je):!0}return!0});J[Te]={...de,parameters:Ye}}),V.some(Te=>!!J[Te])&&(E[P]=J),E},{});return{...s,paths:y,components:f}}t(qpr,"removeHiddenRoutesAndParams");function Vpr(s,{policiesConfig:o}){if(!s.paths)return s;let f=Object.entries(s.paths).reduce((d,[y,E])=>{if(!E)return d;let P={...E};return[P.delete,P.get,P.head,P.patch,P.post,P.put,P.trace,P.options].forEach(F=>{if(!F)return;let J=F["x-zuplo-route"]?.policies?.inbound?.reduce((de,ae)=>{let Ye=o.policies?.find(({name:Kt})=>Kt===ae);if(!Ye)return de;if(!(Ye.handler.export==="CompositeInboundPolicy"))return de.concat(ae);let je=Ye.handler.options?.policies;return je?de.concat(je):de},[]),V=[];if(J&&J.forEach(de=>{o.policies?.forEach(ae=>{ae.name===de&&(ae.handler.export==="ApiAuthKeyInboundPolicy"||ae.handler.export==="ApiKeyInboundPolicy")&&!ae.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&V.push(ae)})}),V.length>0){let de=V.length>0&&V[0].handler&&V[0].handler.options&&V[0].handler.options.authHeader?V[0].handler.options.authHeader:"Authorization",ae=V.length>0&&V[0].handler&&V[0].handler.options&&(V[0].handler.options.authScheme||V[0].handler.options.authScheme==="")?V[0].handler.options.authScheme:"Bearer",Ye=ae!==""?`${ae} ${Wft}`:Wft,Ue={name:de,in:"header",required:!0,example:Ye,schema:{type:"string"},description:`The \`${de}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ye}\`.`};F.parameters?F.parameters.some(kr=>"name"in kr&&kr.name===Ue.name)||F.parameters.unshift(Ue):F.parameters=[Ue];let je={type:"http",scheme:ae.toLowerCase()},Kt="api_key";s.components?.securitySchemes?Object.values(s.components?.securitySchemes).some(kr=>"name"in kr&&kr.type==="apiKey"||"type"in kr&&kr.type==="http"&&kr.scheme===ae)||(s.components.securitySchemes={...s.components.securitySchemes,[Kt]:je}):(s.components||(s.components={}),s.components.securitySchemes={[Kt]:je});let Ut={[Kt]:[]};F.security?F.security.some(kr=>kr[Kt]!==void 0)||F.security.unshift(Ut):F.security=[Ut]}let Te=[];if(J&&J.forEach(de=>{o.policies?.forEach(ae=>{ae.name===de&&(ae.handler.export==="RateLimitInboundPolicy"||ae.handler.export==="ComplexRateLimitInboundPolicy")&&Te.push(ae)})}),Te.length>0){let de={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},ae={...de,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};s.components?.responses||s.components||(s.components={}),s.components.responses={...s.components.responses,RateLimitNoRetryAfter:de,RateLimitWithRetryAfter:ae},F.responses||(F.responses={});let Ye=Te.some(Ue=>Ue.handler.options?.headerMode!=="none");F.responses[429]||(F.responses[429]={$ref:Ye?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),d[y]=P,d},{});return{...s,paths:f}}t(Vpr,"enrichSpecWithZuploData");function Vft(s,o){for(let f in s)f.startsWith(o)?delete s[f]:typeof s[f]=="object"&&Vft(s[f],o)}t(Vft,"removePropertiesByPrefix");function Hpr({relativeOpenApiPath:s},o){if(!o||typeof o!="object")throw new k1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in o)||typeof o.info!="object"||!o.info)throw new k1({message:"The OpenAPI document does not have the required 'info' property.",location:{file:s,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in o.info)||typeof o.info.title!="string")throw new k1({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:s,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(Hpr,"assertIsZuploOpenApiSpec");import edr from"node:fs/promises";import tdr from"node:path";var{stringify:Gpr}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");var Ole={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},LE=17,Ypr={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:LE,ClassExpression:LE,FunctionExpression:LE,ObjectExpression:LE,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function LM(s,o){let{generator:f}=s;if(s.write("("),o!=null&&o.length>0){f[o[0].type](o[0],s);let{length:d}=o;for(let y=1;y<d;y++){let E=o[y];s.write(", "),f[E.type](E,s)}}s.write(")")}t(LM,"formatSequence");function Qft(s,o,f,d){let y=s.expressionsPrecedence[o.type];if(y===LE)return!0;let E=s.expressionsPrecedence[f.type];return y!==E?!d&&y===15&&E===14&&f.operator==="**"||y<E:y!==13&&y!==14?!1:o.operator==="**"&&f.operator==="**"?!d:y===13&&E===13&&(o.operator==="??"||f.operator==="??")?!0:d?Ole[o.operator]<=Ole[f.operator]:Ole[o.operator]<Ole[f.operator]}t(Qft,"expressionNeedsParenthesis");function Fle(s,o,f,d){let{generator:y}=s;Qft(s,o,f,d)?(s.write("("),y[o.type](o,s),s.write(")")):y[o.type](o,s)}t(Fle,"formatExpression");function Kpr(s,o,f,d){let y=o.split(`
600
600
  `),E=y.length-1;if(s.write(y[0].trim()),E>0){s.write(d);for(let P=1;P<E;P++)s.write(f+y[P].trim()+d);s.write(f+y[E].trim())}}t(Kpr,"reindent");function R1(s,o,f,d){let{length:y}=o;for(let E=0;E<y;E++){let P=o[E];s.write(f),P.type[0]==="L"?s.write("// "+P.value.trim()+`
601
601
  `,P):(s.write("/*"),Kpr(s,P.value,f,d),s.write("*/"+d))}}t(R1,"formatComments");function Xpr(s){let o=s;for(;o!=null;){let{type:f}=o;if(f[0]==="C"&&f[1]==="a")return!0;if(f[0]==="M"&&f[1]==="e"&&f[2]==="m")o=o.object;else return!1}}t(Xpr,"hasCallExpression");function x4e(s,o){let{generator:f}=s,{declarations:d}=o;s.write(o.kind+" ");let{length:y}=d;if(y>0){f.VariableDeclarator(d[0],s);for(let E=1;E<y;E++)s.write(", "),f.VariableDeclarator(d[E],s)}}t(x4e,"formatVariableDeclaration");var Hft,Gft,Yft,Kft,Xft,Zft,Zpr={Program(s,o){let f=o.indent.repeat(o.indentLevel),{lineEnd:d,writeComments:y}=o;y&&s.comments!=null&&R1(o,s.comments,f,d);let E=s.body,{length:P}=E;for(let F=0;F<P;F++){let J=E[F];y&&J.comments!=null&&R1(o,J.comments,f,d),o.write(f),this[J.type](J,o),o.write(d)}y&&s.trailingComments!=null&&R1(o,s.trailingComments,f,d)},BlockStatement:Zft=t(function(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o,E=f+o.indent;o.write("{");let P=s.body;if(P!=null&&P.length>0){o.write(d),y&&s.comments!=null&&R1(o,s.comments,E,d);let{length:F}=P;for(let J=0;J<F;J++){let V=P[J];y&&V.comments!=null&&R1(o,V.comments,E,d),o.write(E),this[V.type](V,o),o.write(d)}o.write(f)}else y&&s.comments!=null&&(o.write(d),R1(o,s.comments,E,d),o.write(f));y&&s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write("}"),o.indentLevel--},"BlockStatement"),ClassBody:Zft,StaticBlock(s,o){o.write("static "),this.BlockStatement(s,o)},EmptyStatement(s,o){o.write(";")},ExpressionStatement(s,o){let f=o.expressionsPrecedence[s.expression.type];f===LE||f===3&&s.expression.left.type[0]==="O"?(o.write("("),this[s.expression.type](s.expression,o),o.write(")")):this[s.expression.type](s.expression,o),o.write(";")},IfStatement(s,o){o.write("if ("),this[s.test.type](s.test,o),o.write(") "),this[s.consequent.type](s.consequent,o),s.alternate!=null&&(o.write(" else "),this[s.alternate.type](s.alternate,o))},LabeledStatement(s,o){this[s.label.type](s.label,o),o.write(": "),this[s.body.type](s.body,o)},BreakStatement(s,o){o.write("break"),s.label!=null&&(o.write(" "),this[s.label.type](s.label,o)),o.write(";")},ContinueStatement(s,o){o.write("continue"),s.label!=null&&(o.write(" "),this[s.label.type](s.label,o)),o.write(";")},WithStatement(s,o){o.write("with ("),this[s.object.type](s.object,o),o.write(") "),this[s.body.type](s.body,o)},SwitchStatement(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o;o.indentLevel++;let E=f+o.indent,P=E+o.indent;o.write("switch ("),this[s.discriminant.type](s.discriminant,o),o.write(") {"+d);let{cases:F}=s,{length:J}=F;for(let V=0;V<J;V++){let Te=F[V];y&&Te.comments!=null&&R1(o,Te.comments,E,d),Te.test?(o.write(E+"case "),this[Te.test.type](Te.test,o),o.write(":"+d)):o.write(E+"default:"+d);let{consequent:de}=Te,{length:ae}=de;for(let Ye=0;Ye<ae;Ye++){let Ue=de[Ye];y&&Ue.comments!=null&&R1(o,Ue.comments,P,d),o.write(P),this[Ue.type](Ue,o),o.write(d)}}o.indentLevel-=2,o.write(f+"}")},ReturnStatement(s,o){o.write("return"),s.argument&&(o.write(" "),this[s.argument.type](s.argument,o)),o.write(";")},ThrowStatement(s,o){o.write("throw "),this[s.argument.type](s.argument,o),o.write(";")},TryStatement(s,o){if(o.write("try "),this[s.block.type](s.block,o),s.handler){let{handler:f}=s;f.param==null?o.write(" catch "):(o.write(" catch ("),this[f.param.type](f.param,o),o.write(") ")),this[f.body.type](f.body,o)}s.finalizer&&(o.write(" finally "),this[s.finalizer.type](s.finalizer,o))},WhileStatement(s,o){o.write("while ("),this[s.test.type](s.test,o),o.write(") "),this[s.body.type](s.body,o)},DoWhileStatement(s,o){o.write("do "),this[s.body.type](s.body,o),o.write(" while ("),this[s.test.type](s.test,o),o.write(");")},ForStatement(s,o){if(o.write("for ("),s.init!=null){let{init:f}=s;f.type[0]==="V"?x4e(o,f):this[f.type](f,o)}o.write("; "),s.test&&this[s.test.type](s.test,o),o.write("; "),s.update&&this[s.update.type](s.update,o),o.write(") "),this[s.body.type](s.body,o)},ForInStatement:Hft=t(function(s,o){o.write(`for ${s.await?"await ":""}(`);let{left:f}=s;f.type[0]==="V"?x4e(o,f):this[f.type](f,o),o.write(s.type[3]==="I"?" in ":" of "),this[s.right.type](s.right,o),o.write(") "),this[s.body.type](s.body,o)},"ForInStatement"),ForOfStatement:Hft,DebuggerStatement(s,o){o.write("debugger;",s)},FunctionDeclaration:Gft=t(function(s,o){o.write((s.async?"async ":"")+(s.generator?"function* ":"function ")+(s.id?s.id.name:""),s),LM(o,s.params),o.write(" "),this[s.body.type](s.body,o)},"FunctionDeclaration"),FunctionExpression:Gft,VariableDeclaration(s,o){x4e(o,s),o.write(";")},VariableDeclarator(s,o){this[s.id.type](s.id,o),s.init!=null&&(o.write(" = "),this[s.init.type](s.init,o))},ClassDeclaration(s,o){if(o.write("class "+(s.id?`${s.id.name} `:""),s),s.superClass){o.write("extends ");let{superClass:f}=s,{type:d}=f,y=o.expressionsPrecedence[d];(d[0]!=="C"||d[1]!=="l"||d[5]!=="E")&&(y===LE||y<o.expressionsPrecedence.ClassExpression)?(o.write("("),this[s.superClass.type](f,o),o.write(")")):this[f.type](f,o),o.write(" ")}this.ClassBody(s.body,o)},ImportDeclaration(s,o){o.write("import ");let{specifiers:f,attributes:d}=s,{length:y}=f,E=0;if(y>0){for(;E<y;){E>0&&o.write(", ");let P=f[E],F=P.type[6];if(F==="D")o.write(P.local.name,P),E++;else if(F==="N")o.write("* as "+P.local.name,P),E++;else break}if(E<y){for(o.write("{");;){let P=f[E],{name:F}=P.imported;if(o.write(F,P),F!==P.local.name&&o.write(" as "+P.local.name),++E<y)o.write(", ");else break}o.write("}")}o.write(" from ")}if(this.Literal(s.source,o),d&&d.length>0){o.write(" with { ");for(let P=0;P<d.length;P++)this.ImportAttribute(d[P],o),P<d.length-1&&o.write(", ");o.write(" }")}o.write(";")},ImportAttribute(s,o){this.Identifier(s.key,o),o.write(": "),this.Literal(s.value,o)},ImportExpression(s,o){o.write("import("),this[s.source.type](s.source,o),o.write(")")},ExportDefaultDeclaration(s,o){o.write("export default "),this[s.declaration.type](s.declaration,o),o.expressionsPrecedence[s.declaration.type]!=null&&s.declaration.type[0]!=="F"&&o.write(";")},ExportNamedDeclaration(s,o){if(o.write("export "),s.declaration)this[s.declaration.type](s.declaration,o);else{o.write("{");let{specifiers:f}=s,{length:d}=f;if(d>0)for(let y=0;;){let E=f[y],{name:P}=E.local;if(o.write(P,E),P!==E.exported.name&&o.write(" as "+E.exported.name),++y<d)o.write(", ");else break}if(o.write("}"),s.source&&(o.write(" from "),this.Literal(s.source,o)),s.attributes&&s.attributes.length>0){o.write(" with { ");for(let y=0;y<s.attributes.length;y++)this.ImportAttribute(s.attributes[y],o),y<s.attributes.length-1&&o.write(", ");o.write(" }")}o.write(";")}},ExportAllDeclaration(s,o){if(s.exported!=null?o.write("export * as "+s.exported.name+" from "):o.write("export * from "),this.Literal(s.source,o),s.attributes&&s.attributes.length>0){o.write(" with { ");for(let f=0;f<s.attributes.length;f++)this.ImportAttribute(s.attributes[f],o),f<s.attributes.length-1&&o.write(", ");o.write(" }")}o.write(";")},MethodDefinition(s,o){s.static&&o.write("static ");let f=s.kind[0];(f==="g"||f==="s")&&o.write(s.kind+" "),s.value.async&&o.write("async "),s.value.generator&&o.write("*"),s.computed?(o.write("["),this[s.key.type](s.key,o),o.write("]")):this[s.key.type](s.key,o),LM(o,s.value.params),o.write(" "),this[s.value.body.type](s.value.body,o)},ClassExpression(s,o){this.ClassDeclaration(s,o)},ArrowFunctionExpression(s,o){o.write(s.async?"async ":"",s);let{params:f}=s;f!=null&&(f.length===1&&f[0].type[0]==="I"?o.write(f[0].name,f[0]):LM(o,s.params)),o.write(" => "),s.body.type[0]==="O"?(o.write("("),this.ObjectExpression(s.body,o),o.write(")")):this[s.body.type](s.body,o)},ThisExpression(s,o){o.write("this",s)},Super(s,o){o.write("super",s)},RestElement:Yft=t(function(s,o){o.write("..."),this[s.argument.type](s.argument,o)},"RestElement"),SpreadElement:Yft,YieldExpression(s,o){o.write(s.delegate?"yield*":"yield"),s.argument&&(o.write(" "),this[s.argument.type](s.argument,o))},AwaitExpression(s,o){o.write("await ",s),Fle(o,s.argument,s)},TemplateLiteral(s,o){let{quasis:f,expressions:d}=s;o.write("`");let{length:y}=d;for(let P=0;P<y;P++){let F=d[P],J=f[P];o.write(J.value.raw,J),o.write("${"),this[F.type](F,o),o.write("}")}let E=f[f.length-1];o.write(E.value.raw,E),o.write("`")},TemplateElement(s,o){o.write(s.value.raw,s)},TaggedTemplateExpression(s,o){Fle(o,s.tag,s),this[s.quasi.type](s.quasi,o)},ArrayExpression:Xft=t(function(s,o){if(o.write("["),s.elements.length>0){let{elements:f}=s,{length:d}=f;for(let y=0;;){let E=f[y];if(E!=null&&this[E.type](E,o),++y<d)o.write(", ");else{E==null&&o.write(", ");break}}}o.write("]")},"ArrayExpression"),ArrayPattern:Xft,ObjectExpression(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o,E=f+o.indent;if(o.write("{"),s.properties.length>0){o.write(d),y&&s.comments!=null&&R1(o,s.comments,E,d);let P=","+d,{properties:F}=s,{length:J}=F;for(let V=0;;){let Te=F[V];if(y&&Te.comments!=null&&R1(o,Te.comments,E,d),o.write(E),this[Te.type](Te,o),++V<J)o.write(P);else break}o.write(d),y&&s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write(f+"}")}else y?s.comments!=null?(o.write(d),R1(o,s.comments,E,d),s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write(f+"}")):s.trailingComments!=null?(o.write(d),R1(o,s.trailingComments,E,d),o.write(f+"}")):o.write("}"):o.write("}");o.indentLevel--},Property(s,o){s.method||s.kind[0]!=="i"?this.MethodDefinition(s,o):(s.shorthand||(s.computed?(o.write("["),this[s.key.type](s.key,o),o.write("]")):this[s.key.type](s.key,o),o.write(": ")),this[s.value.type](s.value,o))},PropertyDefinition(s,o){if(s.static&&o.write("static "),s.computed&&o.write("["),this[s.key.type](s.key,o),s.computed&&o.write("]"),s.value==null){s.key.type[0]!=="F"&&o.write(";");return}o.write(" = "),this[s.value.type](s.value,o),o.write(";")},ObjectPattern(s,o){if(o.write("{"),s.properties.length>0){let{properties:f}=s,{length:d}=f;for(let y=0;this[f[y].type](f[y],o),++y<d;)o.write(", ")}o.write("}")},SequenceExpression(s,o){LM(o,s.expressions)},UnaryExpression(s,o){if(s.prefix){let{operator:f,argument:d,argument:{type:y}}=s;o.write(f);let E=Qft(o,d,s);!E&&(f.length>1||y[0]==="U"&&(y[1]==="n"||y[1]==="p")&&d.prefix&&d.operator[0]===f&&(f==="+"||f==="-"))&&o.write(" "),E?(o.write(f.length>1?" (":"("),this[y](d,o),o.write(")")):this[y](d,o)}else this[s.argument.type](s.argument,o),o.write(s.operator)},UpdateExpression(s,o){s.prefix?(o.write(s.operator),this[s.argument.type](s.argument,o)):(this[s.argument.type](s.argument,o),o.write(s.operator))},AssignmentExpression(s,o){this[s.left.type](s.left,o),o.write(" "+s.operator+" "),this[s.right.type](s.right,o)},AssignmentPattern(s,o){this[s.left.type](s.left,o),o.write(" = "),this[s.right.type](s.right,o)},BinaryExpression:Kft=t(function(s,o){let f=s.operator==="in";f&&o.write("("),Fle(o,s.left,s,!1),o.write(" "+s.operator+" "),Fle(o,s.right,s,!0),f&&o.write(")")},"BinaryExpression"),LogicalExpression:Kft,ConditionalExpression(s,o){let{test:f}=s,d=o.expressionsPrecedence[f.type];d===LE||d<=o.expressionsPrecedence.ConditionalExpression?(o.write("("),this[f.type](f,o),o.write(")")):this[f.type](f,o),o.write(" ? "),this[s.consequent.type](s.consequent,o),o.write(" : "),this[s.alternate.type](s.alternate,o)},NewExpression(s,o){o.write("new ");let f=o.expressionsPrecedence[s.callee.type];f===LE||f<o.expressionsPrecedence.CallExpression||Xpr(s.callee)?(o.write("("),this[s.callee.type](s.callee,o),o.write(")")):this[s.callee.type](s.callee,o),LM(o,s.arguments)},CallExpression(s,o){let f=o.expressionsPrecedence[s.callee.type];f===LE||f<o.expressionsPrecedence.CallExpression?(o.write("("),this[s.callee.type](s.callee,o),o.write(")")):this[s.callee.type](s.callee,o),s.optional&&o.write("?."),LM(o,s.arguments)},ChainExpression(s,o){this[s.expression.type](s.expression,o)},MemberExpression(s,o){let f=o.expressionsPrecedence[s.object.type];f===LE||f<o.expressionsPrecedence.MemberExpression?(o.write("("),this[s.object.type](s.object,o),o.write(")")):this[s.object.type](s.object,o),s.computed?(s.optional&&o.write("?."),o.write("["),this[s.property.type](s.property,o),o.write("]")):(s.optional?o.write("?."):o.write("."),this[s.property.type](s.property,o))},MetaProperty(s,o){o.write(s.meta.name+"."+s.property.name,s)},Identifier(s,o){o.write(s.name,s)},PrivateIdentifier(s,o){o.write(`#${s.name}`,s)},Literal(s,o){s.raw!=null?o.write(s.raw,s):s.regex!=null?this.RegExpLiteral(s,o):s.bigint!=null?o.write(s.bigint+"n",s):o.write(Gpr(s.value),s)},RegExpLiteral(s,o){let{regex:f}=s;o.write(`/${f.pattern}/${f.flags}`,s)}},Qpr={};var E4e=class{static{t(this,"State")}constructor(o){let f=o??Qpr;this.output="",f.output!=null?(this.output=f.output,this.write=this.writeToStream):this.output="",this.generator=f.generator!=null?f.generator:Zpr,this.expressionsPrecedence=f.expressionsPrecedence!=null?f.expressionsPrecedence:Ypr,this.indent=f.indent!=null?f.indent:" ",this.lineEnd=f.lineEnd!=null?f.lineEnd:`
602
602
  `,this.indentLevel=f.startingIndentLevel!=null?f.startingIndentLevel:0,this.writeComments=f.comments?f.comments:!1,f.sourceMap!=null&&(this.write=f.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=f.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/core",
3
- "version": "6.69.11",
3
+ "version": "6.70.0",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "type": "module",
@@ -40,9 +40,9 @@
40
40
  "source-map": "^0.7.4"
41
41
  },
42
42
  "peerDependencies": {
43
- "@zuplo/graphql": "6.69.11",
44
- "@zuplo/otel": "6.69.11",
45
- "@zuplo/runtime": "6.69.11",
43
+ "@zuplo/graphql": "6.70.0",
44
+ "@zuplo/otel": "6.70.0",
45
+ "@zuplo/runtime": "6.70.0",
46
46
  "deno": "2.3.1"
47
47
  }
48
48
  }