@dxos/client-services 0.1.35 → 0.1.36

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 (95) hide show
  1. package/dist/lib/browser/{chunk-H5IXSSI7.mjs → chunk-2AYYVPWN.mjs} +835 -950
  2. package/dist/lib/browser/chunk-2AYYVPWN.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +9 -11
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +212 -74
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/index.cjs +942 -1058
  8. package/dist/lib/node/index.cjs.map +4 -4
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +1089 -1067
  11. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  12. package/dist/types/src/packlets/identity/identity-manager.d.ts +1 -0
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  14. package/dist/types/src/packlets/identity/identity.d.ts +3 -3
  15. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  16. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +18 -0
  17. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -0
  18. package/dist/types/src/packlets/invitations/device-invitation-protocol.test.d.ts +2 -0
  19. package/dist/types/src/packlets/invitations/device-invitation-protocol.test.d.ts.map +1 -0
  20. package/dist/types/src/packlets/invitations/index.d.ts +4 -4
  21. package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
  22. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +12 -0
  23. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -0
  24. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +38 -0
  25. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -0
  26. package/dist/types/src/packlets/invitations/invitations-service.d.ts +13 -15
  27. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  28. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +22 -0
  29. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -0
  30. package/dist/types/src/packlets/invitations/space-invitation-protocol.test.d.ts +2 -0
  31. package/dist/types/src/packlets/invitations/space-invitation-protocol.test.d.ts.map +1 -0
  32. package/dist/types/src/packlets/services/service-context.d.ts +6 -4
  33. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  34. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  35. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +2 -0
  36. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  37. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  38. package/dist/types/src/packlets/testing/invitation-utils.d.ts +31 -2
  39. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  40. package/dist/types/src/packlets/testing/test-builder.d.ts +3 -3
  41. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  42. package/dist/types/src/packlets/tests/invitations.test.d.ts +2 -0
  43. package/dist/types/src/packlets/tests/invitations.test.d.ts.map +1 -0
  44. package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -0
  45. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  46. package/package.json +30 -30
  47. package/src/packlets/identity/identity-manager.ts +2 -1
  48. package/src/packlets/identity/identity.ts +3 -3
  49. package/src/packlets/invitations/{device-invitations-handler.test.ts → device-invitation-protocol.test.ts} +3 -3
  50. package/src/packlets/invitations/device-invitation-protocol.ts +83 -0
  51. package/src/packlets/invitations/index.ts +4 -4
  52. package/src/packlets/invitations/invitation-protocol.ts +21 -0
  53. package/src/packlets/invitations/invitations-handler.ts +462 -0
  54. package/src/packlets/invitations/invitations-service.ts +127 -104
  55. package/src/packlets/invitations/space-invitation-protocol.test.ts +221 -0
  56. package/src/packlets/invitations/space-invitation-protocol.ts +117 -0
  57. package/src/packlets/services/service-context.test.ts +11 -4
  58. package/src/packlets/services/service-context.ts +40 -19
  59. package/src/packlets/services/service-host.ts +4 -12
  60. package/src/packlets/services/service-registry.test.ts +23 -25
  61. package/src/packlets/spaces/data-space-manager.ts +5 -0
  62. package/src/packlets/spaces/spaces-service.ts +7 -2
  63. package/src/packlets/storage/storage.ts +2 -0
  64. package/src/packlets/testing/invitation-utils.ts +219 -31
  65. package/src/packlets/testing/test-builder.ts +33 -22
  66. package/src/packlets/tests/client-services.test.ts +33 -76
  67. package/src/packlets/tests/halo-profile.test.ts +2 -28
  68. package/src/packlets/tests/invitations.test.ts +389 -0
  69. package/src/packlets/tests/spaces-invitations.test.ts +12 -30
  70. package/src/packlets/tests/spaces.test.ts +30 -28
  71. package/src/packlets/vault/worker-runtime.ts +4 -0
  72. package/dist/lib/browser/chunk-H5IXSSI7.mjs.map +0 -7
  73. package/dist/types/src/packlets/invitations/device-invitations-handler.d.ts +0 -30
  74. package/dist/types/src/packlets/invitations/device-invitations-handler.d.ts.map +0 -1
  75. package/dist/types/src/packlets/invitations/device-invitations-handler.test.d.ts +0 -2
  76. package/dist/types/src/packlets/invitations/device-invitations-handler.test.d.ts.map +0 -1
  77. package/dist/types/src/packlets/invitations/device-invitations-service.d.ts +0 -13
  78. package/dist/types/src/packlets/invitations/device-invitations-service.d.ts.map +0 -1
  79. package/dist/types/src/packlets/invitations/device-invitations-service.test.d.ts +0 -2
  80. package/dist/types/src/packlets/invitations/device-invitations-service.test.d.ts.map +0 -1
  81. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts +0 -26
  82. package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +0 -1
  83. package/dist/types/src/packlets/invitations/space-invitations-handler.test.d.ts +0 -2
  84. package/dist/types/src/packlets/invitations/space-invitations-handler.test.d.ts.map +0 -1
  85. package/dist/types/src/packlets/invitations/space-invitations-service.d.ts +0 -16
  86. package/dist/types/src/packlets/invitations/space-invitations-service.d.ts.map +0 -1
  87. package/dist/types/src/packlets/invitations/space-invitations-service.test.d.ts +0 -2
  88. package/dist/types/src/packlets/invitations/space-invitations-service.test.d.ts.map +0 -1
  89. package/src/packlets/invitations/device-invitations-handler.ts +0 -370
  90. package/src/packlets/invitations/device-invitations-service.test.ts +0 -96
  91. package/src/packlets/invitations/device-invitations-service.ts +0 -24
  92. package/src/packlets/invitations/space-invitations-handler.test.ts +0 -246
  93. package/src/packlets/invitations/space-invitations-handler.ts +0 -463
  94. package/src/packlets/invitations/space-invitations-service.test.ts +0 -129
  95. package/src/packlets/invitations/space-invitations-service.ts +0 -35
@@ -5,23 +5,46 @@
5
5
  import { expect } from 'chai';
6
6
 
7
7
  import { asyncTimeout, Trigger } from '@dxos/async';
8
- import { Client, Invitation, Space } from '@dxos/client';
8
+ import { Client, Space, SpaceProxy } from '@dxos/client';
9
9
  import { Config } from '@dxos/config';
10
- import { raise } from '@dxos/debug';
11
10
  import { log } from '@dxos/log';
12
11
  import { createStorage, StorageType } from '@dxos/random-access-storage';
13
12
  import { describe, test, afterTest } from '@dxos/test';
14
13
 
15
- import { TestBuilder, testSpace } from '../testing';
14
+ import { performInvitation, TestBuilder, testSpace } from '../testing';
16
15
 
17
16
  describe('Spaces', () => {
18
17
  test('creates a space', async () => {
19
18
  const testBuilder = new TestBuilder();
19
+ testBuilder.storage = createStorage({ type: StorageType.RAM });
20
20
 
21
21
  const client = new Client({ services: testBuilder.createLocal() });
22
+ await client.initialize();
22
23
  afterTest(() => client.destroy());
23
24
 
25
+ await client.halo.createIdentity({ displayName: 'test-user' });
26
+
27
+ // TODO(burdon): Extend basic queries.
28
+ const space = await client.createSpace();
29
+ await testSpace(space.internal.db);
30
+
31
+ expect(space.members.get()).to.be.length(1);
32
+ });
33
+
34
+ // TODO(dmaretskyi): Test suit for different conditions/storages.
35
+ test.skip('creates a space on webfs', async () => {
36
+ const testBuilder = new TestBuilder();
37
+ // testBuilder.storage = createStorage({ type: StorageType.WEBFS });
38
+
39
+ const host = testBuilder.createClientServicesHost();
40
+ await host.open();
41
+ afterTest(() => host.close());
42
+ const [client, server] = testBuilder.createClientServer(host);
43
+ void server.open();
44
+ afterTest(() => server.close());
24
45
  await client.initialize();
46
+ afterTest(() => client.destroy());
47
+
25
48
  await client.halo.createIdentity({ displayName: 'test-user' });
26
49
 
27
50
  // TODO(burdon): Extend basic queries.
@@ -92,33 +115,12 @@ describe('Spaces', () => {
92
115
  afterTest(() => Promise.all([client1.destroy()]));
93
116
  afterTest(() => Promise.all([client2.destroy()]));
94
117
 
95
- const success1 = new Trigger<Invitation>();
96
- const success2 = new Trigger<Invitation>();
97
-
98
118
  const space1 = await client1.createSpace();
99
119
  log('createSpace', { key: space1.key });
100
- const observable1 = space1.createInvitation({ type: Invitation.Type.INTERACTIVE_TESTING });
101
-
102
- observable1.subscribe({
103
- onConnecting: (invitation) => {
104
- const observable2 = client2.acceptInvitation(invitation);
105
- observable2.subscribe({
106
- onSuccess: (invitation: Invitation) => {
107
- success2.wake(invitation);
108
- },
109
- onError: (err: Error) => raise(err)
110
- });
111
- },
112
- onSuccess: (invitation) => {
113
- log('onSuccess');
114
- success1.wake(invitation);
115
- },
116
- onError: (err) => raise(err)
117
- });
118
-
119
- const [_, invitation2] = await Promise.all([success1.wait(), success2.wait()]);
120
-
121
- const space2 = await client2.getSpace(invitation2.spaceKey!)!.waitUntilReady();
120
+ const [, { invitation: guestInvitation }] = await Promise.all(
121
+ performInvitation({ host: space1 as SpaceProxy, guest: client2 })
122
+ );
123
+ const space2 = await client2.getSpace(guestInvitation!.spaceKey!)!.waitUntilReady();
122
124
 
123
125
  const hello = new Trigger();
124
126
  {
@@ -40,6 +40,10 @@ export class WorkerRuntime {
40
40
  this._clientServices = new ClientServicesHost();
41
41
  }
42
42
 
43
+ get host() {
44
+ return this._clientServices;
45
+ }
46
+
43
47
  async start() {
44
48
  log('starting...');
45
49
  try {