import { PatchableArray } from '../structs/PatchableArray.js'; import { Cloneable } from './Cloneable.js'; import { Data } from './Data.js'; import { Decoder } from './Decoder.js'; import { Encodeable, PlainObject } from './Encodeable.js'; import { EncodeContext } from './EncodeContext.js'; import { Field } from './Field.js'; import { AutoEncoderPatchType, PartialWithoutMethods, Patchable } from './Patchable.js'; export type PatchableDecoder = Decoder & (T extends AutoEncoder ? {} : (T extends Patchable ? { patchType: () => PatchableDecoder

; patchIdentifier: () => Decoder; } : {})); export declare function coalesceUndefined(...values: (T)[]): T | undefined; type AutoEncoderConstructorNames = { [K in keyof T]: T[K] extends Function | PatchableArray ? never : K; }[Exclude]; export type AutoEncoderConstructor = Pick>; /** * Create patchable auto encoder. * We are not able to add types here, gets too complex. But we'll add a convenience method with typings */ export declare class AutoEncoder implements Encodeable, Cloneable { readonly _isAutoEncoder = true; static fields: Field[]; private static cachedPatchType?; static isPatch: boolean; static putType?: typeof AutoEncoder; static skipDefaultValuesVersion: number; static patchType(this: T): typeof AutoEncoder & (new () => AutoEncoderPatchType>); /** * Try to build a default value for this object, if possible. If this is not possible it will return undefined. * * Override if you want to set custom default values or disable this behavior. */ static getDefaultValue(this: T): InstanceType | undefined; static isDefaultValue(this: T, value: AutoEncoder): boolean; equals(other: AutoEncoder): boolean; isPatch(this: T | AutoEncoderPatchType): this is AutoEncoderPatchType; isPut(this: T | AutoEncoderPatchType): this is T; static patch(this: T, object: PartialWithoutMethods>>): AutoEncoderPatchType>; patchOrPut(this: T, patch: AutoEncoderPatchType | T): void; /** * Make a deep clone of this object */ clone(this: T): this; patch(this: T, patch: PartialWithoutMethods> | AutoEncoderPatchType | T | PartialWithoutMethods): this; private static compareField; static sortFields(): void; /** * WeakMap is overkill on static classes. * This is drammatically faster than using Object.prototype.hasOwnProperty */ static __fieldsForVersion: Map[]>; static __latestVersion: number; static __latestFields: Field[]; static __isConstructorDefaults: Map boolean>; protected static getIsConstructorDefaults(): Map boolean>; protected static isConstructorDefault(property: string, val: unknown): boolean | null; static get latestVersion(): number; static setCachedLatestVersion(): number; static get latestFields(): Field[]; static fieldsForVersion(version: number): Field[]; static doesPropertyExist(property: string): boolean; /** * Create a new one by providing the properties of the object */ static create(this: T, object: PartialWithoutMethods>): InstanceType; /** * Create a new one by providing the properties of the object */ set(this: T, object: PartialWithoutMethods | T): void; /** * Create a new one by providing the properties of the object. * Maintaining references to objects */ deepSet(this: T, object: PartialWithoutMethods | T): unknown; get static(): typeof AutoEncoder; /** * When returning true, the value won't be encoded in the encoded version of the object */ static isPropertyDefaultValue(field: Field, value: unknown, longTermStorage: boolean): boolean; encode(context: EncodeContext): PlainObject; static decodeField(this: T, v: unknown, context: EncodeContext, currentField?: string): InstanceType; static decode(this: T, data: Data): InstanceType; /** * Upgrade property values coming from an older version * @param from * @param object */ static upgrade(from: number, object: InstanceType, defaultValues: Map): void; /** * Downgrade property values to a new object */ static downgrade(to: number, object: any): object; } export {}; //# sourceMappingURL=AutoEncoder.d.ts.map