//#region src/common/uuid.d.ts /** * Generate raw UUID bytes (128 bits / 16 bytes). * * Uses a cryptographically secure random source provided by * `randomUint8Array`. * * @returns Uint8Array of length 16 with random bytes */ declare function uuidBytes(): Uint8Array; /** * Create a Base62-encoded UUID string from the provided bytes or a newly * generated random UUID. The result is a compact, URL-safe identifier. * * @param bytes - optional 16-byte Uint8Array; if omitted a new random UUID is generated * @returns Base62 string representation (22 characters) */ declare function uuidB62(bytes?: Uint8Array): string; /** * Encode raw UUID bytes to a Base62 string. * * @param bytes - 16-byte UUID as Uint8Array * @returns Base62-encoded string */ declare function uuidEncodeB62(bytes: Uint8Array): string; /** * Decode a Base62-encoded UUID string into raw bytes. * * @param uuid - Base62 string * @returns 16-byte Uint8Array */ declare function uuidDecodeB62(uuid: string): Uint8Array; /** * Create a Base32-encoded UUID string from bytes or a new random UUID. * * @param bytes - optional 16-byte Uint8Array; if omitted a new random UUID is generated * @returns Base32 string representation (26 characters) */ declare function uuidB32(bytes?: Uint8Array): string; /** * Encode raw UUID bytes to a Base32 string. * * @param bytes - 16-byte UUID as Uint8Array * @returns Base32-encoded string */ declare function uuidEncodeB32(bytes: Uint8Array): string; /** * Decode a Base32-encoded UUID string into raw bytes. * * @param uuid - Base32 string * @returns 16-byte Uint8Array */ declare function uuidDecodeB32(uuid: string): Uint8Array; /** * Generate a UUID v4 string. * * Uses the native `crypto.randomUUID()` if available; otherwise falls back to * a random-based implementation using `randomUint8Array`. * * @returns UUID v4 string in standard 8-4-4-4-12 hex format */ declare function uuidv4(): string; /** * Encode 16 raw bytes as a UUID v4 formatted string (hex with dashes). * * @param bytes - 16-byte Uint8Array * @returns UUID string (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) */ declare function uuidEncodeV4(bytes: Uint8Array): string; /** * Decode a UUID v4 string (hex with dashes) into raw bytes. * * @param uuid - UUID string * @returns 16-byte Uint8Array */ declare function uuidDecodeV4(uuid: string): Uint8Array; /** * Create a sortable unique identifier (SUID) as raw bytes. * * The first 6 bytes encode a millisecond timestamp offset from an internal * reference date to allow lexicographic sorting by creation time. The * remaining 10 bytes are random. * * @returns 16-byte Uint8Array where bytes 0-5 are timestamp and 6-15 are random */ declare function suidBytes(): Uint8Array; /** * Create a sortable unique identifier (SUID) and return it encoded using the * currently configured UUID encoding. * * @returns encoded SUID string */ declare function suid(): string; /** * Extract the creation Date from an encoded SUID string. * * @param id - encoded SUID * @returns Date corresponding to the timestamp component of the SUID */ declare function suidDate(id: string): Date; /** * Extract the creation Date from raw SUID bytes. * * @param id - 16-byte SUID as Uint8Array * @returns Date corresponding to the timestamp encoded in bytes 0-5 */ declare function suidBytesDate(id: Uint8Array): Date; /** * Generate a 32-bit unsigned integer from 4 random bytes. * * @returns a random 32-bit unsigned integer */ declare function uuid32bit(): number; declare const mapModes: { base62: { uuid: typeof uuidB62; uuidDecode: typeof uuidDecodeB62; uuidEncode: typeof uuidEncodeB62; }; base32: { uuid: typeof uuidB32; uuidDecode: typeof uuidDecodeB32; uuidEncode: typeof uuidEncodeB32; }; uuidv4: { uuid: typeof uuidv4; uuidDecode: typeof uuidDecodeV4; uuidEncode: typeof uuidEncodeV4; }; test: { uuid: () => string; uuidDecode: (id: string) => Uint8Array; uuidEncode: (bin: Uint8Array) => string; }; }; /** * Configure the default encoding and whether generated IDs should be * lexicographically sortable. * * @param mode - encoding mode ('base62' | 'base32' | 'uuidv4' | 'test') * @param sorted - when true, `uuid()` will prefer sortable SUIDs */ declare function setUuidDefaultEncoding(mode?: keyof typeof mapModes, sorted?: boolean): void; /** * Generate an identifier using the current encoding mode. * * If the default encoding is configured with `sorted=true`, this returns a * sortable SUID; otherwise a random UUID is returned. * * @returns encoded identifier string */ declare function uuid(): string; /** * Decode an encoded identifier according to the current encoding mode into * raw bytes. * * @param uuid - encoded identifier string * @returns raw 16-byte Uint8Array */ declare function uuidDecode(uuid: string): Uint8Array; /** * Encode raw UUID bytes using the current encoding mode. * * @param bytes - 16-byte Uint8Array * @returns encoded identifier string */ declare function uuidEncode(bytes: Uint8Array): string; /** * Validate an encoded identifier by attempting to decode it and checking * for the expected byte length. * * @param uuid - encoded identifier string * @returns true when valid and decodes to 16 bytes */ declare function uuidIsValid(uuid: string): boolean; /** * Simple counter-based unique name generator. * * Returns strings like 'name-0', 'name-1', ... and increments an internal * counter per `name`. * * @param name - base name for the counter (default: 'id') * @returns generated unique name */ declare function uname(name?: string): string; /** Reset the counter used by `uname` for the given name. */ declare function unameReset(name?: string): void; /** * Quick global incremental id generator. * * Returns strings like 'id-0', 'id-1', ... using a single global counter. */ declare function qid(): string; //#endregion export { uuidv4 as C, uuidIsValid as S, uuidDecodeV4 as _, suidBytesDate as a, uuidEncodeB62 as b, unameReset as c, uuidB32 as d, uuidB62 as f, uuidDecodeB62 as g, uuidDecodeB32 as h, suidBytes as i, uuid as l, uuidDecode as m, setUuidDefaultEncoding as n, suidDate as o, uuidBytes as p, suid as r, uname as s, qid as t, uuid32bit as u, uuidEncode as v, uuidEncodeV4 as x, uuidEncodeB32 as y }; //# sourceMappingURL=uuid-CKFZfSff.d.mts.map