import { IObjectWillChange, IObjectChange } from 'mobx'; import { ComplexType, IType, IComplexType } from '../Type'; import { TypeFlags } from '../type-flags'; import { ValueProperty } from '../property-types/ValueProperty'; import { IJsonPatch, IStateTreeNode } from '../../core/NodeUtils'; import { IContext, IValidationResult } from '../type-checker'; import { ObjectNode } from '../../core/ObjectNode'; import { INode } from '../../core/interface'; export declare type ModelTypeConfig = { name?: string; extra?: { [K: string]: any; }; properties?: { [K: string]: IType; }; initializers?: ReadonlyArray<((instance: any) => any)>; preProcessor?: (snapshot: any) => any; }; export declare class ObjectType extends ComplexType { readonly shouldAttachNode: boolean; readonly flags: TypeFlags; readonly initializers: ((instance: any) => any)[]; properties: { [K: string]: IType; }; extra: { [K: string]: any; }; modelConstructor: new () => any; private _props; private propsKeys; private preProcessor; private _identifierProp; constructor(opts: ModelTypeConfig); named(name: string): IModelType; extras(extra: { [k: string]: any; }): IModelType; props(properties: { [K in keyof TP]: IType; } & { [K in keyof SP]: IType; }): IModelType; instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: any): INode; createNewInstance: () => Object; finalizeNewInstance: (node: ObjectNode, snapshot: any) => void; preProcessSnapshot(preProcessor: (snapshot: any) => S): IModelType; willChange(change: IObjectWillChange): IObjectWillChange | null; didChange: (change: IObjectChange) => void; applySnapshot(node: ObjectNode, snapshot: any): void; applyPatchLocally(node: ObjectNode, subpath: string, patch: IJsonPatch): void; applySnapshotPreProcessor(snapshot: any): any; getValue(node: ObjectNode): any; getDefaultSnapshot(): any; getSnapshot(node: ObjectNode): any; hasNestedFields(): boolean; getChildren(node: ObjectNode): INode[]; getChildField(node: ObjectNode, key: string): INode; getChildType(key: string): IType; readonly identityProperty: ValueProperty; getValueProperties(): ValueProperty[]; removeChild(node: ObjectNode, subpath: string): void; isValidSnapshot(value: any, context: IContext): IValidationResult; cloneAndEnhance(opts: ModelTypeConfig): ObjectType; actions(fn: (self: T) => A): IModelType; instantiateActions(self: T, actions: { [name: string]: Function; }): void; views(fn: (self: T) => V): IModelType; instantiateViews(self: T, views: Object): void; volatile(fn: (self: T) => TP): IModelType; instantiateVolatileState(self: T, state: Object): void; extend(fn: (self: T & IStateTreeNode) => { actions?: A; views?: V; state?: VS; }): IModelType; parseModelProps(): void; private forAllProps(fn); describe(): string; } export declare function model(name: string, properties?: IModelProperties): IModelType, IModelPros>; export declare function model(properties?: IModelProperties): IModelType, IModelPros>; export declare type IModelProperties = { [K in keyof T]?: IType | T[K]; }; export declare type IModelVolatileState = { [K in keyof T]?: ((self?: any) => T[K]) | T[K]; }; export declare type IModelPros = { [K in keyof T]?: T[K]; }; export declare type Snapshot = { [K in keyof T]?: Snapshot | T[K]; }; export interface IModelType extends IComplexType { named(newName: string): IModelType; extras(newExtra: { [k: string]: any; }): IModelType; props(props: { [K in keyof TP]?: IType | TP[K]; } & { [K in keyof SP]?: IType | SP[K]; }): IModelType, T & TP>; views(fn: (self: T & IStateTreeNode) => V): IModelType>; actions(fn: (self: T & IStateTreeNode) => A): IModelType>; volatile(fn: (self: T) => TP): IModelType>; extend(fn: (self: T & IStateTreeNode) => { actions?: A; views?: V; state?: VS; }): IModelType & IModelPros & IModelPros>; preProcessSnapshot(fn: (snapshot: any) => S): IModelType; } export declare function compose(t1: IModelType, t2: IModelType, t3?: IModelType): IModelType; export declare function compose(name: string, t1: IModelType, t2: IModelType, t3?: IModelType): IModelType; export declare function compose(name: string, baseType: IModelType, properties: IModelProperties & ThisType, volatileState: IModelVolatileState & ThisType, operations: ThisType): IModelType; export declare function compose(name: string, baseType: IModelType, properties: IModelProperties & ThisType, operations?: ThisType): IModelType; export declare function compose(baseType: IModelType, properties: IModelProperties & ThisType, volatileState: IModelVolatileState & ThisType, operations: ThisType): IModelType; export declare function compose(baseType: IModelType, properties: IModelProperties & ThisType, operations?: ThisType): IModelType; export declare function getObjectType(object: IStateTreeNode): ObjectType;