import { Prop, PropConfig, PropError, PropRef } from './props'; /** * Model configuration interface. */ export interface ModelConfig { context?: Context | (() => Context); failFast?: boolean | (() => boolean); parent?: Model; } /** * Strongly typed javascript object. */ export declare class Model { static readonly $props: { [key: string]: PropConfig; }; readonly $config: ModelConfig; readonly $props: { [key: string]: Prop; }; /** * Class constructor. * @param data Model initial data. * @param config Model configuration. */ constructor(data?: any, config?: ModelConfig); /** * Returns model context object. */ getContext(): Context; /** * Returns parent model instance. */ getParent(): Model; /** * Returns the root model instance. */ getRoot(): Model; /** * Returns a value at path. */ getProp(...keys: any[]): Prop; /** * Returns `true` if the prop exists. */ isProp(...keys: any[]): boolean; /** * Deeply assignes data to model props. */ populate(data: any, strategy?: string): this; /** * Converts this class into serialized data object. */ serialize(strategy?: string): { [key: string]: any; }; /** * Scrolls through the model and returns an array of property instances. */ flatten(prefix?: string[]): PropRef[]; /** * Scrolls through object props and collects results. */ collect(handler: (prop: PropRef) => any): any[]; /** * Scrolls through model props and executes a handler on each prop. */ scroll(handler: (prop: PropRef) => void): number; /** * Converts this class into serialized data object with only the keys that * pass the provided `test`. */ pluck(test: (prop: PropRef) => boolean): { [key: string]: any; }; /** * Sets each model prop to its default value. */ reset(): this; /** * Resets properties then sets properties to their fake values. */ fake(): this; /** * Sets all fileds to `null`. */ empty(): this; /** * Resets information about changed props by setting initial value of each prop. */ commit(): this; /** * Sets each prop to its initial value (value before last commit). */ rollback(): this; /** * Makes all properties not settable. */ freeze(): this; /** * Returns `true` when the `value` represents an object with the same prop * values as the original model. */ isEqual(value: any): boolean; /** * Returns `true` if at least one prop has been changed. */ isChanged(): boolean; /** * Returns `true` when no errors exist. */ isValid(): boolean; /** * Validates props and throws an error. */ validate({ quiet }?: { quiet?: boolean; }): Promise; /** * Handles the error and throws an error if the error can not be handled. */ handle(error: any, { quiet }?: { quiet?: boolean; }): Promise; /** * Sets props errors. */ applyErrors(errors?: PropError[]): this; /** * Returns a list of all props with errors. */ collectErrors(): PropError[]; /** * Removes props errors. */ invalidate(): this; /** * Returns a new Model instance which is the exact copy of the original. */ clone(data?: {}): this; /** * Defines all registered class properties. Registered properties are stored * on the static variable using the @prop decorator. */ protected defineProps(): void; /** * Defines a new class property. */ protected defineProp(key: string, config: PropConfig): void; } //# sourceMappingURL=models.d.ts.map