@nsshunt/stsfhirpg 1.2.39 → 1.2.41

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.mjs CHANGED
@@ -6153,6 +6153,19 @@ var PGFhirAccessLayer = class extends TinyEmitter {
6153
6153
  #dbSTSCombo;
6154
6154
  #transactions = {};
6155
6155
  #maxTransactionTime = 6e4;
6156
+ _tables = [
6157
+ "stsresfhir",
6158
+ "stsresfhirver",
6159
+ "stsresfhirlink",
6160
+ "stsresfhirstring",
6161
+ "stsresfhirtoken",
6162
+ "stsresfhirquantity",
6163
+ "stsresfhirnumber",
6164
+ "stsresfhiruri",
6165
+ "stsresfhirdate",
6166
+ "stsresfhircoords",
6167
+ "stsresfhircombo"
6168
+ ];
6156
6169
  constructor(options) {
6157
6170
  super();
6158
6171
  this.#options = options;
@@ -6925,6 +6938,114 @@ var PGFhirAccessLayer = class extends TinyEmitter {
6925
6938
  client.release();
6926
6939
  }
6927
6940
  };
6941
+ VacuumGlobal = async () => {
6942
+ if (!this.#poolManager) {
6943
+ const errorMessage = `PGFhirAccessLayer:VacuumGlobal(): poolManager not set`;
6944
+ this.#options.logger.error(errorMessage);
6945
+ throw new Error(errorMessage);
6946
+ }
6947
+ let client;
6948
+ try {
6949
+ client = await this.#poolManager.connectReadWrite();
6950
+ } catch (error) {
6951
+ const message = `PGFhirAccessLayer:VacuumGlobal(): Connection Error: [${error}]`;
6952
+ this.#options.logger.error(message);
6953
+ throw new Error(message);
6954
+ }
6955
+ try {
6956
+ await client.query("VACUUM ANALYZE");
6957
+ } catch (error) {
6958
+ const message = `PGFhirAccessLayer:VacuumGlobal(): Query Error: [${error}]`;
6959
+ this.#options.logger.error(message);
6960
+ throw new Error(message);
6961
+ } finally {
6962
+ client.release();
6963
+ }
6964
+ };
6965
+ Vacuum = async () => {
6966
+ if (!this.#poolManager) {
6967
+ const errorMessage = `PGFhirAccessLayer:Vacuum(): poolManager not set`;
6968
+ this.#options.logger.error(errorMessage);
6969
+ throw new Error(errorMessage);
6970
+ }
6971
+ let client;
6972
+ try {
6973
+ client = await this.#poolManager.connectReadWrite();
6974
+ } catch (error) {
6975
+ const message = `PGFhirAccessLayer:Vacuum(): Connection Error: [${error}]`;
6976
+ this.#options.logger.error(message);
6977
+ throw new Error(message);
6978
+ }
6979
+ try {
6980
+ for (const table of this._tables) await client.query(`VACUUM ANALYZE ${table}`);
6981
+ } catch (error) {
6982
+ const message = `PGFhirAccessLayer:Vacuum(): Query Error: [${error}]`;
6983
+ this.#options.logger.error(message);
6984
+ throw new Error(message);
6985
+ } finally {
6986
+ client.release();
6987
+ }
6988
+ };
6989
+ DisableAutoVacuum = async () => {
6990
+ if (!this.#poolManager) {
6991
+ const errorMessage = `PGFhirAccessLayer:DisableAutoVacuum(): poolManager not set`;
6992
+ this.#options.logger.error(errorMessage);
6993
+ throw new Error(errorMessage);
6994
+ }
6995
+ let client;
6996
+ try {
6997
+ client = await this.#poolManager.connectReadWrite();
6998
+ } catch (error) {
6999
+ const message = `PGFhirAccessLayer:DisableAutoVacuum(): Connection Error: [${error}]`;
7000
+ this.#options.logger.error(message);
7001
+ throw new Error(message);
7002
+ }
7003
+ try {
7004
+ for (const table of this._tables) await client.query(`
7005
+ ALTER TABLE ${table}
7006
+ SET (
7007
+ autovacuum_enabled = false,
7008
+ autovacuum_analyze_enabled = false
7009
+ )
7010
+ `);
7011
+ } catch (error) {
7012
+ const message = `PGFhirAccessLayer:DisableAutoVacuum(): Query Error: [${error}]`;
7013
+ this.#options.logger.error(message);
7014
+ throw new Error(message);
7015
+ } finally {
7016
+ client.release();
7017
+ }
7018
+ };
7019
+ EnableAutoVacuum = async () => {
7020
+ if (!this.#poolManager) {
7021
+ const errorMessage = `PGFhirAccessLayer:EnableAutoVacuum(): poolManager not set`;
7022
+ this.#options.logger.error(errorMessage);
7023
+ throw new Error(errorMessage);
7024
+ }
7025
+ let client;
7026
+ try {
7027
+ client = await this.#poolManager.connectReadWrite();
7028
+ } catch (error) {
7029
+ const message = `PGFhirAccessLayer:EnableAutoVacuum(): Connection Error: [${error}]`;
7030
+ this.#options.logger.error(message);
7031
+ throw new Error(message);
7032
+ }
7033
+ try {
7034
+ for (const table of this._tables) await client.query(`
7035
+ ALTER TABLE ${table}
7036
+ RESET (
7037
+ autovacuum_enabled,
7038
+ autovacuum_analyze_enabled
7039
+ )
7040
+ `);
7041
+ } catch (error) {
7042
+ const message = `PGFhirAccessLayer:EnableAutoVacuum(): Query Error: [${error}]`;
7043
+ this.#options.logger.error(message);
7044
+ throw new Error(message);
7045
+ } finally {
7046
+ client.release();
7047
+ }
7048
+ };
6928
7049
  };
6929
7050
  //#endregion
6930
7051
  export { DBSearchIndex, FHIRDateUtils, PGFhirAccessLayer, ResourceHelper, hashReferenceParam, hashStringParam, hashTokenParam, hashUriParam, initHash, normalizeStringParam, xxhash64Signed };