@dxos/echo-db 2.33.5-dev.ea3876ba → 2.33.5-dev.fee8f5fe

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 (411) hide show
  1. package/dist/src/api/index.d.ts +0 -5
  2. package/dist/src/api/index.d.ts.map +1 -1
  3. package/dist/src/api/index.js +5 -6
  4. package/dist/src/api/index.js.map +1 -1
  5. package/dist/src/api/schema.test.js +1 -1
  6. package/dist/src/api/schema.test.js.map +1 -1
  7. package/dist/src/echo.d.ts +1 -0
  8. package/dist/src/echo.d.ts.map +1 -1
  9. package/dist/src/echo.js +10 -21
  10. package/dist/src/echo.js.map +1 -1
  11. package/dist/src/echo.test.js +12 -4
  12. package/dist/src/echo.test.js.map +1 -1
  13. package/dist/src/halo/contact-manager.d.ts +2 -1
  14. package/dist/src/halo/contact-manager.d.ts.map +1 -1
  15. package/dist/src/halo/contact-manager.js +1 -1
  16. package/dist/src/halo/contact-manager.js.map +1 -1
  17. package/dist/src/halo/halo-factory.d.ts +4 -4
  18. package/dist/src/halo/halo-factory.d.ts.map +1 -1
  19. package/dist/src/halo/halo-factory.js +8 -13
  20. package/dist/src/halo/halo-factory.js.map +1 -1
  21. package/dist/src/halo/halo-party.d.ts +5 -4
  22. package/dist/src/halo/halo-party.d.ts.map +1 -1
  23. package/dist/src/halo/halo-party.js +16 -10
  24. package/dist/src/halo/halo-party.js.map +1 -1
  25. package/dist/src/halo/halo.d.ts +2 -2
  26. package/dist/src/halo/halo.d.ts.map +1 -1
  27. package/dist/src/halo/halo.test.js +4 -3
  28. package/dist/src/halo/halo.test.js.map +1 -1
  29. package/dist/src/halo/identity.js +2 -2
  30. package/dist/src/halo/identity.js.map +1 -1
  31. package/dist/src/halo/index.js +5 -1
  32. package/dist/src/halo/index.js.map +1 -1
  33. package/dist/src/halo/party-opener.d.ts +1 -1
  34. package/dist/src/halo/party-opener.d.ts.map +1 -1
  35. package/dist/src/halo/party-opener.js +5 -3
  36. package/dist/src/halo/party-opener.js.map +1 -1
  37. package/dist/src/halo/preferences.d.ts +1 -1
  38. package/dist/src/halo/preferences.d.ts.map +1 -1
  39. package/dist/src/halo/preferences.js +8 -11
  40. package/dist/src/halo/preferences.js.map +1 -1
  41. package/dist/src/index.d.ts +2 -2
  42. package/dist/src/index.d.ts.map +1 -1
  43. package/dist/src/index.js +7 -3
  44. package/dist/src/index.js.map +1 -1
  45. package/dist/src/invitations/greeting-initiator.d.ts +4 -5
  46. package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
  47. package/dist/src/invitations/greeting-initiator.js +4 -4
  48. package/dist/src/invitations/greeting-initiator.js.map +1 -1
  49. package/dist/src/invitations/greeting-protocol-provider.d.ts.map +1 -1
  50. package/dist/src/invitations/greeting-protocol-provider.js +5 -9
  51. package/dist/src/invitations/greeting-protocol-provider.js.map +1 -1
  52. package/dist/src/invitations/greeting-responder.d.ts +6 -4
  53. package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
  54. package/dist/src/invitations/greeting-responder.js +11 -14
  55. package/dist/src/invitations/greeting-responder.js.map +1 -1
  56. package/dist/src/invitations/halo-recovery-initiator.d.ts +1 -1
  57. package/dist/src/invitations/halo-recovery-initiator.d.ts.map +1 -1
  58. package/dist/src/invitations/halo-recovery-initiator.js +2 -2
  59. package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
  60. package/dist/src/invitations/index.js +5 -1
  61. package/dist/src/invitations/index.js.map +1 -1
  62. package/dist/src/invitations/invitation-descriptor.js +6 -2
  63. package/dist/src/invitations/invitation-descriptor.js.map +1 -1
  64. package/dist/src/invitations/invitation-factory.d.ts +5 -2
  65. package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
  66. package/dist/src/invitations/invitation-factory.js +4 -3
  67. package/dist/src/invitations/invitation-factory.js.map +1 -1
  68. package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
  69. package/dist/src/invitations/offline-invitation-claimer.js +7 -9
  70. package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
  71. package/dist/src/{database → packlets/database}/data-mirror.d.ts +0 -0
  72. package/dist/src/packlets/database/data-mirror.d.ts.map +1 -0
  73. package/dist/src/{database → packlets/database}/data-mirror.js +0 -0
  74. package/dist/src/packlets/database/data-mirror.js.map +1 -0
  75. package/dist/src/{database → packlets/database}/data-mirror.test.d.ts +0 -0
  76. package/dist/src/packlets/database/data-mirror.test.d.ts.map +1 -0
  77. package/dist/src/{database → packlets/database}/data-mirror.test.js +2 -2
  78. package/dist/src/packlets/database/data-mirror.test.js.map +1 -0
  79. package/dist/src/{database → packlets/database}/data-service-host.d.ts +0 -0
  80. package/dist/src/packlets/database/data-service-host.d.ts.map +1 -0
  81. package/dist/src/{database → packlets/database}/data-service-host.js +4 -3
  82. package/dist/src/packlets/database/data-service-host.js.map +1 -0
  83. package/dist/src/{database → packlets/database}/data-service-router.d.ts +0 -0
  84. package/dist/src/packlets/database/data-service-router.d.ts.map +1 -0
  85. package/dist/src/{database → packlets/database}/data-service-router.js +0 -0
  86. package/dist/src/packlets/database/data-service-router.js.map +1 -0
  87. package/dist/src/{database → packlets/database}/database-backend.d.ts +4 -5
  88. package/dist/src/packlets/database/database-backend.d.ts.map +1 -0
  89. package/dist/src/{database → packlets/database}/database-backend.js +5 -6
  90. package/dist/src/packlets/database/database-backend.js.map +1 -0
  91. package/dist/src/{api → packlets/database}/database.d.ts +2 -1
  92. package/dist/src/packlets/database/database.d.ts.map +1 -0
  93. package/dist/src/{api → packlets/database}/database.js +2 -2
  94. package/dist/src/packlets/database/database.js.map +1 -0
  95. package/dist/src/{api → packlets/database}/database.test.d.ts +0 -0
  96. package/dist/src/packlets/database/database.test.d.ts.map +1 -0
  97. package/dist/src/{api → packlets/database}/database.test.js +3 -3
  98. package/dist/src/packlets/database/database.test.js.map +1 -0
  99. package/dist/src/{api → packlets/database}/entity.d.ts +1 -1
  100. package/dist/src/packlets/database/entity.d.ts.map +1 -0
  101. package/dist/src/{api → packlets/database}/entity.js +0 -0
  102. package/dist/src/packlets/database/entity.js.map +1 -0
  103. package/dist/src/{database → packlets/database}/index.d.ts +5 -0
  104. package/dist/src/packlets/database/index.d.ts.map +1 -0
  105. package/dist/src/{database → packlets/database}/index.js +10 -1
  106. package/dist/src/packlets/database/index.js.map +1 -0
  107. package/dist/src/{database → packlets/database}/item-demuxer.d.ts +5 -4
  108. package/dist/src/packlets/database/item-demuxer.d.ts.map +1 -0
  109. package/dist/src/{database → packlets/database}/item-demuxer.js +5 -8
  110. package/dist/src/packlets/database/item-demuxer.js.map +1 -0
  111. package/dist/src/{database → packlets/database}/item-demuxer.test.d.ts +0 -0
  112. package/dist/src/packlets/database/item-demuxer.test.d.ts.map +1 -0
  113. package/dist/src/{database → packlets/database}/item-demuxer.test.js +15 -11
  114. package/dist/src/packlets/database/item-demuxer.test.js.map +1 -0
  115. package/dist/src/{database → packlets/database}/item-manager.d.ts +3 -1
  116. package/dist/src/packlets/database/item-manager.d.ts.map +1 -0
  117. package/dist/src/{database → packlets/database}/item-manager.js +13 -12
  118. package/dist/src/packlets/database/item-manager.js.map +1 -0
  119. package/dist/src/{database → packlets/database}/item-manager.test.d.ts +0 -0
  120. package/dist/src/packlets/database/item-manager.test.d.ts.map +1 -0
  121. package/dist/src/{database → packlets/database}/item-manager.test.js +0 -0
  122. package/dist/src/packlets/database/item-manager.test.js.map +1 -0
  123. package/dist/src/{api → packlets/database}/item.d.ts +1 -1
  124. package/dist/src/packlets/database/item.d.ts.map +1 -0
  125. package/dist/src/{api → packlets/database}/item.js +0 -0
  126. package/dist/src/packlets/database/item.js.map +1 -0
  127. package/dist/src/{api → packlets/database}/link.d.ts +1 -1
  128. package/dist/src/packlets/database/link.d.ts.map +1 -0
  129. package/dist/src/{api → packlets/database}/link.js +0 -0
  130. package/dist/src/packlets/database/link.js.map +1 -0
  131. package/dist/src/{api → packlets/database}/selection/index.d.ts +0 -0
  132. package/dist/src/packlets/database/selection/index.d.ts.map +1 -0
  133. package/dist/src/{api → packlets/database}/selection/index.js +5 -1
  134. package/dist/src/packlets/database/selection/index.js.map +1 -0
  135. package/dist/src/{api → packlets/database}/selection/queries.d.ts +0 -0
  136. package/dist/src/packlets/database/selection/queries.d.ts.map +1 -0
  137. package/dist/src/{api → packlets/database}/selection/queries.js +13 -17
  138. package/dist/src/packlets/database/selection/queries.js.map +1 -0
  139. package/dist/src/{api → packlets/database}/selection/result.d.ts +0 -0
  140. package/dist/src/packlets/database/selection/result.d.ts.map +1 -0
  141. package/dist/src/{api → packlets/database}/selection/result.js +0 -0
  142. package/dist/src/packlets/database/selection/result.js.map +1 -0
  143. package/dist/src/{api → packlets/database}/selection/selection.d.ts +0 -0
  144. package/dist/src/packlets/database/selection/selection.d.ts.map +1 -0
  145. package/dist/src/{api → packlets/database}/selection/selection.js +1 -3
  146. package/dist/src/packlets/database/selection/selection.js.map +1 -0
  147. package/dist/src/{api → packlets/database}/selection/selection.test.d.ts +0 -0
  148. package/dist/src/packlets/database/selection/selection.test.d.ts.map +1 -0
  149. package/dist/src/{api → packlets/database}/selection/selection.test.js +4 -12
  150. package/dist/src/packlets/database/selection/selection.test.js.map +1 -0
  151. package/dist/src/{api → packlets/database}/selection/util.d.ts +0 -0
  152. package/dist/src/packlets/database/selection/util.d.ts.map +1 -0
  153. package/dist/src/{api → packlets/database}/selection/util.js +0 -0
  154. package/dist/src/packlets/database/selection/util.js.map +1 -0
  155. package/dist/src/{database → packlets/database}/testing.d.ts +1 -1
  156. package/dist/src/packlets/database/testing.d.ts.map +1 -0
  157. package/dist/src/{database → packlets/database}/testing.js +5 -6
  158. package/dist/src/packlets/database/testing.js.map +1 -0
  159. package/dist/src/{database → packlets/database}/timeframe-clock.d.ts +1 -0
  160. package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -0
  161. package/dist/src/{database → packlets/database}/timeframe-clock.js +3 -0
  162. package/dist/src/packlets/database/timeframe-clock.js.map +1 -0
  163. package/dist/src/{errors.d.ts → packlets/errors/index.d.ts} +1 -1
  164. package/dist/src/packlets/errors/index.d.ts.map +1 -0
  165. package/dist/src/{errors.js → packlets/errors/index.js} +1 -1
  166. package/dist/src/packlets/errors/index.js.map +1 -0
  167. package/dist/src/parties/data-party.d.ts +14 -10
  168. package/dist/src/parties/data-party.d.ts.map +1 -1
  169. package/dist/src/parties/data-party.js +39 -15
  170. package/dist/src/parties/data-party.js.map +1 -1
  171. package/dist/src/parties/data-party.test.js +42 -22
  172. package/dist/src/parties/data-party.test.js.map +1 -1
  173. package/dist/src/parties/index.js +5 -1
  174. package/dist/src/parties/index.js.map +1 -1
  175. package/dist/src/parties/party-factory.d.ts +5 -10
  176. package/dist/src/parties/party-factory.d.ts.map +1 -1
  177. package/dist/src/parties/party-factory.js +30 -54
  178. package/dist/src/parties/party-factory.js.map +1 -1
  179. package/dist/src/parties/party-manager.d.ts +3 -4
  180. package/dist/src/parties/party-manager.d.ts.map +1 -1
  181. package/dist/src/parties/party-manager.js +9 -7
  182. package/dist/src/parties/party-manager.js.map +1 -1
  183. package/dist/src/parties/party-manager.test.js +16 -15
  184. package/dist/src/parties/party-manager.test.js.map +1 -1
  185. package/dist/src/pipeline/{pipeline.d.ts → feed-muxer.d.ts} +10 -15
  186. package/dist/src/pipeline/feed-muxer.d.ts.map +1 -0
  187. package/dist/src/pipeline/{pipeline.js → feed-muxer.js} +34 -44
  188. package/dist/src/pipeline/feed-muxer.js.map +1 -0
  189. package/dist/src/pipeline/feed-muxer.test.d.ts +2 -0
  190. package/dist/src/pipeline/feed-muxer.test.d.ts.map +1 -0
  191. package/dist/src/pipeline/{pipeline.test.js → feed-muxer.test.js} +20 -18
  192. package/dist/src/pipeline/feed-muxer.test.js.map +1 -0
  193. package/dist/src/pipeline/index.d.ts +2 -2
  194. package/dist/src/pipeline/index.d.ts.map +1 -1
  195. package/dist/src/pipeline/index.js +7 -3
  196. package/dist/src/pipeline/index.js.map +1 -1
  197. package/dist/src/pipeline/message-selector.d.ts +3 -3
  198. package/dist/src/pipeline/message-selector.d.ts.map +1 -1
  199. package/dist/src/pipeline/message-selector.js +30 -29
  200. package/dist/src/pipeline/message-selector.js.map +1 -1
  201. package/dist/src/pipeline/metadata-store.d.ts +5 -4
  202. package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
  203. package/dist/src/pipeline/metadata-store.js +11 -5
  204. package/dist/src/pipeline/metadata-store.js.map +1 -1
  205. package/dist/src/pipeline/metadata-store.test.js +8 -4
  206. package/dist/src/pipeline/metadata-store.test.js.map +1 -1
  207. package/dist/src/pipeline/party-feed-provider.d.ts +2 -3
  208. package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
  209. package/dist/src/pipeline/party-feed-provider.js +2 -17
  210. package/dist/src/pipeline/party-feed-provider.js.map +1 -1
  211. package/dist/src/pipeline/{party-core.d.ts → party-pipeline.d.ts} +26 -11
  212. package/dist/src/pipeline/party-pipeline.d.ts.map +1 -0
  213. package/dist/src/pipeline/{party-core.js → party-pipeline.js} +32 -31
  214. package/dist/src/pipeline/party-pipeline.js.map +1 -0
  215. package/dist/src/pipeline/party-pipeline.test.d.ts +2 -0
  216. package/dist/src/pipeline/party-pipeline.test.d.ts.map +1 -0
  217. package/dist/src/pipeline/{party-core.test.js → party-pipeline.test.js} +64 -46
  218. package/dist/src/pipeline/party-pipeline.test.js.map +1 -0
  219. package/dist/src/pipeline/party-processor.d.ts +21 -9
  220. package/dist/src/pipeline/party-processor.d.ts.map +1 -1
  221. package/dist/src/pipeline/party-processor.js +0 -8
  222. package/dist/src/pipeline/party-processor.js.map +1 -1
  223. package/dist/src/protocol/auth-plugin.d.ts +1 -1
  224. package/dist/src/protocol/auth-plugin.d.ts.map +1 -1
  225. package/dist/src/protocol/auth-plugin.js +1 -3
  226. package/dist/src/protocol/auth-plugin.js.map +1 -1
  227. package/dist/src/protocol/authenticator.d.ts +4 -4
  228. package/dist/src/protocol/authenticator.d.ts.map +1 -1
  229. package/dist/src/protocol/authenticator.js +12 -16
  230. package/dist/src/protocol/authenticator.js.map +1 -1
  231. package/dist/src/protocol/authenticator.test.js +1 -4
  232. package/dist/src/protocol/authenticator.test.js.map +1 -1
  233. package/dist/src/protocol/halo-recovery-plugin.d.ts +1 -1
  234. package/dist/src/protocol/halo-recovery-plugin.d.ts.map +1 -1
  235. package/dist/src/protocol/halo-recovery-plugin.js +1 -3
  236. package/dist/src/protocol/halo-recovery-plugin.js.map +1 -1
  237. package/dist/src/protocol/identity-credentials.d.ts +2 -2
  238. package/dist/src/protocol/identity-credentials.d.ts.map +1 -1
  239. package/dist/src/protocol/identity-credentials.js +4 -4
  240. package/dist/src/protocol/identity-credentials.js.map +1 -1
  241. package/dist/src/protocol/index.js +5 -1
  242. package/dist/src/protocol/index.js.map +1 -1
  243. package/dist/src/protocol/offline-invitation-plugin.d.ts +1 -1
  244. package/dist/src/protocol/offline-invitation-plugin.d.ts.map +1 -1
  245. package/dist/src/protocol/offline-invitation-plugin.js +1 -3
  246. package/dist/src/protocol/offline-invitation-plugin.js.map +1 -1
  247. package/dist/src/protocol/party-protocol-factory.d.ts +1 -14
  248. package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -1
  249. package/dist/src/protocol/party-protocol-factory.js +2 -55
  250. package/dist/src/protocol/party-protocol-factory.js.map +1 -1
  251. package/dist/src/protocol/replicator-plugin.d.ts +7 -0
  252. package/dist/src/protocol/replicator-plugin.d.ts.map +1 -0
  253. package/dist/src/protocol/replicator-plugin.js +36 -0
  254. package/dist/src/protocol/replicator-plugin.js.map +1 -0
  255. package/dist/src/snapshots/index.js +5 -1
  256. package/dist/src/snapshots/index.js.map +1 -1
  257. package/dist/src/snapshots/snapshot-generator.d.ts +3 -3
  258. package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
  259. package/dist/src/snapshots/snapshot-generator.js +13 -15
  260. package/dist/src/snapshots/snapshot-generator.js.map +1 -1
  261. package/dist/src/snapshots/snapshot-store.d.ts +3 -3
  262. package/dist/src/snapshots/snapshot-store.d.ts.map +1 -1
  263. package/dist/src/snapshots/snapshot-store.js +5 -5
  264. package/dist/src/snapshots/snapshot-store.js.map +1 -1
  265. package/dist/src/snapshots/snapshot-store.test.js +1 -1
  266. package/dist/src/snapshots/snapshot-store.test.js.map +1 -1
  267. package/dist/src/snapshots/snapshot.test.js +1 -1
  268. package/dist/src/snapshots/snapshot.test.js.map +1 -1
  269. package/dist/src/testing/benchmark.test.d.ts +2 -0
  270. package/dist/src/testing/benchmark.test.d.ts.map +1 -0
  271. package/dist/src/testing/benchmark.test.js +25 -0
  272. package/dist/src/testing/benchmark.test.js.map +1 -0
  273. package/dist/src/testing/index.js +5 -1
  274. package/dist/src/testing/index.js.map +1 -1
  275. package/dist/src/testing/testing-factories.d.ts +1 -1
  276. package/dist/src/testing/testing-factories.d.ts.map +1 -1
  277. package/dist/src/testing/testing-factories.js +2 -2
  278. package/dist/src/testing/testing-factories.js.map +1 -1
  279. package/dist/tsconfig.tsbuildinfo +1 -1
  280. package/package.json +19 -19
  281. package/src/api/index.ts +0 -5
  282. package/src/api/schema.test.ts +1 -2
  283. package/src/echo.test.ts +16 -5
  284. package/src/echo.ts +11 -20
  285. package/src/halo/contact-manager.ts +3 -2
  286. package/src/halo/halo-factory.ts +11 -23
  287. package/src/halo/halo-party.ts +22 -14
  288. package/src/halo/halo.test.ts +4 -3
  289. package/src/halo/halo.ts +2 -2
  290. package/src/halo/identity.ts +2 -2
  291. package/src/halo/party-opener.ts +5 -3
  292. package/src/halo/preferences.ts +10 -12
  293. package/src/index.ts +3 -2
  294. package/src/invitations/greeting-initiator.ts +10 -9
  295. package/src/invitations/greeting-protocol-provider.ts +5 -9
  296. package/src/invitations/greeting-responder.ts +15 -17
  297. package/src/invitations/halo-recovery-initiator.ts +4 -4
  298. package/src/invitations/invitation-descriptor.ts +1 -1
  299. package/src/invitations/invitation-factory.ts +8 -5
  300. package/src/invitations/offline-invitation-claimer.ts +8 -10
  301. package/src/{database → packlets/database}/data-mirror.test.ts +3 -3
  302. package/src/{database → packlets/database}/data-mirror.ts +1 -1
  303. package/src/{database → packlets/database}/data-service-host.ts +2 -1
  304. package/src/{database → packlets/database}/data-service-router.ts +0 -0
  305. package/src/{database → packlets/database}/database-backend.ts +7 -6
  306. package/src/{api → packlets/database}/database.test.ts +2 -1
  307. package/src/{api → packlets/database}/database.ts +3 -1
  308. package/src/{api → packlets/database}/entity.ts +1 -1
  309. package/src/{database → packlets/database}/index.ts +5 -0
  310. package/src/{database → packlets/database}/item-demuxer.test.ts +21 -19
  311. package/src/{database → packlets/database}/item-demuxer.ts +10 -9
  312. package/src/{database → packlets/database}/item-manager.test.ts +0 -0
  313. package/src/{database → packlets/database}/item-manager.ts +5 -3
  314. package/src/{api → packlets/database}/item.ts +2 -2
  315. package/src/{api → packlets/database}/link.ts +1 -1
  316. package/src/{api → packlets/database}/selection/index.ts +0 -0
  317. package/src/{api → packlets/database}/selection/queries.ts +14 -18
  318. package/src/{api → packlets/database}/selection/result.ts +0 -0
  319. package/src/{api → packlets/database}/selection/selection.test.ts +4 -12
  320. package/src/{api → packlets/database}/selection/selection.ts +1 -7
  321. package/src/{api → packlets/database}/selection/util.ts +0 -0
  322. package/src/{database → packlets/database}/testing.ts +4 -7
  323. package/src/{database → packlets/database}/timeframe-clock.ts +4 -0
  324. package/src/{errors.ts → packlets/errors/index.ts} +0 -0
  325. package/src/parties/data-party.test.ts +58 -25
  326. package/src/parties/data-party.ts +48 -20
  327. package/src/parties/party-factory.ts +40 -84
  328. package/src/parties/party-manager.test.ts +24 -15
  329. package/src/parties/party-manager.ts +10 -6
  330. package/src/pipeline/{pipeline.test.ts → feed-muxer.test.ts} +23 -19
  331. package/src/pipeline/{pipeline.ts → feed-muxer.ts} +39 -55
  332. package/src/pipeline/index.ts +2 -2
  333. package/src/pipeline/message-selector.ts +32 -35
  334. package/src/pipeline/metadata-store.test.ts +8 -4
  335. package/src/pipeline/metadata-store.ts +12 -6
  336. package/src/pipeline/party-feed-provider.ts +3 -16
  337. package/src/pipeline/{party-core.test.ts → party-pipeline.test.ts} +67 -48
  338. package/src/pipeline/{party-core.ts → party-pipeline.ts} +59 -31
  339. package/src/pipeline/party-processor.ts +23 -15
  340. package/src/protocol/auth-plugin.ts +1 -3
  341. package/src/protocol/authenticator.test.ts +1 -4
  342. package/src/protocol/authenticator.ts +33 -33
  343. package/src/protocol/halo-recovery-plugin.ts +4 -6
  344. package/src/protocol/identity-credentials.ts +4 -4
  345. package/src/protocol/offline-invitation-plugin.ts +4 -6
  346. package/src/protocol/party-protocol-factory.ts +3 -56
  347. package/src/protocol/replicator-plugin.ts +37 -0
  348. package/src/snapshots/snapshot-generator.ts +14 -18
  349. package/src/snapshots/snapshot-store.test.ts +1 -1
  350. package/src/snapshots/snapshot-store.ts +5 -6
  351. package/src/snapshots/snapshot.test.ts +1 -1
  352. package/src/testing/benchmark.test.ts +30 -0
  353. package/src/testing/testing-factories.ts +3 -3
  354. package/dist/src/api/database.d.ts.map +0 -1
  355. package/dist/src/api/database.js.map +0 -1
  356. package/dist/src/api/database.test.d.ts.map +0 -1
  357. package/dist/src/api/database.test.js.map +0 -1
  358. package/dist/src/api/entity.d.ts.map +0 -1
  359. package/dist/src/api/entity.js.map +0 -1
  360. package/dist/src/api/item.d.ts.map +0 -1
  361. package/dist/src/api/item.js.map +0 -1
  362. package/dist/src/api/link.d.ts.map +0 -1
  363. package/dist/src/api/link.js.map +0 -1
  364. package/dist/src/api/selection/index.d.ts.map +0 -1
  365. package/dist/src/api/selection/index.js.map +0 -1
  366. package/dist/src/api/selection/queries.d.ts.map +0 -1
  367. package/dist/src/api/selection/queries.js.map +0 -1
  368. package/dist/src/api/selection/result.d.ts.map +0 -1
  369. package/dist/src/api/selection/result.js.map +0 -1
  370. package/dist/src/api/selection/selection.d.ts.map +0 -1
  371. package/dist/src/api/selection/selection.js.map +0 -1
  372. package/dist/src/api/selection/selection.test.d.ts.map +0 -1
  373. package/dist/src/api/selection/selection.test.js.map +0 -1
  374. package/dist/src/api/selection/util.d.ts.map +0 -1
  375. package/dist/src/api/selection/util.js.map +0 -1
  376. package/dist/src/database/data-mirror.d.ts.map +0 -1
  377. package/dist/src/database/data-mirror.js.map +0 -1
  378. package/dist/src/database/data-mirror.test.d.ts.map +0 -1
  379. package/dist/src/database/data-mirror.test.js.map +0 -1
  380. package/dist/src/database/data-service-host.d.ts.map +0 -1
  381. package/dist/src/database/data-service-host.js.map +0 -1
  382. package/dist/src/database/data-service-router.d.ts.map +0 -1
  383. package/dist/src/database/data-service-router.js.map +0 -1
  384. package/dist/src/database/database-backend.d.ts.map +0 -1
  385. package/dist/src/database/database-backend.js.map +0 -1
  386. package/dist/src/database/index.d.ts.map +0 -1
  387. package/dist/src/database/index.js.map +0 -1
  388. package/dist/src/database/item-demuxer.d.ts.map +0 -1
  389. package/dist/src/database/item-demuxer.js.map +0 -1
  390. package/dist/src/database/item-demuxer.test.d.ts.map +0 -1
  391. package/dist/src/database/item-demuxer.test.js.map +0 -1
  392. package/dist/src/database/item-manager.d.ts.map +0 -1
  393. package/dist/src/database/item-manager.js.map +0 -1
  394. package/dist/src/database/item-manager.test.d.ts.map +0 -1
  395. package/dist/src/database/item-manager.test.js.map +0 -1
  396. package/dist/src/database/testing.d.ts.map +0 -1
  397. package/dist/src/database/testing.js.map +0 -1
  398. package/dist/src/database/timeframe-clock.d.ts.map +0 -1
  399. package/dist/src/database/timeframe-clock.js.map +0 -1
  400. package/dist/src/errors.d.ts.map +0 -1
  401. package/dist/src/errors.js.map +0 -1
  402. package/dist/src/pipeline/party-core.d.ts.map +0 -1
  403. package/dist/src/pipeline/party-core.js.map +0 -1
  404. package/dist/src/pipeline/party-core.test.d.ts +0 -2
  405. package/dist/src/pipeline/party-core.test.d.ts.map +0 -1
  406. package/dist/src/pipeline/party-core.test.js.map +0 -1
  407. package/dist/src/pipeline/pipeline.d.ts.map +0 -1
  408. package/dist/src/pipeline/pipeline.js.map +0 -1
  409. package/dist/src/pipeline/pipeline.test.d.ts +0 -2
  410. package/dist/src/pipeline/pipeline.test.d.ts.map +0 -1
  411. package/dist/src/pipeline/pipeline.test.js.map +0 -1
@@ -4,11 +4,12 @@
4
4
 
5
5
  import assert from 'assert';
6
6
 
7
- import { createPartyInvitationMessage } from '@dxos/credentials';
7
+ import { createPartyInvitationMessage, Message as HaloMessage } from '@dxos/credentials';
8
8
  import { PublicKey } from '@dxos/crypto';
9
+ import { FeedWriter } from '@dxos/echo-protocol';
9
10
  import { NetworkManager } from '@dxos/network-manager';
10
11
 
11
- import { PartyProcessor } from '../pipeline';
12
+ import { PartyStateProvider } from '../pipeline';
12
13
  import { CredentialsSigner } from '../protocol/credentials-signer';
13
14
  import { defaultInvitationAuthenticator, InvitationAuthenticator, InvitationOptions } from './common';
14
15
  import { GreetingResponder } from './greeting-responder';
@@ -19,10 +20,11 @@ import { InvitationDescriptor, InvitationDescriptorType } from './invitation-des
19
20
  */
20
21
  export class InvitationFactory {
21
22
  constructor (
22
- private readonly _partyProcessor: PartyProcessor,
23
+ private readonly _partyProcessor: PartyStateProvider,
23
24
  // This needs to be a provider in case this is a backend for the HALO party.
24
25
  // Then the identity would be changed after this is instantiated.
25
26
  private readonly _credentialsSigner: CredentialsSigner,
27
+ private readonly _credentialsWriter: FeedWriter<HaloMessage>,
26
28
  private readonly _networkManager: NetworkManager
27
29
  ) {}
28
30
 
@@ -42,7 +44,7 @@ export class InvitationFactory {
42
44
  this._credentialsSigner.getDeviceSigningKeys()
43
45
  );
44
46
 
45
- await this._partyProcessor.writeHaloMessage(invitationMessage);
47
+ await this._credentialsWriter.write(invitationMessage);
46
48
 
47
49
  return new InvitationDescriptor(
48
50
  InvitationDescriptorType.OFFLINE,
@@ -60,7 +62,8 @@ export class InvitationFactory {
60
62
  const responder = new GreetingResponder(
61
63
  this._networkManager,
62
64
  this._partyProcessor,
63
- this._credentialsSigner
65
+ this._credentialsSigner,
66
+ this._credentialsWriter
64
67
  );
65
68
 
66
69
  const { secretValidator, secretProvider } = authenticationDetails;
@@ -23,7 +23,7 @@ import {
23
23
  import { keyToBuffer, keyToString, PublicKey, randomBytes } from '@dxos/crypto';
24
24
  import { FullyConnectedTopology, NetworkManager } from '@dxos/network-manager';
25
25
 
26
- import { InvalidInvitationError } from '../errors';
26
+ import { InvalidInvitationError } from '../packlets/errors';
27
27
  import { CredentialsSigner } from '../protocol';
28
28
  import { greetingProtocolProvider } from './greeting-protocol-provider';
29
29
  import { GreetingState } from './greeting-responder';
@@ -70,8 +70,8 @@ export class OfflineInvitationClaimer {
70
70
  this._greeterPlugin = new GreetingCommandPlugin(localPeerId, async () => false);
71
71
 
72
72
  log('Connecting');
73
- const peerJoinedWaiter = waitForEvent(this._greeterPlugin, 'peer:joined',
74
- () => this._greeterPlugin?.peers.length, timeout);
73
+ const peerJoinedWaiter = waitForEvent(
74
+ this._greeterPlugin, 'peer:joined', () => !!this._greeterPlugin?.peers.length, timeout);
75
75
 
76
76
  await this._networkManager.joinProtocolSwarm({
77
77
  topic: PublicKey.from(swarmKey),
@@ -170,19 +170,17 @@ export class OfflineInvitationClaimer {
170
170
 
171
171
  // The secretProvider should provide an `Auth` message signed directly by the Identity key.
172
172
  static createSecretProvider (credentials: CredentialsSigner): SecretProvider {
173
- return async (info?: SecretInfo) => {
174
- return Buffer.from(codec.encode(
175
- /* The signed portion of the Auth message includes the ID and authNonce provided
173
+ return async (info?: SecretInfo) => Buffer.from(codec.encode(
174
+ /* The signed portion of the Auth message includes the ID and authNonce provided
176
175
  * by the `info` object. These values will be validated on the other end.
177
176
  */
178
- createAuthMessage(
179
- credentials.signer,
177
+ createAuthMessage(
178
+ credentials.signer,
180
179
  info!.id.value,
181
180
  credentials.getIdentityKey(),
182
181
  credentials.getDeviceSigningKeys(),
183
182
  undefined,
184
183
  info!.authNonce.value)
185
- ));
186
- };
184
+ ));
187
185
  }
188
186
  }
@@ -11,10 +11,10 @@ import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
11
11
  import { ModelFactory } from '@dxos/model-factory';
12
12
  import { ObjectModel } from '@dxos/object-model';
13
13
 
14
- import { Item } from '../api';
15
14
  import { DataMirror } from './data-mirror';
16
15
  import { DataServiceHost } from './data-service-host';
17
16
  import { DataServiceRouter } from './data-service-router';
17
+ import { Item } from './item';
18
18
  import { ItemDemuxer } from './item-demuxer';
19
19
  import { ItemManager } from './item-manager';
20
20
 
@@ -26,8 +26,8 @@ describe('DataMirror', () => {
26
26
  const itemManager = new ItemManager(modelFactory, PublicKey.random(), feed);
27
27
  const itemDemuxer = new ItemDemuxer(itemManager, modelFactory, { snapshots: true });
28
28
 
29
- const stream = itemDemuxer.open();
30
- feed.written.on(([msg, meta]) => stream.write({
29
+ const process = itemDemuxer.open();
30
+ feed.written.on(([msg, meta]) => process({
31
31
  data: msg,
32
32
  meta: { ...meta, memberKey: PublicKey.random(), timeframe: new Timeframe() }
33
33
  } as any));
@@ -10,7 +10,7 @@ import { failUndefined } from '@dxos/debug';
10
10
  import { DataService } from '@dxos/echo-protocol';
11
11
  import { Model } from '@dxos/model-factory';
12
12
 
13
- import { Entity } from '../api';
13
+ import { Entity } from './entity';
14
14
  import { ItemManager } from './item-manager';
15
15
 
16
16
  const log = debug('dxos:echo-db:data-mirror');
@@ -18,10 +18,11 @@ import {
18
18
  SubscribeEntityStreamResponse
19
19
  } from '@dxos/echo-protocol';
20
20
 
21
- import { Item, Link } from '../api';
22
21
  import { EntityNotFoundError } from '../errors';
22
+ import { Item } from './item';
23
23
  import { ItemDemuxer } from './item-demuxer';
24
24
  import { ItemManager } from './item-manager';
25
+ import { Link } from './link';
25
26
 
26
27
  const log = debug('dxos:echo-db:data-service-host');
27
28
 
@@ -10,7 +10,7 @@ import { ModelFactory } from '@dxos/model-factory';
10
10
 
11
11
  import { DataMirror } from './data-mirror';
12
12
  import { DataServiceHost } from './data-service-host';
13
- import { ItemDemuxer, ItemDemuxerOptions } from './item-demuxer';
13
+ import { EchoProcessor, ItemDemuxer, ItemDemuxerOptions } from './item-demuxer';
14
14
  import { ItemManager } from './item-manager';
15
15
 
16
16
  const log = debug('dxos:echo-db:database-backend');
@@ -42,12 +42,11 @@ export interface DatabaseBackend {
42
42
  * Write operations result in mutations being written to the outgoing stream.
43
43
  */
44
44
  export class FeedDatabaseBackend implements DatabaseBackend {
45
- private _itemDemuxerInboundStream!: NodeJS.WritableStream
45
+ private _echoProcessor!: EchoProcessor;
46
46
  private _itemManager!: ItemManager;
47
47
  private _itemDemuxer!: ItemDemuxer;
48
48
 
49
49
  constructor (
50
- private readonly _inboundStream: NodeJS.ReadableStream,
51
50
  private readonly _outboundStream: FeedWriter<EchoEnvelope> | undefined,
52
51
  private readonly _snapshot?: DatabaseSnapshot,
53
52
  private readonly _options: ItemDemuxerOptions = {}
@@ -56,16 +55,18 @@ export class FeedDatabaseBackend implements DatabaseBackend {
56
55
  async open (itemManager: ItemManager, modelFactory: ModelFactory) {
57
56
  this._itemManager = itemManager;
58
57
  this._itemDemuxer = new ItemDemuxer(itemManager, modelFactory, this._options);
59
- this._itemDemuxerInboundStream = this._itemDemuxer.open();
60
- this._inboundStream.pipe(this._itemDemuxerInboundStream);
58
+ this._echoProcessor = this._itemDemuxer.open();
61
59
 
62
60
  if (this._snapshot) {
63
61
  await this._itemDemuxer.restoreFromSnapshot(this._snapshot);
64
62
  }
65
63
  }
66
64
 
65
+ get echoProcessor () {
66
+ return this._echoProcessor;
67
+ }
68
+
67
69
  async close () {
68
- this._inboundStream?.unpipe(this._itemDemuxerInboundStream);
69
70
  }
70
71
 
71
72
  get isReadOnly (): boolean {
@@ -10,9 +10,10 @@ import { ModelFactory, TestListModel } from '@dxos/model-factory';
10
10
  import { ObjectModel } from '@dxos/object-model';
11
11
  import { afterTest } from '@dxos/testutils';
12
12
 
13
- import { createInMemoryDatabase, createRemoteDatabaseFromDataServiceHost, DataServiceHost } from '../database';
13
+ import { DataServiceHost } from './data-service-host';
14
14
  import { Item } from './item';
15
15
  import { ItemFilterDeleted } from './selection';
16
+ import { createInMemoryDatabase, createRemoteDatabaseFromDataServiceHost } from './testing';
16
17
 
17
18
  const OBJECT_ORG = 'example:object/org';
18
19
  const OBJECT_PERSON = 'example:object/person';
@@ -10,9 +10,11 @@ import { ItemID, ItemType } from '@dxos/echo-protocol';
10
10
  import { Model, ModelConstructor, ModelFactory, validateModelClass } from '@dxos/model-factory';
11
11
  import { ObjectModel } from '@dxos/object-model';
12
12
 
13
- import { DatabaseBackend, DataServiceHost, ItemManager } from '../database';
13
+ import { DataServiceHost } from './data-service-host';
14
+ import { DatabaseBackend } from './database-backend';
14
15
  import { Entity } from './entity';
15
16
  import { Item } from './item';
17
+ import { ItemManager } from './item-manager';
16
18
  import { Link } from './link';
17
19
  import { RootFilter, Selection, createSelection } from './selection';
18
20
 
@@ -7,7 +7,7 @@ import { ItemID, ItemType } from '@dxos/echo-protocol';
7
7
  import { Model, ModelMeta, StateManager } from '@dxos/model-factory';
8
8
  import { SubscriptionGroup } from '@dxos/util';
9
9
 
10
- import { ItemManager } from '../database';
10
+ import { ItemManager } from './item-manager';
11
11
 
12
12
  /**
13
13
  * Base class for all ECHO entitities.
@@ -10,3 +10,8 @@ export * from './item-demuxer';
10
10
  export * from './item-manager';
11
11
  export * from './testing';
12
12
  export * from './timeframe-clock';
13
+ export * from './item';
14
+ export * from './link';
15
+ export * from './entity';
16
+ export * from './selection';
17
+ export * from './database';
@@ -9,12 +9,11 @@ import { it as test } from 'mocha';
9
9
  import { latch } from '@dxos/async';
10
10
  import { createId, PublicKey } from '@dxos/crypto';
11
11
  import { checkType } from '@dxos/debug';
12
- import { createMockFeedWriterFromStream, EchoEnvelope, IEchoStream, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
13
- import { createTransform } from '@dxos/feed-store';
12
+ import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
14
13
  import { ModelFactory, TestModel } from '@dxos/model-factory';
15
14
  import { ObjectModel } from '@dxos/object-model';
16
15
 
17
- import { Item } from '../api';
16
+ import { Item } from './item';
18
17
  import { ItemDemuxer } from './item-demuxer';
19
18
  import { ItemManager } from './item-manager';
20
19
 
@@ -32,7 +31,7 @@ describe('Item demuxer', () => {
32
31
  const itemDemuxer = new ItemDemuxer(itemManager, modelFactory);
33
32
 
34
33
  const inboundStream = itemDemuxer.open();
35
- feedWriter.written.on(([msg, meta]) => inboundStream.write({
34
+ feedWriter.written.on(([msg, meta]) => inboundStream({
36
35
  data: msg,
37
36
  meta: { ...meta, memberKey }
38
37
  } as any));
@@ -96,28 +95,31 @@ describe('Item demuxer', () => {
96
95
  const modelFactory = new ModelFactory()
97
96
  .registerModel(ObjectModel);
98
97
 
99
- const writeStream = createTransform<EchoEnvelope, IEchoStream>(
100
- async (message: EchoEnvelope): Promise<IEchoStream> => ({
101
- meta: {
102
- feedKey: PublicKey.random(),
103
- memberKey: PublicKey.random(),
104
- seq: 0,
105
- timeframe: new Timeframe()
106
- },
107
- data: message
108
- })
109
- );
110
- const itemManager = new ItemManager(modelFactory, PublicKey.random(), createMockFeedWriterFromStream(writeStream));
98
+ const itemManager = new ItemManager(modelFactory, PublicKey.random(), {
99
+ write: async (message) => {
100
+ void processEchoMessage(message);
101
+ return { feedKey: PublicKey.random(), seq: 0 };
102
+ }
103
+ });
111
104
  const itemDemuxer = new ItemDemuxer(itemManager, modelFactory);
112
- writeStream.pipe(itemDemuxer.open());
105
+ const processor = itemDemuxer.open();
106
+ const processEchoMessage = (message: EchoEnvelope) => processor({
107
+ meta: {
108
+ feedKey: PublicKey.random(),
109
+ memberKey: PublicKey.random(),
110
+ seq: 0,
111
+ timeframe: new Timeframe()
112
+ },
113
+ data: message
114
+ });
113
115
 
114
- writeStream.write(checkType<EchoEnvelope>({
116
+ void processEchoMessage(checkType<EchoEnvelope>({
115
117
  itemId: 'foo',
116
118
  genesis: {
117
119
  modelType: TestModel.meta.type
118
120
  }
119
121
  }));
120
- writeStream.write(checkType<EchoEnvelope>({
122
+ void processEchoMessage(checkType<EchoEnvelope>({
121
123
  itemId: 'bar',
122
124
  genesis: {
123
125
  modelType: ObjectModel.meta.type
@@ -8,12 +8,12 @@ import debug from 'debug';
8
8
  import { Event } from '@dxos/async';
9
9
  import { failUndefined } from '@dxos/debug';
10
10
  import { DatabaseSnapshot, IEchoStream, ItemID, ItemSnapshot, LinkSnapshot } from '@dxos/echo-protocol';
11
- import { createWritable } from '@dxos/feed-store';
12
11
  import { Model, ModelFactory, ModelMessage } from '@dxos/model-factory';
13
- import { jsonReplacer } from '@dxos/util';
14
12
 
15
- import { Entity, Item, Link } from '../api';
13
+ import { Entity } from './entity';
14
+ import { Item } from './item';
16
15
  import { ItemManager, ModelConstructionOptions } from './item-manager';
16
+ import { Link } from './link';
17
17
 
18
18
  const log = debug('dxos:echo-db:item-demuxer');
19
19
 
@@ -21,6 +21,8 @@ export interface ItemDemuxerOptions {
21
21
  snapshots?: boolean
22
22
  }
23
23
 
24
+ export type EchoProcessor = (message: IEchoStream) => Promise<void>
25
+
24
26
  /**
25
27
  * Creates a stream that consumes `IEchoStream` messages and routes them to the associated items.
26
28
  * @param itemManager
@@ -34,7 +36,7 @@ export class ItemDemuxer {
34
36
  private readonly _options: ItemDemuxerOptions = {}
35
37
  ) {}
36
38
 
37
- open (): NodeJS.WritableStream {
39
+ open (): EchoProcessor {
38
40
  this._modelFactory.registered.on(async model => {
39
41
  for (const item of this._itemManager.getUninitializedEntities()) {
40
42
  if (item._stateManager.modelType === model.meta.type) {
@@ -45,8 +47,7 @@ export class ItemDemuxer {
45
47
 
46
48
  // TODO(burdon): Factor out.
47
49
  // TODO(burdon): Should this implement some "back-pressure" (hints) to the PartyProcessor?
48
- return createWritable<IEchoStream>(async (message: IEchoStream) => {
49
- log('Reading:', JSON.stringify(message, jsonReplacer));
50
+ return async (message: IEchoStream) => {
50
51
  const { data: { itemId, genesis, itemMutation, mutation, snapshot }, meta } = message;
51
52
  assert(itemId);
52
53
 
@@ -111,7 +112,7 @@ export class ItemDemuxer {
111
112
  }
112
113
 
113
114
  this.mutation.emit(message);
114
- });
115
+ };
115
116
  }
116
117
 
117
118
  createSnapshot (): DatabaseSnapshot {
@@ -187,7 +188,7 @@ export class ItemDemuxer {
187
188
  * Sort based on parents.
188
189
  * @param items
189
190
  */
190
- export function sortItemsTopologically (items: ItemSnapshot[]): ItemSnapshot[] {
191
+ export const sortItemsTopologically = (items: ItemSnapshot[]): ItemSnapshot[] => {
191
192
  const snapshots: ItemSnapshot[] = [];
192
193
  const seenIds = new Set<ItemID>();
193
194
 
@@ -206,4 +207,4 @@ export function sortItemsTopologically (items: ItemSnapshot[]): ItemSnapshot[] {
206
207
  }
207
208
 
208
209
  return snapshots;
209
- }
210
+ };
@@ -11,8 +11,10 @@ import { timed } from '@dxos/debug';
11
11
  import { EchoEnvelope, FeedWriter, ItemID, ItemType, mapFeedWriter, ModelSnapshot } from '@dxos/echo-protocol';
12
12
  import { Model, ModelFactory, ModelMessage, ModelType, StateManager } from '@dxos/model-factory';
13
13
 
14
- import { Entity, Item, Link } from '../api';
15
14
  import { UnknownModelError } from '../errors';
15
+ import { Entity } from './entity';
16
+ import { Item } from './item';
17
+ import { Link } from './link';
16
18
 
17
19
  const log = debug('dxos:echo-db:item-manager');
18
20
 
@@ -375,7 +377,7 @@ export class ItemManager {
375
377
  /**
376
378
  * Returns a new event that groups all of the updates emitted during single tick into a single event emission.
377
379
  */
378
- function debounceEntityUpdateEvent (event: Event<Entity<any>>): Event<Entity<any>[]> {
380
+ const debounceEntityUpdateEvent = (event: Event<Entity<any>>): Event<Entity<any>[]> => {
379
381
  const debouncedEvent = new Event<Entity<any>[]>();
380
382
 
381
383
  let firing = false;
@@ -395,4 +397,4 @@ function debounceEntityUpdateEvent (event: Event<Entity<any>>): Event<Entity<any
395
397
  }));
396
398
 
397
399
  return debouncedEvent;
398
- }
400
+ };
@@ -7,10 +7,10 @@ import debug from 'debug';
7
7
  import { EchoEnvelope, ItemID, ItemMutation, ItemType, FeedWriter } from '@dxos/echo-protocol';
8
8
  import { Model, StateManager } from '@dxos/model-factory';
9
9
 
10
- import { ItemManager } from '../database';
11
10
  import { Entity } from './entity';
11
+ import { ItemManager } from './item-manager';
12
12
  import type { Link } from './link';
13
- import { Selection, createItemSelection } from './selection';
13
+ import { createItemSelection, Selection } from './selection';
14
14
 
15
15
  const log = debug('dxos:echo-db:item');
16
16
 
@@ -7,9 +7,9 @@ import assert from 'assert';
7
7
  import { ItemID, ItemType } from '@dxos/echo-protocol';
8
8
  import { Model, StateManager } from '@dxos/model-factory';
9
9
 
10
- import { ItemManager } from '../database';
11
10
  import { Entity } from './entity';
12
11
  import { Item } from './item';
12
+ import { ItemManager } from './item-manager';
13
13
 
14
14
  export interface LinkData {
15
15
  sourceId: ItemID
@@ -84,25 +84,21 @@ export const itemFilterToPredicate = (filter: ItemFilter | ItemIdFilter): Predic
84
84
  }
85
85
  };
86
86
 
87
- export const linkFilterToPredicate = (filter: LinkFilter): Predicate<Link> => {
88
- return link => (!filter.type || testOneOrMultiple(filter.type, link.type));
89
- };
87
+ export const linkFilterToPredicate = (filter: LinkFilter): Predicate<Link> => link => (!filter.type || testOneOrMultiple(filter.type, link.type));
90
88
 
91
89
  export const createQueryOptionsFilter = ({
92
90
  deleted = ItemFilterDeleted.HIDE_DELETED
93
- }: QueryOptions): Predicate<Entity> => {
94
- return entity => {
95
- if (entity.model === null) {
96
- return false;
97
- }
98
-
99
- switch (deleted) {
100
- case ItemFilterDeleted.HIDE_DELETED:
101
- return !(entity instanceof Item) || !entity.deleted;
102
- case ItemFilterDeleted.SHOW_DELETED:
103
- return true;
104
- case ItemFilterDeleted.SHOW_DELETED_ONLY:
105
- return entity instanceof Item && entity.deleted;
106
- }
107
- };
91
+ }: QueryOptions): Predicate<Entity> => entity => {
92
+ if (entity.model === null) {
93
+ return false;
94
+ }
95
+
96
+ switch (deleted) {
97
+ case ItemFilterDeleted.HIDE_DELETED:
98
+ return !(entity instanceof Item) || !entity.deleted;
99
+ case ItemFilterDeleted.SHOW_DELETED:
100
+ return true;
101
+ case ItemFilterDeleted.SHOW_DELETED_ONLY:
102
+ return entity instanceof Item && entity.deleted;
103
+ }
108
104
  };
@@ -24,9 +24,7 @@ const modelFactory = new ModelFactory().registerModel(ObjectModel);
24
24
 
25
25
  const createModel = (id: ItemID) => modelFactory.createModel(ObjectModel.meta.type, id, {}, PublicKey.random());
26
26
 
27
- const createItem = (id: ItemID, type: ItemType, parent?: Item<any>) => {
28
- return new Item(null as any, id, type, createModel(id), undefined, parent);
29
- };
27
+ const createItem = (id: ItemID, type: ItemType, parent?: Item<any>) => new Item(null as any, id, type, createModel(id), undefined, parent);
30
28
 
31
29
  const createLink = (id: ItemID, type: ItemType, source: Item<any>, target: Item<any>) => {
32
30
  const link = new Link(null as any, id, type, createModel(id), {
@@ -262,17 +260,11 @@ describe('Selection', () => {
262
260
  test('complex reducer', () => {
263
261
  const query = createReducer({ numItems: 0, numLinks: 0 })
264
262
  .filter({ type: ITEM_ORG })
265
- .call((items: Item[], { numItems, ...rest }) => {
266
- return { ...rest, numItems: numItems + items.length, stage: 'a' };
267
- })
263
+ .call((items: Item[], { numItems, ...rest }) => ({ ...rest, numItems: numItems + items.length, stage: 'a' }))
268
264
  .children({ type: ITEM_PROJECT })
269
- .call((items: Item[], { numItems, ...rest }) => {
270
- return { ...rest, numItems: numItems + items.length, stage: 'b' };
271
- })
265
+ .call((items: Item[], { numItems, ...rest }) => ({ ...rest, numItems: numItems + items.length, stage: 'b' }))
272
266
  .links({ type: LINK_MEMBER })
273
- .call((links: Link[], { numLinks, ...rest }) => {
274
- return { ...rest, numLinks: numLinks + links.length, stage: 'c' };
275
- })
267
+ .call((links: Link[], { numLinks, ...rest }) => ({ ...rest, numLinks: numLinks + links.length, stage: 'c' }))
276
268
  .target()
277
269
  .exec();
278
270
 
@@ -57,13 +57,7 @@ export const createSelection = <R>(
57
57
  * @param update
58
58
  * @param value Initial reducer value.
59
59
  */
60
- export const createItemSelection = <R>(
61
- root: Item<any>,
62
- update: Event<Entity[]>,
63
- value: R
64
- ): Selection<Item<any>, R> => {
65
- return new Selection(() => [[root], value], update, root, value !== undefined);
66
- };
60
+ export const createItemSelection = <R>(root: Item<any>, update: Event<Entity[]>, value: R): Selection<Item<any>, R> => new Selection(() => [[root], value], update, root, value !== undefined);
67
61
 
68
62
  /**
69
63
  * Selections are used to construct database subscriptions.
File without changes
@@ -2,25 +2,22 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { Readable } from 'stream';
6
-
7
5
  import { PublicKey } from '@dxos/crypto';
8
6
  import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
9
7
  import { ModelFactory } from '@dxos/model-factory';
10
8
 
11
- import { Database } from '../api';
12
9
  import { DataServiceHost } from './data-service-host';
13
10
  import { DataServiceRouter } from './data-service-router';
11
+ import { Database } from './database';
14
12
  import { FeedDatabaseBackend, RemoteDatabaseBackend } from './database-backend';
15
13
 
16
14
  export const createInMemoryDatabase = async (modelFactory: ModelFactory) => {
17
15
  const feed = new MockFeedWriter<EchoEnvelope>();
18
- const inboundStream = new Readable({ read () {}, objectMode: true });
19
- feed.written.on(([data, meta]) => inboundStream.push({ data, meta: { ...meta, memberKey: PublicKey.random(), timeframe: new Timeframe([[meta.feedKey, meta.seq]]) } }));
20
-
16
+ const backend = new FeedDatabaseBackend(feed, undefined, { snapshots: true });
17
+ feed.written.on(([data, meta]) => backend.echoProcessor({ data, meta: { ...meta, memberKey: PublicKey.random(), timeframe: new Timeframe([[meta.feedKey, meta.seq]]) } }));
21
18
  const database = new Database(
22
19
  modelFactory,
23
- new FeedDatabaseBackend(inboundStream, feed, undefined, { snapshots: true }),
20
+ backend,
24
21
  PublicKey.random()
25
22
  );
26
23
 
@@ -28,4 +28,8 @@ export class TimeframeClock {
28
28
  const gaps = Timeframe.dependencies(timeframe, this._timeframe);
29
29
  return !gaps.isEmpty();
30
30
  }
31
+
32
+ async waitUntilReached (target: Timeframe) {
33
+ await this.update.waitForCondition(() => Timeframe.dependencies(target, this._timeframe).isEmpty());
34
+ }
31
35
  }
File without changes