@squiz/component-cli-lib 1.12.0-alpha.23 → 1.12.0-alpha.26

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.
@@ -2,38 +2,38 @@
2
2
  1 info using npm@8.19.3
3
3
  2 info using node@v16.19.0
4
4
  3 timing npm:load:whichnode Completed in 0ms
5
- 4 timing config:load:defaults Completed in 2ms
5
+ 4 timing config:load:defaults Completed in 4ms
6
6
  5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
7
- 6 timing config:load:builtin Completed in 1ms
7
+ 6 timing config:load:builtin Completed in 2ms
8
8
  7 timing config:load:cli Completed in 2ms
9
- 8 timing config:load:env Completed in 1ms
9
+ 8 timing config:load:env Completed in 2ms
10
10
  9 info found workspace root at /builds/developer-experience/cmp
11
11
  10 timing config:load:file:/builds/developer-experience/cmp/.npmrc Completed in 0ms
12
- 11 timing config:load:project Completed in 24ms
12
+ 11 timing config:load:project Completed in 35ms
13
13
  12 timing config:load:file:/root/.npmrc Completed in 1ms
14
- 13 timing config:load:user Completed in 1ms
14
+ 13 timing config:load:user Completed in 2ms
15
15
  14 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
16
16
  15 timing config:load:global Completed in 0ms
17
17
  16 timing config:load:validate Completed in 1ms
18
- 17 timing config:load:credentials Completed in 1ms
18
+ 17 timing config:load:credentials Completed in 2ms
19
19
  18 timing config:load:setEnvs Completed in 1ms
20
- 19 timing config:load Completed in 35ms
21
- 20 timing npm:load:configload Completed in 35ms
20
+ 19 timing config:load Completed in 52ms
21
+ 20 timing npm:load:configload Completed in 52ms
22
22
  21 timing npm:load:mkdirpcache Completed in 1ms
23
23
  22 timing npm:load:mkdirplogs Completed in 1ms
24
24
  23 verbose title npm run compile
25
25
  24 verbose argv "run" "compile" "--"
26
- 25 timing npm:load:setTitle Completed in 1ms
27
- 26 timing config:load:flatten Completed in 3ms
28
- 27 timing npm:load:display Completed in 5ms
26
+ 25 timing npm:load:setTitle Completed in 2ms
27
+ 26 timing config:load:flatten Completed in 5ms
28
+ 27 timing npm:load:display Completed in 7ms
29
29
  28 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/component-cli-lib/.npm/_logs
30
- 29 verbose logfile /builds/developer-experience/cmp/packages/component-cli-lib/.npm/_logs/2023-02-10T05_40_20_510Z-debug-0.log
31
- 30 timing npm:load:logFile Completed in 4ms
30
+ 29 verbose logfile /builds/developer-experience/cmp/packages/component-cli-lib/.npm/_logs/2023-02-13T05_00_15_007Z-debug-0.log
31
+ 30 timing npm:load:logFile Completed in 5ms
32
32
  31 timing npm:load:timers Completed in 0ms
33
33
  32 timing npm:load:configScope Completed in 0ms
34
- 33 timing npm:load Completed in 49ms
34
+ 33 timing npm:load Completed in 70ms
35
35
  34 silly logfile done cleaning log files
36
- 35 timing command:run Completed in 4782ms
36
+ 35 timing command:run Completed in 6899ms
37
37
  36 verbose exit 0
38
- 37 timing npm Completed in 4839ms
38
+ 37 timing npm Completed in 6980ms
39
39
  38 info ok
package/lib/index.js CHANGED
@@ -227,7 +227,7 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
227
227
  JOIN component_set_component_version as cscv ON
228
228
  cv.component_name = cscv.component_name AND
229
229
  cv.version = cscv.component_version
230
- WHERE cscv.component_set_web_path=$1 ${n}`;return(await this.executeQueryRaw(i,[t])).map(o=>({componentName:o.component_name,version:o.version,displayName:o.display_name,description:o.description,icon:o.icon?o.icon:void 0,environmentVariables:o.env_vars}))}async getComponentByNameAndVersion(t,r){return await this.findOne({componentName:t,version:r})}async componentVersionExists(t,r){return await this.getComponentByNameAndVersion(t,r)!=null}async addComponentVersion(t,r,n,i,s){if(_ze.test(r)===!1)throw new Error("ComponentVersion does not follow the semver convention. Component version must be in the form of major.minor.patch");return await this.create({componentName:t,version:r,description:i||"",displayName:n||"",icon:s})}};lE.ComponentVersionRepository=xT});var PT=y(uE=>{"use strict";Object.defineProperty(uE,"__esModule",{value:!0});uE.createComponentRepositories=void 0;var vze=XC(),gze=tT(),yze=RK(),Sze=ET(),wze=AT();function Eze(e){return{component:new Sze.ComponentRepository(e),componentVersion:new wze.ComponentVersionRepository(e),componentSet:new gze.ComponentSetRepository(e),componentSetComponentVersion:new vze.ComponentSetComponentVersionRepository(e),componentSetRule:new yze.ComponentSetRuleRepository(e)}}uE.createComponentRepositories=Eze});var AK=y(IT=>{"use strict";Object.defineProperty(IT,"__esModule",{value:!0});IT.default=["20220704054051_initial.sql","20220718172237_adding_component_sets.sql","20220728113941_add_env_vars_field.sql","20220817113300_removing_null_props_from_jsonb.sql","20223525103556_component_set_rule.sql","20221027151225_dummy.sql","20221117151200_add_detail_columns_to_component_version.js","20221220151200_add_required_to_manifests.js","20221222151200_add_required_to_manifests.js","20230111095522_update_environment_property.js","20230203084900_ensure_static_root_exists.js"]});var IK=y(cl=>{"use strict";var bze=cl&&cl.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(cl,"__esModule",{value:!0});cl.createConnectionManager=void 0;var PK=qa(),Rze=PT(),xze=bze(AK());async function Aze(e,t,r){let n=await(0,PK.getConnectionInfo)(t);return new PK.ConnectionManager(e,n,r,xze.default,Rze.createComponentRepositories)}cl.createConnectionManager=Aze});var CK=y(Ls=>{"use strict";var Pze=Ls&&Ls.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),CT=Ls&&Ls.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Pze(t,e,r)};Object.defineProperty(Ls,"__esModule",{value:!0});CT(PH(),Ls);CT(PT(),Ls);CT(IK(),Ls)});var pE=y(dE=>{"use strict";Object.defineProperty(dE,"__esModule",{value:!0});dE.AbstractComponentSetService=void 0;var TT=class{getComponentRuntimeHeaders(t,r){var n,i;let s=(n=r.output.headers)!==null&&n!==void 0?n:{},o=(i=t.headers)!==null&&i!==void 0?i:{};return{...s,...o}}};dE.AbstractComponentSetService=TT});var TK=y(fE=>{"use strict";Object.defineProperty(fE,"__esModule",{value:!0});fE.ComponentSetServiceForLocalDev=void 0;var ll=Jt(),Ize=pE(),OT=class extends Ize.AbstractComponentSetService{constructor(t){super(),this.logger=t}async updateComponentSet(){throw new ll.MethodNotImplementedError("updateComponentSet is not implemented for local development")}async getAllComponentSets(){throw new ll.MethodNotImplementedError("getAllComponentSets is not implemented for local development")}async addComponentSet(){throw new ll.MethodNotImplementedError("addComponentSet is not implemented for local development")}async deleteComponentSet(){throw new ll.MethodNotImplementedError("deleteComponentSet is not implemented for local development")}addComponentToSet(t,r,n){throw new ll.MethodNotImplementedError("addComponentToSet is not implemented for local development")}async getPaginatedComponentSets(t=1,r=[],n="asc"){throw new ll.MethodNotImplementedError("getPaginatedComponentSets is not implemented for local development")}async getComponentSetWebModel(t){return{webPath:t,displayName:"set",description:"debug set",environmentVariables:process.env,headers:{},components:{},componentVersionRules:{}}}async getComponentSet(t){return{webPath:t,displayName:"set",description:"debug set",environmentVariables:process.env,headers:{}}}async getComponentsRuntimeSetData(t,r){let n={},i=t.getModel().environment||[],s=[];for(let o of i)r.environmentVariables[o.name]===void 0?o.required!==!1&&s.push(o.name):n[o.name]=r.environmentVariables[o.name];if(s.length>0)throw new Error(`Missing required environment variables: "${s.join('","')}"`);return{environment:n,displayName:r.displayName,webPath:r.webPath}}async componentVersionInSet(t,r){return!0}};fE.ComponentSetServiceForLocalDev=OT});var qK=y(mE=>{"use strict";Object.defineProperty(mE,"__esModule",{value:!0});mE.ComponentSetServiceForProduction=void 0;var sr=Jt(),Cze=V0(),Tze=pE(),OK=o0(),NT=vT(),NK=iE(),qT=class extends Tze.AbstractComponentSetService{constructor(t,r,n){super(),this.db=t,this.logger=r,this.manifestService=n}async getComponentSet(t){let r=await this.db.repositories.componentSet.findOne({webPath:t});if(!r)throw new sr.ResourceNotFoundError(`component set ${t} could not be found`);return r}async addComponentSet(t){await this.assertValidCreateComponentSet(t);try{let r=await this.db.executeInTransaction(async i=>{var s;let o=await this.db.repositories.componentSet.create(new Cze.ComponentSet({webPath:t.webPath,displayName:t.displayName,description:t.description,environmentVariables:t.environmentVariables,headers:t.headers}),i);await this.saveComponentSetComponents(t.webPath,t.components,i);for(let[a,c]of Object.entries((s=t.componentVersionRules)!==null&&s!==void 0?s:{}))await this.db.repositories.componentSetRule.create(new NT.ComponentSetRule({componentSet:t.webPath,componentName:a,versionPattern:c}),i);return o});return await this.getComponentSetWebModel(r.webPath)}catch(r){throw this.logger.error(`Error occurred when updating component set ${t.webPath}: ${r}`),r}}async updateComponentSet(t,r){var n;let i=await this.db.repositories.componentSet.getComponentSetByWebPath(t);if(!i)throw new sr.ResourceNotFoundError(`Component set with web path ${t} does not exist`);let s=await this.db.repositories.componentSetRule.getComponentSetRulesForSet(t);await this.assertValidComponentSet(r,this.normalise(i,{components:await this.getExistingComponentsForWeb(t),componentVersionRules:s})),this.assertValidcomponentVersionRules(t,r.componentVersionRules),this.assertComponentVersionsMatchRules(r.components,(n=r.componentVersionRules)!==null&&n!==void 0?n:s);let o={};r.displayName!==void 0&&(o.displayName=r.displayName),r.description!==void 0&&(o.description=r.description),r.headers!==void 0&&(o.headers=r.headers),r.environmentVariables!==void 0&&(o.environmentVariables=r.environmentVariables);try{return await this.db.executeInTransaction(async a=>{Object.keys(o).length>0&&await this.db.repositories.componentSet.update({webPath:t},o,a),r.components!==void 0&&await this.saveComponentSetComponents(t,r.components,a),r.componentVersionRules&&(await this.updateComponentVersionRules(t,r.componentVersionRules,a),await this.updateComponentVisibility(t,r.componentVersionRules,a))}),this.getComponentSetWebModel(t)}catch(a){throw this.logger.error(`Error occurred when updating component set ${t}: ${a}`),a}}async getComponentsRuntimeSetData(t,r){var n;let i={},s=t.getModel().environment||[],o=await this.db.repositories.componentSetComponentVersion.findOne({componentName:t.getName(),componentVersion:t.getVersion(),componentSetWebPath:r.webPath});if(!o)throw new sr.ResourceNotFoundError(`component ${t.getName()} ${t.getVersion} couldn't not be found in set ${r.webPath}`);let a=[];for(let c of s)r.environmentVariables[c.name]===void 0?c.required!==!1&&a.push(c.name):i[c.name]=(n=o.environmentVariables[c.name])!==null&&n!==void 0?n:r.environmentVariables[c.name];if(a.length>0)throw new sr.BadRequestError(`Missing required environment variables: "${a.join('","')}"`);return{environment:i,displayName:r.displayName,webPath:r.webPath}}async updateComponentVisibility(t,r,n){let s=(await this.db.repositories.componentSetComponentVersion.find({componentSetWebPath:t})).map(o=>this.db.repositories.componentSetComponentVersion.update(o,{isVisible:(0,NK.satisfies)(o.componentVersion,r[o.componentName]||"*")},n));return await Promise.all(s)}async updateComponentVersionRules(t,r,n){await this.db.repositories.componentSetRule.removeExistingRulesForComponentSet(t);for(let[i,s]of Object.entries(r))await this.db.repositories.componentSetRule.create(new NT.ComponentSetRule({componentSet:t,componentName:i,versionPattern:s}),n)}async getComponentSetWebModel(t,r="visible-only"){let n=await this.db.repositories.componentSet.getComponentSetByWebPath(t);if(n===void 0)throw new sr.ResourceNotFoundError(`Component set with web path ${t} does not exist`);return this.normalise(n,{components:await this.getExistingComponentsForWeb(t,r),componentVersionRules:await this.db.repositories.componentSetRule.getComponentSetRulesForSet(t)})}async deleteComponentSet(t){if(!await this.db.repositories.componentSet.componentSetExists(t))throw new sr.ResourceNotFoundError(`Component set with web path ${t} does not exist`);return await this.db.repositories.componentSet.delete({webPath:t})}normalise(t,{components:r,componentVersionRules:n}){var i,s,o,a,c;return{webPath:(i=t.webPath)!==null&&i!==void 0?i:"",displayName:(s=t.displayName)!==null&&s!==void 0?s:"",description:(o=t.description)!==null&&o!==void 0?o:"",environmentVariables:(a=t.environmentVariables)!==null&&a!==void 0?a:{},headers:(c=t.headers)!==null&&c!==void 0?c:{},components:r??{},componentVersionRules:n??{}}}async saveComponentSetComponents(t,r,n=null){let i=await this.db.repositories.componentSetComponentVersion.find({componentSetWebPath:t}),s=[];r&&Object.entries(r).forEach(([m,f])=>{f.forEach(h=>{var _;s.push({componentName:m,info:{version:h.version,environmentVariables:(_=h.environmentVariables)!==null&&_!==void 0?_:{}}})})});let o=i.filter(m=>!s.find(f=>m.componentName===f.componentName&&m.componentVersion===f.info.version)),a=s.filter(m=>!i.find(f=>f.componentName===m.componentName&&f.componentVersion===m.info.version)),c=s.filter(m=>i.find(f=>f.componentName===m.componentName&&f.componentVersion===m.info.version&&JSON.stringify(f.environmentVariables)!==JSON.stringify(m.info.environmentVariables))),u=this.db.repositories.componentSetComponentVersion,l=o.map(m=>u.delete({componentSetWebPath:t,componentName:m.componentName,componentVersion:m.componentVersion},n)),p=a.map(m=>{var f;return u.create(new OK.ComponentSetComponentVersion({componentSetWebPath:t,componentName:m.componentName,componentVersion:m.info.version,environmentVariables:(f=m.info.environmentVariables)!==null&&f!==void 0?f:{}}),n)}),d=c.map(m=>{var f;return u.update({componentSetWebPath:t,componentName:m.componentName,componentVersion:m.info.version},{environmentVariables:(f=m.info.environmentVariables)!==null&&f!==void 0?f:{}},n)});await Promise.all([...l,...p,...d])}async getExistingComponentsForWeb(t,r="both"){var n;let i=await this.db.repositories.componentVersion.getComponentSetComponentVersionByWebPath(t,r),s={};for(let o of i)s[o.componentName]===void 0&&(s[o.componentName]=[]),s[o.componentName].push({version:o.version,environmentVariables:(n=o.environmentVariables)!==null&&n!==void 0?n:{},description:o.description,displayName:o.displayName,icon:o.icon});return Object.entries(s).forEach(([o,a])=>{s[o]=a.sort((c,u)=>c.version<u.version?-1:c.version>u.version?1:0)}),s}async assertValidCreateComponentSet(t){if(!t.webPath)throw new sr.BadRequestError("Component set 'webPath' must be specificed and non-empty");if(!t.displayName)throw new sr.BadRequestError("Component set 'displayName' must be specificed and non-empty");if(this.assertValidWebPath(t.webPath),await this.db.repositories.componentSet.componentSetExists(t.webPath))throw new sr.BadRequestError(`Component set with web path ${t.webPath} already exists`);await this.assertValidComponentSet(t),this.assertValidcomponentVersionRules(t.webPath,t.componentVersionRules),this.assertComponentVersionsMatchRules(t.components,t.componentVersionRules)}assertComponentVersionsMatchRules(t={},r={}){for(let[n,i]of Object.entries(t))if(!i.every(({version:o})=>(0,NK.satisfies)(o,r[n]||"*")))throw new sr.BadRequestError("Component versions must satisfy version rule")}async assertValidComponentSet(t,r=void 0){var n,i;if(t.environmentVariables!==void 0&&this.assertValidEnvVars(t.environmentVariables),t.headers!==void 0&&this.assertValidHeaders(t.headers),t.components!==void 0){let s=(i=(n=t.environmentVariables)!==null&&n!==void 0?n:r==null?void 0:r.environmentVariables)!==null&&i!==void 0?i:{};await this.assertValidComponents(t.components,s)}}assertValidWebPath(t){if(t.replace(/[^a-z0-9\-_.]/i,"")!==t)throw new sr.BadRequestError("Invalid Component Set web path. Only [A-Za-z0-9_-.] chars are allowed")}assertValidEnvVars(t={}){Object.entries(t).forEach(([r,n])=>{if(r.replace(/[^a-z0-9\-_.]/i,"")!==r)throw new sr.BadRequestError(`Invalid env var '${r}'. Only [A-Za-z0-9_-.] chars are allowed`);if(typeof n!="string")throw new sr.BadRequestError(`Env var '${r}' value must be a string`)})}assertValidHeaders(t){}async assertValidComponents(t,r){let n=this.db.repositories.componentVersion;if(t)for(let[i,s]of Object.entries(t)){if(!i)throw new sr.BadRequestError("Component name must be non-empty");let o=[];for(let a of s){if(!a.version)throw new sr.BadRequestError("Component version must set and be non-empty");if(o.includes(a.version))throw new sr.BadRequestError(`Multiple componet version entries for component ${i} with version ${a.version}`);if(o.push(a.version),a.environmentVariables!==void 0){this.assertValidEnvVars(a.environmentVariables);let c=Object.keys(a.environmentVariables).filter(u=>!Object.keys(r).includes(u));if(c.length)throw new sr.BadRequestError(`Env var(s) '${c.join("', '")}' defined on component ${i} with version ${a.version} is/are not defined on the component set`)}if(!await n.componentVersionExists(i,a.version))throw new sr.BadRequestError(`Component ${i} with version ${a.version} does not exists`)}}}assertValidcomponentVersionRules(t,r={}){for(let[n,i]of Object.entries(r))try{(0,NT.assertIsCompenentSetRule)({componentSet:t,componentName:n,versionPattern:i})}catch(s){throw new sr.BadRequestError(s.message)}}async getAllComponentSets(){let t=await this.db.repositories.componentSet.findAll(),r=[];for(let n of t){let i=await this.getExistingComponentsForWeb(n.webPath),s=await this.db.repositories.componentSetRule.getComponentSetRulesForSet(n.webPath);r.push(this.normalise(n,{components:i,componentVersionRules:s}))}return r}async getPaginatedComponentSets(t=1,r=[],n="asc"){let i=await this.db.repositories.componentSet.getPage(t,r,n),s=[];for(let o of i.items){let a=await this.getExistingComponentsForWeb(o.webPath);s.push(this.normalise(o,{components:a,componentVersionRules:await this.db.repositories.componentSetRule.getComponentSetRulesForSet(o.webPath)}))}return{items:s,pageInfo:(0,sr.getPageInfo)(t,i.pageSize,i.totalCount)}}async componentVersionInSet(t,r){return await this.db.repositories.componentSetComponentVersion.findOne({componentName:t.getName(),componentVersion:t.getVersion(),componentSetWebPath:r})!==void 0}addComponentToSet(t,r,n){return this.db.repositories.componentSetComponentVersion.create(new OK.ComponentSetComponentVersion({componentSetWebPath:t,componentName:r,componentVersion:n}))}};mE.ComponentSetServiceForProduction=qT});var jK=y(hE=>{"use strict";Object.defineProperty(hE,"__esModule",{value:!0});hE.ComponentSetRuleService=void 0;var jT=class{constructor(t,r){this.db=t,this.componentSetService=r}async addComponentVersionToRequiredSets(t,r){let n=await this.db.repositories.componentSetRule.getComponentSetsMatchingComponentVersion(t,r),i=({componentSet:s})=>this.componentSetService.addComponentToSet(s,t,r);return Promise.allSettled(n.map(i))}};hE.ComponentSetRuleService=jT});var kK=y(MK=>{"use strict";Object.defineProperty(MK,"__esModule",{value:!0})});var FK=y(DK=>{"use strict";Object.defineProperty(DK,"__esModule",{value:!0})});var LK=y(_E=>{"use strict";Object.defineProperty(_E,"__esModule",{value:!0});_E.InvalidEnvironmentVariablesError=void 0;var Oze=Jt(),MT=class extends Oze.BadRequestError{constructor(t){let r=t.map(([n,i])=>`"${n}" ${i}`).join("; ");super(`Invalid Environment Variables: ${r}`),this.errors=t,this.name="InvalidEnvironmentVariablesError"}};_E.InvalidEnvironmentVariablesError=MT});var $K=y(zK=>{"use strict";Object.defineProperty(zK,"__esModule",{value:!0})});var VK=y(UK=>{"use strict";Object.defineProperty(UK,"__esModule",{value:!0})});var GK=y(dr=>{"use strict";var Nze=dr&&dr.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Mn=dr&&dr.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Nze(t,e,r)};Object.defineProperty(dr,"__esModule",{value:!0});Mn(V0(),dr);Mn(o0(),dr);Mn(XC(),dr);Mn(tT(),dr);Mn(pE(),dr);Mn(TK(),dr);Mn(qK(),dr);Mn(jK(),dr);Mn(kK(),dr);Mn(FK(),dr);Mn(LK(),dr);Mn($K(),dr);Mn(VK(),dr)});var za=y(zs=>{"use strict";var HK=tt().fromCallback,Zr=Xe(),qze=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(e=>typeof Zr[e]=="function");Object.assign(zs,Zr);qze.forEach(e=>{zs[e]=HK(Zr[e])});zs.exists=function(e,t){return typeof t=="function"?Zr.exists(e,t):new Promise(r=>Zr.exists(e,r))};zs.read=function(e,t,r,n,i,s){return typeof s=="function"?Zr.read(e,t,r,n,i,s):new Promise((o,a)=>{Zr.read(e,t,r,n,i,(c,u,l)=>{if(c)return a(c);o({bytesRead:u,buffer:l})})})};zs.write=function(e,t,...r){return typeof r[r.length-1]=="function"?Zr.write(e,t,...r):new Promise((n,i)=>{Zr.write(e,t,...r,(s,o,a)=>{if(s)return i(s);n({bytesWritten:o,buffer:a})})})};zs.readv=function(e,t,...r){return typeof r[r.length-1]=="function"?Zr.readv(e,t,...r):new Promise((n,i)=>{Zr.readv(e,t,...r,(s,o,a)=>{if(s)return i(s);n({bytesRead:o,buffers:a})})})};zs.writev=function(e,t,...r){return typeof r[r.length-1]=="function"?Zr.writev(e,t,...r):new Promise((n,i)=>{Zr.writev(e,t,...r,(s,o,a)=>{if(s)return i(s);n({bytesWritten:o,buffers:a})})})};typeof Zr.realpath.native=="function"?zs.realpath.native=HK(Zr.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var WK=y((Ett,BK)=>{"use strict";var jze=require("path");BK.exports.checkPath=function(t){if(process.platform==="win32"&&/[<>:"|?*]/.test(t.replace(jze.parse(t).root,""))){let n=new Error(`Path contains invalid characters: ${t}`);throw n.code="EINVAL",n}}});var QK=y((btt,kT)=>{"use strict";var KK=za(),{checkPath:JK}=WK(),YK=e=>{let t={mode:511};return typeof e=="number"?e:{...t,...e}.mode};kT.exports.makeDir=async(e,t)=>(JK(e),KK.mkdir(e,{mode:YK(t),recursive:!0}));kT.exports.makeDirSync=(e,t)=>(JK(e),KK.mkdirSync(e,{mode:YK(t),recursive:!0}))});var Ei=y((Rtt,XK)=>{"use strict";var Mze=tt().fromPromise,{makeDir:kze,makeDirSync:DT}=QK(),FT=Mze(kze);XK.exports={mkdirs:FT,mkdirsSync:DT,mkdirp:FT,mkdirpSync:DT,ensureDir:FT,ensureDirSync:DT}});var Fo=y((xtt,e7)=>{"use strict";var Dze=tt().fromPromise,ZK=za();function Fze(e){return ZK.access(e).then(()=>!0).catch(()=>!1)}e7.exports={pathExists:Dze(Fze),pathExistsSync:ZK.existsSync}});var LT=y((Att,t7)=>{"use strict";var ul=Xe();function Lze(e,t,r,n){ul.open(e,"r+",(i,s)=>{if(i)return n(i);ul.futimes(s,t,r,o=>{ul.close(s,a=>{n&&n(o||a)})})})}function zze(e,t,r){let n=ul.openSync(e,"r+");return ul.futimesSync(n,t,r),ul.closeSync(n)}t7.exports={utimesMillis:Lze,utimesMillisSync:zze}});var $a=y((Ptt,i7)=>{"use strict";var dl=za(),wr=require("path"),$ze=require("util");function Uze(e,t,r){let n=r.dereference?i=>dl.stat(i,{bigint:!0}):i=>dl.lstat(i,{bigint:!0});return Promise.all([n(e),n(t).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,s])=>({srcStat:i,destStat:s}))}function Vze(e,t,r){let n,i=r.dereference?o=>dl.statSync(o,{bigint:!0}):o=>dl.lstatSync(o,{bigint:!0}),s=i(e);try{n=i(t)}catch(o){if(o.code==="ENOENT")return{srcStat:s,destStat:null};throw o}return{srcStat:s,destStat:n}}function Gze(e,t,r,n,i){$ze.callbackify(Uze)(e,t,n,(s,o)=>{if(s)return i(s);let{srcStat:a,destStat:c}=o;if(c){if(Nf(a,c)){let u=wr.basename(e),l=wr.basename(t);return r==="move"&&u!==l&&u.toLowerCase()===l.toLowerCase()?i(null,{srcStat:a,destStat:c,isChangingCase:!0}):i(new Error("Source and destination must not be the same."))}if(a.isDirectory()&&!c.isDirectory())return i(new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`));if(!a.isDirectory()&&c.isDirectory())return i(new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`))}return a.isDirectory()&&zT(e,t)?i(new Error(vE(e,t,r))):i(null,{srcStat:a,destStat:c})})}function Hze(e,t,r,n){let{srcStat:i,destStat:s}=Vze(e,t,n);if(s){if(Nf(i,s)){let o=wr.basename(e),a=wr.basename(t);if(r==="move"&&o!==a&&o.toLowerCase()===a.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&zT(e,t))throw new Error(vE(e,t,r));return{srcStat:i,destStat:s}}function r7(e,t,r,n,i){let s=wr.resolve(wr.dirname(e)),o=wr.resolve(wr.dirname(r));if(o===s||o===wr.parse(o).root)return i();dl.stat(o,{bigint:!0},(a,c)=>a?a.code==="ENOENT"?i():i(a):Nf(t,c)?i(new Error(vE(e,r,n))):r7(e,t,o,n,i))}function n7(e,t,r,n){let i=wr.resolve(wr.dirname(e)),s=wr.resolve(wr.dirname(r));if(s===i||s===wr.parse(s).root)return;let o;try{o=dl.statSync(s,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(Nf(t,o))throw new Error(vE(e,r,n));return n7(e,t,s,n)}function Nf(e,t){return t.ino&&t.dev&&t.ino===e.ino&&t.dev===e.dev}function zT(e,t){let r=wr.resolve(e).split(wr.sep).filter(i=>i),n=wr.resolve(t).split(wr.sep).filter(i=>i);return r.reduce((i,s,o)=>i&&n[o]===s,!0)}function vE(e,t,r){return`Cannot ${r} '${e}' to a subdirectory of itself, '${t}'.`}i7.exports={checkPaths:Gze,checkPathsSync:Hze,checkParentPaths:r7,checkParentPathsSync:n7,isSrcSubdir:zT,areIdentical:Nf}});var u7=y((Itt,l7)=>{"use strict";var vn=Xe(),qf=require("path"),Bze=Ei().mkdirs,Wze=Fo().pathExists,Kze=LT().utimesMillis,jf=$a();function Jze(e,t,r,n){typeof r=="function"&&!n?(n=r,r={}):typeof r=="function"&&(r={filter:r}),n=n||function(){},r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
230
+ WHERE cscv.component_set_web_path=$1 ${n}`;return(await this.executeQueryRaw(i,[t])).map(o=>({componentName:o.component_name,version:o.version,displayName:o.display_name,description:o.description,icon:o.icon?o.icon:void 0,environmentVariables:o.env_vars}))}async getComponentByNameAndVersion(t,r){return await this.findOne({componentName:t,version:r})}async componentVersionExists(t,r){return await this.getComponentByNameAndVersion(t,r)!=null}async addComponentVersion(t,r,n,i,s){if(_ze.test(r)===!1)throw new Error("ComponentVersion does not follow the semver convention. Component version must be in the form of major.minor.patch");return await this.create({componentName:t,version:r,description:i||"",displayName:n||"",icon:s})}};lE.ComponentVersionRepository=xT});var PT=y(uE=>{"use strict";Object.defineProperty(uE,"__esModule",{value:!0});uE.createComponentRepositories=void 0;var vze=XC(),gze=tT(),yze=RK(),Sze=ET(),wze=AT();function Eze(e){return{component:new Sze.ComponentRepository(e),componentVersion:new wze.ComponentVersionRepository(e),componentSet:new gze.ComponentSetRepository(e),componentSetComponentVersion:new vze.ComponentSetComponentVersionRepository(e),componentSetRule:new yze.ComponentSetRuleRepository(e)}}uE.createComponentRepositories=Eze});var AK=y(IT=>{"use strict";Object.defineProperty(IT,"__esModule",{value:!0});IT.default=["20220704054051_initial.sql","20220718172237_adding_component_sets.sql","20220728113941_add_env_vars_field.sql","20220817113300_removing_null_props_from_jsonb.sql","20223525103556_component_set_rule.sql","20221027151225_dummy.sql","20221117151200_add_detail_columns_to_component_version.js","20221220151200_add_required_to_manifests.js","20221222151200_add_required_to_manifests.js","20230111095522_update_environment_property.js","20230203084900_ensure_static_root_exists.js"]});var IK=y(cl=>{"use strict";var bze=cl&&cl.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(cl,"__esModule",{value:!0});cl.createConnectionManager=void 0;var PK=qa(),Rze=PT(),xze=bze(AK());async function Aze(e,t,r){let n=await(0,PK.getConnectionInfo)(t);return new PK.ConnectionManager(e,n,r,xze.default,Rze.createComponentRepositories)}cl.createConnectionManager=Aze});var CK=y(Ls=>{"use strict";var Pze=Ls&&Ls.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),CT=Ls&&Ls.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Pze(t,e,r)};Object.defineProperty(Ls,"__esModule",{value:!0});CT(PH(),Ls);CT(PT(),Ls);CT(IK(),Ls)});var pE=y(dE=>{"use strict";Object.defineProperty(dE,"__esModule",{value:!0});dE.AbstractComponentSetService=void 0;var TT=class{getComponentRuntimeHeaders(t,r){var n,i;let s=(n=r.output.headers)!==null&&n!==void 0?n:{},o=(i=t.headers)!==null&&i!==void 0?i:{};return{...s,...o}}};dE.AbstractComponentSetService=TT});var TK=y(fE=>{"use strict";Object.defineProperty(fE,"__esModule",{value:!0});fE.ComponentSetServiceForLocalDev=void 0;var ll=Jt(),Ize=pE(),OT=class extends Ize.AbstractComponentSetService{constructor(t){super(),this.logger=t}async updateComponentSet(){throw new ll.MethodNotImplementedError("updateComponentSet is not implemented for local development")}async getAllComponentSets(){throw new ll.MethodNotImplementedError("getAllComponentSets is not implemented for local development")}async addComponentSet(){throw new ll.MethodNotImplementedError("addComponentSet is not implemented for local development")}async deleteComponentSet(){throw new ll.MethodNotImplementedError("deleteComponentSet is not implemented for local development")}addComponentToSet(t,r,n){throw new ll.MethodNotImplementedError("addComponentToSet is not implemented for local development")}async getPaginatedComponentSets(t=1,r=[],n="asc"){throw new ll.MethodNotImplementedError("getPaginatedComponentSets is not implemented for local development")}async getComponentSetWebModel(t){return{webPath:t,displayName:"set",description:"debug set",environmentVariables:process.env,headers:{},components:{},componentVersionRules:{}}}async getComponentSet(t){return{webPath:t,displayName:"set",description:"debug set",environmentVariables:process.env,headers:{}}}async getComponentsRuntimeSetData(t,r){let n={},i=t.getModel().environment||[],s=[];for(let o of i)r.environmentVariables[o.name]===void 0?o.required!==!1&&s.push(o.name):n[o.name]=r.environmentVariables[o.name];if(s.length>0)throw new Error(`Missing required environment variables: "${s.join('","')}"`);return{environment:n,displayName:r.displayName,webPath:r.webPath}}async componentVersionInSet(t,r){return!0}};fE.ComponentSetServiceForLocalDev=OT});var qK=y(mE=>{"use strict";Object.defineProperty(mE,"__esModule",{value:!0});mE.ComponentSetServiceForProduction=void 0;var sr=Jt(),Cze=V0(),Tze=pE(),OK=o0(),NT=vT(),NK=iE(),qT=class extends Tze.AbstractComponentSetService{constructor(t,r,n){super(),this.db=t,this.logger=r,this.manifestService=n}async getComponentSet(t){let r=await this.db.repositories.componentSet.findOne({webPath:t});if(!r)throw new sr.ResourceNotFoundError(`component set ${t} could not be found`);return r}async addComponentSet(t){await this.assertValidCreateComponentSet(t);try{let r=await this.db.executeInTransaction(async i=>{var s;let o=await this.db.repositories.componentSet.create(new Cze.ComponentSet({webPath:t.webPath,displayName:t.displayName,description:t.description,environmentVariables:t.environmentVariables,headers:t.headers}),i);await this.saveComponentSetComponents(t.webPath,t.components,i);for(let[a,c]of Object.entries((s=t.componentVersionRules)!==null&&s!==void 0?s:{}))await this.db.repositories.componentSetRule.create(new NT.ComponentSetRule({componentSet:t.webPath,componentName:a,versionPattern:c}),i);return o});return await this.getComponentSetWebModel(r.webPath)}catch(r){throw this.logger.error(`Error occurred when updating component set ${t.webPath}: ${r}`),r}}async updateComponentSet(t,r){var n;let i=await this.db.repositories.componentSet.getComponentSetByWebPath(t);if(!i)throw new sr.ResourceNotFoundError(`Component set with web path ${t} does not exist`);let s=await this.db.repositories.componentSetRule.getComponentSetRulesForSet(t);await this.assertValidComponentSet(r,this.normalise(i,{components:await this.getExistingComponentsForWeb(t),componentVersionRules:s})),this.assertValidcomponentVersionRules(t,r.componentVersionRules),this.assertComponentVersionsMatchRules(r.components,(n=r.componentVersionRules)!==null&&n!==void 0?n:s);let o={};r.displayName!==void 0&&(o.displayName=r.displayName),r.description!==void 0&&(o.description=r.description),r.headers!==void 0&&(o.headers=r.headers),r.environmentVariables!==void 0&&(o.environmentVariables=r.environmentVariables);try{return await this.db.executeInTransaction(async a=>{Object.keys(o).length>0&&await this.db.repositories.componentSet.update({webPath:t},o,a),r.components!==void 0&&await this.saveComponentSetComponents(t,r.components,a),r.componentVersionRules&&(await this.updateComponentVersionRules(t,r.componentVersionRules,a),await this.updateComponentVisibility(t,r.componentVersionRules,a))}),this.getComponentSetWebModel(t)}catch(a){throw this.logger.error(`Error occurred when updating component set ${t}: ${a}`),a}}async getComponentsRuntimeSetData(t,r){var n;let i={},s=t.getModel().environment||[],o=await this.db.repositories.componentSetComponentVersion.findOne({componentName:t.getName(),componentVersion:t.getVersion(),componentSetWebPath:r.webPath});if(!o)throw new sr.ResourceNotFoundError(`component ${t.getName()} ${t.getVersion} couldn't not be found in set ${r.webPath}`);let a=[];for(let c of s)r.environmentVariables[c.name]===void 0?c.required!==!1&&a.push(c.name):i[c.name]=(n=o.environmentVariables[c.name])!==null&&n!==void 0?n:r.environmentVariables[c.name];if(a.length>0)throw new sr.BadRequestError(`Missing required environment variables: "${a.join('","')}"`);return{environment:i,displayName:r.displayName,webPath:r.webPath}}async updateComponentVisibility(t,r,n){let s=(await this.db.repositories.componentSetComponentVersion.find({componentSetWebPath:t})).map(o=>this.db.repositories.componentSetComponentVersion.update(o,{isVisible:(0,NK.satisfies)(o.componentVersion,r[o.componentName]||"*")},n));return await Promise.all(s)}async updateComponentVersionRules(t,r,n){await this.db.repositories.componentSetRule.removeExistingRulesForComponentSet(t);for(let[i,s]of Object.entries(r))await this.db.repositories.componentSetRule.create(new NT.ComponentSetRule({componentSet:t,componentName:i,versionPattern:s}),n)}async getComponentSetWebModel(t,r="visible-only"){let n=await this.db.repositories.componentSet.getComponentSetByWebPath(t);if(n===void 0)throw new sr.ResourceNotFoundError(`Component set with web path ${t} does not exist`);return this.normalise(n,{components:await this.getExistingComponentsForWeb(t,r),componentVersionRules:await this.db.repositories.componentSetRule.getComponentSetRulesForSet(t)})}async deleteComponentSet(t){if(!await this.db.repositories.componentSet.componentSetExists(t))throw new sr.ResourceNotFoundError(`Component set with web path ${t} does not exist`);return await this.db.repositories.componentSet.delete({webPath:t})}normalise(t,{components:r,componentVersionRules:n}){var i,s,o,a,c;return{webPath:(i=t.webPath)!==null&&i!==void 0?i:"",displayName:(s=t.displayName)!==null&&s!==void 0?s:"",description:(o=t.description)!==null&&o!==void 0?o:"",environmentVariables:(a=t.environmentVariables)!==null&&a!==void 0?a:{},headers:(c=t.headers)!==null&&c!==void 0?c:{},components:r??{},componentVersionRules:n??{}}}async saveComponentSetComponents(t,r,n=null){let i=await this.db.repositories.componentSetComponentVersion.find({componentSetWebPath:t}),s=[];r&&Object.entries(r).forEach(([m,f])=>{f.forEach(h=>{var _;s.push({componentName:m,info:{version:h.version,environmentVariables:(_=h.environmentVariables)!==null&&_!==void 0?_:{}}})})});let o=i.filter(m=>!s.find(f=>m.componentName===f.componentName&&m.componentVersion===f.info.version)),a=s.filter(m=>!i.find(f=>f.componentName===m.componentName&&f.componentVersion===m.info.version)),c=s.filter(m=>i.find(f=>f.componentName===m.componentName&&f.componentVersion===m.info.version&&JSON.stringify(f.environmentVariables)!==JSON.stringify(m.info.environmentVariables))),u=this.db.repositories.componentSetComponentVersion,l=o.map(m=>u.delete({componentSetWebPath:t,componentName:m.componentName,componentVersion:m.componentVersion},n)),p=a.map(m=>{var f;return u.create(new OK.ComponentSetComponentVersion({componentSetWebPath:t,componentName:m.componentName,componentVersion:m.info.version,environmentVariables:(f=m.info.environmentVariables)!==null&&f!==void 0?f:{}}),n)}),d=c.map(m=>{var f;return u.update({componentSetWebPath:t,componentName:m.componentName,componentVersion:m.info.version},{environmentVariables:(f=m.info.environmentVariables)!==null&&f!==void 0?f:{}},n)});await Promise.all([...l,...p,...d])}async getExistingComponentsForWeb(t,r="both"){var n;let i=await this.db.repositories.componentVersion.getComponentSetComponentVersionByWebPath(t,r),s={};for(let o of i)s[o.componentName]===void 0&&(s[o.componentName]=[]),s[o.componentName].push({version:o.version,environmentVariables:(n=o.environmentVariables)!==null&&n!==void 0?n:{},description:o.description,displayName:o.displayName,icon:o.icon});return Object.entries(s).forEach(([o,a])=>{s[o]=a.sort((c,u)=>c.version<u.version?-1:c.version>u.version?1:0)}),s}async assertValidCreateComponentSet(t){if(!t.webPath)throw new sr.BadRequestError("Component set 'webPath' must be specificed and non-empty");if(!t.displayName)throw new sr.BadRequestError("Component set 'displayName' must be specificed and non-empty");if(this.assertValidWebPath(t.webPath),await this.db.repositories.componentSet.componentSetExists(t.webPath))throw new sr.BadRequestError(`Component set with web path ${t.webPath} already exists`);await this.assertValidComponentSet(t),this.assertValidcomponentVersionRules(t.webPath,t.componentVersionRules),this.assertComponentVersionsMatchRules(t.components,t.componentVersionRules)}assertComponentVersionsMatchRules(t={},r={}){for(let[n,i]of Object.entries(t))if(!i.every(({version:o})=>(0,NK.satisfies)(o,r[n]||"*")))throw new sr.BadRequestError("Component versions must satisfy version rule")}async assertValidComponentSet(t,r=void 0){var n,i;if(t.environmentVariables!==void 0&&this.assertValidEnvVars(t.environmentVariables),t.headers!==void 0&&this.assertValidHeaders(t.headers),t.components!==void 0){let s=(i=(n=t.environmentVariables)!==null&&n!==void 0?n:r==null?void 0:r.environmentVariables)!==null&&i!==void 0?i:{};await this.assertValidComponents(t.components,s)}}assertValidWebPath(t){if(t.replace(/[^a-z0-9\-_.]/i,"")!==t)throw new sr.BadRequestError("Invalid Component Set web path. Only [A-Za-z0-9_-.] chars are allowed")}assertValidEnvVars(t={}){Object.entries(t).forEach(([r,n])=>{this.assertValidProperty({name:r,value:n,type:"environment variable"})})}assertValidHeaders(t){Object.entries(t).forEach(([r,n])=>{this.assertValidProperty({name:r,value:n,type:"header"})})}assertValidProperty(t){if(!/^[a-z0-9\-_.]+$/i.test(t.name))throw new sr.BadRequestError(`Invalid '${t.type}' name for '${t.name}'. Only [A-Za-z0-9_-.] chars are allowed`);if(typeof t.value!="string")throw new sr.BadRequestError(`Invalid '${t.type}' value for '${t.name}'. Value must be a string`)}async assertValidComponents(t,r){let n=this.db.repositories.componentVersion;if(t)for(let[i,s]of Object.entries(t)){if(!i)throw new sr.BadRequestError("Component name must be non-empty");let o=[];for(let a of s){if(!a.version)throw new sr.BadRequestError("Component version must set and be non-empty");if(o.includes(a.version))throw new sr.BadRequestError(`Multiple componet version entries for component ${i} with version ${a.version}`);if(o.push(a.version),a.environmentVariables!==void 0){this.assertValidEnvVars(a.environmentVariables);let c=Object.keys(a.environmentVariables).filter(u=>!Object.keys(r).includes(u));if(c.length)throw new sr.BadRequestError(`Env var(s) '${c.join("', '")}' defined on component ${i} with version ${a.version} is/are not defined on the component set`)}if(!await n.componentVersionExists(i,a.version))throw new sr.BadRequestError(`Component ${i} with version ${a.version} does not exists`)}}}assertValidcomponentVersionRules(t,r={}){for(let[n,i]of Object.entries(r))try{(0,NT.assertIsCompenentSetRule)({componentSet:t,componentName:n,versionPattern:i})}catch(s){throw new sr.BadRequestError(s.message)}}async getAllComponentSets(){let t=await this.db.repositories.componentSet.findAll(),r=[];for(let n of t){let i=await this.getExistingComponentsForWeb(n.webPath),s=await this.db.repositories.componentSetRule.getComponentSetRulesForSet(n.webPath);r.push(this.normalise(n,{components:i,componentVersionRules:s}))}return r}async getPaginatedComponentSets(t=1,r=[],n="asc"){let i=await this.db.repositories.componentSet.getPage(t,r,n),s=[];for(let o of i.items){let a=await this.getExistingComponentsForWeb(o.webPath);s.push(this.normalise(o,{components:a,componentVersionRules:await this.db.repositories.componentSetRule.getComponentSetRulesForSet(o.webPath)}))}return{items:s,pageInfo:(0,sr.getPageInfo)(t,i.pageSize,i.totalCount)}}async componentVersionInSet(t,r){return await this.db.repositories.componentSetComponentVersion.findOne({componentName:t.getName(),componentVersion:t.getVersion(),componentSetWebPath:r})!==void 0}addComponentToSet(t,r,n){return this.db.repositories.componentSetComponentVersion.create(new OK.ComponentSetComponentVersion({componentSetWebPath:t,componentName:r,componentVersion:n}))}};mE.ComponentSetServiceForProduction=qT});var jK=y(hE=>{"use strict";Object.defineProperty(hE,"__esModule",{value:!0});hE.ComponentSetRuleService=void 0;var jT=class{constructor(t,r){this.db=t,this.componentSetService=r}async addComponentVersionToRequiredSets(t,r){let n=await this.db.repositories.componentSetRule.getComponentSetsMatchingComponentVersion(t,r),i=({componentSet:s})=>this.componentSetService.addComponentToSet(s,t,r);return Promise.allSettled(n.map(i))}};hE.ComponentSetRuleService=jT});var kK=y(MK=>{"use strict";Object.defineProperty(MK,"__esModule",{value:!0})});var FK=y(DK=>{"use strict";Object.defineProperty(DK,"__esModule",{value:!0})});var LK=y(_E=>{"use strict";Object.defineProperty(_E,"__esModule",{value:!0});_E.InvalidEnvironmentVariablesError=void 0;var Oze=Jt(),MT=class extends Oze.BadRequestError{constructor(t){let r=t.map(([n,i])=>`"${n}" ${i}`).join("; ");super(`Invalid Environment Variables: ${r}`),this.errors=t,this.name="InvalidEnvironmentVariablesError"}};_E.InvalidEnvironmentVariablesError=MT});var $K=y(zK=>{"use strict";Object.defineProperty(zK,"__esModule",{value:!0})});var VK=y(UK=>{"use strict";Object.defineProperty(UK,"__esModule",{value:!0})});var GK=y(dr=>{"use strict";var Nze=dr&&dr.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Mn=dr&&dr.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Nze(t,e,r)};Object.defineProperty(dr,"__esModule",{value:!0});Mn(V0(),dr);Mn(o0(),dr);Mn(XC(),dr);Mn(tT(),dr);Mn(pE(),dr);Mn(TK(),dr);Mn(qK(),dr);Mn(jK(),dr);Mn(kK(),dr);Mn(FK(),dr);Mn(LK(),dr);Mn($K(),dr);Mn(VK(),dr)});var za=y(zs=>{"use strict";var HK=tt().fromCallback,Zr=Xe(),qze=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(e=>typeof Zr[e]=="function");Object.assign(zs,Zr);qze.forEach(e=>{zs[e]=HK(Zr[e])});zs.exists=function(e,t){return typeof t=="function"?Zr.exists(e,t):new Promise(r=>Zr.exists(e,r))};zs.read=function(e,t,r,n,i,s){return typeof s=="function"?Zr.read(e,t,r,n,i,s):new Promise((o,a)=>{Zr.read(e,t,r,n,i,(c,u,l)=>{if(c)return a(c);o({bytesRead:u,buffer:l})})})};zs.write=function(e,t,...r){return typeof r[r.length-1]=="function"?Zr.write(e,t,...r):new Promise((n,i)=>{Zr.write(e,t,...r,(s,o,a)=>{if(s)return i(s);n({bytesWritten:o,buffer:a})})})};zs.readv=function(e,t,...r){return typeof r[r.length-1]=="function"?Zr.readv(e,t,...r):new Promise((n,i)=>{Zr.readv(e,t,...r,(s,o,a)=>{if(s)return i(s);n({bytesRead:o,buffers:a})})})};zs.writev=function(e,t,...r){return typeof r[r.length-1]=="function"?Zr.writev(e,t,...r):new Promise((n,i)=>{Zr.writev(e,t,...r,(s,o,a)=>{if(s)return i(s);n({bytesWritten:o,buffers:a})})})};typeof Zr.realpath.native=="function"?zs.realpath.native=HK(Zr.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var WK=y((Ett,BK)=>{"use strict";var jze=require("path");BK.exports.checkPath=function(t){if(process.platform==="win32"&&/[<>:"|?*]/.test(t.replace(jze.parse(t).root,""))){let n=new Error(`Path contains invalid characters: ${t}`);throw n.code="EINVAL",n}}});var QK=y((btt,kT)=>{"use strict";var KK=za(),{checkPath:JK}=WK(),YK=e=>{let t={mode:511};return typeof e=="number"?e:{...t,...e}.mode};kT.exports.makeDir=async(e,t)=>(JK(e),KK.mkdir(e,{mode:YK(t),recursive:!0}));kT.exports.makeDirSync=(e,t)=>(JK(e),KK.mkdirSync(e,{mode:YK(t),recursive:!0}))});var Ei=y((Rtt,XK)=>{"use strict";var Mze=tt().fromPromise,{makeDir:kze,makeDirSync:DT}=QK(),FT=Mze(kze);XK.exports={mkdirs:FT,mkdirsSync:DT,mkdirp:FT,mkdirpSync:DT,ensureDir:FT,ensureDirSync:DT}});var Fo=y((xtt,e7)=>{"use strict";var Dze=tt().fromPromise,ZK=za();function Fze(e){return ZK.access(e).then(()=>!0).catch(()=>!1)}e7.exports={pathExists:Dze(Fze),pathExistsSync:ZK.existsSync}});var LT=y((Att,t7)=>{"use strict";var ul=Xe();function Lze(e,t,r,n){ul.open(e,"r+",(i,s)=>{if(i)return n(i);ul.futimes(s,t,r,o=>{ul.close(s,a=>{n&&n(o||a)})})})}function zze(e,t,r){let n=ul.openSync(e,"r+");return ul.futimesSync(n,t,r),ul.closeSync(n)}t7.exports={utimesMillis:Lze,utimesMillisSync:zze}});var $a=y((Ptt,i7)=>{"use strict";var dl=za(),wr=require("path"),$ze=require("util");function Uze(e,t,r){let n=r.dereference?i=>dl.stat(i,{bigint:!0}):i=>dl.lstat(i,{bigint:!0});return Promise.all([n(e),n(t).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,s])=>({srcStat:i,destStat:s}))}function Vze(e,t,r){let n,i=r.dereference?o=>dl.statSync(o,{bigint:!0}):o=>dl.lstatSync(o,{bigint:!0}),s=i(e);try{n=i(t)}catch(o){if(o.code==="ENOENT")return{srcStat:s,destStat:null};throw o}return{srcStat:s,destStat:n}}function Gze(e,t,r,n,i){$ze.callbackify(Uze)(e,t,n,(s,o)=>{if(s)return i(s);let{srcStat:a,destStat:c}=o;if(c){if(Nf(a,c)){let u=wr.basename(e),l=wr.basename(t);return r==="move"&&u!==l&&u.toLowerCase()===l.toLowerCase()?i(null,{srcStat:a,destStat:c,isChangingCase:!0}):i(new Error("Source and destination must not be the same."))}if(a.isDirectory()&&!c.isDirectory())return i(new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`));if(!a.isDirectory()&&c.isDirectory())return i(new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`))}return a.isDirectory()&&zT(e,t)?i(new Error(vE(e,t,r))):i(null,{srcStat:a,destStat:c})})}function Hze(e,t,r,n){let{srcStat:i,destStat:s}=Vze(e,t,n);if(s){if(Nf(i,s)){let o=wr.basename(e),a=wr.basename(t);if(r==="move"&&o!==a&&o.toLowerCase()===a.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&zT(e,t))throw new Error(vE(e,t,r));return{srcStat:i,destStat:s}}function r7(e,t,r,n,i){let s=wr.resolve(wr.dirname(e)),o=wr.resolve(wr.dirname(r));if(o===s||o===wr.parse(o).root)return i();dl.stat(o,{bigint:!0},(a,c)=>a?a.code==="ENOENT"?i():i(a):Nf(t,c)?i(new Error(vE(e,r,n))):r7(e,t,o,n,i))}function n7(e,t,r,n){let i=wr.resolve(wr.dirname(e)),s=wr.resolve(wr.dirname(r));if(s===i||s===wr.parse(s).root)return;let o;try{o=dl.statSync(s,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(Nf(t,o))throw new Error(vE(e,r,n));return n7(e,t,s,n)}function Nf(e,t){return t.ino&&t.dev&&t.ino===e.ino&&t.dev===e.dev}function zT(e,t){let r=wr.resolve(e).split(wr.sep).filter(i=>i),n=wr.resolve(t).split(wr.sep).filter(i=>i);return r.reduce((i,s,o)=>i&&n[o]===s,!0)}function vE(e,t,r){return`Cannot ${r} '${e}' to a subdirectory of itself, '${t}'.`}i7.exports={checkPaths:Gze,checkPathsSync:Hze,checkParentPaths:r7,checkParentPathsSync:n7,isSrcSubdir:zT,areIdentical:Nf}});var u7=y((Itt,l7)=>{"use strict";var vn=Xe(),qf=require("path"),Bze=Ei().mkdirs,Wze=Fo().pathExists,Kze=LT().utimesMillis,jf=$a();function Jze(e,t,r,n){typeof r=="function"&&!n?(n=r,r={}):typeof r=="function"&&(r={filter:r}),n=n||function(){},r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
231
231
 
232
232
  see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001"),jf.checkPaths(e,t,"copy",r,(i,s)=>{if(i)return n(i);let{srcStat:o,destStat:a}=s;jf.checkParentPaths(e,o,t,"copy",c=>{if(c)return n(c);o7(e,t,r,(u,l)=>{if(u)return n(u);if(!l)return n();Yze(a,e,t,r,n)})})})}function Yze(e,t,r,n,i){let s=qf.dirname(r);Wze(s,(o,a)=>{if(o)return i(o);if(a)return $T(e,t,r,n,i);Bze(s,c=>c?i(c):$T(e,t,r,n,i))})}function o7(e,t,r,n){if(!r.filter)return n(null,!0);Promise.resolve(r.filter(e,t)).then(i=>n(null,i),i=>n(i))}function $T(e,t,r,n,i){(n.dereference?vn.stat:vn.lstat)(t,(o,a)=>o?i(o):a.isDirectory()?n$e(a,e,t,r,n,i):a.isFile()||a.isCharacterDevice()||a.isBlockDevice()?Qze(a,e,t,r,n,i):a.isSymbolicLink()?o$e(e,t,r,n,i):a.isSocket()?i(new Error(`Cannot copy a socket file: ${t}`)):a.isFIFO()?i(new Error(`Cannot copy a FIFO pipe: ${t}`)):i(new Error(`Unknown file: ${t}`)))}function Qze(e,t,r,n,i,s){return t?Xze(e,r,n,i,s):a7(e,r,n,i,s)}function Xze(e,t,r,n,i){if(n.overwrite)vn.unlink(r,s=>s?i(s):a7(e,t,r,n,i));else return n.errorOnExist?i(new Error(`'${r}' already exists`)):i()}function a7(e,t,r,n,i){vn.copyFile(t,r,s=>s?i(s):n.preserveTimestamps?Zze(e.mode,t,r,i):gE(r,e.mode,i))}function Zze(e,t,r,n){return e$e(e)?t$e(r,e,i=>i?n(i):s7(e,t,r,n)):s7(e,t,r,n)}function e$e(e){return(e&128)===0}function t$e(e,t,r){return gE(e,t|128,r)}function s7(e,t,r,n){r$e(t,r,i=>i?n(i):gE(r,e,n))}function gE(e,t,r){return vn.chmod(e,t,r)}function r$e(e,t,r){vn.stat(e,(n,i)=>n?r(n):Kze(t,i.atime,i.mtime,r))}function n$e(e,t,r,n,i,s){return t?c7(r,n,i,s):i$e(e.mode,r,n,i,s)}function i$e(e,t,r,n,i){vn.mkdir(r,s=>{if(s)return i(s);c7(t,r,n,o=>o?i(o):gE(r,e,i))})}function c7(e,t,r,n){vn.readdir(e,(i,s)=>i?n(i):UT(s,e,t,r,n))}function UT(e,t,r,n,i){let s=e.pop();return s?s$e(e,s,t,r,n,i):i()}function s$e(e,t,r,n,i,s){let o=qf.join(r,t),a=qf.join(n,t);o7(o,a,i,(c,u)=>{if(c)return s(c);if(!u)return UT(e,r,n,i,s);jf.checkPaths(o,a,"copy",i,(l,p)=>{if(l)return s(l);let{destStat:d}=p;$T(d,o,a,i,m=>m?s(m):UT(e,r,n,i,s))})})}function o$e(e,t,r,n,i){vn.readlink(t,(s,o)=>{if(s)return i(s);if(n.dereference&&(o=qf.resolve(process.cwd(),o)),e)vn.readlink(r,(a,c)=>a?a.code==="EINVAL"||a.code==="UNKNOWN"?vn.symlink(o,r,i):i(a):(n.dereference&&(c=qf.resolve(process.cwd(),c)),jf.isSrcSubdir(o,c)?i(new Error(`Cannot copy '${o}' to a subdirectory of itself, '${c}'.`)):jf.isSrcSubdir(c,o)?i(new Error(`Cannot overwrite '${c}' with '${o}'.`)):a$e(o,r,i)));else return vn.symlink(o,r,i)})}function a$e(e,t,r){vn.unlink(t,n=>n?r(n):vn.symlink(e,t,r))}l7.exports=Jze});var h7=y((Ctt,m7)=>{"use strict";var en=Xe(),Mf=require("path"),c$e=Ei().mkdirsSync,l$e=LT().utimesMillisSync,kf=$a();function u$e(e,t,r){typeof r=="function"&&(r={filter:r}),r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
233
233
 
@@ -243,7 +243,7 @@ safe-buffer/index.js:
243
243
  */
244
244
  /**
245
245
  * @title @squiz/content-api
246
- * @version 1.12.0-alpha.23
246
+ * @version 1.12.0-alpha.26
247
247
  * @license ISC
248
248
  * @baseUrl /
249
249
  * @contact