@gigamusic/admin 2.0.1 → 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 +3 -3
- package/src/handlers/releases.ts +10 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gigamusic/admin",
|
|
3
|
-
"version": "2.0.
|
|
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
27
|
"@gigamusic/core": "1.0.0",
|
|
29
28
|
"@gigamusic/storage": "1.0.0",
|
|
30
|
-
"@gigamusic/db": "2.0.1"
|
|
29
|
+
"@gigamusic/db": "2.0.1",
|
|
30
|
+
"@gigamusic/audio": "1.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^22.10.5",
|
package/src/handlers/releases.ts
CHANGED
|
@@ -181,13 +181,19 @@ function collectStorageKeys(
|
|
|
181
181
|
return keys;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
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;
|
|
186
191
|
const code = (err as { code?: unknown }).code;
|
|
187
|
-
if (code === "
|
|
192
|
+
if (code === "23505") return true;
|
|
188
193
|
// Some Queries implementations may surface plain Errors with this prefix.
|
|
189
194
|
const message = (err as { message?: unknown }).message;
|
|
190
|
-
|
|
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
197
|
}
|
|
192
198
|
|
|
193
199
|
async function resolveIdParam(
|