mobx-keystone 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/mobx-keystone.esm.js +151 -312
- package/dist/mobx-keystone.esm.mjs +151 -312
- package/dist/mobx-keystone.umd.js +151 -312
- package/dist/types/action/applyAction.d.ts +1 -1
- package/dist/types/action/applyMethodCall.d.ts +1 -1
- package/dist/types/action/index.d.ts +12 -12
- package/dist/types/action/isModelAction.d.ts +1 -1
- package/dist/types/action/middleware.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/actionSerialization.d.ts +3 -3
- package/dist/types/actionMiddlewares/actionSerialization/applySerializedAction.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionSerialization/arraySerializer.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionSerialization/dateSerializer.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/index.d.ts +3 -3
- package/dist/types/actionMiddlewares/actionSerialization/mapSerializer.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionSerialization/objectPathSerializer.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionSerialization/objectSnapshotSerializer.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/plainObjectSerializer.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/primitiveSerializer.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/setSerializer.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionTrackingMiddleware.d.ts +3 -3
- package/dist/types/actionMiddlewares/index.d.ts +6 -6
- package/dist/types/actionMiddlewares/onActionMiddleware.d.ts +3 -3
- package/dist/types/actionMiddlewares/readonlyMiddleware.d.ts +1 -1
- package/dist/types/actionMiddlewares/transactionMiddleware.d.ts +2 -2
- package/dist/types/actionMiddlewares/undoMiddleware.d.ts +8 -8
- package/dist/types/computedTree/index.d.ts +1 -1
- package/dist/types/context/index.d.ts +1 -1
- package/dist/types/dataModel/BaseDataModel.d.ts +3 -3
- package/dist/types/dataModel/DataModel.d.ts +3 -3
- package/dist/types/dataModel/getDataModelMetadata.d.ts +3 -3
- package/dist/types/dataModel/index.d.ts +4 -4
- package/dist/types/dataModel/utils.d.ts +1 -1
- package/dist/types/deepChange/index.d.ts +1 -1
- package/dist/types/deepChange/onDeepChange.d.ts +1 -1
- package/dist/types/frozen/Frozen.d.ts +1 -1
- package/dist/types/frozen/index.d.ts +1 -1
- package/dist/types/globalConfig/index.d.ts +1 -1
- package/dist/types/index.d.ts +24 -24
- package/dist/types/model/BaseModel.d.ts +5 -5
- package/dist/types/model/Model.d.ts +3 -3
- package/dist/types/model/getModelMetadata.d.ts +3 -3
- package/dist/types/model/index.d.ts +6 -6
- package/dist/types/model/mixins.d.ts +4 -4
- package/dist/types/model/utils.d.ts +4 -4
- package/dist/types/modelShared/BaseModelShared.d.ts +5 -5
- package/dist/types/modelShared/index.d.ts +4 -4
- package/dist/types/modelShared/modelDecorator.d.ts +3 -3
- package/dist/types/modelShared/modelInfo.d.ts +3 -3
- package/dist/types/modelShared/newModel.d.ts +3 -3
- package/dist/types/modelShared/prop.d.ts +3 -3
- package/dist/types/modelShared/sharedInternalModel.d.ts +4 -4
- package/dist/types/parent/findParent.d.ts +1 -1
- package/dist/types/parent/index.d.ts +9 -9
- package/dist/types/parent/path.d.ts +1 -1
- package/dist/types/patch/Patch.d.ts +1 -1
- package/dist/types/patch/applyPatches.d.ts +1 -1
- package/dist/types/patch/emitPatch.d.ts +1 -1
- package/dist/types/patch/index.d.ts +5 -5
- package/dist/types/patch/jsonPatch.d.ts +2 -2
- package/dist/types/patch/patchRecorder.d.ts +2 -2
- package/dist/types/redux/index.d.ts +2 -2
- package/dist/types/redux/redux.d.ts +3 -3
- package/dist/types/ref/Ref.d.ts +3 -3
- package/dist/types/ref/core.d.ts +2 -2
- package/dist/types/ref/customRef.d.ts +2 -2
- package/dist/types/ref/index.d.ts +4 -4
- package/dist/types/ref/rootRef.d.ts +2 -2
- package/dist/types/rootStore/index.d.ts +1 -1
- package/dist/types/snapshot/SnapshotOf.d.ts +5 -5
- package/dist/types/snapshot/SnapshotProcessingError.d.ts +2 -2
- package/dist/types/snapshot/applySnapshot.d.ts +1 -1
- package/dist/types/snapshot/cloneTreeValue.d.ts +1 -1
- package/dist/types/snapshot/fromSnapshot.d.ts +2 -2
- package/dist/types/snapshot/getSnapshot.d.ts +2 -2
- package/dist/types/snapshot/index.d.ts +8 -8
- package/dist/types/snapshot/onSnapshot.d.ts +1 -1
- package/dist/types/standardActions/index.d.ts +3 -3
- package/dist/types/standardActions/objectActions.d.ts +1 -1
- package/dist/types/transforms/asMap.d.ts +1 -1
- package/dist/types/transforms/asSet.d.ts +2 -2
- package/dist/types/transforms/bigint.d.ts +1 -1
- package/dist/types/transforms/date.d.ts +1 -1
- package/dist/types/transforms/index.d.ts +4 -4
- package/dist/types/treeUtils/draft.d.ts +1 -1
- package/dist/types/treeUtils/index.d.ts +3 -3
- package/dist/types/tweaker/index.d.ts +2 -2
- package/dist/types/tweaker/tweak.d.ts +1 -1
- package/dist/types/types/SnapshotTypeMismatchError.d.ts +2 -2
- package/dist/types/types/TypeCheckError.d.ts +2 -2
- package/dist/types/types/TypeChecker.d.ts +3 -3
- package/dist/types/types/arrayBased/typesArray.d.ts +2 -2
- package/dist/types/types/arrayBased/typesTuple.d.ts +2 -2
- package/dist/types/types/getTypeInfo.d.ts +2 -2
- package/dist/types/types/index.d.ts +7 -7
- package/dist/types/types/objectBased/typesArraySet.d.ts +3 -3
- package/dist/types/types/objectBased/typesDataModelData.d.ts +4 -4
- package/dist/types/types/objectBased/typesModel.d.ts +4 -4
- package/dist/types/types/objectBased/typesObject.d.ts +3 -3
- package/dist/types/types/objectBased/typesObjectMap.d.ts +3 -3
- package/dist/types/types/objectBased/typesRecord.d.ts +2 -2
- package/dist/types/types/objectBased/typesRef.d.ts +3 -3
- package/dist/types/types/primitiveBased/typesEnum.d.ts +1 -1
- package/dist/types/types/primitiveBased/typesPrimitive.d.ts +3 -3
- package/dist/types/types/primitiveBased/typesRefinedPrimitive.d.ts +2 -2
- package/dist/types/types/schemas.d.ts +5 -5
- package/dist/types/types/tProp.d.ts +4 -4
- package/dist/types/types/typeCheck.d.ts +2 -2
- package/dist/types/types/types.d.ts +39 -39
- package/dist/types/types/utility/typeToStoredData.d.ts +2 -2
- package/dist/types/types/utility/typesBigInt.d.ts +1 -1
- package/dist/types/types/utility/typesCodec.d.ts +6 -6
- package/dist/types/types/utility/typesCodecCore.d.ts +4 -4
- package/dist/types/types/utility/typesCodecSupport.d.ts +4 -4
- package/dist/types/types/utility/typesDate.d.ts +2 -2
- package/dist/types/types/utility/typesMap.d.ts +2 -2
- package/dist/types/types/utility/typesMaybe.d.ts +1 -1
- package/dist/types/types/utility/typesOr.d.ts +2 -2
- package/dist/types/types/utility/typesRefinement.d.ts +3 -3
- package/dist/types/types/utility/typesSet.d.ts +3 -3
- package/dist/types/types/utility/typesSkipCheck.d.ts +2 -2
- package/dist/types/types/utility/typesTag.d.ts +2 -2
- package/dist/types/types/utility/typesUnchecked.d.ts +2 -2
- package/dist/types/utils/ModelPool.d.ts +1 -1
- package/dist/types/wrappers/ArraySet.d.ts +1 -1
- package/dist/types/wrappers/ObjectMap.d.ts +1 -1
- package/dist/types/wrappers/asMap.d.ts +1 -1
- package/dist/types/wrappers/asSet.d.ts +1 -1
- package/dist/types/wrappers/index.d.ts +4 -4
- package/package.json +5 -18
- package/src/action/modelAction.ts +1 -1
- package/src/action/modelFlow.ts +1 -1
- package/src/dataModel/BaseDataModel.ts +5 -5
- package/src/model/BaseModel.ts +7 -6
- package/src/model/mixins.ts +1 -1
- package/src/model/newModel.ts +1 -1
- package/src/modelShared/modelDecorator.ts +4 -6
- package/src/modelShared/modelInfo.ts +2 -1
- package/src/modelShared/sharedInternalModel.ts +1 -1
- package/src/ref/Ref.ts +1 -1
- package/src/snapshot/SnapshotterAndReconcilerPriority.ts +2 -1
- package/src/snapshot/fromModelSnapshot.ts +1 -1
- package/src/snapshot/fromSnapshot.ts +1 -1
- package/src/transforms/ImmutableDate.ts +19 -19
- package/src/tweaker/tweakArray.ts +1 -1
- package/src/tweaker/tweakFrozen.ts +1 -1
- package/src/tweaker/tweakModel.ts +1 -1
- package/src/tweaker/tweakPlainObject.ts +1 -1
- package/src/types/arrayBased/typesArray.ts +1 -1
- package/src/types/arrayBased/typesTuple.ts +1 -1
- package/src/types/objectBased/typesArraySet.ts +1 -1
- package/src/types/objectBased/typesModel.ts +2 -2
- package/src/types/objectBased/typesObject.ts +1 -1
- package/src/types/objectBased/typesObjectMap.ts +1 -1
- package/src/types/objectBased/typesRecord.ts +1 -1
- package/src/types/objectBased/typesRef.ts +2 -2
- package/src/types/primitiveBased/typesPrimitive.ts +1 -1
- package/src/types/schemas.ts +1 -1
- package/src/types/utility/typesCodecCore.ts +1 -1
- package/src/types/utility/typesCodecSupport.ts +2 -0
- package/src/types/utility/typesOr.ts +2 -2
- package/src/types/utility/typesRefinement.ts +1 -1
- package/src/utils/index.ts +20 -13
- package/src/wrappers/ArraySet.ts +3 -5
- package/src/wrappers/ObjectMap.ts +3 -5
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { ArrayTypeInfo, typesArray } from
|
|
2
|
-
import { TupleTypeInfo, typesTuple } from
|
|
3
|
-
import { ArraySetTypeInfo, typesArraySet } from
|
|
4
|
-
import { typesDataModelData } from
|
|
5
|
-
import { ModelTypeInfo, ModelTypeInfoProps, typesModel } from
|
|
6
|
-
import { FrozenTypeInfo, ObjectTypeInfo, ObjectTypeInfoProps, typesFrozen, typesObject } from
|
|
7
|
-
import { ObjectMapTypeInfo, typesObjectMap } from
|
|
8
|
-
import { RecordTypeInfo, typesRecord } from
|
|
9
|
-
import { RefTypeInfo, typesRef } from
|
|
10
|
-
import { typesEnum } from
|
|
11
|
-
import { BooleanTypeInfo, LiteralTypeInfo, NumberTypeInfo, StringTypeInfo, typesLiteral } from
|
|
12
|
-
import { AnyType } from
|
|
13
|
-
import { CodecTypeInfo, typesCodec } from
|
|
14
|
-
import { typesMaybe, typesMaybeNull } from
|
|
15
|
-
import { OrTypeInfo, typesOr } from
|
|
16
|
-
import { RefinementTypeInfo, typesRefinement } from
|
|
17
|
-
import { SkipCheckTypeInfo, typesSkipCheck } from
|
|
18
|
-
import { TagTypeInfo, typesTag } from
|
|
19
|
-
import { typesUnchecked, UncheckedTypeInfo } from
|
|
20
|
-
export { getTypeInfo } from
|
|
21
|
-
export { TypeInfo } from
|
|
1
|
+
import { ArrayTypeInfo, typesArray } from "./arrayBased/typesArray";
|
|
2
|
+
import { TupleTypeInfo, typesTuple } from "./arrayBased/typesTuple";
|
|
3
|
+
import { ArraySetTypeInfo, typesArraySet } from "./objectBased/typesArraySet";
|
|
4
|
+
import { typesDataModelData } from "./objectBased/typesDataModelData";
|
|
5
|
+
import { ModelTypeInfo, type ModelTypeInfoProps, typesModel } from "./objectBased/typesModel";
|
|
6
|
+
import { FrozenTypeInfo, ObjectTypeInfo, type ObjectTypeInfoProps, typesFrozen, typesObject } from "./objectBased/typesObject";
|
|
7
|
+
import { ObjectMapTypeInfo, typesObjectMap } from "./objectBased/typesObjectMap";
|
|
8
|
+
import { RecordTypeInfo, typesRecord } from "./objectBased/typesRecord";
|
|
9
|
+
import { RefTypeInfo, typesRef } from "./objectBased/typesRef";
|
|
10
|
+
import { typesEnum } from "./primitiveBased/typesEnum";
|
|
11
|
+
import { BooleanTypeInfo, LiteralTypeInfo, NumberTypeInfo, StringTypeInfo, typesLiteral } from "./primitiveBased/typesPrimitive";
|
|
12
|
+
import type { AnyType } from "./schemas";
|
|
13
|
+
import { CodecTypeInfo, typesCodec } from "./utility/typesCodec";
|
|
14
|
+
import { typesMaybe, typesMaybeNull } from "./utility/typesMaybe";
|
|
15
|
+
import { OrTypeInfo, typesOr } from "./utility/typesOr";
|
|
16
|
+
import { RefinementTypeInfo, typesRefinement } from "./utility/typesRefinement";
|
|
17
|
+
import { SkipCheckTypeInfo, typesSkipCheck } from "./utility/typesSkipCheck";
|
|
18
|
+
import { TagTypeInfo, typesTag } from "./utility/typesTag";
|
|
19
|
+
import { typesUnchecked, UncheckedTypeInfo } from "./utility/typesUnchecked";
|
|
20
|
+
export { getTypeInfo } from "./getTypeInfo";
|
|
21
|
+
export { TypeInfo } from "./TypeChecker";
|
|
22
22
|
export type { ModelTypeInfoProps, ObjectTypeInfoProps };
|
|
23
23
|
export { ArraySetTypeInfo, ArrayTypeInfo, BooleanTypeInfo, CodecTypeInfo, FrozenTypeInfo, LiteralTypeInfo, ModelTypeInfo, NumberTypeInfo, ObjectMapTypeInfo, ObjectTypeInfo, OrTypeInfo, RecordTypeInfo, RefinementTypeInfo, RefTypeInfo, SkipCheckTypeInfo, StringTypeInfo, TagTypeInfo, TupleTypeInfo, UncheckedTypeInfo, };
|
|
24
24
|
export declare const types: {
|
|
25
25
|
literal: typeof typesLiteral;
|
|
26
|
-
undefined: import(
|
|
27
|
-
null: import(
|
|
28
|
-
boolean: import(
|
|
29
|
-
number: import(
|
|
30
|
-
string: import(
|
|
26
|
+
undefined: import("./schemas").IdentityType<undefined>;
|
|
27
|
+
null: import("./schemas").IdentityType<null>;
|
|
28
|
+
boolean: import("./schemas").IdentityType<boolean>;
|
|
29
|
+
number: import("./schemas").IdentityType<number>;
|
|
30
|
+
string: import("./schemas").IdentityType<string>;
|
|
31
31
|
or: typeof typesOr;
|
|
32
32
|
maybe: typeof typesMaybe;
|
|
33
33
|
maybeNull: typeof typesMaybeNull;
|
|
@@ -44,35 +44,35 @@ export declare const types: {
|
|
|
44
44
|
tag: typeof typesTag;
|
|
45
45
|
refinement: typeof typesRefinement;
|
|
46
46
|
codec: typeof typesCodec;
|
|
47
|
-
integer: import(
|
|
48
|
-
nonEmptyString: import(
|
|
47
|
+
integer: import("./schemas").IdentityType<number>;
|
|
48
|
+
nonEmptyString: import("./schemas").IdentityType<string>;
|
|
49
49
|
objectMap: typeof typesObjectMap;
|
|
50
50
|
arraySet: typeof typesArraySet;
|
|
51
51
|
tuple: typeof typesTuple;
|
|
52
|
-
bigint: import(
|
|
53
|
-
dateAsTimestamp: import(
|
|
54
|
-
dateAsIsoString: import(
|
|
52
|
+
bigint: import(".").CodecFromEncoded<StringConstructor, bigint>;
|
|
53
|
+
dateAsTimestamp: import(".").CodecFromEncoded<NumberConstructor, Date>;
|
|
54
|
+
dateAsIsoString: import(".").CodecFromEncoded<StringConstructor, Date>;
|
|
55
55
|
/**
|
|
56
56
|
* @deprecated Prefer `types.mapFromArray(...)` for runtime `Map` values.
|
|
57
57
|
*/
|
|
58
|
-
mapArray<T extends AnyType>(valueType: T): import(
|
|
58
|
+
mapArray<T extends AnyType>(valueType: T): import("./schemas").ArrayType<import("./schemas").ArrayType<[import("./schemas").IdentityType<string>, T]>[]>;
|
|
59
59
|
/**
|
|
60
60
|
* @deprecated Prefer `types.setFromArray(...)` for runtime `Set` values.
|
|
61
61
|
*/
|
|
62
|
-
setArray<T extends AnyType>(valueType: T): import(
|
|
62
|
+
setArray<T extends AnyType>(valueType: T): import("./schemas").ArrayType<T[]>;
|
|
63
63
|
/**
|
|
64
64
|
* @deprecated Prefer `types.mapFromObject(...)` for runtime `Map` values.
|
|
65
65
|
*/
|
|
66
|
-
mapObject<T extends AnyType>(valueType: T): import(
|
|
67
|
-
mapFromObject<T extends AnyType>(valueType: T): import(
|
|
68
|
-
mapFromArray<TKeyType extends AnyType, TValueType extends AnyType>(keyType: TKeyType, valueType: TValueType): import(
|
|
69
|
-
setFromArray<T extends AnyType>(valueType: T): import(
|
|
66
|
+
mapObject<T extends AnyType>(valueType: T): import("./schemas").RecordType<T>;
|
|
67
|
+
mapFromObject<T extends AnyType>(valueType: T): import(".").CodecFromEncoded<import("./schemas").RecordType<T>, Map<string, import("./schemas").TypeToData<T>>>;
|
|
68
|
+
mapFromArray<TKeyType extends AnyType, TValueType extends AnyType>(keyType: TKeyType, valueType: TValueType): import(".").CodecFromEncoded<import("./schemas").ArrayType<import("./schemas").ArrayType<[TKeyType, TValueType]>[]>, Map<import("./schemas").TypeToData<TKeyType>, import("./schemas").TypeToData<TValueType>>>;
|
|
69
|
+
setFromArray<T extends AnyType>(valueType: T): import(".").CodecFromEncoded<import("./schemas").ArrayType<T[]>, import("mobx").ObservableSet<import("./schemas").TypeToData<T>> | Set<import("./schemas").TypeToData<T>>>;
|
|
70
70
|
/**
|
|
71
71
|
* @deprecated Prefer `types.dateAsIsoString` instead.
|
|
72
72
|
*/
|
|
73
|
-
dateString: import(
|
|
73
|
+
dateString: import("./schemas").IdentityType<string>;
|
|
74
74
|
/**
|
|
75
75
|
* @deprecated Prefer `types.dateAsTimestamp` instead.
|
|
76
76
|
*/
|
|
77
|
-
dateTimestamp: import(
|
|
77
|
+
dateTimestamp: import("./schemas").IdentityType<number>;
|
|
78
78
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SimplifyObject } from
|
|
2
|
-
import { ArrayType, ObjectOptionalKeys, ObjectType, ObjectTypeFunction, RecordType, TypeToData } from
|
|
1
|
+
import type { SimplifyObject } from "../../utils/types";
|
|
2
|
+
import type { ArrayType, ObjectOptionalKeys, ObjectType, ObjectTypeFunction, RecordType, TypeToData } from "../schemas";
|
|
3
3
|
type ArrayStoredData<S extends readonly unknown[]> = number extends S["length"] ? Array<TypeToStoredData<S[number]>> : {
|
|
4
4
|
[k in keyof S]: TypeToStoredData<S[k]>;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const typesBigInt: import(
|
|
1
|
+
export declare const typesBigInt: import("./typesCodecCore").CodecFromEncoded<StringConstructor, bigint>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { typesBigInt } from
|
|
2
|
-
import { CodecTypeInfo, typesCodec } from
|
|
3
|
-
import { createCodecPropTransform, resolveCodecSupport, resolveStoredType, resolveStoredTypeChecker } from
|
|
4
|
-
import { typesDateAsIsoString, typesDateAsTimestamp } from
|
|
5
|
-
import { typesMapFromArray, typesMapFromObject } from
|
|
6
|
-
import { typesSetFromArray } from
|
|
1
|
+
import { typesBigInt } from "./typesBigInt";
|
|
2
|
+
import { CodecTypeInfo, typesCodec } from "./typesCodecCore";
|
|
3
|
+
import { createCodecPropTransform, resolveCodecSupport, resolveStoredType, resolveStoredTypeChecker } from "./typesCodecSupport";
|
|
4
|
+
import { typesDateAsIsoString, typesDateAsTimestamp } from "./typesDate";
|
|
5
|
+
import { typesMapFromArray, typesMapFromObject } from "./typesMap";
|
|
6
|
+
import { typesSetFromArray } from "./typesSet";
|
|
7
7
|
export { CodecTypeInfo, createCodecPropTransform, resolveCodecSupport, resolveStoredType, resolveStoredTypeChecker, typesBigInt, typesCodec, typesDateAsIsoString, typesDateAsTimestamp, typesMapFromArray, typesMapFromObject, typesSetFromArray, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModelPropTransform } from
|
|
2
|
-
import { AnyStandardType, AnyType, CodecType, TypeToData, TypeToSnapshotIn, TypeToSnapshotOut } from
|
|
3
|
-
import { TypeCheckerBaseType, TypeInfo } from
|
|
4
|
-
import { TypeToStoredData } from
|
|
1
|
+
import type { ModelPropTransform } from "../../modelShared/prop";
|
|
2
|
+
import type { AnyStandardType, AnyType, CodecType, TypeToData, TypeToSnapshotIn, TypeToSnapshotOut } from "../schemas";
|
|
3
|
+
import { TypeCheckerBaseType, TypeInfo } from "../TypeChecker";
|
|
4
|
+
import type { TypeToStoredData } from "./typeToStoredData";
|
|
5
5
|
export interface RuntimeAdapter<Stored, Runtime> {
|
|
6
6
|
toRuntime(stored: Stored, setStored?: (stored: Stored) => void): Runtime;
|
|
7
7
|
toStored(runtime: Runtime): Stored;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModelPropTransform } from
|
|
2
|
-
import { AnyStandardType, AnyType } from
|
|
3
|
-
import { ResolvedCodecSupport } from
|
|
1
|
+
import type { ModelPropTransform } from "../../modelShared/prop";
|
|
2
|
+
import type { AnyStandardType, AnyType } from "../schemas";
|
|
3
|
+
import { type ResolvedCodecSupport } from "./typesCodecCore";
|
|
4
4
|
export declare function resolveCodecSupport(type: AnyType): ResolvedCodecSupport;
|
|
5
5
|
export declare function resolveStoredType(type: AnyType): AnyStandardType;
|
|
6
|
-
export declare function resolveStoredTypeChecker(type: AnyType): import(
|
|
6
|
+
export declare function resolveStoredTypeChecker(type: AnyType): import("../TypeChecker").TypeChecker;
|
|
7
7
|
export declare function createCodecPropTransform(type: AnyType): ModelPropTransform<any, unknown>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const typesDateAsTimestamp: import(
|
|
2
|
-
export declare const typesDateAsIsoString: import(
|
|
1
|
+
export declare const typesDateAsTimestamp: import("./typesCodecCore").CodecFromEncoded<NumberConstructor, Date>;
|
|
2
|
+
export declare const typesDateAsIsoString: import("./typesCodecCore").CodecFromEncoded<StringConstructor, Date>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyType, ArrayType, RecordType, TypeToData } from
|
|
2
|
-
import { CodecFromEncoded } from
|
|
1
|
+
import type { AnyType, ArrayType, RecordType, TypeToData } from "../schemas";
|
|
2
|
+
import type { CodecFromEncoded } from "./typesCodecCore";
|
|
3
3
|
export declare function typesMapFromObject<TValueType extends AnyType>(valueType: TValueType): CodecFromEncoded<RecordType<TValueType>, Map<string, TypeToData<TValueType>>>;
|
|
4
4
|
export declare function typesMapFromArray<TKeyType extends AnyType, TValueType extends AnyType>(keyType: TKeyType, valueType: TValueType): CodecFromEncoded<ArrayType<ArrayType<[TKeyType, TValueType]>[]>, Map<TypeToData<TKeyType>, TypeToData<TValueType>>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnyStandardType, AnyType } from
|
|
2
|
-
import { TypeInfo } from
|
|
1
|
+
import type { AnyStandardType, AnyType } from "../schemas";
|
|
2
|
+
import { TypeInfo } from "../TypeChecker";
|
|
3
3
|
/**
|
|
4
4
|
* A type that represents the union of several other types (a | b | c | ...).
|
|
5
5
|
* Accepts a dispatcher that, given a snapshot, returns the type
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnyStandardType, AnyType, TypeToData } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { AnyStandardType, AnyType, TypeToData } from "../schemas";
|
|
2
|
+
import { TypeInfo } from "../TypeChecker";
|
|
3
|
+
import { TypeCheckError } from "../TypeCheckError";
|
|
4
4
|
/**
|
|
5
5
|
* A refinement over a given type. This allows you to do extra checks
|
|
6
6
|
* over models, ensure numbers are integers, etc.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ObservableSet } from
|
|
2
|
-
import { AnyType, ArrayType, TypeToData } from
|
|
3
|
-
import { CodecFromEncoded } from
|
|
1
|
+
import type { ObservableSet } from "mobx";
|
|
2
|
+
import type { AnyType, ArrayType, TypeToData } from "../schemas";
|
|
3
|
+
import type { CodecFromEncoded } from "./typesCodecCore";
|
|
4
4
|
export declare function typesSetFromArray<TValueType extends AnyType>(valueType: TValueType): CodecFromEncoded<ArrayType<TValueType[]>, Set<TypeToData<TValueType>> | ObservableSet<TypeToData<TValueType>>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnyStandardType, AnyType } from
|
|
2
|
-
import { TypeInfo } from
|
|
1
|
+
import type { AnyStandardType, AnyType } from "../schemas";
|
|
2
|
+
import { TypeInfo } from "../TypeChecker";
|
|
3
3
|
/**
|
|
4
4
|
* A type that wraps another type but skips runtime validation.
|
|
5
5
|
* Unlike `types.unchecked()`, this preserves the wrapped type's
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnyStandardType, AnyType } from
|
|
2
|
-
import { TypeInfo } from
|
|
1
|
+
import type { AnyStandardType, AnyType } from "../schemas";
|
|
2
|
+
import { TypeInfo } from "../TypeChecker";
|
|
3
3
|
/**
|
|
4
4
|
* Wrap a given type with tag information.
|
|
5
5
|
* This allows you to associate metadata with the type of a prop that
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IdentityType } from
|
|
2
|
-
import { TypeInfo } from
|
|
1
|
+
import type { IdentityType } from "../schemas";
|
|
2
|
+
import { TypeInfo } from "../TypeChecker";
|
|
3
3
|
/**
|
|
4
4
|
* A type that represents a given value that won't be type checked.
|
|
5
5
|
* This is basically a way to bail out of the runtime type checking system.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./ArraySet";
|
|
2
|
+
export * from "./asMap";
|
|
3
|
+
export * from "./asSet";
|
|
4
|
+
export * from "./ObjectMap";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-keystone",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "A MobX powered state management solution based on data trees with first class support for TypeScript, snapshots, patches and much more",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mobx",
|
|
@@ -50,19 +50,6 @@
|
|
|
50
50
|
"CHANGELOG.md",
|
|
51
51
|
"README.md"
|
|
52
52
|
],
|
|
53
|
-
"scripts": {
|
|
54
|
-
"quick-build": "tsc",
|
|
55
|
-
"quick-build-tests": "tsc -p test",
|
|
56
|
-
"copy-root-files": "shx cp ../../README.md . && shx cp ../../LICENSE . && shx cp ../../CHANGELOG.md .",
|
|
57
|
-
"build": "pnpm run quick-build && pnpm run copy-root-files && shx rm -rf dist && vite build && pnpm run check-declarations && shx cp dist/mobx-keystone.esm.mjs dist/mobx-keystone.esm.js",
|
|
58
|
-
"check-declarations": "tsc -p scripts/tsconfig.check-declarations.json",
|
|
59
|
-
"test": "vitest run",
|
|
60
|
-
"test:ci": "vitest run --coverage",
|
|
61
|
-
"test:perf": "pnpm run build && pnpm run test:perf:run",
|
|
62
|
-
"test:perf:run": "cd perf_bench && NODE_ENV=production TS_NODE_COMPILER=@typescript/typescript6 /usr/bin/time node --expose-gc --require ts-node/register ./report.ts",
|
|
63
|
-
"memtest": "cd perf_bench && NODE_ENV=production TS_NODE_COMPILER=@typescript/typescript6 node --expose-gc --require ts-node/register ./memtest.ts",
|
|
64
|
-
"build-docs": "shx rm -rf ../../apps/site/generated-api && node --import ./scripts/typedoc-typescript6-register.mjs ./node_modules/typedoc/dist/cli.js --options ./typedocconfig.js src/index.ts"
|
|
65
|
-
},
|
|
66
53
|
"peerDependencies": {
|
|
67
54
|
"mobx": "^7.0.0 || ^6.0.0 || ^5.0.0 || ^4.0.0"
|
|
68
55
|
},
|
|
@@ -77,7 +64,7 @@
|
|
|
77
64
|
"@types/babel__core": "^7.20.5",
|
|
78
65
|
"@types/node": "^26.6.2",
|
|
79
66
|
"@typescript/typescript6": "^6.0.2",
|
|
80
|
-
"@vitest/coverage-v8": "
|
|
67
|
+
"@vitest/coverage-v8": "catalog:",
|
|
81
68
|
"expect-type": "^1.4.0",
|
|
82
69
|
"mobx-v4": "npm:mobx@^4.15.7",
|
|
83
70
|
"mobx-v5": "npm:mobx@^5.15.7",
|
|
@@ -89,9 +76,9 @@
|
|
|
89
76
|
"typedoc-docusaurus-theme": "^1.4.3",
|
|
90
77
|
"typedoc-plugin-markdown": "^4.13.1",
|
|
91
78
|
"typescript": "^7.0.2",
|
|
92
|
-
"vite": "
|
|
93
|
-
"vite-
|
|
94
|
-
"vitest": "
|
|
79
|
+
"vite": "catalog:",
|
|
80
|
+
"vite-plus": "catalog:",
|
|
81
|
+
"vitest": "catalog:"
|
|
95
82
|
},
|
|
96
83
|
"dependencies": {
|
|
97
84
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -8,7 +8,7 @@ import { wrapInAction } from "./wrapInAction"
|
|
|
8
8
|
* Decorator that turns a function into a model action.
|
|
9
9
|
*/
|
|
10
10
|
export function modelAction(...args: any[]): void {
|
|
11
|
-
//
|
|
11
|
+
// Proper way to declare a decorator
|
|
12
12
|
return decorateWrapMethodOrField("modelAction", args, (data, fn) => {
|
|
13
13
|
if (isModelAction(fn)) {
|
|
14
14
|
return fn
|
package/src/action/modelFlow.ts
CHANGED
|
@@ -163,7 +163,7 @@ export function isModelFlow(fn: unknown) {
|
|
|
163
163
|
* Decorator that turns a function generator into a model flow.
|
|
164
164
|
*/
|
|
165
165
|
export function modelFlow(...args: any[]): void {
|
|
166
|
-
//
|
|
166
|
+
// Proper way to declare a decorator
|
|
167
167
|
return decorateWrapMethodOrField("modelFlow", args, (data, fn) => {
|
|
168
168
|
if (isModelFlow(fn)) {
|
|
169
169
|
return fn
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { propsTypeSymbol } from "../modelShared/BaseModelShared"
|
|
1
|
+
import { type propsTypeSymbol } from "../modelShared/BaseModelShared"
|
|
2
2
|
import { modelInfoByClass } from "../modelShared/modelInfo"
|
|
3
3
|
import { getInternalModelClassPropsInfo } from "../modelShared/modelPropsInfo"
|
|
4
4
|
import {
|
|
@@ -13,8 +13,8 @@ import { getSnapshot } from "../snapshot/getSnapshot"
|
|
|
13
13
|
import { isTreeNode } from "../tweaker/core"
|
|
14
14
|
import { toTreeNode } from "../tweaker/tweak"
|
|
15
15
|
import { typesDataModelData } from "../types/objectBased/typesDataModelData"
|
|
16
|
-
import type { TypeCheckError } from "../types/TypeCheckError"
|
|
17
16
|
import { typeCheck } from "../types/typeCheck"
|
|
17
|
+
import type { TypeCheckError } from "../types/TypeCheckError"
|
|
18
18
|
import { clonePlainObject, failure, hasOwnProp, isObject, setProtoProp } from "../utils"
|
|
19
19
|
import { getOrCreate } from "../utils/mapUtils"
|
|
20
20
|
import type { DataModelConstructorOptions } from "./DataModelConstructorOptions"
|
|
@@ -73,7 +73,7 @@ export abstract class BaseDataModel<TProps extends ModelProps> {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const constructorOptions =
|
|
76
|
-
//
|
|
76
|
+
// oxlint-disable-next-line eslint/prefer-rest-params -- internal factory code passes hidden constructor options through super().
|
|
77
77
|
arguments[1] as DataModelConstructorOptions
|
|
78
78
|
const { modelClass: _modelClass } = constructorOptions
|
|
79
79
|
const modelClass = _modelClass!
|
|
@@ -140,7 +140,7 @@ export abstract class BaseDataModel<TProps extends ModelProps> {
|
|
|
140
140
|
|
|
141
141
|
const instance = instancesForModelClass.get(tweakedData)
|
|
142
142
|
if (instance) {
|
|
143
|
-
//
|
|
143
|
+
// oxlint-disable-next-line eslint/no-constructor-return -- no other way to return an instance
|
|
144
144
|
return instance
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -189,6 +189,6 @@ export interface AnyDataModel extends BaseDataModel<any> {}
|
|
|
189
189
|
* A data model class declaration, made of a base model and the model interface.
|
|
190
190
|
*/
|
|
191
191
|
export type DataModelClassDeclaration<BaseModelClass, ModelInterface> = BaseModelClass & {
|
|
192
|
-
//
|
|
192
|
+
// oxlint-disable-next-line typescript/prefer-function-type -- make type recursive
|
|
193
193
|
(...args: any[]): ModelInterface
|
|
194
194
|
}
|
package/src/model/BaseModel.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { observable } from "mobx"
|
|
2
2
|
import {
|
|
3
|
-
fromSnapshotOverrideTypeSymbol,
|
|
3
|
+
type fromSnapshotOverrideTypeSymbol,
|
|
4
4
|
type ModelClass,
|
|
5
|
-
propsTypeSymbol,
|
|
6
|
-
toSnapshotOverrideTypeSymbol,
|
|
5
|
+
type propsTypeSymbol,
|
|
6
|
+
type toSnapshotOverrideTypeSymbol,
|
|
7
7
|
} from "../modelShared/BaseModelShared"
|
|
8
8
|
import { modelInfoByClass } from "../modelShared/modelInfo"
|
|
9
9
|
import type {
|
|
@@ -15,12 +15,12 @@ import { getSnapshot } from "../snapshot/getSnapshot"
|
|
|
15
15
|
import { setModelInitialDataSnapshot } from "../snapshot/modelInitialData"
|
|
16
16
|
import type { SnapshotInOfModel, SnapshotOutOfModel } from "../snapshot/SnapshotOf"
|
|
17
17
|
import { typesModel } from "../types/objectBased/typesModel"
|
|
18
|
-
import type { TypeCheckError } from "../types/TypeCheckError"
|
|
19
18
|
import { typeCheck } from "../types/typeCheck"
|
|
19
|
+
import type { TypeCheckError } from "../types/TypeCheckError"
|
|
20
20
|
import { assertIsObject, failure, nodeObservableOptions } from "../utils"
|
|
21
21
|
import { getModelIdPropertyName } from "./getModelMetadata"
|
|
22
|
-
import type { ModelConstructorOptions } from "./ModelConstructorOptions"
|
|
23
22
|
import { modelIdKey, modelTypeKey } from "./metadata"
|
|
23
|
+
import type { ModelConstructorOptions } from "./ModelConstructorOptions"
|
|
24
24
|
import { internalFromSnapshotModel, internalNewModel } from "./newModel"
|
|
25
25
|
import { assertIsModelClass } from "./utils"
|
|
26
26
|
|
|
@@ -134,7 +134,7 @@ export abstract class BaseModel<
|
|
|
134
134
|
constructor(data: ModelPropsToTransformedCreationData<TProps>) {
|
|
135
135
|
const initialData = data as any
|
|
136
136
|
const constructorOptions =
|
|
137
|
-
//
|
|
137
|
+
// oxlint-disable-next-line eslint/prefer-rest-params -- internal factory code passes hidden constructor options through super().
|
|
138
138
|
arguments[1] as ModelConstructorOptions
|
|
139
139
|
const { snapshotInitialData, modelClass, generateNewIds } = constructorOptions
|
|
140
140
|
|
|
@@ -205,6 +205,7 @@ export interface AnyModel extends BaseModel<any, any, any, any> {}
|
|
|
205
205
|
* @param type Abstract model class.
|
|
206
206
|
* @returns
|
|
207
207
|
*/
|
|
208
|
+
// oxlint-disable-next-line typescript/no-wrapper-object-types -- part of the public signature
|
|
208
209
|
export function abstractModelClass<T>(type: T): T & Object {
|
|
209
210
|
return type as any
|
|
210
211
|
}
|
package/src/model/mixins.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
type AbstractModelClass,
|
|
3
3
|
type ModelClass,
|
|
4
4
|
modelClass,
|
|
5
|
-
propsTypeSymbol,
|
|
5
|
+
type propsTypeSymbol,
|
|
6
6
|
} from "../modelShared/BaseModelShared"
|
|
7
7
|
import type { ModelProps, ModelPropsToTransformedData } from "../modelShared/prop"
|
|
8
8
|
import type { AnyModel, BaseModelKeys } from "./BaseModel"
|
package/src/model/newModel.ts
CHANGED
|
@@ -27,8 +27,8 @@ import { failure, hasOwnProp, inDevMode, makePropReadonly } from "../utils"
|
|
|
27
27
|
import { setIfDifferent, setIfDifferentWithReturn } from "../utils/setIfDifferent"
|
|
28
28
|
import type { AnyModel } from "./BaseModel"
|
|
29
29
|
import { getModelIdPropertyName } from "./getModelMetadata"
|
|
30
|
-
import type { ModelConstructorOptions } from "./ModelConstructorOptions"
|
|
31
30
|
import { modelTypeKey } from "./metadata"
|
|
31
|
+
import type { ModelConstructorOptions } from "./ModelConstructorOptions"
|
|
32
32
|
import { assertIsModelClass } from "./utils"
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -43,9 +43,7 @@ export const model =
|
|
|
43
43
|
// the model instance type is checked through `prototype` rather than through a typed constructor
|
|
44
44
|
// signature, since comparing constructor signatures would compute the (expensive) model creation data
|
|
45
45
|
// type of every decorated class
|
|
46
|
-
type ModelDecoratorTarget = (new (
|
|
47
|
-
...args: any
|
|
48
|
-
) => any) & {
|
|
46
|
+
type ModelDecoratorTarget = (new (...args: any) => any) & {
|
|
49
47
|
prototype: AnyModel | AnyDataModel
|
|
50
48
|
}
|
|
51
49
|
|
|
@@ -191,7 +189,7 @@ function tsDecorate(
|
|
|
191
189
|
r = (Reflect as any).decorate(decorators, target, key, desc)
|
|
192
190
|
} else {
|
|
193
191
|
for (
|
|
194
|
-
//
|
|
192
|
+
// oxlint-disable-next-line eslint/no-inner-declarations, eslint/no-var -- minified file
|
|
195
193
|
var i = decorators.length - 1;
|
|
196
194
|
i >= 0;
|
|
197
195
|
i--
|
|
@@ -201,8 +199,8 @@ function tsDecorate(
|
|
|
201
199
|
}
|
|
202
200
|
}
|
|
203
201
|
}
|
|
204
|
-
//
|
|
205
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r
|
|
202
|
+
// oxlint-disable-next-line eslint/no-sequences -- minified file
|
|
203
|
+
return (c > 3 && r && Object.defineProperty(target, key, r), r)
|
|
206
204
|
}
|
|
207
205
|
|
|
208
206
|
/**
|
|
@@ -58,10 +58,11 @@ export function setModelInfo(modelInfo: ModelInfo, unwrappedClass: ModelClass<an
|
|
|
58
58
|
// registration of a model
|
|
59
59
|
const baseModelInfo = findModelInfoForPrototype(Object.getPrototypeOf(unwrappedClass.prototype))
|
|
60
60
|
const ancestorDistances = new Map<string, number>()
|
|
61
|
-
baseModelInfo
|
|
61
|
+
if (baseModelInfo) {
|
|
62
62
|
ancestorDistancesByModelInfo.get(baseModelInfo)?.forEach((distance, name) => {
|
|
63
63
|
ancestorDistances.set(name, distance + 1)
|
|
64
64
|
})
|
|
65
|
+
}
|
|
65
66
|
ancestorDistances.set(modelInfo.name, 0)
|
|
66
67
|
ancestorDistancesByModelInfo.set(modelInfo, ancestorDistances)
|
|
67
68
|
ancestorDistancesByModelName.set(modelInfo.name, ancestorDistances)
|
|
@@ -11,8 +11,8 @@ import type { DataModelMetadata } from "../dataModel/getDataModelMetadata"
|
|
|
11
11
|
import { getGlobalConfig } from "../globalConfig/globalConfig"
|
|
12
12
|
import { type AnyModel, BaseModel, baseModelPropNames } from "../model/BaseModel"
|
|
13
13
|
import type { ModelMetadata } from "../model/getModelMetadata"
|
|
14
|
-
import type { ModelConstructorOptions } from "../model/ModelConstructorOptions"
|
|
15
14
|
import { modelTypeKey } from "../model/metadata"
|
|
15
|
+
import type { ModelConstructorOptions } from "../model/ModelConstructorOptions"
|
|
16
16
|
import { typesObject } from "../types/objectBased/typesObject"
|
|
17
17
|
import { typesString } from "../types/primitiveBased/typesPrimitive"
|
|
18
18
|
import type { AnyType } from "../types/schemas"
|
package/src/ref/Ref.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Model } from "../model/Model"
|
|
2
1
|
import { modelTypeKey } from "../model/metadata"
|
|
2
|
+
import { Model } from "../model/Model"
|
|
3
3
|
import type { ModelClass } from "../modelShared/BaseModelShared"
|
|
4
4
|
import { typesString } from "../types/primitiveBased/typesPrimitive"
|
|
5
5
|
import { tProp } from "../types/tProp"
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @internal
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
/* oxlint-disable typescript/prefer-enum-initializers -- that's ok, it is not serialized */
|
|
5
5
|
export enum SnapshotterAndReconcilerPriority {
|
|
6
6
|
Array,
|
|
7
7
|
Frozen,
|
|
8
8
|
Model,
|
|
9
9
|
PlainObject,
|
|
10
10
|
}
|
|
11
|
+
/* oxlint-enable typescript/prefer-enum-initializers */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnyModel } from "../model/BaseModel"
|
|
2
2
|
import { getModelIdPropertyName } from "../model/getModelMetadata"
|
|
3
|
-
import type { ModelConstructorOptions } from "../model/ModelConstructorOptions"
|
|
4
3
|
import { modelTypeKey } from "../model/metadata"
|
|
4
|
+
import type { ModelConstructorOptions } from "../model/ModelConstructorOptions"
|
|
5
5
|
import { getModelOrSnapshotTypeAndId, getSnapshotModelType } from "../model/utils"
|
|
6
6
|
import type { ModelClass } from "../modelShared/BaseModelShared"
|
|
7
7
|
import { getModelInfoForName, getModelNotRegisteredErrorMessage } from "../modelShared/modelInfo"
|
|
@@ -83,7 +83,7 @@ export function fromSnapshot<T>(arg1: any, arg2: any, arg3?: any): T {
|
|
|
83
83
|
let snapshot: any
|
|
84
84
|
let unprocessedSnapshot: unknown
|
|
85
85
|
let options: Partial<FromSnapshotOptions> | undefined
|
|
86
|
-
//
|
|
86
|
+
// oxlint-disable-next-line eslint/prefer-rest-params -- overload resolution needs the real call arity to distinguish omitted snapshots from omitted type args.
|
|
87
87
|
const standardType = arguments.length >= 2 ? resolveStandardTypeNoThrow(arg1) : undefined
|
|
88
88
|
|
|
89
89
|
if (isLateTypeChecker(arg1) || arg1 instanceof TypeChecker || standardType) {
|