import type { Lix } from "../../lix/open-lix.js"; import type { LixEngine } from "../boot.js"; /** * Sync variant of {@link nanoId}. See {@link nanoId} for behavior and examples. * * @remarks * - Accepts `{ engine }` (or `{ lix }` for backward‑compat) and runs next to SQLite. * - Intended for engine/router and UDFs; app code should use {@link nanoId}. * * @see nanoId */ export declare function nanoIdSync(args: { engine: Pick; length?: number; }): string; /** * Generate a nano ID. * * Deterministic in deterministic mode; otherwise returns a random 21-character nano ID using the nanoid algorithm. * * Use nano IDs when IDs will appear in URLs – their shorter length makes links easier to share. * For better database performance with time-ordered queries, consider {@link uuidV7} instead. * * - Normal mode: URL-safe random ID using custom alphabet (no `-` or `_`). * - Deterministic mode: "test_" + 10-digit zero-padded counter. * - Counter state shared with {@link nextDetermininisticSequenceNumber | nextDeterministicSequenceNumber}. * - The "test_" prefix makes deterministic IDs easily identifiable. * - Choose nano IDs for URL-friendly short IDs, {@link uuidV7} for time-sortable database keys. * - Use the Nano ID collision calculator to choose optimal length. * * @example Normal mode – random nanoid * ```ts * const lix = await openLix(); * const id = await nanoId({ lix }) // "V1StGXR8_Z5jdHi6B-myT" * ``` * * @example Deterministic mode – sequential IDs * ```ts * const lix = await openLix({ * keyValues: [{ key: "lix_deterministic_mode", value: { enabled: true }, lixcol_version_id: "global" }] * }); * await nanoId({ lix }) // "test_0000000000" * await nanoId({ lix }) // "test_0000000001" * await nanoId({ lix }) // "test_0000000002" * ``` * * @example Database operations * ```ts * await lix.db * .insertInto("label") * .values({ id: await nanoId({ lix }), name: "bug", color: "#ff0000" }) * .execute(); * ``` * * @param args.lix Lix instance used to call into the engine. * @param args.length Optional length for non-deterministic mode (default: 21) */ export declare function nanoId(args: { lix: Pick & Record; length?: number; }): Promise; /** * Uses every character from nano id except for the `-` and `_` character. * * - Underscore `_` is not URL safe https://github.com/ai/nanoid/issues/347. * - Dash `-` breaks selecting the ID from the URL in the browser. */ export declare const _nanoIdAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; //# sourceMappingURL=nano-id.d.ts.map