@rotorsoft/act-pg 1.13.13 → 1.13.15

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
@@ -2,6 +2,7 @@
2
2
  import { randomUUID } from "crypto";
3
3
  import {
4
4
  ConcurrencyError,
5
+ dateReviver,
5
6
  log,
6
7
  SNAP_EVENT,
7
8
  StoreError,
@@ -13,17 +14,6 @@ import {
13
14
  makeKeyResolver
14
15
  } from "@rotorsoft/act-crypto";
15
16
  import pg from "pg";
16
-
17
- // src/utils.ts
18
- var ISO_8601 = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\.\d+)?(Z|[+-][0-2][0-9]:[0-5][0-9])?$/;
19
- var dateReviver = (_key, value) => {
20
- if (typeof value === "string" && ISO_8601.test(value)) {
21
- return new Date(value);
22
- }
23
- return value;
24
- };
25
-
26
- // src/postgres-store.ts
27
17
  var logger = log();
28
18
  var SOURCE_METACHARACTER_CLASS = "[]^$.*+?()[{}|\\\\]";
29
19
  var { Pool, types } = pg;
@@ -458,7 +448,11 @@ var PostgresStore = class {
458
448
  const result = await this._pool.query(sql, values);
459
449
  for (const row of result.rows) {
460
450
  if (this._resolve_pii_key && typeof row.pii === "string") {
461
- const decrypted = await decrypt(row.pii, this._resolve_pii_key);
451
+ const decrypted = await decrypt(
452
+ row.pii,
453
+ this._resolve_pii_key,
454
+ dateReviver
455
+ );
462
456
  row.pii = decrypted;
463
457
  }
464
458
  await Promise.resolve(callback(row));
@@ -538,7 +532,11 @@ var PostgresStore = class {
538
532
  if (this._resolve_pii_key) {
539
533
  for (const row of rows) {
540
534
  if (typeof row.pii === "string") {
541
- const decrypted = await decrypt(row.pii, this._resolve_pii_key);
535
+ const decrypted = await decrypt(
536
+ row.pii,
537
+ this._resolve_pii_key,
538
+ dateReviver
539
+ );
542
540
  row.pii = decrypted;
543
541
  }
544
542
  }
@@ -1421,9 +1419,10 @@ var PostgresStore = class {
1421
1419
  this._fqt
1422
1420
  ]);
1423
1421
  const result = /* @__PURE__ */ new Map();
1424
- if (full.length) {
1422
+ const retired = full.filter((t) => t.snapshot === void 0).map((t) => t.stream);
1423
+ if (retired.length) {
1425
1424
  await client.query(`DELETE FROM ${this._fqs} WHERE stream = ANY($1)`, [
1426
- full.map((t) => t.stream)
1425
+ retired
1427
1426
  ]);
1428
1427
  }
1429
1428
  for (const { stream, snapshot, meta } of full) {