@gigamusic/admin 2.0.2 → 2.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gigamusic/admin",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Server-only admin API handler factories for the gigamusic platform (releases CRUD, tracks, uploads, settings, links, orders).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,10 +24,10 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "zod": "^3.24.1",
27
- "@gigamusic/audio": "1.0.0",
28
- "@gigamusic/db": "2.0.1",
29
27
  "@gigamusic/core": "1.0.0",
30
- "@gigamusic/storage": "1.0.0"
28
+ "@gigamusic/storage": "1.0.0",
29
+ "@gigamusic/db": "2.0.1",
30
+ "@gigamusic/audio": "1.0.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.10.5",
@@ -181,14 +181,19 @@ function collectStorageKeys(
181
181
  return keys;
182
182
  }
183
183
 
184
- /** Postgres SQLSTATE 23505 — unique_violation. */
185
- function isUniqueConstraintError(err: unknown): boolean {
186
- if (typeof err !== "object" || err === null) return false;
184
+ /**
185
+ * Postgres SQLSTATE 23505 — unique_violation. Walks the `cause` chain because
186
+ * Drizzle's transaction wrapper re-throws with `code: undefined` and nests the
187
+ * original pg error under `err.cause`.
188
+ */
189
+ function isUniqueConstraintError(err: unknown, depth = 0): boolean {
190
+ if (!err || typeof err !== "object" || depth > 5) return false;
187
191
  const code = (err as { code?: unknown }).code;
188
192
  if (code === "23505") return true;
189
193
  // Some Queries implementations may surface plain Errors with this prefix.
190
194
  const message = (err as { message?: unknown }).message;
191
- return typeof message === "string" && /slug.*(already|exists|unique)/i.test(message);
195
+ if (typeof message === "string" && /slug.*(already|exists|unique)/i.test(message)) return true;
196
+ return isUniqueConstraintError((err as { cause?: unknown }).cause, depth + 1);
192
197
  }
193
198
 
194
199
  async function resolveIdParam(