@zuplo/core 5.2429.0 → 5.2431.0
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/index.minified.js +18 -16
- package/package.json +5 -5
package/index.minified.js
CHANGED
|
@@ -693,7 +693,7 @@ export default {
|
|
|
693
693
|
return handler.requestHandler(request, env, ctx)
|
|
694
694
|
},
|
|
695
695
|
};
|
|
696
|
-
`,nlt=t(async function({systemDirectory:s,logger:a,config:u}){return Fu.timeFn("Generating Worker shim",async()=>{a.debug("Generating Worker shim");let p=u?.flags?.esmWorker?snr:inr,g=nnr.join(s,tce);try{await rnr.writeFile(g,p.trimStart(),"utf-8")}catch(b){a.error(b);let k={message:`Error creating file at ${g}`,pluginName:"generate-worker-entry",severity:"error"};return{warnings:[],errors:[k]}}return{warnings:[],errors:[]}})},"generateWorker");import{readFile as anr}from"fs/promises";import ilt from"path";var onr="validate-dev-portal-json",dH="dev-portal-enabled",alt=t(async function({logger:s,sourceDirectory:a},u){return Fu.timeFn("Validate dev-portal.json file",async()=>{s.debug("Validate dev-portal.json file");let p=ilt.join(a,Kp),g=ilt.join(p,pO);if(!await pc.fileExists(g))return s.debug("Project is missing a dev-portal.json file. Skipping validate-dev-portal-json plugin."),u.set(dH,!1),new Yp;let b=[],k=await anr(g,"utf-8"),N=JSON.parse(k);if(N.enabled===!1)return s.debug("Project has set dev-portal.json to disabled. Skipping validate-dev-portal-json plugin."),u.set(dH,!1),new Yp;if(N.enableAuthentication&&N.authentication){let{provider:M}=N.authentication;if(M&&M!=="auth0"&&M!=="okta"&&M!=="azure-ad"&&M!=="clerk"&&M!=="oidc"&&M!=="external"&&b.push({message:"The authentication setting 'provider' is not set or invalid. Valid values are 'auth0', 'okta', 'azure-ad', 'clerk', 'oidc', or 'external'.",pluginName:"validate-dev-portal-json",severity:"warning"}),M==="external"){let{loginUrl:U,logoutUrl:Q}=N.authentication;mE(U)?U.startsWith("$env(")&&!U.startsWith("$env(ZUPLO_PUBLIC_")&&b.push({message:"'loginUrl' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The authentication setting for 'loginUrl' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(Q)?Q.startsWith("$env(")&&!Q.startsWith("$env(ZUPLO_PUBLIC_")&&b.push({message:"'logoutUrl' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The authentication setting for 'logoutUrl' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"})}else if("authority"in N.authentication){let{authority:U}=N.authentication;if(!N.authentication.devPortalClient)b.push({message:"The authentication setting for 'devPortalClient' is not set. This property is required when 'authority' is also set.",pluginName:"validate-dev-portal-json",severity:"warning"});else{let{clientId:Q,audience:te}=N.authentication.devPortalClient;mE(U)?U.startsWith("$env(")&&!U.startsWith("$env(ZUPLO_PUBLIC_")&&b.push({message:"'authority' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The authentication setting for 'authority' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"}),b.push(...slt({audience:te,clientId:Q}))}}else if("issuer"in N.authentication){let{issuer:U,clientId:Q,clientSecret:te,audience:z}=N.authentication;mE(U)?U.startsWith("$env(")&&!U.startsWith("$env(ZUPLO_PUBLIC_")&&b.push({message:"'issuer' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The authentication setting for 'issuer' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"}),b.push(...slt({audience:z,clientId:Q,clientSecret:te}))}else throw new xS({message:"The dev-portal.json is not valid. The 'authentication' section does not have required fields.",severity:"error"},onr)}if(N.enableMonetization&&N.monetization){let{provider:M}=N.monetization;if((!mE(M)||M!=="stripe")&&b.push({message:"The monetization setting 'provider' is not set or an empty string. Valid values are 'stripe'.",pluginName:"validate-dev-portal-json",severity:"warning"}),M==="stripe"){let{pricingTableId:U,publishableKey:Q,secretKey:te}=N.monetization;mE(U)?U.startsWith("$env(")?U.startsWith("$env(ZUPLO_PUBLIC_")||b.push({message:"'Pricing Table Id' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration. Field monetization.pricingTableId in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):U.startsWith("prctbl_")||b.push({message:"'Pricing Table Id' field must start with prctbl_. Field monetization.pricingTableId in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The monetization setting for 'Pricing Table Id' is not set or is an empty string. Field monetization.pricingTableId in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(Q)?Q.startsWith("$env(")?Q.startsWith("$env(ZUPLO_PUBLIC_")||b.push({message:"'Publishable Key' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration. Field monetization.publishableKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):Q.startsWith("pk_")||b.push({message:"'Publishable Key' field must start with pk_. Field monetization.publishableKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The monetization setting for 'Publishable Key' is not set or is an empty string. Field monetization.publishableKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(te)?te.startsWith("$env(")||b.push({message:"The monetization setting for 'Secret Key' must be an environment variable. Field monetization.secretKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The monetization setting for 'Secret Key' is not set or is an empty string. Field monetization.secretKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"})}}else N.enableMonetization&&!N.monetization&&b.push({message:"Monetization was enabled but no monetization configuration was provider in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"});return{errors:[],warnings:b}})},"validateDevPortalJSON");function slt({audience:s,clientId:a,clientSecret:u}){let p=[];return s&&s.startsWith("$env(")&&!s.startsWith("$env(ZUPLO_PUBLIC_")&&p.push({message:"'audience' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(a)?a.startsWith("$env(")&&!a.startsWith("$env(ZUPLO_PUBLIC_")&&p.push({message:"'clientId' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):p.push({message:"The authentication setting for 'clientId' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(u)&&!u.startsWith("$env(")&&(u.startsWith("$env(ZUPLO_PUBLIC")&&p.push({message:"The authorization setting for 'Client Secret' should not be a public environment variable. ",pluginName:"validate-dev-portal-json",severity:"warning"}),p.push({message:"The authorization setting for 'Client Secret' must be an environment variable. Field authentication.devPortalClient.secretKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"})),p}t(slt,"validateCommonAuth");import{readFile as cnr,readdir as lnr}from"fs/promises";import olt from"path";var Fce="validate-open-api-files",clt=t(async function({sourceDirectory:s,logger:a}){return Fu.timeFn("Building OpenAPI files to build output",async()=>{a.debug("Building OpenAPI files to build output");let u=olt.join(s,Kp),p=[];try{if(!await JR(s))return new Yp({message:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:Fce,severity:"error"});let k=(await lnr(u)).filter(N=>N.endsWith(".oas.json"));for(let N of k){let M=olt.join(u,N);try{N==="zp.oas.json"&&p.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:Fce,severity:"error"});let U=await cnr(M,"utf-8"),Q=JSON.parse(U);if(Q&&Q.paths){let te=Object.entries(Q.paths).filter(z=>z[0]==="zp"||z[0]==="/zp");if(te.length>0){let z=te.length===1?"includes one route path":`includes '${te.length}' routes`;p.push({message:`Open API file '${N}' ${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:Fce,severity:"error"})}}}catch(U){a.error(U)}}}catch(g){return a.error(g),p.length>0?{errors:p,warnings:[]}:new Yp({message:"Failed while validating the open api files in the project",pluginName:Fce,severity:"warning"})}return{errors:p,warnings:[]}})},"validateOpenAPIFiles");var cM=sm(QNe(),1);import{parse as Gnr}from"jsonc-parser";import{readFile as Knr,writeFile as ZNe}from"fs/promises";import Ynr from"path";import Xnr from"prettier";var oM=sm(QNe(),1);var Ylt=t(()=>({include:["modules/**/*",".zuplo/**/*","tests/**/*"],exclude:["./node_modules","./dist"],compilerOptions:{baseUrl:".",module:oM.ModuleKind.ESNext,target:oM.ScriptTarget.ESNext,moduleResolution:oM.ModuleResolutionKind.Bundler,lib:["ESNext","WebWorker","Webworker.Iterable"],preserveConstEnums:!0,useUnknownInCatchVariables:!1,forceConsistentCasingInFileNames:!0,importHelpers:!0,removeComments:!0,esModuleInterop:!0,strictNullChecks:!0,experimentalDecorators:!0,noEmit:!0,paths:{"@app/*":[".zuplo/*"]}}}),"getZuploTsConfigTemplate");var wO="validate-tsconfig",Xlt=t(async function({sourceDirectory:s,logger:a,command:u,environmentType:p}){return Fu.timeFn("Validate TSConfig",async()=>{a.debug("Validate TSConfig");let g=p==="WORKING_COPY"||u==="dev";try{let b=Ylt(),k=Ynr.join(s,"tsconfig.json");if(!await pc.fileExists(k))return g?(await ZNe(k,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:wO,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project does not have a tsconfig.json file.",severity:"error",pluginName:wO,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let N=await Knr(k,"utf-8"),M=Gnr(N);if(!(M&&typeof M=="object"&&"compilerOptions"in M))return g?(await ZNe(k,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:wO,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:wO,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let U=cM.default.convertCompilerOptionsFromJson(M.compilerOptions,s);if(U.errors.length>0)return{warnings:[],errors:U.errors.map(fn=>({severity:"error",pluginName:wO,message:fn.messageText.toString(),detail:"You will need to modify your tsconfig.json file to build this project.",helpUrl:"https://zuplo.com/docs/articles/tsconfig",location:fn.file?{line:fn.file.getLineStarts()[0],length:fn.file.getWidth(),file:fn.file.fileName,column:fn.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 Q=t((fn,mr,tr)=>`The compiler option '${fn}' should ${mr===void 0?"not be set":`be set to '${typeof mr=="string"?mr:JSON.stringify(mr)}'`}, it was ${tr===void 0?"not set":`set to '${typeof tr=="string"?tr:JSON.stringify(tr)}'`}`,"getMessage"),te=!1,z="ESNext",Se=cM.ModuleKind.ESNext,Me=[];U.options.module!==Se&&(g&&(te=!0,M.compilerOptions.module=z),Me.push(Q("module",z,M.compilerOptions.module)));let xe="ES2022",Le=cM.default.ScriptTarget.ES2022;U.options.target!==Le&&(Me.push(Q("target",xe,M.compilerOptions.target)),g&&(te=!0,M.compilerOptions.target=xe));let kt="Bundler",Bt=cM.default.ModuleResolutionKind.Bundler;U.options.moduleResolution!==Bt&&(Me.push(Q("moduleResolution",kt,M.compilerOptions.moduleResolution)),g&&(te=!0,M.compilerOptions.moduleResolution=kt));let ur=["ESNext","WebWorker","Webworker.Iterable"];if(t(fn=>{let mr=ur.map(kr=>kr.toLowerCase()),tr=fn.map(kr=>kr.toLowerCase());return mr.every(kr=>tr.includes(kr))},"includesAllLibs")(M.compilerOptions.lib??[])||(Me.push(Q("lib",ur,M.compilerOptions.lib)),g&&(te=!0,M.compilerOptions.lib=ur)),U.options.baseUrl&&(Me.push(Q("baseUrl",void 0,M.compilerOptions.baseUrl)),g)){te=!0,M.compilerOptions.baseUrl=void 0;let fn=M.compilerOptions.paths??{};fn["@app/*"]&&Array.isArray(fn["@app/*"])&&fn["@app/*"].includes(".zuplo/*")&&(fn["@app/*"]=["./.zuplo/*"],M.compilerOptions.paths=fn)}let er=[];if(Me.length>0&&er.push({message:g&&te?"This project's tsconfig.json was updated to the recommended configuration. This may cause your build to break if you used custom settings.":"This project's tsconfig.json does not match the recommended configuration. You should update this file to ensure your project builds correctly.",severity:"warning",detail:Me.join(`
|
|
696
|
+
`,nlt=t(async function({systemDirectory:s,logger:a,config:u}){return Fu.timeFn("Generating Worker shim",async()=>{a.debug("Generating Worker shim");let p=u?.flags?.esmWorker?snr:inr,g=nnr.join(s,tce);try{await rnr.writeFile(g,p.trimStart(),"utf-8")}catch(b){a.error(b);let k={message:`Error creating file at ${g}`,pluginName:"generate-worker-entry",severity:"error"};return{warnings:[],errors:[k]}}return{warnings:[],errors:[]}})},"generateWorker");import{readFile as anr}from"fs/promises";import ilt from"path";var onr="validate-dev-portal-json",dH="dev-portal-enabled",alt=t(async function({logger:s,sourceDirectory:a},u){return Fu.timeFn("Validate dev-portal.json file",async()=>{s.debug("Validate dev-portal.json file");let p=ilt.join(a,Kp),g=ilt.join(p,pO);if(!await pc.fileExists(g))return s.debug("Project is missing a dev-portal.json file. Skipping validate-dev-portal-json plugin."),u.set(dH,!1),new Yp;let b=[],k=await anr(g,"utf-8"),N=JSON.parse(k);if(N.enabled===!1)return s.debug("Project has set dev-portal.json to disabled. Skipping validate-dev-portal-json plugin."),u.set(dH,!1),new Yp;if(N.enableAuthentication&&N.authentication){let{provider:M}=N.authentication;if(M&&M!=="auth0"&&M!=="okta"&&M!=="azure-ad"&&M!=="clerk"&&M!=="oidc"&&M!=="external"&&b.push({message:"The authentication setting 'provider' is not set or invalid. Valid values are 'auth0', 'okta', 'azure-ad', 'clerk', 'oidc', or 'external'.",pluginName:"validate-dev-portal-json",severity:"warning"}),M==="external"){let{loginUrl:U,logoutUrl:Q}=N.authentication;mE(U)?U.startsWith("$env(")&&!U.startsWith("$env(ZUPLO_PUBLIC_")&&b.push({message:"'loginUrl' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The authentication setting for 'loginUrl' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(Q)?Q.startsWith("$env(")&&!Q.startsWith("$env(ZUPLO_PUBLIC_")&&b.push({message:"'logoutUrl' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The authentication setting for 'logoutUrl' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"})}else if("authority"in N.authentication){let{authority:U}=N.authentication;if(!N.authentication.devPortalClient)b.push({message:"The authentication setting for 'devPortalClient' is not set. This property is required when 'authority' is also set.",pluginName:"validate-dev-portal-json",severity:"warning"});else{let{clientId:Q,audience:te}=N.authentication.devPortalClient;mE(U)?U.startsWith("$env(")&&!U.startsWith("$env(ZUPLO_PUBLIC_")&&b.push({message:"'authority' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The authentication setting for 'authority' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"}),b.push(...slt({audience:te,clientId:Q}))}}else if("issuer"in N.authentication){let{issuer:U,clientId:Q,clientSecret:te,audience:z}=N.authentication;mE(U)?U.startsWith("$env(")&&!U.startsWith("$env(ZUPLO_PUBLIC_")&&b.push({message:"'issuer' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The authentication setting for 'issuer' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"}),b.push(...slt({audience:z,clientId:Q,clientSecret:te}))}else throw new xS({message:"The dev-portal.json is not valid. The 'authentication' section does not have required fields.",severity:"error"},onr)}if(N.enableMonetization&&N.monetization){let{provider:M}=N.monetization;if((!mE(M)||M!=="stripe")&&b.push({message:"The monetization setting 'provider' is not set or an empty string. Valid values are 'stripe'.",pluginName:"validate-dev-portal-json",severity:"warning"}),M==="stripe"){let{pricingTableId:U,publishableKey:Q,secretKey:te}=N.monetization;mE(U)?U.startsWith("$env(")?U.startsWith("$env(ZUPLO_PUBLIC_")||b.push({message:"'Pricing Table Id' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration. Field monetization.pricingTableId in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):U.startsWith("prctbl_")||b.push({message:"'Pricing Table Id' field must start with prctbl_. Field monetization.pricingTableId in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The monetization setting for 'Pricing Table Id' is not set or is an empty string. Field monetization.pricingTableId in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(Q)?Q.startsWith("$env(")?Q.startsWith("$env(ZUPLO_PUBLIC_")||b.push({message:"'Publishable Key' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration. Field monetization.publishableKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):Q.startsWith("pk_")||b.push({message:"'Publishable Key' field must start with pk_. Field monetization.publishableKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The monetization setting for 'Publishable Key' is not set or is an empty string. Field monetization.publishableKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(te)?te.startsWith("$env(")||b.push({message:"The monetization setting for 'Secret Key' must be an environment variable. Field monetization.secretKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"}):b.push({message:"The monetization setting for 'Secret Key' is not set or is an empty string. Field monetization.secretKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"})}}else N.enableMonetization&&!N.monetization&&b.push({message:"Monetization was enabled but no monetization configuration was provider in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"});return{errors:[],warnings:b}})},"validateDevPortalJSON");function slt({audience:s,clientId:a,clientSecret:u}){let p=[];return s&&s.startsWith("$env(")&&!s.startsWith("$env(ZUPLO_PUBLIC_")&&p.push({message:"'audience' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(a)?a.startsWith("$env(")&&!a.startsWith("$env(ZUPLO_PUBLIC_")&&p.push({message:"'clientId' field contains an invalid environment variable. Only variables prefixed with 'ZUPLO_PUBLIC_' can be used in developer portal configuration.",pluginName:"validate-dev-portal-json",severity:"warning"}):p.push({message:"The authentication setting for 'clientId' is not set or is an empty string.",pluginName:"validate-dev-portal-json",severity:"warning"}),mE(u)&&!u.startsWith("$env(")&&(u.startsWith("$env(ZUPLO_PUBLIC")&&p.push({message:"The authorization setting for 'Client Secret' should not be a public environment variable. ",pluginName:"validate-dev-portal-json",severity:"warning"}),p.push({message:"The authorization setting for 'Client Secret' must be an environment variable. Field authentication.devPortalClient.secretKey in dev-portal.json.",pluginName:"validate-dev-portal-json",severity:"warning"})),p}t(slt,"validateCommonAuth");import{readFile as cnr,readdir as lnr}from"fs/promises";import olt from"path";var Fce="validate-open-api-files",clt=t(async function({sourceDirectory:s,logger:a}){return Fu.timeFn("Building OpenAPI files to build output",async()=>{a.debug("Building OpenAPI files to build output");let u=olt.join(s,Kp),p=[];try{if(!await JR(s))return new Yp({message:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:Fce,severity:"error"});let k=(await lnr(u)).filter(N=>N.endsWith(".oas.json"));for(let N of k){let M=olt.join(u,N);try{N==="zp.oas.json"&&p.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:Fce,severity:"error"});let U=await cnr(M,"utf-8"),Q=JSON.parse(U);if(Q&&Q.paths){let te=Object.entries(Q.paths).filter(z=>z[0]==="zp"||z[0]==="/zp");if(te.length>0){let z=te.length===1?"includes one route path":`includes '${te.length}' routes`;p.push({message:`Open API file '${N}' ${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:Fce,severity:"error"})}}}catch(U){a.error(U)}}}catch(g){return a.error(g),p.length>0?{errors:p,warnings:[]}:new Yp({message:"Failed while validating the open api files in the project",pluginName:Fce,severity:"warning"})}return{errors:p,warnings:[]}})},"validateOpenAPIFiles");var cM=sm(QNe(),1);import{parse as Gnr}from"jsonc-parser";import{readFile as Knr,writeFile as ZNe}from"fs/promises";import Ynr from"path";import Xnr from"prettier";var oM=sm(QNe(),1);var Ylt=t(()=>({include:["modules/**/*",".zuplo/**/*","tests/**/*"],exclude:["./node_modules","./dist"],compilerOptions:{baseUrl:".",module:oM.ModuleKind.ESNext,target:oM.ScriptTarget.ESNext,moduleResolution:oM.ModuleResolutionKind.Bundler,lib:["ESNext","WebWorker","Webworker.Iterable"],preserveConstEnums:!0,useUnknownInCatchVariables:!1,forceConsistentCasingInFileNames:!0,importHelpers:!0,removeComments:!0,esModuleInterop:!0,strictNullChecks:!0,experimentalDecorators:!0,noEmit:!0,paths:{"@app/*":[".zuplo/*"]}}}),"getZuploTsConfigTemplate");var wO="validate-tsconfig",Xlt=t(async function({sourceDirectory:s,logger:a,command:u,environmentType:p}){return Fu.timeFn("Validate TSConfig",async()=>{a.debug("Validate TSConfig");let g=p==="WORKING_COPY"||u==="dev";try{let b=Ylt(),k=Ynr.join(s,"tsconfig.json");if(!await pc.fileExists(k))return g?(await ZNe(k,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:wO,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project does not have a tsconfig.json file.",severity:"error",pluginName:wO,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let N=await Knr(k,"utf-8"),M=Gnr(N);if(!(M&&typeof M=="object"&&"compilerOptions"in M))return g?(await ZNe(k,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:wO,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:wO,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let U=cM.default.convertCompilerOptionsFromJson(M.compilerOptions,s);if(U.errors.length>0)return{warnings:[],errors:U.errors.map(fn=>({severity:"error",pluginName:wO,message:fn.messageText.toString(),detail:"You will need to modify your tsconfig.json file to build this project.",helpUrl:"https://zuplo.com/docs/articles/tsconfig",location:fn.file?{line:fn.file.getLineStarts()[0],length:fn.file.getWidth(),file:fn.file.fileName,column:fn.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 Q=t((fn,mr,tr)=>`The compiler option '${fn}' should ${mr===void 0?"not be set":`be set to '${typeof mr=="string"?mr:JSON.stringify(mr)}'`}, it was ${tr===void 0?"not set":`set to '${typeof tr=="string"?tr:JSON.stringify(tr)}'`}`,"getMessage"),te=!1,z="ESNext",Se=cM.ModuleKind.ESNext,Me=[];U.options.module!==Se&&(g&&(te=!0,M.compilerOptions.module=z),Me.push(Q("module",z,M.compilerOptions.module)));let xe="ES2022",Le=cM.default.ScriptTarget.ES2022;U.options.target!==Le&&(Me.push(Q("target",xe,M.compilerOptions.target)),g&&(te=!0,M.compilerOptions.target=xe));let kt="Bundler",Bt=cM.default.ModuleResolutionKind.Bundler;U.options.moduleResolution!==Bt&&(Me.push(Q("moduleResolution",kt,M.compilerOptions.moduleResolution)),g&&(te=!0,M.compilerOptions.moduleResolution=kt));let ur=["ESNext","WebWorker","Webworker.Iterable"];if(t(fn=>{let mr=ur.map(kr=>kr.toLowerCase()),tr=fn.map(kr=>kr.toLowerCase());return mr.every(kr=>tr.includes(kr))},"includesAllLibs")(M.compilerOptions.lib??[])||(Me.push(Q("lib",ur,M.compilerOptions.lib)),g&&(te=!0,M.compilerOptions.lib=ur)),U.options.baseUrl&&(Me.push(Q("baseUrl",void 0,M.compilerOptions.baseUrl)),g)){te=!0,M.compilerOptions.baseUrl=void 0;let fn=M.compilerOptions.paths??{};fn["@app/*"]&&Array.isArray(fn["@app/*"])&&fn["@app/*"].includes(".zuplo/*")&&(fn["@app/*"]=["./.zuplo/*"],M.compilerOptions.paths=fn)}let er=[];if(Me.length>0&&er.push({message:g&&te?"This project's tsconfig.json was updated to the recommended configuration. Custom settings may cause build issues. For guidance on how to adjust your settings, please visit: https://zuplo.com/docs/articles/tsconfig":"This project's tsconfig.json does not match the recommended configuration. You should update this file to the recommended settings to ensure your project builds correctly. For guidance on how to adjust your settings, please visit: https://zuplo.com/docs/articles/tsconfig",severity:"warning",detail:Me.join(`
|
|
697
697
|
`),pluginName:wO,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}),g&&te){let fn=await Xnr.format(JSON.stringify(M,null,2),{parser:"json"});await ZNe(k,fn)}return{warnings:er,errors:[]}}catch(b){a.error(b);let k={message:`Error validating tsconfig.json : ${b.message}`,severity:"error",pluginName:wO};return{warnings:[],errors:[k]}}})},"validateTSConfig");import{parse as Znr}from"@swc/core";import Qnr from"vm";var{hasOwnProperty:Kv}=Object.prototype;function DO(s,a){return s=s.slice(),s.push(a),s}t(DO,"push");function e4e(s,a){return a=a.slice(),a.unshift(s),a}t(e4e,"unshift");var t4e=class extends Error{static{t(this,"NewError")}constructor(a){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=a,this.name="NewError"}};function o_(s,a,u,p,g){if(!(this instanceof o_))try{return new o_(s,a,u,p,g)}catch(k){if(!k.avoidNew)throw k;return k.value}typeof s=="string"&&(g=p,p=u,u=a,a=s,s=null);let b=s&&typeof s=="object";if(s=s||{},this.json=s.json||u,this.path=s.path||a,this.resultType=s.resultType||"value",this.flatten=s.flatten||!1,this.wrap=Kv.call(s,"wrap")?s.wrap:!0,this.sandbox=s.sandbox||{},this.preventEval=s.preventEval||!1,this.parent=s.parent||null,this.parentProperty=s.parentProperty||null,this.callback=s.callback||p||null,this.otherTypeCallback=s.otherTypeCallback||g||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},s.autostart!==!1){let k={path:b?s.path:a};b?"json"in s&&(k.json=s.json):k.json=u;let N=this.evaluate(k);if(!N||typeof N!="object")throw new t4e(N);return N}}t(o_,"JSONPath");o_.prototype.evaluate=function(s,a,u,p){let g=this.parent,b=this.parentProperty,{flatten:k,wrap:N}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,u=u||this.callback,this.currOtherTypeCallback=p||this.otherTypeCallback,a=a||this.json,s=s||this.path,s&&typeof s=="object"&&!Array.isArray(s)){if(!s.path&&s.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Kv.call(s,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:a}=s),k=Kv.call(s,"flatten")?s.flatten:k,this.currResultType=Kv.call(s,"resultType")?s.resultType:this.currResultType,this.currSandbox=Kv.call(s,"sandbox")?s.sandbox:this.currSandbox,N=Kv.call(s,"wrap")?s.wrap:N,this.currPreventEval=Kv.call(s,"preventEval")?s.preventEval:this.currPreventEval,u=Kv.call(s,"callback")?s.callback:u,this.currOtherTypeCallback=Kv.call(s,"otherTypeCallback")?s.otherTypeCallback:this.currOtherTypeCallback,g=Kv.call(s,"parent")?s.parent:g,b=Kv.call(s,"parentProperty")?s.parentProperty:b,s=s.path}if(g=g||null,b=b||null,Array.isArray(s)&&(s=o_.toPathString(s)),!s&&s!==""||!a)return;let M=o_.toPathArray(s);M[0]==="$"&&M.length>1&&M.shift(),this._hasParentSelector=null;let U=this._trace(M,a,["$"],g,b,u).filter(function(Q){return Q&&!Q.isParentSelector});return U.length?!N&&U.length===1&&!U[0].hasArrExpr?this._getPreferredOutput(U[0]):U.reduce((Q,te)=>{let z=this._getPreferredOutput(te);return k&&Array.isArray(z)?Q=Q.concat(z):Q.push(z),Q},[]):N?[]:void 0};o_.prototype._getPreferredOutput=function(s){let a=this.currResultType;switch(a){case"all":{let u=Array.isArray(s.path)?s.path:o_.toPathArray(s.path);return s.pointer=o_.toPointer(u),s.path=typeof s.path=="string"?s.path:o_.toPathString(s.path),s}case"value":case"parent":case"parentProperty":return s[a];case"path":return o_.toPathString(s[a]);case"pointer":return o_.toPointer(s.path);default:throw new TypeError("Unknown result type")}};o_.prototype._handleCallback=function(s,a,u){if(a){let p=this._getPreferredOutput(s);s.path=typeof s.path=="string"?s.path:o_.toPathString(s.path),a(p,u,s)}};o_.prototype._trace=function(s,a,u,p,g,b,k,N){let M;if(!s.length)return M={path:u,value:a,parent:p,parentProperty:g,hasArrExpr:k},this._handleCallback(M,b,"value"),M;let U=s[0],Q=s.slice(1),te=[];function z(Se){Array.isArray(Se)?Se.forEach(Me=>{te.push(Me)}):te.push(Se)}if(t(z,"addRet"),(typeof U!="string"||N)&&a&&Kv.call(a,U))z(this._trace(Q,a[U],DO(u,U),a,U,b,k));else if(U==="*")this._walk(a,Se=>{z(this._trace(Q,a[Se],DO(u,Se),a,Se,b,!0,!0))});else if(U==="..")z(this._trace(Q,a,u,p,g,b,k)),this._walk(a,Se=>{typeof a[Se]=="object"&&z(this._trace(s.slice(),a[Se],DO(u,Se),a,Se,b,!0))});else{if(U==="^")return this._hasParentSelector=!0,{path:u.slice(0,-1),expr:Q,isParentSelector:!0};if(U==="~")return M={path:DO(u,U),value:g,parent:p,parentProperty:null},this._handleCallback(M,b,"property"),M;if(U==="$")z(this._trace(Q,a,u,null,null,b,k));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(U))z(this._slice(U,Q,a,u,p,g,b));else if(U.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let Se=U.replace(/^\?\((.*?)\)$/u,"$1");this._walk(a,Me=>{this._eval(Se,a[Me],Me,u,p,g)&&z(this._trace(Q,a[Me],DO(u,Me),a,Me,b,!0))})}else if(U[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");z(this._trace(e4e(this._eval(U,a,u[u.length-1],u.slice(0,-1),p,g),Q),a,u,p,g,b,k))}else if(U[0]==="@"){let Se=!1,Me=U.slice(1,-2);switch(Me){case"scalar":(!a||!["object","function"].includes(typeof a))&&(Se=!0);break;case"boolean":case"string":case"undefined":case"function":typeof a===Me&&(Se=!0);break;case"integer":Number.isFinite(a)&&!(a%1)&&(Se=!0);break;case"number":Number.isFinite(a)&&(Se=!0);break;case"nonFinite":typeof a=="number"&&!Number.isFinite(a)&&(Se=!0);break;case"object":a&&typeof a===Me&&(Se=!0);break;case"array":Array.isArray(a)&&(Se=!0);break;case"other":Se=this.currOtherTypeCallback(a,u,p,g);break;case"null":a===null&&(Se=!0);break;default:throw new TypeError("Unknown value type "+Me)}if(Se)return M={path:u,value:a,parent:p,parentProperty:g},this._handleCallback(M,b,"value"),M}else if(U[0]==="`"&&a&&Kv.call(a,U.slice(1))){let Se=U.slice(1);z(this._trace(Q,a[Se],DO(u,Se),a,Se,b,k,!0))}else if(U.includes(",")){let Se=U.split(",");for(let Me of Se)z(this._trace(e4e(Me,Q),a,u,p,g,b,!0))}else!N&&a&&Kv.call(a,U)&&z(this._trace(Q,a[U],DO(u,U),a,U,b,k,!0))}if(this._hasParentSelector)for(let Se=0;Se<te.length;Se++){let Me=te[Se];if(Me&&Me.isParentSelector){let xe=this._trace(Me.expr,a,Me.path,p,g,b,k);if(Array.isArray(xe)){te[Se]=xe[0];let Le=xe.length;for(let kt=1;kt<Le;kt++)Se++,te.splice(Se,0,xe[kt])}else te[Se]=xe}}return te};o_.prototype._walk=function(s,a){if(Array.isArray(s)){let u=s.length;for(let p=0;p<u;p++)a(p)}else s&&typeof s=="object"&&Object.keys(s).forEach(u=>{a(u)})};o_.prototype._slice=function(s,a,u,p,g,b,k){if(!Array.isArray(u))return;let N=u.length,M=s.split(":"),U=M[2]&&Number.parseInt(M[2])||1,Q=M[0]&&Number.parseInt(M[0])||0,te=M[1]&&Number.parseInt(M[1])||N;Q=Q<0?Math.max(0,Q+N):Math.min(N,Q),te=te<0?Math.max(0,te+N):Math.min(N,te);let z=[];for(let Se=Q;Se<te;Se+=U)this._trace(e4e(Se,a),u,p,g,b,k,!0).forEach(xe=>{z.push(xe)});return z};o_.prototype._eval=function(s,a,u,p,g,b){this.currSandbox._$_parentProperty=b,this.currSandbox._$_parent=g,this.currSandbox._$_property=u,this.currSandbox._$_root=this.json,this.currSandbox._$_v=a;let k=s.includes("@path");k&&(this.currSandbox._$_path=o_.toPathString(p.concat([u])));let N="script:"+s;if(!o_.cache[N]){let M=s.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");k&&(M=M.replace(/@path/gu,"_$_path")),o_.cache[N]=new this.vm.Script(M)}try{return o_.cache[N].runInNewContext(this.currSandbox)}catch(M){throw new Error("jsonPath: "+M.message+": "+s)}};o_.cache={};o_.toPathString=function(s){let a=s,u=a.length,p="$";for(let g=1;g<u;g++)/^(~|\^|@.*?\(\))$/u.test(a[g])||(p+=/^[0-9*]+$/u.test(a[g])?"["+a[g]+"]":"['"+a[g]+"']");return p};o_.toPointer=function(s){let a=s,u=a.length,p="";for(let g=1;g<u;g++)/^(~|\^|@.*?\(\))$/u.test(a[g])||(p+="/"+a[g].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return p};o_.toPathArray=function(s){let{cache:a}=o_;if(a[s])return a[s].concat();let u=[],g=s.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(b,k){return"[#"+(u.push(k)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(b,k){return"['"+k.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(b,k){return";"+k.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(b){let k=b.match(/#(\d+)/u);return!k||!k[1]?b:u[k[1]]});return a[s]=g,a[s].concat()};o_.prototype.vm=Qnr;import eir from"fs/promises";import tir from"path";var Qlt=t(async function({outputDirectory:s,logger:a}){return Fu.timeFn("Verify Worker output",async()=>{a.debug("Verify Worker output");let u=tir.join(s,"worker.js");try{if(await pc.fileExists(u)){let p=await eir.readFile(u,"utf-8"),g=await Znr(p,{syntax:"ecmascript"}),b=o_({path:"$..callee[?(@property === 'value' && (@ === 'Function'|| @ === 'eval'))]^",json:g.body});if(b&&b.length>0)return{warnings:[{message:"We do not support the use of 'eval' or 'new Function(...)'",severity:"warning",pluginName:"verify-worker-output"}],errors:[]}}}catch(p){a.error(p);let g={message:`Error validating build output : ${p.message}`,severity:"error",pluginName:"verify-worker-output"};return{warnings:[],errors:[g]}}return{warnings:[],errors:[]}})},"verifyWorkerOutput");import*as Zvt from"esbuild";import{randomUUID as rir}from"crypto";var KN=class{static{t(this,"CompilerResult")}buildId;buildTime;buildTimeMs;errors;warnings;status;assets;metafile;constructor(a,u){this.buildId=u?.buildId??rir(),this.buildTime=u?.startBuildTime.toISOString(),this.buildTimeMs=u?.endBuildTime.getTime()-u?.startBuildTime.getTime(),this.errors=a.errors.map(p=>({message:p.text,severity:qW,...p})),this.warnings=a.warnings.map(p=>({message:p.text,severity:zW,...p})),a.metafile&&(this.metafile=a.metafile),this.status=_O,this.warnings&&this.warnings.length>0&&(this.status=jR),this.errors&&this.errors.length>0&&(this.status=Wv)}};var nir=!1;function lM(s,a){return{open:`\x1B[${s.join(";")}m`,close:`\x1B[${a}m`,regexp:new RegExp(`\\x1b\\[${a}m`,"g")}}t(lM,"code");function uM(s,a){return nir?`${a.open}${s.replace(a.regexp,a.open)}${a.close}`:s}t(uM,"run");function iir(s){return uM(s,lM([31],39))}t(iir,"red");function sir(s){return uM(s,lM([32],39))}t(sir,"green");function air(s){return uM(s,lM([33],39))}t(air,"yellow");function oir(s){return uM(s,lM([34],39))}t(oir,"blue");function cir(s){return uM(s,lM([35],39))}t(cir,"magenta");function lir(s){return uM(s,lM([36],39))}t(lir,"cyan");var xFr=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 Zlt=[iir,sir,air,oir,cir,lir];function uir(s){let a=0,u=s.length,p=0;if(u>0)for(;p<u;)a=(a<<5)-a+s.charCodeAt(p++)|0;return a}t(uir,"hashCode");function eut(s){let a=Math.abs(uir(s));return Zlt[a%Zlt.length]}t(eut,"generateColor");import{inspect as fir}from"util";function tut(s,a,...u){let p=0,g=u.length,b=String(a).replace(/%[sdjoO%]/g,k=>{if(k==="%%")return"%";if(p>=g)return k;switch(k){case"%s":return String(u[p++]);case"%d":return Number(u[p++]).toString();case"%o":return s(u[p++]).split(`
|
|
698
698
|
`).map(N=>N.trim()).join(" ");case"%O":return s(u[p++]);case"%j":try{return JSON.stringify(u[p++])}catch{return"[Circular]"}default:return k}});for(let k of u.splice(p))k===null||!(typeof k=="object"&&k!==null)?b+=" "+k:b+=" "+s(k);return b}t(tut,"format");var rut=t((s,...a)=>tut(fir,s,a),"format");var r4e=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(a,u){this.manager=a,this.ns=u,this.color=eut(u),this.last=0,this.enabled=a.enabled.some(p=>p.test(u))}log(...a){if(!this.enabled)return;let u,p=a[0];typeof p=="function"?u=p():u=String(p);let g=Date.now()-(this.last||Date.now());u=rut(u,...a);let b=`${this.color(this.ns)} ${u} ${this.color(`+${g}ms`)}`;console.log(b),this.last=Date.now()}},n4e=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(a){this.debuggers=new Map,this.enabled=a??[]}};function _ir(s){return!s||s.length===0?[]:(s=s.replace(/\s/g,"").replace(/\*/g,".+"),s.split(",").map(a=>new RegExp(`^${a}$`)))}t(_ir,"extract");var qce;function nut(s){qce||(qce=new n4e(_ir(process.env.DEBUG)));let a=new r4e(qce,s);return qce.debuggers.set(s,a),Object.assign(a.log.bind(a),{self:a})}t(nut,"debug");import Nfe,{dirname as Kvt}from"path";import{fileURLToPath as Yvt}from"url";var i4e="no-remote-module";function iut({logger:s}){return{name:i4e,async setup(a){a.onResolve({filter:/^https?:\/\//},u=>(s.error(u,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${u.path}`,detail:"InvalidRemoteModule",pluginName:i4e,location:{line:0,column:0,file:""}}],pluginName:i4e}))}}}t(iut,"blockRemoteModulePlugin");import sut from"fs/promises";import zce from"path";import pir from"prettier";var aut="/docs",dir="/__zuplo/dev-portal";function mir(s){let a=s.trim().toLowerCase();return a.endsWith("/")&&(a=a.slice(0,-1)),a}t(mir,"normalizePathname");function hir(s){let a={sitePathname:s?.sitePathname===dir?aut:s?.sitePathname?mir(s.sitePathname):aut,enabled:s?s.enabled??!0:!1};return`const devPortal = ${JSON.stringify(a)};
|
|
699
699
|
export default devPortal;`}t(hir,"generateSource");function out(s){return{name:"dev-portal-config",setup(a){a.onResolve({filter:/dev-portal.json$/},u=>({namespace:"dev-portal-json",path:zce.isAbsolute(u.path)?u.path:zce.join(u.resolveDir,u.path),pluginName:"dev-portal"})),a.onLoad({filter:/.*/,namespace:"dev-portal-json"},async u=>Fu.timeFn("Generating dev-portal.json data",async()=>{let p,g,b=[];if(await pc.fileExists(u.path)){g=await sut.readFile(u.path,"utf-8");try{p=JSON.parse(g)}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 k;try{if(k=hir(p),Lm.DEBUG_BUILD_MODE&&k&&await pc.dirExists(s.sourceDirectory)){let N=await pir.format(k,{parser:"babel"});await sut.writeFile(zce.join(s.sourceDirectory,NN,"dev-portal.js"),N)}if(b&&b.length>0)throw b}catch(N){N.length>0?N.forEach(M=>{let U={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}]};b.push(U)}):b.push({id:"dev-portal-build-error",text:N.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:N.message,location:null}]})}return{contents:k,errors:b,pluginName:"dev-portal",loader:"js",resolveDir:zce.dirname(u.path),watchFiles:[u.path]}}))}}}t(out,"devPortalConfigPlugin");import cut from"path";var lut="legacy-environment",uut="legacy-environment",gir=`import { environment } from "@zuplo/runtime";
|
|
@@ -706,21 +706,23 @@ export default environment;`;function fut(s){return{name:"environment",setup(a){
|
|
|
706
706
|
}`}t(O0t,"buildRewriteFunction");var ij="x-zuplo-path",sj="x-zuplo-route",b7e="url-pattern",Vue="open-api";var $vr=R0t.default.compile(`
|
|
707
707
|
import { environment } from "@zuplo/runtime";
|
|
708
708
|
import rawRouteData from "./raw.json";
|
|
709
|
-
{
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
709
|
+
const routes = async () => {
|
|
710
|
+
{{#each imports}}
|
|
711
|
+
const {{{name}}} = await import("{{{path}}}");
|
|
712
|
+
{{/each}}
|
|
713
|
+
return {
|
|
714
|
+
routes: [
|
|
715
|
+
{{#each routes}}
|
|
716
|
+
{{{this}}},
|
|
717
|
+
{{/each}}
|
|
718
|
+
],
|
|
719
|
+
{{{policies}}},
|
|
720
|
+
{{{corsPolicies}}},
|
|
721
|
+
versions: [
|
|
722
|
+
{ name: "none", pathPrefix: "" },
|
|
723
|
+
],
|
|
724
|
+
};
|
|
725
|
+
}
|
|
724
726
|
export default routes;
|
|
725
727
|
`);async function x7e(s,a){let u=[],p=[],g=[],b=new zue,k=new Uue,N=JSON.parse(a.content),M=k.validate(N);if(!M.isValid)return{content:"",errors:[{text:JSON.stringify(M.errors),location:{line:0,column:0,file:"/config/policies.json"}}]};let U=new dG().parse(JSON.stringify(N)),Q=[],te=[],z=new mG,Se,Me,xe=U.children.find(er=>er.name.value==="policies");if(xe){let er=b.transform(xe);Se=z.generate(er),Q=N.policies.map(({name:fn})=>fn)}let Le=U.children.find(er=>er.name.value==="corsPolicies");if(Le){let er=b.transform(Le);Me=z.generate(er),te=N.corsPolicies.map(({name:fn})=>fn)}let kt=[];for(let er=0;er<s.length;er++){let fn=[],mr=s[er],tr=pG(mr.content,fn);if(fn.length>0)return{content:"",errors:fn.map(Ma=>({text:Uvr(Ma.error),location:{file:mr.fileName,line:Ma.line,column:Ma.column}}))};if(tr){kt.push(tr);let Ma=GG(tr,["paths"]);if(Ma&&Ma.children){for(let fi of Ma.children)if(fi.children){let jl=Wue(fi),Bu=jl[ij]?.pathMode;if(Bu){if(Bu!==Vue&&Bu!==b7e)return{content:"",errors:[{text:`Unknown path mode ${Bu}`,location:{line:0,column:0,file:mr.fileName}}]}}else Bu=Vue;for(let[sl,$n]of Object.entries(jl))if(sl!==ij){let wy=sl,H_=$n,Nr=H_[sj];if(Nr){let ac=new $ue().validate(Nr);if(ac.isValid){let Uu=S7e(fi),ya=F0t(fi,[Uu,wy,sj]),IS=await Yvr(ya,mr);if(!IS.valid)return{content:"",errors:[{text:IS.errorMsg??`Unknown error on handler for path '${Uu}'`,location:{line:IS.line??0,column:IS.column??0,file:mr.fileName}}]};let ew=Qvr(ya,mr);if(!ew.valid)return{content:"",errors:ew.errors};ew.warnings&&g.push(...ew.warnings),u.push({path:Uu,pathPattern:Uu,pathMode:Bu,httpMethod:wy,rawOpenAPI:H_,config:F0t(fi,[Uu,wy,sj])})}else return{content:"",errors:[{text:JSON.stringify(ac.errors),location:{line:0,column:0,file:mr.fileName}}]}}else{let Jm=S7e(fi),ac={corsPolicy:"none",handler:Kvr(Jm,tr)};u.push({path:Jm,pathPattern:Jm,pathMode:Vue,rawOpenAPI:H_,httpMethod:wy,config:pG(JSON.stringify(ac))})}}}}}let kr=[];for(let Ma=0;Ma<s.length;Ma++){let fi=s[Ma],jl=kt.at(Ma);if(jl){let Bu=GG(jl,["paths"]);if(Bu&&Bu.children){for(let sl of Bu.children)if(sl.children){let $n=Wue(sl);for(let[wy,H_]of Object.entries($n))if(wy!==ij){let Jm=H_[sj];if(Jm&&"policies"in Jm){let ac=Jm.policies;ac.inbound?.forEach(Uu=>{Q.includes(Uu)||kr.push({text:`Policy '${Uu}' does not exist in policies.json. Please add it and rebuild.`,location:{line:$n.line,column:$n.column,file:fi.fileName}})}),ac.outbound?.forEach(Uu=>{Q.includes(Uu)||kr.push({text:`Policy '${Uu}' does not exist in policies.json. Please add it and rebuild.`,location:{line:$n.line,column:$n.column,file:fi.fileName}})})}}}}}}if(kr.length>0)return{content:"",errors:kr};let In=[],ns=["none","anything-goes"];for(let Ma=0;Ma<s.length;Ma++){let fi=s[Ma],jl=kt.at(Ma);if(jl){let Bu=GG(jl,["paths"]);if(Bu&&Bu.children){for(let sl of Bu.children)if(sl.children){let $n=Wue(sl);for(let[wy,H_]of Object.entries($n))if(wy!==ij){let Jm=H_[sj];if(Jm&&"corsPolicy"in Jm){let ac=Jm.corsPolicy;if(ns.includes(ac))continue;te.includes(ac)||In.push({text:`Cors policy '${ac}' does not exist in policies.json. Please add it and rebuild.`,location:{line:$n.line,column:$n.column,file:fi.fileName}})}}}}}}if(In.length>0)return{content:"",errors:In};for(let Ma of u){let fi=new dG().convert(Ma.config);zvr(fi,Ma),Vvr(fi,Ma),Wvr(fi,Ma),Hvr(fi),Gvr(T7e.basename(s[er].fileName,".oas.json"),Ma.path,Ma.httpMethod,fi);let jl=b.transform(fi),Bu=b.errors;if(Bu.length>0)return{content:"",errors:[{text:JSON.stringify(Bu),location:{line:0,column:0,file:mr.fileName}}]};let $n=new mG().generate(jl);p.push($n)}}let Bt=new Map,ur=[];for(let er=0;er<s.length;er++){let fn=s[er],mr=kt.at(er);if(mr){let tr=GG(mr,["paths"]);if(tr&&tr.children){for(let kr of tr.children)if(kr.children){let In=Wue(kr);for(let ns of Object.keys(In)){if(ns===ij)continue;let Ma=ns,fi=S7e(kr),jl=Ma.replace(/\s+/g,"").split(",");if(Bt.has(fi)){let Bu=Bt.get(fi)?.methods??[];jl.forEach(sl=>{Bu?.includes(sl)?ur.push({text:`Cannot have duplicate routes declared. Route '${sl.toUpperCase()} ${fi}' declared more than once.`,location:{line:kr.line,column:kr.column,file:fn.fileName}}):Bu.push(sl)}),Bt.set(fi,{methods:Bu})}else{try{new URLPattern({pathname:fi})}catch{ur.push({text:`Path ${fi} contains invalid characters.`,location:{line:kr.line,column:kr.column,file:fn.fileName}})}Bt.set(fi,{methods:jl})}}}}}}return ur.length>0?{content:"",errors:ur}:{content:$vr({routes:p,imports:b.getImports(),policies:Se??"policies: []",corsPolicies:Me??"corsPolicies: []"}),errors:[],warnings:g}}t(x7e,"compileRoutes");var Jvr=0,qvr=1;function zvr(s,a){let u={type:hc.Property,parent:s,name:null,value:null};u.name={value:"path",type:hc.Identifier,parent:u},u.value=ET.createLiteral(a.path,u),s.children.unshift(u)}t(zvr,"embellishWithPath");function Vvr(s,a){let u={type:hc.Property,parent:s,name:null,value:null};if(u.name={value:"pathPattern",type:hc.Identifier,parent:u},a.pathMode===b7e)u.value=ET.createLiteral(a.path,u);else{let p=/{(\S+?)}/gm,b=a.path.replace(p,":$1");a.path.endsWith("/")||(b=b+"{/}?"),u.value=ET.createLiteral(b,u)}s.children.unshift(u)}t(Vvr,"embellishWithPathPattern");function Wvr(s,a){let u={type:hc.Property,parent:s,name:null,value:null};u.name={value:"methods",type:hc.Identifier,parent:u};let p=a.httpMethod.split(/,/).map(g=>g.trim().toUpperCase());u.value=ET.createArrayOfLiterals(p,u),s.children.unshift(u)}t(Wvr,"embellishWithMethods");function Hvr(s){let a={type:hc.Property,parent:s,name:null,value:null};a.name={value:"version",type:hc.Identifier,parent:a},a.value=ET.createLiteral("none",a),s.children.unshift(a)}t(Hvr,"embellishWithVersion");function Gvr(s,a,u,p){let g={type:hc.Property,parent:p,name:null,value:null};g.name={value:"raw",type:hc.Identifier,parent:p};let b=Bvr(s,a,u);g.value={type:hc.FunctionBody,parent:g,value:`() => {return rawRouteData.${b};}`},p.children.unshift(g)}t(Gvr,"embellishWithRawOpenApi");function Wue(s){return zO(s.type==="property"),zO(Array.isArray(s.children)),Hue(s.children[qvr])}t(Wue,"evaluatePathItem");function S7e(s){return zO(s.type==="property"),zO(Array.isArray(s.children)),Hue(s.children[Jvr])}t(S7e,"evaluatePath");function F0t(s,a){return GG(s.parent,a)}t(F0t,"extractZuploRouteNode");function M0t(s){return Hue(s)}t(M0t,"evaluateZuploRouteNode");function Kvr(s,a){let u=/{(\S+?)}/gm,g=s.replace(u,"${params.$1}"),b=Hue(a);return{export:"urlRewriteHandler",module:"$import(@zuplo/runtime)",options:{rewritePattern:`${b.servers&&b.servers.length>0?b.servers[0].url:"http://example.com"}${g}`,forwardSearch:!0}}}t(Kvr,"addDefaultUrlRewriteHandler");async function Yvr(s,a){let u=M0t(s),p=u.handler.module.replace(/^\$import\(/,"").replace(/\)$/,""),g=T7e.join(T7e.dirname(a.fileName),"..",`${p}.ts`),b=u.handler.export;if(p==="@zuplo/runtime")return{valid:!0};if(await pc.fileExists(g)){let k=await dmt(g);if(k===null)return{valid:!1,errorMsg:`Could not find any export due to a compile error in '${pc.getParentDirFilename(g)}'`};if(!k.has(b)){let N=`Could not find export "${b}" in '${pc.getParentDirFilename(g)}'`,M=0,U=0;if(s.children)for(let Q of s.children)Q.children&&Q.children.forEach(te=>{te.value==="handler"&&(M=te.line,U=te.column)});return{valid:!1,errorMsg:N,line:M,column:U}}return{valid:!0}}else return{valid:!1,errorMsg:`Could not find module '${p}'`}}t(Yvr,"checkModuleIsValid");var L0t=t((s,a)=>{let u=0,p=0;if(s.children)for(let g of s.children)g.children&&g.children.forEach(b=>{b.value==="options"&&b.children?.forEach(k=>{b.value===a&&(u=k.line,p=k.column)})});return{line:u,column:p}},"getHandlerOptionLocation"),Xvr="$env(";function Qvr(s,a){let u=M0t(s),p=u.handler.export;if(p!=="urlForwardHandler"&&p!=="urlRewriteHandler")return{valid:!0};let g="rewritePattern";p==="urlForwardHandler"&&(g="baseUrl");let b=u.handler.options[g];if(!b){let k=L0t(s,g);return{valid:!1,errors:[{text:`Invalid request handler configuration. handler.options.${g} is required but was not provided.`,location:{file:a.fileName,line:k.line,column:k.column}}]}}if(b.includes(Xvr)){let k=L0t(s,g);return{valid:!0,warnings:[{text:`Invalid environment variable access syntax detected. Use \${env.VAR_NAME} instead of $env(VAR_NAME) for handler.options.${g}.`,location:{file:a.fileName,line:k.line,column:k.column}}]}}return{valid:!0}}t(Qvr,"checkHandlerIsValid");import FFe from"fs/promises";import jE from"path";var YG=sm(L1t(),1),j1t=sm(R1t(),1);function M1t(s){let a=s.raw.url??"",u={};try{let p=s.headers["zuplo-user"]??s.user?.sub;p&&(u.userSub=`${p}`);let g=a.match(/(deployments)\/([a-zA-Z-0-9]*)/);g&&g!==null&&g.length>=2&&(u.deployment=g[2]);let b=a.match(/(accounts)\/([a-zA-Z-0-9]*)/);b&&b!==null&&b.length>=2&&(u.account=b[2]);let k=a.match(/(projects)\/([a-zA-Z-0-9]*)/);k&&k!==null&&k.length>=2&&(u.project=k[2])}catch{}return u}t(M1t,"getLoggerContext");var _Fe="logging.googleapis.com/trace",Ixr="logging.googleapis.com/labels",B1t="zuplo-production",ofe=a7();function Oxr(s){return JSON.stringify(s).replace(/^{/,"").replace(/}$/,"")}t(Oxr,"flatJSONString");function Fxr(s,a,u){if(s.length===2&&typeof s[1]=="object"&&s[1]!==null&&(s[0]=`${s[0]} ${JSON.stringify(s[1])}`),s.length>1&&typeof s[0]=="object"&&typeof s[1]=="string"){let g=s[0];g.err instanceof Error&&g.err.stack&&(s[1]=g.err.stack,delete g.err.stack)}let p;try{let g=`{${this?.[YG.pino.symbols.chindingsSym]?.slice(1)||""}}`;if(p=JSON.parse(g),p){if(p.trace&&(p[_Fe]=`projects/${B1t}/traces/${p.trace}`),!p.trace&&p[_Fe]&&delete p[_Fe],u>=50){let N=Error().stack?.split(`
|
|
726
728
|
`).slice(2).filter(M=>!M.includes("node_modules/pino")&&!M.includes("node_modules\\pino")&&!M.includes("node_modules/launchdarkly-node-server-sdk")&&!M.includes("node_modules\\launchdarkly-node-server-sdk"))[0].substr(7);p.caller=N}return p.caller&&u<50&&delete p.caller,this[YG.pino.symbols.chindingsSym]=`,${Oxr(p)}`,a.apply(this,s)}}catch{}return a.apply(this,s)}t(Fxr,"logMethod");function a7({defaultLabels:s={},logStream:a,loggerOptions:u}={}){let p={level:u?.level??process.env.LOG_LEVEL??"info",redact:['requestHeaders["authorization"]','requestHeaders["cookie"]','requestHeaders["cf-access-jwt-assertion"]','requestHeaders["cf-access-client-secret"]','requestHeaders["cf-access-client-id"]','responseHeaders["authorization"]','responseHeaders["cookie"]','responseHeaders["cf-access-jwt-assertion"]','responseHeaders["cf-access-client-secret"]','responseHeaders["cf-access-client-id"]',"cookie"]},g={project_id:B1t};return p.hooks=u?.hooks??{logMethod:Fxr},p.formatters={bindings(b){return g.pid=b.pid,g.hostname=b.hostname,g}},process.env.LOG_FORMAT===void 0||process.env.LOG_FORMAT==="pretty"?p.transport={target:"@zuplo/pino-pretty-configurations"}:process.env.LOG_FORMAT==="gcp"&&(p.messageKey="message",p.formatters={level(b,k){return{severity:Lxr(k)}},log(b){let k=s;if(b.err&&b.err.stack)try{let N=(0,j1t.parse)(b.err.stack);N.length>0&&(b["logging.googleapis.com/sourceLocation"]={file:N[0].file,line:N[0].lineNumber,function:N[0].methodName})}catch{}if(b.req){let N=b.req;b.requestHeaders=N.raw.headers,b.httpRequest={...(b.httpRequest,{requestMethod:N.method,requestUrl:N.url,userAgent:N.headers["user-agent"],remoteIp:N.ip,protocol:N.protocol})};let M=N.headers["zp-rid"]??b.trace;k.requestId=M,N.headers["cf-ray"]&&(k.rayId=N.headers["cf-ray"]),N.headers["cf-worker"]&&(k.worker=N.headers["cf-worker"]);let U=M1t(N);U&&(b={...b,...U})}if(b.res){let N=b.res;b.responseHeaders=N.getHeaders(),b.httpRequest={...(b.httpRequest,{requestMethod:N.request?N.request.method:"",requestUrl:N.request?N.request.url:"",status:N.statusCode,userAgent:N.request?N.request.headers["user-agent"]:"",latency:`${Rxr(N.getResponseTime()/1e3,9)}s`,remoteIp:N.request?N.request.ip:"",protocol:N.request?N.request.protocol:""})}}return b[Ixr]=k,b}},p.serializers={req(b){},res(b){},responseTime:t(function(b){},"responseTime")}),a?(0,YG.pino)(p,a):(0,YG.pino)(p)}t(a7,"createNewLogger");function Lxr(s){return s===10||s===20?"debug":s===30?"info":s===40?"warning":s===50?"error":s===5?"internal":s>=60?"critical":"default"}t(Lxr,"pinoLevelToStackDriverSeverity");function Rxr(s,a){return Math.trunc(s*Math.pow(10,a))/Math.pow(10,a)}t(Rxr,"truncateToDecimalPlace");var avt=sm(Q1t(),1);var QG=t(s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var zxr={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},ZG=t(s=>s.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Vxr=t(s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),Z1t=t(s=>s.join(""),"rangesToString"),evt=t((s,a)=>{let u=a;if(s.charAt(u)!=="[")throw new Error("not in a brace expression");let p=[],g=[],b=u+1,k=!1,N=!1,M=!1,U=!1,Q=u,te="";e:for(;b<s.length;){let xe=s.charAt(b);if((xe==="!"||xe==="^")&&b===u+1){U=!0,b++;continue}if(xe==="]"&&k&&!M){Q=b+1;break}if(k=!0,xe==="\\"&&!M){M=!0,b++;continue}if(xe==="["&&!M){for(let[Le,[kt,Bt,ur]]of Object.entries(zxr))if(s.startsWith(Le,b)){if(te)return["$.",!1,s.length-u,!0];b+=Le.length,ur?g.push(kt):p.push(kt),N=N||Bt;continue e}}if(M=!1,te){xe>te?p.push(ZG(te)+"-"+ZG(xe)):xe===te&&p.push(ZG(xe)),te="",b++;continue}if(s.startsWith("-]",b+1)){p.push(ZG(xe+"-")),b+=2;continue}if(s.startsWith("-",b+1)){te=xe,b+=2;continue}p.push(ZG(xe)),b++}if(Q<b)return["",!1,0,!1];if(!p.length&&!g.length)return["$.",!1,s.length-u,!0];if(g.length===0&&p.length===1&&/^\\?.$/.test(p[0])&&!U){let xe=p[0].length===2?p[0].slice(-1):p[0];return[Vxr(xe),!1,Q-u,!1]}let z="["+(U?"^":"")+Z1t(p)+"]",Se="["+(U?"":"^")+Z1t(g)+"]";return[p.length&&g.length?"("+z+"|"+Se+")":p.length?z:Se,N,Q-u,!0]},"parseClass");var FE=t((s,{windowsPathsNoEscape:a=!1}={})=>a?s.replace(/\[([^\/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),"unescape");var Wxr=new Set(["!","?","+","*","@"]),tvt=t(s=>Wxr.has(s),"isExtglobType"),Hxr="(?!(?:^|/)\\.\\.?(?:$|/))",cfe="(?!\\.)",Gxr=new Set(["[","."]),Kxr=new Set(["..","."]),Yxr=new Set("().*{}+?[]^$\\!"),Xxr=t(s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),mFe="[^/]",rvt=mFe+"*?",nvt=mFe+"+?",cj=class s{static{t(this,"AST")}type;#t;#r;#n=!1;#e=[];#s;#l;#f;#u=!1;#o;#i;#c=!1;constructor(a,u,p={}){this.type=a,a&&(this.#r=!0),this.#s=u,this.#t=this.#s?this.#s.#t:this,this.#o=this.#t===this?p:this.#t.#o,this.#f=this.#t===this?[]:this.#t.#f,a==="!"&&!this.#t.#u&&this.#f.push(this),this.#l=this.#s?this.#s.#e.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let a of this.#e)if(typeof a!="string"&&(a.type||a.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#i!==void 0?this.#i:this.type?this.#i=this.type+"("+this.#e.map(a=>String(a)).join("|")+")":this.#i=this.#e.map(a=>String(a)).join("")}#v(){if(this!==this.#t)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let a;for(;a=this.#f.pop();){if(a.type!=="!")continue;let u=a,p=u.#s;for(;p;){for(let g=u.#l+1;!p.type&&g<p.#e.length;g++)for(let b of a.#e){if(typeof b=="string")throw new Error("string part in extglob AST??");b.copyIn(p.#e[g])}u=p,p=u.#s}}return this}push(...a){for(let u of a)if(u!==""){if(typeof u!="string"&&!(u instanceof s&&u.#s===this))throw new Error("invalid part: "+u);this.#e.push(u)}}toJSON(){let a=this.type===null?this.#e.slice().map(u=>typeof u=="string"?u:u.toJSON()):[this.type,...this.#e.map(u=>u.toJSON())];return this.isStart()&&!this.type&&a.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#u&&this.#s?.type==="!")&&a.push({}),a}isStart(){if(this.#t===this)return!0;if(!this.#s?.isStart())return!1;if(this.#l===0)return!0;let a=this.#s;for(let u=0;u<this.#l;u++){let p=a.#e[u];if(!(p instanceof s&&p.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#s?.type==="!")return!0;if(!this.#s?.isEnd())return!1;if(!this.type)return this.#s?.isEnd();let a=this.#s?this.#s.#e.length:0;return this.#l===a-1}copyIn(a){typeof a=="string"?this.push(a):this.push(a.clone(this))}clone(a){let u=new s(this.type,a);for(let p of this.#e)u.copyIn(p);return u}static#h(a,u,p,g){let b=!1,k=!1,N=-1,M=!1;if(u.type===null){let Se=p,Me="";for(;Se<a.length;){let xe=a.charAt(Se++);if(b||xe==="\\"){b=!b,Me+=xe;continue}if(k){Se===N+1?(xe==="^"||xe==="!")&&(M=!0):xe==="]"&&!(Se===N+2&&M)&&(k=!1),Me+=xe;continue}else if(xe==="["){k=!0,N=Se,M=!1,Me+=xe;continue}if(!g.noext&&tvt(xe)&&a.charAt(Se)==="("){u.push(Me),Me="";let Le=new s(xe,u);Se=s.#h(a,Le,Se,g),u.push(Le);continue}Me+=xe}return u.push(Me),Se}let U=p+1,Q=new s(null,u),te=[],z="";for(;U<a.length;){let Se=a.charAt(U++);if(b||Se==="\\"){b=!b,z+=Se;continue}if(k){U===N+1?(Se==="^"||Se==="!")&&(M=!0):Se==="]"&&!(U===N+2&&M)&&(k=!1),z+=Se;continue}else if(Se==="["){k=!0,N=U,M=!1,z+=Se;continue}if(tvt(Se)&&a.charAt(U)==="("){Q.push(z),z="";let Me=new s(Se,Q);Q.push(Me),U=s.#h(a,Me,U,g);continue}if(Se==="|"){Q.push(z),z="",te.push(Q),Q=new s(null,u);continue}if(Se===")")return z===""&&u.#e.length===0&&(u.#c=!0),Q.push(z),z="",u.push(...te,Q),U;z+=Se}return u.type=null,u.#r=void 0,u.#e=[a.substring(p-1)],U}static fromGlob(a,u={}){let p=new s(null,void 0,u);return s.#h(a,p,0,u),p}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let a=this.toString(),[u,p,g,b]=this.toRegExpSource();if(!(g||this.#r||this.#o.nocase&&!this.#o.nocaseMagicOnly&&a.toUpperCase()!==a.toLowerCase()))return p;let N=(this.#o.nocase?"i":"")+(b?"u":"");return Object.assign(new RegExp(`^${u}$`,N),{_src:u,_glob:a})}toRegExpSource(a){let u=a??!!this.#o.dot;if(this.#t===this&&this.#v(),!this.type){let M=this.isStart()&&this.isEnd(),U=this.#e.map(Se=>{let[Me,xe,Le,kt]=typeof Se=="string"?s.#b(Se,this.#r,M):Se.toRegExpSource(a);return this.#r=this.#r||Le,this.#n=this.#n||kt,Me}).join(""),Q="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Kxr.has(this.#e[0]))){let Me=Gxr,xe=u&&Me.has(U.charAt(0))||U.startsWith("\\.")&&Me.has(U.charAt(2))||U.startsWith("\\.\\.")&&Me.has(U.charAt(4)),Le=!u&&!a&&Me.has(U.charAt(0));Q=xe?Hxr:Le?cfe:""}let te="";return this.isEnd()&&this.#t.#u&&this.#s?.type==="!"&&(te="(?:$|\\/)"),[Q+U+te,FE(U),this.#r=!!this.#r,this.#n]}let p=this.type==="*"||this.type==="+",g=this.type==="!"?"(?:(?!(?:":"(?:",b=this.#p(u);if(this.isStart()&&this.isEnd()&&!b&&this.type!=="!"){let M=this.toString();return this.#e=[M],this.type=null,this.#r=void 0,[M,FE(this.toString()),!1,!1]}let k=!p||a||u||!cfe?"":this.#p(!0);k===b&&(k=""),k&&(b=`(?:${b})(?:${k})*?`);let N="";if(this.type==="!"&&this.#c)N=(this.isStart()&&!u?cfe:"")+nvt;else{let M=this.type==="!"?"))"+(this.isStart()&&!u&&!a?cfe:"")+rvt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&k?")":this.type==="*"&&k?")?":`)${this.type}`;N=g+b+M}return[N,FE(b),this.#r=!!this.#r,this.#n]}#p(a){return this.#e.map(u=>{if(typeof u=="string")throw new Error("string type in extglob ast??");let[p,g,b,k]=u.toRegExpSource(a);return this.#n=this.#n||k,p}).filter(u=>!(this.isStart()&&this.isEnd())||!!u).join("|")}static#b(a,u,p=!1){let g=!1,b="",k=!1;for(let N=0;N<a.length;N++){let M=a.charAt(N);if(g){g=!1,b+=(Yxr.has(M)?"\\":"")+M;continue}if(M==="\\"){N===a.length-1?b+="\\\\":g=!0;continue}if(M==="["){let[U,Q,te,z]=evt(a,N);if(te){b+=U,k=k||Q,N+=te-1,u=u||z;continue}}if(M==="*"){p&&a==="*"?b+=nvt:b+=rvt,u=!0;continue}if(M==="?"){b+=mFe,u=!0;continue}b+=Xxr(M)}return[b,FE(a),!!u,k]}};var lj=t((s,{windowsPathsNoEscape:a=!1}={})=>a?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var F1=t((s,a,u={})=>(QG(a),!u.nocomment&&a.charAt(0)==="#"?!1:new wS(a,u).match(s)),"minimatch"),Qxr=/^\*+([^+@!?\*\[\(]*)$/,Zxr=t(s=>a=>!a.startsWith(".")&&a.endsWith(s),"starDotExtTest"),eEr=t(s=>a=>a.endsWith(s),"starDotExtTestDot"),tEr=t(s=>(s=s.toLowerCase(),a=>!a.startsWith(".")&&a.toLowerCase().endsWith(s)),"starDotExtTestNocase"),rEr=t(s=>(s=s.toLowerCase(),a=>a.toLowerCase().endsWith(s)),"starDotExtTestNocaseDot"),nEr=/^\*+\.\*+$/,iEr=t(s=>!s.startsWith(".")&&s.includes("."),"starDotStarTest"),sEr=t(s=>s!=="."&&s!==".."&&s.includes("."),"starDotStarTestDot"),aEr=/^\.\*+$/,oEr=t(s=>s!=="."&&s!==".."&&s.startsWith("."),"dotStarTest"),cEr=/^\*+$/,lEr=t(s=>s.length!==0&&!s.startsWith("."),"starTest"),uEr=t(s=>s.length!==0&&s!=="."&&s!=="..","starTestDot"),fEr=/^\?+([^+@!?\*\[\(]*)?$/,_Er=t(([s,a=""])=>{let u=ovt([s]);return a?(a=a.toLowerCase(),p=>u(p)&&p.toLowerCase().endsWith(a)):u},"qmarksTestNocase"),pEr=t(([s,a=""])=>{let u=cvt([s]);return a?(a=a.toLowerCase(),p=>u(p)&&p.toLowerCase().endsWith(a)):u},"qmarksTestNocaseDot"),dEr=t(([s,a=""])=>{let u=cvt([s]);return a?p=>u(p)&&p.endsWith(a):u},"qmarksTestDot"),mEr=t(([s,a=""])=>{let u=ovt([s]);return a?p=>u(p)&&p.endsWith(a):u},"qmarksTest"),ovt=t(([s])=>{let a=s.length;return u=>u.length===a&&!u.startsWith(".")},"qmarksTestNoExt"),cvt=t(([s])=>{let a=s.length;return u=>u.length===a&&u!=="."&&u!==".."},"qmarksTestNoExtDot"),lvt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ivt={win32:{sep:"\\"},posix:{sep:"/"}},hEr=lvt==="win32"?ivt.win32.sep:ivt.posix.sep;F1.sep=hEr;var O0=Symbol("globstar **");F1.GLOBSTAR=O0;var gEr="[^/]",yEr=gEr+"*?",vEr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",bEr="(?:(?!(?:\\/|^)\\.).)*?",SEr=t((s,a={})=>u=>F1(u,s,a),"filter");F1.filter=SEr;var NT=t((s,a={})=>Object.assign({},s,a),"ext"),TEr=t(s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return F1;let a=F1;return Object.assign(t((p,g,b={})=>a(p,g,NT(s,b)),"m"),{Minimatch:class extends a.Minimatch{static{t(this,"Minimatch")}constructor(g,b={}){super(g,NT(s,b))}static defaults(g){return a.defaults(NT(s,g)).Minimatch}},AST:class extends a.AST{static{t(this,"AST")}constructor(g,b,k={}){super(g,b,NT(s,k))}static fromGlob(g,b={}){return a.AST.fromGlob(g,NT(s,b))}},unescape:t((p,g={})=>a.unescape(p,NT(s,g)),"unescape"),escape:t((p,g={})=>a.escape(p,NT(s,g)),"escape"),filter:t((p,g={})=>a.filter(p,NT(s,g)),"filter"),defaults:t(p=>a.defaults(NT(s,p)),"defaults"),makeRe:t((p,g={})=>a.makeRe(p,NT(s,g)),"makeRe"),braceExpand:t((p,g={})=>a.braceExpand(p,NT(s,g)),"braceExpand"),match:t((p,g,b={})=>a.match(p,g,NT(s,b)),"match"),sep:a.sep,GLOBSTAR:O0})},"defaults");F1.defaults=TEr;var uvt=t((s,a={})=>(QG(s),a.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:(0,avt.default)(s)),"braceExpand");F1.braceExpand=uvt;var xEr=t((s,a={})=>new wS(s,a).makeRe(),"makeRe");F1.makeRe=xEr;var EEr=t((s,a,u={})=>{let p=new wS(a,u);return s=s.filter(g=>p.match(g)),p.options.nonull&&!s.length&&s.push(a),s},"match");F1.match=EEr;var svt=/[?*]|[+@!]\(.*?\)|\[|\]/,CEr=t(s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),wS=class{static{t(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(a,u={}){QG(a),u=u||{},this.options=u,this.pattern=a,this.platform=u.platform||lvt,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!u.windowsPathsNoEscape||u.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!u.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!u.nonegate,this.comment=!1,this.empty=!1,this.partial=!!u.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=u.windowsNoMagicRoot!==void 0?u.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let a of this.set)for(let u of a)if(typeof u!="string")return!0;return!1}debug(...a){}make(){let a=this.pattern,u=this.options;if(!u.nocomment&&a.charAt(0)==="#"){this.comment=!0;return}if(!a){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],u.debug&&(this.debug=(...b)=>console.error(...b)),this.debug(this.pattern,this.globSet);let p=this.globSet.map(b=>this.slashSplit(b));this.globParts=this.preprocess(p),this.debug(this.pattern,this.globParts);let g=this.globParts.map((b,k,N)=>{if(this.isWindows&&this.windowsNoMagicRoot){let M=b[0]===""&&b[1]===""&&(b[2]==="?"||!svt.test(b[2]))&&!svt.test(b[3]),U=/^[a-z]:/i.test(b[0]);if(M)return[...b.slice(0,4),...b.slice(4).map(Q=>this.parse(Q))];if(U)return[b[0],...b.slice(1).map(Q=>this.parse(Q))]}return b.map(M=>this.parse(M))});if(this.debug(this.pattern,g),this.set=g.filter(b=>b.indexOf(!1)===-1),this.isWindows)for(let b=0;b<this.set.length;b++){let k=this.set[b];k[0]===""&&k[1]===""&&this.globParts[b][2]==="?"&&typeof k[3]=="string"&&/^[a-z]:$/i.test(k[3])&&(k[2]="?")}this.debug(this.pattern,this.set)}preprocess(a){if(this.options.noglobstar)for(let p=0;p<a.length;p++)for(let g=0;g<a[p].length;g++)a[p][g]==="**"&&(a[p][g]="*");let{optimizationLevel:u=1}=this.options;return u>=2?(a=this.firstPhasePreProcess(a),a=this.secondPhasePreProcess(a)):u>=1?a=this.levelOneOptimize(a):a=this.adjascentGlobstarOptimize(a),a}adjascentGlobstarOptimize(a){return a.map(u=>{let p=-1;for(;(p=u.indexOf("**",p+1))!==-1;){let g=p;for(;u[g+1]==="**";)g++;g!==p&&u.splice(p,g-p)}return u})}levelOneOptimize(a){return a.map(u=>(u=u.reduce((p,g)=>{let b=p[p.length-1];return g==="**"&&b==="**"?p:g===".."&&b&&b!==".."&&b!=="."&&b!=="**"?(p.pop(),p):(p.push(g),p)},[]),u.length===0?[""]:u))}levelTwoFileOptimize(a){Array.isArray(a)||(a=this.slashSplit(a));let u=!1;do{if(u=!1,!this.preserveMultipleSlashes){for(let g=1;g<a.length-1;g++){let b=a[g];g===1&&b===""&&a[0]===""||(b==="."||b==="")&&(u=!0,a.splice(g,1),g--)}a[0]==="."&&a.length===2&&(a[1]==="."||a[1]==="")&&(u=!0,a.pop())}let p=0;for(;(p=a.indexOf("..",p+1))!==-1;){let g=a[p-1];g&&g!=="."&&g!==".."&&g!=="**"&&(u=!0,a.splice(p-1,2),p-=2)}}while(u);return a.length===0?[""]:a}firstPhasePreProcess(a){let u=!1;do{u=!1;for(let p of a){let g=-1;for(;(g=p.indexOf("**",g+1))!==-1;){let k=g;for(;p[k+1]==="**";)k++;k>g&&p.splice(g+1,k-g);let N=p[g+1],M=p[g+2],U=p[g+3];if(N!==".."||!M||M==="."||M===".."||!U||U==="."||U==="..")continue;u=!0,p.splice(g,1);let Q=p.slice(0);Q[g]="**",a.push(Q),g--}if(!this.preserveMultipleSlashes){for(let k=1;k<p.length-1;k++){let N=p[k];k===1&&N===""&&p[0]===""||(N==="."||N==="")&&(u=!0,p.splice(k,1),k--)}p[0]==="."&&p.length===2&&(p[1]==="."||p[1]==="")&&(u=!0,p.pop())}let b=0;for(;(b=p.indexOf("..",b+1))!==-1;){let k=p[b-1];if(k&&k!=="."&&k!==".."&&k!=="**"){u=!0;let M=b===1&&p[b+1]==="**"?["."]:[];p.splice(b-1,2,...M),p.length===0&&p.push(""),b-=2}}}}while(u);return a}secondPhasePreProcess(a){for(let u=0;u<a.length-1;u++)for(let p=u+1;p<a.length;p++){let g=this.partsMatch(a[u],a[p],!this.preserveMultipleSlashes);g&&(a[u]=g,a[p]=[])}return a.filter(u=>u.length)}partsMatch(a,u,p=!1){let g=0,b=0,k=[],N="";for(;g<a.length&&b<u.length;)if(a[g]===u[b])k.push(N==="b"?u[b]:a[g]),g++,b++;else if(p&&a[g]==="**"&&u[b]===a[g+1])k.push(a[g]),g++;else if(p&&u[b]==="**"&&a[g]===u[b+1])k.push(u[b]),b++;else if(a[g]==="*"&&u[b]&&(this.options.dot||!u[b].startsWith("."))&&u[b]!=="**"){if(N==="b")return!1;N="a",k.push(a[g]),g++,b++}else if(u[b]==="*"&&a[g]&&(this.options.dot||!a[g].startsWith("."))&&a[g]!=="**"){if(N==="a")return!1;N="b",k.push(u[b]),g++,b++}else return!1;return a.length===u.length&&k}parseNegate(){if(this.nonegate)return;let a=this.pattern,u=!1,p=0;for(let g=0;g<a.length&&a.charAt(g)==="!";g++)u=!u,p++;p&&(this.pattern=a.slice(p)),this.negate=u}matchOne(a,u,p=!1){let g=this.options;if(this.isWindows){let xe=typeof a[0]=="string"&&/^[a-z]:$/i.test(a[0]),Le=!xe&&a[0]===""&&a[1]===""&&a[2]==="?"&&/^[a-z]:$/i.test(a[3]),kt=typeof u[0]=="string"&&/^[a-z]:$/i.test(u[0]),Bt=!kt&&u[0]===""&&u[1]===""&&u[2]==="?"&&typeof u[3]=="string"&&/^[a-z]:$/i.test(u[3]),ur=Le?3:xe?0:void 0,Sr=Bt?3:kt?0:void 0;if(typeof ur=="number"&&typeof Sr=="number"){let[er,fn]=[a[ur],u[Sr]];er.toLowerCase()===fn.toLowerCase()&&(u[Sr]=er,Sr>ur?u=u.slice(Sr):ur>Sr&&(a=a.slice(ur)))}}let{optimizationLevel:b=1}=this.options;b>=2&&(a=this.levelTwoFileOptimize(a)),this.debug("matchOne",this,{file:a,pattern:u}),this.debug("matchOne",a.length,u.length);for(var k=0,N=0,M=a.length,U=u.length;k<M&&N<U;k++,N++){this.debug("matchOne loop");var Q=u[N],te=a[k];if(this.debug(u,Q,te),Q===!1)return!1;if(Q===O0){this.debug("GLOBSTAR",[u,Q,te]);var z=k,Se=N+1;if(Se===U){for(this.debug("** at the end");k<M;k++)if(a[k]==="."||a[k]===".."||!g.dot&&a[k].charAt(0)===".")return!1;return!0}for(;z<M;){var Me=a[z];if(this.debug(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2431.0",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"exports": {
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@swc/core": "^1.7.6",
|
|
37
37
|
"@swc/helpers": "^0.5.12",
|
|
38
|
-
"@zuplo/runtime": "5.
|
|
38
|
+
"@zuplo/runtime": "5.2431.0",
|
|
39
39
|
"chokidar": "^3.5.3",
|
|
40
40
|
"esbuild": "0.23.0",
|
|
41
41
|
"jsonc-parser": "^3.2.0",
|
|
42
42
|
"prettier": "^3.3.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@zuplo/graphql": "5.
|
|
46
|
-
"@zuplo/otel": "5.
|
|
47
|
-
"@zuplo/runtime": "5.
|
|
45
|
+
"@zuplo/graphql": "5.2431.0",
|
|
46
|
+
"@zuplo/otel": "5.2431.0",
|
|
47
|
+
"@zuplo/runtime": "5.2431.0"
|
|
48
48
|
}
|
|
49
49
|
}
|