Libraries
    Preparing search index...

    Class MappingRegistry<TRegistered>

    Type Parameters

    • TRegistered = never
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    _mappers: Map<
        ObjectSchemaBuilder<any, any, any, undefined, false, {}>,
        Map<
            ObjectSchemaBuilder<any, any, any, undefined, false, {}>,
            SchemaToSchemaMapperResult<any, any>,
        >,
    > = ...

    Methods

    • Defines a mapping between two schemas and returns a new immutable registry containing the mapping. The callback fn receives a fresh Mapper and must return it after configuring property mappings. The mapper is automatically finalized and registered. Properties not explicitly mapped or ignored may be auto-mapped if a matching nested mapping is already registered in the registry.

      Type Parameters

      • TFromSchema extends ObjectSchemaBuilder<any, any, any, undefined, false, {}>
      • TToSchema extends ObjectSchemaBuilder<any, any, any, undefined, false, {}>

      Parameters

      Returns MappingRegistry<TRegistered | [TFromSchema, TToSchema]>

      a new MappingRegistry containing all previous mappings plus the newly configured one

      if schemas are invalid, mapping is duplicate, or unmapped properties remain that cannot be auto-mapped

    • Gets a mapper function that will map from the fromSchema to the toSchema. Throws an error if no mapper is found for the given schemas pair.

      Type Parameters

      • TFromSchema extends ObjectSchemaBuilder<any, any, any, undefined, false, {}>
      • TToSchema extends ObjectSchemaBuilder<any, any, any, undefined, false, {}>

      Parameters

      Returns SchemaToSchemaMapperResult<TFromSchema, TToSchema>

      a function that will take a value of the fromSchema type as an argument and return a promise resolving to a value of the toSchema type