@wopr-network/platform-core 1.12.0 → 1.12.2

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.
@@ -23,7 +23,7 @@ export class DrizzleDeletionExecutorRepository {
23
23
  .update(accountDeletionRequests)
24
24
  .set({
25
25
  status: "completed",
26
- completedAt: sql `now()`,
26
+ completedAt: sql `now()::text`,
27
27
  deletionSummary,
28
28
  updatedAt: sql `now()`,
29
29
  })
@@ -69,9 +69,14 @@ export class DrizzleDeletionExecutorRepository {
69
69
  return result.rowCount ?? 0;
70
70
  }
71
71
  catch (err) {
72
- const pgCode = err.code;
72
+ // Drizzle may wrap PGlite errors; check both top-level and cause for the PG code
73
+ const errObj = err;
74
+ const pgCode = errObj.code ?? errObj.cause?.code;
73
75
  if (pgCode === "42P01")
74
76
  return null; // table does not exist
77
+ // PGlite errors surfaced through Drizzle may embed the code in the message
78
+ if (errObj.message?.includes("42P01"))
79
+ return null;
75
80
  throw err;
76
81
  }
77
82
  }
@@ -56,7 +56,7 @@ export class DrizzleDeletionRepository {
56
56
  .update(accountDeletionRequests)
57
57
  .set({
58
58
  status: "completed",
59
- completedAt: sql `now()`,
59
+ completedAt: sql `now()::text`,
60
60
  deletionSummary: summary,
61
61
  updatedAt: sql `now()`,
62
62
  })
@@ -66,7 +66,7 @@ export class DrizzleDeletionRepository {
66
66
  const rows = await this.db
67
67
  .select()
68
68
  .from(accountDeletionRequests)
69
- .where(and(eq(accountDeletionRequests.status, "pending"), lte(accountDeletionRequests.deleteAfter, sql `now()`)));
69
+ .where(and(eq(accountDeletionRequests.status, "pending"), lte(accountDeletionRequests.deleteAfter, sql `now()::text`)));
70
70
  return rows.map(toRow);
71
71
  }
72
72
  async list(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopr-network/platform-core",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -93,7 +93,7 @@ export class DrizzleDeletionExecutorRepository implements IDeletionExecutorRepos
93
93
  .update(accountDeletionRequests)
94
94
  .set({
95
95
  status: "completed",
96
- completedAt: sql`now()`,
96
+ completedAt: sql`now()::text`,
97
97
  deletionSummary,
98
98
  updatedAt: sql`now()`,
99
99
  })
@@ -144,8 +144,12 @@ export class DrizzleDeletionExecutorRepository implements IDeletionExecutorRepos
144
144
  const result = await this.db.execute(sql`DELETE FROM credit_adjustments WHERE tenant_id = ${tenantId}`);
145
145
  return (result as unknown as { rowCount?: number }).rowCount ?? 0;
146
146
  } catch (err: unknown) {
147
- const pgCode = (err as { code?: string }).code;
147
+ // Drizzle may wrap PGlite errors; check both top-level and cause for the PG code
148
+ const errObj = err as { code?: string; cause?: { code?: string }; message?: string };
149
+ const pgCode = errObj.code ?? errObj.cause?.code;
148
150
  if (pgCode === "42P01") return null; // table does not exist
151
+ // PGlite errors surfaced through Drizzle may embed the code in the message
152
+ if (errObj.message?.includes("42P01")) return null;
149
153
  throw err;
150
154
  }
151
155
  }
@@ -85,7 +85,7 @@ export class DrizzleDeletionRepository implements IDeletionRepository {
85
85
  .update(accountDeletionRequests)
86
86
  .set({
87
87
  status: "completed",
88
- completedAt: sql`now()`,
88
+ completedAt: sql`now()::text`,
89
89
  deletionSummary: summary,
90
90
  updatedAt: sql`now()`,
91
91
  })
@@ -96,7 +96,9 @@ export class DrizzleDeletionRepository implements IDeletionRepository {
96
96
  const rows = await this.db
97
97
  .select()
98
98
  .from(accountDeletionRequests)
99
- .where(and(eq(accountDeletionRequests.status, "pending"), lte(accountDeletionRequests.deleteAfter, sql`now()`)));
99
+ .where(
100
+ and(eq(accountDeletionRequests.status, "pending"), lte(accountDeletionRequests.deleteAfter, sql`now()::text`)),
101
+ );
100
102
  return rows.map(toRow);
101
103
  }
102
104