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.13.0 to 3.14.0

dist/core/actionContext.d.ts

17

dist/core/action.d.ts

@@ -1,15 +0,14 @@

import { IDisposer, IAnyStateTreeNode } from "../internal";
import { IDisposer, IAnyStateTreeNode, IActionContext } from "../internal";
export declare type IMiddlewareEventType = "action" | "flow_spawn" | "flow_resume" | "flow_resume_error" | "flow_return" | "flow_throw";
export interface IMiddlewareEvent {
export interface IMiddlewareEvent extends IActionContext {
/** Event type */
readonly type: IMiddlewareEventType;
readonly name: string;
readonly id: number;
/** Parent event unique id */
readonly parentId: number;
/** Parent event object */
readonly parentEvent: IMiddlewareEvent | undefined;
/** Root event unique id */
readonly rootId: number;
/** Id of all events, from root until current (excluding current) */
readonly allParentIds: number[];
readonly context: IAnyStateTreeNode;
readonly tree: IAnyStateTreeNode;
readonly args: any[];
readonly parentEvent: IMiddlewareEvent | undefined;
readonly parentActionEvent: IMiddlewareEvent | undefined;
}

@@ -16,0 +15,0 @@ export declare type IMiddlewareHandler = (actionCall: IMiddlewareEvent, next: (actionCall: IMiddlewareEvent, callback?: (value: any) => any) => void, abort: (value: any) => void) => any;

@@ -1,2 +0,2 @@

import { IAnyStateTreeNode, IType, IAnyModelType, IStateTreeNode, IJsonPatch, IDisposer, IAnyType, ReferenceIdentifier, ExtractC, TypeOfValue, ExtractTWithSTN, ExtractS } from "../internal";
import { IAnyStateTreeNode, IType, IAnyModelType, IStateTreeNode, IJsonPatch, IDisposer, IAnyType, ReferenceIdentifier, TypeOfValue, IActionContext } from "../internal";
/** @hidden */

@@ -85,3 +85,3 @@ export declare type TypeOrStateTreeNodeToStateTreeNode<T extends IAnyType | IAnyStateTreeNode> = T extends IType<any, any, infer TT> ? TT & IStateTreeNode<T> : T;

* // resume recording patches
* resume()
* resume(): void
* // apply all the recorded patches on the given target (the original subject if omitted)

@@ -101,3 +101,3 @@ * replay(target?: IAnyStateTreeNode): void

*/
export declare function recordPatches(subject: IAnyStateTreeNode, filter?: (patch: IJsonPatch, inversePatch: IJsonPatch) => boolean): IPatchRecorder;
export declare function recordPatches(subject: IAnyStateTreeNode, filter?: (patch: IJsonPatch, inversePatch: IJsonPatch, actionContext: IActionContext | undefined) => boolean): IPatchRecorder;
/**

@@ -192,3 +192,3 @@ * The inverse of `unprotect`.

*/
export declare function getParentOfType<IT extends IAnyType>(target: IAnyStateTreeNode, type: IT): ExtractTWithSTN<IT>;
export declare function getParentOfType<IT extends IAnyType>(target: IAnyStateTreeNode, type: IT): IT["Type"];
/**

@@ -243,3 +243,3 @@ * Given an object in a model tree, returns the root object of that tree.

*/
export declare function resolveIdentifier<IT extends IAnyType>(type: IT, target: IAnyStateTreeNode, identifier: ReferenceIdentifier): ExtractTWithSTN<IT> | undefined;
export declare function resolveIdentifier<IT extends IAnyType>(type: IT, target: IAnyStateTreeNode, identifier: ReferenceIdentifier): IT["Type"] | undefined;
/**

@@ -388,3 +388,3 @@ * Returns the identifier of the target node.

export declare function cast<O extends string | number | boolean | null | undefined = never>(snapshotOrInstance: O): O;
export declare function cast<O = never>(snapshotOrInstance: ExtractC<TypeOfValue<O>> | ExtractS<TypeOfValue<O>> | ExtractTWithSTN<TypeOfValue<O>>): O;
export declare function cast<O = never>(snapshotOrInstance: TypeOfValue<O>["CreationType"] | TypeOfValue<O>["SnapshotType"] | TypeOfValue<O>["Type"]): O;
/**

@@ -417,3 +417,3 @@ * Casts a node instance type to an snapshot type so it can be assigned to a type snapshot (e.g. to be used inside a create call).

*/
export declare function castToSnapshot<I>(snapshotOrInstance: I): Extract<I, IAnyStateTreeNode> extends never ? I : ExtractC<TypeOfValue<I>>;
export declare function castToSnapshot<I>(snapshotOrInstance: I): Extract<I, IAnyStateTreeNode> extends never ? I : TypeOfValue<I>["CreationType"];
/**

@@ -420,0 +420,0 @@ * Casts a node instance type to a reference snapshot type so it can be assigned to a refernence snapshot (e.g. to be used inside a create call).

import { IValidationContext, IValidationResult, IStateTreeNode, ModelPrimitive } 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];
export declare type STNValue<T, IT extends IAnyType> = (Extract<T, object> & IStateTreeNode<IT>) | Exclude<T, object>;
/** @hidden */
declare const $type: unique symbol;
/**
* Checks if a type is any or unknown
* @hidden
*/
export declare type IsTypeAnyOrUnknown<T> = unknown extends T ? true : false;
declare type WithoutUndefined<T> = T extends undefined ? never : T;
/**
* Checks if a type is optional (its creation snapshot can be undefined) or not.
* @hidden
*
* Examples:
* - string = false
* - undefined = true
* - string | undefined = true
* - string & undefined = true
* - any = true
* - unknown = true
*/
export declare type IsOptionalType<IT extends IAnyType> = ExtractC<IT> extends WithoutUndefined<ExtractC<IT>> ? IsTypeAnyOrUnknown<ExtractC<IT>> : true;
/**
* 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?];
/**
* @hidden
*/
export declare type STNValue<T, IT extends IAnyType> = Extract<T, object> extends never ? T : (Extract<T, object> & IStateTreeNode<IT>) | Exclude<T, object>;
/**
* A type, either complex or simple.
*/
export interface IType<C, S, T> {
/** @hidden */
readonly [$type]: undefined;
/**

@@ -55,3 +22,2 @@ * Friendly type name.

readonly identifierAttribute?: string;
create(...args: CreateParams<C>): STNValue<T, this>;
/**

@@ -62,3 +28,3 @@ * Creates an instance for the type given an snapshot input.

*/
create(snapshot: C, env?: any): STNValue<T, this>;
create(snapshot?: C, env?: any): this["Type"];
/**

@@ -70,3 +36,3 @@ * Checks if a given snapshot / instance is of the given type.

*/
is(thing: any): thing is C | STNValue<T, this>;
is(thing: any): thing is C | this["Type"];
/**

@@ -90,2 +56,7 @@ * Run's the type's typechecker on the given value with the given validation context.

/**
* @deprecated do not use.
* @hidden
*/
readonly TypeWithoutSTN: T;
/**
* @deprecated use `SnapshotOut<typeof MyType>` instead.

@@ -104,3 +75,4 @@ * @hidden

*/
export declare type IAnyType = IType<any, any, any>;
export interface IAnyType extends IType<any, any, any> {
}
/**

@@ -123,28 +95,39 @@ * A simple type, this is, a type where the instance and the snapshot representation are the same.

*/
export declare type IAnyComplexType = IType<any, any, object>;
export interface IAnyComplexType extends IType<any, any, object> {
}
/** @hidden */
export declare type ExtractC<T extends IAnyType> = T extends IType<infer C, any, any> ? C : never;
export declare type ExtractCSTWithoutSTN<IT extends {
[$type]: undefined;
CreationType: any;
SnapshotType: any;
TypeWithoutSTN: any;
}> = IT["CreationType"] | IT["SnapshotType"] | IT["TypeWithoutSTN"];
/** @hidden */
export declare type ExtractS<T extends IAnyType> = T extends IType<any, infer S, any> ? S : never;
/** @hidden */
export declare type ExtractTWithoutSTN<T extends IAnyType> = T extends IType<any, any, infer X> ? X : never;
/** @hidden */
export declare type ExtractTWithSTN<T extends IAnyType> = InstanceWithDefault<T, never>;
/** @hidden */
export declare type ExtractCSTWithoutSTN<IT extends IAnyType> = IT extends IType<infer C, infer S, infer T> ? C | S | T : never;
/** @hidden */
export declare type ExtractCSTWithSTN<IT extends IAnyType> = IT extends IType<infer C, infer S, infer T> ? C | S | ExtractTWithSTN<IT> : never;
declare type InstanceWithDefault<T, DEFAULT> = T extends IType<any, any, infer TT> ? STNValue<TT, T> : DEFAULT;
export declare type ExtractCSTWithSTN<IT extends {
[$type]: undefined;
CreationType: any;
SnapshotType: any;
Type: any;
}> = IT["CreationType"] | IT["SnapshotType"] | IT["Type"];
/**
* The instance representation of a given type.
*/
export declare type Instance<T> = InstanceWithDefault<T, T>;
export declare type Instance<T> = T extends {
[$type]: undefined;
Type: any;
} ? T["Type"] : T;
/**
* The input (creation) snapshot representation of a given type.
*/
export declare type SnapshotIn<T> = T extends IStateTreeNode<IType<infer STNC, any, any>> ? STNC : T extends IType<infer TC, any, any> ? TC : T;
export declare type SnapshotIn<T> = T extends {
[$type]: undefined;
CreationType: any;
} ? T["CreationType"] : T extends IStateTreeNode<infer IT> ? IT["CreationType"] : T;
/**
* The output snapshot representation of a given type.
*/
export declare type SnapshotOut<T> = T extends IStateTreeNode<IType<any, infer STNS, any>> ? STNS : T extends IType<any, infer TS, any> ? TS : T;
export declare type SnapshotOut<T> = T extends {
[$type]: undefined;
SnapshotType: any;
} ? T["SnapshotType"] : T extends IStateTreeNode<infer IT> ? IT["SnapshotType"] : T;
/**

@@ -151,0 +134,0 @@ * A type which is equivalent to the union of SnapshotIn and Instance types of a given typeof TYPE or typeof VARIABLE.

export { IModelType, IAnyModelType, IDisposer, IMSTMap, IMapType, IMSTArray, IArrayType, IType, IAnyType, ISimpleType, IComplexType, IAnyComplexType, IReferenceType, _CustomCSProcessor, _CustomOrOther, _CustomJoin, _NotCustomized, typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, IReversibleJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IActionTrackingMiddleware2Call, IMiddlewareHandler, IMiddlewareEventType, IActionTrackingMiddlewareHooks, IActionTrackingMiddleware2Hooks, process, isStateTreeNode, IStateTreeNode, IAnyStateTreeNode, flow, castFlowReturn, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware, createActionTrackingMiddleware2, setLivelinessChecking, getLivelinessChecking, LivelinessMode, setLivelynessChecking, // to be deprecated
LivelynessMode, // to be deprecated
ModelSnapshotType, ModelCreationType, ModelSnapshotType2, ModelCreationType2, ModelInstanceType, ModelInstanceTypeProps, ModelPropertiesDeclarationToProperties, ModelProperties, ModelPropertiesDeclaration, 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, ValidOptionalValue, ValidOptionalValues, getMembers, getPropertyMembers, TypeOfValue, cast, castToSnapshot, castToReferenceSnapshot, isType, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, IsOptionalType, isPrimitiveType, isReferenceType, isRefinementType, isUnionType, tryReference, isValidReference, OnReferenceInvalidated, OnReferenceInvalidatedEvent, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, ReferenceIdentifier, ISnapshotProcessor, ISnapshotProcessors, getNodeId, types } from "./internal";
ModelSnapshotType, ModelCreationType, ModelSnapshotType2, ModelCreationType2, ModelInstanceType, ModelInstanceTypeProps, ModelPropertiesDeclarationToProperties, ModelProperties, ModelPropertiesDeclaration, 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, ValidOptionalValue, ValidOptionalValues, getMembers, getPropertyMembers, TypeOfValue, cast, castToSnapshot, castToReferenceSnapshot, isType, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isReferenceType, isRefinementType, isUnionType, tryReference, isValidReference, OnReferenceInvalidated, OnReferenceInvalidatedEvent, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, ReferenceIdentifier, ISnapshotProcessor, ISnapshotProcessors, getNodeId, IActionContext, getRunningActionContext, isActionContextChildOf, isActionContextThisOrChildOf, types } from "./internal";

@@ -12,2 +12,3 @@ export * from "./core/node/livelinessChecking";

export * from "./core/action";
export * from "./core/actionContext";
export * from "./core/type/type-checker";

@@ -14,0 +15,0 @@ export * from "./core/node/identifier-cache";

@@ -1,4 +0,3 @@

import { IMiddlewareEvent, IMiddlewareHandler } from "../internal";
declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
export interface IActionTrackingMiddleware2Call<TEnv> extends Readonly<Omit<IMiddlewareEvent, "type">> {
import { IMiddlewareHandler, IActionContext } from "../internal";
export interface IActionTrackingMiddleware2Call<TEnv> extends Readonly<IActionContext> {
env: TEnv | undefined;

@@ -36,2 +35,1 @@ readonly parentCall?: IActionTrackingMiddleware2Call<TEnv>;

export declare function createActionTrackingMiddleware2<TEnv = any>(middlewareHooks: IActionTrackingMiddleware2Hooks<TEnv>): IMiddlewareHandler;
export {};

@@ -1,2 +0,2 @@

import { IDisposer, IAnyStateTreeNode } from "../internal";
import { IDisposer, IAnyStateTreeNode, IActionContext } from "../internal";
export interface ISerializedActionCall {

@@ -9,3 +9,5 @@ name: string;

actions: ReadonlyArray<ISerializedActionCall>;
readonly recording: boolean;
stop(): void;
resume(): void;
replay(target: IAnyStateTreeNode): void;

@@ -31,13 +33,19 @@ }

* actions: ISerializedActionCall[]
* // true if currently recording
* recording: boolean
* // stop recording actions
* stop(): any
* stop(): void
* // resume recording actions
* resume(): void
* // apply all the recorded actions on the given object
* replay(target: IAnyStateTreeNode): any
* replay(target: IAnyStateTreeNode): void
* }
* ```
*
* The optional filter function allows to skip recording certain actions.
*
* @param subject
* @returns
*/
export declare function recordActions(subject: IAnyStateTreeNode): IActionRecorder;
export declare function recordActions(subject: IAnyStateTreeNode, filter?: (action: ISerializedActionCall, actionContext: IActionContext | undefined) => boolean): IActionRecorder;
/**

@@ -44,0 +52,0 @@ * Registers a function that will be invoked for each action that is called on the provided model instance, or to any of its children.

import { IObservableArray } from "mobx";
import { IAnyType, IType, ExtractS, ExtractC, ExtractTWithSTN, ExtractCSTWithSTN } from "../../internal";
import { IAnyType, IType, ExtractCSTWithSTN } from "../../internal";
/** @hidden */
export interface IMSTArray<IT extends IAnyType> extends IObservableArray<ExtractTWithSTN<IT>> {
push(...items: ExtractTWithSTN<IT>[]): number;
export interface IMSTArray<IT extends IAnyType> extends IObservableArray<IT["Type"]> {
push(...items: IT["Type"][]): number;
push(...items: ExtractCSTWithSTN<IT>[]): number;
concat(...items: ConcatArray<ExtractTWithSTN<IT>>[]): ExtractTWithSTN<IT>[];
concat(...items: ConcatArray<ExtractCSTWithSTN<IT>>[]): ExtractTWithSTN<IT>[];
concat(...items: (ExtractTWithSTN<IT> | ConcatArray<ExtractTWithSTN<IT>>)[]): ExtractTWithSTN<IT>[];
concat(...items: (ExtractCSTWithSTN<IT> | ConcatArray<ExtractCSTWithSTN<IT>>)[]): ExtractTWithSTN<IT>[];
splice(start: number, deleteCount?: number): ExtractTWithSTN<IT>[];
splice(start: number, deleteCount: number, ...items: ExtractTWithSTN<IT>[]): ExtractTWithSTN<IT>[];
splice(start: number, deleteCount: number, ...items: ExtractCSTWithSTN<IT>[]): ExtractTWithSTN<IT>[];
unshift(...items: ExtractTWithSTN<IT>[]): number;
concat(...items: ConcatArray<IT["Type"]>[]): IT["Type"][];
concat(...items: ConcatArray<ExtractCSTWithSTN<IT>>[]): IT["Type"][];
concat(...items: (IT["Type"] | ConcatArray<IT["Type"]>)[]): IT["Type"][];
concat(...items: (ExtractCSTWithSTN<IT> | ConcatArray<ExtractCSTWithSTN<IT>>)[]): IT["Type"][];
splice(start: number, deleteCount?: number): IT["Type"][];
splice(start: number, deleteCount: number, ...items: IT["Type"][]): IT["Type"][];
splice(start: number, deleteCount: number, ...items: ExtractCSTWithSTN<IT>[]): IT["Type"][];
unshift(...items: IT["Type"][]): number;
unshift(...items: ExtractCSTWithSTN<IT>[]): number;
}
/** @hidden */
export interface IArrayType<IT extends IAnyType> extends IType<ExtractC<IT>[] | undefined, ExtractS<IT>[], IMSTArray<IT>> {
export interface IArrayType<IT extends IAnyType> extends IType<IT["CreationType"][] | undefined, IT["SnapshotType"][], IMSTArray<IT>> {
}

@@ -20,0 +20,0 @@ /**

import { IInterceptor, IKeyValueMap, IMapDidChange, IMapWillChange, Lambda } from "mobx";
import { IAnyType, IType, ExtractC, ExtractS, ExtractTWithSTN, ExtractCSTWithSTN, ExtractTWithoutSTN } from "../../internal";
import { IAnyType, IType, ExtractCSTWithSTN } from "../../internal";
/** @hidden */
export interface IMapType<IT extends IAnyType> extends IType<IKeyValueMap<ExtractC<IT>> | undefined, IKeyValueMap<ExtractS<IT>>, IMSTMap<IT>> {
export interface IMapType<IT extends IAnyType> extends IType<IKeyValueMap<IT["CreationType"]> | undefined, IKeyValueMap<IT["SnapshotType"]>, IMSTMap<IT>> {
}

@@ -10,15 +10,15 @@ /** @hidden */

delete(key: string): boolean;
forEach(callbackfn: (value: ExtractTWithSTN<IT>, key: string, map: this) => void, thisArg?: any): void;
get(key: string): ExtractTWithSTN<IT> | undefined;
forEach(callbackfn: (value: IT["Type"], key: string, map: this) => void, thisArg?: any): void;
get(key: string): IT["Type"] | undefined;
has(key: string): boolean;
set(key: string, value: ExtractCSTWithSTN<IT>): this;
readonly size: number;
put(value: ExtractCSTWithSTN<IT>): ExtractTWithSTN<IT>;
put(value: ExtractCSTWithSTN<IT>): IT["Type"];
keys(): IterableIterator<string>;
values(): IterableIterator<ExtractTWithSTN<IT>>;
entries(): IterableIterator<[string, ExtractTWithSTN<IT>]>;
[Symbol.iterator](): IterableIterator<[string, ExtractTWithSTN<IT>]>;
values(): IterableIterator<IT["Type"]>;
entries(): IterableIterator<[string, IT["Type"]]>;
[Symbol.iterator](): IterableIterator<[string, IT["Type"]]>;
/** Merge another object into this map, returns self. */
merge(other: IMSTMap<IType<any, any, ExtractTWithoutSTN<IT>>> | IKeyValueMap<ExtractCSTWithSTN<IT>> | any): this;
replace(values: IMSTMap<IType<any, any, ExtractTWithoutSTN<IT>>> | IKeyValueMap<ExtractCSTWithSTN<IT>> | any): this;
merge(other: IMSTMap<IType<any, any, IT["TypeWithoutSTN"]>> | IKeyValueMap<ExtractCSTWithSTN<IT>> | any): this;
replace(values: IMSTMap<IType<any, any, IT["TypeWithoutSTN"]>> | IKeyValueMap<ExtractCSTWithSTN<IT>> | any): this;
/**

@@ -29,4 +29,4 @@ * Returns a plain object that represents this map.

*/
toPOJO(): IKeyValueMap<ExtractS<IT>>;
toJSON(): IKeyValueMap<ExtractS<IT>>;
toPOJO(): IKeyValueMap<IT["SnapshotType"]>;
toJSON(): IKeyValueMap<IT["SnapshotType"]>;
/**

@@ -36,3 +36,3 @@ * Returns a shallow non observable object clone of this map.

*/
toJS(): Map<string, ExtractTWithSTN<IT>>;
toJS(): Map<string, IT["Type"]>;
toString(): string;

@@ -45,4 +45,4 @@ [Symbol.toStringTag]: "Map";

*/
observe(listener: (changes: IMapDidChange<string, ExtractTWithSTN<IT>>) => void, fireImmediately?: boolean): Lambda;
intercept(handler: IInterceptor<IMapWillChange<string, ExtractTWithSTN<IT>>>): Lambda;
observe(listener: (changes: IMapDidChange<string, IT["Type"]>) => void, fireImmediately?: boolean): Lambda;
intercept(handler: IInterceptor<IMapWillChange<string, IT["Type"]>>): Lambda;
}

@@ -49,0 +49,0 @@ /**

@@ -1,2 +0,2 @@

import { IAnyType, IType, ExtractC, ExtractS, _CustomOrOther, _NotCustomized, IsOptionalType, ExtractTWithSTN, Instance } from "../../internal";
import { IAnyType, IType, _CustomOrOther, _NotCustomized, Instance } from "../../internal";
/** @hidden */

@@ -17,28 +17,50 @@ export interface ModelProperties {

*/
export declare type ModelPropertiesDeclarationToProperties<T extends ModelPropertiesDeclaration> = {
[K in keyof T]: T[K] extends string ? IType<string | undefined, string, string> : T[K] extends number ? IType<number | undefined, number, number> : T[K] extends boolean ? IType<boolean | undefined, boolean, boolean> : T[K] extends Date ? IType<number | Date | undefined, number, Date> : T[K] extends IAnyType ? T[K] : never;
export declare type ModelPropertiesDeclarationToProperties<T extends ModelPropertiesDeclaration> = T extends {
[k: string]: IAnyType;
} ? T : {
[K in keyof T]: T[K] extends IAnyType ? T[K] : T[K] extends string ? IType<string | undefined, string, string> : T[K] extends number ? IType<number | undefined, number, number> : T[K] extends boolean ? IType<boolean | undefined, boolean, boolean> : T[K] extends Date ? IType<number | Date | undefined, number, Date> : never;
};
/**
* Checks if a type is any or unknown
* @hidden
*/
declare type IsAnyOrUnknown<T> = unknown extends T ? true : never;
/**
* Checks if a type is undefined
* @hidden
*/
declare type IsUndefined<T> = T extends undefined ? true : never;
/**
* Checks if a value is optional (undefined, any or unknown).
* @hidden
*
* Examples:
* - string = never
* - undefined = true
* - string | undefined = true
* - string & undefined = true
* - any = true
* - unknown = true
*/
declare type IsOptionalValue<C> = IsUndefined<C> | IsAnyOrUnknown<C>;
/**
* Name of the properties of an object that can't be set to undefined, any or unknown
* @hidden
*/
declare type DefinablePropsNames<T> = {
[K in keyof T]: IsOptionalValue<T[K]> extends never ? K : never;
}[keyof T];
/** @hidden */
export declare type RequiredPropNames<P extends ModelProperties> = {
[K in keyof P]: IsOptionalType<P[K]> extends true ? never : K;
}[keyof P];
/** @hidden */
export declare type RequiredPropsObject<P extends ModelProperties> = Pick<P, RequiredPropNames<P>>;
/** @hidden */
export declare type OptionalPropNames<P extends ModelProperties> = {
[K in keyof P]: IsOptionalType<P[K]> extends true ? K : never;
}[keyof P];
/** @hidden */
export declare type OptionalPropsObject<P extends ModelProperties> = Partial<Pick<P, OptionalPropNames<P>>>;
/** @hidden */
export declare type ExtractCFromProps<P extends ModelProperties> = {
[k in keyof P]: ExtractC<P[k]>;
[k in keyof P]: P[k]["CreationType"];
};
/** @hidden */
export declare type ModelCreationType<P extends ModelProperties> = ExtractCFromProps<RequiredPropsObject<P> & OptionalPropsObject<P>>;
export declare type ModelCreationType<PC> = {
[P in DefinablePropsNames<PC>]: PC[P];
} & Partial<PC>;
/** @hidden */
export declare type ModelCreationType2<P extends ModelProperties, CustomC> = _CustomOrOther<CustomC, ModelCreationType<P>>;
export declare type ModelCreationType2<P extends ModelProperties, CustomC> = _CustomOrOther<CustomC, ModelCreationType<ExtractCFromProps<P>>>;
/** @hidden */
export declare type ModelSnapshotType<P extends ModelProperties> = {
[K in keyof P]: ExtractS<P[K]>;
[K in keyof P]: P[K]["SnapshotType"];
};

@@ -52,3 +74,3 @@ /** @hidden */

export declare type ModelInstanceTypeProps<P extends ModelProperties> = {
[K in keyof P]: ExtractTWithSTN<P[K]>;
[K in keyof P]: P[K]["Type"];
};

@@ -117,1 +139,2 @@ /**

export declare function isModelType<IT extends IAnyModelType = IAnyModelType>(type: IAnyType): type is IT;
export {};

@@ -1,4 +0,4 @@

import { IType, IAnyType, ExtractC, ExtractS, ExtractTWithoutSTN } from "../../internal";
import { IType, IAnyType } from "../../internal";
/** @hidden */
export interface IMaybeIType<IT extends IAnyType, C, O> extends IType<ExtractC<IT> | C, ExtractS<IT> | O, ExtractTWithoutSTN<IT> | O> {
export interface IMaybeIType<IT extends IAnyType, C, O> extends IType<IT["CreationType"] | C, IT["SnapshotType"] | O, IT["TypeWithoutSTN"] | O> {
}

@@ -5,0 +5,0 @@ /** @hidden */

@@ -1,2 +0,2 @@

import { IType, IAnyType, ExtractS, ExtractC, ExtractCSTWithSTN, ExtractTWithoutSTN } from "../../internal";
import { IType, IAnyType, ExtractCSTWithSTN } from "../../internal";
/** @hidden */

@@ -7,5 +7,5 @@ export declare type ValidOptionalValue = string | boolean | number | null | undefined;

/** @hidden */
export declare type OptionalDefaultValueOrFunction<IT extends IAnyType> = ExtractC<IT> | ExtractS<IT> | (() => ExtractCSTWithSTN<IT>);
export declare type OptionalDefaultValueOrFunction<IT extends IAnyType> = IT["CreationType"] | IT["SnapshotType"] | (() => ExtractCSTWithSTN<IT>);
/** @hidden */
export interface IOptionalIType<IT extends IAnyType, OptionalVals extends ValidOptionalValues> extends IType<ExtractC<IT> | OptionalVals[number], ExtractS<IT>, ExtractTWithoutSTN<IT>> {
export interface IOptionalIType<IT extends IAnyType, OptionalVals extends ValidOptionalValues> extends IType<IT["CreationType"] | OptionalVals[number], IT["SnapshotType"], IT["TypeWithoutSTN"]> {
}

@@ -12,0 +12,0 @@ export declare function optional<IT extends IAnyType>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>): IOptionalIType<IT, [undefined]>;

@@ -1,2 +0,2 @@

import { IType, IAnyType, IAnyStateTreeNode, IAnyComplexType, IMaybe, ReferenceIdentifier, ExtractTWithoutSTN, IStateTreeNode } from "../../internal";
import { IType, IAnyType, IAnyStateTreeNode, IAnyComplexType, IMaybe, ReferenceIdentifier, IStateTreeNode } from "../../internal";
export declare type OnReferenceInvalidatedEvent<STN extends IAnyStateTreeNode> = {

@@ -12,3 +12,3 @@ parent: IAnyStateTreeNode;

/** @hidden */
export declare type ReferenceT<IT extends IAnyType> = ExtractTWithoutSTN<IT> & IStateTreeNode<IReferenceType<IT>>;
export declare type ReferenceT<IT extends IAnyType> = IT["TypeWithoutSTN"] & IStateTreeNode<IReferenceType<IT>>;
export interface ReferenceOptionsGetSet<IT extends IAnyComplexType> {

@@ -23,3 +23,3 @@ get(identifier: ReferenceIdentifier, parent: IAnyStateTreeNode | null): ReferenceT<IT>;

/** @hidden */
export interface IReferenceType<IT extends IAnyComplexType> extends IType<ReferenceIdentifier, ReferenceIdentifier, ExtractTWithoutSTN<IT>> {
export interface IReferenceType<IT extends IAnyComplexType> extends IType<ReferenceIdentifier, ReferenceIdentifier, IT["TypeWithoutSTN"]> {
}

@@ -26,0 +26,0 @@ /**

@@ -1,4 +0,4 @@

import { IAnyType, ExtractC } from "../../internal";
export declare function refinement<IT extends IAnyType>(name: string, type: IT, predicate: (snapshot: ExtractC<IT>) => boolean, message?: string | ((v: ExtractC<IT>) => string)): IT;
export declare function refinement<IT extends IAnyType>(type: IT, predicate: (snapshot: ExtractC<IT>) => boolean, message?: string | ((v: ExtractC<IT>) => string)): IT;
import { IAnyType } from "../../internal";
export declare function refinement<IT extends IAnyType>(name: string, type: IT, predicate: (snapshot: IT["CreationType"]) => boolean, message?: string | ((v: IT["CreationType"]) => string)): IT;
export declare function refinement<IT extends IAnyType>(type: IT, predicate: (snapshot: IT["CreationType"]) => boolean, message?: string | ((v: IT["CreationType"]) => string)): IT;
/**

@@ -5,0 +5,0 @@ * Returns if a given value is a refinement type.

@@ -1,2 +0,2 @@

import { IType, ExtractC, ExtractS, IAnyType, ExtractTWithoutSTN } from "../../internal";
import { IType, IAnyType } from "../../internal";
/** @hidden */

@@ -13,3 +13,3 @@ declare const $mstNotCustomized: unique symbol;

*/
export interface ISnapshotProcessor<IT extends IAnyType, CustomC, CustomS> extends IType<_CustomOrOther<CustomC, ExtractC<IT>>, _CustomOrOther<CustomS, ExtractS<IT>>, ExtractTWithoutSTN<IT>> {
export interface ISnapshotProcessor<IT extends IAnyType, CustomC, CustomS> extends IType<_CustomOrOther<CustomC, IT["CreationType"]>, _CustomOrOther<CustomS, IT["SnapshotType"]>, IT["TypeWithoutSTN"]> {
}

@@ -61,3 +61,3 @@ /**

*/
export declare function snapshotProcessor<IT extends IAnyType, CustomC = _NotCustomized, CustomS = _NotCustomized>(type: IT, processors: ISnapshotProcessors<ExtractC<IT>, CustomC, ExtractS<IT>, CustomS>, name?: string): ISnapshotProcessor<IT, CustomC, CustomS>;
export declare function snapshotProcessor<IT extends IAnyType, CustomC = _NotCustomized, CustomS = _NotCustomized>(type: IT, processors: ISnapshotProcessors<IT["CreationType"], CustomC, IT["SnapshotType"], CustomS>, name?: string): ISnapshotProcessor<IT, CustomC, CustomS>;
export {};
{
"name": "mobx-state-tree",
"version": "3.13.0",
"version": "3.14.0",
"description": "Opinionated, transactional, MobX powered state container",

@@ -5,0 +5,0 @@ "main": "dist/mobx-state-tree.js",

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

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