web / lib/services/type-transformation
lib/services/type-transformation
Provides a service for transforming data types within a record.
This service is responsible for applying a set of configurable transformation rules to a data record. It is used to clean and normalize data during the import process, handling mismatches between the source data’s type and the desired schema type.
It supports several transformation strategies:
parse: Attempts to intelligently parse a value into the target type (e.g., string to number).cast: Performs a direct type cast (e.g.,String(value)).custom: Allows for a user-defined JavaScript function to perform the transformation.reject: Throws an error if a type mismatch is found.
Classes
TypeTransformationService
Constructors
Constructor
new TypeTransformationService(
transformations):TypeTransformationService
Parameters
transformations
TransformationRule[]
Returns
Methods
transformRecord()
transformRecord(
record):Promise<{transformed:DataRecord;changes:TransformationChange[]; }>
Parameters
record
DataRecord
Returns
Promise<{ transformed: DataRecord; changes: TransformationChange[]; }>
Last updated on