@gigamusic/admin 2.0.2 → 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.2",
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": {
@@ -25,9 +25,9 @@
25
25
  "dependencies": {
26
26
  "zod": "^3.24.1",
27
27
  "@gigamusic/audio": "1.0.0",
28
- "@gigamusic/db": "2.0.1",
29
28
  "@gigamusic/core": "1.0.0",
30
- "@gigamusic/storage": "1.0.0"
29
+ "@gigamusic/storage": "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
 
@@ -181,13 +182,15 @@ function collectStorageKeys(
181
182
  return keys;
182
183
  }
183
184
 
184
- /** Postgres SQLSTATE 23505 — unique_violation. */
185
+ /**
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.
190
+ */
185
191
  function isUniqueConstraintError(err: unknown): boolean {
186
- if (typeof err !== "object" || err === null) return false;
187
- const code = (err as { code?: unknown }).code;
188
- if (code === "23505") return true;
189
- // Some Queries implementations may surface plain Errors with this prefix.
190
- const message = (err as { message?: unknown }).message;
192
+ if (isUniqueConstraintErrorByCode(err)) return true;
193
+ const message = (err as { message?: unknown } | null | undefined)?.message;
191
194
  return typeof message === "string" && /slug.*(already|exists|unique)/i.test(message);
192
195
  }
193
196