@zuplo/core 6.52.7 → 6.52.12
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.d.ts +5 -6
- package/index.minified.js +1 -1
- package/package.json +5 -5
package/customer.cli.minified.js
CHANGED
|
@@ -609,7 +609,7 @@ globstar while`,s,Q,l,Re,Ie),this.matchOne(s.slice(Q),l.slice(Re),_))return this
|
|
|
609
609
|
`,D):(a.write("/*"),n0r(a,D.value,l,_),a.write("*/"+_))}}t(ev,"formatComments");function i0r(a){let s=a;for(;s!=null;){let{type:l}=s;if(l[0]==="C"&&l[1]==="a")return!0;if(l[0]==="M"&&l[1]==="e"&&l[2]==="m")s=s.object;else return!1}}t(i0r,"hasCallExpression");function SFe(a,s){let{generator:l}=a,{declarations:_}=s;a.write(s.kind+" ");let{length:h}=_;if(h>0){l.VariableDeclarator(_[0],a);for(let b=1;b<h;b++)a.write(", "),l.VariableDeclarator(_[b],a)}}t(SFe,"formatVariableDeclaration");var Kht,Yht,Xht,Qht,Zht,egt,s0r={Program(a,s){let l=s.indent.repeat(s.indentLevel),{lineEnd:_,writeComments:h}=s;h&&a.comments!=null&&ev(s,a.comments,l,_);let b=a.body,{length:D}=b;for(let N=0;N<D;N++){let M=b[N];h&&M.comments!=null&&ev(s,M.comments,l,_),s.write(l),this[M.type](M,s),s.write(_)}h&&a.trailingComments!=null&&ev(s,a.trailingComments,l,_)},BlockStatement:egt=t(function(a,s){let l=s.indent.repeat(s.indentLevel++),{lineEnd:_,writeComments:h}=s,b=l+s.indent;s.write("{");let D=a.body;if(D!=null&&D.length>0){s.write(_),h&&a.comments!=null&&ev(s,a.comments,b,_);let{length:N}=D;for(let M=0;M<N;M++){let z=D[M];h&&z.comments!=null&&ev(s,z.comments,b,_),s.write(b),this[z.type](z,s),s.write(_)}s.write(l)}else h&&a.comments!=null&&(s.write(_),ev(s,a.comments,b,_),s.write(l));h&&a.trailingComments!=null&&ev(s,a.trailingComments,b,_),s.write("}"),s.indentLevel--},"BlockStatement"),ClassBody:egt,StaticBlock(a,s){s.write("static "),this.BlockStatement(a,s)},EmptyStatement(a,s){s.write(";")},ExpressionStatement(a,s){let l=s.expressionsPrecedence[a.expression.type];l===lE||l===3&&a.expression.left.type[0]==="O"?(s.write("("),this[a.expression.type](a.expression,s),s.write(")")):this[a.expression.type](a.expression,s),s.write(";")},IfStatement(a,s){s.write("if ("),this[a.test.type](a.test,s),s.write(") "),this[a.consequent.type](a.consequent,s),a.alternate!=null&&(s.write(" else "),this[a.alternate.type](a.alternate,s))},LabeledStatement(a,s){this[a.label.type](a.label,s),s.write(": "),this[a.body.type](a.body,s)},BreakStatement(a,s){s.write("break"),a.label!=null&&(s.write(" "),this[a.label.type](a.label,s)),s.write(";")},ContinueStatement(a,s){s.write("continue"),a.label!=null&&(s.write(" "),this[a.label.type](a.label,s)),s.write(";")},WithStatement(a,s){s.write("with ("),this[a.object.type](a.object,s),s.write(") "),this[a.body.type](a.body,s)},SwitchStatement(a,s){let l=s.indent.repeat(s.indentLevel++),{lineEnd:_,writeComments:h}=s;s.indentLevel++;let b=l+s.indent,D=b+s.indent;s.write("switch ("),this[a.discriminant.type](a.discriminant,s),s.write(") {"+_);let{cases:N}=a,{length:M}=N;for(let z=0;z<M;z++){let re=N[z];h&&re.comments!=null&&ev(s,re.comments,b,_),re.test?(s.write(b+"case "),this[re.test.type](re.test,s),s.write(":"+_)):s.write(b+"default:"+_);let{consequent:ie}=re,{length:Q}=ie;for(let Re=0;Re<Q;Re++){let Ie=ie[Re];h&&Ie.comments!=null&&ev(s,Ie.comments,D,_),s.write(D),this[Ie.type](Ie,s),s.write(_)}}s.indentLevel-=2,s.write(l+"}")},ReturnStatement(a,s){s.write("return"),a.argument&&(s.write(" "),this[a.argument.type](a.argument,s)),s.write(";")},ThrowStatement(a,s){s.write("throw "),this[a.argument.type](a.argument,s),s.write(";")},TryStatement(a,s){if(s.write("try "),this[a.block.type](a.block,s),a.handler){let{handler:l}=a;l.param==null?s.write(" catch "):(s.write(" catch ("),this[l.param.type](l.param,s),s.write(") ")),this[l.body.type](l.body,s)}a.finalizer&&(s.write(" finally "),this[a.finalizer.type](a.finalizer,s))},WhileStatement(a,s){s.write("while ("),this[a.test.type](a.test,s),s.write(") "),this[a.body.type](a.body,s)},DoWhileStatement(a,s){s.write("do "),this[a.body.type](a.body,s),s.write(" while ("),this[a.test.type](a.test,s),s.write(");")},ForStatement(a,s){if(s.write("for ("),a.init!=null){let{init:l}=a;l.type[0]==="V"?SFe(s,l):this[l.type](l,s)}s.write("; "),a.test&&this[a.test.type](a.test,s),s.write("; "),a.update&&this[a.update.type](a.update,s),s.write(") "),this[a.body.type](a.body,s)},ForInStatement:Kht=t(function(a,s){s.write(`for ${a.await?"await ":""}(`);let{left:l}=a;l.type[0]==="V"?SFe(s,l):this[l.type](l,s),s.write(a.type[3]==="I"?" in ":" of "),this[a.right.type](a.right,s),s.write(") "),this[a.body.type](a.body,s)},"ForInStatement"),ForOfStatement:Kht,DebuggerStatement(a,s){s.write("debugger;",a)},FunctionDeclaration:Yht=t(function(a,s){s.write((a.async?"async ":"")+(a.generator?"function* ":"function ")+(a.id?a.id.name:""),a),Uj(s,a.params),s.write(" "),this[a.body.type](a.body,s)},"FunctionDeclaration"),FunctionExpression:Yht,VariableDeclaration(a,s){SFe(s,a),s.write(";")},VariableDeclarator(a,s){this[a.id.type](a.id,s),a.init!=null&&(s.write(" = "),this[a.init.type](a.init,s))},ClassDeclaration(a,s){if(s.write("class "+(a.id?`${a.id.name} `:""),a),a.superClass){s.write("extends ");let{superClass:l}=a,{type:_}=l,h=s.expressionsPrecedence[_];(_[0]!=="C"||_[1]!=="l"||_[5]!=="E")&&(h===lE||h<s.expressionsPrecedence.ClassExpression)?(s.write("("),this[a.superClass.type](l,s),s.write(")")):this[l.type](l,s),s.write(" ")}this.ClassBody(a.body,s)},ImportDeclaration(a,s){s.write("import ");let{specifiers:l,attributes:_}=a,{length:h}=l,b=0;if(h>0){for(;b<h;){b>0&&s.write(", ");let D=l[b],N=D.type[6];if(N==="D")s.write(D.local.name,D),b++;else if(N==="N")s.write("* as "+D.local.name,D),b++;else break}if(b<h){for(s.write("{");;){let D=l[b],{name:N}=D.imported;if(s.write(N,D),N!==D.local.name&&s.write(" as "+D.local.name),++b<h)s.write(", ");else break}s.write("}")}s.write(" from ")}if(this.Literal(a.source,s),_&&_.length>0){s.write(" with { ");for(let D=0;D<_.length;D++)this.ImportAttribute(_[D],s),D<_.length-1&&s.write(", ");s.write(" }")}s.write(";")},ImportAttribute(a,s){this.Identifier(a.key,s),s.write(": "),this.Literal(a.value,s)},ImportExpression(a,s){s.write("import("),this[a.source.type](a.source,s),s.write(")")},ExportDefaultDeclaration(a,s){s.write("export default "),this[a.declaration.type](a.declaration,s),s.expressionsPrecedence[a.declaration.type]!=null&&a.declaration.type[0]!=="F"&&s.write(";")},ExportNamedDeclaration(a,s){if(s.write("export "),a.declaration)this[a.declaration.type](a.declaration,s);else{s.write("{");let{specifiers:l}=a,{length:_}=l;if(_>0)for(let h=0;;){let b=l[h],{name:D}=b.local;if(s.write(D,b),D!==b.exported.name&&s.write(" as "+b.exported.name),++h<_)s.write(", ");else break}if(s.write("}"),a.source&&(s.write(" from "),this.Literal(a.source,s)),a.attributes&&a.attributes.length>0){s.write(" with { ");for(let h=0;h<a.attributes.length;h++)this.ImportAttribute(a.attributes[h],s),h<a.attributes.length-1&&s.write(", ");s.write(" }")}s.write(";")}},ExportAllDeclaration(a,s){if(a.exported!=null?s.write("export * as "+a.exported.name+" from "):s.write("export * from "),this.Literal(a.source,s),a.attributes&&a.attributes.length>0){s.write(" with { ");for(let l=0;l<a.attributes.length;l++)this.ImportAttribute(a.attributes[l],s),l<a.attributes.length-1&&s.write(", ");s.write(" }")}s.write(";")},MethodDefinition(a,s){a.static&&s.write("static ");let l=a.kind[0];(l==="g"||l==="s")&&s.write(a.kind+" "),a.value.async&&s.write("async "),a.value.generator&&s.write("*"),a.computed?(s.write("["),this[a.key.type](a.key,s),s.write("]")):this[a.key.type](a.key,s),Uj(s,a.value.params),s.write(" "),this[a.value.body.type](a.value.body,s)},ClassExpression(a,s){this.ClassDeclaration(a,s)},ArrowFunctionExpression(a,s){s.write(a.async?"async ":"",a);let{params:l}=a;l!=null&&(l.length===1&&l[0].type[0]==="I"?s.write(l[0].name,l[0]):Uj(s,a.params)),s.write(" => "),a.body.type[0]==="O"?(s.write("("),this.ObjectExpression(a.body,s),s.write(")")):this[a.body.type](a.body,s)},ThisExpression(a,s){s.write("this",a)},Super(a,s){s.write("super",a)},RestElement:Xht=t(function(a,s){s.write("..."),this[a.argument.type](a.argument,s)},"RestElement"),SpreadElement:Xht,YieldExpression(a,s){s.write(a.delegate?"yield*":"yield"),a.argument&&(s.write(" "),this[a.argument.type](a.argument,s))},AwaitExpression(a,s){s.write("await ",a),qfe(s,a.argument,a)},TemplateLiteral(a,s){let{quasis:l,expressions:_}=a;s.write("`");let{length:h}=_;for(let D=0;D<h;D++){let N=_[D],M=l[D];s.write(M.value.raw,M),s.write("${"),this[N.type](N,s),s.write("}")}let b=l[l.length-1];s.write(b.value.raw,b),s.write("`")},TemplateElement(a,s){s.write(a.value.raw,a)},TaggedTemplateExpression(a,s){qfe(s,a.tag,a),this[a.quasi.type](a.quasi,s)},ArrayExpression:Zht=t(function(a,s){if(s.write("["),a.elements.length>0){let{elements:l}=a,{length:_}=l;for(let h=0;;){let b=l[h];if(b!=null&&this[b.type](b,s),++h<_)s.write(", ");else{b==null&&s.write(", ");break}}}s.write("]")},"ArrayExpression"),ArrayPattern:Zht,ObjectExpression(a,s){let l=s.indent.repeat(s.indentLevel++),{lineEnd:_,writeComments:h}=s,b=l+s.indent;if(s.write("{"),a.properties.length>0){s.write(_),h&&a.comments!=null&&ev(s,a.comments,b,_);let D=","+_,{properties:N}=a,{length:M}=N;for(let z=0;;){let re=N[z];if(h&&re.comments!=null&&ev(s,re.comments,b,_),s.write(b),this[re.type](re,s),++z<M)s.write(D);else break}s.write(_),h&&a.trailingComments!=null&&ev(s,a.trailingComments,b,_),s.write(l+"}")}else h?a.comments!=null?(s.write(_),ev(s,a.comments,b,_),a.trailingComments!=null&&ev(s,a.trailingComments,b,_),s.write(l+"}")):a.trailingComments!=null?(s.write(_),ev(s,a.trailingComments,b,_),s.write(l+"}")):s.write("}"):s.write("}");s.indentLevel--},Property(a,s){a.method||a.kind[0]!=="i"?this.MethodDefinition(a,s):(a.shorthand||(a.computed?(s.write("["),this[a.key.type](a.key,s),s.write("]")):this[a.key.type](a.key,s),s.write(": ")),this[a.value.type](a.value,s))},PropertyDefinition(a,s){if(a.static&&s.write("static "),a.computed&&s.write("["),this[a.key.type](a.key,s),a.computed&&s.write("]"),a.value==null){a.key.type[0]!=="F"&&s.write(";");return}s.write(" = "),this[a.value.type](a.value,s),s.write(";")},ObjectPattern(a,s){if(s.write("{"),a.properties.length>0){let{properties:l}=a,{length:_}=l;for(let h=0;this[l[h].type](l[h],s),++h<_;)s.write(", ")}s.write("}")},SequenceExpression(a,s){Uj(s,a.expressions)},UnaryExpression(a,s){if(a.prefix){let{operator:l,argument:_,argument:{type:h}}=a;s.write(l);let b=tgt(s,_,a);!b&&(l.length>1||h[0]==="U"&&(h[1]==="n"||h[1]==="p")&&_.prefix&&_.operator[0]===l&&(l==="+"||l==="-"))&&s.write(" "),b?(s.write(l.length>1?" (":"("),this[h](_,s),s.write(")")):this[h](_,s)}else this[a.argument.type](a.argument,s),s.write(a.operator)},UpdateExpression(a,s){a.prefix?(s.write(a.operator),this[a.argument.type](a.argument,s)):(this[a.argument.type](a.argument,s),s.write(a.operator))},AssignmentExpression(a,s){this[a.left.type](a.left,s),s.write(" "+a.operator+" "),this[a.right.type](a.right,s)},AssignmentPattern(a,s){this[a.left.type](a.left,s),s.write(" = "),this[a.right.type](a.right,s)},BinaryExpression:Qht=t(function(a,s){let l=a.operator==="in";l&&s.write("("),qfe(s,a.left,a,!1),s.write(" "+a.operator+" "),qfe(s,a.right,a,!0),l&&s.write(")")},"BinaryExpression"),LogicalExpression:Qht,ConditionalExpression(a,s){let{test:l}=a,_=s.expressionsPrecedence[l.type];_===lE||_<=s.expressionsPrecedence.ConditionalExpression?(s.write("("),this[l.type](l,s),s.write(")")):this[l.type](l,s),s.write(" ? "),this[a.consequent.type](a.consequent,s),s.write(" : "),this[a.alternate.type](a.alternate,s)},NewExpression(a,s){s.write("new ");let l=s.expressionsPrecedence[a.callee.type];l===lE||l<s.expressionsPrecedence.CallExpression||i0r(a.callee)?(s.write("("),this[a.callee.type](a.callee,s),s.write(")")):this[a.callee.type](a.callee,s),Uj(s,a.arguments)},CallExpression(a,s){let l=s.expressionsPrecedence[a.callee.type];l===lE||l<s.expressionsPrecedence.CallExpression?(s.write("("),this[a.callee.type](a.callee,s),s.write(")")):this[a.callee.type](a.callee,s),a.optional&&s.write("?."),Uj(s,a.arguments)},ChainExpression(a,s){this[a.expression.type](a.expression,s)},MemberExpression(a,s){let l=s.expressionsPrecedence[a.object.type];l===lE||l<s.expressionsPrecedence.MemberExpression?(s.write("("),this[a.object.type](a.object,s),s.write(")")):this[a.object.type](a.object,s),a.computed?(a.optional&&s.write("?."),s.write("["),this[a.property.type](a.property,s),s.write("]")):(a.optional?s.write("?."):s.write("."),this[a.property.type](a.property,s))},MetaProperty(a,s){s.write(a.meta.name+"."+a.property.name,a)},Identifier(a,s){s.write(a.name,a)},PrivateIdentifier(a,s){s.write(`#${a.name}`,a)},Literal(a,s){a.raw!=null?s.write(a.raw,a):a.regex!=null?this.RegExpLiteral(a,s):a.bigint!=null?s.write(a.bigint+"n",a):s.write(t0r(a.value),a)},RegExpLiteral(a,s){let{regex:l}=a;s.write(`/${l.pattern}/${l.flags}`,a)}},a0r={};var TFe=class{static{t(this,"State")}constructor(s){let l=s??a0r;this.output="",l.output!=null?(this.output=l.output,this.write=this.writeToStream):this.output="",this.generator=l.generator!=null?l.generator:s0r,this.expressionsPrecedence=l.expressionsPrecedence!=null?l.expressionsPrecedence:r0r,this.indent=l.indent!=null?l.indent:" ",this.lineEnd=l.lineEnd!=null?l.lineEnd:`
|
|
610
610
|
`,this.indentLevel=l.startingIndentLevel!=null?l.startingIndentLevel:0,this.writeComments=l.comments?l.comments:!1,l.sourceMap!=null&&(this.write=l.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=l.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
|
|
611
611
|
`).length-1,this.mapping={original:null,generated:this,name:void 0,source:l.sourceMap.file||l.sourceMap._file})}write(s){this.output+=s}writeToStream(s){this.output.write(s)}writeAndMap(s,l){this.output+=s,this.map(s,l)}writeToStreamAndMap(s,l){this.output.write(s),this.map(s,l)}map(s,l){if(l!=null){let{type:b}=l;if(b[0]==="L"&&b[2]==="n"){this.column=0,this.line++;return}if(l.loc!=null){let{mapping:D}=this;D.original=l.loc.start,D.name=l.name,this.sourceMap.addMapping(D)}if(b[0]==="T"&&b[8]==="E"||b[0]==="L"&&b[1]==="i"&&typeof l.value=="string"){let{length:D}=s,{column:N,line:M}=this;for(let z=0;z<D;z++)s[z]===`
|
|
612
|
-
`?(N=0,M++):N++;this.column=N,this.line=M;return}}let{length:_}=s,{lineEnd:h}=this;_>0&&(this.lineEndSize>0&&(h.length===1?s[_-1]===h:s.endsWith(h))?(this.line+=this.lineEndSize,this.column=0):this.column+=_)}toString(){return this.output}};function rgt(a,s){let l=new TFe(s);return l.generator[a.type](a,l),l.output}t(rgt,"generate");async function xFe({oasFiles:a,sourceDirectory:s,logger:l}){let _=await l0r({oasFiles:a,sourceDirectory:s,logger:l});return rgt(_)}t(xFe,"generateRawRouteSource");async function l0r({oasFiles:a,sourceDirectory:s,logger:l}){let _=new B3(s,l),h=[];for(let D of a){let N=c0r.basename(D,".oas.json"),M=await _.resolve(D),z=[],re=new Map,ie=await o0r.readFile(D,"utf-8"),Q=JSON.parse(ie);for(let Re in Q.paths){let Ie=Q.paths[Re];for(let we in Ie){if(we.startsWith("x-"))continue;let wt={...Ie[we],...Ie[we].description&&{description:Ie[we].description.length>350?Ie[we].description.substring(0,350).trim()+"...":Ie[we].description}},xt=EG(N,Re,we),Tr=Vfe(D,N,wt,M,z,re);h.unshift(igt(xt,Tr))}}h.unshift(...u0r(N,M,z,re).reverse())}return{type:"Program",body:h,sourceType:"module"}}t(l0r,"generateAst");function Vfe(a,s,l,_,h,b){let D=[];for(let N in l){let M=l[N];if(N==="$ref")return sG(a,s,N3(a,M),_,h,b),{type:"Identifier",name:sgt(s,b.get(N3(a,M)))};let z;switch(typeof M){case"string":case"number":case"boolean":z={type:"Literal",value:M};break;default:Array.isArray(M)?z=ngt(M,a,s,_,h,b):typeof M=="object"&&M!==null&&(z=Vfe(a,s,M,_,h,b));break}if(z){let re=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(N),ie=re?{type:"Identifier",name:N}:{type:"Literal",value:N};D.push({type:"Property",key:ie,value:z,kind:"init",method:!1,shorthand:!1,computed:!re})}}return{type:"ObjectExpression",properties:D}}t(Vfe,"processNode");function ngt(a,s,l,_,h,b){return{type:"ArrayExpression",elements:a.map(D=>{if(Array.isArray(D))return ngt(D,s,l,_,h,b);if(typeof D=="object"&&D!==null){let N=Vfe(s,l,D,_,h,b);return N.type==="Identifier"?N:{type:"ObjectExpression",properties:N.properties||[]}}else return{type:"Literal",value:D}})}}t(ngt,"processArray");function igt(a,s){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s}],kind:"var"},specifiers:[],source:null}}t(igt,"createExportedConstAssignment");function u0r(a,s,l,_){let h=[];for(let b=0;b<l.length;b++){let D=sgt(a,b),N=s.get(l[b]),M=Vfe(Ule(l[b]),a,N,s,l,_);h.push(igt(D,M))}return h}t(u0r,"generateRefs");function sgt(a,s){return`${DA(a)}__ref__${s}`}t(sgt,"getRefIdentifierName");import agt from"node:path";var ogt=t(a=>{let s=null;if(a.value.type==="Object"&&a.value.members.length>0)for(let l of a.value.members){let _=ogt(l);if(_!==null&&(s=_),l.name.value==="enum"&&l.value.type==="Array"&&l.value.elements.length===0){let h=l.value,b=h.loc.start.line,D=h.loc.start.column,N=h.loc.end.column;s={line:b,column:D,length:N-D,lineText:""}}}return s},"findEmptyEnums"),f0r=t(a=>{if(a.startsWith("schema with key or id")&&a.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(a.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(a==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(a==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(a.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(a.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(a.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(a.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(a.includes("Unexpected")&&a.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),CFe=t(async(a,s,l)=>{if(!a)return null;let _={file:agt.join(A4e,a),suggestion:f0r(l)},h=agt.join(s,A4e),b=ou.safePath(s).resolve(h,a),D=await jle(b);if(l.includes("enum must have non-empty array")){if(D){let N=await iG(D);if(N&&N.body.members!==null)for(let M of N.body.members){let z=ogt(M);z&&z!==null&&(_=Object.assign(_??{},z))}if(_){let M=_.line?_.line:0;_.lineText=nG(D,M)}}}else if(l.includes("Unexpected")&&l.includes("in JSON at position")&&D){let N=await iG(D);N&&"lineText"in N&&(_=Object.assign(_??{},N))}return _},"getLocation");import*as K1t from"esbuild";import W7e,{dirname as W1t}from"node:path";import{fileURLToPath as H1t}from"node:url";var EFe=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT):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"}},_0r=new EFe,ih=_0r;var DFe="no-remote-module";function cgt({logger:a}){return{name:DFe,async setup(s){s.onResolve({filter:/^https?:\/\//},l=>(a.error(l,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${l.path}`,detail:"InvalidRemoteModule",pluginName:DFe,location:{line:0,column:0,file:""}}],pluginName:DFe}))}}}t(cgt,"blockRemoteModulePlugin");import ugt from"node:path";import{performance as uE}from"node:perf_hooks";var kK=[];async function p0r(a,s){let l=uE.now();try{return await s()}finally{let _=uE.now()-l;kK.push({name:a,duration:_})}}t(p0r,"timeFn");var d0r={mark:t(a=>{uE.mark(a)},"mark"),measure:t((a,s,l)=>{try{uE.measure(a,s,l)}finally{uE.clearMarks(s),uE.clearMarks(l),uE.clearMeasures(a)}},"measure"),timeFn:p0r,report:t(()=>{if(kK.length>0){let a=kK.reduce((s,{name:l,duration:_})=>(s[l]=`${_.toFixed(0)}ms`,s),{});console.table(a),kK.length=0}},"report"),getDuration:t(a=>{let s=uE.getEntriesByName(a);if(s.length===0)return 0;let l=s[0].duration;return uE.clearMeasures(a),l},"getDuration"),clear:t(()=>{kK.length=0,uE.clearMarks(),uE.clearMeasures()},"clear")},Bu=d0r;import{writeFile as m0r}from"node:fs/promises";async function Sk(a,s){await ou.mkdirForFilePathIfNotExits(a);let l=await import("prettier"),_=s;try{_=await l.format(s,{parser:"babel"})}catch{}await m0r(a,_,"utf-8")}t(Sk,"writeDebugSourceFile");import{readFile as h0r}from"node:fs/promises";import nN from"node:path";var $j=class extends Error{static{t(this,"DevPortalConfigError")}filename;constructor(s,l){super(s,l),this.name="DevPortalConfigError",this.filename=l?.filename}};async function lgt(a){let s=nN.join(V1,qat),l=nN.join(a,s),_=!0,h;if(await ou.fileExists(l)){try{let D=await h0r(l,"utf-8"),N=JSON.parse(D);N.enabled===!1&&(_=!1),h=N.sitePathname}catch(D){throw new $j("Failed to parse dev-portal.json file.",{cause:D,filename:s})}return{enabled:_,type:"legacy",basePath:h,filepath:s}}let b=["zudoku.config.js","zudoku.config.jsx","zudoku.config.ts","zudoku.config.tsx","zudoku.config.mjs"];for(;b.length;){let D=b.pop();if(D){let N=nN.join("docs",D),M=nN.join(a,
|
|
612
|
+
`?(N=0,M++):N++;this.column=N,this.line=M;return}}let{length:_}=s,{lineEnd:h}=this;_>0&&(this.lineEndSize>0&&(h.length===1?s[_-1]===h:s.endsWith(h))?(this.line+=this.lineEndSize,this.column=0):this.column+=_)}toString(){return this.output}};function rgt(a,s){let l=new TFe(s);return l.generator[a.type](a,l),l.output}t(rgt,"generate");async function xFe({oasFiles:a,sourceDirectory:s,logger:l}){let _=await l0r({oasFiles:a,sourceDirectory:s,logger:l});return rgt(_)}t(xFe,"generateRawRouteSource");async function l0r({oasFiles:a,sourceDirectory:s,logger:l}){let _=new B3(s,l),h=[];for(let D of a){let N=c0r.basename(D,".oas.json"),M=await _.resolve(D),z=[],re=new Map,ie=await o0r.readFile(D,"utf-8"),Q=JSON.parse(ie);for(let Re in Q.paths){let Ie=Q.paths[Re];for(let we in Ie){if(we.startsWith("x-"))continue;let wt={...Ie[we],...Ie[we].description&&{description:Ie[we].description.length>350?Ie[we].description.substring(0,350).trim()+"...":Ie[we].description}},xt=EG(N,Re,we),Tr=Vfe(D,N,wt,M,z,re);h.unshift(igt(xt,Tr))}}h.unshift(...u0r(N,M,z,re).reverse())}return{type:"Program",body:h,sourceType:"module"}}t(l0r,"generateAst");function Vfe(a,s,l,_,h,b){let D=[];for(let N in l){let M=l[N];if(N==="$ref")return sG(a,s,N3(a,M),_,h,b),{type:"Identifier",name:sgt(s,b.get(N3(a,M)))};let z;switch(typeof M){case"string":case"number":case"boolean":z={type:"Literal",value:M};break;default:Array.isArray(M)?z=ngt(M,a,s,_,h,b):typeof M=="object"&&M!==null&&(z=Vfe(a,s,M,_,h,b));break}if(z){let re=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(N),ie=re?{type:"Identifier",name:N}:{type:"Literal",value:N};D.push({type:"Property",key:ie,value:z,kind:"init",method:!1,shorthand:!1,computed:!re})}}return{type:"ObjectExpression",properties:D}}t(Vfe,"processNode");function ngt(a,s,l,_,h,b){return{type:"ArrayExpression",elements:a.map(D=>{if(Array.isArray(D))return ngt(D,s,l,_,h,b);if(typeof D=="object"&&D!==null){let N=Vfe(s,l,D,_,h,b);return N.type==="Identifier"?N:{type:"ObjectExpression",properties:N.properties||[]}}else return{type:"Literal",value:D}})}}t(ngt,"processArray");function igt(a,s){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s}],kind:"var"},specifiers:[],source:null}}t(igt,"createExportedConstAssignment");function u0r(a,s,l,_){let h=[];for(let b=0;b<l.length;b++){let D=sgt(a,b),N=s.get(l[b]),M=Vfe(Ule(l[b]),a,N,s,l,_);h.push(igt(D,M))}return h}t(u0r,"generateRefs");function sgt(a,s){return`${DA(a)}__ref__${s}`}t(sgt,"getRefIdentifierName");import agt from"node:path";var ogt=t(a=>{let s=null;if(a.value.type==="Object"&&a.value.members.length>0)for(let l of a.value.members){let _=ogt(l);if(_!==null&&(s=_),l.name.value==="enum"&&l.value.type==="Array"&&l.value.elements.length===0){let h=l.value,b=h.loc.start.line,D=h.loc.start.column,N=h.loc.end.column;s={line:b,column:D,length:N-D,lineText:""}}}return s},"findEmptyEnums"),f0r=t(a=>{if(a.startsWith("schema with key or id")&&a.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(a.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(a==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(a==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(a.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(a.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(a.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(a.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(a.includes("Unexpected")&&a.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),CFe=t(async(a,s,l)=>{if(!a)return null;let _={file:agt.join(A4e,a),suggestion:f0r(l)},h=agt.join(s,A4e),b=ou.safePath(s).resolve(h,a),D=await jle(b);if(l.includes("enum must have non-empty array")){if(D){let N=await iG(D);if(N&&N.body.members!==null)for(let M of N.body.members){let z=ogt(M);z&&z!==null&&(_=Object.assign(_??{},z))}if(_){let M=_.line?_.line:0;_.lineText=nG(D,M)}}}else if(l.includes("Unexpected")&&l.includes("in JSON at position")&&D){let N=await iG(D);N&&"lineText"in N&&(_=Object.assign(_??{},N))}return _},"getLocation");import*as K1t from"esbuild";import W7e,{dirname as W1t}from"node:path";import{fileURLToPath as H1t}from"node:url";var EFe=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT):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"}},_0r=new EFe,ih=_0r;var DFe="no-remote-module";function cgt({logger:a}){return{name:DFe,async setup(s){s.onResolve({filter:/^https?:\/\//},l=>(a.error(l,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${l.path}`,detail:"InvalidRemoteModule",pluginName:DFe,location:{line:0,column:0,file:""}}],pluginName:DFe}))}}}t(cgt,"blockRemoteModulePlugin");import ugt from"node:path";import{performance as uE}from"node:perf_hooks";var kK=[];async function p0r(a,s){let l=uE.now();try{return await s()}finally{let _=uE.now()-l;kK.push({name:a,duration:_})}}t(p0r,"timeFn");var d0r={mark:t(a=>{uE.mark(a)},"mark"),measure:t((a,s,l)=>{try{uE.measure(a,s,l)}finally{uE.clearMarks(s),uE.clearMarks(l),uE.clearMeasures(a)}},"measure"),timeFn:p0r,report:t(()=>{if(kK.length>0){let a=kK.reduce((s,{name:l,duration:_})=>(s[l]=`${_.toFixed(0)}ms`,s),{});console.table(a),kK.length=0}},"report"),getDuration:t(a=>{let s=uE.getEntriesByName(a);if(s.length===0)return 0;let l=s[0].duration;return uE.clearMeasures(a),l},"getDuration"),clear:t(()=>{kK.length=0,uE.clearMarks(),uE.clearMeasures()},"clear")},Bu=d0r;import{writeFile as m0r}from"node:fs/promises";async function Sk(a,s){await ou.mkdirForFilePathIfNotExits(a);let l=await import("prettier"),_=s;try{_=await l.format(s,{parser:"babel"})}catch{}await m0r(a,_,"utf-8")}t(Sk,"writeDebugSourceFile");import{readFile as h0r}from"node:fs/promises";import nN from"node:path";var $j=class extends Error{static{t(this,"DevPortalConfigError")}filename;constructor(s,l){super(s,l),this.name="DevPortalConfigError",this.filename=l?.filename}};async function lgt(a){let s=nN.join(V1,qat),l=nN.join(a,s),_=!0,h;if(await ou.fileExists(l)){try{let D=await h0r(l,"utf-8"),N=JSON.parse(D);N.enabled===!1&&(_=!1),h=N.sitePathname}catch(D){throw new $j("Failed to parse dev-portal.json file.",{cause:D,filename:s})}return{enabled:_,type:"legacy",basePath:h,filepath:s}}let b=["zudoku.config.js","zudoku.config.jsx","zudoku.config.ts","zudoku.config.tsx","zudoku.config.mjs"];for(;b.length;){let D=b.pop();if(D){let N=nN.join("docs",D),M=nN.join(a,N);try{if(await ou.fileExists(M))return{enabled:!0,type:"zudoku",basePath:void 0,filepath:N}}catch(z){throw new $j("Failed to read dev portal configuration file.",{cause:z,filename:N})}}}return{enabled:!1,type:void 0,basePath:void 0,filepath:void 0}}t(lgt,"getDevPortalConfig");function zj(a,s){let l=nN.resolve(a,FM);return Object.keys(s?.outputs??{}).map(b=>{let D=nN.normalize(b);return`./${nN.relative(l,D).split(nN.sep).join("/")}`})}t(zj,"getBuildModules");var fgt="/docs",g0r="/__zuplo/dev-portal";function y0r(a){let s=a.trim().toLowerCase();return s.endsWith("/")&&(s=s.slice(0,-1)),s}t(y0r,"normalizePathname");function v0r(a){let s={basePath:a?.basePath===g0r?fgt:a?.basePath?y0r(a.basePath):fgt,enabled:a?a.enabled??!0:!1,type:a?.type??void 0,urls:a?.urls?.map(_=>new URL(_).origin)??void 0};return`const devPortal = ${JSON.stringify(s)};
|
|
613
613
|
export default devPortal;`}t(v0r,"generateSource");var wK="dev-portal-config",Wfe="dev-portal";function _gt(a){return{name:wK,setup(s){s.onResolve({filter:/zuplo:dev-portal$/},l=>({namespace:Wfe,path:l.path,pluginName:wK})),s.onLoad({filter:/.*/,namespace:Wfe},async()=>Bu.timeFn("Generating dev-portal.json data",async()=>{let l=[],_,h;try{let D=await lgt(a.sourceDirectory);h=D.filepath,_={...D,urls:a.urls?.devPortal?.urls}}catch(D){let N="Failed to load dev portal config",M="config/dev-portal.json";D instanceof $j&&(N=D.message,M=D.filename??M),l.push({id:"dev-portal-build-error",text:N,location:{file:M,namespace:Wfe,line:1,column:0,length:0,lineText:"",suggestion:""},detail:"DevPortalValidationError",pluginName:wK,notes:[{text:D.message,location:null}]})}let b;try{if(b=v0r(_),ih.DEBUG_BUILD_MODE&&b){let D=ugt.join(a.sourceDirectory,zg,"dev-portal.js");await Sk(D,b)}}catch(D){l.push({id:"dev-portal-build-error",text:D.message,location:{file:"dev-portal.json",namespace:Wfe,line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:wK,notes:[{text:D.message,location:null}]})}return{contents:b,errors:l,pluginName:wK,loader:"js",resolveDir:h?ugt.dirname(h):void 0}}))}}}t(_gt,"devPortalConfigPlugin");import pgt from"node:path";var dgt="legacy-environment",mgt="legacy-environment",b0r=`import { environment } from "@zuplo/runtime";
|
|
614
614
|
export default environment;`;function hgt(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:mgt,pluginName:dgt,path:pgt.join(a.sourceDirectory,zg,"environment.js")})),s.onLoad({filter:/.*/,namespace:mgt},async l=>({contents:b0r,loader:"ts",resolveDir:pgt.dirname(l.path),pluginName:dgt}))}}}t(hgt,"environmentPlugin");import bTr from"node:fs/promises";import KT from"node:path";var k1t=ap(m7e(),1),w1t=ap(Kyt(),1),P1t=ap(U7e(),1),A1t=ap($7e(),1);var wk="schemas",w_e="json-schema";function N1t(a){return{name:wk,async setup(s){let l=new P1t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0}),_=KT.join(a.sourceDirectory,LH),h=[],b=[],D;await Bu.timeFn("Initializing schema validation",async()=>{if((0,w1t.default)(l,{mode:"fast"}),l.opts.code.formats=k1t._`require("ajv-formats/dist/formats").fastFormats`,await ou.dirExists(_)&&(l.addKeyword("faker"),D=(await ou.listFolderContents(_,LH)).sort(),await Promise.all(D.map(async N=>{try{let M=ou.safePath(a.sourceDirectory).resolve(_,N);if(!M.startsWith(_))throw new Error("All schemas must be in the schemas directory");let z=await bTr.readFile(M,"utf-8");if(z===""||z===void 0)throw new Error(`Schema 'schemas/${N}' is empty and will be ignored.`);let re=JSON.parse(z);if(re.$schema&&re.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${N}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(l.addSchema(re,N),l.errors?.length){let ie=l.errors[0];h.push({id:"json-schema-validation-error",pluginName:wk,text:`Error: ${ie.message}`,location:{file:KT.join(LH,N)},detail:{params:ie.params,propertyName:ie.propertyName,schemaPath:ie.schemaPath,data:ie.data}})}}catch(M){if(M.message.endsWith("is empty and will be ignored.")){b.push({id:"empty-json-schema-file",pluginName:wk,text:`Schema 'schemas/${N}' is empty and will be ignored.`,location:{file:`schemas/${N}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${N}' is empty and will be ignored.`,location:{file:`schemas/${N}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let z=await CFe(N,a.sourceDirectory,M.message);h.push({id:"json-schema-add-error",pluginName:wk,text:`Error: ${M.message}`,location:z,detail:"InvalidAddSchemaError",notes:[{text:M.message}]})}})),await Promise.all(D.map(async N=>{try{let M=l.getSchema(N);M&&l.compile(M.schema).errors?.forEach(re=>{h.push({text:`Failed to compile ${N}: ${re.message}`})})}catch(M){let z=await CFe(N,a.sourceDirectory,M.message);h.push({id:"json-schema-compile-error",pluginName:wk,text:`The schema file '${N}' is not valid. Error: ${M.message}`,location:z,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),ih.DEBUG_BUILD_MODE)){let N=KT.resolve(a.outputDirectory,LH);await ou.mkdirIfNotExists(N)}}),s.onStart(async()=>{if(D)return{errors:h,warnings:b}}),s.onResolve({filter:/schemas\/.*\.json$/},async N=>Bu.timeFn("Generating JSON schemas...",async()=>{let M=KT.isAbsolute(N.path)?N.path:KT.join(N.resolveDir,N.path);if(N.importer&&N.namespace!=="open-api-routes-json")return{path:M};if(!await ou.fileExists(M)){let z="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${N.path}' from ${z}`,location:{file:KT.join(N.resolveDir,z),namespace:w_e,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${z}`,suggestion:""},detail:"RouteReferenceError",pluginName:wk,notes:[{text:`Unable to resolve reference to '${N.path}' from ${z}`,location:null}]}],namespace:w_e,path:M,pluginName:wk}}return{path:M,namespace:w_e,pluginName:wk}})),s.onLoad({filter:/.*/,namespace:w_e},async N=>Bu.timeFn(`Generating json schema data: ${KT.basename(N.path)}`,async()=>{let M=[],z;try{let re=KT.relative(_,N.path),ie=l.getSchema(re);if(!ie)throw new Error(`Could not load schema at ${N.path}`);z=ie.source?.validateCode;let Q=l.compile(ie.schema);z=(0,A1t.default)(l,Q)}catch(re){M.push({pluginName:wk,text:`Cannot parse project's schemas/${KT.basename(N.path)} file. Error: ${re.message}`,location:null,notes:[{text:re.message,location:null}],detail:re})}if(ih.DEBUG_BUILD_MODE&&z){let re=KT.relative(_,N.path),ie=KT.join(a.sourceDirectory,zg,`${re}.js`);await Sk(ie,z)}return{contents:z,errors:M,pluginName:wk,resolveDir:KT.dirname(N.path),watchFiles:[N.path]}}))}}}t(N1t,"jsonSchemaPlugin");import{relative as STr}from"node:path";var I1t=["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"],TTr="nodejs-compat-plugin";function F1t({sourceDirectory:a}){return{name:TTr,setup(s){let l=new Set;s.onStart(()=>{l.clear()}),s.onResolve({filter:/node:.*/},async({path:_,kind:h,resolveDir:b,...D})=>{let N=`${_}:${h}:${b}:${D.importer}`;if(l.has(N))return;l.add(N);let M=await s.resolve(_,{kind:h,resolveDir:b,importer:D.importer});return M.errors.length>0?I1t.includes(_)||_.includes("/")&&I1t.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:M.errors.map(re=>({...re,location:{file:STr(a,D.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${_}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:M})}}}t(F1t,"nodejsCompatPlugin");import O1t from"node:fs/promises";import gE from"node:path";var _N="open-api-routes-plugin",oY="open-api-routes-json";function L1t(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/zuplo:routes$/},l=>({watchFiles:[...z7e(gE.join(a.sourceDirectory,V1),[".oas.json"],!0),gE.join(a.sourceDirectory,V1,ule)],namespace:oY,path:gE.isAbsolute(l.path)?l.path:gE.join(l.resolveDir,l.path),pluginName:_N})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:oY},async l=>Bu.timeFn("Generating route data...",async()=>{async function _(){let b=gE.resolve(a.sourceDirectory,"config"),D=await ZF(b),N=`$import(.${l.path.replace(/^../,"")})`;return{location:await Tct(D,N,"Update your route configuration to use code from the 'modules' folder"),originalImportValue:N}}t(_,"getLocation");let h=gE.join(l.resolveDir,`${l.path}.ts`);if(l.path.endsWith(".ts")){let{location:b,originalImportValue:D}=await _();return{errors:[{id:"route-build-error",text:`Invalid handler reference '${D}' in ${b?.file??"OpenAPI file"}. Imports must NOT include the '.ts' file extension.`,location:b,detail:"RouteReferenceError",pluginName:_N}],namespace:oY,path:l.path,pluginName:_N}}else if(!await ou.fileExists(h)){let{location:b,originalImportValue:D}=await _();return{errors:[{id:"route-build-error",text:`Invalid handler reference in route. Unable to resolve reference to '${D}' in ${b?.file??"OpenAPI file"}`,location:b,detail:"RouteReferenceError",pluginName:_N}],namespace:oY,path:l.path,pluginName:_N}}})),s.onLoad({filter:/.*/,namespace:oY},async l=>Bu.timeFn("Generating route.json data",async()=>{let _=gE.resolve(a.sourceDirectory,"config"),h=await ZF(_),b=await Promise.all(h.map(async z=>({content:await O1t.readFile(z,"utf-8"),fileName:z}))),D=gE.resolve(_,"policies.json");if(!await ou.fileExists(D))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:_N,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:_N};let N={content:await O1t.readFile(D,"utf-8"),fileName:D},M;try{M=await bFe({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:N,compatibilityDate:a.config.compatibilityDate,checkForDuplicateRoutes:a.config.flags?.checkForDuplicateRoutes??!0})}catch(z){throw new Error("Error compiling routes: "+z.message)}if(ih.DEBUG_BUILD_MODE&&M.content){let z=gE.join(a.sourceDirectory,zg),re=gE.resolve(z,"routes.js");await Sk(re,M.content)}return{contents:M.content,errors:M.errors,pluginName:_N,resolveDir:gE.dirname(l.path),watchFiles:[l.path]}}))}}}t(L1t,"openApiRoutesPlugin");import P_e from"node:path";var cY="raw-route-plugin",R1t="raw-route";function M1t(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/zuplo:raw-routes$/},l=>({namespace:R1t,path:l.path,pluginName:cY})),s.onLoad({filter:/.*/,namespace:R1t},async l=>Bu.timeFn("Building route data",async()=>{let _=P_e.resolve(a.sourceDirectory,V1);if(!await ou.dirExists(_))return{loader:"js",resolveDir:P_e.dirname(l.path),pluginName:cY};let h=await ZF(_);try{let b=await xFe({oasFiles:h,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ih.DEBUG_BUILD_MODE&&b){let D=P_e.join(a.sourceDirectory,zg,"raw-routes.js");await Sk(D,b)}return{contents:b,loader:"js",resolveDir:P_e.dirname(l.path),pluginName:cY}}catch(b){if(b instanceof q1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:b.issue.text,location:b.issue.location,detail:b.issue.detail,pluginName:cY}],pluginName:cY};throw b}}))}}}t(M1t,"rawRoutePlugin");import xTr from"node:fs/promises";import j1t from"node:path";var A_e="runtime-config",B1t="runtime-config-plugin";function U1t(a){return{name:A_e,setup(s){s.onResolve({filter:/zuplo:runtime-extension$/},l=>({namespace:B1t,path:l.path,pluginName:A_e})),s.onLoad({filter:/.*/,namespace:B1t},async()=>Bu.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=j1t.resolve(a.sourceDirectory,zat,"zuplo.runtime.ts"),h=[];return await ou.fileExists(_)?(l=await xTr.readFile(_,"utf-8"),{contents:l,loader:"ts",resolveDir:j1t.dirname(_),errors:h,pluginName:A_e,watchFiles:[_]}):{contents:l,loader:"ts",errors:h,pluginName:A_e}}))}}}t(U1t,"runtimeConfigPlugin");import V7e from"node:fs/promises";import jO from"node:path";var z1t=ap(U7e(),1),J1t=ap($7e(),1);var J7e="schema-validation-plugin",$1t="schema-validation",CTr="module.exports = {}";function q1t(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/zuplo:schema-validations$/},l=>({namespace:$1t,path:l.path,pluginName:J7e})),s.onLoad({filter:/.*/,namespace:$1t},async()=>Bu.timeFn("Validating schemas",async()=>{let l=jO.resolve(a.sourceDirectory,V1,"policies.json");if(!await ou.fileExists(l))return{contents:CTr,loader:"js",resolveDir:jO.dirname(l),pluginName:J7e};let _=await DTr(a.sourceDirectory),h=jO.resolve(a.sourceDirectory,V1),b=await ZF(h),D=await ATr(b,_),N=await ETr({oasFiles:b,routesWithSchemaValidation:D,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ih.DEBUG_BUILD_MODE&&N){let M=jO.join(a.sourceDirectory,zg,"schema-validation.js");await Sk(M,N)}return{contents:N,loader:"js",resolveDir:jO.dirname(l),pluginName:J7e}}))}}}t(q1t,"schemaValidationPlugin");async function ETr({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let h="",b=new B3(l,_);if(s.length===0)return h;let D=new z1t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let N of a){let M=await V7e.readFile(N,"utf-8"),z=jO.basename(N,".oas.json"),re=s.filter(we=>we.fileName===z),ie=await b.resolve(N),Q=JSON.parse(M),Re=[],Ie=new Map;re.forEach(we=>{let wt=Q.paths[we.path][we.method];if(wt.requestBody){let xt;if(wt.requestBody.$ref){let Tr=wt.requestBody.$ref;xt=ie.get(Tr)?.content}else wt.requestBody.content&&(xt=wt.requestBody.content);if(xt)for(let Tr in xt){let fn=xt[Tr].schema,tn=nNe(we.path,we.method,Tr);fn.$id=tn,D.addSchema(fn),q7e(fn,N,z,D,ie,Re,Ie)}}if(wt.parameters)for(let xt of wt.parameters){let Tr=xt.$ref?ie.get(xt.$ref):xt,fn=Tr.schema.$ref?ie.get(Tr.schema.$ref):Tr.schema,tn=rNe(we.path,we.method,Tr.in,Tr.name);fn.$id=tn,D.addSchema(fn),q7e(Tr,N,z,D,ie,Re,Ie)}});for(let we of Re){let wt=ie.get(we),xt=DG(z,we);D.addSchema(wt,xt)}}return h=(0,J1t.default)(D),h}t(ETr,"schemaValidationSource");function q7e(a,s,l,_,h,b,D){for(let N in a){let M=a[N];if(N==="$ref"){let z=DG(l,N3(s,M));a[N]=z,sG(s,l,N3(s,M),h,b,D,(re,ie,Q)=>DG(re,N3(Q,ie)))}else typeof M=="object"&&q7e(M,s,l,_,h,b,D)}}t(q7e,"addRefsToSchema");async function DTr(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await V7e.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return kTr(_,s)}t(DTr,"getPolicyNamesUsingSchemaValidationPolicies");function kTr(a,s){let l=new Set;a.policies?.forEach(h=>{h.handler?.export&&s.has(h.handler.export)&&h.handler.module==="$import(@zuplo/runtime)"&&l.add(h.name)});let _=wTr(a,l);return new Set([...l,..._])}t(kTr,"getPolicyNamesReferencingPolicyHandlers");function wTr(a,s){let l=new Set;return a.policies?.forEach(_=>{_.handler?.export==="CompositeInboundPolicy"&&_.handler?.options?.policies?.forEach(h=>{s.has(h)&&l.add(_.name)})}),l}t(wTr,"getCompositePoliciesContainingPolicy");function PTr(a,s){if(!a["x-zuplo-route"]||!a["x-zuplo-route"].policies)return!1;let l=a["x-zuplo-route"].policies.inbound;if(l){for(let h of l)if(s.has(h))return!0}let _=a["x-zuplo-route"].policies.outbound;if(_){for(let h of _)if(s.has(h))return!0}return!1}t(PTr,"isPolicyPresentInOperation");async function ATr(a,s){let l=[];for(let _ of a){let h=await V7e.readFile(_,"utf-8"),D=JSON.parse(h).paths;for(let N in D){let M=D[N];for(let z in M){let re=M[z];PTr(re,s)&&l.push({fileName:jO.basename(_,".oas.json"),path:N,method:z})}}}return l}t(ATr,"getRoutesContainingPolicies");import{mkdirSync as NTr,writeFileSync as ITr}from"node:fs";import FTr from"node:path";function V1t(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=zj(a.sourceDirectory,l.metafile);NTr(a.outputDirectory,{recursive:!0}),ITr(FTr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(V1t,"writeModulesPlugin");var OTr=gue("zuplo:core:build"),LTr=["workerd","worker","browser"],G1t=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],W7e.resolve(W1t(H1t(import.meta.url)),"..","..","..","node_modules"),W7e.resolve(W1t(H1t(import.meta.url)),"..","..","..","..","..","node_modules")];async function lY({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,logger:h,minify:b=!0,command:D,config:N,urls:M}){let z=W7e.join(a,_le);OTr(`Building with node paths: ${G1t.join(", ")}`);let re=b&&D!=="dev"&&!process.env.DEBUG_BUILD_DISABLE_MINIFY?{minify:!0,chunkNames:"[hash]"}:{minify:!1,keepNames:!0,chunkNames:"[name]-[hash]"},ie=Object.freeze({sourceDirectory:l,outputDirectory:s,cacheDirectory:_,logger:h,debugMode:ih.DEBUG_BUILD_MODE,config:N,urls:M});return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:G1t,entryPoints:[z],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...re,external:[],logLevel:"silent",conditions:LTr,plugins:[hgt(ie),cgt(ie),L1t(ie),M1t(ie),q1t(ie),U1t(ie),_gt(ie),N1t(ie),F1t(ie),V1t(ie)]}}t(lY,"getBaseESBuildConfig");var BO="run-esbuild",Y1t=t(async function({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,buildId:h,logger:b,config:D,command:N,minify:M,urls:z},{data:re}){b.debug("Running esbuild");let ie=await lY({command:N,minify:M,systemDirectory:a,outputDirectory:s,cacheDirectory:_,sourceDirectory:l,logger:b,config:D,urls:z}),Q;try{if(!await qM(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");Q=await K1t.build(ie),re.set("metafile",Q.metafile)}catch(we){if(b.error(we),we.errors||we.warnings)Q=we;else if(we.message.includes("Failed to build project because no open-api file was found on the 'config' folder"))Q={warnings:[],errors:[{id:"missing-open-api-file",text:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:BO,location:null,notes:[],detail:"Failed to build project because no open-api file was found on the 'config' folder"}],outputFiles:void 0,metafile:void 0,mangleCache:void 0};else throw we}Q.errors.length>0&&Q.errors.length>1&&(Q.errors.length=1);let{errors:Re,warnings:Ie}=H7e({buildId:h,result:Q});return{errors:Re,warnings:Ie}},"runEsbuild");function H7e({buildId:a,result:s}){return{status:s.errors.length>0?"Failed":s.warnings.length>0?"Warnings":"Good",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:a,warnings:s.warnings.map(_=>_.text==="Using direct eval with a bundler is not recommended and may cause problems"?{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:"We do not support the use of 'eval' or 'new Function(...)'",severity:sle,pluginName:_.pluginName||BO}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:sle,pluginName:_.pluginName||BO}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:q6e,pluginName:_.pluginName||BO})),metafile:s.metafile}}t(H7e,"esbuildResultToBuildResult");var RTr=t((a,s)=>{let l=s;if(s.includes(a)){let _=new RegExp(`.*(${a})`,"g");l=s.replace(_,"")}return l.match(/^(\/)?(\.\.(\/)?)+/)&&(l=l.replace(/^(\/)?(\.\.(\/)?)+/,"/")),l},"removePrefixFromString"),MTr=t((a,s)=>{let l=s;if(l.includes(a)){let _=new RegExp(`[a-zA-Z0-9-_.\\/]+(${a})`,"g");l=l.replace(_,"")}return l},"cleanFilePathsInMessage"),X1t=t((a,s,l)=>{if(!a||a.length<=0)return a;let _=a.filter(h=>h.message!=='Could not resolve "@zuplo/runtime"');return _&&_.length>0&&_.forEach(h=>{try{h.location&&h.location.file&&(h.location.file=RTr(s,h.location.file)),h.location&&h.location.lineText&&h.location.lineText.includes("@zuplo/core/index.minified.js")&&(h.location.lineText=h.location.lineText.substring(0,200)+"...<Truncated>"),h.message=MTr(s,h.message),h.notes&&h.notes.length>0&&delete h.notes,h.text&&delete h.text,h.pluginName===""&&(h.pluginName=l)}catch{}}),_},"cleanDataOnBuildIssue");function Q1t(a,s){let l=G7e.basename(s);a.errors&&(a.errors=X1t(a.errors,l,BO)),a.warnings&&(a.warnings=X1t(a.warnings,l,BO))}t(Q1t,"formatBuildResult");var jTr=t(a=>G7e.basename(a).startsWith("."),"isHiddenOnUnix"),BTr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function z7e(a,s=[],l=!1){let _=[],h;if(!N_e.existsSync(a)){let b;if(tG.hasMagic(a))b=a;else{let D=s.map(N=>N.startsWith(".")?N:`.${N}`).join("|");b=`${a}+(${D})`}if(_.push(...tG.sync(b,{nodir:!0})),!_.length)throw Error(`Cannot find any files matching pattern "${a}"`);return _}try{if(h=N_e.statSync(a),h.isFile())return[a]}catch{return[]}return N_e.readdirSync(a).forEach(b=>{let D=G7e.join(a,b),N;try{if(N=N_e.statSync(D),N.isDirectory()){l&&_.push(...z7e(D,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!N.isFile()||!BTr(D,s)||jTr(D)||_.push(D)}),_}t(z7e,"lookupFiles");var UO=new cle,pN=` ${UO.gray("|")} `;function K7e({output:a,buildId:s,runtimeVersion:l,compatibilityDate:_}){let h=["Building Zuplo API...",`${pN}Build ID: ${s}`,`${pN}Runtime Version: ${l}`];_&&h.push(`${pN}Compatibility Date: ${_}`),a.info(h.join(`
|
|
615
615
|
`))}t(K7e,"outputApiBuildStart");async function I_e(a,s,l){Q1t(l,a),await Promise.all(l.warnings.map(async h=>Z1t(a,s,h))),await Promise.all(l.errors.map(async h=>Z1t(a,s,h)));let _=process.env.CODEBUILD_BUILD_ID?new Date(new Date().getTime()+1):new Date;l.status==="Good"?s.info(UO.green("Build succeeded"),{timestamp:_}):l.status==="Warnings"?s.warn(UO.yellow("Build succeeded with warnings"),{timestamp:_}):l.status==="Failed"&&s.error(UO.red("Build failed."),{timestamp:_})}t(I_e,"outputBuildResult");async function Z1t(a,s,l){let _=[],h=l.severity??"error",b=h==="error"?UO.red:UO.yellow,D=b(`${h.toUpperCase()}: ${l.message}${l.detail?`
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
declare module '@zuplo/core' {
|
|
1
|
+
declare module "@zuplo/core" {
|
|
3
2
|
const _default: any;
|
|
4
3
|
export = _default;
|
|
5
|
-
|
|
4
|
+
}
|
|
6
5
|
|
|
7
|
-
declare module
|
|
8
|
-
const _default: any;
|
|
9
|
-
export = _default;
|
|
6
|
+
declare module "@zuplo/core/create" {
|
|
7
|
+
const _default: any;
|
|
8
|
+
export = _default;
|
|
10
9
|
}
|
package/index.minified.js
CHANGED
|
@@ -609,7 +609,7 @@ globstar while`,s,Q,l,Re,Ie),this.matchOne(s.slice(Q),l.slice(Re),_))return this
|
|
|
609
609
|
`,D):(a.write("/*"),k0r(a,D.value,l,_),a.write("*/"+_))}}t(ev,"formatComments");function w0r(a){let s=a;for(;s!=null;){let{type:l}=s;if(l[0]==="C"&&l[1]==="a")return!0;if(l[0]==="M"&&l[1]==="e"&&l[2]==="m")s=s.object;else return!1}}t(w0r,"hasCallExpression");function DFe(a,s){let{generator:l}=a,{declarations:_}=s;a.write(s.kind+" ");let{length:h}=_;if(h>0){l.VariableDeclarator(_[0],a);for(let b=1;b<h;b++)a.write(", "),l.VariableDeclarator(_[b],a)}}t(DFe,"formatVariableDeclaration");var rgt,ngt,igt,sgt,agt,ogt,P0r={Program(a,s){let l=s.indent.repeat(s.indentLevel),{lineEnd:_,writeComments:h}=s;h&&a.comments!=null&&ev(s,a.comments,l,_);let b=a.body,{length:D}=b;for(let N=0;N<D;N++){let M=b[N];h&&M.comments!=null&&ev(s,M.comments,l,_),s.write(l),this[M.type](M,s),s.write(_)}h&&a.trailingComments!=null&&ev(s,a.trailingComments,l,_)},BlockStatement:ogt=t(function(a,s){let l=s.indent.repeat(s.indentLevel++),{lineEnd:_,writeComments:h}=s,b=l+s.indent;s.write("{");let D=a.body;if(D!=null&&D.length>0){s.write(_),h&&a.comments!=null&&ev(s,a.comments,b,_);let{length:N}=D;for(let M=0;M<N;M++){let z=D[M];h&&z.comments!=null&&ev(s,z.comments,b,_),s.write(b),this[z.type](z,s),s.write(_)}s.write(l)}else h&&a.comments!=null&&(s.write(_),ev(s,a.comments,b,_),s.write(l));h&&a.trailingComments!=null&&ev(s,a.trailingComments,b,_),s.write("}"),s.indentLevel--},"BlockStatement"),ClassBody:ogt,StaticBlock(a,s){s.write("static "),this.BlockStatement(a,s)},EmptyStatement(a,s){s.write(";")},ExpressionStatement(a,s){let l=s.expressionsPrecedence[a.expression.type];l===uE||l===3&&a.expression.left.type[0]==="O"?(s.write("("),this[a.expression.type](a.expression,s),s.write(")")):this[a.expression.type](a.expression,s),s.write(";")},IfStatement(a,s){s.write("if ("),this[a.test.type](a.test,s),s.write(") "),this[a.consequent.type](a.consequent,s),a.alternate!=null&&(s.write(" else "),this[a.alternate.type](a.alternate,s))},LabeledStatement(a,s){this[a.label.type](a.label,s),s.write(": "),this[a.body.type](a.body,s)},BreakStatement(a,s){s.write("break"),a.label!=null&&(s.write(" "),this[a.label.type](a.label,s)),s.write(";")},ContinueStatement(a,s){s.write("continue"),a.label!=null&&(s.write(" "),this[a.label.type](a.label,s)),s.write(";")},WithStatement(a,s){s.write("with ("),this[a.object.type](a.object,s),s.write(") "),this[a.body.type](a.body,s)},SwitchStatement(a,s){let l=s.indent.repeat(s.indentLevel++),{lineEnd:_,writeComments:h}=s;s.indentLevel++;let b=l+s.indent,D=b+s.indent;s.write("switch ("),this[a.discriminant.type](a.discriminant,s),s.write(") {"+_);let{cases:N}=a,{length:M}=N;for(let z=0;z<M;z++){let re=N[z];h&&re.comments!=null&&ev(s,re.comments,b,_),re.test?(s.write(b+"case "),this[re.test.type](re.test,s),s.write(":"+_)):s.write(b+"default:"+_);let{consequent:ie}=re,{length:Q}=ie;for(let Re=0;Re<Q;Re++){let Ie=ie[Re];h&&Ie.comments!=null&&ev(s,Ie.comments,D,_),s.write(D),this[Ie.type](Ie,s),s.write(_)}}s.indentLevel-=2,s.write(l+"}")},ReturnStatement(a,s){s.write("return"),a.argument&&(s.write(" "),this[a.argument.type](a.argument,s)),s.write(";")},ThrowStatement(a,s){s.write("throw "),this[a.argument.type](a.argument,s),s.write(";")},TryStatement(a,s){if(s.write("try "),this[a.block.type](a.block,s),a.handler){let{handler:l}=a;l.param==null?s.write(" catch "):(s.write(" catch ("),this[l.param.type](l.param,s),s.write(") ")),this[l.body.type](l.body,s)}a.finalizer&&(s.write(" finally "),this[a.finalizer.type](a.finalizer,s))},WhileStatement(a,s){s.write("while ("),this[a.test.type](a.test,s),s.write(") "),this[a.body.type](a.body,s)},DoWhileStatement(a,s){s.write("do "),this[a.body.type](a.body,s),s.write(" while ("),this[a.test.type](a.test,s),s.write(");")},ForStatement(a,s){if(s.write("for ("),a.init!=null){let{init:l}=a;l.type[0]==="V"?DFe(s,l):this[l.type](l,s)}s.write("; "),a.test&&this[a.test.type](a.test,s),s.write("; "),a.update&&this[a.update.type](a.update,s),s.write(") "),this[a.body.type](a.body,s)},ForInStatement:rgt=t(function(a,s){s.write(`for ${a.await?"await ":""}(`);let{left:l}=a;l.type[0]==="V"?DFe(s,l):this[l.type](l,s),s.write(a.type[3]==="I"?" in ":" of "),this[a.right.type](a.right,s),s.write(") "),this[a.body.type](a.body,s)},"ForInStatement"),ForOfStatement:rgt,DebuggerStatement(a,s){s.write("debugger;",a)},FunctionDeclaration:ngt=t(function(a,s){s.write((a.async?"async ":"")+(a.generator?"function* ":"function ")+(a.id?a.id.name:""),a),Uj(s,a.params),s.write(" "),this[a.body.type](a.body,s)},"FunctionDeclaration"),FunctionExpression:ngt,VariableDeclaration(a,s){DFe(s,a),s.write(";")},VariableDeclarator(a,s){this[a.id.type](a.id,s),a.init!=null&&(s.write(" = "),this[a.init.type](a.init,s))},ClassDeclaration(a,s){if(s.write("class "+(a.id?`${a.id.name} `:""),a),a.superClass){s.write("extends ");let{superClass:l}=a,{type:_}=l,h=s.expressionsPrecedence[_];(_[0]!=="C"||_[1]!=="l"||_[5]!=="E")&&(h===uE||h<s.expressionsPrecedence.ClassExpression)?(s.write("("),this[a.superClass.type](l,s),s.write(")")):this[l.type](l,s),s.write(" ")}this.ClassBody(a.body,s)},ImportDeclaration(a,s){s.write("import ");let{specifiers:l,attributes:_}=a,{length:h}=l,b=0;if(h>0){for(;b<h;){b>0&&s.write(", ");let D=l[b],N=D.type[6];if(N==="D")s.write(D.local.name,D),b++;else if(N==="N")s.write("* as "+D.local.name,D),b++;else break}if(b<h){for(s.write("{");;){let D=l[b],{name:N}=D.imported;if(s.write(N,D),N!==D.local.name&&s.write(" as "+D.local.name),++b<h)s.write(", ");else break}s.write("}")}s.write(" from ")}if(this.Literal(a.source,s),_&&_.length>0){s.write(" with { ");for(let D=0;D<_.length;D++)this.ImportAttribute(_[D],s),D<_.length-1&&s.write(", ");s.write(" }")}s.write(";")},ImportAttribute(a,s){this.Identifier(a.key,s),s.write(": "),this.Literal(a.value,s)},ImportExpression(a,s){s.write("import("),this[a.source.type](a.source,s),s.write(")")},ExportDefaultDeclaration(a,s){s.write("export default "),this[a.declaration.type](a.declaration,s),s.expressionsPrecedence[a.declaration.type]!=null&&a.declaration.type[0]!=="F"&&s.write(";")},ExportNamedDeclaration(a,s){if(s.write("export "),a.declaration)this[a.declaration.type](a.declaration,s);else{s.write("{");let{specifiers:l}=a,{length:_}=l;if(_>0)for(let h=0;;){let b=l[h],{name:D}=b.local;if(s.write(D,b),D!==b.exported.name&&s.write(" as "+b.exported.name),++h<_)s.write(", ");else break}if(s.write("}"),a.source&&(s.write(" from "),this.Literal(a.source,s)),a.attributes&&a.attributes.length>0){s.write(" with { ");for(let h=0;h<a.attributes.length;h++)this.ImportAttribute(a.attributes[h],s),h<a.attributes.length-1&&s.write(", ");s.write(" }")}s.write(";")}},ExportAllDeclaration(a,s){if(a.exported!=null?s.write("export * as "+a.exported.name+" from "):s.write("export * from "),this.Literal(a.source,s),a.attributes&&a.attributes.length>0){s.write(" with { ");for(let l=0;l<a.attributes.length;l++)this.ImportAttribute(a.attributes[l],s),l<a.attributes.length-1&&s.write(", ");s.write(" }")}s.write(";")},MethodDefinition(a,s){a.static&&s.write("static ");let l=a.kind[0];(l==="g"||l==="s")&&s.write(a.kind+" "),a.value.async&&s.write("async "),a.value.generator&&s.write("*"),a.computed?(s.write("["),this[a.key.type](a.key,s),s.write("]")):this[a.key.type](a.key,s),Uj(s,a.value.params),s.write(" "),this[a.value.body.type](a.value.body,s)},ClassExpression(a,s){this.ClassDeclaration(a,s)},ArrowFunctionExpression(a,s){s.write(a.async?"async ":"",a);let{params:l}=a;l!=null&&(l.length===1&&l[0].type[0]==="I"?s.write(l[0].name,l[0]):Uj(s,a.params)),s.write(" => "),a.body.type[0]==="O"?(s.write("("),this.ObjectExpression(a.body,s),s.write(")")):this[a.body.type](a.body,s)},ThisExpression(a,s){s.write("this",a)},Super(a,s){s.write("super",a)},RestElement:igt=t(function(a,s){s.write("..."),this[a.argument.type](a.argument,s)},"RestElement"),SpreadElement:igt,YieldExpression(a,s){s.write(a.delegate?"yield*":"yield"),a.argument&&(s.write(" "),this[a.argument.type](a.argument,s))},AwaitExpression(a,s){s.write("await ",a),qfe(s,a.argument,a)},TemplateLiteral(a,s){let{quasis:l,expressions:_}=a;s.write("`");let{length:h}=_;for(let D=0;D<h;D++){let N=_[D],M=l[D];s.write(M.value.raw,M),s.write("${"),this[N.type](N,s),s.write("}")}let b=l[l.length-1];s.write(b.value.raw,b),s.write("`")},TemplateElement(a,s){s.write(a.value.raw,a)},TaggedTemplateExpression(a,s){qfe(s,a.tag,a),this[a.quasi.type](a.quasi,s)},ArrayExpression:agt=t(function(a,s){if(s.write("["),a.elements.length>0){let{elements:l}=a,{length:_}=l;for(let h=0;;){let b=l[h];if(b!=null&&this[b.type](b,s),++h<_)s.write(", ");else{b==null&&s.write(", ");break}}}s.write("]")},"ArrayExpression"),ArrayPattern:agt,ObjectExpression(a,s){let l=s.indent.repeat(s.indentLevel++),{lineEnd:_,writeComments:h}=s,b=l+s.indent;if(s.write("{"),a.properties.length>0){s.write(_),h&&a.comments!=null&&ev(s,a.comments,b,_);let D=","+_,{properties:N}=a,{length:M}=N;for(let z=0;;){let re=N[z];if(h&&re.comments!=null&&ev(s,re.comments,b,_),s.write(b),this[re.type](re,s),++z<M)s.write(D);else break}s.write(_),h&&a.trailingComments!=null&&ev(s,a.trailingComments,b,_),s.write(l+"}")}else h?a.comments!=null?(s.write(_),ev(s,a.comments,b,_),a.trailingComments!=null&&ev(s,a.trailingComments,b,_),s.write(l+"}")):a.trailingComments!=null?(s.write(_),ev(s,a.trailingComments,b,_),s.write(l+"}")):s.write("}"):s.write("}");s.indentLevel--},Property(a,s){a.method||a.kind[0]!=="i"?this.MethodDefinition(a,s):(a.shorthand||(a.computed?(s.write("["),this[a.key.type](a.key,s),s.write("]")):this[a.key.type](a.key,s),s.write(": ")),this[a.value.type](a.value,s))},PropertyDefinition(a,s){if(a.static&&s.write("static "),a.computed&&s.write("["),this[a.key.type](a.key,s),a.computed&&s.write("]"),a.value==null){a.key.type[0]!=="F"&&s.write(";");return}s.write(" = "),this[a.value.type](a.value,s),s.write(";")},ObjectPattern(a,s){if(s.write("{"),a.properties.length>0){let{properties:l}=a,{length:_}=l;for(let h=0;this[l[h].type](l[h],s),++h<_;)s.write(", ")}s.write("}")},SequenceExpression(a,s){Uj(s,a.expressions)},UnaryExpression(a,s){if(a.prefix){let{operator:l,argument:_,argument:{type:h}}=a;s.write(l);let b=cgt(s,_,a);!b&&(l.length>1||h[0]==="U"&&(h[1]==="n"||h[1]==="p")&&_.prefix&&_.operator[0]===l&&(l==="+"||l==="-"))&&s.write(" "),b?(s.write(l.length>1?" (":"("),this[h](_,s),s.write(")")):this[h](_,s)}else this[a.argument.type](a.argument,s),s.write(a.operator)},UpdateExpression(a,s){a.prefix?(s.write(a.operator),this[a.argument.type](a.argument,s)):(this[a.argument.type](a.argument,s),s.write(a.operator))},AssignmentExpression(a,s){this[a.left.type](a.left,s),s.write(" "+a.operator+" "),this[a.right.type](a.right,s)},AssignmentPattern(a,s){this[a.left.type](a.left,s),s.write(" = "),this[a.right.type](a.right,s)},BinaryExpression:sgt=t(function(a,s){let l=a.operator==="in";l&&s.write("("),qfe(s,a.left,a,!1),s.write(" "+a.operator+" "),qfe(s,a.right,a,!0),l&&s.write(")")},"BinaryExpression"),LogicalExpression:sgt,ConditionalExpression(a,s){let{test:l}=a,_=s.expressionsPrecedence[l.type];_===uE||_<=s.expressionsPrecedence.ConditionalExpression?(s.write("("),this[l.type](l,s),s.write(")")):this[l.type](l,s),s.write(" ? "),this[a.consequent.type](a.consequent,s),s.write(" : "),this[a.alternate.type](a.alternate,s)},NewExpression(a,s){s.write("new ");let l=s.expressionsPrecedence[a.callee.type];l===uE||l<s.expressionsPrecedence.CallExpression||w0r(a.callee)?(s.write("("),this[a.callee.type](a.callee,s),s.write(")")):this[a.callee.type](a.callee,s),Uj(s,a.arguments)},CallExpression(a,s){let l=s.expressionsPrecedence[a.callee.type];l===uE||l<s.expressionsPrecedence.CallExpression?(s.write("("),this[a.callee.type](a.callee,s),s.write(")")):this[a.callee.type](a.callee,s),a.optional&&s.write("?."),Uj(s,a.arguments)},ChainExpression(a,s){this[a.expression.type](a.expression,s)},MemberExpression(a,s){let l=s.expressionsPrecedence[a.object.type];l===uE||l<s.expressionsPrecedence.MemberExpression?(s.write("("),this[a.object.type](a.object,s),s.write(")")):this[a.object.type](a.object,s),a.computed?(a.optional&&s.write("?."),s.write("["),this[a.property.type](a.property,s),s.write("]")):(a.optional?s.write("?."):s.write("."),this[a.property.type](a.property,s))},MetaProperty(a,s){s.write(a.meta.name+"."+a.property.name,a)},Identifier(a,s){s.write(a.name,a)},PrivateIdentifier(a,s){s.write(`#${a.name}`,a)},Literal(a,s){a.raw!=null?s.write(a.raw,a):a.regex!=null?this.RegExpLiteral(a,s):a.bigint!=null?s.write(a.bigint+"n",a):s.write(E0r(a.value),a)},RegExpLiteral(a,s){let{regex:l}=a;s.write(`/${l.pattern}/${l.flags}`,a)}},A0r={};var kFe=class{static{t(this,"State")}constructor(s){let l=s??A0r;this.output="",l.output!=null?(this.output=l.output,this.write=this.writeToStream):this.output="",this.generator=l.generator!=null?l.generator:P0r,this.expressionsPrecedence=l.expressionsPrecedence!=null?l.expressionsPrecedence:D0r,this.indent=l.indent!=null?l.indent:" ",this.lineEnd=l.lineEnd!=null?l.lineEnd:`
|
|
610
610
|
`,this.indentLevel=l.startingIndentLevel!=null?l.startingIndentLevel:0,this.writeComments=l.comments?l.comments:!1,l.sourceMap!=null&&(this.write=l.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=l.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
|
|
611
611
|
`).length-1,this.mapping={original:null,generated:this,name:void 0,source:l.sourceMap.file||l.sourceMap._file})}write(s){this.output+=s}writeToStream(s){this.output.write(s)}writeAndMap(s,l){this.output+=s,this.map(s,l)}writeToStreamAndMap(s,l){this.output.write(s),this.map(s,l)}map(s,l){if(l!=null){let{type:b}=l;if(b[0]==="L"&&b[2]==="n"){this.column=0,this.line++;return}if(l.loc!=null){let{mapping:D}=this;D.original=l.loc.start,D.name=l.name,this.sourceMap.addMapping(D)}if(b[0]==="T"&&b[8]==="E"||b[0]==="L"&&b[1]==="i"&&typeof l.value=="string"){let{length:D}=s,{column:N,line:M}=this;for(let z=0;z<D;z++)s[z]===`
|
|
612
|
-
`?(N=0,M++):N++;this.column=N,this.line=M;return}}let{length:_}=s,{lineEnd:h}=this;_>0&&(this.lineEndSize>0&&(h.length===1?s[_-1]===h:s.endsWith(h))?(this.line+=this.lineEndSize,this.column=0):this.column+=_)}toString(){return this.output}};function lgt(a,s){let l=new kFe(s);return l.generator[a.type](a,l),l.output}t(lgt,"generate");async function wFe({oasFiles:a,sourceDirectory:s,logger:l}){let _=await F0r({oasFiles:a,sourceDirectory:s,logger:l});return lgt(_)}t(wFe,"generateRawRouteSource");async function F0r({oasFiles:a,sourceDirectory:s,logger:l}){let _=new z3(s,l),h=[];for(let D of a){let N=I0r.basename(D,".oas.json"),M=await _.resolve(D),z=[],re=new Map,ie=await N0r.readFile(D,"utf-8"),Q=JSON.parse(ie);for(let Re in Q.paths){let Ie=Q.paths[Re];for(let we in Ie){if(we.startsWith("x-"))continue;let wt={...Ie[we],...Ie[we].description&&{description:Ie[we].description.length>350?Ie[we].description.substring(0,350).trim()+"...":Ie[we].description}},xt=DG(N,Re,we),Tr=Vfe(D,N,wt,M,z,re);h.unshift(fgt(xt,Tr))}}h.unshift(...O0r(N,M,z,re).reverse())}return{type:"Program",body:h,sourceType:"module"}}t(F0r,"generateAst");function Vfe(a,s,l,_,h,b){let D=[];for(let N in l){let M=l[N];if(N==="$ref")return aG(a,s,O3(a,M),_,h,b),{type:"Identifier",name:_gt(s,b.get(O3(a,M)))};let z;switch(typeof M){case"string":case"number":case"boolean":z={type:"Literal",value:M};break;default:Array.isArray(M)?z=ugt(M,a,s,_,h,b):typeof M=="object"&&M!==null&&(z=Vfe(a,s,M,_,h,b));break}if(z){let re=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(N),ie=re?{type:"Identifier",name:N}:{type:"Literal",value:N};D.push({type:"Property",key:ie,value:z,kind:"init",method:!1,shorthand:!1,computed:!re})}}return{type:"ObjectExpression",properties:D}}t(Vfe,"processNode");function ugt(a,s,l,_,h,b){return{type:"ArrayExpression",elements:a.map(D=>{if(Array.isArray(D))return ugt(D,s,l,_,h,b);if(typeof D=="object"&&D!==null){let N=Vfe(s,l,D,_,h,b);return N.type==="Identifier"?N:{type:"ObjectExpression",properties:N.properties||[]}}else return{type:"Literal",value:D}})}}t(ugt,"processArray");function fgt(a,s){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s}],kind:"var"},specifiers:[],source:null}}t(fgt,"createExportedConstAssignment");function O0r(a,s,l,_){let h=[];for(let b=0;b<l.length;b++){let D=_gt(a,b),N=s.get(l[b]),M=Vfe(Ule(l[b]),a,N,s,l,_);h.push(fgt(D,M))}return h}t(O0r,"generateRefs");function _gt(a,s){return`${PA(a)}__ref__${s}`}t(_gt,"getRefIdentifierName");import pgt from"node:path";var dgt=t(a=>{let s=null;if(a.value.type==="Object"&&a.value.members.length>0)for(let l of a.value.members){let _=dgt(l);if(_!==null&&(s=_),l.name.value==="enum"&&l.value.type==="Array"&&l.value.elements.length===0){let h=l.value,b=h.loc.start.line,D=h.loc.start.column,N=h.loc.end.column;s={line:b,column:D,length:N-D,lineText:""}}}return s},"findEmptyEnums"),L0r=t(a=>{if(a.startsWith("schema with key or id")&&a.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(a.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(a==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(a==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(a.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(a.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(a.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(a.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(a.includes("Unexpected")&&a.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),PFe=t(async(a,s,l)=>{if(!a)return null;let _={file:pgt.join(L4e,a),suggestion:L0r(l)},h=pgt.join(s,L4e),b=ou.safePath(s).resolve(h,a),D=await jle(b);if(l.includes("enum must have non-empty array")){if(D){let N=await sG(D);if(N&&N.body.members!==null)for(let M of N.body.members){let z=dgt(M);z&&z!==null&&(_=Object.assign(_??{},z))}if(_){let M=_.line?_.line:0;_.lineText=iG(D,M)}}}else if(l.includes("Unexpected")&&l.includes("in JSON at position")&&D){let N=await sG(D);N&&"lineText"in N&&(_=Object.assign(_??{},N))}return _},"getLocation");import*as tvt from"esbuild";import Q7e,{dirname as Q1t}from"node:path";import{fileURLToPath as Z1t}from"node:url";var AFe=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT):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"}},R0r=new AFe,Om=R0r;var NFe="no-remote-module";function mgt({logger:a}){return{name:NFe,async setup(s){s.onResolve({filter:/^https?:\/\//},l=>(a.error(l,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${l.path}`,detail:"InvalidRemoteModule",pluginName:NFe,location:{line:0,column:0,file:""}}],pluginName:NFe}))}}}t(mgt,"blockRemoteModulePlugin");import hgt from"node:path";import{performance as fE}from"node:perf_hooks";var wK=[];async function M0r(a,s){let l=fE.now();try{return await s()}finally{let _=fE.now()-l;wK.push({name:a,duration:_})}}t(M0r,"timeFn");var j0r={mark:t(a=>{fE.mark(a)},"mark"),measure:t((a,s,l)=>{try{fE.measure(a,s,l)}finally{fE.clearMarks(s),fE.clearMarks(l),fE.clearMeasures(a)}},"measure"),timeFn:M0r,report:t(()=>{if(wK.length>0){let a=wK.reduce((s,{name:l,duration:_})=>(s[l]=`${_.toFixed(0)}ms`,s),{});console.table(a),wK.length=0}},"report"),getDuration:t(a=>{let s=fE.getEntriesByName(a);if(s.length===0)return 0;let l=s[0].duration;return fE.clearMeasures(a),l},"getDuration"),clear:t(()=>{wK.length=0,fE.clearMarks(),fE.clearMeasures()},"clear")},Bu=j0r;import{writeFile as B0r}from"node:fs/promises";async function Tk(a,s){await ou.mkdirForFilePathIfNotExits(a);let l=await import("prettier"),_=s;try{_=await l.format(s,{parser:"babel"})}catch{}await B0r(a,_,"utf-8")}t(Tk,"writeDebugSourceFile");import{readFile as U0r}from"node:fs/promises";import aN from"node:path";var $j=class extends Error{static{t(this,"DevPortalConfigError")}filename;constructor(s,l){super(s,l),this.name="DevPortalConfigError",this.filename=l?.filename}};async function IFe(a){let s=aN.join(jy,Zat),l=aN.join(a,s),_=!0,h;if(await ou.fileExists(l)){try{let D=await U0r(l,"utf-8"),N=JSON.parse(D);N.enabled===!1&&(_=!1),h=N.sitePathname}catch(D){throw new $j("Failed to parse dev-portal.json file.",{cause:D,filename:s})}return{enabled:_,type:"legacy",basePath:h,filepath:s}}let b=["zudoku.config.js","zudoku.config.jsx","zudoku.config.ts","zudoku.config.tsx","zudoku.config.mjs"];for(;b.length;){let D=b.pop();if(D){let N=aN.join("docs",D),M=aN.join(a,
|
|
612
|
+
`?(N=0,M++):N++;this.column=N,this.line=M;return}}let{length:_}=s,{lineEnd:h}=this;_>0&&(this.lineEndSize>0&&(h.length===1?s[_-1]===h:s.endsWith(h))?(this.line+=this.lineEndSize,this.column=0):this.column+=_)}toString(){return this.output}};function lgt(a,s){let l=new kFe(s);return l.generator[a.type](a,l),l.output}t(lgt,"generate");async function wFe({oasFiles:a,sourceDirectory:s,logger:l}){let _=await F0r({oasFiles:a,sourceDirectory:s,logger:l});return lgt(_)}t(wFe,"generateRawRouteSource");async function F0r({oasFiles:a,sourceDirectory:s,logger:l}){let _=new z3(s,l),h=[];for(let D of a){let N=I0r.basename(D,".oas.json"),M=await _.resolve(D),z=[],re=new Map,ie=await N0r.readFile(D,"utf-8"),Q=JSON.parse(ie);for(let Re in Q.paths){let Ie=Q.paths[Re];for(let we in Ie){if(we.startsWith("x-"))continue;let wt={...Ie[we],...Ie[we].description&&{description:Ie[we].description.length>350?Ie[we].description.substring(0,350).trim()+"...":Ie[we].description}},xt=DG(N,Re,we),Tr=Vfe(D,N,wt,M,z,re);h.unshift(fgt(xt,Tr))}}h.unshift(...O0r(N,M,z,re).reverse())}return{type:"Program",body:h,sourceType:"module"}}t(F0r,"generateAst");function Vfe(a,s,l,_,h,b){let D=[];for(let N in l){let M=l[N];if(N==="$ref")return aG(a,s,O3(a,M),_,h,b),{type:"Identifier",name:_gt(s,b.get(O3(a,M)))};let z;switch(typeof M){case"string":case"number":case"boolean":z={type:"Literal",value:M};break;default:Array.isArray(M)?z=ugt(M,a,s,_,h,b):typeof M=="object"&&M!==null&&(z=Vfe(a,s,M,_,h,b));break}if(z){let re=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(N),ie=re?{type:"Identifier",name:N}:{type:"Literal",value:N};D.push({type:"Property",key:ie,value:z,kind:"init",method:!1,shorthand:!1,computed:!re})}}return{type:"ObjectExpression",properties:D}}t(Vfe,"processNode");function ugt(a,s,l,_,h,b){return{type:"ArrayExpression",elements:a.map(D=>{if(Array.isArray(D))return ugt(D,s,l,_,h,b);if(typeof D=="object"&&D!==null){let N=Vfe(s,l,D,_,h,b);return N.type==="Identifier"?N:{type:"ObjectExpression",properties:N.properties||[]}}else return{type:"Literal",value:D}})}}t(ugt,"processArray");function fgt(a,s){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s}],kind:"var"},specifiers:[],source:null}}t(fgt,"createExportedConstAssignment");function O0r(a,s,l,_){let h=[];for(let b=0;b<l.length;b++){let D=_gt(a,b),N=s.get(l[b]),M=Vfe(Ule(l[b]),a,N,s,l,_);h.push(fgt(D,M))}return h}t(O0r,"generateRefs");function _gt(a,s){return`${PA(a)}__ref__${s}`}t(_gt,"getRefIdentifierName");import pgt from"node:path";var dgt=t(a=>{let s=null;if(a.value.type==="Object"&&a.value.members.length>0)for(let l of a.value.members){let _=dgt(l);if(_!==null&&(s=_),l.name.value==="enum"&&l.value.type==="Array"&&l.value.elements.length===0){let h=l.value,b=h.loc.start.line,D=h.loc.start.column,N=h.loc.end.column;s={line:b,column:D,length:N-D,lineText:""}}}return s},"findEmptyEnums"),L0r=t(a=>{if(a.startsWith("schema with key or id")&&a.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(a.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(a==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(a==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(a.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(a.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(a.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(a.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(a.includes("Unexpected")&&a.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),PFe=t(async(a,s,l)=>{if(!a)return null;let _={file:pgt.join(L4e,a),suggestion:L0r(l)},h=pgt.join(s,L4e),b=ou.safePath(s).resolve(h,a),D=await jle(b);if(l.includes("enum must have non-empty array")){if(D){let N=await sG(D);if(N&&N.body.members!==null)for(let M of N.body.members){let z=dgt(M);z&&z!==null&&(_=Object.assign(_??{},z))}if(_){let M=_.line?_.line:0;_.lineText=iG(D,M)}}}else if(l.includes("Unexpected")&&l.includes("in JSON at position")&&D){let N=await sG(D);N&&"lineText"in N&&(_=Object.assign(_??{},N))}return _},"getLocation");import*as tvt from"esbuild";import Q7e,{dirname as Q1t}from"node:path";import{fileURLToPath as Z1t}from"node:url";var AFe=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT):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"}},R0r=new AFe,Om=R0r;var NFe="no-remote-module";function mgt({logger:a}){return{name:NFe,async setup(s){s.onResolve({filter:/^https?:\/\//},l=>(a.error(l,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${l.path}`,detail:"InvalidRemoteModule",pluginName:NFe,location:{line:0,column:0,file:""}}],pluginName:NFe}))}}}t(mgt,"blockRemoteModulePlugin");import hgt from"node:path";import{performance as fE}from"node:perf_hooks";var wK=[];async function M0r(a,s){let l=fE.now();try{return await s()}finally{let _=fE.now()-l;wK.push({name:a,duration:_})}}t(M0r,"timeFn");var j0r={mark:t(a=>{fE.mark(a)},"mark"),measure:t((a,s,l)=>{try{fE.measure(a,s,l)}finally{fE.clearMarks(s),fE.clearMarks(l),fE.clearMeasures(a)}},"measure"),timeFn:M0r,report:t(()=>{if(wK.length>0){let a=wK.reduce((s,{name:l,duration:_})=>(s[l]=`${_.toFixed(0)}ms`,s),{});console.table(a),wK.length=0}},"report"),getDuration:t(a=>{let s=fE.getEntriesByName(a);if(s.length===0)return 0;let l=s[0].duration;return fE.clearMeasures(a),l},"getDuration"),clear:t(()=>{wK.length=0,fE.clearMarks(),fE.clearMeasures()},"clear")},Bu=j0r;import{writeFile as B0r}from"node:fs/promises";async function Tk(a,s){await ou.mkdirForFilePathIfNotExits(a);let l=await import("prettier"),_=s;try{_=await l.format(s,{parser:"babel"})}catch{}await B0r(a,_,"utf-8")}t(Tk,"writeDebugSourceFile");import{readFile as U0r}from"node:fs/promises";import aN from"node:path";var $j=class extends Error{static{t(this,"DevPortalConfigError")}filename;constructor(s,l){super(s,l),this.name="DevPortalConfigError",this.filename=l?.filename}};async function IFe(a){let s=aN.join(jy,Zat),l=aN.join(a,s),_=!0,h;if(await ou.fileExists(l)){try{let D=await U0r(l,"utf-8"),N=JSON.parse(D);N.enabled===!1&&(_=!1),h=N.sitePathname}catch(D){throw new $j("Failed to parse dev-portal.json file.",{cause:D,filename:s})}return{enabled:_,type:"legacy",basePath:h,filepath:s}}let b=["zudoku.config.js","zudoku.config.jsx","zudoku.config.ts","zudoku.config.tsx","zudoku.config.mjs"];for(;b.length;){let D=b.pop();if(D){let N=aN.join("docs",D),M=aN.join(a,N);try{if(await ou.fileExists(M))return{enabled:!0,type:"zudoku",basePath:void 0,filepath:N}}catch(z){throw new $j("Failed to read dev portal configuration file.",{cause:z,filename:N})}}}return{enabled:!1,type:void 0,basePath:void 0,filepath:void 0}}t(IFe,"getDevPortalConfig");function zj(a,s){let l=aN.resolve(a,YF);return Object.keys(s?.outputs??{}).map(b=>{let D=aN.normalize(b);return`./${aN.relative(l,D).split(aN.sep).join("/")}`})}t(zj,"getBuildModules");var ggt="/docs",$0r="/__zuplo/dev-portal";function z0r(a){let s=a.trim().toLowerCase();return s.endsWith("/")&&(s=s.slice(0,-1)),s}t(z0r,"normalizePathname");function J0r(a){let s={basePath:a?.basePath===$0r?ggt:a?.basePath?z0r(a.basePath):ggt,enabled:a?a.enabled??!0:!1,type:a?.type??void 0,urls:a?.urls?.map(_=>new URL(_).origin)??void 0};return`const devPortal = ${JSON.stringify(s)};
|
|
613
613
|
export default devPortal;`}t(J0r,"generateSource");var PK="dev-portal-config",Wfe="dev-portal";function ygt(a){return{name:PK,setup(s){s.onResolve({filter:/zuplo:dev-portal$/},l=>({namespace:Wfe,path:l.path,pluginName:PK})),s.onLoad({filter:/.*/,namespace:Wfe},async()=>Bu.timeFn("Generating dev-portal.json data",async()=>{let l=[],_,h;try{let D=await IFe(a.sourceDirectory);h=D.filepath,_={...D,urls:a.urls?.devPortal?.urls}}catch(D){let N="Failed to load dev portal config",M="config/dev-portal.json";D instanceof $j&&(N=D.message,M=D.filename??M),l.push({id:"dev-portal-build-error",text:N,location:{file:M,namespace:Wfe,line:1,column:0,length:0,lineText:"",suggestion:""},detail:"DevPortalValidationError",pluginName:PK,notes:[{text:D.message,location:null}]})}let b;try{if(b=J0r(_),Om.DEBUG_BUILD_MODE&&b){let D=hgt.join(a.sourceDirectory,zg,"dev-portal.js");await Tk(D,b)}}catch(D){l.push({id:"dev-portal-build-error",text:D.message,location:{file:"dev-portal.json",namespace:Wfe,line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:PK,notes:[{text:D.message,location:null}]})}return{contents:b,errors:l,pluginName:PK,loader:"js",resolveDir:h?hgt.dirname(h):void 0}}))}}}t(ygt,"devPortalConfigPlugin");import vgt from"node:path";var bgt="legacy-environment",Sgt="legacy-environment",q0r=`import { environment } from "@zuplo/runtime";
|
|
614
614
|
export default environment;`;function Tgt(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:Sgt,pluginName:bgt,path:vgt.join(a.sourceDirectory,zg,"environment.js")})),s.onLoad({filter:/.*/,namespace:Sgt},async l=>({contents:q0r,loader:"ts",resolveDir:vgt.dirname(l.path),pluginName:bgt}))}}}t(Tgt,"environmentPlugin");import qTr from"node:fs/promises";import KT from"node:path";var F1t=x_(S7e(),1),O1t=x_(t1t(),1),L1t=x_(W7e(),1),R1t=x_(H7e(),1);var Pk="schemas",w_e="json-schema";function M1t(a){return{name:Pk,async setup(s){let l=new L1t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0}),_=KT.join(a.sourceDirectory,RH),h=[],b=[],D;await Bu.timeFn("Initializing schema validation",async()=>{if((0,O1t.default)(l,{mode:"fast"}),l.opts.code.formats=F1t._`require("ajv-formats/dist/formats").fastFormats`,await ou.dirExists(_)&&(l.addKeyword("faker"),D=(await ou.listFolderContents(_,RH)).sort(),await Promise.all(D.map(async N=>{try{let M=ou.safePath(a.sourceDirectory).resolve(_,N);if(!M.startsWith(_))throw new Error("All schemas must be in the schemas directory");let z=await qTr.readFile(M,"utf-8");if(z===""||z===void 0)throw new Error(`Schema 'schemas/${N}' is empty and will be ignored.`);let re=JSON.parse(z);if(re.$schema&&re.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${N}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(l.addSchema(re,N),l.errors?.length){let ie=l.errors[0];h.push({id:"json-schema-validation-error",pluginName:Pk,text:`Error: ${ie.message}`,location:{file:KT.join(RH,N)},detail:{params:ie.params,propertyName:ie.propertyName,schemaPath:ie.schemaPath,data:ie.data}})}}catch(M){if(M.message.endsWith("is empty and will be ignored.")){b.push({id:"empty-json-schema-file",pluginName:Pk,text:`Schema 'schemas/${N}' is empty and will be ignored.`,location:{file:`schemas/${N}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${N}' is empty and will be ignored.`,location:{file:`schemas/${N}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let z=await PFe(N,a.sourceDirectory,M.message);h.push({id:"json-schema-add-error",pluginName:Pk,text:`Error: ${M.message}`,location:z,detail:"InvalidAddSchemaError",notes:[{text:M.message}]})}})),await Promise.all(D.map(async N=>{try{let M=l.getSchema(N);M&&l.compile(M.schema).errors?.forEach(re=>{h.push({text:`Failed to compile ${N}: ${re.message}`})})}catch(M){let z=await PFe(N,a.sourceDirectory,M.message);h.push({id:"json-schema-compile-error",pluginName:Pk,text:`The schema file '${N}' is not valid. Error: ${M.message}`,location:z,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),Om.DEBUG_BUILD_MODE)){let N=KT.resolve(a.outputDirectory,RH);await ou.mkdirIfNotExists(N)}}),s.onStart(async()=>{if(D)return{errors:h,warnings:b}}),s.onResolve({filter:/schemas\/.*\.json$/},async N=>Bu.timeFn("Generating JSON schemas...",async()=>{let M=KT.isAbsolute(N.path)?N.path:KT.join(N.resolveDir,N.path);if(N.importer&&N.namespace!=="open-api-routes-json")return{path:M};if(!await ou.fileExists(M)){let z="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${N.path}' from ${z}`,location:{file:KT.join(N.resolveDir,z),namespace:w_e,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${z}`,suggestion:""},detail:"RouteReferenceError",pluginName:Pk,notes:[{text:`Unable to resolve reference to '${N.path}' from ${z}`,location:null}]}],namespace:w_e,path:M,pluginName:Pk}}return{path:M,namespace:w_e,pluginName:Pk}})),s.onLoad({filter:/.*/,namespace:w_e},async N=>Bu.timeFn(`Generating json schema data: ${KT.basename(N.path)}`,async()=>{let M=[],z;try{let re=KT.relative(_,N.path),ie=l.getSchema(re);if(!ie)throw new Error(`Could not load schema at ${N.path}`);z=ie.source?.validateCode;let Q=l.compile(ie.schema);z=(0,R1t.default)(l,Q)}catch(re){M.push({pluginName:Pk,text:`Cannot parse project's schemas/${KT.basename(N.path)} file. Error: ${re.message}`,location:null,notes:[{text:re.message,location:null}],detail:re})}if(Om.DEBUG_BUILD_MODE&&z){let re=KT.relative(_,N.path),ie=KT.join(a.sourceDirectory,zg,`${re}.js`);await Tk(ie,z)}return{contents:z,errors:M,pluginName:Pk,resolveDir:KT.dirname(N.path),watchFiles:[N.path]}}))}}}t(M1t,"jsonSchemaPlugin");import{relative as VTr}from"node:path";var j1t=["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"],WTr="nodejs-compat-plugin";function B1t({sourceDirectory:a}){return{name:WTr,setup(s){let l=new Set;s.onStart(()=>{l.clear()}),s.onResolve({filter:/node:.*/},async({path:_,kind:h,resolveDir:b,...D})=>{let N=`${_}:${h}:${b}:${D.importer}`;if(l.has(N))return;l.add(N);let M=await s.resolve(_,{kind:h,resolveDir:b,importer:D.importer});return M.errors.length>0?j1t.includes(_)||_.includes("/")&&j1t.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:M.errors.map(re=>({...re,location:{file:VTr(a,D.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${_}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:M})}}}t(B1t,"nodejsCompatPlugin");import U1t from"node:fs/promises";import yE from"node:path";var mN="open-api-routes-plugin",cY="open-api-routes-json";function $1t(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/zuplo:routes$/},l=>({watchFiles:[...G7e(yE.join(a.sourceDirectory,jy),[".oas.json"],!0),yE.join(a.sourceDirectory,jy,ule)],namespace:cY,path:yE.isAbsolute(l.path)?l.path:yE.join(l.resolveDir,l.path),pluginName:mN})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:cY},async l=>Bu.timeFn("Generating route data...",async()=>{async function _(){let b=yE.resolve(a.sourceDirectory,"config"),D=await tO(b),N=`$import(.${l.path.replace(/^../,"")})`;return{location:await Pct(D,N,"Update your route configuration to use code from the 'modules' folder"),originalImportValue:N}}t(_,"getLocation");let h=yE.join(l.resolveDir,`${l.path}.ts`);if(l.path.endsWith(".ts")){let{location:b,originalImportValue:D}=await _();return{errors:[{id:"route-build-error",text:`Invalid handler reference '${D}' in ${b?.file??"OpenAPI file"}. Imports must NOT include the '.ts' file extension.`,location:b,detail:"RouteReferenceError",pluginName:mN}],namespace:cY,path:l.path,pluginName:mN}}else if(!await ou.fileExists(h)){let{location:b,originalImportValue:D}=await _();return{errors:[{id:"route-build-error",text:`Invalid handler reference in route. Unable to resolve reference to '${D}' in ${b?.file??"OpenAPI file"}`,location:b,detail:"RouteReferenceError",pluginName:mN}],namespace:cY,path:l.path,pluginName:mN}}})),s.onLoad({filter:/.*/,namespace:cY},async l=>Bu.timeFn("Generating route.json data",async()=>{let _=yE.resolve(a.sourceDirectory,"config"),h=await tO(_),b=await Promise.all(h.map(async z=>({content:await U1t.readFile(z,"utf-8"),fileName:z}))),D=yE.resolve(_,"policies.json");if(!await ou.fileExists(D))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:mN,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:mN};let N={content:await U1t.readFile(D,"utf-8"),fileName:D},M;try{M=await EFe({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:N,compatibilityDate:a.config.compatibilityDate,checkForDuplicateRoutes:a.config.flags?.checkForDuplicateRoutes??!0})}catch(z){throw new Error("Error compiling routes: "+z.message)}if(Om.DEBUG_BUILD_MODE&&M.content){let z=yE.join(a.sourceDirectory,zg),re=yE.resolve(z,"routes.js");await Tk(re,M.content)}return{contents:M.content,errors:M.errors,pluginName:mN,resolveDir:yE.dirname(l.path),watchFiles:[l.path]}}))}}}t($1t,"openApiRoutesPlugin");import P_e from"node:path";var lY="raw-route-plugin",z1t="raw-route";function J1t(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/zuplo:raw-routes$/},l=>({namespace:z1t,path:l.path,pluginName:lY})),s.onLoad({filter:/.*/,namespace:z1t},async l=>Bu.timeFn("Building route data",async()=>{let _=P_e.resolve(a.sourceDirectory,jy);if(!await ou.dirExists(_))return{loader:"js",resolveDir:P_e.dirname(l.path),pluginName:lY};let h=await tO(_);try{let b=await wFe({oasFiles:h,sourceDirectory:a.sourceDirectory,logger:a.logger});if(Om.DEBUG_BUILD_MODE&&b){let D=P_e.join(a.sourceDirectory,zg,"raw-routes.js");await Tk(D,b)}return{contents:b,loader:"js",resolveDir:P_e.dirname(l.path),pluginName:lY}}catch(b){if(b instanceof V1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:b.issue.text,location:b.issue.location,detail:b.issue.detail,pluginName:lY}],pluginName:lY};throw b}}))}}}t(J1t,"rawRoutePlugin");import HTr from"node:fs/promises";import q1t from"node:path";var A_e="runtime-config",V1t="runtime-config-plugin";function W1t(a){return{name:A_e,setup(s){s.onResolve({filter:/zuplo:runtime-extension$/},l=>({namespace:V1t,path:l.path,pluginName:A_e})),s.onLoad({filter:/.*/,namespace:V1t},async()=>Bu.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=q1t.resolve(a.sourceDirectory,Xat,"zuplo.runtime.ts"),h=[];return await ou.fileExists(_)?(l=await HTr.readFile(_,"utf-8"),{contents:l,loader:"ts",resolveDir:q1t.dirname(_),errors:h,pluginName:A_e,watchFiles:[_]}):{contents:l,loader:"ts",errors:h,pluginName:A_e}}))}}}t(W1t,"runtimeConfigPlugin");import X7e from"node:fs/promises";import UO from"node:path";var G1t=x_(W7e(),1),K1t=x_(H7e(),1);var K7e="schema-validation-plugin",H1t="schema-validation",GTr="module.exports = {}";function Y1t(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/zuplo:schema-validations$/},l=>({namespace:H1t,path:l.path,pluginName:K7e})),s.onLoad({filter:/.*/,namespace:H1t},async()=>Bu.timeFn("Validating schemas",async()=>{let l=UO.resolve(a.sourceDirectory,jy,"policies.json");if(!await ou.fileExists(l))return{contents:GTr,loader:"js",resolveDir:UO.dirname(l),pluginName:K7e};let _=await YTr(a.sourceDirectory),h=UO.resolve(a.sourceDirectory,jy),b=await tO(h),D=await exr(b,_),N=await KTr({oasFiles:b,routesWithSchemaValidation:D,sourceDirectory:a.sourceDirectory,logger:a.logger});if(Om.DEBUG_BUILD_MODE&&N){let M=UO.join(a.sourceDirectory,zg,"schema-validation.js");await Tk(M,N)}return{contents:N,loader:"js",resolveDir:UO.dirname(l),pluginName:K7e}}))}}}t(Y1t,"schemaValidationPlugin");async function KTr({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let h="",b=new z3(l,_);if(s.length===0)return h;let D=new G1t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let N of a){let M=await X7e.readFile(N,"utf-8"),z=UO.basename(N,".oas.json"),re=s.filter(we=>we.fileName===z),ie=await b.resolve(N),Q=JSON.parse(M),Re=[],Ie=new Map;re.forEach(we=>{let wt=Q.paths[we.path][we.method];if(wt.requestBody){let xt;if(wt.requestBody.$ref){let Tr=wt.requestBody.$ref;xt=ie.get(Tr)?.content}else wt.requestBody.content&&(xt=wt.requestBody.content);if(xt)for(let Tr in xt){let fn=xt[Tr].schema,tn=cNe(we.path,we.method,Tr);fn.$id=tn,D.addSchema(fn),Y7e(fn,N,z,D,ie,Re,Ie)}}if(wt.parameters)for(let xt of wt.parameters){let Tr=xt.$ref?ie.get(xt.$ref):xt,fn=Tr.schema.$ref?ie.get(Tr.schema.$ref):Tr.schema,tn=oNe(we.path,we.method,Tr.in,Tr.name);fn.$id=tn,D.addSchema(fn),Y7e(Tr,N,z,D,ie,Re,Ie)}});for(let we of Re){let wt=ie.get(we),xt=kG(z,we);D.addSchema(wt,xt)}}return h=(0,K1t.default)(D),h}t(KTr,"schemaValidationSource");function Y7e(a,s,l,_,h,b,D){for(let N in a){let M=a[N];if(N==="$ref"){let z=kG(l,O3(s,M));a[N]=z,aG(s,l,O3(s,M),h,b,D,(re,ie,Q)=>kG(re,O3(Q,ie)))}else typeof M=="object"&&Y7e(M,s,l,_,h,b,D)}}t(Y7e,"addRefsToSchema");async function YTr(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await X7e.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return XTr(_,s)}t(YTr,"getPolicyNamesUsingSchemaValidationPolicies");function XTr(a,s){let l=new Set;a.policies?.forEach(h=>{h.handler?.export&&s.has(h.handler.export)&&h.handler.module==="$import(@zuplo/runtime)"&&l.add(h.name)});let _=QTr(a,l);return new Set([...l,..._])}t(XTr,"getPolicyNamesReferencingPolicyHandlers");function QTr(a,s){let l=new Set;return a.policies?.forEach(_=>{_.handler?.export==="CompositeInboundPolicy"&&_.handler?.options?.policies?.forEach(h=>{s.has(h)&&l.add(_.name)})}),l}t(QTr,"getCompositePoliciesContainingPolicy");function ZTr(a,s){if(!a["x-zuplo-route"]||!a["x-zuplo-route"].policies)return!1;let l=a["x-zuplo-route"].policies.inbound;if(l){for(let h of l)if(s.has(h))return!0}let _=a["x-zuplo-route"].policies.outbound;if(_){for(let h of _)if(s.has(h))return!0}return!1}t(ZTr,"isPolicyPresentInOperation");async function exr(a,s){let l=[];for(let _ of a){let h=await X7e.readFile(_,"utf-8"),D=JSON.parse(h).paths;for(let N in D){let M=D[N];for(let z in M){let re=M[z];ZTr(re,s)&&l.push({fileName:UO.basename(_,".oas.json"),path:N,method:z})}}}return l}t(exr,"getRoutesContainingPolicies");import{mkdirSync as txr,writeFileSync as rxr}from"node:fs";import nxr from"node:path";function X1t(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=zj(a.sourceDirectory,l.metafile);txr(a.outputDirectory,{recursive:!0}),rxr(nxr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(X1t,"writeModulesPlugin");var ixr=gue("zuplo:core:build"),sxr=["workerd","worker","browser"],evt=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],Q7e.resolve(Q1t(Z1t(import.meta.url)),"..","..","..","node_modules"),Q7e.resolve(Q1t(Z1t(import.meta.url)),"..","..","..","..","..","node_modules")];async function uY({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,logger:h,minify:b=!0,command:D,config:N,urls:M}){let z=Q7e.join(a,_le);ixr(`Building with node paths: ${evt.join(", ")}`);let re=b&&D!=="dev"&&!process.env.DEBUG_BUILD_DISABLE_MINIFY?{minify:!0,chunkNames:"[hash]"}:{minify:!1,keepNames:!0,chunkNames:"[name]-[hash]"},ie=Object.freeze({sourceDirectory:l,outputDirectory:s,cacheDirectory:_,logger:h,debugMode:Om.DEBUG_BUILD_MODE,config:N,urls:M});return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:evt,entryPoints:[z],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...re,external:[],logLevel:"silent",conditions:sxr,plugins:[Tgt(ie),mgt(ie),$1t(ie),J1t(ie),Y1t(ie),W1t(ie),ygt(ie),M1t(ie),B1t(ie),X1t(ie)]}}t(uY,"getBaseESBuildConfig");var $O="run-esbuild",rvt=t(async function({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,buildId:h,logger:b,config:D,command:N,minify:M,urls:z},{data:re}){b.debug("Running esbuild");let ie=await uY({command:N,minify:M,systemDirectory:a,outputDirectory:s,cacheDirectory:_,sourceDirectory:l,logger:b,config:D,urls:z}),Q;try{if(!await qM(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");Q=await tvt.build(ie),re.set("metafile",Q.metafile)}catch(we){if(b.error(we),we.errors||we.warnings)Q=we;else if(we.message.includes("Failed to build project because no open-api file was found on the 'config' folder"))Q={warnings:[],errors:[{id:"missing-open-api-file",text:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:$O,location:null,notes:[],detail:"Failed to build project because no open-api file was found on the 'config' folder"}],outputFiles:void 0,metafile:void 0,mangleCache:void 0};else throw we}Q.errors.length>0&&Q.errors.length>1&&(Q.errors.length=1);let{errors:Re,warnings:Ie}=Z7e({buildId:h,result:Q});return{errors:Re,warnings:Ie}},"runEsbuild");function Z7e({buildId:a,result:s}){return{status:s.errors.length>0?"Failed":s.warnings.length>0?"Warnings":"Good",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:a,warnings:s.warnings.map(_=>_.text==="Using direct eval with a bundler is not recommended and may cause problems"?{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:"We do not support the use of 'eval' or 'new Function(...)'",severity:sle,pluginName:_.pluginName||$O}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:sle,pluginName:_.pluginName||$O}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:H6e,pluginName:_.pluginName||$O})),metafile:s.metafile}}t(Z7e,"esbuildResultToBuildResult");var axr=t((a,s)=>{let l=s;if(s.includes(a)){let _=new RegExp(`.*(${a})`,"g");l=s.replace(_,"")}return l.match(/^(\/)?(\.\.(\/)?)+/)&&(l=l.replace(/^(\/)?(\.\.(\/)?)+/,"/")),l},"removePrefixFromString"),oxr=t((a,s)=>{let l=s;if(l.includes(a)){let _=new RegExp(`[a-zA-Z0-9-_.\\/]+(${a})`,"g");l=l.replace(_,"")}return l},"cleanFilePathsInMessage"),nvt=t((a,s,l)=>{if(!a||a.length<=0)return a;let _=a.filter(h=>h.message!=='Could not resolve "@zuplo/runtime"');return _&&_.length>0&&_.forEach(h=>{try{h.location&&h.location.file&&(h.location.file=axr(s,h.location.file)),h.location&&h.location.lineText&&h.location.lineText.includes("@zuplo/core/index.minified.js")&&(h.location.lineText=h.location.lineText.substring(0,200)+"...<Truncated>"),h.message=oxr(s,h.message),h.notes&&h.notes.length>0&&delete h.notes,h.text&&delete h.text,h.pluginName===""&&(h.pluginName=l)}catch{}}),_},"cleanDataOnBuildIssue");function ivt(a,s){let l=e5e.basename(s);a.errors&&(a.errors=nvt(a.errors,l,$O)),a.warnings&&(a.warnings=nvt(a.warnings,l,$O))}t(ivt,"formatBuildResult");var cxr=t(a=>e5e.basename(a).startsWith("."),"isHiddenOnUnix"),lxr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function G7e(a,s=[],l=!1){let _=[],h;if(!N_e.existsSync(a)){let b;if(rG.hasMagic(a))b=a;else{let D=s.map(N=>N.startsWith(".")?N:`.${N}`).join("|");b=`${a}+(${D})`}if(_.push(...rG.sync(b,{nodir:!0})),!_.length)throw Error(`Cannot find any files matching pattern "${a}"`);return _}try{if(h=N_e.statSync(a),h.isFile())return[a]}catch{return[]}return N_e.readdirSync(a).forEach(b=>{let D=e5e.join(a,b),N;try{if(N=N_e.statSync(D),N.isDirectory()){l&&_.push(...G7e(D,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!N.isFile()||!lxr(D,s)||cxr(D)||_.push(D)}),_}t(G7e,"lookupFiles");var YT=new cle,Ak=` ${YT.gray("|")} `;function vzr(a,s){a.info(YT.green(s))}t(vzr,"outputSuccess");function bzr(a,s){a.warn(YT.yellow(s))}t(bzr,"outputWarning");function Szr(a,s){a.error(`
|
|
615
615
|
${YT.red(s)}`)}t(Szr,"outputCritical");function Tzr(a,s,l){let _=l.sort((D,N)=>{let M=D.path.split("/").length,z=N.path.split("/").length;return M!==z?M-z:D.path.localeCompare(N.path)}),h=Math.max(..._.map(D=>D.path.length)),b=`${s}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/core",
|
|
3
|
-
"version": "6.52.
|
|
3
|
+
"version": "6.52.12",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"prettier": "^3.5.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@zuplo/graphql": "6.52.
|
|
45
|
-
"@zuplo/otel": "6.52.
|
|
46
|
-
"@zuplo/runtime": "6.52.
|
|
44
|
+
"@zuplo/graphql": "6.52.12",
|
|
45
|
+
"@zuplo/otel": "6.52.12",
|
|
46
|
+
"@zuplo/runtime": "6.52.12",
|
|
47
47
|
"deno": "2.3.1"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|