59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { CaseConvention } from '../case';
|
|
import { Deserialize } from '../de';
|
|
import { Nullable } from '../utils';
|
|
import { Serialize } from './interface';
|
|
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;
|
|
}
|
|
export declare const Stage: Readonly<{
|
|
readonly Serialize: 0;
|
|
readonly Deserialize: 1;
|
|
}>;
|
|
export type Stage = typeof Stage[keyof typeof Stage];
|
|
export declare class SerdeOptions {
|
|
readonly target: Nullable<any>;
|
|
readonly container: ContainerOptions;
|
|
readonly properties: Map<string, PropertyOptions>;
|
|
constructor(target: any, container?: ContainerOptions, properties?: Map<string, PropertyOptions>);
|
|
private getClassName;
|
|
getSerializedClassName(defaultName?: string): string | undefined;
|
|
getDeserializedClassName(defaultName?: string): string | undefined;
|
|
private applyPropertyCase;
|
|
private getPropertyName;
|
|
getSerializationPropertyName(property: string): string;
|
|
getDeserializationPropertyName(property: string): string;
|
|
private shouldSkip;
|
|
shouldSerialize(property: string, value: any): boolean;
|
|
shouldDeserialize(property: string, value: any): boolean;
|
|
defaultFor(property: string): any;
|
|
}
|
|
export {};
|