@stacksjs/slug 0.70.23 → 0.70.26
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/dist/index.js +22 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/unique.d.ts +20 -0
- package/package.json +25 -11
- package/dist/index.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './unique';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { slugify } from 'ts-slug';
|
|
2
|
+
import type { TableNames } from '@stacksjs/types';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a URL-safe slug that is unique within `options.table.column`.
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: this function performs a check-then-write, which means two
|
|
7
|
+
* concurrent callers can both observe "slug is free" and then both insert
|
|
8
|
+
* the same value. Add a UNIQUE constraint on `options.column` in your
|
|
9
|
+
* migration as the source of truth — this helper is for ergonomics, not
|
|
10
|
+
* race protection. A bounded retry budget keeps a runaway loop from
|
|
11
|
+
* hammering the DB if 1000+ records share the same base slug (e.g.
|
|
12
|
+
* "untitled" for unsaved drafts).
|
|
13
|
+
*/
|
|
14
|
+
export declare function uniqueSlug(value: string, options?: SlugifyOptions): Promise<string>;
|
|
15
|
+
declare interface SlugifyOptions {
|
|
16
|
+
table: TableNames
|
|
17
|
+
column: string
|
|
18
|
+
}
|
|
19
|
+
// Re-export the original slugify for convenience
|
|
20
|
+
export { slugify };
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/slug",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.26",
|
|
5
5
|
"description": "The Stacks slug functionality.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
|
-
"contributors": [
|
|
7
|
+
"contributors": [
|
|
8
|
+
"Chris Breuer <chris@stacksjs.com>"
|
|
9
|
+
],
|
|
8
10
|
"license": "MIT",
|
|
9
11
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
10
12
|
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/database#readme",
|
|
@@ -16,29 +18,41 @@
|
|
|
16
18
|
"bugs": {
|
|
17
19
|
"url": "https://github.com/stacksjs/stacks/issues"
|
|
18
20
|
},
|
|
19
|
-
"keywords": [
|
|
21
|
+
"keywords": [
|
|
22
|
+
"slugs",
|
|
23
|
+
"models",
|
|
24
|
+
"urls",
|
|
25
|
+
"stacks"
|
|
26
|
+
],
|
|
20
27
|
"exports": {
|
|
21
28
|
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"bun": "./src/index.ts",
|
|
22
31
|
"import": "./dist/index.js"
|
|
23
32
|
},
|
|
24
33
|
"./*": {
|
|
34
|
+
"bun": "./src/*",
|
|
25
35
|
"import": "./dist/*"
|
|
26
36
|
}
|
|
27
37
|
},
|
|
28
38
|
"module": "dist/index.js",
|
|
29
39
|
"types": "dist/index.d.ts",
|
|
30
|
-
"files": [
|
|
40
|
+
"files": [
|
|
41
|
+
"README.md",
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
31
44
|
"scripts": {
|
|
32
45
|
"build": "bun build.ts",
|
|
33
46
|
"typecheck": "bun tsc --noEmit",
|
|
34
47
|
"prepublishOnly": "bun run build"
|
|
35
48
|
},
|
|
36
49
|
"devDependencies": {
|
|
37
|
-
"@stacksjs/cli": "0.70.
|
|
38
|
-
"@stacksjs/database": "0.70.
|
|
39
|
-
"
|
|
40
|
-
"@stacksjs/path": "0.70.
|
|
41
|
-
"@stacksjs/strings": "0.70.
|
|
42
|
-
"@stacksjs/utils": "0.70.
|
|
43
|
-
}
|
|
50
|
+
"@stacksjs/cli": "0.70.23",
|
|
51
|
+
"@stacksjs/database": "0.70.23",
|
|
52
|
+
"better-dx": "^0.2.12",
|
|
53
|
+
"@stacksjs/path": "0.70.23",
|
|
54
|
+
"@stacksjs/strings": "0.70.23",
|
|
55
|
+
"@stacksjs/utils": "0.70.23"
|
|
56
|
+
},
|
|
57
|
+
"sideEffects": false
|
|
44
58
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const wipSlug: true;
|