UNPKG

@mbc-cqrs-serverless/import

Version:
28 lines (27 loc) 1.17 kB
export interface IImportStrategy<TInput extends object, TAttributesDto extends object> { /** * Transforms a raw input object (from an API, CSV row, etc.) * into a standardized DTO. */ transform(input: TInput): Promise<TAttributesDto>; /** * Validates the standardized DTO. * @throws {Error} or a custom exception if validation fails. */ validate(data: TAttributesDto): Promise<void>; } /** * A base class (framework) that provides partial logic for an Import Strategy. * Users can extend this class to save effort. */ export declare abstract class BaseImportStrategy<TInput extends object, TAttributesDto extends object> implements IImportStrategy<TInput, TAttributesDto> { transform(input: TInput): Promise<TAttributesDto>; validate(data: TAttributesDto): Promise<void>; /** * Recursively flattens validation errors into a single array of strings. * @param errors The array of ValidationError objects. * @param parentPath The path of the parent property, used for building nested paths. * @returns An array of human-readable error strings. */ private flattenValidationErrors; }