jazz-tools 0.11.7 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +23 -0
- package/dist/auth/DemoAuth.d.ts.map +1 -1
- package/dist/auth/PassphraseAuth.d.ts.map +1 -1
- package/dist/{chunk-HH3Z4JSB.js → chunk-QJNU65NK.js} +414 -275
- package/dist/chunk-QJNU65NK.js.map +1 -0
- package/dist/coValues/account.d.ts +15 -17
- package/dist/coValues/account.d.ts.map +1 -1
- package/dist/coValues/coFeed.d.ts +23 -18
- package/dist/coValues/coFeed.d.ts.map +1 -1
- package/dist/coValues/coList.d.ts +14 -7
- package/dist/coValues/coList.d.ts.map +1 -1
- package/dist/coValues/coMap.d.ts +36 -33
- package/dist/coValues/coMap.d.ts.map +1 -1
- package/dist/coValues/coPlainText.d.ts +7 -5
- package/dist/coValues/coPlainText.d.ts.map +1 -1
- package/dist/coValues/deepLoading.d.ts +36 -19
- package/dist/coValues/deepLoading.d.ts.map +1 -1
- package/dist/coValues/group.d.ts +14 -7
- package/dist/coValues/group.d.ts.map +1 -1
- package/dist/coValues/inbox.d.ts.map +1 -1
- package/dist/coValues/interfaces.d.ts +45 -11
- package/dist/coValues/interfaces.d.ts.map +1 -1
- package/dist/exports.d.ts +1 -1
- package/dist/exports.d.ts.map +1 -1
- package/dist/implementation/refs.d.ts +3 -0
- package/dist/implementation/refs.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +4 -2
- package/dist/testing.js.map +1 -1
- package/package.json +2 -2
- package/src/auth/DemoAuth.ts +3 -1
- package/src/auth/PassphraseAuth.ts +3 -1
- package/src/coValues/account.ts +43 -49
- package/src/coValues/coFeed.ts +74 -146
- package/src/coValues/coList.ts +47 -54
- package/src/coValues/coMap.ts +47 -54
- package/src/coValues/coPlainText.ts +23 -40
- package/src/coValues/deepLoading.ts +233 -102
- package/src/coValues/group.ts +44 -54
- package/src/coValues/inbox.ts +3 -6
- package/src/coValues/interfaces.ts +216 -105
- package/src/exports.ts +7 -1
- package/src/implementation/refs.ts +45 -7
- package/src/testing.ts +4 -1
- package/src/tests/ContextManager.test.ts +20 -6
- package/src/tests/PassphraseAuth.test.ts +3 -1
- package/src/tests/account.test.ts +26 -2
- package/src/tests/coFeed.test.ts +26 -19
- package/src/tests/coList.test.ts +18 -18
- package/src/tests/coMap.test.ts +67 -19
- package/src/tests/coPlainText.test.ts +8 -4
- package/src/tests/coRichText.test.ts +10 -8
- package/src/tests/deepLoading.test.ts +321 -80
- package/src/tests/groupsAndAccounts.test.ts +10 -12
- package/src/tests/inbox.test.ts +1 -1
- package/src/tests/schemaUnion.test.ts +8 -18
- package/src/tests/subscribe.test.ts +52 -33
- package/src/tests/testing.test.ts +1 -1
- package/dist/chunk-HH3Z4JSB.js.map +0 -1
@@ -18,8 +18,8 @@ import {
|
|
18
18
|
cojsonInternals,
|
19
19
|
} from "../index.js";
|
20
20
|
import {
|
21
|
-
type DepthsIn,
|
22
21
|
ID,
|
22
|
+
Resolved,
|
23
23
|
createCoValueObservable,
|
24
24
|
subscribeToCoValue,
|
25
25
|
} from "../internal.js";
|
@@ -73,8 +73,7 @@ describe("subscribeToCoValue", () => {
|
|
73
73
|
const unsubscribe = subscribeToCoValue(
|
74
74
|
ChatRoom,
|
75
75
|
chatRoom.id,
|
76
|
-
meOnSecondPeer,
|
77
|
-
{},
|
76
|
+
{ loadAs: meOnSecondPeer },
|
78
77
|
updateFn,
|
79
78
|
);
|
80
79
|
|
@@ -134,9 +133,11 @@ describe("subscribeToCoValue", () => {
|
|
134
133
|
const unsubscribe = subscribeToCoValue(
|
135
134
|
ChatRoom,
|
136
135
|
chatRoom.id,
|
137
|
-
meOnSecondPeer,
|
138
136
|
{
|
139
|
-
|
137
|
+
loadAs: meOnSecondPeer,
|
138
|
+
resolve: {
|
139
|
+
messages: true,
|
140
|
+
},
|
140
141
|
},
|
141
142
|
updateFn,
|
142
143
|
);
|
@@ -164,16 +165,20 @@ describe("subscribeToCoValue", () => {
|
|
164
165
|
const chatRoom = createChatRoom(me, "General");
|
165
166
|
const updateFn = vi.fn();
|
166
167
|
|
167
|
-
const { messages } = await chatRoom.ensureLoaded({
|
168
|
+
const { messages } = await chatRoom.ensureLoaded({
|
169
|
+
resolve: { messages: { $each: true } },
|
170
|
+
});
|
168
171
|
|
169
172
|
messages.push(createMessage(me, "Hello"));
|
170
173
|
|
171
174
|
const unsubscribe = subscribeToCoValue(
|
172
175
|
ChatRoom,
|
173
176
|
chatRoom.id,
|
174
|
-
meOnSecondPeer,
|
175
177
|
{
|
176
|
-
|
178
|
+
loadAs: meOnSecondPeer,
|
179
|
+
resolve: {
|
180
|
+
messages: { $each: true },
|
181
|
+
},
|
177
182
|
},
|
178
183
|
updateFn,
|
179
184
|
);
|
@@ -212,9 +217,13 @@ describe("subscribeToCoValue", () => {
|
|
212
217
|
const unsubscribe = subscribeToCoValue(
|
213
218
|
ChatRoom,
|
214
219
|
chatRoom.id,
|
215
|
-
meOnSecondPeer,
|
216
220
|
{
|
217
|
-
|
221
|
+
loadAs: meOnSecondPeer,
|
222
|
+
resolve: {
|
223
|
+
messages: {
|
224
|
+
$each: true,
|
225
|
+
},
|
226
|
+
},
|
218
227
|
},
|
219
228
|
updateFn,
|
220
229
|
);
|
@@ -257,13 +266,15 @@ describe("subscribeToCoValue", () => {
|
|
257
266
|
const unsubscribe = subscribeToCoValue(
|
258
267
|
ChatRoom,
|
259
268
|
chatRoom.id,
|
260
|
-
meOnSecondPeer,
|
261
269
|
{
|
262
|
-
|
263
|
-
|
264
|
-
|
270
|
+
loadAs: meOnSecondPeer,
|
271
|
+
resolve: {
|
272
|
+
messages: {
|
273
|
+
$each: {
|
274
|
+
reactions: true,
|
275
|
+
},
|
265
276
|
},
|
266
|
-
|
277
|
+
},
|
267
278
|
},
|
268
279
|
updateFn,
|
269
280
|
);
|
@@ -323,13 +334,15 @@ describe("subscribeToCoValue", () => {
|
|
323
334
|
const unsubscribe = subscribeToCoValue(
|
324
335
|
ChatRoom,
|
325
336
|
chatRoom.id,
|
326
|
-
meOnSecondPeer,
|
327
337
|
{
|
328
|
-
|
329
|
-
|
330
|
-
|
338
|
+
loadAs: meOnSecondPeer,
|
339
|
+
resolve: {
|
340
|
+
messages: {
|
341
|
+
$each: {
|
342
|
+
reactions: true,
|
343
|
+
},
|
331
344
|
},
|
332
|
-
|
345
|
+
},
|
333
346
|
},
|
334
347
|
updateFn,
|
335
348
|
);
|
@@ -385,11 +398,13 @@ describe("subscribeToCoValue", () => {
|
|
385
398
|
const unsubscribe = subscribeToCoValue(
|
386
399
|
TestList,
|
387
400
|
list.id,
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
401
|
+
{
|
402
|
+
loadAs: account,
|
403
|
+
resolve: {
|
404
|
+
$each: true,
|
405
|
+
},
|
392
406
|
},
|
407
|
+
updateFn,
|
393
408
|
);
|
394
409
|
|
395
410
|
onTestFinished(unsubscribe);
|
@@ -422,14 +437,15 @@ describe("createCoValueObservable", () => {
|
|
422
437
|
it("should update currentValue when subscribed", async () => {
|
423
438
|
const { me, meOnSecondPeer } = await setupAccount();
|
424
439
|
const testMap = createTestMap(me);
|
425
|
-
const observable = createCoValueObservable
|
440
|
+
const observable = createCoValueObservable();
|
426
441
|
const mockListener = vi.fn();
|
427
442
|
|
428
443
|
const unsubscribe = observable.subscribe(
|
429
444
|
TestMap,
|
430
445
|
testMap.id,
|
431
|
-
|
432
|
-
|
446
|
+
{
|
447
|
+
loadAs: meOnSecondPeer,
|
448
|
+
},
|
433
449
|
() => {
|
434
450
|
mockListener();
|
435
451
|
},
|
@@ -450,14 +466,15 @@ describe("createCoValueObservable", () => {
|
|
450
466
|
it("should reset to undefined after unsubscribe", async () => {
|
451
467
|
const { me, meOnSecondPeer } = await setupAccount();
|
452
468
|
const testMap = createTestMap(me);
|
453
|
-
const observable = createCoValueObservable
|
469
|
+
const observable = createCoValueObservable();
|
454
470
|
const mockListener = vi.fn();
|
455
471
|
|
456
472
|
const unsubscribe = observable.subscribe(
|
457
473
|
TestMap,
|
458
474
|
testMap.id,
|
459
|
-
|
460
|
-
|
475
|
+
{
|
476
|
+
loadAs: meOnSecondPeer,
|
477
|
+
},
|
461
478
|
() => {
|
462
479
|
mockListener();
|
463
480
|
},
|
@@ -472,13 +489,15 @@ describe("createCoValueObservable", () => {
|
|
472
489
|
|
473
490
|
it("should return null if the coValue is not found", async () => {
|
474
491
|
const { meOnSecondPeer } = await setupAccount();
|
475
|
-
const observable = createCoValueObservable<
|
492
|
+
const observable = createCoValueObservable<
|
493
|
+
TestMap,
|
494
|
+
Resolved<TestMap, {}>
|
495
|
+
>();
|
476
496
|
|
477
497
|
const unsubscribe = observable.subscribe(
|
478
498
|
TestMap,
|
479
499
|
"co_z123" as ID<TestMap>,
|
480
|
-
meOnSecondPeer,
|
481
|
-
{},
|
500
|
+
{ loadAs: meOnSecondPeer },
|
482
501
|
() => {},
|
483
502
|
);
|
484
503
|
|
@@ -19,7 +19,7 @@ describe("Jazz Test Sync", () => {
|
|
19
19
|
map._raw.set("test", "value");
|
20
20
|
|
21
21
|
// Verify account2 can see the group
|
22
|
-
const loadedMap = await CoMap.load(map.id, account2
|
22
|
+
const loadedMap = await CoMap.load(map.id, { loadAs: account2 });
|
23
23
|
expect(loadedMap).toBeDefined();
|
24
24
|
expect(loadedMap?._raw.get("test")).toBe("value");
|
25
25
|
});
|