UNPKG

emr-types

Version:

Comprehensive TypeScript Types Library for Electronic Medical Record (EMR) Applications - Domain-Driven Design with Zod Validation

132 lines 3.02 kB
/** * ID Value Object * * Represents a unique identifier with validation and type safety * * @interface Id * @description Generic ID value object for domain entities */ export interface Id { /** The unique identifier value */ value: string; /** The type of ID (e.g., 'uuid', 'ulid', 'custom') */ type: 'uuid' | 'ulid' | 'custom' | 'auto-increment'; /** Timestamp when the ID was generated */ generatedAt: Date; /** Whether the ID is valid */ isValid: boolean; } /** * UUID ID Value Object * * Represents a UUID identifier * * @interface UuidId */ export interface UuidId extends Id { type: 'uuid'; } /** * ULID ID Value Object * * Represents a ULID identifier * * @interface UlidId */ export interface UlidId extends Id { type: 'ulid'; } /** * Custom ID Value Object * * Represents a custom identifier * * @interface CustomId */ export interface CustomId extends Id { type: 'custom'; /** Custom format or pattern */ format?: string | undefined; } /** * Auto-increment ID Value Object * * Represents an auto-increment identifier * * @interface AutoIncrementId */ export interface AutoIncrementId extends Id { type: 'auto-increment'; /** The numeric value */ numericValue: number; } /** * ID Factory Functions */ export declare const IdFactory: { /** * Create a UUID ID */ createUuid: (value: string) => UuidId; /** * Create a new UUID ID (generates random UUID) */ create: () => UuidId; /** * Create a ULID ID */ createUlid: (value: string) => UlidId; /** * Create a custom ID */ createCustom: (value: string, format?: string) => CustomId; /** * Create an auto-increment ID */ createAutoIncrement: (value: string, numericValue: number) => AutoIncrementId; /** * Create ID from string (auto-detect type) */ fromString: (value: string) => Id; }; /** * ID Validation Functions */ export declare const IdValidator: { /** * Validate if a string is a valid UUID */ isValidUuid: (value: string) => boolean; /** * Validate if a string is a valid ULID */ isValidUlid: (value: string) => boolean; /** * Validate if a string is a valid auto-increment ID */ isValidAutoIncrement: (value: string) => boolean; /** * Check if an ID object is valid */ isValid: (id: Id) => boolean; /** * Validate ID format */ validateFormat: (value: string) => boolean; /** * Check if ID is empty */ isEmpty: (id: Id) => boolean; /** * Compare two IDs */ areEqual: (id1: Id, id2: Id) => boolean; }; /** * Type guards for ID types */ export declare const isUuidId: (id: Id) => id is UuidId; export declare const isUlidId: (id: Id) => id is UlidId; export declare const isCustomId: (id: Id) => id is CustomId; export declare const isAutoIncrementId: (id: Id) => id is AutoIncrementId; //# sourceMappingURL=Id.d.ts.map