@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
@@ -16,8 +16,8 @@ import {
16
16
  import { createReadable } from '@dxos/feed-store';
17
17
  import { jsonReplacer } from '@dxos/util';
18
18
 
19
- import { TimeframeClock } from '../database';
20
- import { PartyProcessor } from './party-processor';
19
+ import { TimeframeClock } from '../packlets/database';
20
+ import { CredentialProcessor, PartyStateProvider } from './party-processor';
21
21
 
22
22
  interface Options {
23
23
  readLogger?: (msg: any) => void
@@ -55,17 +55,13 @@ export class Pipeline {
55
55
  * @param _options
56
56
  */
57
57
  constructor (
58
- private readonly _partyProcessor: PartyProcessor,
58
+ private readonly _partyProcessor: CredentialProcessor & PartyStateProvider,
59
59
  private readonly _feedStorIterator: FeedStoreIterator,
60
60
  private readonly _timeframeClock: TimeframeClock,
61
61
  private readonly _feedWriter?: FeedWriter<FeedMessage>,
62
62
  private readonly _options: Options = {}
63
63
  ) {}
64
64
 
65
- get partyKey () {
66
- return this._partyProcessor.partyKey;
67
- }
68
-
69
65
  get isOpen () {
70
66
  return this._inboundEchoStream !== undefined;
71
67
  }
@@ -113,6 +109,8 @@ export class Pipeline {
113
109
  try {
114
110
  const { data: message } = block;
115
111
 
112
+ this._timeframeClock.updateTimeframe(PublicKey.from(block.key), block.seq);
113
+
116
114
  //
117
115
  // HALO
118
116
  //
@@ -129,7 +127,6 @@ export class Pipeline {
129
127
  //
130
128
 
131
129
  if (message.echo) {
132
- this._timeframeClock.updateTimeframe(PublicKey.from(block.key), block.seq);
133
130
  const memberKey = this._partyProcessor.getFeedOwningMember(PublicKey.from(block.key));
134
131
  assert(memberKey, `Ownership of feed ${keyToString(block.key)} could not be determined.`);
135
132
 
@@ -142,7 +139,7 @@ export class Pipeline {
142
139
  seq: block.seq,
143
140
  feedKey: block.key,
144
141
  memberKey,
145
- timeframe: message.echo.timeframe ?? new Timeframe()
142
+ timeframe: message.timeframe ?? new Timeframe()
146
143
  },
147
144
  data: message.echo
148
145
  }));
@@ -171,13 +168,13 @@ export class Pipeline {
171
168
  }, this._feedWriter);
172
169
 
173
170
  this._outboundEchoStream = mapFeedWriter<EchoEnvelope, FeedMessage>(async message => ({
174
- echo: {
175
- ...message,
176
- timeframe: this._timeframeClock.timeframe
177
- }
171
+ timeframe: this._timeframeClock.timeframe,
172
+ echo: message
173
+ }), loggingWriter);
174
+ this._outboundHaloStream = mapFeedWriter<HaloMessage, FeedMessage>(async message => ({
175
+ timeframe: this._timeframeClock.timeframe,
176
+ halo: message
178
177
  }), loggingWriter);
179
- this._outboundHaloStream =
180
- mapFeedWriter<HaloMessage, FeedMessage>(async message => ({ halo: message }), loggingWriter);
181
178
  }
182
179
 
183
180
  return [
@@ -9,6 +9,4 @@ import { Replicator } from '@dxos/protocol-plugin-replicator';
9
9
  /**
10
10
  * Creates authenticator network-protocol plugin that guards access to the replicator.
11
11
  */
12
- export function createAuthPlugin (authenticator: Authenticator, peerId: PublicKey) {
13
- return new AuthPlugin(peerId.asBuffer(), authenticator, [Replicator.extension]);
14
- }
12
+ export const createAuthPlugin = (authenticator: Authenticator, peerId: PublicKey) => new AuthPlugin(peerId.asBuffer(), authenticator, [Replicator.extension]);
@@ -6,7 +6,6 @@ import expect from 'expect';
6
6
  import { it as test } from 'mocha';
7
7
 
8
8
  import { createAuthMessage, createKeyAdmitMessage, createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
9
- import { MockFeedWriter } from '@dxos/echo-protocol';
10
9
 
11
10
  import { PartyProcessor } from '../pipeline';
12
11
  import { createAuthenticator } from './authenticator';
@@ -23,8 +22,6 @@ describe('authenticator', () => {
23
22
  const signer = CredentialsSigner.createDirectDeviceSigner(keyring);
24
23
 
25
24
  const partyProcessor = new PartyProcessor(partyKey.publicKey);
26
- const feed = new MockFeedWriter();
27
- partyProcessor.setOutboundStream(feed);
28
25
  await partyProcessor.processMessage({
29
26
  data: createPartyGenesisMessage(
30
27
  keyring,
@@ -53,7 +50,7 @@ describe('authenticator', () => {
53
50
  meta: {} as any
54
51
  });
55
52
 
56
- const authenticator = createAuthenticator(partyProcessor, signer);
53
+ const authenticator = createAuthenticator(partyProcessor, signer, null as any);
57
54
  const credential = createAuthMessage(
58
55
  keyring,
59
56
  partyKey.publicKey,
@@ -4,27 +4,29 @@
4
4
 
5
5
  import debug from 'debug';
6
6
 
7
- import { Authenticator, codec, createAuthMessage, createEnvelopeMessage, createFeedAdmitMessage, PartyAuthenticator } from '@dxos/credentials';
8
- import { FeedKey, PartyKey } from '@dxos/echo-protocol';
7
+ import { Message as HaloMessage, Authenticator, codec, createAuthMessage, createEnvelopeMessage, createFeedAdmitMessage, PartyAuthenticator } from '@dxos/credentials';
8
+ import { FeedKey, FeedWriter, PartyKey } from '@dxos/echo-protocol';
9
9
 
10
10
  import { PartyProcessor } from '../pipeline';
11
11
  import { CredentialsSigner } from './credentials-signer';
12
12
 
13
13
  const log = debug('dxos:echo-db:authenticator');
14
14
 
15
- export function createAuthenticator (partyProcessor: PartyProcessor, credentialsSigner: CredentialsSigner): Authenticator {
16
- return new PartyAuthenticator(partyProcessor.state, async auth => {
17
- if (auth.feedAdmit && auth.feedKey && !partyProcessor.isFeedAdmitted(auth.feedKey)) {
18
- log(`Admitting feed of authenticated member: ${auth.feedKey}`);
19
- await partyProcessor.writeHaloMessage(createEnvelopeMessage(
20
- credentialsSigner.signer,
21
- partyProcessor.partyKey,
22
- auth.feedAdmit,
23
- [credentialsSigner.getDeviceSigningKeys()]
24
- ));
25
- }
26
- });
27
- }
15
+ export const createAuthenticator = (
16
+ partyProcessor: PartyProcessor,
17
+ credentialsSigner: CredentialsSigner,
18
+ credentialsWriter: FeedWriter<HaloMessage>
19
+ ): Authenticator => new PartyAuthenticator(partyProcessor.state, async auth => {
20
+ if (auth.feedAdmit && auth.feedKey && !partyProcessor.isFeedAdmitted(auth.feedKey)) {
21
+ log(`Admitting feed of authenticated member: ${auth.feedKey}`);
22
+ await credentialsWriter.write(createEnvelopeMessage(
23
+ credentialsSigner.signer,
24
+ partyProcessor.partyKey,
25
+ auth.feedAdmit,
26
+ [credentialsSigner.getDeviceSigningKeys()]
27
+ ));
28
+ }
29
+ });
28
30
 
29
31
  export interface CredentialsProvider {
30
32
  /**
@@ -33,24 +35,22 @@ export interface CredentialsProvider {
33
35
  get (): Buffer
34
36
  }
35
37
 
36
- export function createCredentialsProvider (credentialsSigner: CredentialsSigner, partyKey: PartyKey, feedKey: FeedKey): CredentialsProvider {
37
- return {
38
- get: () => {
39
- const authMessage = createAuthMessage(
38
+ export const createCredentialsProvider = (credentialsSigner: CredentialsSigner, partyKey: PartyKey, feedKey: FeedKey): CredentialsProvider => ({
39
+ get: () => {
40
+ const authMessage = createAuthMessage(
41
+ credentialsSigner.signer,
42
+ partyKey,
43
+ credentialsSigner.getIdentityKey(),
44
+ credentialsSigner.getDeviceSigningKeys(),
45
+ feedKey,
46
+ undefined,
47
+ createFeedAdmitMessage(
40
48
  credentialsSigner.signer,
41
49
  partyKey,
42
- credentialsSigner.getIdentityKey(),
43
- credentialsSigner.getDeviceSigningKeys(),
44
50
  feedKey,
45
- undefined,
46
- createFeedAdmitMessage(
47
- credentialsSigner.signer,
48
- partyKey,
49
- feedKey,
50
- [feedKey, credentialsSigner.getDeviceSigningKeys()]
51
- )
52
- );
53
- return Buffer.from(codec.encode(authMessage));
54
- }
55
- };
56
- }
51
+ [feedKey, credentialsSigner.getDeviceSigningKeys()]
52
+ )
53
+ );
54
+ return Buffer.from(codec.encode(authMessage));
55
+ }
56
+ });
@@ -12,9 +12,7 @@ import { HaloRecoveryInitiator, InvitationFactory } from '../invitations';
12
12
  * Plugin is intended to be used in HALO party swarm.
13
13
  *
14
14
  */
15
- export function createHaloRecoveryPlugin (identityKey: PublicKey, invitationFactory: InvitationFactory, peerId: PublicKey) {
16
- return new GreetingCommandPlugin(
17
- peerId.asBuffer(),
18
- HaloRecoveryInitiator.createHaloInvitationClaimHandler(identityKey, invitationFactory)
19
- );
20
- }
15
+ export const createHaloRecoveryPlugin = (identityKey: PublicKey, invitationFactory: InvitationFactory, peerId: PublicKey) => new GreetingCommandPlugin(
16
+ peerId.asBuffer(),
17
+ HaloRecoveryInitiator.createHaloInvitationClaimHandler(identityKey, invitationFactory)
18
+ );
@@ -25,7 +25,7 @@ export interface IdentityCredentials {
25
25
 
26
26
  export type IdentityCredentialsProvider = () => IdentityCredentials | undefined
27
27
 
28
- export async function createTestIdentityCredentials (keyring: Keyring): Promise<IdentityCredentials> {
28
+ export const createTestIdentityCredentials = async (keyring: Keyring): Promise<IdentityCredentials> => {
29
29
  const identityKey = await keyring.createKeyRecord({ type: KeyType.IDENTITY });
30
30
  const deviceKey = await keyring.createKeyRecord({ type: KeyType.DEVICE });
31
31
  const feedKey = await keyring.createKeyRecord({ type: KeyType.FEED });
@@ -53,9 +53,9 @@ export async function createTestIdentityCredentials (keyring: Keyring): Promise<
53
53
  preferences: undefined,
54
54
  contacts: undefined
55
55
  };
56
- }
56
+ };
57
57
 
58
- export async function deriveTestDeviceCredentials (identity: IdentityCredentials): Promise<IdentityCredentials> {
58
+ export const deriveTestDeviceCredentials = async (identity: IdentityCredentials): Promise<IdentityCredentials> => {
59
59
  const deviceKey = await identity.keyring.createKeyRecord({ type: KeyType.DEVICE });
60
60
  const keyAdmit = createKeyAdmitMessage(identity.keyring, identity.identityKey.publicKey, deviceKey, [identity.identityKey]);
61
61
 
@@ -75,4 +75,4 @@ export async function deriveTestDeviceCredentials (identity: IdentityCredentials
75
75
  deviceKeyChain
76
76
  )
77
77
  };
78
- }
78
+ };
@@ -11,9 +11,7 @@ import { InvitationFactory, OfflineInvitationClaimer } from '../invitations';
11
11
  * Creates network protocol plugin that allows peers to claim offline invitations.
12
12
  * Plugin is intended to be used in data-party swarms.
13
13
  */
14
- export function createOfflineInvitationPlugin (invitationFactory: InvitationFactory, peerId: PublicKey) {
15
- return new GreetingCommandPlugin(
16
- peerId.asBuffer(),
17
- OfflineInvitationClaimer.createOfflineInvitationClaimHandler(invitationFactory)
18
- );
19
- }
14
+ export const createOfflineInvitationPlugin = (invitationFactory: InvitationFactory, peerId: PublicKey) => new GreetingCommandPlugin(
15
+ peerId.asBuffer(),
16
+ OfflineInvitationClaimer.createOfflineInvitationClaimHandler(invitationFactory)
17
+ );
@@ -4,17 +4,13 @@
4
4
 
5
5
  import debug from 'debug';
6
6
 
7
- import { synchronized } from '@dxos/async';
8
7
  import { discoveryKey, keyToString, PublicKey } from '@dxos/crypto';
9
- import { FeedKey, PartyKey } from '@dxos/echo-protocol';
10
- import type { HypercoreFeed } from '@dxos/feed-store';
8
+ import { PartyKey } from '@dxos/echo-protocol';
11
9
  import { Protocol } from '@dxos/mesh-protocol';
12
10
  import { MMSTTopology, NetworkManager, Plugin } from '@dxos/network-manager';
13
11
  import { PresencePlugin } from '@dxos/protocol-plugin-presence';
14
- import { Replicator } from '@dxos/protocol-plugin-replicator';
15
12
 
16
13
  import { CredentialsProvider } from '.';
17
- import { PartyFeedProvider } from '../pipeline/party-feed-provider';
18
14
 
19
15
  const log = debug('dxos:echo-db:party-protocol-factory');
20
16
 
@@ -23,21 +19,15 @@ const log = debug('dxos:echo-db:party-protocol-factory');
23
19
  */
24
20
  export class PartyProtocolFactory {
25
21
  private readonly _presencePlugin = new PresencePlugin(this._peerId.asBuffer());
26
- private readonly _replicatorProtocolPluginFactory: ReplicatorProtocolPluginFactory;
27
22
 
28
23
  private _started = false;
29
24
 
30
25
  constructor (
31
26
  private readonly _partyKey: PartyKey,
32
27
  private readonly _networkManager: NetworkManager,
33
- private readonly _feedProvider: PartyFeedProvider,
34
28
  private readonly _peerId: PublicKey,
35
29
  private readonly _credentials: CredentialsProvider
36
- ) {
37
- // Replication.
38
- this._replicatorProtocolPluginFactory =
39
- new ReplicatorProtocolPluginFactory(this._feedProvider);
40
- }
30
+ ) {}
41
31
 
42
32
  async start (plugins: Plugin[]) {
43
33
  if (this._started) {
@@ -73,9 +63,8 @@ export class PartyProtocolFactory {
73
63
  await this._networkManager.leaveProtocolSwarm(this._partyKey);
74
64
  }
75
65
 
76
- private _createProtocol (channel: any, opts: {initiator: boolean}, extraPlugins: Plugin[]) {
66
+ private _createProtocol (channel: any, opts: { initiator: boolean }, extraPlugins: Plugin[]) {
77
67
  const plugins: Plugin[] = [
78
- ...this._replicatorProtocolPluginFactory.createPlugins(),
79
68
  ...extraPlugins,
80
69
  this._presencePlugin
81
70
  ];
@@ -118,45 +107,3 @@ export class PartyProtocolFactory {
118
107
  return protocol;
119
108
  }
120
109
  }
121
-
122
- /**
123
- * Creates the protocol plugin for feed replication.
124
- */
125
- export class ReplicatorProtocolPluginFactory {
126
- constructor (
127
- private readonly _feedProvider: PartyFeedProvider
128
- ) {}
129
-
130
- createPlugins () {
131
- return [
132
- new Replicator({
133
- load: async () => {
134
- const feeds = this._feedProvider.getFeeds();
135
- log(`Loading feeds: ${feeds.map(feed => keyToString(feed.key))}`);
136
- return feeds.map((feed) => ({ discoveryKey: feed.feed.discoveryKey }));
137
- },
138
-
139
- subscribe: (addFeedToReplicatedSet: (feed: any) => void) => {
140
- return this._feedProvider.feedOpened.on(async (feed) => {
141
- log(`Adding feed: ${feed.key.toHex()}`);
142
- addFeedToReplicatedSet({ discoveryKey: feed.feed.discoveryKey });
143
- });
144
- },
145
-
146
- replicate: async (remoteFeeds, info) => {
147
- // We can ignore remoteFeeds entirely, since the set of feeds we want to replicate is dictated by the Party.
148
- // TODO(telackey): Why are we opening feeds? Necessary or belt/braces thinking, or because open party does it?
149
- const feeds = this._feedProvider.getFeeds();
150
- log(`Replicating: peerId=${info.session}; feeds=${feeds.map(feed => feed.key.toHex())}`);
151
- return feeds.map(feed => feed.feed);
152
- }
153
- })
154
- ];
155
- }
156
-
157
- @synchronized
158
- private async _openFeed (key: FeedKey): Promise<HypercoreFeed> {
159
- const descriptor = await this._feedProvider.createOrOpenReadOnlyFeed(key);
160
- return descriptor.feed;
161
- }
162
- }
@@ -0,0 +1,37 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import debug from 'debug';
6
+
7
+ import { keyToString } from '@dxos/crypto';
8
+ import { Replicator } from '@dxos/protocol-plugin-replicator';
9
+
10
+ import { PartyFeedProvider } from '../pipeline';
11
+
12
+ const log = debug('dxos:echo-db:protocol:replicator');
13
+
14
+ /**
15
+ * Creates the protocol plugin for feed replication.
16
+ */
17
+ export const createReplicatorPlugin = (feedProvider: PartyFeedProvider) =>
18
+ new Replicator({
19
+ load: async () => {
20
+ const feeds = feedProvider.getFeeds();
21
+ log(`Loading feeds: ${feeds.map(feed => keyToString(feed.key))}`);
22
+ return feeds.map((feed) => ({ discoveryKey: feed.feed.discoveryKey }));
23
+ },
24
+
25
+ subscribe: (addFeedToReplicatedSet: (feed: any) => void) => feedProvider.feedOpened.on(async (feed) => {
26
+ log(`Adding feed: ${feed.key.toHex()}`);
27
+ addFeedToReplicatedSet({ discoveryKey: feed.feed.discoveryKey });
28
+ }),
29
+
30
+ replicate: async (remoteFeeds, info) => {
31
+ // We can ignore remoteFeeds entirely, since the set of feeds we want to replicate is dictated by the Party.
32
+ // TODO(telackey): Why are we opening feeds? Necessary or belt/braces thinking, or because open party does it?
33
+ const feeds = feedProvider.getFeeds();
34
+ log(`Replicating: peerId=${info.session}; feeds=${feeds.map(feed => feed.key.toHex())}`);
35
+ return feeds.map(feed => feed.feed);
36
+ }
37
+ });
@@ -4,26 +4,22 @@
4
4
 
5
5
  import debug from 'debug';
6
6
 
7
- import { TimeframeClock } from '../database';
7
+ import { TimeframeClock } from '../packlets/database';
8
8
  import { PartyCore } from '../pipeline';
9
9
  import { SnapshotStore } from './snapshot-store';
10
10
 
11
11
  const log = debug('dxos:snapshot-generator');
12
12
 
13
- export function createAutomaticSnapshots (
14
- party: PartyCore, clock: TimeframeClock, store: SnapshotStore, interval: number
15
- ) {
16
- return clock.update.on(async timeframe => {
17
- const totalMessages = timeframe.totalMessages();
18
- if (totalMessages > 0 && totalMessages % interval === 0) {
19
- log(`Saving snapshot of ${party.key.humanize()}...`);
20
- try {
21
- const snapshot = party.createSnapshot();
22
- await store.save(snapshot);
23
- } catch (err: any) {
24
- console.error('Failed to save snapshot');
25
- console.error(err);
26
- }
13
+ export const createAutomaticSnapshots = (party: PartyCore, clock: TimeframeClock, store: SnapshotStore, interval: number) => clock.update.on(async timeframe => {
14
+ const totalMessages = timeframe.totalMessages();
15
+ if (totalMessages > 0 && totalMessages % interval === 0) {
16
+ log(`Saving snapshot of ${party.key.humanize()}...`);
17
+ try {
18
+ const snapshot = party.createSnapshot();
19
+ await store.save(snapshot);
20
+ } catch (err: any) {
21
+ console.error('Failed to save snapshot');
22
+ console.error(err);
27
23
  }
28
- });
29
- }
24
+ }
25
+ });
@@ -7,15 +7,15 @@ import { it as test } from 'mocha';
7
7
 
8
8
  import { createId, createKeyPair, PublicKey } from '@dxos/crypto';
9
9
  import { PartySnapshot } from '@dxos/echo-protocol';
10
+ import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
10
11
 
11
- import { createRamStorage } from '../util';
12
12
  import { SnapshotStore } from './snapshot-store';
13
13
 
14
14
  const createPublicKey = () => PublicKey.from(createKeyPair().publicKey);
15
15
 
16
16
  describe('SnapshotStore', () => {
17
17
  test('in-memory', async () => {
18
- const store = new SnapshotStore(createRamStorage());
18
+ const store = new SnapshotStore(createStorage('', StorageType.RAM).directory('snapshots'));
19
19
 
20
20
  const key1 = createPublicKey();
21
21
  const key2 = createPublicKey();
@@ -7,10 +7,9 @@ import debug from 'debug';
7
7
 
8
8
  import { keyToString } from '@dxos/crypto';
9
9
  import { schema, PartyKey, PartySnapshot } from '@dxos/echo-protocol';
10
- import { IStorage } from '@dxos/random-access-multi-storage';
10
+ import { Directory } from '@dxos/random-access-multi-storage';
11
11
 
12
12
  const log = debug('dxos:snapshot-store');
13
-
14
13
  /**
15
14
  * Stores party snapshots. Takes any `random-access-storage` compatible backend.
16
15
  *
@@ -18,11 +17,11 @@ const log = debug('dxos:snapshot-store');
18
17
  */
19
18
  export class SnapshotStore {
20
19
  constructor (
21
- private readonly _storage: IStorage
20
+ private readonly _directory: Directory
22
21
  ) {}
23
22
 
24
23
  async load (partyKey: PartyKey): Promise<PartySnapshot | undefined> {
25
- const file = this._storage.createOrOpen(partyKey.toHex());
24
+ const file = this._directory.createOrOpen(partyKey.toHex());
26
25
 
27
26
  try {
28
27
  const { size } = await file.stat();
@@ -45,7 +44,7 @@ export class SnapshotStore {
45
44
 
46
45
  async save (snapshot: PartySnapshot) {
47
46
  assert(snapshot.partyKey);
48
- const file = this._storage.createOrOpen(keyToString(snapshot.partyKey), { truncate: true, size: 0 });
47
+ const file = this._directory.createOrOpen(keyToString(snapshot.partyKey), { truncate: true, size: 0 });
49
48
 
50
49
  try {
51
50
  const data = schema.getCodecForType('dxos.echo.snapshot.PartySnapshot').encode(snapshot);
@@ -60,6 +59,6 @@ export class SnapshotStore {
60
59
  */
61
60
  async clear () {
62
61
  log('Clearing all snapshots..');
63
- await this._storage.destroy();
62
+ await this._directory.destroy();
64
63
  }
65
64
  }
@@ -12,7 +12,7 @@ import { schema, ItemID, MockFeedWriter, PartyKey } from '@dxos/echo-protocol';
12
12
  import { ModelFactory } from '@dxos/model-factory';
13
13
  import { ObjectModel, ValueUtil } from '@dxos/object-model';
14
14
 
15
- import { ItemDemuxer, ItemManager } from '../database';
15
+ import { ItemDemuxer, ItemManager } from '../packlets/database';
16
16
  import { createTestInstance } from '../testing';
17
17
 
18
18
  const log = debug('dxos:snapshot:test');
@@ -0,0 +1,30 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { ObjectModel } from '@dxos/object-model';
6
+
7
+ import { ECHO } from '../echo';
8
+
9
+ const ITEMS = 100;
10
+ const MUTATIONS = 1000;
11
+
12
+ it.skip('Database benchmark', async () => {
13
+ const echo = new ECHO({ snapshots: false });
14
+ await echo.open();
15
+ await echo.halo.createProfile();
16
+ const party = await echo.createParty();
17
+
18
+ const start = Date.now();
19
+ for (let i = 0; i < ITEMS; i++) {
20
+ const item = await party.database.createItem({ model: ObjectModel, type: 'test:item' });
21
+
22
+ for (let j = 0; j < MUTATIONS; j++) {
23
+ await item.model.set(`key${j % 100}`, `value-${j}`);
24
+ }
25
+
26
+ console.log(`${i * MUTATIONS}/${ITEMS * MUTATIONS} ${((Date.now() - start) / ((i + 1) * MUTATIONS / 1000)).toFixed(1)} µs/mut ${((i + 1) * MUTATIONS / (Date.now() - start) * 1000).toFixed(1)} mut/s`);
27
+ }
28
+
29
+ await echo.close();
30
+ });
@@ -8,8 +8,8 @@ import { Model } from '@dxos/model-factory';
8
8
  import { ObjectModel } from '@dxos/object-model';
9
9
  import { range } from '@dxos/util';
10
10
 
11
- import { Item, CreateItemOption } from '../api';
12
11
  import { ECHO } from '../echo';
12
+ import { CreateItemOption, Item } from '../packlets/database';
13
13
  import { DataParty } from '../parties';
14
14
  import { createTestInstance, inviteTestPeer } from './testing';
15
15
 
@@ -22,10 +22,10 @@ export type TestPeer = Awaited<ReturnType<typeof createTestInstance>>;
22
22
 
23
23
  export type WithTestMeta<T> = T & { testMeta: TestPeer }
24
24
 
25
- function addTestMeta<T> (obj: T, meta: TestPeer): WithTestMeta<T> {
25
+ const addTestMeta = <T>(obj: T, meta: TestPeer): WithTestMeta<T> => {
26
26
  (obj as any).testMeta = meta;
27
27
  return obj as any;
28
- }
28
+ };
29
29
 
30
30
  /**
31
31
  * Creates a number of test ECHO instances and a party that's shared between all of them.
@@ -5,12 +5,11 @@
5
5
  import debug from 'debug';
6
6
 
7
7
  import { NetworkManagerOptions } from '@dxos/network-manager';
8
- import { IStorage } from '@dxos/random-access-multi-storage';
8
+ import { Storage, createStorage, StorageType } from '@dxos/random-access-multi-storage';
9
9
  import { jsonReplacer } from '@dxos/util';
10
10
 
11
11
  import { ECHO } from '../echo';
12
12
  import { DataParty } from '../parties';
13
- import { createRamStorage } from '../util';
14
13
 
15
14
  export const log = debug('dxos:echo-db:testing');
16
15
 
@@ -21,13 +20,12 @@ export const messageLogger = (tag: string) => (message: any) => {
21
20
  export interface TestOptions {
22
21
  verboseLogging?: boolean
23
22
  initialize?: boolean
24
- storage?: any
23
+ storage?: Storage
25
24
  keyStorage?: any
26
25
  networkManagerOptions?: NetworkManagerOptions
27
26
  // TODO(burdon): Group properties by hierarchical object.
28
27
  snapshots?: boolean
29
28
  snapshotInterval?: number
30
- snapshotStorage?: IStorage
31
29
  }
32
30
 
33
31
  /**
@@ -36,17 +34,15 @@ export interface TestOptions {
36
34
  export const createTestInstance = async ({
37
35
  verboseLogging = false,
38
36
  initialize = false,
39
- storage = createRamStorage(),
37
+ storage = createStorage('', StorageType.RAM),
40
38
  keyStorage = undefined,
41
39
  networkManagerOptions,
42
- snapshotStorage = createRamStorage(),
43
40
  snapshots = true,
44
41
  snapshotInterval
45
42
  }: TestOptions = {}) => {
46
43
  const echo = new ECHO({
47
- feedStorage: storage,
44
+ storage,
48
45
  keyStorage,
49
- snapshotStorage,
50
46
  snapshotInterval,
51
47
  snapshots,
52
48
  networkManagerOptions,
@@ -1 +0,0 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/api/database.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAGhG,OAAO,EAAE,eAAe,EAAE,eAAe,EAAe,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAmB,MAAM,aAAa,CAAC;AAErE,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,KAAK;IAC/C,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAC3B,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,GAAG,C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