jazz-tools 0.13.17 → 0.13.19

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 (82) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/CHANGELOG.md +17 -0
  3. package/dist/{chunk-PYBQOYML.js → chunk-4HBHY4I7.js} +735 -595
  4. package/dist/chunk-4HBHY4I7.js.map +1 -0
  5. package/dist/coValues/account.d.ts +5 -4
  6. package/dist/coValues/account.d.ts.map +1 -1
  7. package/dist/coValues/coFeed.d.ts +1 -0
  8. package/dist/coValues/coFeed.d.ts.map +1 -1
  9. package/dist/coValues/coList.d.ts +1 -0
  10. package/dist/coValues/coList.d.ts.map +1 -1
  11. package/dist/coValues/coMap.d.ts +4 -2
  12. package/dist/coValues/coMap.d.ts.map +1 -1
  13. package/dist/coValues/coPlainText.d.ts +2 -2
  14. package/dist/coValues/coPlainText.d.ts.map +1 -1
  15. package/dist/coValues/deepLoading.d.ts +1 -9
  16. package/dist/coValues/deepLoading.d.ts.map +1 -1
  17. package/dist/coValues/extensions/imageDef.d.ts.map +1 -1
  18. package/dist/coValues/group.d.ts.map +1 -1
  19. package/dist/coValues/inbox.d.ts.map +1 -1
  20. package/dist/coValues/interfaces.d.ts +4 -1
  21. package/dist/coValues/interfaces.d.ts.map +1 -1
  22. package/dist/implementation/createContext.d.ts.map +1 -1
  23. package/dist/implementation/refs.d.ts +5 -10
  24. package/dist/implementation/refs.d.ts.map +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/internal.d.ts +1 -1
  27. package/dist/internal.d.ts.map +1 -1
  28. package/dist/subscribe/CoValueCoreSubscription.d.ts +14 -0
  29. package/dist/subscribe/CoValueCoreSubscription.d.ts.map +1 -0
  30. package/dist/subscribe/JazzError.d.ts +16 -0
  31. package/dist/subscribe/JazzError.d.ts.map +1 -0
  32. package/dist/subscribe/SubscriptionScope.d.ts +43 -0
  33. package/dist/subscribe/SubscriptionScope.d.ts.map +1 -0
  34. package/dist/subscribe/index.d.ts +21 -0
  35. package/dist/subscribe/index.d.ts.map +1 -0
  36. package/dist/subscribe/types.d.ts +12 -0
  37. package/dist/subscribe/types.d.ts.map +1 -0
  38. package/dist/subscribe/utils.d.ts +10 -0
  39. package/dist/subscribe/utils.d.ts.map +1 -0
  40. package/dist/testing.js +2 -2
  41. package/dist/testing.js.map +1 -1
  42. package/dist/tests/coMap.record.test.d.ts +2 -0
  43. package/dist/tests/coMap.record.test.d.ts.map +1 -0
  44. package/dist/tests/utils.d.ts +2 -2
  45. package/dist/tests/utils.d.ts.map +1 -1
  46. package/package.json +2 -2
  47. package/src/coValues/account.ts +43 -31
  48. package/src/coValues/coFeed.ts +11 -7
  49. package/src/coValues/coList.ts +13 -17
  50. package/src/coValues/coMap.ts +72 -80
  51. package/src/coValues/coPlainText.ts +13 -2
  52. package/src/coValues/deepLoading.ts +4 -277
  53. package/src/coValues/extensions/imageDef.ts +1 -7
  54. package/src/coValues/group.ts +7 -6
  55. package/src/coValues/inbox.ts +4 -11
  56. package/src/coValues/interfaces.ts +54 -111
  57. package/src/implementation/createContext.ts +3 -4
  58. package/src/implementation/invites.ts +2 -2
  59. package/src/implementation/refs.ts +30 -121
  60. package/src/internal.ts +1 -2
  61. package/src/subscribe/CoValueCoreSubscription.ts +71 -0
  62. package/src/subscribe/JazzError.ts +48 -0
  63. package/src/subscribe/SubscriptionScope.ts +536 -0
  64. package/src/subscribe/index.ts +82 -0
  65. package/src/subscribe/types.ts +7 -0
  66. package/src/subscribe/utils.ts +36 -0
  67. package/src/testing.ts +1 -1
  68. package/src/tests/ContextManager.test.ts +13 -9
  69. package/src/tests/coFeed.test.ts +6 -6
  70. package/src/tests/coList.test.ts +304 -115
  71. package/src/tests/coMap.record.test.ts +325 -0
  72. package/src/tests/coMap.test.ts +718 -645
  73. package/src/tests/coPlainText.test.ts +2 -2
  74. package/src/tests/createContext.test.ts +8 -8
  75. package/src/tests/deepLoading.test.ts +8 -34
  76. package/src/tests/groupsAndAccounts.test.ts +6 -4
  77. package/src/tests/subscribe.test.ts +614 -42
  78. package/src/tests/utils.ts +8 -6
  79. package/dist/chunk-PYBQOYML.js.map +0 -1
  80. package/dist/implementation/subscriptionScope.d.ts +0 -34
  81. package/dist/implementation/subscriptionScope.d.ts.map +0 -1
  82. package/src/implementation/subscriptionScope.ts +0 -165
@@ -119,7 +119,7 @@ describe("CoPlainText", () => {
119
119
  await createJazzContextFromExistingCredentials({
120
120
  credentials: {
121
121
  accountID: me.id,
122
- secret: me._raw.agentSecret,
122
+ secret: me._raw.core.node.getCurrentAgent().agentSecret,
123
123
  },
124
124
  sessionProvider: randomSessionProvider,
125
125
  peersToLoadFrom: [initialAsPeer],
@@ -150,7 +150,7 @@ describe("CoPlainText", () => {
150
150
  await createJazzContextFromExistingCredentials({
151
151
  credentials: {
152
152
  accountID: me.id,
153
- secret: me._raw.agentSecret,
153
+ secret: me._raw.core.node.getCurrentAgent().agentSecret,
154
154
  },
155
155
  sessionProvider: randomSessionProvider,
156
156
  peersToLoadFrom: [initialAsPeer],
@@ -1,4 +1,4 @@
1
- import { AgentSecret } from "cojson";
1
+ import { AgentSecret, RawCoMap } from "cojson";
2
2
  import { WasmCrypto } from "cojson/crypto/WasmCrypto";
3
3
  import { beforeEach, describe, expect, test, vi } from "vitest";
4
4
  import {
@@ -44,7 +44,7 @@ describe("createContext methods", () => {
44
44
 
45
45
  const credentials: Credentials = {
46
46
  accountID: account.id,
47
- secret: account._raw.core.node.account.agentSecret,
47
+ secret: account._raw.core.node.getCurrentAgent().agentSecret,
48
48
  };
49
49
 
50
50
  const context = await createJazzContextFromExistingCredentials({
@@ -72,7 +72,7 @@ describe("createContext methods", () => {
72
72
 
73
73
  const credentials: Credentials = {
74
74
  accountID: account.id,
75
- secret: account._raw.core.node.account.agentSecret,
75
+ secret: account._raw.core.node.getCurrentAgent().agentSecret,
76
76
  };
77
77
 
78
78
  const context = await createJazzContextFromExistingCredentials({
@@ -96,7 +96,7 @@ describe("createContext methods", () => {
96
96
  const context = await createJazzContextFromExistingCredentials({
97
97
  credentials: {
98
98
  accountID: account.id,
99
- secret: account._raw.core.node.account.agentSecret,
99
+ secret: account._raw.core.node.getCurrentAgent().agentSecret,
100
100
  },
101
101
  peersToLoadFrom: [getPeerConnectedToTestSyncServer()],
102
102
  crypto: Crypto,
@@ -119,7 +119,7 @@ describe("createContext methods", () => {
119
119
  const context = await createJazzContextFromExistingCredentials({
120
120
  credentials: {
121
121
  accountID: account.id,
122
- secret: account._raw.core.node.account.agentSecret,
122
+ secret: account._raw.core.node.getCurrentAgent().agentSecret,
123
123
  },
124
124
  peersToLoadFrom: [getPeerConnectedToTestSyncServer()],
125
125
  crypto: Crypto,
@@ -139,7 +139,7 @@ describe("createContext methods", () => {
139
139
  const context = await createJazzContextFromExistingCredentials({
140
140
  credentials: {
141
141
  accountID: account.id,
142
- secret: account._raw.core.node.account.agentSecret,
142
+ secret: account._raw.core.node.getCurrentAgent().agentSecret,
143
143
  },
144
144
  peersToLoadFrom: [getPeerConnectedToTestSyncServer()],
145
145
  crypto: Crypto,
@@ -172,7 +172,7 @@ describe("createContext methods", () => {
172
172
  crypto: Crypto,
173
173
  });
174
174
 
175
- expect(context.node.account.agentSecret).toBe(initialSecret);
175
+ expect(context.node.getCurrentAgent().agentSecret).toBe(initialSecret);
176
176
  });
177
177
 
178
178
  test("handles custom account schema", async () => {
@@ -311,7 +311,7 @@ describe("createContext methods", () => {
311
311
  sessionProvider: randomSessionProvider,
312
312
  });
313
313
 
314
- expect(context.node.account.agentSecret).toBe(initialSecret);
314
+ expect(context.node.getCurrentAgent().agentSecret).toBe(initialSecret);
315
315
  expect(await storage.get()).toEqual({
316
316
  accountID: "test" as ID<Account>,
317
317
  secretSeed: new Uint8Array([1, 2, 3]),
@@ -57,7 +57,7 @@ describe("Deep loading with depth arg", async () => {
57
57
  await createJazzContextFromExistingCredentials({
58
58
  credentials: {
59
59
  accountID: me.id,
60
- secret: me._raw.agentSecret,
60
+ secret: me._raw.core.node.getCurrentAgent().agentSecret,
61
61
  },
62
62
  sessionProvider: randomSessionProvider,
63
63
  peersToLoadFrom: [initialAsPeer],
@@ -281,7 +281,7 @@ test("Deep loading a record-like coMap", async () => {
281
281
  await createJazzContextFromExistingCredentials({
282
282
  credentials: {
283
283
  accountID: me.id,
284
- secret: me._raw.agentSecret,
284
+ secret: me._raw.core.node.getCurrentAgent().agentSecret,
285
285
  },
286
286
  sessionProvider: randomSessionProvider,
287
287
  peersToLoadFrom: [initialAsPeer],
@@ -401,8 +401,7 @@ describe("Deep loading with unauthorized account", async () => {
401
401
  expect(mapOnAlice).toBe(null);
402
402
 
403
403
  expect(errorSpy).toHaveBeenCalledWith(
404
- "Not enough permissions to load / subscribe to CoValue",
405
- map.id,
404
+ `The current user is not authorized to access this value from ${map.id}`,
406
405
  );
407
406
 
408
407
  errorSpy.mockReset();
@@ -424,12 +423,7 @@ describe("Deep loading with unauthorized account", async () => {
424
423
  expect(mapWithListOnAlice).toBe(null);
425
424
 
426
425
  expect(errorSpy).toHaveBeenCalledWith(
427
- "Not enough permissions to load / subscribe to CoValue",
428
- map.id,
429
- "on path",
430
- "list",
431
- "unaccessible value:",
432
- map.list?.id,
426
+ `The current user is not authorized to access this value from ${map.id} on path list`,
433
427
  );
434
428
 
435
429
  errorSpy.mockReset();
@@ -463,12 +457,7 @@ describe("Deep loading with unauthorized account", async () => {
463
457
  expect(mapOnAlice).toBe(null);
464
458
 
465
459
  expect(errorSpy).toHaveBeenCalledWith(
466
- "Not enough permissions to load / subscribe to CoValue",
467
- map.id,
468
- "on path",
469
- "list.0",
470
- "unaccessible value:",
471
- map.list?.[0]?.id,
460
+ `The current user is not authorized to access this value from ${map.id} on path list.0`,
472
461
  );
473
462
 
474
463
  errorSpy.mockReset();
@@ -495,12 +484,7 @@ describe("Deep loading with unauthorized account", async () => {
495
484
  expect(mapOnAlice?.optionalRef?.value).toBe(undefined);
496
485
 
497
486
  expect(errorSpy).toHaveBeenCalledWith(
498
- "Not enough permissions to load / subscribe to CoValue",
499
- map.id,
500
- "on path",
501
- "optionalRef",
502
- "unaccessible value:",
503
- map.optionalRef?.id,
487
+ `The current user is not authorized to access this value from ${map.id} on path optionalRef`,
504
488
  );
505
489
 
506
490
  errorSpy.mockReset();
@@ -559,12 +543,7 @@ describe("Deep loading with unauthorized account", async () => {
559
543
  expect(mapOnAlice).toBe(null);
560
544
 
561
545
  expect(errorSpy).toHaveBeenCalledWith(
562
- "Not enough permissions to load / subscribe to CoValue",
563
- map.id,
564
- "on path",
565
- "list.0.stream",
566
- "unaccessible value:",
567
- map.list?.[0]?.stream?.id,
546
+ `The current user is not authorized to access this value from ${map.id} on path list.0.stream`,
568
547
  );
569
548
 
570
549
  errorSpy.mockReset();
@@ -600,12 +579,7 @@ describe("Deep loading with unauthorized account", async () => {
600
579
  expect(mapOnAlice).toBe(null);
601
580
 
602
581
  expect(errorSpy).toHaveBeenCalledWith(
603
- "Not enough permissions to load / subscribe to CoValue",
604
- map.id,
605
- "on path",
606
- "list.0.stream." + value.id,
607
- "unaccessible value:",
608
- value.id,
582
+ `The current user is not authorized to access this value from ${map.id} on path list.0.stream.${value.id}`,
609
583
  );
610
584
 
611
585
  errorSpy.mockReset();
@@ -3,7 +3,7 @@ import { assert, beforeEach, describe, expect, test } from "vitest";
3
3
  import { Account, CoMap, Group, Profile, co } from "../exports.js";
4
4
  import { Ref } from "../internal.js";
5
5
  import { createJazzTestAccount, setupJazzTestSync } from "../testing.js";
6
- import { setupTwoNodes } from "./utils.js";
6
+ import { setupTwoNodes, waitFor } from "./utils.js";
7
7
 
8
8
  const Crypto = await WasmCrypto.create();
9
9
 
@@ -113,10 +113,12 @@ describe("Group inheritance", () => {
113
113
 
114
114
  mapInChild.title = "In Child (updated)";
115
115
 
116
- const mapAsReaderAfterUpdate = await TestMap.load(mapInChild.id, {
117
- loadAs: reader,
116
+ await waitFor(async () => {
117
+ const mapAsReaderAfterUpdate = await TestMap.load(mapInChild.id, {
118
+ loadAs: reader,
119
+ });
120
+ expect(mapAsReaderAfterUpdate).toBe(null);
118
121
  });
119
- expect(mapAsReaderAfterUpdate).toBe(null);
120
122
  });
121
123
 
122
124
  test("Group inheritance with grand-children", async () => {