jazz-tools 0.13.16 → 0.13.18
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 +19 -0
- package/dist/{chunk-GIZWJXSR.js → chunk-ITSHLDQB.js} +731 -600
- package/dist/chunk-ITSHLDQB.js.map +1 -0
- package/dist/coValues/account.d.ts +5 -4
- package/dist/coValues/account.d.ts.map +1 -1
- package/dist/coValues/coFeed.d.ts +3 -3
- package/dist/coValues/coFeed.d.ts.map +1 -1
- package/dist/coValues/coList.d.ts +1 -0
- package/dist/coValues/coList.d.ts.map +1 -1
- package/dist/coValues/coMap.d.ts +4 -2
- package/dist/coValues/coMap.d.ts.map +1 -1
- package/dist/coValues/coPlainText.d.ts +2 -2
- package/dist/coValues/coPlainText.d.ts.map +1 -1
- package/dist/coValues/deepLoading.d.ts +1 -9
- package/dist/coValues/deepLoading.d.ts.map +1 -1
- package/dist/coValues/extensions/imageDef.d.ts.map +1 -1
- package/dist/coValues/group.d.ts.map +1 -1
- package/dist/coValues/inbox.d.ts.map +1 -1
- package/dist/coValues/interfaces.d.ts +4 -1
- package/dist/coValues/interfaces.d.ts.map +1 -1
- package/dist/implementation/createContext.d.ts.map +1 -1
- package/dist/implementation/refs.d.ts +5 -10
- package/dist/implementation/refs.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/subscribe/CoValueCoreSubscription.d.ts +14 -0
- package/dist/subscribe/CoValueCoreSubscription.d.ts.map +1 -0
- package/dist/subscribe/JazzError.d.ts +16 -0
- package/dist/subscribe/JazzError.d.ts.map +1 -0
- package/dist/subscribe/SubscriptionScope.d.ts +42 -0
- package/dist/subscribe/SubscriptionScope.d.ts.map +1 -0
- package/dist/subscribe/index.d.ts +21 -0
- package/dist/subscribe/index.d.ts.map +1 -0
- package/dist/subscribe/types.d.ts +12 -0
- package/dist/subscribe/types.d.ts.map +1 -0
- package/dist/subscribe/utils.d.ts +10 -0
- package/dist/subscribe/utils.d.ts.map +1 -0
- package/dist/testing.js +2 -2
- package/dist/testing.js.map +1 -1
- package/dist/tests/coMap.record.test.d.ts +2 -0
- package/dist/tests/coMap.record.test.d.ts.map +1 -0
- package/dist/tests/utils.d.ts +2 -2
- package/dist/tests/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/coValues/account.ts +43 -31
- package/src/coValues/coFeed.ts +28 -13
- package/src/coValues/coList.ts +13 -17
- package/src/coValues/coMap.ts +72 -80
- package/src/coValues/coPlainText.ts +13 -2
- package/src/coValues/deepLoading.ts +4 -277
- package/src/coValues/extensions/imageDef.ts +1 -7
- package/src/coValues/group.ts +7 -6
- package/src/coValues/inbox.ts +4 -11
- package/src/coValues/interfaces.ts +54 -111
- package/src/implementation/createContext.ts +3 -4
- package/src/implementation/invites.ts +2 -2
- package/src/implementation/refs.ts +30 -121
- package/src/internal.ts +1 -2
- package/src/subscribe/CoValueCoreSubscription.ts +71 -0
- package/src/subscribe/JazzError.ts +48 -0
- package/src/subscribe/SubscriptionScope.ts +523 -0
- package/src/subscribe/index.ts +82 -0
- package/src/subscribe/types.ts +7 -0
- package/src/subscribe/utils.ts +36 -0
- package/src/testing.ts +1 -1
- package/src/tests/ContextManager.test.ts +13 -9
- package/src/tests/coFeed.test.ts +104 -4
- package/src/tests/coList.test.ts +304 -115
- package/src/tests/coMap.record.test.ts +325 -0
- package/src/tests/coMap.test.ts +718 -645
- package/src/tests/coPlainText.test.ts +2 -2
- package/src/tests/createContext.test.ts +8 -8
- package/src/tests/deepLoading.test.ts +8 -34
- package/src/tests/groupsAndAccounts.test.ts +6 -4
- package/src/tests/subscribe.test.ts +357 -42
- package/src/tests/utils.ts +8 -6
- package/tsconfig.json +2 -1
- package/dist/chunk-GIZWJXSR.js.map +0 -1
- package/dist/implementation/subscriptionScope.d.ts +0 -34
- package/dist/implementation/subscriptionScope.d.ts.map +0 -1
- package/src/implementation/subscriptionScope.ts +0 -165
@@ -113,7 +113,7 @@ describe("ContextManager", () => {
|
|
113
113
|
|
114
114
|
const credentials = {
|
115
115
|
accountID: account.id,
|
116
|
-
accountSecret: account._raw.core.node.
|
116
|
+
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
117
117
|
provider: "test",
|
118
118
|
};
|
119
119
|
|
@@ -130,7 +130,7 @@ describe("ContextManager", () => {
|
|
130
130
|
|
131
131
|
const credentials = {
|
132
132
|
accountID: account.id,
|
133
|
-
accountSecret: account._raw.core.node.
|
133
|
+
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
134
134
|
provider: "test",
|
135
135
|
};
|
136
136
|
|
@@ -193,7 +193,7 @@ describe("ContextManager", () => {
|
|
193
193
|
// Authenticate with credentials
|
194
194
|
await manager.authenticate({
|
195
195
|
accountID: account.id,
|
196
|
-
accountSecret: account._raw.core.node.
|
196
|
+
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
197
197
|
provider: "test",
|
198
198
|
});
|
199
199
|
|
@@ -207,7 +207,7 @@ describe("ContextManager", () => {
|
|
207
207
|
|
208
208
|
await manager.getAuthSecretStorage().set({
|
209
209
|
accountID: account.id,
|
210
|
-
accountSecret: account._raw.core.node.
|
210
|
+
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
211
211
|
provider: "test",
|
212
212
|
});
|
213
213
|
|
@@ -217,7 +217,7 @@ describe("ContextManager", () => {
|
|
217
217
|
// Authenticate with same credentials
|
218
218
|
await manager.authenticate({
|
219
219
|
accountID: account.id,
|
220
|
-
accountSecret: account._raw.core.node.
|
220
|
+
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
221
221
|
provider: "test",
|
222
222
|
});
|
223
223
|
|
@@ -253,9 +253,11 @@ describe("ContextManager", () => {
|
|
253
253
|
customManager.getCurrentValue() as JazzAuthContext<CustomAccount>
|
254
254
|
).me;
|
255
255
|
|
256
|
+
console.log("before", account._refs.root?.id);
|
257
|
+
|
256
258
|
await customManager.authenticate({
|
257
259
|
accountID: account.id,
|
258
|
-
accountSecret: account._raw.core.node.
|
260
|
+
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
259
261
|
provider: "test",
|
260
262
|
});
|
261
263
|
|
@@ -263,6 +265,8 @@ describe("ContextManager", () => {
|
|
263
265
|
resolve: { root: true },
|
264
266
|
});
|
265
267
|
|
268
|
+
console.log("after", me._refs.root?.id);
|
269
|
+
|
266
270
|
expect(me.root.id).toBe(lastRootId);
|
267
271
|
});
|
268
272
|
|
@@ -299,7 +303,7 @@ describe("ContextManager", () => {
|
|
299
303
|
|
300
304
|
await customManager.authenticate({
|
301
305
|
accountID: account.id,
|
302
|
-
accountSecret: account._raw.core.node.
|
306
|
+
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
303
307
|
provider: "test",
|
304
308
|
});
|
305
309
|
|
@@ -365,7 +369,7 @@ describe("ContextManager", () => {
|
|
365
369
|
|
366
370
|
await customManager.authenticate({
|
367
371
|
accountID: account.id,
|
368
|
-
accountSecret: account._raw.core.node.
|
372
|
+
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
369
373
|
provider: "test",
|
370
374
|
});
|
371
375
|
|
@@ -408,7 +412,7 @@ describe("ContextManager", () => {
|
|
408
412
|
|
409
413
|
await manager.getAuthSecretStorage().set({
|
410
414
|
accountID: account.id,
|
411
|
-
accountSecret: account._raw.core.node.
|
415
|
+
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
412
416
|
provider: "test",
|
413
417
|
});
|
414
418
|
|
package/src/tests/coFeed.test.ts
CHANGED
@@ -117,7 +117,7 @@ describe("CoFeed resolution", async () => {
|
|
117
117
|
await createJazzContextFromExistingCredentials({
|
118
118
|
credentials: {
|
119
119
|
accountID: me.id,
|
120
|
-
secret: me._raw.agentSecret,
|
120
|
+
secret: me._raw.core.node.getCurrentAgent().agentSecret,
|
121
121
|
},
|
122
122
|
sessionProvider: randomSessionProvider,
|
123
123
|
peersToLoadFrom: [initialAsPeer],
|
@@ -203,7 +203,7 @@ describe("CoFeed resolution", async () => {
|
|
203
203
|
await createJazzContextFromExistingCredentials({
|
204
204
|
credentials: {
|
205
205
|
accountID: me.id,
|
206
|
-
secret: me._raw.agentSecret,
|
206
|
+
secret: me._raw.core.node.getCurrentAgent().agentSecret,
|
207
207
|
},
|
208
208
|
sessionProvider: randomSessionProvider,
|
209
209
|
peersToLoadFrom: [initialAsPeer],
|
@@ -257,6 +257,50 @@ describe("CoFeed resolution", async () => {
|
|
257
257
|
const update6 = (await queue.next()).value;
|
258
258
|
expect(update6[me.id]?.value?.[me.id]?.value?.[me.id]?.value).toBe("jam");
|
259
259
|
});
|
260
|
+
|
261
|
+
test("Subscription without options", async () => {
|
262
|
+
const { me, stream } = await initNodeAndStream();
|
263
|
+
|
264
|
+
const [initialAsPeer, secondAsPeer] = connectedPeers("initial", "second", {
|
265
|
+
peer1role: "server",
|
266
|
+
peer2role: "client",
|
267
|
+
});
|
268
|
+
if (!isControlledAccount(me)) {
|
269
|
+
throw "me is not a controlled account";
|
270
|
+
}
|
271
|
+
me._raw.core.node.syncManager.addPeer(secondAsPeer);
|
272
|
+
|
273
|
+
await createJazzContextFromExistingCredentials({
|
274
|
+
credentials: {
|
275
|
+
accountID: me.id,
|
276
|
+
secret: me._raw.core.node.getCurrentAgent().agentSecret,
|
277
|
+
},
|
278
|
+
sessionProvider: randomSessionProvider,
|
279
|
+
peersToLoadFrom: [initialAsPeer],
|
280
|
+
crypto: Crypto,
|
281
|
+
});
|
282
|
+
|
283
|
+
const queue = new cojsonInternals.Channel();
|
284
|
+
|
285
|
+
TestStream.subscribe(stream.id, (subscribedStream) => {
|
286
|
+
void queue.push(subscribedStream);
|
287
|
+
});
|
288
|
+
|
289
|
+
const update1 = (await queue.next()).value;
|
290
|
+
expect(update1[me.id]?.value).toEqual(null);
|
291
|
+
|
292
|
+
const update2 = (await queue.next()).value;
|
293
|
+
expect(update2[me.id]?.value?.[me.id]?.value).toEqual(null);
|
294
|
+
|
295
|
+
const update3 = (await queue.next()).value;
|
296
|
+
expect(update3[me.id]?.value?.[me.id]?.value).toBeDefined();
|
297
|
+
expect(update3[me.id]?.value?.[me.id]?.value?.[me.id]?.value).toBe("milk");
|
298
|
+
|
299
|
+
update3[me.id]!.value![me.id]!.value!.push("bread");
|
300
|
+
|
301
|
+
const update4 = (await queue.next()).value;
|
302
|
+
expect(update4[me.id]?.value?.[me.id]?.value?.[me.id]?.value).toBe("bread");
|
303
|
+
});
|
260
304
|
});
|
261
305
|
|
262
306
|
describe("Simple FileStream operations", async () => {
|
@@ -327,7 +371,7 @@ describe("FileStream loading & Subscription", async () => {
|
|
327
371
|
await createJazzContextFromExistingCredentials({
|
328
372
|
credentials: {
|
329
373
|
accountID: me.id,
|
330
|
-
secret: me._raw.agentSecret,
|
374
|
+
secret: me._raw.core.node.getCurrentAgent().agentSecret,
|
331
375
|
},
|
332
376
|
sessionProvider: randomSessionProvider,
|
333
377
|
peersToLoadFrom: [initialAsPeer],
|
@@ -361,7 +405,7 @@ describe("FileStream loading & Subscription", async () => {
|
|
361
405
|
await createJazzContextFromExistingCredentials({
|
362
406
|
credentials: {
|
363
407
|
accountID: me.id,
|
364
|
-
secret: me._raw.agentSecret,
|
408
|
+
secret: me._raw.core.node.getCurrentAgent().agentSecret,
|
365
409
|
},
|
366
410
|
sessionProvider: randomSessionProvider,
|
367
411
|
peersToLoadFrom: [initialAsPeer],
|
@@ -425,6 +469,62 @@ describe("FileStream loading & Subscription", async () => {
|
|
425
469
|
finished: true,
|
426
470
|
});
|
427
471
|
});
|
472
|
+
|
473
|
+
test("Subscription without options", async () => {
|
474
|
+
const { me } = await initNodeAndStream();
|
475
|
+
const stream = FileStream.create({ owner: me });
|
476
|
+
|
477
|
+
const [initialAsPeer, secondAsPeer] = connectedPeers("initial", "second", {
|
478
|
+
peer1role: "server",
|
479
|
+
peer2role: "client",
|
480
|
+
});
|
481
|
+
me._raw.core.node.syncManager.addPeer(secondAsPeer);
|
482
|
+
if (!isControlledAccount(me)) {
|
483
|
+
throw "me is not a controlled account";
|
484
|
+
}
|
485
|
+
await createJazzContextFromExistingCredentials({
|
486
|
+
credentials: {
|
487
|
+
accountID: me.id,
|
488
|
+
secret: me._raw.core.node.getCurrentAgent().agentSecret,
|
489
|
+
},
|
490
|
+
sessionProvider: randomSessionProvider,
|
491
|
+
peersToLoadFrom: [initialAsPeer],
|
492
|
+
crypto: Crypto,
|
493
|
+
});
|
494
|
+
|
495
|
+
const queue = new cojsonInternals.Channel();
|
496
|
+
|
497
|
+
FileStream.subscribe(stream.id, (subscribedStream) => {
|
498
|
+
void queue.push(subscribedStream);
|
499
|
+
});
|
500
|
+
|
501
|
+
// Initial state
|
502
|
+
const update1 = (await queue.next()).value;
|
503
|
+
expect(update1.getChunks()).toBe(undefined);
|
504
|
+
|
505
|
+
// Start the stream
|
506
|
+
stream.start({ mimeType: "text/plain" });
|
507
|
+
const update2 = (await queue.next()).value;
|
508
|
+
expect(update2.getChunks({ allowUnfinished: true })).toMatchObject({
|
509
|
+
mimeType: "text/plain",
|
510
|
+
finished: false,
|
511
|
+
});
|
512
|
+
|
513
|
+
// Push a chunk
|
514
|
+
stream.push(new Uint8Array([1, 2, 3]));
|
515
|
+
const update3 = (await queue.next()).value;
|
516
|
+
expect(update3.getChunks({ allowUnfinished: true })?.chunks).toHaveLength(
|
517
|
+
1,
|
518
|
+
);
|
519
|
+
expect(update3.getChunks({ allowUnfinished: true })?.chunks?.[0]).toEqual(
|
520
|
+
new Uint8Array([1, 2, 3]),
|
521
|
+
);
|
522
|
+
|
523
|
+
// End the stream
|
524
|
+
stream.end();
|
525
|
+
const update4 = (await queue.next()).value;
|
526
|
+
expect(update4.getChunks()?.finished).toBe(true);
|
527
|
+
});
|
428
528
|
});
|
429
529
|
|
430
530
|
describe("FileStream.loadAsBlob", async () => {
|