@dxos/client-services 0.10.0 → 0.11.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 (304) hide show
  1. package/dist/lib/chunk-client-services-layer.mjs +11425 -0
  2. package/dist/lib/chunk-client-services-layer.mjs.map +1 -0
  3. package/dist/lib/chunk-decorate.mjs +9 -0
  4. package/dist/lib/index.mjs +731 -0
  5. package/dist/lib/index.mjs.map +1 -0
  6. package/dist/lib/packlets/diagnostics/browser-diagnostics-broadcast.mjs +72 -0
  7. package/dist/lib/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +1 -0
  8. package/dist/lib/packlets/diagnostics/diagnostics-broadcast.mjs +14 -0
  9. package/dist/lib/packlets/diagnostics/diagnostics-broadcast.mjs.map +1 -0
  10. package/dist/lib/packlets/locks/browser.mjs +105 -0
  11. package/dist/lib/packlets/locks/browser.mjs.map +1 -0
  12. package/dist/lib/packlets/locks/node.mjs +53 -0
  13. package/dist/lib/packlets/locks/node.mjs.map +1 -0
  14. package/dist/lib/testing.mjs +570 -0
  15. package/dist/lib/testing.mjs.map +1 -0
  16. package/dist/types/src/index.d.ts +2 -0
  17. package/dist/types/src/index.d.ts.map +1 -1
  18. package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +21 -4
  19. package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
  20. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +8 -7
  21. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  22. package/dist/types/src/packlets/devices/devices-service.d.ts +7 -5
  23. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  24. package/dist/types/src/packlets/devtools/devtools.d.ts +30 -29
  25. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  26. package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
  27. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  28. package/dist/types/src/packlets/devtools/network.d.ts +2 -1
  29. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  30. package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
  31. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +2 -2
  32. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
  33. package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -1
  34. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +1 -8
  35. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
  36. package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
  37. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  38. package/dist/types/src/packlets/identity/contacts-service.d.ts +9 -6
  39. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  40. package/dist/types/src/packlets/identity/identity-manager.d.ts +32 -3
  41. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  42. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +23 -4
  43. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  44. package/dist/types/src/packlets/identity/identity-service.d.ts +15 -20
  45. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  46. package/dist/types/src/packlets/identity/identity.d.ts +2 -2
  47. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  48. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
  49. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +17 -0
  50. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  51. package/dist/types/src/packlets/invitations/invitations-manager.d.ts +25 -4
  52. package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
  53. package/dist/types/src/packlets/invitations/invitations-service.d.ts +11 -11
  54. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  55. package/dist/types/src/packlets/logging/logging-service.d.ts +14 -12
  56. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  57. package/dist/types/src/packlets/metadata/index.d.ts +3 -0
  58. package/dist/types/src/packlets/metadata/index.d.ts.map +1 -0
  59. package/dist/types/src/packlets/metadata/metadata-store.d.ts +107 -0
  60. package/dist/types/src/packlets/metadata/metadata-store.d.ts.map +1 -0
  61. package/dist/types/src/packlets/metadata/metadata-store.test.d.ts +2 -0
  62. package/dist/types/src/packlets/metadata/metadata-store.test.d.ts.map +1 -0
  63. package/dist/types/src/packlets/metadata/sqlite-metadata-store.d.ts +65 -0
  64. package/dist/types/src/packlets/metadata/sqlite-metadata-store.d.ts.map +1 -0
  65. package/dist/types/src/packlets/network/network-service.d.ts +15 -14
  66. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  67. package/dist/types/src/packlets/pipeline/codec.d.ts +11 -0
  68. package/dist/types/src/packlets/pipeline/codec.d.ts.map +1 -0
  69. package/dist/types/src/packlets/pipeline/feeds.d.ts +7 -0
  70. package/dist/types/src/packlets/pipeline/feeds.d.ts.map +1 -0
  71. package/dist/types/src/packlets/pipeline/index.d.ts +5 -0
  72. package/dist/types/src/packlets/pipeline/index.d.ts.map +1 -0
  73. package/dist/types/src/packlets/pipeline/message-selector.d.ts +11 -0
  74. package/dist/types/src/packlets/pipeline/message-selector.d.ts.map +1 -0
  75. package/dist/types/src/packlets/pipeline/pipeline-stress.test.d.ts +2 -0
  76. package/dist/types/src/packlets/pipeline/pipeline-stress.test.d.ts.map +1 -0
  77. package/dist/types/src/packlets/pipeline/pipeline.d.ts +131 -0
  78. package/dist/types/src/packlets/pipeline/pipeline.d.ts.map +1 -0
  79. package/dist/types/src/packlets/pipeline/pipeline.test.d.ts +2 -0
  80. package/dist/types/src/packlets/pipeline/pipeline.test.d.ts.map +1 -0
  81. package/dist/types/src/packlets/pipeline/testing/index.d.ts +2 -0
  82. package/dist/types/src/packlets/pipeline/testing/index.d.ts.map +1 -0
  83. package/dist/types/src/packlets/pipeline/testing/test-feed-builder.d.ts +9 -0
  84. package/dist/types/src/packlets/pipeline/testing/test-feed-builder.d.ts.map +1 -0
  85. package/dist/types/src/packlets/pipeline/timeframe-clock.d.ts +31 -0
  86. package/dist/types/src/packlets/pipeline/timeframe-clock.d.ts.map +1 -0
  87. package/dist/types/src/packlets/services/client-services-layer.d.ts +21 -0
  88. package/dist/types/src/packlets/services/client-services-layer.d.ts.map +1 -0
  89. package/dist/types/src/packlets/services/cross-device-space-synchronizer.d.ts +28 -0
  90. package/dist/types/src/packlets/services/cross-device-space-synchronizer.d.ts.map +1 -0
  91. package/dist/types/src/packlets/services/effect-rpc.test.d.ts +2 -0
  92. package/dist/types/src/packlets/services/effect-rpc.test.d.ts.map +1 -0
  93. package/dist/types/src/packlets/services/feed-syncer.d.ts +22 -2
  94. package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -1
  95. package/dist/types/src/packlets/services/index.d.ts +2 -2
  96. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  97. package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
  98. package/dist/types/src/packlets/services/service-context.d.ts +38 -57
  99. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  100. package/dist/types/src/packlets/services/service-host.d.ts +82 -31
  101. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  102. package/dist/types/src/packlets/services/sqlite-storage.d.ts +29 -0
  103. package/dist/types/src/packlets/services/sqlite-storage.d.ts.map +1 -1
  104. package/dist/types/src/packlets/services/sqlite-storage.test.d.ts +2 -0
  105. package/dist/types/src/packlets/services/sqlite-storage.test.d.ts.map +1 -0
  106. package/dist/types/src/packlets/space/admission-discovery-extension.d.ts +30 -0
  107. package/dist/types/src/packlets/space/admission-discovery-extension.d.ts.map +1 -0
  108. package/dist/types/src/packlets/space/auth.d.ts +24 -0
  109. package/dist/types/src/packlets/space/auth.d.ts.map +1 -0
  110. package/dist/types/src/packlets/space/control-pipeline.d.ts +46 -0
  111. package/dist/types/src/packlets/space/control-pipeline.d.ts.map +1 -0
  112. package/dist/types/src/packlets/space/control-pipeline.test.d.ts +2 -0
  113. package/dist/types/src/packlets/space/control-pipeline.test.d.ts.map +1 -0
  114. package/dist/types/src/packlets/space/index.d.ts +6 -0
  115. package/dist/types/src/packlets/space/index.d.ts.map +1 -0
  116. package/dist/types/src/packlets/space/replication.browser.test.d.ts +2 -0
  117. package/dist/types/src/packlets/space/replication.browser.test.d.ts.map +1 -0
  118. package/dist/types/src/packlets/space/space-manager.browser.test.d.ts +2 -0
  119. package/dist/types/src/packlets/space/space-manager.browser.test.d.ts.map +1 -0
  120. package/dist/types/src/packlets/space/space-manager.d.ts +72 -0
  121. package/dist/types/src/packlets/space/space-manager.d.ts.map +1 -0
  122. package/dist/types/src/packlets/space/space-protocol.browser.test.d.ts +2 -0
  123. package/dist/types/src/packlets/space/space-protocol.browser.test.d.ts.map +1 -0
  124. package/dist/types/src/packlets/space/space-protocol.d.ts +99 -0
  125. package/dist/types/src/packlets/space/space-protocol.d.ts.map +1 -0
  126. package/dist/types/src/packlets/space/space-protocol.test.d.ts +2 -0
  127. package/dist/types/src/packlets/space/space-protocol.test.d.ts.map +1 -0
  128. package/dist/types/src/packlets/space/space.d.ts +65 -0
  129. package/dist/types/src/packlets/space/space.d.ts.map +1 -0
  130. package/dist/types/src/packlets/space/space.test.d.ts +2 -0
  131. package/dist/types/src/packlets/space/space.test.d.ts.map +1 -0
  132. package/dist/types/src/packlets/space/testing/change-metadata.d.ts +8 -0
  133. package/dist/types/src/packlets/space/testing/change-metadata.d.ts.map +1 -0
  134. package/dist/types/src/packlets/space/testing/index.d.ts +4 -0
  135. package/dist/types/src/packlets/space/testing/index.d.ts.map +1 -0
  136. package/dist/types/src/packlets/space/testing/test-agent-builder.d.ts +62 -0
  137. package/dist/types/src/packlets/space/testing/test-agent-builder.d.ts.map +1 -0
  138. package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts +1 -1
  139. package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts.map +1 -1
  140. package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts.map +1 -1
  141. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +40 -7
  142. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  143. package/dist/types/src/packlets/spaces/data-space.d.ts +3 -1
  144. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  145. package/dist/types/src/packlets/spaces/genesis.d.ts +1 -1
  146. package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
  147. package/dist/types/src/packlets/spaces/spaces-service.d.ts +25 -23
  148. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  149. package/dist/types/src/packlets/storage/level.d.ts.map +1 -1
  150. package/dist/types/src/packlets/system/system-service.d.ts +18 -18
  151. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  152. package/dist/types/src/packlets/testing/invitation-utils.d.ts +1 -1
  153. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  154. package/dist/types/src/packlets/testing/test-builder.d.ts +7 -6
  155. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  156. package/dist/types/src/packlets/worker/worker-runtime.d.ts +41 -58
  157. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  158. package/dist/types/src/packlets/worker/worker-session.d.ts +21 -8
  159. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
  160. package/dist/types/src/testing/index.d.ts +1 -0
  161. package/dist/types/src/testing/index.d.ts.map +1 -1
  162. package/dist/types/src/version.d.ts +1 -1
  163. package/dist/types/tsconfig.tsbuildinfo +1 -1
  164. package/package.json +52 -48
  165. package/src/index.ts +2 -0
  166. package/src/packlets/agents/edge-agent-manager.ts +56 -15
  167. package/src/packlets/agents/edge-agent-service.ts +25 -15
  168. package/src/packlets/devices/devices-service.test.ts +20 -19
  169. package/src/packlets/devices/devices-service.ts +17 -17
  170. package/src/packlets/devtools/devtools.ts +133 -75
  171. package/src/packlets/devtools/feeds.ts +2 -1
  172. package/src/packlets/devtools/network.ts +42 -12
  173. package/src/packlets/devtools/spaces.ts +1 -1
  174. package/src/packlets/diagnostics/diagnostics-broadcast.ts +4 -2
  175. package/src/packlets/diagnostics/diagnostics-collector.ts +5 -18
  176. package/src/packlets/diagnostics/diagnostics.ts +0 -11
  177. package/src/packlets/identity/authenticator.ts +2 -1
  178. package/src/packlets/identity/contacts-service.ts +46 -37
  179. package/src/packlets/identity/identity-manager.test.ts +3 -1
  180. package/src/packlets/identity/identity-manager.ts +73 -5
  181. package/src/packlets/identity/identity-recovery-manager.ts +56 -7
  182. package/src/packlets/identity/identity-service.test.ts +27 -18
  183. package/src/packlets/identity/identity-service.ts +114 -71
  184. package/src/packlets/identity/identity.test.ts +4 -9
  185. package/src/packlets/identity/identity.ts +1 -2
  186. package/src/packlets/invitations/edge-invitation-handler.ts +0 -1
  187. package/src/packlets/invitations/invitations-handler.ts +39 -3
  188. package/src/packlets/invitations/invitations-manager.ts +52 -4
  189. package/src/packlets/invitations/invitations-service.ts +54 -28
  190. package/src/packlets/logging/logging-service.ts +41 -29
  191. package/src/packlets/logging/logging.test.ts +28 -15
  192. package/src/packlets/metadata/index.ts +6 -0
  193. package/src/packlets/metadata/metadata-store.test.ts +49 -0
  194. package/src/packlets/metadata/metadata-store.ts +446 -0
  195. package/src/packlets/metadata/sqlite-metadata-store.ts +409 -0
  196. package/src/packlets/network/network-service.test.ts +19 -12
  197. package/src/packlets/network/network-service.ts +96 -29
  198. package/src/packlets/pipeline/codec.ts +18 -0
  199. package/src/packlets/pipeline/feeds.ts +22 -0
  200. package/src/packlets/pipeline/index.ts +8 -0
  201. package/src/packlets/pipeline/message-selector.ts +35 -0
  202. package/src/packlets/pipeline/pipeline-stress.test.ts +230 -0
  203. package/src/packlets/pipeline/pipeline.test.ts +140 -0
  204. package/src/packlets/pipeline/pipeline.ts +439 -0
  205. package/src/packlets/pipeline/testing/index.ts +5 -0
  206. package/src/packlets/pipeline/testing/test-feed-builder.ts +19 -0
  207. package/src/packlets/pipeline/timeframe-clock.ts +81 -0
  208. package/src/packlets/services/client-services-layer.ts +186 -0
  209. package/src/packlets/services/cross-device-space-synchronizer.ts +132 -0
  210. package/src/packlets/services/effect-rpc.test.ts +314 -0
  211. package/src/packlets/services/feed-syncer.ts +57 -3
  212. package/src/packlets/services/index.ts +2 -2
  213. package/src/packlets/services/platform.ts +0 -6
  214. package/src/packlets/services/service-context.ts +219 -522
  215. package/src/packlets/services/service-host.test.ts +34 -11
  216. package/src/packlets/services/service-host.ts +693 -213
  217. package/src/packlets/services/spec.md +106 -0
  218. package/src/packlets/services/sqlite-storage.test.ts +48 -0
  219. package/src/packlets/services/sqlite-storage.ts +117 -20
  220. package/src/packlets/space/admission-discovery-extension.ts +91 -0
  221. package/src/packlets/space/auth.ts +92 -0
  222. package/src/packlets/space/control-pipeline.test.ts +165 -0
  223. package/src/packlets/space/control-pipeline.ts +229 -0
  224. package/src/packlets/space/index.ts +9 -0
  225. package/src/packlets/space/replication.browser.test.ts +58 -0
  226. package/src/packlets/space/space-manager.browser.test.ts +40 -0
  227. package/src/packlets/space/space-manager.ts +224 -0
  228. package/src/packlets/space/space-protocol.browser.test.ts +129 -0
  229. package/src/packlets/space/space-protocol.test.ts +158 -0
  230. package/src/packlets/space/space-protocol.ts +308 -0
  231. package/src/packlets/space/space.test.ts +181 -0
  232. package/src/packlets/space/space.ts +196 -0
  233. package/src/packlets/space/testing/change-metadata.ts +27 -0
  234. package/src/packlets/space/testing/index.ts +7 -0
  235. package/src/packlets/space/testing/test-agent-builder.ts +252 -0
  236. package/src/packlets/space-export/serialized-space-reader.ts +3 -1
  237. package/src/packlets/space-export/serialized-space-writer.ts +53 -30
  238. package/src/packlets/space-export/space-archive.test.ts +30 -0
  239. package/src/packlets/spaces/data-space-manager.test.ts +1 -1
  240. package/src/packlets/spaces/data-space-manager.ts +148 -33
  241. package/src/packlets/spaces/data-space.ts +29 -18
  242. package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
  243. package/src/packlets/spaces/genesis.ts +1 -1
  244. package/src/packlets/spaces/spaces-service.test.ts +35 -22
  245. package/src/packlets/spaces/spaces-service.ts +259 -180
  246. package/src/packlets/storage/level.ts +3 -1
  247. package/src/packlets/system/system-service.test.ts +31 -13
  248. package/src/packlets/system/system-service.ts +65 -37
  249. package/src/packlets/testing/invitation-utils.ts +3 -3
  250. package/src/packlets/testing/test-builder.ts +35 -20
  251. package/src/packlets/worker/worker-runtime.ts +222 -260
  252. package/src/packlets/worker/worker-session.ts +108 -91
  253. package/src/testing/index.ts +1 -0
  254. package/src/version.ts +1 -1
  255. package/dist/lib/browser/chunk-QCWEHHJW.mjs +0 -24
  256. package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +0 -7
  257. package/dist/lib/browser/chunk-XJRPB3GA.mjs +0 -22
  258. package/dist/lib/browser/chunk-XJRPB3GA.mjs.map +0 -7
  259. package/dist/lib/browser/chunk-XU5R2BMF.mjs +0 -8837
  260. package/dist/lib/browser/chunk-XU5R2BMF.mjs.map +0 -7
  261. package/dist/lib/browser/index.mjs +0 -876
  262. package/dist/lib/browser/index.mjs.map +0 -7
  263. package/dist/lib/browser/meta.json +0 -1
  264. package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +0 -88
  265. package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +0 -7
  266. package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +0 -11
  267. package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +0 -7
  268. package/dist/lib/browser/packlets/locks/browser.mjs +0 -86
  269. package/dist/lib/browser/packlets/locks/browser.mjs.map +0 -7
  270. package/dist/lib/browser/packlets/locks/node.mjs +0 -48
  271. package/dist/lib/browser/packlets/locks/node.mjs.map +0 -7
  272. package/dist/lib/browser/testing/index.mjs +0 -436
  273. package/dist/lib/browser/testing/index.mjs.map +0 -7
  274. package/dist/lib/node-esm/chunk-2DT3MZRL.mjs +0 -22
  275. package/dist/lib/node-esm/chunk-2DT3MZRL.mjs.map +0 -7
  276. package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +0 -24
  277. package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +0 -7
  278. package/dist/lib/node-esm/chunk-H5YTUD35.mjs +0 -8837
  279. package/dist/lib/node-esm/chunk-H5YTUD35.mjs.map +0 -7
  280. package/dist/lib/node-esm/index.mjs +0 -876
  281. package/dist/lib/node-esm/index.mjs.map +0 -7
  282. package/dist/lib/node-esm/meta.json +0 -1
  283. package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +0 -88
  284. package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +0 -7
  285. package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +0 -11
  286. package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +0 -7
  287. package/dist/lib/node-esm/packlets/locks/browser.mjs +0 -86
  288. package/dist/lib/node-esm/packlets/locks/browser.mjs.map +0 -7
  289. package/dist/lib/node-esm/packlets/locks/node.mjs +0 -48
  290. package/dist/lib/node-esm/packlets/locks/node.mjs.map +0 -7
  291. package/dist/lib/node-esm/testing/index.mjs +0 -436
  292. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  293. package/dist/types/src/packlets/services/client-rpc-server.d.ts +0 -24
  294. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +0 -1
  295. package/dist/types/src/packlets/services/service-registry.d.ts +0 -15
  296. package/dist/types/src/packlets/services/service-registry.d.ts.map +0 -1
  297. package/dist/types/src/packlets/services/service-registry.test.d.ts +0 -2
  298. package/dist/types/src/packlets/services/service-registry.test.d.ts.map +0 -1
  299. package/dist/types/src/testing/setup.d.ts +0 -3
  300. package/dist/types/src/testing/setup.d.ts.map +0 -1
  301. package/src/packlets/services/client-rpc-server.ts +0 -111
  302. package/src/packlets/services/service-registry.test.ts +0 -78
  303. package/src/packlets/services/service-registry.ts +0 -36
  304. package/src/testing/setup.ts +0 -11
@@ -2,16 +2,22 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { beforeEach, describe, expect, test } from 'vitest';
5
+ import * as Effect from 'effect/Effect';
6
+ import * as Option from 'effect/Option';
7
+ import * as Runtime from 'effect/Runtime';
8
+ import * as Stream from 'effect/Stream';
9
+ import { beforeEach, describe, expect, onTestFinished, test } from 'vitest';
6
10
 
7
11
  import { Event, Trigger } from '@dxos/async';
8
12
  import { Config } from '@dxos/config';
9
- import { type QueryStatusResponse, type SystemService, SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
13
+ import { EffectEx } from '@dxos/effect';
14
+ import { subscribeStream } from '@dxos/protocols';
15
+ import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
10
16
 
11
17
  import { SystemServiceImpl } from './system-service';
12
18
 
13
19
  describe('SystemService', () => {
14
- let systemService: SystemService;
20
+ let systemService: SystemServiceImpl;
15
21
  let config: Config;
16
22
  let statusUpdate: Event<void>;
17
23
  let currentStatus: SystemStatus;
@@ -45,35 +51,47 @@ describe('SystemService', () => {
45
51
  });
46
52
 
47
53
  test('getConfig returns config', async () => {
48
- expect(await systemService.getConfig()).to.deep.equal(config.values);
54
+ expect(await EffectEx.runPromise(systemService['SystemService.getConfig']())).to.deep.equal(config.values);
49
55
  });
50
56
 
51
57
  test('updateStatus triggers callback', async () => {
52
- await systemService.updateStatus({ status: SystemStatus.INACTIVE });
58
+ await EffectEx.runPromise(systemService['SystemService.updateStatus']({ status: SystemStatus.INACTIVE }));
53
59
  const result = await updateStatus.wait();
54
60
  expect(result).to.equal(SystemStatus.INACTIVE);
55
61
  });
56
62
 
57
63
  test('queryStatus returns initial status', async () => {
58
- const status = new Trigger<QueryStatusResponse>();
59
- systemService.queryStatus({}).subscribe((response) => {
60
- status.wake(response);
61
- });
62
- expect(await status.wait()).to.deep.equal({ status: SystemStatus.ACTIVE });
64
+ const response = await EffectEx.runPromise(
65
+ systemService['SystemService.queryStatus']({}).pipe(Stream.runHead, Effect.map(Option.getOrThrow)),
66
+ );
67
+ expect(response).to.deep.equal({ status: SystemStatus.ACTIVE });
63
68
  });
64
69
 
65
70
  test('queryStatus streams status changes', async () => {
66
71
  const statuses: SystemStatus[] = [];
67
- systemService.queryStatus({}).subscribe(({ status }) => {
68
- statuses.push(status);
72
+ const first = new Trigger();
73
+ const done = new Trigger();
74
+ const cleanup = subscribeStream(Runtime.defaultRuntime, systemService['SystemService.queryStatus']({}), {
75
+ onData: ({ status }) => {
76
+ statuses.push(status);
77
+ first.wake();
78
+ if (statuses.length === 3) {
79
+ done.wake();
80
+ }
81
+ },
69
82
  });
83
+ onTestFinished(cleanup);
84
+
85
+ // Wait for the initial emission so the status subscription is active before mutating.
86
+ await first.wait();
70
87
  changeStatus(SystemStatus.INACTIVE);
71
88
  changeStatus(SystemStatus.ACTIVE);
89
+ await done.wait();
72
90
  expect(statuses).to.deep.equal([SystemStatus.ACTIVE, SystemStatus.INACTIVE, SystemStatus.ACTIVE]);
73
91
  });
74
92
 
75
93
  test('reset triggers callback', async () => {
76
- await systemService.reset();
94
+ await EffectEx.runPromise(systemService['SystemService.reset']());
77
95
  const result = await reset.wait();
78
96
  expect(result).to.be.true;
79
97
  });
@@ -2,18 +2,22 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
+ import * as Effect from 'effect/Effect';
6
+ import * as EffectStream from 'effect/Stream';
7
+
5
8
  import { type Event } from '@dxos/async';
6
- import { Stream } from '@dxos/codec-protobuf/stream';
7
9
  import { type Config } from '@dxos/config';
8
10
  import {
9
11
  GetDiagnosticsRequest,
12
+ type GetDiagnosticsResponse,
10
13
  type Platform,
11
14
  type QueryStatusRequest,
12
15
  type QueryStatusResponse,
13
- type SystemService,
14
16
  type SystemStatus,
15
17
  type UpdateStatusRequest,
16
18
  } from '@dxos/protocols/proto/dxos/client/services';
19
+ import { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';
20
+ import { type SystemService } from '@dxos/protocols/rpc';
17
21
  import { type MaybePromise, jsonKeyReplacer } from '@dxos/util';
18
22
 
19
23
  import { type Diagnostics } from '../diagnostics';
@@ -28,15 +32,15 @@ export type SystemServiceOptions = {
28
32
  onReset: () => MaybePromise<void>;
29
33
  };
30
34
 
31
- export class SystemServiceImpl implements SystemService {
32
- private readonly _config?: SystemServiceOptions['config'];
33
- private readonly _statusUpdate: SystemServiceOptions['statusUpdate'];
34
- private readonly _getCurrentStatus: SystemServiceOptions['getCurrentStatus'];
35
- private readonly _onUpdateStatus: SystemServiceOptions['onUpdateStatus'];
36
- private readonly _onReset: SystemServiceOptions['onReset'];
37
- private readonly _getDiagnostics: SystemServiceOptions['getDiagnostics'];
35
+ export class SystemServiceImpl implements SystemService.Handlers {
36
+ private readonly '_config'?: SystemServiceOptions['config'];
37
+ private readonly '_statusUpdate': SystemServiceOptions['statusUpdate'];
38
+ private readonly '_getCurrentStatus': SystemServiceOptions['getCurrentStatus'];
39
+ private readonly '_onUpdateStatus': SystemServiceOptions['onUpdateStatus'];
40
+ private readonly '_onReset': SystemServiceOptions['onReset'];
41
+ private readonly '_getDiagnostics': SystemServiceOptions['getDiagnostics'];
38
42
 
39
- constructor({
43
+ 'constructor'({
40
44
  config,
41
45
  statusUpdate,
42
46
  getDiagnostics,
@@ -52,55 +56,79 @@ export class SystemServiceImpl implements SystemService {
52
56
  this._onReset = onReset;
53
57
  }
54
58
 
55
- async getConfig() {
56
- return (await this._config?.())?.values ?? {};
59
+ ['SystemService.getConfig'](): Effect.Effect<ConfigProto, Error> {
60
+ return Effect.tryPromise({
61
+ try: async () => (await this._config?.())?.values ?? {},
62
+ catch: (error) => error as Error,
63
+ });
57
64
  }
58
65
 
59
66
  /**
60
67
  * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
61
68
  */
62
- async getDiagnostics({ keys }: GetDiagnosticsRequest = {}) {
63
- const diagnostics = await this._getDiagnostics();
64
- return {
65
- timestamp: new Date(),
66
- diagnostics: JSON.parse(
67
- JSON.stringify(
68
- diagnostics,
69
- jsonKeyReplacer({
70
- truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
71
- humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE,
72
- }),
73
- ),
74
- ),
75
- };
69
+ ['SystemService.getDiagnostics']({ keys }: GetDiagnosticsRequest = {}): Effect.Effect<GetDiagnosticsResponse, Error> {
70
+ return Effect.tryPromise({
71
+ try: async () => {
72
+ const diagnostics = await this._getDiagnostics();
73
+ return {
74
+ timestamp: new Date(),
75
+ diagnostics: JSON.parse(
76
+ JSON.stringify(
77
+ diagnostics,
78
+ jsonKeyReplacer({
79
+ truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
80
+ humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE,
81
+ }),
82
+ ),
83
+ ),
84
+ };
85
+ },
86
+ catch: (error) => error as Error,
87
+ });
76
88
  }
77
89
 
78
- async getPlatform(): Promise<Platform> {
79
- return getPlatform();
90
+ ['SystemService.getPlatform'](): Effect.Effect<Platform, Error> {
91
+ return Effect.tryPromise({
92
+ try: async () => getPlatform(),
93
+ catch: (error) => error as Error,
94
+ });
80
95
  }
81
96
 
82
- async updateStatus({ status }: UpdateStatusRequest): Promise<void> {
83
- await this._onUpdateStatus(status);
97
+ ['SystemService.updateStatus']({ status }: UpdateStatusRequest): Effect.Effect<void, Error> {
98
+ return Effect.tryPromise({
99
+ try: async () => {
100
+ await this._onUpdateStatus(status);
101
+ },
102
+ catch: (error) => error as Error,
103
+ });
84
104
  }
85
105
 
86
106
  // TODO(burdon): Standardize interval option in stream request?
87
- queryStatus({ interval = 3_000 }: QueryStatusRequest = {}): Stream<QueryStatusResponse> {
88
- return new Stream(({ next }) => {
107
+ ['SystemService.queryStatus']({ interval = 3_000 }: QueryStatusRequest = {}): EffectStream.Stream<
108
+ QueryStatusResponse,
109
+ Error
110
+ > {
111
+ return EffectStream.async<QueryStatusResponse, Error>((emit) => {
89
112
  const update = () => {
90
- next({ status: this._getCurrentStatus() });
113
+ void emit.single({ status: this._getCurrentStatus() });
91
114
  };
92
115
 
93
116
  update();
94
117
  const unsubscribe = this._statusUpdate.on(() => update());
95
118
  const i = setInterval(update, interval);
96
- return () => {
119
+ return Effect.sync(() => {
97
120
  clearInterval(i);
98
121
  unsubscribe();
99
- };
122
+ });
100
123
  });
101
124
  }
102
125
 
103
- async reset(): Promise<void> {
104
- await this._onReset();
126
+ ['SystemService.reset'](): Effect.Effect<void, Error> {
127
+ return Effect.tryPromise({
128
+ try: async () => {
129
+ await this._onReset();
130
+ },
131
+ catch: (error) => error as Error,
132
+ });
105
133
  }
106
134
  }
@@ -9,7 +9,7 @@ import { invariant } from '@dxos/invariant';
9
9
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
10
10
  import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
11
11
 
12
- import { ServiceContext } from '../services';
12
+ import { ClientServicesHost, type ServiceContext } from '../services';
13
13
 
14
14
  /**
15
15
  * Strip secrets from invitation before giving it to the peer.
@@ -229,7 +229,7 @@ export const createInvitation = async (
229
229
  ...(options ?? {}),
230
230
  };
231
231
 
232
- if (host instanceof ServiceContext) {
232
+ if (host instanceof ClientServicesHost) {
233
233
  return host.invitationsManager.createInvitation(new Context(), {
234
234
  kind: Invitation.Kind.SPACE,
235
235
  ...options,
@@ -246,7 +246,7 @@ export const acceptInvitation = (
246
246
  ): AuthenticatingInvitation => {
247
247
  invitation = sanitizeInvitation(invitation);
248
248
 
249
- if (guest instanceof ServiceContext) {
249
+ if (guest instanceof ClientServicesHost) {
250
250
  return guest.invitationsManager.acceptInvitation(new Context(), {
251
251
  invitation,
252
252
  deviceProfile: guestDeviceProfile,
@@ -7,12 +7,11 @@ import * as Effect from 'effect/Effect';
7
7
  import * as Layer from 'effect/Layer';
8
8
  import * as ManagedRuntime from 'effect/ManagedRuntime';
9
9
 
10
- import { type Config } from '@dxos/config';
10
+ import { Config } from '@dxos/config';
11
11
  import { Context } from '@dxos/context';
12
12
  import { CredentialGenerator, createCredentialSignerWithChain } from '@dxos/credentials';
13
13
  import { failUndefined } from '@dxos/debug';
14
- import { EchoHost, MeshEchoReplicator, SpaceManager, valueEncoding } from '@dxos/echo-host';
15
- import { SqliteMetadataStore } from '@dxos/echo-host';
14
+ import { EchoHost, MeshEchoReplicator } from '@dxos/echo-host';
16
15
  import { RuntimeProvider } from '@dxos/effect';
17
16
  import { FeedFactory, FeedStore } from '@dxos/feed-store';
18
17
  import { SqliteKeyring } from '@dxos/keyring';
@@ -25,8 +24,11 @@ import * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
25
24
  import { SqliteBlobStore } from '@dxos/teleport-extension-object-sync';
26
25
 
27
26
  import { InvitationsHandler, InvitationsManager, SpaceInvitationProtocol } from '../invitations';
28
- import { ClientServicesHost, ServiceContext, type ServiceContextRuntimeProps } from '../services';
27
+ import { SqliteMetadataStore } from '../metadata';
28
+ import { valueEncoding } from '../pipeline';
29
+ import { ClientServicesHost, type ServiceContext, type ServiceContextRuntimeProps } from '../services';
29
30
  import { SqliteStorage } from '../services/sqlite-storage';
31
+ import { SpaceManager } from '../space';
30
32
  import { DataSpaceManager, type DataSpaceManagerRuntimeProps, type SigningContext } from '../spaces';
31
33
 
32
34
  //
@@ -55,23 +57,35 @@ export const createServiceContext = async ({
55
57
  }: {
56
58
  signalManagerFactory?: () => Promise<SignalManager>;
57
59
  runtimeProps?: ServiceContextRuntimeProps;
58
- } = {}) => {
60
+ } = {}): Promise<ServiceContext> => {
59
61
  const signalManager = await signalManagerFactory();
60
- const networkManager = new SwarmNetworkManager({
61
- signalManager,
62
- transportFactory: MemoryTransportFactory,
63
- });
64
62
 
63
+ // The host builds its component stack over this SQLite runtime; dispose it once the host closes so
64
+ // the layer-scoped finalizers (e.g. EchoHost) do not leak across tests.
65
65
  const runtime = ManagedRuntime.make(
66
66
  SqlTransaction.layer
67
67
  .pipe(Layer.provideMerge(sqliteLayerMemory), Layer.provideMerge(Reactivity.layer))
68
68
  .pipe(Layer.orDie),
69
- ).runtimeEffect;
69
+ );
70
70
 
71
- return new ServiceContext(networkManager, signalManager, undefined, undefined, runtime, {
72
- invitationConnectionDefaultProps: { teleport: { controlHeartbeatInterval: 200 } },
73
- ...runtimeProps,
71
+ const host = new ClientServicesHost({
72
+ config: new Config(),
73
+ signalManager,
74
+ transportFactory: MemoryTransportFactory,
75
+ runtime: runtime.runtimeEffect,
76
+ runtimeProps: {
77
+ invitationConnectionDefaultProps: { teleport: { controlHeartbeatInterval: 200 } },
78
+ ...runtimeProps,
79
+ },
74
80
  });
81
+
82
+ const closeHost = host.close.bind(host);
83
+ host.close = async (ctx = new Context()) => {
84
+ await closeHost(ctx);
85
+ await runtime.dispose();
86
+ };
87
+
88
+ return host;
75
89
  };
76
90
 
77
91
  export const createPeers = async (numPeers: number, signalManagerFactory?: () => Promise<SignalManager>) => {
@@ -204,7 +218,7 @@ export class TestPeer {
204
218
  spaceManager: this.spaceManager,
205
219
  metadataStore: this.metadataStore,
206
220
  keyring: this.keyring,
207
- signingContext: this.identity,
221
+ signingContextProvider: () => this.identity,
208
222
  feedStore: this.feedStore,
209
223
  echoHost: this.echoHost,
210
224
  invitationsManager: this.invitationsManager,
@@ -216,17 +230,18 @@ export class TestPeer {
216
230
  }
217
231
 
218
232
  get invitationsManager() {
219
- return (this._props.invitationsManager ??= new InvitationsManager(
220
- new InvitationsHandler(this.networkManager),
221
- (invitation) => {
233
+ if (!this._props.invitationsManager) {
234
+ const manager = new InvitationsManager(new InvitationsHandler(this.networkManager), this.metadataStore);
235
+ manager.setInvitationHandlerFactory((invitation) => {
222
236
  if (invitation.kind === Invitation.Kind.SPACE) {
223
237
  return new SpaceInvitationProtocol(this.dataSpaceManager, this.identity!, this.keyring, invitation.spaceKey!);
224
238
  } else {
225
239
  throw new Error('not implemented');
226
240
  }
227
- },
228
- this.metadataStore,
229
- ));
241
+ });
242
+ this._props.invitationsManager = manager;
243
+ }
244
+ return this._props.invitationsManager;
230
245
  }
231
246
 
232
247
  async createIdentity(): Promise<void> {