jazz-tools 0.17.13 → 0.18.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.js +1 -1
- package/.svelte-kit/__package__/media/image.svelte +3 -9
- package/.svelte-kit/__package__/media/image.svelte.d.ts +1 -6
- package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/media/image.types.d.ts +7 -0
- package/.svelte-kit/__package__/media/image.types.d.ts.map +1 -0
- package/.svelte-kit/__package__/media/image.types.js +1 -0
- package/.svelte-kit/__package__/tests/media/image.svelte.test.js +31 -31
- package/.turbo/turbo-build.log +49 -49
- package/CHANGELOG.md +42 -0
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-SFP5PBPX.js → chunk-HJ3GTGY7.js} +1325 -1001
- package/dist/chunk-HJ3GTGY7.js.map +1 -0
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/inspector/{custom-element-ZSNTCECD.js → custom-element-WCY6D3QJ.js} +3 -3
- package/dist/inspector/{custom-element-ZSNTCECD.js.map → custom-element-WCY6D3QJ.js.map} +1 -1
- package/dist/inspector/index.js +1 -1
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/media/{chunk-E5J3WLQW.js → chunk-KR2V6X2N.js} +14 -9
- package/dist/media/chunk-KR2V6X2N.js.map +1 -0
- package/dist/media/create-image.d.ts +6 -6
- package/dist/media/index.browser.d.ts +6 -6
- package/dist/media/index.browser.js +1 -1
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/index.native.d.ts +6 -6
- package/dist/media/index.native.js +1 -1
- package/dist/media/utils.d.ts.map +1 -1
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/index.js.map +1 -1
- package/dist/react/index.js +7 -5
- package/dist/react/index.js.map +1 -1
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +4658 -23
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-native-core/index.js +1 -1
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +1 -1
- package/dist/svelte/media/image.svelte +3 -9
- package/dist/svelte/media/image.svelte.d.ts +1 -6
- package/dist/svelte/media/image.svelte.d.ts.map +1 -1
- package/dist/svelte/media/image.types.d.ts +7 -0
- package/dist/svelte/media/image.types.d.ts.map +1 -0
- package/dist/svelte/media/image.types.js +1 -0
- package/dist/svelte/tests/media/image.svelte.test.js +31 -31
- package/dist/testing.js +18 -14
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/CoFieldInit.d.ts +13 -0
- package/dist/tools/coValues/CoFieldInit.d.ts.map +1 -0
- package/dist/tools/coValues/CoValueBase.d.ts +18 -15
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +100 -46
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts +78 -62
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts +212 -99
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +200 -192
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/coPlainText.d.ts +30 -22
- package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +13 -13
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
- package/dist/tools/coValues/group.d.ts +32 -32
- 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 +18 -17
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/profile.d.ts +6 -5
- package/dist/tools/coValues/profile.d.ts.map +1 -1
- package/dist/tools/coValues/schemaUnion.d.ts +3 -3
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +1 -1
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts +2 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -1
- package/dist/tools/implementation/schema.d.ts +5 -5
- package/dist/tools/implementation/schema.d.ts.map +1 -1
- package/dist/tools/implementation/symbols.d.ts +2 -0
- package/dist/tools/implementation/symbols.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +6 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +8 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +12 -7
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +13 -7
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +11 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/{CoFieldInit.d.ts → CoFieldSchemaInit.d.ts} +7 -7
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +2 -1
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/lib/migration.d.ts +1 -1
- package/dist/tools/lib/migration.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/index.d.ts +1 -1
- package/dist/tools/subscribe/index.d.ts.map +1 -1
- package/dist/tools/subscribe/utils.d.ts +2 -2
- package/dist/tools/subscribe/utils.d.ts.map +1 -1
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/utils.d.ts +2 -6
- package/dist/tools/tests/utils.d.ts.map +1 -1
- package/dist/worker/index.js +3 -3
- package/dist/worker/index.js.map +1 -1
- package/package.json +4 -4
- package/src/browser/auth/PasskeyAuth.ts +2 -2
- package/src/browser/createBrowserContext.ts +2 -2
- package/src/browser/tests/PasskeyAuth.test.ts +2 -2
- package/src/inspector/custom-element.tsx +2 -2
- package/src/inspector/viewer/new-app.tsx +1 -1
- package/src/media/create-image.test.ts +7 -7
- package/src/media/create-image.ts +5 -3
- package/src/media/index.ts +1 -1
- package/src/media/utils.test.ts +72 -66
- package/src/media/utils.ts +9 -6
- package/src/prosemirror/lib/plugin.ts +1 -1
- package/src/prosemirror/lib/sync.ts +1 -1
- package/src/prosemirror/tests/plugin.test.ts +4 -4
- package/src/react/media/image.tsx +2 -2
- package/src/react/tests/media/image.test.tsx +52 -32
- package/src/react-core/hooks.ts +11 -5
- package/src/react-core/tests/useAccount.test.ts +16 -22
- package/src/react-core/tests/useCoState.test.ts +19 -19
- package/src/react-core/tests/useInboxSender.test.ts +5 -2
- package/src/react-core/tests/usePassPhraseAuth.test.ts +6 -6
- package/src/react-native-core/media/image.tsx +1 -1
- package/src/svelte/jazz.class.svelte.ts +1 -1
- package/src/svelte/media/image.svelte +3 -9
- package/src/svelte/media/image.types.ts +7 -0
- package/src/svelte/tests/media/image.svelte.test.ts +34 -32
- package/src/tools/auth/DemoAuth.ts +2 -2
- package/src/tools/auth/PassphraseAuth.ts +2 -2
- package/src/tools/auth/clerk/index.ts +2 -2
- package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +1 -1
- package/src/tools/coValues/CoFieldInit.ts +20 -0
- package/src/tools/coValues/CoValueBase.ts +40 -60
- package/src/tools/coValues/account.ts +306 -232
- package/src/tools/coValues/coFeed.ts +185 -153
- package/src/tools/coValues/coList.ts +507 -334
- package/src/tools/coValues/coMap.ts +420 -286
- package/src/tools/coValues/coPlainText.ts +94 -110
- package/src/tools/coValues/deepLoading.ts +13 -13
- package/src/tools/coValues/group.ts +100 -114
- package/src/tools/coValues/inbox.ts +16 -14
- package/src/tools/coValues/interfaces.ts +49 -31
- package/src/tools/coValues/profile.ts +8 -6
- package/src/tools/coValues/request.ts +9 -9
- package/src/tools/coValues/schemaUnion.ts +11 -5
- package/src/tools/exports.ts +1 -1
- package/src/tools/implementation/ContextManager.ts +4 -4
- package/src/tools/implementation/anonymousJazzAgent.ts +2 -1
- package/src/tools/implementation/createContext.ts +1 -1
- package/src/tools/implementation/devtoolsFormatters.ts +9 -9
- package/src/tools/implementation/invites.ts +2 -2
- package/src/tools/implementation/schema.ts +7 -7
- package/src/tools/implementation/symbols.ts +3 -0
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +11 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +18 -7
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +17 -7
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +20 -11
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +19 -2
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +6 -0
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +6 -0
- package/src/tools/implementation/zodSchema/typeConverters/{CoFieldInit.ts → CoFieldSchemaInit.ts} +11 -11
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +4 -4
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +4 -4
- package/src/tools/implementation/zodSchema/zodCo.ts +47 -10
- package/src/tools/internal.ts +2 -1
- package/src/tools/lib/migration.ts +5 -5
- package/src/tools/subscribe/SubscriptionScope.ts +32 -24
- package/src/tools/subscribe/index.ts +4 -4
- package/src/tools/subscribe/utils.ts +11 -11
- package/src/tools/testing.ts +17 -13
- package/src/tools/tests/ContextManager.test.ts +68 -57
- package/src/tools/tests/PassphraseAuth.test.ts +2 -2
- package/src/tools/tests/account.test.ts +154 -74
- package/src/tools/tests/coDiscriminatedUnion.test-d.ts +12 -6
- package/src/tools/tests/coDiscriminatedUnion.test.ts +26 -17
- package/src/tools/tests/coFeed.test-d.ts +18 -17
- package/src/tools/tests/coFeed.test.ts +108 -97
- package/src/tools/tests/coList.test-d.ts +18 -23
- package/src/tools/tests/coList.test.ts +350 -165
- package/src/tools/tests/coMap.record.test-d.ts +9 -13
- package/src/tools/tests/coMap.record.test.ts +37 -23
- package/src/tools/tests/coMap.test-d.ts +43 -21
- package/src/tools/tests/coMap.test.ts +368 -182
- package/src/tools/tests/coOptional.test.ts +28 -13
- package/src/tools/tests/coPlainText.test.ts +15 -15
- package/src/tools/tests/createContext.test.ts +14 -14
- package/src/tools/tests/deepLoading.test.ts +95 -94
- package/src/tools/tests/exportImport.test.ts +61 -41
- package/src/tools/tests/groupsAndAccounts.test.ts +333 -116
- package/src/tools/tests/inbox.test.ts +22 -17
- package/src/tools/tests/interfaces.test.ts +12 -11
- package/src/tools/tests/invites.test.ts +6 -4
- package/src/tools/tests/load.test.ts +20 -18
- package/src/tools/tests/patterns/notifications.test.ts +6 -6
- package/src/tools/tests/patterns/quest.test.ts +3 -3
- package/src/tools/tests/patterns/requestToJoin.test.ts +22 -22
- package/src/tools/tests/request.test.ts +38 -39
- package/src/tools/tests/schemaUnion.test.ts +64 -10
- package/src/tools/tests/subscribe.test.ts +64 -64
- package/src/tools/tests/testing.test.ts +5 -9
- package/src/tools/tests/utils.ts +3 -3
- package/src/tools/tests/zod.test.ts +3 -3
- package/src/worker/index.ts +3 -3
- package/dist/chunk-SFP5PBPX.js.map +0 -1
- package/dist/media/chunk-E5J3WLQW.js.map +0 -1
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts.map +0 -1
@@ -70,7 +70,7 @@ describe("subscribeToCoValue", () => {
|
|
70
70
|
|
71
71
|
const unsubscribe = subscribeToCoValue(
|
72
72
|
coValueClassFromCoValueClassOrSchema(ChatRoom),
|
73
|
-
chatRoom.id,
|
73
|
+
chatRoom.$jazz.id,
|
74
74
|
{ loadAs: meOnSecondPeer },
|
75
75
|
(value) => {
|
76
76
|
result = value;
|
@@ -85,7 +85,7 @@ describe("subscribeToCoValue", () => {
|
|
85
85
|
});
|
86
86
|
|
87
87
|
expect(result).not.toBeNull();
|
88
|
-
expect(result
|
88
|
+
expect(result?.$jazz.id).toBe(chatRoom.$jazz.id);
|
89
89
|
expect(result?.messages).toEqual(null);
|
90
90
|
expect(result?.name).toBe("General");
|
91
91
|
|
@@ -98,7 +98,7 @@ describe("subscribeToCoValue", () => {
|
|
98
98
|
expect(result?.messages).toEqual([]);
|
99
99
|
|
100
100
|
updateFn.mockClear();
|
101
|
-
chatRoom.name
|
101
|
+
chatRoom.$jazz.set("name", "Lounge");
|
102
102
|
|
103
103
|
await waitFor(() => {
|
104
104
|
expect(updateFn).toHaveBeenCalled();
|
@@ -117,7 +117,7 @@ describe("subscribeToCoValue", () => {
|
|
117
117
|
|
118
118
|
const unsubscribe = subscribeToCoValue(
|
119
119
|
coValueClassFromCoValueClassOrSchema(ChatRoom),
|
120
|
-
chatRoom.id,
|
120
|
+
chatRoom.$jazz.id,
|
121
121
|
{
|
122
122
|
loadAs: meOnSecondPeer,
|
123
123
|
resolve: {
|
@@ -138,7 +138,7 @@ describe("subscribeToCoValue", () => {
|
|
138
138
|
|
139
139
|
expect(updateFn).toHaveBeenCalledTimes(1);
|
140
140
|
expect(result).toMatchObject({
|
141
|
-
id: chatRoom.id,
|
141
|
+
$jazz: expect.objectContaining({ id: chatRoom.$jazz.id }),
|
142
142
|
name: "General",
|
143
143
|
messages: [],
|
144
144
|
});
|
@@ -150,15 +150,15 @@ describe("subscribeToCoValue", () => {
|
|
150
150
|
const chatRoom = createChatRoom(me, "General");
|
151
151
|
const updateFn = vi.fn();
|
152
152
|
|
153
|
-
const { messages } = await chatRoom.ensureLoaded({
|
153
|
+
const { messages } = await chatRoom.$jazz.ensureLoaded({
|
154
154
|
resolve: { messages: { $each: true } },
|
155
155
|
});
|
156
156
|
|
157
|
-
messages.push(createMessage(me, "Hello"));
|
157
|
+
messages.$jazz.push(createMessage(me, "Hello"));
|
158
158
|
|
159
159
|
const unsubscribe = subscribeToCoValue(
|
160
160
|
coValueClassFromCoValueClassOrSchema(ChatRoom),
|
161
|
-
chatRoom.id,
|
161
|
+
chatRoom.$jazz.id,
|
162
162
|
{
|
163
163
|
loadAs: meOnSecondPeer,
|
164
164
|
resolve: {
|
@@ -173,15 +173,15 @@ describe("subscribeToCoValue", () => {
|
|
173
173
|
});
|
174
174
|
|
175
175
|
unsubscribe();
|
176
|
-
chatRoom.name
|
177
|
-
messages.push(createMessage(me, "Hello 2"));
|
176
|
+
chatRoom.$jazz.set("name", "Lounge");
|
177
|
+
messages.$jazz.push(createMessage(me, "Hello 2"));
|
178
178
|
|
179
179
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
180
180
|
|
181
181
|
expect(updateFn).toHaveBeenCalledTimes(1);
|
182
182
|
expect(updateFn).toHaveBeenCalledWith(
|
183
183
|
expect.objectContaining({
|
184
|
-
id: chatRoom.id,
|
184
|
+
$jazz: expect.objectContaining({ id: chatRoom.$jazz.id }),
|
185
185
|
}),
|
186
186
|
expect.any(Function),
|
187
187
|
);
|
@@ -195,13 +195,13 @@ describe("subscribeToCoValue", () => {
|
|
195
195
|
me,
|
196
196
|
"Hello Luigi, are you ready to save the princess?",
|
197
197
|
);
|
198
|
-
chatRoom.messages
|
198
|
+
chatRoom.messages?.$jazz.push(message);
|
199
199
|
|
200
200
|
const updateFn = vi.fn();
|
201
201
|
|
202
202
|
const unsubscribe = subscribeToCoValue(
|
203
203
|
coValueClassFromCoValueClassOrSchema(ChatRoom),
|
204
|
-
chatRoom.id,
|
204
|
+
chatRoom.$jazz.id,
|
205
205
|
{
|
206
206
|
loadAs: meOnSecondPeer,
|
207
207
|
resolve: {
|
@@ -221,7 +221,7 @@ describe("subscribeToCoValue", () => {
|
|
221
221
|
expect(lastValue?.messages?.[0]?.text).toBe(message.text);
|
222
222
|
});
|
223
223
|
|
224
|
-
message.text
|
224
|
+
message.$jazz.set("text", "Nevermind, she was gone to the supermarket");
|
225
225
|
updateFn.mockClear();
|
226
226
|
|
227
227
|
await waitFor(() => {
|
@@ -243,8 +243,8 @@ describe("subscribeToCoValue", () => {
|
|
243
243
|
"Hello Luigi, are you ready to save the princess?",
|
244
244
|
);
|
245
245
|
const message2 = createMessage(me, "Let's go!");
|
246
|
-
chatRoom.messages
|
247
|
-
chatRoom.messages
|
246
|
+
chatRoom.messages?.$jazz.push(message);
|
247
|
+
chatRoom.messages?.$jazz.push(message2);
|
248
248
|
|
249
249
|
const updateFn = vi.fn();
|
250
250
|
|
@@ -261,7 +261,7 @@ describe("subscribeToCoValue", () => {
|
|
261
261
|
|
262
262
|
const unsubscribe = subscribeToCoValue(
|
263
263
|
coValueClassFromCoValueClassOrSchema(ChatRoom),
|
264
|
-
chatRoom.id,
|
264
|
+
chatRoom.$jazz.id,
|
265
265
|
{
|
266
266
|
loadAs: meOnSecondPeer,
|
267
267
|
resolve: {
|
@@ -292,7 +292,7 @@ describe("subscribeToCoValue", () => {
|
|
292
292
|
const initialMessage2 = initialValue?.messages[1];
|
293
293
|
const initialMessageReactions = initialValue?.messages[0]?.reactions;
|
294
294
|
|
295
|
-
message.reactions
|
295
|
+
message.reactions?.$jazz.push("👍");
|
296
296
|
|
297
297
|
updateFn.mockClear();
|
298
298
|
|
@@ -325,14 +325,14 @@ describe("subscribeToCoValue", () => {
|
|
325
325
|
"Hello Luigi, are you ready to save the princess?",
|
326
326
|
);
|
327
327
|
const message2 = createMessage(me, "Let's go!");
|
328
|
-
chatRoom.messages
|
329
|
-
chatRoom.messages
|
328
|
+
chatRoom.messages?.$jazz.push(message);
|
329
|
+
chatRoom.messages?.$jazz.push(message2);
|
330
330
|
|
331
331
|
const updateFn = vi.fn();
|
332
332
|
|
333
333
|
const unsubscribe = subscribeToCoValue(
|
334
334
|
coValueClassFromCoValueClassOrSchema(ChatRoom),
|
335
|
-
chatRoom.id,
|
335
|
+
chatRoom.$jazz.id,
|
336
336
|
{
|
337
337
|
loadAs: meOnSecondPeer,
|
338
338
|
resolve: {
|
@@ -356,7 +356,7 @@ describe("subscribeToCoValue", () => {
|
|
356
356
|
});
|
357
357
|
|
358
358
|
const initialValue = updateFn.mock.lastCall?.[0];
|
359
|
-
chatRoom.name
|
359
|
+
chatRoom.$jazz.set("name", "Me and Luigi");
|
360
360
|
|
361
361
|
updateFn.mockClear();
|
362
362
|
|
@@ -396,7 +396,7 @@ describe("subscribeToCoValue", () => {
|
|
396
396
|
|
397
397
|
const unsubscribe = subscribeToCoValue(
|
398
398
|
coValueClassFromCoValueClassOrSchema(TestList),
|
399
|
-
list.id,
|
399
|
+
list.$jazz.id,
|
400
400
|
{
|
401
401
|
loadAs: account,
|
402
402
|
resolve: {
|
@@ -457,7 +457,7 @@ describe("subscribeToCoValue", () => {
|
|
457
457
|
|
458
458
|
const unsubscribe = subscribeToCoValue(
|
459
459
|
coValueClassFromCoValueClassOrSchema(TestList),
|
460
|
-
list.id,
|
460
|
+
list.$jazz.id,
|
461
461
|
{
|
462
462
|
loadAs: reader,
|
463
463
|
resolve: {
|
@@ -503,8 +503,8 @@ describe("subscribeToCoValue", () => {
|
|
503
503
|
});
|
504
504
|
|
505
505
|
// Disconnect the creator from the sync server
|
506
|
-
creator.
|
507
|
-
.getServerPeers(creator.
|
506
|
+
creator.$jazz.localNode.syncManager
|
507
|
+
.getServerPeers(creator.$jazz.raw.id)
|
508
508
|
.forEach((peer) => {
|
509
509
|
peer.gracefulShutdown();
|
510
510
|
});
|
@@ -530,7 +530,7 @@ describe("subscribeToCoValue", () => {
|
|
530
530
|
|
531
531
|
const unsubscribe = subscribeToCoValue(
|
532
532
|
coValueClassFromCoValueClassOrSchema(TestList),
|
533
|
-
list.id,
|
533
|
+
list.$jazz.id,
|
534
534
|
{
|
535
535
|
loadAs: reader,
|
536
536
|
resolve: {
|
@@ -548,7 +548,7 @@ describe("subscribeToCoValue", () => {
|
|
548
548
|
expect(onUnavailable).toHaveBeenCalled();
|
549
549
|
});
|
550
550
|
|
551
|
-
creator.
|
551
|
+
creator.$jazz.localNode.syncManager.addPeer(
|
552
552
|
getPeerConnectedToTestSyncServer(),
|
553
553
|
);
|
554
554
|
|
@@ -605,7 +605,7 @@ describe("subscribeToCoValue", () => {
|
|
605
605
|
|
606
606
|
const unsubscribe = subscribeToCoValue(
|
607
607
|
coValueClassFromCoValueClassOrSchema(TestList),
|
608
|
-
list.id,
|
608
|
+
list.$jazz.id,
|
609
609
|
{
|
610
610
|
loadAs: reader,
|
611
611
|
resolve: {
|
@@ -623,7 +623,7 @@ describe("subscribeToCoValue", () => {
|
|
623
623
|
expect(onUnavailable).toHaveBeenCalled();
|
624
624
|
});
|
625
625
|
|
626
|
-
list
|
626
|
+
list.$jazz.set(0, TestMap.create({ value: "1" }, everyone));
|
627
627
|
|
628
628
|
await waitFor(() => {
|
629
629
|
expect(updateFn).toHaveBeenCalled();
|
@@ -675,7 +675,7 @@ describe("subscribeToCoValue", () => {
|
|
675
675
|
|
676
676
|
const unsubscribe = subscribeToCoValue(
|
677
677
|
coValueClassFromCoValueClassOrSchema(TestList),
|
678
|
-
list.id,
|
678
|
+
list.$jazz.id,
|
679
679
|
{
|
680
680
|
loadAs: reader,
|
681
681
|
resolve: {
|
@@ -727,7 +727,7 @@ describe("subscribeToCoValue", () => {
|
|
727
727
|
|
728
728
|
const unsubscribe = subscribeToCoValue(
|
729
729
|
coValueClassFromCoValueClassOrSchema(TestList),
|
730
|
-
list.id,
|
730
|
+
list.$jazz.id,
|
731
731
|
{
|
732
732
|
loadAs: creator,
|
733
733
|
resolve: {
|
@@ -751,7 +751,7 @@ describe("subscribeToCoValue", () => {
|
|
751
751
|
|
752
752
|
updateFn.mockClear();
|
753
753
|
|
754
|
-
list
|
754
|
+
list.$jazz.set(0, undefined);
|
755
755
|
|
756
756
|
await waitFor(() => {
|
757
757
|
expect(updateFn).toHaveBeenCalled();
|
@@ -762,7 +762,7 @@ describe("subscribeToCoValue", () => {
|
|
762
762
|
|
763
763
|
updateFn.mockClear();
|
764
764
|
|
765
|
-
firstItem.value
|
765
|
+
firstItem.$jazz.set("value", "3");
|
766
766
|
|
767
767
|
expect(updateFn).not.toHaveBeenCalled();
|
768
768
|
});
|
@@ -794,7 +794,7 @@ describe("subscribeToCoValue", () => {
|
|
794
794
|
|
795
795
|
const unsubscribe = subscribeToCoValue(
|
796
796
|
coValueClassFromCoValueClassOrSchema(TestList),
|
797
|
-
list.id,
|
797
|
+
list.$jazz.id,
|
798
798
|
{
|
799
799
|
loadAs: creator,
|
800
800
|
resolve: {
|
@@ -819,7 +819,7 @@ describe("subscribeToCoValue", () => {
|
|
819
819
|
|
820
820
|
// Replace the first item with a new map
|
821
821
|
const newMap = TestMap.create({ value: "3" }, creator);
|
822
|
-
list
|
822
|
+
list.$jazz.set(0, newMap);
|
823
823
|
|
824
824
|
await waitFor(() => {
|
825
825
|
expect(updateFn).toHaveBeenCalled();
|
@@ -831,11 +831,11 @@ describe("subscribeToCoValue", () => {
|
|
831
831
|
|
832
832
|
updateFn.mockClear();
|
833
833
|
|
834
|
-
firstItem.value
|
834
|
+
firstItem.$jazz.set("value", "4");
|
835
835
|
|
836
836
|
expect(updateFn).not.toHaveBeenCalled();
|
837
837
|
|
838
|
-
newMap.value
|
838
|
+
newMap.$jazz.set("value", "5");
|
839
839
|
|
840
840
|
expect(updateFn).toHaveBeenCalled();
|
841
841
|
expect(result[0]?.value).toBe("5");
|
@@ -854,9 +854,9 @@ describe("subscribeToCoValue", () => {
|
|
854
854
|
const reader = await createJazzTestAccount();
|
855
855
|
|
856
856
|
await Promise.all([
|
857
|
-
writer1.waitForAllCoValuesSync(),
|
858
|
-
writer2.waitForAllCoValuesSync(),
|
859
|
-
reader.waitForAllCoValuesSync(),
|
857
|
+
writer1.$jazz.waitForAllCoValuesSync(),
|
858
|
+
writer2.$jazz.waitForAllCoValuesSync(),
|
859
|
+
reader.$jazz.waitForAllCoValuesSync(),
|
860
860
|
]);
|
861
861
|
|
862
862
|
const group = Group.create(creator);
|
@@ -866,11 +866,11 @@ describe("subscribeToCoValue", () => {
|
|
866
866
|
|
867
867
|
const person = Person.create({ name: "creator" }, group);
|
868
868
|
|
869
|
-
await person.waitForSync();
|
869
|
+
await person.$jazz.waitForSync();
|
870
870
|
|
871
871
|
// Disconnect from the sync server, so we can change permissions but not sync them
|
872
|
-
creator.
|
873
|
-
.getServerPeers(creator.
|
872
|
+
creator.$jazz.localNode.syncManager
|
873
|
+
.getServerPeers(creator.$jazz.raw.id)
|
874
874
|
.forEach((peer) => {
|
875
875
|
peer.gracefulShutdown();
|
876
876
|
});
|
@@ -885,7 +885,7 @@ describe("subscribeToCoValue", () => {
|
|
885
885
|
|
886
886
|
const unsubscribe = subscribeToCoValue(
|
887
887
|
coValueClassFromCoValueClassOrSchema(Person),
|
888
|
-
person.id,
|
888
|
+
person.$jazz.id,
|
889
889
|
{
|
890
890
|
loadAs: reader,
|
891
891
|
},
|
@@ -898,11 +898,11 @@ describe("subscribeToCoValue", () => {
|
|
898
898
|
expect(spy).toHaveBeenCalledTimes(1);
|
899
899
|
expect(value?.name).toBe("creator");
|
900
900
|
|
901
|
-
const personOnWriter1 = await Person.load(person.id, {
|
901
|
+
const personOnWriter1 = await Person.load(person.$jazz.id, {
|
902
902
|
loadAs: writer1,
|
903
903
|
});
|
904
904
|
|
905
|
-
const personOnWriter2 = await Person.load(person.id, {
|
905
|
+
const personOnWriter2 = await Person.load(person.$jazz.id, {
|
906
906
|
loadAs: writer2,
|
907
907
|
});
|
908
908
|
|
@@ -910,25 +910,25 @@ describe("subscribeToCoValue", () => {
|
|
910
910
|
|
911
911
|
assert(personOnWriter1);
|
912
912
|
assert(personOnWriter2);
|
913
|
-
personOnWriter1.name
|
914
|
-
personOnWriter2.name
|
913
|
+
personOnWriter1.$jazz.set("name", "writer1");
|
914
|
+
personOnWriter2.$jazz.set("name", "writer2");
|
915
915
|
|
916
916
|
await waitFor(() => expect(spy).toHaveBeenCalled());
|
917
917
|
expect(spy).toHaveBeenCalledTimes(1);
|
918
918
|
expect(value?.name).toBe("writer1");
|
919
|
-
expect(value
|
919
|
+
expect(value?.$jazz.raw.totalValidTransactions).toBe(2);
|
920
920
|
|
921
921
|
spy.mockClear();
|
922
922
|
|
923
923
|
// Reconnect to the sync server
|
924
|
-
creator.
|
924
|
+
creator.$jazz.localNode.syncManager.addPeer(
|
925
925
|
getPeerConnectedToTestSyncServer(),
|
926
926
|
);
|
927
927
|
|
928
928
|
await waitFor(() => expect(spy).toHaveBeenCalled());
|
929
929
|
expect(spy).toHaveBeenCalledTimes(1);
|
930
930
|
expect(value?.name).toBe("writer2");
|
931
|
-
expect(value
|
931
|
+
expect(value?.$jazz.raw.totalValidTransactions).toBe(2);
|
932
932
|
});
|
933
933
|
|
934
934
|
it("errors on autoloaded values shouldn't block updates", async () => {
|
@@ -972,7 +972,7 @@ describe("subscribeToCoValue", () => {
|
|
972
972
|
|
973
973
|
const unsubscribe = subscribeToCoValue(
|
974
974
|
coValueClassFromCoValueClassOrSchema(TestList),
|
975
|
-
list.id,
|
975
|
+
list.$jazz.id,
|
976
976
|
{
|
977
977
|
loadAs: reader,
|
978
978
|
resolve: true,
|
@@ -998,7 +998,7 @@ describe("subscribeToCoValue", () => {
|
|
998
998
|
|
999
999
|
updateFn.mockClear();
|
1000
1000
|
|
1001
|
-
list
|
1001
|
+
list.$jazz.set(1, TestMap.create({ value: "updated" }, everyone));
|
1002
1002
|
|
1003
1003
|
await waitFor(() => {
|
1004
1004
|
expect(result?.[1]?.value).toBe("updated");
|
@@ -1059,7 +1059,7 @@ describe("subscribeToCoValue", () => {
|
|
1059
1059
|
|
1060
1060
|
const unsubscribe = subscribeToCoValue(
|
1061
1061
|
coValueClassFromCoValueClassOrSchema(PersonList),
|
1062
|
-
list.id,
|
1062
|
+
list.$jazz.id,
|
1063
1063
|
{
|
1064
1064
|
loadAs: reader,
|
1065
1065
|
resolve: {
|
@@ -1088,13 +1088,13 @@ describe("subscribeToCoValue", () => {
|
|
1088
1088
|
expect(result?.[2]?.dog?.name).toBe("Bella");
|
1089
1089
|
});
|
1090
1090
|
|
1091
|
-
list[0]
|
1091
|
+
list[0]!.$jazz.set("dog", Dog.create({ name: "Ninja" }));
|
1092
1092
|
|
1093
1093
|
await waitFor(() => {
|
1094
1094
|
expect(result?.[0]?.dog).toBe(null);
|
1095
1095
|
});
|
1096
1096
|
|
1097
|
-
list[1]
|
1097
|
+
list[1]!.$jazz.set("dog", Dog.create({ name: "Pinkie" }, everyone));
|
1098
1098
|
|
1099
1099
|
await waitFor(() => {
|
1100
1100
|
expect(result?.[1]?.dog?.name).toBe("Pinkie");
|
@@ -1155,7 +1155,7 @@ describe("subscribeToCoValue", () => {
|
|
1155
1155
|
|
1156
1156
|
const unsubscribe = subscribeToCoValue(
|
1157
1157
|
coValueClassFromCoValueClassOrSchema(PersonList),
|
1158
|
-
list.id,
|
1158
|
+
list.$jazz.id,
|
1159
1159
|
{
|
1160
1160
|
loadAs: reader,
|
1161
1161
|
resolve: {
|
@@ -1223,11 +1223,11 @@ describe("subscribeToCoValue", () => {
|
|
1223
1223
|
const value = "x".repeat(chunkSize);
|
1224
1224
|
|
1225
1225
|
for (let i = 0; i < chunks; i++) {
|
1226
|
-
largeMap.data.push(value);
|
1226
|
+
largeMap.data.$jazz.push(value);
|
1227
1227
|
}
|
1228
1228
|
|
1229
1229
|
// Wait for the large coValue to be fully synced
|
1230
|
-
await largeMap.data.
|
1230
|
+
await largeMap.data.$jazz.raw.core.waitForSync();
|
1231
1231
|
|
1232
1232
|
const alice = await createJazzTestAccount();
|
1233
1233
|
|
@@ -1239,7 +1239,7 @@ describe("subscribeToCoValue", () => {
|
|
1239
1239
|
// Test subscribing to the large coValue
|
1240
1240
|
const unsubscribe = subscribeToCoValue(
|
1241
1241
|
coValueClassFromCoValueClassOrSchema(LargeDataset),
|
1242
|
-
largeMap.id,
|
1242
|
+
largeMap.$jazz.id,
|
1243
1243
|
{
|
1244
1244
|
loadAs: alice,
|
1245
1245
|
resolve: {
|
@@ -1264,13 +1264,13 @@ describe("subscribeToCoValue", () => {
|
|
1264
1264
|
);
|
1265
1265
|
|
1266
1266
|
expect(result.data.length).toBe(chunks);
|
1267
|
-
expect(result.data.
|
1268
|
-
largeMap.data.
|
1267
|
+
expect(result.data.$jazz.raw.core.knownState()).toEqual(
|
1268
|
+
largeMap.data.$jazz.raw.core.knownState(),
|
1269
1269
|
);
|
1270
1270
|
|
1271
1271
|
// Test that updates to the large coValue are properly subscribed
|
1272
1272
|
updateFn.mockClear();
|
1273
|
-
largeMap.data.push("new entry");
|
1273
|
+
largeMap.data.$jazz.push("new entry");
|
1274
1274
|
|
1275
1275
|
await waitFor(() => {
|
1276
1276
|
expect(updateFn).toHaveBeenCalled();
|
@@ -16,12 +16,12 @@ describe("Jazz Test Sync", () => {
|
|
16
16
|
group.addMember("everyone", "reader");
|
17
17
|
|
18
18
|
const map = CoMap.create({}, group);
|
19
|
-
map.
|
19
|
+
map.$jazz.raw.set("test", "value");
|
20
20
|
|
21
21
|
// Verify account2 can see the group
|
22
|
-
const loadedMap = await CoMap.load(map.id, { loadAs: account2 });
|
22
|
+
const loadedMap = await CoMap.load(map.$jazz.id, { loadAs: account2 });
|
23
23
|
expect(loadedMap).toBeDefined();
|
24
|
-
expect(loadedMap
|
24
|
+
expect(loadedMap?.$jazz.raw.get("test")).toBe("value");
|
25
25
|
});
|
26
26
|
|
27
27
|
test("correctly set the globalMe before starting the migration", async () => {
|
@@ -36,9 +36,7 @@ describe("Jazz Test Sync", () => {
|
|
36
36
|
})
|
37
37
|
.withMigration((account) => {
|
38
38
|
if (account.root === undefined) {
|
39
|
-
account.root
|
40
|
-
value: "ok",
|
41
|
-
});
|
39
|
+
account.$jazz.set("root", { value: "ok" });
|
42
40
|
}
|
43
41
|
});
|
44
42
|
|
@@ -62,9 +60,7 @@ describe("Jazz Test Sync", () => {
|
|
62
60
|
})
|
63
61
|
.withMigration((account) => {
|
64
62
|
if (account.root === undefined) {
|
65
|
-
account.root
|
66
|
-
value: "ok",
|
67
|
-
});
|
63
|
+
account.$jazz.set("root", { value: "ok" });
|
68
64
|
}
|
69
65
|
});
|
70
66
|
|
package/src/tools/tests/utils.ts
CHANGED
@@ -30,12 +30,12 @@ export async function setupAccount() {
|
|
30
30
|
if (!isControlledAccount(me)) {
|
31
31
|
throw "me is not a controlled account";
|
32
32
|
}
|
33
|
-
me.
|
33
|
+
me.$jazz.localNode.syncManager.addPeer(secondPeer);
|
34
34
|
const { account: meOnSecondPeer } =
|
35
35
|
await createJazzContextFromExistingCredentials({
|
36
36
|
credentials: {
|
37
|
-
accountID: me.id,
|
38
|
-
secret: me.
|
37
|
+
accountID: me.$jazz.id,
|
38
|
+
secret: me.$jazz.localNode.getCurrentAgent().agentSecret,
|
39
39
|
},
|
40
40
|
sessionProvider: randomSessionProvider,
|
41
41
|
peersToLoadFrom: [initialAsPeer],
|
@@ -79,7 +79,7 @@ describe("co.map and Zod schema compatibility", () => {
|
|
79
79
|
});
|
80
80
|
expect(map.updatedAt).toBeNull();
|
81
81
|
|
82
|
-
map.updatedAt
|
82
|
+
map.$jazz.set("updatedAt", "Test");
|
83
83
|
expect(map.updatedAt).toEqual("Test");
|
84
84
|
});
|
85
85
|
|
@@ -91,10 +91,10 @@ describe("co.map and Zod schema compatibility", () => {
|
|
91
91
|
const map = schema.create({});
|
92
92
|
expect(map.updatedAt).toBeUndefined();
|
93
93
|
|
94
|
-
map.updatedAt
|
94
|
+
map.$jazz.set("updatedAt", null);
|
95
95
|
expect(map.updatedAt).toBeNull();
|
96
96
|
|
97
|
-
map.updatedAt
|
97
|
+
map.$jazz.set("updatedAt", "Test");
|
98
98
|
expect(map.updatedAt).toEqual("Test");
|
99
99
|
});
|
100
100
|
|
package/src/worker/index.ts
CHANGED
@@ -87,16 +87,16 @@ export async function startWorker<
|
|
87
87
|
});
|
88
88
|
|
89
89
|
const account = context.account as InstanceOfSchema<S>;
|
90
|
-
node = account.
|
90
|
+
node = account.$jazz.localNode;
|
91
91
|
|
92
|
-
if (!account.
|
92
|
+
if (!account.$jazz.refs.profile?.id) {
|
93
93
|
throw new Error("Account has no profile");
|
94
94
|
}
|
95
95
|
|
96
96
|
const inbox = await Inbox.load(account);
|
97
97
|
|
98
98
|
async function done() {
|
99
|
-
await context.account.waitForAllCoValuesSync();
|
99
|
+
await context.account.$jazz.waitForAllCoValuesSync();
|
100
100
|
|
101
101
|
wsPeer.disable();
|
102
102
|
context.done();
|