mobx-state-tree 3.14.1 → 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 +24 -4
- package/dist/core/action.d.ts +50 -50
- package/dist/core/actionContext.d.ts +27 -27
- 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 -451
- 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 -161
- package/dist/index.d.ts +3 -3
- package/dist/internal.d.ts +37 -37
- package/dist/middlewares/create-action-tracking-middleware.d.ts +24 -24
- package/dist/middlewares/createActionTrackingMiddleware2.d.ts +34 -34
- package/dist/middlewares/on-action.d.ts +87 -87
- package/dist/mobx-state-tree.js +6227 -6206
- package/dist/mobx-state-tree.min.js +16 -1
- package/dist/mobx-state-tree.module.js +6227 -6206
- package/dist/mobx-state-tree.umd.js +6206 -6207
- 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 -127
- 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 -41
- 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 +11 -9
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -64,6 +64,12 @@ Supported browsers:
|
|
|
64
64
|
- MobX-state-tree runs on any ES5 environment
|
|
65
65
|
- However, for MobX version 4 or 5 can be used. MobX 4 will run on any environment, MobX 5 only on modern browsers. See for more details the [MobX readme](https://github.com/mobxjs/mobx#browser-support)
|
|
66
66
|
|
|
67
|
+
Supported devtools:
|
|
68
|
+
|
|
69
|
+
- [Reactotron](https://github.com/infinitered/reactotron)
|
|
70
|
+
- [MobX DevTools](https://chrome.google.com/webstore/detail/mobx-developer-tools/pfgnfdagidkfgccljigdamigbcnndkod)
|
|
71
|
+
- The Redux can be connected as well as demonstrated [here](https://github.com/mobxjs/mobx-state-tree/blob/1906a394906d2e8f2cc1c778e1e3228307c1b112/packages/mst-example-redux-todomvc/src/index.js#L6)
|
|
72
|
+
|
|
67
73
|
# Getting started
|
|
68
74
|
|
|
69
75
|
See the [Getting started](https://github.com/mobxjs/mobx-state-tree/blob/master/docs/getting-started.md#getting-started) tutorial or follow the free [egghead.io course](https://egghead.io/courses/manage-application-state-with-mobx-state-tree) (note however that the course is for MST v2, so it might be a bit outdated).
|
|
@@ -946,7 +952,7 @@ const Todo = types
|
|
|
946
952
|
|
|
947
953
|
The object that is returned from the `volatile` initializer function can contain any piece of data and will result in an instance property with the same name. Volatile properties have the following characteristics:
|
|
948
954
|
|
|
949
|
-
1.
|
|
955
|
+
1. They can be read from outside the model (if you want hidden volatile state, keep the state in your closure as shown in the previous section, and _only_ if it is not used on a view consider not making it observable)
|
|
950
956
|
2. The volatile properties will be only observable, see [observable _references_](https://mobx.js.org/refguide/modifiers.html). Values assigned to them will be unmodified and not automatically converted to deep observable structures.
|
|
951
957
|
3. Like normal properties, they can only be modified through actions
|
|
952
958
|
4. Volatile props will not show up in snapshots, and cannot be updated by applying snapshots
|
|
@@ -1028,7 +1034,7 @@ Note that since MST v3 `types.array` and `types.map` are wrapped in `types.optio
|
|
|
1028
1034
|
## Utility types
|
|
1029
1035
|
|
|
1030
1036
|
- `types.union(options?: { dispatcher?: (snapshot) => Type, eager?: boolean }, types...)` create a union of multiple types. If the correct type cannot be inferred unambiguously from a snapshot, provide a dispatcher function to determine the type. When `eager` flag is set to `true` (default) - the first matching type will be used, if set to `false` the type check will pass only if exactly 1 type matches.
|
|
1031
|
-
- `types.optional(type, defaultValue, optionalValues?)` marks
|
|
1037
|
+
- `types.optional(type, defaultValue, optionalValues?)` marks a value as being optional (in e.g. a model). If a value is not provided/`undefined` (or set to any of the primitive values passed as an optional `optionalValues` array) the `defaultValue` will be used instead. If `defaultValue` is a function, it will be evaluated. This can be used to generate, for example, IDs or timestamps upon creation.
|
|
1032
1038
|
- `types.literal(value)` can be used to create a literal type, where the only possible value is specifically that value. This is very powerful in combination with `union`s. E.g. `temperature: types.union(types.literal("hot"), types.literal("cold"))`.
|
|
1033
1039
|
- `types.enumeration(name?, options: string[])` creates an enumeration. This method is a shorthand for a union of string literals. If you are using typescript and want to create a type based on an string enum (e.g. `enum Color { ... }`) then use `types.enumeration<Color>("Color", Object.values(Color))`, where the `"Color"` name argument is optional.
|
|
1034
1040
|
- `types.refinement(name?, baseType, (snapshot) => boolean)` creates a type that is more specific than the base type, e.g. `types.refinement(types.string, value => value.length > 5)` to create a type of strings that can only be longer then 5.
|
|
@@ -1121,6 +1127,21 @@ Note, except for `preProcessSnapshot` and `postProcessSnapshot`, all hooks shoul
|
|
|
1121
1127
|
|
|
1122
1128
|
All hooks can be defined multiple times and can be composed automatically.
|
|
1123
1129
|
|
|
1130
|
+
## LifeCycle hooks for `types.array`/`types.map`
|
|
1131
|
+
|
|
1132
|
+
Hooks for `types.array`/`types.map` can be defined by using the `.hooks(self => ({}))` method.
|
|
1133
|
+
|
|
1134
|
+
Calling `.hooks(...)` produces new type, same as calling `.actions()` for `types.model`.
|
|
1135
|
+
|
|
1136
|
+
Available hooks are:
|
|
1137
|
+
|
|
1138
|
+
| Hook | Meaning |
|
|
1139
|
+
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1140
|
+
| `afterCreate` | Immediately after an instance is initialized: right after `.create()` for root node or after the first access for the nested one. Children will fire this event before parents. You can't make assumptions about the parent safely, use `afterAttach` if you need to. |
|
|
1141
|
+
| `afterAttach` | As soon as the _direct_ parent is assigned (this node is attached to another node). If an element is created as part of a parent, `afterAttach` is also fired. Unlike `afterCreate`, `afterAttach` will fire breadth first. So, in `afterAttach` one can safely make assumptions about the parent, but in `afterCreate` not |
|
|
1142
|
+
| `beforeDetach` | As soon as the node is removed from the _direct_ parent, but only if the node is _not_ destroyed. In other words, when `detach(node)` is used |
|
|
1143
|
+
| `beforeDestroy` | Called before the node is destroyed, as a result of calling `destroy`, or by removing or replacing the node from the tree. Child destructors will fire before parents |
|
|
1144
|
+
|
|
1124
1145
|
# Api overview
|
|
1125
1146
|
|
|
1126
1147
|
See the [full API docs](docs/API/README.md) for more details.
|
|
@@ -1178,8 +1199,7 @@ See the [full API docs](docs/API/README.md) for more details.
|
|
|
1178
1199
|
| [`setLivelinessChecking("warn" \| "ignore" \| "error")`](docs/API/README.md#setlivelinesschecking) | 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 |
|
|
1179
1200
|
| [`getLivelinessChecking()`](docs/API/README.md#getlivelinesschecking) | Returns the current liveliness checking mode. |
|
|
1180
1201
|
| [`splitJsonPath(path)`](docs/API/README.md#splitjsonpath) | Splits and unescapes the given JSON `path` into path parts |
|
|
1181
|
-
| [`typecheck(type, value)`](docs/API/README.md#typecheck) | Typechecks a value against a type. Throws on errors. Use this if you need typechecks even in a production build.
|
|
1182
|
-
NOTE: set process.env.ENABLE_TYPE_CHECK = "true" if you want to enable typeChecking in any environment |
|
|
1202
|
+
| [`typecheck(type, value)`](docs/API/README.md#typecheck) | Typechecks a value against a type. Throws on errors. Use this if you need typechecks even in a production build. NOTE: set process.env.ENABLE_TYPE_CHECK = "true" if you want to enable type checking in any environment |
|
|
1183
1203
|
| [`tryResolve(node, path)`](docs/API/README.md#tryresolve) | Like `resolve`, but just returns `null` if resolving fails at any point in the path |
|
|
1184
1204
|
| [`tryReference(() => node \| null \| undefined, checkIfAlive = true)`](docs/API/README.md#tryreference) | Tests if a reference is valid (pointing to an existing node and optionally if alive) and returns such reference if it the check passes, else it returns undefined. |
|
|
1185
1205
|
| [`unprotect(node)`](docs/API/README.md#unprotect) | Unprotects `node`, making it possible to directly modify any value in the subtree, without actions |
|
package/dist/core/action.d.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { IDisposer, IAnyStateTreeNode, IActionContext } from "../internal";
|
|
2
|
-
export declare type IMiddlewareEventType = "action" | "flow_spawn" | "flow_resume" | "flow_resume_error" | "flow_return" | "flow_throw";
|
|
3
|
-
export interface IMiddlewareEvent extends IActionContext {
|
|
4
|
-
/** Event type */
|
|
5
|
-
readonly type: IMiddlewareEventType;
|
|
6
|
-
/** Parent event unique id */
|
|
7
|
-
readonly parentId: number;
|
|
8
|
-
/** Parent event object */
|
|
9
|
-
readonly parentEvent: IMiddlewareEvent | undefined;
|
|
10
|
-
/** Root event unique id */
|
|
11
|
-
readonly rootId: number;
|
|
12
|
-
/** Id of all events, from root until current (excluding current) */
|
|
13
|
-
readonly allParentIds: number[];
|
|
14
|
-
}
|
|
15
|
-
export declare type IMiddlewareHandler = (actionCall: IMiddlewareEvent, next: (actionCall: IMiddlewareEvent, callback?: (value: any) => any) => void, abort: (value: any) => void) => any;
|
|
16
|
-
/**
|
|
17
|
-
* Middleware can be used to intercept any action is invoked on the subtree where it is attached.
|
|
18
|
-
* If a tree is protected (by default), this means that any mutation of the tree will pass through your middleware.
|
|
19
|
-
*
|
|
20
|
-
* For more details, see the [middleware docs](../middleware.md)
|
|
21
|
-
*
|
|
22
|
-
* @param target Node to apply the middleware to.
|
|
23
|
-
* @param middleware Middleware to apply.
|
|
24
|
-
* @returns A callable function to dispose the middleware.
|
|
25
|
-
*/
|
|
26
|
-
export declare function addMiddleware(target: IAnyStateTreeNode, handler: IMiddlewareHandler, includeHooks?: boolean): IDisposer;
|
|
27
|
-
/**
|
|
28
|
-
* Binds middleware to a specific action.
|
|
29
|
-
*
|
|
30
|
-
* Example:
|
|
31
|
-
* ```ts
|
|
32
|
-
* type.actions(self => {
|
|
33
|
-
* function takeA____() {
|
|
34
|
-
* self.toilet.donate()
|
|
35
|
-
* self.wipe()
|
|
36
|
-
* self.wipe()
|
|
37
|
-
* self.toilet.flush()
|
|
38
|
-
* }
|
|
39
|
-
* return {
|
|
40
|
-
* takeA____: decorate(atomic, takeA____)
|
|
41
|
-
* }
|
|
42
|
-
* })
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @param handler
|
|
46
|
-
* @param fn
|
|
47
|
-
* @param includeHooks
|
|
48
|
-
* @returns The original function
|
|
49
|
-
*/
|
|
50
|
-
export declare function decorate<T extends Function>(handler: IMiddlewareHandler, fn: T, includeHooks?: boolean): T;
|
|
1
|
+
import { IDisposer, IAnyStateTreeNode, IActionContext } from "../internal";
|
|
2
|
+
export declare type IMiddlewareEventType = "action" | "flow_spawn" | "flow_resume" | "flow_resume_error" | "flow_return" | "flow_throw";
|
|
3
|
+
export interface IMiddlewareEvent extends IActionContext {
|
|
4
|
+
/** Event type */
|
|
5
|
+
readonly type: IMiddlewareEventType;
|
|
6
|
+
/** Parent event unique id */
|
|
7
|
+
readonly parentId: number;
|
|
8
|
+
/** Parent event object */
|
|
9
|
+
readonly parentEvent: IMiddlewareEvent | undefined;
|
|
10
|
+
/** Root event unique id */
|
|
11
|
+
readonly rootId: number;
|
|
12
|
+
/** Id of all events, from root until current (excluding current) */
|
|
13
|
+
readonly allParentIds: number[];
|
|
14
|
+
}
|
|
15
|
+
export declare type IMiddlewareHandler = (actionCall: IMiddlewareEvent, next: (actionCall: IMiddlewareEvent, callback?: (value: any) => any) => void, abort: (value: any) => void) => any;
|
|
16
|
+
/**
|
|
17
|
+
* Middleware can be used to intercept any action is invoked on the subtree where it is attached.
|
|
18
|
+
* If a tree is protected (by default), this means that any mutation of the tree will pass through your middleware.
|
|
19
|
+
*
|
|
20
|
+
* For more details, see the [middleware docs](../middleware.md)
|
|
21
|
+
*
|
|
22
|
+
* @param target Node to apply the middleware to.
|
|
23
|
+
* @param middleware Middleware to apply.
|
|
24
|
+
* @returns A callable function to dispose the middleware.
|
|
25
|
+
*/
|
|
26
|
+
export declare function addMiddleware(target: IAnyStateTreeNode, handler: IMiddlewareHandler, includeHooks?: boolean): IDisposer;
|
|
27
|
+
/**
|
|
28
|
+
* Binds middleware to a specific action.
|
|
29
|
+
*
|
|
30
|
+
* Example:
|
|
31
|
+
* ```ts
|
|
32
|
+
* type.actions(self => {
|
|
33
|
+
* function takeA____() {
|
|
34
|
+
* self.toilet.donate()
|
|
35
|
+
* self.wipe()
|
|
36
|
+
* self.wipe()
|
|
37
|
+
* self.toilet.flush()
|
|
38
|
+
* }
|
|
39
|
+
* return {
|
|
40
|
+
* takeA____: decorate(atomic, takeA____)
|
|
41
|
+
* }
|
|
42
|
+
* })
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @param handler
|
|
46
|
+
* @param fn
|
|
47
|
+
* @param includeHooks
|
|
48
|
+
* @returns The original function
|
|
49
|
+
*/
|
|
50
|
+
export declare function decorate<T extends Function>(handler: IMiddlewareHandler, fn: T, includeHooks?: boolean): T;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { IAnyStateTreeNode, IMiddlewareEvent } from "../internal";
|
|
2
|
-
export interface IActionContext {
|
|
3
|
-
/** Event name (action name for actions) */
|
|
4
|
-
readonly name: string;
|
|
5
|
-
/** Event unique id */
|
|
6
|
-
readonly id: number;
|
|
7
|
-
/** Parent action event object */
|
|
8
|
-
readonly parentActionEvent: IMiddlewareEvent | undefined;
|
|
9
|
-
/** Event context (node where the action was invoked) */
|
|
10
|
-
readonly context: IAnyStateTreeNode;
|
|
11
|
-
/** Event tree (root node of the node where the action was invoked) */
|
|
12
|
-
readonly tree: IAnyStateTreeNode;
|
|
13
|
-
/** Event arguments in an array (action arguments for actions) */
|
|
14
|
-
readonly args: any[];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Returns the currently executing MST action context, or undefined if none.
|
|
18
|
-
*/
|
|
19
|
-
export declare function getRunningActionContext(): IActionContext | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Returns if the given action context is a parent of this action context.
|
|
22
|
-
*/
|
|
23
|
-
export declare function isActionContextChildOf(actionContext: IActionContext, parent: number | IActionContext | IMiddlewareEvent): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Returns if the given action context is this or a parent of this action context.
|
|
26
|
-
*/
|
|
27
|
-
export declare function isActionContextThisOrChildOf(actionContext: IActionContext, parentOrThis: number | IActionContext | IMiddlewareEvent): boolean;
|
|
1
|
+
import { IAnyStateTreeNode, IMiddlewareEvent } from "../internal";
|
|
2
|
+
export interface IActionContext {
|
|
3
|
+
/** Event name (action name for actions) */
|
|
4
|
+
readonly name: string;
|
|
5
|
+
/** Event unique id */
|
|
6
|
+
readonly id: number;
|
|
7
|
+
/** Parent action event object */
|
|
8
|
+
readonly parentActionEvent: IMiddlewareEvent | undefined;
|
|
9
|
+
/** Event context (node where the action was invoked) */
|
|
10
|
+
readonly context: IAnyStateTreeNode;
|
|
11
|
+
/** Event tree (root node of the node where the action was invoked) */
|
|
12
|
+
readonly tree: IAnyStateTreeNode;
|
|
13
|
+
/** Event arguments in an array (action arguments for actions) */
|
|
14
|
+
readonly args: any[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the currently executing MST action context, or undefined if none.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getRunningActionContext(): IActionContext | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Returns if the given action context is a parent of this action context.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isActionContextChildOf(actionContext: IActionContext, parent: number | IActionContext | IMiddlewareEvent): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns if the given action context is this or a parent of this action context.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isActionContextThisOrChildOf(actionContext: IActionContext, parentOrThis: number | IActionContext | IMiddlewareEvent): boolean;
|
package/dist/core/flow.d.ts
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare
|
|
15
|
-
/** @hidden */
|
|
16
|
-
export declare type IfAllAreFlowYieldThenVoid<R> = Exclude<R, FlowYield> extends never ? void : Exclude<R, FlowYield>;
|
|
17
|
-
/**
|
|
18
|
-
* See [asynchronous actions](https://github.com/mobxjs/mobx-state-tree/blob/master/docs/async-actions.md).
|
|
19
|
-
*
|
|
20
|
-
* @returns The flow as a promise.
|
|
21
|
-
*/
|
|
22
|
-
export declare function flow<R, Args extends any[]>(generator: (...args: Args) => IterableIterator<R>): (...args: Args) => Promise<FlowReturnType<R>>;
|
|
23
|
-
/**
|
|
24
|
-
* Used for TypeScript to make flows that return a promise return the actual promise result.
|
|
25
|
-
*
|
|
26
|
-
* @param val
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
export declare function castFlowReturn<T>(val: T): FlowReturn<T>;
|
|
30
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* See [asynchronous actions](https://github.com/mobxjs/mobx-state-tree/blob/master/docs/async-actions.md).
|
|
3
|
+
*
|
|
4
|
+
* @returns The flow as a promise.
|
|
5
|
+
*/
|
|
6
|
+
export declare function flow<R, Args extends any[]>(generator: (...args: Args) => Generator<any, R, any>): (...args: Args) => Promise<R>;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Not needed since TS3.6.
|
|
9
|
+
* Used for TypeScript to make flows that return a promise return the actual promise result.
|
|
10
|
+
*
|
|
11
|
+
* @param val
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function castFlowReturn<T>(val: T): T;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://tools.ietf.org/html/rfc6902
|
|
3
|
-
* http://jsonpatch.com/
|
|
4
|
-
*/
|
|
5
|
-
export interface IJsonPatch {
|
|
6
|
-
readonly op: "replace" | "add" | "remove";
|
|
7
|
-
readonly path: string;
|
|
8
|
-
readonly value?: any;
|
|
9
|
-
}
|
|
10
|
-
export interface IReversibleJsonPatch extends IJsonPatch {
|
|
11
|
-
readonly oldValue: any;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Escape slashes and backslashes.
|
|
15
|
-
*
|
|
16
|
-
* http://tools.ietf.org/html/rfc6901
|
|
17
|
-
*/
|
|
18
|
-
export declare function escapeJsonPath(path: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Unescape slashes and backslashes.
|
|
21
|
-
*/
|
|
22
|
-
export declare function unescapeJsonPath(path: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* Generates a json-path compliant json path from path parts.
|
|
25
|
-
*
|
|
26
|
-
* @param path
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
export declare function joinJsonPath(path: string[]): string;
|
|
30
|
-
/**
|
|
31
|
-
* Splits and decodes a json path into several parts.
|
|
32
|
-
*
|
|
33
|
-
* @param path
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
export declare function splitJsonPath(path: string): string[];
|
|
1
|
+
/**
|
|
2
|
+
* https://tools.ietf.org/html/rfc6902
|
|
3
|
+
* http://jsonpatch.com/
|
|
4
|
+
*/
|
|
5
|
+
export interface IJsonPatch {
|
|
6
|
+
readonly op: "replace" | "add" | "remove";
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly value?: any;
|
|
9
|
+
}
|
|
10
|
+
export interface IReversibleJsonPatch extends IJsonPatch {
|
|
11
|
+
readonly oldValue: any;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Escape slashes and backslashes.
|
|
15
|
+
*
|
|
16
|
+
* http://tools.ietf.org/html/rfc6901
|
|
17
|
+
*/
|
|
18
|
+
export declare function escapeJsonPath(path: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Unescape slashes and backslashes.
|
|
21
|
+
*/
|
|
22
|
+
export declare function unescapeJsonPath(path: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generates a json-path compliant json path from path parts.
|
|
25
|
+
*
|
|
26
|
+
* @param path
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export declare function joinJsonPath(path: string[]): string;
|
|
30
|
+
/**
|
|
31
|
+
* Splits and decodes a json path into several parts.
|
|
32
|
+
*
|
|
33
|
+
* @param path
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
export declare function splitJsonPath(path: string): string[];
|