@gigamusic/links 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 +1 -1
- package/src/api/validation.ts +9 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gigamusic/links",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Editable Linktree-style link pages for gigamusic artist sites. Ships a Drizzle schema, admin API handler factories, and platform-detection helpers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/src/api/validation.ts
CHANGED
|
@@ -5,11 +5,13 @@ export const INVALID_SLUG_MESSAGE =
|
|
|
5
5
|
"Slug must be lowercase letters, numbers, and dashes";
|
|
6
6
|
export const RESERVED_SLUG_MESSAGE = "Slug is reserved";
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
8
|
+
/**
|
|
9
|
+
* True for the Postgres SQLSTATE 23505 (unique_violation). Walks the `cause`
|
|
10
|
+
* chain because Drizzle's transaction wrapper re-throws with `code: undefined`
|
|
11
|
+
* and nests the original pg error under `err.cause`.
|
|
12
|
+
*/
|
|
13
|
+
export function isUniqueConstraintError(err: unknown, depth = 0): boolean {
|
|
14
|
+
if (!err || typeof err !== "object" || depth > 5) return false;
|
|
15
|
+
if ((err as { code?: string }).code === "23505") return true;
|
|
16
|
+
return isUniqueConstraintError((err as { cause?: unknown }).cause, depth + 1);
|
|
15
17
|
}
|