import { Type } from "@tsed/core"; import { JsonSchema } from "@tsed/schema"; /** * Signature exposed by compiled mappers. They accept an input value plus contextual options * and return the serialized/deserialized result. */ export type JsonMapperCallback = (input: any, options?: Options) => any; /** * Executable mapper plus its unique identifier stored in the compiler cache. */ export type CachedJsonMapper = { id: string; fn: JsonMapperCallback; }; /** * Cached mapper registry keyed by the groups fingerprint generated for a schema. */ export type CachedGroupsJsonMapper = Map>; /** * Base compiler that turns schema metadata into executable (de)serialization functions. * Subclasses supply `map`, `alterValue`, and `createMapper` implementations to specialize * the pipeline for serialization or deserialization. */ export declare abstract class JsonMapperCompiler = any> { /** * Cached mappers metadata * @protected */ protected cache: Map, CachedGroupsJsonMapper>; /** * Cached executable mappers by his id * @protected */ protected mappers: Record>; /** * Cached schemas * @protected */ protected schemes: Record; /** * Cached classes by his id * @protected */ protected constructors: Record>; /** * Global variables available in the mapper * @protected */ protected globals: Record; constructor(); addTypeMapper(model: Type | string, fn: any): this; removeTypeMapper(model: Type | string): void; addGlobal(key: string, value: any): this; eval(mapper: string, { id, groupsId, model, storeGroups }: { id: string; groupsId: string; model: Type | string; storeGroups: CachedGroupsJsonMapper; }): CachedJsonMapper; createContext(options: Options): Options & { cache: Map, CachedGroupsJsonMapper>; }; compile(model: Type | string, groups: false | string[], opts?: { mapper?: any; }): CachedJsonMapper; protected execMapper(id: string, value: any, options: Options): any; protected abstract map(input: any, options: Options): any; protected abstract alterValue(schemaId: string, value: any, options: Options): any; protected abstract createMapper(model: Type, id: string, groups: false | string[]): string; protected getType(model: Type): Type | MapConstructor | ObjectConstructor | ArrayConstructor | SetConstructor; protected alterIgnore(id: string, options: Options): any; protected alterGroups(schema: JsonSchema, groups: false | string[]): boolean; protected getGroupsId(groups: false | string[]): string; protected getId(model: Type | string, groupsId: string): string; protected getSchemaId(id: string, propertyKey: string): string; }