///
import { BossObject, BossPrimitive } from "uparsecjs";
interface MapSerializationHandler {
serialize: (instance: T) => Promise;
deserialize: (map: BossObject) => Promise;
}
/**
* The simple object that has sort of "copy constructor" that assigns all properties from an argument.
* Useful to implement interfaces.
*/
export declare class CaseObject {
constructor(props: any);
}
export interface MapSerializable {
toMap(): Promise;
}
interface MapDeserializable extends Function {
fromMap(params: BossObject): Promise;
}
export declare class MapSerializer {
static Exception: {
new (message?: string | undefined): {
name: string;
message: string;
stack?: string | undefined;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
stackTraceLimit: number;
};
static NotFound: {
new (message?: string | undefined): {
name: string;
message: string;
stack?: string | undefined;
};
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
stackTraceLimit: number;
};
static registerClass(cls: MapDeserializable, overrideName?: string): void;
static registerCaseObject(cls: T, overrideName?: string): void;
static register(name: string, handler: MapSerializationHandler): void;
static deserialize(serialized: BossObject): Promise;
static serializeAny(source: any): Promise;
static deserializeAny(source: BossPrimitive): Promise;
/**
*
* @param source
*/
static serialize(source: any): Promise;
static toBoss(source: any): Promise;
/**
* Unpack boss binary and deserialize its root object or object at some path.
* @param allowNotTyped use [[deserializeAny]] instead of [[deserialize]], to restore structures without `$` type tag
* @param packed binary boss-packed data
* @param path if present, specify the path inside unpacked data to the object to unpack.
* @return promise to the unpacked object.
* @throws NotFound if path does not existing in the unpacked object
* @throws Exception if deserialization failed
*/
static deserializeBoss(allowNotTyped: boolean | undefined, packed: Uint8Array, ...path: string[]): Promise;
static fromBoss(packed: Uint8Array, ...path: string[]): Promise;
static anyFromBoss(packed: Uint8Array, ...path: string[]): Promise;
}
/**
* Decorator to register a class as MapSerializable providing it meets interface requirements. Works only
* if the class constructor name is the same as a type tag. If not, use direct registration with
* [[MapSerializer.registerClass]] for example.
* @param cls class to register
*/
export declare function Serializable(cls: MapDeserializable): void;
export declare function fromBoss(packed: Uint8Array, ...path: string[]): Promise;
export declare function toBoss(source: Function | MapSerializable): Promise;
export declare type SerializedSet = {
$: 'Set';
data: T[];
};
export {};