@rotorsoft/act-pg 1.13.4 → 1.13.6

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.js CHANGED
@@ -27,10 +27,13 @@ var dateReviver = (_key, value) => {
27
27
  var logger = log();
28
28
  var SOURCE_METACHARACTER_CLASS = "[]^$.*+?()[{}|\\\\]";
29
29
  var { Pool, types } = pg;
30
- types.setTypeParser(
31
- types.builtins.JSONB,
32
- (val) => JSON.parse(val, dateReviver)
33
- );
30
+ var JSONB_OID = types.builtins.JSONB;
31
+ var scopedTypes = {
32
+ getTypeParser: ((oid, format) => oid === JSONB_OID ? (val) => JSON.parse(val, dateReviver) : types.getTypeParser(
33
+ oid,
34
+ format
35
+ ))
36
+ };
34
37
  var SAFE_IDENTIFIER = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
35
38
  var PG_UNIQUE_VIOLATION = "23505";
36
39
  var NOTIFY_CHANNEL_PREFIX = "act_commit";
@@ -172,7 +175,7 @@ var PostgresStore = class {
172
175
  pii_encryption: ___,
173
176
  ...poolConfig
174
177
  } = this.config;
175
- this._pool = new Pool(poolConfig);
178
+ this._pool = new Pool({ ...poolConfig, types: scopedTypes });
176
179
  this._fqt = `"${this.config.schema}"."${this.config.table}"`;
177
180
  this._fqs = `"${this.config.schema}"."${this.config.table}_streams"`;
178
181
  this._channel = notify_channel(this.config.schema, this.config.table);
@@ -420,11 +423,11 @@ var PostgresStore = class {
420
423
  query.stream_exact ? `stream = $${values.length}` : `stream ~ $${values.length}`
421
424
  );
422
425
  }
423
- if (names?.length) {
426
+ if (names !== void 0) {
424
427
  values.push(names);
425
428
  conditions.push(`name = ANY($${values.length})`);
426
429
  }
427
- if (before) {
430
+ if (before !== void 0) {
428
431
  values.push(before);
429
432
  conditions.push(`id<$${values.length}`);
430
433
  }
@@ -996,7 +999,7 @@ var PostgresStore = class {
996
999
  values.push(query.after);
997
1000
  conditions.push(`stream > $${values.length}`);
998
1001
  }
999
- let sql = `SELECT stream, source, at, retry, blocked, error, leased_by, leased_until, priority, lane FROM ${this._fqs}`;
1002
+ let sql = `SELECT stream, source, at, retry, blocked, error, leased_by, leased_until, priority, lane, deferred_at FROM ${this._fqs}`;
1000
1003
  if (conditions.length) sql += " WHERE " + conditions.join(" AND ");
1001
1004
  values.push(limit);
1002
1005
  sql += ` ORDER BY stream LIMIT $${values.length}`;
@@ -1020,7 +1023,10 @@ var PostgresStore = class {
1020
1023
  priority: row.priority,
1021
1024
  leased_by: row.leased_by ?? void 0,
1022
1025
  leased_until: row.leased_until ?? void 0,
1023
- lane: row.lane
1026
+ lane: row.lane,
1027
+ // Persisted as timestamptz; surface as ms since epoch (#1221) so
1028
+ // the cold-start re-seed can re-arm the drain at the due-time.
1029
+ deferred_at: row.deferred_at ? row.deferred_at.getTime() : void 0
1024
1030
  });
1025
1031
  count++;
1026
1032
  }