jazz-tools 0.18.37 → 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 +53 -53
- package/CHANGELOG.md +33 -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/inspector/{custom-element-SUVJ7CPN.js → custom-element-QESCMFY7.js} +13 -3
- package/dist/inspector/{custom-element-SUVJ7CPN.js.map → custom-element-QESCMFY7.js.map} +1 -1
- package/dist/inspector/index.js +12 -2
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/inspector/viewer/history-view.d.ts.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 +74 -10
- package/src/inspector/viewer/history-view.tsx +14 -5
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LocalNode, RawCoValue } from "cojson";
|
|
2
2
|
import type { BranchDefinition } from "./types.js";
|
|
3
|
+
import { CoValueLoadingState } from "./types.js";
|
|
3
4
|
/**
|
|
4
5
|
* Manages subscriptions to CoValue cores, handling both direct subscriptions
|
|
5
6
|
* and branch-based subscriptions with automatic loading and error handling.
|
|
@@ -15,7 +16,7 @@ export declare class CoValueCoreSubscription {
|
|
|
15
16
|
private localNode;
|
|
16
17
|
private listener;
|
|
17
18
|
private skipRetry?;
|
|
18
|
-
constructor(localNode: LocalNode, id: string, listener: (value: RawCoValue |
|
|
19
|
+
constructor(localNode: LocalNode, id: string, listener: (value: RawCoValue | typeof CoValueLoadingState.UNAVAILABLE) => void, skipRetry?: boolean, branch?: BranchDefinition);
|
|
19
20
|
/**
|
|
20
21
|
* Rehydrates the subscription by resetting the unsubscribed flag and initializing the subscription again
|
|
21
22
|
*/
|
|
@@ -55,7 +56,7 @@ export declare class CoValueCoreSubscription {
|
|
|
55
56
|
* This is the final step where we actually start receiving updates.
|
|
56
57
|
*/
|
|
57
58
|
private subscribe;
|
|
58
|
-
emit(value: RawCoValue |
|
|
59
|
+
emit(value: RawCoValue | typeof CoValueLoadingState.UNAVAILABLE): void;
|
|
59
60
|
/**
|
|
60
61
|
* Unsubscribes from all active subscriptions and marks the instance as unsubscribed.
|
|
61
62
|
* This prevents any further operations and ensures proper cleanup.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoValueCoreSubscription.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/CoValueCoreSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAET,UAAU,EACX,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"CoValueCoreSubscription.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/CoValueCoreSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAET,UAAU,EACX,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,aAAa,CAAC,CAAU;IAChC,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,QAAQ,CAEN;IACV,OAAO,CAAC,SAAS,CAAC,CAAU;gBAG1B,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CACR,KAAK,EAAE,UAAU,GAAG,OAAO,mBAAmB,CAAC,WAAW,KACvD,IAAI,EACT,SAAS,CAAC,EAAE,OAAO,EACnB,MAAM,CAAC,EAAE,gBAAgB;IAY3B;;OAEG;IACH,SAAS;IAWT;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAmB9B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAuB7B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAY/B;;;OAGG;IACH,OAAO,CAAC,WAAW;IAsBnB;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IA6BpC;;;OAGG;IACH,OAAO,CAAC,SAAS;IASjB,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,mBAAmB,CAAC,WAAW,GAAG,IAAI;IAStE;;;OAGG;IACH,WAAW,IAAI,IAAI;CAKpB"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { CoValue, ID } from "../internal.js";
|
|
2
|
+
import { CoValueLoadingState } from "./types.js";
|
|
2
3
|
export declare class JazzError {
|
|
3
4
|
id: ID<CoValue> | undefined;
|
|
4
|
-
type:
|
|
5
|
+
type: typeof CoValueLoadingState.UNAVAILABLE | typeof CoValueLoadingState.UNAUTHORIZED;
|
|
5
6
|
issues: JazzErrorIssue[];
|
|
6
|
-
constructor(id: ID<CoValue> | undefined, type:
|
|
7
|
+
constructor(id: ID<CoValue> | undefined, type: typeof CoValueLoadingState.UNAVAILABLE | typeof CoValueLoadingState.UNAUTHORIZED, issues: JazzErrorIssue[]);
|
|
7
8
|
toString(): string;
|
|
8
9
|
prependPath(item: string): JazzError;
|
|
9
10
|
}
|
|
10
11
|
export type JazzErrorIssue = {
|
|
11
|
-
code:
|
|
12
|
+
code: typeof CoValueLoadingState.UNAVAILABLE | typeof CoValueLoadingState.UNAUTHORIZED | "validationError";
|
|
12
13
|
message: string;
|
|
13
14
|
params: Record<string, any>;
|
|
14
15
|
path: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JazzError.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/JazzError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"JazzError.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/JazzError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,SAAS;IAEX,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,SAAS;IAC3B,IAAI,EACP,OAAO,mBAAmB,CAAC,WAAW,GACtC,OAAO,mBAAmB,CAAC,YAAY;IACpC,MAAM,EAAE,cAAc,EAAE;gBAJxB,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,SAAS,EAC3B,IAAI,EACP,OAAO,mBAAmB,CAAC,WAAW,GACtC,OAAO,mBAAmB,CAAC,YAAY,EACpC,MAAM,EAAE,cAAc,EAAE;IAGjC,QAAQ;IAkBR,WAAW,CAAC,IAAI,EAAE,MAAM;CAczB;AACD,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EACA,OAAO,mBAAmB,CAAC,WAAW,GACtC,OAAO,mBAAmB,CAAC,YAAY,GACvC,iBAAiB,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC"}
|
|
@@ -2,7 +2,8 @@ import type { LocalNode, RawCoValue } from "cojson";
|
|
|
2
2
|
import { CoList, CoMap, type CoValue, type ID, type RefEncoded, type RefsToResolve } from "../internal.js";
|
|
3
3
|
import { CoValueCoreSubscription } from "./CoValueCoreSubscription.js";
|
|
4
4
|
import { JazzError } from "./JazzError.js";
|
|
5
|
-
import type { BranchDefinition, SubscriptionValue,
|
|
5
|
+
import type { BranchDefinition, SubscriptionValue, SubscriptionValueLoading } from "./types.js";
|
|
6
|
+
import { CoValueLoadingState, NotLoadedCoValueState } from "./types.js";
|
|
6
7
|
export declare class SubscriptionScope<D extends CoValue> {
|
|
7
8
|
node: LocalNode;
|
|
8
9
|
id: ID<D>;
|
|
@@ -20,7 +21,7 @@ export declare class SubscriptionScope<D extends CoValue> {
|
|
|
20
21
|
* Autoloaded child ids that are unloaded
|
|
21
22
|
*/
|
|
22
23
|
pendingAutoloadedChildren: Set<string>;
|
|
23
|
-
value: SubscriptionValue<D, any> |
|
|
24
|
+
value: SubscriptionValue<D, any> | SubscriptionValueLoading;
|
|
24
25
|
childErrors: Map<string, JazzError>;
|
|
25
26
|
validationErrors: Map<string, JazzError>;
|
|
26
27
|
errorFromChildren: JazzError | undefined;
|
|
@@ -38,11 +39,11 @@ export declare class SubscriptionScope<D extends CoValue> {
|
|
|
38
39
|
silenceUpdates: boolean;
|
|
39
40
|
constructor(node: LocalNode, resolve: RefsToResolve<D>, id: ID<D>, schema: RefEncoded<D>, skipRetry?: boolean, bestEffortResolution?: boolean, unstable_branch?: BranchDefinition | undefined);
|
|
40
41
|
updateValue(value: SubscriptionValue<D, any>): void;
|
|
41
|
-
handleUpdate(update: RawCoValue |
|
|
42
|
+
handleUpdate(update: RawCoValue | typeof CoValueLoadingState.UNAVAILABLE): void;
|
|
42
43
|
computeChildErrors(): JazzError | undefined;
|
|
43
|
-
handleChildUpdate: (id: string, value: SubscriptionValue<any, any> |
|
|
44
|
+
handleChildUpdate: (id: string, value: SubscriptionValue<any, any> | SubscriptionValueLoading, key?: string) => void;
|
|
44
45
|
shouldSendUpdates(): boolean;
|
|
45
|
-
getCurrentValue(): D |
|
|
46
|
+
getCurrentValue(): D | NotLoadedCoValueState;
|
|
46
47
|
triggerUpdate(): void;
|
|
47
48
|
subscribers: Set<(value: SubscriptionValue<D, any>) => void>;
|
|
48
49
|
subscribe(listener: (value: SubscriptionValue<D, any>) => void): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionScope.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/SubscriptionScope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAEL,MAAM,EACN,KAAK,EACL,KAAK,OAAO,EACZ,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"SubscriptionScope.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/SubscriptionScope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAEL,MAAM,EACN,KAAK,EACL,KAAK,OAAO,EACZ,KAAK,EAAE,EAEP,KAAK,UAAU,EACf,KAAK,aAAa,EAInB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE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,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,EAC3B,GAAG,CAAC,EAAE,MAAM;IAoDd,OAAO;CAOR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAgB,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAgB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,OAAO,EAAE,KAAK,EAAE,CAAC,qDA0B/D;AAED,yBAAyB;AAEzB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,OAAO,EAChD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,OAwBZ;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,EAC/C,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,OAgB5B"}
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import type { Account, CoValue, Group, RefsToResolve, Resolved } from "../internal.js";
|
|
2
2
|
import type { JazzError } from "./JazzError.js";
|
|
3
|
+
export declare const CoValueLoadingState: {
|
|
4
|
+
/**
|
|
5
|
+
* The coValue is loaded.
|
|
6
|
+
*/
|
|
7
|
+
readonly LOADED: "loaded";
|
|
8
|
+
/**
|
|
9
|
+
* The coValue is being loaded.
|
|
10
|
+
*/
|
|
11
|
+
readonly LOADING: "loading";
|
|
12
|
+
/**
|
|
13
|
+
* The coValue was loaded but the account is not authorized to access it.
|
|
14
|
+
*/
|
|
15
|
+
readonly UNAUTHORIZED: "unauthorized";
|
|
16
|
+
/**
|
|
17
|
+
* Tried to load the coValue but failed.
|
|
18
|
+
*/
|
|
19
|
+
readonly UNAVAILABLE: "unavailable";
|
|
20
|
+
};
|
|
21
|
+
export type CoValueLoadingState = (typeof CoValueLoadingState)[keyof typeof CoValueLoadingState];
|
|
22
|
+
export type NotLoadedCoValueState = typeof CoValueLoadingState.LOADING | typeof CoValueLoadingState.UNAUTHORIZED | typeof CoValueLoadingState.UNAVAILABLE;
|
|
3
23
|
export type SubscriptionValue<D extends CoValue, R extends RefsToResolve<D>> = {
|
|
4
|
-
type:
|
|
24
|
+
type: typeof CoValueLoadingState.LOADED;
|
|
5
25
|
value: Resolved<D, R>;
|
|
6
26
|
id: string;
|
|
7
27
|
} | JazzError;
|
|
8
|
-
export type
|
|
9
|
-
type:
|
|
28
|
+
export type SubscriptionValueLoading = {
|
|
29
|
+
type: typeof CoValueLoadingState.LOADING;
|
|
10
30
|
id: string;
|
|
11
31
|
};
|
|
12
32
|
export type BranchDefinition = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,aAAa,EACb,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,IACvE;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,aAAa,EACb,QAAQ,EACT,MAAM,gBAAgB,CAAC;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ceRoot":"","sources":["../../../src/tools/subscribe/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,UAAU,EAGX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAUnE;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,EAC7C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,GAAG,EAAE,UAAU,EACf,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;;;;EAgBxC"}
|
package/dist/tools/testing.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LocalNode } from "cojson";
|
|
2
2
|
import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
|
|
3
|
-
import { Account, AccountClass, type AnonymousJazzAgent, CoValueFromRaw, CoreAccountSchema, InstanceOfSchema, JazzContextManager, JazzContextManagerAuthProps, JazzContextManagerBaseProps } from "./internal.js";
|
|
3
|
+
import { Account, AccountClass, type AnonymousJazzAgent, CoValueFromRaw, CoreAccountSchema, InstanceOfSchema, JazzContextManager, JazzContextManagerAuthProps, JazzContextManagerBaseProps, CoValue } from "./internal.js";
|
|
4
|
+
export { assertLoaded } from "./lib/utils.js";
|
|
4
5
|
export declare class TestJSCrypto extends PureJSCrypto {
|
|
5
6
|
static create(): Promise<PureJSCrypto>;
|
|
6
7
|
}
|
|
@@ -49,7 +50,7 @@ export declare class TestJazzContextManager<Acc extends Account> extends JazzCon
|
|
|
49
50
|
fromNode: (typeof Account)["fromNode"];
|
|
50
51
|
} & CoValueFromRaw<Acc> extends infer T ? T extends import("./internal.js").CoValueClass<Acc> & {
|
|
51
52
|
fromNode: (typeof Account)["fromNode"];
|
|
52
|
-
} & CoValueFromRaw<Acc> ? T extends import("./internal.js").CoValueClass<
|
|
53
|
+
} & CoValueFromRaw<Acc> ? T extends import("./internal.js").CoValueClass<CoValue> ? InstanceType<T> : never : never : never;
|
|
53
54
|
node: LocalNode;
|
|
54
55
|
done: () => void;
|
|
55
56
|
logOut: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/tools/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACL,OAAO,EACP,YAAY,EACZ,KAAK,kBAAkB,EAEvB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/tools/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACL,OAAO,EACP,YAAY,EACZ,KAAK,kBAAkB,EAEvB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAK3B,OAAO,EAIR,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAO9C,qBAAa,YAAa,SAAQ,YAAY;WAC/B,MAAM;CAoBpB;AAED,wBAAgB,gCAAgC,0BAiC/C;AAKD,wBAAsB,qBAAqB,CACzC,CAAC,SACG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,GACjD,iBAAiB,EACrB,OAAO,CAAC,EAAE;IACV,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,aAAa,CAAC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Z,KAAK,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC;IA8C1C,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,OAAO,EAClC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,kBAAkB,CAAA;KAAE,EACxC,KAAK,GAAE,2BAA2B,CAAC,GAAG,CAAM;IAuBxC,aAAa,CACjB,KAAK,EAAE,2BAA2B,CAAC,GAAG,CAAC,EACvC,SAAS,CAAC,EAAE,2BAA2B;;uBAsF2gN,cAAc;;;;;;;0CA1D5hN,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI;;;CAMrE;AAED,wBAAsB,YAAY,CAChC,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,KAAK,GAAE,QAAQ,GAAG,QAAmB,EACrC,KAAK,GAAE,QAAQ,GAAG,QAAmB,iBAgBtC;AAED,wBAAsB,iBAAiB,CAAC,EACtC,UAAkB,GACnB,GAAE;IACD,UAAU,CAAC,EAAE,OAAO,CAAC;CACjB,oBAgBL;AAED,wBAAgB,mBAAmB,SAKlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.resolved.test.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/schema.resolved.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountClass } from "../coValues/account";
|
|
2
2
|
import { CoID, LocalNode, RawCoValue } from "cojson";
|
|
3
3
|
import { Account } from "../index";
|
|
4
|
-
import { CoValueFromRaw } from "../internal";
|
|
4
|
+
import { CoValue, CoValueFromRaw, MaybeLoaded, LoadedAndRequired } from "../internal";
|
|
5
5
|
export declare function setupAccount(): Promise<{
|
|
6
6
|
me: import("../internal").ControlledAccount;
|
|
7
7
|
meOnSecondPeer: Account | ({
|
|
@@ -18,4 +18,5 @@ export declare function setupTwoNodes(options?: {
|
|
|
18
18
|
}>;
|
|
19
19
|
export declare function waitFor(callback: () => boolean | void | Promise<boolean | void>): Promise<void>;
|
|
20
20
|
export declare function loadCoValueOrFail<V extends RawCoValue>(node: LocalNode, id: CoID<V>): Promise<V>;
|
|
21
|
+
export declare function assertLoaded<T extends MaybeLoaded<CoValue>>(coValue: T): asserts coValue is LoadedAndRequired<T>;
|
|
21
22
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAuB,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGrD,OAAO,EACL,OAAO,EAGR,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,OAAO,EACP,cAAc,EAEd,WAAW,EACX,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAIrB,wBAAsB,YAAY;;;;;GAgCjC;AAED,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE;IAC5C,mBAAmB,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CACvE;;;;;GAgDA;AAED,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,iBA2BzD;AAED,wBAAsB,iBAAiB,CAAC,CAAC,SAAS,UAAU,EAC1D,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,GACV,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,CAAC,OAAO,CAAC,EACzD,OAAO,EAAE,CAAC,GACT,OAAO,CAAC,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAEzC"}
|
package/package.json
CHANGED
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
},
|
|
188
188
|
"type": "module",
|
|
189
189
|
"license": "MIT",
|
|
190
|
-
"version": "0.
|
|
190
|
+
"version": "0.19.0",
|
|
191
191
|
"dependencies": {
|
|
192
192
|
"@manuscripts/prosemirror-recreate-steps": "^0.1.4",
|
|
193
193
|
"@scure/base": "1.2.1",
|
|
@@ -204,9 +204,9 @@
|
|
|
204
204
|
"prosemirror-transform": "^1.9.0",
|
|
205
205
|
"use-sync-external-store": "^1.5.0",
|
|
206
206
|
"zod": "4.1.11",
|
|
207
|
-
"cojson": "0.
|
|
208
|
-
"cojson-storage-indexeddb": "0.
|
|
209
|
-
"cojson-transport-ws": "0.
|
|
207
|
+
"cojson": "0.19.0",
|
|
208
|
+
"cojson-storage-indexeddb": "0.19.0",
|
|
209
|
+
"cojson-transport-ws": "0.19.0"
|
|
210
210
|
},
|
|
211
211
|
"devDependencies": {
|
|
212
212
|
"@scure/bip39": "^1.3.0",
|
|
@@ -80,7 +80,7 @@ export const JazzBetterAuthDatabaseAdapter = (
|
|
|
80
80
|
|
|
81
81
|
let worker: Account | undefined = undefined;
|
|
82
82
|
|
|
83
|
-
async function getWorker() {
|
|
83
|
+
async function getWorker(): Promise<Account> {
|
|
84
84
|
if (worker) {
|
|
85
85
|
return worker;
|
|
86
86
|
}
|
|
@@ -96,7 +96,7 @@ export const JazzBetterAuthDatabaseAdapter = (
|
|
|
96
96
|
|
|
97
97
|
worker = result.worker;
|
|
98
98
|
|
|
99
|
-
return worker;
|
|
99
|
+
return result.worker;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
async function initRepository(
|
|
@@ -45,7 +45,7 @@ export class AccountRepository extends JazzRepository {
|
|
|
45
45
|
if (isWhereBySingleField(this.getAccountIdProperty(), where)) {
|
|
46
46
|
const accountIdIndex = await this.getAccountIdIndex(where[0].value);
|
|
47
47
|
|
|
48
|
-
const ids = accountIdIndex
|
|
48
|
+
const ids = accountIdIndex.$isLoaded ? accountIdIndex : [];
|
|
49
49
|
|
|
50
50
|
if (ids.length === 0) {
|
|
51
51
|
return [];
|
|
@@ -102,7 +102,7 @@ export class AccountRepository extends JazzRepository {
|
|
|
102
102
|
private async updateAccountIdIndex(accountId: string, entityId: string) {
|
|
103
103
|
const accountIdIndex = await this.getAccountIdIndex(accountId);
|
|
104
104
|
|
|
105
|
-
const ids = accountIdIndex
|
|
105
|
+
const ids = accountIdIndex.$isLoaded ? accountIdIndex : [];
|
|
106
106
|
|
|
107
107
|
await AccountIdIndex.upsertUnique({
|
|
108
108
|
value: [...ids, entityId],
|
|
@@ -114,7 +114,7 @@ export class AccountRepository extends JazzRepository {
|
|
|
114
114
|
private async deleteAccountIdIndex(accountId: string, entityId: string) {
|
|
115
115
|
const accountIdIndex = await this.getAccountIdIndex(accountId);
|
|
116
116
|
|
|
117
|
-
const ids = accountIdIndex
|
|
117
|
+
const ids = accountIdIndex.$isLoaded ? accountIdIndex : [];
|
|
118
118
|
|
|
119
119
|
await AccountIdIndex.upsertUnique({
|
|
120
120
|
value: ids.filter((id) => id !== entityId),
|
|
@@ -80,16 +80,19 @@ export class JazzRepository {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// If we have a unique id, we must check for soft deleted items first
|
|
83
|
-
const existingNode =
|
|
83
|
+
const existingNode = await schema.loadUnique(
|
|
84
84
|
uniqueId,
|
|
85
85
|
list.$jazz.owner.$jazz.id,
|
|
86
86
|
{
|
|
87
87
|
loadAs: this.worker,
|
|
88
88
|
},
|
|
89
|
-
)
|
|
89
|
+
);
|
|
90
90
|
|
|
91
91
|
// if the entity exists and is not soft deleted, we must throw an error
|
|
92
|
-
if (
|
|
92
|
+
if (
|
|
93
|
+
existingNode.$isLoaded &&
|
|
94
|
+
existingNode.$jazz.raw.get("_deleted") !== true
|
|
95
|
+
) {
|
|
93
96
|
throw new Error("Entity already exists");
|
|
94
97
|
}
|
|
95
98
|
|
|
@@ -103,7 +106,7 @@ export class JazzRepository {
|
|
|
103
106
|
unique: uniqueId,
|
|
104
107
|
});
|
|
105
108
|
|
|
106
|
-
if (!node) {
|
|
109
|
+
if (!node.$isLoaded) {
|
|
107
110
|
throw new Error("Unable to create entity");
|
|
108
111
|
}
|
|
109
112
|
|
|
@@ -131,7 +134,7 @@ export class JazzRepository {
|
|
|
131
134
|
|
|
132
135
|
const node = await this.getSchema(model).load(id, { loadAs: this.worker });
|
|
133
136
|
|
|
134
|
-
if (!node) {
|
|
137
|
+
if (!node.$isLoaded) {
|
|
135
138
|
return null;
|
|
136
139
|
}
|
|
137
140
|
|
|
@@ -156,7 +159,7 @@ export class JazzRepository {
|
|
|
156
159
|
},
|
|
157
160
|
);
|
|
158
161
|
|
|
159
|
-
if (!node) {
|
|
162
|
+
if (!node.$isLoaded) {
|
|
160
163
|
return null;
|
|
161
164
|
}
|
|
162
165
|
|
|
@@ -27,7 +27,7 @@ export class UserRepository extends JazzRepository {
|
|
|
27
27
|
|
|
28
28
|
const emailIndex = await this.loadEmailIndex(userEmail);
|
|
29
29
|
|
|
30
|
-
if (emailIndex
|
|
30
|
+
if (emailIndex.$isLoaded && emailIndex.user) {
|
|
31
31
|
throw new Error("Email already exists");
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -68,7 +68,11 @@ export class UserRepository extends JazzRepository {
|
|
|
68
68
|
private async findByEmail(email: string): Promise<TableItem[]> {
|
|
69
69
|
const emailIndex = await this.loadEmailIndex(email);
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
if (!emailIndex.$isLoaded) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const user = emailIndex.user;
|
|
72
76
|
|
|
73
77
|
if (!user) {
|
|
74
78
|
return [];
|
|
@@ -55,7 +55,7 @@ export function createJazzSchema(schema: BetterAuthDbSchema): JazzSchema {
|
|
|
55
55
|
},
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
-
if (!dbRoot) {
|
|
58
|
+
if (!dbRoot.$isLoaded) {
|
|
59
59
|
// Create a group for the first time
|
|
60
60
|
// it will be the owner of the all tables and data
|
|
61
61
|
const adminGroup = Group.create({ owner: account });
|
|
@@ -16,6 +16,7 @@ import { startWorker } from "jazz-tools/worker";
|
|
|
16
16
|
import { createWorkerAccount, startSyncServer } from "./sync-utils.js";
|
|
17
17
|
import { JazzBetterAuthDatabaseAdapter } from "../index.js";
|
|
18
18
|
import { TableItem } from "../schema.js";
|
|
19
|
+
import { assertLoaded } from "jazz-tools/testing";
|
|
19
20
|
|
|
20
21
|
describe("JazzBetterAuthDatabaseAdapter tests", async () => {
|
|
21
22
|
describe("better-auth internal tests", async () => {
|
|
@@ -197,9 +198,7 @@ describe("JazzBetterAuthDatabaseAdapter tests", async () => {
|
|
|
197
198
|
},
|
|
198
199
|
});
|
|
199
200
|
|
|
200
|
-
|
|
201
|
-
assert(db.group);
|
|
202
|
-
assert(db.tables);
|
|
201
|
+
assertLoaded(db);
|
|
203
202
|
|
|
204
203
|
// Create a new worker account
|
|
205
204
|
const newWorkerAccount = await createWorkerAccount({
|
|
@@ -208,7 +207,7 @@ describe("JazzBetterAuthDatabaseAdapter tests", async () => {
|
|
|
208
207
|
});
|
|
209
208
|
|
|
210
209
|
const newWorkerRef = await Account.load(newWorkerAccount.accountID);
|
|
211
|
-
|
|
210
|
+
assertLoaded(newWorkerRef);
|
|
212
211
|
|
|
213
212
|
// Add the new worker to the group
|
|
214
213
|
db.group.addMember(newWorkerRef, "admin");
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// @vitest-environment happy-dom
|
|
2
|
-
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
|
3
|
-
import {
|
|
2
|
+
import { afterEach, assert, beforeAll, describe, expect, it } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
assertLoaded,
|
|
5
|
+
createJazzTestAccount,
|
|
6
|
+
setupJazzTestSync,
|
|
7
|
+
} from "jazz-tools/testing";
|
|
4
8
|
import { co, z } from "jazz-tools";
|
|
5
9
|
import {
|
|
6
10
|
cleanup,
|
|
@@ -45,7 +49,7 @@ describe("HistoryView", async () => {
|
|
|
45
49
|
.create({ foo: "bar" }, account);
|
|
46
50
|
|
|
47
51
|
render(
|
|
48
|
-
<HistoryView coValue={value.$jazz.raw} node={
|
|
52
|
+
<HistoryView coValue={value.$jazz.raw} node={account.$jazz.localNode} />,
|
|
49
53
|
);
|
|
50
54
|
|
|
51
55
|
expect(
|
|
@@ -69,7 +73,10 @@ describe("HistoryView", async () => {
|
|
|
69
73
|
value.$jazz.delete("certified");
|
|
70
74
|
|
|
71
75
|
render(
|
|
72
|
-
<HistoryView
|
|
76
|
+
<HistoryView
|
|
77
|
+
coValue={value.$jazz.raw}
|
|
78
|
+
node={account.$jazz.localNode}
|
|
79
|
+
/>,
|
|
73
80
|
);
|
|
74
81
|
|
|
75
82
|
const history = [
|
|
@@ -82,8 +89,6 @@ describe("HistoryView", async () => {
|
|
|
82
89
|
'Property "certified" has been deleted',
|
|
83
90
|
].toReversed(); // Default sort is descending
|
|
84
91
|
|
|
85
|
-
expect(screen.getAllByRole("row")).toHaveLength(history.length + 2);
|
|
86
|
-
|
|
87
92
|
await waitFor(() => {
|
|
88
93
|
expect(screen.getAllByRole("row")[2]?.textContent).toContain(
|
|
89
94
|
account.$jazz.id,
|
|
@@ -92,6 +97,56 @@ describe("HistoryView", async () => {
|
|
|
92
97
|
|
|
93
98
|
expect(extractActions()).toEqual(history);
|
|
94
99
|
});
|
|
100
|
+
|
|
101
|
+
it("should render invalid changes", async () => {
|
|
102
|
+
const account2 = await createJazzTestAccount();
|
|
103
|
+
const group = co.group().create(account);
|
|
104
|
+
group.addMember(account2, "reader");
|
|
105
|
+
|
|
106
|
+
const Schema = co.map({
|
|
107
|
+
pet: z.string(),
|
|
108
|
+
age: z.number(),
|
|
109
|
+
certified: z.boolean().optional(),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const value = Schema.create(
|
|
113
|
+
{ pet: "dog", age: 10, certified: false },
|
|
114
|
+
group,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const valueOnAccount2 = await Schema.load(value.$jazz.id, {
|
|
118
|
+
loadAs: account2,
|
|
119
|
+
});
|
|
120
|
+
assertLoaded(valueOnAccount2);
|
|
121
|
+
|
|
122
|
+
// This is invalid, since account2 is a reader
|
|
123
|
+
valueOnAccount2.$jazz.set("pet", "cat");
|
|
124
|
+
|
|
125
|
+
render(
|
|
126
|
+
<HistoryView
|
|
127
|
+
coValue={valueOnAccount2.$jazz.raw}
|
|
128
|
+
node={account2.$jazz.localNode}
|
|
129
|
+
/>,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const history = [
|
|
133
|
+
'Property "pet" has been set to "dog"',
|
|
134
|
+
'Property "age" has been set to 10',
|
|
135
|
+
'Property "certified" has been set to false',
|
|
136
|
+
|
|
137
|
+
// Account2 can't write to the value
|
|
138
|
+
'Property "pet" has been set to "cat"Invalid transaction: Transactor has no write permissions',
|
|
139
|
+
].toReversed(); // Default sort is descending
|
|
140
|
+
|
|
141
|
+
await waitFor(() => {
|
|
142
|
+
expect(screen.getAllByRole("row")[2]?.textContent).toContain(
|
|
143
|
+
account2.$jazz.id,
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
expect(extractActions()).toEqual(history);
|
|
148
|
+
});
|
|
149
|
+
|
|
95
150
|
it("should render co.map changes with json", async () => {
|
|
96
151
|
const d = new Date();
|
|
97
152
|
const value = co
|
|
@@ -147,7 +202,10 @@ describe("HistoryView", async () => {
|
|
|
147
202
|
value.$jazz.shift();
|
|
148
203
|
|
|
149
204
|
render(
|
|
150
|
-
<HistoryView
|
|
205
|
+
<HistoryView
|
|
206
|
+
coValue={value.$jazz.raw}
|
|
207
|
+
node={account.$jazz.localNode}
|
|
208
|
+
/>,
|
|
151
209
|
);
|
|
152
210
|
|
|
153
211
|
const history = [
|
|
@@ -194,7 +252,10 @@ describe("HistoryView", async () => {
|
|
|
194
252
|
value.$jazz.shift();
|
|
195
253
|
|
|
196
254
|
render(
|
|
197
|
-
<HistoryView
|
|
255
|
+
<HistoryView
|
|
256
|
+
coValue={value.$jazz.raw}
|
|
257
|
+
node={account.$jazz.localNode}
|
|
258
|
+
/>,
|
|
198
259
|
);
|
|
199
260
|
|
|
200
261
|
const history = [
|
|
@@ -223,8 +284,11 @@ describe("HistoryView", async () => {
|
|
|
223
284
|
const group3 = co.group().create(account);
|
|
224
285
|
group3.addMember(group, "inherit");
|
|
225
286
|
|
|
226
|
-
|
|
227
|
-
<HistoryView
|
|
287
|
+
render(
|
|
288
|
+
<HistoryView
|
|
289
|
+
coValue={group.$jazz.raw}
|
|
290
|
+
node={account.$jazz.localNode}
|
|
291
|
+
/>,
|
|
228
292
|
);
|
|
229
293
|
|
|
230
294
|
const history = [
|
|
@@ -31,6 +31,7 @@ type HistoryEntry = {
|
|
|
31
31
|
action: string;
|
|
32
32
|
timestamp: Date;
|
|
33
33
|
isValid: boolean;
|
|
34
|
+
validationErrorMessage: string | undefined;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
export function HistoryView({
|
|
@@ -85,7 +86,18 @@ export function HistoryView({
|
|
|
85
86
|
{
|
|
86
87
|
id: "action",
|
|
87
88
|
header: "Action",
|
|
88
|
-
accessor: (row) =>
|
|
89
|
+
accessor: (row) => {
|
|
90
|
+
if (row.isValid) return row.action;
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
{row.action}
|
|
95
|
+
<span style={{ color: "red", display: "block" }}>
|
|
96
|
+
Invalid transaction: {row.validationErrorMessage}
|
|
97
|
+
</span>
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
},
|
|
89
101
|
sortable: false,
|
|
90
102
|
filterable: true,
|
|
91
103
|
sortFn: (a, b) => a.action.localeCompare(b.action),
|
|
@@ -131,10 +143,6 @@ function getTransactionChanges(
|
|
|
131
143
|
readKey,
|
|
132
144
|
) ?? []
|
|
133
145
|
);
|
|
134
|
-
|
|
135
|
-
// const decryptedString = coValue.core.verified.sessions.get(tx.txID.sessionID)?.impl.decryptNextTransactionChangesJson(tx.txID.txIndex, readKey);
|
|
136
|
-
|
|
137
|
-
// return decryptedString ? [decryptedString] : [];
|
|
138
146
|
}
|
|
139
147
|
|
|
140
148
|
return tx.changes ?? (tx.tx as any).changes ?? [];
|
|
@@ -150,6 +158,7 @@ function getHistory(coValue: RawCoValue): HistoryEntry[] {
|
|
|
150
158
|
action: mapTransactionToAction(change, coValue),
|
|
151
159
|
timestamp: new Date(tx.currentMadeAt),
|
|
152
160
|
isValid: tx.isValid,
|
|
161
|
+
validationErrorMessage: tx.validationErrorMessage,
|
|
153
162
|
}));
|
|
154
163
|
});
|
|
155
164
|
}
|
package/src/media/utils.test.ts
CHANGED
|
@@ -253,6 +253,11 @@ describe("loadImageBySize", async () => {
|
|
|
253
253
|
return imageDef;
|
|
254
254
|
};
|
|
255
255
|
|
|
256
|
+
it("return null if the image cannot be loaded", async () => {
|
|
257
|
+
const result = await loadImageBySize("invalid-id", 256, 256);
|
|
258
|
+
expect(result).toBeNull();
|
|
259
|
+
});
|
|
260
|
+
|
|
256
261
|
it("returns original if progressive is false", async () => {
|
|
257
262
|
const imageDef = await createImageDef([[1920, 1080]], false);
|
|
258
263
|
const result = await loadImageBySize(imageDef, 256, 256);
|