/** * ID generation utility with uniqueness guarantees * Provides various ID generation strategies for database entities */ /** * Generate a timestamp-based ID with microsecond precision * Format: timestamp-random-counter * Example: "1704067200000-a3f2-0001" */ export declare function generateTimestampId(): string; /** * Generate a nano ID - URL-safe, short, unique identifier * Uses a larger alphabet for better uniqueness in shorter strings */ export declare function generateNanoId(length?: number): string; /** * Generate a UUID v4 compliant identifier * Standard format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx */ export declare function generateUUID(): string; /** * Generate a prefixed ID for better organization * Format: prefix_id * Example: "user_1704067200000-a3f2-0001" */ export declare function generatePrefixedId(prefix: string): string; /** * Generate a ULID (Universally Unique Lexicographically Sortable Identifier) * Sortable by creation time, case-insensitive */ export declare function generateULID(): string; /** * Generate a sortable ID that includes type information * Format: type:timestamp:random * Example: "user:1704067200000:a3f2" */ export declare function generateTypedId(type: string): string; /** * Check if a string is a valid ID format */ export declare function isValidId(id: unknown): id is string; /** * Check if ID matches expected format */ export declare function isValidIdFormat(id: string, format: "uuid" | "ulid" | "timestamp" | "nano"): boolean; export type IdGeneratorConfig = { strategy: "timestamp" | "nano" | "uuid" | "ulid" | "prefixed" | "typed"; prefix?: string; type?: string; length?: number; }; /** * Default ID generator configuration */ export declare const defaultIdConfig: IdGeneratorConfig; /** * Create an ID generator with specific configuration */ export declare function createIdGenerator(config?: IdGeneratorConfig): () => string; /** * Default ID generator using nano ID strategy */ export declare const generateId: () => string; /** * Collection-specific ID generators * Allows different ID strategies per collection */ export declare class CollectionIdGenerators { private generators; private defaultGenerator; constructor(defaultConfig?: IdGeneratorConfig); /** * Register a custom ID generator for a collection */ register(collection: string, config: IdGeneratorConfig): void; /** * Get ID generator for a collection */ getGenerator(collection: string): () => string; /** * Generate ID for a collection */ generateFor(collection: string): string; } /** * Extract timestamp from timestamp-based IDs */ export declare function extractTimestamp(id: string): number | null; /** * Extract type from typed IDs */ export declare function extractType(id: string): string | null; /** * Compare IDs for sorting (works with timestamp-based IDs) */ export declare function compareIds(a: string, b: string): number; //# sourceMappingURL=id-generator.d.ts.map