71 lines
2.6 KiB
TypeScript
71 lines
2.6 KiB
TypeScript
import { Deserialize } from './de';
|
|
import { Serialize } from './ser';
|
|
import { CaseConvention } from './case';
|
|
import { Nullable } from './utils';
|
|
export interface RenameOptions {
|
|
serialize?: string;
|
|
deserialize?: string;
|
|
}
|
|
export interface RenameAllOptions {
|
|
serialize?: CaseConvention;
|
|
deserialize?: CaseConvention;
|
|
}
|
|
export interface ContainerOptions {
|
|
rename?: RenameOptions | string;
|
|
renameAll?: RenameAllOptions | CaseConvention;
|
|
default?: () => any;
|
|
denyUnknownFields?: boolean;
|
|
tag?: string;
|
|
untagged?: boolean;
|
|
}
|
|
interface Predicate {
|
|
<T>(value: T): boolean;
|
|
}
|
|
export interface SkipOptions {
|
|
serialize?: Predicate | boolean;
|
|
deserialize?: Predicate | boolean;
|
|
}
|
|
export interface PropertyOptions {
|
|
alias?: string | string[];
|
|
default?: () => any;
|
|
flatten?: boolean;
|
|
rename?: RenameOptions | string;
|
|
skip?: SkipOptions | Predicate | boolean;
|
|
serializeWith?: Serialize<any>;
|
|
deserializeWith?: Deserialize<any>;
|
|
}
|
|
export declare const Stage: Readonly<{
|
|
readonly Serialize: 0;
|
|
readonly Deserialize: 1;
|
|
}>;
|
|
export declare class PropertyMap extends Map<string, PropertyOptions> {
|
|
private readonly options;
|
|
private readonly aliases;
|
|
constructor(options: SerdeOptions, iterable?: Iterable<any>);
|
|
private setAliasesFromOptions;
|
|
set(key: string, value: PropertyOptions): this;
|
|
addAlias(alias: string | Iterable<string>, key: string): void;
|
|
getFieldFromAlias(alias: string): string | undefined;
|
|
private buildAliasMap;
|
|
}
|
|
export type Stage = typeof Stage[keyof typeof Stage];
|
|
export declare class SerdeOptions {
|
|
readonly target: Nullable<any>;
|
|
readonly container: ContainerOptions;
|
|
readonly properties: PropertyMap;
|
|
constructor(target: any, container?: ContainerOptions, properties?: PropertyMap);
|
|
private getClassName;
|
|
getSerializedClassName(defaultName?: string): string | undefined;
|
|
getDeserializedClassName(defaultName?: string): string | undefined;
|
|
getCaseConvention(stage: Stage): CaseConvention | undefined;
|
|
applyCaseConvention(stage: Stage, property: string): string;
|
|
getPropertyRename(stage: Stage, property: string): string | undefined;
|
|
getSerializationPropertyName(property: string): string;
|
|
getNameFromAlias(alias: string): string | undefined;
|
|
getDeserializationPropertyName(property: string): string;
|
|
shouldSkip(stage: Stage, property: string, value: any): boolean;
|
|
shouldSkipSerialization(property: string, value: any): boolean;
|
|
shouldSkipDeserialization(property: string, value: any): boolean;
|
|
defaultFor(property: string): any;
|
|
}
|
|
export {};
|