@dxos/client 2.29.2-dev.f64f2a6f → 2.30.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.
Files changed (208) hide show
  1. package/dist/src/{client → api}/client.d.ts +12 -8
  2. package/dist/src/api/client.d.ts.map +1 -0
  3. package/dist/src/{client → api}/client.js +19 -18
  4. package/dist/src/api/client.js.map +1 -0
  5. package/dist/src/{client → api}/client.test.d.ts +0 -0
  6. package/dist/src/api/client.test.d.ts.map +1 -0
  7. package/dist/src/{client → api}/client.test.js +2 -2
  8. package/dist/src/api/client.test.js.map +1 -0
  9. package/dist/src/{interfaces → api}/errors.d.ts +0 -0
  10. package/dist/src/api/errors.d.ts.map +1 -0
  11. package/dist/src/{interfaces → api}/errors.js +0 -0
  12. package/dist/src/api/errors.js.map +1 -0
  13. package/dist/src/api/index.d.ts +6 -3
  14. package/dist/src/api/index.d.ts.map +1 -1
  15. package/dist/src/api/index.js +4 -3
  16. package/dist/src/api/index.js.map +1 -1
  17. package/dist/src/api/local.test.d.ts +2 -0
  18. package/dist/src/api/local.test.d.ts.map +1 -0
  19. package/dist/src/{client/local-client.test.js → api/local.test.js} +2 -3
  20. package/dist/src/api/local.test.js.map +1 -0
  21. package/dist/src/api/{echo-proxy.d.ts → proxies/echo-proxy.d.ts} +19 -3
  22. package/dist/src/api/proxies/echo-proxy.d.ts.map +1 -0
  23. package/dist/src/api/{echo-proxy.js → proxies/echo-proxy.js} +9 -6
  24. package/dist/src/api/proxies/echo-proxy.js.map +1 -0
  25. package/dist/src/api/{halo-proxy.d.ts → proxies/halo-proxy.d.ts} +39 -11
  26. package/dist/src/api/proxies/halo-proxy.d.ts.map +1 -0
  27. package/dist/src/api/{halo-proxy.js → proxies/halo-proxy.js} +13 -10
  28. package/dist/src/api/{halo-proxy.js.map → proxies/halo-proxy.js.map} +1 -1
  29. package/dist/src/api/proxies/index.d.ts +4 -0
  30. package/dist/src/api/proxies/index.d.ts.map +1 -0
  31. package/dist/src/{client → api/proxies}/index.js +4 -2
  32. package/dist/src/api/proxies/index.js.map +1 -0
  33. package/dist/src/api/{party-proxy.d.ts → proxies/party-proxy.d.ts} +51 -16
  34. package/dist/src/api/proxies/party-proxy.d.ts.map +1 -0
  35. package/dist/src/api/{party-proxy.js → proxies/party-proxy.js} +31 -28
  36. package/dist/src/api/proxies/party-proxy.js.map +1 -0
  37. package/dist/src/api/serializer.d.ts +11 -0
  38. package/dist/src/api/serializer.d.ts.map +1 -0
  39. package/dist/src/{util/partySerializer.js → api/serializer.js} +6 -10
  40. package/dist/src/api/serializer.js.map +1 -0
  41. package/dist/src/devtools/devtools-context.d.ts +6 -6
  42. package/dist/src/devtools/devtools-context.d.ts.map +1 -1
  43. package/dist/src/devtools/index.d.ts +1 -1
  44. package/dist/src/devtools/index.d.ts.map +1 -1
  45. package/dist/src/devtools/index.js +1 -1
  46. package/dist/src/devtools/index.js.map +1 -1
  47. package/dist/src/devtools/keys.d.ts.map +1 -1
  48. package/dist/src/devtools/keys.js.map +1 -1
  49. package/dist/src/index.d.ts +5 -7
  50. package/dist/src/index.d.ts.map +1 -1
  51. package/dist/src/index.js +10 -12
  52. package/dist/src/index.js.map +1 -1
  53. package/dist/src/proto/gen/dxos/client.d.ts +2 -2
  54. package/dist/src/proto/gen/dxos/client.d.ts.map +1 -1
  55. package/dist/src/proto/gen/index.js +1 -1
  56. package/dist/src/{interfaces/client-service-provider.d.ts → services/client-service.d.ts} +3 -3
  57. package/dist/src/services/client-service.d.ts.map +1 -0
  58. package/dist/src/{interfaces/client-service-provider.js → services/client-service.js} +3 -1
  59. package/dist/src/services/client-service.js.map +1 -0
  60. package/dist/src/{client/service-host/services → services/impl}/halo.d.ts +11 -8
  61. package/dist/src/services/impl/halo.d.ts.map +1 -0
  62. package/dist/src/{client/service-host/services → services/impl}/halo.js +34 -47
  63. package/dist/src/services/impl/halo.js.map +1 -0
  64. package/dist/src/services/impl/index.d.ts +3 -0
  65. package/dist/src/services/impl/index.d.ts.map +1 -0
  66. package/dist/src/{client/service-host/services → services/impl}/index.js +0 -0
  67. package/dist/src/services/impl/index.js.map +1 -0
  68. package/dist/src/{client/service-host/services → services/impl}/party.d.ts +8 -5
  69. package/dist/src/services/impl/party.d.ts.map +1 -0
  70. package/dist/src/{client/service-host/services → services/impl}/party.js +5 -2
  71. package/dist/src/services/impl/party.js.map +1 -0
  72. package/dist/src/{client/service-host/services → services/impl}/profile.d.ts +7 -4
  73. package/dist/src/services/impl/profile.d.ts.map +1 -0
  74. package/dist/src/{client/service-host/services → services/impl}/profile.js +4 -1
  75. package/dist/src/services/impl/profile.js.map +1 -0
  76. package/dist/src/services/impl/services.d.ts +4 -0
  77. package/dist/src/services/impl/services.d.ts.map +1 -0
  78. package/dist/src/{client/service-host/services → services/impl}/services.js +2 -2
  79. package/dist/src/services/impl/services.js.map +1 -0
  80. package/dist/src/services/impl/system.d.ts +4 -0
  81. package/dist/src/services/impl/system.d.ts.map +1 -0
  82. package/dist/src/{client/service-host/services → services/impl}/system.js +0 -0
  83. package/dist/src/services/impl/system.js.map +1 -0
  84. package/dist/src/{client/service-host/services/interfaces.d.ts → services/impl/types.d.ts} +12 -3
  85. package/dist/src/services/impl/types.d.ts.map +1 -0
  86. package/dist/src/{client/service-host/services/interfaces.js → services/impl/types.js} +1 -1
  87. package/dist/src/services/impl/types.js.map +1 -0
  88. package/dist/src/services/index.d.ts +5 -0
  89. package/dist/src/services/index.d.ts.map +1 -0
  90. package/dist/src/{client/service-host → services}/index.js +2 -0
  91. package/dist/src/services/index.js.map +1 -0
  92. package/dist/src/{client/service-host → services}/service-host.d.ts +6 -2
  93. package/dist/src/services/service-host.d.ts.map +1 -0
  94. package/dist/src/{client/service-host → services}/service-host.js +14 -7
  95. package/dist/src/services/service-host.js.map +1 -0
  96. package/dist/src/{client → services}/service-proxy.d.ts +1 -1
  97. package/dist/src/services/service-proxy.d.ts.map +1 -0
  98. package/dist/src/{client → services}/service-proxy.js +4 -3
  99. package/dist/src/services/service-proxy.js.map +1 -0
  100. package/dist/src/services/services.test.d.ts +2 -0
  101. package/dist/src/services/services.test.d.ts.map +1 -0
  102. package/dist/src/{client/client-services.test.js → services/services.test.js} +3 -3
  103. package/dist/src/services/services.test.js.map +1 -0
  104. package/dist/src/{client/service-host → services}/storage.d.ts +0 -0
  105. package/dist/src/services/storage.d.ts.map +1 -0
  106. package/dist/src/{client/service-host → services}/storage.js +7 -7
  107. package/dist/src/services/storage.js.map +1 -0
  108. package/dist/src/util/index.d.ts +1 -2
  109. package/dist/src/util/index.d.ts.map +1 -1
  110. package/dist/src/util/index.js +1 -2
  111. package/dist/src/util/index.js.map +1 -1
  112. package/dist/src/util/{createWindowMessagePort.d.ts → messages.d.ts} +1 -1
  113. package/dist/src/util/messages.d.ts.map +1 -0
  114. package/dist/src/util/{createWindowMessagePort.js → messages.js} +8 -6
  115. package/dist/src/util/messages.js.map +1 -0
  116. package/dist/tsconfig.tsbuildinfo +1 -1
  117. package/package.json +29 -31
  118. package/src/{client → api}/client.test.ts +1 -1
  119. package/src/{client → api}/client.ts +22 -15
  120. package/src/{interfaces → api}/errors.ts +0 -0
  121. package/src/api/index.ts +7 -3
  122. package/src/{client/local-client.test.ts → api/local.test.ts} +1 -7
  123. package/src/api/{echo-proxy.ts → proxies/echo-proxy.ts} +28 -10
  124. package/src/api/{halo-proxy.ts → proxies/halo-proxy.ts} +47 -14
  125. package/src/api/proxies/index.ts +7 -0
  126. package/src/api/{party-proxy.ts → proxies/party-proxy.ts} +77 -28
  127. package/src/{util/partySerializer.ts → api/serializer.ts} +6 -10
  128. package/src/devtools/devtools-context.ts +9 -10
  129. package/src/devtools/index.ts +1 -1
  130. package/src/devtools/keys.ts +0 -2
  131. package/src/index.ts +8 -10
  132. package/src/proto/gen/dxos/client.ts +2 -2
  133. package/src/proto/gen/index.ts +1 -1
  134. package/src/{interfaces/client-service-provider.ts → services/client-service.ts} +11 -10
  135. package/src/{client/service-host/services → services/impl}/halo.ts +40 -53
  136. package/src/{client/service-host/services → services/impl}/index.ts +1 -0
  137. package/src/{client/service-host/services → services/impl}/party.ts +11 -6
  138. package/src/{client/service-host/services → services/impl}/profile.ts +19 -6
  139. package/src/{client/service-host/services → services/impl}/services.ts +4 -4
  140. package/src/{client/service-host/services → services/impl}/system.ts +3 -2
  141. package/src/{client/service-host/services/interfaces.ts → services/impl/types.ts} +15 -2
  142. package/src/services/index.ts +9 -0
  143. package/src/{client/service-host → services}/service-host.ts +16 -9
  144. package/src/{client → services}/service-proxy.ts +2 -1
  145. package/src/{client/client-services.test.ts → services/services.test.ts} +1 -1
  146. package/src/{client/service-host → services}/storage.ts +2 -2
  147. package/src/util/index.ts +1 -2
  148. package/src/util/{createWindowMessagePort.ts → messages.ts} +8 -5
  149. package/dist/src/api/echo-proxy.d.ts.map +0 -1
  150. package/dist/src/api/echo-proxy.js.map +0 -1
  151. package/dist/src/api/halo-proxy.d.ts.map +0 -1
  152. package/dist/src/api/party-proxy.d.ts.map +0 -1
  153. package/dist/src/api/party-proxy.js.map +0 -1
  154. package/dist/src/client/client-services.test.d.ts +0 -2
  155. package/dist/src/client/client-services.test.d.ts.map +0 -1
  156. package/dist/src/client/client-services.test.js.map +0 -1
  157. package/dist/src/client/client.d.ts.map +0 -1
  158. package/dist/src/client/client.js.map +0 -1
  159. package/dist/src/client/client.test.d.ts.map +0 -1
  160. package/dist/src/client/client.test.js.map +0 -1
  161. package/dist/src/client/index.d.ts +0 -2
  162. package/dist/src/client/index.d.ts.map +0 -1
  163. package/dist/src/client/index.js.map +0 -1
  164. package/dist/src/client/local-client.test.d.ts +0 -2
  165. package/dist/src/client/local-client.test.d.ts.map +0 -1
  166. package/dist/src/client/local-client.test.js.map +0 -1
  167. package/dist/src/client/service-host/index.d.ts +0 -2
  168. package/dist/src/client/service-host/index.d.ts.map +0 -1
  169. package/dist/src/client/service-host/index.js.map +0 -1
  170. package/dist/src/client/service-host/service-host.d.ts.map +0 -1
  171. package/dist/src/client/service-host/service-host.js.map +0 -1
  172. package/dist/src/client/service-host/services/halo.d.ts.map +0 -1
  173. package/dist/src/client/service-host/services/halo.js.map +0 -1
  174. package/dist/src/client/service-host/services/index.d.ts +0 -2
  175. package/dist/src/client/service-host/services/index.d.ts.map +0 -1
  176. package/dist/src/client/service-host/services/index.js.map +0 -1
  177. package/dist/src/client/service-host/services/interfaces.d.ts.map +0 -1
  178. package/dist/src/client/service-host/services/interfaces.js.map +0 -1
  179. package/dist/src/client/service-host/services/party.d.ts.map +0 -1
  180. package/dist/src/client/service-host/services/party.js.map +0 -1
  181. package/dist/src/client/service-host/services/profile.d.ts.map +0 -1
  182. package/dist/src/client/service-host/services/profile.js.map +0 -1
  183. package/dist/src/client/service-host/services/services.d.ts +0 -4
  184. package/dist/src/client/service-host/services/services.d.ts.map +0 -1
  185. package/dist/src/client/service-host/services/services.js.map +0 -1
  186. package/dist/src/client/service-host/services/system.d.ts +0 -4
  187. package/dist/src/client/service-host/services/system.d.ts.map +0 -1
  188. package/dist/src/client/service-host/services/system.js.map +0 -1
  189. package/dist/src/client/service-host/storage.d.ts.map +0 -1
  190. package/dist/src/client/service-host/storage.js.map +0 -1
  191. package/dist/src/client/service-proxy.d.ts.map +0 -1
  192. package/dist/src/client/service-proxy.js.map +0 -1
  193. package/dist/src/interfaces/client-service-provider.d.ts.map +0 -1
  194. package/dist/src/interfaces/client-service-provider.js.map +0 -1
  195. package/dist/src/interfaces/errors.d.ts.map +0 -1
  196. package/dist/src/interfaces/errors.js.map +0 -1
  197. package/dist/src/interfaces/index.d.ts +0 -3
  198. package/dist/src/interfaces/index.d.ts.map +0 -1
  199. package/dist/src/interfaces/index.js +0 -18
  200. package/dist/src/interfaces/index.js.map +0 -1
  201. package/dist/src/util/createWindowMessagePort.d.ts.map +0 -1
  202. package/dist/src/util/createWindowMessagePort.js.map +0 -1
  203. package/dist/src/util/partySerializer.d.ts +0 -9
  204. package/dist/src/util/partySerializer.d.ts.map +0 -1
  205. package/dist/src/util/partySerializer.js.map +0 -1
  206. package/src/client/index.ts +0 -5
  207. package/src/client/service-host/index.ts +0 -5
  208. package/src/interfaces/index.ts +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/client",
3
- "version": "2.29.2-dev.f64f2a6f",
3
+ "version": "2.30.0",
4
4
  "license": "MIT",
5
5
  "author": "DXOS.org",
6
6
  "main": "dist/src/index.js",
@@ -9,32 +9,22 @@
9
9
  "dist",
10
10
  "src"
11
11
  ],
12
- "scripts": {
13
- "prebuild": "node -p \"'export const DXOS_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
14
- "build": "npm run prebuild && toolchain build",
15
- "build:test": "toolchain build:test",
16
- "lint": "toolchain lint",
17
- "test": "toolchain test"
18
- },
19
12
  "dependencies": {
20
- "@dxos/async": "workspace:*",
21
- "@dxos/codec-protobuf": "workspace:*",
22
- "@dxos/config": "workspace:*",
23
- "@dxos/credentials": "workspace:*",
24
- "@dxos/crypto": "workspace:*",
25
- "@dxos/debug": "workspace:*",
26
- "@dxos/echo-db": "workspace:*",
27
- "@dxos/echo-protocol": "workspace:*",
28
- "@dxos/feed-store": "workspace:*",
29
- "@dxos/model-factory": "workspace:*",
30
- "@dxos/network-manager": "workspace:*",
31
- "@dxos/object-model": "workspace:*",
32
- "@dxos/protocols": "workspace:*",
33
- "@dxos/rpc": "workspace:*",
34
- "@dxos/util": "workspace:*",
35
- "@polkadot/keyring": "6.11.1",
36
- "@polkadot/util": "6.11.1",
37
- "@polkadot/util-crypto": "6.11.1",
13
+ "@dxos/async": "2.30.0",
14
+ "@dxos/codec-protobuf": "2.30.0",
15
+ "@dxos/config": "2.30.0",
16
+ "@dxos/credentials": "2.30.0",
17
+ "@dxos/crypto": "2.30.0",
18
+ "@dxos/debug": "2.30.0",
19
+ "@dxos/echo-db": "2.30.0",
20
+ "@dxos/echo-protocol": "2.30.0",
21
+ "@dxos/feed-store": "2.30.0",
22
+ "@dxos/model-factory": "2.30.0",
23
+ "@dxos/network-manager": "2.30.0",
24
+ "@dxos/object-model": "2.30.0",
25
+ "@dxos/protocols": "2.30.0",
26
+ "@dxos/rpc": "2.30.0",
27
+ "@dxos/util": "2.30.0",
38
28
  "abstract-leveldown": "~7.0.0",
39
29
  "assert": "^2.0.0",
40
30
  "debug": "^4.3.3",
@@ -48,9 +38,9 @@
48
38
  },
49
39
  "devDependencies": {
50
40
  "@dxos/eslint-plugin": "~1.0.27",
51
- "@dxos/protocols-toolchain": "workspace:*",
52
- "@dxos/random-access-multi-storage": "workspace:*",
53
- "@dxos/testutils": "workspace:*",
41
+ "@dxos/protocols-toolchain": "2.30.0",
42
+ "@dxos/random-access-multi-storage": "2.30.0",
43
+ "@dxos/testutils": "2.30.0",
54
44
  "@types/debug": "^4.1.7",
55
45
  "@types/jest": "^26.0.7",
56
46
  "@types/level-js": "~4.0.1",
@@ -70,5 +60,13 @@
70
60
  },
71
61
  "toolchain": {
72
62
  "testingFramework": "mocha"
73
- }
74
- }
63
+ },
64
+ "scripts": {
65
+ "prebuild": "node -p \"'export const DXOS_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
66
+ "build": "npm run prebuild && toolchain build",
67
+ "build:test": "toolchain build:test",
68
+ "lint": "toolchain lint",
69
+ "test": "toolchain test"
70
+ },
71
+ "readme": "# @dxos/client\n\n[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)](https://github.com/standard/semistandard)\n[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)\n\nDescription...\n\n## Install\n\n## Usage\n\n...\n\n## Contributing\n\nPRs accepted.\n\n## License\n\nAGPL-3.0 © DXOS\n"
72
+ }
@@ -17,7 +17,7 @@ import { ObjectModel } from '@dxos/object-model';
17
17
  import { createBundledRpcServer, createLinkedPorts } from '@dxos/rpc';
18
18
  import { afterTest } from '@dxos/testutils';
19
19
 
20
- import { clientServiceBundle } from '../interfaces';
20
+ import { clientServiceBundle } from '../services';
21
21
  import { Client } from './client';
22
22
 
23
23
  describe('Client', () => {
@@ -12,15 +12,13 @@ import { OpenProgress } from '@dxos/echo-db';
12
12
  import { ModelConstructor } from '@dxos/model-factory';
13
13
  import { RpcPort } from '@dxos/rpc';
14
14
 
15
- import { EchoProxy, HaloProxy } from '../api';
16
15
  import { DevtoolsHook } from '../devtools';
17
- import { ClientServiceProvider, ClientServices, RemoteServiceConnectionTimeout } from '../interfaces';
18
- import { InvalidConfigurationError } from '../interfaces/errors';
19
16
  import { Runtime } from '../proto/gen/dxos/config';
17
+ import { ClientServiceProvider, ClientServices, ClientServiceHost, ClientServiceProxy, HaloSigner } from '../services';
20
18
  import { createWindowMessagePort, isNode } from '../util';
21
19
  import { DXOS_VERSION } from '../version';
22
- import { ClientServiceHost } from './service-host';
23
- import { ClientServiceProxy } from './service-proxy';
20
+ import { InvalidConfigurationError, RemoteServiceConnectionTimeout } from './errors';
21
+ import { Echo, EchoProxy, Halo, HaloProxy } from './proxies';
24
22
 
25
23
  const log = debug('dxos:client');
26
24
 
@@ -44,6 +42,11 @@ export interface ClientOptions {
44
42
  * Only used when remote=true.
45
43
  */
46
44
  rpcPort?: RpcPort;
45
+
46
+ /**
47
+ *
48
+ */
49
+ signer?: HaloSigner
47
50
  }
48
51
 
49
52
  /**
@@ -67,7 +70,8 @@ export class Client {
67
70
  * Creates the client object based on supplied configuration.
68
71
  * Requires initialization after creating by calling `.initialize()`.
69
72
  */
70
- constructor (config: ConfigObject | Config = { version: 1 }, options: ClientOptions = {}) {
73
+ // TODO(burdon): Remove or factor out default config?
74
+ constructor (config: ConfigObject | Config = defaultConfig, options: ClientOptions = {}) {
71
75
  if (typeof config !== 'object' || config == null) {
72
76
  throw new InvalidParameterError('Invalid config.');
73
77
  }
@@ -113,7 +117,7 @@ export class Client {
113
117
  /**
114
118
  * ECHO database.
115
119
  */
116
- get echo (): EchoProxy {
120
+ get echo (): Echo {
117
121
  assert(this._echo, 'Client not initialized.');
118
122
  return this._echo;
119
123
  }
@@ -121,17 +125,12 @@ export class Client {
121
125
  /**
122
126
  * HALO credentials.
123
127
  */
124
- get halo (): HaloProxy {
128
+ get halo (): Halo {
125
129
  assert(this._halo, 'Client not initialized.');
126
130
  return this._halo;
127
131
  }
128
132
 
129
- /**
130
- * Client services that can be proxied.
131
- */
132
- get services (): ClientServices {
133
- return this._serviceProvider.services;
134
- }
133
+ // TODO(burdon): Expose mesh for messaging?
135
134
 
136
135
  /**
137
136
  * Returns true if client is connected to a remote services protvider.
@@ -140,6 +139,14 @@ export class Client {
140
139
  return this._serviceProvider instanceof ClientServiceProxy;
141
140
  }
142
141
 
142
+ /**
143
+ * Client services that can be proxied.
144
+ */
145
+ // TODO(burdon): Remove from API?
146
+ get services (): ClientServices {
147
+ return this._serviceProvider.services;
148
+ }
149
+
143
150
  /**
144
151
  * Initializes internal resources in an idempotent way.
145
152
  * Required before using the Client instance.
@@ -240,7 +247,7 @@ export class Client {
240
247
  * Registers a new ECHO model.
241
248
  */
242
249
  registerModel (constructor: ModelConstructor<any>): this {
243
- this.echo.modelFactory.registerModel(constructor);
250
+ this._echo.modelFactory.registerModel(constructor);
244
251
  return this;
245
252
  }
246
253
 
File without changes
package/src/api/index.ts CHANGED
@@ -2,7 +2,11 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- export * from './echo-proxy';
6
- export * from './halo-proxy';
5
+ export { SignRequest, SignResponse } from '../proto/gen/dxos/client';
6
+ export { HaloSigner } from '../services';
7
+
8
+ export * from './client';
9
+ export * from './errors';
7
10
  export * from './invitations';
8
- export * from './party-proxy';
11
+ export * from './proxies';
12
+ export * from './serializer';
@@ -11,9 +11,7 @@ import { ConfigObject } from '@dxos/config';
11
11
  import { Client } from './client';
12
12
 
13
13
  describe('Client', () => {
14
- describe('Local-only tests', () => {
15
-
16
- });
14
+ describe('Local-only tests', () => {});
17
15
 
18
16
  describe('With persistent storage', () => {
19
17
  test('persistent storage', async () => {
@@ -32,11 +30,8 @@ describe('Client', () => {
32
30
  {
33
31
  const client = new Client(config);
34
32
  await client.initialize();
35
-
36
33
  await client.halo.createProfile({ username: 'test-user' });
37
-
38
34
  expect(client.halo.profile).toBeDefined();
39
-
40
35
  await client.destroy();
41
36
  }
42
37
 
@@ -44,7 +39,6 @@ describe('Client', () => {
44
39
  const client = new Client(config);
45
40
  await client.initialize();
46
41
  await waitForCondition(() => !!client.halo.profile);
47
-
48
42
  expect(client.halo.profile).toBeDefined();
49
43
  await client.destroy();
50
44
  }
@@ -13,11 +13,10 @@ import { ModelFactory } from '@dxos/model-factory';
13
13
  import { ObjectModel } from '@dxos/object-model';
14
14
  import { ComplexMap, SubscriptionGroup } from '@dxos/util';
15
15
 
16
- import { ClientServiceHost } from '../client/service-host';
17
- import { ClientServiceProvider } from '../interfaces';
16
+ import { ClientServiceHost, ClientServiceProvider } from '../../services';
17
+ import { Invitation, InvitationProxy } from '../invitations';
18
18
  import { HaloProxy } from './halo-proxy';
19
- import { Invitation, InvitationProxy } from './invitations';
20
- import { Party } from './party-proxy';
19
+ import { Party, PartyProxy } from './party-proxy';
21
20
 
22
21
  export class PartyInvitation extends Invitation<Party> {
23
22
  /**
@@ -28,11 +27,24 @@ export class PartyInvitation extends Invitation<Party> {
28
27
  }
29
28
  }
30
29
 
30
+ /**
31
+ * ECHO API.
32
+ */
33
+ // TODO(burdon): Separate public API form implementation (move comments here).
34
+ export interface Echo {
35
+ info (): { parties: number }
36
+ createParty (): Promise<Party>
37
+ cloneParty (snapshot: PartySnapshot): Promise<Party>
38
+ getParty (partyKey: PartyKey): Party | undefined
39
+ queryParties (): ResultSet<Party>
40
+ acceptInvitation (invitationDescriptor: InvitationDescriptor): PartyInvitation
41
+ }
42
+
31
43
  /**
32
44
  * Client proxy to local/remote ECHO service.
33
45
  */
34
- export class EchoProxy {
35
- private readonly _parties = new ComplexMap<PublicKey, Party>(key => key.toHex());
46
+ export class EchoProxy implements Echo {
47
+ private readonly _parties = new ComplexMap<PublicKey, PartyProxy>(key => key.toHex());
36
48
  private readonly _partiesChanged = new Event();
37
49
  private readonly _subscriptions = new SubscriptionGroup();
38
50
  private readonly _modelFactory: ModelFactory;
@@ -41,8 +53,8 @@ export class EchoProxy {
41
53
  private readonly _serviceProvider: ClientServiceProvider,
42
54
  private readonly _haloProxy: HaloProxy
43
55
  ) {
44
- this._modelFactory = _serviceProvider instanceof ClientServiceHost
45
- ? _serviceProvider.echo.modelFactory : new ModelFactory();
56
+ this._modelFactory =
57
+ _serviceProvider instanceof ClientServiceHost ? _serviceProvider.echo.modelFactory : new ModelFactory();
46
58
 
47
59
  this._modelFactory.registerModel(ObjectModel); // Register object-model by default.
48
60
  }
@@ -55,6 +67,7 @@ export class EchoProxy {
55
67
  if (this._serviceProvider instanceof ClientServiceHost) {
56
68
  return this._serviceProvider.echo.networkManager;
57
69
  }
70
+
58
71
  throw new Error('Network Manager not available in service proxy.');
59
72
  }
60
73
 
@@ -80,7 +93,7 @@ export class EchoProxy {
80
93
  if (!this._parties.has(party.publicKey)) {
81
94
  await this._haloProxy.profileChanged.waitForCondition(() => !!this._haloProxy.profile);
82
95
 
83
- const partyProxy = new Party(this._serviceProvider, this._modelFactory, party, this._haloProxy.profile!.publicKey);
96
+ const partyProxy = new PartyProxy(this._serviceProvider, this._modelFactory, party, this._haloProxy.profile!.publicKey);
84
97
  await partyProxy.initialize();
85
98
  this._parties.set(partyProxy.key, partyProxy);
86
99
 
@@ -139,8 +152,10 @@ export class EchoProxy {
139
152
  partyReceived();
140
153
  }
141
154
  };
155
+
142
156
  this._partiesChanged.on(handler);
143
157
  handler();
158
+
144
159
  await partyReceivedPromise;
145
160
  this._partiesChanged.off(handler);
146
161
 
@@ -177,8 +192,11 @@ export class EchoProxy {
177
192
  return this._parties.get(partyKey);
178
193
  }
179
194
 
195
+ /**
196
+ *
197
+ */
180
198
  queryParties (): ResultSet<Party> {
181
- return new ResultSet(this._partiesChanged, () => Array.from(this._parties.values()));
199
+ return new ResultSet<Party>(this._partiesChanged, () => Array.from(this._parties.values()));
182
200
  }
183
201
 
184
202
  /**
@@ -4,17 +4,47 @@
4
4
 
5
5
  import { Event } from '@dxos/async';
6
6
  import { KeyRecord } from '@dxos/credentials';
7
+ import { PublicKey } from '@dxos/crypto';
7
8
  import { Contact, CreateProfileOptions, InvitationDescriptor, PartyMember, ResultSet } from '@dxos/echo-db';
8
9
  import { SubscriptionGroup } from '@dxos/util';
9
10
 
10
- import { ClientServiceProvider } from '../interfaces';
11
- import { Profile, SignRequest } from '../proto/gen/dxos/client';
12
- import { Invitation, InvitationProxy, InvitationRequest } from './invitations';
11
+ import { Profile, SignRequest, SignResponse } from '../../proto/gen/dxos/client';
12
+ import { ClientServiceProvider } from '../../services';
13
+ import { Invitation, InvitationProxy, InvitationRequest } from '../invitations';
14
+
15
+ /**
16
+ * HALO API.
17
+ */
18
+ // TODO(burdon): Separate public API form implementation (move comments here).
19
+ export interface Halo {
20
+ info (): { key?: PublicKey }
21
+
22
+ get profile (): Profile | undefined
23
+ createProfile (options?: CreateProfileOptions): Promise<Profile>
24
+ recoverProfile (seedPhrase: string): Promise<Profile>
25
+
26
+ /**
27
+ * @deprecated
28
+ */
29
+ subscribeToProfile (callback: (profile: Profile) => void): void
30
+
31
+ queryContacts (): ResultSet<Contact>
32
+ createInvitation (): Promise<InvitationRequest>
33
+ acceptInvitation (invitationDescriptor: InvitationDescriptor): Invitation
34
+
35
+ addKeyRecord (keyRecord: KeyRecord): Promise<void>
36
+ sign (request: SignRequest): Promise<SignResponse>
37
+
38
+ setGlobalPreference (key: string, value: string): Promise<void>
39
+ getGlobalPreference (key: string): Promise<string | undefined>
40
+ setDevicePreference (key: string, value: string): Promise<void>
41
+ getDevicePreference (key: string): Promise<string | undefined>
42
+ }
13
43
 
14
44
  /**
15
45
  * Client proxy to local/remote HALO service.
16
46
  */
17
- export class HaloProxy {
47
+ export class HaloProxy implements Halo {
18
48
  private readonly _invitationProxy = new InvitationProxy();
19
49
  private readonly _subscriptions = new SubscriptionGroup();
20
50
 
@@ -49,9 +79,12 @@ export class HaloProxy {
49
79
  return this._profile;
50
80
  }
51
81
 
52
- // TODO(burdon): Should be part of profile object. Or use standard Result object.
53
- subscribeToProfile (cb: () => void): () => void {
54
- return this.profileChanged.on(cb);
82
+ /**
83
+ * @deprecated
84
+ */
85
+ // TODO(burdon): Remove and expose event handler?
86
+ subscribeToProfile (callback: (profile: Profile) => void): () => void {
87
+ return this.profileChanged.on(() => callback(this._profile!));
55
88
  }
56
89
 
57
90
  /**
@@ -64,13 +97,6 @@ export class HaloProxy {
64
97
  return this._profile;
65
98
  }
66
99
 
67
- /**
68
- * Query for contacts. Contacts represent member keys across all known Parties.
69
- */
70
- queryContacts (): ResultSet<Contact> {
71
- return new ResultSet(this._contactsChanged, () => this._contacts);
72
- }
73
-
74
100
  /**
75
101
  * Joins an existing identity HALO from a recovery seed phrase.
76
102
  */
@@ -79,6 +105,13 @@ export class HaloProxy {
79
105
  return this._profile;
80
106
  }
81
107
 
108
+ /**
109
+ * Query for contacts. Contacts represent member keys across all known Parties.
110
+ */
111
+ queryContacts (): ResultSet<Contact> {
112
+ return new ResultSet(this._contactsChanged, () => this._contacts);
113
+ }
114
+
82
115
  /**
83
116
  * Creates an invitation to an existing HALO party.
84
117
  * Used to authorize another device of the same user.
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2021 DXOS.org
3
+ //
4
+
5
+ export * from './echo-proxy';
6
+ export * from './halo-proxy';
7
+ export * from './party-proxy';
@@ -5,28 +5,72 @@
5
5
  import { PublicKey } from '@dxos/crypto';
6
6
  import { failUndefined } from '@dxos/debug';
7
7
  import {
8
- PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, ActivationOptions, Database, Item, RemoteDatabaseBackend
8
+ PARTY_ITEM_TYPE,
9
+ PARTY_TITLE_PROPERTY,
10
+ ActivationOptions,
11
+ Database,
12
+ Item,
13
+ RemoteDatabaseBackend,
14
+ ResultSet,
15
+ PartyMember
9
16
  } from '@dxos/echo-db';
10
- import { PartyKey } from '@dxos/echo-protocol';
17
+ import { PartyKey, PartySnapshot } from '@dxos/echo-protocol';
11
18
  import { ModelFactory } from '@dxos/model-factory';
12
19
  import { ObjectModel, ObjectProperties } from '@dxos/object-model';
13
20
 
14
- import { ClientServiceHost } from '../client/service-host';
15
- import { ClientServiceProxy } from '../client/service-proxy';
16
- import { ClientServiceProvider } from '../interfaces';
17
- import { Party as PartyProto } from '../proto/gen/dxos/client';
18
- import { streamToResultSet } from '../util';
19
- import { InvitationRequest, InvitationProxy } from './invitations';
21
+ import { Party as PartyProto } from '../../proto/gen/dxos/client';
22
+ import { ClientServiceHost, ClientServiceProvider, ClientServiceProxy } from '../../services';
23
+ import { streamToResultSet } from '../../util';
24
+ import { InvitationRequest, InvitationProxy } from '../invitations';
20
25
 
21
26
  export interface CreationInvitationOptions {
22
27
  inviteeKey?: PublicKey
23
28
  }
24
29
 
30
+ /**
31
+ * Party API.
32
+ */
33
+ // TODO(burdon): Separate public API form implementation (move comments here).
34
+ export interface Party {
35
+ get key (): PublicKey
36
+ get isOpen (): boolean
37
+ get isActive (): boolean
38
+
39
+ get database (): Database
40
+ get select (): Database['select']
41
+ get reduce (): Database['reduce']
42
+
43
+ initialize (): Promise<void>
44
+ destroy (): Promise<void>
45
+
46
+ open (): Promise<void>
47
+ close (): Promise<void>
48
+ setActive (active: boolean, options: ActivationOptions): Promise<void>
49
+
50
+ setTitle (title: string): Promise<void>
51
+ getTitle (): string
52
+
53
+ get properties (): ObjectProperties
54
+ /**
55
+ * @deprecated
56
+ */
57
+ setProperty (key: string, value?: any): Promise<void>
58
+ /**
59
+ * @deprecated
60
+ */
61
+ getProperty (key: string, defaultValue?: any): any
62
+
63
+ queryMembers (): ResultSet<PartyMember>
64
+ createInvitation (options?: CreationInvitationOptions): Promise<InvitationRequest>
65
+
66
+ createSnapshot (): Promise<PartySnapshot>
67
+ }
68
+
25
69
  /**
26
70
  * Main public Party API.
27
71
  * Proxies requests to local/remove services.
28
72
  */
29
- export class Party {
73
+ export class PartyProxy implements Party {
30
74
  private readonly _database?: Database;
31
75
  private readonly _invitationProxy = new InvitationProxy();
32
76
 
@@ -65,6 +109,7 @@ export class Party {
65
109
  }
66
110
  }
67
111
 
112
+ // TODO(burdon): Getter require by react hook.
68
113
  get invitationProxy () {
69
114
  return this._invitationProxy;
70
115
  }
@@ -89,6 +134,20 @@ export class Party {
89
134
  return this._database;
90
135
  }
91
136
 
137
+ /**
138
+ * Returns a selection context, which can be used to traverse the object graph.
139
+ */
140
+ get select (): Database['select'] {
141
+ return this.database.select.bind(this.database);
142
+ }
143
+
144
+ /**
145
+ * Returns a selection context, which can be used to traverse the object graph.
146
+ */
147
+ get reduce (): Database['reduce'] {
148
+ return this.database.reduce.bind(this.database);
149
+ }
150
+
92
151
  /**
93
152
  * Called by EchoProxy open.
94
153
  */
@@ -111,11 +170,14 @@ export class Party {
111
170
  }
112
171
 
113
172
  async open () {
114
- return this.setOpen(true);
173
+ await this._setOpen(true);
115
174
  }
116
175
 
117
- // TODO(burdon): Requires comment.
118
- async setOpen (open: boolean) {
176
+ async close () {
177
+ await this._setOpen(false);
178
+ }
179
+
180
+ async _setOpen (open: boolean) {
119
181
  await this._serviceProvider.services.PartyService.setPartyState({
120
182
  partyKey: this.key,
121
183
  open
@@ -142,7 +204,6 @@ export class Party {
142
204
  */
143
205
  async setTitle (title: string) {
144
206
  await this.setProperty(PARTY_TITLE_PROPERTY, title);
145
- return this;
146
207
  }
147
208
 
148
209
  /**
@@ -157,7 +218,6 @@ export class Party {
157
218
  */
158
219
  async setProperty (key: string, value?: any) {
159
220
  await this.properties.set(key, value);
160
- return this;
161
221
  }
162
222
 
163
223
  /**
@@ -167,20 +227,6 @@ export class Party {
167
227
  return this.properties.get(key, defaultValue);
168
228
  }
169
229
 
170
- /**
171
- * Returns a selection context, which can be used to traverse the object graph.
172
- */
173
- get select (): Database['select'] {
174
- return this.database.select.bind(this.database);
175
- }
176
-
177
- /**
178
- * Returns a selection context, which can be used to traverse the object graph.
179
- */
180
- get reduce (): Database['reduce'] {
181
- return this.database.reduce.bind(this.database);
182
- }
183
-
184
230
  /**
185
231
  * Return set of party members.
186
232
  */
@@ -208,6 +254,9 @@ export class Party {
208
254
  return this._invitationProxy.createInvitationRequest({ stream });
209
255
  }
210
256
 
257
+ /**
258
+ * Implementation method.
259
+ */
211
260
  createSnapshot () {
212
261
  return this._serviceProvider.services.PartyService.createSnapshot({ partyKey: this.key });
213
262
  }
@@ -2,12 +2,14 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { Party } from '../api';
6
- import { Client } from '../client';
7
- import { schema } from '../proto/gen/';
5
+ import { Client, Party } from '../api';
6
+ import { schema } from '../proto/gen';
8
7
 
9
8
  const partyCodec = schema.getCodecForType('dxos.echo.snapshot.PartySnapshot');
10
9
 
10
+ /**
11
+ * Import/export party.
12
+ */
11
13
  export class PartySerializer {
12
14
  constructor (
13
15
  private readonly _client: Client
@@ -18,13 +20,7 @@ export class PartySerializer {
18
20
  return new Blob([partyCodec.encode(snapshot)]);
19
21
  }
20
22
 
21
- async deserializeParty (partyToImport: File | Uint8Array) {
22
- let data;
23
- if (partyToImport instanceof File) {
24
- data = await new Uint8Array(await partyToImport.arrayBuffer());
25
- } else {
26
- data = partyToImport;
27
- }
23
+ async deserializeParty (data: Uint8Array) {
28
24
  return await this._client.echo.cloneParty(partyCodec.decode(data));
29
25
  }
30
26
  }
@@ -9,25 +9,24 @@ import { FeedStore } from '@dxos/feed-store';
9
9
  import { ModelFactory } from '@dxos/model-factory';
10
10
  import { NetworkManager } from '@dxos/network-manager';
11
11
 
12
- import { Client } from '../client';
13
- import { ClientServiceProvider } from '../interfaces';
12
+ import { Client } from '../api';
13
+ import { ClientServiceProvider } from '../services';
14
14
 
15
15
  /**
16
16
  * A hook bound to window.__DXOS__.
17
17
  */
18
18
  export interface DevtoolsHook {
19
19
  // TODO(marik-d): Reduce to just exporting ClientServices.
20
-
21
- serviceHost: ClientServiceProvider,
22
- client: Client,
20
+ serviceHost: ClientServiceProvider
21
+ client: Client
23
22
  }
24
23
 
25
24
  export interface DevtoolsServiceDependencies {
26
- echo: ECHO,
27
- feedStore: FeedStore,
28
- networkManager: NetworkManager,
29
- modelFactory: ModelFactory,
30
- keyring: Keyring,
31
25
  debug: any
32
26
  config: Config
27
+ feedStore: FeedStore
28
+ networkManager: NetworkManager
29
+ keyring: Keyring
30
+ echo: ECHO
31
+ modelFactory: ModelFactory
33
32
  }