New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mobx-state-tree

Package Overview
Dependencies
Maintainers
3
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-state-tree - npm Package Compare versions

Comparing version 3.9.0 to 3.10.0

dist/core/node/livelynessChecking.d.ts

21

dist/core/action.d.ts

@@ -21,12 +21,12 @@ import { IDisposer, IAnyStateTreeNode } from "../internal";

*
* @export
* @param {IStateTreeNode} target
* @param {(action: IRawActionCall, next: (call: IRawActionCall) => any) => any} middleware
* @returns {IDisposer}
* @param target Node to apply the middleware to.
* @param middleware Middleware to apply.
* @returns A callable function to dispose the middleware.
*/
export declare function addMiddleware(target: IAnyStateTreeNode, handler: IMiddlewareHandler, includeHooks?: boolean): IDisposer;
/**
* Binds middleware to a specific action
* Binds middleware to a specific action.
*
* @example
* Example:
* ```ts
* type.actions(self => {

@@ -43,9 +43,8 @@ * function takeA____() {

* })
* ```
*
* @export
* @template T
* @param {IMiddlewareHandler} handler
* @param Function} fn
* @returns the original function
* @param handler
* @param fn
* @returns The original function
*/
export declare function decorate<T extends Function>(handler: IMiddlewareHandler, fn: T): T;

@@ -0,8 +1,12 @@

/** @hidden */
export interface FlowYield {
"!!flowYield": undefined;
}
/** @hidden */
export interface FlowReturn<T> {
"!!flowReturn": T;
}
export declare type FlowReturnType<R> = IfAllAreFlowYieldThenVoid<R extends FlowReturn<infer FR> ? FR : R extends Promise<any> ? FlowYield : R>;
/** @hidden */
export declare type FlowReturnType<R> = IfAllAreFlowYieldThenVoid<R extends FlowReturn<infer FR> ? FR extends Promise<infer FRP> ? FRP : FR : R extends Promise<any> ? FlowYield : R>;
/** @hidden */
export declare type IfAllAreFlowYieldThenVoid<R> = Exclude<R, FlowYield> extends never ? void : Exclude<R, FlowYield>;

@@ -12,15 +16,11 @@ /**

*
* @export
* @alias flow
* @returns {Promise}
* @returns The flow as a promise.
*/
export declare function flow<R, Args extends any[]>(generator: (...args: Args) => IterableIterator<R>): (...args: Args) => Promise<FlowReturnType<R>>;
/**
* Used for TypeScript to force a flow to return a promise.
* Used for TypeScript to make flows that return a promise return the actual promise result.
*
* @export
* @template T
* @param {T} val
* @returns {FlowReturn<T>}
* @param val
* @returns
*/
export declare function castFlowReturn<T>(val: T): FlowReturn<T>;

@@ -0,1 +1,5 @@

/**
* https://tools.ietf.org/html/rfc6902
* http://jsonpatch.com/
*/
export interface IJsonPatch {

@@ -10,3 +14,4 @@ op: "replace" | "add" | "remove";

/**
* escape slashes and backslashes
* Escape slashes and backslashes.
*
* http://tools.ietf.org/html/rfc6901

@@ -16,20 +21,18 @@ */

/**
* unescape slashes and backslashes
* Unescape slashes and backslashes.
*/
export declare function unescapeJsonPath(str: string): string;
/**
* Generates a json-path compliant json path from path parts
* Generates a json-path compliant json path from path parts.
*
* @export
* @param {string[]} path
* @returns {string}
* @param path
* @returns
*/
export declare function joinJsonPath(path: string[]): string;
/**
* Splits and decodes a json path into several parts
* Splits and decodes a json path into several parts.
*
* @export
* @param {string} path
* @returns {string[]}
* @param path
* @returns
*/
export declare function splitJsonPath(path: string): string[];
import { ExtractT, IAnyStateTreeNode, IType, IAnyModelType, IStateTreeNode, IJsonPatch, IDisposer, IAnyType, ModelPrimitive, ExtractNodeC, ReferenceIdentifier } from "../internal";
/** @hidden */
export declare type TypeOrStateTreeNodeToStateTreeNode<T extends IAnyType | IAnyStateTreeNode> = T extends IType<any, any, infer TT> ? TT : T;

@@ -6,11 +7,11 @@ /**

*
* @export
* @param {IStateTreeNode} object
* @returns {IAnyType}
* @param object
* @returns
*/
export declare function getType(object: IAnyStateTreeNode): IType<any, any, any>;
export declare function getType(object: IAnyStateTreeNode): IAnyType;
/**
* Returns the _declared_ type of the given sub property of an object, array or map.
*
* @example
* Example:
* ```ts
* const Box = types.model({ x: 0, y: 0 })

@@ -20,9 +21,9 @@ * const box = Box.create()

* console.log(getChildType(box, "x").name) // 'number'
* ```
*
* @export
* @param {IStateTreeNode} object
* @param {string} child
* @returns {IAnyType}
* @param object
* @param child
* @returns
*/
export declare function getChildType(object: IAnyStateTreeNode, child: string): IType<any, any, any>;
export declare function getChildType(object: IAnyStateTreeNode, child: string): IAnyType;
/**

@@ -33,6 +34,5 @@ * Registers a function that will be invoked for each mutation that is applied to the provided model instance, or to any of its children.

*
* @export
* @param {Object} target the model instance from which to receive patches
* @param {(patch: IJsonPatch, reversePatch) => void} callback the callback that is invoked for each patch. The reversePatch is a patch that would actually undo the emitted patch
* @returns {IDisposer} function to remove the listener
* @param target the model instance from which to receive patches
* @param callback the callback that is invoked for each patch. The reversePatch is a patch that would actually undo the emitted patch
* @returns function to remove the listener
*/

@@ -45,6 +45,5 @@ export declare function onPatch(target: IAnyStateTreeNode, callback: (patch: IJsonPatch, reversePatch: IJsonPatch) => void): IDisposer;

*
* @export
* @param {Object} target
* @param {(snapshot: any) => void} callback
* @returns {IDisposer}
* @param target
* @param callback
* @returns
*/

@@ -58,5 +57,4 @@ export declare function onSnapshot<S>(target: IStateTreeNode<any, S>, callback: (snapshot: S) => void): IDisposer;

*
* @export
* @param {Object} target
* @param {IJsonPatch} patch
* @param target
* @param patch
* @returns

@@ -76,3 +74,4 @@ */

*
* @example
* Example:
* ```ts
* export interface IPatchRecorder {

@@ -93,14 +92,12 @@ * // the recorded patches

* }
* ```
*
* @export
* @param {IStateTreeNode} subject
* @returns {IPatchRecorder}
* @param subject
* @returns
*/
export declare function recordPatches(subject: IAnyStateTreeNode): IPatchRecorder;
/**
* The inverse of `unprotect`
* The inverse of `unprotect`.
*
* @export
* @param {IStateTreeNode} target
*
*/

@@ -115,3 +112,4 @@ export declare function protect(target: IAnyStateTreeNode): void;

*
* @example
* Example:
* ```ts
* const Todo = types.model({

@@ -130,2 +128,3 @@ * done: false

* todo.done = false // OK
* ```
*/

@@ -140,5 +139,4 @@ export declare function unprotect(target: IAnyStateTreeNode): void;

*
* @export
* @param {Object} target
* @param {Object} snapshot
* @param target
* @param snapshot
* @returns

@@ -151,15 +149,13 @@ */

*
* @export
* @param {Object} target
* @param {boolean} applyPostProcess = true, by default the postProcessSnapshot gets applied
* @returns {*}
* @param target
* @param applyPostProcess If true (the default) then postProcessSnapshot gets applied.
* @returns
*/
export declare function getSnapshot<S>(target: IStateTreeNode<any, S>, applyPostProcess?: boolean): S;
/**
* Given a model instance, returns `true` if the object has a parent, that is, is part of another object, map or array
* Given a model instance, returns `true` if the object has a parent, that is, is part of another object, map or array.
*
* @export
* @param {Object} target
* @param {number} depth = 1, how far should we look upward?
* @returns {boolean}
* @param target
* @param depth How far should we look upward? 1 by default.
* @returns
*/

@@ -171,12 +167,10 @@ export declare function hasParent(target: IAnyStateTreeNode, depth?: number): boolean;

* Note that the immediate parent can be either an object, map or array, and
* doesn't necessarily refer to the parent model
* doesn't necessarily refer to the parent model.
*
* Please note that in child nodes access to the root is only possible
* once the `afterAttach` hook has fired
* once the `afterAttach` hook has fired.
*
*
* @export
* @param {Object} target
* @param {number} depth = 1, how far should we look upward?
* @returns {*}
* @param target
* @param depth How far should we look upward? 1 by default.
* @returns
*/

@@ -187,6 +181,5 @@ export declare function getParent<IT extends IAnyStateTreeNode | IAnyType>(target: IAnyStateTreeNode, depth?: number): TypeOrStateTreeNodeToStateTreeNode<IT>;

*
* @export
* @param {Object} target
* @param {IAnyType} type
* @returns {boolean}
* @param target
* @param type
* @returns
*/

@@ -197,18 +190,15 @@ export declare function hasParentOfType(target: IAnyStateTreeNode, type: IAnyType): boolean;

*
*
* @export
* @param {IStateTreeNode} target
* @param {IType<any, any, T>} type
* @returns {T}
* @param target
* @param type
* @returns
*/
export declare function getParentOfType<IT extends IAnyType>(target: IAnyStateTreeNode, type: IT): ExtractT<IT>;
/**
* Given an object in a model tree, returns the root object of that tree
* Given an object in a model tree, returns the root object of that tree.
*
* Please note that in child nodes access to the root is only possible
* once the `afterAttach` hook has fired
* once the `afterAttach` hook has fired.
*
* @export
* @param {Object} target
* @returns {*}
* @param target
* @returns
*/

@@ -219,21 +209,18 @@ export declare function getRoot<IT extends IAnyType | IAnyStateTreeNode>(target: IAnyStateTreeNode): TypeOrStateTreeNodeToStateTreeNode<IT>;

*
* @export
* @param {Object} target
* @returns {string}
* @param target
* @returns
*/
export declare function getPath(target: IAnyStateTreeNode): string;
/**
* Returns the path of the given object as unescaped string array
* Returns the path of the given object as unescaped string array.
*
* @export
* @param {Object} target
* @returns {string[]}
* @param target
* @returns
*/
export declare function getPathParts(target: IAnyStateTreeNode): string[];
/**
* Returns true if the given object is the root of a model tree
* Returns true if the given object is the root of a model tree.
*
* @export
* @param {Object} target
* @returns {boolean}
* @param target
* @returns
*/

@@ -245,6 +232,5 @@ export declare function isRoot(target: IAnyStateTreeNode): boolean;

*
* @export
* @param {Object} target
* @param {string} path - escaped json path
* @returns {*}
* @param target
* @param path escaped json path
* @returns
*/

@@ -256,7 +242,6 @@ export declare function resolvePath(target: IAnyStateTreeNode, path: string): any;

*
* @export
* @param {IAnyType} type
* @param {IStateTreeNode} target
* @param {(string | number)} identifier
* @returns {*}
* @param type
* @param target
* @param identifier
* @returns
*/

@@ -268,5 +253,4 @@ export declare function resolveIdentifier<IT extends IAnyType>(type: IT, target: IAnyStateTreeNode, identifier: ReferenceIdentifier): ExtractT<IT> | undefined;

*
* @export
* @param {IStateTreeNode} target
* @returns {(string | null)}
* @param target
* @returns
*/

@@ -278,7 +262,5 @@ export declare function getIdentifier(target: IAnyStateTreeNode): string | null;

*
* @export
* @template N
* @param {(() => N | null | undefined)} getter Function to access the reference.
* @param {boolean} [checkIfAlive=true] true to also make sure the referenced node is alive (default), false to skip this check.
* @returns {(N | undefined)}
* @param getter Function to access the reference.
* @param checkIfAlive true to also make sure the referenced node is alive (default), false to skip this check.
* @returns
*/

@@ -289,16 +271,13 @@ export declare function tryReference<N extends IAnyStateTreeNode>(getter: () => N | null | undefined, checkIfAlive?: boolean): N | undefined;

*
* @export
* @template N
* @param {(() => N | null | undefined)} getter Function to access the reference.
* @param {boolean} [checkIfAlive=true] true to also make sure the referenced node is alive (default), false to skip this check.
* @returns {boolean}
* @param getter Function to access the reference.
* @param checkIfAlive true to also make sure the referenced node is alive (default), false to skip this check.
* @returns
*/
export declare function isValidReference<N extends IAnyStateTreeNode>(getter: () => N | null | undefined, checkIfAlive?: boolean): boolean;
/**
* Try to resolve a given path relative to a given node.
*
*
* @export
* @param {Object} target
* @param {string} path
* @returns {*}
* @param target
* @param path
* @returns
*/

@@ -310,6 +289,5 @@ export declare function tryResolve(target: IAnyStateTreeNode, path: string): any;

*
* @export
* @param {IStateTreeNode} base
* @param {IStateTreeNode} target
* @returns {string}
* @param base
* @param target
* @returns
*/

@@ -323,7 +301,5 @@ export declare function getRelativePath(base: IAnyStateTreeNode, target: IAnyStateTreeNode): string;

*
* @export
* @template T
* @param {T} source
* @param {boolean | any} keepEnvironment indicates whether the clone should inherit the same environment (`true`, the default), or not have an environment (`false`). If an object is passed in as second argument, that will act as the environment for the cloned tree.
* @returns {T}
* @param source
* @param keepEnvironment indicates whether the clone should inherit the same environment (`true`, the default), or not have an environment (`false`). If an object is passed in as second argument, that will act as the environment for the cloned tree.
* @returns
*/

@@ -345,5 +321,4 @@ export declare function clone<T extends IAnyStateTreeNode>(source: T, keepEnvironment?: boolean | any): T;

*
* @export
* @param {IStateTreeNode} target
* @returns {boolean}
* @param target
* @returns
*/

@@ -358,3 +333,4 @@ export declare function isAlive(target: IAnyStateTreeNode): boolean;

*
* @example
* Example:
* ```ts
* const Todo = types.model({

@@ -373,7 +349,7 @@ * title: types.string

* }))
* ```
*
* @export
* @param {IStateTreeNode} target
* @param {() => void} disposer
* @returns {() => void} the same disposer that was passed as argument
* @param target
* @param disposer
* @returns The same disposer that was passed as argument
*/

@@ -390,9 +366,8 @@ export declare function addDisposer(target: IAnyStateTreeNode, disposer: () => void): (() => void);

*
* @export
* @param {IStateTreeNode} target
* @returns {*}
* @param target
* @returns
*/
export declare function getEnv<T = any>(target: IAnyStateTreeNode): T;
/**
* Performs a depth first walk through a tree
* Performs a depth first walk through a tree.
*/

@@ -409,5 +384,4 @@ export declare function walk(target: IAnyStateTreeNode, processor: (item: IAnyStateTreeNode) => void): void;

*
* @export
* @param {IAnyModelType | IStateTreeNode} typeOrNode
* @returns {IModelReflectionPropertiesData}
* @param typeOrNode
* @returns
*/

@@ -423,5 +397,4 @@ export declare function getPropertyMembers(typeOrNode: IAnyModelType | IStateTreeNode): IModelReflectionPropertiesData;

*
* @export
* @param {IAnyStateTreeNode} target
* @returns {IModelReflectionData}
* @param target
* @returns
*/

@@ -437,3 +410,4 @@ export declare function getMembers(target: IAnyStateTreeNode): IModelReflectionData;

*
* @example
* Example:
* ```ts
* const ModelA = types.model({

@@ -454,4 +428,4 @@ * n: types.number

* const b = ModelB.create({ innerModel: castToSnapshot(a)})
* ```
*
* @export
* @param snapshotOrInstance Snapshot or instance

@@ -466,3 +440,4 @@ * @returns The same object casted as an input (creation) snapshot

*
* @example
* Example:
* ```ts
* const ModelA = types.model({

@@ -484,7 +459,7 @@ * id: types.identifier,

* const b = ModelB.create({ refA: castToReference(a)})
* ```
*
* @export
* @param snapshotOrInstance Instance
* @param instance Instance
* @returns The same object casted as an reference snapshot (string or number)
*/
export declare function castToReferenceSnapshot<I>(instance: I): Extract<I, IAnyStateTreeNode> extends never ? I : ReferenceIdentifier;

@@ -0,1 +1,7 @@

/**
* Defines what MST should do when running into reads / writes to objects that have died.
* - `"warn"`: Print a warning (default).
* - `"error"`: Throw an exception.
* - "`ignore`": Do nothing.
*/
export declare type LivelinessMode = "warn" | "error" | "ignore";

@@ -5,8 +11,5 @@ /**

* By default it will print a warning.
* Use te `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
* Use the `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
*
* Possible values: `"warn"`, `"error"` and `"ignore"`
*
* @export
* @param {LivelinessMode} mode
* @param mode `"warn"`, `"error"` or `"ignore"`
*/

@@ -17,21 +20,20 @@ export declare function setLivelinessChecking(mode: LivelinessMode): void;

*
* Possible values: `"warn"`, `"error"` and `"ignore"`
*
* @export
* @returns {LivelinessMode}
* @returns `"warn"`, `"error"` or `"ignore"`
*/
export declare function getLivelinessChecking(): LivelinessMode;
/**
* @deprecated use LivelinessMode instead
* @hidden
*/
export declare type LivelynessMode = LivelinessMode;
/**
* @deprecated use setLivelinessChecking instead
* @hidden
*
* Defines what MST should do when running into reads / writes to objects that have died.
* By default it will print a warning.
* Use te `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
* Use the `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
*
* Possible values: `"warn"`, `"error"` and `"ignore"`
*
* @export
* @param {LivelinessMode} mode
* @param mode `"warn"`, `"error"` or `"ignore"`
*/
export declare function setLivelynessChecking(mode: LivelinessMode): void;

@@ -0,1 +1,5 @@

/**
* Common interface that represents a node instance.
* @hidden
*/
export interface IStateTreeNode<C = any, S = any> {

@@ -6,5 +10,12 @@ readonly $treenode?: any;

declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
/** @hidden */
export declare type RedefineIStateTreeNode<T, STN extends IAnyStateTreeNode> = T extends IAnyStateTreeNode ? Omit<T, "!!types"> & STN : T;
/** @hidden */
export declare type ExtractNodeC<T> = T extends IStateTreeNode<infer C, any> ? C : never;
/** @hidden */
export declare type ExtractNodeS<T> = T extends IStateTreeNode<any, infer S> ? S : never;
/**
* Represents any state tree node instance.
* @hidden
*/
export interface IAnyStateTreeNode extends IStateTreeNode<any, any> {

@@ -17,7 +28,6 @@ }

*
* @export
* @param {*} value
* @returns {value is IStateTreeNode}
* @param value
* @returns true if the value is a state tree node.
*/
export declare function isStateTreeNode<C = any, S = any>(value: any): value is IStateTreeNode<C, S>;
export {};

@@ -1,18 +0,45 @@

/** @deprecated has been renamed to `flow()`. */
/**
* @deprecated has been renamed to `flow()`.
* @hidden
*/
export declare function process<R>(generator: () => IterableIterator<any>): () => Promise<R>;
/** @deprecated has been renamed to `flow()`. */
/**
* @deprecated has been renamed to `flow()`.
* @hidden
*/
export declare function process<A1>(generator: (a1: A1) => IterableIterator<any>): (a1: A1) => Promise<any>;
/** @deprecated has been renamed to `flow()`. */
/**
* @deprecated has been renamed to `flow()`.
* @hidden
*/
export declare function process<A1, A2>(generator: (a1: A1, a2: A2) => IterableIterator<any>): (a1: A1, a2: A2) => Promise<any>;
/** @deprecated has been renamed to `flow()`. */
/**
* @deprecated has been renamed to `flow()`.
* @hidden
*/
export declare function process<A1, A2, A3>(generator: (a1: A1, a2: A2, a3: A3) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3) => Promise<any>;
/** @deprecated has been renamed to `flow()`. */
/**
* @deprecated has been renamed to `flow()`.
* @hidden
*/
export declare function process<A1, A2, A3, A4>(generator: (a1: A1, a2: A2, a3: A3, a4: A4) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4) => Promise<any>;
/** @deprecated has been renamed to `flow()`. */
/**
* @deprecated has been renamed to `flow()`.
* @hidden
*/
export declare function process<A1, A2, A3, A4, A5>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Promise<any>;
/** @deprecated has been renamed to `flow()`. */
/**
* @deprecated has been renamed to `flow()`.
* @hidden
*/
export declare function process<A1, A2, A3, A4, A5, A6>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Promise<any>;
/** @deprecated has been renamed to `flow()`. */
/**
* @deprecated has been renamed to `flow()`.
* @hidden
*/
export declare function process<A1, A2, A3, A4, A5, A6, A7>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Promise<any>;
/** @deprecated has been renamed to `flow()`. */
/**
* @deprecated has been renamed to `flow()`.
* @hidden
*/
export declare function process<A1, A2, A3, A4, A5, A6, A7, A8>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Promise<any>;

@@ -18,6 +18,5 @@ import { IAnyType, IType } from "../../internal";

*
* @export
* @param {IAnyType} type
* @param {*} value
* @param type Type to check against.
* @param value Value to be checked.
*/
export declare function typecheck<C, S, T>(type: IType<C, S, T>, value: C | S | T): void;
import { IContext, IValidationResult, IStateTreeNode, ModelPrimitive, IAnyStateTreeNode } from "../../internal";
/**
* Name of the properties of an object that can't be set to undefined
* @hidden
*/
export declare type DefinablePropsNames<T> = {
[K in keyof T]: Extract<T[K], undefined> extends never ? K : never;
}[keyof T];
/**
* Checks if a type is any or unknown
* @hidden
*/
export declare type IsTypeAnyOrUnknown<T> = unknown extends T ? true : false;
/**
* Checks if a type supports an empty create() function
* Basically !any, !unknown, X | undefined, objects with all properties being optional
* @hidden
*/
export declare type IsEmptyCreationType<O> = IsTypeAnyOrUnknown<O> extends true ? true : Extract<O, undefined> extends never ? (DefinablePropsNames<O> extends never | undefined ? true : false) : true;
/**
* Chooses a create function based on the creation type.
* @hidden
*/
export declare type CreateParams<C> = IsEmptyCreationType<C> extends false ? [C, any?] : [C?, any?];
/**
* A type, either complex or simple.
*/
export interface IType<C, S, T> {
name: string;
create(...args: CreateParams<C>): T;
create(snapshot: C, env?: any): T;
is(thing: any): thing is C | S | T;
validate(thing: any, context: IContext): IValidationResult;
describe(): string;
/**
* @deprecated use `InstanceOf` instead.
* @hidden
*/
Type: T;
/**
* @deprecated use `SnapshotOut` instead.
* @hidden
*/
SnapshotType: S;
/**
* @deprecated use `SnapshotIn` instead.
* @hidden
*/
CreationType: C;
}
/**
* Any kind of type.
*/
export declare type IAnyType = IType<any, any, any>;
/**
* A simple type, this is, a type where the instance and the snapshot representation are the same.
*/
export interface ISimpleType<T> extends IType<T, T, T> {
}
/** @hidden */
export declare type Primitives = ModelPrimitive | null | undefined;
/**
* A complex type.
* @deprecated just for compatibility with old versions, could be deprecated on the next major version
* @hidden
*/
export interface IComplexType<C, S, T> extends IType<C, S, T & IStateTreeNode<C, S>> {
}
/**
* Any kind of complex type.
*/
export declare type IAnyComplexType = IType<any, any, IAnyStateTreeNode>;
/** @hidden */
export declare type ExtractC<T extends IAnyType> = T extends IType<infer C, any, any> ? C : never;
/** @hidden */
export declare type ExtractS<T extends IAnyType> = T extends IType<any, infer S, any> ? S : never;
/** @hidden */
export declare type ExtractT<T extends IAnyType> = T extends IType<any, any, infer X> ? X : never;
/** @hidden */
export declare type ExtractCST<IT extends IAnyType> = IT extends IType<infer C, infer S, infer T> ? C | S | T : never;
/**
* The instance representation of a given type.
*/
export declare type Instance<T> = T extends IStateTreeNode ? T : T extends IType<any, any, infer TT> ? TT : T;
/**
* The input (creation) snapshot representation of a given type.
*/
export declare type SnapshotIn<T> = T extends IStateTreeNode<infer STNC, any> ? STNC : T extends IType<infer TC, any, any> ? TC : T;
/**
* The output snapshot representation of a given type.
*/
export declare type SnapshotOut<T> = T extends IStateTreeNode<any, infer STNS> ? STNS : T extends IType<any, infer TS, any> ? TS : T;

@@ -37,8 +98,9 @@ /**

* For example:
* - SnapshotOrInstance<typeof ModelA> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>
* - SnapshotOrInstance<typeof self.a (where self.a is a ModelA)> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>
* - `SnapshotOrInstance<typeof ModelA> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`
* - `SnapshotOrInstance<typeof self.a (where self.a is a ModelA)> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`
*
* Usually you might want to use this when your model has a setter action that sets a property.
*
* @example
* Example:
* ```ts
* const ModelA = types.model({

@@ -56,2 +118,3 @@ * n: types.number

* }))
* ```
*/

@@ -62,6 +125,5 @@ export declare type SnapshotOrInstance<T> = SnapshotIn<T> | Instance<T>;

*
* @export
* @param {*} value
* @returns {value is IAnyType}
* @param value Value to check.
* @returns `true` if the value is a type.
*/
export declare function isType(value: any): value is IAnyType;

@@ -1,35 +0,3 @@

import "./internal";
import { enumeration, model, compose, custom, reference, safeReference, union, optional, literal, maybe, maybeNull, refinement, map, array, frozen, late } from "./internal";
export declare const types: {
enumeration: typeof enumeration;
model: typeof model;
compose: typeof compose;
custom: typeof custom;
reference: typeof reference;
safeReference: typeof safeReference;
union: typeof union;
optional: typeof optional;
literal: typeof literal;
maybe: typeof maybe;
maybeNull: typeof maybeNull;
refinement: typeof refinement;
string: ISimpleType<string>;
boolean: ISimpleType<boolean>;
number: ISimpleType<number>;
integer: ISimpleType<number>;
Date: IType<number | Date, number, Date>;
map: typeof map;
array: typeof array;
frozen: typeof frozen;
identifier: ISimpleType<string>;
identifierNumber: ISimpleType<number>;
late: typeof late;
undefined: ISimpleType<undefined>;
null: ISimpleType<null>;
};
import { IModelType, IAnyModelType, IMSTMap, IMapType, IMSTArray, IArrayType, IType, IAnyType, ISimpleType, IComplexType, IAnyComplexType, IReferenceType, typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, IReversibleJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, IAnyStateTreeNode, _CustomCSProcessor, _CustomOrOther, _CustomJoin, _NotCustomized, flow, castFlowReturn, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware, setLivelinessChecking, getLivelinessChecking, LivelinessMode, setLivelynessChecking, // to be deprecated
LivelynessMode, // to be deprecated
ModelSnapshotType, ModelCreationType, ModelSnapshotType2, ModelCreationType2, ModelInstanceType, ModelInstanceTypeProps, ModelPropertiesDeclarationToProperties, ModelProperties, ModelPropertiesDeclaration, OptionalProperty, ModelActions, ITypeUnion, CustomTypeOptions, UnionOptions, Instance, SnapshotIn, SnapshotOut, SnapshotOrInstance, TypeOrStateTreeNodeToStateTreeNode, UnionStringArray, getType, getChildType, onPatch, onSnapshot, applyPatch, IPatchRecorder, recordPatches, protect, unprotect, isProtected, applySnapshot, getSnapshot, hasParent, getParent, hasParentOfType, getParentOfType, getRoot, getPath, getPathParts, isRoot, resolvePath, resolveIdentifier, getIdentifier, tryResolve, getRelativePath, clone, detach, destroy, isAlive, addDisposer, getEnv, walk, IModelReflectionData, IModelReflectionPropertiesData, IMaybeIType, IMaybe, IMaybeNull, IOptionalIType, OptionalDefaultValueOrFunction, getMembers, getPropertyMembers, ExtractNodeC, ExtractNodeS, cast, castToSnapshot, castToReferenceSnapshot, isType, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isReferenceType, isRefinementType, isUnionType, tryReference, isValidReference, OnReferenceInvalidated, OnReferenceInvalidatedEvent, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, ReferenceIdentifier } from "./internal";
export { IModelType, IAnyModelType, IMSTMap, IMapType, IMSTArray, IArrayType, IType, IAnyType, ISimpleType, IComplexType, IAnyComplexType, IReferenceType, _CustomCSProcessor, _CustomOrOther, _CustomJoin, _NotCustomized, typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, IReversibleJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, IAnyStateTreeNode, flow, castFlowReturn, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware, setLivelinessChecking, getLivelinessChecking, LivelinessMode, setLivelynessChecking, // to be deprecated
LivelynessMode, // to be deprecated
ModelSnapshotType, ModelCreationType, ModelSnapshotType2, ModelCreationType2, ModelInstanceType, ModelInstanceTypeProps, ModelPropertiesDeclarationToProperties, ModelProperties, ModelPropertiesDeclaration, OptionalProperty, ModelActions, ITypeUnion, CustomTypeOptions, UnionOptions, Instance, SnapshotIn, SnapshotOut, SnapshotOrInstance, TypeOrStateTreeNodeToStateTreeNode, UnionStringArray, getType, getChildType, onPatch, onSnapshot, applyPatch, IPatchRecorder, recordPatches, protect, unprotect, isProtected, applySnapshot, getSnapshot, hasParent, getParent, hasParentOfType, getParentOfType, getRoot, getPath, getPathParts, isRoot, resolvePath, resolveIdentifier, getIdentifier, tryResolve, getRelativePath, clone, detach, destroy, isAlive, addDisposer, getEnv, walk, IModelReflectionData, IModelReflectionPropertiesData, IMaybeIType, IMaybe, IMaybeNull, IOptionalIType, OptionalDefaultValueOrFunction, getMembers, getPropertyMembers, ExtractNodeC, ExtractNodeS, cast, castToSnapshot, castToReferenceSnapshot, isType, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isReferenceType, isRefinementType, isUnionType, tryReference, isValidReference, OnReferenceInvalidated, OnReferenceInvalidatedEvent, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, ReferenceIdentifier };
ModelSnapshotType, ModelCreationType, ModelSnapshotType2, ModelCreationType2, ModelInstanceType, ModelInstanceTypeProps, ModelPropertiesDeclarationToProperties, ModelProperties, ModelPropertiesDeclaration, OptionalProperty, ModelActions, ITypeUnion, CustomTypeOptions, UnionOptions, Instance, SnapshotIn, SnapshotOut, SnapshotOrInstance, TypeOrStateTreeNodeToStateTreeNode, UnionStringArray, getType, getChildType, onPatch, onSnapshot, applyPatch, IPatchRecorder, recordPatches, protect, unprotect, isProtected, applySnapshot, getSnapshot, hasParent, getParent, hasParentOfType, getParentOfType, getRoot, getPath, getPathParts, isRoot, resolvePath, resolveIdentifier, getIdentifier, tryResolve, getRelativePath, clone, detach, destroy, isAlive, addDisposer, getEnv, walk, IModelReflectionData, IModelReflectionPropertiesData, IMaybeIType, IMaybe, IMaybeNull, IOptionalIType, OptionalDefaultValueOrFunction, getMembers, getPropertyMembers, ExtractNodeC, ExtractNodeS, cast, castToSnapshot, castToReferenceSnapshot, isType, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isReferenceType, isRefinementType, isUnionType, tryReference, isValidReference, OnReferenceInvalidated, OnReferenceInvalidatedEvent, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, ReferenceIdentifier, types } from "./internal";

@@ -34,1 +34,2 @@ export * from "./core/node/livelinessChecking";

export * from "./types/utility-types/custom";
export * from "./types";
import { IMiddlewareEvent, IMiddlewareHandler } from "../internal";
export interface IActionTrackingMiddlewareHooks<T> {
filter?: (call: IMiddlewareEvent) => boolean;
onStart: (call: IMiddlewareEvent) => T;
onResume: (call: IMiddlewareEvent, context: T) => void;
onSuspend: (call: IMiddlewareEvent, context: T) => void;
onSuccess: (call: IMiddlewareEvent, context: T, result: any) => void;
onFail: (call: IMiddlewareEvent, context: T, error: any) => void;
}
/**

@@ -11,22 +19,5 @@ * Convenience utility to create action based middleware that supports async processes more easily.

*
* @export
* @template T
* @template any
* @param {{
* filter?: (call: IMiddlewareEvent) => boolean
* onStart: (call: IMiddlewareEvent) => T
* onResume: (call: IMiddlewareEvent, context: T) => void
* onSuspend: (call: IMiddlewareEvent, context: T) => void
* onSuccess: (call: IMiddlewareEvent, context: T, result: any) => void
* onFail: (call: IMiddlewareEvent, context: T, error: any) => void
* }} hooks
* @returns {IMiddlewareHandler}
* @param hooks
* @returns
*/
export declare function createActionTrackingMiddleware<T = any>(hooks: {
filter?: (call: IMiddlewareEvent) => boolean;
onStart: (call: IMiddlewareEvent) => T;
onResume: (call: IMiddlewareEvent, context: T) => void;
onSuspend: (call: IMiddlewareEvent, context: T) => void;
onSuccess: (call: IMiddlewareEvent, context: T, result: any) => void;
onFail: (call: IMiddlewareEvent, context: T, error: any) => void;
}): IMiddlewareHandler;
export declare function createActionTrackingMiddleware<T = any>(hooks: IActionTrackingMiddlewareHooks<T>): IMiddlewareHandler;

@@ -17,5 +17,4 @@ import { IDisposer, IAnyStateTreeNode } from "../internal";

*
* @export
* @param {Object} target
* @param {IActionCall[]} actions
* @param target
* @param actions
*/

@@ -27,3 +26,4 @@ export declare function applyAction(target: IAnyStateTreeNode, actions: ISerializedActionCall | ISerializedActionCall[]): void;

*
* @example
* Example:
* ```ts
* export interface IActionRecorder {

@@ -37,6 +37,6 @@ * // the recorded actions

* }
* ```
*
* @export
* @param {IStateTreeNode} subject
* @returns {IPatchRecorder}
* @param subject
* @returns
*/

@@ -53,3 +53,4 @@ export declare function recordActions(subject: IAnyStateTreeNode): IActionRecorder;

*
* @example
* Example:
* ```ts
* const Todo = types.model({

@@ -75,9 +76,9 @@ * task: types.string

* // Logs: { name: "add", path: "", args: [{ task: "Grab a coffee" }] }
* ```
*
* @export
* @param {IStateTreeNode} target
* @param {(call: ISerializedActionCall) => void} listener
* @param attachAfter {boolean} (default false) fires the listener *after* the action has executed instead of before.
* @returns {IDisposer}
* @param target
* @param listener
* @param attachAfter (default false) fires the listener *after* the action has executed instead of before.
* @returns
*/
export declare function onAction(target: IAnyStateTreeNode, listener: (call: ISerializedActionCall) => void, attachAfter?: boolean): IDisposer;
import { IObservableArray } from "mobx";
import { IAnyType, IStateTreeNode, IType, OptionalProperty, ExtractS, ExtractC, ExtractT, ExtractCST } from "../../internal";
/** @hidden */
export interface IMSTArray<IT extends IAnyType> extends IObservableArray<ExtractT<IT>>, IStateTreeNode<ExtractC<IT>[] | undefined, ExtractS<IT>[]> {

@@ -16,2 +17,3 @@ push(...items: ExtractT<IT>[]): number;

}
/** @hidden */
export interface IArrayType<IT extends IAnyType> extends IType<ExtractC<IT>[] | undefined, ExtractS<IT>[], IMSTArray<IT>>, OptionalProperty {

@@ -24,3 +26,4 @@ }

*
* @example
* Example:
* ```ts
* const Todo = types.model({

@@ -38,7 +41,7 @@ * task: types.string

* console.log(s.todos[0]) // prints: "Grab coffee"
* ```
*
* @export
* @alias types.array
* @param {IType<S, T>} subtype
* @returns {IArrayType<IT>}
* @param subtype
* @returns
*/

@@ -49,7 +52,5 @@ export declare function array<IT extends IAnyType>(subtype: IT): IArrayType<IT>;

*
* @export
* @template Items
* @param {IAnyType} type
* @returns {type is IArrayType<Items>}
* @param type
* @returns `true` if the type is an array type.
*/
export declare function isArrayType<Items extends IAnyType = IAnyType>(type: IAnyType): type is IArrayType<Items>;
import { IInterceptor, IKeyValueMap, IMapDidChange, IMapWillChange, Lambda } from "mobx";
import { IAnyType, IType, OptionalProperty, ExtractC, ExtractS, ExtractT, ExtractCST, IStateTreeNode } from "../../internal";
/** @hidden */
export interface IMapType<IT extends IAnyType> extends IType<IKeyValueMap<ExtractC<IT>> | undefined, IKeyValueMap<ExtractS<IT>>, IMSTMap<IT>>, OptionalProperty {
}
/** @hidden */
export interface IMSTMap<IT extends IAnyType> extends IStateTreeNode<IKeyValueMap<ExtractC<IT>> | undefined, IKeyValueMap<ExtractS<IT>>> {

@@ -49,3 +51,4 @@ clear(): void;

*
* @example
* Example:
* ```ts
* const Todo = types.model({

@@ -65,7 +68,7 @@ * id: types.identifier,

* console.log(s.todos.get(17).task) // prints: "Grab coffee"
* ```
*
* @export
* @alias types.map
* @param {IType<S, T>} subtype
* @returns {IMapType<IT>}
* @param subtype
* @returns
*/

@@ -76,7 +79,5 @@ export declare function map<IT extends IAnyType>(subtype: IT): IMapType<IT>;

*
* @export
* @template Items
* @param {IAnyType} type
* @returns {type is IMapType<Items>}
* @param type
* @returns `true` if it is a map type.
*/
export declare function isMapType<Items extends IAnyType = IAnyType>(type: IAnyType): type is IMapType<Items>;
import { IAnyType, IStateTreeNode, IType, ExtractC, ExtractS, ExtractT } from "../../internal";
/** @hidden */
export interface ModelProperties {
[key: string]: IAnyType;
}
/** @hidden */
export declare type ModelPrimitive = string | number | boolean | Date;
/** @hidden */
export interface ModelPropertiesDeclaration {

@@ -11,2 +14,4 @@ [key: string]: ModelPrimitive | IAnyType;

* Unmaps syntax property declarations to a map of { propName: IType }
*
* @hidden
*/

@@ -16,11 +21,15 @@ export declare type ModelPropertiesDeclarationToProperties<T extends ModelPropertiesDeclaration> = {

};
/** @hidden */
export interface OptionalProperty {
readonly "!!optionalType": undefined;
}
/** @hidden */
export interface _NotCustomized {
readonly "!!mstNotCustomized": undefined;
}
/** @hidden */
export declare type _CustomOrOther<Custom, Other> = Custom extends _NotCustomized ? Other : Custom;
/**
* Maps property types to the snapshot, including omitted optional attributes
* @hidden
*/

@@ -30,26 +39,45 @@ export declare type RequiredPropNames<T> = {

}[keyof T];
/** @hidden */
export declare type RequiredProps<T> = Pick<T, RequiredPropNames<T>>;
/** @hidden */
export declare type RequiredPropsObject<P extends ModelProperties> = {
[K in keyof RequiredProps<P>]: P[K];
};
/** @hidden */
export declare type OptionalPropNames<T> = {
[K in keyof T]: T[K] extends OptionalProperty ? K : never;
}[keyof T];
/** @hidden */
export declare type OptionalProps<T> = Pick<T, OptionalPropNames<T>>;
/** @hidden */
export declare type OptionalPropsObject<P extends ModelProperties> = {
[K in keyof OptionalProps<P>]?: P[K];
};
/** @hidden */
export declare type ExtractCFromProps<P extends ModelProperties> = {
[k in keyof P]: ExtractC<P[k]>;
};
/** @hidden */
export declare type ModelCreationType<P extends ModelProperties> = ExtractCFromProps<RequiredPropsObject<P> & OptionalPropsObject<P>>;
/** @hidden */
export declare type ModelCreationType2<P extends ModelProperties, CustomC> = _CustomOrOther<CustomC, ModelCreationType<P>>;
/** @hidden */
export declare type ModelSnapshotType<P extends ModelProperties> = {
[K in keyof P]: ExtractS<P[K]>;
};
/** @hidden */
export declare type ModelSnapshotType2<P extends ModelProperties, CustomS> = _CustomOrOther<CustomS, ModelSnapshotType<P>>;
/**
* @hidden
* we keep this separate from ModelInstanceType to shorten model instance types generated declarations
*/
export declare type ModelInstanceTypeProps<P extends ModelProperties> = {
[K in keyof P]: ExtractT<P[K]>;
};
/**
* @hidden
* do not transform this to an interface or model instance type generated declarations will be longer
*/
export declare type ModelInstanceType<P extends ModelProperties, O, CustomC, CustomS> = ModelInstanceTypeProps<P> & O & IStateTreeNode<ModelCreationType2<P, CustomC>, ModelSnapshotType2<P, CustomS>>;
/** @hidden */
export interface ModelActions {

@@ -73,8 +101,14 @@ [key: string]: Function;

}
/**
* Any model type.
*/
export interface IAnyModelType extends IModelType<any, any, any, any> {
}
/** @hidden */
export declare type ExtractProps<T extends IAnyModelType> = T extends IModelType<infer P, any, any, any> ? P : never;
/** @hidden */
export declare type ExtractOthers<T extends IAnyModelType> = T extends IModelType<any, infer O, any, any> ? O : never;
export declare function model<P extends ModelPropertiesDeclaration = {}>(name: string, properties?: P): IModelType<ModelPropertiesDeclarationToProperties<P>, {}>;
export declare function model<P extends ModelPropertiesDeclaration = {}>(properties?: P): IModelType<ModelPropertiesDeclarationToProperties<P>, {}>;
/** @hidden */
export declare type _CustomJoin<A, B> = A extends _NotCustomized ? B : A & B;

@@ -100,7 +134,5 @@ export declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB>(name: string, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>): IModelType<PA & PB, OA & OB, _CustomJoin<FCA, FCB>, _CustomJoin<FSA, FSB>>;

*
* @export
* @template IT
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/
export declare function isModelType<IT extends IAnyModelType = IAnyModelType>(type: IAnyType): type is IT;

@@ -6,5 +6,5 @@ import { ISimpleType, IType } from "../internal";

*
* @export
* @alias types.string
* @example
* Example:
* ```ts
* const Person = types.model({

@@ -14,2 +14,3 @@ * firstName: types.string,

* })
* ```
*/

@@ -21,5 +22,5 @@ export declare const string: ISimpleType<string>;

*
* @export
* @alias types.number
* @example
* Example:
* ```ts
* const Vector = types.model({

@@ -29,2 +30,3 @@ * x: types.number,

* })
* ```
*/

@@ -36,5 +38,5 @@ export declare const number: ISimpleType<number>;

*
* @export
* @alias types.integer
* @example
* Example:
* ```ts
* const Size = types.model({

@@ -44,2 +46,3 @@ * width: types.integer,

* })
* ```
*/

@@ -51,5 +54,5 @@ export declare const integer: ISimpleType<number>;

*
* @export
* @alias types.boolean
* @example
* Example:
* ```ts
* const Thing = types.model({

@@ -59,2 +62,3 @@ * isCool: types.boolean,

* })
* ```
*/

@@ -65,3 +69,2 @@ export declare const boolean: ISimpleType<boolean>;

*
* @export
* @alias types.null

@@ -73,3 +76,2 @@ */

*
* @export
* @alias types.undefined

@@ -81,5 +83,5 @@ */

*
* @export
* @alias types.Date
* @example
* Example:
* ```ts
* const LogLine = types.model({

@@ -90,2 +92,3 @@ * timestamp: types.Date,

* LogLine.create({ timestamp: new Date() })
* ```
*/

@@ -96,7 +99,5 @@ export declare const DatePrimitive: IType<number | Date, number, Date>;

*
* @export
* @template IT
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/
export declare function isPrimitiveType<IT extends ISimpleType<string> | ISimpleType<number> | ISimpleType<boolean> | typeof DatePrimitive>(type: IT): type is IT;
import { IType } from "../../internal";
export interface CustomTypeOptions<S, T> {
/** Friendly name */
name: string;
/** given a serialized value, how to turn it into the target type */
fromSnapshot(snapshot: S): T;
/** return the serialization of the current value */
toSnapshot(value: T): S;
/** if true, this is a converted value, if false, it's a snapshot */
isTargetType(value: T | S): boolean;
/** a non empty string is assumed to be a validation error */
getValidationMessage(snapshot: S): string;

@@ -13,4 +18,3 @@ }

* The signature of the options is:
*
* ```javascript
* ```ts
* export interface CustomTypeOptions<S, T> {

@@ -30,3 +34,4 @@ * // Friendly name

*
* @example
* Example:
* ```ts
* const DecimalPrimitive = types.custom<string, Decimal>({

@@ -52,10 +57,8 @@ * name: "Decimal",

* })
* ```
*
* @export
* @alias types.custom
* @template S
* @template T
* @param {CustomTypeOptions<S, T>} options
* @returns {(IType<S | T, S, T>)}
* @param options
* @returns
*/
export declare function custom<S, T>(options: CustomTypeOptions<S, T>): IType<S | T, S, T>;
import { ISimpleType } from "../../internal";
/** @hidden */
export declare type UnionStringArray<T extends string[]> = T[number];
export declare function enumeration<T extends string>(options: T[]): ISimpleType<UnionStringArray<T[]>>;
export declare function enumeration<T extends string>(name: string, options: T[]): ISimpleType<UnionStringArray<T[]>>;

@@ -8,8 +8,5 @@ import { IType, OptionalProperty } from "../../internal";

*
* @export
* @template IT
* @template T
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/
export declare function isFrozenType<IT extends IType<T | any, T, T>, T = any>(type: IT): type is IT;

@@ -9,3 +9,4 @@ import { ISimpleType } from "../../internal";

*
* @example
* Example:
* ```ts
* const Todo = types.model("Todo", {

@@ -15,7 +16,6 @@ * id: types.identifier,

* })
* ```
*
* @export
* @alias types.identifier
* @template T
* @returns {IType<T, T>}
* @returns
*/

@@ -26,3 +26,4 @@ export declare const identifier: ISimpleType<string>;

*
* @example
* Example:
* ```ts
* const Todo = types.model("Todo", {

@@ -32,7 +33,6 @@ * id: types.identifierNumber,

* })
* ```
*
* @export
* @alias types.identifierNumber
* @template T
* @returns {IType<T, T>}
* @returns
*/

@@ -43,8 +43,9 @@ export declare const identifierNumber: ISimpleType<number>;

*
* @export
* @template IT
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/
export declare function isIdentifierType<IT extends typeof identifier | typeof identifierNumber>(type: IT): type is IT;
/**
* Valid types for identifiers.
*/
export declare type ReferenceIdentifier = string | number;

@@ -7,7 +7,5 @@ import { IAnyType } from "../../internal";

*
* @export
* @template IT
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/
export declare function isLateType<IT extends IAnyType>(type: IT): type is IT;

@@ -7,3 +7,4 @@ import { ISimpleType, Primitives } from "../../internal";

*
* @example
* Example:
* ```ts
* const Person = types.model({

@@ -13,8 +14,7 @@ * name: types.string,

* })
* ```
*
* @export
* @alias types.literal
* @template S
* @param {S} value The value to use in the strict equal check
* @returns {ISimpleType<S>}
* @param value The value to use in the strict equal check
* @returns
*/

@@ -25,7 +25,5 @@ export declare function literal<S extends Primitives>(value: S): ISimpleType<S>;

*
* @export
* @template IT
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/
export declare function isLiteralType<IT extends ISimpleType<any>>(type: IT): type is IT;
import { IType, IAnyType, ExtractC, ExtractS, ExtractT, OptionalProperty, IStateTreeNode, RedefineIStateTreeNode } from "../../internal";
/** @hidden */
export interface IMaybeIType<IT extends IAnyType, C, O> extends IType<ExtractC<IT> | C, ExtractS<IT> | O, RedefineIStateTreeNode<ExtractT<IT>, IStateTreeNode<ExtractC<IT> | C, ExtractS<IT> | O>> | O>, OptionalProperty {
}
/** @hidden */
export interface IMaybe<IT extends IAnyType> extends IMaybeIType<IT, undefined, undefined> {
}
/** @hidden */
export interface IMaybeNull<IT extends IAnyType> extends IMaybeIType<IT, null | undefined, null> {

@@ -12,7 +15,5 @@ }

*
* @export
* @alias types.maybe
* @template IT
* @param {IT} type
* @returns {IMaybe<IT>}
* @param type
* @returns
*/

@@ -24,8 +25,6 @@ export declare function maybe<IT extends IAnyType>(type: IT): IMaybe<IT>;

*
* @export
* @alias types.maybeNull
* @template IT
* @param {IT} type
* @returns {IMaybeNull<IT>}
* @param type
* @returns
*/
export declare function maybeNull<IT extends IAnyType>(type: IT): IMaybeNull<IT>;
import { IType, IAnyType, OptionalProperty, ExtractT, ExtractS, ExtractC, ExtractCST, RedefineIStateTreeNode, IStateTreeNode } from "../../internal";
/** @hidden */
export declare type OptionalDefaultValueOrFunction<IT extends IAnyType> = ExtractC<IT> | ExtractS<IT> | (() => ExtractCST<IT>);
/** @hidden */
export interface IOptionalIType<IT extends IAnyType> extends IType<ExtractC<IT> | undefined, ExtractS<IT>, RedefineIStateTreeNode<ExtractT<IT>, IStateTreeNode<ExtractC<IT> | undefined, ExtractS<IT>>>>, OptionalProperty {

@@ -11,3 +13,4 @@ }

*
* @example
* Example:
* ```ts
* const Todo = types.model({

@@ -21,9 +24,8 @@ * title: types.optional(types.string, "Test"),

* const todo = Todo.create({ title: "Get coffee "})
* ```
*
* @export
* @alias types.optional
* @template IT
* @param {IT} type
* @param {OptionalDefaultValueOrFunction<IT>} defaultValueOrFunction
* @returns {IT extends OptionalProperty ? IT : IOptionalIType<IT>}
* @param type
* @param defaultValueOrFunction
* @returns
*/

@@ -34,7 +36,6 @@ export declare function optional<IT extends IAnyType>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>): IT extends OptionalProperty ? IT : IOptionalIType<IT>;

*
* @export
* @template IT
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/
export declare function isOptionalType<IT extends IType<any | undefined, any, any> & OptionalProperty>(type: IT): type is IT;

@@ -19,2 +19,3 @@ import { IType, ExtractT, IAnyStateTreeNode, IAnyComplexType, IStateTreeNode, RedefineIStateTreeNode, IMaybe, ReferenceIdentifier } from "../../internal";

export declare type ReferenceOptions<IT extends IAnyComplexType> = ReferenceOptionsGetSet<IT> | ReferenceOptionsOnInvalidated<IT> | (ReferenceOptionsGetSet<IT> & ReferenceOptionsOnInvalidated<IT>);
/** @hidden */
export interface IReferenceType<IT extends IAnyComplexType> extends IType<ReferenceIdentifier, ReferenceIdentifier, RedefineIStateTreeNode<ExtractT<IT>, IStateTreeNode<ReferenceIdentifier, ReferenceIdentifier>>> {

@@ -26,3 +27,2 @@ }

*
* @export
* @alias types.reference

@@ -34,6 +34,4 @@ */

*
* @export
* @template IT
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/

@@ -48,9 +46,7 @@ export declare function isReferenceType<IT extends IReferenceType<any>>(type: IT): type is IT;

*
* @export
* @alias types.safeReference
* @template IT
* @param {IT} subType
* @param {ReferenceOptionsGetSet<IT>} [options]
* @returns {IMaybe<IReferenceType<IT>>}
* @param subType
* @param options
* @returns
*/
export declare function safeReference<IT extends IAnyComplexType>(subType: IT, options?: ReferenceOptionsGetSet<IT>): IMaybe<IReferenceType<IT>>;

@@ -7,7 +7,5 @@ import { IAnyType, ExtractC } from "../../internal";

*
* @export
* @template IT
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/
export declare function isRefinementType<IT extends IAnyType>(type: IT): type is IT;

@@ -7,3 +7,8 @@ import { IType, IAnyType, IModelType, ModelProperties, ModelInstanceType, ModelSnapshotType2, ModelCreationType2, _NotCustomized, RedefineIStateTreeNode, IStateTreeNode } from "../../internal";

}
/**
* Transform _NotCustomized | _NotCustomized... to _NotCustomized, _NotCustomized | A | B to A | B
* @hidden
*/
export declare type _CustomCSProcessor<T> = Exclude<T, _NotCustomized> extends never ? _NotCustomized : Exclude<T, _NotCustomized>;
/** @hidden */
export interface ITypeUnion<C, S, T> extends IType<_CustomCSProcessor<C>, _CustomCSProcessor<S>, RedefineIStateTreeNode<T, IStateTreeNode<_CustomCSProcessor<C>, _CustomCSProcessor<S>>>> {

@@ -48,7 +53,5 @@ }

*
* @export
* @template IT
* @param {IT} type
* @returns {type is IT}
* @param type
* @returns
*/
export declare function isUnionType<IT extends IAnyType>(type: IT): type is IT;
{
"name": "mobx-state-tree",
"version": "3.9.0",
"version": "3.10.0",
"description": "Opinionated, transactional, MobX powered state container",

@@ -17,7 +17,7 @@ "main": "dist/mobx-state-tree.js",

"test:cyclic": "yarn run build && node -e \"require('.')\"",
"test:mobx4": "yarn add -D mobx@4.5.0 && yarn build && yarn jest --ci && git checkout package.json ../../yarn.lock && yarn install",
"test:mobx4": "yarn add -D mobx@4.8.0 && yarn build && yarn jest --ci && git checkout package.json ../../yarn.lock && yarn install",
"_prepublish": "yarn run build && yarn run build-docs",
"coverage": "yarn jest --coverage",
"lint-docs": "tsc && documentation lint lib/index.js",
"build-docs": "tsc && documentation build lib/index.js --sort-order alpha -f md -o ../../API.md.tmp && concat -o ../../API.md ../../docs/API_header.md ../../API.md.tmp && shx rm ../../API.md.tmp",
"fix-docs": "replace --quiet \"&lt;\" \"<\" ../../docs/API/README.md && replace --quiet \"&gt;\" \">\" ../../docs/API/README.md && concat -o ../../docs/API/README.md ../../docs/API_header.md ../../docs/API/README.md",
"build-docs": "shx rm -rf ../../docs/API && typedoc --options ./typedocconfig.js && yarn fix-docs",
"lint": "tslint -c ../../tslint.json 'src/**/*.ts'"

@@ -46,9 +46,9 @@ },

"cross-env": "^5.1.1",
"documentation": "^8.0.0",
"jest": "^23.4.0",
"mobx": "^5.5.0",
"rollup": "^0.67.0",
"mobx": "^5.8.0",
"replace": "^1.0.1",
"rollup": "^1.0.0",
"rollup-plugin-commonjs": "^9.0.0",
"rollup-plugin-filesize": "^5.0.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.0.0",

@@ -60,6 +60,8 @@ "rollup-plugin-uglify": "^6.0.0",

"tslib": "^1.7.1",
"typedoc": "^0.13.0",
"typedoc-plugin-markdown": "^1.1.20",
"typescript": "~3.0.0"
},
"peerDependencies": {
"mobx": ">=4.5.0 <5.0.0 || >=5.5.0 <6.0.0"
"mobx": ">=4.8.0 <5.0.0 || >=5.8.0 <6.0.0"
},

@@ -66,0 +68,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc