rich-domain
Version:
This package provide utils file and interfaces to assistant build a complex application with domain driving design
34 lines • 1.93 kB
TypeScript
import { AutoMapperSerializer, EntityMapperPayload, _AutoMapper, _Entity, _ValueObject } from "../types";
/**
* @description The AutoMapper class is responsible for transforming domain resources (entities, value objects)
* into plain objects or primitive values. It provides methods to recursively process nested value objects, IDs,
* entities, and arrays, ensuring all complex data structures are serialized into a consistent object format.
*/
export declare class AutoMapper<Props> implements _AutoMapper<Props> {
private validator;
/**
* @description Converts a value object into a plain object or a primitive value.
* This method handles multiple scenarios, including:
* - Null values
* - Symbol values
* - ID values
* - Simple data types (strings, numbers, booleans, dates, objects)
* - Nested value objects
* - Arrays containing complex data
* @param valueObject An instance representing a value object to be transformed.
* @returns A plain object, primitive value, or serialized structure derived from the given value object.
*/
valueObjectToObj(valueObject: _ValueObject<Props>): AutoMapperSerializer<Props>;
/**
* @description Transforms an entity into a plain object, including its associated meta properties
* (`id`, `createdAt`, `updatedAt`). This method:
* - Resolves IDs to their primitive value forms.
* - Recursively converts nested entities, aggregates, and value objects to plain objects.
* - Preserves arrays and transforms their elements as needed.
* @param entity The entity instance to be transformed into a plain object.
* @returns A plain object representing the entity, including its metadata and serialized properties.
*/
entityToObj(entity: _Entity<Props>): AutoMapperSerializer<Props> & EntityMapperPayload;
}
export default AutoMapper;
//# sourceMappingURL=auto-mapper.d.ts.map