mobx-keystone 1.13.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +24 -7
  2. package/dist/mobx-keystone.esm.js +1123 -302
  3. package/dist/mobx-keystone.esm.mjs +1123 -302
  4. package/dist/mobx-keystone.umd.js +1123 -302
  5. package/dist/types/model/utils.d.ts +10 -0
  6. package/dist/types/modelShared/modelInfo.d.ts +7 -0
  7. package/dist/types/snapshot/SnapshotProcessingError.d.ts +20 -0
  8. package/dist/types/snapshot/index.d.ts +1 -0
  9. package/dist/types/types/SnapshotTypeMismatchError.d.ts +21 -0
  10. package/dist/types/types/TypeCheckError.d.ts +34 -6
  11. package/dist/types/types/index.d.ts +3 -2
  12. package/dist/types/types/objectBased/typesModel.d.ts +1 -1
  13. package/dist/types/types/typeCheckScope.d.ts +18 -0
  14. package/dist/types/types/utility/typesRefinement.d.ts +6 -2
  15. package/dist/types/utils/errorDiagnostics.d.ts +1 -0
  16. package/package.json +2 -2
  17. package/src/dataModel/BaseDataModel.ts +9 -9
  18. package/src/dataModel/newDataModel.ts +11 -11
  19. package/src/model/newModel.ts +283 -283
  20. package/src/model/utils.ts +31 -2
  21. package/src/modelShared/modelInfo.ts +17 -0
  22. package/src/modelShared/sharedInternalModel.ts +8 -3
  23. package/src/parent/path.ts +381 -370
  24. package/src/patch/applyPatches.ts +34 -25
  25. package/src/snapshot/SnapshotProcessingError.ts +45 -0
  26. package/src/snapshot/applySnapshot.ts +59 -27
  27. package/src/snapshot/fromArraySnapshot.ts +33 -32
  28. package/src/snapshot/fromModelSnapshot.ts +34 -21
  29. package/src/snapshot/fromPlainObjectSnapshot.ts +42 -37
  30. package/src/snapshot/fromSnapshot.ts +36 -20
  31. package/src/snapshot/index.ts +1 -0
  32. package/src/snapshot/reconcileArraySnapshot.ts +70 -65
  33. package/src/snapshot/reconcileModelSnapshot.ts +87 -71
  34. package/src/snapshot/reconcilePlainObjectSnapshot.ts +6 -3
  35. package/src/snapshot/reconcileSnapshot.ts +88 -78
  36. package/src/tweaker/tweak.ts +183 -183
  37. package/src/tweaker/tweakPlainObject.ts +2 -2
  38. package/src/tweaker/typeChecking.ts +150 -71
  39. package/src/types/SnapshotTypeMismatchError.ts +46 -0
  40. package/src/types/TypeCheckError.ts +184 -51
  41. package/src/types/TypeChecker.ts +116 -28
  42. package/src/types/arrayBased/typesArray.ts +167 -109
  43. package/src/types/arrayBased/typesTuple.ts +165 -113
  44. package/src/types/index.ts +6 -5
  45. package/src/types/objectBased/typesArraySet.ts +128 -111
  46. package/src/types/objectBased/typesDataModelData.ts +3 -2
  47. package/src/types/objectBased/typesModel.ts +20 -7
  48. package/src/types/objectBased/typesObject.ts +349 -225
  49. package/src/types/objectBased/typesObjectMap.ts +139 -124
  50. package/src/types/objectBased/typesRecord.ts +174 -129
  51. package/src/types/objectBased/typesRef.ts +92 -82
  52. package/src/types/primitiveBased/typesPrimitive.ts +216 -186
  53. package/src/types/typeCheck.ts +52 -21
  54. package/src/types/typeCheckScope.ts +109 -0
  55. package/src/types/utility/typesOr.ts +200 -189
  56. package/src/types/utility/typesRefinement.ts +124 -111
  57. package/src/types/utility/typesTag.ts +87 -80
  58. package/src/types/utility/typesUnchecked.ts +39 -38
  59. package/src/utils/errorDiagnostics.ts +204 -0
  60. package/src/utils/index.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,10 +1,27 @@
1
- # Change Log
2
-
3
- ## 1.13.0
4
-
5
- - Added array syntax as a `tProp` union shorthand, for example `tProp([String, Number])` as an alias for `tProp(types.or(String, Number))`.
6
- - Docs: added a migration guide for moving from `mobx-state-tree` to `mobx-keystone`.
7
- - `withSetter` now supports a value transform function (for example `withSetter(cloneTreeValue)`) for preprocessing setter values.
1
+ # Change Log
2
+
3
+ ## 1.15.0
4
+
5
+ - Added `registerModels(...)` to explicitly keep model/data-model class references at runtime (useful in snapshot-heavy apps where imports may be elided).
6
+ - Improved unknown model registry errors to include actionable guidance (`registerModels`, side-effect/runtime imports, and typed/runtime model references).
7
+ - Performance: model auto type-checking is now significantly faster by validating only changed branches and invalidating caches more selectively (including arrays, tuples, records, and wrapper types such as `or`/`refinement`). Before these changes setting a single type-checked property had a penalty of a 95% vs the non type-checked version. After changes this penalty is reduced to a 25% instead.
8
+
9
+ ## 1.14.0
10
+
11
+ - `TypeCheckError` now supports a single object parameter and still accepts positional constructor arguments for backward compatibility.
12
+ - `TypeCheckError.throw()` now throws `TypeCheckErrorFailure` (which extends `MobxKeystoneError`), and union snapshot mismatches now throw `SnapshotTypeMismatchError` (also extending `MobxKeystoneError`) with structured metadata.
13
+ - Snapshot processing now throws a dedicated `SnapshotProcessingError` (extends `MobxKeystoneError`) across `fromSnapshot` / `applySnapshot` / reconciliation paths.
14
+ - `SnapshotProcessingError` messages now include enriched diagnostics text (full deep path, value preview, and model trail when available), making it much easier to pinpoint failing nested fields quickly.
15
+ - `SnapshotProcessingError`, `SnapshotTypeMismatchError`, and `TypeCheckError` now share one diagnostics message formatter and a consistent layout: `MSG - Path: ... - Value: ... - Model trail: ...`, so error output is predictable across snapshot and type-check flows.
16
+ - Improved snapshot/type error diagnostics end-to-end: path-aware messages across `fromSnapshot` / `applySnapshot` / union snapshot processing, plus structured error metadata (`path`, `expectedTypeName`, `actualValue`, `typeCheckedValue`, `modelTrail`) on thrown errors when available for easier tooling and debugging.
17
+ - Note: because diagnostics were improved, error message text changed in these paths (`TypeCheckError`, `SnapshotProcessingError`, `SnapshotTypeMismatchError`, and related snapshot/apply patches flows). If you assert exact error strings, update expectations.
18
+ - `applyPatches` reconciliation errors now also include accurate patch paths in diagnostics.
19
+
20
+ ## 1.13.0
21
+
22
+ - Added array syntax as a `tProp` union shorthand, for example `tProp([String, Number])` as an alias for `tProp(types.or(String, Number))`.
23
+ - Docs: added a migration guide for moving from `mobx-state-tree` to `mobx-keystone`.
24
+ - `withSetter` now supports a value transform function (for example `withSetter(cloneTreeValue)`) for preprocessing setter values.
8
25
  - `cloneTreeValue` now accepts clone options (same as `clone`), so callers can customize behavior (for example `generateNewIds: false`).
9
26
 
10
27
  ## 1.12.2