@nsshunt/stsfhirpg 1.0.11 → 1.0.13

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.
@@ -5,16 +5,16 @@ const stsutils = require("@nsshunt/stsutils");
5
5
  const stsfhirclient = require("@nsshunt/stsfhirclient");
6
6
  const stsconfig = require("@nsshunt/stsconfig");
7
7
  const cluster = require("cluster");
8
- const require$$0$1 = require("crypto");
9
- const require$$0$4 = require("events");
10
- const require$$1 = require("util");
11
- const require$$0$3 = require("dns");
12
- const require$$0$2 = require("fs");
13
- const require$$0$5 = require("net");
14
- const require$$1$1 = require("tls");
15
- const require$$0$8 = require("path");
16
- const require$$0$7 = require("stream");
17
- const require$$0$6 = require("buffer");
8
+ const require$$0 = require("crypto");
9
+ const require$$0$3 = require("events");
10
+ const require$$1$1 = require("util");
11
+ const require$$0$2 = require("dns");
12
+ const require$$0$1 = require("fs");
13
+ const require$$0$4 = require("net");
14
+ const require$$1$2 = require("tls");
15
+ const require$$0$7 = require("path");
16
+ const require$$0$6 = require("stream");
17
+ const require$$0$5 = require("buffer");
18
18
  class LuxonError extends Error {
19
19
  }
20
20
  class InvalidDateTimeError extends LuxonError {
@@ -12553,7 +12553,7 @@ function requireUtils$1() {
12553
12553
  if (hasRequiredUtils$1) return utils$1;
12554
12554
  hasRequiredUtils$1 = 1;
12555
12555
  const defaults2 = requireDefaults();
12556
- const util2 = require$$1;
12556
+ const util2 = require$$1$1;
12557
12557
  const { isDate: isDate2 } = util2.types || util2;
12558
12558
  function escapeElement(elementRepresentation) {
12559
12559
  const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
@@ -12711,7 +12711,7 @@ var hasRequiredUtilsLegacy;
12711
12711
  function requireUtilsLegacy() {
12712
12712
  if (hasRequiredUtilsLegacy) return utilsLegacy;
12713
12713
  hasRequiredUtilsLegacy = 1;
12714
- const nodeCrypto = require$$0$1;
12714
+ const nodeCrypto = require$$0;
12715
12715
  function md5(string) {
12716
12716
  return nodeCrypto.createHash("md5").update(string, "utf-8").digest("hex");
12717
12717
  }
@@ -12749,7 +12749,7 @@ var hasRequiredUtilsWebcrypto;
12749
12749
  function requireUtilsWebcrypto() {
12750
12750
  if (hasRequiredUtilsWebcrypto) return utilsWebcrypto;
12751
12751
  hasRequiredUtilsWebcrypto = 1;
12752
- const nodeCrypto = require$$0$1;
12752
+ const nodeCrypto = require$$0;
12753
12753
  utilsWebcrypto = {
12754
12754
  postgresMd5PasswordHash,
12755
12755
  randomBytes,
@@ -13182,7 +13182,7 @@ function requirePgConnectionString() {
13182
13182
  if (config.sslcert || config.sslkey || config.sslrootcert || config.sslmode) {
13183
13183
  config.ssl = {};
13184
13184
  }
13185
- const fs2 = config.sslcert || config.sslkey || config.sslrootcert ? require$$0$2 : null;
13185
+ const fs2 = config.sslcert || config.sslkey || config.sslrootcert ? require$$0$1 : null;
13186
13186
  if (config.sslcert) {
13187
13187
  config.ssl.cert = fs2.readFileSync(config.sslcert).toString();
13188
13188
  }
@@ -13311,7 +13311,7 @@ var hasRequiredConnectionParameters;
13311
13311
  function requireConnectionParameters() {
13312
13312
  if (hasRequiredConnectionParameters) return connectionParameters;
13313
13313
  hasRequiredConnectionParameters = 1;
13314
- const dns = require$$0$3;
13314
+ const dns = require$$0$2;
13315
13315
  const defaults2 = requireDefaults();
13316
13316
  const parse2 = requirePgConnectionString().parse;
13317
13317
  const val = function(key, config, envVar) {
@@ -13543,7 +13543,7 @@ var hasRequiredQuery$1;
13543
13543
  function requireQuery$1() {
13544
13544
  if (hasRequiredQuery$1) return query$1;
13545
13545
  hasRequiredQuery$1 = 1;
13546
- const { EventEmitter } = require$$0$4;
13546
+ const { EventEmitter } = require$$0$3;
13547
13547
  const Result = requireResult();
13548
13548
  const utils2 = requireUtils$1();
13549
13549
  class Query extends EventEmitter {
@@ -14207,11 +14207,10 @@ function requireBufferReader() {
14207
14207
  hasRequiredBufferReader = 1;
14208
14208
  Object.defineProperty(bufferReader, "__esModule", { value: true });
14209
14209
  bufferReader.BufferReader = void 0;
14210
- const emptyBuffer = Buffer.allocUnsafe(0);
14211
14210
  class BufferReader {
14212
14211
  constructor(offset2 = 0) {
14213
14212
  this.offset = offset2;
14214
- this.buffer = emptyBuffer;
14213
+ this.buffer = Buffer.allocUnsafe(0);
14215
14214
  this.encoding = "utf-8";
14216
14215
  }
14217
14216
  setBuffer(offset2, buffer) {
@@ -14621,11 +14620,11 @@ function requireStream() {
14621
14620
  };
14622
14621
  function getNodejsStreamFuncs() {
14623
14622
  function getStream2(ssl) {
14624
- const net = require$$0$5;
14623
+ const net = require$$0$4;
14625
14624
  return new net.Socket();
14626
14625
  }
14627
14626
  function getSecureStream2(options) {
14628
- const tls = require$$1$1;
14627
+ const tls = require$$1$2;
14629
14628
  return tls.connect(options);
14630
14629
  }
14631
14630
  return {
@@ -14672,7 +14671,7 @@ var hasRequiredConnection;
14672
14671
  function requireConnection() {
14673
14672
  if (hasRequiredConnection) return connection;
14674
14673
  hasRequiredConnection = 1;
14675
- const EventEmitter = require$$0$4.EventEmitter;
14674
+ const EventEmitter = require$$0$3.EventEmitter;
14676
14675
  const { parse: parse2, serialize } = requireDist();
14677
14676
  const { getStream, getSecureStream } = requireStream();
14678
14677
  const flushBuffer = serialize.flush();
@@ -14744,7 +14743,7 @@ function requireConnection() {
14744
14743
  options.key = self2.ssl.key;
14745
14744
  }
14746
14745
  }
14747
- const net = require$$0$5;
14746
+ const net = require$$0$4;
14748
14747
  if (net.isIP && net.isIP(host) === 0) {
14749
14748
  options.servername = host;
14750
14749
  }
@@ -14859,7 +14858,7 @@ function requireSafeBuffer() {
14859
14858
  if (hasRequiredSafeBuffer) return safeBuffer.exports;
14860
14859
  hasRequiredSafeBuffer = 1;
14861
14860
  (function(module2, exports$1) {
14862
- var buffer = require$$0$6;
14861
+ var buffer = require$$0$5;
14863
14862
  var Buffer2 = buffer.Buffer;
14864
14863
  function copyProps(src, dst) {
14865
14864
  for (var key in src) {
@@ -15156,7 +15155,7 @@ var hasRequiredSplit2;
15156
15155
  function requireSplit2() {
15157
15156
  if (hasRequiredSplit2) return split2;
15158
15157
  hasRequiredSplit2 = 1;
15159
- const { Transform } = require$$0$7;
15158
+ const { Transform } = require$$0$6;
15160
15159
  const { StringDecoder } = requireString_decoder();
15161
15160
  const kLast = /* @__PURE__ */ Symbol("last");
15162
15161
  const kDecoder = /* @__PURE__ */ Symbol("decoder");
@@ -15257,7 +15256,7 @@ function requireHelper() {
15257
15256
  if (hasRequiredHelper) return helper.exports;
15258
15257
  hasRequiredHelper = 1;
15259
15258
  (function(module2) {
15260
- var path = require$$0$8, Stream = require$$0$7.Stream, split = requireSplit2(), util2 = require$$1, defaultPort = 5432, isWin = process.platform === "win32", warnStream = process.stderr;
15259
+ var path = require$$0$7, Stream = require$$0$6.Stream, split = requireSplit2(), util2 = require$$1$1, defaultPort = 5432, isWin = process.platform === "win32", warnStream = process.stderr;
15261
15260
  var S_IRWXG = 56, S_IRWXO = 7, S_IFMT = 61440, S_IFREG = 32768;
15262
15261
  function isRegFile(mode) {
15263
15262
  return (mode & S_IFMT) == S_IFREG;
@@ -15418,7 +15417,7 @@ var hasRequiredLib$1;
15418
15417
  function requireLib$1() {
15419
15418
  if (hasRequiredLib$1) return lib.exports;
15420
15419
  hasRequiredLib$1 = 1;
15421
- var fs2 = require$$0$2, helper2 = requireHelper();
15420
+ var fs2 = require$$0$1, helper2 = requireHelper();
15422
15421
  lib.exports = function(connInfo, cb) {
15423
15422
  var file = helper2.getFileName();
15424
15423
  fs2.stat(file, function(err, stat) {
@@ -15437,9 +15436,9 @@ var hasRequiredClient$1;
15437
15436
  function requireClient$1() {
15438
15437
  if (hasRequiredClient$1) return client$1;
15439
15438
  hasRequiredClient$1 = 1;
15440
- const EventEmitter = require$$0$4.EventEmitter;
15439
+ const EventEmitter = require$$0$3.EventEmitter;
15441
15440
  const utils2 = requireUtils$1();
15442
- const nodeUtils = require$$1;
15441
+ const nodeUtils = require$$1$1;
15443
15442
  const sasl2 = requireSasl();
15444
15443
  const TypeOverrides = requireTypeOverrides();
15445
15444
  const ConnectionParameters = requireConnectionParameters();
@@ -15450,22 +15449,27 @@ function requireClient$1() {
15450
15449
  const activeQueryDeprecationNotice = nodeUtils.deprecate(
15451
15450
  () => {
15452
15451
  },
15453
- "Client.activeQuery is deprecated and will be removed in a future version."
15452
+ "Client.activeQuery is deprecated and will be removed in pg@9.0"
15454
15453
  );
15455
15454
  const queryQueueDeprecationNotice = nodeUtils.deprecate(
15456
15455
  () => {
15457
15456
  },
15458
- "Client.queryQueue is deprecated and will be removed in a future version."
15457
+ "Client.queryQueue is deprecated and will be removed in pg@9.0."
15459
15458
  );
15460
15459
  const pgPassDeprecationNotice = nodeUtils.deprecate(
15461
15460
  () => {
15462
15461
  },
15463
- "pgpass support is deprecated and will be removed in a future version. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this funciton you can call the pgpass module in your own code."
15462
+ "pgpass support is deprecated and will be removed in pg@9.0. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code."
15464
15463
  );
15465
15464
  const byoPromiseDeprecationNotice = nodeUtils.deprecate(
15466
15465
  () => {
15467
15466
  },
15468
- "Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in a future version."
15467
+ "Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0."
15468
+ );
15469
+ const queryQueueLengthDeprecationNotice = nodeUtils.deprecate(
15470
+ () => {
15471
+ },
15472
+ "Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead."
15469
15473
  );
15470
15474
  class Client extends EventEmitter {
15471
15475
  constructor(config) {
@@ -15637,7 +15641,7 @@ function requireClient$1() {
15637
15641
  _getPassword(cb) {
15638
15642
  const con = this.connection;
15639
15643
  if (typeof this.password === "function") {
15640
- this._Promise.resolve().then(() => this.password()).then((pass) => {
15644
+ this._Promise.resolve().then(() => this.password(this.connectionParameters)).then((pass) => {
15641
15645
  if (pass !== void 0) {
15642
15646
  if (typeof pass !== "string") {
15643
15647
  con.emit("error", new TypeError("Password must be a string"));
@@ -15943,8 +15947,12 @@ function requireClient$1() {
15943
15947
  } else if (typeof config.submit === "function") {
15944
15948
  readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
15945
15949
  result2 = query2 = config;
15946
- if (typeof values === "function") {
15947
- query2.callback = query2.callback || values;
15950
+ if (!query2.callback) {
15951
+ if (typeof values === "function") {
15952
+ query2.callback = values;
15953
+ } else if (callback) {
15954
+ query2.callback = callback;
15955
+ }
15948
15956
  }
15949
15957
  } else {
15950
15958
  readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
@@ -15959,7 +15967,8 @@ function requireClient$1() {
15959
15967
  }
15960
15968
  }
15961
15969
  if (readTimeout) {
15962
- queryCallback = query2.callback;
15970
+ queryCallback = query2.callback || (() => {
15971
+ });
15963
15972
  readTimeoutTimer = setTimeout(() => {
15964
15973
  const error = new Error("Query read timeout");
15965
15974
  process.nextTick(() => {
@@ -15997,6 +16006,9 @@ function requireClient$1() {
15997
16006
  });
15998
16007
  return result2;
15999
16008
  }
16009
+ if (this._queryQueue.length > 0) {
16010
+ queryQueueLengthDeprecationNotice();
16011
+ }
16000
16012
  this._queryQueue.push(query2);
16001
16013
  this._pulseQueryQueue();
16002
16014
  return result2;
@@ -16043,7 +16055,7 @@ var hasRequiredPgPool;
16043
16055
  function requirePgPool() {
16044
16056
  if (hasRequiredPgPool) return pgPool;
16045
16057
  hasRequiredPgPool = 1;
16046
- const EventEmitter = require$$0$4.EventEmitter;
16058
+ const EventEmitter = require$$0$3.EventEmitter;
16047
16059
  const NOOP = function() {
16048
16060
  };
16049
16061
  const removeWhere = (list, predicate) => {
@@ -16131,6 +16143,13 @@ function requirePgPool() {
16131
16143
  this.ending = false;
16132
16144
  this.ended = false;
16133
16145
  }
16146
+ _promiseTry(f) {
16147
+ const Promise2 = this.Promise;
16148
+ if (typeof Promise2.try === "function") {
16149
+ return Promise2.try(f);
16150
+ }
16151
+ return new Promise2((resolve) => resolve(f()));
16152
+ }
16134
16153
  _isFull() {
16135
16154
  return this._clients.length >= this.options.max;
16136
16155
  }
@@ -16234,9 +16253,15 @@ function requirePgPool() {
16234
16253
  let timeoutHit = false;
16235
16254
  if (this.options.connectionTimeoutMillis) {
16236
16255
  tid = setTimeout(() => {
16237
- this.log("ending client due to timeout");
16238
- timeoutHit = true;
16239
- client2.connection ? client2.connection.stream.destroy() : client2.end();
16256
+ if (client2.connection) {
16257
+ this.log("ending client due to timeout");
16258
+ timeoutHit = true;
16259
+ client2.connection.stream.destroy();
16260
+ } else if (!client2.isConnected()) {
16261
+ this.log("ending client due to timeout");
16262
+ timeoutHit = true;
16263
+ client2.end();
16264
+ }
16240
16265
  }, this.options.connectionTimeoutMillis);
16241
16266
  }
16242
16267
  this.log("connecting new client");
@@ -16257,27 +16282,47 @@ function requirePgPool() {
16257
16282
  }
16258
16283
  } else {
16259
16284
  this.log("new client connected");
16260
- if (this.options.maxLifetimeSeconds !== 0) {
16261
- const maxLifetimeTimeout = setTimeout(() => {
16262
- this.log("ending client due to expired lifetime");
16263
- this._expired.add(client2);
16264
- const idleIndex = this._idle.findIndex((idleItem) => idleItem.client === client2);
16265
- if (idleIndex !== -1) {
16266
- this._acquireClient(
16267
- client2,
16268
- new PendingItem((err2, client3, clientRelease) => clientRelease()),
16269
- idleListener,
16270
- false
16271
- );
16285
+ if (this.options.onConnect) {
16286
+ this._promiseTry(() => this.options.onConnect(client2)).then(
16287
+ () => {
16288
+ this._afterConnect(client2, pendingItem, idleListener);
16289
+ },
16290
+ (hookErr) => {
16291
+ this._clients = this._clients.filter((c) => c !== client2);
16292
+ client2.end(() => {
16293
+ this._pulseQueue();
16294
+ if (!pendingItem.timedOut) {
16295
+ pendingItem.callback(hookErr, void 0, NOOP);
16296
+ }
16297
+ });
16272
16298
  }
16273
- }, this.options.maxLifetimeSeconds * 1e3);
16274
- maxLifetimeTimeout.unref();
16275
- client2.once("end", () => clearTimeout(maxLifetimeTimeout));
16299
+ );
16300
+ return;
16276
16301
  }
16277
- return this._acquireClient(client2, pendingItem, idleListener, true);
16302
+ return this._afterConnect(client2, pendingItem, idleListener);
16278
16303
  }
16279
16304
  });
16280
16305
  }
16306
+ _afterConnect(client2, pendingItem, idleListener) {
16307
+ if (this.options.maxLifetimeSeconds !== 0) {
16308
+ const maxLifetimeTimeout = setTimeout(() => {
16309
+ this.log("ending client due to expired lifetime");
16310
+ this._expired.add(client2);
16311
+ const idleIndex = this._idle.findIndex((idleItem) => idleItem.client === client2);
16312
+ if (idleIndex !== -1) {
16313
+ this._acquireClient(
16314
+ client2,
16315
+ new PendingItem((err, client3, clientRelease) => clientRelease()),
16316
+ idleListener,
16317
+ false
16318
+ );
16319
+ }
16320
+ }, this.options.maxLifetimeSeconds * 1e3);
16321
+ maxLifetimeTimeout.unref();
16322
+ client2.once("end", () => clearTimeout(maxLifetimeTimeout));
16323
+ }
16324
+ return this._acquireClient(client2, pendingItem, idleListener, true);
16325
+ }
16281
16326
  // acquire a client for a pending work item
16282
16327
  _acquireClient(client2, pendingItem, idleListener, isNew) {
16283
16328
  if (isNew) {
@@ -16437,14 +16482,14 @@ const __viteOptionalPeerDep_pgNative_pg_true$1 = /* @__PURE__ */ Object.freeze(/
16437
16482
  __proto__: null,
16438
16483
  default: __viteOptionalPeerDep_pgNative_pg_true
16439
16484
  }, Symbol.toStringTag, { value: "Module" }));
16440
- const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteOptionalPeerDep_pgNative_pg_true$1);
16485
+ const require$$1 = /* @__PURE__ */ getAugmentedNamespace(__viteOptionalPeerDep_pgNative_pg_true$1);
16441
16486
  var query = { exports: {} };
16442
16487
  var hasRequiredQuery;
16443
16488
  function requireQuery() {
16444
16489
  if (hasRequiredQuery) return query.exports;
16445
16490
  hasRequiredQuery = 1;
16446
- const EventEmitter = require$$0$4.EventEmitter;
16447
- const util2 = require$$1;
16491
+ const EventEmitter = require$$0$3.EventEmitter;
16492
+ const util2 = require$$1$1;
16448
16493
  const utils2 = requireUtils$1();
16449
16494
  const NativeQuery = query.exports = function(config, values, callback) {
16450
16495
  EventEmitter.call(this);
@@ -16583,17 +16628,23 @@ var hasRequiredClient;
16583
16628
  function requireClient() {
16584
16629
  if (hasRequiredClient) return client.exports;
16585
16630
  hasRequiredClient = 1;
16631
+ const nodeUtils = require$$1$1;
16586
16632
  var Native;
16587
16633
  try {
16588
- Native = require$$0;
16634
+ Native = require$$1;
16589
16635
  } catch (e) {
16590
16636
  throw e;
16591
16637
  }
16592
16638
  const TypeOverrides = requireTypeOverrides();
16593
- const EventEmitter = require$$0$4.EventEmitter;
16594
- const util2 = require$$1;
16639
+ const EventEmitter = require$$0$3.EventEmitter;
16640
+ const util2 = require$$1$1;
16595
16641
  const ConnectionParameters = requireConnectionParameters();
16596
16642
  const NativeQuery = requireQuery();
16643
+ const queryQueueLengthDeprecationNotice = nodeUtils.deprecate(
16644
+ () => {
16645
+ },
16646
+ "Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead."
16647
+ );
16597
16648
  const Client = client.exports = function(config) {
16598
16649
  EventEmitter.call(this);
16599
16650
  config = config || {};
@@ -16715,7 +16766,8 @@ function requireClient() {
16715
16766
  }
16716
16767
  }
16717
16768
  if (readTimeout) {
16718
- queryCallback = query2.callback;
16769
+ queryCallback = query2.callback || (() => {
16770
+ });
16719
16771
  readTimeoutTimer = setTimeout(() => {
16720
16772
  const error = new Error("Query read timeout");
16721
16773
  process.nextTick(() => {
@@ -16749,6 +16801,9 @@ function requireClient() {
16749
16801
  });
16750
16802
  return result2;
16751
16803
  }
16804
+ if (this._queryQueue.length > 0) {
16805
+ queryQueueLengthDeprecationNotice();
16806
+ }
16752
16807
  this._queryQueue.push(query2);
16753
16808
  this._pulseQueryQueue();
16754
16809
  return result2;
@@ -16766,6 +16821,7 @@ function requireClient() {
16766
16821
  });
16767
16822
  }
16768
16823
  this.native.end(function() {
16824
+ self2._connected = false;
16769
16825
  self2._errorAllQueries(new Error("Connection terminated"));
16770
16826
  process.nextTick(() => {
16771
16827
  self2.emit("end");
@@ -16816,6 +16872,9 @@ function requireClient() {
16816
16872
  Client.prototype.getTypeParser = function(oid, format) {
16817
16873
  return this._types.getTypeParser(oid, format);
16818
16874
  };
16875
+ Client.prototype.isConnected = function() {
16876
+ return this._connected;
16877
+ };
16819
16878
  return client.exports;
16820
16879
  }
16821
16880
  var native;
@@ -17075,7 +17134,7 @@ class PGPoolManager extends tinyEmitterExports.TinyEmitter {
17075
17134
  return this.#pools[this.#GetPoolKey(0)].pool.connect();
17076
17135
  }
17077
17136
  async connectReadOnly() {
17078
- const poolIndex = require$$0$1.randomInt(0, Object.keys(this.#pools).length);
17137
+ const poolIndex = require$$0.randomInt(0, Object.keys(this.#pools).length);
17079
17138
  return this.#pools[this.#GetPoolKey(poolIndex)].pool.connect();
17080
17139
  }
17081
17140
  //@@ make event using TinyEmitter