@squiz/render-runtime-lib 1.2.1-alpha.80 → 1.2.1-alpha.83

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/lib/index.js CHANGED
@@ -19873,16 +19873,16 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
19873
19873
  return prev;
19874
19874
  }, {});
19875
19875
  }
19876
- getConnection() {
19877
- return this.pool.connect();
19876
+ async getConnection() {
19877
+ return await this.pool.connect();
19878
19878
  }
19879
- async create(value) {
19879
+ async create(value, transactionClient = null) {
19880
19880
  const columns = Object.keys(value).map((a) => `"${this.modelPropertyToSqlColumn[a]}"`).join(", ");
19881
19881
  const values = Object.values(value).map((a, index) => `$${index + 1}`).join(", ");
19882
- const result = await this.executeQuery(`INSERT INTO ${this.tableName} (${columns}) VALUES (${values}) RETURNING *`, Object.values(value));
19882
+ const result = await this.executeQuery(`INSERT INTO ${this.tableName} (${columns}) VALUES (${values}) RETURNING *`, Object.values(value), transactionClient);
19883
19883
  return result[0];
19884
19884
  }
19885
- async update(where, newValue) {
19885
+ async update(where, newValue, transactionClient = null) {
19886
19886
  const whereValues = Object.values(where);
19887
19887
  const newValues = Object.values(newValue);
19888
19888
  const setString = Object.keys(newValue).map((a, index) => `"${this.modelPropertyToSqlColumn[a]}" = $${index + 1}`).join(", ");
@@ -19890,17 +19890,19 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
19890
19890
  const result = await this.executeQuery(`UPDATE ${this.tableName}
19891
19891
  SET ${setString}
19892
19892
  WHERE ${whereString}
19893
- RETURNING *`, [...Object.values(newValues), ...Object.values(whereValues)]);
19893
+ RETURNING *`, [...Object.values(newValues), ...Object.values(whereValues)], transactionClient);
19894
19894
  return result;
19895
19895
  }
19896
- async delete(where) {
19897
- const client = await this.pool.connect();
19896
+ async delete(where, transactionClient = null) {
19897
+ const client = transactionClient ?? await this.getConnection();
19898
19898
  try {
19899
19899
  const whereString = this.createWhereStringFromPartialModel(where);
19900
19900
  const result = await client.query(`DELETE FROM ${this.tableName} WHERE ${whereString}`, Object.values(where));
19901
19901
  return result.rowCount;
19902
19902
  } finally {
19903
- client.release();
19903
+ if (client && !transactionClient) {
19904
+ client.release();
19905
+ }
19904
19906
  }
19905
19907
  }
19906
19908
  createWhereStringFromPartialModel(values, initialIndex = 0) {
@@ -19914,13 +19916,13 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
19914
19916
  }, "");
19915
19917
  return sql;
19916
19918
  }
19917
- async executeQuery(query, values) {
19918
- const client = await this.pool.connect();
19919
+ async executeQuery(query, values, transactionClient = null) {
19920
+ const client = transactionClient ?? await this.getConnection();
19919
19921
  try {
19920
19922
  const result = await client.query(query, values);
19921
19923
  return result.rows.map((a) => this.createAndHydrateModel(a));
19922
19924
  } finally {
19923
- if (client) {
19925
+ if (client && !transactionClient) {
19924
19926
  client.release();
19925
19927
  }
19926
19928
  }
@@ -19945,6 +19947,11 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
19945
19947
  WHERE ${this.createWhereStringFromPartialModel(item)}`, Object.values(item));
19946
19948
  return result;
19947
19949
  }
19950
+ async findAll() {
19951
+ const result = await this.executeQuery(`SELECT *
19952
+ FROM ${this.tableName}`, []);
19953
+ return result;
19954
+ }
19948
19955
  };
19949
19956
  var ComponentRepository = class extends AbstractRepository {
19950
19957
  constructor(options) {
@@ -20111,7 +20118,54 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
20111
20118
  setTimeout(resolve, timeMs);
20112
20119
  });
20113
20120
  }
20114
- var migration_list_default = ["20220704054051_initial.sql"];
20121
+ var migration_list_default = ["20220704054051_initial.sql", "20220718172237_adding_component_sets.sql"];
20122
+ var ComponentSet = class {
20123
+ constructor() {
20124
+ this.webPath = "";
20125
+ this.displayName = "";
20126
+ this.envVars = {};
20127
+ this.description = "";
20128
+ this.headers = {};
20129
+ }
20130
+ };
20131
+ var ComponentSetRepository = class extends AbstractRepository {
20132
+ constructor(options) {
20133
+ super(options.repositories, options.pool, "component_set", {
20134
+ webPath: "web_path",
20135
+ displayName: "display_name",
20136
+ description: "description",
20137
+ envVars: "env_vars",
20138
+ headers: "headers"
20139
+ }, ComponentSet);
20140
+ }
20141
+ async getComponentSetByWebPath(webPath) {
20142
+ return this.findOne({ webPath });
20143
+ }
20144
+ async componentSetExists(webPath) {
20145
+ const comp = await this.getComponentSetByWebPath(webPath);
20146
+ return comp != null;
20147
+ }
20148
+ };
20149
+ var ComponentSetComponentVersion = class {
20150
+ constructor() {
20151
+ this.componentSetWebPath = "";
20152
+ this.componentName = "";
20153
+ this.componentVersion = "";
20154
+ }
20155
+ };
20156
+ var ComponentSetComponentVersionRepository = class extends AbstractRepository {
20157
+ constructor(options) {
20158
+ super(options.repositories, options.pool, "component_set_component_version", {
20159
+ componentSetWebPath: "component_set_web_path",
20160
+ componentName: "component_name",
20161
+ componentVersion: "component_version"
20162
+ }, ComponentSetComponentVersion);
20163
+ }
20164
+ async componentSetComponentVersionExists(componentSetWebPath, componentName, componentVersion) {
20165
+ const row = await this.findOne({ componentSetWebPath, componentName, componentVersion });
20166
+ return row != null;
20167
+ }
20168
+ };
20115
20169
  var ConnectionManager2 = class {
20116
20170
  constructor(applicationName, connection, migrationDirectory) {
20117
20171
  this.applicationName = applicationName;
@@ -20132,7 +20186,9 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
20132
20186
  });
20133
20187
  this.repositories = {
20134
20188
  component: new ComponentRepository(this),
20135
- componentVersion: new ComponentVersionRepository(this)
20189
+ componentVersion: new ComponentVersionRepository(this),
20190
+ componentSet: new ComponentSetRepository(this),
20191
+ componentSetComponentVersion: new ComponentSetComponentVersionRepository(this)
20136
20192
  };
20137
20193
  }
20138
20194
  async applyMigrations() {
@@ -20144,6 +20200,22 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
20144
20200
  await this.pool.end();
20145
20201
  this.pool.removeAllListeners();
20146
20202
  }
20203
+ async executeInTransaction(func) {
20204
+ const client = await this.pool.connect();
20205
+ try {
20206
+ await client.query("BEGIN");
20207
+ const value = await func(client);
20208
+ await client.query("COMMIT");
20209
+ return value;
20210
+ } catch (e) {
20211
+ await client.query("ROLLBACK");
20212
+ throw e;
20213
+ } finally {
20214
+ if (client) {
20215
+ client.release();
20216
+ }
20217
+ }
20218
+ }
20147
20219
  };
20148
20220
  var import_client_secrets_manager = __toESM2(require_dist_cjs44());
20149
20221
  async function getConnectionInfo2(config) {
@@ -26671,11 +26743,11 @@ var require_codegen = __commonJS({
26671
26743
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
26672
26744
  return `${varKind} ${this.name}${rhs};` + _n;
26673
26745
  }
26674
- optimizeNames(names, constants) {
26746
+ optimizeNames(names, constants2) {
26675
26747
  if (!names[this.name.str])
26676
26748
  return;
26677
26749
  if (this.rhs)
26678
- this.rhs = optimizeExpr(this.rhs, names, constants);
26750
+ this.rhs = optimizeExpr(this.rhs, names, constants2);
26679
26751
  return this;
26680
26752
  }
26681
26753
  get names() {
@@ -26692,10 +26764,10 @@ var require_codegen = __commonJS({
26692
26764
  render({ _n }) {
26693
26765
  return `${this.lhs} = ${this.rhs};` + _n;
26694
26766
  }
26695
- optimizeNames(names, constants) {
26767
+ optimizeNames(names, constants2) {
26696
26768
  if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
26697
26769
  return;
26698
- this.rhs = optimizeExpr(this.rhs, names, constants);
26770
+ this.rhs = optimizeExpr(this.rhs, names, constants2);
26699
26771
  return this;
26700
26772
  }
26701
26773
  get names() {
@@ -26756,8 +26828,8 @@ var require_codegen = __commonJS({
26756
26828
  optimizeNodes() {
26757
26829
  return `${this.code}` ? this : void 0;
26758
26830
  }
26759
- optimizeNames(names, constants) {
26760
- this.code = optimizeExpr(this.code, names, constants);
26831
+ optimizeNames(names, constants2) {
26832
+ this.code = optimizeExpr(this.code, names, constants2);
26761
26833
  return this;
26762
26834
  }
26763
26835
  get names() {
@@ -26786,12 +26858,12 @@ var require_codegen = __commonJS({
26786
26858
  }
26787
26859
  return nodes.length > 0 ? this : void 0;
26788
26860
  }
26789
- optimizeNames(names, constants) {
26861
+ optimizeNames(names, constants2) {
26790
26862
  const { nodes } = this;
26791
26863
  let i = nodes.length;
26792
26864
  while (i--) {
26793
26865
  const n = nodes[i];
26794
- if (n.optimizeNames(names, constants))
26866
+ if (n.optimizeNames(names, constants2))
26795
26867
  continue;
26796
26868
  subtractNames(names, n.names);
26797
26869
  nodes.splice(i, 1);
@@ -26844,12 +26916,12 @@ var require_codegen = __commonJS({
26844
26916
  return void 0;
26845
26917
  return this;
26846
26918
  }
26847
- optimizeNames(names, constants) {
26919
+ optimizeNames(names, constants2) {
26848
26920
  var _a;
26849
- this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
26850
- if (!(super.optimizeNames(names, constants) || this.else))
26921
+ this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants2);
26922
+ if (!(super.optimizeNames(names, constants2) || this.else))
26851
26923
  return;
26852
- this.condition = optimizeExpr(this.condition, names, constants);
26924
+ this.condition = optimizeExpr(this.condition, names, constants2);
26853
26925
  return this;
26854
26926
  }
26855
26927
  get names() {
@@ -26872,10 +26944,10 @@ var require_codegen = __commonJS({
26872
26944
  render(opts) {
26873
26945
  return `for(${this.iteration})` + super.render(opts);
26874
26946
  }
26875
- optimizeNames(names, constants) {
26876
- if (!super.optimizeNames(names, constants))
26947
+ optimizeNames(names, constants2) {
26948
+ if (!super.optimizeNames(names, constants2))
26877
26949
  return;
26878
- this.iteration = optimizeExpr(this.iteration, names, constants);
26950
+ this.iteration = optimizeExpr(this.iteration, names, constants2);
26879
26951
  return this;
26880
26952
  }
26881
26953
  get names() {
@@ -26911,10 +26983,10 @@ var require_codegen = __commonJS({
26911
26983
  render(opts) {
26912
26984
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
26913
26985
  }
26914
- optimizeNames(names, constants) {
26915
- if (!super.optimizeNames(names, constants))
26986
+ optimizeNames(names, constants2) {
26987
+ if (!super.optimizeNames(names, constants2))
26916
26988
  return;
26917
- this.iterable = optimizeExpr(this.iterable, names, constants);
26989
+ this.iterable = optimizeExpr(this.iterable, names, constants2);
26918
26990
  return this;
26919
26991
  }
26920
26992
  get names() {
@@ -26956,11 +27028,11 @@ var require_codegen = __commonJS({
26956
27028
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
26957
27029
  return this;
26958
27030
  }
26959
- optimizeNames(names, constants) {
27031
+ optimizeNames(names, constants2) {
26960
27032
  var _a, _b;
26961
- super.optimizeNames(names, constants);
26962
- (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
26963
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
27033
+ super.optimizeNames(names, constants2);
27034
+ (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants2);
27035
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants2);
26964
27036
  return this;
26965
27037
  }
26966
27038
  get names() {
@@ -27230,7 +27302,7 @@ var require_codegen = __commonJS({
27230
27302
  function addExprNames(names, from) {
27231
27303
  return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
27232
27304
  }
27233
- function optimizeExpr(expr, names, constants) {
27305
+ function optimizeExpr(expr, names, constants2) {
27234
27306
  if (expr instanceof code_1.Name)
27235
27307
  return replaceName(expr);
27236
27308
  if (!canOptimize(expr))
@@ -27245,14 +27317,14 @@ var require_codegen = __commonJS({
27245
27317
  return items;
27246
27318
  }, []));
27247
27319
  function replaceName(n) {
27248
- const c = constants[n.str];
27320
+ const c = constants2[n.str];
27249
27321
  if (c === void 0 || names[n.str] !== 1)
27250
27322
  return n;
27251
27323
  delete names[n.str];
27252
27324
  return c;
27253
27325
  }
27254
27326
  function canOptimize(e) {
27255
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0);
27327
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants2[c.str] !== void 0);
27256
27328
  }
27257
27329
  }
27258
27330
  function subtractNames(names, from) {
@@ -38369,7 +38441,7 @@ var require_universalify = __commonJS({
38369
38441
  // ../component-lib/node_modules/graceful-fs/polyfills.js
38370
38442
  var require_polyfills = __commonJS({
38371
38443
  "../component-lib/node_modules/graceful-fs/polyfills.js"(exports2, module2) {
38372
- var constants = require("constants");
38444
+ var constants2 = require("constants");
38373
38445
  var origCwd = process.cwd;
38374
38446
  var cwd = null;
38375
38447
  var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
@@ -38394,7 +38466,7 @@ var require_polyfills = __commonJS({
38394
38466
  var chdir;
38395
38467
  module2.exports = patch;
38396
38468
  function patch(fs) {
38397
- if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
38469
+ if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
38398
38470
  patchLchmod(fs);
38399
38471
  }
38400
38472
  if (!fs.lutimes) {
@@ -38499,7 +38571,7 @@ var require_polyfills = __commonJS({
38499
38571
  }(fs.readSync);
38500
38572
  function patchLchmod(fs2) {
38501
38573
  fs2.lchmod = function(path7, mode, callback) {
38502
- fs2.open(path7, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
38574
+ fs2.open(path7, constants2.O_WRONLY | constants2.O_SYMLINK, mode, function(err, fd) {
38503
38575
  if (err) {
38504
38576
  if (callback)
38505
38577
  callback(err);
@@ -38514,7 +38586,7 @@ var require_polyfills = __commonJS({
38514
38586
  });
38515
38587
  };
38516
38588
  fs2.lchmodSync = function(path7, mode) {
38517
- var fd = fs2.openSync(path7, constants.O_WRONLY | constants.O_SYMLINK, mode);
38589
+ var fd = fs2.openSync(path7, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
38518
38590
  var threw = true;
38519
38591
  var ret;
38520
38592
  try {
@@ -38534,9 +38606,9 @@ var require_polyfills = __commonJS({
38534
38606
  };
38535
38607
  }
38536
38608
  function patchLutimes(fs2) {
38537
- if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
38609
+ if (constants2.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
38538
38610
  fs2.lutimes = function(path7, at, mt, cb) {
38539
- fs2.open(path7, constants.O_SYMLINK, function(er, fd) {
38611
+ fs2.open(path7, constants2.O_SYMLINK, function(er, fd) {
38540
38612
  if (er) {
38541
38613
  if (cb)
38542
38614
  cb(er);
@@ -38551,7 +38623,7 @@ var require_polyfills = __commonJS({
38551
38623
  });
38552
38624
  };
38553
38625
  fs2.lutimesSync = function(path7, at, mt) {
38554
- var fd = fs2.openSync(path7, constants.O_SYMLINK);
38626
+ var fd = fs2.openSync(path7, constants2.O_SYMLINK);
38555
38627
  var ret;
38556
38628
  var threw = true;
38557
38629
  try {
@@ -55582,14 +55654,14 @@ var require_zip_archive_entry = __commonJS({
55582
55654
  var ArchiveEntry = require_archive_entry();
55583
55655
  var GeneralPurposeBit = require_general_purpose_bit();
55584
55656
  var UnixStat = require_unix_stat();
55585
- var constants = require_constants();
55657
+ var constants2 = require_constants();
55586
55658
  var zipUtil = require_util5();
55587
55659
  var ZipArchiveEntry = module2.exports = function(name) {
55588
55660
  if (!(this instanceof ZipArchiveEntry)) {
55589
55661
  return new ZipArchiveEntry(name);
55590
55662
  }
55591
55663
  ArchiveEntry.call(this);
55592
- this.platform = constants.PLATFORM_FAT;
55664
+ this.platform = constants2.PLATFORM_FAT;
55593
55665
  this.method = -1;
55594
55666
  this.name = null;
55595
55667
  this.size = 0;
@@ -55597,7 +55669,7 @@ var require_zip_archive_entry = __commonJS({
55597
55669
  this.gpb = new GeneralPurposeBit();
55598
55670
  this.crc = 0;
55599
55671
  this.time = -1;
55600
- this.minver = constants.MIN_VERSION_INITIAL;
55672
+ this.minver = constants2.MIN_VERSION_INITIAL;
55601
55673
  this.mode = -1;
55602
55674
  this.extra = null;
55603
55675
  this.exattr = 0;
@@ -55624,7 +55696,7 @@ var require_zip_archive_entry = __commonJS({
55624
55696
  return this.exattr;
55625
55697
  };
55626
55698
  ZipArchiveEntry.prototype.getExtra = function() {
55627
- return this.extra !== null ? this.extra : constants.EMPTY;
55699
+ return this.extra !== null ? this.extra : constants2.EMPTY;
55628
55700
  };
55629
55701
  ZipArchiveEntry.prototype.getGeneralPurposeBit = function() {
55630
55702
  return this.gpb;
@@ -55657,7 +55729,7 @@ var require_zip_archive_entry = __commonJS({
55657
55729
  return this.time !== -1 ? this.time : 0;
55658
55730
  };
55659
55731
  ZipArchiveEntry.prototype.getUnixMode = function() {
55660
- return this.platform !== constants.PLATFORM_UNIX ? 0 : this.getExternalAttributes() >> constants.SHORT_SHIFT & constants.SHORT_MASK;
55732
+ return this.platform !== constants2.PLATFORM_UNIX ? 0 : this.getExternalAttributes() >> constants2.SHORT_SHIFT & constants2.SHORT_MASK;
55661
55733
  };
55662
55734
  ZipArchiveEntry.prototype.getVersionNeededToExtract = function() {
55663
55735
  return this.minver;
@@ -55727,12 +55799,12 @@ var require_zip_archive_entry = __commonJS({
55727
55799
  this.time = zipUtil.dateToDos(time, forceLocalTime);
55728
55800
  };
55729
55801
  ZipArchiveEntry.prototype.setUnixMode = function(mode) {
55730
- mode |= this.isDirectory() ? constants.S_IFDIR : constants.S_IFREG;
55802
+ mode |= this.isDirectory() ? constants2.S_IFDIR : constants2.S_IFREG;
55731
55803
  var extattr = 0;
55732
- extattr |= mode << constants.SHORT_SHIFT | (this.isDirectory() ? constants.S_DOS_D : constants.S_DOS_A);
55804
+ extattr |= mode << constants2.SHORT_SHIFT | (this.isDirectory() ? constants2.S_DOS_D : constants2.S_DOS_A);
55733
55805
  this.setExternalAttributes(extattr);
55734
- this.mode = mode & constants.MODE_MASK;
55735
- this.platform = constants.PLATFORM_UNIX;
55806
+ this.mode = mode & constants2.MODE_MASK;
55807
+ this.platform = constants2.PLATFORM_UNIX;
55736
55808
  };
55737
55809
  ZipArchiveEntry.prototype.setVersionNeededToExtract = function(minver) {
55738
55810
  this.minver = minver;
@@ -55744,7 +55816,7 @@ var require_zip_archive_entry = __commonJS({
55744
55816
  return (this.getUnixMode() & UnixStat.FILE_TYPE_FLAG) === UnixStat.LINK_FLAG;
55745
55817
  };
55746
55818
  ZipArchiveEntry.prototype.isZip64 = function() {
55747
- return this.csize > constants.ZIP64_MAGIC || this.size > constants.ZIP64_MAGIC;
55819
+ return this.csize > constants2.ZIP64_MAGIC || this.size > constants2.ZIP64_MAGIC;
55748
55820
  };
55749
55821
  }
55750
55822
  });
@@ -56375,7 +56447,7 @@ var require_zip_archive_output_stream = __commonJS({
56375
56447
  var ArchiveOutputStream = require_archive_output_stream();
56376
56448
  var ZipArchiveEntry = require_zip_archive_entry();
56377
56449
  var GeneralPurposeBit = require_general_purpose_bit();
56378
- var constants = require_constants();
56450
+ var constants2 = require_constants();
56379
56451
  var util = require_util6();
56380
56452
  var zipUtil = require_util5();
56381
56453
  var ZipArchiveOutputStream = module2.exports = function(options) {
@@ -56411,21 +56483,21 @@ var require_zip_archive_output_stream = __commonJS({
56411
56483
  };
56412
56484
  ZipArchiveOutputStream.prototype._appendBuffer = function(ae, source, callback) {
56413
56485
  if (source.length === 0) {
56414
- ae.setMethod(constants.METHOD_STORED);
56486
+ ae.setMethod(constants2.METHOD_STORED);
56415
56487
  }
56416
56488
  var method = ae.getMethod();
56417
- if (method === constants.METHOD_STORED) {
56489
+ if (method === constants2.METHOD_STORED) {
56418
56490
  ae.setSize(source.length);
56419
56491
  ae.setCompressedSize(source.length);
56420
56492
  ae.setCrc(crc32.unsigned(source));
56421
56493
  }
56422
56494
  this._writeLocalFileHeader(ae);
56423
- if (method === constants.METHOD_STORED) {
56495
+ if (method === constants2.METHOD_STORED) {
56424
56496
  this.write(source);
56425
56497
  this._afterAppend(ae);
56426
56498
  callback(null, ae);
56427
56499
  return;
56428
- } else if (method === constants.METHOD_DEFLATED) {
56500
+ } else if (method === constants2.METHOD_DEFLATED) {
56429
56501
  this._smartStream(ae, callback).end(source);
56430
56502
  return;
56431
56503
  } else {
@@ -56435,7 +56507,7 @@ var require_zip_archive_output_stream = __commonJS({
56435
56507
  };
56436
56508
  ZipArchiveOutputStream.prototype._appendStream = function(ae, source, callback) {
56437
56509
  ae.getGeneralPurposeBit().useDataDescriptor(true);
56438
- ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR);
56510
+ ae.setVersionNeededToExtract(constants2.MIN_VERSION_DATA_DESCRIPTOR);
56439
56511
  this._writeLocalFileHeader(ae);
56440
56512
  var smart = this._smartStream(ae, callback);
56441
56513
  source.once("error", function(err) {
@@ -56452,7 +56524,7 @@ var require_zip_archive_output_stream = __commonJS({
56452
56524
  o.zlib = {};
56453
56525
  }
56454
56526
  if (typeof o.zlib.level !== "number") {
56455
- o.zlib.level = constants.ZLIB_BEST_SPEED;
56527
+ o.zlib.level = constants2.ZLIB_BEST_SPEED;
56456
56528
  }
56457
56529
  o.forceZip64 = !!o.forceZip64;
56458
56530
  o.forceLocalTime = !!o.forceLocalTime;
@@ -56475,11 +56547,11 @@ var require_zip_archive_output_stream = __commonJS({
56475
56547
  };
56476
56548
  ZipArchiveOutputStream.prototype._normalizeEntry = function(ae) {
56477
56549
  if (ae.getMethod() === -1) {
56478
- ae.setMethod(constants.METHOD_DEFLATED);
56550
+ ae.setMethod(constants2.METHOD_DEFLATED);
56479
56551
  }
56480
- if (ae.getMethod() === constants.METHOD_DEFLATED) {
56552
+ if (ae.getMethod() === constants2.METHOD_DEFLATED) {
56481
56553
  ae.getGeneralPurposeBit().useDataDescriptor(true);
56482
- ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR);
56554
+ ae.setVersionNeededToExtract(constants2.MIN_VERSION_DATA_DESCRIPTOR);
56483
56555
  }
56484
56556
  if (ae.getTime() === -1) {
56485
56557
  ae.setTime(new Date(), this._archive.forceLocalTime);
@@ -56491,7 +56563,7 @@ var require_zip_archive_output_stream = __commonJS({
56491
56563
  };
56492
56564
  };
56493
56565
  ZipArchiveOutputStream.prototype._smartStream = function(ae, callback) {
56494
- var deflate = ae.getMethod() === constants.METHOD_DEFLATED;
56566
+ var deflate = ae.getMethod() === constants2.METHOD_DEFLATED;
56495
56567
  var process2 = deflate ? new DeflateCRC32Stream(this.options.zlib) : new CRC32Stream();
56496
56568
  var error = null;
56497
56569
  function handleStuff() {
@@ -56514,13 +56586,13 @@ var require_zip_archive_output_stream = __commonJS({
56514
56586
  var size = this._archive.centralLength;
56515
56587
  var offset = this._archive.centralOffset;
56516
56588
  if (this.isZip64()) {
56517
- records = constants.ZIP64_MAGIC_SHORT;
56518
- size = constants.ZIP64_MAGIC;
56519
- offset = constants.ZIP64_MAGIC;
56589
+ records = constants2.ZIP64_MAGIC_SHORT;
56590
+ size = constants2.ZIP64_MAGIC;
56591
+ offset = constants2.ZIP64_MAGIC;
56520
56592
  }
56521
- this.write(zipUtil.getLongBytes(constants.SIG_EOCD));
56522
- this.write(constants.SHORT_ZERO);
56523
- this.write(constants.SHORT_ZERO);
56593
+ this.write(zipUtil.getLongBytes(constants2.SIG_EOCD));
56594
+ this.write(constants2.SHORT_ZERO);
56595
+ this.write(constants2.SHORT_ZERO);
56524
56596
  this.write(zipUtil.getShortBytes(records));
56525
56597
  this.write(zipUtil.getShortBytes(records));
56526
56598
  this.write(zipUtil.getLongBytes(size));
@@ -56531,18 +56603,18 @@ var require_zip_archive_output_stream = __commonJS({
56531
56603
  this.write(comment);
56532
56604
  };
56533
56605
  ZipArchiveOutputStream.prototype._writeCentralDirectoryZip64 = function() {
56534
- this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD));
56606
+ this.write(zipUtil.getLongBytes(constants2.SIG_ZIP64_EOCD));
56535
56607
  this.write(zipUtil.getEightBytes(44));
56536
- this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64));
56537
- this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64));
56538
- this.write(constants.LONG_ZERO);
56539
- this.write(constants.LONG_ZERO);
56608
+ this.write(zipUtil.getShortBytes(constants2.MIN_VERSION_ZIP64));
56609
+ this.write(zipUtil.getShortBytes(constants2.MIN_VERSION_ZIP64));
56610
+ this.write(constants2.LONG_ZERO);
56611
+ this.write(constants2.LONG_ZERO);
56540
56612
  this.write(zipUtil.getEightBytes(this._entries.length));
56541
56613
  this.write(zipUtil.getEightBytes(this._entries.length));
56542
56614
  this.write(zipUtil.getEightBytes(this._archive.centralLength));
56543
56615
  this.write(zipUtil.getEightBytes(this._archive.centralOffset));
56544
- this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD_LOC));
56545
- this.write(constants.LONG_ZERO);
56616
+ this.write(zipUtil.getLongBytes(constants2.SIG_ZIP64_EOCD_LOC));
56617
+ this.write(constants2.LONG_ZERO);
56546
56618
  this.write(zipUtil.getEightBytes(this._archive.centralOffset + this._archive.centralLength));
56547
56619
  this.write(zipUtil.getLongBytes(1));
56548
56620
  };
@@ -56552,12 +56624,12 @@ var require_zip_archive_output_stream = __commonJS({
56552
56624
  var offsets = ae._offsets;
56553
56625
  var size = ae.getSize();
56554
56626
  var compressedSize = ae.getCompressedSize();
56555
- if (ae.isZip64() || offsets.file > constants.ZIP64_MAGIC) {
56556
- size = constants.ZIP64_MAGIC;
56557
- compressedSize = constants.ZIP64_MAGIC;
56558
- ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64);
56627
+ if (ae.isZip64() || offsets.file > constants2.ZIP64_MAGIC) {
56628
+ size = constants2.ZIP64_MAGIC;
56629
+ compressedSize = constants2.ZIP64_MAGIC;
56630
+ ae.setVersionNeededToExtract(constants2.MIN_VERSION_ZIP64);
56559
56631
  var extraBuf = Buffer.concat([
56560
- zipUtil.getShortBytes(constants.ZIP64_EXTRA_ID),
56632
+ zipUtil.getShortBytes(constants2.ZIP64_EXTRA_ID),
56561
56633
  zipUtil.getShortBytes(24),
56562
56634
  zipUtil.getEightBytes(ae.getSize()),
56563
56635
  zipUtil.getEightBytes(ae.getCompressedSize()),
@@ -56565,8 +56637,8 @@ var require_zip_archive_output_stream = __commonJS({
56565
56637
  ], 28);
56566
56638
  ae.setExtra(extraBuf);
56567
56639
  }
56568
- this.write(zipUtil.getLongBytes(constants.SIG_CFH));
56569
- this.write(zipUtil.getShortBytes(ae.getPlatform() << 8 | constants.VERSION_MADEBY));
56640
+ this.write(zipUtil.getLongBytes(constants2.SIG_CFH));
56641
+ this.write(zipUtil.getShortBytes(ae.getPlatform() << 8 | constants2.VERSION_MADEBY));
56570
56642
  this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract()));
56571
56643
  this.write(gpb.encode());
56572
56644
  this.write(zipUtil.getShortBytes(method));
@@ -56584,11 +56656,11 @@ var require_zip_archive_output_stream = __commonJS({
56584
56656
  this.write(zipUtil.getShortBytes(name.length));
56585
56657
  this.write(zipUtil.getShortBytes(extra.length));
56586
56658
  this.write(zipUtil.getShortBytes(comment.length));
56587
- this.write(constants.SHORT_ZERO);
56659
+ this.write(constants2.SHORT_ZERO);
56588
56660
  this.write(zipUtil.getShortBytes(ae.getInternalAttributes()));
56589
56661
  this.write(zipUtil.getLongBytes(ae.getExternalAttributes()));
56590
- if (offsets.file > constants.ZIP64_MAGIC) {
56591
- this.write(zipUtil.getLongBytes(constants.ZIP64_MAGIC));
56662
+ if (offsets.file > constants2.ZIP64_MAGIC) {
56663
+ this.write(zipUtil.getLongBytes(constants2.ZIP64_MAGIC));
56592
56664
  } else {
56593
56665
  this.write(zipUtil.getLongBytes(offsets.file));
56594
56666
  }
@@ -56597,7 +56669,7 @@ var require_zip_archive_output_stream = __commonJS({
56597
56669
  this.write(comment);
56598
56670
  };
56599
56671
  ZipArchiveOutputStream.prototype._writeDataDescriptor = function(ae) {
56600
- this.write(zipUtil.getLongBytes(constants.SIG_DD));
56672
+ this.write(zipUtil.getLongBytes(constants2.SIG_DD));
56601
56673
  this.write(zipUtil.getLongBytes(ae.getCrc()));
56602
56674
  if (ae.isZip64()) {
56603
56675
  this.write(zipUtil.getEightBytes(ae.getCompressedSize()));
@@ -56614,22 +56686,22 @@ var require_zip_archive_output_stream = __commonJS({
56614
56686
  var extra = ae.getLocalFileDataExtra();
56615
56687
  if (ae.isZip64()) {
56616
56688
  gpb.useDataDescriptor(true);
56617
- ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64);
56689
+ ae.setVersionNeededToExtract(constants2.MIN_VERSION_ZIP64);
56618
56690
  }
56619
56691
  if (gpb.usesUTF8ForNames()) {
56620
56692
  name = Buffer.from(name);
56621
56693
  }
56622
56694
  ae._offsets.file = this.offset;
56623
- this.write(zipUtil.getLongBytes(constants.SIG_LFH));
56695
+ this.write(zipUtil.getLongBytes(constants2.SIG_LFH));
56624
56696
  this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract()));
56625
56697
  this.write(gpb.encode());
56626
56698
  this.write(zipUtil.getShortBytes(method));
56627
56699
  this.write(zipUtil.getLongBytes(ae.getTimeDos()));
56628
56700
  ae._offsets.data = this.offset;
56629
56701
  if (gpb.usesDataDescriptor()) {
56630
- this.write(constants.LONG_ZERO);
56631
- this.write(constants.LONG_ZERO);
56632
- this.write(constants.LONG_ZERO);
56702
+ this.write(constants2.LONG_ZERO);
56703
+ this.write(constants2.LONG_ZERO);
56704
+ this.write(constants2.LONG_ZERO);
56633
56705
  } else {
56634
56706
  this.write(zipUtil.getLongBytes(ae.getCrc()));
56635
56707
  this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
@@ -56645,7 +56717,7 @@ var require_zip_archive_output_stream = __commonJS({
56645
56717
  return this._archive.comment !== null ? this._archive.comment : "";
56646
56718
  };
56647
56719
  ZipArchiveOutputStream.prototype.isZip64 = function() {
56648
- return this._archive.forceZip64 || this._entries.length > constants.ZIP64_MAGIC_SHORT || this._archive.centralLength > constants.ZIP64_MAGIC || this._archive.centralOffset > constants.ZIP64_MAGIC;
56720
+ return this._archive.forceZip64 || this._entries.length > constants2.ZIP64_MAGIC_SHORT || this._archive.centralLength > constants2.ZIP64_MAGIC || this._archive.centralOffset > constants2.ZIP64_MAGIC;
56649
56721
  };
56650
56722
  ZipArchiveOutputStream.prototype.setComment = function(comment) {
56651
56723
  this._archive.comment = comment;
@@ -57803,7 +57875,7 @@ var require_end_of_stream2 = __commonJS({
57803
57875
  // ../component-lib/node_modules/tar-stream/pack.js
57804
57876
  var require_pack = __commonJS({
57805
57877
  "../component-lib/node_modules/tar-stream/pack.js"(exports2, module2) {
57806
- var constants = require_fs_constants();
57878
+ var constants2 = require_fs_constants();
57807
57879
  var eos = require_end_of_stream2();
57808
57880
  var inherits = require_inherits2();
57809
57881
  var alloc = Buffer.alloc;
@@ -57822,16 +57894,16 @@ var require_pack = __commonJS({
57822
57894
  self2.push(END_OF_TAR.slice(0, 512 - size));
57823
57895
  };
57824
57896
  function modeToType(mode) {
57825
- switch (mode & constants.S_IFMT) {
57826
- case constants.S_IFBLK:
57897
+ switch (mode & constants2.S_IFMT) {
57898
+ case constants2.S_IFBLK:
57827
57899
  return "block-device";
57828
- case constants.S_IFCHR:
57900
+ case constants2.S_IFCHR:
57829
57901
  return "character-device";
57830
- case constants.S_IFDIR:
57902
+ case constants2.S_IFDIR:
57831
57903
  return "directory";
57832
- case constants.S_IFIFO:
57904
+ case constants2.S_IFIFO:
57833
57905
  return "fifo";
57834
- case constants.S_IFLNK:
57906
+ case constants2.S_IFLNK:
57835
57907
  return "symlink";
57836
57908
  }
57837
57909
  return "file";
@@ -80935,7 +81007,7 @@ var require_universalify2 = __commonJS({
80935
81007
  // node_modules/graceful-fs/polyfills.js
80936
81008
  var require_polyfills2 = __commonJS({
80937
81009
  "node_modules/graceful-fs/polyfills.js"(exports2, module2) {
80938
- var constants = require("constants");
81010
+ var constants2 = require("constants");
80939
81011
  var origCwd = process.cwd;
80940
81012
  var cwd = null;
80941
81013
  var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
@@ -80960,7 +81032,7 @@ var require_polyfills2 = __commonJS({
80960
81032
  var chdir;
80961
81033
  module2.exports = patch;
80962
81034
  function patch(fs) {
80963
- if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
81035
+ if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
80964
81036
  patchLchmod(fs);
80965
81037
  }
80966
81038
  if (!fs.lutimes) {
@@ -81065,7 +81137,7 @@ var require_polyfills2 = __commonJS({
81065
81137
  }(fs.readSync);
81066
81138
  function patchLchmod(fs2) {
81067
81139
  fs2.lchmod = function(path7, mode, callback) {
81068
- fs2.open(path7, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
81140
+ fs2.open(path7, constants2.O_WRONLY | constants2.O_SYMLINK, mode, function(err, fd) {
81069
81141
  if (err) {
81070
81142
  if (callback)
81071
81143
  callback(err);
@@ -81080,7 +81152,7 @@ var require_polyfills2 = __commonJS({
81080
81152
  });
81081
81153
  };
81082
81154
  fs2.lchmodSync = function(path7, mode) {
81083
- var fd = fs2.openSync(path7, constants.O_WRONLY | constants.O_SYMLINK, mode);
81155
+ var fd = fs2.openSync(path7, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
81084
81156
  var threw = true;
81085
81157
  var ret;
81086
81158
  try {
@@ -81100,9 +81172,9 @@ var require_polyfills2 = __commonJS({
81100
81172
  };
81101
81173
  }
81102
81174
  function patchLutimes(fs2) {
81103
- if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
81175
+ if (constants2.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
81104
81176
  fs2.lutimes = function(path7, at, mt, cb) {
81105
- fs2.open(path7, constants.O_SYMLINK, function(er, fd) {
81177
+ fs2.open(path7, constants2.O_SYMLINK, function(er, fd) {
81106
81178
  if (er) {
81107
81179
  if (cb)
81108
81180
  cb(er);
@@ -81117,7 +81189,7 @@ var require_polyfills2 = __commonJS({
81117
81189
  });
81118
81190
  };
81119
81191
  fs2.lutimesSync = function(path7, at, mt) {
81120
- var fd = fs2.openSync(path7, constants.O_SYMLINK);
81192
+ var fd = fs2.openSync(path7, constants2.O_SYMLINK);
81121
81193
  var ret;
81122
81194
  var threw = true;
81123
81195
  try {
@@ -94801,10 +94873,11 @@ var static_default = router3;
94801
94873
  // src/webserver/controllers/core.ts
94802
94874
  var import_component_lib8 = __toESM(require_lib7());
94803
94875
  var import_express4 = __toESM(require_express2());
94804
- var import_path4 = __toESM(require("path"));
94876
+ var import_fs = require("fs");
94805
94877
  var import_fs_extra = __toESM(require_lib10());
94806
94878
  var import_promises = __toESM(require("fs/promises"));
94807
94879
  var import_os2 = __toESM(require("os"));
94880
+ var import_path4 = __toESM(require("path"));
94808
94881
  var router4 = import_express4.default.Router();
94809
94882
  router4.get("/schemas/:version.json", async (req, res, _next) => {
94810
94883
  const schema = import_component_lib8.schemaVersions[req.params.version];
@@ -94814,22 +94887,32 @@ router4.get("/schemas/:version.json", async (req, res, _next) => {
94814
94887
  res.status(200).json(schema);
94815
94888
  });
94816
94889
  router4.get("/health", async (req, res, _next) => {
94890
+ var _a, _b, _c, _d, _e;
94817
94891
  try {
94818
94892
  const packagePath = import_path4.default.resolve("package.json");
94819
94893
  const pkg = JSON.parse(await import_promises.default.readFile(packagePath, { encoding: "utf-8" }));
94820
94894
  if (!pkg.version) {
94821
94895
  throw new import_component_lib8.BadRequestError(`package could not be loaded from ../package.json`);
94822
94896
  }
94823
- const config = ComponentRunner.getConfig();
94824
- if (!await import_fs_extra.default.pathExists(config.dataMountPoint)) {
94825
- throw new import_component_lib8.BadRequestError(`${config.dataMountPoint} does not exist`);
94897
+ const crConfig = ComponentRunner.getConfig();
94898
+ const webConfig = Webserver.getConfig();
94899
+ if (!await import_fs_extra.default.pathExists(crConfig.dataMountPoint)) {
94900
+ throw new import_component_lib8.BadRequestError(`${crConfig.dataMountPoint} does not exist`);
94826
94901
  }
94902
+ const dbHealth = { idle: (_a = req.db) == null ? void 0 : _a.pool.idleCount, max: (_b = req.db) == null ? void 0 : _b.pool.totalCount, waiting: (_c = req.db) == null ? void 0 : _c.pool.waitingCount };
94903
+ if (req.db && req.db.pool.totalCount === 0) {
94904
+ throw new Error("Database has no listeners");
94905
+ }
94906
+ await import_promises.default.access(crConfig.dataMountPoint, import_fs.constants.R_OK);
94827
94907
  res.status(200).send({
94828
94908
  status: "healthy",
94829
94909
  version: pkg.version,
94910
+ buildVersion: (_d = webConfig.compiledConfig) == null ? void 0 : _d.buildVersion,
94911
+ buildBranch: (_e = webConfig.compiledConfig) == null ? void 0 : _e.buildBranch,
94830
94912
  name: pkg.name,
94831
94913
  "number-of-cpus": import_os2.default.cpus().length,
94832
- "number-of-workers": ComponentRunner.get().healthCheck()
94914
+ "number-of-workers": ComponentRunner.get().healthCheck(),
94915
+ db: dbHealth
94833
94916
  });
94834
94917
  } catch (error) {
94835
94918
  req.log.error(error);
@@ -94922,7 +95005,7 @@ var Webserver = class {
94922
95005
  (0, import_strict2.default)(Webserver.config);
94923
95006
  return Webserver.config;
94924
95007
  }
94925
- static async start(config, db) {
95008
+ static async start(config, db, compiledConfig) {
94926
95009
  (0, import_strict2.default)(!Webserver.singleton);
94927
95010
  (0, import_strict2.default)(ComponentRunner.get());
94928
95011
  if (config.shouldRunMigrations === true) {
@@ -94935,7 +95018,7 @@ var Webserver = class {
94935
95018
  throw e;
94936
95019
  }
94937
95020
  }
94938
- config = Webserver.mergeConfig(config);
95021
+ config = Webserver.mergeConfig(config, compiledConfig);
94939
95022
  const app = setupApp(db);
94940
95023
  const server = await new Promise((resolve) => {
94941
95024
  const server2 = app.listen(config.port);
@@ -94954,10 +95037,11 @@ var Webserver = class {
94954
95037
  this.singleton.close();
94955
95038
  this.singleton = void 0;
94956
95039
  }
94957
- static mergeConfig(config) {
95040
+ static mergeConfig(config, compiledConfig = {}) {
94958
95041
  return {
94959
95042
  port: 3e3,
94960
- ...config
95043
+ ...config,
95044
+ compiledConfig
94961
95045
  };
94962
95046
  }
94963
95047
  };
@@ -94982,6 +95066,10 @@ var import_path5 = __toESM(require("path"));
94982
95066
  function getTestConfig(port) {
94983
95067
  const rootDir = (0, import_child_process.execSync)("git rev-parse --show-toplevel", { encoding: "utf-8" }).replace(/\n$/, "");
94984
95068
  return {
95069
+ compiledConfig: {
95070
+ buildVersion: "v1.0.0",
95071
+ buildBranch: "develop"
95072
+ },
94985
95073
  dbConnection: {
94986
95074
  databaseConnectionString: "postgresql://root:root@localhost:5432/cmp_db?schema=public",
94987
95075
  databaseConnectionSecret: false
@@ -95797,7 +95885,7 @@ async function startRenderStack(config) {
95797
95885
  db = new import_component_db_lib.ConnectionManager("render-runtime", connection, "../lib/migrations");
95798
95886
  }
95799
95887
  ComponentRunner.start(config.componentRunner);
95800
- await Webserver.start(config.webserver, db);
95888
+ await Webserver.start(config.webserver, db, config.compiledConfig);
95801
95889
  }
95802
95890
  async function stopRenderStack() {
95803
95891
  Webserver.stop();