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
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
createJazzTestGuest,
|
|
8
8
|
setupJazzTestSync,
|
|
9
9
|
} from "../testing.js";
|
|
10
|
+
import { assertLoaded } from "./utils.js";
|
|
10
11
|
|
|
11
12
|
cojsonInternals.CO_VALUE_LOADING_CONFIG.RETRY_DELAY = 10;
|
|
12
13
|
|
|
@@ -291,9 +292,9 @@ describe("importContentPieces", () => {
|
|
|
291
292
|
|
|
292
293
|
// Verify bob can now access the person
|
|
293
294
|
const importedPerson = await Person.load(person.$jazz.id, { loadAs: bob });
|
|
294
|
-
|
|
295
|
-
expect(importedPerson
|
|
296
|
-
expect(importedPerson
|
|
295
|
+
assertLoaded(importedPerson);
|
|
296
|
+
expect(importedPerson.name).toBe("John");
|
|
297
|
+
expect(importedPerson.age).toBe(30);
|
|
297
298
|
});
|
|
298
299
|
|
|
299
300
|
test("imports content pieces with nested references", async () => {
|
|
@@ -339,11 +340,11 @@ describe("importContentPieces", () => {
|
|
|
339
340
|
loadAs: bob,
|
|
340
341
|
});
|
|
341
342
|
|
|
342
|
-
|
|
343
|
-
expect(importedPerson
|
|
344
|
-
expect(importedPerson
|
|
345
|
-
expect(importedPerson
|
|
346
|
-
expect(importedPerson
|
|
343
|
+
assertLoaded(importedPerson);
|
|
344
|
+
expect(importedPerson.name).toBe("John");
|
|
345
|
+
expect(importedPerson.address).not.toBeNull();
|
|
346
|
+
expect(importedPerson.address.street).toBe("123 Main St");
|
|
347
|
+
expect(importedPerson.address.city).toBe("New York");
|
|
347
348
|
});
|
|
348
349
|
|
|
349
350
|
test("imports content pieces to anonymous agent", async () => {
|
|
@@ -376,8 +377,8 @@ describe("importContentPieces", () => {
|
|
|
376
377
|
const importedPerson = await Person.load(person.$jazz.id, {
|
|
377
378
|
loadAs: guest,
|
|
378
379
|
});
|
|
379
|
-
|
|
380
|
-
expect(importedPerson
|
|
380
|
+
assertLoaded(importedPerson);
|
|
381
|
+
expect(importedPerson.name).toBe("John");
|
|
381
382
|
});
|
|
382
383
|
|
|
383
384
|
test("imports content pieces without specifying loadAs (uses current account)", async () => {
|
|
@@ -410,8 +411,8 @@ describe("importContentPieces", () => {
|
|
|
410
411
|
|
|
411
412
|
// Verify bob can access the person
|
|
412
413
|
const importedPerson = await Person.load(person.$jazz.id, { loadAs: bob });
|
|
413
|
-
|
|
414
|
-
expect(importedPerson
|
|
414
|
+
assertLoaded(importedPerson);
|
|
415
|
+
expect(importedPerson.name).toBe("John");
|
|
415
416
|
});
|
|
416
417
|
|
|
417
418
|
test("handles empty content pieces array", async () => {
|
|
@@ -452,8 +453,8 @@ describe("importContentPieces", () => {
|
|
|
452
453
|
|
|
453
454
|
// Should still work correctly
|
|
454
455
|
const importedPerson = await Person.load(person.$jazz.id, { loadAs: bob });
|
|
455
|
-
|
|
456
|
-
expect(importedPerson
|
|
456
|
+
assertLoaded(importedPerson);
|
|
457
|
+
expect(importedPerson.name).toBe("John");
|
|
457
458
|
});
|
|
458
459
|
|
|
459
460
|
test("imports content pieces with complex nested structure", async () => {
|
|
@@ -534,7 +535,7 @@ describe("importContentPieces", () => {
|
|
|
534
535
|
loadAs: bob,
|
|
535
536
|
});
|
|
536
537
|
|
|
537
|
-
|
|
538
|
+
assertLoaded(importedBlog);
|
|
538
539
|
expect(importedBlog?.name).toBe("My Blog");
|
|
539
540
|
expect(importedBlog?.posts.length).toBe(1);
|
|
540
541
|
expect(importedBlog?.posts[0]?.title).toBe("My First Post");
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
|
2
2
|
import { assert, beforeEach, describe, expect, test } from "vitest";
|
|
3
3
|
import { CoMap, Group, z } from "../exports.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Account,
|
|
6
|
+
Loaded,
|
|
7
|
+
MaybeLoaded,
|
|
8
|
+
Ref,
|
|
9
|
+
co,
|
|
10
|
+
CoValueLoadingState,
|
|
11
|
+
} from "../internal.js";
|
|
5
12
|
import { createJazzTestAccount, setupJazzTestSync } from "../testing.js";
|
|
6
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
assertLoaded,
|
|
15
|
+
loadCoValueOrFail,
|
|
16
|
+
setupTwoNodes,
|
|
17
|
+
waitFor,
|
|
18
|
+
} from "./utils.js";
|
|
7
19
|
|
|
8
20
|
const Crypto = await WasmCrypto.create();
|
|
9
21
|
|
|
@@ -31,9 +43,9 @@ describe("Custom accounts and groups", async () => {
|
|
|
31
43
|
.withMigration((account, creationProps?: { name: string }) => {
|
|
32
44
|
// making sure that the inferred type of account.root & account.profile considers the root/profile not being loaded
|
|
33
45
|
type R = typeof account.root;
|
|
34
|
-
const _r: R = {} as Loaded<typeof Root
|
|
46
|
+
const _r: R = {} as MaybeLoaded<Loaded<typeof Root>>;
|
|
35
47
|
type P = typeof account.profile;
|
|
36
|
-
const _p: P = {} as Loaded<typeof CustomProfile
|
|
48
|
+
const _p: P = {} as MaybeLoaded<Loaded<typeof CustomProfile>>;
|
|
37
49
|
if (creationProps) {
|
|
38
50
|
const profileGroup = Group.create({ owner: account });
|
|
39
51
|
profileGroup.addMember("everyone", "reader");
|
|
@@ -65,8 +77,10 @@ describe("Custom accounts and groups", async () => {
|
|
|
65
77
|
const meAsMember = group.members.find(
|
|
66
78
|
(member) => member.id === me.$jazz.id,
|
|
67
79
|
);
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
const memberAccount = meAsMember?.account;
|
|
81
|
+
assert(memberAccount);
|
|
82
|
+
assertLoaded(memberAccount.profile);
|
|
83
|
+
expect(memberAccount.profile.name).toBe("Hermes Puggington");
|
|
70
84
|
});
|
|
71
85
|
});
|
|
72
86
|
|
|
@@ -97,7 +111,8 @@ describe("Group inheritance", () => {
|
|
|
97
111
|
const mapAsReader = await TestMap.load(mapInChild.$jazz.id, {
|
|
98
112
|
loadAs: reader,
|
|
99
113
|
});
|
|
100
|
-
|
|
114
|
+
assertLoaded(mapAsReader);
|
|
115
|
+
expect(mapAsReader.title).toBe("In Child");
|
|
101
116
|
|
|
102
117
|
await parentGroup.removeMember(reader);
|
|
103
118
|
|
|
@@ -107,7 +122,9 @@ describe("Group inheritance", () => {
|
|
|
107
122
|
const mapAsReaderAfterUpdate = await TestMap.load(mapInChild.$jazz.id, {
|
|
108
123
|
loadAs: reader,
|
|
109
124
|
});
|
|
110
|
-
expect(mapAsReaderAfterUpdate).toBe(
|
|
125
|
+
expect(mapAsReaderAfterUpdate.$jazz.loadingState).toBe(
|
|
126
|
+
CoValueLoadingState.UNAUTHORIZED,
|
|
127
|
+
);
|
|
111
128
|
});
|
|
112
129
|
});
|
|
113
130
|
|
|
@@ -138,7 +155,8 @@ describe("Group inheritance", () => {
|
|
|
138
155
|
const mapAsReader = await TestMap.load(mapInGrandChild.$jazz.id, {
|
|
139
156
|
loadAs: reader,
|
|
140
157
|
});
|
|
141
|
-
|
|
158
|
+
assertLoaded(mapAsReader);
|
|
159
|
+
expect(mapAsReader.title).toBe("In Grand Child");
|
|
142
160
|
|
|
143
161
|
await grandParentGroup.removeMember(reader);
|
|
144
162
|
|
|
@@ -152,7 +170,9 @@ describe("Group inheritance", () => {
|
|
|
152
170
|
loadAs: reader,
|
|
153
171
|
},
|
|
154
172
|
);
|
|
155
|
-
expect(mapAsReaderAfterUpdate).toBe(
|
|
173
|
+
expect(mapAsReaderAfterUpdate.$jazz.loadingState).toBe(
|
|
174
|
+
CoValueLoadingState.UNAUTHORIZED,
|
|
175
|
+
);
|
|
156
176
|
});
|
|
157
177
|
|
|
158
178
|
test("Group.getParentGroups should return the parent groups", async () => {
|
|
@@ -196,7 +216,7 @@ describe("Group inheritance", () => {
|
|
|
196
216
|
|
|
197
217
|
const loadedGroup = await serverNode.load(group.$jazz.raw.id);
|
|
198
218
|
|
|
199
|
-
expect(loadedGroup).not.toBe(
|
|
219
|
+
expect(loadedGroup).not.toBe(CoValueLoadingState.UNAVAILABLE);
|
|
200
220
|
});
|
|
201
221
|
|
|
202
222
|
test("everyone is valid only for reader, writer and writeOnly roles", () => {
|
|
@@ -275,8 +295,8 @@ describe("Group inheritance", () => {
|
|
|
275
295
|
const loadedAlice = await Account.load(alice.$jazz.id);
|
|
276
296
|
const loadedBob = await Account.load(bob.$jazz.id);
|
|
277
297
|
|
|
278
|
-
|
|
279
|
-
|
|
298
|
+
assertLoaded(loadedBob);
|
|
299
|
+
assertLoaded(loadedAlice);
|
|
280
300
|
|
|
281
301
|
const parentGroup = Group.create();
|
|
282
302
|
// `parentGroup` has `alice` as a writer
|
|
@@ -331,9 +351,10 @@ describe("Group inheritance", () => {
|
|
|
331
351
|
const task = board.columns[0]![0]!;
|
|
332
352
|
|
|
333
353
|
const boardAsWriter = await Board.load(board.$jazz.id, { loadAs: me });
|
|
334
|
-
|
|
354
|
+
assertLoaded(boardAsWriter);
|
|
355
|
+
expect(boardAsWriter.title).toEqual("My board");
|
|
335
356
|
const taskAsWriter = await Task.load(task.$jazz.id, { loadAs: me });
|
|
336
|
-
expect(taskAsWriter
|
|
357
|
+
expect(taskAsWriter.toString()).toEqual("Task 1.1");
|
|
337
358
|
});
|
|
338
359
|
|
|
339
360
|
test("nested CoValues inherit permissions from the referencing CoValue", async () => {
|
|
@@ -351,7 +372,9 @@ describe("Group inheritance", () => {
|
|
|
351
372
|
const boardAsReader = await Board.load(board.$jazz.id, {
|
|
352
373
|
loadAs: reader,
|
|
353
374
|
});
|
|
354
|
-
expect(boardAsReader).
|
|
375
|
+
expect(boardAsReader.$jazz.loadingState).toBe(
|
|
376
|
+
CoValueLoadingState.UNAUTHORIZED,
|
|
377
|
+
);
|
|
355
378
|
});
|
|
356
379
|
});
|
|
357
380
|
});
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "../testing";
|
|
15
15
|
import { cojsonInternals, LocalNode } from "cojson";
|
|
16
16
|
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
|
17
|
+
import { assertLoaded } from "./utils";
|
|
17
18
|
|
|
18
19
|
const Message = co.map({
|
|
19
20
|
text: z.string(),
|
|
@@ -163,7 +164,8 @@ describe("Inbox", () => {
|
|
|
163
164
|
const resultId = await inboxSender.sendMessage(message);
|
|
164
165
|
|
|
165
166
|
const result = await Message.load(resultId, { loadAs: receiver });
|
|
166
|
-
|
|
167
|
+
assertLoaded(result);
|
|
168
|
+
expect(result.text).toBe("Responded from the inbox");
|
|
167
169
|
|
|
168
170
|
unsubscribe();
|
|
169
171
|
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { waitFor } from "@testing-library/dom";
|
|
2
1
|
import { cojsonInternals, emptyKnownState } from "cojson";
|
|
3
2
|
import { assert, beforeEach, expect, test } from "vitest";
|
|
4
3
|
import { Account, Group, co, exportCoValue, z } from "../exports.js";
|
|
4
|
+
import { CoValueLoadingState } from "../internal.js";
|
|
5
5
|
import {
|
|
6
6
|
createJazzTestAccount,
|
|
7
7
|
disableJazzTestSync,
|
|
8
8
|
getPeerConnectedToTestSyncServer,
|
|
9
9
|
setupJazzTestSync,
|
|
10
10
|
} from "../testing.js";
|
|
11
|
+
import { assertLoaded, waitFor } from "./utils.js";
|
|
11
12
|
|
|
12
13
|
cojsonInternals.CO_VALUE_LOADING_CONFIG.RETRY_DELAY = 10;
|
|
13
14
|
|
|
@@ -30,17 +31,17 @@ test("load a value", async () => {
|
|
|
30
31
|
const alice = await createJazzTestAccount();
|
|
31
32
|
|
|
32
33
|
const john = await Person.load(map.$jazz.id, { loadAs: alice });
|
|
33
|
-
|
|
34
|
+
assertLoaded(john);
|
|
34
35
|
expect(john?.name).toBe("John");
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
test("return
|
|
38
|
+
test("return 'unavailable' if id is invalid", async () => {
|
|
38
39
|
const Person = co.map({
|
|
39
40
|
name: z.string(),
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
const john = await Person.load("test");
|
|
43
|
-
expect(john).
|
|
44
|
+
expect(john.$jazz.loadingState).toBe(CoValueLoadingState.UNAVAILABLE);
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
test("load a missing optional value (co.optional)", async () => {
|
|
@@ -64,8 +65,7 @@ test("load a missing optional value (co.optional)", async () => {
|
|
|
64
65
|
resolve: { dog: true },
|
|
65
66
|
});
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
assertLoaded(john);
|
|
69
69
|
expect(john.name).toBe("John");
|
|
70
70
|
expect(john.dog).toBeUndefined();
|
|
71
71
|
});
|
|
@@ -91,8 +91,7 @@ test("load a missing optional value (Schema.optional)", async () => {
|
|
|
91
91
|
resolve: { dog: true },
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
assertLoaded(john);
|
|
96
95
|
expect(john.name).toBe("John");
|
|
97
96
|
expect(john.dog).toBeUndefined();
|
|
98
97
|
});
|
|
@@ -124,8 +123,7 @@ test("load a missing optional value (optional discrminatedUnion)", async () => {
|
|
|
124
123
|
resolve: { pet: true },
|
|
125
124
|
});
|
|
126
125
|
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
assertLoaded(john);
|
|
129
127
|
expect(john.name).toBe("John");
|
|
130
128
|
expect(john.pet).toBeUndefined();
|
|
131
129
|
});
|
|
@@ -160,11 +158,11 @@ test("retry an unavailable value", async () => {
|
|
|
160
158
|
);
|
|
161
159
|
|
|
162
160
|
const john = await promise;
|
|
163
|
-
|
|
164
|
-
expect(john
|
|
161
|
+
assertLoaded(john);
|
|
162
|
+
expect(john.name).toBe("John");
|
|
165
163
|
});
|
|
166
164
|
|
|
167
|
-
test("returns
|
|
165
|
+
test("returns 'unavailable' if the value is unavailable after retries", async () => {
|
|
168
166
|
const Person = co.map({
|
|
169
167
|
name: z.string(),
|
|
170
168
|
});
|
|
@@ -186,7 +184,7 @@ test("returns null if the value is unavailable after retries", async () => {
|
|
|
186
184
|
|
|
187
185
|
const john = await Person.load(map.$jazz.id, { loadAs: alice });
|
|
188
186
|
|
|
189
|
-
expect(john).
|
|
187
|
+
expect(john.$jazz.loadingState).toBe(CoValueLoadingState.UNAVAILABLE);
|
|
190
188
|
});
|
|
191
189
|
|
|
192
190
|
test("load works even when the coValue access is granted after the creation", async () => {
|
|
@@ -204,8 +202,8 @@ test("load works even when the coValue access is granted after the creation", as
|
|
|
204
202
|
|
|
205
203
|
const mapOnBob = await Person.load(map.$jazz.id, { loadAs: bob });
|
|
206
204
|
|
|
207
|
-
|
|
208
|
-
expect(mapOnBob
|
|
205
|
+
assertLoaded(mapOnBob);
|
|
206
|
+
expect(mapOnBob.name).toBe("John");
|
|
209
207
|
});
|
|
210
208
|
|
|
211
209
|
test("load a large coValue", async () => {
|
|
@@ -259,8 +257,7 @@ test("load a large coValue", async () => {
|
|
|
259
257
|
},
|
|
260
258
|
});
|
|
261
259
|
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
assertLoaded(loadedDataset);
|
|
264
261
|
expect(loadedDataset.metadata.name).toBe("Large Dataset");
|
|
265
262
|
expect(loadedDataset.metadata.description).toBe(
|
|
266
263
|
"A dataset with many entries for testing large coValue loading",
|
|
@@ -329,9 +326,8 @@ test("should wait for the full streaming of the group", async () => {
|
|
|
329
326
|
|
|
330
327
|
// Load the value and expect the migration to run only once
|
|
331
328
|
const loadedPerson = await Person.load(person.$jazz.id, { loadAs: bob });
|
|
332
|
-
expect(loadedPerson).not.toBeNull();
|
|
333
|
-
assert(loadedPerson);
|
|
334
329
|
|
|
330
|
+
assertLoaded(loadedPerson);
|
|
335
331
|
expect(loadedPerson.$jazz.owner.$jazz.raw.core.verified.isStreaming()).toBe(
|
|
336
332
|
false,
|
|
337
333
|
);
|
|
@@ -399,9 +395,8 @@ test("should wait for the full streaming of the parent groups", async () => {
|
|
|
399
395
|
|
|
400
396
|
// Load the value and expect the migration to run only once
|
|
401
397
|
const loadedPerson = await Person.load(person.$jazz.id, { loadAs: bob });
|
|
402
|
-
expect(loadedPerson).not.toBeNull();
|
|
403
|
-
assert(loadedPerson);
|
|
404
398
|
|
|
399
|
+
assertLoaded(loadedPerson);
|
|
405
400
|
expect(loadedPerson.$jazz.owner.$jazz.raw.core.verified.isStreaming()).toBe(
|
|
406
401
|
false,
|
|
407
402
|
);
|
|
@@ -465,5 +460,16 @@ test("should correctly reject the load if after the group streaming the account
|
|
|
465
460
|
|
|
466
461
|
// Load the value and expect the migration to run only once
|
|
467
462
|
const loadedPerson = await Person.load(person.$jazz.id, { loadAs: bob });
|
|
468
|
-
expect(loadedPerson).
|
|
463
|
+
expect(loadedPerson.$isLoaded).toEqual(false);
|
|
464
|
+
expect(loadedPerson.$jazz.loadingState).toEqual(
|
|
465
|
+
CoValueLoadingState.UNAVAILABLE,
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
await waitFor(async () => {
|
|
469
|
+
const loadedPerson = await Person.load(person.$jazz.id, { loadAs: bob });
|
|
470
|
+
expect(loadedPerson.$isLoaded).toEqual(false);
|
|
471
|
+
expect(loadedPerson.$jazz.loadingState).toEqual(
|
|
472
|
+
CoValueLoadingState.UNAUTHORIZED,
|
|
473
|
+
);
|
|
474
|
+
});
|
|
469
475
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assert, beforeEach, describe, expect, test } from "vitest";
|
|
2
2
|
import { co, z } from "../../exports.js";
|
|
3
3
|
import { createJazzTestAccount, setupJazzTestSync } from "../../testing.js";
|
|
4
|
+
import { assertLoaded } from "../utils.js";
|
|
4
5
|
|
|
5
6
|
// Define the difficulty levels enum
|
|
6
7
|
const difficultyLevels = ["easy", "medium", "hard"] as const;
|
|
@@ -51,7 +52,7 @@ describe("QuestSchema", () => {
|
|
|
51
52
|
|
|
52
53
|
// Load the quest to trigger the migration
|
|
53
54
|
const loadedQuest = await QuestSchema.load(quest.$jazz.id);
|
|
54
|
-
|
|
55
|
+
assertLoaded(loadedQuest);
|
|
55
56
|
|
|
56
57
|
// After loading, the migration should have run and filled categories
|
|
57
58
|
expect(loadedQuest.categories).toEqual(["adventure"]);
|
|
@@ -76,7 +77,7 @@ describe("QuestSchema", () => {
|
|
|
76
77
|
|
|
77
78
|
// Load the quest to ensure migration doesn't change existing categories
|
|
78
79
|
const loadedQuest = await QuestSchema.load(quest.$jazz.id);
|
|
79
|
-
|
|
80
|
+
assertLoaded(loadedQuest);
|
|
80
81
|
|
|
81
82
|
// Categories should remain unchanged after migration
|
|
82
83
|
expect(loadedQuest.categories).toEqual(["combat", "boss-fight", "endgame"]);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { assert, describe, expect, test } from "vitest";
|
|
2
2
|
import { Account, Group, co, z } from "../../exports";
|
|
3
|
+
import { CoValueLoadingState } from "../../internal.js";
|
|
3
4
|
import {
|
|
4
5
|
createJazzTestAccount,
|
|
5
6
|
linkAccounts,
|
|
6
7
|
setupJazzTestSync,
|
|
7
8
|
} from "../../testing";
|
|
9
|
+
import { assertLoaded } from "../utils.js";
|
|
8
10
|
|
|
9
11
|
const RequestToJoin = co.map({
|
|
10
12
|
account: Account,
|
|
@@ -98,9 +100,7 @@ async function sendRequestToJoin(organizationId: string, account: Account) {
|
|
|
98
100
|
loadAs: account,
|
|
99
101
|
});
|
|
100
102
|
|
|
101
|
-
|
|
102
|
-
throw new Error("RequestsMap not found");
|
|
103
|
-
}
|
|
103
|
+
assertLoaded(organization);
|
|
104
104
|
|
|
105
105
|
const group = Group.create(account);
|
|
106
106
|
group.addMember(organization.adminsGroup);
|
|
@@ -130,9 +130,7 @@ async function approveRequest(
|
|
|
130
130
|
resolve: { statuses: true, requests: { $each: true }, mainGroup: true },
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
throw new Error("Organization not found");
|
|
135
|
-
}
|
|
133
|
+
assertLoaded(organization);
|
|
136
134
|
|
|
137
135
|
const request = organization.requests[user.$jazz.id];
|
|
138
136
|
|
|
@@ -165,9 +163,7 @@ async function rejectRequest(
|
|
|
165
163
|
resolve: { statuses: true, requests: { $each: true } },
|
|
166
164
|
});
|
|
167
165
|
|
|
168
|
-
|
|
169
|
-
throw new Error("Organization not found");
|
|
170
|
-
}
|
|
166
|
+
assertLoaded(organization);
|
|
171
167
|
|
|
172
168
|
const request = organization.requests[user.$jazz.id];
|
|
173
169
|
|
|
@@ -201,7 +197,7 @@ describe("Request to join", () => {
|
|
|
201
197
|
},
|
|
202
198
|
});
|
|
203
199
|
|
|
204
|
-
|
|
200
|
+
assertLoaded(organization);
|
|
205
201
|
|
|
206
202
|
await sendRequestToJoin(organizationId, user1);
|
|
207
203
|
|
|
@@ -213,7 +209,7 @@ describe("Request to join", () => {
|
|
|
213
209
|
loadAs: user1,
|
|
214
210
|
});
|
|
215
211
|
|
|
216
|
-
|
|
212
|
+
assertLoaded(projectsOnUser);
|
|
217
213
|
|
|
218
214
|
projectsOnUser.$jazz.push("project1");
|
|
219
215
|
|
|
@@ -232,7 +228,7 @@ describe("Request to join", () => {
|
|
|
232
228
|
},
|
|
233
229
|
});
|
|
234
230
|
|
|
235
|
-
|
|
231
|
+
assertLoaded(organization);
|
|
236
232
|
|
|
237
233
|
await sendRequestToJoin(organizationId, user1);
|
|
238
234
|
await rejectRequest(organizationId, admin1, user1);
|
|
@@ -243,7 +239,9 @@ describe("Request to join", () => {
|
|
|
243
239
|
loadAs: user1,
|
|
244
240
|
});
|
|
245
241
|
|
|
246
|
-
expect(projectsOnUser).
|
|
242
|
+
expect(projectsOnUser.$jazz.loadingState).toBe(
|
|
243
|
+
CoValueLoadingState.UNAUTHORIZED,
|
|
244
|
+
);
|
|
247
245
|
});
|
|
248
246
|
|
|
249
247
|
test("admin2 can see the status of the requests", async () => {
|
|
@@ -257,12 +255,12 @@ describe("Request to join", () => {
|
|
|
257
255
|
resolve: { requests: { $each: true }, statuses: { $each: true } },
|
|
258
256
|
});
|
|
259
257
|
|
|
260
|
-
|
|
258
|
+
assertLoaded(organization);
|
|
261
259
|
expect(organization.statuses[user1.$jazz.id]).toBe("approved");
|
|
262
260
|
const requestOnAdmin2 = await RequestToJoin.load(request.$jazz.id, {
|
|
263
261
|
loadAs: admin2,
|
|
264
262
|
});
|
|
265
|
-
|
|
263
|
+
assertLoaded(requestOnAdmin2);
|
|
266
264
|
expect(requestOnAdmin2.status).toBe("approved");
|
|
267
265
|
});
|
|
268
266
|
|
|
@@ -276,7 +274,9 @@ describe("Request to join", () => {
|
|
|
276
274
|
});
|
|
277
275
|
|
|
278
276
|
// With the writeOnly permission, the user can download the request
|
|
279
|
-
// but not
|
|
280
|
-
expect(requestOnUser2).
|
|
277
|
+
// but not its content
|
|
278
|
+
expect(requestOnUser2.$jazz.loadingState).toBe(
|
|
279
|
+
CoValueLoadingState.UNAUTHORIZED,
|
|
280
|
+
);
|
|
281
281
|
});
|
|
282
282
|
});
|
|
@@ -9,7 +9,12 @@ import {
|
|
|
9
9
|
isJazzRequestError,
|
|
10
10
|
} from "../coValues/request.js";
|
|
11
11
|
import { Account, CoPlainText, Group, co } from "../index.js";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
createUnloadedCoValue,
|
|
14
|
+
CoValueLoadingState,
|
|
15
|
+
exportCoValue,
|
|
16
|
+
importContentPieces,
|
|
17
|
+
} from "../internal.js";
|
|
13
18
|
import { createJazzTestAccount, linkAccounts } from "../testing.js";
|
|
14
19
|
|
|
15
20
|
const server = setupServer();
|
|
@@ -654,7 +659,12 @@ describe("JazzRequestError handling", () => {
|
|
|
654
659
|
|
|
655
660
|
server.use(
|
|
656
661
|
http.post("https://api.example.com/api/user", async ({ request }) => {
|
|
657
|
-
vi.spyOn(Account, "load").mockResolvedValue(
|
|
662
|
+
vi.spyOn(Account, "load").mockResolvedValue(
|
|
663
|
+
createUnloadedCoValue(
|
|
664
|
+
"some-covalue-id",
|
|
665
|
+
CoValueLoadingState.UNAVAILABLE,
|
|
666
|
+
),
|
|
667
|
+
);
|
|
658
668
|
|
|
659
669
|
return userRequest.handle(request, worker, async () => {
|
|
660
670
|
return { bio: "test" };
|