@zuplo/core 6.21.15 → 6.21.17
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 +5 -5
- package/index.minified.js +91 -90
- package/package.json +4 -4
package/customer.cli.minified.js
CHANGED
|
@@ -589,12 +589,12 @@ globstar while`,s,Z,l,Re,Pe),this.matchOne(s.slice(Z),l.slice(Re),_))return this
|
|
|
589
589
|
`?(A=0,M++):A++;this.column=A,this.line=M;return}}let{length:_}=s,{lineEnd:m}=this;_>0&&(this.lineEndSize>0&&(m.length===1?s[_-1]===m:s.endsWith(m))?(this.line+=this.lineEndSize,this.column=0):this.column+=_)}toString(){return this.output}};function jmt(a,s){let l=new h8e(s);return l.generator[a.type](a,l),l.output}t(jmt,"generate");import vhr from"fs/promises";import bhr from"path";async function g8e({oasFiles:a,sourceDirectory:s,logger:l}){let _=await Shr({oasFiles:a,sourceDirectory:s,logger:l});return jmt(_)}t(g8e,"generateRawRouteSource");async function Shr({oasFiles:a,sourceDirectory:s,logger:l}){let _=new f3(s,l),m=[];for(let D of a){let A=bhr.basename(D,".oas.json"),M=await _.resolve(D),U=[],ie=new Map,se=await vhr.readFile(D,"utf-8"),Z=JSON.parse(se);for(let Re in Z.paths){let Pe=Z.paths[Re];for(let ke in Pe){if(ke.startsWith("x-"))continue;let{description:wt,...At}=Pe[ke],yr=ZH(A,Re,ke),zr=Xue(D,A,At,M,U,ie);m.unshift(Umt(yr,zr))}}m.unshift(...Thr(A,M,U,ie).reverse())}return{type:"Program",body:m,sourceType:"module"}}t(Shr,"generateAst");function Xue(a,s,l,_,m,b){let D=[];for(let A in l){let M=l[A];if(A==="$ref")return LH(a,s,r3(a,M),_,m,b),{type:"Identifier",name:$mt(s,b.get(r3(a,M)))};let U;switch(typeof M){case"string":case"number":case"boolean":U={type:"Literal",value:M};break;default:Array.isArray(M)?U=Bmt(M,a,s,_,m,b):typeof M=="object"&&M!==null&&(U={type:"ObjectExpression",properties:Xue(a,s,M,_,m,b).properties||[]});break}if(U){let ie=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(A),se=ie?{type:"Identifier",name:A}:{type:"Literal",value:A};D.push({type:"Property",key:se,value:U,kind:"init",method:!1,shorthand:!1,computed:!ie})}}return{type:"ObjectExpression",properties:D}}t(Xue,"processNode");function Bmt(a,s,l,_,m,b){return{type:"ArrayExpression",elements:a.map(D=>{if(Array.isArray(D))return Bmt(D,s,l,_,m,b);if(typeof D=="object"&&D!==null){let A=Xue(s,l,D,_,m,b);return A.type==="Identifier"?A:{type:"ObjectExpression",properties:A.properties||[]}}else return{type:"Literal",value:D}})}}t(Bmt,"processArray");function Umt(a,s){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s}],kind:"var"},specifiers:[],source:null}}t(Umt,"createExportedConstAssignment");function Thr(a,s,l,_){let m=[];for(let b=0;b<l.length;b++){let D=$mt(a,b),A=s.get(l[b]),M=Xue(w6e(l[b]),a,A,s,l,_);m.push(Umt(D,M))}return m}t(Thr,"generateRefs");function $mt(a,s){return`${eA(a)}__ref__${s}`}t($mt,"getRefIdentifierName");import Jmt from"path";var zmt=t(a=>{let s=null;if(a.value.type==="Object"&&a.value.members.length>0)for(let l of a.value.members){let _=zmt(l);if(_!==null&&(s=_),l.name.value==="enum"&&l.value.type==="Array"&&l.value.elements.length===0){let m=l.value,b=m.loc.start.line,D=m.loc.start.column,A=m.loc.end.column;s={line:b,column:D,length:A-D,lineText:""}}}return s},"findEmptyEnums"),xhr=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"),y8e=t(async(a,s,l)=>{if(!a)return null;let _={file:Jmt.join(C6e,a),suggestion:xhr(l)},m=Jmt.join(s,C6e),b=wl.safePath(s).resolve(m,a),D=await Vce(b);if(l.includes("enum must have non-empty array")){if(D){let A=await FH(D);if(A&&A.body.members!==null)for(let M of A.body.members){let U=zmt(M);U&&U!==null&&(_=Object.assign(_??{},U))}if(_){let M=_.line?_.line:0;_.lineText=OH(D,M)}}}else if(l.includes("Unexpected")&&l.includes("in JSON at position")&&D){let A=await FH(D);A&&"lineText"in A&&(_=Object.assign(_??{},A))}return _},"getLocation");import*as Lyt from"esbuild";import{performance as Que,PerformanceObserver as Ehr}from"perf_hooks";var v8e=[];async function Chr(a,s){let l=Que.timerify(s),_=new Ehr(m=>{let b=m.getEntries()[0];v8e.push({name:a,duration:b.duration}),_.disconnect()});return _.observe({entryTypes:["function"]}),l()}t(Chr,"timeFn");var Dhr={mark:t(a=>{Que.mark(a)},"mark"),measure:t((a,s,l)=>{Que.measure(a,s,l)},"measure"),timeFn:Chr,report:t(()=>{v8e.length>0&&console.table(v8e)},"report"),getDuration:t(a=>{let s=Que.getEntriesByName(a);return s.length===0?0:s[0].duration},"getDuration")},zf=Dhr;var khr=!1;function tj(a,s){return{open:`\x1B[${a.join(";")}m`,close:`\x1B[${s}m`,regexp:new RegExp(`\\x1b\\[${s}m`,"g")}}t(tj,"code");function rj(a,s){return khr?`${s.open}${a.replace(s.regexp,s.open)}${s.close}`:a}t(rj,"run");function whr(a){return rj(a,tj([31],39))}t(whr,"red");function Phr(a){return rj(a,tj([32],39))}t(Phr,"green");function Ahr(a){return rj(a,tj([33],39))}t(Ahr,"yellow");function Nhr(a){return rj(a,tj([34],39))}t(Nhr,"blue");function Ihr(a){return rj(a,tj([35],39))}t(Ihr,"magenta");function Ohr(a){return rj(a,tj([36],39))}t(Ohr,"cyan");var $9r=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|"),"g");var qmt=[whr,Phr,Ahr,Nhr,Ihr,Ohr];function Fhr(a){let s=0,l=a.length,_=0;if(l>0)for(;_<l;)s=(s<<5)-s+a.charCodeAt(_++)|0;return s}t(Fhr,"hashCode");function Vmt(a){let s=Math.abs(Fhr(a));return qmt[s%qmt.length]}t(Vmt,"generateColor");import{inspect as Lhr}from"util";function Wmt(a,s,...l){let _=0,m=l.length,b=String(s).replace(/%[sdjoO%]/g,D=>{if(D==="%%")return"%";if(_>=m)return D;switch(D){case"%s":return String(l[_++]);case"%d":return Number(l[_++]).toString();case"%o":return a(l[_++]).split(`
|
|
590
590
|
`).map(A=>A.trim()).join(" ");case"%O":return a(l[_++]);case"%j":try{return JSON.stringify(l[_++])}catch{return"[Circular]"}default:return D}});for(let D of l.splice(_))D===null||!(typeof D=="object"&&D!==null)?b+=" "+D:b+=" "+a(D);return b}t(Wmt,"format");var Hmt=t((a,...s)=>Wmt(Lhr,a,s),"format");var b8e=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(s,l){this.manager=s,this.ns=l,this.color=Vmt(l),this.last=0,this.enabled=s.enabled.some(_=>_.test(l))}log(...s){if(!this.enabled)return;let l,_=s[0];typeof _=="function"?l=_():l=String(_);let m=Date.now()-(this.last||Date.now());l=Hmt(l,...s);let b=`${this.color(this.ns)} ${l} ${this.color(`+${m}ms`)}`;console.log(b),this.last=Date.now()}},S8e=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(s){this.debuggers=new Map,this.enabled=s??[]}};function Rhr(a){return!a||a.length===0?[]:(a=a.replace(/\s/g,"").replace(/\*/g,".+"),a.split(",").map(s=>new RegExp(`^${s}$`)))}t(Rhr,"extract");var Zue;function Gmt(a){Zue||(Zue=new S8e(Rhr(process.env.DEBUG)));let s=new b8e(Zue,a);return Zue.debuggers.set(a,s),Object.assign(s.log.bind(s),{self:s})}t(Gmt,"debug");import qFe,{dirname as Iyt}from"path";import{fileURLToPath as Oyt}from"url";var T8e=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"}},Mhr=new T8e,ph=Mhr;var x8e="no-remote-module";function Kmt({logger:a}){return{name:x8e,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:x8e,location:{line:0,column:0,file:""}}],pluginName:x8e}))}}}t(Kmt,"blockRemoteModulePlugin");import Uhr from"fs/promises";import efe from"path";import{writeFile as jhr}from"fs/promises";async function sk(a,s){await wl.mkdirForFilePathIfNotExits(a);let l=await import("prettier"),_=s;try{_=await l.format(s,{parser:"babel"})}catch{}await jhr(a,_,"utf-8")}t(sk,"writeDebugSourceFile");import Ymt from"path";var Bhr=["zudoku.config.ts","zudoku.config.tsx","zudoku.config.js","zudoku.config.jsx","zudoku.config.mjs"];async function Xmt(a){if(await wl.fileExists(`${a}/config/dev-portal.json`))return"dev-portal";for(let s of Bhr)if(await wl.fileExists(`${a}/docs/${s}`))return"zudoku"}t(Xmt,"getDevPortalType");function nj(a,s){let l=Ymt.relative(process.cwd(),Ymt.join(a,GR));return Object.keys(s?.outputs??{}).map(m=>`.${m.replace(l,"")}`)}t(nj,"getBuildModules");var Qmt="/docs",$hr="/__zuplo/dev-portal";function Jhr(a){let s=a.trim().toLowerCase();return s.endsWith("/")&&(s=s.slice(0,-1)),s}t(Jhr,"normalizePathname");function zhr(a){let s={sitePathname:a?.sitePathname===$hr?Qmt:a?.sitePathname?Jhr(a.sitePathname):Qmt,enabled:a?a.enabled??!0:!1,version:a?.version??"legacy"};return`const devPortal = ${JSON.stringify(s)};
|
|
591
591
|
export default devPortal;`}t(zhr,"generateSource");function Zmt(a){return{name:"dev-portal-config",setup(s){s.onResolve({filter:/dev-portal.json$/},l=>({namespace:"dev-portal-json",path:efe.isAbsolute(l.path)?l.path:efe.join(l.resolveDir,l.path),pluginName:"dev-portal"})),s.onLoad({filter:/.*/,namespace:"dev-portal-json"},async l=>zf.timeFn("Generating dev-portal.json data",async()=>{let _,m,b=[],D=await Xmt(a.sourceDirectory);if(D==="zudoku")_={version:"zudoku",enabled:!0,sitePathname:"/docs"};else if(D==="dev-portal"){m=await Uhr.readFile(l.path,"utf-8");try{_=JSON.parse(m)}catch{b.push({id:"dev-portal-build-error",text:"Could not parse dev-portal.json. Ensure that the file is valid JSON.",location:{file:"dev-portal.json",namespace:"dev-portal-json",line:1,column:0,length:0,lineText:"",suggestion:""},detail:"DevPortalValidationError",pluginName:"dev-portal",notes:[{text:"Could not parse dev-portal.json. Ensure that the file is valid JSON.",location:null}]})}}if(b&&b.length>0)throw b;let A;try{if(A=zhr(_),ph.DEBUG_BUILD_MODE&&A){let M=efe.join(a.sourceDirectory,".zuplo","dev-portal.js");await sk(M,A)}if(b&&b.length>0)throw b}catch(M){M.length>0?M.forEach(U=>{let ie={id:"dev-portal-build-error",text:U.message,location:{file:"dev-portal.json",namespace:"dev-portal-json",line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:"dev-portal",notes:[{text:U.message,location:null}]};b.push(ie)}):b.push({id:"dev-portal-build-error",text:M.message,location:{file:"dev-portal.json",namespace:"dev-portal-json",line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:"dev-portal",notes:[{text:M.message,location:null}]})}return{contents:A,errors:b,pluginName:"dev-portal",loader:"js",resolveDir:efe.dirname(l.path),watchFiles:[l.path]}}))}}}t(Zmt,"devPortalConfigPlugin");import eht from"path";var tht="legacy-environment",rht="legacy-environment",qhr=`import { environment } from "@zuplo/runtime";
|
|
592
|
-
export default environment;`;function nht(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:rht,pluginName:tht,path:eht.join(a.sourceDirectory,Q4,"environment.js")})),s.onLoad({filter:/.*/,namespace:rht},async l=>({contents:qhr,loader:"ts",resolveDir:eht.dirname(l.path),pluginName:tht}))}}}t(nht,"environmentPlugin");var dyt=up(_Fe(),1),myt=up(R0t(),1),hyt=up(MFe(),1),gyt=up(jFe(),1);import z2r from"fs/promises";import z2 from"path";var _k="schemas",Rfe="json-schema";function yyt(a){return{name:_k,async setup(s){let l=new hyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});(0,myt.default)(l,{mode:"fast"}),l.opts.code.formats=dyt._`require("ajv-formats/dist/formats").fastFormats`;let _=z2.join(a.sourceDirectory,lH),m,b=[],D=[];if(await wl.dirExists(_)&&(l.addKeyword("faker"),m=await wl.listFolderContents(_,lH),await Promise.all(m.map(async A=>{try{let M=wl.safePath(a.sourceDirectory).resolve(_,A);if(!M.startsWith(_))throw new Error("All schemas must be in the schemas directory");let U=await z2r.readFile(M,"utf-8");if(U===""||U===void 0)throw new Error(`Schema 'schemas/${A}' is empty and will be ignored.`);let ie=JSON.parse(U);if(ie.$schema&&ie.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${A}: 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.$dataMetaSchema,l.addSchema(ie,A),l.errors?.length){let se=l.errors[0];b.push({id:"json-schema-validation-error",pluginName:_k,text:`Error: ${se.message}`,location:{file:z2.join(lH,A)},detail:{params:se.params,propertyName:se.propertyName,schemaPath:se.schemaPath,data:se.data}})}}catch(M){if(M.message.endsWith("is empty and will be ignored.")){D.push({id:"empty-json-schema-file",pluginName:_k,text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let U=await y8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-add-error",pluginName:_k,text:`Error: ${M.message}`,location:U,detail:"InvalidAddSchemaError",notes:[{text:M.message}]})}})),await Promise.all(m.map(async A=>{try{let M=l.getSchema(A);M&&l.compile(M.schema).errors?.forEach(ie=>{b.push({text:`Failed to compile ${A}: ${ie.message}`})})}catch(M){let U=await y8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-compile-error",pluginName:_k,text:`The schema file '${A}' is not valid. Error: ${M.message}`,location:U,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),ph.DEBUG_BUILD_MODE)){let A=z2.resolve(a.outputDirectory,lH);await wl.mkdirIfNotExists(A)}s.onStart(async()=>{if(m)return{errors:b,warnings:D}}),s.onResolve({filter:/schemas\/.*\.json$/},async A=>{let M=z2.isAbsolute(A.path)?A.path:z2.join(A.resolveDir,A.path);if(A.importer&&A.importer!==z2.join(a.sourceDirectory,"config/routes.json"))return{path:M};if(!await wl.fileExists(M)){let U="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${A.path}' from ${U}`,location:{file:z2.join(A.resolveDir,U),namespace:Rfe,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${U}`,suggestion:""},detail:"RouteReferenceError",pluginName:_k,notes:[{text:`Unable to resolve reference to '${A.path}' from ${U}`,location:null}]}],namespace:Rfe,path:M,pluginName:_k}}return{path:M,namespace:Rfe,pluginName:_k}}),s.onLoad({filter:/.*/,namespace:Rfe},async A=>zf.timeFn(`Generating json schema data: ${z2.basename(A.path)}`,async()=>{let M=[],U;try{let ie=z2.relative(_,A.path),se=l.getSchema(ie);if(!se)throw new Error(`Could not load schema at ${A.path}`);U=se.source?.validateCode;let Z=l.compile(se.schema);U=(0,gyt.default)(l,Z)}catch(ie){M.push({pluginName:_k,text:`Cannot parse project's schemas/${z2.basename(A.path)} file. Error: ${ie.message}`,location:null,notes:[{text:ie.message,location:null}],detail:ie})}if(ph.DEBUG_BUILD_MODE&&U){let ie=z2.relative(_,A.path),se=z2.join(a.sourceDirectory,".zuplo",`${ie}.js`);await sk(se,U)}return{contents:U,errors:M,pluginName:_k,resolveDir:z2.dirname(A.path),watchFiles:[A.path]}}))}}}t(yyt,"jsonSchemaPlugin");import{relative as q2r}from"path";var vyt=["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"],V2r="nodejs-compat-plugin";function byt({sourceDirectory:a}){return{name:V2r,setup(s){let l=new Set;s.onStart(()=>{l.clear()}),s.onResolve({filter:/node:.*/},async({path:_,kind:m,resolveDir:b,...D})=>{let A=`${_}:${m}:${b}:${D.importer}`;if(l.has(A))return;l.add(A);let M=await s.resolve(_,{kind:m,resolveDir:b,importer:D.importer});return M.errors.length>0?vyt.includes(_)||_.includes("/")&&vyt.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:M.errors.map(ie=>({...ie,location:{file:q2r(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(byt,"nodejsCompatPlugin");import Syt from"fs/promises";import ZE from"path";var Cj="open-api-routes-plugin",Mfe="open-api-routes-json";function Tyt(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/routes.json$/},l=>({watchFiles:[...BFe(ZE.join(a.sourceDirectory,j2),[".oas.json"],!0),ZE.join(a.sourceDirectory,j2,dce)],namespace:Mfe,path:ZE.isAbsolute(l.path)?l.path:ZE.join(l.resolveDir,l.path),pluginName:Cj})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:Mfe},async l=>{let _=ZE.join(l.resolveDir,`${l.path}.ts`);if(!await wl.fileExists(_)){let m=`$import(.${l.path.replace(/^../,"")})`,b=ZE.resolve(a.sourceDirectory,"config"),D=await xO(b),A=await fot(D,m,"Update your route configuration to use code from the 'modules' folder");return{errors:[{id:"route-build-error",text:`Invalid handler reference in routes.json. Unable to resolve reference to '${m}' from routes.json`,location:A,detail:"RouteReferenceError",pluginName:Cj}],namespace:Mfe,path:l.path,pluginName:Cj}}}),s.onLoad({filter:/.*/,namespace:Mfe},async l=>zf.timeFn("Generating route.json data",async()=>{let _=ZE.resolve(a.sourceDirectory,"config"),m=await xO(_),b=await Promise.all(m.map(async U=>({content:await Syt.readFile(U,"utf-8"),fileName:U}))),D=ZE.resolve(_,"policies.json");if(!await wl.fileExists(D))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:Cj,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:Cj};let A={content:await Syt.readFile(D,"utf-8"),fileName:D},M;try{M=await d8e({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:A})}catch(U){throw new Error("Error compiling routes: "+U.message)}if(ph.DEBUG_BUILD_MODE&&M.content){let U=ZE.join(a.sourceDirectory,".zuplo"),ie=ZE.resolve(U,"routes.js");await sk(ie,M.content)}return{contents:M.content,errors:M.errors,pluginName:Cj,resolveDir:ZE.dirname(l.path),watchFiles:[l.path]}}))}}}t(Tyt,"openApiRoutesPlugin");import jfe from"path";var IK="raw-route-plugin",xyt="raw-route";function Eyt(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/raw.json$/},l=>({namespace:xyt,path:l.path,pluginName:IK})),s.onLoad({filter:/.*/,namespace:xyt},async l=>{let _=jfe.resolve(a.sourceDirectory,j2);if(!await wl.dirExists(_))return{loader:"js",resolveDir:jfe.dirname(l.path),pluginName:IK};let m=await xO(_);try{let b=await g8e({oasFiles:m,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ph.DEBUG_BUILD_MODE&&b){let D=jfe.join(a.sourceDirectory,".zuplo","raw-routes.js");await sk(D,b)}return{contents:b,loader:"js",resolveDir:jfe.dirname(l.path),pluginName:IK}}catch(b){if(b instanceof M1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:b.issue.text,location:b.issue.location,detail:b.issue.detail,pluginName:IK}],pluginName:IK};throw b}})}}}t(Eyt,"rawRoutePlugin");import W2r from"fs/promises";import UFe from"path";var Bfe="runtime-config",Cyt="runtime-config-plugin";function Dyt(){return{name:Bfe,setup(a){a.onResolve({filter:/^\.\.\/modules\/zuplo.runtime.ts$/},s=>({namespace:Cyt,path:UFe.isAbsolute(s.path)?s.path:UFe.join(s.resolveDir,s.path),pluginName:Bfe})),a.onLoad({filter:/.*/,namespace:Cyt},async s=>zf.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=[];return await wl.fileExists(s.path)?(l=await W2r.readFile(s.path,"utf-8"),{contents:l,loader:"ts",resolveDir:UFe.dirname(s.path),errors:_,pluginName:Bfe,watchFiles:[s.path]}):{contents:l,loader:"ts",errors:_,pluginName:Bfe}}))}}}t(Dyt,"runtimeConfigPlugin");var wyt=up(MFe(),1),Pyt=up(jFe(),1);import zFe from"fs/promises";import cF from"path";var $Fe="schema-validation-plugin",kyt="schema-validation",H2r="module.exports = {}";function Ayt(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/ajv-schema.json$/},l=>({namespace:kyt,path:l.path,pluginName:$Fe})),s.onLoad({filter:/.*/,namespace:kyt},async l=>{let _=cF.resolve(a.sourceDirectory,j2,"policies.json");if(!await wl.fileExists(_))return{contents:H2r,loader:"js",resolveDir:cF.dirname(l.path),pluginName:$Fe};let m=await K2r(a.sourceDirectory),b=cF.resolve(a.sourceDirectory,j2),D=await xO(b),A=await Z2r(D,m),M=await G2r({oasFiles:D,routesWithSchemaValidation:A,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ph.DEBUG_BUILD_MODE&&M){let U=cF.join(a.sourceDirectory,".zuplo","schema-validation.js");await sk(U,M)}return{contents:M,loader:"js",resolveDir:cF.dirname(l.path),pluginName:$Fe}})}}}t(Ayt,"schemaValidationPlugin");async function G2r({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let m="",b=new f3(l,_);if(s.length===0)return m;let D=new wyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let A of a){let M=await zFe.readFile(A,"utf-8"),U=cF.basename(A,".oas.json"),ie=s.filter(ke=>ke.fileName===U),se=await b.resolve(A),Z=JSON.parse(M),Re=[],Pe=new Map;ie.forEach(ke=>{let wt=Z.paths[ke.path][ke.method];if(wt.requestBody){let At;if(wt.requestBody.$ref){let yr=wt.requestBody.$ref;At=se.get(yr)?.content}else wt.requestBody.content&&(At=wt.requestBody.content);if(At)for(let yr in At){let zr=At[yr].schema,en=X4e(ke.path,ke.method,yr);zr.$id=en,D.addSchema(zr),JFe(zr,A,U,D,se,Re,Pe)}}if(wt.parameters)for(let At of wt.parameters){let yr=At.$ref?se.get(At.$ref):At,zr=yr.schema.$ref?se.get(yr.schema.$ref):yr.schema,en=Y4e(ke.path,ke.method,yr.in,yr.name);zr.$id=en,D.addSchema(zr),JFe(yr,A,U,D,se,Re,Pe)}});for(let ke of Re){let wt=se.get(ke),At=eG(U,ke);D.addSchema(wt,At)}}return m=(0,Pyt.default)(D),m}t(G2r,"schemaValidationSource");function JFe(a,s,l,_,m,b,D){for(let A in a){let M=a[A];if(A==="$ref"){let U=eG(l,r3(s,M));a[A]=U,LH(s,l,r3(s,M),m,b,D,(ie,se)=>eG(ie,r3(s,se)))}else typeof M=="object"&&JFe(M,s,l,_,m,b,D)}}t(JFe,"addRefsToSchema");async function K2r(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await zFe.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return Y2r(_,s)}t(K2r,"getPolicyNamesUsingSchemaValidationPolicies");function Y2r(a,s){let l=new Set;a.policies?.forEach(m=>{m.handler?.export&&s.has(m.handler.export)&&m.handler.module==="$import(@zuplo/runtime)"&&l.add(m.name)});let _=X2r(a,l);return new Set([...l,..._])}t(Y2r,"getPolicyNamesReferencingPolicyHandlers");function X2r(a,s){let l=new Set;return a.policies?.forEach(_=>{_.handler?.export==="CompositeInboundPolicy"&&_.handler?.options?.policies?.forEach(m=>{s.has(m)&&l.add(_.name)})}),l}t(X2r,"getCompositePoliciesContainingPolicy");function Q2r(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 m of l)if(s.has(m))return!0}let _=a["x-zuplo-route"].policies.outbound;if(_){for(let m of _)if(s.has(m))return!0}return!1}t(Q2r,"isPolicyPresentInOperation");async function Z2r(a,s){let l=[];for(let _ of a){let m=await zFe.readFile(_,"utf-8"),D=JSON.parse(m).paths;for(let A in D){let M=D[A];for(let U in M){let ie=M[U];Q2r(ie,s)&&l.push({fileName:cF.basename(_,".oas.json"),path:A,method:U})}}}return l}t(Z2r,"getRoutesContainingPolicies");import{mkdirSync as eSr,writeFileSync as tSr}from"fs";import rSr from"path";function Nyt(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=nj(a.sourceDirectory,l.metafile);eSr(a.outputDirectory,{recursive:!0}),tSr(rSr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(Nyt,"writeModulesPlugin");var nSr=Gmt("zuplo:core:build"),iSr=["workerd","worker","browser"],Fyt=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],qFe.resolve(Iyt(Oyt(import.meta.url)),"..","..","..","node_modules"),qFe.resolve(Iyt(Oyt(import.meta.url)),"..","..","..","..","..","node_modules")];async function OK({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,logger:m,minify:b=!0,command:D,flags:A}){let M=qFe.join(a,hce);nSr(`Building with node paths: ${Fyt.join(", ")}`);let U=b&&D!=="dev"&&!process.env.DEBUG_BUILD_DISABLE_MINIFY?{minify:!0,chunkNames:"[hash]"}:{minify:!1,keepNames:!0,chunkNames:"[name]-[hash]"},ie={sourceDirectory:l,outputDirectory:s,cacheDirectory:_,logger:m,debugMode:ph.DEBUG_BUILD_MODE,flags:A};return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:Fyt,entryPoints:[M],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...U,external:[],logLevel:"silent",conditions:iSr,plugins:[nht(ie),Kmt(ie),Tyt(ie),Eyt(ie),Ayt(ie),Dyt(),Zmt(ie),yyt(ie),byt(ie),Nyt(ie)]}}t(OK,"getBaseESBuildConfig");var lF="run-esbuild",Ryt=t(async function({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,buildId:m,logger:b,config:D,command:A,minify:M},U){return zf.timeFn("Running esbuild",async()=>{b.info(`Running build_id: ${m}`);let ie=await OK({command:A,minify:M,systemDirectory:a,outputDirectory:s,cacheDirectory:_,sourceDirectory:l,logger:b,flags:D.flags}),se;try{if(!await oM(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");se=await Lyt.build(ie),U.set("metafile",se.metafile)}catch(Pe){if(b.error(Pe),Pe.errors||Pe.warnings)se=Pe;else if(Pe.message.includes("Failed to build project because no open-api file was found on the 'config' folder"))se={warnings:[],errors:[{id:"missing-open-api-file",text:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:lF,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 Pe}se.errors.length>0&&se.errors.length>1&&(se.errors.length=1);let{errors:Z,warnings:Re}=VFe({buildId:m,result:se});return{errors:Z,warnings:Re}})},"runEsbuild");function VFe({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:fce,pluginName:_.pluginName||lF}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:fce,pluginName:_.pluginName||lF}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:UAe,pluginName:_.pluginName||lF})),metafile:s.metafile}}t(VFe,"esbuildResultToBuildResult");var sSr=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"),aSr=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"),Myt=t((a,s,l)=>{if(!a||a.length<=0)return a;let _=a.filter(m=>m.message!=='Could not resolve "@zuplo/runtime"');return _&&_.length>0&&_.forEach(m=>{try{m.location&&m.location.file&&(m.location.file=sSr(s,m.location.file)),m.location&&m.location.lineText&&m.location.lineText.includes("@zuplo/core/index.minified.js")&&(m.location.lineText=m.location.lineText.substring(0,200)+"...<Truncated>"),m.message=aSr(s,m.message),m.notes&&m.notes.length>0&&delete m.notes,m.text&&delete m.text,m.pluginName===""&&(m.pluginName=l)}catch{}}),_},"cleanDataOnBuildIssue");function jyt(a,s){let l=WFe.basename(s);a.errors&&(a.errors=Myt(a.errors,l,lF)),a.warnings&&(a.warnings=Myt(a.warnings,l,lF))}t(jyt,"formatBuildResult");var oSr=t(a=>WFe.basename(a).startsWith("."),"isHiddenOnUnix"),cSr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function BFe(a,s=[],l=!1){let _=[],m;if(!Ufe.existsSync(a)){let b;if(NH.hasMagic(a))b=a;else{let D=s.map(A=>A.startsWith(".")?A:`.${A}`).join("|");b=`${a}+(${D})`}if(_.push(...NH.sync(b,{nodir:!0})),!_.length)throw Error(`Cannot find any files matching pattern "${a}"`);return _}try{if(m=Ufe.statSync(a),m.isFile())return[a]}catch{return[]}return Ufe.readdirSync(a).forEach(b=>{let D=WFe.join(a,b),A;try{if(A=Ufe.statSync(D),A.isDirectory()){l&&_.push(...BFe(D,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!A.isFile()||!cSr(D,s)||oSr(D)||_.push(D)}),_}t(BFe,"lookupFiles");var uF=new Sce({level:process.env.FORCE_BUILD_COLORS?2:void 0}),L3=` ${uF.gray("|")} `;function HFe({output:a,buildId:s,runtimeVersion:l,compatibilityDate:_}){let m=["Building Zuplo API...",`${L3}Build ID: ${s}`,`${L3}Runtime Version: ${l}`];_&&m.push(`${L3}Compatibility Date: ${_}`),a.child("api").info(m.join(`
|
|
593
|
-
`))}t(HFe,"
|
|
592
|
+
export default environment;`;function nht(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:rht,pluginName:tht,path:eht.join(a.sourceDirectory,Q4,"environment.js")})),s.onLoad({filter:/.*/,namespace:rht},async l=>({contents:qhr,loader:"ts",resolveDir:eht.dirname(l.path),pluginName:tht}))}}}t(nht,"environmentPlugin");var dyt=up(_Fe(),1),myt=up(R0t(),1),hyt=up(MFe(),1),gyt=up(jFe(),1);import z2r from"fs/promises";import z2 from"path";var _k="schemas",Rfe="json-schema";function yyt(a){return{name:_k,async setup(s){let l=new hyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});(0,myt.default)(l,{mode:"fast"}),l.opts.code.formats=dyt._`require("ajv-formats/dist/formats").fastFormats`;let _=z2.join(a.sourceDirectory,lH),m,b=[],D=[];if(await wl.dirExists(_)&&(l.addKeyword("faker"),m=await wl.listFolderContents(_,lH),await Promise.all(m.map(async A=>{try{let M=wl.safePath(a.sourceDirectory).resolve(_,A);if(!M.startsWith(_))throw new Error("All schemas must be in the schemas directory");let U=await z2r.readFile(M,"utf-8");if(U===""||U===void 0)throw new Error(`Schema 'schemas/${A}' is empty and will be ignored.`);let ie=JSON.parse(U);if(ie.$schema&&ie.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${A}: 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.$dataMetaSchema,l.addSchema(ie,A),l.errors?.length){let se=l.errors[0];b.push({id:"json-schema-validation-error",pluginName:_k,text:`Error: ${se.message}`,location:{file:z2.join(lH,A)},detail:{params:se.params,propertyName:se.propertyName,schemaPath:se.schemaPath,data:se.data}})}}catch(M){if(M.message.endsWith("is empty and will be ignored.")){D.push({id:"empty-json-schema-file",pluginName:_k,text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${A}' is empty and will be ignored.`,location:{file:`schemas/${A}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let U=await y8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-add-error",pluginName:_k,text:`Error: ${M.message}`,location:U,detail:"InvalidAddSchemaError",notes:[{text:M.message}]})}})),await Promise.all(m.map(async A=>{try{let M=l.getSchema(A);M&&l.compile(M.schema).errors?.forEach(ie=>{b.push({text:`Failed to compile ${A}: ${ie.message}`})})}catch(M){let U=await y8e(A,a.sourceDirectory,M.message);b.push({id:"json-schema-compile-error",pluginName:_k,text:`The schema file '${A}' is not valid. Error: ${M.message}`,location:U,detail:"InvalidSchemaError",notes:[{text:M.message}]})}})),ph.DEBUG_BUILD_MODE)){let A=z2.resolve(a.outputDirectory,lH);await wl.mkdirIfNotExists(A)}s.onStart(async()=>{if(m)return{errors:b,warnings:D}}),s.onResolve({filter:/schemas\/.*\.json$/},async A=>{let M=z2.isAbsolute(A.path)?A.path:z2.join(A.resolveDir,A.path);if(A.importer&&A.importer!==z2.join(a.sourceDirectory,"config/routes.json"))return{path:M};if(!await wl.fileExists(M)){let U="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${A.path}' from ${U}`,location:{file:z2.join(A.resolveDir,U),namespace:Rfe,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${U}`,suggestion:""},detail:"RouteReferenceError",pluginName:_k,notes:[{text:`Unable to resolve reference to '${A.path}' from ${U}`,location:null}]}],namespace:Rfe,path:M,pluginName:_k}}return{path:M,namespace:Rfe,pluginName:_k}}),s.onLoad({filter:/.*/,namespace:Rfe},async A=>zf.timeFn(`Generating json schema data: ${z2.basename(A.path)}`,async()=>{let M=[],U;try{let ie=z2.relative(_,A.path),se=l.getSchema(ie);if(!se)throw new Error(`Could not load schema at ${A.path}`);U=se.source?.validateCode;let Z=l.compile(se.schema);U=(0,gyt.default)(l,Z)}catch(ie){M.push({pluginName:_k,text:`Cannot parse project's schemas/${z2.basename(A.path)} file. Error: ${ie.message}`,location:null,notes:[{text:ie.message,location:null}],detail:ie})}if(ph.DEBUG_BUILD_MODE&&U){let ie=z2.relative(_,A.path),se=z2.join(a.sourceDirectory,".zuplo",`${ie}.js`);await sk(se,U)}return{contents:U,errors:M,pluginName:_k,resolveDir:z2.dirname(A.path),watchFiles:[A.path]}}))}}}t(yyt,"jsonSchemaPlugin");import{relative as q2r}from"path";var vyt=["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"],V2r="nodejs-compat-plugin";function byt({sourceDirectory:a}){return{name:V2r,setup(s){let l=new Set;s.onStart(()=>{l.clear()}),s.onResolve({filter:/node:.*/},async({path:_,kind:m,resolveDir:b,...D})=>{let A=`${_}:${m}:${b}:${D.importer}`;if(l.has(A))return;l.add(A);let M=await s.resolve(_,{kind:m,resolveDir:b,importer:D.importer});return M.errors.length>0?vyt.includes(_)||_.includes("/")&&vyt.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:M.errors.map(ie=>({...ie,location:{file:q2r(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(byt,"nodejsCompatPlugin");import Syt from"fs/promises";import ZE from"path";var Cj="open-api-routes-plugin",Mfe="open-api-routes-json";function Tyt(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/routes.json$/},l=>({watchFiles:[...BFe(ZE.join(a.sourceDirectory,j2),[".oas.json"],!0),ZE.join(a.sourceDirectory,j2,dce)],namespace:Mfe,path:ZE.isAbsolute(l.path)?l.path:ZE.join(l.resolveDir,l.path),pluginName:Cj})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:Mfe},async l=>{let _=ZE.join(l.resolveDir,`${l.path}.ts`);if(!await wl.fileExists(_)){let m=`$import(.${l.path.replace(/^../,"")})`,b=ZE.resolve(a.sourceDirectory,"config"),D=await xO(b),A=await fot(D,m,"Update your route configuration to use code from the 'modules' folder");return{errors:[{id:"route-build-error",text:`Invalid handler reference in routes.json. Unable to resolve reference to '${m}' from routes.json`,location:A,detail:"RouteReferenceError",pluginName:Cj}],namespace:Mfe,path:l.path,pluginName:Cj}}}),s.onLoad({filter:/.*/,namespace:Mfe},async l=>zf.timeFn("Generating route.json data",async()=>{let _=ZE.resolve(a.sourceDirectory,"config"),m=await xO(_),b=await Promise.all(m.map(async U=>({content:await Syt.readFile(U,"utf-8"),fileName:U}))),D=ZE.resolve(_,"policies.json");if(!await wl.fileExists(D))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:Cj,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:Cj};let A={content:await Syt.readFile(D,"utf-8"),fileName:D},M;try{M=await d8e({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:A})}catch(U){throw new Error("Error compiling routes: "+U.message)}if(ph.DEBUG_BUILD_MODE&&M.content){let U=ZE.join(a.sourceDirectory,".zuplo"),ie=ZE.resolve(U,"routes.js");await sk(ie,M.content)}return{contents:M.content,errors:M.errors,pluginName:Cj,resolveDir:ZE.dirname(l.path),watchFiles:[l.path]}}))}}}t(Tyt,"openApiRoutesPlugin");import jfe from"path";var IK="raw-route-plugin",xyt="raw-route";function Eyt(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/raw.json$/},l=>({namespace:xyt,path:l.path,pluginName:IK})),s.onLoad({filter:/.*/,namespace:xyt},async l=>{let _=jfe.resolve(a.sourceDirectory,j2);if(!await wl.dirExists(_))return{loader:"js",resolveDir:jfe.dirname(l.path),pluginName:IK};let m=await xO(_);try{let b=await g8e({oasFiles:m,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ph.DEBUG_BUILD_MODE&&b){let D=jfe.join(a.sourceDirectory,".zuplo","raw-routes.js");await sk(D,b)}return{contents:b,loader:"js",resolveDir:jfe.dirname(l.path),pluginName:IK}}catch(b){if(b instanceof M1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:b.issue.text,location:b.issue.location,detail:b.issue.detail,pluginName:IK}],pluginName:IK};throw b}})}}}t(Eyt,"rawRoutePlugin");import W2r from"fs/promises";import UFe from"path";var Bfe="runtime-config",Cyt="runtime-config-plugin";function Dyt(){return{name:Bfe,setup(a){a.onResolve({filter:/^\.\.\/modules\/zuplo.runtime.ts$/},s=>({namespace:Cyt,path:UFe.isAbsolute(s.path)?s.path:UFe.join(s.resolveDir,s.path),pluginName:Bfe})),a.onLoad({filter:/.*/,namespace:Cyt},async s=>zf.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=[];return await wl.fileExists(s.path)?(l=await W2r.readFile(s.path,"utf-8"),{contents:l,loader:"ts",resolveDir:UFe.dirname(s.path),errors:_,pluginName:Bfe,watchFiles:[s.path]}):{contents:l,loader:"ts",errors:_,pluginName:Bfe}}))}}}t(Dyt,"runtimeConfigPlugin");var wyt=up(MFe(),1),Pyt=up(jFe(),1);import zFe from"fs/promises";import cF from"path";var $Fe="schema-validation-plugin",kyt="schema-validation",H2r="module.exports = {}";function Ayt(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/ajv-schema.json$/},l=>({namespace:kyt,path:l.path,pluginName:$Fe})),s.onLoad({filter:/.*/,namespace:kyt},async l=>{let _=cF.resolve(a.sourceDirectory,j2,"policies.json");if(!await wl.fileExists(_))return{contents:H2r,loader:"js",resolveDir:cF.dirname(l.path),pluginName:$Fe};let m=await K2r(a.sourceDirectory),b=cF.resolve(a.sourceDirectory,j2),D=await xO(b),A=await Z2r(D,m),M=await G2r({oasFiles:D,routesWithSchemaValidation:A,sourceDirectory:a.sourceDirectory,logger:a.logger});if(ph.DEBUG_BUILD_MODE&&M){let U=cF.join(a.sourceDirectory,".zuplo","schema-validation.js");await sk(U,M)}return{contents:M,loader:"js",resolveDir:cF.dirname(l.path),pluginName:$Fe}})}}}t(Ayt,"schemaValidationPlugin");async function G2r({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let m="",b=new f3(l,_);if(s.length===0)return m;let D=new wyt.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let A of a){let M=await zFe.readFile(A,"utf-8"),U=cF.basename(A,".oas.json"),ie=s.filter(ke=>ke.fileName===U),se=await b.resolve(A),Z=JSON.parse(M),Re=[],Pe=new Map;ie.forEach(ke=>{let wt=Z.paths[ke.path][ke.method];if(wt.requestBody){let At;if(wt.requestBody.$ref){let yr=wt.requestBody.$ref;At=se.get(yr)?.content}else wt.requestBody.content&&(At=wt.requestBody.content);if(At)for(let yr in At){let zr=At[yr].schema,en=X4e(ke.path,ke.method,yr);zr.$id=en,D.addSchema(zr),JFe(zr,A,U,D,se,Re,Pe)}}if(wt.parameters)for(let At of wt.parameters){let yr=At.$ref?se.get(At.$ref):At,zr=yr.schema.$ref?se.get(yr.schema.$ref):yr.schema,en=Y4e(ke.path,ke.method,yr.in,yr.name);zr.$id=en,D.addSchema(zr),JFe(yr,A,U,D,se,Re,Pe)}});for(let ke of Re){let wt=se.get(ke),At=eG(U,ke);D.addSchema(wt,At)}}return m=(0,Pyt.default)(D),m}t(G2r,"schemaValidationSource");function JFe(a,s,l,_,m,b,D){for(let A in a){let M=a[A];if(A==="$ref"){let U=eG(l,r3(s,M));a[A]=U,LH(s,l,r3(s,M),m,b,D,(ie,se)=>eG(ie,r3(s,se)))}else typeof M=="object"&&JFe(M,s,l,_,m,b,D)}}t(JFe,"addRefsToSchema");async function K2r(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await zFe.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return Y2r(_,s)}t(K2r,"getPolicyNamesUsingSchemaValidationPolicies");function Y2r(a,s){let l=new Set;a.policies?.forEach(m=>{m.handler?.export&&s.has(m.handler.export)&&m.handler.module==="$import(@zuplo/runtime)"&&l.add(m.name)});let _=X2r(a,l);return new Set([...l,..._])}t(Y2r,"getPolicyNamesReferencingPolicyHandlers");function X2r(a,s){let l=new Set;return a.policies?.forEach(_=>{_.handler?.export==="CompositeInboundPolicy"&&_.handler?.options?.policies?.forEach(m=>{s.has(m)&&l.add(_.name)})}),l}t(X2r,"getCompositePoliciesContainingPolicy");function Q2r(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 m of l)if(s.has(m))return!0}let _=a["x-zuplo-route"].policies.outbound;if(_){for(let m of _)if(s.has(m))return!0}return!1}t(Q2r,"isPolicyPresentInOperation");async function Z2r(a,s){let l=[];for(let _ of a){let m=await zFe.readFile(_,"utf-8"),D=JSON.parse(m).paths;for(let A in D){let M=D[A];for(let U in M){let ie=M[U];Q2r(ie,s)&&l.push({fileName:cF.basename(_,".oas.json"),path:A,method:U})}}}return l}t(Z2r,"getRoutesContainingPolicies");import{mkdirSync as eSr,writeFileSync as tSr}from"fs";import rSr from"path";function Nyt(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=nj(a.sourceDirectory,l.metafile);eSr(a.outputDirectory,{recursive:!0}),tSr(rSr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(Nyt,"writeModulesPlugin");var nSr=Gmt("zuplo:core:build"),iSr=["workerd","worker","browser"],Fyt=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],qFe.resolve(Iyt(Oyt(import.meta.url)),"..","..","..","node_modules"),qFe.resolve(Iyt(Oyt(import.meta.url)),"..","..","..","..","..","node_modules")];async function OK({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,logger:m,minify:b=!0,command:D,flags:A}){let M=qFe.join(a,hce);nSr(`Building with node paths: ${Fyt.join(", ")}`);let U=b&&D!=="dev"&&!process.env.DEBUG_BUILD_DISABLE_MINIFY?{minify:!0,chunkNames:"[hash]"}:{minify:!1,keepNames:!0,chunkNames:"[name]-[hash]"},ie={sourceDirectory:l,outputDirectory:s,cacheDirectory:_,logger:m,debugMode:ph.DEBUG_BUILD_MODE,flags:A};return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:Fyt,entryPoints:[M],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...U,external:[],logLevel:"silent",conditions:iSr,plugins:[nht(ie),Kmt(ie),Tyt(ie),Eyt(ie),Ayt(ie),Dyt(),Zmt(ie),yyt(ie),byt(ie),Nyt(ie)]}}t(OK,"getBaseESBuildConfig");var lF="run-esbuild",Ryt=t(async function({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,buildId:m,logger:b,config:D,command:A,minify:M},U){return zf.timeFn("Running esbuild",async()=>{b.info(`Running build_id: ${m}`);let ie=await OK({command:A,minify:M,systemDirectory:a,outputDirectory:s,cacheDirectory:_,sourceDirectory:l,logger:b,flags:D.flags}),se;try{if(!await oM(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");se=await Lyt.build(ie),U.set("metafile",se.metafile)}catch(Pe){if(b.error(Pe),Pe.errors||Pe.warnings)se=Pe;else if(Pe.message.includes("Failed to build project because no open-api file was found on the 'config' folder"))se={warnings:[],errors:[{id:"missing-open-api-file",text:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:lF,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 Pe}se.errors.length>0&&se.errors.length>1&&(se.errors.length=1);let{errors:Z,warnings:Re}=VFe({buildId:m,result:se});return{errors:Z,warnings:Re}})},"runEsbuild");function VFe({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:fce,pluginName:_.pluginName||lF}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:fce,pluginName:_.pluginName||lF}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:UAe,pluginName:_.pluginName||lF})),metafile:s.metafile}}t(VFe,"esbuildResultToBuildResult");var sSr=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"),aSr=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"),Myt=t((a,s,l)=>{if(!a||a.length<=0)return a;let _=a.filter(m=>m.message!=='Could not resolve "@zuplo/runtime"');return _&&_.length>0&&_.forEach(m=>{try{m.location&&m.location.file&&(m.location.file=sSr(s,m.location.file)),m.location&&m.location.lineText&&m.location.lineText.includes("@zuplo/core/index.minified.js")&&(m.location.lineText=m.location.lineText.substring(0,200)+"...<Truncated>"),m.message=aSr(s,m.message),m.notes&&m.notes.length>0&&delete m.notes,m.text&&delete m.text,m.pluginName===""&&(m.pluginName=l)}catch{}}),_},"cleanDataOnBuildIssue");function jyt(a,s){let l=WFe.basename(s);a.errors&&(a.errors=Myt(a.errors,l,lF)),a.warnings&&(a.warnings=Myt(a.warnings,l,lF))}t(jyt,"formatBuildResult");var oSr=t(a=>WFe.basename(a).startsWith("."),"isHiddenOnUnix"),cSr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function BFe(a,s=[],l=!1){let _=[],m;if(!Ufe.existsSync(a)){let b;if(NH.hasMagic(a))b=a;else{let D=s.map(A=>A.startsWith(".")?A:`.${A}`).join("|");b=`${a}+(${D})`}if(_.push(...NH.sync(b,{nodir:!0})),!_.length)throw Error(`Cannot find any files matching pattern "${a}"`);return _}try{if(m=Ufe.statSync(a),m.isFile())return[a]}catch{return[]}return Ufe.readdirSync(a).forEach(b=>{let D=WFe.join(a,b),A;try{if(A=Ufe.statSync(D),A.isDirectory()){l&&_.push(...BFe(D,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!A.isFile()||!cSr(D,s)||oSr(D)||_.push(D)}),_}t(BFe,"lookupFiles");var uF=new Sce({level:process.env.FORCE_BUILD_COLORS?2:void 0}),L3=` ${uF.gray("|")} `;function HFe({output:a,buildId:s,runtimeVersion:l,compatibilityDate:_}){let m=["Building Zuplo API...",`${L3}Build ID: ${s}`,`${L3}Runtime Version: ${l}`];_&&m.push(`${L3}Compatibility Date: ${_}`),a.info(m.join(`
|
|
593
|
+
`))}t(HFe,"outputApiBuildStart");async function $fe(a,s,l){jyt(l,a),await Promise.all(l.warnings.map(async _=>Byt(a,s,_))),await Promise.all(l.errors.map(async _=>Byt(a,s,_))),l.status==="Good"?s.info(uF.green("Build succeeded"),{status:"success"}):l.status==="Warnings"?s.warn(uF.yellow("Build succeeded with warnings"),{status:"success"}):l.status==="Failed"&&s.error(uF.red("Build failed."),{status:"failed"})}t($fe,"outputBuildResult");async function Byt(a,s,l){let _=[],m=l.severity??"error",b=m==="error"?uF.red:uF.yellow,D=b(`${m.toUpperCase()}: ${l.message}${l.detail?`
|
|
594
594
|
${L3}${l.detail.toString().split(`
|
|
595
595
|
`).join(`
|
|
596
|
-
${L3}`)}`:""}`);_.push(D);let A=fSr(l.location??void 0);if(A&&_.push(`${L3}${b(`The error was found in the file: ${A}`)}`),l.location&&l.location.file&&l.location.column!==0&&l.location.line!==0)try{let M=uSr.join(a,l.location.file),U=await lSr(M,"utf-8"),ie=(0,Uyt.codeFrameColumns)(U,{start:{line:l.location.line,column:l.location.column}},{highlightCode:!0,forceColor:!!process.env.FORCE_BUILD_COLORS,message:l.message,linesAbove:3,linesBelow:3});_.push(L3),_.push(ie)}catch{}else l.location&&l.location.file&&_.push(uF.red(`${L3}File: ${l.location.file}:${l.location.line}:${l.location.column}`));_.push(""),l.severity==="warning"?s.
|
|
597
|
-
`)):s.
|
|
596
|
+
${L3}`)}`:""}`);_.push(D);let A=fSr(l.location??void 0);if(A&&_.push(`${L3}${b(`The error was found in the file: ${A}`)}`),l.location&&l.location.file&&l.location.column!==0&&l.location.line!==0)try{let M=uSr.join(a,l.location.file),U=await lSr(M,"utf-8"),ie=(0,Uyt.codeFrameColumns)(U,{start:{line:l.location.line,column:l.location.column}},{highlightCode:!0,forceColor:!!process.env.FORCE_BUILD_COLORS,message:l.message,linesAbove:3,linesBelow:3});_.push(L3),_.push(ie)}catch{}else l.location&&l.location.file&&_.push(uF.red(`${L3}File: ${l.location.file}:${l.location.line}:${l.location.column}`));_.push(""),l.severity==="warning"?s.warn(_.join(`
|
|
597
|
+
`)):s.error(_.join(`
|
|
598
598
|
`))}t(Byt,"logIssue");function fSr(a){if(a&&a.file){let s=a.file;if(a.line)return`${s}:${a.line}`;if(a.column)return`${s}:${a.column}`}}t(fSr,"getFileLocation");var $T=class{static{t(this,"PluginResult")}errors=[];warnings=[];constructor(s){s&&this.errors.push(s)}};async function $yt(a,s){let l=[],_=[],m=new Map;for await(let b of a)try{let D=await b(s,m);if(_.push(...D.errors.map(A=>(A.pluginName===""&&(A.pluginName=b.name),A))),l.push(...D.warnings),D.errors.length>0)break}catch(D){D instanceof M1?_.push({...D.issue,pluginName:D.pluginName??"unknown"}):_.push(D);break}return{errors:_,warnings:l,data:m}}t($yt,"runPlugins");import{parse as _Sr}from"jsonc-parser";import{readFile as pSr}from"fs/promises";import Jyt from"path";async function Jfe(a){let s=Jyt.join(a,Tst),l=Jyt.join(a,xst),_=!1,m=s;await wl.fileExists(s)?(_=!0,m=s):await wl.fileExists(l)&&(_=!0,m=l);let b,D;if(_){let M=await pSr(m,"utf-8"),ie=_Sr(M,[]);if(typeof ie!="object")return{status:yO,errors:[{message:"Invalid zuplo.jsonc file.",detail:"The zuplo.jsonc file is not a valid JSON object",pluginName:"buildData",severity:"error"}]};if("version"in ie&&ie.version!==1)return{status:yO,errors:[{message:"Invalid version set in zuplo.jsonc file.",detail:"version in zuplo.jsonc must be set to 1",pluginName:"buildData",severity:"error"}]};if("compatibilityDate"in ie&&WR&&typeof ie.compatibilityDate=="string"){if(!WR.includes(ie.compatibilityDate)){let se={message:"Invalid compatibilityDate set in zuplo.jsonc file.",detail:`compatibilityDate was set to ${ie.compatibilityDate}. Valid compatibility dates are ${WR.join(", ")}`,pluginName:"buildData",severity:"error"};return{status:yO,errors:[se]}}b=ie.compatibilityDate}D=uce(b,ie.flags)}else D=uce(void 0,void 0);return{status:gO,config:{version:1,compatibilityDate:b,flags:D}}}t(Jfe,"getZuploConfig");import{mkdir as zyt,readFile as dSr,readdir as mSr,writeFile as hSr}from"fs/promises";import FK from"path";var qyt=t(async function({sourceDirectory:a,logger:s,outputDirectory:l,deploymentName:_,environmentType:m,customDomain:b}){return zf.timeFn("Building OpenAPI files to build output",async()=>{s.debug("Building OpenAPI files to build output");let D=FK.join(a,j2),A=FK.join(D,dce),M=FK.join(l,bst,j2);try{if(await wl.dirExists(l)||await zyt(l),await wl.dirExists(M)||await zyt(M,{recursive:!0}),!await oM(a))return new $T({message:"Failed to build project because no OpenAPI file was found on the 'config' folder",pluginName:"build-open-api-files",severity:"error"});let se=(await mSr(D)).filter(Pe=>Pe.endsWith(".oas.json"));if(!await wl.fileExists(A))return new $T({message:"The project must include a policies file ('/config/policies.json')",pluginName:"build-open-api-files",severity:"error"});let Z=await dSr(A,"utf-8"),Re=JSON.parse(Z);for await(let Pe of se){let ke=FK.join(D,Pe),wt;try{wt=await Vlt({sourceDirectory:a,openApiDocPath:ke,policiesConfig:Re,logger:s,environmentType:m,deploymentName:_,customDomain:b})}catch(zr){if(s.error(zr),zr instanceof SyntaxError||zr instanceof CT.ResolverError||zr instanceof CT.JSONParserError||zr instanceof CT.ParserError||zr instanceof CT.MissingPointerError||zr instanceof IO)return new $T({message:zr.message,location:{file:Pe,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:""},pluginName:"build-open-api-files",severity:"error"});if(zr instanceof M1)return new $T({...zr.issue,pluginName:"build-open-api-files"});throw zr}let At=JSON.stringify(wt,null,2),yr=FK.join(M,Pe);await hSr(yr,At,"utf-8")}}catch(U){return s.error(U),new $T({message:"Error building OpenAPI files",pluginName:"build-open-api-files",severity:"error"})}return new $T})},"buildOpenApiFiles");import gSr from"fs/promises";import ySr from"path";var Vyt=t(async function({outputDirectory:a,systemDirectory:s,cacheDirectory:l,logger:_}){return zf.timeFn("Cleaning output",async()=>{_.debug("Cleaning output");let m=ySr.join(l,"routes"),b=[a,s,m];for await(let D of b)try{await gSr.rm(D,{recursive:!0,force:!0})}catch(A){_.error(A)}return{warnings:[],errors:[]}})},"cleanOutput");import Wyt from"fs/promises";var Hyt=t(async function({systemDirectory:a,cacheDirectory:s,logger:l}){return zf.timeFn("Creating system directory",async()=>{l.debug("Creating system directory");try{return await wl.dirExists(a)?l.debug("System directory already exists, skipping"):await Wyt.mkdir(a),await wl.dirExists(s)?l.debug("Cache directory already exists, skipping"):await Wyt.mkdir(s,{recursive:!0}),{warnings:[],errors:[]}}catch(_){return l.error(_),{warnings:[],errors:[]}}return{warnings:[],errors:[]}})},"createSystemDir");var Gyt=t(async function({logger:a}){return zf.timeFn("Checking for breaking changes",async()=>(a.debug("Checking for breaking changes"),{warnings:[],errors:[]}))},"checkForDeprecations");import{readFile as vSr,writeFile as bSr}from"fs/promises";import Kyt,{dirname as SSr}from"path";import{fileURLToPath as TSr}from"url";var Yyt=t(async function({systemDirectory:a,buildId:s,logger:l,config:_,publicZuploEnvironmentVariables:m}){return zf.timeFn("Generating build data",async()=>{l.debug("Generating build data");let b=await vSr(Kyt.resolve(SSr(TSr(import.meta.url)),"../../../package.json"),"utf-8"),D=JSON.parse(b),A={BUILD_ID:s??"",GIT_SHA:process.env.GIT_SHA,TIMESTAMP:new Date().toISOString(),BUILD_ENV:ph.NODE_ENV,ZUPLO_VERSION:D.version,API_VERSION:process.env.API_VERSION,COMPATIBILITY_DATE:_?.compatibilityDate,ACCOUNT_NAME:m?.ZUPLO_ACCOUNT_NAME,PROJECT_NAME:m?.ZUPLO_PROJECT_NAME,ENVIRONMENT_TYPE:m?.ZUPLO_ENVIRONMENT_TYPE,IS_LOCAL_DEVELOPMENT:ph.isLocalDevelopment(),COMPATIBILITY_FLAGS:_ce?_ce[_?.compatibilityDate??"none"]:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1}},M=JSON.stringify(A,void 0,2),U=Kyt.join(a,mce);try{await bSr(U,M.trimStart(),"utf-8")}catch(ie){l.error(ie);let se={message:`Error creating file at ${U}`,pluginName:"buildData",severity:"error"};return{warnings:[],errors:[se]}}return{warnings:[],errors:[]}})},"generateBuildData");import xSr from"fs/promises";import ESr from"path";var CSr=`import { Handler, ServiceProviderImpl } from "@zuplo/runtime";
|
|
599
599
|
import routeLoader from "../config/routes.json";
|
|
600
600
|
import * as schemaValidations from "./ajv-schema.json";
|
|
@@ -626,7 +626,7 @@ export default {
|
|
|
626
626
|
},
|
|
627
627
|
};
|
|
628
628
|
`,Xyt=t(async function({systemDirectory:a,logger:s}){return zf.timeFn("Generating Worker shim",async()=>{s.debug("Generating Worker shim");let l=ESr.join(a,hce);try{await xSr.writeFile(l,CSr,"utf-8")}catch(_){s.error(_);let m={message:`Error creating file at ${l}`,pluginName:"generate-worker-entry",severity:"error"};return{warnings:[],errors:[m]}}return{warnings:[],errors:[]}})},"generateWorker");import{readFile as DSr,readdir as kSr}from"fs/promises";import Qyt from"path";var zfe="validate-open-api-files",Zyt=t(async function({sourceDirectory:a,logger:s}){return zf.timeFn("Building OpenAPI files to build output",async()=>{s.debug("Building OpenAPI files to build output");let l=Qyt.join(a,j2),_=[];try{if(!await oM(a))return new $T({message:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:zfe,severity:"error"});let D=(await kSr(l)).filter(A=>A.endsWith(".oas.json"));for(let A of D){let M=Qyt.join(l,A);try{A==="zp.oas.json"&&_.push({message:"Open API files cannot be named 'zp.oas.json' since 'zp' is a reserved prefix. Update the file name to solve this build issue.",pluginName:zfe,severity:"error"});let U=await DSr(M,"utf-8"),ie=JSON.parse(U);if(ie&&ie.paths){let se=Object.entries(ie.paths).filter(Z=>Z[0]==="zp"||Z[0]==="/zp");if(se.length>0){let Z=se.length===1?"includes one route path":`includes '${se.length}' routes`;_.push({message:`Open API file '${A}' ${Z} that's named '/zp' which is a reserved route name. Updating the route to something other than '/zp' will solve this build issue.`,pluginName:zfe,severity:"error"})}}}catch(U){s.error(U)}}}catch(m){return s.error(m),_.length>0?{errors:_,warnings:[]}:new $T({message:"Failed while validating the open api files in the project",pluginName:zfe,severity:"warning"})}return{errors:_,warnings:[]}})},"validateOpenAPIFiles");var wj=up(c7e(),1);import{parse as HSr}from"jsonc-parser";import{readFile as GSr,writeFile as v1t}from"fs/promises";import KSr from"path";var kj=up(c7e(),1);var y1t=t(()=>({include:["modules/**/*",".zuplo/**/*","tests/**/*"],exclude:["./node_modules","./dist"],compilerOptions:{module:kj.ModuleKind.ESNext,target:kj.ScriptTarget.ES2022,moduleResolution:kj.ModuleResolutionKind.Bundler,lib:["ESNext","WebWorker","Webworker.Iterable"],preserveConstEnums:!0,useUnknownInCatchVariables:!1,forceConsistentCasingInFileNames:!0,importHelpers:!0,esModuleInterop:!0,strictNullChecks:!0,noEmit:!0}}),"getZuploTsConfigTemplate");var pF="validate-tsconfig",b1t=t(async function({sourceDirectory:a,logger:s,command:l,environmentType:_}){return zf.timeFn("Validate TSConfig",async()=>{s.debug("Validate TSConfig");let m=_==="WORKING_COPY"||l==="dev";try{let b=y1t(),D=KSr.join(a,"tsconfig.json");if(!await wl.fileExists(D))return m?(await v1t(D,JSON.stringify(b,null,2)),{warnings:[{message:"This project does not have a tsconfig.json file. The file has been created for you.",severity:"warning",pluginName:pF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project does not have a tsconfig.json file.",severity:"error",pluginName:pF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let A=await GSr(D,"utf-8"),M=HSr(A);if(!(M&&typeof M=="object"&&"compilerOptions"in M))return m?(await v1t(D,JSON.stringify(b,null,2)),{warnings:[{message:"This project's tsconfig.json file was invalid. A valid file has been written for you.",severity:"warning",pluginName:pF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project's tsconfig.json file is invalid. It must have a compilerOptions.",severity:"error",pluginName:pF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let U=wj.default.convertCompilerOptionsFromJson(M.compilerOptions,a);if(U.errors.length>0)return{warnings:[],errors:U.errors.map(hn=>({severity:"error",pluginName:pF,message:hn.messageText.toString(),detail:"You will need to modify your tsconfig.json file to build this project.",helpUrl:"https://zuplo.com/docs/articles/tsconfig",location:hn.file?{line:hn.file.getLineStarts()[0],length:hn.file.getWidth(),file:hn.file.fileName,column:hn.file.getStart(),lineText:"",namespace:"",suggestion:""}:void 0}))};if(!M||typeof M!="object")throw new TypeError("The userConfigRaw is not an object, this should not happen.");if(!("compilerOptions"in M)||M.compilerOptions===null||M.compilerOptions===void 0||typeof M.compilerOptions!="object")throw new TypeError("The userConfigRaw.compilerOptions property is not an object, this should not happen.");let ie=t((hn,br,mr)=>`The compiler option '${hn}' should ${br===void 0?"not be set":`be set to '${typeof br=="string"?br:JSON.stringify(br)}'`}, it was ${mr===void 0?"not set":`set to '${typeof mr=="string"?mr:JSON.stringify(mr)}'`}`,"getMessage"),se="ESNext",Z=wj.ModuleKind.ESNext,Re=[];U.options.module!==Z&&Re.push(ie("module",se,M.compilerOptions.module));let Pe="ES2022",ke=wj.default.ScriptTarget.ES2022;U.options.target!==ke&&Re.push(ie("target",Pe,M.compilerOptions.target));let wt="Bundler",At=wj.default.ModuleResolutionKind.Bundler;U.options.moduleResolution!==At&&Re.push(ie("moduleResolution",wt,M.compilerOptions.moduleResolution));let yr=["ESNext","WebWorker","Webworker.Iterable"];t(hn=>{let br=yr.map(Is=>Is.toLowerCase()),mr=hn.map(Is=>Is.toLowerCase());return br.every(Is=>mr.includes(Is))},"includesAllLibs")(M.compilerOptions.lib??[])||Re.push(ie("lib",yr,M.compilerOptions.lib)),U.options.baseUrl&&Re.push(ie("baseUrl",void 0,M.compilerOptions.baseUrl));let en=[];return Re.length>0&&en.push({message:"This project's tsconfig.json was not set to the recommended settings. Custom settings may cause build issues. For guidance on how to adjust your settings, please visit: https://zuplo.com/docs/articles/tsconfig",severity:"warning",detail:Re.join(`
|
|
629
|
-
`),pluginName:pF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}),{warnings:en,errors:[]}}catch(b){s.error(b);let D={message:`Error validating tsconfig.json : ${b.message}`,severity:"error",pluginName:pF};return{warnings:[],errors:[D]}}})},"validateTSConfig");var Pj;try{let a=YSr(MK.resolve(XSr(QSr(import.meta.url)),"../../package.json"),"utf-8");Pj=JSON.parse(a).version}catch{Pj="0.0.0"}async function l7e({buildId:a,sourceDirectory:s,deploymentName:l=MK.basename(s),command:_,minify:m,entitlements:b,environmentType:D,logger:A,output:M,noCompile:U=!1,projectId:ie,customDomain:se,publicZuploEnvironmentVariables:Z={}}){let Re=`Run build with build_id: ${a}`;return zf.timeFn(Re,async()=>{let Pe=await Jfe(s),ke=MK.join(s,GR),wt;if("errors"in Pe)HFe({output:M,buildId:a,runtimeVersion:Pj}),wt={status:"Failed",flags:void 0,compatibilityDate:void 0,runtimeVersion:Pj,outputPath:ke,buildTime:new Date().toISOString(),buildTimeMs:0,buildId:a,warnings:[],errors:Pe.errors,metafile:void 0};else{U||HFe({output:M,buildId:a,runtimeVersion:Pj,compatibilityDate:Pe.config.compatibilityDate});let zr={command:_,minify:m,deploymentName:l,sourceDirectory:s,outputDirectory:ke,systemDirectory:MK.join(s,Q4),cacheDirectory:MK.join(s,"node_modules",Q4),buildId:a,logger:A,output:M,config:Pe.config,publicZuploEnvironmentVariables:Z,projectId:ie,entitlements:b,environmentType:D,customDomain:se},en=[];en.push(Vyt),en.push(Hyt),en.push(Gyt),en.push(Yyt),en.push(b1t),en.push(Zyt),en.push(Xyt),U||en.push(Ryt),en.push(qyt);let hn=await $yt(en,zr),br=hn.errors.length>0?yO:hn.warnings.length>0?BAe:gO,mr=hn.data.get("metafile");wt={status:br,compatibilityDate:Pe.config.compatibilityDate,runtimeVersion:Pj,outputPath:ke,buildTime:new Date().toISOString(),buildTimeMs:0,metafile:mr,buildId:a,warnings:hn.warnings,errors:hn.errors,flags:Pe.config.flags}}wt.warnings.length>0&&wt.warnings.forEach(zr=>{A.warn(zr)}),wt.errors.length>0&&wt.errors.forEach(zr=>{A.error(zr)}),A.debug(`Build ${a} completed ${U?"on watch mode":"with status "+wt.status}`);let{metafile:At,...yr}=wt;return A.debug(yr,`Compiler results for build ${a}`),process.env.ZUPLO_SHOW_PERF&&zf.report(),wt.buildTimeMs=zf.getDuration(Re),U||await $fe(s,M,wt),wt})}t(l7e,"build");var bTt=up(b5e(),1);import{existsSync as Awr}from"fs";import{mkdir as Nwr,readFile as Iwr}from"fs/promises";import eY from"path";import KDr from"chokidar";import*as U2t from"esbuild";import{randomUUID as B2t}from"crypto";import YDr from"events";import cB from"path";var S5e=class extends YDr{static{t(this,"WatchEmitter")}},lB=class{static{t(this,"BuildWatcher")}esbuildContext;emitter=new S5e;envFilesWatcher;outputDirectory;sourceDirectory;command;logger;publicZuploEnvironmentVariables;projectName;buildId;output;constructor({sourceDirectory:s,command:l,logger:_,publicZuploEnvironmentVariables:m={},buildId:b,output:D}){this.sourceDirectory=s,this.command=l,this.outputDirectory=cB.join(s,GR),this.logger=_,this.publicZuploEnvironmentVariables=m,this.projectName=cB.basename(s),this.buildId=b,this.output=D,this.envFilesWatcher=KDr.watch([cB.join(s,".env"),cB.join(s,".env.zuplo")])}watchEnvFiles(){this.envFilesWatcher.on("change",async()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("add",async()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("unlink",async()=>{this.emitter.emit("reload",null,null)})}onReload=t(s=>{this.emitter.on("reload",s)},"onReload");async start(){let{sourceDirectory:s}=this;if(this.esbuildContext!==void 0)throw new Error("Watcher cannot be started more than once");let l=await l7e({buildId:this.buildId,output:this.output,sourceDirectory:s,noCompile:!0,command:this.command,publicZuploEnvironmentVariables:this.publicZuploEnvironmentVariables,logger:this.logger}),_=await OK({command:this.command,systemDirectory:cB.join(s,Q4),cacheDirectory:cB.join(s,"node_modules",Q4),outputDirectory:this.outputDirectory,sourceDirectory:s,logger:this.logger,flags:l.flags}),m=this;_.plugins?.push({name:"on-end",setup(b){b.onEnd(D=>{m.logger.debug("Watcher (build) reloaded");let A=VFe({buildId:B2t(),result:D});A.errors.length>0?m.logger.error(A.errors,"Build errors"):m.logger.debug(`Successfully rebuilt watched project. Build id ${A.buildId}`);let M={...A,compatibilityDate:l.compatibilityDate,flags:l.flags};m.emitter.emit("reload",M,null)})}}),this.esbuildContext=await U2t.context(_);try{if((await this.esbuildContext.rebuild()).errors.length>0){let D={status:"Failed",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:B2t(),warnings:[],errors:[],metafile:void 0};await $fe(s,m.output,D),this.logger.error(D.errors,"Build errors")}}catch(b){throw await this.close(),b}await this.esbuildContext.watch()}async close(){try{await this.envFilesWatcher.close(),this.esbuildContext&&(await this.esbuildContext.dispose(),this.logger.debug("ESBuild watcher closed"))}catch(s){this.logger.error(s)}}};var H5e=up(V2t(),1);var hTt=up(OSt(),1);import{Buffer as Ewr}from"buffer";import Cwr from"path";import mTt from"child_process";import Ape from"process";function F5e(a){let s=typeof a=="string"?`
|
|
629
|
+
`),pluginName:pF,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}),{warnings:en,errors:[]}}catch(b){s.error(b);let D={message:`Error validating tsconfig.json : ${b.message}`,severity:"error",pluginName:pF};return{warnings:[],errors:[D]}}})},"validateTSConfig");var Pj;try{let a=YSr(MK.resolve(XSr(QSr(import.meta.url)),"../../package.json"),"utf-8");Pj=JSON.parse(a).version}catch{Pj="0.0.0"}async function l7e({buildId:a,sourceDirectory:s,deploymentName:l=MK.basename(s),command:_,minify:m,entitlements:b,environmentType:D,logger:A,output:M,noCompile:U=!1,projectId:ie,customDomain:se,publicZuploEnvironmentVariables:Z={}}){let Re=`Run build with build_id: ${a}`;return zf.timeFn(Re,async()=>{let Pe=await Jfe(s),ke=MK.join(s,GR),wt;if("errors"in Pe)HFe({output:M.child("api"),buildId:a,runtimeVersion:Pj}),wt={status:"Failed",flags:void 0,compatibilityDate:void 0,runtimeVersion:Pj,outputPath:ke,buildTime:new Date().toISOString(),buildTimeMs:0,buildId:a,warnings:[],errors:Pe.errors,metafile:void 0};else{U||HFe({output:M.child("api"),buildId:a,runtimeVersion:Pj,compatibilityDate:Pe.config.compatibilityDate});let zr={command:_,minify:m,deploymentName:l,sourceDirectory:s,outputDirectory:ke,systemDirectory:MK.join(s,Q4),cacheDirectory:MK.join(s,"node_modules",Q4),buildId:a,logger:A,output:M,config:Pe.config,publicZuploEnvironmentVariables:Z,projectId:ie,entitlements:b,environmentType:D,customDomain:se},en=[];en.push(Vyt),en.push(Hyt),en.push(Gyt),en.push(Yyt),en.push(b1t),en.push(Zyt),en.push(Xyt),U||en.push(Ryt),en.push(qyt);let hn=await $yt(en,zr),br=hn.errors.length>0?yO:hn.warnings.length>0?BAe:gO,mr=hn.data.get("metafile");wt={status:br,compatibilityDate:Pe.config.compatibilityDate,runtimeVersion:Pj,outputPath:ke,buildTime:new Date().toISOString(),buildTimeMs:0,metafile:mr,buildId:a,warnings:hn.warnings,errors:hn.errors,flags:Pe.config.flags}}wt.warnings.length>0&&wt.warnings.forEach(zr=>{A.warn(zr)}),wt.errors.length>0&&wt.errors.forEach(zr=>{A.error(zr)}),A.debug(`Build ${a} completed ${U?"on watch mode":"with status "+wt.status}`);let{metafile:At,...yr}=wt;return A.debug(yr,`Compiler results for build ${a}`),process.env.ZUPLO_SHOW_PERF&&zf.report(),wt.buildTimeMs=zf.getDuration(Re),U||await $fe(s,M.child("api"),wt),wt})}t(l7e,"build");var bTt=up(b5e(),1);import{existsSync as Awr}from"fs";import{mkdir as Nwr,readFile as Iwr}from"fs/promises";import eY from"path";import KDr from"chokidar";import*as U2t from"esbuild";import{randomUUID as B2t}from"crypto";import YDr from"events";import cB from"path";var S5e=class extends YDr{static{t(this,"WatchEmitter")}},lB=class{static{t(this,"BuildWatcher")}esbuildContext;emitter=new S5e;envFilesWatcher;outputDirectory;sourceDirectory;command;logger;publicZuploEnvironmentVariables;projectName;buildId;output;constructor({sourceDirectory:s,command:l,logger:_,publicZuploEnvironmentVariables:m={},buildId:b,output:D}){this.sourceDirectory=s,this.command=l,this.outputDirectory=cB.join(s,GR),this.logger=_,this.publicZuploEnvironmentVariables=m,this.projectName=cB.basename(s),this.buildId=b,this.output=D,this.envFilesWatcher=KDr.watch([cB.join(s,".env"),cB.join(s,".env.zuplo")])}watchEnvFiles(){this.envFilesWatcher.on("change",async()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("add",async()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("unlink",async()=>{this.emitter.emit("reload",null,null)})}onReload=t(s=>{this.emitter.on("reload",s)},"onReload");async start(){let{sourceDirectory:s}=this;if(this.esbuildContext!==void 0)throw new Error("Watcher cannot be started more than once");let l=await l7e({buildId:this.buildId,output:this.output,sourceDirectory:s,noCompile:!0,command:this.command,publicZuploEnvironmentVariables:this.publicZuploEnvironmentVariables,logger:this.logger}),_=await OK({command:this.command,systemDirectory:cB.join(s,Q4),cacheDirectory:cB.join(s,"node_modules",Q4),outputDirectory:this.outputDirectory,sourceDirectory:s,logger:this.logger,flags:l.flags}),m=this;_.plugins?.push({name:"on-end",setup(b){b.onEnd(D=>{m.logger.debug("Watcher (build) reloaded");let A=VFe({buildId:B2t(),result:D});A.errors.length>0?m.logger.error(A.errors,"Build errors"):m.logger.debug(`Successfully rebuilt watched project. Build id ${A.buildId}`);let M={...A,compatibilityDate:l.compatibilityDate,flags:l.flags};m.emitter.emit("reload",M,null)})}}),this.esbuildContext=await U2t.context(_);try{if((await this.esbuildContext.rebuild()).errors.length>0){let D={status:"Failed",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:B2t(),warnings:[],errors:[],metafile:void 0};await $fe(s,m.output.child("api"),D),this.logger.error(D.errors,"Build errors")}}catch(b){throw await this.close(),b}await this.esbuildContext.watch()}async close(){try{await this.envFilesWatcher.close(),this.esbuildContext&&(await this.esbuildContext.dispose(),this.logger.debug("ESBuild watcher closed"))}catch(s){this.logger.error(s)}}};var H5e=up(V2t(),1);var hTt=up(OSt(),1);import{Buffer as Ewr}from"buffer";import Cwr from"path";import mTt from"child_process";import Ape from"process";function F5e(a){let s=typeof a=="string"?`
|
|
630
630
|
`:10,l=typeof a=="string"?"\r":13;return a[a.length-1]===s&&(a=a.slice(0,-1)),a[a.length-1]===l&&(a=a.slice(0,-1)),a}t(F5e,"stripFinalNewline");import Tpe from"process";import XK from"path";import{fileURLToPath as FSt}from"url";function Spe(a={}){let{env:s=process.env,platform:l=process.platform}=a;return l!=="win32"?"PATH":Object.keys(s).reverse().find(_=>_.toUpperCase()==="PATH")||"Path"}t(Spe,"pathKey");var jkr=t(({cwd:a=Tpe.cwd(),path:s=Tpe.env[Spe()],preferLocal:l=!0,execPath:_=Tpe.execPath,addExecPath:m=!0}={})=>{let b=a instanceof URL?FSt(a):a,D=XK.resolve(b),A=[];return l&&Bkr(A,D),m&&Ukr(A,_,D),[...A,s].join(XK.delimiter)},"npmRunPath"),Bkr=t((a,s)=>{let l;for(;l!==s;)a.push(XK.join(s,"node_modules/.bin")),l=s,s=XK.resolve(s,"..")},"applyPreferLocal"),Ukr=t((a,s,l)=>{let _=s instanceof URL?FSt(s):s;a.push(XK.resolve(l,_,".."))},"applyExecPath"),LSt=t(({env:a=Tpe.env,...s}={})=>{a={...a};let l=Spe({env:a});return s.path=a[l],a[l]=jkr(s),a},"npmRunPathEnv");var $kr=t((a,s,l,_)=>{if(l==="length"||l==="prototype"||l==="arguments"||l==="caller")return;let m=Object.getOwnPropertyDescriptor(a,l),b=Object.getOwnPropertyDescriptor(s,l);!Jkr(m,b)&&_||Object.defineProperty(a,l,b)},"copyProperty"),Jkr=t(function(a,s){return a===void 0||a.configurable||a.writable===s.writable&&a.enumerable===s.enumerable&&a.configurable===s.configurable&&(a.writable||a.value===s.value)},"canCopyProperty"),zkr=t((a,s)=>{let l=Object.getPrototypeOf(s);l!==Object.getPrototypeOf(a)&&Object.setPrototypeOf(a,l)},"changePrototype"),qkr=t((a,s)=>`/* Wrapped ${a}*/
|
|
631
631
|
${s}`,"wrappedToString"),Vkr=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Wkr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Hkr=t((a,s,l)=>{let _=l===""?"":`with ${l.trim()}() `,m=qkr.bind(null,_,s.toString());Object.defineProperty(m,"name",Wkr),Object.defineProperty(a,"toString",{...Vkr,value:m})},"changeToString");function L5e(a,s,{ignoreNonConfigurable:l=!1}={}){let{name:_}=a;for(let m of Reflect.ownKeys(s))$kr(a,s,m,l);return zkr(a,s),Hkr(a,s,_),a}t(L5e,"mimicFunction");var xpe=new WeakMap,RSt=t((a,s={})=>{if(typeof a!="function")throw new TypeError("Expected a function");let l,_=0,m=a.displayName||a.name||"<anonymous>",b=t(function(...D){if(xpe.set(b,++_),_===1)l=a.apply(this,D),a=null;else if(s.throw===!0)throw new Error(`Function \`${m}\` can only be called once`);return l},"onetime");return L5e(b,a),xpe.set(b,_),b},"onetime");RSt.callCount=a=>{if(!xpe.has(a))throw new Error(`The given function \`${a.name}\` is not wrapped by the \`onetime\` package`);return xpe.get(a)};var MSt=RSt;import{constants as Xkr}from"os";var jSt=t(function(){let a=R5e-BSt+1;return Array.from({length:a},Gkr)},"getRealtimeSignals"),Gkr=t(function(a,s){return{name:`SIGRT${s+1}`,number:BSt+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),BSt=34,R5e=64;import{constants as Kkr}from"os";var USt=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var M5e=t(function(){let a=jSt();return[...USt,...a].map(Ykr)},"getSignals"),Ykr=t(function({name:a,number:s,description:l,action:_,forced:m=!1,standard:b}){let{signals:{[a]:D}}=Kkr,A=D!==void 0;return{name:a,number:A?D:s,description:l,supported:A,action:_,forced:m,standard:b}},"normalizeSignal");var Qkr=t(function(){return M5e().reduce(Zkr,{})},"getSignalsByName"),Zkr=t(function(a,{name:s,number:l,description:_,supported:m,action:b,forced:D,standard:A}){return{...a,[s]:{name:s,number:l,description:_,supported:m,action:b,forced:D,standard:A}}},"getSignalByName"),$St=Qkr(),ewr=t(function(){let a=M5e(),s=R5e+1,l=Array.from({length:s},(_,m)=>twr(m,a));return Object.assign({},...l)},"getSignalsByNumber"),twr=t(function(a,s){let l=rwr(a,s);if(l===void 0)return{};let{name:_,description:m,supported:b,action:D,forced:A,standard:M}=l;return{[a]:{name:_,number:a,description:m,supported:b,action:D,forced:A,standard:M}}},"getSignalByNumber"),rwr=t(function(a,s){let l=s.find(({name:_})=>Xkr.signals[_]===a);return l!==void 0?l:s.find(_=>_.number===a)},"findSignalByNumber"),wVr=ewr();var nwr=t(({timedOut:a,timeout:s,errorCode:l,signal:_,signalDescription:m,exitCode:b,isCanceled:D})=>a?`timed out after ${s} milliseconds`:D?"was canceled":l!==void 0?`failed with ${l}`:_!==void 0?`was killed with ${_} (${m})`:b!==void 0?`failed with exit code ${b}`:"failed","getErrorPrefix"),j5e=t(({stdout:a,stderr:s,all:l,error:_,signal:m,exitCode:b,command:D,escapedCommand:A,timedOut:M,isCanceled:U,killed:ie,parsed:{options:{timeout:se}}})=>{b=b===null?void 0:b,m=m===null?void 0:m;let Z=m===void 0?void 0:$St[m].description,Re=_&&_.code,ke=`Command ${nwr({timedOut:M,timeout:se,errorCode:Re,signal:m,signalDescription:Z,exitCode:b,isCanceled:U})}: ${D}`,wt=Object.prototype.toString.call(_)==="[object Error]",At=wt?`${ke}
|
|
632
632
|
${_.message}`:ke,yr=[At,s,a].filter(Boolean).join(`
|