/** * @module morphism */ import { SCHEMA_OPTIONS_SYMBOL } from './helpers'; import { Schema, StrictSchema, Constructable, SourceFromSchema, Mapper, DestinationFromSchema } from './types'; import { createSchema, SchemaOptions } from './MorphismTree'; import { IMorphismRegistry } from './MorphismRegistry'; /** * Currying function that either outputs a mapping function or the transformed data. * * @example * ```js * // => Outputs a function when only a schema is provided const fn = morphism(schema); const result = fn(data); // => Outputs the transformed data when a schema and the input data is provided const result = morphism(schema, data); // => Outputs the transformed data as an ES6 Class Object when a schema, the input data and an ES6 Class are provided const result = morphism(schema, data, Foo); // result is type of Foo * ``` * @param {Schema} schema Structure-preserving object from a source data towards a target data * @param {} items Object or Collection to be mapped * @param {} type * */ declare function morphism, SourceFromSchema>, Source extends SourceFromSchema = SourceFromSchema>(schema: TSchema, data: Source[]): DestinationFromSchema[]; declare function morphism, SourceFromSchema>, Source extends SourceFromSchema = SourceFromSchema>(schema: TSchema, data: Source): DestinationFromSchema; declare function morphism, SourceFromSchema>>(schema: TSchema): Mapper; declare function morphism(schema: TSchema, items: null, type: Constructable): Mapper; declare function morphism, SourceFromSchema>, Target = never, Source extends SourceFromSchema = SourceFromSchema>(schema: TSchema, items: Source, type: Constructable): Target; declare function morphism, SourceFromSchema>, Target = never, Source extends SourceFromSchema = SourceFromSchema>(schema: TSchema, items: Source[], type: Constructable): Target[]; /** * Function Decorator transforming the return value of the targeted Function using the provided Schema and/or Type * * @param {Schema} schema Structure-preserving object from a source data towards a target data * @param {Constructable} [type] Target Class Type */ export declare function morph(schema: Schema, type?: Constructable): (_target: any, _name: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Function Decorator transforming the return value of the targeted Function to JS Object(s) using the provided Schema * * @param {StrictSchema} schema Structure-preserving object from a source data towards a target data */ export declare function toJSObject(schema: StrictSchema): (_target: any, _name: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Function Decorator transforming the return value of the targeted Function using the provided Schema and Class Type * * @param {Schema} schema Structure-preserving object from a source data towards a target data * @param {Constructable} [type] Target Class Type */ export declare function toClassObject(schema: Schema, type: Constructable): (_target: any, _name: string, descriptor: PropertyDescriptor) => PropertyDescriptor; declare const Morphism: typeof morphism & IMorphismRegistry; export { morphism, createSchema, Schema, StrictSchema, SchemaOptions, Mapper, SCHEMA_OPTIONS_SYMBOL }; export default Morphism;