@optimystic/db-core 0.0.1

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 (345) hide show
  1. package/README.md +328 -0
  2. package/dist/index.min.js +18 -0
  3. package/dist/index.min.js.map +7 -0
  4. package/dist/src/blocks/block-store.d.ts +12 -0
  5. package/dist/src/blocks/block-store.d.ts.map +1 -0
  6. package/dist/src/blocks/block-store.js +2 -0
  7. package/dist/src/blocks/block-store.js.map +1 -0
  8. package/dist/src/blocks/block-types.d.ts +3 -0
  9. package/dist/src/blocks/block-types.d.ts.map +1 -0
  10. package/dist/src/blocks/block-types.js +9 -0
  11. package/dist/src/blocks/block-types.js.map +1 -0
  12. package/dist/src/blocks/helpers.d.ts +4 -0
  13. package/dist/src/blocks/helpers.d.ts.map +1 -0
  14. package/dist/src/blocks/helpers.js +12 -0
  15. package/dist/src/blocks/helpers.js.map +1 -0
  16. package/dist/src/blocks/index.d.ts +5 -0
  17. package/dist/src/blocks/index.d.ts.map +1 -0
  18. package/dist/src/blocks/index.js +5 -0
  19. package/dist/src/blocks/index.js.map +1 -0
  20. package/dist/src/blocks/structs.d.ts +14 -0
  21. package/dist/src/blocks/structs.d.ts.map +1 -0
  22. package/dist/src/blocks/structs.js +2 -0
  23. package/dist/src/blocks/structs.js.map +1 -0
  24. package/dist/src/btree/btree.d.ts +135 -0
  25. package/dist/src/btree/btree.d.ts.map +1 -0
  26. package/dist/src/btree/btree.js +727 -0
  27. package/dist/src/btree/btree.js.map +1 -0
  28. package/dist/src/btree/independent-trunk.d.ts +17 -0
  29. package/dist/src/btree/independent-trunk.d.ts.map +1 -0
  30. package/dist/src/btree/independent-trunk.js +41 -0
  31. package/dist/src/btree/independent-trunk.js.map +1 -0
  32. package/dist/src/btree/index.d.ts +6 -0
  33. package/dist/src/btree/index.d.ts.map +1 -0
  34. package/dist/src/btree/index.js +6 -0
  35. package/dist/src/btree/index.js.map +1 -0
  36. package/dist/src/btree/key-range.d.ts +13 -0
  37. package/dist/src/btree/key-range.d.ts.map +1 -0
  38. package/dist/src/btree/key-range.js +20 -0
  39. package/dist/src/btree/key-range.js.map +1 -0
  40. package/dist/src/btree/keyset.d.ts +4 -0
  41. package/dist/src/btree/keyset.d.ts.map +1 -0
  42. package/dist/src/btree/keyset.js +4 -0
  43. package/dist/src/btree/keyset.js.map +1 -0
  44. package/dist/src/btree/nodes.d.ts +16 -0
  45. package/dist/src/btree/nodes.d.ts.map +1 -0
  46. package/dist/src/btree/nodes.js +9 -0
  47. package/dist/src/btree/nodes.js.map +1 -0
  48. package/dist/src/btree/path.d.ts +22 -0
  49. package/dist/src/btree/path.d.ts.map +1 -0
  50. package/dist/src/btree/path.js +39 -0
  51. package/dist/src/btree/path.js.map +1 -0
  52. package/dist/src/btree/tree-block.d.ts +7 -0
  53. package/dist/src/btree/tree-block.d.ts.map +1 -0
  54. package/dist/src/btree/tree-block.js +5 -0
  55. package/dist/src/btree/tree-block.js.map +1 -0
  56. package/dist/src/btree/trunk.d.ts +13 -0
  57. package/dist/src/btree/trunk.d.ts.map +1 -0
  58. package/dist/src/btree/trunk.js +2 -0
  59. package/dist/src/btree/trunk.js.map +1 -0
  60. package/dist/src/chain/chain-nodes.d.ts +18 -0
  61. package/dist/src/chain/chain-nodes.d.ts.map +1 -0
  62. package/dist/src/chain/chain-nodes.js +10 -0
  63. package/dist/src/chain/chain-nodes.js.map +1 -0
  64. package/dist/src/chain/chain.d.ts +75 -0
  65. package/dist/src/chain/chain.d.ts.map +1 -0
  66. package/dist/src/chain/chain.js +268 -0
  67. package/dist/src/chain/chain.js.map +1 -0
  68. package/dist/src/chain/index.d.ts +2 -0
  69. package/dist/src/chain/index.d.ts.map +1 -0
  70. package/dist/src/chain/index.js +2 -0
  71. package/dist/src/chain/index.js.map +1 -0
  72. package/dist/src/cluster/i-cluster.d.ts +5 -0
  73. package/dist/src/cluster/i-cluster.d.ts.map +1 -0
  74. package/dist/src/cluster/i-cluster.js +2 -0
  75. package/dist/src/cluster/i-cluster.js.map +1 -0
  76. package/dist/src/cluster/index.d.ts +3 -0
  77. package/dist/src/cluster/index.d.ts.map +1 -0
  78. package/dist/src/cluster/index.js +3 -0
  79. package/dist/src/cluster/index.js.map +1 -0
  80. package/dist/src/cluster/structs.d.ts +47 -0
  81. package/dist/src/cluster/structs.d.ts.map +1 -0
  82. package/dist/src/cluster/structs.js +2 -0
  83. package/dist/src/cluster/structs.js.map +1 -0
  84. package/dist/src/collection/action.d.ts +26 -0
  85. package/dist/src/collection/action.d.ts.map +1 -0
  86. package/dist/src/collection/action.js +2 -0
  87. package/dist/src/collection/action.js.map +1 -0
  88. package/dist/src/collection/collection.d.ts +48 -0
  89. package/dist/src/collection/collection.d.ts.map +1 -0
  90. package/dist/src/collection/collection.js +175 -0
  91. package/dist/src/collection/collection.js.map +1 -0
  92. package/dist/src/collection/index.d.ts +4 -0
  93. package/dist/src/collection/index.d.ts.map +1 -0
  94. package/dist/src/collection/index.js +4 -0
  95. package/dist/src/collection/index.js.map +1 -0
  96. package/dist/src/collection/struct.d.ts +16 -0
  97. package/dist/src/collection/struct.d.ts.map +1 -0
  98. package/dist/src/collection/struct.js +2 -0
  99. package/dist/src/collection/struct.js.map +1 -0
  100. package/dist/src/collections/diary/diary.d.ts +9 -0
  101. package/dist/src/collections/diary/diary.d.ts.map +1 -0
  102. package/dist/src/collections/diary/diary.js +37 -0
  103. package/dist/src/collections/diary/diary.js.map +1 -0
  104. package/dist/src/collections/diary/index.d.ts +3 -0
  105. package/dist/src/collections/diary/index.d.ts.map +1 -0
  106. package/dist/src/collections/diary/index.js +3 -0
  107. package/dist/src/collections/diary/index.js.map +1 -0
  108. package/dist/src/collections/diary/struct.d.ts +2 -0
  109. package/dist/src/collections/diary/struct.d.ts.map +1 -0
  110. package/dist/src/collections/diary/struct.js +3 -0
  111. package/dist/src/collections/diary/struct.js.map +1 -0
  112. package/dist/src/collections/index.d.ts +3 -0
  113. package/dist/src/collections/index.d.ts.map +1 -0
  114. package/dist/src/collections/index.js +3 -0
  115. package/dist/src/collections/index.js.map +1 -0
  116. package/dist/src/collections/tree/collection-trunk.d.ts +11 -0
  117. package/dist/src/collections/tree/collection-trunk.d.ts.map +1 -0
  118. package/dist/src/collections/tree/collection-trunk.js +22 -0
  119. package/dist/src/collections/tree/collection-trunk.js.map +1 -0
  120. package/dist/src/collections/tree/index.d.ts +3 -0
  121. package/dist/src/collections/tree/index.d.ts.map +1 -0
  122. package/dist/src/collections/tree/index.js +3 -0
  123. package/dist/src/collections/tree/index.js.map +1 -0
  124. package/dist/src/collections/tree/struct.d.ts +12 -0
  125. package/dist/src/collections/tree/struct.d.ts.map +1 -0
  126. package/dist/src/collections/tree/struct.js +4 -0
  127. package/dist/src/collections/tree/struct.js.map +1 -0
  128. package/dist/src/collections/tree/tree.d.ts +34 -0
  129. package/dist/src/collections/tree/tree.d.ts.map +1 -0
  130. package/dist/src/collections/tree/tree.js +100 -0
  131. package/dist/src/collections/tree/tree.js.map +1 -0
  132. package/dist/src/index.d.ts +18 -0
  133. package/dist/src/index.d.ts.map +1 -0
  134. package/dist/src/index.js +18 -0
  135. package/dist/src/index.js.map +1 -0
  136. package/dist/src/log/index.d.ts +3 -0
  137. package/dist/src/log/index.d.ts.map +1 -0
  138. package/dist/src/log/index.js +3 -0
  139. package/dist/src/log/index.js.map +1 -0
  140. package/dist/src/log/log.d.ts +57 -0
  141. package/dist/src/log/log.d.ts.map +1 -0
  142. package/dist/src/log/log.js +131 -0
  143. package/dist/src/log/log.js.map +1 -0
  144. package/dist/src/log/struct.d.ts +36 -0
  145. package/dist/src/log/struct.d.ts.map +1 -0
  146. package/dist/src/log/struct.js +3 -0
  147. package/dist/src/log/struct.js.map +1 -0
  148. package/dist/src/network/i-key-network.d.ts +21 -0
  149. package/dist/src/network/i-key-network.d.ts.map +1 -0
  150. package/dist/src/network/i-key-network.js +2 -0
  151. package/dist/src/network/i-key-network.js.map +1 -0
  152. package/dist/src/network/i-peer-network.d.ts +8 -0
  153. package/dist/src/network/i-peer-network.d.ts.map +1 -0
  154. package/dist/src/network/i-peer-network.js +2 -0
  155. package/dist/src/network/i-peer-network.js.map +1 -0
  156. package/dist/src/network/i-repo.d.ts +17 -0
  157. package/dist/src/network/i-repo.d.ts.map +1 -0
  158. package/dist/src/network/i-repo.js +2 -0
  159. package/dist/src/network/i-repo.js.map +1 -0
  160. package/dist/src/network/index.d.ts +6 -0
  161. package/dist/src/network/index.d.ts.map +1 -0
  162. package/dist/src/network/index.js +6 -0
  163. package/dist/src/network/index.js.map +1 -0
  164. package/dist/src/network/repo-protocol.d.ts +19 -0
  165. package/dist/src/network/repo-protocol.d.ts.map +1 -0
  166. package/dist/src/network/repo-protocol.js +2 -0
  167. package/dist/src/network/repo-protocol.js.map +1 -0
  168. package/dist/src/network/struct.d.ts +115 -0
  169. package/dist/src/network/struct.d.ts.map +1 -0
  170. package/dist/src/network/struct.js +2 -0
  171. package/dist/src/network/struct.js.map +1 -0
  172. package/dist/src/transaction/actions-engine.d.ts +37 -0
  173. package/dist/src/transaction/actions-engine.d.ts.map +1 -0
  174. package/dist/src/transaction/actions-engine.js +67 -0
  175. package/dist/src/transaction/actions-engine.js.map +1 -0
  176. package/dist/src/transaction/context.d.ts +60 -0
  177. package/dist/src/transaction/context.d.ts.map +1 -0
  178. package/dist/src/transaction/context.js +91 -0
  179. package/dist/src/transaction/context.js.map +1 -0
  180. package/dist/src/transaction/coordinator.d.ts +118 -0
  181. package/dist/src/transaction/coordinator.d.ts.map +1 -0
  182. package/dist/src/transaction/coordinator.js +417 -0
  183. package/dist/src/transaction/coordinator.js.map +1 -0
  184. package/dist/src/transaction/index.d.ts +10 -0
  185. package/dist/src/transaction/index.d.ts.map +1 -0
  186. package/dist/src/transaction/index.js +7 -0
  187. package/dist/src/transaction/index.js.map +1 -0
  188. package/dist/src/transaction/session.d.ts +80 -0
  189. package/dist/src/transaction/session.d.ts.map +1 -0
  190. package/dist/src/transaction/session.js +161 -0
  191. package/dist/src/transaction/session.js.map +1 -0
  192. package/dist/src/transaction/transaction.d.ts +156 -0
  193. package/dist/src/transaction/transaction.d.ts.map +1 -0
  194. package/dist/src/transaction/transaction.js +31 -0
  195. package/dist/src/transaction/transaction.js.map +1 -0
  196. package/dist/src/transaction/validator.d.ts +46 -0
  197. package/dist/src/transaction/validator.d.ts.map +1 -0
  198. package/dist/src/transaction/validator.js +97 -0
  199. package/dist/src/transaction/validator.js.map +1 -0
  200. package/dist/src/transactor/index.d.ts +4 -0
  201. package/dist/src/transactor/index.d.ts.map +1 -0
  202. package/dist/src/transactor/index.js +4 -0
  203. package/dist/src/transactor/index.js.map +1 -0
  204. package/dist/src/transactor/network-transactor.d.ts +36 -0
  205. package/dist/src/transactor/network-transactor.d.ts.map +1 -0
  206. package/dist/src/transactor/network-transactor.js +297 -0
  207. package/dist/src/transactor/network-transactor.js.map +1 -0
  208. package/dist/src/transactor/transactor-source.d.ts +24 -0
  209. package/dist/src/transactor/transactor-source.d.ts.map +1 -0
  210. package/dist/src/transactor/transactor-source.js +62 -0
  211. package/dist/src/transactor/transactor-source.js.map +1 -0
  212. package/dist/src/transactor/transactor.d.ts +38 -0
  213. package/dist/src/transactor/transactor.d.ts.map +1 -0
  214. package/dist/src/transactor/transactor.js +2 -0
  215. package/dist/src/transactor/transactor.js.map +1 -0
  216. package/dist/src/transform/atomic.d.ts +8 -0
  217. package/dist/src/transform/atomic.d.ts.map +1 -0
  218. package/dist/src/transform/atomic.js +14 -0
  219. package/dist/src/transform/atomic.js.map +1 -0
  220. package/dist/src/transform/cache-source.d.ts +13 -0
  221. package/dist/src/transform/cache-source.d.ts.map +1 -0
  222. package/dist/src/transform/cache-source.js +52 -0
  223. package/dist/src/transform/cache-source.js.map +1 -0
  224. package/dist/src/transform/helpers.d.ts +25 -0
  225. package/dist/src/transform/helpers.d.ts.map +1 -0
  226. package/dist/src/transform/helpers.js +105 -0
  227. package/dist/src/transform/helpers.js.map +1 -0
  228. package/dist/src/transform/index.d.ts +6 -0
  229. package/dist/src/transform/index.d.ts.map +1 -0
  230. package/dist/src/transform/index.js +6 -0
  231. package/dist/src/transform/index.js.map +1 -0
  232. package/dist/src/transform/struct.d.ts +19 -0
  233. package/dist/src/transform/struct.d.ts.map +1 -0
  234. package/dist/src/transform/struct.js +2 -0
  235. package/dist/src/transform/struct.js.map +1 -0
  236. package/dist/src/transform/tracker.d.ts +22 -0
  237. package/dist/src/transform/tracker.d.ts.map +1 -0
  238. package/dist/src/transform/tracker.js +64 -0
  239. package/dist/src/transform/tracker.js.map +1 -0
  240. package/dist/src/utility/actor.d.ts +11 -0
  241. package/dist/src/utility/actor.d.ts.map +1 -0
  242. package/dist/src/utility/actor.js +39 -0
  243. package/dist/src/utility/actor.js.map +1 -0
  244. package/dist/src/utility/batch-coordinator.d.ts +56 -0
  245. package/dist/src/utility/batch-coordinator.d.ts.map +1 -0
  246. package/dist/src/utility/batch-coordinator.js +127 -0
  247. package/dist/src/utility/batch-coordinator.js.map +1 -0
  248. package/dist/src/utility/block-id-to-bytes.d.ts +3 -0
  249. package/dist/src/utility/block-id-to-bytes.d.ts.map +1 -0
  250. package/dist/src/utility/block-id-to-bytes.js +7 -0
  251. package/dist/src/utility/block-id-to-bytes.js.map +1 -0
  252. package/dist/src/utility/ensured.d.ts +3 -0
  253. package/dist/src/utility/ensured.d.ts.map +1 -0
  254. package/dist/src/utility/ensured.js +24 -0
  255. package/dist/src/utility/ensured.js.map +1 -0
  256. package/dist/src/utility/groupby.d.ts +8 -0
  257. package/dist/src/utility/groupby.d.ts.map +1 -0
  258. package/dist/src/utility/groupby.js +15 -0
  259. package/dist/src/utility/groupby.js.map +1 -0
  260. package/dist/src/utility/is-record-empty.d.ts +3 -0
  261. package/dist/src/utility/is-record-empty.d.ts.map +1 -0
  262. package/dist/src/utility/is-record-empty.js +7 -0
  263. package/dist/src/utility/is-record-empty.js.map +1 -0
  264. package/dist/src/utility/latches.d.ts +11 -0
  265. package/dist/src/utility/latches.d.ts.map +1 -0
  266. package/dist/src/utility/latches.js +36 -0
  267. package/dist/src/utility/latches.js.map +1 -0
  268. package/dist/src/utility/nameof.d.ts +3 -0
  269. package/dist/src/utility/nameof.d.ts.map +1 -0
  270. package/dist/src/utility/nameof.js +5 -0
  271. package/dist/src/utility/nameof.js.map +1 -0
  272. package/dist/src/utility/pending.d.ts +13 -0
  273. package/dist/src/utility/pending.d.ts.map +1 -0
  274. package/dist/src/utility/pending.js +37 -0
  275. package/dist/src/utility/pending.js.map +1 -0
  276. package/package.json +56 -0
  277. package/src/blocks/block-store.ts +13 -0
  278. package/src/blocks/block-types.ts +11 -0
  279. package/src/blocks/helpers.ts +13 -0
  280. package/src/blocks/index.ts +5 -0
  281. package/src/blocks/structs.ts +17 -0
  282. package/src/btree/btree.ts +804 -0
  283. package/src/btree/independent-trunk.ts +54 -0
  284. package/src/btree/index.ts +5 -0
  285. package/src/btree/key-range.ts +15 -0
  286. package/src/btree/keyset.ts +6 -0
  287. package/src/btree/nodes.ts +25 -0
  288. package/src/btree/path.ts +37 -0
  289. package/src/btree/tree-block.ts +11 -0
  290. package/src/btree/trunk.ts +14 -0
  291. package/src/chain/chain-nodes.ts +24 -0
  292. package/src/chain/chain.ts +324 -0
  293. package/src/chain/index.ts +2 -0
  294. package/src/cluster/i-cluster.ts +6 -0
  295. package/src/cluster/index.ts +2 -0
  296. package/src/cluster/structs.ts +46 -0
  297. package/src/collection/action.ts +31 -0
  298. package/src/collection/collection.ts +200 -0
  299. package/src/collection/index.ts +3 -0
  300. package/src/collection/struct.ts +20 -0
  301. package/src/collections/diary/diary.ts +43 -0
  302. package/src/collections/diary/index.ts +2 -0
  303. package/src/collections/diary/struct.ts +3 -0
  304. package/src/collections/index.ts +2 -0
  305. package/src/collections/tree/collection-trunk.ts +25 -0
  306. package/src/collections/tree/index.ts +2 -0
  307. package/src/collections/tree/readme.md +19 -0
  308. package/src/collections/tree/struct.ts +18 -0
  309. package/src/collections/tree/tree.ts +124 -0
  310. package/src/index.ts +17 -0
  311. package/src/log/index.ts +2 -0
  312. package/src/log/log.ts +155 -0
  313. package/src/log/struct.ts +40 -0
  314. package/src/network/i-key-network.ts +24 -0
  315. package/src/network/i-peer-network.ts +8 -0
  316. package/src/network/i-repo.ts +19 -0
  317. package/src/network/index.ts +5 -0
  318. package/src/network/repo-protocol.ts +12 -0
  319. package/src/network/struct.ts +137 -0
  320. package/src/transaction/actions-engine.ts +83 -0
  321. package/src/transaction/context.ts +103 -0
  322. package/src/transaction/coordinator.ts +583 -0
  323. package/src/transaction/index.ts +30 -0
  324. package/src/transaction/session.ts +182 -0
  325. package/src/transaction/transaction.ts +205 -0
  326. package/src/transaction/validator.ts +150 -0
  327. package/src/transactor/index.ts +4 -0
  328. package/src/transactor/network-transactor.ts +435 -0
  329. package/src/transactor/transactor-source.ts +65 -0
  330. package/src/transactor/transactor.ts +44 -0
  331. package/src/transform/atomic.ts +16 -0
  332. package/src/transform/cache-source.ts +57 -0
  333. package/src/transform/helpers.ts +117 -0
  334. package/src/transform/index.ts +5 -0
  335. package/src/transform/struct.ts +22 -0
  336. package/src/transform/tracker.ts +70 -0
  337. package/src/utility/actor.ts +62 -0
  338. package/src/utility/batch-coordinator.ts +174 -0
  339. package/src/utility/block-id-to-bytes.ts +8 -0
  340. package/src/utility/ensured.ts +32 -0
  341. package/src/utility/groupby.ts +18 -0
  342. package/src/utility/is-record-empty.ts +5 -0
  343. package/src/utility/latches.ts +42 -0
  344. package/src/utility/nameof.ts +7 -0
  345. package/src/utility/pending.ts +41 -0
@@ -0,0 +1,18 @@
1
+ export * from "./blocks/index.js";
2
+ export * from "./btree/index.js";
3
+ export * from "./chain/index.js";
4
+ export * from "./cluster/index.js";
5
+ export * from "./collection/index.js";
6
+ export * from "./collections/index.js";
7
+ export * from "./log/index.js";
8
+ export * from "./network/index.js";
9
+ export * from "./transaction/index.js";
10
+ export * from "./transactor/index.js";
11
+ export * from "./transform/index.js";
12
+ export * from "./utility/groupby.js";
13
+ export * from "./utility/latches.js";
14
+ export * from "./utility/nameof.js";
15
+ export * from "./utility/ensured.js";
16
+ export * from "./utility/pending.js";
17
+ export * from "./utility/block-id-to-bytes.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./log.js";
2
+ export * from "./struct.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/log/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./log.js";
2
+ export * from "./struct.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/log/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { Chain } from "../index.js";
2
+ import type { IBlock, BlockId, ActionId, CollectionId, ChainPath, ActionRev, ActionContext, BlockStore } from "../index.js";
3
+ import type { ChainDataNode } from '../chain/chain-nodes.js';
4
+ import type { LogEntry } from "./index.js";
5
+ import type { GetFromResult } from './struct.js';
6
+ export type LogBlock<TAction> = ChainDataNode<LogEntry<TAction>> & {
7
+ /** Base64url encoded Sha256 hash of the next block - present on every block except the head */
8
+ priorHash?: string;
9
+ };
10
+ export declare const priorHash$: string;
11
+ export declare class Log<TAction> {
12
+ private readonly chain;
13
+ protected constructor(chain: Chain<LogEntry<TAction>>);
14
+ get id(): string;
15
+ /** Opens a presumably existing log. */
16
+ static open<TAction>(store: BlockStore<IBlock>, id: BlockId): Promise<Log<TAction> | undefined>;
17
+ /** Creates a new log. */
18
+ static create<TAction>(store: BlockStore<IBlock>, newId?: BlockId): Promise<Log<TAction>>;
19
+ /** Adds a new entry to the log. */
20
+ addActions(actions: TAction[], actionId: ActionId, rev: number, getBlockIds: () => BlockId[], collectionIds?: CollectionId[], timestamp?: number): Promise<{
21
+ entry: {
22
+ action: {
23
+ blockIds: string[];
24
+ actionId: ActionId;
25
+ actions: TAction[];
26
+ collectionIds?: CollectionId[];
27
+ };
28
+ timestamp: number;
29
+ rev: number;
30
+ checkpoint?: import("./struct.js").CheckpointEntry;
31
+ };
32
+ tailPath: ChainPath<LogEntry<TAction>>;
33
+ }>;
34
+ /** Adds a checkpoint to the log. */
35
+ addCheckpoint(pendings: ActionRev[], rev: number, timestamp?: number): Promise<{
36
+ entry: {
37
+ timestamp: number;
38
+ rev: number;
39
+ checkpoint: {
40
+ pendings: ActionRev[];
41
+ };
42
+ };
43
+ tailPath: ChainPath<LogEntry<TAction>>;
44
+ }>;
45
+ /** Gets the action context of the log. */
46
+ getActionContext(): Promise<ActionContext | undefined>;
47
+ /** Gets the actions from startRev (exclusive), to latest in the log. */
48
+ getFrom(startRev: number | undefined): Promise<GetFromResult<TAction>>;
49
+ /** Enumerates log entries from the given starting path or end if undefined, in forward (from tail to head) or reverse (from head to tail) order. */
50
+ select(starting?: ChainPath<LogEntry<TAction>>, forward?: boolean): AsyncGenerator<LogEntry<TAction>, void, unknown>;
51
+ /** Returns the set of pending transactions in the most recent checkpoint, at or preceding the given path. */
52
+ private findCheckpoint;
53
+ /** Returns the set of pending actions following, the given checkpoint path. */
54
+ private pendingFrom;
55
+ private static getChainOptions;
56
+ }
57
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/log/log.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAmB,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAoB,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9I,OAAO,KAAK,EAAwB,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,YAAY,CAAC;AAGxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,QAAQ,CAAC,OAAO,IAAI,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAC7D;IACD,+FAA+F;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEH,eAAO,MAAM,UAAU,QAAqC,CAAC;AAE7D,qBAAa,GAAG,CAAC,OAAO;IAEtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IADvB,SAAS,aACS,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAIjD,IAAI,EAAE,WAEL;IAED,uCAAuC;WAC1B,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAKrG,yBAAyB;WACZ,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO;IAIvE,mCAAmC;IAC7B,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,EAAE,EAAE,aAAa,GAAE,YAAY,EAAO,EAAE,SAAS,GAAE,MAAmB;;;;;;;;;;;;;;IAQtK,oCAAoC;IAC9B,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,MAAmB;;;;;;;;;;IAMtF,0CAA0C;IACpC,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAgB5D,wEAAwE;IAClE,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAmC5E,oJAAoJ;IAC7I,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,UAAO;IAMrE,6GAA6G;YAC/F,cAAc;IAc5B,+EAA+E;YACjE,WAAW;IAWzB,OAAO,CAAC,MAAM,CAAC,eAAe;CAa9B"}
@@ -0,0 +1,131 @@
1
+ import { sha256 } from 'multiformats/hashes/sha2';
2
+ import { Chain, entryAt, nameof } from "../index.js";
3
+ import { LogDataBlockType, LogHeaderBlockType } from "./index.js";
4
+ import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
5
+ export const priorHash$ = nameof("priorHash");
6
+ export class Log {
7
+ chain;
8
+ constructor(chain) {
9
+ this.chain = chain;
10
+ }
11
+ get id() {
12
+ return this.chain.id;
13
+ }
14
+ /** Opens a presumably existing log. */
15
+ static async open(store, id) {
16
+ const chain = await Chain.open(store, id, Log.getChainOptions(store));
17
+ return chain ? new Log(chain) : undefined;
18
+ }
19
+ /** Creates a new log. */
20
+ static async create(store, newId) {
21
+ return new Log(await Chain.create(store, { ...Log.getChainOptions(store), newId }));
22
+ }
23
+ /** Adds a new entry to the log. */
24
+ async addActions(actions, actionId, rev, getBlockIds, collectionIds = [], timestamp = Date.now()) {
25
+ const entry = { timestamp, rev, action: { actionId, actions, blockIds: [], collectionIds } };
26
+ const tailPath = await this.chain.add(entry);
27
+ const entryWithBlockIds = { ...entry, action: { ...entry.action, blockIds: getBlockIds() } };
28
+ this.chain.updateAt(tailPath, entryWithBlockIds);
29
+ return { entry: entryWithBlockIds, tailPath };
30
+ }
31
+ /** Adds a checkpoint to the log. */
32
+ async addCheckpoint(pendings, rev, timestamp = Date.now()) {
33
+ const entry = { timestamp, rev, checkpoint: { pendings } };
34
+ const tailPath = await this.chain.add(entry);
35
+ return { entry, tailPath };
36
+ }
37
+ /** Gets the action context of the log. */
38
+ async getActionContext() {
39
+ const tailPath = await this.chain.getTail();
40
+ if (!tailPath) {
41
+ return undefined;
42
+ }
43
+ const checkpoint = await this.findCheckpoint(tailPath);
44
+ return {
45
+ committed: checkpoint
46
+ ? [...checkpoint.pendings, ...await this.pendingFrom(checkpoint.path)]
47
+ : [],
48
+ rev: checkpoint?.rev ?? 0,
49
+ };
50
+ }
51
+ /** Gets the actions from startRev (exclusive), to latest in the log. */
52
+ async getFrom(startRev) {
53
+ const entries = [];
54
+ const pendings = [];
55
+ let rev;
56
+ let checkpointPath;
57
+ // Step through collecting both pending and entries until a checkpoint is found
58
+ for await (const path of this.chain.select(undefined, false)) {
59
+ const entry = entryAt(path);
60
+ rev = rev ?? entry.rev;
61
+ if (entry.checkpoint) {
62
+ checkpointPath = path;
63
+ pendings.unshift(...entry.checkpoint.pendings);
64
+ break;
65
+ }
66
+ pendings.unshift({ actionId: entry.action.actionId, rev: entry.rev });
67
+ if (startRev !== undefined && entry.rev > startRev) {
68
+ entries.unshift(entry.action);
69
+ } // Can't stop at rev, because we need to collect all pending actions for the context
70
+ }
71
+ // Continue stepping past the checkpoint until the given rev is reached
72
+ if (checkpointPath) {
73
+ for await (const path of this.chain.select(checkpointPath, false)) {
74
+ const entry = entryAt(path);
75
+ if (startRev !== undefined && entry.rev > startRev) {
76
+ if (entry.action) {
77
+ entries.unshift(entry.action);
78
+ }
79
+ }
80
+ else {
81
+ break;
82
+ }
83
+ }
84
+ }
85
+ return { context: rev ? { committed: pendings, rev } : undefined, entries };
86
+ }
87
+ /** Enumerates log entries from the given starting path or end if undefined, in forward (from tail to head) or reverse (from head to tail) order. */
88
+ async *select(starting, forward = true) {
89
+ for await (const path of this.chain.select(starting, forward)) {
90
+ yield entryAt(path);
91
+ }
92
+ }
93
+ /** Returns the set of pending transactions in the most recent checkpoint, at or preceding the given path. */
94
+ async findCheckpoint(starting) {
95
+ let lastPath;
96
+ let rev;
97
+ for await (const path of this.chain.select(starting, false)) {
98
+ const entry = entryAt(path);
99
+ rev = rev ?? entry.rev;
100
+ if (entry.checkpoint) {
101
+ return { path, pendings: entry.checkpoint.pendings, rev };
102
+ }
103
+ lastPath = path;
104
+ }
105
+ return lastPath ? { path: lastPath, pendings: [], rev } : undefined;
106
+ }
107
+ /** Returns the set of pending actions following, the given checkpoint path. */
108
+ async pendingFrom(starting) {
109
+ const pendings = [];
110
+ for await (const actionPath of this.chain.select(starting)) {
111
+ const entry = entryAt(actionPath);
112
+ if (entry?.action) {
113
+ pendings.push({ actionId: entry.action.actionId, rev: entry.rev });
114
+ }
115
+ }
116
+ return pendings;
117
+ }
118
+ static getChainOptions(store) {
119
+ return {
120
+ createDataBlock: () => ({ header: store.createBlockHeader(LogDataBlockType) }),
121
+ createHeaderBlock: (id) => ({ header: store.createBlockHeader(LogHeaderBlockType, id) }),
122
+ newBlock: async (newTail, oldTail) => {
123
+ if (oldTail) {
124
+ const hash = await sha256.digest(new TextEncoder().encode(JSON.stringify(oldTail)));
125
+ newTail.priorHash = uint8ArrayToString(hash.digest, 'base64url');
126
+ }
127
+ },
128
+ };
129
+ }
130
+ }
131
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":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O,CAAC,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;gBAClE,CAAC;YACF,CAAC;SACsC,CAAC;IAE1C,CAAC;CACD"}
@@ -0,0 +1,36 @@
1
+ import type { BlockId, CollectionId, ActionContext, ActionId, ActionRev } from "../index.js";
2
+ /** A log entry - either an action or a checkpoint */
3
+ export type LogEntry<TAction> = {
4
+ /** Linux timestamp of the entry */
5
+ readonly timestamp: number;
6
+ /** Revision number - monotonically increasing from the prior entry's rev. Starts at 1. */
7
+ readonly rev: number;
8
+ readonly action?: ActionEntry<TAction>;
9
+ readonly checkpoint?: CheckpointEntry;
10
+ };
11
+ /** An action entry represents a unit of work that is atomic */
12
+ export type ActionEntry<TAction> = {
13
+ /** Generated unique identifier for the action */
14
+ readonly actionId: ActionId;
15
+ /** Actions to be applied */
16
+ readonly actions: TAction[];
17
+ /** Block ids affected by the action - includes the log related blocks */
18
+ blockIds: BlockId[];
19
+ /** Other collection ids affected by the action - this action is conditional on successful commit in all of these collections */
20
+ readonly collectionIds?: CollectionId[];
21
+ };
22
+ /** A checkpoint entry restates the currently uncheckpointed actions */
23
+ export type CheckpointEntry = {
24
+ /** The current set of pending action/revs
25
+ * - actions implicitly increase the set of pending Ids
26
+ * - this restates the entire current set
27
+ * - missing from the set are the implicitly checkpointed ones */
28
+ readonly pendings: ActionRev[];
29
+ };
30
+ export declare const LogDataBlockType = "LGD";
31
+ export declare const LogHeaderBlockType = "LGH";
32
+ export type GetFromResult<TAction> = {
33
+ context: ActionContext | undefined;
34
+ entries: ActionEntry<TAction>[];
35
+ };
36
+ //# sourceMappingURL=struct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../../src/log/struct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7F,qDAAqD;AACrD,MAAM,MAAM,QAAQ,CAAC,OAAO,IAAI;IAC/B,mCAAmC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,2FAA2F;IAC3F,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;CACtC,CAAC;AAEF,+DAA+D;AAC/D,MAAM,MAAM,WAAW,CAAC,OAAO,IAAI;IAClC,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,4BAA4B;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;IAC5B,yEAAyE;IACzE,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,gIAAgI;IAChI,QAAQ,CAAC,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CACxC,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,eAAe,GAAG;IAC7B;;;qEAGiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AACtC,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC,MAAM,MAAM,aAAa,CAAC,OAAO,IAAI;IACpC,OAAO,EAAE,aAAa,GAAG,SAAS,CAAC;IACnC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;CAChC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export const LogDataBlockType = "LGD";
2
+ export const LogHeaderBlockType = "LGH";
3
+ //# sourceMappingURL=struct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"struct.js","sourceRoot":"","sources":["../../../src/log/struct.ts"],"names":[],"mappings":"AAiCA,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { PeerId } from "@libp2p/interface";
2
+ import type { ClusterPeers } from "../cluster/structs.js";
3
+ export type FindCoordinatorOptions = {
4
+ /** Peers that have already been tried (and failed) */
5
+ excludedPeers?: PeerId[];
6
+ };
7
+ export type IKeyNetwork = {
8
+ /**
9
+ * Find a coordinator node responsible for a given key and establish connection
10
+ * @param key The key to find coordinator for
11
+ * @returns Promise resolving to ID of coordinator node
12
+ */
13
+ findCoordinator<T>(key: Uint8Array, options?: Partial<FindCoordinatorOptions>): Promise<PeerId>;
14
+ /**
15
+ * Find the peers in the cluster responsible for a given key
16
+ * @param key The key to find peers for
17
+ * @returns Promise resolving to the peers in the cluster
18
+ */
19
+ findCluster(key: Uint8Array): Promise<ClusterPeers>;
20
+ };
21
+ //# sourceMappingURL=i-key-network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i-key-network.d.ts","sourceRoot":"","sources":["../../../src/network/i-key-network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG;IACpC,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG;IACzB;;;;OAIG;IACH,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhG;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACpD,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=i-key-network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i-key-network.js","sourceRoot":"","sources":["../../../src/network/i-key-network.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { AbortOptions, PeerId, Stream } from "@libp2p/interface";
2
+ export type IPeerNetwork = {
3
+ /**
4
+ * Dial a peer and establish a protocol stream
5
+ */
6
+ connect(peerId: PeerId, protocol: string, options?: AbortOptions): Promise<Stream>;
7
+ };
8
+ //# sourceMappingURL=i-peer-network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i-peer-network.d.ts","sourceRoot":"","sources":["../../../src/network/i-peer-network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACpF,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=i-peer-network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i-peer-network.js","sourceRoot":"","sources":["../../../src/network/i-peer-network.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import type { ActionBlocks, CommitResult, GetBlockResults, PendResult, PendRequest, BlockGets, BlockId, ActionId } from "../index.js";
2
+ export type MessageOptions = {
3
+ expiration?: number;
4
+ signal?: AbortSignal;
5
+ };
6
+ export type RepoCommitRequest = {
7
+ blockIds: BlockId[];
8
+ actionId: ActionId;
9
+ rev: number;
10
+ };
11
+ export type IRepo = {
12
+ get(blockGets: BlockGets, options?: MessageOptions): Promise<GetBlockResults>;
13
+ pend(request: PendRequest, options?: MessageOptions): Promise<PendResult>;
14
+ cancel(actionRef: ActionBlocks, options?: MessageOptions): Promise<void>;
15
+ commit(request: RepoCommitRequest, options?: MessageOptions): Promise<CommitResult>;
16
+ };
17
+ //# sourceMappingURL=i-repo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i-repo.d.ts","sourceRoot":"","sources":["../../../src/network/i-repo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAiB,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAErJ,MAAM,MAAM,cAAc,GAAG;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IACnB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9E,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1E,MAAM,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,MAAM,CAAC,OAAO,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACpF,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=i-repo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i-repo.js","sourceRoot":"","sources":["../../../src/network/i-repo.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export * from "./i-key-network.js";
2
+ export * from "./i-peer-network.js";
3
+ export * from "./i-repo.js";
4
+ export * from "./repo-protocol.js";
5
+ export * from "./struct.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/network/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./i-key-network.js";
2
+ export * from "./i-peer-network.js";
3
+ export * from "./i-repo.js";
4
+ export * from "./repo-protocol.js";
5
+ export * from "./struct.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/network/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { ActionBlocks, PendRequest, CommitRequest, BlockGets } from "../index.js";
2
+ export type RepoMessage = {
3
+ operations: [
4
+ {
5
+ get: BlockGets;
6
+ } | {
7
+ pend: PendRequest;
8
+ } | {
9
+ cancel: {
10
+ actionRef: ActionBlocks;
11
+ };
12
+ } | {
13
+ commit: CommitRequest;
14
+ }
15
+ ];
16
+ expiration?: number;
17
+ coordinatingBlockIds?: string[];
18
+ };
19
+ //# sourceMappingURL=repo-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-protocol.d.ts","sourceRoot":"","sources":["../../../src/network/repo-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvF,MAAM,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE;QACX;YAAE,GAAG,EAAE,SAAS,CAAA;SAAE,GAClB;YAAE,IAAI,EAAE,WAAW,CAAA;SAAE,GACrB;YAAE,MAAM,EAAE;gBAAE,SAAS,EAAE,YAAY,CAAA;aAAE,CAAA;SAAE,GACvC;YAAE,MAAM,EAAE,aAAa,CAAA;SAAE;KACzB,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=repo-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-protocol.js","sourceRoot":"","sources":["../../../src/network/repo-protocol.ts"],"names":[],"mappings":""}
@@ -0,0 +1,115 @@
1
+ import type { CollectionId, BlockId, IBlock, ActionId, Transform, Transforms } from "../index.js";
2
+ import type { ActionContext, ActionRev } from "../collection/action.js";
3
+ import type { Transaction } from "../transaction/transaction.js";
4
+ import type { PeerId } from "@libp2p/interface";
5
+ export type ActionBlocks = {
6
+ blockIds: BlockId[];
7
+ actionId: ActionId;
8
+ };
9
+ export type ActionTransforms = {
10
+ actionId: ActionId;
11
+ rev?: number;
12
+ transforms: Transforms;
13
+ };
14
+ export type ActionTransform = {
15
+ actionId: ActionId;
16
+ rev?: number;
17
+ transform: Transform;
18
+ };
19
+ export type ActionPending = {
20
+ blockId: BlockId;
21
+ actionId: ActionId;
22
+ transform?: Transform;
23
+ };
24
+ export type PendRequest = ActionTransforms & {
25
+ /** What to do if there are any pending actions.
26
+ * 'c' is continue normally,
27
+ * 'f' is fail, returning the pending ActionIds,
28
+ * 'r' is return, which fails but returns the pending ActionIds and their transforms */
29
+ policy: 'c' | 'f' | 'r';
30
+ /** For multi-collection transactions: the full transaction for replay/validation */
31
+ transaction?: Transaction;
32
+ /** For multi-collection transactions: hash of ALL operations across all blocks */
33
+ operationsHash?: string;
34
+ /** For multi-collection transactions: supercluster nominees for consensus */
35
+ superclusterNominees?: PeerId[];
36
+ };
37
+ export type BlockActionStatus = ActionBlocks & {
38
+ statuses: ('pending' | 'committed' | 'checkpointed' | 'aborted')[];
39
+ };
40
+ export type PendSuccess = {
41
+ success: true;
42
+ /** List of already pending actions that were found on blocks touched by this pend */
43
+ pending: ActionPending[];
44
+ /** The affected blocks */
45
+ blockIds: BlockId[];
46
+ };
47
+ export type StaleFailure = {
48
+ success: false;
49
+ /** The reason for the failure */
50
+ reason?: string;
51
+ /** List of actions that have already been committed and are newer than our known revision */
52
+ missing?: ActionTransforms[];
53
+ /** List of actions that are pending on the blocks touched by this pend */
54
+ pending?: ActionPending[];
55
+ };
56
+ export type PendResult = PendSuccess | StaleFailure;
57
+ export type CommitRequest = ActionBlocks & {
58
+ /** The header block of the collection, if this is a new collection (commit first) */
59
+ headerId?: BlockId;
60
+ /** The tail block of the log (commit next) */
61
+ tailId: BlockId;
62
+ /** The new revision for the committed action */
63
+ rev: number;
64
+ };
65
+ export type CommitResult = CommitSuccess | StaleFailure;
66
+ export type CommitSuccess = {
67
+ success: true;
68
+ /** If present, the identified collection acts as the coordinator for the multi-collection transaction */
69
+ coordinatorId?: CollectionId;
70
+ };
71
+ export type BlockActionState = {
72
+ /** The latest action that has been committed */
73
+ latest?: ActionRev;
74
+ /** If present, the specified actions are pending */
75
+ pendings?: ActionId[];
76
+ };
77
+ export type BlockGets = {
78
+ blockIds: BlockId[];
79
+ context?: ActionContext;
80
+ };
81
+ export type GetBlockResult = {
82
+ /** The retrieved block - undefined if the block was deleted */
83
+ block?: IBlock;
84
+ /** The latest and pending states of the repo that retrieved the block */
85
+ state: BlockActionState;
86
+ };
87
+ export type GetBlockResults = Record<BlockId, GetBlockResult>;
88
+ /**
89
+ * Result of validating a transaction in a PendRequest.
90
+ */
91
+ export type PendValidationResult = {
92
+ /** Whether validation passed */
93
+ valid: boolean;
94
+ /** Reason for validation failure (if valid=false) */
95
+ reason?: string;
96
+ };
97
+ /**
98
+ * Hook for validating transactions in PendRequests.
99
+ *
100
+ * This hook is called by the storage layer when receiving a PendRequest
101
+ * that includes a transaction and operationsHash. If validation fails,
102
+ * the pend operation is rejected.
103
+ *
104
+ * If the hook is not provided, validation is skipped (storage-only nodes).
105
+ */
106
+ export type PendValidationHook = (transaction: Transaction, operationsHash: string) => Promise<PendValidationResult>;
107
+ /** @deprecated Use ActionBlocks instead */
108
+ export type TrxBlocks = ActionBlocks;
109
+ /** @deprecated Use ActionTransforms instead */
110
+ export type TrxTransforms = ActionTransforms;
111
+ /** @deprecated Use ActionTransform instead */
112
+ export type TrxTransform = ActionTransform;
113
+ /** @deprecated Use ActionPending instead */
114
+ export type TrxPending = ActionPending;
115
+ //# sourceMappingURL=struct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,aAAa,GAA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@@ -0,0 +1 @@
1
+ {"version":3,"file":"struct.js","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ import type { ITransactionEngine, Transaction, ExecutionResult, CollectionActions } from './transaction.js';
2
+ import type { TransactionCoordinator } from './coordinator.js';
3
+ export declare const ACTIONS_ENGINE_ID = "actions@1.0.0";
4
+ /**
5
+ * Built-in action-based transaction engine for testing.
6
+ *
7
+ * This engine treats each statement as a JSON-encoded CollectionActions object.
8
+ * It's useful for testing the transaction infrastructure without needing SQL.
9
+ *
10
+ * Each statement format:
11
+ * ```json
12
+ * {
13
+ * "collectionId": "users",
14
+ * "actions": [
15
+ * { "type": "insert", "data": { "id": 1, "name": "Alice" } }
16
+ * ]
17
+ * }
18
+ * ```
19
+ */
20
+ export declare class ActionsEngine implements ITransactionEngine {
21
+ private coordinator;
22
+ constructor(coordinator: TransactionCoordinator);
23
+ execute(transaction: Transaction): Promise<ExecutionResult>;
24
+ }
25
+ /**
26
+ * Statement format for the actions engine (array of CollectionActions).
27
+ * @deprecated Use CollectionActions[] directly
28
+ */
29
+ export type ActionsStatement = {
30
+ collections: CollectionActions[];
31
+ };
32
+ /**
33
+ * Helper to create an actions-based transaction statements array.
34
+ * Each CollectionActions becomes a separate statement.
35
+ */
36
+ export declare function createActionsStatements(collections: CollectionActions[]): string[];
37
+ //# sourceMappingURL=actions-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions-engine.d.ts","sourceRoot":"","sources":["../../../src/transaction/actions-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC5G,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,aAAc,YAAW,kBAAkB;IAC3C,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE,sBAAsB;IAEjD,OAAO,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;CAyCjE;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,WAAW,EAAE,iBAAiB,EAAE,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAElF"}