mobx-keystone
Advanced tools
Comparing version 0.54.0 to 0.55.0
@@ -10,2 +10,6 @@ /** | ||
/** | ||
* onLazyInit hook | ||
*/ | ||
OnLazyInit = "$$onLazyInit", | ||
/** | ||
* onAttachedToRootStore hook | ||
@@ -22,2 +26,3 @@ */ | ||
* - onInit() hook | ||
* - onLazyInit() hook | ||
* - onAttachedToRootStore() hook | ||
@@ -24,0 +29,0 @@ * - disposer returned by a onAttachedToRootStore() hook |
import type { O } from "ts-toolbelt"; | ||
import type { AnyDataModel } from "../dataModel/BaseDataModel"; | ||
import type { AnyModel } from "../model/BaseModel"; | ||
@@ -7,7 +8,11 @@ import { ActionContext, ActionContextActionType } from "./context"; | ||
*/ | ||
export declare function wrapInAction<T extends Function>({ name, fn, actionType, overrideContext, isFlowFinisher, }: { | ||
name: string; | ||
export declare type WrapInActionOverrideContextFn = (ctx: O.Writable<ActionContext>, self: any) => void; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare function wrapInAction<T extends Function>({ nameOrNameFn, fn, actionType, overrideContext, isFlowFinisher, }: { | ||
nameOrNameFn: string | (() => string); | ||
fn: T; | ||
actionType: ActionContextActionType; | ||
overrideContext?: (ctx: O.Writable<ActionContext>) => void; | ||
overrideContext?: WrapInActionOverrideContextFn; | ||
isFlowFinisher?: boolean; | ||
@@ -18,2 +23,2 @@ }): T; | ||
*/ | ||
export declare function wrapModelMethodInActionIfNeeded<M extends AnyModel>(model: M, propertyKey: keyof M, name: string): void; | ||
export declare function wrapModelMethodInActionIfNeeded<M extends AnyModel | AnyDataModel>(model: M, propertyKey: keyof M, name: string): void; |
@@ -60,6 +60,6 @@ import type { ActionMiddlewareDisposer } from "../action/middleware"; | ||
declare const UndoStore_base: import("../model/Model")._Model<unknown, { | ||
undoEvents: import("..").OptionalModelProp<UndoEvent[], UndoEvent[]>; | ||
redoEvents: import("..").OptionalModelProp<UndoEvent[], UndoEvent[]>; | ||
undoEvents: import("..").OptionalModelProp<UndoEvent[]>; | ||
redoEvents: import("..").OptionalModelProp<UndoEvent[]>; | ||
} & { | ||
$modelId: import("..").ModelProp<string, string, string, string, string, true, never>; | ||
$modelId: import("..").ModelProp<string, string, string, true, never>; | ||
}>; | ||
@@ -66,0 +66,0 @@ /** |
export * from "./action"; | ||
export * from "./actionMiddlewares"; | ||
export * from "./context"; | ||
export * from "./fnModel"; | ||
export * from "./dataModel"; | ||
export * from "./frozen"; | ||
export * from "./globalConfig"; | ||
export * from "./model"; | ||
export * from "./modelShared"; | ||
export * from "./parent"; | ||
export * from "./patch"; | ||
export * from "./propTransform"; | ||
export * from "./redux"; | ||
@@ -15,2 +15,3 @@ export * from "./ref"; | ||
export * from "./snapshot"; | ||
export * from "./standardActions"; | ||
export * from "./treeUtils"; | ||
@@ -17,0 +18,0 @@ export * from "./tweaker"; |
import type { O } from "ts-toolbelt"; | ||
import { creationDataTypeSymbol, dataTypeSymbol, ModelClass } from "../modelShared/BaseModelShared"; | ||
import type { SnapshotInOfModel, SnapshotInOfObject, SnapshotOutOfModel } from "../snapshot/SnapshotOf"; | ||
@@ -8,18 +9,2 @@ import type { TypeCheckError } from "../typeChecking/TypeCheckError"; | ||
*/ | ||
export declare const propsDataTypeSymbol: unique symbol; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare const propsCreationDataTypeSymbol: unique symbol; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare const instanceDataTypeSymbol: unique symbol; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare const instanceCreationDataTypeSymbol: unique symbol; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare const modelIdPropertyNameSymbol: unique symbol; | ||
@@ -31,21 +16,13 @@ /** | ||
* | ||
* @typeparam PropsData Props data type. | ||
* @typeparam Data Data type. | ||
* @typeparam CreationData Creation data type. | ||
* @typeparam InstanceData Instace data type. | ||
* @typeparam InstanceCreationData Instance creation data type. | ||
* @typeparam ModelIdPropertyName Model id property name. | ||
*/ | ||
export declare abstract class BaseModel<PropsData extends { | ||
export declare abstract class BaseModel<Data extends { | ||
[k: string]: any; | ||
}, PropsCreationData extends { | ||
}, CreationData extends { | ||
[k: string]: any; | ||
}, InstanceData extends { | ||
[k: string]: any; | ||
} = PropsData, InstanceCreationData extends { | ||
[k: string]: any; | ||
} = PropsCreationData, ModelIdPropertyName extends string = never> { | ||
[propsDataTypeSymbol]: PropsData; | ||
[propsCreationDataTypeSymbol]: PropsCreationData; | ||
[instanceDataTypeSymbol]: InstanceData; | ||
[instanceCreationDataTypeSymbol]: InstanceCreationData; | ||
}, ModelIdPropertyName extends string = never> { | ||
[dataTypeSymbol]: Data; | ||
[creationDataTypeSymbol]: CreationData; | ||
[modelIdPropertyNameSymbol]: ModelIdPropertyName; | ||
@@ -73,5 +50,4 @@ /** | ||
* Use it if one of the data properties matches one of the model properties/functions. | ||
* This also allows access to the backed values of transformed properties. | ||
*/ | ||
readonly $: PropsData; | ||
readonly $: Data; | ||
/** | ||
@@ -99,3 +75,3 @@ * Optional hook that will run once this model instance is attached to the tree of a model marked as | ||
[k: string]: any; | ||
}): SnapshotInOfObject<PropsCreationData> & { | ||
}): SnapshotInOfObject<CreationData> & { | ||
[modelTypeKey]?: string; | ||
@@ -105,3 +81,3 @@ }; | ||
* Performs a type check over the model instance. | ||
* For this to work a data type has to be declared in the model decorator. | ||
* For this to work a data type has to be declared as part of the model properties. | ||
* | ||
@@ -112,5 +88,5 @@ * @returns A `TypeCheckError` or `null` if there is no error. | ||
/** | ||
* Creates an instance of Model. | ||
* Creates an instance of a model. | ||
*/ | ||
constructor(data: InstanceCreationData); | ||
constructor(data: CreationData); | ||
toString(options?: { | ||
@@ -123,21 +99,5 @@ withData?: boolean; | ||
*/ | ||
export interface AnyModel extends BaseModel<any, any, any, any, any> { | ||
export interface AnyModel extends BaseModel<any, any, any> { | ||
} | ||
/** | ||
* Extracts the instance type of a model class. | ||
*/ | ||
export interface ModelClass<M extends AnyModel> { | ||
new (initialData: any): M; | ||
} | ||
/** | ||
* Extracts the instance type of an abstract model class. | ||
*/ | ||
export declare type AbstractModelClass<M extends AnyModel> = abstract new (initialData: any) => M; | ||
/** | ||
* A model class declaration, made of a base model and the model interface. | ||
*/ | ||
export declare type ModelClassDeclaration<BaseModelClass, ModelInterface> = BaseModelClass & { | ||
new (...args: any[]): ModelInterface; | ||
}; | ||
/** | ||
* @deprecated Should not be needed anymore. | ||
@@ -154,29 +114,2 @@ * | ||
/** | ||
* Tricks Typescript into accepting a particular kind of generic class as a parameter for `ExtendedModel`. | ||
* Does nothing in runtime. | ||
* | ||
* @typeparam T Generic model class type. | ||
* @param type Generic model class. | ||
* @returns | ||
*/ | ||
export declare function modelClass<T extends AnyModel>(type: { | ||
prototype: T; | ||
}): ModelClass<T>; | ||
/** | ||
* The props data type of a model. | ||
*/ | ||
export declare type ModelPropsData<M extends AnyModel> = M["$"]; | ||
/** | ||
* The props creation data type of a model. | ||
*/ | ||
export declare type ModelPropsCreationData<M extends AnyModel> = M[typeof propsCreationDataTypeSymbol]; | ||
/** | ||
* The instance data type of a model. | ||
*/ | ||
export declare type ModelInstanceData<M extends AnyModel> = M[typeof instanceDataTypeSymbol]; | ||
/** | ||
* The transformed creation data type of a model. | ||
*/ | ||
export declare type ModelInstanceCreationData<M extends AnyModel> = M[typeof instanceCreationDataTypeSymbol]; | ||
/** | ||
* The model id property name. | ||
@@ -207,1 +140,7 @@ */ | ||
export declare function modelSnapshotOutWithMetadata<M extends AnyModel>(modelClass: ModelClass<M>, snapshot: O.Omit<SnapshotOutOfModel<M>, ModelIdPropertyName<M> | typeof modelTypeKey>, internalId?: string): SnapshotOutOfModel<M>; | ||
/** | ||
* A model class declaration, made of a base model and the model interface. | ||
*/ | ||
export declare type ModelClassDeclaration<BaseModelClass, ModelInterface> = BaseModelClass & { | ||
new (...args: any[]): ModelInterface; | ||
}; |
@@ -0,3 +1,4 @@ | ||
import type { ModelClass } from "../modelShared/BaseModelShared"; | ||
import type { AnyType } from "../typeChecking/schemas"; | ||
import type { AnyModel, ModelClass } from "./BaseModel"; | ||
import type { AnyModel } from "./BaseModel"; | ||
/** | ||
@@ -15,2 +16,6 @@ * Associated model metadata. | ||
modelIdProperty: string; | ||
/** | ||
* A value type will be cloned automatically when being attached to a new tree. | ||
*/ | ||
valueType: boolean; | ||
} | ||
@@ -17,0 +22,0 @@ /** |
@@ -5,4 +5,2 @@ export * from "./BaseModel"; | ||
export * from "./Model"; | ||
export * from "./modelDecorator"; | ||
export * from "./prop"; | ||
export * from "./utils"; |
@@ -1,9 +0,8 @@ | ||
import { AbstractModelClass, AnyModel, BaseModel } from "./BaseModel"; | ||
import { AbstractModelClass } from "../modelShared/BaseModelShared"; | ||
import { idProp, ModelProps, ModelPropsToCreationData, ModelPropsToData, ModelPropsToSetter } from "../modelShared/prop"; | ||
import type { AnyModel, BaseModel } from "./BaseModel"; | ||
import { modelTypeKey } from "./metadata"; | ||
import { idProp, ModelProps, ModelPropsToInstanceCreationData, ModelPropsToInstanceData, ModelPropsToPropsCreationData, ModelPropsToPropsData, ModelPropsToSetterActions } from "./prop"; | ||
declare const propsDataSymbol: unique symbol; | ||
declare const instanceDataSymbol: unique symbol; | ||
declare const propsCreationDataSymbol: unique symbol; | ||
declare const instanceCreationDataSymbol: unique symbol; | ||
declare const composedInstanceCreationDataSymbol: unique symbol; | ||
declare const dataSymbol: unique symbol; | ||
declare const creationDataSymbol: unique symbol; | ||
declare const composedCreationDataSymbol: unique symbol; | ||
export interface _Model<SuperModel, TProps extends ModelProps> { | ||
@@ -14,8 +13,6 @@ /** | ||
readonly [modelTypeKey]: string | undefined; | ||
[propsDataSymbol]: ModelPropsToPropsData<TProps>; | ||
[instanceDataSymbol]: ModelPropsToInstanceData<TProps>; | ||
[propsCreationDataSymbol]: ModelPropsToPropsCreationData<TProps>; | ||
[instanceCreationDataSymbol]: ModelPropsToInstanceCreationData<TProps>; | ||
[composedInstanceCreationDataSymbol]: SuperModel extends BaseModel<any, any, any, infer ICD, any> ? this[typeof instanceCreationDataSymbol] & ICD : this[typeof instanceCreationDataSymbol]; | ||
new (data: this[typeof composedInstanceCreationDataSymbol]): SuperModel & BaseModel<this[typeof propsDataSymbol], this[typeof propsCreationDataSymbol], this[typeof instanceDataSymbol], this[typeof instanceCreationDataSymbol], ExtractModelIdProp<TProps> & string> & Omit<this[typeof instanceDataSymbol], keyof AnyModel> & ModelPropsToSetterActions<TProps>; | ||
[dataSymbol]: ModelPropsToData<TProps>; | ||
[creationDataSymbol]: ModelPropsToCreationData<TProps>; | ||
[composedCreationDataSymbol]: SuperModel extends BaseModel<any, infer CD, any> ? this[typeof creationDataSymbol] & CD : this[typeof creationDataSymbol]; | ||
new (data: this[typeof composedCreationDataSymbol]): SuperModel & BaseModel<this[typeof dataSymbol], this[typeof creationDataSymbol], ExtractModelIdProp<TProps> & string> & Omit<this[typeof dataSymbol], keyof AnyModel> & ModelPropsToSetter<TProps>; | ||
} | ||
@@ -42,5 +39,6 @@ /** | ||
* @param modelProps Model properties. | ||
* @param modelOptions Model options. | ||
* @returns | ||
*/ | ||
export declare function ExtendedModel<TProps extends ModelProps, TModel extends AnyModel>(baseModel: AbstractModelClass<TModel>, modelProps: TProps): _Model<TModel, AddModelIdPropIfNeeded<TProps>>; | ||
export declare function ExtendedModel<TProps extends ModelProps, TModel extends AnyModel>(baseModel: AbstractModelClass<TModel>, modelProps: TProps, modelOptions?: ModelOptions): _Model<TModel, AddModelIdPropIfNeeded<TProps>>; | ||
/** | ||
@@ -53,4 +51,15 @@ * Base abstract class for models. | ||
* @param modelProps Model properties. | ||
* @param modelOptions Model options. | ||
*/ | ||
export declare function Model<TProps extends ModelProps>(modelProps: TProps): _Model<unknown, AddModelIdPropIfNeeded<TProps>>; | ||
export declare function Model<TProps extends ModelProps>(modelProps: TProps, modelOptions?: ModelOptions): _Model<unknown, AddModelIdPropIfNeeded<TProps>>; | ||
/** | ||
* Model options. | ||
*/ | ||
export interface ModelOptions { | ||
/** | ||
* A value type will be cloned automatically when being attached to a new tree. | ||
* The default is `false`. | ||
*/ | ||
valueType?: boolean; | ||
} | ||
export {}; |
@@ -1,27 +0,8 @@ | ||
import type { AnyModel, ModelClass } from "./BaseModel"; | ||
import { modelTypeKey } from "./metadata"; | ||
interface ModelInfo { | ||
name: string; | ||
class: ModelClass<AnyModel>; | ||
} | ||
import { modelTypeKey } from "../model/metadata"; | ||
import { ModelInfo } from "../modelShared/modelInfo"; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare const modelInfoByName: { | ||
[name: string]: ModelInfo; | ||
}; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare const modelInfoByClass: Map<ModelClass<AnyModel>, ModelInfo>; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare function getModelInfoForName(name: string): ModelInfo | undefined; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare function getModelInfoForObject(obj: { | ||
[modelTypeKey]: string; | ||
}): ModelInfo | undefined; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import type { ModelClass } from "../model/BaseModel"; | ||
import type { ModelClass } from "../modelShared/BaseModelShared"; | ||
declare const Ref_base: import("../model/Model")._Model<unknown, { | ||
@@ -6,5 +6,5 @@ /** | ||
*/ | ||
id: import("..").MaybeOptionalModelProp<string, string>; | ||
id: import("..").MaybeOptionalModelProp<string>; | ||
} & { | ||
$modelId: import("..").ModelProp<string, string, string, string, string, true, never>; | ||
$modelId: import("..").ModelProp<string, string, string, true, never>; | ||
}>; | ||
@@ -11,0 +11,0 @@ /** |
@@ -20,1 +20,4 @@ import type { SnapshotInOf, SnapshotOutOf } from "./SnapshotOf"; | ||
export declare let fromSnapshot: <T>(snapshot: SnapshotInOf<T> | SnapshotOutOf<T>, options?: Partial<FromSnapshotOptions> | undefined) => T; | ||
export declare const observableOptions: { | ||
deep: boolean; | ||
}; |
@@ -0,1 +1,5 @@ | ||
import "./fromArraySnapshot"; | ||
import "./fromFrozenSnapshot"; | ||
import "./fromModelSnapshot"; | ||
import "./fromPlainObjectSnapshot"; | ||
import "./reconcileArraySnapshot"; | ||
@@ -2,0 +6,0 @@ import "./reconcileFrozenSnapshot"; |
@@ -14,6 +14,6 @@ import type { SnapshotOutOf } from "./SnapshotOf"; | ||
* @typeparam T Object type. | ||
* @param node Object to get the snapshot from. | ||
* @param nodeOrFn Object to get the snapshot from or a function to get it. | ||
* @param listener Function that will be triggered when the snapshot changes. | ||
* @returns A disposer. | ||
*/ | ||
export declare function onSnapshot<T extends object>(node: T, listener: OnSnapshotListener<T>): OnSnapshotDisposer; | ||
export declare function onSnapshot<T extends object>(nodeOrFn: T | (() => T), listener: OnSnapshotListener<T>): OnSnapshotDisposer; |
import type { Frozen, frozenKey } from "../frozen/Frozen"; | ||
import type { AnyModel, ModelPropsCreationData, ModelPropsData } from "../model/BaseModel"; | ||
import type { AnyModel } from "../model/BaseModel"; | ||
import type { modelIdKey, modelTypeKey } from "../model/metadata"; | ||
import type { ModelCreationData, ModelData } from "../modelShared/BaseModelShared"; | ||
import type { ArraySet, ObjectMap } from "../wrappers"; | ||
@@ -8,3 +9,3 @@ export declare type SnapshotOutOfObject<T> = { | ||
}; | ||
export declare type SnapshotOutOfModel<M extends AnyModel> = SnapshotOutOfObject<ModelPropsData<M>> & { | ||
export declare type SnapshotOutOfModel<M extends AnyModel> = SnapshotOutOfObject<ModelData<M>> & { | ||
[modelTypeKey]: string; | ||
@@ -34,3 +35,3 @@ }; | ||
fromSnapshot(sn: infer S): any; | ||
} ? S : ModelPropsCreationData<M>> & { | ||
} ? S : ModelCreationData<M>> & { | ||
[modelTypeKey]: string; | ||
@@ -37,0 +38,0 @@ }; |
import { Frozen } from "../frozen/Frozen"; | ||
import type { ParentPath } from "../parent/path"; | ||
/** | ||
* @ingore | ||
* @ignore | ||
*/ | ||
export declare function tweakFrozen<T extends Frozen<any>>(frozenObj: T, parentPath: ParentPath<any> | undefined): T; |
@@ -1,2 +0,3 @@ | ||
import type { AnyModel, ModelClass } from "../model/BaseModel"; | ||
import type { AnyModel } from "../model/BaseModel"; | ||
import type { ModelClass } from "../modelShared/BaseModelShared"; | ||
import type { AnyStandardType, IdentityType } from "./schemas"; | ||
@@ -3,0 +4,0 @@ import { TypeInfo } from "./TypeChecker"; |
@@ -1,2 +0,2 @@ | ||
import { MaybeOptionalModelProp, MaybeOptionalModelPropWithSetterAction, ModelPropOptions, ModelPropOptionsWithSetterAction, OnlyPrimitives, OptionalModelProp, OptionalModelPropWithSetterAction } from "../model/prop"; | ||
import { MaybeOptionalModelProp, OnlyPrimitives, OptionalModelProp } from "../modelShared/prop"; | ||
import type { AnyType, TypeToData } from "./schemas"; | ||
@@ -13,21 +13,6 @@ /** | ||
* @param defaultValue Default value. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp(defaultValue: string, options: ModelPropOptionsWithSetterAction): OptionalModelPropWithSetterAction<string>; | ||
export declare function tProp(defaultValue: string): OptionalModelProp<string>; | ||
/** | ||
* Defines a string model property with a default value. | ||
* Equivalent to `tProp(types.string, defaultValue)`. | ||
* | ||
* Example: | ||
* ```ts | ||
* x: tProp("foo") // an optional string that will take the value `"foo"` when undefined. | ||
* ``` | ||
* | ||
* @param defaultValue Default value. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp(defaultValue: string, options?: ModelPropOptions): OptionalModelProp<string>; | ||
/** | ||
* Defines a number model property with a default value. | ||
@@ -42,21 +27,6 @@ * Equivalent to `tProp(types.number, defaultValue)`. | ||
* @param defaultValue Default value. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp(defaultValue: number, options: ModelPropOptionsWithSetterAction): OptionalModelPropWithSetterAction<number>; | ||
export declare function tProp(defaultValue: number): OptionalModelProp<number>; | ||
/** | ||
* Defines a number model property with a default value. | ||
* Equivalent to `tProp(types.number, defaultValue)`. | ||
* | ||
* Example: | ||
* ```ts | ||
* x: tProp(42) // an optional number that will take the value `42` when undefined. | ||
* ``` | ||
* | ||
* @param defaultValue Default value. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp(defaultValue: number, options?: ModelPropOptions): OptionalModelProp<number>; | ||
/** | ||
* Defines a boolean model property with a default value. | ||
@@ -74,18 +44,4 @@ * Equivalent to `tProp(types.boolean, defaultValue)`. | ||
*/ | ||
export declare function tProp(defaultValue: boolean, options: ModelPropOptionsWithSetterAction): OptionalModelPropWithSetterAction<boolean>; | ||
export declare function tProp(defaultValue: boolean): OptionalModelProp<boolean>; | ||
/** | ||
* Defines a boolean model property with a default value. | ||
* Equivalent to `tProp(types.boolean, defaultValue)`. | ||
* | ||
* Example: | ||
* ```ts | ||
* x: tProp(true) // an optional boolean that will take the value `true` when undefined. | ||
* ``` | ||
* | ||
* @param defaultValue Default value. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp(defaultValue: boolean, options?: ModelPropOptions): OptionalModelProp<boolean>; | ||
/** | ||
* Defines a model property, with an optional function to generate a default value | ||
@@ -101,26 +57,8 @@ * if the input snapshot / model creation data is `null` or `undefined` and with an associated type checker. | ||
* @typeparam TType Type checker type. | ||
* @param type Type checker. | ||
* @param defaultFn Default value generator function. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp<TType extends AnyType>(type: TType, defaultFn: () => TypeToData<TType>, options: ModelPropOptionsWithSetterAction): OptionalModelPropWithSetterAction<TypeToData<TType>>; | ||
/** | ||
* Defines a model property, with an optional function to generate a default value | ||
* if the input snapshot / model creation data is `null` or `undefined` and with an associated type checker. | ||
* | ||
* Example: | ||
* ```ts | ||
* x: tProp(types.number, () => 10) // an optional number, with a default value of 10 | ||
* x: tProp(types.array(types.number), () => []) // an optional number array, with a default empty array | ||
* ``` | ||
* | ||
* @typeparam TType Type checker type. | ||
* | ||
* @param type Type checker. | ||
* @param defaultFn Default value generator function. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp<TType extends AnyType>(type: TType, defaultFn: () => TypeToData<TType>, options?: ModelPropOptions): OptionalModelProp<TypeToData<TType>>; | ||
export declare function tProp<TType extends AnyType>(type: TType, defaultFn: () => TypeToData<TType>): OptionalModelProp<TypeToData<TType>>; | ||
/** | ||
@@ -138,27 +76,8 @@ * Defines a model property, with an optional default value | ||
* @typeparam TType Type checker type. | ||
* @param type Type checker. | ||
* @param defaultValue Default value generator function. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp<TType extends AnyType>(type: TType, defaultValue: OnlyPrimitives<TypeToData<TType>>, options: ModelPropOptionsWithSetterAction): OptionalModelPropWithSetterAction<TypeToData<TType>>; | ||
/** | ||
* Defines a model property, with an optional default value | ||
* if the input snapshot / model creation data is `null` or `undefined` and with an associated type checker. | ||
* You should only use this with primitive values and never with object values | ||
* (array, model, object, etc). | ||
* | ||
* Example: | ||
* ```ts | ||
* x: tProp(types.number, 10) // an optional number, with a default value of 10 | ||
* ``` | ||
* | ||
* @typeparam TType Type checker type. | ||
* | ||
* @param type Type checker. | ||
* @param defaultValue Default value generator function. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp<TType extends AnyType>(type: TType, defaultValue: OnlyPrimitives<TypeToData<TType>>, options?: ModelPropOptions): OptionalModelProp<TypeToData<TType>>; | ||
export declare function tProp<TType extends AnyType>(type: TType, defaultValue: OnlyPrimitives<TypeToData<TType>>): OptionalModelProp<TypeToData<TType>>; | ||
/** | ||
@@ -174,22 +93,6 @@ * Defines a model property with no default value and an associated type checker. | ||
* @typeparam TType Type checker type. | ||
* @param type Type checker. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp<TType extends AnyType>(type: TType, options: ModelPropOptionsWithSetterAction): MaybeOptionalModelPropWithSetterAction<TypeToData<TType>>; | ||
/** | ||
* Defines a model property with no default value and an associated type checker. | ||
* | ||
* Example: | ||
* ```ts | ||
* x: tProp(types.number) // a required number | ||
* x: tProp(types.maybe(types.number)) // an optional number, which defaults to undefined | ||
* ``` | ||
* | ||
* @typeparam TType Type checker type. | ||
* | ||
* @param type Type checker. | ||
* @param options Model property options. | ||
* @returns | ||
*/ | ||
export declare function tProp<TType extends AnyType>(type: TType, options?: ModelPropOptions): MaybeOptionalModelProp<TypeToData<TType>>; | ||
export declare function tProp<TType extends AnyType>(type: TType): MaybeOptionalModelProp<TypeToData<TType>>; |
import { ArrayTypeInfo, typesArray } from "./array"; | ||
import { ArraySetTypeInfo, typesArraySet } from "./arraySet"; | ||
import { typesDataModelData } from "./dataModelData"; | ||
import { typesEnum } from "./enum"; | ||
@@ -33,2 +34,3 @@ import { typesMaybe, typesMaybeNull } from "./maybe"; | ||
model: typeof typesModel; | ||
dataModelData: typeof typesDataModelData; | ||
object: typeof typesObject; | ||
@@ -35,0 +37,0 @@ ref: typeof typesRef; |
declare const ArraySet_base: import("../model/Model")._Model<unknown, { | ||
items: import("..").OptionalModelProp<any[], any[]>; | ||
items: import("..").OptionalModelProp<any[]>; | ||
} & { | ||
$modelId: import("..").ModelProp<string, string, string, string, string, true, never>; | ||
$modelId: import("..").ModelProp<string, string, string, true, never>; | ||
}>; | ||
@@ -6,0 +6,0 @@ /** |
declare const ObjectMap_base: import("../model/Model")._Model<unknown, { | ||
items: import("..").OptionalModelProp<{ | ||
[k: string]: any; | ||
}, { | ||
[k: string]: any; | ||
}>; | ||
} & { | ||
$modelId: import("..").ModelProp<string, string, string, string, string, true, never>; | ||
$modelId: import("..").ModelProp<string, string, string, true, never>; | ||
}>; | ||
@@ -10,0 +8,0 @@ /** |
{ | ||
"name": "mobx-keystone", | ||
"version": "0.54.0", | ||
"version": "0.55.0", | ||
"description": "A MobX powered state management solution based on data trees with first class support for Typescript, snapshots, patches and much more", | ||
@@ -48,27 +48,34 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/jest": "^26.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.5.0", | ||
"@typescript-eslint/parser": "^4.5.0", | ||
"eslint": "^7.12.1", | ||
"eslint-plugin-flowtype": "^5.2.0", | ||
"eslint-plugin-jest": "^24.1.0", | ||
"eslint-webpack-plugin": "^2.1.0", | ||
"mobx": "^6.0.1", | ||
"netlify-cli": "^3.4.3", | ||
"shx": "^0.3.2", | ||
"@types/jest": "^26.0.22", | ||
"@typescript-eslint/eslint-plugin": "^4.20.0", | ||
"@typescript-eslint/parser": "^4.20.0", | ||
"eslint": "^7.23.0", | ||
"eslint-plugin-flowtype": "^5.4.0", | ||
"eslint-plugin-jest": "^24.3.2", | ||
"eslint-webpack-plugin": "^2.5.3", | ||
"mobx": "^6.1.8", | ||
"netlify-cli": "^3.13.10", | ||
"shx": "^0.3.3", | ||
"spec.ts": "^1.1.3", | ||
"ts-node": "^9.0.0", | ||
"ts-node": "^9.1.1", | ||
"tsdx": "^0.14.1", | ||
"typedoc": "^0.20.5", | ||
"typescript": "^4.2.2" | ||
"typedoc": "^0.20.34", | ||
"typescript": "^4.2.3" | ||
}, | ||
"dependencies": { | ||
"fast-deep-equal": "^3.1.1", | ||
"ts-toolbelt": "^9.3.12", | ||
"tslib": "^2.0.0", | ||
"uuid": "^8.1.0" | ||
"fast-deep-equal": "^3.1.3", | ||
"ts-toolbelt": "^9.6.0", | ||
"tslib": "^2.1.0", | ||
"uuid": "^8.3.2" | ||
}, | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"jest": { | ||
"globals": { | ||
"ts-jest": { | ||
"tsconfig": "./tsconfig.test.json" | ||
} | ||
} | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
4456220
188
35062
Updatedfast-deep-equal@^3.1.3
Updatedts-toolbelt@^9.6.0
Updatedtslib@^2.1.0
Updateduuid@^8.3.2