jazz-tools 0.13.31 → 0.14.1
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +22 -3
- package/dist/auth/DemoAuth.d.ts.map +1 -1
- package/dist/auth/PassphraseAuth.d.ts +1 -3
- package/dist/auth/PassphraseAuth.d.ts.map +1 -1
- package/dist/{chunk-IJU4XPFS.js → chunk-WLOZKDOH.js} +3536 -3291
- package/dist/chunk-WLOZKDOH.js.map +1 -0
- package/dist/coValues/CoValueBase.d.ts +22 -0
- package/dist/coValues/CoValueBase.d.ts.map +1 -0
- package/dist/coValues/account.d.ts +12 -12
- package/dist/coValues/account.d.ts.map +1 -1
- package/dist/coValues/coFeed.d.ts +24 -25
- package/dist/coValues/coFeed.d.ts.map +1 -1
- package/dist/coValues/coList.d.ts +10 -13
- package/dist/coValues/coList.d.ts.map +1 -1
- package/dist/coValues/coMap.d.ts +32 -35
- package/dist/coValues/coMap.d.ts.map +1 -1
- package/dist/coValues/coPlainText.d.ts.map +1 -1
- package/dist/coValues/deepLoading.d.ts +17 -21
- package/dist/coValues/deepLoading.d.ts.map +1 -1
- package/dist/coValues/extensions/imageDef.d.ts +12 -11
- package/dist/coValues/extensions/imageDef.d.ts.map +1 -1
- package/dist/coValues/group.d.ts +5 -9
- package/dist/coValues/group.d.ts.map +1 -1
- package/dist/coValues/inbox.d.ts +2 -3
- package/dist/coValues/inbox.d.ts.map +1 -1
- package/dist/coValues/interfaces.d.ts +8 -34
- package/dist/coValues/interfaces.d.ts.map +1 -1
- package/dist/coValues/profile.d.ts +4 -14
- package/dist/coValues/profile.d.ts.map +1 -1
- package/dist/coValues/registeredSchemas.d.ts +1 -3
- package/dist/coValues/registeredSchemas.d.ts.map +1 -1
- package/dist/coValues/schemaUnion.d.ts +6 -6
- package/dist/exports.d.ts +12 -16
- package/dist/exports.d.ts.map +1 -1
- package/dist/implementation/ContextManager.d.ts +1 -1
- package/dist/implementation/ContextManager.d.ts.map +1 -1
- package/dist/implementation/activeAccountContext.d.ts +1 -1
- package/dist/implementation/activeAccountContext.d.ts.map +1 -1
- package/dist/implementation/createContext.d.ts +10 -10
- package/dist/implementation/createContext.d.ts.map +1 -1
- package/dist/implementation/invites.d.ts +6 -6
- package/dist/implementation/invites.d.ts.map +1 -1
- package/dist/implementation/refs.d.ts +2 -2
- package/dist/implementation/refs.d.ts.map +1 -1
- package/dist/implementation/schema.d.ts +21 -28
- package/dist/implementation/schema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts +9 -0
- package/dist/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts.map +1 -0
- package/dist/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts +28 -0
- package/dist/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +65 -0
- package/dist/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +28 -0
- package/dist/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +24 -0
- package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +41 -0
- package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +35 -0
- package/dist/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +9 -0
- package/dist/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +20 -0
- package/dist/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +18 -0
- package/dist/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +24 -0
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +21 -0
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -0
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +29 -0
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -0
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +29 -0
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +1 -0
- package/dist/implementation/zodSchema/unionUtils.d.ts +6 -0
- package/dist/implementation/zodSchema/unionUtils.d.ts.map +1 -0
- package/dist/implementation/zodSchema/zodCo.d.ts +35 -0
- package/dist/implementation/zodSchema/zodCo.d.ts.map +1 -0
- package/dist/implementation/zodSchema/zodSchema.d.ts +38 -0
- package/dist/implementation/zodSchema/zodSchema.d.ts.map +1 -0
- package/dist/index.js +295 -10
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +34 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/subscribe/SubscriptionScope.d.ts +1 -2
- package/dist/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/subscribe/utils.d.ts +2 -2
- package/dist/subscribe/utils.d.ts.map +1 -1
- package/dist/testing.d.ts +10 -8
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/tests/utils.d.ts +6 -2
- package/dist/tests/utils.d.ts.map +1 -1
- package/dist/types.d.ts +1 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/auth/DemoAuth.ts +1 -2
- package/src/auth/PassphraseAuth.ts +1 -1
- package/src/coValues/CoValueBase.ts +88 -0
- package/src/coValues/account.ts +53 -43
- package/src/coValues/coFeed.ts +65 -83
- package/src/coValues/coList.ts +28 -21
- package/src/coValues/coMap.ts +54 -38
- package/src/coValues/coPlainText.ts +4 -1
- package/src/coValues/deepLoading.ts +35 -43
- package/src/coValues/extensions/imageDef.ts +21 -19
- package/src/coValues/group.ts +37 -38
- package/src/coValues/inbox.ts +24 -11
- package/src/coValues/interfaces.ts +29 -93
- package/src/coValues/profile.ts +12 -13
- package/src/coValues/registeredSchemas.ts +1 -3
- package/src/coValues/schemaUnion.ts +6 -6
- package/src/exports.ts +47 -25
- package/src/implementation/activeAccountContext.ts +1 -1
- package/src/implementation/createContext.ts +39 -24
- package/src/implementation/invites.ts +15 -12
- package/src/implementation/refs.ts +6 -4
- package/src/implementation/schema.ts +22 -34
- package/src/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts +101 -0
- package/src/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts +191 -0
- package/src/implementation/zodSchema/schemaTypes/AccountSchema.ts +102 -0
- package/src/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +70 -0
- package/src/implementation/zodSchema/schemaTypes/CoListSchema.ts +59 -0
- package/src/implementation/zodSchema/schemaTypes/CoMapSchema.ts +126 -0
- package/src/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +98 -0
- package/src/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +9 -0
- package/src/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +27 -0
- package/src/implementation/zodSchema/schemaTypes/RichTextSchema.ts +25 -0
- package/src/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +61 -0
- package/src/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +77 -0
- package/src/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +90 -0
- package/src/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.ts +103 -0
- package/src/implementation/zodSchema/unionUtils.ts +139 -0
- package/src/implementation/zodSchema/zodCo.ts +409 -0
- package/src/implementation/zodSchema/zodSchema.ts +116 -0
- package/src/internal.ts +38 -0
- package/src/subscribe/SubscriptionScope.ts +3 -1
- package/src/subscribe/utils.ts +7 -2
- package/src/testing.ts +14 -16
- package/src/tests/ContextManager.test.ts +73 -47
- package/src/tests/DemoAuth.test.ts +1 -1
- package/src/tests/account.test.ts +6 -9
- package/src/tests/coFeed.test.ts +102 -63
- package/src/tests/coList.test.ts +82 -95
- package/src/tests/coMap.record.test.ts +53 -87
- package/src/tests/coMap.test.ts +297 -312
- package/src/tests/coPlainText.test.ts +19 -39
- package/src/tests/createContext.test.ts +33 -15
- package/src/tests/deepLoading.test.ts +196 -179
- package/src/tests/groupsAndAccounts.test.ts +81 -72
- package/src/tests/imageDef.test.ts +22 -13
- package/src/tests/inbox.test.ts +36 -29
- package/src/tests/load.test.ts +10 -10
- package/src/tests/patterns/requestToJoin.test.ts +31 -31
- package/src/tests/schema.test.ts +37 -38
- package/src/tests/schemaUnion.test.ts +54 -64
- package/src/tests/subscribe.test.ts +118 -116
- package/src/tests/testing.test.ts +33 -33
- package/src/tests/utils.ts +3 -2
- package/src/types.ts +1 -8
- package/dist/chunk-IJU4XPFS.js.map +0 -1
- package/dist/tests/deepLoading.test-d.d.ts +0 -2
- package/dist/tests/deepLoading.test-d.d.ts.map +0 -1
- package/src/tests/deepLoading.test-d.ts +0 -393
package/src/tests/coList.test.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { cojsonInternals } from "cojson";
|
2
1
|
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
3
2
|
import { beforeEach, describe, expect, test, vi } from "vitest";
|
4
3
|
import {
|
@@ -6,18 +5,14 @@ import {
|
|
6
5
|
CoList,
|
7
6
|
CoMap,
|
8
7
|
Group,
|
9
|
-
|
10
|
-
co,
|
11
|
-
createJazzContextFromExistingCredentials,
|
12
|
-
isControlledAccount,
|
8
|
+
coField,
|
13
9
|
subscribeToCoValue,
|
10
|
+
z,
|
14
11
|
} from "../index.js";
|
15
|
-
import {
|
12
|
+
import { Loaded, co, zodSchemaToCoSchema } from "../internal.js";
|
16
13
|
import { createJazzTestAccount, setupJazzTestSync } from "../testing.js";
|
17
14
|
import { waitFor } from "./utils.js";
|
18
15
|
|
19
|
-
const connectedPeers = cojsonInternals.connectedPeers;
|
20
|
-
|
21
16
|
const Crypto = await WasmCrypto.create();
|
22
17
|
|
23
18
|
let me = await Account.create({
|
@@ -35,7 +30,7 @@ beforeEach(async () => {
|
|
35
30
|
});
|
36
31
|
|
37
32
|
describe("Simple CoList operations", async () => {
|
38
|
-
|
33
|
+
const TestList = co.list(z.string());
|
39
34
|
|
40
35
|
const list = TestList.create(["bread", "butter", "onion"], { owner: me });
|
41
36
|
|
@@ -76,11 +71,11 @@ describe("Simple CoList operations", async () => {
|
|
76
71
|
});
|
77
72
|
|
78
73
|
test("assignment with ref", () => {
|
79
|
-
|
80
|
-
name
|
81
|
-
}
|
74
|
+
const Ingredient = co.map({
|
75
|
+
name: z.string(),
|
76
|
+
});
|
82
77
|
|
83
|
-
|
78
|
+
const Recipe = co.list(Ingredient);
|
84
79
|
|
85
80
|
const recipe = Recipe.create(
|
86
81
|
[
|
@@ -95,12 +90,12 @@ describe("Simple CoList operations", async () => {
|
|
95
90
|
expect(recipe[1]?.name).toBe("margarine");
|
96
91
|
});
|
97
92
|
|
98
|
-
test("assign
|
99
|
-
|
100
|
-
name
|
101
|
-
}
|
93
|
+
test("assign undefined on a required ref", () => {
|
94
|
+
const Ingredient = co.map({
|
95
|
+
name: z.string(),
|
96
|
+
});
|
102
97
|
|
103
|
-
|
98
|
+
const Recipe = co.list(Ingredient);
|
104
99
|
|
105
100
|
const recipe = Recipe.create(
|
106
101
|
[
|
@@ -112,18 +107,18 @@ describe("Simple CoList operations", async () => {
|
|
112
107
|
);
|
113
108
|
|
114
109
|
expect(() => {
|
115
|
-
recipe[1] =
|
116
|
-
}).toThrow("Cannot set required reference 1 to
|
110
|
+
recipe[1] = undefined as unknown as Loaded<typeof Ingredient>;
|
111
|
+
}).toThrow("Cannot set required reference 1 to undefined");
|
117
112
|
|
118
113
|
expect(recipe[1]?.name).toBe("butter");
|
119
114
|
});
|
120
115
|
|
121
|
-
test("assign
|
122
|
-
|
123
|
-
name
|
124
|
-
}
|
116
|
+
test("assign undefined on an optional ref", () => {
|
117
|
+
const Ingredient = co.map({
|
118
|
+
name: z.string(),
|
119
|
+
});
|
125
120
|
|
126
|
-
|
121
|
+
const Recipe = co.list(z.optional(Ingredient));
|
127
122
|
|
128
123
|
const recipe = Recipe.create(
|
129
124
|
[
|
@@ -134,8 +129,8 @@ describe("Simple CoList operations", async () => {
|
|
134
129
|
{ owner: me },
|
135
130
|
);
|
136
131
|
|
137
|
-
recipe[1] =
|
138
|
-
expect(recipe[1]).toBe(
|
132
|
+
recipe[1] = undefined;
|
133
|
+
expect(recipe[1]).toBe(undefined);
|
139
134
|
});
|
140
135
|
|
141
136
|
test("push", () => {
|
@@ -269,11 +264,11 @@ describe("Simple CoList operations", async () => {
|
|
269
264
|
});
|
270
265
|
|
271
266
|
test("sort list of refs", async () => {
|
272
|
-
|
273
|
-
text
|
274
|
-
}
|
267
|
+
const Message = co.map({
|
268
|
+
text: z.string(),
|
269
|
+
});
|
275
270
|
|
276
|
-
|
271
|
+
const Chat = co.list(Message);
|
277
272
|
|
278
273
|
const chat = Chat.create(
|
279
274
|
[
|
@@ -316,9 +311,9 @@ describe("Simple CoList operations", async () => {
|
|
316
311
|
});
|
317
312
|
|
318
313
|
test("filter + assign to coMap", () => {
|
319
|
-
|
320
|
-
list
|
321
|
-
}
|
314
|
+
const TestMap = co.map({
|
315
|
+
list: TestList,
|
316
|
+
});
|
322
317
|
|
323
318
|
const map = TestMap.create(
|
324
319
|
{
|
@@ -338,7 +333,7 @@ describe("Simple CoList operations", async () => {
|
|
338
333
|
});
|
339
334
|
|
340
335
|
test("filter + assign to CoList", () => {
|
341
|
-
|
336
|
+
const TestListOfLists = co.list(TestList);
|
342
337
|
|
343
338
|
const list = TestListOfLists.create(
|
344
339
|
[
|
@@ -361,7 +356,7 @@ describe("Simple CoList operations", async () => {
|
|
361
356
|
|
362
357
|
describe("CoList applyDiff operations", async () => {
|
363
358
|
test("applyDiff with primitive values", () => {
|
364
|
-
|
359
|
+
const StringList = co.list(z.string());
|
365
360
|
const list = StringList.create(["a", "b", "c"], { owner: me });
|
366
361
|
|
367
362
|
// Test adding items
|
@@ -382,12 +377,8 @@ describe("CoList applyDiff operations", async () => {
|
|
382
377
|
});
|
383
378
|
|
384
379
|
test("applyDiff with reference values", () => {
|
385
|
-
|
386
|
-
|
387
|
-
return this[0];
|
388
|
-
}
|
389
|
-
}
|
390
|
-
class RefList extends CoList.Of(co.ref(NestedItem)) {}
|
380
|
+
const NestedItem = co.list(z.string());
|
381
|
+
const RefList = co.list(NestedItem);
|
391
382
|
|
392
383
|
const item1 = NestedItem.create(["item1"], { owner: me });
|
393
384
|
const item2 = NestedItem.create(["item2"], { owner: me });
|
@@ -399,18 +390,18 @@ describe("CoList applyDiff operations", async () => {
|
|
399
390
|
// Test adding reference items
|
400
391
|
list.applyDiff([item1, item2, item3]);
|
401
392
|
expect(list.length).toBe(3);
|
402
|
-
expect(list[2]?.
|
393
|
+
expect(list[2]?.[0]).toBe("item3");
|
403
394
|
|
404
395
|
// Test removing reference items
|
405
396
|
list.applyDiff([item1, item3]);
|
406
397
|
expect(list.length).toBe(2);
|
407
|
-
expect(list[0]?.
|
408
|
-
expect(list[1]?.
|
398
|
+
expect(list[0]?.[0]).toBe("item1");
|
399
|
+
expect(list[1]?.[0]).toBe("item3");
|
409
400
|
|
410
401
|
// Test replacing reference items
|
411
402
|
list.applyDiff([item4]);
|
412
403
|
expect(list.length).toBe(1);
|
413
|
-
expect(list[0]?.
|
404
|
+
expect(list[0]?.[0]).toBe("item4");
|
414
405
|
|
415
406
|
// Test empty list
|
416
407
|
list.applyDiff([]);
|
@@ -418,11 +409,11 @@ describe("CoList applyDiff operations", async () => {
|
|
418
409
|
});
|
419
410
|
|
420
411
|
test("applyDiff with refs + filter", () => {
|
421
|
-
|
422
|
-
type
|
423
|
-
}
|
412
|
+
const TestMap = co.map({
|
413
|
+
type: z.string(),
|
414
|
+
});
|
424
415
|
|
425
|
-
|
416
|
+
const TestList = co.list(TestMap);
|
426
417
|
|
427
418
|
const bread = TestMap.create({ type: "bread" }, me);
|
428
419
|
const butter = TestMap.create({ type: "butter" }, me);
|
@@ -436,7 +427,7 @@ describe("CoList applyDiff operations", async () => {
|
|
436
427
|
});
|
437
428
|
|
438
429
|
test("applyDiff with mixed operations", () => {
|
439
|
-
|
430
|
+
const StringList = co.list(z.string());
|
440
431
|
const list = StringList.create(["a", "b", "c", "d", "e"], { owner: me });
|
441
432
|
|
442
433
|
// Test multiple operations at once
|
@@ -454,15 +445,11 @@ describe("CoList applyDiff operations", async () => {
|
|
454
445
|
});
|
455
446
|
|
456
447
|
describe("CoList resolution", async () => {
|
457
|
-
|
458
|
-
joined() {
|
459
|
-
return this.join(",");
|
460
|
-
}
|
461
|
-
}
|
448
|
+
const TwiceNestedList = co.list(z.string());
|
462
449
|
|
463
|
-
|
450
|
+
const NestedList = co.list(TwiceNestedList);
|
464
451
|
|
465
|
-
|
452
|
+
const TestList = co.list(NestedList);
|
466
453
|
|
467
454
|
const initNodeAndList = async () => {
|
468
455
|
const me = await Account.create({
|
@@ -489,7 +476,7 @@ describe("CoList resolution", async () => {
|
|
489
476
|
const { list } = await initNodeAndList();
|
490
477
|
|
491
478
|
expect(list[0]?.[0]?.[0]).toBe("a");
|
492
|
-
expect(list[0]?.[0]?.
|
479
|
+
expect(list[0]?.[0]?.join(",")).toBe("a,b");
|
493
480
|
expect(list[0]?.[0]?.id).toBeDefined();
|
494
481
|
expect(list[1]?.[0]?.[0]).toBe("c");
|
495
482
|
});
|
@@ -497,18 +484,18 @@ describe("CoList resolution", async () => {
|
|
497
484
|
|
498
485
|
describe("CoList subscription", async () => {
|
499
486
|
test("subscription on a locally available list with deep resolve", async () => {
|
500
|
-
|
501
|
-
name
|
502
|
-
}
|
487
|
+
const Item = co.map({
|
488
|
+
name: z.string(),
|
489
|
+
});
|
503
490
|
|
504
|
-
|
491
|
+
const TestList = co.list(Item);
|
505
492
|
|
506
493
|
const list = TestList.create(
|
507
494
|
[Item.create({ name: "Item 1" }), Item.create({ name: "Item 2" })],
|
508
495
|
{ owner: me },
|
509
496
|
);
|
510
497
|
|
511
|
-
const updates:
|
498
|
+
const updates: Loaded<typeof TestList, { $each: true }>[] = [];
|
512
499
|
const spy = vi.fn((list) => updates.push(list));
|
513
500
|
|
514
501
|
TestList.subscribe(
|
@@ -541,18 +528,18 @@ describe("CoList subscription", async () => {
|
|
541
528
|
});
|
542
529
|
|
543
530
|
test("subscription on a locally available list with autoload", async () => {
|
544
|
-
|
545
|
-
name
|
546
|
-
}
|
531
|
+
const Item = co.map({
|
532
|
+
name: z.string(),
|
533
|
+
});
|
547
534
|
|
548
|
-
|
535
|
+
const TestList = co.list(Item);
|
549
536
|
|
550
537
|
const list = TestList.create(
|
551
538
|
[Item.create({ name: "Item 1" }), Item.create({ name: "Item 2" })],
|
552
539
|
{ owner: me },
|
553
540
|
);
|
554
541
|
|
555
|
-
const updates: TestList[] = [];
|
542
|
+
const updates: Loaded<typeof TestList>[] = [];
|
556
543
|
const spy = vi.fn((list) => updates.push(list));
|
557
544
|
|
558
545
|
TestList.subscribe(list.id, {}, spy);
|
@@ -577,22 +564,22 @@ describe("CoList subscription", async () => {
|
|
577
564
|
});
|
578
565
|
|
579
566
|
test("subscription on a locally available list with syncResolution", async () => {
|
580
|
-
|
581
|
-
name
|
582
|
-
}
|
567
|
+
const Item = co.map({
|
568
|
+
name: z.string(),
|
569
|
+
});
|
583
570
|
|
584
|
-
|
571
|
+
const TestList = co.list(Item);
|
585
572
|
|
586
573
|
const list = TestList.create(
|
587
574
|
[Item.create({ name: "Item 1" }), Item.create({ name: "Item 2" })],
|
588
575
|
{ owner: me },
|
589
576
|
);
|
590
577
|
|
591
|
-
const updates: TestList[] = [];
|
578
|
+
const updates: Loaded<typeof TestList>[] = [];
|
592
579
|
const spy = vi.fn((list) => updates.push(list));
|
593
580
|
|
594
581
|
subscribeToCoValue(
|
595
|
-
TestList,
|
582
|
+
zodSchemaToCoSchema(TestList),
|
596
583
|
list.id,
|
597
584
|
{
|
598
585
|
syncResolution: true,
|
@@ -620,11 +607,11 @@ describe("CoList subscription", async () => {
|
|
620
607
|
});
|
621
608
|
|
622
609
|
test("subscription on a remotely available list with deep resolve", async () => {
|
623
|
-
|
624
|
-
name
|
625
|
-
}
|
610
|
+
const Item = co.map({
|
611
|
+
name: z.string(),
|
612
|
+
});
|
626
613
|
|
627
|
-
|
614
|
+
const TestList = co.list(Item);
|
628
615
|
|
629
616
|
const group = Group.create();
|
630
617
|
group.addMember("everyone", "writer");
|
@@ -639,7 +626,7 @@ describe("CoList subscription", async () => {
|
|
639
626
|
|
640
627
|
const userB = await createJazzTestAccount();
|
641
628
|
|
642
|
-
const updates:
|
629
|
+
const updates: Loaded<typeof TestList, { $each: true }>[] = [];
|
643
630
|
const spy = vi.fn((list) => updates.push(list));
|
644
631
|
|
645
632
|
TestList.subscribe(
|
@@ -673,11 +660,11 @@ describe("CoList subscription", async () => {
|
|
673
660
|
});
|
674
661
|
|
675
662
|
test("subscription on a remotely available list with autoload", async () => {
|
676
|
-
|
677
|
-
name
|
678
|
-
}
|
663
|
+
const Item = co.map({
|
664
|
+
name: z.string(),
|
665
|
+
});
|
679
666
|
|
680
|
-
|
667
|
+
const TestList = co.list(Item);
|
681
668
|
|
682
669
|
const group = Group.create();
|
683
670
|
group.addMember("everyone", "writer");
|
@@ -690,7 +677,7 @@ describe("CoList subscription", async () => {
|
|
690
677
|
group,
|
691
678
|
);
|
692
679
|
|
693
|
-
const updates: TestList[] = [];
|
680
|
+
const updates: Loaded<typeof TestList>[] = [];
|
694
681
|
const spy = vi.fn((list) => updates.push(list));
|
695
682
|
|
696
683
|
const userB = await createJazzTestAccount();
|
@@ -723,18 +710,18 @@ describe("CoList subscription", async () => {
|
|
723
710
|
});
|
724
711
|
|
725
712
|
test("replacing list items triggers updates", async () => {
|
726
|
-
|
727
|
-
name
|
728
|
-
}
|
713
|
+
const Item = co.map({
|
714
|
+
name: z.string(),
|
715
|
+
});
|
729
716
|
|
730
|
-
|
717
|
+
const TestList = co.list(Item);
|
731
718
|
|
732
719
|
const list = TestList.create(
|
733
720
|
[Item.create({ name: "Item 1" }), Item.create({ name: "Item 2" })],
|
734
721
|
{ owner: me },
|
735
722
|
);
|
736
723
|
|
737
|
-
const updates:
|
724
|
+
const updates: Loaded<typeof TestList, { $each: true }>[] = [];
|
738
725
|
const spy = vi.fn((list) => updates.push(list));
|
739
726
|
|
740
727
|
TestList.subscribe(
|
@@ -767,11 +754,11 @@ describe("CoList subscription", async () => {
|
|
767
754
|
});
|
768
755
|
|
769
756
|
test("pushing a new item triggers updates correctly", async () => {
|
770
|
-
|
771
|
-
name
|
772
|
-
}
|
757
|
+
const Item = co.map({
|
758
|
+
name: z.string(),
|
759
|
+
});
|
773
760
|
|
774
|
-
|
761
|
+
const TestList = co.list(Item);
|
775
762
|
|
776
763
|
const group = Group.create();
|
777
764
|
group.addMember("everyone", "writer");
|
@@ -784,7 +771,7 @@ describe("CoList subscription", async () => {
|
|
784
771
|
group,
|
785
772
|
);
|
786
773
|
|
787
|
-
const updates: TestList[] = [];
|
774
|
+
const updates: Loaded<typeof TestList, { $each: true }>[] = [];
|
788
775
|
const spy = vi.fn((list) => updates.push(list));
|
789
776
|
|
790
777
|
const userB = await createJazzTestAccount();
|