@dxos/echo-db 2.33.4-dev.faf06c70 → 2.33.5-dev.0d84e06f

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 (378) 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 +0 -5
  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 +5 -12
  8. package/dist/src/echo.d.ts.map +1 -1
  9. package/dist/src/echo.js +11 -22
  10. package/dist/src/echo.js.map +1 -1
  11. package/dist/src/echo.test.js +12 -0
  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.map +1 -1
  18. package/dist/src/halo/halo-factory.js +5 -11
  19. package/dist/src/halo/halo-factory.js.map +1 -1
  20. package/dist/src/halo/halo-party.d.ts +1 -1
  21. package/dist/src/halo/halo-party.d.ts.map +1 -1
  22. package/dist/src/halo/halo-party.js +8 -6
  23. package/dist/src/halo/halo-party.js.map +1 -1
  24. package/dist/src/halo/halo.test.js +5 -4
  25. package/dist/src/halo/halo.test.js.map +1 -1
  26. package/dist/src/halo/identity.js +2 -2
  27. package/dist/src/halo/identity.js.map +1 -1
  28. package/dist/src/halo/party-opener.d.ts +1 -1
  29. package/dist/src/halo/party-opener.d.ts.map +1 -1
  30. package/dist/src/halo/party-opener.js +2 -2
  31. package/dist/src/halo/party-opener.js.map +1 -1
  32. package/dist/src/halo/preferences.d.ts +1 -1
  33. package/dist/src/halo/preferences.d.ts.map +1 -1
  34. package/dist/src/halo/preferences.js +8 -11
  35. package/dist/src/halo/preferences.js.map +1 -1
  36. package/dist/src/index.d.ts +2 -3
  37. package/dist/src/index.d.ts.map +1 -1
  38. package/dist/src/index.js +2 -3
  39. package/dist/src/index.js.map +1 -1
  40. package/dist/src/invitations/greeting-protocol-provider.d.ts.map +1 -1
  41. package/dist/src/invitations/greeting-protocol-provider.js +5 -9
  42. package/dist/src/invitations/greeting-protocol-provider.js.map +1 -1
  43. package/dist/src/invitations/greeting-responder.d.ts +6 -4
  44. package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
  45. package/dist/src/invitations/greeting-responder.js +11 -14
  46. package/dist/src/invitations/greeting-responder.js.map +1 -1
  47. package/dist/src/invitations/halo-recovery-initiator.js +1 -1
  48. package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
  49. package/dist/src/invitations/invitation-descriptor.js +1 -1
  50. package/dist/src/invitations/invitation-descriptor.js.map +1 -1
  51. package/dist/src/invitations/invitation-factory.d.ts +5 -2
  52. package/dist/src/invitations/invitation-factory.d.ts.map +1 -1
  53. package/dist/src/invitations/invitation-factory.js +4 -3
  54. package/dist/src/invitations/invitation-factory.js.map +1 -1
  55. package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
  56. package/dist/src/invitations/offline-invitation-claimer.js +6 -8
  57. package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
  58. package/dist/src/{database → packlets/database}/data-mirror.d.ts +0 -0
  59. package/dist/src/packlets/database/data-mirror.d.ts.map +1 -0
  60. package/dist/src/{database → packlets/database}/data-mirror.js +0 -0
  61. package/dist/src/packlets/database/data-mirror.js.map +1 -0
  62. package/dist/src/{database → packlets/database}/data-mirror.test.d.ts +0 -0
  63. package/dist/src/packlets/database/data-mirror.test.d.ts.map +1 -0
  64. package/dist/src/{database → packlets/database}/data-mirror.test.js +0 -0
  65. package/dist/src/packlets/database/data-mirror.test.js.map +1 -0
  66. package/dist/src/{database → packlets/database}/data-service-host.d.ts +0 -0
  67. package/dist/src/packlets/database/data-service-host.d.ts.map +1 -0
  68. package/dist/src/{database → packlets/database}/data-service-host.js +4 -3
  69. package/dist/src/packlets/database/data-service-host.js.map +1 -0
  70. package/dist/src/{database → packlets/database}/data-service-router.d.ts +0 -0
  71. package/dist/src/packlets/database/data-service-router.d.ts.map +1 -0
  72. package/dist/src/{database → packlets/database}/data-service-router.js +0 -0
  73. package/dist/src/packlets/database/data-service-router.js.map +1 -0
  74. package/dist/src/{database → packlets/database}/database-backend.d.ts +0 -0
  75. package/dist/src/packlets/database/database-backend.d.ts.map +1 -0
  76. package/dist/src/{database → packlets/database}/database-backend.js +0 -0
  77. package/dist/src/packlets/database/database-backend.js.map +1 -0
  78. package/dist/src/{api → packlets/database}/database.d.ts +2 -1
  79. package/dist/src/packlets/database/database.d.ts.map +1 -0
  80. package/dist/src/{api → packlets/database}/database.js +2 -2
  81. package/dist/src/packlets/database/database.js.map +1 -0
  82. package/dist/src/{api → packlets/database}/database.test.d.ts +0 -0
  83. package/dist/src/packlets/database/database.test.d.ts.map +1 -0
  84. package/dist/src/{api → packlets/database}/database.test.js +3 -3
  85. package/dist/src/packlets/database/database.test.js.map +1 -0
  86. package/dist/src/{api → packlets/database}/entity.d.ts +1 -1
  87. package/dist/src/packlets/database/entity.d.ts.map +1 -0
  88. package/dist/src/{api → packlets/database}/entity.js +0 -0
  89. package/dist/src/packlets/database/entity.js.map +1 -0
  90. package/dist/src/{database → packlets/database}/index.d.ts +5 -0
  91. package/dist/src/packlets/database/index.d.ts.map +1 -0
  92. package/dist/src/{database → packlets/database}/index.js +5 -0
  93. package/dist/src/packlets/database/index.js.map +1 -0
  94. package/dist/src/{database → packlets/database}/item-demuxer.d.ts +3 -2
  95. package/dist/src/packlets/database/item-demuxer.d.ts.map +1 -0
  96. package/dist/src/{database → packlets/database}/item-demuxer.js +3 -5
  97. package/dist/src/packlets/database/item-demuxer.js.map +1 -0
  98. package/dist/src/{database → packlets/database}/item-demuxer.test.d.ts +0 -0
  99. package/dist/src/packlets/database/item-demuxer.test.d.ts.map +1 -0
  100. package/dist/src/{database → packlets/database}/item-demuxer.test.js +2 -2
  101. package/dist/src/packlets/database/item-demuxer.test.js.map +1 -0
  102. package/dist/src/{database → packlets/database}/item-manager.d.ts +3 -1
  103. package/dist/src/packlets/database/item-manager.d.ts.map +1 -0
  104. package/dist/src/{database → packlets/database}/item-manager.js +13 -12
  105. package/dist/src/packlets/database/item-manager.js.map +1 -0
  106. package/dist/src/{database → packlets/database}/item-manager.test.d.ts +0 -0
  107. package/dist/src/packlets/database/item-manager.test.d.ts.map +1 -0
  108. package/dist/src/{database → packlets/database}/item-manager.test.js +0 -0
  109. package/dist/src/packlets/database/item-manager.test.js.map +1 -0
  110. package/dist/src/{api → packlets/database}/item.d.ts +1 -1
  111. package/dist/src/packlets/database/item.d.ts.map +1 -0
  112. package/dist/src/{api → packlets/database}/item.js +0 -0
  113. package/dist/src/packlets/database/item.js.map +1 -0
  114. package/dist/src/{api → packlets/database}/link.d.ts +1 -1
  115. package/dist/src/packlets/database/link.d.ts.map +1 -0
  116. package/dist/src/{api → packlets/database}/link.js +0 -0
  117. package/dist/src/packlets/database/link.js.map +1 -0
  118. package/dist/src/{api → packlets/database}/selection/index.d.ts +0 -0
  119. package/dist/src/packlets/database/selection/index.d.ts.map +1 -0
  120. package/dist/src/{api → packlets/database}/selection/index.js +0 -0
  121. package/dist/src/packlets/database/selection/index.js.map +1 -0
  122. package/dist/src/{api → packlets/database}/selection/queries.d.ts +0 -0
  123. package/dist/src/packlets/database/selection/queries.d.ts.map +1 -0
  124. package/dist/src/{api → packlets/database}/selection/queries.js +13 -17
  125. package/dist/src/packlets/database/selection/queries.js.map +1 -0
  126. package/dist/src/{api → packlets/database}/selection/result.d.ts +0 -0
  127. package/dist/src/packlets/database/selection/result.d.ts.map +1 -0
  128. package/dist/src/{api → packlets/database}/selection/result.js +0 -0
  129. package/dist/src/packlets/database/selection/result.js.map +1 -0
  130. package/dist/src/{api → packlets/database}/selection/selection.d.ts +0 -0
  131. package/dist/src/packlets/database/selection/selection.d.ts.map +1 -0
  132. package/dist/src/{api → packlets/database}/selection/selection.js +1 -3
  133. package/dist/src/packlets/database/selection/selection.js.map +1 -0
  134. package/dist/src/{api → packlets/database}/selection/selection.test.d.ts +0 -0
  135. package/dist/src/packlets/database/selection/selection.test.d.ts.map +1 -0
  136. package/dist/src/{api → packlets/database}/selection/selection.test.js +4 -12
  137. package/dist/src/packlets/database/selection/selection.test.js.map +1 -0
  138. package/dist/src/{api → packlets/database}/selection/util.d.ts +0 -0
  139. package/dist/src/packlets/database/selection/util.d.ts.map +1 -0
  140. package/dist/src/{api → packlets/database}/selection/util.js +0 -0
  141. package/dist/src/packlets/database/selection/util.js.map +1 -0
  142. package/dist/src/{database → packlets/database}/testing.d.ts +1 -1
  143. package/dist/src/packlets/database/testing.d.ts.map +1 -0
  144. package/dist/src/{database → packlets/database}/testing.js +4 -4
  145. package/dist/src/packlets/database/testing.js.map +1 -0
  146. package/dist/src/{database → packlets/database}/timeframe-clock.d.ts +0 -0
  147. package/dist/src/packlets/database/timeframe-clock.d.ts.map +1 -0
  148. package/dist/src/{database → packlets/database}/timeframe-clock.js +0 -0
  149. package/dist/src/packlets/database/timeframe-clock.js.map +1 -0
  150. package/dist/src/{errors.d.ts → packlets/errors/index.d.ts} +1 -1
  151. package/dist/src/packlets/errors/index.d.ts.map +1 -0
  152. package/dist/src/{errors.js → packlets/errors/index.js} +1 -1
  153. package/dist/src/packlets/errors/index.js.map +1 -0
  154. package/dist/src/parties/data-party.d.ts +8 -5
  155. package/dist/src/parties/data-party.d.ts.map +1 -1
  156. package/dist/src/parties/data-party.js +13 -10
  157. package/dist/src/parties/data-party.js.map +1 -1
  158. package/dist/src/parties/data-party.test.js +18 -18
  159. package/dist/src/parties/data-party.test.js.map +1 -1
  160. package/dist/src/parties/party-factory.d.ts +0 -6
  161. package/dist/src/parties/party-factory.d.ts.map +1 -1
  162. package/dist/src/parties/party-factory.js +20 -48
  163. package/dist/src/parties/party-factory.js.map +1 -1
  164. package/dist/src/parties/party-manager.d.ts.map +1 -1
  165. package/dist/src/parties/party-manager.js +2 -1
  166. package/dist/src/parties/party-manager.js.map +1 -1
  167. package/dist/src/parties/party-manager.test.js +13 -10
  168. package/dist/src/parties/party-manager.test.js.map +1 -1
  169. package/dist/src/pipeline/message-selector.d.ts +3 -3
  170. package/dist/src/pipeline/message-selector.d.ts.map +1 -1
  171. package/dist/src/pipeline/message-selector.js +30 -39
  172. package/dist/src/pipeline/message-selector.js.map +1 -1
  173. package/dist/src/pipeline/metadata-store.d.ts +3 -3
  174. package/dist/src/pipeline/metadata-store.d.ts.map +1 -1
  175. package/dist/src/pipeline/metadata-store.js +5 -5
  176. package/dist/src/pipeline/metadata-store.js.map +1 -1
  177. package/dist/src/pipeline/metadata-store.test.js +9 -5
  178. package/dist/src/pipeline/metadata-store.test.js.map +1 -1
  179. package/dist/src/pipeline/party-core.d.ts +4 -3
  180. package/dist/src/pipeline/party-core.d.ts.map +1 -1
  181. package/dist/src/pipeline/party-core.js +7 -7
  182. package/dist/src/pipeline/party-core.js.map +1 -1
  183. package/dist/src/pipeline/party-core.test.js +30 -55
  184. package/dist/src/pipeline/party-core.test.js.map +1 -1
  185. package/dist/src/pipeline/party-processor.d.ts +21 -9
  186. package/dist/src/pipeline/party-processor.d.ts.map +1 -1
  187. package/dist/src/pipeline/party-processor.js +0 -8
  188. package/dist/src/pipeline/party-processor.js.map +1 -1
  189. package/dist/src/pipeline/pipeline.d.ts +3 -5
  190. package/dist/src/pipeline/pipeline.d.ts.map +1 -1
  191. package/dist/src/pipeline/pipeline.js +8 -11
  192. package/dist/src/pipeline/pipeline.js.map +1 -1
  193. package/dist/src/pipeline/pipeline.test.js +4 -5
  194. package/dist/src/pipeline/pipeline.test.js.map +1 -1
  195. package/dist/src/protocol/auth-plugin.d.ts +1 -1
  196. package/dist/src/protocol/auth-plugin.d.ts.map +1 -1
  197. package/dist/src/protocol/auth-plugin.js +1 -3
  198. package/dist/src/protocol/auth-plugin.js.map +1 -1
  199. package/dist/src/protocol/authenticator.d.ts +4 -4
  200. package/dist/src/protocol/authenticator.d.ts.map +1 -1
  201. package/dist/src/protocol/authenticator.js +12 -16
  202. package/dist/src/protocol/authenticator.js.map +1 -1
  203. package/dist/src/protocol/authenticator.test.js +1 -4
  204. package/dist/src/protocol/authenticator.test.js.map +1 -1
  205. package/dist/src/protocol/halo-recovery-plugin.d.ts +1 -1
  206. package/dist/src/protocol/halo-recovery-plugin.d.ts.map +1 -1
  207. package/dist/src/protocol/halo-recovery-plugin.js +1 -3
  208. package/dist/src/protocol/halo-recovery-plugin.js.map +1 -1
  209. package/dist/src/protocol/identity-credentials.d.ts +2 -2
  210. package/dist/src/protocol/identity-credentials.d.ts.map +1 -1
  211. package/dist/src/protocol/identity-credentials.js +4 -4
  212. package/dist/src/protocol/identity-credentials.js.map +1 -1
  213. package/dist/src/protocol/offline-invitation-plugin.d.ts +1 -1
  214. package/dist/src/protocol/offline-invitation-plugin.d.ts.map +1 -1
  215. package/dist/src/protocol/offline-invitation-plugin.js +1 -3
  216. package/dist/src/protocol/offline-invitation-plugin.js.map +1 -1
  217. package/dist/src/protocol/party-protocol-factory.d.ts +1 -14
  218. package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -1
  219. package/dist/src/protocol/party-protocol-factory.js +2 -55
  220. package/dist/src/protocol/party-protocol-factory.js.map +1 -1
  221. package/dist/src/protocol/replicator-plugin.d.ts +7 -0
  222. package/dist/src/protocol/replicator-plugin.d.ts.map +1 -0
  223. package/dist/src/protocol/replicator-plugin.js +36 -0
  224. package/dist/src/protocol/replicator-plugin.js.map +1 -0
  225. package/dist/src/snapshots/snapshot-generator.d.ts +2 -2
  226. package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
  227. package/dist/src/snapshots/snapshot-generator.js +13 -15
  228. package/dist/src/snapshots/snapshot-generator.js.map +1 -1
  229. package/dist/src/snapshots/snapshot-store.d.ts +3 -3
  230. package/dist/src/snapshots/snapshot-store.d.ts.map +1 -1
  231. package/dist/src/snapshots/snapshot-store.js +5 -5
  232. package/dist/src/snapshots/snapshot-store.js.map +1 -1
  233. package/dist/src/snapshots/snapshot-store.test.js +2 -2
  234. package/dist/src/snapshots/snapshot-store.test.js.map +1 -1
  235. package/dist/src/snapshots/snapshot.test.js +1 -1
  236. package/dist/src/snapshots/snapshot.test.js.map +1 -1
  237. package/dist/src/testing/benchmark.test.d.ts +2 -0
  238. package/dist/src/testing/benchmark.test.d.ts.map +1 -0
  239. package/dist/src/testing/benchmark.test.js +25 -0
  240. package/dist/src/testing/benchmark.test.js.map +1 -0
  241. package/dist/src/testing/testing-factories.d.ts +1 -1
  242. package/dist/src/testing/testing-factories.d.ts.map +1 -1
  243. package/dist/src/testing/testing-factories.js +2 -2
  244. package/dist/src/testing/testing-factories.js.map +1 -1
  245. package/dist/src/testing/testing.d.ts +3 -4
  246. package/dist/src/testing/testing.d.ts.map +1 -1
  247. package/dist/src/testing/testing.js +3 -4
  248. package/dist/src/testing/testing.js.map +1 -1
  249. package/dist/tsconfig.tsbuildinfo +1 -1
  250. package/package.json +21 -21
  251. package/src/api/index.ts +0 -5
  252. package/src/api/schema.test.ts +1 -2
  253. package/src/echo.test.ts +16 -1
  254. package/src/echo.ts +15 -37
  255. package/src/halo/contact-manager.ts +3 -2
  256. package/src/halo/halo-factory.ts +6 -18
  257. package/src/halo/halo-party.ts +12 -6
  258. package/src/halo/halo.test.ts +5 -4
  259. package/src/halo/identity.ts +2 -2
  260. package/src/halo/party-opener.ts +2 -2
  261. package/src/halo/preferences.ts +10 -12
  262. package/src/index.ts +3 -3
  263. package/src/invitations/greeting-protocol-provider.ts +5 -9
  264. package/src/invitations/greeting-responder.ts +15 -17
  265. package/src/invitations/halo-recovery-initiator.ts +1 -1
  266. package/src/invitations/invitation-descriptor.ts +1 -1
  267. package/src/invitations/invitation-factory.ts +8 -5
  268. package/src/invitations/offline-invitation-claimer.ts +6 -8
  269. package/src/{database → packlets/database}/data-mirror.test.ts +1 -1
  270. package/src/{database → packlets/database}/data-mirror.ts +1 -1
  271. package/src/{database → packlets/database}/data-service-host.ts +2 -1
  272. package/src/{database → packlets/database}/data-service-router.ts +0 -0
  273. package/src/{database → packlets/database}/database-backend.ts +0 -0
  274. package/src/{api → packlets/database}/database.test.ts +2 -1
  275. package/src/{api → packlets/database}/database.ts +3 -1
  276. package/src/{api → packlets/database}/entity.ts +1 -1
  277. package/src/{database → packlets/database}/index.ts +5 -0
  278. package/src/{database → packlets/database}/item-demuxer.test.ts +1 -1
  279. package/src/{database → packlets/database}/item-demuxer.ts +5 -5
  280. package/src/{database → packlets/database}/item-manager.test.ts +0 -0
  281. package/src/{database → packlets/database}/item-manager.ts +5 -3
  282. package/src/{api → packlets/database}/item.ts +2 -2
  283. package/src/{api → packlets/database}/link.ts +1 -1
  284. package/src/{api → packlets/database}/selection/index.ts +0 -0
  285. package/src/{api → packlets/database}/selection/queries.ts +14 -18
  286. package/src/{api → packlets/database}/selection/result.ts +0 -0
  287. package/src/{api → packlets/database}/selection/selection.test.ts +4 -12
  288. package/src/{api → packlets/database}/selection/selection.ts +1 -7
  289. package/src/{api → packlets/database}/selection/util.ts +0 -0
  290. package/src/{database → packlets/database}/testing.ts +2 -2
  291. package/src/{database → packlets/database}/timeframe-clock.ts +0 -0
  292. package/src/{errors.ts → packlets/errors/index.ts} +0 -0
  293. package/src/parties/data-party.test.ts +19 -18
  294. package/src/parties/data-party.ts +17 -11
  295. package/src/parties/party-factory.ts +26 -72
  296. package/src/parties/party-manager.test.ts +20 -11
  297. package/src/parties/party-manager.ts +2 -1
  298. package/src/pipeline/message-selector.ts +33 -45
  299. package/src/pipeline/metadata-store.test.ts +9 -5
  300. package/src/pipeline/metadata-store.ts +5 -5
  301. package/src/pipeline/party-core.test.ts +33 -73
  302. package/src/pipeline/party-core.ts +8 -9
  303. package/src/pipeline/party-processor.ts +23 -15
  304. package/src/pipeline/pipeline.test.ts +4 -5
  305. package/src/pipeline/pipeline.ts +12 -15
  306. package/src/protocol/auth-plugin.ts +1 -3
  307. package/src/protocol/authenticator.test.ts +1 -4
  308. package/src/protocol/authenticator.ts +33 -33
  309. package/src/protocol/halo-recovery-plugin.ts +4 -6
  310. package/src/protocol/identity-credentials.ts +4 -4
  311. package/src/protocol/offline-invitation-plugin.ts +4 -6
  312. package/src/protocol/party-protocol-factory.ts +3 -56
  313. package/src/protocol/replicator-plugin.ts +37 -0
  314. package/src/snapshots/snapshot-generator.ts +13 -17
  315. package/src/snapshots/snapshot-store.test.ts +2 -2
  316. package/src/snapshots/snapshot-store.ts +5 -6
  317. package/src/snapshots/snapshot.test.ts +1 -1
  318. package/src/testing/benchmark.test.ts +30 -0
  319. package/src/testing/testing-factories.ts +3 -3
  320. package/src/testing/testing.ts +4 -8
  321. package/dist/src/api/database.d.ts.map +0 -1
  322. package/dist/src/api/database.js.map +0 -1
  323. package/dist/src/api/database.test.d.ts.map +0 -1
  324. package/dist/src/api/database.test.js.map +0 -1
  325. package/dist/src/api/entity.d.ts.map +0 -1
  326. package/dist/src/api/entity.js.map +0 -1
  327. package/dist/src/api/item.d.ts.map +0 -1
  328. package/dist/src/api/item.js.map +0 -1
  329. package/dist/src/api/link.d.ts.map +0 -1
  330. package/dist/src/api/link.js.map +0 -1
  331. package/dist/src/api/selection/index.d.ts.map +0 -1
  332. package/dist/src/api/selection/index.js.map +0 -1
  333. package/dist/src/api/selection/queries.d.ts.map +0 -1
  334. package/dist/src/api/selection/queries.js.map +0 -1
  335. package/dist/src/api/selection/result.d.ts.map +0 -1
  336. package/dist/src/api/selection/result.js.map +0 -1
  337. package/dist/src/api/selection/selection.d.ts.map +0 -1
  338. package/dist/src/api/selection/selection.js.map +0 -1
  339. package/dist/src/api/selection/selection.test.d.ts.map +0 -1
  340. package/dist/src/api/selection/selection.test.js.map +0 -1
  341. package/dist/src/api/selection/util.d.ts.map +0 -1
  342. package/dist/src/api/selection/util.js.map +0 -1
  343. package/dist/src/database/data-mirror.d.ts.map +0 -1
  344. package/dist/src/database/data-mirror.js.map +0 -1
  345. package/dist/src/database/data-mirror.test.d.ts.map +0 -1
  346. package/dist/src/database/data-mirror.test.js.map +0 -1
  347. package/dist/src/database/data-service-host.d.ts.map +0 -1
  348. package/dist/src/database/data-service-host.js.map +0 -1
  349. package/dist/src/database/data-service-router.d.ts.map +0 -1
  350. package/dist/src/database/data-service-router.js.map +0 -1
  351. package/dist/src/database/database-backend.d.ts.map +0 -1
  352. package/dist/src/database/database-backend.js.map +0 -1
  353. package/dist/src/database/index.d.ts.map +0 -1
  354. package/dist/src/database/index.js.map +0 -1
  355. package/dist/src/database/item-demuxer.d.ts.map +0 -1
  356. package/dist/src/database/item-demuxer.js.map +0 -1
  357. package/dist/src/database/item-demuxer.test.d.ts.map +0 -1
  358. package/dist/src/database/item-demuxer.test.js.map +0 -1
  359. package/dist/src/database/item-manager.d.ts.map +0 -1
  360. package/dist/src/database/item-manager.js.map +0 -1
  361. package/dist/src/database/item-manager.test.d.ts.map +0 -1
  362. package/dist/src/database/item-manager.test.js.map +0 -1
  363. package/dist/src/database/testing.d.ts.map +0 -1
  364. package/dist/src/database/testing.js.map +0 -1
  365. package/dist/src/database/timeframe-clock.d.ts.map +0 -1
  366. package/dist/src/database/timeframe-clock.js.map +0 -1
  367. package/dist/src/errors.d.ts.map +0 -1
  368. package/dist/src/errors.js.map +0 -1
  369. package/dist/src/util/index.d.ts +0 -2
  370. package/dist/src/util/index.d.ts.map +0 -1
  371. package/dist/src/util/index.js +0 -17
  372. package/dist/src/util/index.js.map +0 -1
  373. package/dist/src/util/persistant-ram-storage.d.ts +0 -6
  374. package/dist/src/util/persistant-ram-storage.d.ts.map +0 -1
  375. package/dist/src/util/persistant-ram-storage.js +0 -32
  376. package/dist/src/util/persistant-ram-storage.js.map +0 -1
  377. package/src/util/index.ts +0 -5
  378. package/src/util/persistant-ram-storage.ts +0 -33
@@ -10,10 +10,11 @@ import { failUndefined } from '@dxos/debug';
10
10
  import { DatabaseSnapshot, IEchoStream, ItemID, ItemSnapshot, LinkSnapshot } from '@dxos/echo-protocol';
11
11
  import { createWritable } from '@dxos/feed-store';
12
12
  import { Model, ModelFactory, ModelMessage } from '@dxos/model-factory';
13
- import { jsonReplacer } from '@dxos/util';
14
13
 
15
- import { Entity, Item, Link } from '../api';
14
+ import { Entity } from './entity';
15
+ import { Item } from './item';
16
16
  import { ItemManager, ModelConstructionOptions } from './item-manager';
17
+ import { Link } from './link';
17
18
 
18
19
  const log = debug('dxos:echo-db:item-demuxer');
19
20
 
@@ -46,7 +47,6 @@ export class ItemDemuxer {
46
47
  // TODO(burdon): Factor out.
47
48
  // TODO(burdon): Should this implement some "back-pressure" (hints) to the PartyProcessor?
48
49
  return createWritable<IEchoStream>(async (message: IEchoStream) => {
49
- log('Reading:', JSON.stringify(message, jsonReplacer));
50
50
  const { data: { itemId, genesis, itemMutation, mutation, snapshot }, meta } = message;
51
51
  assert(itemId);
52
52
 
@@ -187,7 +187,7 @@ export class ItemDemuxer {
187
187
  * Sort based on parents.
188
188
  * @param items
189
189
  */
190
- export function sortItemsTopologically (items: ItemSnapshot[]): ItemSnapshot[] {
190
+ export const sortItemsTopologically = (items: ItemSnapshot[]): ItemSnapshot[] => {
191
191
  const snapshots: ItemSnapshot[] = [];
192
192
  const seenIds = new Set<ItemID>();
193
193
 
@@ -206,4 +206,4 @@ export function sortItemsTopologically (items: ItemSnapshot[]): ItemSnapshot[] {
206
206
  }
207
207
 
208
208
  return snapshots;
209
- }
209
+ };
@@ -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
@@ -8,14 +8,14 @@ import { PublicKey } from '@dxos/crypto';
8
8
  import { EchoEnvelope, MockFeedWriter, Timeframe } from '@dxos/echo-protocol';
9
9
  import { ModelFactory } from '@dxos/model-factory';
10
10
 
11
- import { Database } from '../api';
12
11
  import { DataServiceHost } from './data-service-host';
13
12
  import { DataServiceRouter } from './data-service-router';
13
+ import { Database } from './database';
14
14
  import { FeedDatabaseBackend, RemoteDatabaseBackend } from './database-backend';
15
15
 
16
16
  export const createInMemoryDatabase = async (modelFactory: ModelFactory) => {
17
17
  const feed = new MockFeedWriter<EchoEnvelope>();
18
- const inboundStream = new Readable({ read () {}, objectMode: true });
18
+ const inboundStream = new Readable({ read: () => {}, objectMode: true });
19
19
  feed.written.on(([data, meta]) => inboundStream.push({ data, meta: { ...meta, memberKey: PublicKey.random(), timeframe: new Timeframe([[meta.feedKey, meta.seq]]) } }));
20
20
 
21
21
  const database = new Database(
File without changes
@@ -19,14 +19,15 @@ import { MetadataStore, PartyFeedProvider } from '../pipeline';
19
19
  import { createAuthenticator, createCredentialsProvider } from '../protocol';
20
20
  import { createTestIdentityCredentials, deriveTestDeviceCredentials, IdentityCredentials } from '../protocol/identity-credentials';
21
21
  import { SnapshotStore } from '../snapshots';
22
- import { createRamStorage } from '../util';
23
22
  import { DataParty } from './data-party';
24
23
 
25
24
  describe('DataParty', () => {
26
25
  const createParty = async (identity: IdentityCredentials, partyKey: PublicKey, hints: KeyHint[]) => {
27
- const metadataStore = new MetadataStore(createRamStorage());
28
- const feedStore = new FeedStore(createStorage('', StorageType.RAM), { valueEncoding: codec });
29
- const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
26
+
27
+ const storage = createStorage('', StorageType.RAM);
28
+ const snapshotStore = new SnapshotStore(storage.directory('snapshots'));
29
+ const metadataStore = new MetadataStore(storage.directory('metadata'));
30
+ const feedStore = new FeedStore(storage.directory('feed'), { valueEncoding: codec });
30
31
  const modelFactory = new ModelFactory().registerModel(ObjectModel);
31
32
  const networkManager = new NetworkManager();
32
33
  const partyFeedProvider = new PartyFeedProvider(metadataStore, identity.keyring, feedStore, partyKey);
@@ -60,8 +61,8 @@ describe('DataParty', () => {
60
61
  const party = await createParty(identity, partyKey.publicKey, []);
61
62
  await party.open();
62
63
 
63
- const feed = await party.feedProvider.createOrOpenWritableFeed();
64
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
64
+ const feed = await party.getWriteFeed();
65
+ await party.credentialsWriter.write(createPartyGenesisMessage(
65
66
  keyring,
66
67
  partyKey,
67
68
  feed.key,
@@ -80,15 +81,15 @@ describe('DataParty', () => {
80
81
 
81
82
  const party = await createParty(identity, partyKey.publicKey, []);
82
83
  await party.open();
83
- const feed = await party.feedProvider.createOrOpenWritableFeed();
84
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
84
+ const feed = await party.getWriteFeed();
85
+ await party.credentialsWriter.write(createPartyGenesisMessage(
85
86
  keyring,
86
87
  partyKey,
87
88
  feed.key,
88
89
  partyKey
89
90
  ));
90
91
 
91
- const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner());
92
+ const authenticator = createAuthenticator(party.processor, identity.createCredentialsSigner(), party.credentialsWriter);
92
93
  const credentialsProvider = createCredentialsProvider(identity.createCredentialsSigner(), party.key, feed.key);
93
94
 
94
95
  const wrappedCredentials = haloCodec.decode(credentialsProvider.get());
@@ -104,14 +105,14 @@ describe('DataParty', () => {
104
105
 
105
106
  const party = await createParty(identityA, partyKey.publicKey, []);
106
107
  await party.open();
107
- const feed = await party.feedProvider.createOrOpenWritableFeed();
108
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
108
+ const feed = await party.getWriteFeed();
109
+ await party.credentialsWriter.write(createPartyGenesisMessage(
109
110
  keyring,
110
111
  partyKey,
111
112
  feed.key,
112
113
  partyKey
113
114
  ));
114
- const authenticator = createAuthenticator(party.processor, identityA.createCredentialsSigner());
115
+ const authenticator = createAuthenticator(party.processor, identityA.createCredentialsSigner(), party.credentialsWriter);
115
116
 
116
117
  const identityB = await deriveTestDeviceCredentials(identityA);
117
118
  const credentialsProvider = createCredentialsProvider(identityB.createCredentialsSigner(), party.key, feed.key);
@@ -129,14 +130,14 @@ describe('DataParty', () => {
129
130
 
130
131
  const partyA = await createParty(identityA, partyKey.publicKey, []);
131
132
  await partyA.open();
132
- const feedA = await partyA.feedProvider.createOrOpenWritableFeed();
133
- await partyA.processor.writeHaloMessage(createPartyGenesisMessage(
133
+ const feedA = await partyA.getWriteFeed();
134
+ await partyA.credentialsWriter.write(createPartyGenesisMessage(
134
135
  keyring,
135
136
  partyKey,
136
137
  feedA.key,
137
138
  partyKey
138
139
  ));
139
- await partyA.processor.writeHaloMessage(createKeyAdmitMessage(
140
+ await partyA.credentialsWriter.write(createKeyAdmitMessage(
140
141
  keyring,
141
142
  partyKey.publicKey,
142
143
  identityA.identityKey,
@@ -165,14 +166,14 @@ describe('DataParty', () => {
165
166
 
166
167
  const partyA = await createParty(identityA, partyKeyA.publicKey, []);
167
168
  await partyA.open();
168
- const feedA = await partyA.feedProvider.createOrOpenWritableFeed();
169
- await partyA.processor.writeHaloMessage(createPartyGenesisMessage(
169
+ const feedA = await partyA.getWriteFeed();
170
+ await partyA.credentialsWriter.write(createPartyGenesisMessage(
170
171
  identityA.keyring,
171
172
  partyKeyA,
172
173
  feedA.key,
173
174
  partyKeyA
174
175
  ));
175
- await partyA.processor.writeHaloMessage(createKeyAdmitMessage(
176
+ await partyA.credentialsWriter.write(createKeyAdmitMessage(
176
177
  identityA.keyring,
177
178
  partyKeyA.publicKey,
178
179
  identityA.identityKey,
@@ -9,16 +9,19 @@ import { KeyHint } from '@dxos/credentials';
9
9
  import { PublicKey } from '@dxos/crypto';
10
10
  import { timed } from '@dxos/debug';
11
11
  import { PartyKey, PartySnapshot, Timeframe } from '@dxos/echo-protocol';
12
+ import { FeedDescriptor } from '@dxos/feed-store';
12
13
  import { ModelFactory } from '@dxos/model-factory';
13
14
  import { NetworkManager } from '@dxos/network-manager';
14
15
  import { ObjectModel } from '@dxos/object-model';
15
16
 
16
- import { Database, Item, ResultSet } from '../api';
17
+ import { ResultSet } from '../api';
17
18
  import { ActivationOptions, PartyPreferences, Preferences } from '../halo';
18
19
  import { InvitationFactory } from '../invitations';
20
+ import { Database, Item } from '../packlets/database';
19
21
  import { PartyFeedProvider, PartyProtocolFactory, PartyCore, PartyOptions } from '../pipeline';
20
22
  import { createAuthPlugin, createOfflineInvitationPlugin, createAuthenticator, createCredentialsProvider } from '../protocol';
21
23
  import { CredentialsSigner } from '../protocol/credentials-signer';
24
+ import { createReplicatorPlugin } from '../protocol/replicator-plugin';
22
25
  import { SnapshotStore } from '../snapshots';
23
26
  import { CONTACT_DEBOUNCE_INTERVAL } from './party-manager';
24
27
 
@@ -125,14 +128,8 @@ export class DataParty {
125
128
  return this._invitationManager;
126
129
  }
127
130
 
128
- // TODO(burdon): Remove?
129
- get feedProvider (): PartyFeedProvider {
130
- return this._feedProvider;
131
- }
132
-
133
- get preferences (): PartyPreferences {
134
- assert(this._preferences, 'Preferences not available.');
135
- return this._preferences;
131
+ get credentialsWriter () {
132
+ return this._partyCore.credentialsWriter;
136
133
  }
137
134
 
138
135
  get title () {
@@ -160,6 +157,7 @@ export class DataParty {
160
157
  this._invitationManager = new InvitationFactory(
161
158
  this._partyCore.processor,
162
159
  this._credentialsSigner,
160
+ this._partyCore.credentialsWriter,
163
161
  this._networkManager
164
162
  );
165
163
 
@@ -173,13 +171,13 @@ export class DataParty {
173
171
  this._protocol = new PartyProtocolFactory(
174
172
  this._partyCore.key,
175
173
  this._networkManager,
176
- this._feedProvider,
177
174
  deviceKey.publicKey,
178
175
  createCredentialsProvider(this._credentialsSigner, this._partyCore.key, writeFeed.key)
179
176
  );
180
177
 
181
178
  await this._protocol.start([
182
- createAuthPlugin(createAuthenticator(this._partyCore.processor, this._credentialsSigner), deviceKey.publicKey),
179
+ createReplicatorPlugin(this._feedProvider),
180
+ createAuthPlugin(createAuthenticator(this._partyCore.processor, this._credentialsSigner, this.credentialsWriter), deviceKey.publicKey),
183
181
  createOfflineInvitationPlugin(this._invitationManager, deviceKey.publicKey)
184
182
  ]);
185
183
 
@@ -210,6 +208,14 @@ export class DataParty {
210
208
  return this;
211
209
  }
212
210
 
211
+ async getWriteFeed (): Promise<FeedDescriptor> {
212
+ return this._feedProvider.createOrOpenWritableFeed();
213
+ }
214
+
215
+ getFeeds (): FeedDescriptor[] {
216
+ return this._feedProvider.getFeeds();
217
+ }
218
+
213
219
  get isActive (): boolean {
214
220
  assert(this._preferences, 'PartyActivator required');
215
221
  return this._preferences.isActive;
@@ -21,11 +21,11 @@ import { ModelFactory } from '@dxos/model-factory';
21
21
  import { NetworkManager } from '@dxos/network-manager';
22
22
  import { ObjectModel } from '@dxos/object-model';
23
23
 
24
- import { IdentityNotInitializedError } from '../errors';
25
24
  import {
26
25
  createDataPartyAdmissionMessages,
27
26
  GreetingInitiator, InvitationDescriptor, InvitationDescriptorType, OfflineInvitationClaimer
28
27
  } from '../invitations';
28
+ import { IdentityNotInitializedError } from '../packlets/errors';
29
29
  import { PartyFeedProvider, PartyOptions } from '../pipeline';
30
30
  import { IdentityCredentialsProvider } from '../protocol/identity-credentials';
31
31
  import { SnapshotStore } from '../snapshots';
@@ -60,10 +60,10 @@ export class PartyFactory {
60
60
  // Connect the pipeline.
61
61
  await party.open();
62
62
 
63
- const writableFeed = await party.feedProvider.createOrOpenWritableFeed();
63
+ const writableFeed = await party.getWriteFeed();
64
64
 
65
65
  // PartyGenesis (self-signed by Party).
66
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
66
+ await party.credentialsWriter.write(createPartyGenesisMessage(
67
67
  identity.keyring,
68
68
  partyKey,
69
69
  writableFeed.key,
@@ -71,7 +71,7 @@ export class PartyFactory {
71
71
  );
72
72
 
73
73
  // KeyAdmit (IdentityGenesis in an Envelope signed by Party).
74
- await party.processor.writeHaloMessage(createEnvelopeMessage(
74
+ await party.credentialsWriter.write(createEnvelopeMessage(
75
75
  identity.keyring,
76
76
  partyKey.publicKey,
77
77
  wrapMessage(identity.identityGenesis),
@@ -80,7 +80,7 @@ export class PartyFactory {
80
80
 
81
81
  // FeedAdmit (signed by the Device KeyChain).
82
82
  // TODO(dmaretskyi): Is this really needed since a feed is already admitted by party genesis message.
83
- await party.processor.writeHaloMessage(createFeedAdmitMessage(
83
+ await party.credentialsWriter.write(createFeedAdmitMessage(
84
84
  identity.keyring,
85
85
  partyKey.publicKey,
86
86
  writableFeed.key,
@@ -89,7 +89,7 @@ export class PartyFactory {
89
89
 
90
90
  // IdentityInfo in an Envelope signed by the Device KeyChain.
91
91
  if (identity.identityInfo) {
92
- await party.processor.writeHaloMessage(createEnvelopeMessage(
92
+ await party.credentialsWriter.write(createEnvelopeMessage(
93
93
  identity.keyring,
94
94
  partyKey.publicKey,
95
95
  wrapMessage(identity.identityInfo),
@@ -106,50 +106,6 @@ export class PartyFactory {
106
106
  return party;
107
107
  }
108
108
 
109
- /**
110
- * Constructs a party object and creates a local write feed for it.
111
- * @param partyKey
112
- * @param hints
113
- */
114
- async addParty (partyKey: PartyKey, hints: KeyHint[] = []) {
115
- const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
116
-
117
- /*
118
- * TODO(telackey): We shouldn't have to add our key here, it should be in the hints, but our hint
119
- * mechanism is broken by not waiting on the messages to be processed before returning.
120
- */
121
-
122
- const feedProvider = this._feedProviderFactory(partyKey);
123
- const { feed } = await feedProvider.createOrOpenWritableFeed();
124
- const feedKeyPair = identity.keyring.getKey(feed.key);
125
- assert(feedKeyPair, 'Keypair for writable feed not found.');
126
- const party = new DataParty(
127
- partyKey,
128
- this._modelFactory,
129
- this._snapshotStore,
130
- feedProvider,
131
- identity.createCredentialsSigner(),
132
- identity.preferences,
133
- this._networkManager,
134
- hints,
135
- undefined,
136
- this._options
137
- );
138
-
139
- await party.open();
140
- const isHalo = identity.identityKey.publicKey.equals(partyKey);
141
- const signingKey = isHalo ? identity.deviceKey : identity.deviceKeyChain;
142
- assert(signingKey, 'No device key or keychain.');
143
- // Write the Feed genesis message.
144
- await party.processor.writeHaloMessage(createFeedAdmitMessage(
145
- identity.keyring,
146
- partyKey,
147
- feedKeyPair.publicKey,
148
- [signingKey]
149
- ));
150
- return party;
151
- }
152
-
153
109
  /**
154
110
  * Constructs a party object from an existing set of feeds.
155
111
  * @param partyKey
@@ -190,7 +146,6 @@ export class PartyFactory {
190
146
  }
191
147
 
192
148
  async joinParty (invitationDescriptor: InvitationDescriptor, secretProvider: SecretProvider): Promise<DataParty> {
193
- const haloInvitation = !!invitationDescriptor.identityKey;
194
149
  const originalInvitation = invitationDescriptor;
195
150
 
196
151
  const identity = this._identityProvider() ?? raise(new IdentityNotInitializedError());
@@ -218,19 +173,18 @@ export class PartyFactory {
218
173
 
219
174
  await initiator.connect();
220
175
  const { partyKey, hints } = await initiator.redeemInvitation(secretProvider);
221
- const party = await this.addParty(partyKey, hints);
176
+ const party = await this.constructParty(partyKey, hints);
177
+ await party.open();
222
178
  await initiator.destroy();
223
- if (!haloInvitation) {
224
- // Copy our signed IdentityInfo into the new Party.
225
- const infoMessage = identity.identityInfo;
226
- if (infoMessage) {
227
- await party.processor.writeHaloMessage(createEnvelopeMessage(
228
- identity.keyring,
229
- partyKey,
230
- wrapMessage(infoMessage),
231
- [identity.deviceKeyChain]
232
- ));
233
- }
179
+
180
+ // Copy our signed IdentityInfo into the new Party.
181
+ if (identity.identityInfo) {
182
+ await party.credentialsWriter.write(createEnvelopeMessage(
183
+ identity.keyring,
184
+ partyKey,
185
+ wrapMessage(identity.identityInfo),
186
+ [identity.deviceKeyChain]
187
+ ));
234
188
  }
235
189
 
236
190
  return party;
@@ -247,10 +201,10 @@ export class PartyFactory {
247
201
  // Connect the pipeline.
248
202
  await party.open();
249
203
 
250
- const writableFeed = await party.feedProvider.createOrOpenWritableFeed();
204
+ const writableFeed = await party.getWriteFeed();
251
205
 
252
206
  // PartyGenesis (self-signed by Party).
253
- await party.processor.writeHaloMessage(createPartyGenesisMessage(
207
+ await party.credentialsWriter.write(createPartyGenesisMessage(
254
208
  identity.keyring,
255
209
  partyKey,
256
210
  writableFeed.key,
@@ -258,7 +212,7 @@ export class PartyFactory {
258
212
  );
259
213
 
260
214
  // KeyAdmit (IdentityGenesis in an Envelope signed by Party).
261
- await party.processor.writeHaloMessage(createEnvelopeMessage(
215
+ await party.credentialsWriter.write(createEnvelopeMessage(
262
216
  identity.keyring,
263
217
  partyKey.publicKey,
264
218
  wrapMessage(identity.identityGenesis),
@@ -266,7 +220,7 @@ export class PartyFactory {
266
220
  ));
267
221
 
268
222
  // FeedAdmit (signed by the Device KeyChain).
269
- await party.processor.writeHaloMessage(createFeedAdmitMessage(
223
+ await party.credentialsWriter.write(createFeedAdmitMessage(
270
224
  identity.keyring,
271
225
  partyKey.publicKey,
272
226
  writableFeed.key,
@@ -275,7 +229,7 @@ export class PartyFactory {
275
229
 
276
230
  // IdentityInfo in an Envelope signed by the Device KeyChain.
277
231
  if (identity.identityInfo) {
278
- await party.processor.writeHaloMessage(createEnvelopeMessage(
232
+ await party.credentialsWriter.write(createEnvelopeMessage(
279
233
  identity.keyring,
280
234
  partyKey.publicKey,
281
235
  wrapMessage(identity.identityInfo),
@@ -285,7 +239,7 @@ export class PartyFactory {
285
239
 
286
240
  // const keyAdmitMessage = snapshot.halo?.messages?.[1];
287
241
  // assert(keyAdmitMessage);
288
- // await party.processor.writeHaloMessage(createEnvelopeMessage(
242
+ // await party.writeCredentialsMessage(createEnvelopeMessage(
289
243
  // identity.signer,
290
244
  // partyKey.publicKey,
291
245
  // keyAdmitMessage,
@@ -293,13 +247,14 @@ export class PartyFactory {
293
247
  // ));
294
248
 
295
249
  // for(const message of snapshot.halo?.messages?.slice(2) || []) {
296
- // await party.processor.writeHaloMessage(message);
250
+ // await party.writeCredentialsMessage(message);
297
251
  // }
298
252
 
299
253
  // Write messages to create ECHO items.
300
254
  const feedWriter = createFeedWriter(writableFeed.feed);
301
255
  for (const item of snapshot.database?.items || []) {
302
256
  const message: FeedMessage = {
257
+ timeframe: new Timeframe(),
303
258
  echo: {
304
259
  itemId: item.itemId ?? failUndefined(),
305
260
  genesis: {
@@ -310,8 +265,7 @@ export class PartyFactory {
310
265
  itemMutation: {
311
266
  parentId: item.parentId
312
267
  },
313
- snapshot: item.model,
314
- timeframe: new Timeframe()
268
+ snapshot: item.model
315
269
  }
316
270
  };
317
271
  await feedWriter.write(message);