@zuplo/core 6.70.16 → 6.70.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.
@@ -601,7 +601,7 @@ globstar while`,s,de,o,ae,Ye),this.matchOne(s.slice(de),o.slice(ae),f))return th
601
601
  `,P):(s.write("/*"),kpr(s,P.value,f,d),s.write("*/"+d))}}t(R1,"formatComments");function wpr(s){let o=s;for(;o!=null;){let{type:f}=o;if(f[0]==="C"&&f[1]==="a")return!0;if(f[0]==="M"&&f[1]==="e"&&f[2]==="m")o=o.object;else return!1}}t(wpr,"hasCallExpression");function yIe(s,o){let{generator:f}=s,{declarations:d}=o;s.write(o.kind+" ");let{length:y}=d;if(y>0){f.VariableDeclarator(d[0],s);for(let E=1;E<y;E++)s.write(", "),f.VariableDeclarator(d[E],s)}}t(yIe,"formatVariableDeclaration");var Bft,Uft,zft,$ft,Jft,Wft,Dpr={Program(s,o){let f=o.indent.repeat(o.indentLevel),{lineEnd:d,writeComments:y}=o;y&&s.comments!=null&&R1(o,s.comments,f,d);let E=s.body,{length:P}=E;for(let F=0;F<P;F++){let J=E[F];y&&J.comments!=null&&R1(o,J.comments,f,d),o.write(f),this[J.type](J,o),o.write(d)}y&&s.trailingComments!=null&&R1(o,s.trailingComments,f,d)},BlockStatement:Wft=t(function(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o,E=f+o.indent;o.write("{");let P=s.body;if(P!=null&&P.length>0){o.write(d),y&&s.comments!=null&&R1(o,s.comments,E,d);let{length:F}=P;for(let J=0;J<F;J++){let G=P[J];y&&G.comments!=null&&R1(o,G.comments,E,d),o.write(E),this[G.type](G,o),o.write(d)}o.write(f)}else y&&s.comments!=null&&(o.write(d),R1(o,s.comments,E,d),o.write(f));y&&s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write("}"),o.indentLevel--},"BlockStatement"),ClassBody:Wft,StaticBlock(s,o){o.write("static "),this.BlockStatement(s,o)},EmptyStatement(s,o){o.write(";")},ExpressionStatement(s,o){let f=o.expressionsPrecedence[s.expression.type];f===OE||f===3&&s.expression.left.type[0]==="O"?(o.write("("),this[s.expression.type](s.expression,o),o.write(")")):this[s.expression.type](s.expression,o),o.write(";")},IfStatement(s,o){o.write("if ("),this[s.test.type](s.test,o),o.write(") "),this[s.consequent.type](s.consequent,o),s.alternate!=null&&(o.write(" else "),this[s.alternate.type](s.alternate,o))},LabeledStatement(s,o){this[s.label.type](s.label,o),o.write(": "),this[s.body.type](s.body,o)},BreakStatement(s,o){o.write("break"),s.label!=null&&(o.write(" "),this[s.label.type](s.label,o)),o.write(";")},ContinueStatement(s,o){o.write("continue"),s.label!=null&&(o.write(" "),this[s.label.type](s.label,o)),o.write(";")},WithStatement(s,o){o.write("with ("),this[s.object.type](s.object,o),o.write(") "),this[s.body.type](s.body,o)},SwitchStatement(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o;o.indentLevel++;let E=f+o.indent,P=E+o.indent;o.write("switch ("),this[s.discriminant.type](s.discriminant,o),o.write(") {"+d);let{cases:F}=s,{length:J}=F;for(let G=0;G<J;G++){let Te=F[G];y&&Te.comments!=null&&R1(o,Te.comments,E,d),Te.test?(o.write(E+"case "),this[Te.test.type](Te.test,o),o.write(":"+d)):o.write(E+"default:"+d);let{consequent:de}=Te,{length:ae}=de;for(let Ye=0;Ye<ae;Ye++){let Ue=de[Ye];y&&Ue.comments!=null&&R1(o,Ue.comments,P,d),o.write(P),this[Ue.type](Ue,o),o.write(d)}}o.indentLevel-=2,o.write(f+"}")},ReturnStatement(s,o){o.write("return"),s.argument&&(o.write(" "),this[s.argument.type](s.argument,o)),o.write(";")},ThrowStatement(s,o){o.write("throw "),this[s.argument.type](s.argument,o),o.write(";")},TryStatement(s,o){if(o.write("try "),this[s.block.type](s.block,o),s.handler){let{handler:f}=s;f.param==null?o.write(" catch "):(o.write(" catch ("),this[f.param.type](f.param,o),o.write(") ")),this[f.body.type](f.body,o)}s.finalizer&&(o.write(" finally "),this[s.finalizer.type](s.finalizer,o))},WhileStatement(s,o){o.write("while ("),this[s.test.type](s.test,o),o.write(") "),this[s.body.type](s.body,o)},DoWhileStatement(s,o){o.write("do "),this[s.body.type](s.body,o),o.write(" while ("),this[s.test.type](s.test,o),o.write(");")},ForStatement(s,o){if(o.write("for ("),s.init!=null){let{init:f}=s;f.type[0]==="V"?yIe(o,f):this[f.type](f,o)}o.write("; "),s.test&&this[s.test.type](s.test,o),o.write("; "),s.update&&this[s.update.type](s.update,o),o.write(") "),this[s.body.type](s.body,o)},ForInStatement:Bft=t(function(s,o){o.write(`for ${s.await?"await ":""}(`);let{left:f}=s;f.type[0]==="V"?yIe(o,f):this[f.type](f,o),o.write(s.type[3]==="I"?" in ":" of "),this[s.right.type](s.right,o),o.write(") "),this[s.body.type](s.body,o)},"ForInStatement"),ForOfStatement:Bft,DebuggerStatement(s,o){o.write("debugger;",s)},FunctionDeclaration:Uft=t(function(s,o){o.write((s.async?"async ":"")+(s.generator?"function* ":"function ")+(s.id?s.id.name:""),s),LM(o,s.params),o.write(" "),this[s.body.type](s.body,o)},"FunctionDeclaration"),FunctionExpression:Uft,VariableDeclaration(s,o){yIe(o,s),o.write(";")},VariableDeclarator(s,o){this[s.id.type](s.id,o),s.init!=null&&(o.write(" = "),this[s.init.type](s.init,o))},ClassDeclaration(s,o){if(o.write("class "+(s.id?`${s.id.name} `:""),s),s.superClass){o.write("extends ");let{superClass:f}=s,{type:d}=f,y=o.expressionsPrecedence[d];(d[0]!=="C"||d[1]!=="l"||d[5]!=="E")&&(y===OE||y<o.expressionsPrecedence.ClassExpression)?(o.write("("),this[s.superClass.type](f,o),o.write(")")):this[f.type](f,o),o.write(" ")}this.ClassBody(s.body,o)},ImportDeclaration(s,o){o.write("import ");let{specifiers:f,attributes:d}=s,{length:y}=f,E=0;if(y>0){for(;E<y;){E>0&&o.write(", ");let P=f[E],F=P.type[6];if(F==="D")o.write(P.local.name,P),E++;else if(F==="N")o.write("* as "+P.local.name,P),E++;else break}if(E<y){for(o.write("{");;){let P=f[E],{name:F}=P.imported;if(o.write(F,P),F!==P.local.name&&o.write(" as "+P.local.name),++E<y)o.write(", ");else break}o.write("}")}o.write(" from ")}if(this.Literal(s.source,o),d&&d.length>0){o.write(" with { ");for(let P=0;P<d.length;P++)this.ImportAttribute(d[P],o),P<d.length-1&&o.write(", ");o.write(" }")}o.write(";")},ImportAttribute(s,o){this.Identifier(s.key,o),o.write(": "),this.Literal(s.value,o)},ImportExpression(s,o){o.write("import("),this[s.source.type](s.source,o),o.write(")")},ExportDefaultDeclaration(s,o){o.write("export default "),this[s.declaration.type](s.declaration,o),o.expressionsPrecedence[s.declaration.type]!=null&&s.declaration.type[0]!=="F"&&o.write(";")},ExportNamedDeclaration(s,o){if(o.write("export "),s.declaration)this[s.declaration.type](s.declaration,o);else{o.write("{");let{specifiers:f}=s,{length:d}=f;if(d>0)for(let y=0;;){let E=f[y],{name:P}=E.local;if(o.write(P,E),P!==E.exported.name&&o.write(" as "+E.exported.name),++y<d)o.write(", ");else break}if(o.write("}"),s.source&&(o.write(" from "),this.Literal(s.source,o)),s.attributes&&s.attributes.length>0){o.write(" with { ");for(let y=0;y<s.attributes.length;y++)this.ImportAttribute(s.attributes[y],o),y<s.attributes.length-1&&o.write(", ");o.write(" }")}o.write(";")}},ExportAllDeclaration(s,o){if(s.exported!=null?o.write("export * as "+s.exported.name+" from "):o.write("export * from "),this.Literal(s.source,o),s.attributes&&s.attributes.length>0){o.write(" with { ");for(let f=0;f<s.attributes.length;f++)this.ImportAttribute(s.attributes[f],o),f<s.attributes.length-1&&o.write(", ");o.write(" }")}o.write(";")},MethodDefinition(s,o){s.static&&o.write("static ");let f=s.kind[0];(f==="g"||f==="s")&&o.write(s.kind+" "),s.value.async&&o.write("async "),s.value.generator&&o.write("*"),s.computed?(o.write("["),this[s.key.type](s.key,o),o.write("]")):this[s.key.type](s.key,o),LM(o,s.value.params),o.write(" "),this[s.value.body.type](s.value.body,o)},ClassExpression(s,o){this.ClassDeclaration(s,o)},ArrowFunctionExpression(s,o){o.write(s.async?"async ":"",s);let{params:f}=s;f!=null&&(f.length===1&&f[0].type[0]==="I"?o.write(f[0].name,f[0]):LM(o,s.params)),o.write(" => "),s.body.type[0]==="O"?(o.write("("),this.ObjectExpression(s.body,o),o.write(")")):this[s.body.type](s.body,o)},ThisExpression(s,o){o.write("this",s)},Super(s,o){o.write("super",s)},RestElement:zft=t(function(s,o){o.write("..."),this[s.argument.type](s.argument,o)},"RestElement"),SpreadElement:zft,YieldExpression(s,o){o.write(s.delegate?"yield*":"yield"),s.argument&&(o.write(" "),this[s.argument.type](s.argument,o))},AwaitExpression(s,o){o.write("await ",s),Fle(o,s.argument,s)},TemplateLiteral(s,o){let{quasis:f,expressions:d}=s;o.write("`");let{length:y}=d;for(let P=0;P<y;P++){let F=d[P],J=f[P];o.write(J.value.raw,J),o.write("${"),this[F.type](F,o),o.write("}")}let E=f[f.length-1];o.write(E.value.raw,E),o.write("`")},TemplateElement(s,o){o.write(s.value.raw,s)},TaggedTemplateExpression(s,o){Fle(o,s.tag,s),this[s.quasi.type](s.quasi,o)},ArrayExpression:Jft=t(function(s,o){if(o.write("["),s.elements.length>0){let{elements:f}=s,{length:d}=f;for(let y=0;;){let E=f[y];if(E!=null&&this[E.type](E,o),++y<d)o.write(", ");else{E==null&&o.write(", ");break}}}o.write("]")},"ArrayExpression"),ArrayPattern:Jft,ObjectExpression(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o,E=f+o.indent;if(o.write("{"),s.properties.length>0){o.write(d),y&&s.comments!=null&&R1(o,s.comments,E,d);let P=","+d,{properties:F}=s,{length:J}=F;for(let G=0;;){let Te=F[G];if(y&&Te.comments!=null&&R1(o,Te.comments,E,d),o.write(E),this[Te.type](Te,o),++G<J)o.write(P);else break}o.write(d),y&&s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write(f+"}")}else y?s.comments!=null?(o.write(d),R1(o,s.comments,E,d),s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write(f+"}")):s.trailingComments!=null?(o.write(d),R1(o,s.trailingComments,E,d),o.write(f+"}")):o.write("}"):o.write("}");o.indentLevel--},Property(s,o){s.method||s.kind[0]!=="i"?this.MethodDefinition(s,o):(s.shorthand||(s.computed?(o.write("["),this[s.key.type](s.key,o),o.write("]")):this[s.key.type](s.key,o),o.write(": ")),this[s.value.type](s.value,o))},PropertyDefinition(s,o){if(s.static&&o.write("static "),s.computed&&o.write("["),this[s.key.type](s.key,o),s.computed&&o.write("]"),s.value==null){s.key.type[0]!=="F"&&o.write(";");return}o.write(" = "),this[s.value.type](s.value,o),o.write(";")},ObjectPattern(s,o){if(o.write("{"),s.properties.length>0){let{properties:f}=s,{length:d}=f;for(let y=0;this[f[y].type](f[y],o),++y<d;)o.write(", ")}o.write("}")},SequenceExpression(s,o){LM(o,s.expressions)},UnaryExpression(s,o){if(s.prefix){let{operator:f,argument:d,argument:{type:y}}=s;o.write(f);let E=qft(o,d,s);!E&&(f.length>1||y[0]==="U"&&(y[1]==="n"||y[1]==="p")&&d.prefix&&d.operator[0]===f&&(f==="+"||f==="-"))&&o.write(" "),E?(o.write(f.length>1?" (":"("),this[y](d,o),o.write(")")):this[y](d,o)}else this[s.argument.type](s.argument,o),o.write(s.operator)},UpdateExpression(s,o){s.prefix?(o.write(s.operator),this[s.argument.type](s.argument,o)):(this[s.argument.type](s.argument,o),o.write(s.operator))},AssignmentExpression(s,o){this[s.left.type](s.left,o),o.write(" "+s.operator+" "),this[s.right.type](s.right,o)},AssignmentPattern(s,o){this[s.left.type](s.left,o),o.write(" = "),this[s.right.type](s.right,o)},BinaryExpression:$ft=t(function(s,o){let f=s.operator==="in";f&&o.write("("),Fle(o,s.left,s,!1),o.write(" "+s.operator+" "),Fle(o,s.right,s,!0),f&&o.write(")")},"BinaryExpression"),LogicalExpression:$ft,ConditionalExpression(s,o){let{test:f}=s,d=o.expressionsPrecedence[f.type];d===OE||d<=o.expressionsPrecedence.ConditionalExpression?(o.write("("),this[f.type](f,o),o.write(")")):this[f.type](f,o),o.write(" ? "),this[s.consequent.type](s.consequent,o),o.write(" : "),this[s.alternate.type](s.alternate,o)},NewExpression(s,o){o.write("new ");let f=o.expressionsPrecedence[s.callee.type];f===OE||f<o.expressionsPrecedence.CallExpression||wpr(s.callee)?(o.write("("),this[s.callee.type](s.callee,o),o.write(")")):this[s.callee.type](s.callee,o),LM(o,s.arguments)},CallExpression(s,o){let f=o.expressionsPrecedence[s.callee.type];f===OE||f<o.expressionsPrecedence.CallExpression?(o.write("("),this[s.callee.type](s.callee,o),o.write(")")):this[s.callee.type](s.callee,o),s.optional&&o.write("?."),LM(o,s.arguments)},ChainExpression(s,o){this[s.expression.type](s.expression,o)},MemberExpression(s,o){let f=o.expressionsPrecedence[s.object.type];f===OE||f<o.expressionsPrecedence.MemberExpression?(o.write("("),this[s.object.type](s.object,o),o.write(")")):this[s.object.type](s.object,o),s.computed?(s.optional&&o.write("?."),o.write("["),this[s.property.type](s.property,o),o.write("]")):(s.optional?o.write("?."):o.write("."),this[s.property.type](s.property,o))},MetaProperty(s,o){o.write(s.meta.name+"."+s.property.name,s)},Identifier(s,o){o.write(s.name,s)},PrivateIdentifier(s,o){o.write(`#${s.name}`,s)},Literal(s,o){s.raw!=null?o.write(s.raw,s):s.regex!=null?this.RegExpLiteral(s,o):s.bigint!=null?o.write(s.bigint+"n",s):o.write(Epr(s.value),s)},RegExpLiteral(s,o){let{regex:f}=s;o.write(`/${f.pattern}/${f.flags}`,s)}},Ppr={};var vIe=class{static{t(this,"State")}constructor(o){let f=o??Ppr;this.output="",f.output!=null?(this.output=f.output,this.write=this.writeToStream):this.output="",this.generator=f.generator!=null?f.generator:Dpr,this.expressionsPrecedence=f.expressionsPrecedence!=null?f.expressionsPrecedence:Cpr,this.indent=f.indent!=null?f.indent:" ",this.lineEnd=f.lineEnd!=null?f.lineEnd:`
602
602
  `,this.indentLevel=f.startingIndentLevel!=null?f.startingIndentLevel:0,this.writeComments=f.comments?f.comments:!1,f.sourceMap!=null&&(this.write=f.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=f.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
603
603
  `).length-1,this.mapping={original:null,generated:this,name:void 0,source:f.sourceMap.file||f.sourceMap._file})}write(o){this.output+=o}writeToStream(o){this.output.write(o)}writeAndMap(o,f){this.output+=o,this.map(o,f)}writeToStreamAndMap(o,f){this.output.write(o),this.map(o,f)}map(o,f){if(f!=null){let{type:E}=f;if(E[0]==="L"&&E[2]==="n"){this.column=0,this.line++;return}if(f.loc!=null){let{mapping:P}=this;P.original=f.loc.start,P.name=f.name,this.sourceMap.addMapping(P)}if(E[0]==="T"&&E[8]==="E"||E[0]==="L"&&E[1]==="i"&&typeof f.value=="string"){let{length:P}=o,{column:F,line:J}=this;for(let G=0;G<P;G++)o[G]===`
604
- `?(F=0,J++):F++;this.column=F,this.line=J;return}}let{length:d}=o,{lineEnd:y}=this;d>0&&(this.lineEndSize>0&&(y.length===1?o[d-1]===y:o.endsWith(y))?(this.line+=this.lineEndSize,this.column=0):this.column+=d)}toString(){return this.output}};function Vft(s,o){let f=new vIe(o);return f.generator[s.type](s,f),f.output}t(Vft,"generate");async function bIe({oasFiles:s,sourceDirectory:o,logger:f}){let d=await Ipr({oasFiles:s,sourceDirectory:o,logger:f});return Vft(d)}t(bIe,"generateRawRouteSource");async function Ipr({oasFiles:s,sourceDirectory:o,logger:f}){let d=new g4(o,f),y=[];for(let P of s){let F=Npr.basename(P,".oas.json"),J=await d.resolve(P),G=[],Te=new Map,de=await Apr.readFile(P,"utf-8"),ae=JSON.parse(de);for(let Ye in ae.paths){let Ue=ae.paths[Ye],je=Ue.parameters||[],Kt={};Ue.summary&&(Kt.pathSummary=Ue.summary),Ue.description&&(Kt.pathDescription=Ue.description),Ue.servers&&(Kt.pathServers=Ue.servers);for(let Ut in Ue){if(!ile(Ut))continue;let kr=Ue[Ut],An=[...je,...kr.parameters||[]],nn={...kr,...An.length>0&&{parameters:An},...Kt,...kr.description&&{description:kr.description.length>350?`${kr.description.substring(0,350).trim()}...`:kr.description}},Pn=PV(F,Ye,Ut),wr=Lle(P,F,nn,J,G,Te);y.unshift(Gft(Pn,wr))}}y.unshift(...Opr(F,J,G,Te).reverse())}return{type:"Program",body:y,sourceType:"module"}}t(Ipr,"generateAst");function Lle(s,o,f,d,y,E){let P=[];for(let F in f){let J=f[F];if(F==="$ref")return kV(s,o,HN(s,J),d,y,E),{type:"Identifier",name:Yft(o,E.get(HN(s,J)))};let G;switch(typeof J){case"string":case"number":case"boolean":G={type:"Literal",value:J};break;default:Array.isArray(J)?G=Hft(J,s,o,d,y,E):typeof J=="object"&&J!==null&&(G=Lle(s,o,J,d,y,E));break}if(G){let Te=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(F),de=Te?{type:"Identifier",name:F}:{type:"Literal",value:F};P.push({type:"Property",key:de,value:G,kind:"init",method:!1,shorthand:!1,computed:!Te})}}return{type:"ObjectExpression",properties:P}}t(Lle,"processNode");function Hft(s,o,f,d,y,E){return{type:"ArrayExpression",elements:s.map(P=>{if(Array.isArray(P))return Hft(P,o,f,d,y,E);if(typeof P=="object"&&P!==null){let F=Lle(o,f,P,d,y,E);return F.type==="Identifier"?F:{type:"ObjectExpression",properties:F.properties||[]}}else return{type:"Literal",value:P}})}}t(Hft,"processArray");function Gft(s,o){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:o}],kind:"var"},specifiers:[],source:null}}t(Gft,"createExportedConstAssignment");function Opr(s,o,f,d){let y=[];for(let E=0;E<f.length;E++){let P=Yft(s,E),F=o.get(f[E]),J=Lle(Noe(f[E]),s,F,o,f,d);y.push(Gft(P,J))}return y}t(Opr,"generateRefs");function Yft(s,o){return`${UP(s)}__ref__${o}`}t(Yft,"getRefIdentifierName");import Kft from"node:path";var Xft=t(s=>{let o=null;if(s.value.type==="Object"&&s.value.members.length>0)for(let f of s.value.members){let d=Xft(f);if(d!==null&&(o=d),f.name.value==="enum"&&f.value.type==="Array"&&f.value.elements.length===0){let y=f.value,E=y.loc.start.line,P=y.loc.start.column,F=y.loc.end.column;o={line:E,column:P,length:F-P,lineText:""}}}return o},"findEmptyEnums"),Fpr=t(s=>{if(s.startsWith("schema with key or id")&&s.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(s.includes("All JSON schemas must use version 2020-12"))return"All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html";if(s==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(s==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(s.startsWith("can't resolve reference http"))return"Cannot resolve remote references, try adding them directly to the schema file or as a schema file in the project.";if(s.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(s.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(s.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(s.includes("Unexpected")&&s.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),SIe=t(async(s,o,f)=>{if(!s)return null;let d={file:Kft.join(UPe,s),suggestion:Fpr(f)},y=Kft.join(o,UPe),E=tu.safePath(o).resolve(y,s),P=await Poe(E);if(f.includes("enum must have non-empty array")){if(P){let F=await CV(P);if(F&&F.body.members!==null)for(let J of F.body.members){let G=Xft(J);G&&G!==null&&(d=Object.assign(d??{},G))}if(d){let J=d.line?d.line:0;d.lineText=EV(P,J)}}}else if(f.includes("Unexpected")&&f.includes("in JSON at position")&&P){let F=await CV(P);F&&"lineText"in F&&(d=Object.assign(d??{},F))}return d},"getLocation");import*as J_t from"esbuild";import BIe,{dirname as U_t}from"node:path";import{fileURLToPath as z_t}from"node:url";var TIe=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT,10):3e3}get DEBUG_BUILD_MODE(){return!!process.env.DEBUG_BUILD_MODE}get USE_MONOREPO_PACKAGES(){return process.env.USE_MONOREPO_PACKAGES==="true"}get EXPERIMENTAL_CODEGEN(){return!!process.env.EXPERIMENTAL_CODEGEN}get NODE_ENV(){return process.env.NODE_ENV}isProduction(){return this.NODE_ENV==="production"}isLocalDevelopment(){return process.env.ZUPLO_IS_LOCAL_DEVELOPMENT==="true"}},Lpr=new TIe,Gm=Lpr;var xIe="no-remote-module";function Zft({logger:s}){return{name:xIe,async setup(o){o.onResolve({filter:/^https?:\/\//},f=>(s.error(f,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${f.path}`,detail:"InvalidRemoteModule",pluginName:xIe,location:{line:0,column:0,file:""}}],pluginName:xIe}))}}}t(Zft,"blockRemoteModulePlugin");import Qft from"node:path";var e_t="legacy-environment",t_t="legacy-environment",Rpr=`import { environment } from "@zuplo/runtime";
604
+ `?(F=0,J++):F++;this.column=F,this.line=J;return}}let{length:d}=o,{lineEnd:y}=this;d>0&&(this.lineEndSize>0&&(y.length===1?o[d-1]===y:o.endsWith(y))?(this.line+=this.lineEndSize,this.column=0):this.column+=d)}toString(){return this.output}};function Vft(s,o){let f=new vIe(o);return f.generator[s.type](s,f),f.output}t(Vft,"generate");async function bIe({oasFiles:s,sourceDirectory:o,logger:f}){let d=await Ipr({oasFiles:s,sourceDirectory:o,logger:f});return Vft(d)}t(bIe,"generateRawRouteSource");async function Ipr({oasFiles:s,sourceDirectory:o,logger:f}){let d=new g4(o,f),y=[];for(let P of s){let F=Npr.basename(P,".oas.json"),J=await d.resolve(P),G=[],Te=new Map,de=await Apr.readFile(P,"utf-8"),ae=JSON.parse(de);for(let Ye in ae.paths){let Ue=ae.paths[Ye],je=Ue.parameters||[],Kt={};Ue.summary&&(Kt.pathSummary=Ue.summary),Ue.description&&(Kt.pathDescription=Ue.description),Ue.servers&&(Kt.pathServers=Ue.servers);for(let Ut in Ue){if(!ile(Ut))continue;let kr=Ue[Ut],An=[...je,...kr.parameters||[]],nn={...kr,...An.length>0&&{parameters:An},...Kt,...kr.description&&{description:kr.description.length>350?`${kr.description.substring(0,350).trim()}...`:kr.description}},Pn=PV(F,Ye,Ut),wr=Lle(P,F,nn,J,G,Te);y.unshift(Gft(Pn,wr))}}y.unshift(...Opr(F,J,G,Te).reverse())}return{type:"Program",body:y,sourceType:"module"}}t(Ipr,"generateAst");function Lle(s,o,f,d,y,E){let P=[];for(let F in f){let J=f[F];if(F==="$ref")return kV(s,o,HN(s,J),d,y,E),{type:"Identifier",name:Yft(o,E.get(HN(s,J)))};let G;switch(typeof J){case"string":case"number":case"boolean":G={type:"Literal",value:J};break;default:Array.isArray(J)?G=Hft(J,s,o,d,y,E):typeof J=="object"&&J!==null&&(G=Lle(s,o,J,d,y,E));break}if(G){let Te=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(F),de=Te?{type:"Identifier",name:F}:{type:"Literal",value:F};P.push({type:"Property",key:de,value:G,kind:"init",method:!1,shorthand:!1,computed:!Te})}}return{type:"ObjectExpression",properties:P}}t(Lle,"processNode");function Hft(s,o,f,d,y,E){return{type:"ArrayExpression",elements:s.map(P=>{if(Array.isArray(P))return Hft(P,o,f,d,y,E);if(typeof P=="object"&&P!==null){let F=Lle(o,f,P,d,y,E);return F.type==="Identifier"?F:{type:"ObjectExpression",properties:F.properties||[]}}else return{type:"Literal",value:P}})}}t(Hft,"processArray");function Gft(s,o){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:o}],kind:"var"},specifiers:[],source:null,attributes:[]}}t(Gft,"createExportedConstAssignment");function Opr(s,o,f,d){let y=[];for(let E=0;E<f.length;E++){let P=Yft(s,E),F=o.get(f[E]),J=Lle(Noe(f[E]),s,F,o,f,d);y.push(Gft(P,J))}return y}t(Opr,"generateRefs");function Yft(s,o){return`${UP(s)}__ref__${o}`}t(Yft,"getRefIdentifierName");import Kft from"node:path";var Xft=t(s=>{let o=null;if(s.value.type==="Object"&&s.value.members.length>0)for(let f of s.value.members){let d=Xft(f);if(d!==null&&(o=d),f.name.value==="enum"&&f.value.type==="Array"&&f.value.elements.length===0){let y=f.value,E=y.loc.start.line,P=y.loc.start.column,F=y.loc.end.column;o={line:E,column:P,length:F-P,lineText:""}}}return o},"findEmptyEnums"),Fpr=t(s=>{if(s.startsWith("schema with key or id")&&s.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(s.includes("All JSON schemas must use version 2020-12"))return"All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html";if(s==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(s==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(s.startsWith("can't resolve reference http"))return"Cannot resolve remote references, try adding them directly to the schema file or as a schema file in the project.";if(s.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(s.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(s.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(s.includes("Unexpected")&&s.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),SIe=t(async(s,o,f)=>{if(!s)return null;let d={file:Kft.join(UPe,s),suggestion:Fpr(f)},y=Kft.join(o,UPe),E=tu.safePath(o).resolve(y,s),P=await Poe(E);if(f.includes("enum must have non-empty array")){if(P){let F=await CV(P);if(F&&F.body.members!==null)for(let J of F.body.members){let G=Xft(J);G&&G!==null&&(d=Object.assign(d??{},G))}if(d){let J=d.line?d.line:0;d.lineText=EV(P,J)}}}else if(f.includes("Unexpected")&&f.includes("in JSON at position")&&P){let F=await CV(P);F&&"lineText"in F&&(d=Object.assign(d??{},F))}return d},"getLocation");import*as J_t from"esbuild";import BIe,{dirname as U_t}from"node:path";import{fileURLToPath as z_t}from"node:url";var TIe=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT,10):3e3}get DEBUG_BUILD_MODE(){return!!process.env.DEBUG_BUILD_MODE}get USE_MONOREPO_PACKAGES(){return process.env.USE_MONOREPO_PACKAGES==="true"}get EXPERIMENTAL_CODEGEN(){return!!process.env.EXPERIMENTAL_CODEGEN}get NODE_ENV(){return process.env.NODE_ENV}isProduction(){return this.NODE_ENV==="production"}isLocalDevelopment(){return process.env.ZUPLO_IS_LOCAL_DEVELOPMENT==="true"}},Lpr=new TIe,Gm=Lpr;var xIe="no-remote-module";function Zft({logger:s}){return{name:xIe,async setup(o){o.onResolve({filter:/^https?:\/\//},f=>(s.error(f,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${f.path}`,detail:"InvalidRemoteModule",pluginName:xIe,location:{line:0,column:0,file:""}}],pluginName:xIe}))}}}t(Zft,"blockRemoteModulePlugin");import Qft from"node:path";var e_t="legacy-environment",t_t="legacy-environment",Rpr=`import { environment } from "@zuplo/runtime";
605
605
  export default environment;`;function r_t(s){return{name:"environment",setup(o){o.onResolve({filter:/@app\/environment$/},()=>({namespace:t_t,pluginName:e_t,path:Qft.join(s.sourceDirectory,Ng,"environment.js")})),o.onLoad({filter:/.*/,namespace:t_t},async f=>({contents:Rpr,loader:"ts",resolveDir:Qft.dirname(f.path),pluginName:e_t}))}}}t(r_t,"environmentPlugin");import idr from"node:fs/promises";import bT from"node:path";var g_t=Vp(xH(),1),y_t=Vp(Gce(),1),v_t=Vp(EIe(),1),b_t=Vp(IIe(),1);import{performance as RE}from"node:perf_hooks";var HH=[];async function tdr(s,o){let f=RE.now();try{return await o()}finally{let d=RE.now()-f;HH.push({name:s,duration:d})}}t(tdr,"timeFn");var rdr={mark:t(s=>{RE.mark(s)},"mark"),measure:t((s,o,f)=>{try{RE.measure(s,o,f)}finally{RE.clearMarks(o),RE.clearMarks(f),RE.clearMeasures(s)}},"measure"),timeFn:tdr,report:t(()=>{if(HH.length>0){let s=HH.reduce((o,{name:f,duration:d})=>(o[f]=`${d.toFixed(0)}ms`,o),{});console.table(s),HH.length=0}},"report"),getDuration:t(s=>{let o=RE.getEntriesByName(s);if(o.length===0)return 0;let f=o[0].duration;return RE.clearMeasures(s),f},"getDuration"),clear:t(()=>{HH.length=0,RE.clearMarks(),RE.clearMeasures()},"clear")},Ou=rdr;import{writeFile as ndr}from"node:fs/promises";async function Wk(s,o){await tu.mkdirForFilePathIfNotExits(s);let f=await import("prettier"),d=o;try{d=await f.format(o,{parser:"babel"})}catch{}await ndr(s,d,"utf-8")}t(Wk,"writeDebugSourceFile");var qk="schemas",Mle="json-schema";function S_t(s){return{name:qk,async setup(o){let f=new y_t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0}),d=bT.join(s.sourceDirectory,oV),y=[],E=[],P;await Ou.timeFn("Initializing schema validation",async()=>{if((0,b_t.default)(f,{mode:"fast"}),f.opts.code.formats=g_t._`require("ajv-formats/dist/formats").fastFormats`,await tu.dirExists(d)&&(f.addKeyword("faker"),P=(await tu.listFolderContents(d,oV)).sort(),await Promise.all(P.map(async F=>{try{let J=tu.safePath(s.sourceDirectory).resolve(d,F);if(!J.startsWith(d))throw new Error("All schemas must be in the schemas directory");let G=await idr.readFile(J,"utf-8");if(G===""||G===void 0)throw new Error(`Schema 'schemas/${F}' is empty and will be ignored.`);let Te=JSON.parse(G);if(Te.$schema&&Te.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${F}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(f.addSchema(Te,F),f.errors?.length){let de=f.errors[0];y.push({id:"json-schema-validation-error",pluginName:qk,text:`Error: ${de.message}`,location:{file:bT.join(oV,F)},detail:{params:de.params,propertyName:de.propertyName,schemaPath:de.schemaPath,data:de.data}})}}catch(J){if(J.message.endsWith("is empty and will be ignored.")){E.push({id:"empty-json-schema-file",pluginName:qk,text:`Schema 'schemas/${F}' is empty and will be ignored.`,location:{file:`schemas/${F}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${F}' is empty and will be ignored.`,location:{file:`schemas/${F}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let G=await SIe(F,s.sourceDirectory,J.message);y.push({id:"json-schema-add-error",pluginName:qk,text:`Error: ${J.message}`,location:G,detail:"InvalidAddSchemaError",notes:[{text:J.message}]})}})),await Promise.all(P.map(async F=>{try{let J=f.getSchema(F);J&&f.compile(J.schema).errors?.forEach(Te=>{y.push({text:`Failed to compile ${F}: ${Te.message}`})})}catch(J){let G=await SIe(F,s.sourceDirectory,J.message);y.push({id:"json-schema-compile-error",pluginName:qk,text:`The schema file '${F}' is not valid. Error: ${J.message}`,location:G,detail:"InvalidSchemaError",notes:[{text:J.message}]})}})),Gm.DEBUG_BUILD_MODE)){let F=bT.resolve(s.outputDirectory,oV);await tu.mkdirIfNotExists(F)}}),o.onStart(async()=>{if(P)return{errors:y,warnings:E}}),o.onResolve({filter:/schemas\/.*\.json$/},async F=>Ou.timeFn("Generating JSON schemas...",async()=>{let J=bT.isAbsolute(F.path)?F.path:bT.join(F.resolveDir,F.path);if(F.importer&&F.namespace!=="open-api-routes-json")return{path:J};if(!await tu.fileExists(J)){let G="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${F.path}' from ${G}`,location:{file:bT.join(F.resolveDir,G),namespace:Mle,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${G}`,suggestion:""},detail:"RouteReferenceError",pluginName:qk,notes:[{text:`Unable to resolve reference to '${F.path}' from ${G}`,location:null}]}],namespace:Mle,path:J,pluginName:qk}}return{path:J,namespace:Mle,pluginName:qk}})),o.onLoad({filter:/.*/,namespace:Mle},async F=>Ou.timeFn(`Generating json schema data: ${bT.basename(F.path)}`,async()=>{let J=[],G;try{let Te=bT.relative(d,F.path),de=f.getSchema(Te);if(!de)throw new Error(`Could not load schema at ${F.path}`);G=de.source?.validateCode;let ae=f.compile(de.schema);G=(0,v_t.default)(f,ae)}catch(Te){J.push({pluginName:qk,text:`Cannot parse project's schemas/${bT.basename(F.path)} file. Error: ${Te.message}`,location:null,notes:[{text:Te.message,location:null}],detail:Te})}if(Gm.DEBUG_BUILD_MODE&&G){let Te=bT.relative(d,F.path),de=bT.join(s.sourceDirectory,Ng,`${Te}.js`);await Wk(de,G)}return{contents:G,errors:J,pluginName:qk,resolveDir:bT.dirname(F.path),watchFiles:[F.path]}}))}}}t(S_t,"jsonSchemaPlugin");import{relative as sdr}from"node:path";var T_t=["node:assert","node:async_hooks","node:buffer","node:crypto","node:diagnostics_channel","node:events","node:path","node:process","node:stream","node:string_decoder","node:util"],adr="nodejs-compat-plugin";function x_t({sourceDirectory:s}){return{name:adr,setup(o){let f=new Set;o.onStart(()=>{f.clear()}),o.onResolve({filter:/node:.*/},async({path:d,kind:y,resolveDir:E,...P})=>{let F=`${d}:${y}:${E}:${P.importer}`;if(f.has(F))return;f.add(F);let J=await o.resolve(d,{kind:y,resolveDir:E,importer:P.importer});return J.errors.length>0?T_t.includes(d)||d.includes("/")&&T_t.includes(d.split("/")[0])?{external:!0}:{external:!0,warnings:J.errors.map(Te=>({...Te,location:{file:sdr(s,P.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${d}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:J})}}}t(x_t,"nodejsCompatPlugin");import E_t from"node:fs/promises";import ME from"node:path";var v4="open-api-routes-plugin",GH="open-api-routes-json";function C_t(s){return{name:"open-api-routes-plugin",setup(o){o.onResolve({filter:/zuplo:routes$/},f=>({watchFiles:[...OIe(ME.join(s.sourceDirectory,k1),[".oas.json"],!0),ME.join(s.sourceDirectory,k1,noe)],namespace:GH,path:ME.isAbsolute(f.path)?f.path:ME.join(f.resolveDir,f.path),pluginName:v4})),o.onResolve({filter:/^\.\.\/modules\/.*/,namespace:GH},async f=>Ou.timeFn("Generating route data...",async()=>{async function d(){let E=ME.resolve(s.sourceDirectory,"config"),P=await dO(E),F=`$import(.${f.path.replace(/^../,"")})`;return{location:await Unt(P,F,"Update your route configuration to use code from the 'modules' folder"),originalImportValue:F}}t(d,"getLocation");let y=ME.join(f.resolveDir,`${f.path}.ts`);if(f.path.endsWith(".ts")){let{location:E,originalImportValue:P}=await d();return{errors:[{id:"route-build-error",text:`Invalid handler reference '${P}' in ${E?.file??"OpenAPI file"}. Imports must NOT include the '.ts' file extension.`,location:E,detail:"RouteReferenceError",pluginName:v4}],namespace:GH,path:f.path,pluginName:v4}}else if(!await tu.fileExists(y)){let{location:E,originalImportValue:P}=await d();return{errors:[{id:"route-build-error",text:`Invalid handler reference in route. Unable to resolve reference to '${P}' in ${E?.file??"OpenAPI file"}`,location:E,detail:"RouteReferenceError",pluginName:v4}],namespace:GH,path:f.path,pluginName:v4}}})),o.onLoad({filter:/.*/,namespace:GH},async f=>Ou.timeFn("Generating route.json data",async()=>{let d=ME.resolve(s.sourceDirectory,"config"),y=await dO(d),E=await Promise.all(y.map(async G=>({content:await E_t.readFile(G,"utf-8"),fileName:G}))),P=ME.resolve(d,"policies.json");if(!await tu.fileExists(P))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:v4,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:v4};let F={content:await E_t.readFile(P,"utf-8"),fileName:P},J;try{J=await t4e({sourceDirectory:s.sourceDirectory,oasContent:E,policiesContent:F,compatibilityDate:s.config.compatibilityDate,allowDuplicateRoutes:s.config.allowDuplicateRoutes})}catch(G){throw new Error(`Error compiling routes: ${G.message}`)}if(Gm.DEBUG_BUILD_MODE&&J.content){let G=ME.join(s.sourceDirectory,Ng),Te=ME.resolve(G,"routes.js");await Wk(Te,J.content)}return{contents:J.content,errors:J.errors,pluginName:v4,resolveDir:ME.dirname(f.path),watchFiles:[f.path]}}))}}}t(C_t,"openApiRoutesPlugin");import jle from"node:path";var YH="raw-route-plugin",k_t="raw-route";function w_t(s){return{name:"raw-route-plugin",setup(o){o.onResolve({filter:/zuplo:raw-routes$/},f=>({namespace:k_t,path:f.path,pluginName:YH})),o.onLoad({filter:/.*/,namespace:k_t},async f=>Ou.timeFn("Building route data",async()=>{let d=jle.resolve(s.sourceDirectory,k1);if(!await tu.dirExists(d))return{loader:"js",resolveDir:jle.dirname(f.path),pluginName:YH};let y=await dO(d);try{let E=await bIe({oasFiles:y,sourceDirectory:s.sourceDirectory,logger:s.logger});if(Gm.DEBUG_BUILD_MODE&&E){let P=jle.join(s.sourceDirectory,Ng,"raw-routes.js");await Wk(P,E)}return{contents:E,loader:"js",resolveDir:jle.dirname(f.path),pluginName:YH}}catch(E){if(E instanceof C1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:E.issue.text,location:E.issue.location,detail:E.issue.detail,pluginName:YH}],pluginName:YH};throw E}}))}}}t(w_t,"rawRoutePlugin");import odr from"node:fs/promises";import D_t from"node:path";var Ble="runtime-extensions-plugin",P_t="runtime-extensions";function A_t(s){return{name:Ble,setup(o){o.onResolve({filter:/zuplo:runtime-extension$/},f=>({namespace:P_t,path:f.path,pluginName:Ble})),o.onLoad({filter:/.*/,namespace:P_t},async()=>Ou.timeFn("Generating zuplo.runtime.ts data",async()=>{let f="export const runtimeInit = undefined;",d=D_t.resolve(s.sourceDirectory,Ytt,"zuplo.runtime.ts"),y=[];return await tu.fileExists(d)?(f=await odr.readFile(d,"utf-8"),{contents:f,loader:"ts",resolveDir:D_t.dirname(d),errors:y,pluginName:Ble,watchFiles:[d]}):{contents:f,loader:"ts",errors:y,pluginName:Ble}}))}}}t(A_t,"runtimeExtensionsPlugin");import I_t from"node:path";import{readFile as cdr}from"node:fs/promises";import b4 from"node:path";var jM=class extends Error{static{t(this,"DevPortalConfigError")}filename;constructor(o,f){super(o,f),this.name="DevPortalConfigError",this.filename=f?.filename}};async function N_t(s){let o=["zudoku.config.tsx","zudoku.config.ts","zudoku.config.js","zudoku.config.jsx","zudoku.config.mjs"];for(;o.length;){let P=o.pop();if(P){let F=b4.join("docs",P),J=b4.join(s,F);try{if(await tu.fileExists(J))return{enabled:!0,type:"zudoku",basePath:void 0,filepath:F}}catch(G){throw new jM("Failed to read dev portal configuration file.",{cause:G,filename:F})}}}let f=b4.join(k1,Xtt),d=b4.join(s,f),y=!0,E;if(await tu.fileExists(d)){try{let P=await cdr(d,"utf-8"),F=JSON.parse(P);F.enabled===!1&&(y=!1),E=F.sitePathname}catch(P){throw new jM("Failed to parse dev-portal.json file.",{cause:P,filename:f})}return{enabled:y,type:"legacy",basePath:E,filepath:f}}return{enabled:!1,type:void 0,basePath:void 0,filepath:void 0}}t(N_t,"getDevPortalConfig");function BM(s,o){let f=b4.resolve(s,U9);return Object.keys(o?.outputs??{}).map(E=>{let P=b4.normalize(E);return`./${b4.relative(f,P).split(b4.sep).join("/")}`})}t(BM,"getBuildModules");var O_t="/docs",ldr="/__zuplo/dev-portal";function udr(s){let o=s.trim().toLowerCase();return o.endsWith("/")&&(o=o.slice(0,-1)),o}t(udr,"normalizePathname");function fdr(s,o){let d={developerPortal:{basePath:s?.basePath===ldr?O_t:s?.basePath?udr(s.basePath):O_t,enabled:s?s.enabled??!0:!1,type:s?.type??void 0,urls:s?.urls?{defaultUrl:s.urls.defaultUrl,urls:s.urls.urls.map(E=>new URL(E).origin)}:void 0},api:o};return`const runtimeSettings = ${JSON.stringify(d)};
606
606
  export default runtimeSettings;`}t(fdr,"generateSource");var KH="runtime-settings-plugin",Ule="runtime-settings";function F_t(s){return{name:KH,setup(o){o.onResolve({filter:/zuplo:runtime-settings$/},f=>({namespace:Ule,path:f.path,pluginName:KH})),o.onLoad({filter:/.*/,namespace:Ule},async()=>Ou.timeFn("Generating runtime settings",async()=>{let f=[],d,y;try{let F=await N_t(s.sourceDirectory);y=F.filepath,d={...F,urls:s.urls?.devPortal}}catch(F){let J="Failed to load dev portal config",G="config/dev-portal.json";F instanceof jM&&(J=F.message,G=F.filename??G),f.push({id:"dev-portal-build-error",text:J,location:{file:G,namespace:Ule,line:1,column:0,length:0,lineText:"",suggestion:""},detail:"DevPortalValidationError",pluginName:KH,notes:[{text:F.message,location:null}]})}let E={urls:s.urls?.api},P;try{if(P=fdr(d,E),Gm.DEBUG_BUILD_MODE&&P){let F=I_t.join(s.sourceDirectory,Ng,"dev-portal.js");await Wk(F,P)}}catch(F){f.push({id:"dev-portal-build-error",text:F.message,location:{file:"dev-portal.json",namespace:Ule,line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:KH,notes:[{text:F.message,location:null}]})}return{contents:P,errors:f,pluginName:KH,loader:"js",resolveDir:y?I_t.dirname(y):void 0}}))}}}t(F_t,"runtimeSettingsPlugin");import jIe from"node:fs/promises";import UO from"node:path";var R_t=Vp(xH(),1),LIe=Vp(Gce(),1),RIe=Vp(EIe(),1),M_t=Vp(IIe(),1);var FIe="schema-validation-plugin",L_t="schema-validation",_dr="module.exports = {}";function j_t(s){return{name:"schema-validation-plugin",setup(o){o.onResolve({filter:/zuplo:schema-validations$/},f=>({namespace:L_t,path:f.path,pluginName:FIe})),o.onLoad({filter:/.*/,namespace:L_t},async()=>Ou.timeFn("Validating schemas",async()=>{let f=UO.resolve(s.sourceDirectory,k1,"policies.json");if(!await tu.fileExists(f))return{contents:_dr,loader:"js",resolveDir:UO.dirname(f),pluginName:FIe};let d=await ddr(s.sourceDirectory),y=UO.resolve(s.sourceDirectory,k1),E=await dO(y),P=await ydr(E,d),F=await pdr({oasFiles:E,routesWithSchemaValidation:P,sourceDirectory:s.sourceDirectory,logger:s.logger});if(Gm.DEBUG_BUILD_MODE&&F){let J=UO.join(s.sourceDirectory,Ng,"schema-validation.js");await Wk(J,F)}return{contents:F,loader:"js",resolveDir:UO.dirname(f),pluginName:FIe}}))}}}t(j_t,"schemaValidationPlugin");async function pdr({oasFiles:s,routesWithSchemaValidation:o,sourceDirectory:f,logger:d}){let y="",E=new g4(f,d);if(o.length===0)return y;let P={code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0},F=new LIe.Ajv2020(P),J=new LIe.Ajv2020({...P,coerceTypes:"array"});(0,M_t.default)(J,{mode:"fast"}),J.opts.code.formats=R_t._`require("ajv-formats/dist/formats").fastFormats`;for(let G of s){let Te=await jIe.readFile(G,"utf-8"),de=UO.basename(G,".oas.json"),ae=o.filter(Ut=>Ut.fileName===de),Ye=await E.resolve(G),Ue=JSON.parse(Te),je=[],Kt=new Map;ae.forEach(Ut=>{let kr=Ue.paths[Ut.path][Ut.method];if(kr.requestBody){let An;if(kr.requestBody.$ref){let nn=kr.requestBody.$ref;An=Ye.get(nn)?.content}else kr.requestBody.content&&(An=kr.requestBody.content);if(An)for(let nn in An){let Pn=An[nn].schema,wr=YPe(Ut.path,Ut.method,nn);Pn.$id=wr,F.addSchema(Pn),MIe(Pn,G,de,F,Ye,je,Kt)}}if(kr.parameters)for(let An of kr.parameters){let nn=An.$ref?Ye.get(An.$ref):An,Pn=nn.schema.$ref?Ye.get(nn.schema.$ref):nn.schema,wr=GPe(Ut.path,Ut.method,nn.in,nn.name);Pn.$id=wr,J.addSchema(Pn),MIe(nn,G,de,J,Ye,je,Kt)}});for(let Ut of je){let kr=Ye.get(Ut),An=AV(de,Ut);F.addSchema(kr,An),J.addSchema(kr,An)}}return y=`"use strict";
607
607
  const __paramExports = (function () {
package/index.minified.js CHANGED
@@ -601,7 +601,7 @@ globstar while`,s,de,o,ae,Ye),this.matchOne(s.slice(de),o.slice(ae),f))return th
601
601
  `,P):(s.write("/*"),Kpr(s,P.value,f,d),s.write("*/"+d))}}t(R1,"formatComments");function Xpr(s){let o=s;for(;o!=null;){let{type:f}=o;if(f[0]==="C"&&f[1]==="a")return!0;if(f[0]==="M"&&f[1]==="e"&&f[2]==="m")o=o.object;else return!1}}t(Xpr,"hasCallExpression");function x4e(s,o){let{generator:f}=s,{declarations:d}=o;s.write(o.kind+" ");let{length:y}=d;if(y>0){f.VariableDeclarator(d[0],s);for(let E=1;E<y;E++)s.write(", "),f.VariableDeclarator(d[E],s)}}t(x4e,"formatVariableDeclaration");var Hft,Gft,Yft,Kft,Xft,Zft,Zpr={Program(s,o){let f=o.indent.repeat(o.indentLevel),{lineEnd:d,writeComments:y}=o;y&&s.comments!=null&&R1(o,s.comments,f,d);let E=s.body,{length:P}=E;for(let F=0;F<P;F++){let J=E[F];y&&J.comments!=null&&R1(o,J.comments,f,d),o.write(f),this[J.type](J,o),o.write(d)}y&&s.trailingComments!=null&&R1(o,s.trailingComments,f,d)},BlockStatement:Zft=t(function(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o,E=f+o.indent;o.write("{");let P=s.body;if(P!=null&&P.length>0){o.write(d),y&&s.comments!=null&&R1(o,s.comments,E,d);let{length:F}=P;for(let J=0;J<F;J++){let V=P[J];y&&V.comments!=null&&R1(o,V.comments,E,d),o.write(E),this[V.type](V,o),o.write(d)}o.write(f)}else y&&s.comments!=null&&(o.write(d),R1(o,s.comments,E,d),o.write(f));y&&s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write("}"),o.indentLevel--},"BlockStatement"),ClassBody:Zft,StaticBlock(s,o){o.write("static "),this.BlockStatement(s,o)},EmptyStatement(s,o){o.write(";")},ExpressionStatement(s,o){let f=o.expressionsPrecedence[s.expression.type];f===LE||f===3&&s.expression.left.type[0]==="O"?(o.write("("),this[s.expression.type](s.expression,o),o.write(")")):this[s.expression.type](s.expression,o),o.write(";")},IfStatement(s,o){o.write("if ("),this[s.test.type](s.test,o),o.write(") "),this[s.consequent.type](s.consequent,o),s.alternate!=null&&(o.write(" else "),this[s.alternate.type](s.alternate,o))},LabeledStatement(s,o){this[s.label.type](s.label,o),o.write(": "),this[s.body.type](s.body,o)},BreakStatement(s,o){o.write("break"),s.label!=null&&(o.write(" "),this[s.label.type](s.label,o)),o.write(";")},ContinueStatement(s,o){o.write("continue"),s.label!=null&&(o.write(" "),this[s.label.type](s.label,o)),o.write(";")},WithStatement(s,o){o.write("with ("),this[s.object.type](s.object,o),o.write(") "),this[s.body.type](s.body,o)},SwitchStatement(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o;o.indentLevel++;let E=f+o.indent,P=E+o.indent;o.write("switch ("),this[s.discriminant.type](s.discriminant,o),o.write(") {"+d);let{cases:F}=s,{length:J}=F;for(let V=0;V<J;V++){let Te=F[V];y&&Te.comments!=null&&R1(o,Te.comments,E,d),Te.test?(o.write(E+"case "),this[Te.test.type](Te.test,o),o.write(":"+d)):o.write(E+"default:"+d);let{consequent:de}=Te,{length:ae}=de;for(let Ye=0;Ye<ae;Ye++){let Ue=de[Ye];y&&Ue.comments!=null&&R1(o,Ue.comments,P,d),o.write(P),this[Ue.type](Ue,o),o.write(d)}}o.indentLevel-=2,o.write(f+"}")},ReturnStatement(s,o){o.write("return"),s.argument&&(o.write(" "),this[s.argument.type](s.argument,o)),o.write(";")},ThrowStatement(s,o){o.write("throw "),this[s.argument.type](s.argument,o),o.write(";")},TryStatement(s,o){if(o.write("try "),this[s.block.type](s.block,o),s.handler){let{handler:f}=s;f.param==null?o.write(" catch "):(o.write(" catch ("),this[f.param.type](f.param,o),o.write(") ")),this[f.body.type](f.body,o)}s.finalizer&&(o.write(" finally "),this[s.finalizer.type](s.finalizer,o))},WhileStatement(s,o){o.write("while ("),this[s.test.type](s.test,o),o.write(") "),this[s.body.type](s.body,o)},DoWhileStatement(s,o){o.write("do "),this[s.body.type](s.body,o),o.write(" while ("),this[s.test.type](s.test,o),o.write(");")},ForStatement(s,o){if(o.write("for ("),s.init!=null){let{init:f}=s;f.type[0]==="V"?x4e(o,f):this[f.type](f,o)}o.write("; "),s.test&&this[s.test.type](s.test,o),o.write("; "),s.update&&this[s.update.type](s.update,o),o.write(") "),this[s.body.type](s.body,o)},ForInStatement:Hft=t(function(s,o){o.write(`for ${s.await?"await ":""}(`);let{left:f}=s;f.type[0]==="V"?x4e(o,f):this[f.type](f,o),o.write(s.type[3]==="I"?" in ":" of "),this[s.right.type](s.right,o),o.write(") "),this[s.body.type](s.body,o)},"ForInStatement"),ForOfStatement:Hft,DebuggerStatement(s,o){o.write("debugger;",s)},FunctionDeclaration:Gft=t(function(s,o){o.write((s.async?"async ":"")+(s.generator?"function* ":"function ")+(s.id?s.id.name:""),s),LM(o,s.params),o.write(" "),this[s.body.type](s.body,o)},"FunctionDeclaration"),FunctionExpression:Gft,VariableDeclaration(s,o){x4e(o,s),o.write(";")},VariableDeclarator(s,o){this[s.id.type](s.id,o),s.init!=null&&(o.write(" = "),this[s.init.type](s.init,o))},ClassDeclaration(s,o){if(o.write("class "+(s.id?`${s.id.name} `:""),s),s.superClass){o.write("extends ");let{superClass:f}=s,{type:d}=f,y=o.expressionsPrecedence[d];(d[0]!=="C"||d[1]!=="l"||d[5]!=="E")&&(y===LE||y<o.expressionsPrecedence.ClassExpression)?(o.write("("),this[s.superClass.type](f,o),o.write(")")):this[f.type](f,o),o.write(" ")}this.ClassBody(s.body,o)},ImportDeclaration(s,o){o.write("import ");let{specifiers:f,attributes:d}=s,{length:y}=f,E=0;if(y>0){for(;E<y;){E>0&&o.write(", ");let P=f[E],F=P.type[6];if(F==="D")o.write(P.local.name,P),E++;else if(F==="N")o.write("* as "+P.local.name,P),E++;else break}if(E<y){for(o.write("{");;){let P=f[E],{name:F}=P.imported;if(o.write(F,P),F!==P.local.name&&o.write(" as "+P.local.name),++E<y)o.write(", ");else break}o.write("}")}o.write(" from ")}if(this.Literal(s.source,o),d&&d.length>0){o.write(" with { ");for(let P=0;P<d.length;P++)this.ImportAttribute(d[P],o),P<d.length-1&&o.write(", ");o.write(" }")}o.write(";")},ImportAttribute(s,o){this.Identifier(s.key,o),o.write(": "),this.Literal(s.value,o)},ImportExpression(s,o){o.write("import("),this[s.source.type](s.source,o),o.write(")")},ExportDefaultDeclaration(s,o){o.write("export default "),this[s.declaration.type](s.declaration,o),o.expressionsPrecedence[s.declaration.type]!=null&&s.declaration.type[0]!=="F"&&o.write(";")},ExportNamedDeclaration(s,o){if(o.write("export "),s.declaration)this[s.declaration.type](s.declaration,o);else{o.write("{");let{specifiers:f}=s,{length:d}=f;if(d>0)for(let y=0;;){let E=f[y],{name:P}=E.local;if(o.write(P,E),P!==E.exported.name&&o.write(" as "+E.exported.name),++y<d)o.write(", ");else break}if(o.write("}"),s.source&&(o.write(" from "),this.Literal(s.source,o)),s.attributes&&s.attributes.length>0){o.write(" with { ");for(let y=0;y<s.attributes.length;y++)this.ImportAttribute(s.attributes[y],o),y<s.attributes.length-1&&o.write(", ");o.write(" }")}o.write(";")}},ExportAllDeclaration(s,o){if(s.exported!=null?o.write("export * as "+s.exported.name+" from "):o.write("export * from "),this.Literal(s.source,o),s.attributes&&s.attributes.length>0){o.write(" with { ");for(let f=0;f<s.attributes.length;f++)this.ImportAttribute(s.attributes[f],o),f<s.attributes.length-1&&o.write(", ");o.write(" }")}o.write(";")},MethodDefinition(s,o){s.static&&o.write("static ");let f=s.kind[0];(f==="g"||f==="s")&&o.write(s.kind+" "),s.value.async&&o.write("async "),s.value.generator&&o.write("*"),s.computed?(o.write("["),this[s.key.type](s.key,o),o.write("]")):this[s.key.type](s.key,o),LM(o,s.value.params),o.write(" "),this[s.value.body.type](s.value.body,o)},ClassExpression(s,o){this.ClassDeclaration(s,o)},ArrowFunctionExpression(s,o){o.write(s.async?"async ":"",s);let{params:f}=s;f!=null&&(f.length===1&&f[0].type[0]==="I"?o.write(f[0].name,f[0]):LM(o,s.params)),o.write(" => "),s.body.type[0]==="O"?(o.write("("),this.ObjectExpression(s.body,o),o.write(")")):this[s.body.type](s.body,o)},ThisExpression(s,o){o.write("this",s)},Super(s,o){o.write("super",s)},RestElement:Yft=t(function(s,o){o.write("..."),this[s.argument.type](s.argument,o)},"RestElement"),SpreadElement:Yft,YieldExpression(s,o){o.write(s.delegate?"yield*":"yield"),s.argument&&(o.write(" "),this[s.argument.type](s.argument,o))},AwaitExpression(s,o){o.write("await ",s),Fle(o,s.argument,s)},TemplateLiteral(s,o){let{quasis:f,expressions:d}=s;o.write("`");let{length:y}=d;for(let P=0;P<y;P++){let F=d[P],J=f[P];o.write(J.value.raw,J),o.write("${"),this[F.type](F,o),o.write("}")}let E=f[f.length-1];o.write(E.value.raw,E),o.write("`")},TemplateElement(s,o){o.write(s.value.raw,s)},TaggedTemplateExpression(s,o){Fle(o,s.tag,s),this[s.quasi.type](s.quasi,o)},ArrayExpression:Xft=t(function(s,o){if(o.write("["),s.elements.length>0){let{elements:f}=s,{length:d}=f;for(let y=0;;){let E=f[y];if(E!=null&&this[E.type](E,o),++y<d)o.write(", ");else{E==null&&o.write(", ");break}}}o.write("]")},"ArrayExpression"),ArrayPattern:Xft,ObjectExpression(s,o){let f=o.indent.repeat(o.indentLevel++),{lineEnd:d,writeComments:y}=o,E=f+o.indent;if(o.write("{"),s.properties.length>0){o.write(d),y&&s.comments!=null&&R1(o,s.comments,E,d);let P=","+d,{properties:F}=s,{length:J}=F;for(let V=0;;){let Te=F[V];if(y&&Te.comments!=null&&R1(o,Te.comments,E,d),o.write(E),this[Te.type](Te,o),++V<J)o.write(P);else break}o.write(d),y&&s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write(f+"}")}else y?s.comments!=null?(o.write(d),R1(o,s.comments,E,d),s.trailingComments!=null&&R1(o,s.trailingComments,E,d),o.write(f+"}")):s.trailingComments!=null?(o.write(d),R1(o,s.trailingComments,E,d),o.write(f+"}")):o.write("}"):o.write("}");o.indentLevel--},Property(s,o){s.method||s.kind[0]!=="i"?this.MethodDefinition(s,o):(s.shorthand||(s.computed?(o.write("["),this[s.key.type](s.key,o),o.write("]")):this[s.key.type](s.key,o),o.write(": ")),this[s.value.type](s.value,o))},PropertyDefinition(s,o){if(s.static&&o.write("static "),s.computed&&o.write("["),this[s.key.type](s.key,o),s.computed&&o.write("]"),s.value==null){s.key.type[0]!=="F"&&o.write(";");return}o.write(" = "),this[s.value.type](s.value,o),o.write(";")},ObjectPattern(s,o){if(o.write("{"),s.properties.length>0){let{properties:f}=s,{length:d}=f;for(let y=0;this[f[y].type](f[y],o),++y<d;)o.write(", ")}o.write("}")},SequenceExpression(s,o){LM(o,s.expressions)},UnaryExpression(s,o){if(s.prefix){let{operator:f,argument:d,argument:{type:y}}=s;o.write(f);let E=Qft(o,d,s);!E&&(f.length>1||y[0]==="U"&&(y[1]==="n"||y[1]==="p")&&d.prefix&&d.operator[0]===f&&(f==="+"||f==="-"))&&o.write(" "),E?(o.write(f.length>1?" (":"("),this[y](d,o),o.write(")")):this[y](d,o)}else this[s.argument.type](s.argument,o),o.write(s.operator)},UpdateExpression(s,o){s.prefix?(o.write(s.operator),this[s.argument.type](s.argument,o)):(this[s.argument.type](s.argument,o),o.write(s.operator))},AssignmentExpression(s,o){this[s.left.type](s.left,o),o.write(" "+s.operator+" "),this[s.right.type](s.right,o)},AssignmentPattern(s,o){this[s.left.type](s.left,o),o.write(" = "),this[s.right.type](s.right,o)},BinaryExpression:Kft=t(function(s,o){let f=s.operator==="in";f&&o.write("("),Fle(o,s.left,s,!1),o.write(" "+s.operator+" "),Fle(o,s.right,s,!0),f&&o.write(")")},"BinaryExpression"),LogicalExpression:Kft,ConditionalExpression(s,o){let{test:f}=s,d=o.expressionsPrecedence[f.type];d===LE||d<=o.expressionsPrecedence.ConditionalExpression?(o.write("("),this[f.type](f,o),o.write(")")):this[f.type](f,o),o.write(" ? "),this[s.consequent.type](s.consequent,o),o.write(" : "),this[s.alternate.type](s.alternate,o)},NewExpression(s,o){o.write("new ");let f=o.expressionsPrecedence[s.callee.type];f===LE||f<o.expressionsPrecedence.CallExpression||Xpr(s.callee)?(o.write("("),this[s.callee.type](s.callee,o),o.write(")")):this[s.callee.type](s.callee,o),LM(o,s.arguments)},CallExpression(s,o){let f=o.expressionsPrecedence[s.callee.type];f===LE||f<o.expressionsPrecedence.CallExpression?(o.write("("),this[s.callee.type](s.callee,o),o.write(")")):this[s.callee.type](s.callee,o),s.optional&&o.write("?."),LM(o,s.arguments)},ChainExpression(s,o){this[s.expression.type](s.expression,o)},MemberExpression(s,o){let f=o.expressionsPrecedence[s.object.type];f===LE||f<o.expressionsPrecedence.MemberExpression?(o.write("("),this[s.object.type](s.object,o),o.write(")")):this[s.object.type](s.object,o),s.computed?(s.optional&&o.write("?."),o.write("["),this[s.property.type](s.property,o),o.write("]")):(s.optional?o.write("?."):o.write("."),this[s.property.type](s.property,o))},MetaProperty(s,o){o.write(s.meta.name+"."+s.property.name,s)},Identifier(s,o){o.write(s.name,s)},PrivateIdentifier(s,o){o.write(`#${s.name}`,s)},Literal(s,o){s.raw!=null?o.write(s.raw,s):s.regex!=null?this.RegExpLiteral(s,o):s.bigint!=null?o.write(s.bigint+"n",s):o.write(Gpr(s.value),s)},RegExpLiteral(s,o){let{regex:f}=s;o.write(`/${f.pattern}/${f.flags}`,s)}},Qpr={};var E4e=class{static{t(this,"State")}constructor(o){let f=o??Qpr;this.output="",f.output!=null?(this.output=f.output,this.write=this.writeToStream):this.output="",this.generator=f.generator!=null?f.generator:Zpr,this.expressionsPrecedence=f.expressionsPrecedence!=null?f.expressionsPrecedence:Ypr,this.indent=f.indent!=null?f.indent:" ",this.lineEnd=f.lineEnd!=null?f.lineEnd:`
602
602
  `,this.indentLevel=f.startingIndentLevel!=null?f.startingIndentLevel:0,this.writeComments=f.comments?f.comments:!1,f.sourceMap!=null&&(this.write=f.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=f.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
603
603
  `).length-1,this.mapping={original:null,generated:this,name:void 0,source:f.sourceMap.file||f.sourceMap._file})}write(o){this.output+=o}writeToStream(o){this.output.write(o)}writeAndMap(o,f){this.output+=o,this.map(o,f)}writeToStreamAndMap(o,f){this.output.write(o),this.map(o,f)}map(o,f){if(f!=null){let{type:E}=f;if(E[0]==="L"&&E[2]==="n"){this.column=0,this.line++;return}if(f.loc!=null){let{mapping:P}=this;P.original=f.loc.start,P.name=f.name,this.sourceMap.addMapping(P)}if(E[0]==="T"&&E[8]==="E"||E[0]==="L"&&E[1]==="i"&&typeof f.value=="string"){let{length:P}=o,{column:F,line:J}=this;for(let V=0;V<P;V++)o[V]===`
604
- `?(F=0,J++):F++;this.column=F,this.line=J;return}}let{length:d}=o,{lineEnd:y}=this;d>0&&(this.lineEndSize>0&&(y.length===1?o[d-1]===y:o.endsWith(y))?(this.line+=this.lineEndSize,this.column=0):this.column+=d)}toString(){return this.output}};function e_t(s,o){let f=new E4e(o);return f.generator[s.type](s,f),f.output}t(e_t,"generate");async function C4e({oasFiles:s,sourceDirectory:o,logger:f}){let d=await rdr({oasFiles:s,sourceDirectory:o,logger:f});return e_t(d)}t(C4e,"generateRawRouteSource");async function rdr({oasFiles:s,sourceDirectory:o,logger:f}){let d=new bI(o,f),y=[];for(let P of s){let F=tdr.basename(P,".oas.json"),J=await d.resolve(P),V=[],Te=new Map,de=await edr.readFile(P,"utf-8"),ae=JSON.parse(de);for(let Ye in ae.paths){let Ue=ae.paths[Ye],je=Ue.parameters||[],Kt={};Ue.summary&&(Kt.pathSummary=Ue.summary),Ue.description&&(Kt.pathDescription=Ue.description),Ue.servers&&(Kt.pathServers=Ue.servers);for(let Ut in Ue){if(!ile(Ut))continue;let kr=Ue[Ut],An=[...je,...kr.parameters||[]],nn={...kr,...An.length>0&&{parameters:An},...Kt,...kr.description&&{description:kr.description.length>350?`${kr.description.substring(0,350).trim()}...`:kr.description}},Pn=AV(F,Ye,Ut),wr=Lle(P,F,nn,J,V,Te);y.unshift(r_t(Pn,wr))}}y.unshift(...ndr(F,J,V,Te).reverse())}return{type:"Program",body:y,sourceType:"module"}}t(rdr,"generateAst");function Lle(s,o,f,d,y,E){let P=[];for(let F in f){let J=f[F];if(F==="$ref")return wV(s,o,KN(s,J),d,y,E),{type:"Identifier",name:n_t(o,E.get(KN(s,J)))};let V;switch(typeof J){case"string":case"number":case"boolean":V={type:"Literal",value:J};break;default:Array.isArray(J)?V=t_t(J,s,o,d,y,E):typeof J=="object"&&J!==null&&(V=Lle(s,o,J,d,y,E));break}if(V){let Te=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(F),de=Te?{type:"Identifier",name:F}:{type:"Literal",value:F};P.push({type:"Property",key:de,value:V,kind:"init",method:!1,shorthand:!1,computed:!Te})}}return{type:"ObjectExpression",properties:P}}t(Lle,"processNode");function t_t(s,o,f,d,y,E){return{type:"ArrayExpression",elements:s.map(P=>{if(Array.isArray(P))return t_t(P,o,f,d,y,E);if(typeof P=="object"&&P!==null){let F=Lle(o,f,P,d,y,E);return F.type==="Identifier"?F:{type:"ObjectExpression",properties:F.properties||[]}}else return{type:"Literal",value:P}})}}t(t_t,"processArray");function r_t(s,o){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:o}],kind:"var"},specifiers:[],source:null}}t(r_t,"createExportedConstAssignment");function ndr(s,o,f,d){let y=[];for(let E=0;E<f.length;E++){let P=n_t(s,E),F=o.get(f[E]),J=Lle(Noe(f[E]),s,F,o,f,d);y.push(r_t(P,J))}return y}t(ndr,"generateRefs");function n_t(s,o){return`${JP(s)}__ref__${o}`}t(n_t,"getRefIdentifierName");import i_t from"node:path";var s_t=t(s=>{let o=null;if(s.value.type==="Object"&&s.value.members.length>0)for(let f of s.value.members){let d=s_t(f);if(d!==null&&(o=d),f.name.value==="enum"&&f.value.type==="Array"&&f.value.elements.length===0){let y=f.value,E=y.loc.start.line,P=y.loc.start.column,F=y.loc.end.column;o={line:E,column:P,length:F-P,lineText:""}}}return o},"findEmptyEnums"),idr=t(s=>{if(s.startsWith("schema with key or id")&&s.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(s.includes("All JSON schemas must use version 2020-12"))return"All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html";if(s==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(s==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(s.startsWith("can't resolve reference http"))return"Cannot resolve remote references, try adding them directly to the schema file or as a schema file in the project.";if(s.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(s.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(s.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(s.includes("Unexpected")&&s.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),k4e=t(async(s,o,f)=>{if(!s)return null;let d={file:i_t.join(qPe,s),suggestion:idr(f)},y=i_t.join(o,qPe),E=tu.safePath(o).resolve(y,s),P=await Poe(E);if(f.includes("enum must have non-empty array")){if(P){let F=await kV(P);if(F&&F.body.members!==null)for(let J of F.body.members){let V=s_t(J);V&&V!==null&&(d=Object.assign(d??{},V))}if(d){let J=d.line?d.line:0;d.lineText=CV(P,J)}}}else if(f.includes("Unexpected")&&f.includes("in JSON at position")&&P){let F=await kV(P);F&&"lineText"in F&&(d=Object.assign(d??{},F))}return d},"getLocation");import*as K_t from"esbuild";import q4e,{dirname as H_t}from"node:path";import{fileURLToPath as G_t}from"node:url";var w4e=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT,10):3e3}get DEBUG_BUILD_MODE(){return!!process.env.DEBUG_BUILD_MODE}get USE_MONOREPO_PACKAGES(){return process.env.USE_MONOREPO_PACKAGES==="true"}get EXPERIMENTAL_CODEGEN(){return!!process.env.EXPERIMENTAL_CODEGEN}get NODE_ENV(){return process.env.NODE_ENV}isProduction(){return this.NODE_ENV==="production"}isLocalDevelopment(){return process.env.ZUPLO_IS_LOCAL_DEVELOPMENT==="true"}},sdr=new w4e,km=sdr;var D4e="no-remote-module";function a_t({logger:s}){return{name:D4e,async setup(o){o.onResolve({filter:/^https?:\/\//},f=>(s.error(f,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${f.path}`,detail:"InvalidRemoteModule",pluginName:D4e,location:{line:0,column:0,file:""}}],pluginName:D4e}))}}}t(a_t,"blockRemoteModulePlugin");import o_t from"node:path";var c_t="legacy-environment",l_t="legacy-environment",adr=`import { environment } from "@zuplo/runtime";
604
+ `?(F=0,J++):F++;this.column=F,this.line=J;return}}let{length:d}=o,{lineEnd:y}=this;d>0&&(this.lineEndSize>0&&(y.length===1?o[d-1]===y:o.endsWith(y))?(this.line+=this.lineEndSize,this.column=0):this.column+=d)}toString(){return this.output}};function e_t(s,o){let f=new E4e(o);return f.generator[s.type](s,f),f.output}t(e_t,"generate");async function C4e({oasFiles:s,sourceDirectory:o,logger:f}){let d=await rdr({oasFiles:s,sourceDirectory:o,logger:f});return e_t(d)}t(C4e,"generateRawRouteSource");async function rdr({oasFiles:s,sourceDirectory:o,logger:f}){let d=new bI(o,f),y=[];for(let P of s){let F=tdr.basename(P,".oas.json"),J=await d.resolve(P),V=[],Te=new Map,de=await edr.readFile(P,"utf-8"),ae=JSON.parse(de);for(let Ye in ae.paths){let Ue=ae.paths[Ye],je=Ue.parameters||[],Kt={};Ue.summary&&(Kt.pathSummary=Ue.summary),Ue.description&&(Kt.pathDescription=Ue.description),Ue.servers&&(Kt.pathServers=Ue.servers);for(let Ut in Ue){if(!ile(Ut))continue;let kr=Ue[Ut],An=[...je,...kr.parameters||[]],nn={...kr,...An.length>0&&{parameters:An},...Kt,...kr.description&&{description:kr.description.length>350?`${kr.description.substring(0,350).trim()}...`:kr.description}},Pn=AV(F,Ye,Ut),wr=Lle(P,F,nn,J,V,Te);y.unshift(r_t(Pn,wr))}}y.unshift(...ndr(F,J,V,Te).reverse())}return{type:"Program",body:y,sourceType:"module"}}t(rdr,"generateAst");function Lle(s,o,f,d,y,E){let P=[];for(let F in f){let J=f[F];if(F==="$ref")return wV(s,o,KN(s,J),d,y,E),{type:"Identifier",name:n_t(o,E.get(KN(s,J)))};let V;switch(typeof J){case"string":case"number":case"boolean":V={type:"Literal",value:J};break;default:Array.isArray(J)?V=t_t(J,s,o,d,y,E):typeof J=="object"&&J!==null&&(V=Lle(s,o,J,d,y,E));break}if(V){let Te=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(F),de=Te?{type:"Identifier",name:F}:{type:"Literal",value:F};P.push({type:"Property",key:de,value:V,kind:"init",method:!1,shorthand:!1,computed:!Te})}}return{type:"ObjectExpression",properties:P}}t(Lle,"processNode");function t_t(s,o,f,d,y,E){return{type:"ArrayExpression",elements:s.map(P=>{if(Array.isArray(P))return t_t(P,o,f,d,y,E);if(typeof P=="object"&&P!==null){let F=Lle(o,f,P,d,y,E);return F.type==="Identifier"?F:{type:"ObjectExpression",properties:F.properties||[]}}else return{type:"Literal",value:P}})}}t(t_t,"processArray");function r_t(s,o){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:o}],kind:"var"},specifiers:[],source:null,attributes:[]}}t(r_t,"createExportedConstAssignment");function ndr(s,o,f,d){let y=[];for(let E=0;E<f.length;E++){let P=n_t(s,E),F=o.get(f[E]),J=Lle(Noe(f[E]),s,F,o,f,d);y.push(r_t(P,J))}return y}t(ndr,"generateRefs");function n_t(s,o){return`${JP(s)}__ref__${o}`}t(n_t,"getRefIdentifierName");import i_t from"node:path";var s_t=t(s=>{let o=null;if(s.value.type==="Object"&&s.value.members.length>0)for(let f of s.value.members){let d=s_t(f);if(d!==null&&(o=d),f.name.value==="enum"&&f.value.type==="Array"&&f.value.elements.length===0){let y=f.value,E=y.loc.start.line,P=y.loc.start.column,F=y.loc.end.column;o={line:E,column:P,length:F-P,lineText:""}}}return o},"findEmptyEnums"),idr=t(s=>{if(s.startsWith("schema with key or id")&&s.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(s.includes("All JSON schemas must use version 2020-12"))return"All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html";if(s==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(s==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(s.startsWith("can't resolve reference http"))return"Cannot resolve remote references, try adding them directly to the schema file or as a schema file in the project.";if(s.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(s.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(s.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(s.includes("Unexpected")&&s.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),k4e=t(async(s,o,f)=>{if(!s)return null;let d={file:i_t.join(qPe,s),suggestion:idr(f)},y=i_t.join(o,qPe),E=tu.safePath(o).resolve(y,s),P=await Poe(E);if(f.includes("enum must have non-empty array")){if(P){let F=await kV(P);if(F&&F.body.members!==null)for(let J of F.body.members){let V=s_t(J);V&&V!==null&&(d=Object.assign(d??{},V))}if(d){let J=d.line?d.line:0;d.lineText=CV(P,J)}}}else if(f.includes("Unexpected")&&f.includes("in JSON at position")&&P){let F=await kV(P);F&&"lineText"in F&&(d=Object.assign(d??{},F))}return d},"getLocation");import*as K_t from"esbuild";import q4e,{dirname as H_t}from"node:path";import{fileURLToPath as G_t}from"node:url";var w4e=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT,10):3e3}get DEBUG_BUILD_MODE(){return!!process.env.DEBUG_BUILD_MODE}get USE_MONOREPO_PACKAGES(){return process.env.USE_MONOREPO_PACKAGES==="true"}get EXPERIMENTAL_CODEGEN(){return!!process.env.EXPERIMENTAL_CODEGEN}get NODE_ENV(){return process.env.NODE_ENV}isProduction(){return this.NODE_ENV==="production"}isLocalDevelopment(){return process.env.ZUPLO_IS_LOCAL_DEVELOPMENT==="true"}},sdr=new w4e,km=sdr;var D4e="no-remote-module";function a_t({logger:s}){return{name:D4e,async setup(o){o.onResolve({filter:/^https?:\/\//},f=>(s.error(f,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${f.path}`,detail:"InvalidRemoteModule",pluginName:D4e,location:{line:0,column:0,file:""}}],pluginName:D4e}))}}}t(a_t,"blockRemoteModulePlugin");import o_t from"node:path";var c_t="legacy-environment",l_t="legacy-environment",adr=`import { environment } from "@zuplo/runtime";
605
605
  export default environment;`;function u_t(s){return{name:"environment",setup(o){o.onResolve({filter:/@app\/environment$/},()=>({namespace:l_t,pluginName:c_t,path:o_t.join(s.sourceDirectory,Ng,"environment.js")})),o.onLoad({filter:/.*/,namespace:l_t},async f=>({contents:adr,loader:"ts",resolveDir:o_t.dirname(f.path),pluginName:c_t}))}}}t(u_t,"environmentPlugin");import Ddr from"node:fs/promises";import ST from"node:path";var C_t=ep(EH(),1),k_t=ep(Gce(),1),w_t=ep(P4e(),1),D_t=ep(M4e(),1);import{performance as jE}from"node:perf_hooks";var GH=[];async function Cdr(s,o){let f=jE.now();try{return await o()}finally{let d=jE.now()-f;GH.push({name:s,duration:d})}}t(Cdr,"timeFn");var kdr={mark:t(s=>{jE.mark(s)},"mark"),measure:t((s,o,f)=>{try{jE.measure(s,o,f)}finally{jE.clearMarks(o),jE.clearMarks(f),jE.clearMeasures(s)}},"measure"),timeFn:Cdr,report:t(()=>{if(GH.length>0){let s=GH.reduce((o,{name:f,duration:d})=>(o[f]=`${d.toFixed(0)}ms`,o),{});console.table(s),GH.length=0}},"report"),getDuration:t(s=>{let o=jE.getEntriesByName(s);if(o.length===0)return 0;let f=o[0].duration;return jE.clearMeasures(s),f},"getDuration"),clear:t(()=>{GH.length=0,jE.clearMarks(),jE.clearMeasures()},"clear")},Ou=kdr;import{writeFile as wdr}from"node:fs/promises";async function Vk(s,o){await tu.mkdirForFilePathIfNotExits(s);let f=await import("prettier"),d=o;try{d=await f.format(o,{parser:"babel"})}catch{}await wdr(s,d,"utf-8")}t(Vk,"writeDebugSourceFile");var Hk="schemas",Mle="json-schema";function P_t(s){return{name:Hk,async setup(o){let f=new k_t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0}),d=ST.join(s.sourceDirectory,cV),y=[],E=[],P;await Ou.timeFn("Initializing schema validation",async()=>{if((0,D_t.default)(f,{mode:"fast"}),f.opts.code.formats=C_t._`require("ajv-formats/dist/formats").fastFormats`,await tu.dirExists(d)&&(f.addKeyword("faker"),P=(await tu.listFolderContents(d,cV)).sort(),await Promise.all(P.map(async F=>{try{let J=tu.safePath(s.sourceDirectory).resolve(d,F);if(!J.startsWith(d))throw new Error("All schemas must be in the schemas directory");let V=await Ddr.readFile(J,"utf-8");if(V===""||V===void 0)throw new Error(`Schema 'schemas/${F}' is empty and will be ignored.`);let Te=JSON.parse(V);if(Te.$schema&&Te.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${F}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(f.addSchema(Te,F),f.errors?.length){let de=f.errors[0];y.push({id:"json-schema-validation-error",pluginName:Hk,text:`Error: ${de.message}`,location:{file:ST.join(cV,F)},detail:{params:de.params,propertyName:de.propertyName,schemaPath:de.schemaPath,data:de.data}})}}catch(J){if(J.message.endsWith("is empty and will be ignored.")){E.push({id:"empty-json-schema-file",pluginName:Hk,text:`Schema 'schemas/${F}' is empty and will be ignored.`,location:{file:`schemas/${F}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${F}' is empty and will be ignored.`,location:{file:`schemas/${F}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let V=await k4e(F,s.sourceDirectory,J.message);y.push({id:"json-schema-add-error",pluginName:Hk,text:`Error: ${J.message}`,location:V,detail:"InvalidAddSchemaError",notes:[{text:J.message}]})}})),await Promise.all(P.map(async F=>{try{let J=f.getSchema(F);J&&f.compile(J.schema).errors?.forEach(Te=>{y.push({text:`Failed to compile ${F}: ${Te.message}`})})}catch(J){let V=await k4e(F,s.sourceDirectory,J.message);y.push({id:"json-schema-compile-error",pluginName:Hk,text:`The schema file '${F}' is not valid. Error: ${J.message}`,location:V,detail:"InvalidSchemaError",notes:[{text:J.message}]})}})),km.DEBUG_BUILD_MODE)){let F=ST.resolve(s.outputDirectory,cV);await tu.mkdirIfNotExists(F)}}),o.onStart(async()=>{if(P)return{errors:y,warnings:E}}),o.onResolve({filter:/schemas\/.*\.json$/},async F=>Ou.timeFn("Generating JSON schemas...",async()=>{let J=ST.isAbsolute(F.path)?F.path:ST.join(F.resolveDir,F.path);if(F.importer&&F.namespace!=="open-api-routes-json")return{path:J};if(!await tu.fileExists(J)){let V="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${F.path}' from ${V}`,location:{file:ST.join(F.resolveDir,V),namespace:Mle,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${V}`,suggestion:""},detail:"RouteReferenceError",pluginName:Hk,notes:[{text:`Unable to resolve reference to '${F.path}' from ${V}`,location:null}]}],namespace:Mle,path:J,pluginName:Hk}}return{path:J,namespace:Mle,pluginName:Hk}})),o.onLoad({filter:/.*/,namespace:Mle},async F=>Ou.timeFn(`Generating json schema data: ${ST.basename(F.path)}`,async()=>{let J=[],V;try{let Te=ST.relative(d,F.path),de=f.getSchema(Te);if(!de)throw new Error(`Could not load schema at ${F.path}`);V=de.source?.validateCode;let ae=f.compile(de.schema);V=(0,w_t.default)(f,ae)}catch(Te){J.push({pluginName:Hk,text:`Cannot parse project's schemas/${ST.basename(F.path)} file. Error: ${Te.message}`,location:null,notes:[{text:Te.message,location:null}],detail:Te})}if(km.DEBUG_BUILD_MODE&&V){let Te=ST.relative(d,F.path),de=ST.join(s.sourceDirectory,Ng,`${Te}.js`);await Vk(de,V)}return{contents:V,errors:J,pluginName:Hk,resolveDir:ST.dirname(F.path),watchFiles:[F.path]}}))}}}t(P_t,"jsonSchemaPlugin");import{relative as Pdr}from"node:path";var A_t=["node:assert","node:async_hooks","node:buffer","node:crypto","node:diagnostics_channel","node:events","node:path","node:process","node:stream","node:string_decoder","node:util"],Adr="nodejs-compat-plugin";function N_t({sourceDirectory:s}){return{name:Adr,setup(o){let f=new Set;o.onStart(()=>{f.clear()}),o.onResolve({filter:/node:.*/},async({path:d,kind:y,resolveDir:E,...P})=>{let F=`${d}:${y}:${E}:${P.importer}`;if(f.has(F))return;f.add(F);let J=await o.resolve(d,{kind:y,resolveDir:E,importer:P.importer});return J.errors.length>0?A_t.includes(d)||d.includes("/")&&A_t.includes(d.split("/")[0])?{external:!0}:{external:!0,warnings:J.errors.map(Te=>({...Te,location:{file:Pdr(s,P.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${d}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:J})}}}t(N_t,"nodejsCompatPlugin");import I_t from"node:fs/promises";import BE from"node:path";var TI="open-api-routes-plugin",YH="open-api-routes-json";function O_t(s){return{name:"open-api-routes-plugin",setup(o){o.onResolve({filter:/zuplo:routes$/},f=>({watchFiles:[...j4e(BE.join(s.sourceDirectory,xy),[".oas.json"],!0),BE.join(s.sourceDirectory,xy,noe)],namespace:YH,path:BE.isAbsolute(f.path)?f.path:BE.join(f.resolveDir,f.path),pluginName:TI})),o.onResolve({filter:/^\.\.\/modules\/.*/,namespace:YH},async f=>Ou.timeFn("Generating route data...",async()=>{async function d(){let E=BE.resolve(s.sourceDirectory,"config"),P=await hO(E),F=`$import(.${f.path.replace(/^../,"")})`;return{location:await Gnt(P,F,"Update your route configuration to use code from the 'modules' folder"),originalImportValue:F}}t(d,"getLocation");let y=BE.join(f.resolveDir,`${f.path}.ts`);if(f.path.endsWith(".ts")){let{location:E,originalImportValue:P}=await d();return{errors:[{id:"route-build-error",text:`Invalid handler reference '${P}' in ${E?.file??"OpenAPI file"}. Imports must NOT include the '.ts' file extension.`,location:E,detail:"RouteReferenceError",pluginName:TI}],namespace:YH,path:f.path,pluginName:TI}}else if(!await tu.fileExists(y)){let{location:E,originalImportValue:P}=await d();return{errors:[{id:"route-build-error",text:`Invalid handler reference in route. Unable to resolve reference to '${P}' in ${E?.file??"OpenAPI file"}`,location:E,detail:"RouteReferenceError",pluginName:TI}],namespace:YH,path:f.path,pluginName:TI}}})),o.onLoad({filter:/.*/,namespace:YH},async f=>Ou.timeFn("Generating route.json data",async()=>{let d=BE.resolve(s.sourceDirectory,"config"),y=await hO(d),E=await Promise.all(y.map(async V=>({content:await I_t.readFile(V,"utf-8"),fileName:V}))),P=BE.resolve(d,"policies.json");if(!await tu.fileExists(P))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:TI,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:TI};let F={content:await I_t.readFile(P,"utf-8"),fileName:P},J;try{J=await aIe({sourceDirectory:s.sourceDirectory,oasContent:E,policiesContent:F,compatibilityDate:s.config.compatibilityDate,allowDuplicateRoutes:s.config.allowDuplicateRoutes})}catch(V){throw new Error(`Error compiling routes: ${V.message}`)}if(km.DEBUG_BUILD_MODE&&J.content){let V=BE.join(s.sourceDirectory,Ng),Te=BE.resolve(V,"routes.js");await Vk(Te,J.content)}return{contents:J.content,errors:J.errors,pluginName:TI,resolveDir:BE.dirname(f.path),watchFiles:[f.path]}}))}}}t(O_t,"openApiRoutesPlugin");import jle from"node:path";var KH="raw-route-plugin",F_t="raw-route";function L_t(s){return{name:"raw-route-plugin",setup(o){o.onResolve({filter:/zuplo:raw-routes$/},f=>({namespace:F_t,path:f.path,pluginName:KH})),o.onLoad({filter:/.*/,namespace:F_t},async f=>Ou.timeFn("Building route data",async()=>{let d=jle.resolve(s.sourceDirectory,xy);if(!await tu.dirExists(d))return{loader:"js",resolveDir:jle.dirname(f.path),pluginName:KH};let y=await hO(d);try{let E=await C4e({oasFiles:y,sourceDirectory:s.sourceDirectory,logger:s.logger});if(km.DEBUG_BUILD_MODE&&E){let P=jle.join(s.sourceDirectory,Ng,"raw-routes.js");await Vk(P,E)}return{contents:E,loader:"js",resolveDir:jle.dirname(f.path),pluginName:KH}}catch(E){if(E instanceof k1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:E.issue.text,location:E.issue.location,detail:E.issue.detail,pluginName:KH}],pluginName:KH};throw E}}))}}}t(L_t,"rawRoutePlugin");import Ndr from"node:fs/promises";import R_t from"node:path";var Ble="runtime-extensions-plugin",M_t="runtime-extensions";function j_t(s){return{name:Ble,setup(o){o.onResolve({filter:/zuplo:runtime-extension$/},f=>({namespace:M_t,path:f.path,pluginName:Ble})),o.onLoad({filter:/.*/,namespace:M_t},async()=>Ou.timeFn("Generating zuplo.runtime.ts data",async()=>{let f="export const runtimeInit = undefined;",d=R_t.resolve(s.sourceDirectory,srt,"zuplo.runtime.ts"),y=[];return await tu.fileExists(d)?(f=await Ndr.readFile(d,"utf-8"),{contents:f,loader:"ts",resolveDir:R_t.dirname(d),errors:y,pluginName:Ble,watchFiles:[d]}):{contents:f,loader:"ts",errors:y,pluginName:Ble}}))}}}t(j_t,"runtimeExtensionsPlugin");import B_t from"node:path";import{readFile as Idr}from"node:fs/promises";import xI from"node:path";var jM=class extends Error{static{t(this,"DevPortalConfigError")}filename;constructor(o,f){super(o,f),this.name="DevPortalConfigError",this.filename=f?.filename}};async function B4e(s){let o=["zudoku.config.tsx","zudoku.config.ts","zudoku.config.js","zudoku.config.jsx","zudoku.config.mjs"];for(;o.length;){let P=o.pop();if(P){let F=xI.join("docs",P),J=xI.join(s,F);try{if(await tu.fileExists(J))return{enabled:!0,type:"zudoku",basePath:void 0,filepath:F}}catch(V){throw new jM("Failed to read dev portal configuration file.",{cause:V,filename:F})}}}let f=xI.join(xy,ort),d=xI.join(s,f),y=!0,E;if(await tu.fileExists(d)){try{let P=await Idr(d,"utf-8"),F=JSON.parse(P);F.enabled===!1&&(y=!1),E=F.sitePathname}catch(P){throw new jM("Failed to parse dev-portal.json file.",{cause:P,filename:f})}return{enabled:y,type:"legacy",basePath:E,filepath:f}}return{enabled:!1,type:void 0,basePath:void 0,filepath:void 0}}t(B4e,"getDevPortalConfig");function BM(s,o){let f=xI.resolve(s,uO);return Object.keys(o?.outputs??{}).map(E=>{let P=xI.normalize(E);return`./${xI.relative(f,P).split(xI.sep).join("/")}`})}t(BM,"getBuildModules");var U_t="/docs",Odr="/__zuplo/dev-portal";function Fdr(s){let o=s.trim().toLowerCase();return o.endsWith("/")&&(o=o.slice(0,-1)),o}t(Fdr,"normalizePathname");function Ldr(s,o){let d={developerPortal:{basePath:s?.basePath===Odr?U_t:s?.basePath?Fdr(s.basePath):U_t,enabled:s?s.enabled??!0:!1,type:s?.type??void 0,urls:s?.urls?{defaultUrl:s.urls.defaultUrl,urls:s.urls.urls.map(E=>new URL(E).origin)}:void 0},api:o};return`const runtimeSettings = ${JSON.stringify(d)};
606
606
  export default runtimeSettings;`}t(Ldr,"generateSource");var XH="runtime-settings-plugin",Ule="runtime-settings";function z_t(s){return{name:XH,setup(o){o.onResolve({filter:/zuplo:runtime-settings$/},f=>({namespace:Ule,path:f.path,pluginName:XH})),o.onLoad({filter:/.*/,namespace:Ule},async()=>Ou.timeFn("Generating runtime settings",async()=>{let f=[],d,y;try{let F=await B4e(s.sourceDirectory);y=F.filepath,d={...F,urls:s.urls?.devPortal}}catch(F){let J="Failed to load dev portal config",V="config/dev-portal.json";F instanceof jM&&(J=F.message,V=F.filename??V),f.push({id:"dev-portal-build-error",text:J,location:{file:V,namespace:Ule,line:1,column:0,length:0,lineText:"",suggestion:""},detail:"DevPortalValidationError",pluginName:XH,notes:[{text:F.message,location:null}]})}let E={urls:s.urls?.api},P;try{if(P=Ldr(d,E),km.DEBUG_BUILD_MODE&&P){let F=B_t.join(s.sourceDirectory,Ng,"dev-portal.js");await Vk(F,P)}}catch(F){f.push({id:"dev-portal-build-error",text:F.message,location:{file:"dev-portal.json",namespace:Ule,line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:XH,notes:[{text:F.message,location:null}]})}return{contents:P,errors:f,pluginName:XH,loader:"js",resolveDir:y?B_t.dirname(y):void 0}}))}}}t(z_t,"runtimeSettingsPlugin");import W4e from"node:fs/promises";import $O from"node:path";var J_t=ep(EH(),1),z4e=ep(Gce(),1),$4e=ep(P4e(),1),W_t=ep(M4e(),1);var U4e="schema-validation-plugin",$_t="schema-validation",Rdr="module.exports = {}";function q_t(s){return{name:"schema-validation-plugin",setup(o){o.onResolve({filter:/zuplo:schema-validations$/},f=>({namespace:$_t,path:f.path,pluginName:U4e})),o.onLoad({filter:/.*/,namespace:$_t},async()=>Ou.timeFn("Validating schemas",async()=>{let f=$O.resolve(s.sourceDirectory,xy,"policies.json");if(!await tu.fileExists(f))return{contents:Rdr,loader:"js",resolveDir:$O.dirname(f),pluginName:U4e};let d=await jdr(s.sourceDirectory),y=$O.resolve(s.sourceDirectory,xy),E=await hO(y),P=await $dr(E,d),F=await Mdr({oasFiles:E,routesWithSchemaValidation:P,sourceDirectory:s.sourceDirectory,logger:s.logger});if(km.DEBUG_BUILD_MODE&&F){let J=$O.join(s.sourceDirectory,Ng,"schema-validation.js");await Vk(J,F)}return{contents:F,loader:"js",resolveDir:$O.dirname(f),pluginName:U4e}}))}}}t(q_t,"schemaValidationPlugin");async function Mdr({oasFiles:s,routesWithSchemaValidation:o,sourceDirectory:f,logger:d}){let y="",E=new bI(f,d);if(o.length===0)return y;let P={code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0},F=new z4e.Ajv2020(P),J=new z4e.Ajv2020({...P,coerceTypes:"array"});(0,W_t.default)(J,{mode:"fast"}),J.opts.code.formats=J_t._`require("ajv-formats/dist/formats").fastFormats`;for(let V of s){let Te=await W4e.readFile(V,"utf-8"),de=$O.basename(V,".oas.json"),ae=o.filter(Ut=>Ut.fileName===de),Ye=await E.resolve(V),Ue=JSON.parse(Te),je=[],Kt=new Map;ae.forEach(Ut=>{let kr=Ue.paths[Ut.path][Ut.method];if(kr.requestBody){let An;if(kr.requestBody.$ref){let nn=kr.requestBody.$ref;An=Ye.get(nn)?.content}else kr.requestBody.content&&(An=kr.requestBody.content);if(An)for(let nn in An){let Pn=An[nn].schema,wr=eAe(Ut.path,Ut.method,nn);Pn.$id=wr,F.addSchema(Pn),J4e(Pn,V,de,F,Ye,je,Kt)}}if(kr.parameters)for(let An of kr.parameters){let nn=An.$ref?Ye.get(An.$ref):An,Pn=nn.schema.$ref?Ye.get(nn.schema.$ref):nn.schema,wr=QPe(Ut.path,Ut.method,nn.in,nn.name);Pn.$id=wr,J.addSchema(Pn),J4e(nn,V,de,J,Ye,je,Kt)}});for(let Ut of je){let kr=Ye.get(Ut),An=NV(de,Ut);F.addSchema(kr,An),J.addSchema(kr,An)}}return y=`"use strict";
607
607
  const __paramExports = (function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/core",
3
- "version": "6.70.16",
3
+ "version": "6.70.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": "6.70.16",
44
- "@zuplo/otel": "6.70.16",
45
- "@zuplo/runtime": "6.70.16",
43
+ "@zuplo/graphql": "6.70.22",
44
+ "@zuplo/otel": "6.70.22",
45
+ "@zuplo/runtime": "6.70.22",
46
46
  "deno": "2.3.1"
47
47
  }
48
48
  }