@zuplo/core 7.5.0 → 7.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/customer.cli.minified.js +1 -1
- package/index.minified.js +1 -1
- package/package.json +4 -4
package/customer.cli.minified.js
CHANGED
|
@@ -572,7 +572,7 @@ globstar while`,s,pe,o,ae,rt),this.matchOne(s.slice(pe),o.slice(ae),f))return th
|
|
|
572
572
|
`),stderr:E.join(`
|
|
573
573
|
`),exitCode:A},"Tar process logs")}}t(LXt,"tarFolder");async function RXt({tarFilePath:s,outputDir:o,logger:f}){let d=[],y=[],E;try{await new Promise((A,R)=>{let q=tit("sh",["-c",`tar -xvf ${s} -C ${o};`]);q.stdout.on("data",K=>{let ve=K.toString().trim();ve.length>0&&d.push(ve.trim())}),q.stderr.on("data",K=>{let ve=K.toString().trim();ve.length>0&&y.push(ve.trim())}),q.on("close",K=>{E=K,K===0?A():R(new Error(`tar process exited with code ${K}`))}),q.on("error",K=>{R(K)})})}catch(A){throw new Error("Failed to untar file",{cause:A})}finally{f.info({stdout:d.join(`
|
|
574
574
|
`),stderr:y.join(`
|
|
575
|
-
`),exitCode:E},"Untar process logs")}}t(RXt,"untarFile");async function MXt(s){if(await XPe(s))return await qN.rm(s,{recursive:!0})}t(MXt,"deleteFolder");var nu=ZPe;var Yct=wp(Est(),1);import{AssertionError as uer}from"node:assert";function UP(s,o){if(s===!1)throw new uer({message:o})}t(UP,"assert");var qo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(qo||(qo={}));function H9(s){return s.type===qo.Object}t(H9,"isAstObject");function zP(s){return s.type===qo.Property}t(zP,"isAstProperty");function IAe(s){return s.type===qo.Array}t(IAe,"isAstArray");function fO(s){return s.type===qo.Literal}t(fO,"isAstLiteral");function GN(s){if(s===void 0)throw new Error("Node is undefined");if(!H9(s))throw new Error("Node is not object")}t(GN,"assertAstObject");import{findNodeAtLocation as fer,getNodeValue as _er,printParseErrorCode as per,visit as der}from"jsonc-parser";var mer={DEFAULT:{allowTrailingComma:!1}};function UV(s,o=[],f=mer.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(q){d.type==="property"&&(d.length=q-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function E(q){return d.children?.push(q),q}t(E,"onValue"),der(s,{onObjectBegin:t((q,K,ve,pe)=>{d=E({type:"object",offset:q,length:-1,line:ve+1,column:pe+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((q,K,ve,pe,ae)=>{d=E({type:"property",offset:K,length:-1,line:pe+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:q,offset:K,length:ve,line:pe,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((q,K)=>{y(q+K),d.length=q+K-d.offset,d=d.parent,y(q+K)},"onObjectEnd"),onArrayBegin:t((q,K,ve,pe)=>{d=E({type:"array",offset:q,length:-1,line:ve+1,column:pe+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((q,K)=>{d.length=q+K-d.offset,d=d.parent,y(q+K)},"onArrayEnd"),onLiteralValue:t((q,K,ve,pe,ae)=>{E({type:her(q),offset:K,length:ve,line:pe+1,column:ae+1,parent:d,value:q}),y(K+ve)},"onLiteralValue"),onSeparator:t((q,K)=>{d.type==="property"&&(q===":"?d.colonOffset=K:q===","&&y(K))},"onSeparator"),onError:t((q,K,ve,pe,ae)=>{o.push({error:q,offset:K,length:ve,line:pe+1,column:ae+1})},"onError")},f);let R=d.children?.[0];return R&&delete R.parent,R}t(UV,"parse");function her(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(her,"getNodeType");function G9(s,o){return fer(s,o)}t(G9,"findNodeAtLocation");function zV(s){return _er(s)}t(zV,"getNodeValue");function Cst(s){return per(s)}t(Cst,"printParseErrorCode");var JV=class{static{t(this,"AstAdapter")}parse(o){let d=UV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:qo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:qo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){UP(o.children?.length===2,"Invalid property node");let d={type:qo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:qo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:qo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var PS={createLiteral:t((s,o)=>({type:qo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:qo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:qo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:qo.Property,parent:f,name:null,value:o};return d.name={value:s,type:qo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:qo.Array,parent:o,children:[]};for(let d of s)f.children.push(PS.createLiteral(d,f));return f},"createArrayOfLiterals")};var ger=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,$V=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case qo.Array:return this.generateArray(o,f);case qo.Object:return this.generateObject(o,f);case qo.Property:return this.generateProperty(o,f);case qo.Literal:return this.generateLiteral(o,f);case qo.FunctionCall:return this.generateFunctionCall(o,f);case qo.Identifier:return this.generateIdentifier(o,f);case qo.Raw:return this.generateRaw(o,f);case qo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,E)=>{this.generateSource(o,d),y<E.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=ger.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import yer from"node:fs/promises";import{parse as ver}from"@swc/core";var kst=t(async s=>{let o=new Set;try{let f=await yer.readFile(s,"utf-8");(await ver(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"getJSFileExports");var wst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-dlp","ai-gateway-fallback-model-v2","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"],Dst={"ai-gateway-auth-v2-inbound":"ai-gateway-auth-v2","ai-gateway-configuration-executor-v2-inbound":"ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2-inbound":"ai-gateway-configuration-loader-v2","ai-gateway-dlp-inbound":"ai-gateway-dlp","ai-gateway-fallback-model-v2-inbound":"ai-gateway-fallback-model-v2","ai-gateway-metering-v2-inbound":"ai-gateway-metering-v2","ai-gateway-model-filtering-v2-inbound":"ai-gateway-model-filtering-v2","ai-gateway-semantic-cache-inbound":"ai-gateway-semantic-cache","ai-gateway-semantic-cache-outbound":"ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2-inbound":"ai-gateway-semantic-cache-v2","akamai-ai-firewall-v2-inbound":"akamai-ai-firewall-v2","akamai-firewall-for-ai-inbound":"akamai-firewall-for-ai","akamai-firewall-for-ai-outbound":"akamai-firewall-for-ai","comet-opik-tracing-v2-inbound":"comet-opik-tracing-v2","galileo-tracing-v2-inbound":"galileo-tracing-v2","prompt-injection-outbound":"prompt-injection","semantic-cache-inbound":"semantic-cache"};var Pst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var OAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Ast={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var FAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var LAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var Bct=wp(Hce(),1),Uct=wp(Xce(),1);var Zce=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new Bct.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Uct.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let E={details:{}},A=y.instancePath.split("/");if(A.length>2){let q=A[1],K=A[2]?parseInt(A[2],10):0,ve=A[3],pe=Number.isNaN(K)?void 0:f[q][K][ve];E={details:{property:q,index:K,field:ve,fieldValue:pe}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let q=y.instancePath.split("/"),K=q[q.length-1];y.message=`Value of property '${K}' must be '${y.params.type}'`}let R=Object.assign(y,E);d.push(R)}),d}};var iI=Zce.instance;iI.addSchema(FAe,"route-configuration.schema.json");iI.addSchema(Ast,"policy-configuration.schema.json");iI.addSchema(OAe,"policies.schema.json");iI.addSchema(LAe,"open-api-route-configuration.schema.json");iI.addSchema(Pst,"fragments.schema.json");var HAr=iI.compile(FAe),zct=iI.compile(LAe),XNe=iI.compile(OAe);var Qce=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=XNe(o),this.results}};var ele=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=zct(o),this.results}};import Wor from"node:path";var ZNe=/\$import\((.*)\)/,bH=/\$env\((.*?)\)/g;var jk=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},$or=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),qP=t((s,o)=>{if(!s)return!1;let f=$or(s);return o.split("/").every((E,A)=>{let R=f[A];return R?E==="*"||zP(R)&&R.name.value===E?!0:E==="{}"?R.type===qo.Object:E==="[]"?R.type===qo.Array:!1:!1})},"testPosition");var tle=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),H9(o)?o.children.forEach(f=>{this.visitor(f)}):IAe(o)?o.children.forEach(f=>{this.visitor(f)}):zP(o)&&this.visitor(o.value)}},Jct=t(s=>{let o=new RegExp(bH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(bH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),$ct=t((s,o,f)=>d=>{if(fO(d)&&typeof d.value=="string"&&d.parent&&IAe(d.parent)){if(!s.some(A=>qP(d.parent,A))){bH.test(d.value)&&o.push(new jk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=Jct(d.value);if(E){let A=d.parent,R=A.children.indexOf(d);if(R!==-1)if(E.type==="raw"){let q={type:qo.Raw,parent:A,value:E.value};A.children[R]=q}else A.children[R]=PS.createTemplateString(E.value,d)}return}if(!zP(d)||!fO(d.value)||typeof d.value.value!="string")return;if(!s.some(E=>qP(d,E))){bH.test(d.value.value)&&o.push(new jk("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=Jct(d.value.value);if(y)if(y.type==="raw"){let E={type:qo.Raw,parent:null,value:y.value};d.value=E}else d.value=PS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var SH="config/routes.json",qor=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Vor=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","handler/{}/options/{}/onOpen/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Wct=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Hor="handler/{}/options/{}/rewritePattern",Gor="handler/{}/options/{}/baseUrl",rle=class extends tle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!zP(o)||!fO(o.value)||typeof o.value.value!="string")&&qP(o,Hor)){if(!o.parent||!H9(o.parent)){this.errors.push(new jk("Invalid node, expected object",SH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:qct(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!zP(o)||!fO(o.value)||typeof o.value.value!="string")&&qP(o,Gor)){if(!o.parent||!H9(o.parent)){this.errors.push(new jk("Invalid node, expected object",SH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:qct(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!zP(o)||!fO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!Vor.some(R=>qP(o,R))&&!Wct.some(R=>qP(o,R))){if(ZNe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new jk("An $import() statement is not expected at this location.",SH,o.location,f))}return}let d=ZNe.exec(f);if(Wct.some(R=>qP(o,R))&&!d)return;if(!d){this.errors.push(new jk("Invalid $import() statement",SH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Wor.posix.join("..",y));let E=this.getImportName(y),A={type:qo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=$ct(qor,this.errors,SH)};function qct(s){return`(request, context) => {
|
|
575
|
+
`),exitCode:E},"Untar process logs")}}t(RXt,"untarFile");async function MXt(s){if(await XPe(s))return await qN.rm(s,{recursive:!0})}t(MXt,"deleteFolder");var nu=ZPe;var Yct=wp(Est(),1);import{AssertionError as uer}from"node:assert";function UP(s,o){if(s===!1)throw new uer({message:o})}t(UP,"assert");var qo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(qo||(qo={}));function H9(s){return s.type===qo.Object}t(H9,"isAstObject");function zP(s){return s.type===qo.Property}t(zP,"isAstProperty");function IAe(s){return s.type===qo.Array}t(IAe,"isAstArray");function fO(s){return s.type===qo.Literal}t(fO,"isAstLiteral");function GN(s){if(s===void 0)throw new Error("Node is undefined");if(!H9(s))throw new Error("Node is not object")}t(GN,"assertAstObject");import{findNodeAtLocation as fer,getNodeValue as _er,printParseErrorCode as per,visit as der}from"jsonc-parser";var mer={DEFAULT:{allowTrailingComma:!1}};function UV(s,o=[],f=mer.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(q){d.type==="property"&&(d.length=q-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function E(q){return d.children?.push(q),q}t(E,"onValue"),der(s,{onObjectBegin:t((q,K,ve,pe)=>{d=E({type:"object",offset:q,length:-1,line:ve+1,column:pe+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((q,K,ve,pe,ae)=>{d=E({type:"property",offset:K,length:-1,line:pe+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:q,offset:K,length:ve,line:pe,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((q,K)=>{y(q+K),d.length=q+K-d.offset,d=d.parent,y(q+K)},"onObjectEnd"),onArrayBegin:t((q,K,ve,pe)=>{d=E({type:"array",offset:q,length:-1,line:ve+1,column:pe+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((q,K)=>{d.length=q+K-d.offset,d=d.parent,y(q+K)},"onArrayEnd"),onLiteralValue:t((q,K,ve,pe,ae)=>{E({type:her(q),offset:K,length:ve,line:pe+1,column:ae+1,parent:d,value:q}),y(K+ve)},"onLiteralValue"),onSeparator:t((q,K)=>{d.type==="property"&&(q===":"?d.colonOffset=K:q===","&&y(K))},"onSeparator"),onError:t((q,K,ve,pe,ae)=>{o.push({error:q,offset:K,length:ve,line:pe+1,column:ae+1})},"onError")},f);let R=d.children?.[0];return R&&delete R.parent,R}t(UV,"parse");function her(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(her,"getNodeType");function G9(s,o){return fer(s,o)}t(G9,"findNodeAtLocation");function zV(s){return _er(s)}t(zV,"getNodeValue");function Cst(s){return per(s)}t(Cst,"printParseErrorCode");var JV=class{static{t(this,"AstAdapter")}parse(o){let d=UV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:qo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:qo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){UP(o.children?.length===2,"Invalid property node");let d={type:qo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:qo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:qo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var PS={createLiteral:t((s,o)=>({type:qo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:qo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:qo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:qo.Property,parent:f,name:null,value:o};return d.name={value:s,type:qo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:qo.Array,parent:o,children:[]};for(let d of s)f.children.push(PS.createLiteral(d,f));return f},"createArrayOfLiterals")};var ger=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,$V=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case qo.Array:return this.generateArray(o,f);case qo.Object:return this.generateObject(o,f);case qo.Property:return this.generateProperty(o,f);case qo.Literal:return this.generateLiteral(o,f);case qo.FunctionCall:return this.generateFunctionCall(o,f);case qo.Identifier:return this.generateIdentifier(o,f);case qo.Raw:return this.generateRaw(o,f);case qo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,E)=>{this.generateSource(o,d),y<E.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=ger.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import yer from"node:fs/promises";import{parse as ver}from"@swc/core";var kst=t(async s=>{let o=new Set;try{let f=await yer.readFile(s,"utf-8");(await ver(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"getJSFileExports");var wst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-dlp","ai-gateway-fallback-model-v2","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","ai-gateway-smart-router","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"],Dst={"ai-gateway-auth-v2-inbound":"ai-gateway-auth-v2","ai-gateway-configuration-executor-v2-inbound":"ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2-inbound":"ai-gateway-configuration-loader-v2","ai-gateway-dlp-inbound":"ai-gateway-dlp","ai-gateway-fallback-model-v2-inbound":"ai-gateway-fallback-model-v2","ai-gateway-metering-v2-inbound":"ai-gateway-metering-v2","ai-gateway-model-filtering-v2-inbound":"ai-gateway-model-filtering-v2","ai-gateway-semantic-cache-inbound":"ai-gateway-semantic-cache","ai-gateway-semantic-cache-outbound":"ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2-inbound":"ai-gateway-semantic-cache-v2","ai-gateway-smart-router-inbound":"ai-gateway-smart-router","akamai-ai-firewall-v2-inbound":"akamai-ai-firewall-v2","akamai-firewall-for-ai-inbound":"akamai-firewall-for-ai","akamai-firewall-for-ai-outbound":"akamai-firewall-for-ai","comet-opik-tracing-v2-inbound":"comet-opik-tracing-v2","galileo-tracing-v2-inbound":"galileo-tracing-v2","prompt-injection-outbound":"prompt-injection","semantic-cache-inbound":"semantic-cache"};var Pst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var OAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Ast={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var FAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var LAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var Bct=wp(Hce(),1),Uct=wp(Xce(),1);var Zce=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new Bct.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Uct.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let E={details:{}},A=y.instancePath.split("/");if(A.length>2){let q=A[1],K=A[2]?parseInt(A[2],10):0,ve=A[3],pe=Number.isNaN(K)?void 0:f[q][K][ve];E={details:{property:q,index:K,field:ve,fieldValue:pe}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let q=y.instancePath.split("/"),K=q[q.length-1];y.message=`Value of property '${K}' must be '${y.params.type}'`}let R=Object.assign(y,E);d.push(R)}),d}};var iI=Zce.instance;iI.addSchema(FAe,"route-configuration.schema.json");iI.addSchema(Ast,"policy-configuration.schema.json");iI.addSchema(OAe,"policies.schema.json");iI.addSchema(LAe,"open-api-route-configuration.schema.json");iI.addSchema(Pst,"fragments.schema.json");var HAr=iI.compile(FAe),zct=iI.compile(LAe),XNe=iI.compile(OAe);var Qce=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=XNe(o),this.results}};var ele=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=zct(o),this.results}};import Wor from"node:path";var ZNe=/\$import\((.*)\)/,bH=/\$env\((.*?)\)/g;var jk=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},$or=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),qP=t((s,o)=>{if(!s)return!1;let f=$or(s);return o.split("/").every((E,A)=>{let R=f[A];return R?E==="*"||zP(R)&&R.name.value===E?!0:E==="{}"?R.type===qo.Object:E==="[]"?R.type===qo.Array:!1:!1})},"testPosition");var tle=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),H9(o)?o.children.forEach(f=>{this.visitor(f)}):IAe(o)?o.children.forEach(f=>{this.visitor(f)}):zP(o)&&this.visitor(o.value)}},Jct=t(s=>{let o=new RegExp(bH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(bH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),$ct=t((s,o,f)=>d=>{if(fO(d)&&typeof d.value=="string"&&d.parent&&IAe(d.parent)){if(!s.some(A=>qP(d.parent,A))){bH.test(d.value)&&o.push(new jk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=Jct(d.value);if(E){let A=d.parent,R=A.children.indexOf(d);if(R!==-1)if(E.type==="raw"){let q={type:qo.Raw,parent:A,value:E.value};A.children[R]=q}else A.children[R]=PS.createTemplateString(E.value,d)}return}if(!zP(d)||!fO(d.value)||typeof d.value.value!="string")return;if(!s.some(E=>qP(d,E))){bH.test(d.value.value)&&o.push(new jk("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=Jct(d.value.value);if(y)if(y.type==="raw"){let E={type:qo.Raw,parent:null,value:y.value};d.value=E}else d.value=PS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var SH="config/routes.json",qor=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Vor=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","handler/{}/options/{}/onOpen/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Wct=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Hor="handler/{}/options/{}/rewritePattern",Gor="handler/{}/options/{}/baseUrl",rle=class extends tle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!zP(o)||!fO(o.value)||typeof o.value.value!="string")&&qP(o,Hor)){if(!o.parent||!H9(o.parent)){this.errors.push(new jk("Invalid node, expected object",SH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:qct(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!zP(o)||!fO(o.value)||typeof o.value.value!="string")&&qP(o,Gor)){if(!o.parent||!H9(o.parent)){this.errors.push(new jk("Invalid node, expected object",SH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:qct(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!zP(o)||!fO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!Vor.some(R=>qP(o,R))&&!Wct.some(R=>qP(o,R))){if(ZNe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new jk("An $import() statement is not expected at this location.",SH,o.location,f))}return}let d=ZNe.exec(f);if(Wct.some(R=>qP(o,R))&&!d)return;if(!d){this.errors.push(new jk("Invalid $import() statement",SH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Wor.posix.join("..",y));let E=this.getImportName(y),A={type:qo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=$ct(qor,this.errors,SH)};function qct(s){return`(request, context) => {
|
|
576
576
|
const { params, url, query, method, headers } = request;
|
|
577
577
|
const { host, hostname, origin, pathname, port, search } = new URL(url);
|
|
578
578
|
const e = encodeURIComponent;
|
package/index.minified.js
CHANGED
|
@@ -572,7 +572,7 @@ globstar while`,s,pe,o,ae,rt),this.matchOne(s.slice(pe),o.slice(ae),f))return th
|
|
|
572
572
|
`),stderr:E.join(`
|
|
573
573
|
`),exitCode:A},"Tar process logs")}}t(sZt,"tarFolder");async function aZt({tarFilePath:s,outputDir:o,logger:f}){let d=[],y=[],E;try{await new Promise((A,R)=>{let q=cit("sh",["-c",`tar -xvf ${s} -C ${o};`]);q.stdout.on("data",K=>{let ve=K.toString().trim();ve.length>0&&d.push(ve.trim())}),q.stderr.on("data",K=>{let ve=K.toString().trim();ve.length>0&&y.push(ve.trim())}),q.on("close",K=>{E=K,K===0?A():R(new Error(`tar process exited with code ${K}`))}),q.on("error",K=>{R(K)})})}catch(A){throw new Error("Failed to untar file",{cause:A})}finally{f.info({stdout:d.join(`
|
|
574
574
|
`),stderr:y.join(`
|
|
575
|
-
`),exitCode:E},"Untar process logs")}}t(aZt,"untarFile");async function oZt(s){if(await nAe(s))return await GN.rm(s,{recursive:!0})}t(oZt,"deleteFolder");var nu=iAe;var rlt=R_(Nst(),1);import{AssertionError as Fer}from"node:assert";function $P(s,o){if(s===!1)throw new Fer({message:o})}t($P,"assert");var qo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(qo||(qo={}));function H9(s){return s.type===qo.Object}t(H9,"isAstObject");function WP(s){return s.type===qo.Property}t(WP,"isAstProperty");function jAe(s){return s.type===qo.Array}t(jAe,"isAstArray");function pO(s){return s.type===qo.Literal}t(pO,"isAstLiteral");function XN(s){if(s===void 0)throw new Error("Node is undefined");if(!H9(s))throw new Error("Node is not object")}t(XN,"assertAstObject");import{findNodeAtLocation as Ler,getNodeValue as Rer,printParseErrorCode as Mer,visit as jer}from"jsonc-parser";var Ber={DEFAULT:{allowTrailingComma:!1}};function zV(s,o=[],f=Ber.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(q){d.type==="property"&&(d.length=q-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function E(q){return d.children?.push(q),q}t(E,"onValue"),jer(s,{onObjectBegin:t((q,K,ve,pe)=>{d=E({type:"object",offset:q,length:-1,line:ve+1,column:pe+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((q,K,ve,pe,ae)=>{d=E({type:"property",offset:K,length:-1,line:pe+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:q,offset:K,length:ve,line:pe,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((q,K)=>{y(q+K),d.length=q+K-d.offset,d=d.parent,y(q+K)},"onObjectEnd"),onArrayBegin:t((q,K,ve,pe)=>{d=E({type:"array",offset:q,length:-1,line:ve+1,column:pe+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((q,K)=>{d.length=q+K-d.offset,d=d.parent,y(q+K)},"onArrayEnd"),onLiteralValue:t((q,K,ve,pe,ae)=>{E({type:Uer(q),offset:K,length:ve,line:pe+1,column:ae+1,parent:d,value:q}),y(K+ve)},"onLiteralValue"),onSeparator:t((q,K)=>{d.type==="property"&&(q===":"?d.colonOffset=K:q===","&&y(K))},"onSeparator"),onError:t((q,K,ve,pe,ae)=>{o.push({error:q,offset:K,length:ve,line:pe+1,column:ae+1})},"onError")},f);let R=d.children?.[0];return R&&delete R.parent,R}t(zV,"parse");function Uer(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(Uer,"getNodeType");function G9(s,o){return Ler(s,o)}t(G9,"findNodeAtLocation");function JV(s){return Rer(s)}t(JV,"getNodeValue");function Ist(s){return Mer(s)}t(Ist,"printParseErrorCode");var $V=class{static{t(this,"AstAdapter")}parse(o){let d=zV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:qo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:qo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){$P(o.children?.length===2,"Invalid property node");let d={type:qo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:qo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:qo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var PS={createLiteral:t((s,o)=>({type:qo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:qo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:qo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:qo.Property,parent:f,name:null,value:o};return d.name={value:s,type:qo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:qo.Array,parent:o,children:[]};for(let d of s)f.children.push(PS.createLiteral(d,f));return f},"createArrayOfLiterals")};var zer=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,WV=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case qo.Array:return this.generateArray(o,f);case qo.Object:return this.generateObject(o,f);case qo.Property:return this.generateProperty(o,f);case qo.Literal:return this.generateLiteral(o,f);case qo.FunctionCall:return this.generateFunctionCall(o,f);case qo.Identifier:return this.generateIdentifier(o,f);case qo.Raw:return this.generateRaw(o,f);case qo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,E)=>{this.generateSource(o,d),y<E.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=zer.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Jer from"node:fs/promises";import{parse as $er}from"@swc/core";var Ost=t(async s=>{let o=new Set;try{let f=await Jer.readFile(s,"utf-8");(await $er(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"getJSFileExports");var Fst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-dlp","ai-gateway-fallback-model-v2","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"],Lst={"ai-gateway-auth-v2-inbound":"ai-gateway-auth-v2","ai-gateway-configuration-executor-v2-inbound":"ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2-inbound":"ai-gateway-configuration-loader-v2","ai-gateway-dlp-inbound":"ai-gateway-dlp","ai-gateway-fallback-model-v2-inbound":"ai-gateway-fallback-model-v2","ai-gateway-metering-v2-inbound":"ai-gateway-metering-v2","ai-gateway-model-filtering-v2-inbound":"ai-gateway-model-filtering-v2","ai-gateway-semantic-cache-inbound":"ai-gateway-semantic-cache","ai-gateway-semantic-cache-outbound":"ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2-inbound":"ai-gateway-semantic-cache-v2","akamai-ai-firewall-v2-inbound":"akamai-ai-firewall-v2","akamai-firewall-for-ai-inbound":"akamai-firewall-for-ai","akamai-firewall-for-ai-outbound":"akamai-firewall-for-ai","comet-opik-tracing-v2-inbound":"comet-opik-tracing-v2","galileo-tracing-v2-inbound":"galileo-tracing-v2","prompt-injection-outbound":"prompt-injection","semantic-cache-inbound":"semantic-cache"};var Rst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var BAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Mst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var UAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var zAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var Vct=R_(Gce(),1),Hct=R_(Zce(),1);var Qce=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new Vct.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Hct.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let E={details:{}},A=y.instancePath.split("/");if(A.length>2){let q=A[1],K=A[2]?parseInt(A[2],10):0,ve=A[3],pe=Number.isNaN(K)?void 0:f[q][K][ve];E={details:{property:q,index:K,field:ve,fieldValue:pe}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let q=y.instancePath.split("/"),K=q[q.length-1];y.message=`Value of property '${K}' must be '${y.params.type}'`}let R=Object.assign(y,E);d.push(R)}),d}};var oI=Qce.instance;oI.addSchema(UAe,"route-configuration.schema.json");oI.addSchema(Mst,"policy-configuration.schema.json");oI.addSchema(BAe,"policies.schema.json");oI.addSchema(zAe,"open-api-route-configuration.schema.json");oI.addSchema(Rst,"fragments.schema.json");var y6r=oI.compile(UAe),Gct=oI.compile(zAe),nIe=oI.compile(BAe);var ele=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=nIe(o),this.results}};var tle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=Gct(o),this.results}};import dcr from"node:path";var iIe=/\$import\((.*)\)/,SH=/\$env\((.*?)\)/g;var Uk=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},pcr=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),GP=t((s,o)=>{if(!s)return!1;let f=pcr(s);return o.split("/").every((E,A)=>{let R=f[A];return R?E==="*"||WP(R)&&R.name.value===E?!0:E==="{}"?R.type===qo.Object:E==="[]"?R.type===qo.Array:!1:!1})},"testPosition");var rle=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),H9(o)?o.children.forEach(f=>{this.visitor(f)}):jAe(o)?o.children.forEach(f=>{this.visitor(f)}):WP(o)&&this.visitor(o.value)}},Yct=t(s=>{let o=new RegExp(SH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(SH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),Kct=t((s,o,f)=>d=>{if(pO(d)&&typeof d.value=="string"&&d.parent&&jAe(d.parent)){if(!s.some(A=>GP(d.parent,A))){SH.test(d.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=Yct(d.value);if(E){let A=d.parent,R=A.children.indexOf(d);if(R!==-1)if(E.type==="raw"){let q={type:qo.Raw,parent:A,value:E.value};A.children[R]=q}else A.children[R]=PS.createTemplateString(E.value,d)}return}if(!WP(d)||!pO(d.value)||typeof d.value.value!="string")return;if(!s.some(E=>GP(d,E))){SH.test(d.value.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=Yct(d.value.value);if(y)if(y.type==="raw"){let E={type:qo.Raw,parent:null,value:y.value};d.value=E}else d.value=PS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var TH="config/routes.json",mcr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],hcr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","handler/{}/options/{}/onOpen/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Xct=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],gcr="handler/{}/options/{}/rewritePattern",ycr="handler/{}/options/{}/baseUrl",nle=class extends rle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!WP(o)||!pO(o.value)||typeof o.value.value!="string")&&GP(o,gcr)){if(!o.parent||!H9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",TH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:Zct(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!WP(o)||!pO(o.value)||typeof o.value.value!="string")&&GP(o,ycr)){if(!o.parent||!H9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",TH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:Zct(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!WP(o)||!pO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!hcr.some(R=>GP(o,R))&&!Xct.some(R=>GP(o,R))){if(iIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Uk("An $import() statement is not expected at this location.",TH,o.location,f))}return}let d=iIe.exec(f);if(Xct.some(R=>GP(o,R))&&!d)return;if(!d){this.errors.push(new Uk("Invalid $import() statement",TH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=dcr.posix.join("..",y));let E=this.getImportName(y),A={type:qo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=Kct(mcr,this.errors,TH)};function Zct(s){return`(request, context) => {
|
|
575
|
+
`),exitCode:E},"Untar process logs")}}t(aZt,"untarFile");async function oZt(s){if(await nAe(s))return await GN.rm(s,{recursive:!0})}t(oZt,"deleteFolder");var nu=iAe;var rlt=R_(Nst(),1);import{AssertionError as Fer}from"node:assert";function $P(s,o){if(s===!1)throw new Fer({message:o})}t($P,"assert");var qo;(function(s){s.Object="Object",s.Property="Property",s.Array="Array",s.Literal="Literal",s.TemplateString="TemplateString",s.Identifier="Identifier",s.FunctionCall="FunctionCall",s.Raw="Raw"})(qo||(qo={}));function H9(s){return s.type===qo.Object}t(H9,"isAstObject");function WP(s){return s.type===qo.Property}t(WP,"isAstProperty");function jAe(s){return s.type===qo.Array}t(jAe,"isAstArray");function pO(s){return s.type===qo.Literal}t(pO,"isAstLiteral");function XN(s){if(s===void 0)throw new Error("Node is undefined");if(!H9(s))throw new Error("Node is not object")}t(XN,"assertAstObject");import{findNodeAtLocation as Ler,getNodeValue as Rer,printParseErrorCode as Mer,visit as jer}from"jsonc-parser";var Ber={DEFAULT:{allowTrailingComma:!1}};function zV(s,o=[],f=Ber.DEFAULT){let d={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function y(q){d.type==="property"&&(d.length=q-d.offset,d=d.parent)}t(y,"ensurePropertyComplete");function E(q){return d.children?.push(q),q}t(E,"onValue"),jer(s,{onObjectBegin:t((q,K,ve,pe)=>{d=E({type:"object",offset:q,length:-1,line:ve+1,column:pe+1,parent:d,children:[]})},"onObjectBegin"),onObjectProperty:t((q,K,ve,pe,ae)=>{d=E({type:"property",offset:K,length:-1,line:pe+1,column:ae+1,parent:d,children:[]}),d.children?.push({type:"string",value:q,offset:K,length:ve,line:pe,column:ae,parent:d})},"onObjectProperty"),onObjectEnd:t((q,K)=>{y(q+K),d.length=q+K-d.offset,d=d.parent,y(q+K)},"onObjectEnd"),onArrayBegin:t((q,K,ve,pe)=>{d=E({type:"array",offset:q,length:-1,line:ve+1,column:pe+1,parent:d,children:[]})},"onArrayBegin"),onArrayEnd:t((q,K)=>{d.length=q+K-d.offset,d=d.parent,y(q+K)},"onArrayEnd"),onLiteralValue:t((q,K,ve,pe,ae)=>{E({type:Uer(q),offset:K,length:ve,line:pe+1,column:ae+1,parent:d,value:q}),y(K+ve)},"onLiteralValue"),onSeparator:t((q,K)=>{d.type==="property"&&(q===":"?d.colonOffset=K:q===","&&y(K))},"onSeparator"),onError:t((q,K,ve,pe,ae)=>{o.push({error:q,offset:K,length:ve,line:pe+1,column:ae+1})},"onError")},f);let R=d.children?.[0];return R&&delete R.parent,R}t(zV,"parse");function Uer(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(s){if(Array.isArray(s))return"array"}else return"null";return"object"}default:return"null"}}t(Uer,"getNodeType");function G9(s,o){return Ler(s,o)}t(G9,"findNodeAtLocation");function JV(s){return Rer(s)}t(JV,"getNodeValue");function Ist(s){return Mer(s)}t(Ist,"printParseErrorCode");var $V=class{static{t(this,"AstAdapter")}parse(o){let d=zV(o,[]);if(d)return this.parseNode(d,void 0);throw new Error("Failed to parse JSON")}convert(o){return this.parseNode(o,void 0)}parseNode(o,f){switch(o.type){case"object":return this.createObject(o,f);case"array":return this.createArray(o,f);case"property":return this.createProperty(o,f);case"string":return this.createLiteral(o,f);case"number":return this.createLiteral(o,f);case"boolean":return this.createLiteral(o,f);case"null":return this.createLiteral(o,f)}}createLiteral(o,f){return{type:qo.Literal,location:{line:o.line,column:o.column},parent:f,value:o.type==="null"?null:o.value}}createObject(o,f){let d={type:qo.Object,children:[],parent:f,location:{line:o.line,column:o.column}};return o.children?.forEach(y=>{d.children.push(this.parseNode(y,d))}),d}createProperty(o,f){$P(o.children?.length===2,"Invalid property node");let d={type:qo.Property,location:{line:o.line,column:o.column},parent:f,name:null,value:null};return d.name={value:o.children[0].value,location:{line:o.line,column:o.column},type:qo.Identifier,parent:d},d.value=this.parseNode(o.children[1],d),d}createArray(o,f){let d={type:qo.Array,location:{line:o.line,column:o.column},parent:f,children:[]};return o.children?.forEach(y=>d.children.push(this.parseNode(y,d))),d}};var PS={createLiteral:t((s,o)=>({type:qo.Literal,parent:o,value:s}),"createLiteral"),createTemplateString:t((s,o)=>({type:qo.TemplateString,parent:o,value:s}),"createTemplateString"),createIdentifier:t((s,o)=>({type:qo.Identifier,value:s,parent:o}),"createIdentifier"),createProperty:t((s,o,f)=>{let d={type:qo.Property,parent:f,name:null,value:o};return d.name={value:s,type:qo.Identifier,parent:d},d.value.parent=d,d},"createProperty"),createArrayOfLiterals:t((s,o)=>{let f={type:qo.Array,parent:o,children:[]};for(let d of s)f.children.push(PS.createLiteral(d,f));return f},"createArrayOfLiterals")};var zer=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,WV=class{static{t(this,"SourceGenerator")}generate(o){let f=[];return this.generateSource(f,o),f.join("")}generateSource(o,f){switch(f.type){case qo.Array:return this.generateArray(o,f);case qo.Object:return this.generateObject(o,f);case qo.Property:return this.generateProperty(o,f);case qo.Literal:return this.generateLiteral(o,f);case qo.FunctionCall:return this.generateFunctionCall(o,f);case qo.Identifier:return this.generateIdentifier(o,f);case qo.Raw:return this.generateRaw(o,f);case qo.TemplateString:return this.generateTemplateString(o,f)}}generateArray(o,f){o.push("["),f.children.map(d=>{this.generateSource(o,d),o.push(",")}),o.push("]")}generateObject(o,f){o.push("{"),f.children.forEach(d=>{this.generateSource(o,d),o.push(",")}),o.push("}")}generateProperty(o,f){this.generateIdentifier(o,f.name),o.push(":"),this.generateSource(o,f.value)}generateFunctionCall(o,f){o.push(f.name.value),o.push("("),f.children.forEach((d,y,E)=>{this.generateSource(o,d),y<E.length&&o.push(",")}),o.push(")")}generateRaw(o,f){o.push(f.value)}generateTemplateString(o,f){o.push("`"),o.push(f.value.replaceAll("`","\\`")),o.push("`")}generateLiteral(o,f){if(f.value===null)return o.push("null");switch(typeof f.value){case"number":case"boolean":return o.push(`${f.value}`);case"string":{let d=f.value,y=JSON.stringify(d);return o.push(`${y}`)}}}generateIdentifier(o,f){let d=zer.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Jer from"node:fs/promises";import{parse as $er}from"@swc/core";var Ost=t(async s=>{let o=new Set;try{let f=await Jer.readFile(s,"utf-8");(await $er(f,{syntax:"typescript"})).body.forEach(y=>{y.type==="ExportDefaultDeclaration"||y.type==="ExportDefaultExpression"?o.add("default"):y.type==="ExportDeclaration"&&y.declaration.type==="FunctionDeclaration"?o.add(y.declaration.identifier.value):y.type==="ExportDeclaration"&&y.declaration.type==="VariableDeclaration"&&y.declaration.declarations[0].id.type==="Identifier"&&o.add(y.declaration.declarations[0].id.value)})}catch{return null}return o},"getJSFileExports");var Fst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-dlp","ai-gateway-fallback-model-v2","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2","ai-gateway-smart-router","akamai-ai-firewall","akamai-ai-firewall-v2","akamai-firewall-for-ai","comet-opik-tracing-v2","galileo-tracing-v2","prompt-injection","semantic-cache"],Lst={"ai-gateway-auth-v2-inbound":"ai-gateway-auth-v2","ai-gateway-configuration-executor-v2-inbound":"ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2-inbound":"ai-gateway-configuration-loader-v2","ai-gateway-dlp-inbound":"ai-gateway-dlp","ai-gateway-fallback-model-v2-inbound":"ai-gateway-fallback-model-v2","ai-gateway-metering-v2-inbound":"ai-gateway-metering-v2","ai-gateway-model-filtering-v2-inbound":"ai-gateway-model-filtering-v2","ai-gateway-semantic-cache-inbound":"ai-gateway-semantic-cache","ai-gateway-semantic-cache-outbound":"ai-gateway-semantic-cache","ai-gateway-semantic-cache-v2-inbound":"ai-gateway-semantic-cache-v2","ai-gateway-smart-router-inbound":"ai-gateway-smart-router","akamai-ai-firewall-v2-inbound":"akamai-ai-firewall-v2","akamai-firewall-for-ai-inbound":"akamai-firewall-for-ai","akamai-firewall-for-ai-outbound":"akamai-firewall-for-ai","comet-opik-tracing-v2-inbound":"comet-opik-tracing-v2","galileo-tracing-v2-inbound":"galileo-tracing-v2","prompt-injection-outbound":"prompt-injection","semantic-cache-inbound":"semantic-cache"};var Rst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var BAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var Mst={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var UAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var zAe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{oneOf:[{type:"object",additionalProperties:!1,properties:{type:{const:"tool"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"},includeOutputSchema:{type:"boolean"},includeStructuredContent:{type:"boolean"},annotations:{type:"object",additionalProperties:!1,properties:{title:{type:"string"},readOnlyHint:{type:"boolean"},destructiveHint:{type:"boolean"},idempotentHint:{type:"boolean"},openWorldHint:{type:"boolean"}}},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"prompt"},name:{type:"string"},description:{type:"string"},enabled:{type:"boolean"}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"resource"},name:{type:"string"},description:{type:"string"},uri:{type:"string"},mimeType:{type:"string"},enabled:{type:"boolean"},_meta:{type:"object",additionalProperties:!0}},required:["type"]},{type:"object",additionalProperties:!1,properties:{type:{const:"graphql"},enabled:{type:"boolean"},introspectionTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},executeTool:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}}},required:["type"]}]},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var Vct=R_(Gce(),1),Hct=R_(Zce(),1);var Qce=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new Vct.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Hct.default)(this.ajv,{mode:"fast"})}addSchema(o,f){this.ajv.addSchema(o,f)}compile(o){let f=this.ajv.compile(o);return t(y=>({isValid:f(y),errors:this.toSimpleErrors(f.errors,y),warnings:[]}),"validator")}toSimpleErrors(o,f){let d=[];return o?.forEach(y=>{y.keyword==="enum"&&y.params.allowedValues&&Array.isArray(y.params.allowedValues)&&(y.message+=`; ${y.params.allowedValues.join(", ")}`),y.instancePath&&(y.instancePath=y.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let E={details:{}},A=y.instancePath.split("/");if(A.length>2){let q=A[1],K=A[2]?parseInt(A[2],10):0,ve=A[3],pe=Number.isNaN(K)?void 0:f[q][K][ve];E={details:{property:q,index:K,field:ve,fieldValue:pe}}}if(y.keyword==="required"&&y.params.missingProperty&&y.instancePath&&(y.message=`A 'path' is missing required property '${y.params.missingProperty}'`),y.keyword==="additionalProperties"&&y.params.additionalProperty&&y.instancePath&&(y.message=`A 'path' should NOT include property '${y.params.additionalProperty}'`),y.keyword==="type"&&y.params.type&&y.instancePath){let q=y.instancePath.split("/"),K=q[q.length-1];y.message=`Value of property '${K}' must be '${y.params.type}'`}let R=Object.assign(y,E);d.push(R)}),d}};var oI=Qce.instance;oI.addSchema(UAe,"route-configuration.schema.json");oI.addSchema(Mst,"policy-configuration.schema.json");oI.addSchema(BAe,"policies.schema.json");oI.addSchema(zAe,"open-api-route-configuration.schema.json");oI.addSchema(Rst,"fragments.schema.json");var y6r=oI.compile(UAe),Gct=oI.compile(zAe),nIe=oI.compile(BAe);var ele=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=nIe(o),this.results}};var tle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=Gct(o),this.results}};import dcr from"node:path";var iIe=/\$import\((.*)\)/,SH=/\$env\((.*?)\)/g;var Uk=class extends Error{static{t(this,"CodeGenError")}location;constructor(o,f,d,y){super(o),this.location={file:f,namespace:"",line:d?d.line:0,column:d?d.column:0,length:0,lineText:y??"",suggestion:""}}},pcr=t(s=>{let o=[],f=s;for(;f.parent;)o.push(f),f=f.parent;return o.reverse()},"invertTree"),GP=t((s,o)=>{if(!s)return!1;let f=pcr(s);return o.split("/").every((E,A)=>{let R=f[A];return R?E==="*"||WP(R)&&R.name.value===E?!0:E==="{}"?R.type===qo.Object:E==="[]"?R.type===qo.Array:!1:!1})},"testPosition");var rle=class{static{t(this,"AstTransformer")}errors=[];transform(o){return this.visitor(o),o}visitor(o){this.visit(o),H9(o)?o.children.forEach(f=>{this.visitor(f)}):jAe(o)?o.children.forEach(f=>{this.visitor(f)}):WP(o)&&this.visitor(o.value)}},Yct=t(s=>{let o=new RegExp(SH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(SH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),Kct=t((s,o,f)=>d=>{if(pO(d)&&typeof d.value=="string"&&d.parent&&jAe(d.parent)){if(!s.some(A=>GP(d.parent,A))){SH.test(d.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=Yct(d.value);if(E){let A=d.parent,R=A.children.indexOf(d);if(R!==-1)if(E.type==="raw"){let q={type:qo.Raw,parent:A,value:E.value};A.children[R]=q}else A.children[R]=PS.createTemplateString(E.value,d)}return}if(!WP(d)||!pO(d.value)||typeof d.value.value!="string")return;if(!s.some(E=>GP(d,E))){SH.test(d.value.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value.value));return}let y=Yct(d.value.value);if(y)if(y.type==="raw"){let E={type:qo.Raw,parent:null,value:y.value};d.value=E}else d.value=PS.createTemplateString(y.value,d)},"getEnvStatementTransformer");var TH="config/routes.json",mcr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],hcr=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","handler/{}/options/{}/onOpen/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],Xct=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],gcr="handler/{}/options/{}/rewritePattern",ycr="handler/{}/options/{}/baseUrl",nle=class extends rle{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(o){this.addedImports.has(o)||this.addedImports.set(o,`__import${this.importCount++}`);let f=this.addedImports.get(o);if(!f)throw new Error("Import name is undefined. This should not happen.");return f}getImports(){let o=[];return this.addedImports.forEach((f,d)=>{o.push({name:f,path:d})}),o}visit(o){this.rewriteHandlerFunction(o),this.rewriteForwardFunction(o),this.replaceImportStatements(o),this.replaceEnvStatements(o)}rewriteHandlerFunction(o){if(!(!WP(o)||!pO(o.value)||typeof o.value.value!="string")&&GP(o,gcr)){if(!o.parent||!H9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",TH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:Zct(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}rewriteForwardFunction(o){if(!(!WP(o)||!pO(o.value)||typeof o.value.value!="string")&&GP(o,ycr)){if(!o.parent||!H9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",TH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:Zct(f)},y=PS.createProperty("__rewriteFunction",d,o);o.parent.children.push(y)}}replaceImportStatements(o){if(!WP(o)||!pO(o.value))return;let f=o.value.value;if(typeof f!="string")return;if(!hcr.some(R=>GP(o,R))&&!Xct.some(R=>GP(o,R))){if(iIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Uk("An $import() statement is not expected at this location.",TH,o.location,f))}return}let d=iIe.exec(f);if(Xct.some(R=>GP(o,R))&&!d)return;if(!d){this.errors.push(new Uk("Invalid $import() statement",TH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=dcr.posix.join("..",y));let E=this.getImportName(y),A={type:qo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=Kct(mcr,this.errors,TH)};function Zct(s){return`(request, context) => {
|
|
576
576
|
const { params, url, query, method, headers } = request;
|
|
577
577
|
const { host, hostname, origin, pathname, port, search } = new URL(url);
|
|
578
578
|
const e = encodeURIComponent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/core",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.2",
|
|
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": "7.5.
|
|
44
|
-
"@zuplo/otel": "7.5.
|
|
45
|
-
"@zuplo/runtime": "7.5.
|
|
43
|
+
"@zuplo/graphql": "7.5.2",
|
|
44
|
+
"@zuplo/otel": "7.5.2",
|
|
45
|
+
"@zuplo/runtime": "7.5.2",
|
|
46
46
|
"deno": "2.3.1"
|
|
47
47
|
}
|
|
48
48
|
}
|