/** * Base Mapper * * Abstract base class for domain mappers handling data transformation. * Supports all HTTP operations with corresponding mapping methods. * * Mapping concerns: * - Request mapping (domain → API DTO for POST, PUT, PATCH, DELETE) * - Response mapping (API DTO → domain) * - Store mapping (domain ↔ Zustand state) * - Query mapping (filters → query params) * * Note: Validation is handled by BaseValidator, not here. * * @example * ```typescript * class ExampleMapper extends BaseMapper< * ExampleEntity, // Domain model * ExampleResponseDTO, // API response * CreateExampleDTO, // POST body * UpdateExampleDTO, // PUT body * PatchExampleDTO, // PATCH body * QueryExampleDTO, // GET params * ExampleStoreItem // Store state * > { * toDomain(dto) { ... } * toCreateDTO(data) { ... } * // ... implement needed methods * } * ``` */ import type { CoreBaseMapperInstance } from '@plyaz/types/core'; /** * Abstract base mapper with default implementations * * Required to implement: * - toDomain(dto): Convert API response to domain model * * Optional to implement (based on your needs): * - toCreateDTO(data): For POST requests * - toUpdateDTO(data): For PUT requests * - toPatchDTO(data): For PATCH requests * - toQueryDTO(filters): For GET query params * - toStoreState(domain): Custom store state shape * - fromStoreState(state): Restore domain from store */ export declare abstract class BaseMapper, TQueryDTO = unknown, TStoreState = TDomain> implements CoreBaseMapperInstance { /** * Convert API response DTO to domain model * Handle snake_case → camelCase, add computed properties */ abstract toDomain(dto: TResponseDTO): TDomain; /** * Convert domain data to create DTO (POST body) * Handle camelCase → snake_case, pick required fields */ toCreateDTO?(data: Partial): TCreateDTO; /** * Convert domain data to update DTO (PUT body - full replacement) * Default: same as toCreateDTO */ toUpdateDTO?(data: Partial): TUpdateDTO; /** * Convert domain data to patch DTO (PATCH body - partial) * Default: picks only defined fields */ toPatchDTO?(data: Partial): TPatchDTO; /** * Convert filter object to query params DTO (GET) * Handle pagination, sorting, filtering */ toQueryDTO?(filters: Partial): TQueryDTO; /** * Convert database row/repository result to response DTO * Override to map repository output to API response format * Useful when repository returns different format than API expects */ toResponseDTO?(row: unknown): TResponseDTO; /** * Map array of DTOs to domain models */ toDomainList(dtos: TResponseDTO[]): TDomain[]; /** * Convert domain model to store state (serializable) * Default: strips functions, keeps data */ toStoreState(domain: TDomain): TStoreState; /** * Convert array of domain models to aggregated store state * Override to customize how multiple items map to store * Default: returns array of individual store states (as Partial since shape may differ) */ toStoreStateList?(domains: TDomain[]): Partial; /** * Restore domain model from store state * Override to restore computed properties/methods */ fromStoreState(state: TStoreState): TDomain; } //# sourceMappingURL=BaseMapper.d.ts.map