cojson 0.8.19-group-inheritance.0 → 0.8.21

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 (39) hide show
  1. package/CHANGELOG.md +8 -2
  2. package/dist/native/PeerState.js +5 -0
  3. package/dist/native/PeerState.js.map +1 -1
  4. package/dist/native/coValueCore.js +3 -34
  5. package/dist/native/coValueCore.js.map +1 -1
  6. package/dist/native/coValues/group.js +3 -89
  7. package/dist/native/coValues/group.js.map +1 -1
  8. package/dist/native/permissions.js +145 -174
  9. package/dist/native/permissions.js.map +1 -1
  10. package/dist/native/storage/index.js +4 -8
  11. package/dist/native/storage/index.js.map +1 -1
  12. package/dist/native/sync.js +17 -11
  13. package/dist/native/sync.js.map +1 -1
  14. package/dist/web/PeerState.js +5 -0
  15. package/dist/web/PeerState.js.map +1 -1
  16. package/dist/web/coValueCore.js +3 -34
  17. package/dist/web/coValueCore.js.map +1 -1
  18. package/dist/web/coValues/group.js +3 -89
  19. package/dist/web/coValues/group.js.map +1 -1
  20. package/dist/web/permissions.js +145 -174
  21. package/dist/web/permissions.js.map +1 -1
  22. package/dist/web/storage/index.js +4 -8
  23. package/dist/web/storage/index.js.map +1 -1
  24. package/dist/web/sync.js +17 -11
  25. package/dist/web/sync.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/PeerKnownStates.ts +1 -1
  28. package/src/PeerState.ts +9 -1
  29. package/src/coValueCore.ts +4 -50
  30. package/src/coValues/group.ts +4 -159
  31. package/src/permissions.ts +203 -244
  32. package/src/storage/index.ts +4 -12
  33. package/src/sync.ts +20 -12
  34. package/src/tests/PeerState.test.ts +44 -1
  35. package/src/tests/permissions.test.ts +0 -748
  36. package/src/tests/sync.test.ts +17 -10
  37. package/.turbo/turbo-build.log +0 -12
  38. package/.turbo/turbo-lint.log +0 -4
  39. package/.turbo/turbo-test.log +0 -1001
@@ -1590,32 +1590,39 @@ function createTwoConnectedNodes() {
1590
1590
 
1591
1591
  describe("SyncManager - knownStates vs optimisticKnownStates", () => {
1592
1592
  test("knownStates and optimisticKnownStates are the same when the coValue is fully synced", async () => {
1593
- const { client } = createTwoConnectedNodes();
1593
+ const { client, jazzCloud } = createTwoConnectedNodes();
1594
1594
 
1595
1595
  // Create test data
1596
1596
  const group = client.createGroup();
1597
- const map = group.createMap();
1598
- map.set("key1", "value1", "trusting");
1597
+ const mapOnClient = group.createMap();
1598
+ mapOnClient.set("key1", "value1", "trusting");
1599
1599
 
1600
- await client.syncManager.actuallySyncCoValue(map.core);
1600
+ await client.syncManager.actuallySyncCoValue(mapOnClient.core);
1601
1601
 
1602
1602
  // Wait for the full sync to complete
1603
1603
  await waitFor(() => {
1604
1604
  return client.syncManager.syncStateSubscriptionManager.getIsCoValueFullyUploadedIntoPeer(
1605
1605
  "jazzCloudConnection",
1606
- map.core.id,
1606
+ mapOnClient.core.id,
1607
1607
  );
1608
1608
  });
1609
1609
 
1610
- const peerState = client.syncManager.peers["jazzCloudConnection"]!;
1610
+ const peerStateClient = client.syncManager.peers["jazzCloudConnection"]!;
1611
+ const peerStateJazzCloud =
1612
+ jazzCloud.syncManager.peers["connectionWithClient"]!;
1611
1613
 
1612
1614
  // The optimisticKnownStates should be the same as the knownStates after the full sync is complete
1613
- expect(peerState.optimisticKnownStates.get(map.core.id)).toEqual(
1614
- peerState.knownStates.get(map.core.id),
1615
- );
1615
+ expect(
1616
+ peerStateClient.optimisticKnownStates.get(mapOnClient.core.id),
1617
+ ).toEqual(peerStateClient.knownStates.get(mapOnClient.core.id));
1618
+
1619
+ // On the other node the knownStates should be updated correctly based on the messages we received
1620
+ expect(
1621
+ peerStateJazzCloud.optimisticKnownStates.get(mapOnClient.core.id),
1622
+ ).toEqual(peerStateJazzCloud.knownStates.get(mapOnClient.core.id));
1616
1623
  });
1617
1624
 
1618
- test("optimisticKnownStates is updated as new transactions are received, while knownStates only when the coValue is fully synced", async () => {
1625
+ test("optimisticKnownStates is updated as new transactions are sent, while knownStates only when the updates are acknowledged", async () => {
1619
1626
  const { client, jazzCloudConnectionAsPeer } = createTwoConnectedNodes();
1620
1627
 
1621
1628
  // Create test data and sync the first change
@@ -1,12 +0,0 @@
1
-
2
- > cojson@0.8.18 build /Users/anselm/jazz/jazz/packages/cojson
3
- > rm -rf ./dist && pnpm run build:native && pnpm run build:web
4
-
5
-
6
- > cojson@0.8.18 build:native /Users/anselm/jazz/jazz/packages/cojson
7
- > tsc --sourceMap --outDir dist/native -p tsconfig.native.json
8
-
9
-
10
- > cojson@0.8.18 build:web /Users/anselm/jazz/jazz/packages/cojson
11
- > tsc --sourceMap --outDir dist/web -p tsconfig.web.json
12
-
@@ -1,4 +0,0 @@
1
-
2
- > cojson@0.7.35-guest-auth.5 lint /Users/anselm/jazz/jazz/packages/cojson
3
- > eslint . --ext ts,tsx
4
-