@nsshunt/stsfhirpg 1.2.40 → 1.2.42

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/dist/index.cjs CHANGED
@@ -6180,6 +6180,19 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
6180
6180
  #dbSTSCombo;
6181
6181
  #transactions = {};
6182
6182
  #maxTransactionTime = 6e4;
6183
+ _tables = [
6184
+ "stsresfhir",
6185
+ "stsresfhirver",
6186
+ "stsresfhirlink",
6187
+ "stsresfhirstring",
6188
+ "stsresfhirtoken",
6189
+ "stsresfhirquantity",
6190
+ "stsresfhirnumber",
6191
+ "stsresfhiruri",
6192
+ "stsresfhirdate",
6193
+ "stsresfhircoords",
6194
+ "stsresfhircombo"
6195
+ ];
6183
6196
  constructor(options) {
6184
6197
  super();
6185
6198
  this.#options = options;
@@ -6952,6 +6965,30 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
6952
6965
  client.release();
6953
6966
  }
6954
6967
  };
6968
+ VacuumGlobal = async () => {
6969
+ if (!this.#poolManager) {
6970
+ const errorMessage = `PGFhirAccessLayer:VacuumGlobal(): poolManager not set`;
6971
+ this.#options.logger.error(errorMessage);
6972
+ throw new Error(errorMessage);
6973
+ }
6974
+ let client;
6975
+ try {
6976
+ client = await this.#poolManager.connectReadWrite();
6977
+ } catch (error) {
6978
+ const message = `PGFhirAccessLayer:VacuumGlobal(): Connection Error: [${error}]`;
6979
+ this.#options.logger.error(message);
6980
+ throw new Error(message);
6981
+ }
6982
+ try {
6983
+ await client.query("VACUUM ANALYZE");
6984
+ } catch (error) {
6985
+ const message = `PGFhirAccessLayer:VacuumGlobal(): Query Error: [${error}]`;
6986
+ this.#options.logger.error(message);
6987
+ throw new Error(message);
6988
+ } finally {
6989
+ client.release();
6990
+ }
6991
+ };
6955
6992
  Vacuum = async () => {
6956
6993
  if (!this.#poolManager) {
6957
6994
  const errorMessage = `PGFhirAccessLayer:Vacuum(): poolManager not set`;
@@ -6967,7 +7004,7 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
6967
7004
  throw new Error(message);
6968
7005
  }
6969
7006
  try {
6970
- await client.query("VACUUM ANALYZE");
7007
+ for (const table of this._tables) await client.query(`VACUUM ANALYZE ${table}`);
6971
7008
  } catch (error) {
6972
7009
  const message = `PGFhirAccessLayer:Vacuum(): Query Error: [${error}]`;
6973
7010
  this.#options.logger.error(message);
@@ -6976,6 +7013,60 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
6976
7013
  client.release();
6977
7014
  }
6978
7015
  };
7016
+ DisableAutoVacuum = async () => {
7017
+ if (!this.#poolManager) {
7018
+ const errorMessage = `PGFhirAccessLayer:DisableAutoVacuum(): poolManager not set`;
7019
+ this.#options.logger.error(errorMessage);
7020
+ throw new Error(errorMessage);
7021
+ }
7022
+ let client;
7023
+ try {
7024
+ client = await this.#poolManager.connectReadWrite();
7025
+ } catch (error) {
7026
+ const message = `PGFhirAccessLayer:DisableAutoVacuum(): Connection Error: [${error}]`;
7027
+ this.#options.logger.error(message);
7028
+ throw new Error(message);
7029
+ }
7030
+ try {
7031
+ for (const table of this._tables) await client.query(`
7032
+ ALTER TABLE ${table}
7033
+ SET (autovacuum_enabled = false)
7034
+ `);
7035
+ } catch (error) {
7036
+ const message = `PGFhirAccessLayer:DisableAutoVacuum(): Query Error: [${error}]`;
7037
+ this.#options.logger.error(message);
7038
+ throw new Error(message);
7039
+ } finally {
7040
+ client.release();
7041
+ }
7042
+ };
7043
+ EnableAutoVacuum = async () => {
7044
+ if (!this.#poolManager) {
7045
+ const errorMessage = `PGFhirAccessLayer:EnableAutoVacuum(): poolManager not set`;
7046
+ this.#options.logger.error(errorMessage);
7047
+ throw new Error(errorMessage);
7048
+ }
7049
+ let client;
7050
+ try {
7051
+ client = await this.#poolManager.connectReadWrite();
7052
+ } catch (error) {
7053
+ const message = `PGFhirAccessLayer:EnableAutoVacuum(): Connection Error: [${error}]`;
7054
+ this.#options.logger.error(message);
7055
+ throw new Error(message);
7056
+ }
7057
+ try {
7058
+ for (const table of this._tables) await client.query(`
7059
+ ALTER TABLE ${table}
7060
+ RESET (autovacuum_enabled)
7061
+ `);
7062
+ } catch (error) {
7063
+ const message = `PGFhirAccessLayer:EnableAutoVacuum(): Query Error: [${error}]`;
7064
+ this.#options.logger.error(message);
7065
+ throw new Error(message);
7066
+ } finally {
7067
+ client.release();
7068
+ }
7069
+ };
6979
7070
  };
6980
7071
  //#endregion
6981
7072
  exports.DBSearchIndex = DBSearchIndex;