@stacksjs/slug 0.75.318 → 0.75.321

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 CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{randomBytes as n}from"crypto";import{db as a}from"@stacksjs/database/runtime";import{slugify as u}from"ts-slug";async function p(i,e){let t=u(i);if(!e?.table||!e?.column)return t;let r=t,s=1,o=1000;while(s<=o){if(!await a.selectFrom(e.table).select(["id"]).where(e.column,"=",r).executeTakeFirst())return r;s++,r=`${t}-${s}`}let l=n(6).toString("base64url").toLowerCase().replace(/[^a-z0-9]/g,"").slice(0,8);return`${t}-${l}`}export{u as slugify,p as uniqueSlug};
2
+ import{randomBytes as m}from"crypto";import{db as u}from"@stacksjs/database/runtime";import{slugify as f}from"ts-slug";async function d(c,e){let t=f(c);if(!e?.table||!e?.column)return t;let a=e.connection??u,i=(s)=>(e.claimed?.add(s),s),r=t,n=1,l=1000;while(n<=l){if(!(e.claimed?.has(r)||await a.selectFrom(e.table).select(["id"]).where(e.column,"=",r).executeTakeFirst()))return i(r);n++,r=`${t}-${n}`}let o=m(6).toString("base64url").toLowerCase().replace(/[^a-z0-9]/g,"").slice(0,8);return i(`${t}-${o}`)}export{f as slugify,d as uniqueSlug};
package/dist/unique.d.ts CHANGED
@@ -15,6 +15,8 @@ export declare function uniqueSlug(value: string, options?: SlugifyOptions): Pro
15
15
  declare interface SlugifyOptions {
16
16
  table: TableNames
17
17
  column: string
18
+ connection?: { selectFrom: (table: any) => any }
19
+ claimed?: Set<string>
18
20
  }
19
21
  // Re-export the original slugify for convenience
20
22
  export { slugify };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/slug",
3
3
  "type": "module",
4
- "version": "0.75.318",
4
+ "version": "0.75.321",
5
5
  "description": "The Stacks slug functionality.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -56,14 +56,14 @@
56
56
  "prepublishOnly": "bun run build"
57
57
  },
58
58
  "dependencies": {
59
- "@stacksjs/database": "0.75.318",
59
+ "@stacksjs/database": "0.75.321",
60
60
  "ts-slug": "^0.1.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@stacksjs/cli": "0.75.318",
64
- "@stacksjs/path": "0.75.318",
65
- "@stacksjs/strings": "0.75.318",
66
- "@stacksjs/utils": "0.75.318",
63
+ "@stacksjs/cli": "0.75.321",
64
+ "@stacksjs/path": "0.75.321",
65
+ "@stacksjs/strings": "0.75.321",
66
+ "@stacksjs/utils": "0.75.321",
67
67
  "better-dx": "^0.2.24"
68
68
  },
69
69
  "sideEffects": false