mobx-state-tree 3.12.2 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -23
- package/dist/core/action.d.ts +50 -48
- package/dist/core/actionContext.d.ts +27 -0
- package/dist/core/flow.d.ts +14 -30
- package/dist/core/json-patch.d.ts +36 -36
- package/dist/core/mst-operations.d.ts +451 -444
- package/dist/core/node/BaseNode.d.ts +1 -1
- package/dist/core/node/Hook.d.ts +17 -1
- package/dist/core/node/create-node.d.ts +1 -1
- package/dist/core/node/identifier-cache.d.ts +1 -1
- package/dist/core/node/livelinessChecking.d.ts +37 -37
- package/dist/core/node/node-utils.d.ts +28 -28
- package/dist/core/node/object-node.d.ts +1 -1
- package/dist/core/node/scalar-node.d.ts +1 -1
- package/dist/core/process.d.ts +45 -45
- package/dist/core/type/type-checker.d.ts +30 -30
- package/dist/core/type/type.d.ts +162 -177
- package/dist/index.d.ts +3 -3
- package/dist/internal.d.ts +37 -35
- package/dist/middlewares/create-action-tracking-middleware.d.ts +24 -22
- package/dist/middlewares/createActionTrackingMiddleware2.d.ts +34 -0
- package/dist/middlewares/on-action.d.ts +87 -79
- package/dist/mobx-state-tree.js +6285 -5985
- package/dist/mobx-state-tree.min.js +16 -1
- package/dist/mobx-state-tree.module.js +6234 -5938
- package/dist/mobx-state-tree.umd.js +6263 -5985
- package/dist/mobx-state-tree.umd.min.js +16 -1
- package/dist/types/complex-types/array.d.ts +52 -51
- package/dist/types/complex-types/map.d.ts +80 -79
- package/dist/types/complex-types/model.d.ts +133 -125
- package/dist/types/index.d.ts +29 -29
- package/dist/types/primitives.d.ts +81 -81
- package/dist/types/utility-types/custom.d.ts +60 -60
- package/dist/types/utility-types/enumeration.d.ts +5 -5
- package/dist/types/utility-types/frozen.d.ts +11 -11
- package/dist/types/utility-types/identifier.d.ts +44 -44
- package/dist/types/utility-types/late.d.ts +10 -10
- package/dist/types/utility-types/literal.d.ts +25 -25
- package/dist/types/utility-types/maybe.d.ts +26 -26
- package/dist/types/utility-types/optional.d.ts +20 -20
- package/dist/types/utility-types/reference.d.ts +41 -47
- package/dist/types/utility-types/refinement.d.ts +10 -10
- package/dist/types/utility-types/snapshotProcessor.d.ts +61 -61
- package/dist/types/utility-types/union.d.ts +55 -55
- package/dist/utils.d.ts +4 -4
- package/package.json +16 -12
package/dist/core/type/type.d.ts
CHANGED
|
@@ -1,177 +1,162 @@
|
|
|
1
|
-
import { IValidationContext, IValidationResult, IStateTreeNode, ModelPrimitive } from "../../internal";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @hidden
|
|
5
|
-
*/
|
|
6
|
-
export declare type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* @
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
* @
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
export declare type
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
*
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
*
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
*
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
* setInnerModel(m: SnapshotOrInstance<typeof self.innerModel>) {
|
|
164
|
-
* self.innerModel = cast(m)
|
|
165
|
-
* }
|
|
166
|
-
* }))
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
export declare type SnapshotOrInstance<T> = SnapshotIn<T> | Instance<T>;
|
|
170
|
-
/**
|
|
171
|
-
* Returns if a given value represents a type.
|
|
172
|
-
*
|
|
173
|
-
* @param value Value to check.
|
|
174
|
-
* @returns `true` if the value is a type.
|
|
175
|
-
*/
|
|
176
|
-
export declare function isType(value: any): value is IAnyType;
|
|
177
|
-
export {};
|
|
1
|
+
import { IValidationContext, IValidationResult, IStateTreeNode, ModelPrimitive } from "../../internal";
|
|
2
|
+
/**
|
|
3
|
+
* A state tree node value.
|
|
4
|
+
* @hidden
|
|
5
|
+
*/
|
|
6
|
+
export declare type STNValue<T, IT extends IAnyType> = T extends object ? T & IStateTreeNode<IT> : T;
|
|
7
|
+
/** @hidden */
|
|
8
|
+
declare const $type: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* A type, either complex or simple.
|
|
11
|
+
*/
|
|
12
|
+
export interface IType<C, S, T> {
|
|
13
|
+
/** @hidden */
|
|
14
|
+
readonly [$type]: undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Friendly type name.
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* Name of the identifier attribute or null if none.
|
|
21
|
+
*/
|
|
22
|
+
readonly identifierAttribute?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an instance for the type given an snapshot input.
|
|
25
|
+
*
|
|
26
|
+
* @returns An instance of that type.
|
|
27
|
+
*/
|
|
28
|
+
create(snapshot?: C, env?: any): this["Type"];
|
|
29
|
+
/**
|
|
30
|
+
* Checks if a given snapshot / instance is of the given type.
|
|
31
|
+
*
|
|
32
|
+
* @param thing Snapshot or instance to be checked.
|
|
33
|
+
* @returns true if the value is of the current type, false otherwise.
|
|
34
|
+
*/
|
|
35
|
+
is(thing: any): thing is C | this["Type"];
|
|
36
|
+
/**
|
|
37
|
+
* Run's the type's typechecker on the given value with the given validation context.
|
|
38
|
+
*
|
|
39
|
+
* @param thing Value to be checked, either a snapshot or an instance.
|
|
40
|
+
* @param context Validation context, an array of { subpaths, subtypes } that should be validated
|
|
41
|
+
* @returns The validation result, an array with the list of validation errors.
|
|
42
|
+
*/
|
|
43
|
+
validate(thing: C, context: IValidationContext): IValidationResult;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the textual representation of the type as a string.
|
|
46
|
+
*/
|
|
47
|
+
describe(): string;
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated use `Instance<typeof MyType>` instead.
|
|
50
|
+
* @hidden
|
|
51
|
+
*/
|
|
52
|
+
readonly Type: STNValue<T, this>;
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated do not use.
|
|
55
|
+
* @hidden
|
|
56
|
+
*/
|
|
57
|
+
readonly TypeWithoutSTN: T;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated use `SnapshotOut<typeof MyType>` instead.
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
62
|
+
readonly SnapshotType: S;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated use `SnapshotIn<typeof MyType>` instead.
|
|
65
|
+
* @hidden
|
|
66
|
+
*/
|
|
67
|
+
readonly CreationType: C;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Any kind of type.
|
|
71
|
+
*/
|
|
72
|
+
export interface IAnyType extends IType<any, any, any> {
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A simple type, this is, a type where the instance and the snapshot representation are the same.
|
|
76
|
+
*/
|
|
77
|
+
export interface ISimpleType<T> extends IType<T, T, T> {
|
|
78
|
+
}
|
|
79
|
+
/** @hidden */
|
|
80
|
+
export declare type Primitives = ModelPrimitive | null | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* A complex type.
|
|
83
|
+
* @deprecated just for compatibility with old versions, could be deprecated on the next major version
|
|
84
|
+
* @hidden
|
|
85
|
+
*/
|
|
86
|
+
export interface IComplexType<C, S, T> extends IType<C, S, T & object> {
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Any kind of complex type.
|
|
90
|
+
*/
|
|
91
|
+
export interface IAnyComplexType extends IType<any, any, object> {
|
|
92
|
+
}
|
|
93
|
+
/** @hidden */
|
|
94
|
+
export declare type ExtractCSTWithoutSTN<IT extends {
|
|
95
|
+
[$type]: undefined;
|
|
96
|
+
CreationType: any;
|
|
97
|
+
SnapshotType: any;
|
|
98
|
+
TypeWithoutSTN: any;
|
|
99
|
+
}> = IT["CreationType"] | IT["SnapshotType"] | IT["TypeWithoutSTN"];
|
|
100
|
+
/** @hidden */
|
|
101
|
+
export declare type ExtractCSTWithSTN<IT extends {
|
|
102
|
+
[$type]: undefined;
|
|
103
|
+
CreationType: any;
|
|
104
|
+
SnapshotType: any;
|
|
105
|
+
Type: any;
|
|
106
|
+
}> = IT["CreationType"] | IT["SnapshotType"] | IT["Type"];
|
|
107
|
+
/**
|
|
108
|
+
* The instance representation of a given type.
|
|
109
|
+
*/
|
|
110
|
+
export declare type Instance<T> = T extends {
|
|
111
|
+
[$type]: undefined;
|
|
112
|
+
Type: any;
|
|
113
|
+
} ? T["Type"] : T;
|
|
114
|
+
/**
|
|
115
|
+
* The input (creation) snapshot representation of a given type.
|
|
116
|
+
*/
|
|
117
|
+
export declare type SnapshotIn<T> = T extends {
|
|
118
|
+
[$type]: undefined;
|
|
119
|
+
CreationType: any;
|
|
120
|
+
} ? T["CreationType"] : T extends IStateTreeNode<infer IT> ? IT["CreationType"] : T;
|
|
121
|
+
/**
|
|
122
|
+
* The output snapshot representation of a given type.
|
|
123
|
+
*/
|
|
124
|
+
export declare type SnapshotOut<T> = T extends {
|
|
125
|
+
[$type]: undefined;
|
|
126
|
+
SnapshotType: any;
|
|
127
|
+
} ? T["SnapshotType"] : T extends IStateTreeNode<infer IT> ? IT["SnapshotType"] : T;
|
|
128
|
+
/**
|
|
129
|
+
* A type which is equivalent to the union of SnapshotIn and Instance types of a given typeof TYPE or typeof VARIABLE.
|
|
130
|
+
* For primitives it defaults to the primitive itself.
|
|
131
|
+
*
|
|
132
|
+
* For example:
|
|
133
|
+
* - `SnapshotOrInstance<typeof ModelA> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`
|
|
134
|
+
* - `SnapshotOrInstance<typeof self.a (where self.a is a ModelA)> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`
|
|
135
|
+
*
|
|
136
|
+
* Usually you might want to use this when your model has a setter action that sets a property.
|
|
137
|
+
*
|
|
138
|
+
* Example:
|
|
139
|
+
* ```ts
|
|
140
|
+
* const ModelA = types.model({
|
|
141
|
+
* n: types.number
|
|
142
|
+
* })
|
|
143
|
+
*
|
|
144
|
+
* const ModelB = types.model({
|
|
145
|
+
* innerModel: ModelA
|
|
146
|
+
* }).actions(self => ({
|
|
147
|
+
* // this will accept as property both the snapshot and the instance, whichever is preferred
|
|
148
|
+
* setInnerModel(m: SnapshotOrInstance<typeof self.innerModel>) {
|
|
149
|
+
* self.innerModel = cast(m)
|
|
150
|
+
* }
|
|
151
|
+
* }))
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export declare type SnapshotOrInstance<T> = SnapshotIn<T> | Instance<T>;
|
|
155
|
+
/**
|
|
156
|
+
* Returns if a given value represents a type.
|
|
157
|
+
*
|
|
158
|
+
* @param value Value to check.
|
|
159
|
+
* @returns `true` if the value is a type.
|
|
160
|
+
*/
|
|
161
|
+
export declare function isType(value: any): value is IAnyType;
|
|
162
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
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, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, IAnyStateTreeNode, flow, castFlowReturn, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware, setLivelinessChecking, getLivelinessChecking, LivelinessMode, setLivelynessChecking, // to be deprecated
|
|
2
|
-
LivelynessMode, // to be deprecated
|
|
3
|
-
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,
|
|
1
|
+
export { IModelType, IAnyModelType, IDisposer, IMSTMap, IMapType, IMSTArray, IArrayType, IType, IAnyType, ModelPrimitive, 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
|
|
2
|
+
LivelynessMode, // to be deprecated
|
|
3
|
+
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";
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
export * from "./core/node/livelinessChecking";
|
|
2
|
-
export * from "./core/node/Hook";
|
|
3
|
-
export * from "./core/mst-operations";
|
|
4
|
-
export * from "./core/node/BaseNode";
|
|
5
|
-
export * from "./core/node/scalar-node";
|
|
6
|
-
export * from "./core/node/object-node";
|
|
7
|
-
export * from "./core/type/type";
|
|
8
|
-
export * from "./middlewares/create-action-tracking-middleware";
|
|
9
|
-
export * from "./middlewares/
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./core/
|
|
12
|
-
export * from "./core/
|
|
13
|
-
export * from "./core/
|
|
14
|
-
export * from "./core/node/
|
|
15
|
-
export * from "./core/
|
|
16
|
-
export * from "./core/
|
|
17
|
-
export * from "./core/
|
|
18
|
-
export * from "./
|
|
19
|
-
export * from "./
|
|
20
|
-
export * from "./
|
|
21
|
-
export * from "./types/
|
|
22
|
-
export * from "./types/complex-types/
|
|
23
|
-
export * from "./types/
|
|
24
|
-
export * from "./types/
|
|
25
|
-
export * from "./types/
|
|
26
|
-
export * from "./types/utility-types/
|
|
27
|
-
export * from "./types/utility-types/
|
|
28
|
-
export * from "./types/utility-types/
|
|
29
|
-
export * from "./types/utility-types/
|
|
30
|
-
export * from "./types/utility-types/
|
|
31
|
-
export * from "./types/utility-types/
|
|
32
|
-
export * from "./types/utility-types/
|
|
33
|
-
export * from "./types/utility-types/
|
|
34
|
-
export * from "./types/utility-types/
|
|
35
|
-
export * from "./types";
|
|
1
|
+
export * from "./core/node/livelinessChecking";
|
|
2
|
+
export * from "./core/node/Hook";
|
|
3
|
+
export * from "./core/mst-operations";
|
|
4
|
+
export * from "./core/node/BaseNode";
|
|
5
|
+
export * from "./core/node/scalar-node";
|
|
6
|
+
export * from "./core/node/object-node";
|
|
7
|
+
export * from "./core/type/type";
|
|
8
|
+
export * from "./middlewares/create-action-tracking-middleware";
|
|
9
|
+
export * from "./middlewares/createActionTrackingMiddleware2";
|
|
10
|
+
export * from "./middlewares/on-action";
|
|
11
|
+
export * from "./core/action";
|
|
12
|
+
export * from "./core/actionContext";
|
|
13
|
+
export * from "./core/type/type-checker";
|
|
14
|
+
export * from "./core/node/identifier-cache";
|
|
15
|
+
export * from "./core/node/create-node";
|
|
16
|
+
export * from "./core/node/node-utils";
|
|
17
|
+
export * from "./core/process";
|
|
18
|
+
export * from "./core/flow";
|
|
19
|
+
export * from "./core/json-patch";
|
|
20
|
+
export * from "./utils";
|
|
21
|
+
export * from "./types/utility-types/snapshotProcessor";
|
|
22
|
+
export * from "./types/complex-types/map";
|
|
23
|
+
export * from "./types/complex-types/array";
|
|
24
|
+
export * from "./types/complex-types/model";
|
|
25
|
+
export * from "./types/primitives";
|
|
26
|
+
export * from "./types/utility-types/literal";
|
|
27
|
+
export * from "./types/utility-types/refinement";
|
|
28
|
+
export * from "./types/utility-types/enumeration";
|
|
29
|
+
export * from "./types/utility-types/union";
|
|
30
|
+
export * from "./types/utility-types/optional";
|
|
31
|
+
export * from "./types/utility-types/maybe";
|
|
32
|
+
export * from "./types/utility-types/late";
|
|
33
|
+
export * from "./types/utility-types/frozen";
|
|
34
|
+
export * from "./types/utility-types/reference";
|
|
35
|
+
export * from "./types/utility-types/identifier";
|
|
36
|
+
export * from "./types/utility-types/custom";
|
|
37
|
+
export * from "./types";
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { IMiddlewareEvent, IMiddlewareHandler } from "../internal";
|
|
2
|
-
export interface IActionTrackingMiddlewareHooks<T> {
|
|
3
|
-
filter?: (call: IMiddlewareEvent) => boolean;
|
|
4
|
-
onStart: (call: IMiddlewareEvent) => T;
|
|
5
|
-
onResume: (call: IMiddlewareEvent, context: T) => void;
|
|
6
|
-
onSuspend: (call: IMiddlewareEvent, context: T) => void;
|
|
7
|
-
onSuccess: (call: IMiddlewareEvent, context: T, result: any) => void;
|
|
8
|
-
onFail: (call: IMiddlewareEvent, context: T, error: any) => void;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { IMiddlewareEvent, IMiddlewareHandler } from "../internal";
|
|
2
|
+
export interface IActionTrackingMiddlewareHooks<T> {
|
|
3
|
+
filter?: (call: IMiddlewareEvent) => boolean;
|
|
4
|
+
onStart: (call: IMiddlewareEvent) => T;
|
|
5
|
+
onResume: (call: IMiddlewareEvent, context: T) => void;
|
|
6
|
+
onSuspend: (call: IMiddlewareEvent, context: T) => void;
|
|
7
|
+
onSuccess: (call: IMiddlewareEvent, context: T, result: any) => void;
|
|
8
|
+
onFail: (call: IMiddlewareEvent, context: T, error: any) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Note: Consider migrating to `createActionTrackingMiddleware2`, it is easier to use.
|
|
12
|
+
*
|
|
13
|
+
* Convenience utility to create action based middleware that supports async processes more easily.
|
|
14
|
+
* All hooks are called for both synchronous and asynchronous actions. Except that either `onSuccess` or `onFail` is called
|
|
15
|
+
*
|
|
16
|
+
* The create middleware tracks the process of an action (assuming it passes the `filter`).
|
|
17
|
+
* `onResume` can return any value, which will be passed as second argument to any other hook. This makes it possible to keep state during a process.
|
|
18
|
+
*
|
|
19
|
+
* See the `atomic` middleware for an example
|
|
20
|
+
*
|
|
21
|
+
* @param hooks
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare function createActionTrackingMiddleware<T = any>(hooks: IActionTrackingMiddlewareHooks<T>): IMiddlewareHandler;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IMiddlewareHandler, IActionContext } from "../internal";
|
|
2
|
+
export interface IActionTrackingMiddleware2Call<TEnv> extends Readonly<IActionContext> {
|
|
3
|
+
env: TEnv | undefined;
|
|
4
|
+
readonly parentCall?: IActionTrackingMiddleware2Call<TEnv>;
|
|
5
|
+
}
|
|
6
|
+
export interface IActionTrackingMiddleware2Hooks<TEnv> {
|
|
7
|
+
filter?: (call: IActionTrackingMiddleware2Call<TEnv>) => boolean;
|
|
8
|
+
onStart: (call: IActionTrackingMiddleware2Call<TEnv>) => void;
|
|
9
|
+
onFinish: (call: IActionTrackingMiddleware2Call<TEnv>, error?: any) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Convenience utility to create action based middleware that supports async processes more easily.
|
|
13
|
+
* The flow is like this:
|
|
14
|
+
* - for each action: if filter passes -> `onStart` -> (inner actions recursively) -> `onFinish`
|
|
15
|
+
*
|
|
16
|
+
* Example: if we had an action `a` that called inside an action `b1`, then `b2` the flow would be:
|
|
17
|
+
* - `filter(a)`
|
|
18
|
+
* - `onStart(a)`
|
|
19
|
+
* - `filter(b1)`
|
|
20
|
+
* - `onStart(b1)`
|
|
21
|
+
* - `onFinish(b1)`
|
|
22
|
+
* - `filter(b2)`
|
|
23
|
+
* - `onStart(b2)`
|
|
24
|
+
* - `onFinish(b2)`
|
|
25
|
+
* - `onFinish(a)`
|
|
26
|
+
*
|
|
27
|
+
* The flow is the same no matter if the actions are sync or async.
|
|
28
|
+
*
|
|
29
|
+
* See the `atomic` middleware for an example
|
|
30
|
+
*
|
|
31
|
+
* @param hooks
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare function createActionTrackingMiddleware2<TEnv = any>(middlewareHooks: IActionTrackingMiddleware2Hooks<TEnv>): IMiddlewareHandler;
|