jazz-tools 0.18.38 → 0.19.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/.svelte-kit/__package__/jazz.class.svelte.d.ts +8 -8
- package/.svelte-kit/__package__/jazz.class.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/jazz.class.svelte.js +39 -14
- package/.svelte-kit/__package__/media/image.svelte +6 -5
- package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/tests/AccountCoState.svelte.test-d.d.ts +2 -0
- package/.svelte-kit/__package__/tests/AccountCoState.svelte.test-d.d.ts.map +1 -0
- package/.svelte-kit/__package__/tests/AccountCoState.svelte.test-d.js +19 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test-d.d.ts +2 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test-d.d.ts.map +1 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test-d.js +16 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test.d.ts +2 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test.d.ts.map +1 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test.js +42 -0
- package/.svelte-kit/__package__/tests/TestCoStateWrapper.svelte +23 -0
- package/.svelte-kit/__package__/tests/TestCoStateWrapper.svelte.d.ts +12 -0
- package/.svelte-kit/__package__/tests/TestCoStateWrapper.svelte.d.ts.map +1 -0
- package/.turbo/turbo-build.log +57 -57
- package/CHANGELOG.md +22 -0
- package/dist/better-auth/database-adapter/index.js +14 -11
- package/dist/better-auth/database-adapter/index.js.map +1 -1
- package/dist/better-auth/database-adapter/repository/generic.d.ts +1 -1
- package/dist/better-auth/database-adapter/repository/generic.d.ts.map +1 -1
- package/dist/better-auth/database-adapter/repository/user.d.ts.map +1 -1
- package/dist/{chunk-OSQ7S47Q.js → chunk-P3YLNFN4.js} +504 -232
- package/dist/chunk-P3YLNFN4.js.map +1 -0
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/media/{chunk-K6GCHLQU.js → chunk-3LKBM3G3.js} +23 -15
- package/dist/media/chunk-3LKBM3G3.js.map +1 -0
- package/dist/media/create-image/browser.d.ts +2 -2
- package/dist/media/create-image/react-native.d.ts +2 -2
- package/dist/media/create-image/server.d.ts +2 -2
- package/dist/media/create-image-factory.d.ts +2 -2
- package/dist/media/index.browser.js +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/index.native.js +1 -1
- package/dist/media/index.server.js +1 -1
- package/dist/media/utils.d.ts.map +1 -1
- package/dist/react/hooks.d.ts +1 -1
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +31 -15
- package/dist/react/index.js.map +1 -1
- package/dist/react/media/image.d.ts.map +1 -1
- package/dist/react-core/hooks.d.ts +126 -224
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +65 -63
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/subscription-provider.d.ts.map +1 -1
- package/dist/react-core/tests/createCoValueSubscriptionContext.test.d.ts +2 -0
- package/dist/react-core/tests/createCoValueSubscriptionContext.test.d.ts.map +1 -0
- package/dist/react-core/tests/useAccount.selector.test.d.ts +2 -0
- package/dist/react-core/tests/useAccount.selector.test.d.ts.map +1 -0
- package/dist/react-core/tests/useCoState.selector.test.d.ts +2 -0
- package/dist/react-core/tests/useCoState.selector.test.d.ts.map +1 -0
- package/dist/react-native-core/hooks.d.ts +1 -1
- package/dist/react-native-core/hooks.d.ts.map +1 -1
- package/dist/react-native-core/index.js +7 -5
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/react-native-core/media/image.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.d.ts +8 -8
- package/dist/svelte/jazz.class.svelte.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +39 -14
- package/dist/svelte/media/image.svelte +6 -5
- package/dist/svelte/media/image.svelte.d.ts.map +1 -1
- package/dist/svelte/tests/AccountCoState.svelte.test-d.d.ts +2 -0
- package/dist/svelte/tests/AccountCoState.svelte.test-d.d.ts.map +1 -0
- package/dist/svelte/tests/AccountCoState.svelte.test-d.js +19 -0
- package/dist/svelte/tests/CoState.svelte.test-d.d.ts +2 -0
- package/dist/svelte/tests/CoState.svelte.test-d.d.ts.map +1 -0
- package/dist/svelte/tests/CoState.svelte.test-d.js +16 -0
- package/dist/svelte/tests/CoState.svelte.test.d.ts +2 -0
- package/dist/svelte/tests/CoState.svelte.test.d.ts.map +1 -0
- package/dist/svelte/tests/CoState.svelte.test.js +42 -0
- package/dist/svelte/tests/TestCoStateWrapper.svelte +23 -0
- package/dist/svelte/tests/TestCoStateWrapper.svelte.d.ts +12 -0
- package/dist/svelte/tests/TestCoStateWrapper.svelte.d.ts.map +1 -0
- package/dist/testing.js +3 -1
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/CoValueBase.d.ts +4 -1
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +6 -6
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts +5 -5
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts +9 -8
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +17 -17
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/coPlainText.d.ts +3 -3
- package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
- package/dist/tools/coValues/coVector.d.ts +3 -3
- package/dist/tools/coValues/coVector.d.ts.map +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +66 -36
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts.map +1 -1
- package/dist/tools/coValues/group.d.ts +2 -2
- package/dist/tools/coValues/group.d.ts.map +1 -1
- package/dist/tools/coValues/inbox.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +14 -6
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/request.d.ts.map +1 -1
- package/dist/tools/coValues/schemaUnion.d.ts +2 -2
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +3 -3
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/refs.d.ts +3 -3
- package/dist/tools/implementation/refs.d.ts.map +1 -1
- package/dist/tools/implementation/schema.d.ts +2 -2
- package/dist/tools/implementation/schema.d.ts.map +1 -1
- package/dist/tools/implementation/schemaUtils.d.ts +8 -0
- package/dist/tools/implementation/schemaUtils.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +33 -18
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +5 -4
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +23 -12
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +29 -18
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +39 -22
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +30 -19
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts +5 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts +6 -5
- package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +3 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesMaybeLoaded.d.ts +22 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesMaybeLoaded.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.d.ts +9 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts +7 -6
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +3 -3
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/lib/utils.d.ts +14 -0
- package/dist/tools/lib/utils.d.ts.map +1 -0
- package/dist/tools/lib/utils.test.d.ts +2 -0
- package/dist/tools/lib/utils.test.d.ts.map +1 -0
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts +3 -2
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
- package/dist/tools/subscribe/JazzError.d.ts +4 -3
- package/dist/tools/subscribe/JazzError.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts +6 -5
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/index.d.ts.map +1 -1
- package/dist/tools/subscribe/types.d.ts +23 -3
- package/dist/tools/subscribe/types.d.ts.map +1 -1
- package/dist/tools/subscribe/utils.d.ts.map +1 -1
- package/dist/tools/testing.d.ts +3 -2
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/schema.resolved.test.d.ts +2 -0
- package/dist/tools/tests/schema.resolved.test.d.ts.map +1 -0
- package/dist/tools/tests/utils.d.ts +2 -1
- package/dist/tools/tests/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/better-auth/database-adapter/index.ts +2 -2
- package/src/better-auth/database-adapter/repository/account.ts +3 -3
- package/src/better-auth/database-adapter/repository/generic.ts +9 -6
- package/src/better-auth/database-adapter/repository/user.ts +6 -2
- package/src/better-auth/database-adapter/schema.ts +1 -1
- package/src/better-auth/database-adapter/tests/index.test.ts +3 -4
- package/src/inspector/tests/viewer/history-view.test.tsx +6 -2
- package/src/media/utils.test.ts +5 -0
- package/src/media/utils.ts +25 -16
- package/src/react/hooks.tsx +2 -2
- package/src/react/index.ts +2 -2
- package/src/react/media/image.tsx +10 -2
- package/src/react/tests/useAcceptInvite.test.ts +3 -1
- package/src/react-core/hooks.ts +226 -304
- package/src/react-core/subscription-provider.tsx +14 -7
- package/src/react-core/tests/createCoValueSubscriptionContext.test.tsx +233 -0
- package/src/react-core/tests/subscription.bench.tsx +32 -15
- package/src/react-core/tests/{useAccountWithSelector.test.ts → useAccount.selector.test.ts} +72 -24
- package/src/react-core/tests/useAccount.test.ts +92 -106
- package/src/react-core/tests/{useCoStateWithSelector.test.ts → useCoState.selector.test.ts} +23 -8
- package/src/react-core/tests/useCoState.test.ts +173 -49
- package/src/react-core/tests/useInboxSender.test.ts +3 -1
- package/src/react-core/tests/usePassPhraseAuth.test.ts +11 -82
- package/src/react-core/tests/useSubscriptionSelector.test.ts +48 -14
- package/src/react-native-core/hooks.tsx +2 -2
- package/src/react-native-core/media/image.tsx +3 -1
- package/src/svelte/jazz.class.svelte.ts +103 -27
- package/src/svelte/media/image.svelte +6 -5
- package/src/svelte/tests/AccountCoState.svelte.test-d.ts +23 -0
- package/src/svelte/tests/CoState.svelte.test-d.ts +20 -0
- package/src/svelte/tests/CoState.svelte.test.ts +57 -0
- package/src/svelte/tests/TestCoStateWrapper.svelte +23 -0
- package/src/tools/coValues/CoValueBase.ts +12 -0
- package/src/tools/coValues/account.ts +17 -12
- package/src/tools/coValues/coFeed.ts +38 -15
- package/src/tools/coValues/coList.ts +16 -11
- package/src/tools/coValues/coMap.ts +15 -14
- package/src/tools/coValues/coPlainText.ts +6 -3
- package/src/tools/coValues/coVector.ts +6 -5
- package/src/tools/coValues/deepLoading.ts +98 -51
- package/src/tools/coValues/group.ts +3 -2
- package/src/tools/coValues/inbox.ts +11 -10
- package/src/tools/coValues/interfaces.ts +49 -27
- package/src/tools/coValues/request.ts +8 -6
- package/src/tools/coValues/schemaUnion.ts +2 -1
- package/src/tools/exports.ts +11 -1
- package/src/tools/implementation/refs.ts +19 -13
- package/src/tools/implementation/schema.ts +5 -4
- package/src/tools/implementation/schemaUtils.ts +15 -0
- package/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts +4 -4
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +131 -95
- package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +19 -9
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +73 -22
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +86 -28
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +204 -148
- package/src/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.ts +1 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +71 -27
- package/src/tools/implementation/zodSchema/schemaTypes/CoValueSchema.ts +7 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.ts +8 -6
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +4 -1
- package/src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts +4 -1
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +4 -1
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +4 -1
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +3 -0
- package/src/tools/implementation/zodSchema/typeConverters/{InstanceOfSchemaCoValuesNullable.ts → InstanceOfSchemaCoValuesMaybeLoaded.ts} +47 -39
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +4 -0
- package/src/tools/implementation/zodSchema/typeConverters/{InstanceOrPrimitiveOfSchemaCoValuesNullable.ts → InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.ts} +7 -3
- package/src/tools/implementation/zodSchema/zodSchema.ts +15 -7
- package/src/tools/internal.ts +3 -3
- package/src/tools/lib/utils.test.ts +56 -0
- package/src/tools/lib/utils.ts +32 -0
- package/src/tools/subscribe/CoValueCoreSubscription.ts +13 -8
- package/src/tools/subscribe/JazzError.ts +8 -2
- package/src/tools/subscribe/SubscriptionScope.ts +55 -44
- package/src/tools/subscribe/index.ts +12 -4
- package/src/tools/subscribe/types.ts +36 -2
- package/src/tools/subscribe/utils.ts +2 -1
- package/src/tools/testing.ts +5 -0
- package/src/tools/tests/CoValueCoreSubscription.test.ts +10 -4
- package/src/tools/tests/ContextManager.test.ts +12 -5
- package/src/tools/tests/account.test.ts +22 -12
- package/src/tools/tests/coDiscriminatedUnion.test.ts +8 -4
- package/src/tools/tests/coFeed.branch.test.ts +48 -32
- package/src/tools/tests/coFeed.test-d.ts +17 -10
- package/src/tools/tests/coFeed.test.ts +52 -30
- package/src/tools/tests/coList.branch.test.ts +21 -21
- package/src/tools/tests/coList.test-d.ts +39 -23
- package/src/tools/tests/coList.test.ts +51 -25
- package/src/tools/tests/coList.unique.test.ts +34 -29
- package/src/tools/tests/coMap.branch.test.ts +20 -21
- package/src/tools/tests/coMap.record.test-d.ts +28 -26
- package/src/tools/tests/coMap.record.test.ts +30 -20
- package/src/tools/tests/coMap.test-d.ts +31 -29
- package/src/tools/tests/coMap.test.ts +67 -40
- package/src/tools/tests/coMap.unique.test.ts +25 -24
- package/src/tools/tests/coVector.test.ts +29 -15
- package/src/tools/tests/createContext.test.ts +5 -3
- package/src/tools/tests/deepLoading.test.ts +314 -117
- package/src/tools/tests/exportImport.test.ts +16 -15
- package/src/tools/tests/groupsAndAccounts.test.ts +39 -16
- package/src/tools/tests/inbox.test.ts +3 -1
- package/src/tools/tests/load.test.ts +29 -23
- package/src/tools/tests/patterns/quest.test.ts +3 -2
- package/src/tools/tests/patterns/requestToJoin.test.ts +17 -17
- package/src/tools/tests/request.test.ts +12 -2
- package/src/tools/tests/schema.resolved.test.ts +723 -0
- package/src/tools/tests/schemaUnion.test.ts +7 -3
- package/src/tools/tests/subscribe.test.ts +39 -21
- package/src/tools/tests/testing.test.ts +3 -2
- package/src/tools/tests/utils.ts +15 -2
- package/dist/chunk-OSQ7S47Q.js.map +0 -1
- package/dist/media/chunk-K6GCHLQU.js.map +0 -1
- package/dist/react-core/tests/useAccountWithSelector.test.d.ts +0 -2
- package/dist/react-core/tests/useAccountWithSelector.test.d.ts.map +0 -1
- package/dist/react-core/tests/useCoStateWithSelector.test.d.ts +0 -2
- package/dist/react-core/tests/useCoStateWithSelector.test.d.ts.map +0 -1
- package/dist/tools/implementation/errors.d.ts +0 -2
- package/dist/tools/implementation/errors.d.ts.map +0 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +0 -19
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +0 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +0 -5
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +0 -1
- package/dist/tools/lib/id.d.ts +0 -2
- package/dist/tools/lib/id.d.ts.map +0 -1
- package/src/tools/implementation/errors.ts +0 -1
- package/src/tools/lib/id.ts +0 -3
package/src/tools/exports.ts
CHANGED
|
@@ -31,6 +31,9 @@ export type {
|
|
|
31
31
|
RefsToResolve,
|
|
32
32
|
RefsToResolveStrict,
|
|
33
33
|
CoMapInit_DEPRECATED as CoMapInit,
|
|
34
|
+
CoMapEdit,
|
|
35
|
+
CoMapEdits,
|
|
36
|
+
LastAndAllCoMapEdits,
|
|
34
37
|
CoFeedEntry,
|
|
35
38
|
SingleCoFeedEntry,
|
|
36
39
|
TextPos,
|
|
@@ -49,6 +52,8 @@ export {
|
|
|
49
52
|
CoPlainText,
|
|
50
53
|
CoRichText,
|
|
51
54
|
Account,
|
|
55
|
+
assertLoaded,
|
|
56
|
+
getLoadedOrUndefined,
|
|
52
57
|
isControlledAccount,
|
|
53
58
|
loadCoValue,
|
|
54
59
|
subscribeToCoValue,
|
|
@@ -57,6 +62,7 @@ export {
|
|
|
57
62
|
exportCoValue,
|
|
58
63
|
importContentPieces,
|
|
59
64
|
Ref,
|
|
65
|
+
createUnloadedCoValue,
|
|
60
66
|
unstable_loadUnique,
|
|
61
67
|
} from "./internal.js";
|
|
62
68
|
|
|
@@ -104,8 +110,12 @@ export type * from "./types.js";
|
|
|
104
110
|
export {
|
|
105
111
|
coValueClassFromCoValueClassOrSchema,
|
|
106
112
|
type InstanceOfSchema,
|
|
107
|
-
type
|
|
113
|
+
type InstanceOfSchemaCoValuesMaybeLoaded,
|
|
114
|
+
type SchemaResolveQuery,
|
|
108
115
|
type CoValueClassOrSchema,
|
|
116
|
+
CoValueLoadingState,
|
|
117
|
+
type MaybeLoaded,
|
|
118
|
+
type NotLoaded,
|
|
109
119
|
type Loaded,
|
|
110
120
|
type BaseAccountShape,
|
|
111
121
|
type DefaultAccountShape,
|
|
@@ -5,11 +5,13 @@ import {
|
|
|
5
5
|
ID,
|
|
6
6
|
RefEncoded,
|
|
7
7
|
SubscriptionScope,
|
|
8
|
-
|
|
9
|
-
import {
|
|
8
|
+
LoadedAndRequired,
|
|
10
9
|
accessChildById,
|
|
10
|
+
CoValueLoadingState,
|
|
11
11
|
getSubscriptionScope,
|
|
12
12
|
isRefEncoded,
|
|
13
|
+
createUnloadedCoValue,
|
|
14
|
+
MaybeLoaded,
|
|
13
15
|
} from "../internal.js";
|
|
14
16
|
|
|
15
17
|
export class Ref<out V extends CoValue> {
|
|
@@ -24,10 +26,10 @@ export class Ref<out V extends CoValue> {
|
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
async load(): Promise<V
|
|
29
|
+
async load(): Promise<MaybeLoaded<V>> {
|
|
28
30
|
const subscriptionScope = getSubscriptionScope(this.parent);
|
|
29
31
|
|
|
30
|
-
let node: SubscriptionScope<CoValue> | undefined
|
|
32
|
+
let node: SubscriptionScope<CoValue> | undefined;
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* If the parent subscription scope is closed, we can't use it
|
|
@@ -51,25 +53,29 @@ export class Ref<out V extends CoValue> {
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
if (!node) {
|
|
54
|
-
return
|
|
56
|
+
return createUnloadedCoValue(this.id, CoValueLoadingState.LOADING);
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
const value = node.value;
|
|
58
60
|
|
|
59
|
-
if (value?.type ===
|
|
61
|
+
if (value?.type === CoValueLoadingState.LOADED) {
|
|
60
62
|
return value.value as V;
|
|
61
63
|
} else {
|
|
62
64
|
return new Promise((resolve) => {
|
|
63
65
|
const unsubscribe = node.subscribe((value) => {
|
|
64
|
-
if (value?.type ===
|
|
66
|
+
if (value?.type === CoValueLoadingState.LOADED) {
|
|
65
67
|
unsubscribe();
|
|
66
68
|
resolve(value.value as V);
|
|
67
|
-
} else if (value?.type ===
|
|
69
|
+
} else if (value?.type === CoValueLoadingState.UNAVAILABLE) {
|
|
68
70
|
unsubscribe();
|
|
69
|
-
resolve(
|
|
70
|
-
|
|
71
|
+
resolve(
|
|
72
|
+
createUnloadedCoValue(this.id, CoValueLoadingState.UNAVAILABLE),
|
|
73
|
+
);
|
|
74
|
+
} else if (value?.type === CoValueLoadingState.UNAUTHORIZED) {
|
|
71
75
|
unsubscribe();
|
|
72
|
-
resolve(
|
|
76
|
+
resolve(
|
|
77
|
+
createUnloadedCoValue(this.id, CoValueLoadingState.UNAUTHORIZED),
|
|
78
|
+
);
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
if (subscriptionScope.closed) {
|
|
@@ -144,6 +150,6 @@ export function makeRefs<Keys extends string | number>(
|
|
|
144
150
|
});
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
export type RefIfCoValue<V> =
|
|
148
|
-
? Ref<
|
|
153
|
+
export type RefIfCoValue<V> = LoadedAndRequired<V> extends CoValue
|
|
154
|
+
? Ref<LoadedAndRequired<V>>
|
|
149
155
|
: never;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
CoValueFromRaw,
|
|
8
8
|
Group,
|
|
9
9
|
ItemsSym,
|
|
10
|
+
LoadedAndRequired,
|
|
10
11
|
SchemaInit,
|
|
11
12
|
isCoValueClass,
|
|
12
13
|
} from "../internal.js";
|
|
@@ -182,11 +183,11 @@ export function instantiateRefEncodedWithInit<V extends CoValue>(
|
|
|
182
183
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
184
|
export type Schema = JsonEncoded | RefEncoded<CoValue> | EncodedAs<any>;
|
|
184
185
|
|
|
185
|
-
export type SchemaFor<Field> =
|
|
186
|
-
? RefEncoded<
|
|
187
|
-
:
|
|
186
|
+
export type SchemaFor<Field> = LoadedAndRequired<Field> extends CoValue
|
|
187
|
+
? RefEncoded<LoadedAndRequired<Field>>
|
|
188
|
+
: LoadedAndRequired<Field> extends JsonValue
|
|
188
189
|
? JsonEncoded
|
|
189
|
-
: EncodedAs<
|
|
190
|
+
: EncodedAs<LoadedAndRequired<Field>>;
|
|
190
191
|
|
|
191
192
|
export type Encoder<V> = {
|
|
192
193
|
encode: (value: V) => JsonValue;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CoreResolveQuery } from "./zodSchema/schemaTypes/CoValueSchema";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Remove getters from an object
|
|
3
5
|
*
|
|
@@ -16,3 +18,16 @@ export function removeGetters<T extends object>(obj: T): Partial<T> {
|
|
|
16
18
|
|
|
17
19
|
return result;
|
|
18
20
|
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Adds a CoValue schema's resolve query to a load options object
|
|
24
|
+
* if no resolve query is provided.
|
|
25
|
+
*/
|
|
26
|
+
export function withSchemaResolveQuery<
|
|
27
|
+
const T extends { resolve?: CoreResolveQuery },
|
|
28
|
+
>(loadOptions: T | undefined, schemaResolveQuery: CoreResolveQuery): T {
|
|
29
|
+
const newOptions: CoreResolveQuery = loadOptions ? { ...loadOptions } : {};
|
|
30
|
+
// TODO merge the schema resolve query with the user-provided resolve query
|
|
31
|
+
newOptions.resolve ||= schemaResolveQuery;
|
|
32
|
+
return newOptions as T;
|
|
33
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { RawCoList, RawCoMap } from "cojson";
|
|
2
2
|
import {
|
|
3
3
|
Account,
|
|
4
|
+
AccountSchema,
|
|
4
5
|
CoDiscriminatedUnionSchema,
|
|
5
6
|
CoFeed,
|
|
6
7
|
CoFeedSchema,
|
|
7
8
|
CoList,
|
|
8
9
|
CoListSchema,
|
|
9
10
|
CoMap,
|
|
11
|
+
CoMapSchema,
|
|
10
12
|
CoPlainText,
|
|
11
13
|
CoRichText,
|
|
12
14
|
CoValueClass,
|
|
@@ -15,8 +17,6 @@ import {
|
|
|
15
17
|
CoVectorSchema,
|
|
16
18
|
PlainTextSchema,
|
|
17
19
|
SchemaUnion,
|
|
18
|
-
enrichAccountSchema,
|
|
19
|
-
enrichCoMapSchema,
|
|
20
20
|
isCoValueClass,
|
|
21
21
|
Group,
|
|
22
22
|
CoVector,
|
|
@@ -98,8 +98,8 @@ export function hydrateCoreCoValueSchema<S extends AnyCoreCoValueSchema>(
|
|
|
98
98
|
|
|
99
99
|
const coValueSchema =
|
|
100
100
|
ClassToExtend === Account
|
|
101
|
-
?
|
|
102
|
-
:
|
|
101
|
+
? new AccountSchema(schema as any, coValueClass as any)
|
|
102
|
+
: new CoMapSchema(schema as any, coValueClass as any);
|
|
103
103
|
|
|
104
104
|
return coValueSchema as unknown as CoValueSchemaFromCoreSchema<S>;
|
|
105
105
|
} else if (schema.builtin === "CoList") {
|
|
@@ -2,14 +2,20 @@ import {
|
|
|
2
2
|
Account,
|
|
3
3
|
AccountCreationProps,
|
|
4
4
|
BranchDefinition,
|
|
5
|
+
CoMapSchemaDefinition,
|
|
5
6
|
coOptionalDefiner,
|
|
6
7
|
Group,
|
|
8
|
+
MaybeLoaded,
|
|
7
9
|
RefsToResolveStrict,
|
|
10
|
+
RefsToResolve,
|
|
11
|
+
Resolved,
|
|
8
12
|
Simplify,
|
|
13
|
+
SubscribeListenerOptions,
|
|
14
|
+
unstable_mergeBranchWithResolve,
|
|
9
15
|
} from "../../../internal.js";
|
|
10
16
|
import { AnonymousJazzAgent } from "../../anonymousJazzAgent.js";
|
|
11
17
|
import { InstanceOrPrimitiveOfSchema } from "../typeConverters/InstanceOrPrimitiveOfSchema.js";
|
|
12
|
-
import {
|
|
18
|
+
import { InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded } from "../typeConverters/InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.js";
|
|
13
19
|
import { z } from "../zodReExport.js";
|
|
14
20
|
import { AnyZodOrCoValueSchema, Loaded, ResolveQuery } from "../zodSchema.js";
|
|
15
21
|
import {
|
|
@@ -17,6 +23,9 @@ import {
|
|
|
17
23
|
CoreCoMapSchema,
|
|
18
24
|
createCoreCoMapSchema,
|
|
19
25
|
} from "./CoMapSchema.js";
|
|
26
|
+
import { CoOptionalSchema } from "./CoOptionalSchema.js";
|
|
27
|
+
import { CoreResolveQuery } from "./CoValueSchema.js";
|
|
28
|
+
import { withSchemaResolveQuery } from "../../schemaUtils.js";
|
|
20
29
|
|
|
21
30
|
export type BaseProfileShape = {
|
|
22
31
|
name: z.core.$ZodString<string>;
|
|
@@ -34,60 +43,151 @@ export type DefaultAccountShape = {
|
|
|
34
43
|
root: CoMapSchema<{}>;
|
|
35
44
|
};
|
|
36
45
|
|
|
37
|
-
export
|
|
46
|
+
export class AccountSchema<
|
|
38
47
|
Shape extends BaseAccountShape = DefaultAccountShape,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
DefaultResolveQuery extends CoreResolveQuery = true,
|
|
49
|
+
> implements CoreAccountSchema<Shape>
|
|
50
|
+
{
|
|
51
|
+
collaborative = true as const;
|
|
52
|
+
builtin = "Account" as const;
|
|
53
|
+
shape: Shape;
|
|
54
|
+
getDefinition: () => CoMapSchemaDefinition;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Default resolve query to be used when loading instances of this schema.
|
|
58
|
+
* This resolve query will be used when no resolve query is provided to the load method.
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
resolveQuery: DefaultResolveQuery = true as DefaultResolveQuery;
|
|
62
|
+
|
|
63
|
+
constructor(
|
|
64
|
+
coreSchema: CoreAccountSchema<Shape>,
|
|
65
|
+
private coValueClass: typeof Account,
|
|
66
|
+
) {
|
|
67
|
+
this.shape = coreSchema.shape;
|
|
68
|
+
this.getDefinition = coreSchema.getDefinition;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
create(
|
|
53
72
|
options: Simplify<Parameters<(typeof Account)["create"]>[0]>,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
): Promise<AccountInstance<Shape>> {
|
|
74
|
+
// @ts-expect-error
|
|
75
|
+
return this.coValueClass.create(options);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
load<
|
|
79
|
+
// @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is
|
|
80
|
+
const R extends ResolveQuery<AccountSchema<Shape>> = DefaultResolveQuery,
|
|
81
|
+
>(
|
|
57
82
|
id: string,
|
|
58
83
|
options?: {
|
|
59
84
|
loadAs?: Account | AnonymousJazzAgent;
|
|
60
85
|
resolve?: RefsToResolveStrict<AccountSchema<Shape>, R>;
|
|
61
86
|
},
|
|
62
|
-
)
|
|
87
|
+
): Promise<MaybeLoaded<Loaded<AccountSchema<Shape>, R>>> {
|
|
88
|
+
// @ts-expect-error
|
|
89
|
+
return this.coValueClass.load(
|
|
90
|
+
id,
|
|
91
|
+
// @ts-expect-error
|
|
92
|
+
withSchemaResolveQuery(options, this.resolveQuery),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
63
95
|
|
|
64
96
|
/** @internal */
|
|
65
|
-
createAs
|
|
97
|
+
createAs(
|
|
66
98
|
as: Account,
|
|
67
99
|
options: {
|
|
68
|
-
creationProps
|
|
100
|
+
creationProps: { name: string };
|
|
69
101
|
},
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
|
|
102
|
+
): Promise<AccountInstance<Shape>> {
|
|
103
|
+
// @ts-expect-error
|
|
104
|
+
return this.coValueClass.createAs(as, options);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
unstable_merge<
|
|
108
|
+
// @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is
|
|
109
|
+
R extends ResolveQuery<AccountSchema<Shape>> = DefaultResolveQuery,
|
|
110
|
+
>(
|
|
73
111
|
id: string,
|
|
74
|
-
options
|
|
112
|
+
options: {
|
|
75
113
|
loadAs?: Account | AnonymousJazzAgent;
|
|
76
114
|
resolve?: RefsToResolveStrict<AccountSchema<Shape>, R>;
|
|
77
115
|
branch: BranchDefinition;
|
|
78
116
|
},
|
|
79
|
-
)
|
|
117
|
+
): Promise<void> {
|
|
118
|
+
return unstable_mergeBranchWithResolve(
|
|
119
|
+
this.coValueClass,
|
|
120
|
+
id,
|
|
121
|
+
// @ts-expect-error
|
|
122
|
+
withSchemaResolveQuery(options, this.resolveQuery),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
subscribe<
|
|
127
|
+
const R extends RefsToResolve<
|
|
128
|
+
Simplify<AccountInstance<Shape>>
|
|
129
|
+
// @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is
|
|
130
|
+
> = DefaultResolveQuery,
|
|
131
|
+
>(
|
|
132
|
+
id: string,
|
|
133
|
+
options: SubscribeListenerOptions<Simplify<AccountInstance<Shape>>, R>,
|
|
134
|
+
listener: (
|
|
135
|
+
value: Resolved<Simplify<AccountInstance<Shape>>, R>,
|
|
136
|
+
unsubscribe: () => void,
|
|
137
|
+
) => void,
|
|
138
|
+
): () => void {
|
|
139
|
+
return this.coValueClass.subscribe(
|
|
140
|
+
id,
|
|
141
|
+
// @ts-expect-error
|
|
142
|
+
withSchemaResolveQuery(options, this.resolveQuery),
|
|
143
|
+
listener,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
80
146
|
|
|
81
|
-
getMe
|
|
147
|
+
getMe(): Loaded<this, true> {
|
|
148
|
+
// @ts-expect-error
|
|
149
|
+
return this.coValueClass.getMe();
|
|
150
|
+
}
|
|
82
151
|
|
|
83
152
|
withMigration(
|
|
84
153
|
migration: (
|
|
85
154
|
account: Loaded<AccountSchema<Shape>>,
|
|
86
155
|
creationProps?: { name: string },
|
|
87
156
|
) => void,
|
|
88
|
-
): AccountSchema<Shape
|
|
89
|
-
|
|
90
|
-
|
|
157
|
+
): AccountSchema<Shape, DefaultResolveQuery> {
|
|
158
|
+
(this.coValueClass.prototype as Account).migrate = async function (
|
|
159
|
+
this,
|
|
160
|
+
creationProps,
|
|
161
|
+
) {
|
|
162
|
+
// @ts-expect-error
|
|
163
|
+
await migration(this, creationProps);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
getCoValueClass(): typeof Account {
|
|
170
|
+
return this.coValueClass;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
optional(): CoOptionalSchema<this> {
|
|
174
|
+
return coOptionalDefiner(this);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Adds a default resolve query to be used when loading instances of this schema.
|
|
179
|
+
* This resolve query will be used when no resolve query is provided to the load method.
|
|
180
|
+
*/
|
|
181
|
+
resolved<R extends ResolveQuery<AccountSchema<Shape>>>(
|
|
182
|
+
resolveQuery: RefsToResolveStrict<AccountSchema<Shape>, R>,
|
|
183
|
+
): AccountSchema<Shape, R> {
|
|
184
|
+
const coreSchema: CoreAccountSchema<Shape> = createCoreAccountSchema(
|
|
185
|
+
this.shape,
|
|
186
|
+
);
|
|
187
|
+
const copy = new AccountSchema<Shape, R>(coreSchema, this.coValueClass);
|
|
188
|
+
copy.resolveQuery = resolveQuery as R;
|
|
189
|
+
return copy;
|
|
190
|
+
}
|
|
91
191
|
}
|
|
92
192
|
|
|
93
193
|
export function createCoreAccountSchema<Shape extends BaseAccountShape>(
|
|
@@ -99,62 +199,6 @@ export function createCoreAccountSchema<Shape extends BaseAccountShape>(
|
|
|
99
199
|
};
|
|
100
200
|
}
|
|
101
201
|
|
|
102
|
-
export function enrichAccountSchema<Shape extends BaseAccountShape>(
|
|
103
|
-
schema: CoreAccountSchema<Shape>,
|
|
104
|
-
coValueClass: typeof Account,
|
|
105
|
-
): AccountSchema<Shape> {
|
|
106
|
-
const enrichedSchema = Object.assign(schema, {
|
|
107
|
-
create: (...args: any[]) => {
|
|
108
|
-
// @ts-expect-error
|
|
109
|
-
return coValueClass.create(...args);
|
|
110
|
-
},
|
|
111
|
-
createAs: (...args: any[]) => {
|
|
112
|
-
// @ts-expect-error
|
|
113
|
-
return coValueClass.createAs(...args);
|
|
114
|
-
},
|
|
115
|
-
getMe: (...args: any[]) => {
|
|
116
|
-
// @ts-expect-error
|
|
117
|
-
return coValueClass.getMe(...args);
|
|
118
|
-
},
|
|
119
|
-
load: (...args: any[]) => {
|
|
120
|
-
// @ts-expect-error
|
|
121
|
-
return coValueClass.load(...args);
|
|
122
|
-
},
|
|
123
|
-
subscribe: (...args: any[]) => {
|
|
124
|
-
// @ts-expect-error
|
|
125
|
-
return coValueClass.subscribe(...args);
|
|
126
|
-
},
|
|
127
|
-
fromRaw: (...args: any[]) => {
|
|
128
|
-
// @ts-expect-error
|
|
129
|
-
return coValueClass.fromRaw(...args);
|
|
130
|
-
},
|
|
131
|
-
unstable_merge: (...args: any[]) => {
|
|
132
|
-
// @ts-expect-error
|
|
133
|
-
return unstable_mergeBranchWithResolve(coValueClass, ...args);
|
|
134
|
-
},
|
|
135
|
-
withMigration: (
|
|
136
|
-
migration: (
|
|
137
|
-
value: any,
|
|
138
|
-
creationProps?: AccountCreationProps,
|
|
139
|
-
) => void | Promise<void>,
|
|
140
|
-
) => {
|
|
141
|
-
(coValueClass.prototype as Account).migrate = async function (
|
|
142
|
-
this,
|
|
143
|
-
creationProps,
|
|
144
|
-
) {
|
|
145
|
-
await migration(this, creationProps);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
return enrichedSchema;
|
|
149
|
-
},
|
|
150
|
-
getCoValueClass: () => {
|
|
151
|
-
return coValueClass;
|
|
152
|
-
},
|
|
153
|
-
optional: () => coOptionalDefiner(enrichedSchema),
|
|
154
|
-
}) as unknown as AccountSchema<Shape>;
|
|
155
|
-
return enrichedSchema;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
202
|
export type DefaultProfileShape = {
|
|
159
203
|
name: z.core.$ZodString<string>;
|
|
160
204
|
inbox: z.core.$ZodOptional<z.core.$ZodString>;
|
|
@@ -176,11 +220,3 @@ export interface CoreAccountSchema<
|
|
|
176
220
|
export type AccountInstance<Shape extends z.core.$ZodLooseShape> = {
|
|
177
221
|
readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchema<Shape[key]>;
|
|
178
222
|
} & Account;
|
|
179
|
-
|
|
180
|
-
export type AccountInstanceCoValuesNullable<
|
|
181
|
-
Shape extends z.core.$ZodLooseShape,
|
|
182
|
-
> = {
|
|
183
|
-
readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchemaCoValuesNullable<
|
|
184
|
-
Shape[key]
|
|
185
|
-
>;
|
|
186
|
-
} & Account;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Account,
|
|
3
3
|
AnonymousJazzAgent,
|
|
4
|
+
LoadedAndRequired,
|
|
4
5
|
BranchDefinition,
|
|
5
6
|
InstanceOfSchema,
|
|
6
|
-
|
|
7
|
+
InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded,
|
|
8
|
+
MaybeLoaded,
|
|
7
9
|
Resolved,
|
|
8
10
|
SchemaUnion,
|
|
9
11
|
SchemaUnionConcreteSubclass,
|
|
@@ -47,6 +49,7 @@ export class CoDiscriminatedUnionSchema<
|
|
|
47
49
|
readonly collaborative = true as const;
|
|
48
50
|
readonly builtin = "CoDiscriminatedUnion" as const;
|
|
49
51
|
readonly getDefinition: () => CoDiscriminatedUnionSchemaDefinition<Options>;
|
|
52
|
+
readonly resolveQuery = true as const;
|
|
50
53
|
|
|
51
54
|
constructor(
|
|
52
55
|
coreSchema: CoreCoDiscriminatedUnionSchema<Options>,
|
|
@@ -64,22 +67,26 @@ export class CoDiscriminatedUnionSchema<
|
|
|
64
67
|
skipRetry?: boolean;
|
|
65
68
|
unstable_branch?: BranchDefinition;
|
|
66
69
|
},
|
|
67
|
-
): Promise<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
): Promise<
|
|
71
|
+
MaybeLoaded<
|
|
72
|
+
Resolved<
|
|
73
|
+
CoDiscriminatedUnionInstanceCoValuesMaybeLoaded<Options> & SchemaUnion,
|
|
74
|
+
true
|
|
75
|
+
>
|
|
76
|
+
>
|
|
77
|
+
> {
|
|
71
78
|
return this.coValueClass.load(id, options) as any;
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
subscribe(
|
|
75
82
|
id: string,
|
|
76
83
|
options: SubscribeListenerOptions<
|
|
77
|
-
|
|
84
|
+
CoDiscriminatedUnionInstanceCoValuesMaybeLoaded<Options> & SchemaUnion,
|
|
78
85
|
true
|
|
79
86
|
>,
|
|
80
87
|
listener: (
|
|
81
88
|
value: Resolved<
|
|
82
|
-
|
|
89
|
+
CoDiscriminatedUnionInstanceCoValuesMaybeLoaded<Options> & SchemaUnion,
|
|
83
90
|
true
|
|
84
91
|
>,
|
|
85
92
|
unsubscribe: () => void,
|
|
@@ -133,9 +140,12 @@ export function createCoreCoDiscriminatedUnionSchema<
|
|
|
133
140
|
return schemas;
|
|
134
141
|
},
|
|
135
142
|
}),
|
|
143
|
+
resolveQuery: true as const,
|
|
136
144
|
};
|
|
137
145
|
}
|
|
138
146
|
|
|
139
|
-
type
|
|
147
|
+
type CoDiscriminatedUnionInstanceCoValuesMaybeLoaded<
|
|
140
148
|
Options extends DiscriminableCoValueSchemas,
|
|
141
|
-
> =
|
|
149
|
+
> = LoadedAndRequired<
|
|
150
|
+
InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded<Options[number]>
|
|
151
|
+
>;
|