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.
Files changed (228) hide show
  1. package/.svelte-kit/__package__/jazz.class.svelte.js +1 -1
  2. package/.svelte-kit/__package__/media/image.svelte +3 -9
  3. package/.svelte-kit/__package__/media/image.svelte.d.ts +1 -6
  4. package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
  5. package/.svelte-kit/__package__/media/image.types.d.ts +7 -0
  6. package/.svelte-kit/__package__/media/image.types.d.ts.map +1 -0
  7. package/.svelte-kit/__package__/media/image.types.js +1 -0
  8. package/.svelte-kit/__package__/tests/media/image.svelte.test.js +31 -31
  9. package/.turbo/turbo-build.log +49 -49
  10. package/CHANGELOG.md +42 -0
  11. package/dist/browser/index.js +2 -2
  12. package/dist/browser/index.js.map +1 -1
  13. package/dist/{chunk-SFP5PBPX.js → chunk-HJ3GTGY7.js} +1325 -1001
  14. package/dist/chunk-HJ3GTGY7.js.map +1 -0
  15. package/dist/index.js +18 -18
  16. package/dist/index.js.map +1 -1
  17. package/dist/inspector/{custom-element-ZSNTCECD.js → custom-element-WCY6D3QJ.js} +3 -3
  18. package/dist/inspector/{custom-element-ZSNTCECD.js.map → custom-element-WCY6D3QJ.js.map} +1 -1
  19. package/dist/inspector/index.js +1 -1
  20. package/dist/inspector/index.js.map +1 -1
  21. package/dist/inspector/register-custom-element.js +1 -1
  22. package/dist/media/{chunk-E5J3WLQW.js → chunk-KR2V6X2N.js} +14 -9
  23. package/dist/media/chunk-KR2V6X2N.js.map +1 -0
  24. package/dist/media/create-image.d.ts +6 -6
  25. package/dist/media/index.browser.d.ts +6 -6
  26. package/dist/media/index.browser.js +1 -1
  27. package/dist/media/index.d.ts +1 -1
  28. package/dist/media/index.js +1 -1
  29. package/dist/media/index.native.d.ts +6 -6
  30. package/dist/media/index.native.js +1 -1
  31. package/dist/media/utils.d.ts.map +1 -1
  32. package/dist/prosemirror/index.js +2 -2
  33. package/dist/prosemirror/index.js.map +1 -1
  34. package/dist/react/index.js +7 -5
  35. package/dist/react/index.js.map +1 -1
  36. package/dist/react-core/hooks.d.ts.map +1 -1
  37. package/dist/react-core/index.js +4658 -23
  38. package/dist/react-core/index.js.map +1 -1
  39. package/dist/react-native-core/index.js +1 -1
  40. package/dist/react-native-core/index.js.map +1 -1
  41. package/dist/svelte/jazz.class.svelte.js +1 -1
  42. package/dist/svelte/media/image.svelte +3 -9
  43. package/dist/svelte/media/image.svelte.d.ts +1 -6
  44. package/dist/svelte/media/image.svelte.d.ts.map +1 -1
  45. package/dist/svelte/media/image.types.d.ts +7 -0
  46. package/dist/svelte/media/image.types.d.ts.map +1 -0
  47. package/dist/svelte/media/image.types.js +1 -0
  48. package/dist/svelte/tests/media/image.svelte.test.js +31 -31
  49. package/dist/testing.js +18 -14
  50. package/dist/testing.js.map +1 -1
  51. package/dist/tools/coValues/CoFieldInit.d.ts +13 -0
  52. package/dist/tools/coValues/CoFieldInit.d.ts.map +1 -0
  53. package/dist/tools/coValues/CoValueBase.d.ts +18 -15
  54. package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
  55. package/dist/tools/coValues/account.d.ts +100 -46
  56. package/dist/tools/coValues/account.d.ts.map +1 -1
  57. package/dist/tools/coValues/coFeed.d.ts +78 -62
  58. package/dist/tools/coValues/coFeed.d.ts.map +1 -1
  59. package/dist/tools/coValues/coList.d.ts +212 -99
  60. package/dist/tools/coValues/coList.d.ts.map +1 -1
  61. package/dist/tools/coValues/coMap.d.ts +200 -192
  62. package/dist/tools/coValues/coMap.d.ts.map +1 -1
  63. package/dist/tools/coValues/coPlainText.d.ts +30 -22
  64. package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
  65. package/dist/tools/coValues/deepLoading.d.ts +13 -13
  66. package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
  67. package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
  68. package/dist/tools/coValues/group.d.ts +32 -32
  69. package/dist/tools/coValues/group.d.ts.map +1 -1
  70. package/dist/tools/coValues/inbox.d.ts.map +1 -1
  71. package/dist/tools/coValues/interfaces.d.ts +18 -17
  72. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  73. package/dist/tools/coValues/profile.d.ts +6 -5
  74. package/dist/tools/coValues/profile.d.ts.map +1 -1
  75. package/dist/tools/coValues/schemaUnion.d.ts +3 -3
  76. package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
  77. package/dist/tools/exports.d.ts +1 -1
  78. package/dist/tools/exports.d.ts.map +1 -1
  79. package/dist/tools/implementation/anonymousJazzAgent.d.ts +2 -1
  80. package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -1
  81. package/dist/tools/implementation/schema.d.ts +5 -5
  82. package/dist/tools/implementation/schema.d.ts.map +1 -1
  83. package/dist/tools/implementation/symbols.d.ts +2 -0
  84. package/dist/tools/implementation/symbols.d.ts.map +1 -1
  85. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
  86. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  87. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +6 -2
  88. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
  89. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +8 -3
  90. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
  91. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +12 -7
  92. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
  93. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +13 -7
  94. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
  95. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +11 -2
  96. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
  97. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +4 -0
  98. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
  99. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +4 -0
  100. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
  101. package/dist/tools/implementation/zodSchema/typeConverters/{CoFieldInit.d.ts → CoFieldSchemaInit.d.ts} +7 -7
  102. package/dist/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.d.ts.map +1 -0
  103. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +4 -4
  104. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
  105. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +4 -4
  106. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
  107. package/dist/tools/implementation/zodSchema/zodCo.d.ts +2 -2
  108. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  109. package/dist/tools/internal.d.ts +2 -1
  110. package/dist/tools/internal.d.ts.map +1 -1
  111. package/dist/tools/lib/migration.d.ts +1 -1
  112. package/dist/tools/lib/migration.d.ts.map +1 -1
  113. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  114. package/dist/tools/subscribe/index.d.ts +1 -1
  115. package/dist/tools/subscribe/index.d.ts.map +1 -1
  116. package/dist/tools/subscribe/utils.d.ts +2 -2
  117. package/dist/tools/subscribe/utils.d.ts.map +1 -1
  118. package/dist/tools/testing.d.ts.map +1 -1
  119. package/dist/tools/tests/utils.d.ts +2 -6
  120. package/dist/tools/tests/utils.d.ts.map +1 -1
  121. package/dist/worker/index.js +3 -3
  122. package/dist/worker/index.js.map +1 -1
  123. package/package.json +4 -4
  124. package/src/browser/auth/PasskeyAuth.ts +2 -2
  125. package/src/browser/createBrowserContext.ts +2 -2
  126. package/src/browser/tests/PasskeyAuth.test.ts +2 -2
  127. package/src/inspector/custom-element.tsx +2 -2
  128. package/src/inspector/viewer/new-app.tsx +1 -1
  129. package/src/media/create-image.test.ts +7 -7
  130. package/src/media/create-image.ts +5 -3
  131. package/src/media/index.ts +1 -1
  132. package/src/media/utils.test.ts +72 -66
  133. package/src/media/utils.ts +9 -6
  134. package/src/prosemirror/lib/plugin.ts +1 -1
  135. package/src/prosemirror/lib/sync.ts +1 -1
  136. package/src/prosemirror/tests/plugin.test.ts +4 -4
  137. package/src/react/media/image.tsx +2 -2
  138. package/src/react/tests/media/image.test.tsx +52 -32
  139. package/src/react-core/hooks.ts +11 -5
  140. package/src/react-core/tests/useAccount.test.ts +16 -22
  141. package/src/react-core/tests/useCoState.test.ts +19 -19
  142. package/src/react-core/tests/useInboxSender.test.ts +5 -2
  143. package/src/react-core/tests/usePassPhraseAuth.test.ts +6 -6
  144. package/src/react-native-core/media/image.tsx +1 -1
  145. package/src/svelte/jazz.class.svelte.ts +1 -1
  146. package/src/svelte/media/image.svelte +3 -9
  147. package/src/svelte/media/image.types.ts +7 -0
  148. package/src/svelte/tests/media/image.svelte.test.ts +34 -32
  149. package/src/tools/auth/DemoAuth.ts +2 -2
  150. package/src/tools/auth/PassphraseAuth.ts +2 -2
  151. package/src/tools/auth/clerk/index.ts +2 -2
  152. package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +1 -1
  153. package/src/tools/coValues/CoFieldInit.ts +20 -0
  154. package/src/tools/coValues/CoValueBase.ts +40 -60
  155. package/src/tools/coValues/account.ts +306 -232
  156. package/src/tools/coValues/coFeed.ts +185 -153
  157. package/src/tools/coValues/coList.ts +507 -334
  158. package/src/tools/coValues/coMap.ts +420 -286
  159. package/src/tools/coValues/coPlainText.ts +94 -110
  160. package/src/tools/coValues/deepLoading.ts +13 -13
  161. package/src/tools/coValues/group.ts +100 -114
  162. package/src/tools/coValues/inbox.ts +16 -14
  163. package/src/tools/coValues/interfaces.ts +49 -31
  164. package/src/tools/coValues/profile.ts +8 -6
  165. package/src/tools/coValues/request.ts +9 -9
  166. package/src/tools/coValues/schemaUnion.ts +11 -5
  167. package/src/tools/exports.ts +1 -1
  168. package/src/tools/implementation/ContextManager.ts +4 -4
  169. package/src/tools/implementation/anonymousJazzAgent.ts +2 -1
  170. package/src/tools/implementation/createContext.ts +1 -1
  171. package/src/tools/implementation/devtoolsFormatters.ts +9 -9
  172. package/src/tools/implementation/invites.ts +2 -2
  173. package/src/tools/implementation/schema.ts +7 -7
  174. package/src/tools/implementation/symbols.ts +3 -0
  175. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
  176. package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +11 -2
  177. package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +18 -7
  178. package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +17 -7
  179. package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +20 -11
  180. package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +19 -2
  181. package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +6 -0
  182. package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +6 -0
  183. package/src/tools/implementation/zodSchema/typeConverters/{CoFieldInit.ts → CoFieldSchemaInit.ts} +11 -11
  184. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +4 -4
  185. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +4 -4
  186. package/src/tools/implementation/zodSchema/zodCo.ts +47 -10
  187. package/src/tools/internal.ts +2 -1
  188. package/src/tools/lib/migration.ts +5 -5
  189. package/src/tools/subscribe/SubscriptionScope.ts +32 -24
  190. package/src/tools/subscribe/index.ts +4 -4
  191. package/src/tools/subscribe/utils.ts +11 -11
  192. package/src/tools/testing.ts +17 -13
  193. package/src/tools/tests/ContextManager.test.ts +68 -57
  194. package/src/tools/tests/PassphraseAuth.test.ts +2 -2
  195. package/src/tools/tests/account.test.ts +154 -74
  196. package/src/tools/tests/coDiscriminatedUnion.test-d.ts +12 -6
  197. package/src/tools/tests/coDiscriminatedUnion.test.ts +26 -17
  198. package/src/tools/tests/coFeed.test-d.ts +18 -17
  199. package/src/tools/tests/coFeed.test.ts +108 -97
  200. package/src/tools/tests/coList.test-d.ts +18 -23
  201. package/src/tools/tests/coList.test.ts +350 -165
  202. package/src/tools/tests/coMap.record.test-d.ts +9 -13
  203. package/src/tools/tests/coMap.record.test.ts +37 -23
  204. package/src/tools/tests/coMap.test-d.ts +43 -21
  205. package/src/tools/tests/coMap.test.ts +368 -182
  206. package/src/tools/tests/coOptional.test.ts +28 -13
  207. package/src/tools/tests/coPlainText.test.ts +15 -15
  208. package/src/tools/tests/createContext.test.ts +14 -14
  209. package/src/tools/tests/deepLoading.test.ts +95 -94
  210. package/src/tools/tests/exportImport.test.ts +61 -41
  211. package/src/tools/tests/groupsAndAccounts.test.ts +333 -116
  212. package/src/tools/tests/inbox.test.ts +22 -17
  213. package/src/tools/tests/interfaces.test.ts +12 -11
  214. package/src/tools/tests/invites.test.ts +6 -4
  215. package/src/tools/tests/load.test.ts +20 -18
  216. package/src/tools/tests/patterns/notifications.test.ts +6 -6
  217. package/src/tools/tests/patterns/quest.test.ts +3 -3
  218. package/src/tools/tests/patterns/requestToJoin.test.ts +22 -22
  219. package/src/tools/tests/request.test.ts +38 -39
  220. package/src/tools/tests/schemaUnion.test.ts +64 -10
  221. package/src/tools/tests/subscribe.test.ts +64 -64
  222. package/src/tools/tests/testing.test.ts +5 -9
  223. package/src/tools/tests/utils.ts +3 -3
  224. package/src/tools/tests/zod.test.ts +3 -3
  225. package/src/worker/index.ts +3 -3
  226. package/dist/chunk-SFP5PBPX.js.map +0 -1
  227. package/dist/media/chunk-E5J3WLQW.js.map +0 -1
  228. package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts.map +0 -1
@@ -12,7 +12,7 @@ import {
12
12
  runWithoutActiveAccount,
13
13
  setupJazzTestSync,
14
14
  } from "../testing.js";
15
- import { waitFor } from "./utils.js";
15
+ import { setupTwoNodes, waitFor } from "./utils.js";
16
16
 
17
17
  const Crypto = await WasmCrypto.create();
18
18
 
@@ -39,7 +39,7 @@ describe("Simple CoList operations", async () => {
39
39
  expect(list[0]).toBe("bread");
40
40
  expect(list[1]).toBe("butter");
41
41
  expect(list[2]).toBe("onion");
42
- expect(list._raw.asArray()).toEqual(["bread", "butter", "onion"]);
42
+ expect(list.$jazz.raw.asArray()).toEqual(["bread", "butter", "onion"]);
43
43
  expect(list.length).toBe(3);
44
44
  expect(list.map((item) => item.toUpperCase())).toEqual([
45
45
  "BREAD",
@@ -127,12 +127,12 @@ describe("Simple CoList operations", async () => {
127
127
  const list = TestList.create(["bread", "butter", "onion"], {
128
128
  owner: me,
129
129
  });
130
- list[1] = "margarine";
131
- expect(list._raw.asArray()).toEqual(["bread", "margarine", "onion"]);
130
+ list.$jazz.set(1, "margarine");
131
+ expect(list.$jazz.raw.asArray()).toEqual(["bread", "margarine", "onion"]);
132
132
  expect(list[1]).toBe("margarine");
133
133
  });
134
134
 
135
- test("assignment with ref", () => {
135
+ test("assignment with ref using CoValue", () => {
136
136
  const Ingredient = co.map({
137
137
  name: z.string(),
138
138
  });
@@ -147,9 +147,11 @@ describe("Simple CoList operations", async () => {
147
147
  ],
148
148
  { owner: me },
149
149
  );
150
+ const originalIngredient = recipe[1];
150
151
 
151
- recipe[1] = Ingredient.create({ name: "margarine" }, me);
152
+ recipe.$jazz.set(1, Ingredient.create({ name: "margarine" }, me));
152
153
  expect(recipe[1]?.name).toBe("margarine");
154
+ expect(recipe[1]?.$jazz.id).not.toBe(originalIngredient?.$jazz.id);
153
155
  });
154
156
 
155
157
  test("assign undefined on a required ref", () => {
@@ -169,7 +171,7 @@ describe("Simple CoList operations", async () => {
169
171
  );
170
172
 
171
173
  expect(() => {
172
- recipe[1] = undefined as unknown as Loaded<typeof Ingredient>;
174
+ recipe.$jazz.set(1, undefined as unknown as Loaded<typeof Ingredient>);
173
175
  }).toThrow("Cannot set required reference 1 to undefined");
174
176
 
175
177
  expect(recipe[1]?.name).toBe("butter");
@@ -191,54 +193,104 @@ describe("Simple CoList operations", async () => {
191
193
  { owner: me },
192
194
  );
193
195
 
194
- recipe[1] = undefined;
196
+ recipe.$jazz.set(1, undefined);
195
197
  expect(recipe[1]).toBe(undefined);
196
198
  });
197
199
 
198
- test("push", () => {
199
- const list = TestList.create(["bread", "butter", "onion"], {
200
- owner: me,
200
+ test("assignment with ref using JSON", () => {
201
+ const Ingredient = co.map({
202
+ name: z.string(),
201
203
  });
202
- list.push("cheese");
203
- expect(list[3]).toBe("cheese");
204
- expect(list._raw.asArray()).toEqual([
205
- "bread",
206
- "butter",
207
- "onion",
208
- "cheese",
209
- ]);
204
+
205
+ const Recipe = co.list(Ingredient);
206
+
207
+ const recipe = Recipe.create(
208
+ [{ name: "bread" }, { name: "butter" }, { name: "onion" }],
209
+ { owner: me },
210
+ );
211
+ const originalIngredient = recipe[1];
212
+
213
+ recipe.$jazz.set(1, { name: "margarine" });
214
+ expect(recipe[1]?.name).toBe("margarine");
215
+ expect(recipe[1]?.$jazz.id).not.toBe(originalIngredient?.$jazz.id);
210
216
  });
211
217
 
212
- test("unshift", () => {
213
- const list = TestList.create(["bread", "butter", "onion"], {
214
- owner: me,
218
+ describe("push", () => {
219
+ test("push into CoList of non-collaborative values", () => {
220
+ const list = TestList.create(["bread", "butter", "onion"], {
221
+ owner: me,
222
+ });
223
+ list.$jazz.push("cheese");
224
+ expect(list[3]).toBe("cheese");
225
+ expect(list.$jazz.raw.asArray()).toEqual([
226
+ "bread",
227
+ "butter",
228
+ "onion",
229
+ "cheese",
230
+ ]);
231
+ });
232
+
233
+ test("push CoValue into list of CoValues", () => {
234
+ const Schema = co.list(co.plainText());
235
+ const list = Schema.create(["bread", "butter", "onion"]);
236
+ list.$jazz.push(Schema.element.create("cheese"));
237
+ expect(list[3]?.toString()).toBe("cheese");
238
+ });
239
+
240
+ test("push JSON into list of CoValues", () => {
241
+ const Schema = co.list(co.plainText());
242
+ const list = Schema.create(["bread", "butter", "onion"]);
243
+ list.$jazz.push("cheese");
244
+ expect(list[3]?.toString()).toBe("cheese");
245
+ });
246
+ });
247
+
248
+ describe("unshift", () => {
249
+ test("add non-collaborative element at the beginning of the list", () => {
250
+ const list = TestList.create(["bread", "butter", "onion"], {
251
+ owner: me,
252
+ });
253
+ list.$jazz.unshift("lettuce");
254
+ expect(list[0]).toBe("lettuce");
255
+ expect(list.$jazz.raw.asArray()).toEqual([
256
+ "lettuce",
257
+ "bread",
258
+ "butter",
259
+ "onion",
260
+ ]);
261
+ });
262
+
263
+ test("add CoValue at the beginning of a CoValue CoList", () => {
264
+ const Schema = co.list(co.plainText());
265
+ const list = Schema.create(["bread", "butter", "onion"]);
266
+ list.$jazz.unshift(Schema.element.create("lettuce"));
267
+ expect(list[0]?.toString()).toBe("lettuce");
268
+ });
269
+
270
+ test("add JSON at the beginning of a CoValue CoList", () => {
271
+ const Schema = co.list(co.plainText());
272
+ const list = Schema.create(["bread", "butter", "onion"]);
273
+ list.$jazz.unshift("lettuce");
274
+ expect(list[0]?.toString()).toBe("lettuce");
215
275
  });
216
- list.unshift("lettuce");
217
- expect(list[0]).toBe("lettuce");
218
- expect(list._raw.asArray()).toEqual([
219
- "lettuce",
220
- "bread",
221
- "butter",
222
- "onion",
223
- ]);
224
276
  });
225
277
 
226
278
  test("pop", () => {
227
279
  const list = TestList.create(["bread", "butter", "onion"], {
228
280
  owner: me,
229
281
  });
230
- expect(list.pop()).toBe("onion");
282
+ expect(list.$jazz.pop()).toBe("onion");
231
283
  expect(list.length).toBe(2);
232
- expect(list._raw.asArray()).toEqual(["bread", "butter"]);
284
+ expect(list.$jazz.raw.asArray()).toEqual(["bread", "butter"]);
233
285
  });
234
286
 
235
287
  test("shift", () => {
236
288
  const list = TestList.create(["bread", "butter", "onion"], {
237
289
  owner: me,
238
290
  });
239
- expect(list.shift()).toBe("bread");
291
+ expect(list.$jazz.shift()).toBe("bread");
240
292
  expect(list.length).toBe(2);
241
- expect(list._raw.asArray()).toEqual(["butter", "onion"]);
293
+ expect(list.$jazz.raw.asArray()).toEqual(["butter", "onion"]);
242
294
  });
243
295
 
244
296
  describe("splice", () => {
@@ -246,9 +298,9 @@ describe("Simple CoList operations", async () => {
246
298
  const list = TestList.create(["bread", "butter", "onion"], {
247
299
  owner: me,
248
300
  });
249
- list.splice(1, 1, "salt", "pepper");
301
+ list.$jazz.splice(1, 1, "salt", "pepper");
250
302
  expect(list.length).toBe(4);
251
- expect(list._raw.asArray()).toEqual([
303
+ expect(list.$jazz.raw.asArray()).toEqual([
252
304
  "bread",
253
305
  "salt",
254
306
  "pepper",
@@ -260,9 +312,9 @@ describe("Simple CoList operations", async () => {
260
312
  const list = TestList.create(["bread", "butter", "onion"], {
261
313
  owner: me,
262
314
  });
263
- list.splice(0, 0, "salt", "pepper");
315
+ list.$jazz.splice(0, 0, "salt", "pepper");
264
316
  expect(list.length).toBe(5);
265
- expect(list._raw.asArray()).toEqual([
317
+ expect(list.$jazz.raw.asArray()).toEqual([
266
318
  "salt",
267
319
  "pepper",
268
320
  "bread",
@@ -275,9 +327,9 @@ describe("Simple CoList operations", async () => {
275
327
  const list = TestList.create(["bread", "butter", "onion"], {
276
328
  owner: me,
277
329
  });
278
- list.splice(1, 0, "salt", "pepper");
330
+ list.$jazz.splice(1, 0, "salt", "pepper");
279
331
  expect(list.length).toBe(5);
280
- expect(list._raw.asArray()).toEqual([
332
+ expect(list.$jazz.raw.asArray()).toEqual([
281
333
  "bread",
282
334
  "salt",
283
335
  "pepper",
@@ -290,9 +342,9 @@ describe("Simple CoList operations", async () => {
290
342
  const list = TestList.create(["bread", "butter", "onion"], {
291
343
  owner: me,
292
344
  });
293
- list.splice(2, 0, "salt", "pepper");
345
+ list.$jazz.splice(2, 0, "salt", "pepper");
294
346
  expect(list.length).toBe(5);
295
- expect(list._raw.asArray()).toEqual([
347
+ expect(list.$jazz.raw.asArray()).toEqual([
296
348
  "bread",
297
349
  "butter",
298
350
  "salt",
@@ -300,76 +352,117 @@ describe("Simple CoList operations", async () => {
300
352
  "onion",
301
353
  ]);
302
354
  });
303
- });
304
355
 
305
- test("sort", () => {
306
- const list = TestList.create(
307
- ["hedgehog", "giraffe", "iguana", "flamingo"],
308
- { owner: me },
309
- );
356
+ test("insert CoValue into a CoValue CoList", () => {
357
+ const Schema = co.list(co.plainText());
358
+ const list = Schema.create(["bread", "butter", "onion"]);
359
+ list.$jazz.splice(1, 0, Schema.element.create("lettuce"));
360
+ expect(list[1]?.toString()).toBe("lettuce");
361
+ });
310
362
 
311
- list.sort();
312
- expect(list._raw.asArray()).toEqual([
313
- "flamingo",
314
- "giraffe",
315
- "hedgehog",
316
- "iguana",
317
- ]);
318
-
319
- list.sort((a, b) => b.localeCompare(a));
320
- expect(list._raw.asArray()).toEqual([
321
- "iguana",
322
- "hedgehog",
323
- "giraffe",
324
- "flamingo",
325
- ]);
363
+ test("insert JSON into a CoValue CoList", () => {
364
+ const Schema = co.list(co.plainText());
365
+ const list = Schema.create(["bread", "butter", "onion"]);
366
+ list.$jazz.splice(1, 0, "lettuce");
367
+ expect(list[1]?.toString()).toBe("lettuce");
368
+ });
326
369
  });
327
370
 
328
- test("sort list of refs", async () => {
329
- const Message = co.map({
330
- text: z.string(),
371
+ describe("remove", () => {
372
+ describe("remove by index", () => {
373
+ test("remove one item", () => {
374
+ const list = TestList.create(["bread", "butter", "onion"]);
375
+
376
+ expect(list.$jazz.remove(1)).toEqual(["butter"]);
377
+ expect(list.$jazz.raw.asArray()).toEqual(["bread", "onion"]);
378
+ });
379
+
380
+ test("remove multiple items", () => {
381
+ const list = TestList.create(["bread", "butter", "onion"]);
382
+
383
+ expect(list.$jazz.remove(0, 2)).toEqual(["bread", "onion"]);
384
+ expect(list.$jazz.raw.asArray()).toEqual(["butter"]);
385
+ });
386
+
387
+ test("ignores out-of-bound indices", () => {
388
+ const list = TestList.create(["bread", "butter", "onion"]);
389
+
390
+ expect(list.$jazz.remove(4, -1, 1)).toEqual(["butter"]);
391
+ expect(list.$jazz.raw.asArray()).toEqual(["bread", "onion"]);
392
+ });
331
393
  });
332
394
 
333
- const Chat = co.list(Message);
395
+ describe("remove by predicate", () => {
396
+ test("removes elements matching the predicate", () => {
397
+ const list = TestList.create(["bread", "butter", "onion"]);
334
398
 
335
- const chat = Chat.create(
336
- [
337
- Message.create({ text: "world" }, { owner: me }),
338
- Message.create({ text: "hello" }, { owner: me }),
339
- ],
340
- { owner: me },
341
- );
399
+ expect(list.$jazz.remove((item) => item === "butter")).toEqual([
400
+ "butter",
401
+ ]);
402
+ expect(list.$jazz.raw.asArray()).toEqual(["bread", "onion"]);
403
+ });
342
404
 
343
- chat.sort((a, b) => a!.text.localeCompare(b!.text));
344
- expect(chat.map((m) => m!.text)).toEqual(["hello", "world"]);
405
+ test("the predicate is called with the item, index and the coList", () => {
406
+ const list = TestList.create(["bread", "butter", "onion"]);
345
407
 
346
- chat.push(Message.create({ text: "beans on toast" }, { owner: me }));
347
- chat.sort((a, b) => a!.text.localeCompare(b!.text));
348
- expect(chat.map((m) => m!.text)).toEqual([
349
- "beans on toast",
350
- "hello",
351
- "world",
352
- ]);
408
+ expect(
409
+ list.$jazz.remove(
410
+ (item, index, coList) => index > 0 && index < coList.length - 1,
411
+ ),
412
+ ).toEqual(["butter"]);
413
+ expect(list.$jazz.raw.asArray()).toEqual(["bread", "onion"]);
414
+ });
415
+ });
416
+
417
+ // CoListItem's type was being incorrectly inferred as nullable when using ensureLoaded
418
+ // on loaded CoLists. Keeping this test to ensure it doesn't regress.
419
+ test("removes elements from loaded CoLists", async () => {
420
+ const NestedList = co.list(co.map({ title: z.string() }));
421
+ const list = NestedList.create([
422
+ { title: "bread" },
423
+ { title: "butter" },
424
+ { title: "onion" },
425
+ ]);
426
+ const bread = list[0];
427
+ const butter = list[1];
428
+ const onion = list[2];
429
+
430
+ const shallowlyLoadedList = await NestedList.load(list.$jazz.id);
431
+ assert(shallowlyLoadedList);
432
+
433
+ const loadedList = await shallowlyLoadedList.$jazz.ensureLoaded({
434
+ resolve: { $each: true },
435
+ });
436
+
437
+ expect(
438
+ loadedList.$jazz.remove((item) => item.title === "butter"),
439
+ ).toEqual([butter]);
440
+ expect(shallowlyLoadedList[0]).toEqual(bread);
441
+ expect(shallowlyLoadedList[1]).toEqual(onion);
442
+ });
353
443
  });
354
444
 
355
- test("applyDiff", () => {
356
- const list = TestList.create(["bread", "butter", "onion"], {
357
- owner: me,
445
+ describe("retain", () => {
446
+ test("retains elements matching the predicate", () => {
447
+ const list = TestList.create(["bread", "butter", "onion"]);
448
+
449
+ expect(list.$jazz.retain((item) => item === "butter")).toEqual([
450
+ "bread",
451
+ "onion",
452
+ ]);
453
+ expect(list.$jazz.raw.asArray()).toEqual(["butter"]);
454
+ });
455
+
456
+ test("the predicate is called with the item, index and the coList", () => {
457
+ const list = TestList.create(["bread", "butter", "onion"]);
458
+
459
+ expect(
460
+ list.$jazz.retain(
461
+ (item, index, coList) => index > 0 && index < coList.length - 1,
462
+ ),
463
+ ).toEqual(["bread", "onion"]);
464
+ expect(list.$jazz.raw.asArray()).toEqual(["butter"]);
358
465
  });
359
- // replace
360
- list.applyDiff(["bread", "margarine", "onion"]);
361
- expect(list._raw.asArray()).toEqual(["bread", "margarine", "onion"]);
362
- // delete
363
- list.applyDiff(["bread", "onion"]);
364
- expect(list._raw.asArray()).toEqual(["bread", "onion"]);
365
- // insert multiple
366
- list.applyDiff(["bread", "margarine", "onion", "cheese"]);
367
- expect(list._raw.asArray()).toEqual([
368
- "bread",
369
- "margarine",
370
- "onion",
371
- "cheese",
372
- ]);
373
466
  });
374
467
 
375
468
  test("filter + assign to coMap", () => {
@@ -386,12 +479,12 @@ describe("Simple CoList operations", async () => {
386
479
  { owner: me },
387
480
  );
388
481
 
389
- expect(() => {
390
- // @ts-expect-error
391
- map.list = map.list?.filter((item) => item !== "butter");
392
- }).toThrow("Cannot set reference list to a non-CoValue. Got bread,onion");
482
+ map.$jazz.set(
483
+ "list",
484
+ map.list?.filter((item) => item !== "butter"),
485
+ );
393
486
 
394
- expect(map.list?._raw.asArray()).toEqual(["bread", "butter", "onion"]);
487
+ expect(map.list?.$jazz.raw.asArray()).toEqual(["bread", "onion"]);
395
488
  });
396
489
 
397
490
  test("filter + assign to CoList", () => {
@@ -406,12 +499,9 @@ describe("Simple CoList operations", async () => {
406
499
  { owner: me },
407
500
  );
408
501
 
409
- expect(() => {
410
- // @ts-expect-error
411
- list[0] = list[0]?.filter((item) => item !== "butter");
412
- }).toThrow("Cannot set reference 0 to a non-CoValue. Got bread,onion");
502
+ list.$jazz.set(0, list[0]?.filter((item) => item !== "butter") ?? []);
413
503
 
414
- expect(list[0]?._raw.asArray()).toEqual(["bread", "butter", "onion"]);
504
+ expect(list[0]?.$jazz.raw.asArray()).toEqual(["bread", "onion"]);
415
505
  });
416
506
  });
417
507
  });
@@ -422,52 +512,99 @@ describe("CoList applyDiff operations", async () => {
422
512
  const list = StringList.create(["a", "b", "c"], { owner: me });
423
513
 
424
514
  // Test adding items
425
- list.applyDiff(["a", "b", "c", "d", "e"]);
426
- expect(list._raw.asArray()).toEqual(["a", "b", "c", "d", "e"]);
515
+ list.$jazz.applyDiff(["a", "b", "c", "d", "e"]);
516
+ expect(list.$jazz.raw.asArray()).toEqual(["a", "b", "c", "d", "e"]);
427
517
 
428
518
  // Test removing items
429
- list.applyDiff(["a", "c", "e"]);
430
- expect(list._raw.asArray()).toEqual(["a", "c", "e"]);
519
+ list.$jazz.applyDiff(["a", "c", "e"]);
520
+ expect(list.$jazz.raw.asArray()).toEqual(["a", "c", "e"]);
431
521
 
432
522
  // Test replacing items
433
- list.applyDiff(["x", "y", "z"]);
434
- expect(list._raw.asArray()).toEqual(["x", "y", "z"]);
523
+ list.$jazz.applyDiff(["x", "y", "z"]);
524
+ expect(list.$jazz.raw.asArray()).toEqual(["x", "y", "z"]);
435
525
 
436
526
  // Test empty list
437
- list.applyDiff([]);
438
- expect(list._raw.asArray()).toEqual([]);
527
+ list.$jazz.applyDiff([]);
528
+ expect(list.$jazz.raw.asArray()).toEqual([]);
439
529
  });
440
530
 
441
- test("applyDiff with reference values", () => {
442
- const NestedItem = co.list(z.string());
443
- const RefList = co.list(NestedItem);
531
+ test("applyDiff with reference values using CoValues", () => {
532
+ const TicTacToeRow = co.list(z.string());
533
+ const TicTacToeBoard = co.list(TicTacToeRow);
444
534
 
445
- const item1 = NestedItem.create(["item1"], { owner: me });
446
- const item2 = NestedItem.create(["item2"], { owner: me });
447
- const item3 = NestedItem.create(["item3"], { owner: me });
448
- const item4 = NestedItem.create(["item4"], { owner: me });
535
+ const row1 = TicTacToeRow.create(["X", "O", ""], { owner: me });
536
+ const row2 = TicTacToeRow.create(["", "X", "O"], { owner: me });
537
+ const row3 = TicTacToeRow.create(["O", "O", ""], { owner: me });
538
+ const winningRow = TicTacToeRow.create(["O", "O", "X"], { owner: me });
449
539
 
450
- const list = RefList.create([item1, item2], { owner: me });
540
+ const list = TicTacToeBoard.create([row1, row2], { owner: me });
451
541
 
452
542
  // Test adding reference items
453
- list.applyDiff([item1, item2, item3]);
543
+ list.$jazz.applyDiff([row1, row2, row3]);
544
+ expect(list.length).toBe(3);
545
+ expect(list[2]?.toJSON()).toEqual(["O", "O", ""]);
546
+
547
+ // Test replacing reference items
548
+ list.$jazz.applyDiff([row1, row2, winningRow]);
454
549
  expect(list.length).toBe(3);
455
- expect(list[2]?.[0]).toBe("item3");
550
+ expect(list[2]?.toJSON()).toEqual(["O", "O", "X"]);
551
+ // Only elements with different $jazz.id are replaced
552
+ expect(list[0]?.$jazz.id).toBe(row1?.$jazz.id);
553
+ expect(list[1]?.$jazz.id).toBe(row2?.$jazz.id);
554
+ expect(list[2]?.$jazz.id).not.toBe(row3?.$jazz.id);
456
555
 
457
556
  // Test removing reference items
458
- list.applyDiff([item1, item3]);
557
+ list.$jazz.applyDiff([row1, row3]);
459
558
  expect(list.length).toBe(2);
460
- expect(list[0]?.[0]).toBe("item1");
461
- expect(list[1]?.[0]).toBe("item3");
559
+ expect(list[0]?.toJSON()).toEqual(["X", "O", ""]);
560
+ expect(list[0]?.$jazz.id).toBe(row1?.$jazz.id);
561
+ expect(list[1]?.toJSON()).toEqual(["O", "O", ""]);
562
+ expect(list[1]?.$jazz.id).not.toBe(row2?.$jazz.id);
563
+
564
+ // Test empty list
565
+ list.$jazz.applyDiff([]);
566
+ expect(list.$jazz.raw.asArray()).toEqual([]);
567
+ });
568
+
569
+ test("applyDiff with reference values using JSON", () => {
570
+ const TicTacToeRow = co.list(z.string());
571
+ const TicTacToeBoard = co.list(TicTacToeRow);
572
+
573
+ const row1 = ["X", "O", ""];
574
+ const row2 = ["", "X", "O"];
575
+ const row3 = ["O", "O", ""];
576
+ const winningRow = ["O", "O", "X"];
577
+
578
+ const list = TicTacToeBoard.create([row1, row2], { owner: me });
579
+ const originalRow1 = list[0];
580
+ const originalRow2 = list[1];
581
+ const originalRow3 = list[2];
582
+
583
+ // Test adding reference items
584
+ list.$jazz.applyDiff([row1, row2, row3]);
585
+ expect(list.length).toBe(3);
586
+ expect(list[2]?.toJSON()).toEqual(["O", "O", ""]);
462
587
 
463
588
  // Test replacing reference items
464
- list.applyDiff([item4]);
465
- expect(list.length).toBe(1);
466
- expect(list[0]?.[0]).toBe("item4");
589
+ list.$jazz.applyDiff([row1, row2, winningRow]);
590
+ expect(list.length).toBe(3);
591
+ expect(list[2]?.toJSON()).toEqual(["O", "O", "X"]);
592
+ // All elements are replaced because new JSON values are set
593
+ expect(list[0]?.$jazz.id).not.toBe(originalRow1?.$jazz.id);
594
+ expect(list[1]?.$jazz.id).not.toBe(originalRow2?.$jazz.id);
595
+ expect(list[2]?.$jazz.id).not.toBe(originalRow3?.$jazz.id);
596
+
597
+ // Test removing reference items
598
+ list.$jazz.applyDiff([row1, row3]);
599
+ expect(list.length).toBe(2);
600
+ expect(list[0]?.toJSON()).toEqual(["X", "O", ""]);
601
+ expect(list[0]?.$jazz.id).not.toBe(originalRow1?.$jazz.id);
602
+ expect(list[1]?.toJSON()).toEqual(["O", "O", ""]);
603
+ expect(list[1]?.$jazz.id).not.toBe(originalRow2?.$jazz.id);
467
604
 
468
605
  // Test empty list
469
- list.applyDiff([]);
470
- expect(list._raw.asArray()).toEqual([]);
606
+ list.$jazz.applyDiff([]);
607
+ expect(list.$jazz.raw.asArray()).toEqual([]);
471
608
  });
472
609
 
473
610
  test("applyDiff with refs + filter", () => {
@@ -483,9 +620,9 @@ describe("CoList applyDiff operations", async () => {
483
620
 
484
621
  const list = TestList.create([bread, butter, onion], me);
485
622
 
486
- list.applyDiff(list.filter((item) => item?.type !== "butter"));
623
+ list.$jazz.applyDiff(list.filter((item) => item?.type !== "butter"));
487
624
 
488
- expect(list._raw.asArray()).toEqual([bread.id, onion.id]);
625
+ expect(list.$jazz.raw.asArray()).toEqual([bread.$jazz.id, onion.$jazz.id]);
489
626
  });
490
627
 
491
628
  test("applyDiff with mixed operations", () => {
@@ -493,16 +630,16 @@ describe("CoList applyDiff operations", async () => {
493
630
  const list = StringList.create(["a", "b", "c", "d", "e"], { owner: me });
494
631
 
495
632
  // Test multiple operations at once
496
- list.applyDiff(["a", "x", "c", "y", "e"]);
497
- expect(list._raw.asArray()).toEqual(["a", "x", "c", "y", "e"]);
633
+ list.$jazz.applyDiff(["a", "x", "c", "y", "e"]);
634
+ expect(list.$jazz.raw.asArray()).toEqual(["a", "x", "c", "y", "e"]);
498
635
 
499
636
  // Test reordering
500
- list.applyDiff(["e", "c", "a", "y", "x"]);
501
- expect(list._raw.asArray()).toEqual(["e", "c", "a", "y", "x"]);
637
+ list.$jazz.applyDiff(["e", "c", "a", "y", "x"]);
638
+ expect(list.$jazz.raw.asArray()).toEqual(["e", "c", "a", "y", "x"]);
502
639
 
503
640
  // Test partial update
504
- list.applyDiff(["e", "c", "new", "y", "x"]);
505
- expect(list._raw.asArray()).toEqual(["e", "c", "new", "y", "x"]);
641
+ list.$jazz.applyDiff(["e", "c", "new", "y", "x"]);
642
+ expect(list.$jazz.raw.asArray()).toEqual(["e", "c", "new", "y", "x"]);
506
643
  });
507
644
  });
508
645
 
@@ -539,9 +676,57 @@ describe("CoList resolution", async () => {
539
676
 
540
677
  expect(list[0]?.[0]?.[0]).toBe("a");
541
678
  expect(list[0]?.[0]?.join(",")).toBe("a,b");
542
- expect(list[0]?.[0]?.id).toBeDefined();
679
+ expect(list[0]?.[0]?.$jazz.id).toBeDefined();
543
680
  expect(list[1]?.[0]?.[0]).toBe("c");
544
681
  });
682
+
683
+ test("accessing the value refs", async () => {
684
+ const Dog = co.map({
685
+ name: z.string(),
686
+ breed: z.string(),
687
+ });
688
+
689
+ const Pets = co.list(Dog);
690
+
691
+ const group = Group.create();
692
+ group.addMember("everyone", "writer");
693
+
694
+ const pets = Pets.create([{ name: "Rex", breed: "Labrador" }], group);
695
+
696
+ const userB = await createJazzTestAccount();
697
+ const loadedPets = await Pets.load(pets.$jazz.id, {
698
+ loadAs: userB,
699
+ });
700
+
701
+ assert(loadedPets);
702
+
703
+ const petReference = loadedPets.$jazz.refs[0];
704
+ expect(petReference).toBeDefined();
705
+ expect(petReference?.id).toBe(pets[0]?.$jazz.id);
706
+
707
+ const dog = await petReference?.load();
708
+
709
+ assert(dog);
710
+
711
+ expect(dog.name).toEqual("Rex");
712
+ });
713
+
714
+ test("waitForSync should resolve when the value is uploaded", async () => {
715
+ const TestList = co.list(z.number());
716
+
717
+ const { clientNode, serverNode, clientAccount } = await setupTwoNodes();
718
+
719
+ const list = TestList.create([1, 2, 3], { owner: clientAccount });
720
+
721
+ await list.$jazz.waitForSync({ timeout: 1000 });
722
+
723
+ // Killing the client node so the serverNode can't load the list from it
724
+ clientNode.gracefulShutdown();
725
+
726
+ const loadedMap = await serverNode.load(list.$jazz.raw.id);
727
+
728
+ expect(loadedMap).not.toBe("unavailable");
729
+ });
545
730
  });
546
731
 
547
732
  describe("CoList subscription", async () => {
@@ -561,7 +746,7 @@ describe("CoList subscription", async () => {
561
746
  const spy = vi.fn((list) => updates.push(list));
562
747
 
563
748
  TestList.subscribe(
564
- list.id,
749
+ list.$jazz.id,
565
750
  {
566
751
  resolve: {
567
752
  $each: true,
@@ -579,7 +764,7 @@ describe("CoList subscription", async () => {
579
764
  expect(updates[0]?.[0]?.name).toEqual("Item 1");
580
765
  expect(updates[0]?.[1]?.name).toEqual("Item 2");
581
766
 
582
- list[0]!.name = "Updated Item 1";
767
+ list[0]!.$jazz.set("name", "Updated Item 1");
583
768
 
584
769
  await waitFor(() => expect(spy).toHaveBeenCalledTimes(2));
585
770
 
@@ -604,7 +789,7 @@ describe("CoList subscription", async () => {
604
789
  const updates: Loaded<typeof TestList>[] = [];
605
790
  const spy = vi.fn((list) => updates.push(list));
606
791
 
607
- TestList.subscribe(list.id, {}, spy);
792
+ TestList.subscribe(list.$jazz.id, {}, spy);
608
793
 
609
794
  expect(spy).not.toHaveBeenCalled();
610
795
 
@@ -615,7 +800,7 @@ describe("CoList subscription", async () => {
615
800
  expect(updates[0]?.[0]?.name).toEqual("Item 1");
616
801
  expect(updates[0]?.[1]?.name).toEqual("Item 2");
617
802
 
618
- list[0]!.name = "Updated Item 1";
803
+ list[0]!.$jazz.set("name", "Updated Item 1");
619
804
 
620
805
  await waitFor(() => expect(spy).toHaveBeenCalledTimes(2));
621
806
 
@@ -642,7 +827,7 @@ describe("CoList subscription", async () => {
642
827
 
643
828
  subscribeToCoValue(
644
829
  coValueClassFromCoValueClassOrSchema(TestList),
645
- list.id,
830
+ list.$jazz.id,
646
831
  {
647
832
  syncResolution: true,
648
833
  loadAs: Account.getMe(),
@@ -658,7 +843,7 @@ describe("CoList subscription", async () => {
658
843
 
659
844
  expect(spy).toHaveBeenCalledTimes(1);
660
845
 
661
- list[0]!.name = "Updated Item 1";
846
+ list[0]!.$jazz.set("name", "Updated Item 1");
662
847
 
663
848
  expect(spy).toHaveBeenCalledTimes(2);
664
849
 
@@ -692,7 +877,7 @@ describe("CoList subscription", async () => {
692
877
  const spy = vi.fn((list) => updates.push(list));
693
878
 
694
879
  TestList.subscribe(
695
- list.id,
880
+ list.$jazz.id,
696
881
  {
697
882
  resolve: {
698
883
  $each: true,
@@ -711,7 +896,7 @@ describe("CoList subscription", async () => {
711
896
  expect(updates[0]?.[0]?.name).toEqual("Item 1");
712
897
  expect(updates[0]?.[1]?.name).toEqual("Item 2");
713
898
 
714
- list[0]!.name = "Updated Item 1";
899
+ list[0]!.$jazz.set("name", "Updated Item 1");
715
900
 
716
901
  await waitFor(() => expect(spy).toHaveBeenCalledTimes(2));
717
902
 
@@ -745,7 +930,7 @@ describe("CoList subscription", async () => {
745
930
  const userB = await createJazzTestAccount();
746
931
 
747
932
  TestList.subscribe(
748
- list.id,
933
+ list.$jazz.id,
749
934
  {
750
935
  loadAs: userB,
751
936
  },
@@ -761,7 +946,7 @@ describe("CoList subscription", async () => {
761
946
  expect(updates[0]?.[0]?.name).toEqual("Item 1");
762
947
  expect(updates[0]?.[1]?.name).toEqual("Item 2");
763
948
 
764
- list[0]!.name = "Updated Item 1";
949
+ list[0]!.$jazz.set("name", "Updated Item 1");
765
950
 
766
951
  await waitFor(() => expect(spy).toHaveBeenCalledTimes(2));
767
952
 
@@ -787,7 +972,7 @@ describe("CoList subscription", async () => {
787
972
  const spy = vi.fn((list) => updates.push(list));
788
973
 
789
974
  TestList.subscribe(
790
- list.id,
975
+ list.$jazz.id,
791
976
  {
792
977
  resolve: {
793
978
  $each: true,
@@ -805,7 +990,7 @@ describe("CoList subscription", async () => {
805
990
  expect(updates[0]?.[0]?.name).toEqual("Item 1");
806
991
  expect(updates[0]?.[1]?.name).toEqual("Item 2");
807
992
 
808
- list[0] = Item.create({ name: "New Item 1" });
993
+ list.$jazz.set(0, Item.create({ name: "New Item 1" }));
809
994
 
810
995
  await waitFor(() => expect(spy).toHaveBeenCalledTimes(2));
811
996
 
@@ -839,7 +1024,7 @@ describe("CoList subscription", async () => {
839
1024
  const userB = await createJazzTestAccount();
840
1025
 
841
1026
  TestList.subscribe(
842
- list.id,
1027
+ list.$jazz.id,
843
1028
  {
844
1029
  loadAs: userB,
845
1030
  resolve: {
@@ -860,7 +1045,7 @@ describe("CoList subscription", async () => {
860
1045
 
861
1046
  expect(spy).toHaveBeenCalledTimes(1);
862
1047
 
863
- list.push(Item.create({ name: "Item 3" }, group));
1048
+ list.$jazz.push(Item.create({ name: "Item 3" }, group));
864
1049
 
865
1050
  await waitFor(() => expect(spy).toHaveBeenCalledTimes(2));
866
1051
 
@@ -893,7 +1078,7 @@ describe("CoList subscription", async () => {
893
1078
 
894
1079
  const bob = await createJazzTestAccount();
895
1080
 
896
- const loadedPerson = await Person.load(person.id, {
1081
+ const loadedPerson = await Person.load(person.$jazz.id, {
897
1082
  resolve: { dogs: { $onError: null } },
898
1083
  loadAs: bob,
899
1084
  });
@@ -914,7 +1099,7 @@ describe("CoList unique methods", () => {
914
1099
  unique: "test-list",
915
1100
  });
916
1101
 
917
- const foundList = await ItemList.loadUnique("test-list", group.id);
1102
+ const foundList = await ItemList.loadUnique("test-list", group.$jazz.id);
918
1103
  expect(foundList).toEqual(originalList);
919
1104
  expect(foundList?.length).toBe(3);
920
1105
  expect(foundList?.[0]).toBe("item1");
@@ -924,7 +1109,7 @@ describe("CoList unique methods", () => {
924
1109
  const ItemList = co.list(z.string());
925
1110
  const group = Group.create();
926
1111
 
927
- const foundList = await ItemList.loadUnique("non-existent", group.id);
1112
+ const foundList = await ItemList.loadUnique("non-existent", group.$jazz.id);
928
1113
  expect(foundList).toBeNull();
929
1114
  });
930
1115
 
@@ -967,7 +1152,7 @@ describe("CoList unique methods", () => {
967
1152
  expect(result?.[1]).toBe("item2");
968
1153
  expect(result?.[2]).toBe("item3");
969
1154
 
970
- expect(result?._owner).toEqual(account);
1155
+ expect(result?.$jazz.owner).toEqual(account);
971
1156
  });
972
1157
 
973
1158
  test("upsertUnique updates existing list", async () => {
@@ -1063,8 +1248,8 @@ describe("CoList unique methods", () => {
1063
1248
  unique: "find-test",
1064
1249
  });
1065
1250
 
1066
- const foundId = ItemList.findUnique("find-test", group.id);
1067
- expect(foundId).toBe(originalList.id);
1251
+ const foundId = ItemList.findUnique("find-test", group.$jazz.id);
1252
+ expect(foundId).toBe(originalList.$jazz.id);
1068
1253
  });
1069
1254
 
1070
1255
  test("upsertUnique with resolve options", async () => {