import type { DbReader, DbWriter } from "./types"; /** * Pure: turn a human name into a URL-safe base slug. Doesn't check * uniqueness — combine with `availableSlug` for that. * * Rules: * - lowercase * - non-alphanumeric runs become single dashes * - trim leading/trailing dashes * - max 40 chars (so a numeric suffix can land within typical * 50-char schema constraints) * - empty result (e.g. emoji-only name) → `fallback` * * @param name The user-typed display name to slugify. * @param fallback Replacement when the slug strips to empty. Default: "x". */ export declare function slugifyName(name: string, fallback?: string): string; /** * Find the first slug that's available in the named entity's `field` * column. Tries `base`, then `base-2`, `base-3`, …, then a 6-char * random suffix as a final fallback. * * Reserved slugs (operational subdomain names, brand-protected words) * can be passed via `reserved`; matches are skipped. * * Caller still wraps the eventual insert in try/catch — TOCTOU is * always possible with this kind of "check then write" probe, and * the framework's UNIQUE index is the actual source of truth. The * helper just minimises the number of avoidable retries. * * @example * ```ts * const slug = await availableSlug(ctx.db, { * entity: "Workspace", * field: "slug", * name: args.name, * reserved: RESERVED_SUBDOMAINS, * }); * await ctx.db.insert("Workspace", { slug, ... }); * ``` */ export declare function availableSlug(db: DbReader | DbWriter, options: { entity: string; field?: string; name: string; reserved?: ReadonlySet | readonly string[]; /** Max numeric suffix to try before falling back to random. Default: 50. */ maxNumericTries?: number; }): Promise;