mobx-keystone 1.20.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +864 -853
- package/README.md +61 -61
- package/dist/mobx-keystone.esm.js +11336 -11148
- package/dist/mobx-keystone.esm.mjs +11336 -11148
- package/dist/mobx-keystone.umd.js +12229 -11738
- package/dist/types/actionMiddlewares/undoMiddleware.d.ts +1 -1
- package/dist/types/modelShared/prop.d.ts +5 -0
- package/dist/types/redux/connectReduxDevTools.d.ts +17 -4
- package/dist/types/ref/Ref.d.ts +1 -1
- package/dist/types/treeUtils/sandbox.d.ts +1 -1
- package/dist/types/types/TypeChecker.d.ts +1 -1
- package/dist/types/types/arrayBased/typesArray.d.ts +1 -1
- package/dist/types/types/arrayBased/typesTuple.d.ts +1 -1
- package/dist/types/types/objectBased/typesArraySet.d.ts +1 -1
- package/dist/types/types/objectBased/typesDataModelData.d.ts +1 -1
- package/dist/types/types/objectBased/typesModel.d.ts +1 -1
- package/dist/types/types/objectBased/typesObject.d.ts +3 -3
- package/dist/types/types/objectBased/typesObjectMap.d.ts +1 -1
- package/dist/types/types/objectBased/typesRecord.d.ts +1 -1
- package/dist/types/types/primitiveBased/typesPrimitive.d.ts +1 -1
- package/dist/types/types/types.d.ts +3 -3
- package/dist/types/types/utility/typesCodec.d.ts +1 -6
- package/dist/types/types/utility/typesCodecCore.d.ts +1 -1
- package/dist/types/types/utility/typesOr.d.ts +1 -1
- package/dist/types/types/utility/typesRefinement.d.ts +1 -1
- package/dist/types/types/utility/typesSkipCheck.d.ts +1 -1
- package/dist/types/types/utility/typesTag.d.ts +1 -1
- package/dist/types/wrappers/ObjectMap.d.ts +2 -0
- package/dist/types/wrappers/asMap.d.ts +10 -6
- package/package.json +14 -12
- package/src/action/applyAction.ts +125 -114
- package/src/action/applyMethodCall.ts +37 -37
- package/src/action/isModelAction.ts +16 -16
- package/src/action/middleware.ts +137 -137
- package/src/action/modelFlow.ts +240 -240
- package/src/action/modelFlowPromiseGenerator.ts +127 -125
- package/src/action/pendingActions.ts +42 -42
- package/src/action/wrapInAction.ts +156 -156
- package/src/actionMiddlewares/actionSerialization/actionSerialization.ts +1 -1
- package/src/actionMiddlewares/actionSerialization/applySerializedAction.ts +172 -172
- package/src/actionMiddlewares/actionSerialization/arraySerializer.ts +20 -20
- package/src/actionMiddlewares/actionSerialization/dateSerializer.ts +17 -17
- package/src/actionMiddlewares/actionSerialization/mapSerializer.ts +42 -42
- package/src/actionMiddlewares/actionSerialization/objectPathSerializer.ts +50 -50
- package/src/actionMiddlewares/actionSerialization/objectSnapshotSerializer.ts +21 -21
- package/src/actionMiddlewares/actionSerialization/plainObjectSerializer.ts +24 -32
- package/src/actionMiddlewares/actionSerialization/primitiveSerializer.ts +51 -51
- package/src/actionMiddlewares/actionSerialization/setSerializer.ts +37 -37
- package/src/actionMiddlewares/actionTrackingMiddleware.ts +3 -3
- package/src/actionMiddlewares/onActionMiddleware.ts +2 -2
- package/src/actionMiddlewares/readonlyMiddleware.ts +2 -2
- package/src/actionMiddlewares/transactionMiddleware.ts +4 -4
- package/src/actionMiddlewares/undoMiddleware.ts +804 -796
- package/src/actionMiddlewares/utils.ts +2 -2
- package/src/computedTree/computedTree.ts +143 -143
- package/src/context/context.ts +1 -1
- package/src/dataModel/BaseDataModel.ts +194 -192
- package/src/dataModel/actions.ts +1 -1
- package/src/dataModel/newDataModel.ts +57 -57
- package/src/deepChange/index.ts +1 -1
- package/src/deepChange/onDeepChange.ts +244 -244
- package/src/frozen/Frozen.ts +146 -146
- package/src/globalConfig/globalConfig.ts +107 -107
- package/src/index.ts +24 -24
- package/src/model/BaseModel.ts +275 -273
- package/src/model/ModelConstructorOptions.ts +15 -15
- package/src/model/getModelMetadata.ts +51 -51
- package/src/model/index.ts +6 -6
- package/src/model/mixins.ts +288 -288
- package/src/model/newModel.ts +301 -301
- package/src/model/utils.ts +249 -249
- package/src/modelShared/modelDecorator.ts +260 -253
- package/src/modelShared/modelInfo.ts +50 -50
- package/src/modelShared/modelSymbols.ts +3 -3
- package/src/modelShared/newModel.ts +25 -25
- package/src/modelShared/prop.ts +713 -684
- package/src/modelShared/sharedInternalModel.ts +427 -417
- package/src/modelShared/utils.ts +24 -24
- package/src/parent/core.ts +65 -65
- package/src/parent/coreObjectChildren.ts +180 -180
- package/src/parent/detach.ts +47 -47
- package/src/parent/findParent.ts +1 -1
- package/src/parent/getChildrenObjects.ts +25 -25
- package/src/parent/path.ts +386 -381
- package/src/parent/setParent.ts +149 -149
- package/src/parent/walkTree.ts +1 -1
- package/src/patch/applyPatches.ts +187 -187
- package/src/patch/jsonPatch.ts +108 -108
- package/src/patch/patchRecorder.ts +6 -1
- package/src/redux/connectReduxDevTools.ts +39 -7
- package/src/redux/redux.ts +6 -2
- package/src/ref/Ref.ts +1 -1
- package/src/ref/core.ts +339 -345
- package/src/ref/customRef.ts +3 -3
- package/src/ref/rootRef.ts +100 -100
- package/src/rootStore/attachDetach.ts +89 -89
- package/src/rootStore/rootStore.ts +1 -1
- package/src/snapshot/SnapshotOf.ts +104 -104
- package/src/snapshot/SnapshotProcessingError.ts +45 -45
- package/src/snapshot/applySnapshot.ts +177 -181
- package/src/snapshot/cloneTreeValue.ts +30 -30
- package/src/snapshot/fromArraySnapshot.ts +27 -33
- package/src/snapshot/fromModelSnapshot.ts +70 -70
- package/src/snapshot/fromPlainObjectSnapshot.ts +47 -42
- package/src/snapshot/fromSnapshot.ts +198 -198
- package/src/snapshot/getSnapshot.ts +80 -79
- package/src/snapshot/index.ts +8 -8
- package/src/snapshot/internal.ts +230 -230
- package/src/snapshot/reconcileArraySnapshot.ts +70 -70
- package/src/snapshot/reconcileModelSnapshot.ts +155 -150
- package/src/snapshot/reconcilePlainObjectSnapshot.ts +72 -72
- package/src/snapshot/reconcileSnapshot.ts +88 -88
- package/src/standardActions/actions.ts +64 -64
- package/src/standardActions/objectActions.ts +60 -60
- package/src/transforms/ImmutableDate.ts +93 -93
- package/src/transforms/asMap.ts +50 -50
- package/src/transforms/asSet.ts +22 -22
- package/src/transforms/bigint.ts +20 -20
- package/src/transforms/date.ts +40 -40
- package/src/treeUtils/deepEquals.ts +55 -55
- package/src/treeUtils/sandbox.ts +6 -3
- package/src/tweaker/TweakerPriority.ts +9 -9
- package/src/tweaker/tweak.ts +4 -3
- package/src/tweaker/tweakArray.ts +530 -475
- package/src/tweaker/tweakFrozen.ts +42 -42
- package/src/tweaker/tweakModel.ts +1 -1
- package/src/tweaker/tweakPlainObject.ts +355 -355
- package/src/tweaker/typeChecking.ts +101 -101
- package/src/types/SnapshotTypeMismatchError.ts +46 -46
- package/src/types/TypeCheckError.ts +183 -184
- package/src/types/TypeChecker.ts +202 -185
- package/src/types/arrayBased/typesArray.ts +136 -137
- package/src/types/arrayBased/typesTuple.ts +138 -139
- package/src/types/createPerEntryCachedCheck.ts +166 -160
- package/src/types/index.ts +6 -6
- package/src/types/objectBased/typesArraySet.ts +133 -134
- package/src/types/objectBased/typesDataModelData.ts +203 -204
- package/src/types/objectBased/typesModel.ts +220 -221
- package/src/types/objectBased/typesObject.ts +308 -310
- package/src/types/objectBased/typesObjectMap.ts +142 -143
- package/src/types/objectBased/typesRecord.ts +156 -157
- package/src/types/objectBased/typesRef.ts +89 -89
- package/src/types/primitiveBased/typesEnum.ts +63 -63
- package/src/types/primitiveBased/typesPrimitive.ts +219 -220
- package/src/types/registerDefaultStandardTypeResolvers.ts +21 -21
- package/src/types/resolveTypeChecker.ts +78 -78
- package/src/types/schemas.ts +208 -208
- package/src/types/tProp.ts +277 -268
- package/src/types/typeCheck.ts +21 -21
- package/src/types/typeCheckErrorUtils.ts +23 -23
- package/src/types/types.ts +142 -142
- package/src/types/utility/typeToStoredData.ts +37 -37
- package/src/types/utility/typesBigInt.ts +15 -15
- package/src/types/utility/typesCodec.ts +41 -38
- package/src/types/utility/typesCodecCore.ts +178 -178
- package/src/types/utility/typesCodecSupport.ts +806 -806
- package/src/types/utility/typesDate.ts +27 -27
- package/src/types/utility/typesMap.ts +253 -222
- package/src/types/utility/typesOr.ts +263 -259
- package/src/types/utility/typesRefinement.ts +131 -125
- package/src/types/utility/typesSet.ts +110 -110
- package/src/types/utility/typesSkipCheck.ts +69 -70
- package/src/types/utility/typesTag.ts +88 -82
- package/src/types/utility/typesUnchecked.ts +40 -40
- package/src/utils/AnyFunction.ts +4 -4
- package/src/utils/ModelPool.ts +59 -59
- package/src/utils/chainFns.ts +18 -18
- package/src/utils/decorators.ts +274 -274
- package/src/utils/errorDiagnostics.ts +204 -204
- package/src/utils/index.ts +443 -372
- package/src/wrappers/ArraySet.ts +156 -156
- package/src/wrappers/ObjectMap.ts +155 -136
- package/src/wrappers/asMap.ts +65 -30
- package/src/wrappers/asSet.ts +3 -3
package/src/types/types.ts
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
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, ModelTypeInfoProps, typesModel } from "./objectBased/typesModel"
|
|
6
|
-
import {
|
|
7
|
-
FrozenTypeInfo,
|
|
8
|
-
ObjectTypeInfo,
|
|
9
|
-
ObjectTypeInfoProps,
|
|
10
|
-
typesFrozen,
|
|
11
|
-
typesObject,
|
|
12
|
-
} from "./objectBased/typesObject"
|
|
13
|
-
import { ObjectMapTypeInfo, typesObjectMap } from "./objectBased/typesObjectMap"
|
|
14
|
-
import { RecordTypeInfo, typesRecord } from "./objectBased/typesRecord"
|
|
15
|
-
import { RefTypeInfo, typesRef } from "./objectBased/typesRef"
|
|
16
|
-
import { typesEnum } from "./primitiveBased/typesEnum"
|
|
17
|
-
import {
|
|
18
|
-
BooleanTypeInfo,
|
|
19
|
-
LiteralTypeInfo,
|
|
20
|
-
NumberTypeInfo,
|
|
21
|
-
StringTypeInfo,
|
|
22
|
-
typesBoolean,
|
|
23
|
-
typesLiteral,
|
|
24
|
-
typesNull,
|
|
25
|
-
typesNumber,
|
|
26
|
-
typesString,
|
|
27
|
-
typesUndefined,
|
|
28
|
-
} from "./primitiveBased/typesPrimitive"
|
|
29
|
-
import { typesInteger, typesNonEmptyString } from "./primitiveBased/typesRefinedPrimitive"
|
|
30
|
-
import type { AnyType } from "./schemas"
|
|
31
|
-
import {
|
|
32
|
-
CodecTypeInfo,
|
|
33
|
-
typesBigInt,
|
|
34
|
-
typesCodec,
|
|
35
|
-
typesDateAsIsoString,
|
|
36
|
-
typesDateAsTimestamp,
|
|
37
|
-
typesMapFromArray,
|
|
38
|
-
typesMapFromObject,
|
|
39
|
-
typesSetFromArray,
|
|
40
|
-
} from "./utility/typesCodec"
|
|
41
|
-
import { typesMaybe, typesMaybeNull } from "./utility/typesMaybe"
|
|
42
|
-
import { OrTypeInfo, typesOr } from "./utility/typesOr"
|
|
43
|
-
import { RefinementTypeInfo, typesRefinement } from "./utility/typesRefinement"
|
|
44
|
-
import { SkipCheckTypeInfo, typesSkipCheck } from "./utility/typesSkipCheck"
|
|
45
|
-
import { TagTypeInfo, typesTag } from "./utility/typesTag"
|
|
46
|
-
import { typesUnchecked, UncheckedTypeInfo } from "./utility/typesUnchecked"
|
|
47
|
-
|
|
48
|
-
export { getTypeInfo } from "./getTypeInfo"
|
|
49
|
-
export { TypeInfo } from "./TypeChecker"
|
|
50
|
-
export type {
|
|
51
|
-
export {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
FrozenTypeInfo,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
TupleTypeInfo,
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export const types = {
|
|
74
|
-
literal: typesLiteral,
|
|
75
|
-
undefined: typesUndefined,
|
|
76
|
-
null: typesNull,
|
|
77
|
-
boolean: typesBoolean,
|
|
78
|
-
number: typesNumber,
|
|
79
|
-
string: typesString,
|
|
80
|
-
or: typesOr,
|
|
81
|
-
maybe: typesMaybe,
|
|
82
|
-
maybeNull: typesMaybeNull,
|
|
83
|
-
array: typesArray,
|
|
84
|
-
record: typesRecord,
|
|
85
|
-
unchecked: typesUnchecked,
|
|
86
|
-
skipCheck: typesSkipCheck,
|
|
87
|
-
model: typesModel,
|
|
88
|
-
dataModelData: typesDataModelData,
|
|
89
|
-
object: typesObject,
|
|
90
|
-
ref: typesRef,
|
|
91
|
-
frozen: typesFrozen,
|
|
92
|
-
enum: typesEnum,
|
|
93
|
-
tag: typesTag,
|
|
94
|
-
refinement: typesRefinement,
|
|
95
|
-
codec: typesCodec,
|
|
96
|
-
integer: typesInteger,
|
|
97
|
-
nonEmptyString: typesNonEmptyString,
|
|
98
|
-
objectMap: typesObjectMap,
|
|
99
|
-
arraySet: typesArraySet,
|
|
100
|
-
tuple: typesTuple,
|
|
101
|
-
bigint: typesBigInt,
|
|
102
|
-
dateAsTimestamp: typesDateAsTimestamp,
|
|
103
|
-
dateAsIsoString: typesDateAsIsoString,
|
|
104
|
-
/**
|
|
105
|
-
* @deprecated Prefer `types.mapFromArray(...)` for runtime `Map` values.
|
|
106
|
-
*/
|
|
107
|
-
mapArray<T extends AnyType>(valueType: T) {
|
|
108
|
-
return typesArray(typesTuple(typesString, valueType))
|
|
109
|
-
},
|
|
110
|
-
/**
|
|
111
|
-
* @deprecated Prefer `types.setFromArray(...)` for runtime `Set` values.
|
|
112
|
-
*/
|
|
113
|
-
setArray<T extends AnyType>(valueType: T) {
|
|
114
|
-
return typesArray(valueType)
|
|
115
|
-
},
|
|
116
|
-
/**
|
|
117
|
-
* @deprecated Prefer `types.mapFromObject(...)` for runtime `Map` values.
|
|
118
|
-
*/
|
|
119
|
-
mapObject<T extends AnyType>(valueType: T) {
|
|
120
|
-
return typesRecord(valueType)
|
|
121
|
-
},
|
|
122
|
-
mapFromObject<T extends AnyType>(valueType: T) {
|
|
123
|
-
return typesMapFromObject(valueType)
|
|
124
|
-
},
|
|
125
|
-
mapFromArray<TKeyType extends AnyType, TValueType extends AnyType>(
|
|
126
|
-
keyType: TKeyType,
|
|
127
|
-
valueType: TValueType
|
|
128
|
-
) {
|
|
129
|
-
return typesMapFromArray(keyType, valueType)
|
|
130
|
-
},
|
|
131
|
-
setFromArray<T extends AnyType>(valueType: T) {
|
|
132
|
-
return typesSetFromArray(valueType)
|
|
133
|
-
},
|
|
134
|
-
/**
|
|
135
|
-
* @deprecated Prefer `types.dateAsIsoString` instead.
|
|
136
|
-
*/
|
|
137
|
-
dateString: typesNonEmptyString,
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated Prefer `types.dateAsTimestamp` instead.
|
|
140
|
-
*/
|
|
141
|
-
dateTimestamp: typesInteger,
|
|
142
|
-
}
|
|
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 {
|
|
7
|
+
FrozenTypeInfo,
|
|
8
|
+
ObjectTypeInfo,
|
|
9
|
+
type ObjectTypeInfoProps,
|
|
10
|
+
typesFrozen,
|
|
11
|
+
typesObject,
|
|
12
|
+
} from "./objectBased/typesObject"
|
|
13
|
+
import { ObjectMapTypeInfo, typesObjectMap } from "./objectBased/typesObjectMap"
|
|
14
|
+
import { RecordTypeInfo, typesRecord } from "./objectBased/typesRecord"
|
|
15
|
+
import { RefTypeInfo, typesRef } from "./objectBased/typesRef"
|
|
16
|
+
import { typesEnum } from "./primitiveBased/typesEnum"
|
|
17
|
+
import {
|
|
18
|
+
BooleanTypeInfo,
|
|
19
|
+
LiteralTypeInfo,
|
|
20
|
+
NumberTypeInfo,
|
|
21
|
+
StringTypeInfo,
|
|
22
|
+
typesBoolean,
|
|
23
|
+
typesLiteral,
|
|
24
|
+
typesNull,
|
|
25
|
+
typesNumber,
|
|
26
|
+
typesString,
|
|
27
|
+
typesUndefined,
|
|
28
|
+
} from "./primitiveBased/typesPrimitive"
|
|
29
|
+
import { typesInteger, typesNonEmptyString } from "./primitiveBased/typesRefinedPrimitive"
|
|
30
|
+
import type { AnyType } from "./schemas"
|
|
31
|
+
import {
|
|
32
|
+
CodecTypeInfo,
|
|
33
|
+
typesBigInt,
|
|
34
|
+
typesCodec,
|
|
35
|
+
typesDateAsIsoString,
|
|
36
|
+
typesDateAsTimestamp,
|
|
37
|
+
typesMapFromArray,
|
|
38
|
+
typesMapFromObject,
|
|
39
|
+
typesSetFromArray,
|
|
40
|
+
} from "./utility/typesCodec"
|
|
41
|
+
import { typesMaybe, typesMaybeNull } from "./utility/typesMaybe"
|
|
42
|
+
import { OrTypeInfo, typesOr } from "./utility/typesOr"
|
|
43
|
+
import { RefinementTypeInfo, typesRefinement } from "./utility/typesRefinement"
|
|
44
|
+
import { SkipCheckTypeInfo, typesSkipCheck } from "./utility/typesSkipCheck"
|
|
45
|
+
import { TagTypeInfo, typesTag } from "./utility/typesTag"
|
|
46
|
+
import { typesUnchecked, UncheckedTypeInfo } from "./utility/typesUnchecked"
|
|
47
|
+
|
|
48
|
+
export { getTypeInfo } from "./getTypeInfo"
|
|
49
|
+
export { TypeInfo } from "./TypeChecker"
|
|
50
|
+
export type { ModelTypeInfoProps, ObjectTypeInfoProps }
|
|
51
|
+
export {
|
|
52
|
+
ArraySetTypeInfo,
|
|
53
|
+
ArrayTypeInfo,
|
|
54
|
+
BooleanTypeInfo,
|
|
55
|
+
CodecTypeInfo,
|
|
56
|
+
FrozenTypeInfo,
|
|
57
|
+
LiteralTypeInfo,
|
|
58
|
+
ModelTypeInfo,
|
|
59
|
+
NumberTypeInfo,
|
|
60
|
+
ObjectMapTypeInfo,
|
|
61
|
+
ObjectTypeInfo,
|
|
62
|
+
OrTypeInfo,
|
|
63
|
+
RecordTypeInfo,
|
|
64
|
+
RefinementTypeInfo,
|
|
65
|
+
RefTypeInfo,
|
|
66
|
+
SkipCheckTypeInfo,
|
|
67
|
+
StringTypeInfo,
|
|
68
|
+
TagTypeInfo,
|
|
69
|
+
TupleTypeInfo,
|
|
70
|
+
UncheckedTypeInfo,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const types = {
|
|
74
|
+
literal: typesLiteral,
|
|
75
|
+
undefined: typesUndefined,
|
|
76
|
+
null: typesNull,
|
|
77
|
+
boolean: typesBoolean,
|
|
78
|
+
number: typesNumber,
|
|
79
|
+
string: typesString,
|
|
80
|
+
or: typesOr,
|
|
81
|
+
maybe: typesMaybe,
|
|
82
|
+
maybeNull: typesMaybeNull,
|
|
83
|
+
array: typesArray,
|
|
84
|
+
record: typesRecord,
|
|
85
|
+
unchecked: typesUnchecked,
|
|
86
|
+
skipCheck: typesSkipCheck,
|
|
87
|
+
model: typesModel,
|
|
88
|
+
dataModelData: typesDataModelData,
|
|
89
|
+
object: typesObject,
|
|
90
|
+
ref: typesRef,
|
|
91
|
+
frozen: typesFrozen,
|
|
92
|
+
enum: typesEnum,
|
|
93
|
+
tag: typesTag,
|
|
94
|
+
refinement: typesRefinement,
|
|
95
|
+
codec: typesCodec,
|
|
96
|
+
integer: typesInteger,
|
|
97
|
+
nonEmptyString: typesNonEmptyString,
|
|
98
|
+
objectMap: typesObjectMap,
|
|
99
|
+
arraySet: typesArraySet,
|
|
100
|
+
tuple: typesTuple,
|
|
101
|
+
bigint: typesBigInt,
|
|
102
|
+
dateAsTimestamp: typesDateAsTimestamp,
|
|
103
|
+
dateAsIsoString: typesDateAsIsoString,
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated Prefer `types.mapFromArray(...)` for runtime `Map` values.
|
|
106
|
+
*/
|
|
107
|
+
mapArray<T extends AnyType>(valueType: T) {
|
|
108
|
+
return typesArray(typesTuple(typesString, valueType))
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* @deprecated Prefer `types.setFromArray(...)` for runtime `Set` values.
|
|
112
|
+
*/
|
|
113
|
+
setArray<T extends AnyType>(valueType: T) {
|
|
114
|
+
return typesArray(valueType)
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated Prefer `types.mapFromObject(...)` for runtime `Map` values.
|
|
118
|
+
*/
|
|
119
|
+
mapObject<T extends AnyType>(valueType: T) {
|
|
120
|
+
return typesRecord(valueType)
|
|
121
|
+
},
|
|
122
|
+
mapFromObject<T extends AnyType>(valueType: T) {
|
|
123
|
+
return typesMapFromObject(valueType)
|
|
124
|
+
},
|
|
125
|
+
mapFromArray<TKeyType extends AnyType, TValueType extends AnyType>(
|
|
126
|
+
keyType: TKeyType,
|
|
127
|
+
valueType: TValueType
|
|
128
|
+
) {
|
|
129
|
+
return typesMapFromArray(keyType, valueType)
|
|
130
|
+
},
|
|
131
|
+
setFromArray<T extends AnyType>(valueType: T) {
|
|
132
|
+
return typesSetFromArray(valueType)
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated Prefer `types.dateAsIsoString` instead.
|
|
136
|
+
*/
|
|
137
|
+
dateString: typesNonEmptyString,
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated Prefer `types.dateAsTimestamp` instead.
|
|
140
|
+
*/
|
|
141
|
+
dateTimestamp: typesInteger,
|
|
142
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import type { O } from "ts-toolbelt"
|
|
2
|
-
import type {
|
|
3
|
-
ArrayType,
|
|
4
|
-
CodecType,
|
|
5
|
-
ObjectOptionalKeys,
|
|
6
|
-
ObjectType,
|
|
7
|
-
ObjectTypeFunction,
|
|
8
|
-
RecordType,
|
|
9
|
-
TypeToData,
|
|
10
|
-
} from "../schemas"
|
|
11
|
-
|
|
12
|
-
type ArrayStoredData<S extends readonly unknown[]> = number extends S["length"]
|
|
13
|
-
? Array<TypeToStoredData<S[number]> extends infer R ? R : never>
|
|
14
|
-
: {
|
|
15
|
-
[k in keyof S]: TypeToStoredData<S[k]> extends infer R ? R : never
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type ObjectStoredData<S> = O.Optional<
|
|
19
|
-
{ [k in keyof S]: TypeToStoredData<S[k]> extends infer R ? R : never },
|
|
20
|
-
ObjectOptionalKeys<S>
|
|
21
|
-
>
|
|
22
|
-
|
|
23
|
-
export type TypeToStoredData<S> = S extends ObjectTypeFunction
|
|
24
|
-
? ObjectStoredData<ReturnType<S>> extends infer R
|
|
25
|
-
? R
|
|
26
|
-
: never
|
|
27
|
-
: S extends CodecType<any, any, any, infer D>
|
|
28
|
-
? D
|
|
29
|
-
: S extends ArrayType<infer A>
|
|
30
|
-
? ArrayStoredData<A>
|
|
31
|
-
: S extends ObjectType<infer O>
|
|
32
|
-
? ObjectStoredData<O>
|
|
33
|
-
: S extends RecordType<infer R>
|
|
34
|
-
? {
|
|
35
|
-
[k: string]: TypeToStoredData<R> extends infer D ? D : never
|
|
36
|
-
}
|
|
37
|
-
: TypeToData<S>
|
|
1
|
+
import type { O } from "ts-toolbelt"
|
|
2
|
+
import type {
|
|
3
|
+
ArrayType,
|
|
4
|
+
CodecType,
|
|
5
|
+
ObjectOptionalKeys,
|
|
6
|
+
ObjectType,
|
|
7
|
+
ObjectTypeFunction,
|
|
8
|
+
RecordType,
|
|
9
|
+
TypeToData,
|
|
10
|
+
} from "../schemas"
|
|
11
|
+
|
|
12
|
+
type ArrayStoredData<S extends readonly unknown[]> = number extends S["length"]
|
|
13
|
+
? Array<TypeToStoredData<S[number]> extends infer R ? R : never>
|
|
14
|
+
: {
|
|
15
|
+
[k in keyof S]: TypeToStoredData<S[k]> extends infer R ? R : never
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type ObjectStoredData<S> = O.Optional<
|
|
19
|
+
{ [k in keyof S]: TypeToStoredData<S[k]> extends infer R ? R : never },
|
|
20
|
+
ObjectOptionalKeys<S>
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
export type TypeToStoredData<S> = S extends ObjectTypeFunction
|
|
24
|
+
? ObjectStoredData<ReturnType<S>> extends infer R
|
|
25
|
+
? R
|
|
26
|
+
: never
|
|
27
|
+
: S extends CodecType<any, any, any, infer D>
|
|
28
|
+
? D
|
|
29
|
+
: S extends ArrayType<infer A>
|
|
30
|
+
? ArrayStoredData<A>
|
|
31
|
+
: S extends ObjectType<infer O>
|
|
32
|
+
? ObjectStoredData<O>
|
|
33
|
+
: S extends RecordType<infer R>
|
|
34
|
+
? {
|
|
35
|
+
[k: string]: TypeToStoredData<R> extends infer D ? D : never
|
|
36
|
+
}
|
|
37
|
+
: TypeToData<S>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { stringToBigIntTransform } from "../../transforms/bigint"
|
|
2
|
-
import { TypeCheckerBaseType } from "../TypeChecker"
|
|
3
|
-
import { createCodecType } from "./typesCodecCore"
|
|
4
|
-
|
|
5
|
-
export const typesBigInt = createCodecType(
|
|
6
|
-
{
|
|
7
|
-
typeName: "bigint",
|
|
8
|
-
encodedType: String,
|
|
9
|
-
is(value): value is bigint {
|
|
10
|
-
return typeof value === "bigint"
|
|
11
|
-
},
|
|
12
|
-
...stringToBigIntTransform(),
|
|
13
|
-
},
|
|
14
|
-
TypeCheckerBaseType.Primitive
|
|
15
|
-
)
|
|
1
|
+
import { stringToBigIntTransform } from "../../transforms/bigint"
|
|
2
|
+
import { TypeCheckerBaseType } from "../TypeChecker"
|
|
3
|
+
import { createCodecType } from "./typesCodecCore"
|
|
4
|
+
|
|
5
|
+
export const typesBigInt = createCodecType(
|
|
6
|
+
{
|
|
7
|
+
typeName: "bigint",
|
|
8
|
+
encodedType: String,
|
|
9
|
+
is(value): value is bigint {
|
|
10
|
+
return typeof value === "bigint"
|
|
11
|
+
},
|
|
12
|
+
...stringToBigIntTransform(),
|
|
13
|
+
},
|
|
14
|
+
TypeCheckerBaseType.Primitive
|
|
15
|
+
)
|
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
import { registerStandardTypeResolver } from "../resolveTypeChecker"
|
|
2
|
-
import { typesBigInt } from "./typesBigInt"
|
|
3
|
-
import { CodecTypeInfo, typesCodec } from "./typesCodecCore"
|
|
4
|
-
import {
|
|
5
|
-
createCodecPropTransform,
|
|
6
|
-
resolveCodecSupport,
|
|
7
|
-
resolveStoredType,
|
|
8
|
-
resolveStoredTypeChecker,
|
|
9
|
-
} from "./typesCodecSupport"
|
|
10
|
-
import { typesDateAsIsoString, typesDateAsTimestamp } from "./typesDate"
|
|
11
|
-
import { typesMapFromArray, typesMapFromObject } from "./typesMap"
|
|
12
|
-
import { typesSetFromArray } from "./typesSet"
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
|
|
16
|
-
createCodecPropTransform,
|
|
17
|
-
resolveCodecSupport,
|
|
18
|
-
resolveStoredType,
|
|
19
|
-
resolveStoredTypeChecker,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
codecStandardTypeResolversRegistered
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { registerStandardTypeResolver } from "../resolveTypeChecker"
|
|
2
|
+
import { typesBigInt } from "./typesBigInt"
|
|
3
|
+
import { CodecTypeInfo, typesCodec } from "./typesCodecCore"
|
|
4
|
+
import {
|
|
5
|
+
createCodecPropTransform,
|
|
6
|
+
resolveCodecSupport,
|
|
7
|
+
resolveStoredType,
|
|
8
|
+
resolveStoredTypeChecker,
|
|
9
|
+
} from "./typesCodecSupport"
|
|
10
|
+
import { typesDateAsIsoString, typesDateAsTimestamp } from "./typesDate"
|
|
11
|
+
import { typesMapFromArray, typesMapFromObject } from "./typesMap"
|
|
12
|
+
import { typesSetFromArray } from "./typesSet"
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
CodecTypeInfo,
|
|
16
|
+
createCodecPropTransform,
|
|
17
|
+
resolveCodecSupport,
|
|
18
|
+
resolveStoredType,
|
|
19
|
+
resolveStoredTypeChecker,
|
|
20
|
+
typesBigInt,
|
|
21
|
+
typesCodec,
|
|
22
|
+
typesDateAsIsoString,
|
|
23
|
+
typesDateAsTimestamp,
|
|
24
|
+
typesMapFromArray,
|
|
25
|
+
typesMapFromObject,
|
|
26
|
+
typesSetFromArray,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let codecStandardTypeResolversRegistered = false
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export function registerCodecStandardTypeResolvers() {
|
|
35
|
+
if (codecStandardTypeResolversRegistered) {
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
codecStandardTypeResolversRegistered = true
|
|
39
|
+
|
|
40
|
+
registerStandardTypeResolver((value) => (value === BigInt ? typesBigInt : undefined))
|
|
41
|
+
}
|