@gigamusic/admin 2.0.3 → 2.1.0

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.3",
3
+ "version": "2.1.0",
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",
27
28
  "@gigamusic/core": "1.0.0",
28
29
  "@gigamusic/storage": "1.0.0",
29
- "@gigamusic/db": "2.0.1",
30
- "@gigamusic/audio": "1.0.0"
30
+ "@gigamusic/db": "2.1.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.10.5",
@@ -4,6 +4,7 @@ import {
4
4
  TrackInputSchema,
5
5
  type ReleaseInput,
6
6
  } from "@gigamusic/core";
7
+ import { isUniqueConstraintError as isUniqueConstraintErrorByCode } from "@gigamusic/db";
7
8
  import type { AdminDeps, RouteHandler } from "../lib/types";
8
9
  import { badRequest, json, notFound } from "../lib/responses";
9
10
 
@@ -182,18 +183,15 @@ function collectStorageKeys(
182
183
  }
183
184
 
184
185
  /**
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`.
186
+ * Catches the canonical pg unique-violation (via `@gigamusic/db`'s
187
+ * cause-walking helper) AND a message-text fallback for `Queries`
188
+ * implementations that surface plain `Error`s with a slug-related prefix
189
+ * rather than a code.
188
190
  */
189
- function isUniqueConstraintError(err: unknown, depth = 0): boolean {
190
- if (!err || typeof err !== "object" || depth > 5) return false;
191
- const code = (err as { code?: unknown }).code;
192
- if (code === "23505") return true;
193
- // Some Queries implementations may surface plain Errors with this prefix.
194
- const message = (err as { message?: unknown }).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);
191
+ function isUniqueConstraintError(err: unknown): boolean {
192
+ if (isUniqueConstraintErrorByCode(err)) return true;
193
+ const message = (err as { message?: unknown } | null | undefined)?.message;
194
+ return typeof message === "string" && /slug.*(already|exists|unique)/i.test(message);
197
195
  }
198
196
 
199
197
  async function resolveIdParam(