import { EntityId } from '../../../contracts/src/index.ts'; /** * Configuration for EntityId generation patterns */ export interface EntityIdPattern { /** Base prefix for the ID */ prefix?: string; /** Suffix for the ID */ suffix?: string; /** Separator between parts */ separator?: string; /** Include timestamp component */ includeTimestamp?: boolean; /** Include random component */ includeRandom?: boolean; /** Custom template with placeholders */ template?: string; } /** * Utility class for generating EntityId instances with various strategies. * * This generator provides multiple strategies for creating EntityIds that * are appropriate for different testing scenarios: * - UUID-based for realistic production-like IDs * - Sequential for predictable test scenarios * - Pattern-based for domain-specific ID formats * - Custom strategies for specialized requirements */ export declare class EntityIdGenerator { /** * Generates a UUID-based EntityId using the proper factory method. * * @returns New EntityId with random UUID * * @example * ```typescript * const userId = EntityIdGenerator.uuid(); * console.log(userId.toString()); // "a1b2c3d4-e5f6-7890-abcd-ef1234567890" * ``` */ static uuid(): EntityId; /** * Generates a text-based EntityId with optional custom value. * * @param value Optional custom text value (generates random if not provided) * @returns New EntityId with text value * * @example * ```typescript * const customId = EntityIdGenerator.text('user-123'); * const randomId = EntityIdGenerator.text(); // Generates random text ID * ``` */ static text(value?: string): EntityId; /** * Generates a sequential EntityId with a base prefix. * * @param prefix Base prefix for the sequential ID * @param padding Number of digits for zero-padding (default: 3) * @returns New EntityId with sequential number * * @example * ```typescript * const user1 = EntityIdGenerator.sequential('user'); // "user-001" * const user2 = EntityIdGenerator.sequential('user'); // "user-002" * const order1 = EntityIdGenerator.sequential('order', 5); // "order-00001" * ``` */ static sequential(prefix: string, padding?: number): EntityId; /** * Generates an EntityId based on a pattern template. * * Supported placeholders: * - {{uuid}} - Full UUID * - {{uuid:8}} - First 8 characters of UUID * - {{sequence}} - Sequential number * - {{sequence:4}} - Sequential number with 4-digit padding * - {{timestamp}} - Unix timestamp * - {{date}} - YYYY-MM-DD format * - {{year}} - Current year * - {{month}} - Current month (01-12) * - {{random:6}} - Random alphanumeric string of specified length * - {{faker:word}} - Faker.js word * * @param template Template string with placeholders * @param context Optional context for sequential counting * @returns New EntityId based on pattern * * @example * ```typescript * // Order IDs with year and sequence * const orderId = EntityIdGenerator.pattern('ORDER-{{year}}-{{sequence:4}}'); * // Result: "ORDER-2025-0001" * * // User IDs with random component * const userId = EntityIdGenerator.pattern('USER-{{random:6}}'); * // Result: "USER-A1B2C3" * * // Event IDs with timestamp * const eventId = EntityIdGenerator.pattern('EVENT-{{timestamp}}-{{uuid:8}}'); * // Result: "EVENT-1706123456-a1b2c3d4" * ``` */ static pattern(template: string, context?: string): EntityId; /** * Generates an EntityId using a custom pattern configuration. * * @param pattern Pattern configuration object * @param context Optional context for sequential counting * @returns New EntityId based on configuration * * @example * ```typescript * const orderId = EntityIdGenerator.fromPattern({ * prefix: 'ORDER', * includeTimestamp: true, * includeRandom: true, * separator: '-' * }); * // Result: "ORDER-1706123456-A1B2C3" * ``` */ static fromPattern(pattern: EntityIdPattern, context?: string): EntityId; /** * Generates multiple EntityIds using the specified strategy. * * @param count Number of EntityIds to generate * @param strategy Generation strategy function * @returns Array of generated EntityIds * * @example * ```typescript * // Generate 10 UUID-based EntityIds * const uuids = EntityIdGenerator.many(10, () => EntityIdGenerator.uuid()); * * // Generate 5 sequential user IDs * const users = EntityIdGenerator.many(5, () => EntityIdGenerator.sequential('user')); * * // Generate 3 pattern-based order IDs * const orders = EntityIdGenerator.many(3, () => * EntityIdGenerator.pattern('ORDER-{{year}}-{{sequence:4}}') * ); * ``` */ static many(count: number, strategy: () => EntityId): EntityId[]; /** * Resets sequential counters for clean test scenarios. * * @param context Optional specific context to reset (resets all if not provided) * * @example * ```typescript * // Reset all counters * EntityIdGenerator.resetCounters(); * * // Reset specific context * EntityIdGenerator.resetCounters('user'); * ``` */ static resetCounters(context?: string): void; /** * Gets the current counter value for a context. * * @param context Context name to check * @returns Current counter value */ static getCounterValue(context: string): number; /** * Generates EntityIds for common domain scenarios. * Provides convenient presets for typical business domains. */ static readonly presets: { /** * User-related EntityId generators */ users: { /** Standard user ID: USER-001, USER-002, etc. */ standard: () => EntityId; /** Admin user ID: ADMIN-YYYY-001 */ admin: () => EntityId; /** Customer ID: CUST-{{random:6}} */ customer: () => EntityId; /** Guest user ID: GUEST-{{timestamp}} */ guest: () => EntityId; }; /** * Order-related EntityId generators */ orders: { /** Standard order ID: ORDER-2025-0001 */ standard: () => EntityId; /** Draft order ID: DRAFT-{{random:8}} */ draft: () => EntityId; /** Subscription order: SUB-{{year}}{{month}}-{{sequence:3}} */ subscription: () => EntityId; /** Return order: RET-{{uuid:12}} */ return: () => EntityId; }; /** * Product-related EntityId generators */ products: { /** Standard product ID: PROD-001 */ standard: () => EntityId; /** SKU-based ID: SKU-{{random:6}}-{{sequence:2}} */ sku: () => EntityId; /** Category-based: CAT-{{faker:word}}-{{sequence:3}} */ category: () => EntityId; }; /** * Event-related EntityId generators */ events: { /** Domain event: EVT-{{timestamp}}-{{uuid:8}} */ domain: () => EntityId; /** Integration event: INT-{{date}}-{{sequence:4}} */ integration: () => EntityId; /** Audit event: AUDIT-{{year}}{{month}}-{{sequence:5}} */ audit: () => EntityId; }; }; }