@jbrowse/mobx-state-tree 5.7.1 → 5.8.7

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.
Files changed (253) hide show
  1. package/README.md +0 -10
  2. package/dist/index.d.ts +2135 -2
  3. package/dist/mobx-state-tree.cjs +6894 -0
  4. package/dist/mobx-state-tree.cjs.map +1 -0
  5. package/dist/mobx-state-tree.mjs +6814 -0
  6. package/dist/mobx-state-tree.mjs.map +1 -0
  7. package/package.json +30 -26
  8. package/dist/core/action.d.ts +0 -87
  9. package/dist/core/action.js +0 -228
  10. package/dist/core/action.js.map +0 -1
  11. package/dist/core/actionContext.d.ts +0 -27
  12. package/dist/core/actionContext.js +0 -42
  13. package/dist/core/actionContext.js.map +0 -1
  14. package/dist/core/flow.d.ts +0 -69
  15. package/dist/core/flow.js +0 -180
  16. package/dist/core/flow.js.map +0 -1
  17. package/dist/core/json-patch.d.ts +0 -46
  18. package/dist/core/json-patch.js +0 -133
  19. package/dist/core/json-patch.js.map +0 -1
  20. package/dist/core/mst-operations.d.ts +0 -459
  21. package/dist/core/mst-operations.js +0 -885
  22. package/dist/core/mst-operations.js.map +0 -1
  23. package/dist/core/node/BaseNode.d.ts +0 -62
  24. package/dist/core/node/BaseNode.js +0 -152
  25. package/dist/core/node/BaseNode.js.map +0 -1
  26. package/dist/core/node/Hook.d.ts +0 -17
  27. package/dist/core/node/Hook.js +0 -15
  28. package/dist/core/node/Hook.js.map +0 -1
  29. package/dist/core/node/create-node.d.ts +0 -16
  30. package/dist/core/node/create-node.js +0 -41
  31. package/dist/core/node/create-node.js.map +0 -1
  32. package/dist/core/node/identifier-cache.d.ts +0 -19
  33. package/dist/core/node/identifier-cache.js +0 -115
  34. package/dist/core/node/identifier-cache.js.map +0 -1
  35. package/dist/core/node/livelinessChecking.d.ts +0 -37
  36. package/dist/core/node/livelinessChecking.js +0 -38
  37. package/dist/core/node/livelinessChecking.js.map +0 -1
  38. package/dist/core/node/node-utils.d.ts +0 -83
  39. package/dist/core/node/node-utils.js +0 -165
  40. package/dist/core/node/node-utils.js.map +0 -1
  41. package/dist/core/node/object-node.d.ts +0 -101
  42. package/dist/core/node/object-node.js +0 -546
  43. package/dist/core/node/object-node.js.map +0 -1
  44. package/dist/core/node/scalar-node.d.ts +0 -21
  45. package/dist/core/node/scalar-node.js +0 -90
  46. package/dist/core/node/scalar-node.js.map +0 -1
  47. package/dist/core/process.d.ts +0 -50
  48. package/dist/core/process.js +0 -39
  49. package/dist/core/process.js.map +0 -1
  50. package/dist/core/type/type-checker.d.ts +0 -69
  51. package/dist/core/type/type-checker.js +0 -154
  52. package/dist/core/type/type-checker.js.map +0 -1
  53. package/dist/core/type/type.d.ts +0 -317
  54. package/dist/core/type/type.js +0 -251
  55. package/dist/core/type/type.js.map +0 -1
  56. package/dist/index.js +0 -85
  57. package/dist/index.js.map +0 -1
  58. package/dist/internal.d.ts +0 -39
  59. package/dist/internal.js +0 -60
  60. package/dist/internal.js.map +0 -1
  61. package/dist/middlewares/create-action-tracking-middleware.d.ts +0 -24
  62. package/dist/middlewares/create-action-tracking-middleware.js +0 -81
  63. package/dist/middlewares/create-action-tracking-middleware.js.map +0 -1
  64. package/dist/middlewares/createActionTrackingMiddleware2.d.ts +0 -34
  65. package/dist/middlewares/createActionTrackingMiddleware2.js +0 -133
  66. package/dist/middlewares/createActionTrackingMiddleware2.js.map +0 -1
  67. package/dist/middlewares/on-action.d.ts +0 -87
  68. package/dist/middlewares/on-action.js +0 -215
  69. package/dist/middlewares/on-action.js.map +0 -1
  70. package/dist/package.json +0 -1
  71. package/dist/types/complex-types/array.d.ts +0 -81
  72. package/dist/types/complex-types/array.js +0 -353
  73. package/dist/types/complex-types/array.js.map +0 -1
  74. package/dist/types/complex-types/map.d.ts +0 -111
  75. package/dist/types/complex-types/map.js +0 -362
  76. package/dist/types/complex-types/map.js.map +0 -1
  77. package/dist/types/complex-types/model.d.ts +0 -193
  78. package/dist/types/complex-types/model.js +0 -478
  79. package/dist/types/complex-types/model.js.map +0 -1
  80. package/dist/types/index.d.ts +0 -33
  81. package/dist/types/index.js +0 -38
  82. package/dist/types/index.js.map +0 -1
  83. package/dist/types/primitives.d.ts +0 -125
  84. package/dist/types/primitives.js +0 -183
  85. package/dist/types/primitives.js.map +0 -1
  86. package/dist/types/utility-types/custom.d.ts +0 -75
  87. package/dist/types/utility-types/custom.js +0 -111
  88. package/dist/types/utility-types/custom.js.map +0 -1
  89. package/dist/types/utility-types/enumeration.d.ts +0 -5
  90. package/dist/types/utility-types/enumeration.js +0 -34
  91. package/dist/types/utility-types/enumeration.js.map +0 -1
  92. package/dist/types/utility-types/frozen.d.ts +0 -24
  93. package/dist/types/utility-types/frozen.js +0 -98
  94. package/dist/types/utility-types/frozen.js.map +0 -1
  95. package/dist/types/utility-types/identifier.d.ts +0 -87
  96. package/dist/types/utility-types/identifier.js +0 -130
  97. package/dist/types/utility-types/identifier.js.map +0 -1
  98. package/dist/types/utility-types/late.d.ts +0 -10
  99. package/dist/types/utility-types/late.js +0 -110
  100. package/dist/types/utility-types/late.js.map +0 -1
  101. package/dist/types/utility-types/lazy.d.ts +0 -23
  102. package/dist/types/utility-types/lazy.js +0 -77
  103. package/dist/types/utility-types/lazy.js.map +0 -1
  104. package/dist/types/utility-types/literal.d.ts +0 -38
  105. package/dist/types/utility-types/literal.js +0 -64
  106. package/dist/types/utility-types/literal.js.map +0 -1
  107. package/dist/types/utility-types/maybe.d.ts +0 -26
  108. package/dist/types/utility-types/maybe.js +0 -30
  109. package/dist/types/utility-types/maybe.js.map +0 -1
  110. package/dist/types/utility-types/optional.d.ts +0 -42
  111. package/dist/types/utility-types/optional.js +0 -141
  112. package/dist/types/utility-types/optional.js.map +0 -1
  113. package/dist/types/utility-types/reference.d.ts +0 -90
  114. package/dist/types/utility-types/reference.js +0 -393
  115. package/dist/types/utility-types/reference.js.map +0 -1
  116. package/dist/types/utility-types/refinement.d.ts +0 -10
  117. package/dist/types/utility-types/refinement.js +0 -86
  118. package/dist/types/utility-types/refinement.js.map +0 -1
  119. package/dist/types/utility-types/resilient.d.ts +0 -18
  120. package/dist/types/utility-types/resilient.js +0 -121
  121. package/dist/types/utility-types/resilient.js.map +0 -1
  122. package/dist/types/utility-types/snapshotProcessor.d.ts +0 -63
  123. package/dist/types/utility-types/snapshotProcessor.js +0 -162
  124. package/dist/types/utility-types/snapshotProcessor.js.map +0 -1
  125. package/dist/types/utility-types/union.d.ts +0 -78
  126. package/dist/types/utility-types/union.js +0 -246
  127. package/dist/types/utility-types/union.js.map +0 -1
  128. package/dist/utils.d.ts +0 -230
  129. package/dist/utils.js +0 -483
  130. package/dist/utils.js.map +0 -1
  131. package/esm/core/action.d.ts +0 -87
  132. package/esm/core/action.js +0 -219
  133. package/esm/core/action.js.map +0 -1
  134. package/esm/core/actionContext.d.ts +0 -27
  135. package/esm/core/actionContext.js +0 -37
  136. package/esm/core/actionContext.js.map +0 -1
  137. package/esm/core/flow.d.ts +0 -69
  138. package/esm/core/flow.js +0 -173
  139. package/esm/core/flow.js.map +0 -1
  140. package/esm/core/json-patch.d.ts +0 -46
  141. package/esm/core/json-patch.js +0 -125
  142. package/esm/core/json-patch.js.map +0 -1
  143. package/esm/core/mst-operations.d.ts +0 -459
  144. package/esm/core/mst-operations.js +0 -844
  145. package/esm/core/mst-operations.js.map +0 -1
  146. package/esm/core/node/BaseNode.d.ts +0 -62
  147. package/esm/core/node/BaseNode.js +0 -148
  148. package/esm/core/node/BaseNode.js.map +0 -1
  149. package/esm/core/node/Hook.d.ts +0 -17
  150. package/esm/core/node/Hook.js +0 -12
  151. package/esm/core/node/Hook.js.map +0 -1
  152. package/esm/core/node/create-node.d.ts +0 -16
  153. package/esm/core/node/create-node.js +0 -36
  154. package/esm/core/node/create-node.js.map +0 -1
  155. package/esm/core/node/identifier-cache.d.ts +0 -19
  156. package/esm/core/node/identifier-cache.js +0 -111
  157. package/esm/core/node/identifier-cache.js.map +0 -1
  158. package/esm/core/node/livelinessChecking.d.ts +0 -37
  159. package/esm/core/node/livelinessChecking.js +0 -33
  160. package/esm/core/node/livelinessChecking.js.map +0 -1
  161. package/esm/core/node/node-utils.d.ts +0 -83
  162. package/esm/core/node/node-utils.js +0 -153
  163. package/esm/core/node/node-utils.js.map +0 -1
  164. package/esm/core/node/object-node.d.ts +0 -101
  165. package/esm/core/node/object-node.js +0 -542
  166. package/esm/core/node/object-node.js.map +0 -1
  167. package/esm/core/node/scalar-node.d.ts +0 -21
  168. package/esm/core/node/scalar-node.js +0 -86
  169. package/esm/core/node/scalar-node.js.map +0 -1
  170. package/esm/core/process.d.ts +0 -50
  171. package/esm/core/process.js +0 -35
  172. package/esm/core/process.js.map +0 -1
  173. package/esm/core/type/type-checker.d.ts +0 -69
  174. package/esm/core/type/type-checker.js +0 -144
  175. package/esm/core/type/type-checker.js.map +0 -1
  176. package/esm/core/type/type.d.ts +0 -317
  177. package/esm/core/type/type.js +0 -243
  178. package/esm/core/type/type.js.map +0 -1
  179. package/esm/index.d.ts +0 -2
  180. package/esm/index.js +0 -2
  181. package/esm/index.js.map +0 -1
  182. package/esm/internal.d.ts +0 -39
  183. package/esm/internal.js +0 -44
  184. package/esm/internal.js.map +0 -1
  185. package/esm/middlewares/create-action-tracking-middleware.d.ts +0 -24
  186. package/esm/middlewares/create-action-tracking-middleware.js +0 -78
  187. package/esm/middlewares/create-action-tracking-middleware.js.map +0 -1
  188. package/esm/middlewares/createActionTrackingMiddleware2.d.ts +0 -34
  189. package/esm/middlewares/createActionTrackingMiddleware2.js +0 -130
  190. package/esm/middlewares/createActionTrackingMiddleware2.js.map +0 -1
  191. package/esm/middlewares/on-action.d.ts +0 -87
  192. package/esm/middlewares/on-action.js +0 -210
  193. package/esm/middlewares/on-action.js.map +0 -1
  194. package/esm/types/complex-types/array.d.ts +0 -81
  195. package/esm/types/complex-types/array.js +0 -347
  196. package/esm/types/complex-types/array.js.map +0 -1
  197. package/esm/types/complex-types/map.d.ts +0 -111
  198. package/esm/types/complex-types/map.js +0 -356
  199. package/esm/types/complex-types/map.js.map +0 -1
  200. package/esm/types/complex-types/model.d.ts +0 -193
  201. package/esm/types/complex-types/model.js +0 -471
  202. package/esm/types/complex-types/model.js.map +0 -1
  203. package/esm/types/index.d.ts +0 -33
  204. package/esm/types/index.js +0 -35
  205. package/esm/types/index.js.map +0 -1
  206. package/esm/types/primitives.d.ts +0 -125
  207. package/esm/types/primitives.js +0 -177
  208. package/esm/types/primitives.js.map +0 -1
  209. package/esm/types/utility-types/custom.d.ts +0 -75
  210. package/esm/types/utility-types/custom.js +0 -106
  211. package/esm/types/utility-types/custom.js.map +0 -1
  212. package/esm/types/utility-types/enumeration.d.ts +0 -5
  213. package/esm/types/utility-types/enumeration.js +0 -31
  214. package/esm/types/utility-types/enumeration.js.map +0 -1
  215. package/esm/types/utility-types/frozen.d.ts +0 -24
  216. package/esm/types/utility-types/frozen.js +0 -92
  217. package/esm/types/utility-types/frozen.js.map +0 -1
  218. package/esm/types/utility-types/identifier.d.ts +0 -87
  219. package/esm/types/utility-types/identifier.js +0 -121
  220. package/esm/types/utility-types/identifier.js.map +0 -1
  221. package/esm/types/utility-types/late.d.ts +0 -10
  222. package/esm/types/utility-types/late.js +0 -106
  223. package/esm/types/utility-types/late.js.map +0 -1
  224. package/esm/types/utility-types/lazy.d.ts +0 -23
  225. package/esm/types/utility-types/lazy.js +0 -72
  226. package/esm/types/utility-types/lazy.js.map +0 -1
  227. package/esm/types/utility-types/literal.d.ts +0 -38
  228. package/esm/types/utility-types/literal.js +0 -58
  229. package/esm/types/utility-types/literal.js.map +0 -1
  230. package/esm/types/utility-types/maybe.d.ts +0 -26
  231. package/esm/types/utility-types/maybe.js +0 -26
  232. package/esm/types/utility-types/maybe.js.map +0 -1
  233. package/esm/types/utility-types/optional.d.ts +0 -42
  234. package/esm/types/utility-types/optional.js +0 -135
  235. package/esm/types/utility-types/optional.js.map +0 -1
  236. package/esm/types/utility-types/reference.d.ts +0 -90
  237. package/esm/types/utility-types/reference.js +0 -383
  238. package/esm/types/utility-types/reference.js.map +0 -1
  239. package/esm/types/utility-types/refinement.d.ts +0 -10
  240. package/esm/types/utility-types/refinement.js +0 -82
  241. package/esm/types/utility-types/refinement.js.map +0 -1
  242. package/esm/types/utility-types/resilient.d.ts +0 -18
  243. package/esm/types/utility-types/resilient.js +0 -118
  244. package/esm/types/utility-types/resilient.js.map +0 -1
  245. package/esm/types/utility-types/snapshotProcessor.d.ts +0 -63
  246. package/esm/types/utility-types/snapshotProcessor.js +0 -159
  247. package/esm/types/utility-types/snapshotProcessor.js.map +0 -1
  248. package/esm/types/utility-types/union.d.ts +0 -78
  249. package/esm/types/utility-types/union.js +0 -240
  250. package/esm/types/utility-types/union.js.map +0 -1
  251. package/esm/utils.d.ts +0 -230
  252. package/esm/utils.js +0 -449
  253. package/esm/utils.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2135 @@
1
- export type { CustomTypeOptions, IActionContext, IActionRecorder, IActionTrackingMiddleware2Call, IActionTrackingMiddleware2Hooks, IActionTrackingMiddlewareHooks, IAnyComplexType, IAnyModelType, IAnyStateTreeNode, IAnyType, IArrayType, IComplexType, IDisposer, IJsonPatch, IMSTArray, IMSTMap, IMapType, IMaybe, IMaybeIType, IMaybeNull, IMiddlewareEvent, IMiddlewareEventType, IMiddlewareHandler, IModelReflectionData, IModelReflectionPropertiesData, IModelType, IOptionalIType, IPatchRecorder, IReferenceType, IReversibleJsonPatch, ISerializedActionCall, ISimpleType, ISnapshotProcessor, ISnapshotProcessors, IStateTreeNode, IType, ITypeUnion, Instance, LivelinessMode, LivelynessMode, ModelActions, ModelCreationType2, ModelCreationType, ModelInstanceType, ModelInstanceTypeProps, ModelPrimitive, ModelProperties, ModelPropertiesDeclaration, ModelPropertiesDeclarationToProperties, ModelSnapshotType2, ModelSnapshotType, OnReferenceInvalidated, OnReferenceInvalidatedEvent, OptionalDefaultValueOrFunction, ReferenceIdentifier, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, SnapshotIn, SnapshotOrInstance, SnapshotOut, TypeOfValue, TypeOrStateTreeNodeToStateTreeNode, UnionOptions, UnionStringArray, ValidOptionalValue, ValidOptionalValues, _CustomCSProcessor, _CustomJoin, _CustomOrOther, _NotCustomized, NonEmptyObject, ExtractCFromProps } from "./internal.ts";
2
- export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware2, createActionTrackingMiddleware, decorate, destroy, detach, escapeJsonPath, flow, getChildType, getEnv, getIdentifier, getLivelinessChecking, getMembers, getNodeId, getParent, getParentOfType, getPath, getPathParts, getPropertyMembers, getRelativePath, getRoot, getRunningActionContext, getSnapshot, getType, hasParent, hasParentOfType, isActionContextChildOf, isActionContextThisOrChildOf, isAlive, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isProtected, isReferenceType, isRefinementType, isRoot, isStateTreeNode, isType, isUnionType, isValidReference, joinJsonPath, onAction, onPatch, onSnapshot, process, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setLivelinessChecking, setLivelynessChecking, splitJsonPath, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, types as t, unescapeJsonPath, unprotect, walk, setDevMode } from "./internal.ts";
1
+ import { IKeyValueMap, IMapDidChange, Lambda, IInterceptor, IMapWillChange, IObservableArray } from 'mobx';
2
+
3
+ /**
4
+ * Defines what MST should do when running into reads / writes to objects that have died.
5
+ * - `"warn"`: Print a warning (default).
6
+ * - `"error"`: Throw an exception.
7
+ * - "`ignore`": Do nothing.
8
+ */
9
+ type LivelinessMode = "warn" | "error" | "ignore";
10
+ /**
11
+ * Defines what MST should do when running into reads / writes to objects that have died.
12
+ * By default it will print a warning.
13
+ * Use the `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
14
+ *
15
+ * @param mode `"warn"`, `"error"` or `"ignore"`
16
+ */
17
+ declare function setLivelinessChecking(mode: LivelinessMode): void;
18
+ /**
19
+ * Returns the current liveliness checking mode.
20
+ *
21
+ * @returns `"warn"`, `"error"` or `"ignore"`
22
+ */
23
+ declare function getLivelinessChecking(): LivelinessMode;
24
+ /**
25
+ * @deprecated use LivelinessMode instead
26
+ * @hidden
27
+ */
28
+ type LivelynessMode = LivelinessMode;
29
+ /**
30
+ * @deprecated use setLivelinessChecking instead
31
+ * @hidden
32
+ *
33
+ * Defines what MST should do when running into reads / writes to objects that have died.
34
+ * By default it will print a warning.
35
+ * Use the `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
36
+ *
37
+ * @param mode `"warn"`, `"error"` or `"ignore"`
38
+ */
39
+ declare function setLivelynessChecking(mode: LivelinessMode): void;
40
+
41
+ /**
42
+ * @hidden
43
+ */
44
+ declare enum Hook {
45
+ afterCreate = "afterCreate",
46
+ afterAttach = "afterAttach",
47
+ afterCreationFinalization = "afterCreationFinalization",
48
+ beforeDetach = "beforeDetach",
49
+ beforeDestroy = "beforeDestroy"
50
+ }
51
+ interface IHooks {
52
+ [Hook.afterCreate]?: () => void;
53
+ [Hook.afterAttach]?: () => void;
54
+ [Hook.beforeDetach]?: () => void;
55
+ [Hook.beforeDestroy]?: () => void;
56
+ }
57
+ type IHooksGetter<T> = (self: T) => IHooks;
58
+
59
+ /** @hidden */
60
+ type TypeOrStateTreeNodeToStateTreeNode<T extends IAnyType | IAnyStateTreeNode> = T extends IType<any, any, infer TT> ? TT & IStateTreeNode<T> : T;
61
+ /**
62
+ * Returns the _actual_ type of the given tree node. (Or throws)
63
+ *
64
+ * @param object
65
+ * @returns
66
+ */
67
+ declare function getType(object: IAnyStateTreeNode): IAnyComplexType;
68
+ /**
69
+ * Returns the _declared_ type of the given sub property of an object, array or map.
70
+ * In the case of arrays and maps the property name is optional and will be ignored.
71
+ *
72
+ * Example:
73
+ * ```ts
74
+ * const Box = types.model({ x: 0, y: 0 })
75
+ * const box = Box.create()
76
+ *
77
+ * console.log(getChildType(box, "x").name) // 'number'
78
+ * ```
79
+ *
80
+ * @param object
81
+ * @param propertyName
82
+ * @returns
83
+ */
84
+ declare function getChildType(object: IAnyStateTreeNode, propertyName?: string): IAnyType;
85
+ /**
86
+ * Registers a function that will be invoked for each mutation that is applied to the provided model instance, or to any of its children.
87
+ * See [patches](https://github.com/mobxjs/mobx-state-tree#patches) for more details. onPatch events are emitted immediately and will not await the end of a transaction.
88
+ * Patches can be used to deeply observe a model tree.
89
+ *
90
+ * @param target the model instance from which to receive patches
91
+ * @param callback the callback that is invoked for each patch. The reversePatch is a patch that would actually undo the emitted patch
92
+ * @returns function to remove the listener
93
+ */
94
+ declare function onPatch(target: IAnyStateTreeNode, callback: (patch: IJsonPatch, reversePatch: IJsonPatch) => void): IDisposer;
95
+ /**
96
+ * Registers a function that is invoked whenever a new snapshot for the given model instance is available.
97
+ * The listener will only be fire at the end of the current MobX (trans)action.
98
+ * See [snapshots](https://github.com/mobxjs/mobx-state-tree#snapshots) for more details.
99
+ *
100
+ * @param target
101
+ * @param callback
102
+ * @returns
103
+ */
104
+ declare function onSnapshot<S>(target: IStateTreeNode<IType<any, S, any>>, callback: (snapshot: S) => void): IDisposer;
105
+ /**
106
+ * Applies a JSON-patch to the given model instance or bails out if the patch couldn't be applied
107
+ * See [patches](https://github.com/mobxjs/mobx-state-tree#patches) for more details.
108
+ *
109
+ * Can apply a single past, or an array of patches.
110
+ *
111
+ * @param target
112
+ * @param patch
113
+ * @returns
114
+ */
115
+ declare function applyPatch(target: IAnyStateTreeNode, patch: IJsonPatch | ReadonlyArray<IJsonPatch>): void;
116
+ interface IPatchRecorder {
117
+ patches: ReadonlyArray<IJsonPatch>;
118
+ inversePatches: ReadonlyArray<IJsonPatch>;
119
+ reversedInversePatches: ReadonlyArray<IJsonPatch>;
120
+ readonly recording: boolean;
121
+ stop(): void;
122
+ resume(): void;
123
+ replay(target?: IAnyStateTreeNode): void;
124
+ undo(target?: IAnyStateTreeNode): void;
125
+ }
126
+ /**
127
+ * Small abstraction around `onPatch` and `applyPatch`, attaches a patch listener to a tree and records all the patches.
128
+ * Returns a recorder object with the following signature:
129
+ *
130
+ * Example:
131
+ * ```ts
132
+ * export interface IPatchRecorder {
133
+ * // the recorded patches
134
+ * patches: IJsonPatch[]
135
+ * // the inverse of the recorded patches
136
+ * inversePatches: IJsonPatch[]
137
+ * // true if currently recording
138
+ * recording: boolean
139
+ * // stop recording patches
140
+ * stop(): void
141
+ * // resume recording patches
142
+ * resume(): void
143
+ * // apply all the recorded patches on the given target (the original subject if omitted)
144
+ * replay(target?: IAnyStateTreeNode): void
145
+ * // reverse apply the recorded patches on the given target (the original subject if omitted)
146
+ * // stops the recorder if not already stopped
147
+ * undo(): void
148
+ * }
149
+ * ```
150
+ *
151
+ * The optional filter function allows to skip recording certain patches.
152
+ *
153
+ * @param subject
154
+ * @param filter
155
+ * @returns
156
+ */
157
+ declare function recordPatches(subject: IAnyStateTreeNode, filter?: (patch: IJsonPatch, inversePatch: IJsonPatch, actionContext: IActionContext | undefined) => boolean): IPatchRecorder;
158
+ /**
159
+ * The inverse of `unprotect`.
160
+ *
161
+ * @param target
162
+ */
163
+ declare function protect(target: IAnyStateTreeNode): void;
164
+ /**
165
+ * By default it is not allowed to directly modify a model. Models can only be modified through actions.
166
+ * However, in some cases you don't care about the advantages (like replayability, traceability, etc) this yields.
167
+ * For example because you are building a PoC or don't have any middleware attached to your tree.
168
+ *
169
+ * In that case you can disable this protection by calling `unprotect` on the root of your tree.
170
+ *
171
+ * Example:
172
+ * ```ts
173
+ * const Todo = types.model({
174
+ * done: false
175
+ * }).actions(self => ({
176
+ * toggle() {
177
+ * self.done = !self.done
178
+ * }
179
+ * }))
180
+ *
181
+ * const todo = Todo.create()
182
+ * todo.done = true // throws!
183
+ * todo.toggle() // OK
184
+ * unprotect(todo)
185
+ * todo.done = false // OK
186
+ * ```
187
+ */
188
+ declare function unprotect(target: IAnyStateTreeNode): void;
189
+ /**
190
+ * Returns true if the object is in protected mode, @see protect
191
+ */
192
+ declare function isProtected(target: IAnyStateTreeNode): boolean;
193
+ /**
194
+ * Applies a snapshot to a given model instances. Patch and snapshot listeners will be invoked as usual.
195
+ *
196
+ * @param target
197
+ * @param snapshot
198
+ * @returns
199
+ */
200
+ declare function applySnapshot<C>(target: IStateTreeNode<IType<C, any, any>>, snapshot: C): void;
201
+ /**
202
+ * Calculates a snapshot from the given model instance. The snapshot will always reflect the latest state but use
203
+ * structural sharing where possible. Doesn't require MobX transactions to be completed.
204
+ *
205
+ * @param target
206
+ * @param applyPostProcess If true (the default) then postProcessSnapshot gets applied.
207
+ * @returns
208
+ */
209
+ declare function getSnapshot<S>(target: IStateTreeNode<IType<any, S, any>>, applyPostProcess?: boolean): S;
210
+ /**
211
+ * Given a model instance, returns `true` if the object has a parent, that is, is part of another object, map or array.
212
+ *
213
+ * @param target
214
+ * @param depth How far should we look upward? 1 by default.
215
+ * @returns
216
+ */
217
+ declare function hasParent(target: IAnyStateTreeNode, depth?: number): boolean;
218
+ /**
219
+ * Returns the immediate parent of this object, or throws.
220
+ *
221
+ * Note that the immediate parent can be either an object, map or array, and
222
+ * doesn't necessarily refer to the parent model.
223
+ *
224
+ * Please note that in child nodes access to the root is only possible
225
+ * once the `afterAttach` hook has fired.
226
+ *
227
+ * @param target
228
+ * @param depth How far should we look upward? 1 by default.
229
+ * @returns
230
+ */
231
+ declare function getParent<IT extends IAnyStateTreeNode | IAnyComplexType>(target: IAnyStateTreeNode, depth?: number): TypeOrStateTreeNodeToStateTreeNode<IT>;
232
+ /**
233
+ * Given a model instance, returns `true` if the object has a parent of given type, that is, is part of another object, map or array
234
+ *
235
+ * @param target
236
+ * @param type
237
+ * @returns
238
+ */
239
+ declare function hasParentOfType(target: IAnyStateTreeNode, type: IAnyComplexType): boolean;
240
+ /**
241
+ * Returns the target's parent of a given type, or throws.
242
+ *
243
+ * @param target
244
+ * @param type
245
+ * @returns
246
+ */
247
+ declare function getParentOfType<IT extends IAnyComplexType>(target: IAnyStateTreeNode, type: IT): IT["Type"];
248
+ /**
249
+ * Given an object in a model tree, returns the root object of that tree.
250
+ *
251
+ * Please note that in child nodes access to the root is only possible
252
+ * once the `afterAttach` hook has fired.
253
+ *
254
+ * @param target
255
+ * @returns
256
+ */
257
+ declare function getRoot<IT extends IAnyComplexType | IAnyStateTreeNode>(target: IAnyStateTreeNode): TypeOrStateTreeNodeToStateTreeNode<IT>;
258
+ /**
259
+ * Returns the path of the given object in the model tree
260
+ *
261
+ * @param target
262
+ * @returns
263
+ */
264
+ declare function getPath(target: IAnyStateTreeNode): string;
265
+ /**
266
+ * Returns the path of the given object as unescaped string array.
267
+ *
268
+ * @param target
269
+ * @returns
270
+ */
271
+ declare function getPathParts(target: IAnyStateTreeNode): string[];
272
+ /**
273
+ * Returns true if the given object is the root of a model tree.
274
+ *
275
+ * @param target
276
+ * @returns
277
+ */
278
+ declare function isRoot(target: IAnyStateTreeNode): boolean;
279
+ /**
280
+ * Resolves a path relatively to a given object.
281
+ * Returns undefined if no value can be found.
282
+ *
283
+ * @param target
284
+ * @param path escaped json path
285
+ * @returns
286
+ */
287
+ declare function resolvePath(target: IAnyStateTreeNode, path: string): any;
288
+ /**
289
+ * Resolves a model instance given a root target, the type and the identifier you are searching for.
290
+ * Returns undefined if no value can be found.
291
+ *
292
+ * @param type
293
+ * @param target
294
+ * @param identifier
295
+ * @returns
296
+ */
297
+ declare function resolveIdentifier<IT extends IAnyModelType>(type: IT, target: IAnyStateTreeNode, identifier: ReferenceIdentifier): IT["Type"] | undefined;
298
+ /**
299
+ * Returns the identifier of the target node.
300
+ * This is the *string normalized* identifier, which might not match the type of the identifier attribute
301
+ *
302
+ * @param target
303
+ * @returns
304
+ */
305
+ declare function getIdentifier(target: IAnyStateTreeNode): string | null;
306
+ /**
307
+ * Tests if a reference is valid (pointing to an existing node and optionally if alive) and returns such reference if the check passes,
308
+ * else it returns undefined.
309
+ *
310
+ * @param getter Function to access the reference.
311
+ * @param checkIfAlive true to also make sure the referenced node is alive (default), false to skip this check.
312
+ * @returns
313
+ */
314
+ declare function tryReference<N extends IAnyStateTreeNode>(getter: () => N | null | undefined, checkIfAlive?: boolean): N | undefined;
315
+ /**
316
+ * Tests if a reference is valid (pointing to an existing node and optionally if alive) and returns if the check passes or not.
317
+ *
318
+ * @param getter Function to access the reference.
319
+ * @param checkIfAlive true to also make sure the referenced node is alive (default), false to skip this check.
320
+ * @returns
321
+ */
322
+ declare function isValidReference<N extends IAnyStateTreeNode>(getter: () => N | null | undefined, checkIfAlive?: boolean): boolean;
323
+ /**
324
+ * Try to resolve a given path relative to a given node.
325
+ *
326
+ * @param target
327
+ * @param path
328
+ * @returns
329
+ */
330
+ declare function tryResolve(target: IAnyStateTreeNode, path: string): any;
331
+ /**
332
+ * Given two state tree nodes that are part of the same tree,
333
+ * returns the shortest jsonpath needed to navigate from the one to the other
334
+ *
335
+ * @param base
336
+ * @param target
337
+ * @returns
338
+ */
339
+ declare function getRelativePath(base: IAnyStateTreeNode, target: IAnyStateTreeNode): string;
340
+ /**
341
+ * Returns a deep copy of the given state tree node as new tree.
342
+ * Shorthand for `snapshot(x) = getType(x).create(getSnapshot(x))`
343
+ *
344
+ * _Tip: clone will create a literal copy, including the same identifiers. To modify identifiers etc. during cloning, don't use clone but take a snapshot of the tree, modify it, and create new instance_
345
+ *
346
+ * @param source
347
+ * @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.
348
+ * @returns
349
+ */
350
+ declare function clone<T extends IAnyStateTreeNode>(source: T, keepEnvironment?: boolean | any): T;
351
+ /**
352
+ * Removes a model element from the state tree, and let it live on as a new state tree
353
+ */
354
+ declare function detach<T extends IAnyStateTreeNode>(target: T): T;
355
+ /**
356
+ * Removes a model element from the state tree, and mark it as end-of-life; the element should not be used anymore
357
+ */
358
+ declare function destroy(target: IAnyStateTreeNode): void;
359
+ /**
360
+ * Returns true if the given state tree node is not killed yet.
361
+ * This means that the node is still a part of a tree, and that `destroy`
362
+ * has not been called. If a node is not alive anymore, the only thing one can do with it
363
+ * is requesting it's last path and snapshot
364
+ *
365
+ * @param target
366
+ * @returns
367
+ */
368
+ declare function isAlive(target: IAnyStateTreeNode): boolean;
369
+ /**
370
+ * Use this utility to register a function that should be called whenever the
371
+ * targeted state tree node is destroyed. This is a useful alternative to managing
372
+ * cleanup methods yourself using the `beforeDestroy` hook.
373
+ *
374
+ * This methods returns the same disposer that was passed as argument.
375
+ *
376
+ * Example:
377
+ * ```ts
378
+ * const Todo = types.model({
379
+ * title: types.string
380
+ * }).actions(self => ({
381
+ * afterCreate() {
382
+ * const autoSaveDisposer = reaction(
383
+ * () => getSnapshot(self),
384
+ * snapshot => sendSnapshotToServerSomehow(snapshot)
385
+ * )
386
+ * // stop sending updates to server if this
387
+ * // instance is destroyed
388
+ * addDisposer(self, autoSaveDisposer)
389
+ * }
390
+ * }))
391
+ * ```
392
+ *
393
+ * @param target
394
+ * @param disposer
395
+ * @returns The same disposer that was passed as argument
396
+ */
397
+ declare function addDisposer(target: IAnyStateTreeNode, disposer: IDisposer): IDisposer;
398
+ /**
399
+ * Returns the environment of the current state tree. For more info on environments,
400
+ * see [Dependency injection](https://github.com/mobxjs/mobx-state-tree#dependency-injection)
401
+ *
402
+ * Please note that in child nodes access to the root is only possible
403
+ * once the `afterAttach` hook has fired
404
+ *
405
+ * Returns an empty environment if the tree wasn't initialized with an environment
406
+ *
407
+ * @param target
408
+ * @returns
409
+ */
410
+ declare function getEnv<T = any>(target: IAnyStateTreeNode): T;
411
+ /**
412
+ * Performs a depth first walk through a tree.
413
+ */
414
+ declare function walk(target: IAnyStateTreeNode, processor: (item: IAnyStateTreeNode) => void): void;
415
+ interface IModelReflectionPropertiesData {
416
+ name: string;
417
+ properties: {
418
+ [K: string]: IAnyType;
419
+ };
420
+ }
421
+ /**
422
+ * Returns a reflection of the model type properties and name for either a model type or model node.
423
+ *
424
+ * @param typeOrNode
425
+ * @returns
426
+ */
427
+ declare function getPropertyMembers(typeOrNode: IAnyModelType | IAnyStateTreeNode): IModelReflectionPropertiesData;
428
+ interface IModelReflectionData extends IModelReflectionPropertiesData {
429
+ actions: string[];
430
+ views: string[];
431
+ volatile: string[];
432
+ flowActions: string[];
433
+ }
434
+ /**
435
+ * Returns a reflection of the model node, including name, properties, views, volatile state,
436
+ * and actions. `flowActions` is also provided as a separate array of names for any action that
437
+ * came from a flow generator as well.
438
+ *
439
+ * In the case where a model has two actions: `doSomething` and `doSomethingWithFlow`, where
440
+ * `doSomethingWithFlow` is a flow generator, the `actions` array will contain both actions,
441
+ * i.e. ["doSomething", "doSomethingWithFlow"], and the `flowActions` array will contain only
442
+ * the flow action, i.e. ["doSomethingWithFlow"].
443
+ *
444
+ * @param target
445
+ * @returns
446
+ */
447
+ declare function getMembers(target: IAnyStateTreeNode): IModelReflectionData;
448
+ declare function cast<O extends string | number | boolean | null | undefined = never>(snapshotOrInstance: O): O;
449
+ declare function cast<O = never>(snapshotOrInstance: TypeOfValue<O>["CreationType"] | TypeOfValue<O>["SnapshotType"] | TypeOfValue<O>["Type"]): O;
450
+ /**
451
+ * Casts a node instance type to a snapshot type so it can be assigned to a type snapshot (e.g. to be used inside a create call).
452
+ * Note that this is just a cast for the type system, this is, it won't actually convert an instance to a snapshot,
453
+ * but just fool typescript into thinking so.
454
+ *
455
+ * Example:
456
+ * ```ts
457
+ * const ModelA = types.model({
458
+ * n: types.number
459
+ * }).actions(self => ({
460
+ * setN(aNumber: number) {
461
+ * self.n = aNumber
462
+ * }
463
+ * }))
464
+ *
465
+ * const ModelB = types.model({
466
+ * innerModel: ModelA
467
+ * })
468
+ *
469
+ * const a = ModelA.create({ n: 5 });
470
+ * // this will allow the compiler to use a model as if it were a snapshot
471
+ * const b = ModelB.create({ innerModel: castToSnapshot(a)})
472
+ * ```
473
+ *
474
+ * @param snapshotOrInstance Snapshot or instance
475
+ * @returns The same object cast as an input (creation) snapshot
476
+ */
477
+ declare function castToSnapshot<I>(snapshotOrInstance: I): Extract<I, IAnyStateTreeNode> extends never ? I : TypeOfValue<I>["CreationType"];
478
+ /**
479
+ * Casts a node instance type to a reference snapshot type so it can be assigned to a reference snapshot (e.g. to be used inside a create call).
480
+ * Note that this is just a cast for the type system, this is, it won't actually convert an instance to a reference snapshot,
481
+ * but just fool typescript into thinking so.
482
+ *
483
+ * Example:
484
+ * ```ts
485
+ * const ModelA = types.model({
486
+ * id: types.identifier,
487
+ * n: types.number
488
+ * }).actions(self => ({
489
+ * setN(aNumber: number) {
490
+ * self.n = aNumber
491
+ * }
492
+ * }))
493
+ *
494
+ * const ModelB = types.model({
495
+ * refA: types.reference(ModelA)
496
+ * })
497
+ *
498
+ * const a = ModelA.create({ id: 'someId', n: 5 });
499
+ * // this will allow the compiler to use a model as if it were a reference snapshot
500
+ * const b = ModelB.create({ refA: castToReferenceSnapshot(a)})
501
+ * ```
502
+ *
503
+ * @param instance Instance
504
+ * @returns The same object cast as a reference snapshot (string or number)
505
+ */
506
+ declare function castToReferenceSnapshot<I>(instance: I): Extract<I, IAnyStateTreeNode> extends never ? I : ReferenceIdentifier;
507
+ /**
508
+ * Returns the unique node id (not to be confused with the instance identifier) for a
509
+ * given instance.
510
+ * This id is a number that is unique for each instance.
511
+ *
512
+ * @export
513
+ * @param target
514
+ * @returns
515
+ */
516
+ declare function getNodeId(target: IAnyStateTreeNode): number;
517
+
518
+ type HookSubscribers = {
519
+ [Hook.afterAttach]: (node: AnyNode, hook: Hook) => void;
520
+ [Hook.afterCreate]: (node: AnyNode, hook: Hook) => void;
521
+ [Hook.afterCreationFinalization]: (node: AnyNode, hook: Hook) => void;
522
+ [Hook.beforeDestroy]: (node: AnyNode, hook: Hook) => void;
523
+ [Hook.beforeDetach]: (node: AnyNode, hook: Hook) => void;
524
+ };
525
+ /**
526
+ * @internal
527
+ * @hidden
528
+ */
529
+ declare abstract class BaseNode<C, S, T> {
530
+ readonly type: IAnyType;
531
+ environment: any;
532
+ private _escapedSubpath?;
533
+ private _subpath;
534
+ get subpath(): string;
535
+ private _subpathUponDeath?;
536
+ get subpathUponDeath(): string | undefined;
537
+ private _pathUponDeath?;
538
+ protected get pathUponDeath(): string | undefined;
539
+ storedValue: any;
540
+ get value(): T;
541
+ private aliveAtom?;
542
+ private _state;
543
+ get state(): NodeLifeCycle;
544
+ set state(val: NodeLifeCycle);
545
+ private _hookSubscribers?;
546
+ protected abstract fireHook(name: Hook): void;
547
+ protected fireInternalHook(name: Hook): void;
548
+ registerHook<H extends Hook>(hook: H, hookHandler: HookSubscribers[H]): IDisposer;
549
+ private _parent;
550
+ get parent(): AnyObjectNode | null;
551
+ constructor(type: IAnyType, parent: AnyObjectNode | null, subpath: string, environment: any);
552
+ getReconciliationType(): IAnyType;
553
+ private pathAtom?;
554
+ protected baseSetParent(parent: AnyObjectNode | null, subpath: string): void;
555
+ get path(): string;
556
+ protected getEscapedPath(reportObserved: boolean): string;
557
+ get isRoot(): boolean;
558
+ abstract get root(): AnyObjectNode;
559
+ abstract setParent(newParent: AnyObjectNode | null, subpath: string | null): void;
560
+ abstract get snapshot(): S;
561
+ abstract getSnapshot(): S;
562
+ get isAlive(): boolean;
563
+ get isDetaching(): boolean;
564
+ get observableIsAlive(): boolean;
565
+ abstract die(): void;
566
+ abstract finalizeCreation(): void;
567
+ protected baseFinalizeCreation(whenFinalized?: () => void): void;
568
+ abstract finalizeDeath(): void;
569
+ protected baseFinalizeDeath(): void;
570
+ abstract aboutToDie(): void;
571
+ protected baseAboutToDie(): void;
572
+ }
573
+ /**
574
+ * @internal
575
+ * @hidden
576
+ */
577
+ type AnyNode = BaseNode<any, any, any>;
578
+
579
+ /**
580
+ * @internal
581
+ * @hidden
582
+ */
583
+ interface IChildNodesMap {
584
+ [key: string]: AnyNode;
585
+ }
586
+ /**
587
+ * @internal
588
+ * @hidden
589
+ */
590
+ declare class ObjectNode<C, S, T> extends BaseNode<C, S, T> {
591
+ readonly type: ComplexType<C, S, T>;
592
+ storedValue: T & IStateTreeNode<IType<C, S, T>>;
593
+ readonly nodeId: number;
594
+ readonly identifierAttribute?: string;
595
+ readonly identifier: string | null;
596
+ readonly unnormalizedIdentifier: ReferenceIdentifier | null;
597
+ identifierCache?: IdentifierCache;
598
+ isProtectionEnabled: boolean;
599
+ middlewares?: IMiddleware[];
600
+ hasSnapshotPostProcessor: boolean;
601
+ private _applyPatches?;
602
+ applyPatches(patches: IJsonPatch[]): void;
603
+ private _applySnapshot?;
604
+ applySnapshot(snapshot: C): void;
605
+ private _autoUnbox;
606
+ _isRunningAction: boolean;
607
+ private _hasSnapshotReaction;
608
+ private _observableInstanceState;
609
+ private _childNodes;
610
+ private _initialSnapshot;
611
+ private _cachedInitialSnapshot?;
612
+ private _cachedInitialSnapshotCreated;
613
+ private _snapshotComputed;
614
+ constructor(complexType: ComplexType<C, S, T>, parent: AnyObjectNode | null, subpath: string, environment: any, initialValue: C);
615
+ createObservableInstanceIfNeeded(fireHooks?: boolean): void;
616
+ createObservableInstance(fireHooks?: boolean): void;
617
+ get root(): AnyObjectNode;
618
+ clearParent(): void;
619
+ setParent(newParent: AnyObjectNode, subpath: string): void;
620
+ protected fireHook(name: Hook): void;
621
+ private _snapshotUponDeath?;
622
+ get snapshot(): S;
623
+ getSnapshot(): S;
624
+ private _getActualSnapshot;
625
+ private _getCachedInitialSnapshot;
626
+ private isRunningAction;
627
+ assertAlive(context: AssertAliveContext): void;
628
+ private _getAssertAliveError;
629
+ getChildNode(subpath: string): AnyNode;
630
+ getChildren(): ReadonlyArray<AnyNode>;
631
+ getChildType(propertyName?: string): IAnyType;
632
+ get isProtected(): boolean;
633
+ assertWritable(context: AssertAliveContext): void;
634
+ removeChild(subpath: string): void;
635
+ unbox(childNode: AnyNode | undefined): AnyNode | undefined;
636
+ toString(): string;
637
+ finalizeCreation(): void;
638
+ detach(): void;
639
+ private preboot;
640
+ die(): void;
641
+ aboutToDie(): void;
642
+ finalizeDeath(): void;
643
+ onSnapshot(onChange: (snapshot: S) => void): IDisposer;
644
+ protected emitSnapshot(snapshot: S): void;
645
+ onPatch(handler: (patch: IJsonPatch, reversePatch: IJsonPatch) => void): IDisposer;
646
+ emitPatch(basePatch: IReversibleJsonPatch, source: AnyNode): void;
647
+ hasDisposer(disposer: () => void): boolean;
648
+ addDisposer(disposer: () => void): void;
649
+ removeDisposer(disposer: () => void): void;
650
+ private removeMiddleware;
651
+ addMiddleWare(handler: IMiddlewareHandler, includeHooks?: boolean): IDisposer;
652
+ applyPatchLocally(subpath: string, patch: IJsonPatch): void;
653
+ private _addSnapshotReaction;
654
+ private _internalEvents?;
655
+ private _internalEventsHasSubscribers;
656
+ private _internalEventsRegister;
657
+ private _internalEventsHas;
658
+ private _internalEventsUnregister;
659
+ private _internalEventsEmit;
660
+ private _internalEventsClear;
661
+ private _internalEventsClearAll;
662
+ }
663
+ /**
664
+ * @internal
665
+ * @hidden
666
+ */
667
+ type AnyObjectNode = ObjectNode<any, any, any>;
668
+ /**
669
+ * @internal
670
+ * @hidden
671
+ */
672
+ interface AssertAliveContext {
673
+ subpath?: string;
674
+ actionContext?: IMiddlewareEvent;
675
+ }
676
+
677
+ /**
678
+ * @internal
679
+ * @hidden
680
+ */
681
+ declare enum TypeFlags {
682
+ String = 1,
683
+ Number = 2,
684
+ Boolean = 4,
685
+ Date = 8,
686
+ Literal = 16,
687
+ Array = 32,
688
+ Map = 64,
689
+ Object = 128,
690
+ Frozen = 256,
691
+ Optional = 512,
692
+ Reference = 1024,
693
+ Identifier = 2048,
694
+ Late = 4096,
695
+ Refinement = 8192,
696
+ Union = 16384,
697
+ Null = 32768,
698
+ Undefined = 65536,
699
+ Integer = 131072,
700
+ Custom = 262144,
701
+ SnapshotProcessor = 524288,
702
+ Lazy = 1048576,
703
+ Finite = 2097152,
704
+ Float = 4194304
705
+ }
706
+ /**
707
+ * @internal
708
+ * @hidden
709
+ */
710
+ declare const cannotDetermineSubtype = "cannotDetermine";
711
+ /**
712
+ * A state tree node value.
713
+ * @hidden
714
+ */
715
+ type STNValue<T, IT extends IAnyType> = T extends object ? T & IStateTreeNode<IT> : T;
716
+ /** @hidden */
717
+ declare const $type: unique symbol;
718
+ /**
719
+ * A type, either complex or simple.
720
+ */
721
+ interface IType<C, S, T> {
722
+ /** @hidden */
723
+ readonly [$type]: undefined;
724
+ /**
725
+ * Friendly type name.
726
+ */
727
+ name: string;
728
+ /**
729
+ * Name of the identifier attribute or null if none.
730
+ */
731
+ readonly identifierAttribute?: string;
732
+ /**
733
+ * Creates an instance for the type given an snapshot input.
734
+ *
735
+ * @returns An instance of that type.
736
+ */
737
+ create(snapshot?: C, env?: any): this["Type"];
738
+ /**
739
+ * Checks if a given snapshot / instance is of the given type.
740
+ *
741
+ * @param thing Snapshot or instance to be checked.
742
+ * @returns true if the value is of the current type, false otherwise.
743
+ */
744
+ is(thing: any): thing is C | this["Type"];
745
+ /**
746
+ * Run's the type's typechecker on the given value with the given validation context.
747
+ *
748
+ * @param thing Value to be checked, either a snapshot or an instance.
749
+ * @param context Validation context, an array of { subpaths, subtypes } that should be validated
750
+ * @returns The validation result, an array with the list of validation errors.
751
+ */
752
+ validate(thing: C, context: IValidationContext): IValidationResult;
753
+ /**
754
+ * Gets the textual representation of the type as a string.
755
+ */
756
+ describe(): string;
757
+ /**
758
+ * @deprecated use `Instance<typeof MyType>` instead.
759
+ * @hidden
760
+ */
761
+ readonly Type: STNValue<T, this>;
762
+ /**
763
+ * @deprecated do not use.
764
+ * @hidden
765
+ */
766
+ readonly TypeWithoutSTN: T;
767
+ /**
768
+ * @deprecated use `SnapshotOut<typeof MyType>` instead.
769
+ * @hidden
770
+ */
771
+ readonly SnapshotType: S;
772
+ /**
773
+ * @deprecated use `SnapshotIn<typeof MyType>` instead.
774
+ * @hidden
775
+ */
776
+ readonly CreationType: C;
777
+ /**
778
+ * @internal
779
+ * @hidden
780
+ */
781
+ flags: TypeFlags;
782
+ /**
783
+ * @internal
784
+ * @hidden
785
+ */
786
+ isType: true;
787
+ /**
788
+ * @internal
789
+ * @hidden
790
+ */
791
+ instantiate(parent: AnyObjectNode | null, subpath: string, environment: any, initialValue: C | T): BaseNode<C, S, T>;
792
+ /**
793
+ * @internal
794
+ * @hidden
795
+ */
796
+ reconcile(current: BaseNode<C, S, T>, newValue: C | T, parent: AnyObjectNode, subpath: string): BaseNode<C, S, T>;
797
+ /**
798
+ * @internal
799
+ * @hidden
800
+ */
801
+ getSnapshot(node: BaseNode<C, S, T>, applyPostProcess?: boolean): S;
802
+ /**
803
+ * @internal
804
+ * @hidden
805
+ */
806
+ isAssignableFrom(type: IAnyType): boolean;
807
+ /**
808
+ * @internal
809
+ * @hidden
810
+ */
811
+ getSubTypes(): IAnyType[] | IAnyType | null | typeof cannotDetermineSubtype;
812
+ }
813
+ /**
814
+ * Any kind of type.
815
+ */
816
+ interface IAnyType extends IType<any, any, any> {
817
+ }
818
+ /**
819
+ * A simple type, this is, a type where the instance and the snapshot representation are the same.
820
+ */
821
+ interface ISimpleType<T> extends IType<T, T, T> {
822
+ }
823
+ /** @hidden */
824
+ type Primitives = ModelPrimitive | null | undefined;
825
+ /**
826
+ * A complex type.
827
+ * @deprecated just for compatibility with old versions, could be deprecated on the next major version
828
+ * @hidden
829
+ */
830
+ interface IComplexType<C, S, T> extends IType<C, S, T & object> {
831
+ }
832
+ /**
833
+ * Any kind of complex type.
834
+ */
835
+ interface IAnyComplexType extends IType<any, any, object> {
836
+ }
837
+ /** @hidden */
838
+ type ExtractCSTWithSTN<IT extends {
839
+ [$type]: undefined;
840
+ CreationType: any;
841
+ SnapshotType: any;
842
+ Type: any;
843
+ }> = IT["CreationType"] | IT["SnapshotType"] | IT["Type"];
844
+ /**
845
+ * The instance representation of a given type.
846
+ */
847
+ type Instance<T> = T extends {
848
+ [$type]: undefined;
849
+ Type: any;
850
+ } ? T["Type"] : T;
851
+ /**
852
+ * The input (creation) snapshot representation of a given type.
853
+ */
854
+ type SnapshotIn<T> = T extends {
855
+ [$type]: undefined;
856
+ CreationType: any;
857
+ } ? T["CreationType"] : T extends IStateTreeNode<infer IT> ? IT["CreationType"] : T;
858
+ /**
859
+ * The output snapshot representation of a given type.
860
+ */
861
+ type SnapshotOut<T> = T extends {
862
+ [$type]: undefined;
863
+ SnapshotType: any;
864
+ } ? T["SnapshotType"] : T extends IStateTreeNode<infer IT> ? IT["SnapshotType"] : T;
865
+ /**
866
+ * A type which is equivalent to the union of SnapshotIn and Instance types of a given typeof TYPE or typeof VARIABLE.
867
+ * For primitives it defaults to the primitive itself.
868
+ *
869
+ * For example:
870
+ * - `SnapshotOrInstance<typeof ModelA> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`
871
+ * - `SnapshotOrInstance<typeof self.a (where self.a is a ModelA)> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`
872
+ *
873
+ * Usually you might want to use this when your model has a setter action that sets a property.
874
+ *
875
+ * Example:
876
+ * ```ts
877
+ * const ModelA = types.model({
878
+ * n: types.number
879
+ * })
880
+ *
881
+ * const ModelB = types.model({
882
+ * innerModel: ModelA
883
+ * }).actions(self => ({
884
+ * // this will accept as property both the snapshot and the instance, whichever is preferred
885
+ * setInnerModel(m: SnapshotOrInstance<typeof self.innerModel>) {
886
+ * self.innerModel = cast(m)
887
+ * }
888
+ * }))
889
+ * ```
890
+ */
891
+ type SnapshotOrInstance<T> = SnapshotIn<T> | Instance<T>;
892
+ /**
893
+ * A base type produces a MST node (Node in the state tree)
894
+ *
895
+ * @internal
896
+ * @hidden
897
+ */
898
+ declare abstract class BaseType<C, S, T, N extends BaseNode<any, any, any> = BaseNode<C, S, T>> implements IType<C, S, T> {
899
+ [$type]: undefined;
900
+ readonly C: C;
901
+ readonly S: S;
902
+ readonly T: T;
903
+ readonly N: N;
904
+ readonly isType = true;
905
+ readonly name: string;
906
+ constructor(name: string);
907
+ create(snapshot?: C, environment?: any): any;
908
+ getSnapshot(_node: N, _applyPostProcess?: boolean): S;
909
+ abstract reconcile(current: N, newValue: C | T, parent: AnyObjectNode, subpath: string): N;
910
+ abstract instantiate(parent: AnyObjectNode | null, subpath: string, environment: any, initialValue: C | T): N;
911
+ abstract flags: TypeFlags;
912
+ abstract describe(): string;
913
+ abstract isValidSnapshot(value: C, context: IValidationContext): IValidationResult;
914
+ isAssignableFrom(type: IAnyType): boolean;
915
+ validate(value: C | T, context: IValidationContext): IValidationResult;
916
+ is(thing: any): thing is any;
917
+ get Type(): any;
918
+ get TypeWithoutSTN(): any;
919
+ get SnapshotType(): any;
920
+ get CreationType(): any;
921
+ abstract getSubTypes(): IAnyType[] | IAnyType | null | typeof cannotDetermineSubtype;
922
+ }
923
+ /**
924
+ * A complex type produces a MST node (Node in the state tree)
925
+ *
926
+ * @internal
927
+ * @hidden
928
+ */
929
+ declare abstract class ComplexType<C, S, T> extends BaseType<C, S, T, ObjectNode<C, S, T>> {
930
+ identifierAttribute?: string;
931
+ constructor(name: string);
932
+ create(snapshot?: C, environment?: any): any;
933
+ getValue(node: this["N"]): T;
934
+ abstract getDefaultSnapshot(): C;
935
+ abstract createNewInstance(childNodes: IChildNodesMap): T;
936
+ abstract finalizeNewInstance(node: this["N"], instance: any): void;
937
+ abstract applySnapshot(node: this["N"], snapshot: C): void;
938
+ abstract applyPatchLocally(node: this["N"], subpath: string, patch: IJsonPatch): void;
939
+ abstract processInitialSnapshot(childNodes: IChildNodesMap, snapshot: C): S;
940
+ abstract getChildren(node: this["N"]): ReadonlyArray<AnyNode>;
941
+ abstract getChildNode(node: this["N"], key: string): AnyNode;
942
+ abstract getChildType(propertyName?: string): IAnyType;
943
+ abstract initializeChildNodes(node: this["N"], snapshot: any): IChildNodesMap;
944
+ abstract removeChild(node: this["N"], subpath: string): void;
945
+ isMatchingSnapshotId(current: this["N"], snapshot: C): boolean;
946
+ private tryToReconcileNode;
947
+ reconcile(current: this["N"], newValue: C | T, parent: AnyObjectNode, subpath: string): this["N"];
948
+ getSubTypes(): null;
949
+ }
950
+ /**
951
+ * Returns if a given value represents a type.
952
+ *
953
+ * @param value Value to check.
954
+ * @returns `true` if the value is a type.
955
+ */
956
+ declare function isType(value: any): value is IAnyType;
957
+
958
+ interface IActionTrackingMiddlewareHooks<T> {
959
+ filter?: (call: IMiddlewareEvent) => boolean;
960
+ onStart: (call: IMiddlewareEvent) => T;
961
+ onResume: (call: IMiddlewareEvent, context: T) => void;
962
+ onSuspend: (call: IMiddlewareEvent, context: T) => void;
963
+ onSuccess: (call: IMiddlewareEvent, context: T, result: any) => void;
964
+ onFail: (call: IMiddlewareEvent, context: T, error: any) => void;
965
+ }
966
+ /**
967
+ * Note: Consider migrating to `createActionTrackingMiddleware2`, it is easier to use.
968
+ *
969
+ * Convenience utility to create action based middleware that supports async processes more easily.
970
+ * All hooks are called for both synchronous and asynchronous actions. Except that either `onSuccess` or `onFail` is called
971
+ *
972
+ * The create middleware tracks the process of an action (assuming it passes the `filter`).
973
+ * `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.
974
+ *
975
+ * See the `atomic` middleware for an example
976
+ *
977
+ * @param hooks
978
+ * @returns
979
+ */
980
+ declare function createActionTrackingMiddleware<T = any>(hooks: IActionTrackingMiddlewareHooks<T>): IMiddlewareHandler;
981
+
982
+ interface IActionTrackingMiddleware2Call<TEnv> extends Readonly<IActionContext> {
983
+ env: TEnv | undefined;
984
+ readonly parentCall?: IActionTrackingMiddleware2Call<TEnv>;
985
+ }
986
+ interface IActionTrackingMiddleware2Hooks<TEnv> {
987
+ filter?: (call: IActionTrackingMiddleware2Call<TEnv>) => boolean;
988
+ onStart: (call: IActionTrackingMiddleware2Call<TEnv>) => void;
989
+ onFinish: (call: IActionTrackingMiddleware2Call<TEnv>, error?: any) => void;
990
+ }
991
+ /**
992
+ * Convenience utility to create action based middleware that supports async processes more easily.
993
+ * The flow is like this:
994
+ * - for each action: if filter passes -> `onStart` -> (inner actions recursively) -> `onFinish`
995
+ *
996
+ * Example: if we had an action `a` that called inside an action `b1`, then `b2` the flow would be:
997
+ * - `filter(a)`
998
+ * - `onStart(a)`
999
+ * - `filter(b1)`
1000
+ * - `onStart(b1)`
1001
+ * - `onFinish(b1)`
1002
+ * - `filter(b2)`
1003
+ * - `onStart(b2)`
1004
+ * - `onFinish(b2)`
1005
+ * - `onFinish(a)`
1006
+ *
1007
+ * The flow is the same no matter if the actions are sync or async.
1008
+ *
1009
+ * See the `atomic` middleware for an example
1010
+ *
1011
+ * @param hooks
1012
+ * @returns
1013
+ */
1014
+ declare function createActionTrackingMiddleware2<TEnv = any>(middlewareHooks: IActionTrackingMiddleware2Hooks<TEnv>): IMiddlewareHandler;
1015
+
1016
+ interface ISerializedActionCall {
1017
+ name: string;
1018
+ path?: string;
1019
+ args?: any[];
1020
+ }
1021
+ interface IActionRecorder {
1022
+ actions: ReadonlyArray<ISerializedActionCall>;
1023
+ readonly recording: boolean;
1024
+ stop(): void;
1025
+ resume(): void;
1026
+ replay(target: IAnyStateTreeNode): void;
1027
+ }
1028
+ /**
1029
+ * Applies an action or a series of actions in a single MobX transaction.
1030
+ * Does not return any value
1031
+ * Takes an action description as produced by the `onAction` middleware.
1032
+ *
1033
+ * @param target
1034
+ * @param actions
1035
+ */
1036
+ declare function applyAction(target: IAnyStateTreeNode, actions: ISerializedActionCall | ISerializedActionCall[]): void;
1037
+ /**
1038
+ * Small abstraction around `onAction` and `applyAction`, attaches an action listener to a tree and records all the actions emitted.
1039
+ * Returns an recorder object with the following signature:
1040
+ *
1041
+ * Example:
1042
+ * ```ts
1043
+ * export interface IActionRecorder {
1044
+ * // the recorded actions
1045
+ * actions: ISerializedActionCall[]
1046
+ * // true if currently recording
1047
+ * recording: boolean
1048
+ * // stop recording actions
1049
+ * stop(): void
1050
+ * // resume recording actions
1051
+ * resume(): void
1052
+ * // apply all the recorded actions on the given object
1053
+ * replay(target: IAnyStateTreeNode): void
1054
+ * }
1055
+ * ```
1056
+ *
1057
+ * The optional filter function allows to skip recording certain actions.
1058
+ *
1059
+ * @param subject
1060
+ * @returns
1061
+ */
1062
+ declare function recordActions(subject: IAnyStateTreeNode, filter?: (action: ISerializedActionCall, actionContext: IActionContext | undefined) => boolean): IActionRecorder;
1063
+ /**
1064
+ * Registers a function that will be invoked for each action that is called on the provided model instance, or to any of its children.
1065
+ * See [actions](https://github.com/mobxjs/mobx-state-tree#actions) for more details. onAction events are emitted only for the outermost called action in the stack.
1066
+ * Action can also be intercepted by middleware using addMiddleware to change the function call before it will be run.
1067
+ *
1068
+ * Not all action arguments might be serializable. For unserializable arguments, a struct like `{ $MST_UNSERIALIZABLE: true, type: "someType" }` will be generated.
1069
+ * MST Nodes are considered non-serializable as well (they could be serialized as there snapshot, but it is uncertain whether an replaying party will be able to handle such a non-instantiated snapshot).
1070
+ * Rather, when using `onAction` middleware, one should consider in passing arguments which are 1: an id, 2: a (relative) path, or 3: a snapshot. Instead of a real MST node.
1071
+ *
1072
+ * Example:
1073
+ * ```ts
1074
+ * const Todo = types.model({
1075
+ * task: types.string
1076
+ * })
1077
+ *
1078
+ * const TodoStore = types.model({
1079
+ * todos: types.array(Todo)
1080
+ * }).actions(self => ({
1081
+ * add(todo) {
1082
+ * self.todos.push(todo);
1083
+ * }
1084
+ * }))
1085
+ *
1086
+ * const s = TodoStore.create({ todos: [] })
1087
+ *
1088
+ * let disposer = onAction(s, (call) => {
1089
+ * console.log(call);
1090
+ * })
1091
+ *
1092
+ * s.add({ task: "Grab a coffee" })
1093
+ * // Logs: { name: "add", path: "", args: [{ task: "Grab a coffee" }] }
1094
+ * ```
1095
+ *
1096
+ * @param target
1097
+ * @param listener
1098
+ * @param attachAfter (default false) fires the listener *after* the action has executed instead of before.
1099
+ * @returns
1100
+ */
1101
+ declare function onAction(target: IAnyStateTreeNode, listener: (call: ISerializedActionCall) => void, attachAfter?: boolean): IDisposer;
1102
+
1103
+ type IMiddlewareEventType = "action" | "flow_spawn" | "flow_resume" | "flow_resume_error" | "flow_return" | "flow_throw";
1104
+ interface IMiddlewareEvent extends IActionContext {
1105
+ /** Event type */
1106
+ readonly type: IMiddlewareEventType;
1107
+ /** Parent event unique id */
1108
+ readonly parentId: number;
1109
+ /** Parent event object */
1110
+ readonly parentEvent: IMiddlewareEvent | undefined;
1111
+ /** Root event unique id */
1112
+ readonly rootId: number;
1113
+ /** Id of all events, from root until current (excluding current) */
1114
+ readonly allParentIds: number[];
1115
+ }
1116
+ interface FunctionWithFlag extends Function {
1117
+ _isMSTAction?: boolean;
1118
+ _isFlowAction?: boolean;
1119
+ }
1120
+ /**
1121
+ * @internal
1122
+ * @hidden
1123
+ */
1124
+ type IMiddleware = {
1125
+ handler: IMiddlewareHandler;
1126
+ includeHooks: boolean;
1127
+ };
1128
+ type IMiddlewareHandler = (actionCall: IMiddlewareEvent, next: (actionCall: IMiddlewareEvent, callback?: (value: any) => any) => void, abort: (value: any) => void) => any;
1129
+ /**
1130
+ * Middleware can be used to intercept any action is invoked on the subtree where it is attached.
1131
+ * If a tree is protected (by default), this means that any mutation of the tree will pass through your middleware.
1132
+ *
1133
+ * For more details, see the [middleware docs](concepts/middleware.md)
1134
+ *
1135
+ * @param target Node to apply the middleware to.
1136
+ * @param middleware Middleware to apply.
1137
+ * @returns A callable function to dispose the middleware.
1138
+ */
1139
+ declare function addMiddleware(target: IAnyStateTreeNode, handler: IMiddlewareHandler, includeHooks?: boolean): IDisposer;
1140
+ /**
1141
+ * Binds middleware to a specific action.
1142
+ *
1143
+ * Example:
1144
+ * ```ts
1145
+ * type.actions(self => {
1146
+ * function takeA____() {
1147
+ * self.toilet.donate()
1148
+ * self.wipe()
1149
+ * self.wipe()
1150
+ * self.toilet.flush()
1151
+ * }
1152
+ * return {
1153
+ * takeA____: decorate(atomic, takeA____)
1154
+ * }
1155
+ * })
1156
+ * ```
1157
+ *
1158
+ * @param handler
1159
+ * @param fn
1160
+ * @param includeHooks
1161
+ * @returns The original function
1162
+ */
1163
+ declare function decorate<T extends Function>(handler: IMiddlewareHandler, fn: T, includeHooks?: boolean): T;
1164
+
1165
+ interface IActionContext {
1166
+ /** Event name (action name for actions) */
1167
+ readonly name: string;
1168
+ /** Event unique id */
1169
+ readonly id: number;
1170
+ /** Parent action event object */
1171
+ readonly parentActionEvent: IMiddlewareEvent | undefined;
1172
+ /** Event context (node where the action was invoked) */
1173
+ readonly context: IAnyStateTreeNode;
1174
+ /** Event tree (root node of the node where the action was invoked) */
1175
+ readonly tree: IAnyStateTreeNode;
1176
+ /** Event arguments in an array (action arguments for actions) */
1177
+ readonly args: any[];
1178
+ }
1179
+ /**
1180
+ * Returns the currently executing MST action context, or undefined if none.
1181
+ */
1182
+ declare function getRunningActionContext(): IActionContext | undefined;
1183
+ /**
1184
+ * Returns if the given action context is a parent of this action context.
1185
+ */
1186
+ declare function isActionContextChildOf(actionContext: IActionContext, parent: number | IActionContext | IMiddlewareEvent): boolean;
1187
+ /**
1188
+ * Returns if the given action context is this or a parent of this action context.
1189
+ */
1190
+ declare function isActionContextThisOrChildOf(actionContext: IActionContext, parentOrThis: number | IActionContext | IMiddlewareEvent): boolean;
1191
+
1192
+ /** Validation context entry, this is, where the validation should run against which type */
1193
+ interface IValidationContextEntry {
1194
+ /** Subpath where the validation should be run, or an empty string to validate it all */
1195
+ path: string;
1196
+ /** Type to validate the subpath against */
1197
+ type: IAnyType;
1198
+ }
1199
+ /** Array of validation context entries */
1200
+ type IValidationContext = IValidationContextEntry[];
1201
+ /** Type validation error */
1202
+ interface IValidationError {
1203
+ /** Validation context */
1204
+ context: IValidationContext;
1205
+ /** Value that was being validated, either a snapshot or an instance */
1206
+ value: any;
1207
+ /** Error message */
1208
+ message?: string;
1209
+ }
1210
+ /** Type validation result, which is an array of type validation errors */
1211
+ type IValidationResult = IValidationError[];
1212
+ /**
1213
+ * Run's the typechecker for the given type on the given value, which can be a snapshot or an instance.
1214
+ * Throws if the given value is not according the provided type specification.
1215
+ * Use this if you need typechecks even in a production build (by default all automatic runtime type checks will be skipped in production builds)
1216
+ *
1217
+ * @param type Type to check against.
1218
+ * @param value Value to be checked, either a snapshot or an instance.
1219
+ */
1220
+ declare function typecheck<IT extends IAnyType>(type: IT, value: ExtractCSTWithSTN<IT>): void;
1221
+
1222
+ /**
1223
+ * @internal
1224
+ * @hidden
1225
+ */
1226
+ declare class IdentifierCache {
1227
+ private cacheId;
1228
+ private cache;
1229
+ private lastCacheModificationPerId;
1230
+ constructor();
1231
+ private updateLastCacheModificationPerId;
1232
+ getLastCacheModificationPerId(identifier: string): string;
1233
+ addNodeToCache(node: AnyObjectNode, lastCacheUpdate?: boolean): void;
1234
+ mergeCache(node: AnyObjectNode): void;
1235
+ notifyDied(node: AnyObjectNode): void;
1236
+ splitCache(splitNode: AnyObjectNode): IdentifierCache;
1237
+ has(type: IAnyComplexType, identifier: string): boolean;
1238
+ resolve<IT extends IAnyComplexType>(type: IT, identifier: string): ObjectNode<IT["CreationType"], IT["SnapshotType"], IT["TypeWithoutSTN"]> | null;
1239
+ }
1240
+
1241
+ /**
1242
+ * @internal
1243
+ * @hidden
1244
+ */
1245
+ declare enum NodeLifeCycle {
1246
+ INITIALIZING = 0,// setting up
1247
+ CREATED = 1,// afterCreate has run
1248
+ FINALIZED = 2,// afterAttach has run
1249
+ DETACHING = 3,// being detached from the tree
1250
+ DEAD = 4
1251
+ }
1252
+ /** @hidden */
1253
+ declare const $stateTreeNodeType: unique symbol;
1254
+ /**
1255
+ * Common interface that represents a node instance.
1256
+ * @hidden
1257
+ */
1258
+ interface IStateTreeNode<IT extends IAnyType = IAnyType> {
1259
+ /**
1260
+ * @internal
1261
+ */
1262
+ readonly $treenode?: any;
1263
+ readonly [$stateTreeNodeType]?: [IT] | [any];
1264
+ }
1265
+ /** @hidden */
1266
+ type TypeOfValue<T extends IAnyStateTreeNode> = T extends IStateTreeNode<infer IT> ? IT : never;
1267
+ /**
1268
+ * Represents any state tree node instance.
1269
+ * @hidden
1270
+ */
1271
+ interface IAnyStateTreeNode extends STNValue<any, IAnyType> {
1272
+ }
1273
+ /**
1274
+ * Returns true if the given value is a node in a state tree.
1275
+ * More precisely, that is, if the value is an instance of a
1276
+ * `types.model`, `types.array` or `types.map`.
1277
+ *
1278
+ * @param value
1279
+ * @returns true if the value is a state tree node.
1280
+ */
1281
+ declare function isStateTreeNode<IT extends IAnyComplexType = IAnyComplexType>(value: any): value is STNValue<Instance<IT>, IT>;
1282
+
1283
+ /**
1284
+ * @deprecated has been renamed to `flow()`.
1285
+ * @hidden
1286
+ */
1287
+ declare function process<R>(generator: () => IterableIterator<any>): () => Promise<R>;
1288
+ /**
1289
+ * @deprecated has been renamed to `flow()`.
1290
+ * @hidden
1291
+ */
1292
+ declare function process<A1>(generator: (a1: A1) => IterableIterator<any>): (a1: A1) => Promise<any>;
1293
+ /**
1294
+ * @deprecated has been renamed to `flow()`.
1295
+ * @hidden
1296
+ */
1297
+ declare function process<A1, A2>(generator: (a1: A1, a2: A2) => IterableIterator<any>): (a1: A1, a2: A2) => Promise<any>;
1298
+ /**
1299
+ * @deprecated has been renamed to `flow()`.
1300
+ * @hidden
1301
+ */
1302
+ declare function process<A1, A2, A3>(generator: (a1: A1, a2: A2, a3: A3) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3) => Promise<any>;
1303
+ /**
1304
+ * @deprecated has been renamed to `flow()`.
1305
+ * @hidden
1306
+ */
1307
+ 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>;
1308
+ /**
1309
+ * @deprecated has been renamed to `flow()`.
1310
+ * @hidden
1311
+ */
1312
+ 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>;
1313
+ /**
1314
+ * @deprecated has been renamed to `flow()`.
1315
+ * @hidden
1316
+ */
1317
+ 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>;
1318
+ /**
1319
+ * @deprecated has been renamed to `flow()`.
1320
+ * @hidden
1321
+ */
1322
+ 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>;
1323
+ /**
1324
+ * @deprecated has been renamed to `flow()`.
1325
+ * @hidden
1326
+ */
1327
+ 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>;
1328
+
1329
+ /**
1330
+ * @hidden
1331
+ */
1332
+ type FlowReturn<R> = R extends Promise<infer T> ? T : R;
1333
+ /**
1334
+ * See [asynchronous actions](concepts/async-actions.md).
1335
+ *
1336
+ * @returns The flow as a promise.
1337
+ */
1338
+ declare function flow<R, Args extends any[]>(generator: (...args: Args) => Generator<PromiseLike<any>, R, any>): (...args: Args) => Promise<FlowReturn<R>>;
1339
+ /**
1340
+ * @deprecated Not needed since TS3.6.
1341
+ * Used for TypeScript to make flows that return a promise return the actual promise result.
1342
+ *
1343
+ * @param val
1344
+ * @returns
1345
+ */
1346
+ declare function castFlowReturn<T>(val: T): T;
1347
+ /**
1348
+ * @experimental
1349
+ * experimental api - might change on minor/patch releases
1350
+ *
1351
+ * Convert a promise-returning function to a generator-returning one.
1352
+ * This is intended to allow for usage of `yield*` in async actions to
1353
+ * retain the promise return type.
1354
+ *
1355
+ * Example:
1356
+ * ```ts
1357
+ * function getDataAsync(input: string): Promise<number> { ... }
1358
+ * const getDataGen = toGeneratorFunction(getDataAsync);
1359
+ *
1360
+ * const someModel.actions(self => ({
1361
+ * someAction: flow(function*() {
1362
+ * // value is typed as number
1363
+ * const value = yield* getDataGen("input value");
1364
+ * ...
1365
+ * })
1366
+ * }))
1367
+ * ```
1368
+ */
1369
+ declare function toGeneratorFunction<R, Args extends any[]>(p: (...args: Args) => Promise<R>): (...args: Args) => Generator<Promise<R>, R, R>;
1370
+ /**
1371
+ * @experimental
1372
+ * experimental api - might change on minor/patch releases
1373
+ *
1374
+ * Convert a promise to a generator yielding that promise
1375
+ * This is intended to allow for usage of `yield*` in async actions to
1376
+ * retain the promise return type.
1377
+ *
1378
+ * Example:
1379
+ * ```ts
1380
+ * function getDataAsync(input: string): Promise<number> { ... }
1381
+ *
1382
+ * const someModel.actions(self => ({
1383
+ * someAction: flow(function*() {
1384
+ * // value is typed as number
1385
+ * const value = yield* toGenerator(getDataAsync("input value"));
1386
+ * ...
1387
+ * })
1388
+ * }))
1389
+ * ```
1390
+ */
1391
+ declare function toGenerator<R>(p: Promise<R>): Generator<Promise<R>, R, R>;
1392
+
1393
+ /**
1394
+ * https://tools.ietf.org/html/rfc6902
1395
+ * http://jsonpatch.com/
1396
+ */
1397
+ interface IJsonPatch {
1398
+ readonly op: "replace" | "add" | "remove";
1399
+ readonly path: string;
1400
+ readonly value?: any;
1401
+ }
1402
+ interface IReversibleJsonPatch extends IJsonPatch {
1403
+ readonly oldValue: any;
1404
+ }
1405
+ /**
1406
+ * Escape slashes and backslashes.
1407
+ *
1408
+ * http://tools.ietf.org/html/rfc6901
1409
+ */
1410
+ declare function escapeJsonPath(path: string): string;
1411
+ /**
1412
+ * Unescape slashes and backslashes.
1413
+ */
1414
+ declare function unescapeJsonPath(path: string): string;
1415
+ /**
1416
+ * Generates a json-path compliant json path from path parts.
1417
+ *
1418
+ * @param path
1419
+ * @returns
1420
+ */
1421
+ declare function joinJsonPath(path: string[]): string;
1422
+ /**
1423
+ * Splits and decodes a json path into several parts.
1424
+ *
1425
+ * @param path
1426
+ * @returns
1427
+ */
1428
+ declare function splitJsonPath(path: string): string[];
1429
+
1430
+ /**
1431
+ * A generic disposer.
1432
+ */
1433
+ type IDisposer = () => void;
1434
+ /**
1435
+ * @internal
1436
+ * @hidden
1437
+ */
1438
+ declare function setDevMode(value: boolean): void;
1439
+
1440
+ /** @hidden */
1441
+ declare const $mstNotCustomized: unique symbol;
1442
+ /** @hidden */
1443
+ interface _NotCustomized {
1444
+ readonly [$mstNotCustomized]: undefined;
1445
+ }
1446
+ /** @hidden */
1447
+ type _CustomOrOther<Custom, Other> = Custom extends _NotCustomized ? Other : Custom;
1448
+ /**
1449
+ * A type that has its snapshots processed.
1450
+ */
1451
+ interface ISnapshotProcessor<IT extends IAnyType, CustomC, CustomS> extends IType<_CustomOrOther<CustomC, IT["CreationType"]>, _CustomOrOther<CustomS, IT["SnapshotType"]>, IT["TypeWithoutSTN"]> {
1452
+ }
1453
+ /**
1454
+ * Snapshot processors.
1455
+ */
1456
+ interface ISnapshotProcessors<IT extends IAnyType, CustomC, CustomS> {
1457
+ /**
1458
+ * Function that transforms an input snapshot.
1459
+ */
1460
+ preProcessor?(snapshot: CustomC): IT["CreationType"];
1461
+ /**
1462
+ * Function that transforms an output snapshot.
1463
+ * @param snapshot
1464
+ */
1465
+ postProcessor?(snapshot: IT["SnapshotType"], node: Instance<IT>): CustomS;
1466
+ }
1467
+ /**
1468
+ * `types.snapshotProcessor` - Runs a pre/post snapshot processor before/after serializing a given type.
1469
+ *
1470
+ * Example:
1471
+ * ```ts
1472
+ * const Todo1 = types.model({ text: types.string })
1473
+ * // in the backend the text type must be null when empty
1474
+ * interface BackendTodo {
1475
+ * text: string | null
1476
+ * }
1477
+ *
1478
+ * const Todo2 = types.snapshotProcessor(Todo1, {
1479
+ * // from snapshot to instance
1480
+ * preProcessor(snapshot: BackendTodo) {
1481
+ * return {
1482
+ * text: sn.text || "";
1483
+ * }
1484
+ * },
1485
+ *
1486
+ * // from instance to snapshot
1487
+ * postProcessor(snapshot, node): BackendTodo {
1488
+ * return {
1489
+ * text: !sn.text ? null : sn.text
1490
+ * }
1491
+ * }
1492
+ * })
1493
+ * ```
1494
+ *
1495
+ * @param type Type to run the processors over.
1496
+ * @param processors Processors to run.
1497
+ * @param name Type name, or undefined to inherit the inner type one.
1498
+ * @returns
1499
+ */
1500
+ declare function snapshotProcessor<IT extends IAnyType, CustomC = _NotCustomized, CustomS = _NotCustomized>(type: IT, processors: ISnapshotProcessors<IT, CustomC, CustomS>, name?: string): ISnapshotProcessor<IT, CustomC, CustomS>;
1501
+
1502
+ /** @hidden */
1503
+ interface IMapType<IT extends IAnyType> extends IType<IKeyValueMap<IT["CreationType"]> | undefined, IKeyValueMap<IT["SnapshotType"]>, IMSTMap<IT>> {
1504
+ hooks(hooks: IHooksGetter<IMSTMap<IT>>): IMapType<IT>;
1505
+ }
1506
+ /** @hidden */
1507
+ interface IMSTMap<IT extends IAnyType> {
1508
+ clear(): void;
1509
+ delete(key: string): boolean;
1510
+ forEach(callbackfn: (value: IT["Type"], key: string | number, map: this) => void, thisArg?: any): void;
1511
+ get(key: string | number): IT["Type"] | undefined;
1512
+ has(key: string | number): boolean;
1513
+ set(key: string | number, value: ExtractCSTWithSTN<IT>): this;
1514
+ readonly size: number;
1515
+ put(value: ExtractCSTWithSTN<IT>): IT["Type"];
1516
+ keys(): IterableIterator<string>;
1517
+ values(): IterableIterator<IT["Type"]>;
1518
+ entries(): IterableIterator<[string, IT["Type"]]>;
1519
+ [Symbol.iterator](): IterableIterator<[string, IT["Type"]]>;
1520
+ /** Merge another object into this map, returns self. */
1521
+ merge(other: IMSTMap<IType<any, any, IT["TypeWithoutSTN"]>> | IKeyValueMap<ExtractCSTWithSTN<IT>> | any): this;
1522
+ replace(values: IMSTMap<IType<any, any, IT["TypeWithoutSTN"]>> | IKeyValueMap<ExtractCSTWithSTN<IT>> | any): this;
1523
+ toJSON(): IKeyValueMap<IT["SnapshotType"]>;
1524
+ toString(): string;
1525
+ [Symbol.toStringTag]: "Map";
1526
+ /**
1527
+ * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
1528
+ * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
1529
+ * for callback details
1530
+ */
1531
+ observe(listener: (changes: IMapDidChange<string, IT["Type"]>) => void, fireImmediately?: boolean): Lambda;
1532
+ intercept(handler: IInterceptor<IMapWillChange<string, IT["Type"]>>): Lambda;
1533
+ }
1534
+ /**
1535
+ * `types.map` - Creates a key based collection type who's children are all of a uniform declared type.
1536
+ * If the type stored in a map has an identifier, it is mandatory to store the child under that identifier in the map.
1537
+ *
1538
+ * This type will always produce [observable maps](https://mobx.js.org/api.html#observablemap)
1539
+ *
1540
+ * Example:
1541
+ * ```ts
1542
+ * const Todo = types.model({
1543
+ * id: types.identifier,
1544
+ * task: types.string
1545
+ * })
1546
+ *
1547
+ * const TodoStore = types.model({
1548
+ * todos: types.map(Todo)
1549
+ * })
1550
+ *
1551
+ * const s = TodoStore.create({ todos: {} })
1552
+ * unprotect(s)
1553
+ * s.todos.set(17, { task: "Grab coffee", id: 17 })
1554
+ * s.todos.put({ task: "Grab cookie", id: 18 }) // put will infer key from the identifier
1555
+ * console.log(s.todos.get(17).task) // prints: "Grab coffee"
1556
+ * ```
1557
+ *
1558
+ * @param subtype
1559
+ * @returns
1560
+ */
1561
+ declare function map<IT extends IAnyType>(subtype: IT): IMapType<IT>;
1562
+ /**
1563
+ * Returns if a given value represents a map type.
1564
+ *
1565
+ * @param type
1566
+ * @returns `true` if it is a map type.
1567
+ */
1568
+ declare function isMapType<Items extends IAnyType = IAnyType>(type: IAnyType): type is IMapType<Items>;
1569
+
1570
+ /** @hidden */
1571
+ interface IMSTArray<IT extends IAnyType> extends IObservableArray<IT["Type"]> {
1572
+ push(...items: IT["Type"][]): number;
1573
+ push(...items: ExtractCSTWithSTN<IT>[]): number;
1574
+ concat(...items: ConcatArray<IT["Type"]>[]): IT["Type"][];
1575
+ concat(...items: ConcatArray<ExtractCSTWithSTN<IT>>[]): IT["Type"][];
1576
+ concat(...items: (IT["Type"] | ConcatArray<IT["Type"]>)[]): IT["Type"][];
1577
+ concat(...items: (ExtractCSTWithSTN<IT> | ConcatArray<ExtractCSTWithSTN<IT>>)[]): IT["Type"][];
1578
+ splice(start: number, deleteCount?: number): IT["Type"][];
1579
+ splice(start: number, deleteCount: number, ...items: IT["Type"][]): IT["Type"][];
1580
+ splice(start: number, deleteCount: number, ...items: ExtractCSTWithSTN<IT>[]): IT["Type"][];
1581
+ unshift(...items: IT["Type"][]): number;
1582
+ unshift(...items: ExtractCSTWithSTN<IT>[]): number;
1583
+ }
1584
+ /** @hidden */
1585
+ interface IArrayType<IT extends IAnyType> extends IType<readonly IT["CreationType"][] | undefined, IT["SnapshotType"][], IMSTArray<IT>> {
1586
+ hooks(hooks: IHooksGetter<IMSTArray<IAnyType>>): IArrayType<IT>;
1587
+ }
1588
+ /**
1589
+ * `types.array` - Creates an index based collection type who's children are all of a uniform declared type.
1590
+ *
1591
+ * This type will always produce [observable arrays](https://mobx.js.org/api.html#observablearray)
1592
+ *
1593
+ * Example:
1594
+ * ```ts
1595
+ * const Todo = types.model({
1596
+ * task: types.string
1597
+ * })
1598
+ *
1599
+ * const TodoStore = types.model({
1600
+ * todos: types.array(Todo)
1601
+ * })
1602
+ *
1603
+ * const s = TodoStore.create({ todos: [] })
1604
+ * unprotect(s) // needed to allow modifying outside of an action
1605
+ * s.todos.push({ task: "Grab coffee" })
1606
+ * console.log(s.todos[0]) // prints: "Grab coffee"
1607
+ * ```
1608
+ *
1609
+ * @param subtype
1610
+ * @returns
1611
+ */
1612
+ declare function array<IT extends IAnyType>(subtype: IT): IArrayType<IT>;
1613
+ /**
1614
+ * Returns if a given value represents an array type.
1615
+ *
1616
+ * @param type
1617
+ * @returns `true` if the type is an array type.
1618
+ */
1619
+ declare function isArrayType<Items extends IAnyType = IAnyType>(type: IAnyType): type is IArrayType<Items>;
1620
+
1621
+ /** @hidden */
1622
+ interface ModelProperties {
1623
+ [key: string]: IAnyType;
1624
+ }
1625
+ /** @hidden */
1626
+ type ModelPrimitive = string | number | boolean | Date;
1627
+ /** @hidden */
1628
+ interface ModelPropertiesDeclaration {
1629
+ [key: string]: ModelPrimitive | IAnyType;
1630
+ }
1631
+ /**
1632
+ * Unmaps syntax property declarations to a map of { propName: IType }
1633
+ *
1634
+ * @hidden
1635
+ */
1636
+ type ModelPropertiesDeclarationToProperties<T extends ModelPropertiesDeclaration> = T extends {
1637
+ [k: string]: IAnyType;
1638
+ } ? T : {
1639
+ [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;
1640
+ };
1641
+ /**
1642
+ * Checks if a value is optional (undefined, any or unknown).
1643
+ * @hidden
1644
+ *
1645
+ * Examples:
1646
+ * - string = false
1647
+ * - undefined = true
1648
+ * - string | undefined = true
1649
+ * - string & undefined = false, but we don't care
1650
+ * - any = true
1651
+ * - unknown = true
1652
+ */
1653
+ type IsOptionalValue<C, TV, FV> = undefined extends C ? TV : FV;
1654
+ /**
1655
+ * Name of the properties of an object that can't be set to undefined, any or unknown
1656
+ * @hidden
1657
+ */
1658
+ type DefinablePropsNames<T> = {
1659
+ [K in keyof T]: IsOptionalValue<T[K], never, K>;
1660
+ }[keyof T];
1661
+ /** @hidden */
1662
+ declare const $nonEmptyObject: unique symbol;
1663
+ /** @hidden */
1664
+ interface NonEmptyObject {
1665
+ [$nonEmptyObject]?: any;
1666
+ }
1667
+ /** @hidden */
1668
+ type ExtractCFromProps<P extends ModelProperties> = {
1669
+ [k in keyof P]: P[k]["CreationType"];
1670
+ };
1671
+ /** @hidden */
1672
+ type ModelCreationType<PC> = {
1673
+ [P in DefinablePropsNames<PC>]: PC[P];
1674
+ } & Partial<PC> & NonEmptyObject;
1675
+ /** @hidden */
1676
+ type ModelCreationType2<P extends ModelProperties, CustomC> = keyof P extends never ? IStateTreeNode : _CustomOrOther<CustomC, ModelCreationType<ExtractCFromProps<P>>>;
1677
+ /** @hidden */
1678
+ type ModelSnapshotType<P extends ModelProperties> = {
1679
+ [K in keyof P]: P[K]["SnapshotType"];
1680
+ } & NonEmptyObject;
1681
+ /** @hidden */
1682
+ type ModelSnapshotType2<P extends ModelProperties, CustomS> = _CustomOrOther<CustomS, ModelSnapshotType<P>>;
1683
+ /**
1684
+ * @hidden
1685
+ * we keep this separate from ModelInstanceType to shorten model instance types generated declarations
1686
+ */
1687
+ type ModelInstanceTypeProps<P extends ModelProperties> = {
1688
+ [K in keyof P]: P[K]["Type"];
1689
+ } & NonEmptyObject;
1690
+ /**
1691
+ * @hidden
1692
+ * do not transform this to an interface or model instance type generated declarations will be longer
1693
+ */
1694
+ type ModelInstanceType<P extends ModelProperties, O> = ModelInstanceTypeProps<P> & O;
1695
+ /** @hidden */
1696
+ interface ModelActions {
1697
+ [key: string]: FunctionWithFlag;
1698
+ }
1699
+ interface IModelType<PROPS extends ModelProperties, OTHERS, CustomC = _NotCustomized, CustomS = _NotCustomized> extends IType<ModelCreationType2<PROPS, CustomC>, ModelSnapshotType2<PROPS, CustomS>, ModelInstanceType<PROPS, OTHERS>> {
1700
+ readonly properties: PROPS;
1701
+ named(newName: string): IModelType<PROPS, OTHERS, CustomC, CustomS>;
1702
+ props<PROPS2 extends ModelPropertiesDeclaration>(props: PROPS2): IModelType<PROPS & ModelPropertiesDeclarationToProperties<PROPS2>, OTHERS, CustomC, CustomS>;
1703
+ views<V extends object>(fn: (self: Instance<this>) => V): IModelType<PROPS, OTHERS & V, CustomC, CustomS>;
1704
+ actions<A extends ModelActions>(fn: (self: Instance<this>) => A): IModelType<PROPS, OTHERS & A, CustomC, CustomS>;
1705
+ volatile<TP extends object>(fn: (self: Instance<this>) => TP): IModelType<PROPS, OTHERS & TP, CustomC, CustomS>;
1706
+ extend<A extends ModelActions = {}, V extends object = {}, VS extends object = {}>(fn: (self: Instance<this>) => {
1707
+ actions?: A;
1708
+ views?: V;
1709
+ state?: VS;
1710
+ }): IModelType<PROPS, OTHERS & A & V & VS, CustomC, CustomS>;
1711
+ preProcessSnapshot<NewC = ModelCreationType2<PROPS, CustomC>>(fn: (snapshot: NewC) => ModelCreationType2<PROPS, CustomC>): IModelType<PROPS, OTHERS, NewC, CustomS>;
1712
+ postProcessSnapshot<NewS = ModelSnapshotType2<PROPS, CustomS>>(fn: (snapshot: ModelSnapshotType2<PROPS, CustomS>) => NewS): IModelType<PROPS, OTHERS, CustomC, NewS>;
1713
+ }
1714
+ /**
1715
+ * Any model type.
1716
+ */
1717
+ interface IAnyModelType extends IModelType<any, any, any, any> {
1718
+ }
1719
+ declare function model<P extends ModelPropertiesDeclaration = {}>(name: string, properties?: P): IModelType<ModelPropertiesDeclarationToProperties<P>, {}>;
1720
+ declare function model<P extends ModelPropertiesDeclaration = {}>(properties?: P): IModelType<ModelPropertiesDeclarationToProperties<P>, {}>;
1721
+ /** @hidden */
1722
+ type _CustomJoin<A, B> = A extends _NotCustomized ? B : A & B;
1723
+ 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>>;
1724
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>): IModelType<PA & PB, OA & OB, _CustomJoin<FCA, FCB>, _CustomJoin<FSA, FSB>>;
1725
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC>(name: string, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>): IModelType<PA & PB & PC, OA & OB & OC, _CustomJoin<FCA, _CustomJoin<FCB, FCC>>, _CustomJoin<FSA, _CustomJoin<FSB, FSC>>>;
1726
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>): IModelType<PA & PB & PC, OA & OB & OC, _CustomJoin<FCA, _CustomJoin<FCB, FCC>>, _CustomJoin<FSA, _CustomJoin<FSB, FSC>>>;
1727
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD>(name: string, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>): IModelType<PA & PB & PC & PD, OA & OB & OC & OD, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, FCD>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, FSD>>>>;
1728
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>): IModelType<PA & PB & PC & PD, OA & OB & OC & OD, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, FCD>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, FSD>>>>;
1729
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE>(name: string, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>): IModelType<PA & PB & PC & PD & PE, OA & OB & OC & OD & OE, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, FCE>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, FSE>>>>>;
1730
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>): IModelType<PA & PB & PC & PD & PE, OA & OB & OC & OD & OE, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, FCE>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, FSE>>>>>;
1731
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF>(name: string, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>): IModelType<PA & PB & PC & PD & PE & PF, OA & OB & OC & OD & OE & OF, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, _CustomJoin<FCE, FCF>>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, _CustomJoin<FSE, FSF>>>>>>;
1732
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>): IModelType<PA & PB & PC & PD & PE & PF, OA & OB & OC & OD & OE & OF, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, _CustomJoin<FCE, FCF>>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, _CustomJoin<FSE, FSF>>>>>>;
1733
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG>(name: string, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>): IModelType<PA & PB & PC & PD & PE & PF & PG, OA & OB & OC & OD & OE & OF & OG, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, _CustomJoin<FCE, _CustomJoin<FCF, FCG>>>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, _CustomJoin<FSE, _CustomJoin<FSF, FSG>>>>>>>;
1734
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>): IModelType<PA & PB & PC & PD & PE & PF & PG, OA & OB & OC & OD & OE & OF & OG, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, _CustomJoin<FCE, _CustomJoin<FCF, FCG>>>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, _CustomJoin<FSE, _CustomJoin<FSF, FSG>>>>>>>;
1735
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG, PH extends ModelProperties, OH, FCH, FSH>(name: string, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>, H: IModelType<PH, OH, FCH, FSH>): IModelType<PA & PB & PC & PD & PE & PF & PG & PH, OA & OB & OC & OD & OE & OF & OG & OH, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, _CustomJoin<FCE, _CustomJoin<FCF, _CustomJoin<FCG, FCH>>>>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, _CustomJoin<FSE, _CustomJoin<FSF, _CustomJoin<FSG, FSH>>>>>>>>;
1736
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG, PH extends ModelProperties, OH, FCH, FSH>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>, H: IModelType<PH, OH, FCH, FSH>): IModelType<PA & PB & PC & PD & PE & PF & PG & PH, OA & OB & OC & OD & OE & OF & OG & OH, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, _CustomJoin<FCE, _CustomJoin<FCF, _CustomJoin<FCG, FCH>>>>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, _CustomJoin<FSE, _CustomJoin<FSF, _CustomJoin<FSG, FSH>>>>>>>>;
1737
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG, PH extends ModelProperties, OH, FCH, FSH, PI extends ModelProperties, OI, FCI, FSI>(name: string, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>, H: IModelType<PH, OH, FCH, FSH>, I: IModelType<PI, OI, FCI, FSI>): IModelType<PA & PB & PC & PD & PE & PF & PG & PH & PI, OA & OB & OC & OD & OE & OF & OG & OH & OI, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, _CustomJoin<FCE, _CustomJoin<FCF, _CustomJoin<FCG, _CustomJoin<FCH, FCI>>>>>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, _CustomJoin<FSE, _CustomJoin<FSF, _CustomJoin<FSG, _CustomJoin<FSH, FSI>>>>>>>>>;
1738
+ declare function compose<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG, PH extends ModelProperties, OH, FCH, FSH, PI extends ModelProperties, OI, FCI, FSI>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>, H: IModelType<PH, OH, FCH, FSH>, I: IModelType<PI, OI, FCI, FSI>): IModelType<PA & PB & PC & PD & PE & PF & PG & PH & PI, OA & OB & OC & OD & OE & OF & OG & OH & OI, _CustomJoin<FCA, _CustomJoin<FCB, _CustomJoin<FCC, _CustomJoin<FCD, _CustomJoin<FCE, _CustomJoin<FCF, _CustomJoin<FCG, _CustomJoin<FCH, FCI>>>>>>>>, _CustomJoin<FSA, _CustomJoin<FSB, _CustomJoin<FSC, _CustomJoin<FSD, _CustomJoin<FSE, _CustomJoin<FSF, _CustomJoin<FSG, _CustomJoin<FSH, FSI>>>>>>>>>;
1739
+ /**
1740
+ * Returns if a given value represents a model type.
1741
+ *
1742
+ * @param type
1743
+ * @returns
1744
+ */
1745
+ declare function isModelType<IT extends IAnyModelType = IAnyModelType>(type: IAnyType): type is IT;
1746
+
1747
+ /**
1748
+ * `types.Date` - Creates a type that can only contain a javascript Date value.
1749
+ *
1750
+ * Example:
1751
+ * ```ts
1752
+ * const LogLine = types.model({
1753
+ * timestamp: types.Date,
1754
+ * })
1755
+ *
1756
+ * LogLine.create({ timestamp: new Date() })
1757
+ * ```
1758
+ */
1759
+ declare const DatePrimitive: IType<number | Date, number, Date>;
1760
+ /**
1761
+ * Returns if a given value represents a primitive type.
1762
+ *
1763
+ * @param type
1764
+ * @returns
1765
+ */
1766
+ declare function isPrimitiveType<IT extends ISimpleType<string> | ISimpleType<number> | ISimpleType<boolean> | typeof DatePrimitive>(type: IT): type is IT;
1767
+
1768
+ /**
1769
+ * `types.literal` - The literal type will return a type that will match only the exact given type.
1770
+ * The given value must be a primitive, in order to be serialized to a snapshot correctly.
1771
+ * You can use literal to match exact strings for example the exact male or female string.
1772
+ *
1773
+ * Example:
1774
+ * ```ts
1775
+ * const Person = types.model({
1776
+ * name: types.string,
1777
+ * gender: types.union(types.literal('male'), types.literal('female'))
1778
+ * })
1779
+ * ```
1780
+ *
1781
+ * @param value The value to use in the strict equal check
1782
+ * @returns
1783
+ */
1784
+ declare function literal<S extends Primitives>(value: S): ISimpleType<S>;
1785
+ /**
1786
+ * Returns if a given value represents a literal type.
1787
+ *
1788
+ * @param type
1789
+ * @returns
1790
+ */
1791
+ declare function isLiteralType<IT extends ISimpleType<any>>(type: IT): type is IT;
1792
+
1793
+ declare function refinement<IT extends IAnyType>(name: string, type: IT, predicate: (snapshot: IT["CreationType"]) => boolean, message?: string | ((v: IT["CreationType"]) => string)): IT;
1794
+ declare function refinement<IT extends IAnyType>(type: IT, predicate: (snapshot: IT["CreationType"]) => boolean, message?: string | ((v: IT["CreationType"]) => string)): IT;
1795
+ /**
1796
+ * Returns if a given value is a refinement type.
1797
+ *
1798
+ * @param type
1799
+ * @returns
1800
+ */
1801
+ declare function isRefinementType<IT extends IAnyType>(type: IT): type is IT;
1802
+
1803
+ /** @hidden */
1804
+ type UnionStringArray<T extends readonly string[]> = T[number];
1805
+ declare function enumeration<T extends readonly string[]>(options: T): ISimpleType<UnionStringArray<T>>;
1806
+ declare function enumeration<T extends string>(name: string, options: T[]): ISimpleType<UnionStringArray<T[]>>;
1807
+
1808
+ type ITypeDispatcher = (snapshot: any) => IAnyType;
1809
+ interface UnionOptions {
1810
+ eager?: boolean;
1811
+ dispatcher?: ITypeDispatcher;
1812
+ }
1813
+ /**
1814
+ * Transform _NotCustomized | _NotCustomized... to _NotCustomized, _NotCustomized | A | B to A | B
1815
+ * @hidden
1816
+ */
1817
+ type _CustomCSProcessor<T> = Exclude<T, _NotCustomized> extends never ? _NotCustomized : Exclude<T, _NotCustomized>;
1818
+ /** @hidden */
1819
+ interface ITypeUnion<C, S, T> extends IType<_CustomCSProcessor<C>, _CustomCSProcessor<S>, T> {
1820
+ }
1821
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB>>;
1822
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB>(options: UnionOptions, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB>>;
1823
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC>>;
1824
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC>(options: UnionOptions, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC>>;
1825
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD>>;
1826
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD>(options: UnionOptions, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD>>;
1827
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE>>;
1828
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE>(options: UnionOptions, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE>>;
1829
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE> | ModelCreationType2<PF, FCF>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE> | ModelSnapshotType2<PF, FSF>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE> | ModelInstanceType<PF, OF>>;
1830
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF>(options: UnionOptions, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE> | ModelCreationType2<PF, FCF>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE> | ModelSnapshotType2<PF, FSF>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE> | ModelInstanceType<PF, OF>>;
1831
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE> | ModelCreationType2<PF, FCF> | ModelCreationType2<PG, FCG>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE> | ModelSnapshotType2<PF, FSF> | ModelSnapshotType2<PG, FSG>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE> | ModelInstanceType<PF, OF> | ModelInstanceType<PG, OG>>;
1832
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG>(options: UnionOptions, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE> | ModelCreationType2<PF, FCF> | ModelCreationType2<PG, FCG>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE> | ModelSnapshotType2<PF, FSF> | ModelSnapshotType2<PG, FSG>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE> | ModelInstanceType<PF, OF> | ModelInstanceType<PG, OG>>;
1833
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG, PH extends ModelProperties, OH, FCH, FSH>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>, H: IModelType<PH, OH, FCH, FSH>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE> | ModelCreationType2<PF, FCF> | ModelCreationType2<PG, FCG> | ModelCreationType2<PH, FCH>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE> | ModelSnapshotType2<PF, FSF> | ModelSnapshotType2<PG, FSG> | ModelSnapshotType2<PH, FSH>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE> | ModelInstanceType<PF, OF> | ModelInstanceType<PG, OG> | ModelInstanceType<PH, OH>>;
1834
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG, PH extends ModelProperties, OH, FCH, FSH>(options: UnionOptions, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>, H: IModelType<PH, OH, FCH, FSH>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE> | ModelCreationType2<PF, FCF> | ModelCreationType2<PG, FCG> | ModelCreationType2<PH, FCH>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE> | ModelSnapshotType2<PF, FSF> | ModelSnapshotType2<PG, FSG> | ModelSnapshotType2<PH, FSH>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE> | ModelInstanceType<PF, OF> | ModelInstanceType<PG, OG> | ModelInstanceType<PH, OH>>;
1835
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG, PH extends ModelProperties, OH, FCH, FSH, PI extends ModelProperties, OI, FCI, FSI>(A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>, H: IModelType<PH, OH, FCH, FSH>, I: IModelType<PI, OI, FCI, FSI>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE> | ModelCreationType2<PF, FCF> | ModelCreationType2<PG, FCG> | ModelCreationType2<PH, FCH> | ModelCreationType2<PI, FCI>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE> | ModelSnapshotType2<PF, FSF> | ModelSnapshotType2<PG, FSG> | ModelSnapshotType2<PH, FSH> | ModelSnapshotType2<PI, FSI>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE> | ModelInstanceType<PF, OF> | ModelInstanceType<PG, OG> | ModelInstanceType<PH, OH> | ModelInstanceType<PI, OI>>;
1836
+ declare function union<PA extends ModelProperties, OA, FCA, FSA, PB extends ModelProperties, OB, FCB, FSB, PC extends ModelProperties, OC, FCC, FSC, PD extends ModelProperties, OD, FCD, FSD, PE extends ModelProperties, OE, FCE, FSE, PF extends ModelProperties, OF, FCF, FSF, PG extends ModelProperties, OG, FCG, FSG, PH extends ModelProperties, OH, FCH, FSH, PI extends ModelProperties, OI, FCI, FSI>(options: UnionOptions, A: IModelType<PA, OA, FCA, FSA>, B: IModelType<PB, OB, FCB, FSB>, C: IModelType<PC, OC, FCC, FSC>, D: IModelType<PD, OD, FCD, FSD>, E: IModelType<PE, OE, FCE, FSE>, F: IModelType<PF, OF, FCF, FSF>, G: IModelType<PG, OG, FCG, FSG>, H: IModelType<PH, OH, FCH, FSH>, I: IModelType<PI, OI, FCI, FSI>): ITypeUnion<ModelCreationType2<PA, FCA> | ModelCreationType2<PB, FCB> | ModelCreationType2<PC, FCC> | ModelCreationType2<PD, FCD> | ModelCreationType2<PE, FCE> | ModelCreationType2<PF, FCF> | ModelCreationType2<PG, FCG> | ModelCreationType2<PH, FCH> | ModelCreationType2<PI, FCI>, ModelSnapshotType2<PA, FSA> | ModelSnapshotType2<PB, FSB> | ModelSnapshotType2<PC, FSC> | ModelSnapshotType2<PD, FSD> | ModelSnapshotType2<PE, FSE> | ModelSnapshotType2<PF, FSF> | ModelSnapshotType2<PG, FSG> | ModelSnapshotType2<PH, FSH> | ModelSnapshotType2<PI, FSI>, ModelInstanceType<PA, OA> | ModelInstanceType<PB, OB> | ModelInstanceType<PC, OC> | ModelInstanceType<PD, OD> | ModelInstanceType<PE, OE> | ModelInstanceType<PF, OF> | ModelInstanceType<PG, OG> | ModelInstanceType<PH, OH> | ModelInstanceType<PI, OI>>;
1837
+ declare function union<CA, SA, TA, CB, SB, TB>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>): ITypeUnion<CA | CB, SA | SB, TA | TB>;
1838
+ declare function union<CA, SA, TA, CB, SB, TB>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>): ITypeUnion<CA | CB, SA | SB, TA | TB>;
1839
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>): ITypeUnion<CA | CB | CC, SA | SB | SC, TA | TB | TC>;
1840
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>): ITypeUnion<CA | CB | CC, SA | SB | SC, TA | TB | TC>;
1841
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>): ITypeUnion<CA | CB | CC | CD, SA | SB | SC | SD, TA | TB | TC | TD>;
1842
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>): ITypeUnion<CA | CB | CC | CD, SA | SB | SC | SD, TA | TB | TC | TD>;
1843
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>): ITypeUnion<CA | CB | CC | CD | CE, SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>;
1844
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>): ITypeUnion<CA | CB | CC | CD | CE, SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>;
1845
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>): ITypeUnion<CA | CB | CC | CD | CE | CF, SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>;
1846
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>): ITypeUnion<CA | CB | CC | CD | CE | CF, SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>;
1847
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>): ITypeUnion<CA | CB | CC | CD | CE | CF | CG, SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>;
1848
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>): ITypeUnion<CA | CB | CC | CD | CE | CF | CG, SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>;
1849
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>): ITypeUnion<CA | CB | CC | CD | CE | CF | CG | CH, SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>;
1850
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>): ITypeUnion<CA | CB | CC | CD | CE | CF | CG | CH, SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>;
1851
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH, CI, SI, TI>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>, I: IType<CI, SI, TI>): ITypeUnion<CA | CB | CC | CD | CE | CF | CG | CH | CI, SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>;
1852
+ declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH, CI, SI, TI>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>, I: IType<CI, SI, TI>): ITypeUnion<CA | CB | CC | CD | CE | CF | CG | CH | CI, SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>;
1853
+ declare function union(...types: IAnyType[]): IAnyType;
1854
+ declare function union(dispatchOrType: UnionOptions | IAnyType, ...otherTypes: IAnyType[]): IAnyType;
1855
+ /**
1856
+ * Returns if a given value represents a union type.
1857
+ *
1858
+ * @param type
1859
+ * @returns
1860
+ */
1861
+ declare function isUnionType<IT extends IAnyType>(type: IT): type is IT;
1862
+
1863
+ /** @hidden */
1864
+ type ValidOptionalValue = string | boolean | number | null | undefined;
1865
+ /** @hidden */
1866
+ type ValidOptionalValues = [ValidOptionalValue, ...ValidOptionalValue[]];
1867
+ /** @hidden */
1868
+ type OptionalDefaultValueOrFunction<IT extends IAnyType> = IT["CreationType"] | IT["SnapshotType"] | (() => ExtractCSTWithSTN<IT>);
1869
+ /** @hidden */
1870
+ interface IOptionalIType<IT extends IAnyType, OptionalVals extends ValidOptionalValues> extends IType<IT["CreationType"] | OptionalVals[number], IT["SnapshotType"], IT["TypeWithoutSTN"]> {
1871
+ }
1872
+ declare function optional<IT extends IAnyType>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>): IOptionalIType<IT, [undefined]>;
1873
+ declare function optional<IT extends IAnyType, OptionalVals extends ValidOptionalValues>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>, optionalValues: OptionalVals): IOptionalIType<IT, OptionalVals>;
1874
+ /**
1875
+ * Returns if a value represents an optional type.
1876
+ *
1877
+ * @template IT
1878
+ * @param type
1879
+ * @returns
1880
+ */
1881
+ declare function isOptionalType<IT extends IAnyType>(type: IT): type is IT;
1882
+
1883
+ /** @hidden */
1884
+ interface IMaybeIType<IT extends IAnyType, C, O> extends IType<IT["CreationType"] | C, IT["SnapshotType"] | O, IT["TypeWithoutSTN"] | O> {
1885
+ }
1886
+ /** @hidden */
1887
+ interface IMaybe<IT extends IAnyType> extends IMaybeIType<IT, undefined, undefined> {
1888
+ }
1889
+ /** @hidden */
1890
+ interface IMaybeNull<IT extends IAnyType> extends IMaybeIType<IT, null | undefined, null> {
1891
+ }
1892
+ /**
1893
+ * `types.maybe` - Maybe will make a type nullable, and also optional.
1894
+ * The value `undefined` will be used to represent nullability.
1895
+ *
1896
+ * @param type
1897
+ * @returns
1898
+ */
1899
+ declare function maybe<IT extends IAnyType>(type: IT): IMaybe<IT>;
1900
+ /**
1901
+ * `types.maybeNull` - Maybe will make a type nullable, and also optional.
1902
+ * The value `null` will be used to represent no value.
1903
+ *
1904
+ * @param type
1905
+ * @returns
1906
+ */
1907
+ declare function maybeNull<IT extends IAnyType>(type: IT): IMaybeNull<IT>;
1908
+
1909
+ declare function late<T extends IAnyType>(type: () => T): T;
1910
+ declare function late<T extends IAnyType>(name: string, type: () => T): T;
1911
+ /**
1912
+ * Returns if a given value represents a late type.
1913
+ *
1914
+ * @param type
1915
+ * @returns
1916
+ */
1917
+ declare function isLateType<IT extends IAnyType>(type: IT): type is IT;
1918
+
1919
+ interface LazyOptions<T extends IType<any, any, any>, U> {
1920
+ loadType: () => Promise<T>;
1921
+ shouldLoadPredicate: (parent: U) => boolean;
1922
+ }
1923
+ declare function lazy<T extends IType<any, any, any>, U>(name: string, options: LazyOptions<T, U>): T;
1924
+
1925
+ declare function frozen<C>(subType: IType<C, any, any>): IType<C, C, C>;
1926
+ declare function frozen<T>(defaultValue: T): IType<T | undefined | null, T, T>;
1927
+ declare function frozen<T = any>(): IType<T, T, T>;
1928
+ /**
1929
+ * Returns if a given value represents a frozen type.
1930
+ *
1931
+ * @param type
1932
+ * @returns
1933
+ */
1934
+ declare function isFrozenType<IT extends IType<T | any, T, T>, T = any>(type: IT): type is IT;
1935
+
1936
+ type OnReferenceInvalidatedEvent<STN extends IAnyStateTreeNode> = {
1937
+ parent: IAnyStateTreeNode;
1938
+ invalidTarget: STN | undefined;
1939
+ invalidId: ReferenceIdentifier;
1940
+ replaceRef: (newRef: STN | null | undefined) => void;
1941
+ removeRef: () => void;
1942
+ cause: "detach" | "destroy" | "invalidSnapshotReference";
1943
+ };
1944
+ type OnReferenceInvalidated<STN extends IAnyStateTreeNode> = (event: OnReferenceInvalidatedEvent<STN>) => void;
1945
+ /** @hidden */
1946
+ type ReferenceT<IT extends IAnyType> = IT["TypeWithoutSTN"] & IStateTreeNode<IReferenceType<IT>>;
1947
+ interface ReferenceOptionsGetSet<IT extends IAnyComplexType> {
1948
+ get(identifier: ReferenceIdentifier, parent: IAnyStateTreeNode | null): ReferenceT<IT>;
1949
+ set(value: ReferenceT<IT>, parent: IAnyStateTreeNode | null): ReferenceIdentifier;
1950
+ }
1951
+ interface ReferenceOptionsOnInvalidated<IT extends IAnyComplexType> {
1952
+ onInvalidated: OnReferenceInvalidated<ReferenceT<IT>>;
1953
+ }
1954
+ type ReferenceOptions<IT extends IAnyComplexType> = ReferenceOptionsGetSet<IT> | ReferenceOptionsOnInvalidated<IT> | (ReferenceOptionsGetSet<IT> & ReferenceOptionsOnInvalidated<IT>);
1955
+ /** @hidden */
1956
+ interface IReferenceType<IT extends IAnyComplexType> extends IType<ReferenceIdentifier, ReferenceIdentifier, IT["TypeWithoutSTN"]> {
1957
+ }
1958
+ /**
1959
+ * `types.reference` - Creates a reference to another type, which should have defined an identifier.
1960
+ * See also the [reference and identifiers](https://github.com/mobxjs/mobx-state-tree#references-and-identifiers) section.
1961
+ */
1962
+ declare function reference<IT extends IAnyComplexType>(subType: IT, options?: ReferenceOptions<IT>): IReferenceType<IT>;
1963
+ /**
1964
+ * Returns if a given value represents a reference type.
1965
+ *
1966
+ * @param type
1967
+ * @returns
1968
+ */
1969
+ declare function isReferenceType<IT extends IReferenceType<any>>(type: IT): type is IT;
1970
+ declare function safeReference<IT extends IAnyComplexType>(subType: IT, options: (ReferenceOptionsGetSet<IT> | object) & {
1971
+ acceptsUndefined: false;
1972
+ onInvalidated?: OnReferenceInvalidated<ReferenceT<IT>>;
1973
+ }): IReferenceType<IT>;
1974
+ declare function safeReference<IT extends IAnyComplexType>(subType: IT, options?: (ReferenceOptionsGetSet<IT> | object) & {
1975
+ acceptsUndefined?: boolean;
1976
+ onInvalidated?: OnReferenceInvalidated<ReferenceT<IT>>;
1977
+ }): IMaybe<IReferenceType<IT>>;
1978
+
1979
+ /**
1980
+ * `types.identifier` - Identifiers are used to make references, lifecycle events and reconciling works.
1981
+ * Inside a state tree, for each type can exist only one instance for each given identifier.
1982
+ * For example there couldn't be 2 instances of user with id 1. If you need more, consider using references.
1983
+ * Identifier can be used only as type property of a model.
1984
+ * This type accepts as parameter the value type of the identifier field that can be either string or number.
1985
+ *
1986
+ * Example:
1987
+ * ```ts
1988
+ * const Todo = types.model("Todo", {
1989
+ * id: types.identifier,
1990
+ * title: types.string
1991
+ * })
1992
+ * ```
1993
+ *
1994
+ * @returns
1995
+ */
1996
+ declare const identifier: ISimpleType<string>;
1997
+ /**
1998
+ * `types.identifierNumber` - Similar to `types.identifier`. This one will serialize from / to a number when applying snapshots
1999
+ *
2000
+ * Example:
2001
+ * ```ts
2002
+ * const Todo = types.model("Todo", {
2003
+ * id: types.identifierNumber,
2004
+ * title: types.string
2005
+ * })
2006
+ * ```
2007
+ *
2008
+ * @returns
2009
+ */
2010
+ declare const identifierNumber: ISimpleType<number>;
2011
+ /**
2012
+ * Returns if a given value represents an identifier type.
2013
+ *
2014
+ * @param type
2015
+ * @returns
2016
+ */
2017
+ declare function isIdentifierType<IT extends typeof identifier | typeof identifierNumber>(type: IT): type is IT;
2018
+ /**
2019
+ * Valid types for identifiers.
2020
+ */
2021
+ type ReferenceIdentifier = string | number;
2022
+
2023
+ interface CustomTypeOptions<S, T> {
2024
+ /** Friendly name */
2025
+ name: string;
2026
+ /** given a serialized value and environment, how to turn it into the target type */
2027
+ fromSnapshot(snapshot: S, env?: any): T;
2028
+ /** return the serialization of the current value */
2029
+ toSnapshot(value: T): S;
2030
+ /** if true, this is a converted value, if false, it's a snapshot */
2031
+ isTargetType(value: T | S): boolean;
2032
+ /** a non empty string is assumed to be a validation error */
2033
+ getValidationMessage(snapshot: S): string;
2034
+ }
2035
+ /**
2036
+ * `types.custom` - Creates a custom type. Custom types can be used for arbitrary immutable values, that have a serializable representation. For example, to create your own Date representation, Decimal type etc.
2037
+ *
2038
+ * The signature of the options is:
2039
+ * ```ts
2040
+ * export interface CustomTypeOptions<S, T> {
2041
+ * // Friendly name
2042
+ * name: string
2043
+ * // given a serialized value and environment, how to turn it into the target type
2044
+ * fromSnapshot(snapshot: S, env: any): T
2045
+ * // return the serialization of the current value
2046
+ * toSnapshot(value: T): S
2047
+ * // if true, this is a converted value, if false, it's a snapshot
2048
+ * isTargetType(value: T | S): value is T
2049
+ * // a non empty string is assumed to be a validation error
2050
+ * getValidationMessage?(snapshot: S): string
2051
+ * }
2052
+ * ```
2053
+ *
2054
+ * Example:
2055
+ * ```ts
2056
+ * const DecimalPrimitive = types.custom<string, Decimal>({
2057
+ * name: "Decimal",
2058
+ * fromSnapshot(value: string) {
2059
+ * return new Decimal(value)
2060
+ * },
2061
+ * toSnapshot(value: Decimal) {
2062
+ * return value.toString()
2063
+ * },
2064
+ * isTargetType(value: string | Decimal): boolean {
2065
+ * return value instanceof Decimal
2066
+ * },
2067
+ * getValidationMessage(value: string): string {
2068
+ * if (/^-?\d+\.\d+$/.test(value)) return "" // OK
2069
+ * return `'${value}' doesn't look like a valid decimal number`
2070
+ * }
2071
+ * })
2072
+ *
2073
+ * const Wallet = types.model({
2074
+ * balance: DecimalPrimitive
2075
+ * })
2076
+ * ```
2077
+ *
2078
+ * @param options
2079
+ * @returns
2080
+ */
2081
+ declare function custom<S, T>(options: CustomTypeOptions<S, T>): IType<S | T, S, T>;
2082
+
2083
+ interface IResilientType<IT extends IAnyType, FT extends IAnyType> extends IType<IT["CreationType"] | FT["CreationType"], IT["SnapshotType"] | FT["SnapshotType"], IT["TypeWithoutSTN"] | FT["TypeWithoutSTN"]> {
2084
+ }
2085
+ /**
2086
+ * `types.resilient` - Wraps a type so that instantiation errors are caught
2087
+ * and a fallback type is used instead. This is useful for loading data that
2088
+ * may contain unknown or invalid subtrees (e.g., plugin types that are not
2089
+ * installed) without crashing the entire state tree.
2090
+ *
2091
+ * The `createFallbackSnapshot` callback receives the caught error and the
2092
+ * original snapshot, and must return a valid snapshot for the fallback type.
2093
+ *
2094
+ * @param type The type to wrap.
2095
+ * @param fallbackType The fallback type to use when instantiation fails.
2096
+ * @param createFallbackSnapshot Callback that produces a fallback snapshot from the error and original snapshot.
2097
+ * @returns A resilient type.
2098
+ */
2099
+ declare function resilient<IT extends IAnyType, FT extends IAnyType>(type: IT, fallbackType: FT, createFallbackSnapshot: (error: unknown, snapshot: any) => FT["CreationType"]): IResilientType<IT, FT>;
2100
+
2101
+ declare const types: {
2102
+ enumeration: typeof enumeration;
2103
+ model: typeof model;
2104
+ compose: typeof compose;
2105
+ custom: typeof custom;
2106
+ reference: typeof reference;
2107
+ safeReference: typeof safeReference;
2108
+ union: typeof union;
2109
+ optional: typeof optional;
2110
+ literal: typeof literal;
2111
+ maybe: typeof maybe;
2112
+ maybeNull: typeof maybeNull;
2113
+ refinement: typeof refinement;
2114
+ string: ISimpleType<string>;
2115
+ boolean: ISimpleType<boolean>;
2116
+ number: ISimpleType<number>;
2117
+ integer: ISimpleType<number>;
2118
+ float: ISimpleType<number>;
2119
+ finite: ISimpleType<number>;
2120
+ Date: IType<number | Date, number, Date>;
2121
+ map: typeof map;
2122
+ array: typeof array;
2123
+ frozen: typeof frozen;
2124
+ identifier: ISimpleType<string>;
2125
+ identifierNumber: ISimpleType<number>;
2126
+ late: typeof late;
2127
+ lazy: typeof lazy;
2128
+ undefined: ISimpleType<undefined>;
2129
+ null: ISimpleType<null>;
2130
+ snapshotProcessor: typeof snapshotProcessor;
2131
+ resilient: typeof resilient;
2132
+ };
2133
+
2134
+ export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware, createActionTrackingMiddleware2, decorate, destroy, detach, escapeJsonPath, flow, getChildType, getEnv, getIdentifier, getLivelinessChecking, getMembers, getNodeId, getParent, getParentOfType, getPath, getPathParts, getPropertyMembers, getRelativePath, getRoot, getRunningActionContext, getSnapshot, getType, hasParent, hasParentOfType, isActionContextChildOf, isActionContextThisOrChildOf, isAlive, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isProtected, isReferenceType, isRefinementType, isRoot, isStateTreeNode, isType, isUnionType, isValidReference, joinJsonPath, onAction, onPatch, onSnapshot, process, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setDevMode, setLivelinessChecking, setLivelynessChecking, splitJsonPath, types as t, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, unescapeJsonPath, unprotect, walk };
2135
+ export type { CustomTypeOptions, IActionContext, IActionRecorder, IActionTrackingMiddleware2Call, IActionTrackingMiddleware2Hooks, IActionTrackingMiddlewareHooks, IAnyComplexType, IAnyModelType, IAnyStateTreeNode, IAnyType, IArrayType, IComplexType, IDisposer, IJsonPatch, IMSTArray, IMSTMap, IMapType, IMaybe, IMaybeIType, IMaybeNull, IMiddlewareEvent, IMiddlewareEventType, IMiddlewareHandler, IModelReflectionData, IModelReflectionPropertiesData, IModelType, IOptionalIType, IPatchRecorder, IReferenceType, IReversibleJsonPatch, ISerializedActionCall, ISimpleType, ISnapshotProcessor, ISnapshotProcessors, IStateTreeNode, IType, ITypeUnion, Instance, LivelinessMode, LivelynessMode, ModelActions, ModelCreationType, ModelCreationType2, ModelInstanceType, ModelInstanceTypeProps, ModelPrimitive, ModelProperties, ModelPropertiesDeclaration, ModelPropertiesDeclarationToProperties, ModelSnapshotType, ModelSnapshotType2, NonEmptyObject, OnReferenceInvalidated, OnReferenceInvalidatedEvent, OptionalDefaultValueOrFunction, ReferenceIdentifier, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, SnapshotIn, SnapshotOrInstance, SnapshotOut, TypeOfValue, TypeOrStateTreeNodeToStateTreeNode, UnionOptions, UnionStringArray, ValidOptionalValue, ValidOptionalValues, _CustomCSProcessor, _CustomJoin, _CustomOrOther, _NotCustomized };