@zuplo/core 7.8.20 → 7.8.22
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(zXt,"tarFolder");async function JXt({tarFilePath:s,outputDir:o,logger:f}){let d=[],y=[],E;try{await new Promise((A,R)=>{let q=nit("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(JXt,"untarFile");async function $Xt(s){if(await QPe(s))return await qN.rm(s,{recursive:!0})}t($Xt,"deleteFolder");var nu=eAe;var Xct=wp(kst(),1);import{AssertionError as her}from"node:assert";function UP(s,o){if(s===!1)throw new her({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 FAe(s){return s.type===qo.Array}t(FAe,"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 ger,getNodeValue as yer,printParseErrorCode as ver,visit as ber}from"jsonc-parser";var Ser={DEFAULT:{allowTrailingComma:!1}};function zV(s,o=[],f=Ser.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"),ber(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:Ter(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 Ter(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(Ter,"getNodeType");function G9(s,o){return ger(s,o)}t(G9,"findNodeAtLocation");function JV(s){return yer(s)}t(JV,"getNodeValue");function wst(s){return ver(s)}t(wst,"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){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 xer=/^[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=xer.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Eer from"node:fs/promises";import{parse as Cer}from"@swc/core";var Dst=t(async s=>{let o=new Set;try{let f=await Eer.readFile(s,"utf-8");(await Cer(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 Pst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-dlp","ai-gateway-fallback-model-v2","ai-gateway-internal-only","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-prompt-injection","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"],Ast={"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-internal-only-inbound":"ai-gateway-internal-only","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 Nst={$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 LAe={$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 Ist={$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 RAe={$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 MAe={$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"},toolInputStyle:{enum:["flat","nested"]},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 zct=wp(Yce(),1),Jct=wp(Qce(),1);var ele=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new zct.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Jct.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=ele.instance;iI.addSchema(RAe,"route-configuration.schema.json");iI.addSchema(Ist,"policy-configuration.schema.json");iI.addSchema(LAe,"policies.schema.json");iI.addSchema(MAe,"open-api-route-configuration.schema.json");iI.addSchema(Nst,"fragments.schema.json");var r6r=iI.compile(RAe),$ct=iI.compile(MAe),QNe=iI.compile(LAe);var tle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=QNe(o),this.results}};var rle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=$ct(o),this.results}};import Kor from"node:path";var eIe=/\$import\((.*)\)/,SH=/\$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:""}}},Yor=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=Yor(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 nle=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)}):FAe(o)?o.children.forEach(f=>{this.visitor(f)}):zP(o)&&this.visitor(o.value)}},Wct=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"),qct=t((s,o,f)=>d=>{if(fO(d)&&typeof d.value=="string"&&d.parent&&FAe(d.parent)){if(!s.some(A=>qP(d.parent,A))){SH.test(d.value)&&o.push(new jk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=Wct(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))){SH.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=Wct(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",Xor=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Zor=["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"],Vct=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Qor="handler/{}/options/{}/rewritePattern",ecr="handler/{}/options/{}/baseUrl",ile=class extends nle{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,Qor)){if(!o.parent||!H9(o.parent)){this.errors.push(new jk("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:Hct(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,ecr)){if(!o.parent||!H9(o.parent)){this.errors.push(new jk("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:Hct(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(!Zor.some(R=>qP(o,R))&&!Vct.some(R=>qP(o,R))){if(eIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new jk("An $import() statement is not expected at this location.",TH,o.location,f))}return}let d=eIe.exec(f);if(Vct.some(R=>qP(o,R))&&!d)return;if(!d){this.errors.push(new jk("Invalid $import() statement",TH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Kor.posix.join("..",y));let E=this.getImportName(y),A={type:qo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=qct(Xor,this.errors,TH)};function Hct(s){return`(request, context) => {
|
|
575
|
+
`),exitCode:E},"Untar process logs")}}t(JXt,"untarFile");async function $Xt(s){if(await QPe(s))return await qN.rm(s,{recursive:!0})}t($Xt,"deleteFolder");var nu=eAe;var Xct=wp(kst(),1);import{AssertionError as her}from"node:assert";function UP(s,o){if(s===!1)throw new her({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 FAe(s){return s.type===qo.Array}t(FAe,"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 ger,getNodeValue as yer,printParseErrorCode as ver,visit as ber}from"jsonc-parser";var Ser={DEFAULT:{allowTrailingComma:!1}};function zV(s,o=[],f=Ser.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"),ber(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:Ter(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 Ter(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(Ter,"getNodeType");function G9(s,o){return ger(s,o)}t(G9,"findNodeAtLocation");function JV(s){return yer(s)}t(JV,"getNodeValue");function wst(s){return ver(s)}t(wst,"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){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 xer=/^[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=xer.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Eer from"node:fs/promises";import{parse as Cer}from"@swc/core";var Dst=t(async s=>{let o=new Set;try{let f=await Eer.readFile(s,"utf-8");(await Cer(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 Pst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-dlp","ai-gateway-fallback-model-v2","ai-gateway-internal-only","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-model-override","ai-gateway-prompt-injection","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"],Ast={"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-internal-only-inbound":"ai-gateway-internal-only","ai-gateway-metering-v2-inbound":"ai-gateway-metering-v2","ai-gateway-model-filtering-v2-inbound":"ai-gateway-model-filtering-v2","ai-gateway-model-override-inbound":"ai-gateway-model-override","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 Nst={$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 LAe={$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 Ist={$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 RAe={$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 MAe={$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"},toolInputStyle:{enum:["flat","nested"]},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 zct=wp(Yce(),1),Jct=wp(Qce(),1);var ele=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new zct.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Jct.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=ele.instance;iI.addSchema(RAe,"route-configuration.schema.json");iI.addSchema(Ist,"policy-configuration.schema.json");iI.addSchema(LAe,"policies.schema.json");iI.addSchema(MAe,"open-api-route-configuration.schema.json");iI.addSchema(Nst,"fragments.schema.json");var r6r=iI.compile(RAe),$ct=iI.compile(MAe),QNe=iI.compile(LAe);var tle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=QNe(o),this.results}};var rle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=$ct(o),this.results}};import Kor from"node:path";var eIe=/\$import\((.*)\)/,SH=/\$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:""}}},Yor=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=Yor(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 nle=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)}):FAe(o)?o.children.forEach(f=>{this.visitor(f)}):zP(o)&&this.visitor(o.value)}},Wct=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"),qct=t((s,o,f)=>d=>{if(fO(d)&&typeof d.value=="string"&&d.parent&&FAe(d.parent)){if(!s.some(A=>qP(d.parent,A))){SH.test(d.value)&&o.push(new jk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=Wct(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))){SH.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=Wct(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",Xor=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Zor=["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"],Vct=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],Qor="handler/{}/options/{}/rewritePattern",ecr="handler/{}/options/{}/baseUrl",ile=class extends nle{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,Qor)){if(!o.parent||!H9(o.parent)){this.errors.push(new jk("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:Hct(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,ecr)){if(!o.parent||!H9(o.parent)){this.errors.push(new jk("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:Hct(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(!Zor.some(R=>qP(o,R))&&!Vct.some(R=>qP(o,R))){if(eIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new jk("An $import() statement is not expected at this location.",TH,o.location,f))}return}let d=eIe.exec(f);if(Vct.some(R=>qP(o,R))&&!d)return;if(!d){this.errors.push(new jk("Invalid $import() statement",TH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=Kor.posix.join("..",y));let E=this.getImportName(y),A={type:qo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=qct(Xor,this.errors,TH)};function Hct(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(fZt,"tarFolder");async function _Zt({tarFilePath:s,outputDir:o,logger:f}){let d=[],y=[],E;try{await new Promise((A,R)=>{let q=uit("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(_Zt,"untarFile");async function pZt(s){if(await sAe(s))return await GN.rm(s,{recursive:!0})}t(pZt,"deleteFolder");var nu=aAe;var ilt=R_(Ost(),1);import{AssertionError as Uer}from"node:assert";function $P(s,o){if(s===!1)throw new Uer({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 UAe(s){return s.type===qo.Array}t(UAe,"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 zer,getNodeValue as Jer,printParseErrorCode as $er,visit as Wer}from"jsonc-parser";var qer={DEFAULT:{allowTrailingComma:!1}};function JV(s,o=[],f=qer.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"),Wer(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:Ver(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(JV,"parse");function Ver(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(Ver,"getNodeType");function G9(s,o){return zer(s,o)}t(G9,"findNodeAtLocation");function $V(s){return Jer(s)}t($V,"getNodeValue");function Fst(s){return $er(s)}t(Fst,"printParseErrorCode");var WV=class{static{t(this,"AstAdapter")}parse(o){let d=JV(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 Her=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,qV=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=Her.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Ger from"node:fs/promises";import{parse as Yer}from"@swc/core";var Lst=t(async s=>{let o=new Set;try{let f=await Ger.readFile(s,"utf-8");(await Yer(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 Rst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-dlp","ai-gateway-fallback-model-v2","ai-gateway-internal-only","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-prompt-injection","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"],Mst={"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-internal-only-inbound":"ai-gateway-internal-only","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 jst={$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 zAe={$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 Bst={$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 JAe={$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 $Ae={$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"},toolInputStyle:{enum:["flat","nested"]},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 Gct=R_(Kce(),1),Yct=R_(ele(),1);var tle=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new Gct.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Yct.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=tle.instance;oI.addSchema(JAe,"route-configuration.schema.json");oI.addSchema(Bst,"policy-configuration.schema.json");oI.addSchema(zAe,"policies.schema.json");oI.addSchema($Ae,"open-api-route-configuration.schema.json");oI.addSchema(jst,"fragments.schema.json");var w6r=oI.compile(JAe),Kct=oI.compile($Ae),sIe=oI.compile(zAe);var rle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=sIe(o),this.results}};var nle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=Kct(o),this.results}};import bcr from"node:path";var aIe=/\$import\((.*)\)/,TH=/\$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:""}}},vcr=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=vcr(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 ile=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)}):UAe(o)?o.children.forEach(f=>{this.visitor(f)}):WP(o)&&this.visitor(o.value)}},Xct=t(s=>{let o=new RegExp(TH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(TH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),Zct=t((s,o,f)=>d=>{if(pO(d)&&typeof d.value=="string"&&d.parent&&UAe(d.parent)){if(!s.some(A=>GP(d.parent,A))){TH.test(d.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=Xct(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))){TH.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=Xct(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 xH="config/routes.json",Scr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Tcr=["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"],Qct=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],xcr="handler/{}/options/{}/rewritePattern",Ecr="handler/{}/options/{}/baseUrl",sle=class extends ile{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,xcr)){if(!o.parent||!H9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",xH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:elt(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,Ecr)){if(!o.parent||!H9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",xH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:elt(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(!Tcr.some(R=>GP(o,R))&&!Qct.some(R=>GP(o,R))){if(aIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Uk("An $import() statement is not expected at this location.",xH,o.location,f))}return}let d=aIe.exec(f);if(Qct.some(R=>GP(o,R))&&!d)return;if(!d){this.errors.push(new Uk("Invalid $import() statement",xH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=bcr.posix.join("..",y));let E=this.getImportName(y),A={type:qo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=Zct(Scr,this.errors,xH)};function elt(s){return`(request, context) => {
|
|
575
|
+
`),exitCode:E},"Untar process logs")}}t(_Zt,"untarFile");async function pZt(s){if(await sAe(s))return await GN.rm(s,{recursive:!0})}t(pZt,"deleteFolder");var nu=aAe;var ilt=R_(Ost(),1);import{AssertionError as Uer}from"node:assert";function $P(s,o){if(s===!1)throw new Uer({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 UAe(s){return s.type===qo.Array}t(UAe,"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 zer,getNodeValue as Jer,printParseErrorCode as $er,visit as Wer}from"jsonc-parser";var qer={DEFAULT:{allowTrailingComma:!1}};function JV(s,o=[],f=qer.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"),Wer(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:Ver(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(JV,"parse");function Ver(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(Ver,"getNodeType");function G9(s,o){return zer(s,o)}t(G9,"findNodeAtLocation");function $V(s){return Jer(s)}t($V,"getNodeValue");function Fst(s){return $er(s)}t(Fst,"printParseErrorCode");var WV=class{static{t(this,"AstAdapter")}parse(o){let d=JV(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 Her=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,qV=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=Her.test(f.value)?f.value:`'${f.value}'`;o.push(d)}};import Ger from"node:fs/promises";import{parse as Yer}from"@swc/core";var Lst=t(async s=>{let o=new Set;try{let f=await Ger.readFile(s,"utf-8");(await Yer(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 Rst=["ai-gateway-auth-v2","ai-gateway-configuration-executor-v2","ai-gateway-configuration-loader-v2","ai-gateway-dlp","ai-gateway-fallback-model-v2","ai-gateway-internal-only","ai-gateway-metering-v2","ai-gateway-model-filtering-v2","ai-gateway-model-override","ai-gateway-prompt-injection","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"],Mst={"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-internal-only-inbound":"ai-gateway-internal-only","ai-gateway-metering-v2-inbound":"ai-gateway-metering-v2","ai-gateway-model-filtering-v2-inbound":"ai-gateway-model-filtering-v2","ai-gateway-model-override-inbound":"ai-gateway-model-override","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 jst={$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 zAe={$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 Bst={$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 JAe={$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 $Ae={$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"},toolInputStyle:{enum:["flat","nested"]},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 Gct=R_(Kce(),1),Yct=R_(ele(),1);var tle=class s{static{t(this,"JsonValidator")}static#e=new s;static get instance(){return s.#e}ajv;constructor(){this.ajv=new Gct.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,Yct.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=tle.instance;oI.addSchema(JAe,"route-configuration.schema.json");oI.addSchema(Bst,"policy-configuration.schema.json");oI.addSchema(zAe,"policies.schema.json");oI.addSchema($Ae,"open-api-route-configuration.schema.json");oI.addSchema(jst,"fragments.schema.json");var w6r=oI.compile(JAe),Kct=oI.compile($Ae),sIe=oI.compile(zAe);var rle=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(o){return this.results=sIe(o),this.results}};var nle=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(o){return this.results=Kct(o),this.results}};import bcr from"node:path";var aIe=/\$import\((.*)\)/,TH=/\$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:""}}},vcr=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=vcr(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 ile=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)}):UAe(o)?o.children.forEach(f=>{this.visitor(f)}):WP(o)&&this.visitor(o.value)}},Xct=t(s=>{let o=new RegExp(TH).exec(s);if(o?.length===2&&o[0]===s)return{type:"raw",value:`environment["${o[1]}"]`};{let f=s.replaceAll(new RegExp(TH),(d,y)=>`\${environment["${y}"] ? environment["${y}"] : ""}`);if(f!==s)return{type:"template",value:f}}return null},"replaceEnvInString"),Zct=t((s,o,f)=>d=>{if(pO(d)&&typeof d.value=="string"&&d.parent&&UAe(d.parent)){if(!s.some(A=>GP(d.parent,A))){TH.test(d.value)&&o.push(new Uk("An $env() statement is not expected at this location.",f,d.location,d.value));return}let E=Xct(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))){TH.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=Xct(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 xH="config/routes.json",Scr=["handler/{}/options/*","handler/{}/options/*/[]","policies/[]/{}/handler/{}/options/*","policies/[]/{}/handler/{}/options/*/[]","corsPolicies/[]/{}/*","corsPolicies/[]/{}/*/[]"],Tcr=["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"],Qct=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],xcr="handler/{}/options/{}/rewritePattern",Ecr="handler/{}/options/{}/baseUrl",sle=class extends ile{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,xcr)){if(!o.parent||!H9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",xH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:elt(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,Ecr)){if(!o.parent||!H9(o.parent)){this.errors.push(new Uk("Invalid node, expected object",xH,o.parent?o.parent.location:o.location,void 0));return}let f=o.value.value,d={type:qo.Raw,parent:null,value:elt(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(!Tcr.some(R=>GP(o,R))&&!Qct.some(R=>GP(o,R))){if(aIe.test(f)){if(o.name.value==="$ref")return;this.errors.push(new Uk("An $import() statement is not expected at this location.",xH,o.location,f))}return}let d=aIe.exec(f);if(Qct.some(R=>GP(o,R))&&!d)return;if(!d){this.errors.push(new Uk("Invalid $import() statement",xH,o.location,f));return}let y=d[1];y=y.replace(/\\/g,"/"),y.startsWith(".")&&(y=bcr.posix.join("..",y));let E=this.getImportName(y),A={type:qo.Identifier,parent:o.parent,value:E};o.value=A}replaceEnvStatements=Zct(Scr,this.errors,xH)};function elt(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.8.
|
|
3
|
+
"version": "7.8.22",
|
|
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.8.
|
|
44
|
-
"@zuplo/otel": "7.8.
|
|
45
|
-
"@zuplo/runtime": "7.8.
|
|
43
|
+
"@zuplo/graphql": "7.8.22",
|
|
44
|
+
"@zuplo/otel": "7.8.22",
|
|
45
|
+
"@zuplo/runtime": "7.8.22",
|
|
46
46
|
"deno": "2.8.3"
|
|
47
47
|
}
|
|
48
48
|
}
|