import { ClassSchema, PropertyCompilerSchema, PropertySchema } from "./decorators"; import { ClassType } from "@marcj/estdlib"; export declare let moment: any; /** * This is used withing JIT functions. * @hidden */ export declare function findParent(parents: any[], parentType: ClassType): T | undefined; /** * This resolves the PropertyCompilerSchema for a property path. * * A property path can be a deep path, separated with dots. This function makes sure to return the * correct PropertyCompilerSchema so that a correct compiler can be built to convert this type. */ export declare function resolvePropertyCompilerSchema(schema: ClassSchema, propertyPath: string): PropertyCompilerSchema; /** * A handy utility class that allows fast access to a JitPropertyConverter class. */ export declare class CacheJitPropertyConverter { readonly fromFormat: string; readonly toFormat: string; protected cache: Map, JitPropertyConverter>; constructor(fromFormat: string, toFormat: string); getJitPropertyConverter(classType: ClassType): JitPropertyConverter; } /** * Creates a new JIT compiled function to convert given property schema for certain paths. * Paths can be deep paths making it possible to convert patch-like/mongo structure * * Note: If fromFormat -> toFormat has no compiler templates registered, * the generated function does virtually nothing. */ export declare class JitPropertyConverter { readonly fromFormat: string; readonly toFormat: string; protected schema: ClassSchema; protected cacheJitPropertyMap: WeakMap; constructor(fromFormat: string, toFormat: string, classType: ClassType); convert(path: string, value: any, parents?: any[]): any; convertProperty(property: PropertyCompilerSchema, value: any, parents?: any[]): any; } /** * * Creates a new JIT compiled function to convert given property schema. Deep paths are not allowed. */ export declare function createJITConverterFromPropertySchema(fromFormat: string, toFormat: string, property: PropertySchema): (value: any, parents?: any[]) => any; export declare class ToClassState { onFullLoadCallbacks: (() => void)[]; } export declare function createClassToXFunction(classType: ClassType, toFormat: string | 'plain'): (instance: T) => any; export declare function createXToClassFunction(classType: ClassType, fromTarget: string | 'plain'): (data: { [name: string]: any; }, parents?: any[], state?: ToClassState) => T; export declare function jitPlainToClass(classType: ClassType, data: any, parents?: any[]): T; export declare function jitClassToPlain(classType: ClassType, instance: T): Partial; export declare function jitPartial(fromFormat: string, toFormat: string, classType: ClassType, partial: { [name: string]: any; }, parents?: any[]): Partial<{ [F in K]: any; }>; export declare function jitPartialClassToPlain(classType: ClassType, partial: { [name: string]: any; }): Partial<{ [F in K]: any; }>; export declare function jitPartialPlainToClass(classType: ClassType, partial: { [name: string]: any; }, parents?: any[]): Partial<{ [F in K]: any; }>;