jazz-tools 0.13.31 → 0.14.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.
Files changed (166) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/CHANGELOG.md +14 -3
  3. package/dist/auth/DemoAuth.d.ts.map +1 -1
  4. package/dist/auth/PassphraseAuth.d.ts +1 -3
  5. package/dist/auth/PassphraseAuth.d.ts.map +1 -1
  6. package/dist/{chunk-IJU4XPFS.js → chunk-2ASOGEYA.js} +3535 -3291
  7. package/dist/chunk-2ASOGEYA.js.map +1 -0
  8. package/dist/coValues/CoValueBase.d.ts +22 -0
  9. package/dist/coValues/CoValueBase.d.ts.map +1 -0
  10. package/dist/coValues/account.d.ts +12 -12
  11. package/dist/coValues/account.d.ts.map +1 -1
  12. package/dist/coValues/coFeed.d.ts +24 -25
  13. package/dist/coValues/coFeed.d.ts.map +1 -1
  14. package/dist/coValues/coList.d.ts +10 -13
  15. package/dist/coValues/coList.d.ts.map +1 -1
  16. package/dist/coValues/coMap.d.ts +32 -35
  17. package/dist/coValues/coMap.d.ts.map +1 -1
  18. package/dist/coValues/coPlainText.d.ts.map +1 -1
  19. package/dist/coValues/deepLoading.d.ts +17 -21
  20. package/dist/coValues/deepLoading.d.ts.map +1 -1
  21. package/dist/coValues/extensions/imageDef.d.ts +12 -11
  22. package/dist/coValues/extensions/imageDef.d.ts.map +1 -1
  23. package/dist/coValues/group.d.ts +5 -9
  24. package/dist/coValues/group.d.ts.map +1 -1
  25. package/dist/coValues/inbox.d.ts +2 -3
  26. package/dist/coValues/inbox.d.ts.map +1 -1
  27. package/dist/coValues/interfaces.d.ts +8 -34
  28. package/dist/coValues/interfaces.d.ts.map +1 -1
  29. package/dist/coValues/profile.d.ts +4 -14
  30. package/dist/coValues/profile.d.ts.map +1 -1
  31. package/dist/coValues/registeredSchemas.d.ts +1 -3
  32. package/dist/coValues/registeredSchemas.d.ts.map +1 -1
  33. package/dist/coValues/schemaUnion.d.ts +6 -6
  34. package/dist/exports.d.ts +12 -16
  35. package/dist/exports.d.ts.map +1 -1
  36. package/dist/implementation/ContextManager.d.ts +1 -1
  37. package/dist/implementation/ContextManager.d.ts.map +1 -1
  38. package/dist/implementation/activeAccountContext.d.ts +1 -1
  39. package/dist/implementation/activeAccountContext.d.ts.map +1 -1
  40. package/dist/implementation/createContext.d.ts +10 -10
  41. package/dist/implementation/createContext.d.ts.map +1 -1
  42. package/dist/implementation/invites.d.ts +6 -6
  43. package/dist/implementation/invites.d.ts.map +1 -1
  44. package/dist/implementation/refs.d.ts +2 -2
  45. package/dist/implementation/refs.d.ts.map +1 -1
  46. package/dist/implementation/schema.d.ts +21 -28
  47. package/dist/implementation/schema.d.ts.map +1 -1
  48. package/dist/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts +9 -0
  49. package/dist/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts.map +1 -0
  50. package/dist/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts +28 -0
  51. package/dist/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +1 -0
  52. package/dist/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +65 -0
  53. package/dist/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -0
  54. package/dist/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +28 -0
  55. package/dist/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -0
  56. package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +24 -0
  57. package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -0
  58. package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +41 -0
  59. package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -0
  60. package/dist/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +35 -0
  61. package/dist/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -0
  62. package/dist/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +9 -0
  63. package/dist/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -0
  64. package/dist/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +20 -0
  65. package/dist/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -0
  66. package/dist/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +18 -0
  67. package/dist/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -0
  68. package/dist/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +24 -0
  69. package/dist/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -0
  70. package/dist/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +21 -0
  71. package/dist/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -0
  72. package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +29 -0
  73. package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -0
  74. package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +29 -0
  75. package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +1 -0
  76. package/dist/implementation/zodSchema/unionUtils.d.ts +6 -0
  77. package/dist/implementation/zodSchema/unionUtils.d.ts.map +1 -0
  78. package/dist/implementation/zodSchema/zodCo.d.ts +35 -0
  79. package/dist/implementation/zodSchema/zodCo.d.ts.map +1 -0
  80. package/dist/implementation/zodSchema/zodSchema.d.ts +38 -0
  81. package/dist/implementation/zodSchema/zodSchema.d.ts.map +1 -0
  82. package/dist/index.js +295 -10
  83. package/dist/index.js.map +1 -1
  84. package/dist/internal.d.ts +34 -0
  85. package/dist/internal.d.ts.map +1 -1
  86. package/dist/subscribe/SubscriptionScope.d.ts +1 -2
  87. package/dist/subscribe/SubscriptionScope.d.ts.map +1 -1
  88. package/dist/subscribe/utils.d.ts +2 -2
  89. package/dist/subscribe/utils.d.ts.map +1 -1
  90. package/dist/testing.d.ts +10 -8
  91. package/dist/testing.d.ts.map +1 -1
  92. package/dist/testing.js +1 -1
  93. package/dist/testing.js.map +1 -1
  94. package/dist/tests/utils.d.ts +6 -2
  95. package/dist/tests/utils.d.ts.map +1 -1
  96. package/dist/types.d.ts +1 -7
  97. package/dist/types.d.ts.map +1 -1
  98. package/package.json +3 -2
  99. package/src/auth/DemoAuth.ts +1 -2
  100. package/src/auth/PassphraseAuth.ts +1 -1
  101. package/src/coValues/CoValueBase.ts +83 -0
  102. package/src/coValues/account.ts +53 -43
  103. package/src/coValues/coFeed.ts +65 -83
  104. package/src/coValues/coList.ts +28 -21
  105. package/src/coValues/coMap.ts +54 -38
  106. package/src/coValues/coPlainText.ts +4 -1
  107. package/src/coValues/deepLoading.ts +35 -43
  108. package/src/coValues/extensions/imageDef.ts +21 -19
  109. package/src/coValues/group.ts +37 -38
  110. package/src/coValues/inbox.ts +24 -11
  111. package/src/coValues/interfaces.ts +29 -93
  112. package/src/coValues/profile.ts +12 -13
  113. package/src/coValues/registeredSchemas.ts +1 -3
  114. package/src/coValues/schemaUnion.ts +6 -6
  115. package/src/exports.ts +47 -25
  116. package/src/implementation/activeAccountContext.ts +1 -1
  117. package/src/implementation/createContext.ts +39 -24
  118. package/src/implementation/invites.ts +15 -12
  119. package/src/implementation/refs.ts +6 -4
  120. package/src/implementation/schema.ts +22 -34
  121. package/src/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts +101 -0
  122. package/src/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts +191 -0
  123. package/src/implementation/zodSchema/schemaTypes/AccountSchema.ts +102 -0
  124. package/src/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +70 -0
  125. package/src/implementation/zodSchema/schemaTypes/CoListSchema.ts +59 -0
  126. package/src/implementation/zodSchema/schemaTypes/CoMapSchema.ts +126 -0
  127. package/src/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +98 -0
  128. package/src/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +9 -0
  129. package/src/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +27 -0
  130. package/src/implementation/zodSchema/schemaTypes/RichTextSchema.ts +25 -0
  131. package/src/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +61 -0
  132. package/src/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +77 -0
  133. package/src/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +90 -0
  134. package/src/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.ts +103 -0
  135. package/src/implementation/zodSchema/unionUtils.ts +139 -0
  136. package/src/implementation/zodSchema/zodCo.ts +409 -0
  137. package/src/implementation/zodSchema/zodSchema.ts +116 -0
  138. package/src/internal.ts +38 -0
  139. package/src/subscribe/SubscriptionScope.ts +3 -1
  140. package/src/subscribe/utils.ts +7 -2
  141. package/src/testing.ts +14 -16
  142. package/src/tests/ContextManager.test.ts +73 -47
  143. package/src/tests/DemoAuth.test.ts +1 -1
  144. package/src/tests/account.test.ts +6 -9
  145. package/src/tests/coFeed.test.ts +102 -63
  146. package/src/tests/coList.test.ts +82 -95
  147. package/src/tests/coMap.record.test.ts +53 -87
  148. package/src/tests/coMap.test.ts +297 -312
  149. package/src/tests/coPlainText.test.ts +19 -39
  150. package/src/tests/createContext.test.ts +33 -15
  151. package/src/tests/deepLoading.test.ts +196 -179
  152. package/src/tests/groupsAndAccounts.test.ts +81 -72
  153. package/src/tests/imageDef.test.ts +22 -13
  154. package/src/tests/inbox.test.ts +36 -29
  155. package/src/tests/load.test.ts +10 -10
  156. package/src/tests/patterns/requestToJoin.test.ts +31 -31
  157. package/src/tests/schema.test.ts +37 -38
  158. package/src/tests/schemaUnion.test.ts +54 -64
  159. package/src/tests/subscribe.test.ts +118 -116
  160. package/src/tests/testing.test.ts +33 -33
  161. package/src/tests/utils.ts +3 -2
  162. package/src/types.ts +1 -8
  163. package/dist/chunk-IJU4XPFS.js.map +0 -1
  164. package/dist/tests/deepLoading.test-d.d.ts +0 -2
  165. package/dist/tests/deepLoading.test-d.d.ts.map +0 -1
  166. package/src/tests/deepLoading.test-d.ts +0 -393
@@ -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
- Resolved,
10
- co,
11
- createJazzContextFromExistingCredentials,
12
- isControlledAccount,
8
+ coField,
13
9
  subscribeToCoValue,
10
+ z,
14
11
  } from "../index.js";
15
- import { randomSessionProvider } from "../internal.js";
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
- class TestList extends CoList.Of(co.string) {}
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
- class Ingredient extends CoMap {
80
- name = co.string;
81
- }
74
+ const Ingredient = co.map({
75
+ name: z.string(),
76
+ });
82
77
 
83
- class Recipe extends CoList.Of(co.ref(Ingredient)) {}
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 null on a required ref", () => {
99
- class Ingredient extends CoMap {
100
- name = co.string;
101
- }
93
+ test("assign undefined on a required ref", () => {
94
+ const Ingredient = co.map({
95
+ name: z.string(),
96
+ });
102
97
 
103
- class Recipe extends CoList.Of(co.ref(Ingredient)) {}
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] = null;
116
- }).toThrow("Cannot set required reference 1 to null");
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 null on an optional ref", () => {
122
- class Ingredient extends CoMap {
123
- name = co.string;
124
- }
116
+ test("assign undefined on an optional ref", () => {
117
+ const Ingredient = co.map({
118
+ name: z.string(),
119
+ });
125
120
 
126
- class Recipe extends CoList.Of(co.optional.ref(Ingredient)) {}
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] = null;
138
- expect(recipe[1]).toBe(null);
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
- class Message extends CoMap {
273
- text = co.string;
274
- }
267
+ const Message = co.map({
268
+ text: z.string(),
269
+ });
275
270
 
276
- class Chat extends CoList.Of(co.ref(Message)) {}
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
- class TestMap extends CoMap {
320
- list = co.ref(TestList);
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
- class TestListOfLists extends CoList.Of(co.ref(TestList)) {}
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
- class StringList extends CoList.Of(co.string) {}
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
- class NestedItem extends CoList.Of(co.string) {
386
- get value() {
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]?.value).toBe("item3");
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]?.value).toBe("item1");
408
- expect(list[1]?.value).toBe("item3");
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]?.value).toBe("item4");
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
- class TestMap extends CoMap {
422
- type = co.string;
423
- }
412
+ const TestMap = co.map({
413
+ type: z.string(),
414
+ });
424
415
 
425
- class TestList extends CoList.Of(co.ref(TestMap)) {}
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
- class StringList extends CoList.Of(co.string) {}
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
- class TwiceNestedList extends CoList.Of(co.string) {
458
- joined() {
459
- return this.join(",");
460
- }
461
- }
448
+ const TwiceNestedList = co.list(z.string());
462
449
 
463
- class NestedList extends CoList.Of(co.ref(TwiceNestedList)) {}
450
+ const NestedList = co.list(TwiceNestedList);
464
451
 
465
- class TestList extends CoList.Of(co.ref(NestedList)) {}
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]?.joined()).toBe("a,b");
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
- class Item extends CoMap {
501
- name = co.string;
502
- }
487
+ const Item = co.map({
488
+ name: z.string(),
489
+ });
503
490
 
504
- class TestList extends CoList.Of(co.ref(Item)) {}
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: Resolved<TestList, { $each: true }>[] = [];
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
- class Item extends CoMap {
545
- name = co.string;
546
- }
531
+ const Item = co.map({
532
+ name: z.string(),
533
+ });
547
534
 
548
- class TestList extends CoList.Of(co.ref(Item)) {}
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
- class Item extends CoMap {
581
- name = co.string;
582
- }
567
+ const Item = co.map({
568
+ name: z.string(),
569
+ });
583
570
 
584
- class TestList extends CoList.Of(co.ref(Item)) {}
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
- class Item extends CoMap {
624
- name = co.string;
625
- }
610
+ const Item = co.map({
611
+ name: z.string(),
612
+ });
626
613
 
627
- class TestList extends CoList.Of(co.ref(Item)) {}
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: Resolved<TestList, { $each: true }>[] = [];
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
- class Item extends CoMap {
677
- name = co.string;
678
- }
663
+ const Item = co.map({
664
+ name: z.string(),
665
+ });
679
666
 
680
- class TestList extends CoList.Of(co.ref(Item)) {}
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
- class Item extends CoMap {
727
- name = co.string;
728
- }
713
+ const Item = co.map({
714
+ name: z.string(),
715
+ });
729
716
 
730
- class TestList extends CoList.Of(co.ref(Item)) {}
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: Resolved<TestList, { $each: true }>[] = [];
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
- class Item extends CoMap {
771
- name = co.string;
772
- }
757
+ const Item = co.map({
758
+ name: z.string(),
759
+ });
773
760
 
774
- class TestList extends CoList.Of(co.ref(Item)) {}
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();