@bsv/wallet-toolbox 1.1.7 → 1.1.9

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 (317) hide show
  1. package/docs/client.md +3872 -1555
  2. package/docs/monitor.md +29 -27
  3. package/docs/services.md +22 -22
  4. package/docs/setup.md +23 -23
  5. package/docs/storage.md +2747 -438
  6. package/docs/wallet.md +3872 -1555
  7. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +4 -4
  8. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
  9. package/out/src/monitor/tasks/TaskCheckForProofs.js +2 -2
  10. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
  11. package/out/src/monitor/tasks/TaskSendWaiting.d.ts +2 -2
  12. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
  13. package/out/src/monitor/tasks/TaskSendWaiting.js +2 -2
  14. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
  15. package/out/src/sdk/StorageSyncReader.d.ts +30 -30
  16. package/out/src/sdk/StorageSyncReader.d.ts.map +1 -1
  17. package/out/src/sdk/StorageSyncReaderWriter.d.ts +60 -60
  18. package/out/src/sdk/StorageSyncReaderWriter.d.ts.map +1 -1
  19. package/out/src/sdk/WalletStorage.interfaces.d.ts +36 -36
  20. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  21. package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
  22. package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
  23. package/out/src/storage/StorageKnex.d.ts +61 -61
  24. package/out/src/storage/StorageKnex.d.ts.map +1 -1
  25. package/out/src/storage/StorageKnex.js +13 -4
  26. package/out/src/storage/StorageKnex.js.map +1 -1
  27. package/out/src/storage/StorageProvider.d.ts +16 -15
  28. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  29. package/out/src/storage/StorageProvider.js +8 -8
  30. package/out/src/storage/StorageProvider.js.map +1 -1
  31. package/out/src/storage/StorageReader.d.ts +21 -21
  32. package/out/src/storage/StorageReader.d.ts.map +1 -1
  33. package/out/src/storage/StorageReader.js.map +1 -1
  34. package/out/src/storage/StorageReaderWriter.d.ts +60 -60
  35. package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
  36. package/out/src/storage/StorageReaderWriter.js.map +1 -1
  37. package/out/src/storage/StorageSyncReader.d.ts +17 -17
  38. package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
  39. package/out/src/storage/StorageSyncReader.js.map +1 -1
  40. package/out/src/storage/WalletStorageManager.d.ts +9 -9
  41. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  42. package/out/src/storage/WalletStorageManager.js +2 -2
  43. package/out/src/storage/WalletStorageManager.js.map +1 -1
  44. package/out/src/storage/index.all.d.ts +2 -2
  45. package/out/src/storage/index.all.d.ts.map +1 -1
  46. package/out/src/storage/index.all.js +3 -3
  47. package/out/src/storage/index.all.js.map +1 -1
  48. package/out/src/storage/index.client.d.ts +2 -2
  49. package/out/src/storage/index.client.d.ts.map +1 -1
  50. package/out/src/storage/index.client.js +2 -25
  51. package/out/src/storage/index.client.js.map +1 -1
  52. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +3 -3
  53. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
  54. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
  55. package/out/src/storage/methods/createAction.d.ts.map +1 -1
  56. package/out/src/storage/methods/createAction.js +1 -1
  57. package/out/src/storage/methods/createAction.js.map +1 -1
  58. package/out/src/storage/methods/getBeefForTransaction.js +2 -2
  59. package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
  60. package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
  61. package/out/src/storage/methods/getSyncChunk.js.map +1 -1
  62. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
  63. package/out/src/storage/methods/internalizeAction.js +1 -1
  64. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  65. package/out/src/storage/methods/listActions.js.map +1 -1
  66. package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
  67. package/out/src/storage/methods/listCertificates.js.map +1 -1
  68. package/out/src/storage/methods/listOutputs.js.map +1 -1
  69. package/out/src/storage/methods/processAction.d.ts +4 -4
  70. package/out/src/storage/methods/processAction.d.ts.map +1 -1
  71. package/out/src/storage/methods/processAction.js +2 -2
  72. package/out/src/storage/methods/processAction.js.map +1 -1
  73. package/out/src/storage/methods/purgeData.d.ts.map +1 -1
  74. package/out/src/storage/methods/purgeData.js.map +1 -1
  75. package/out/src/storage/methods/reviewStatus.js.map +1 -1
  76. package/out/src/storage/remoting/StorageClient.d.ts +230 -15
  77. package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
  78. package/out/src/storage/remoting/StorageClient.js +222 -7
  79. package/out/src/storage/remoting/StorageClient.js.map +1 -1
  80. package/out/src/storage/schema/entities/Certificate.d.ts +9 -9
  81. package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -1
  82. package/out/src/storage/schema/entities/Certificate.js +5 -5
  83. package/out/src/storage/schema/entities/Certificate.js.map +1 -1
  84. package/out/src/storage/schema/entities/CertificateField.d.ts +9 -9
  85. package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -1
  86. package/out/src/storage/schema/entities/CertificateField.js +5 -5
  87. package/out/src/storage/schema/entities/CertificateField.js.map +1 -1
  88. package/out/src/storage/schema/entities/Commission.d.ts +9 -9
  89. package/out/src/storage/schema/entities/Commission.d.ts.map +1 -1
  90. package/out/src/storage/schema/entities/Commission.js +5 -5
  91. package/out/src/storage/schema/entities/Commission.js.map +1 -1
  92. package/out/src/storage/schema/entities/EntityBase.d.ts +1 -1
  93. package/out/src/storage/schema/entities/MergeEntity.d.ts +6 -7
  94. package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
  95. package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
  96. package/out/src/storage/schema/entities/Output.d.ts +9 -9
  97. package/out/src/storage/schema/entities/Output.d.ts.map +1 -1
  98. package/out/src/storage/schema/entities/Output.js +5 -5
  99. package/out/src/storage/schema/entities/Output.js.map +1 -1
  100. package/out/src/storage/schema/entities/OutputBasket.d.ts +9 -9
  101. package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -1
  102. package/out/src/storage/schema/entities/OutputBasket.js +5 -5
  103. package/out/src/storage/schema/entities/OutputBasket.js.map +1 -1
  104. package/out/src/storage/schema/entities/OutputTag.d.ts +9 -9
  105. package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -1
  106. package/out/src/storage/schema/entities/OutputTag.js +5 -5
  107. package/out/src/storage/schema/entities/OutputTag.js.map +1 -1
  108. package/out/src/storage/schema/entities/OutputTagMap.d.ts +9 -9
  109. package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -1
  110. package/out/src/storage/schema/entities/OutputTagMap.js +5 -5
  111. package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -1
  112. package/out/src/storage/schema/entities/ProvenTx.d.ts +11 -11
  113. package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -1
  114. package/out/src/storage/schema/entities/ProvenTx.js +11 -11
  115. package/out/src/storage/schema/entities/ProvenTx.js.map +1 -1
  116. package/out/src/storage/schema/entities/ProvenTxReq.d.ts +19 -19
  117. package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -1
  118. package/out/src/storage/schema/entities/ProvenTxReq.js +13 -13
  119. package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -1
  120. package/out/src/storage/schema/entities/SyncState.d.ts +11 -11
  121. package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -1
  122. package/out/src/storage/schema/entities/SyncState.js +27 -27
  123. package/out/src/storage/schema/entities/SyncState.js.map +1 -1
  124. package/out/src/storage/schema/entities/Transaction.d.ts +11 -11
  125. package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -1
  126. package/out/src/storage/schema/entities/Transaction.js +6 -6
  127. package/out/src/storage/schema/entities/Transaction.js.map +1 -1
  128. package/out/src/storage/schema/entities/TxLabel.d.ts +9 -9
  129. package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -1
  130. package/out/src/storage/schema/entities/TxLabel.js +5 -5
  131. package/out/src/storage/schema/entities/TxLabel.js.map +1 -1
  132. package/out/src/storage/schema/entities/TxLabelMap.d.ts +9 -9
  133. package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -1
  134. package/out/src/storage/schema/entities/TxLabelMap.js +5 -5
  135. package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -1
  136. package/out/src/storage/schema/entities/User.d.ts +9 -9
  137. package/out/src/storage/schema/entities/User.d.ts.map +1 -1
  138. package/out/src/storage/schema/entities/User.js +5 -5
  139. package/out/src/storage/schema/entities/User.js.map +1 -1
  140. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js +20 -307
  141. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -1
  142. package/out/src/storage/schema/entities/__tests/CertificateTests.test.js +17 -158
  143. package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -1
  144. package/out/src/storage/schema/entities/__tests/CommissionTests.test.js +23 -309
  145. package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -1
  146. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js +19 -306
  147. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -1
  148. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js +19 -306
  149. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -1
  150. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js +23 -237
  151. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -1
  152. package/out/src/storage/schema/entities/__tests/OutputTests.test.js +20 -233
  153. package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -1
  154. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js +27 -98
  155. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -1
  156. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +25 -241
  157. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
  158. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js +38 -112
  159. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -1
  160. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +39 -323
  161. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -1
  162. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js +31 -169
  163. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -1
  164. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js +16 -159
  165. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -1
  166. package/out/src/storage/schema/entities/__tests/usersTests.test.js +21 -168
  167. package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -1
  168. package/out/src/storage/schema/tables/Certificate.d.ts +4 -4
  169. package/out/src/storage/schema/tables/Certificate.d.ts.map +1 -1
  170. package/out/src/storage/schema/tables/CertificateField.d.ts +1 -1
  171. package/out/src/storage/schema/tables/CertificateField.d.ts.map +1 -1
  172. package/out/src/storage/schema/tables/Commission.d.ts +1 -1
  173. package/out/src/storage/schema/tables/Commission.d.ts.map +1 -1
  174. package/out/src/storage/schema/tables/MonitorEvent.d.ts +1 -1
  175. package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +1 -1
  176. package/out/src/storage/schema/tables/Output.d.ts +5 -5
  177. package/out/src/storage/schema/tables/Output.d.ts.map +1 -1
  178. package/out/src/storage/schema/tables/OutputBasket.d.ts +1 -1
  179. package/out/src/storage/schema/tables/OutputBasket.d.ts.map +1 -1
  180. package/out/src/storage/schema/tables/OutputTag.d.ts +1 -1
  181. package/out/src/storage/schema/tables/OutputTag.d.ts.map +1 -1
  182. package/out/src/storage/schema/tables/OutputTagMap.d.ts +1 -1
  183. package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +1 -1
  184. package/out/src/storage/schema/tables/ProvenTx.d.ts +1 -1
  185. package/out/src/storage/schema/tables/ProvenTx.d.ts.map +1 -1
  186. package/out/src/storage/schema/tables/ProvenTxReq.d.ts +2 -2
  187. package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +1 -1
  188. package/out/src/storage/schema/tables/SyncState.d.ts +1 -1
  189. package/out/src/storage/schema/tables/SyncState.d.ts.map +1 -1
  190. package/out/src/storage/schema/tables/{Settings.d.ts → TableSettings.d.ts} +2 -2
  191. package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -0
  192. package/out/src/storage/schema/tables/{Settings.js → TableSettings.js} +1 -1
  193. package/out/src/storage/schema/tables/TableSettings.js.map +1 -0
  194. package/out/src/storage/schema/tables/Transaction.d.ts +1 -1
  195. package/out/src/storage/schema/tables/Transaction.d.ts.map +1 -1
  196. package/out/src/storage/schema/tables/TxLabel.d.ts +1 -1
  197. package/out/src/storage/schema/tables/TxLabel.d.ts.map +1 -1
  198. package/out/src/storage/schema/tables/TxLabelMap.d.ts +1 -1
  199. package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +1 -1
  200. package/out/src/storage/schema/tables/User.d.ts +1 -1
  201. package/out/src/storage/schema/tables/User.d.ts.map +1 -1
  202. package/out/src/storage/schema/tables/index.d.ts +1 -1
  203. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  204. package/out/src/storage/schema/tables/index.js +1 -1
  205. package/out/src/storage/schema/tables/index.js.map +1 -1
  206. package/out/src/storage/sync/StorageMySQLDojoReader.d.ts +17 -17
  207. package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
  208. package/out/src/storage/sync/StorageMySQLDojoReader.js +2 -2
  209. package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
  210. package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
  211. package/out/test/Wallet/live/walletLive.man.test.js +1 -1
  212. package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
  213. package/out/test/monitor/Monitor.test.js +7 -7
  214. package/out/test/monitor/Monitor.test.js.map +1 -1
  215. package/out/test/storage/StorageMySQLDojoReader.man.test.js +1 -1
  216. package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -1
  217. package/out/test/storage/insert.test.js.map +1 -1
  218. package/out/test/storage/update.test.js.map +1 -1
  219. package/out/test/storage/update2.test.js.map +1 -1
  220. package/out/test/utils/TestUtilsWalletStorage.d.ts +56 -56
  221. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
  222. package/out/test/utils/TestUtilsWalletStorage.js +11 -4
  223. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
  224. package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -1
  225. package/out/tsconfig.all.tsbuildinfo +1 -1
  226. package/package.json +2 -2
  227. package/src/monitor/tasks/TaskCheckForProofs.ts +11 -10
  228. package/src/monitor/tasks/TaskSendWaiting.ts +5 -5
  229. package/src/sdk/StorageSyncReader.ts +48 -30
  230. package/src/sdk/StorageSyncReaderWriter.ts +77 -63
  231. package/src/sdk/WalletStorage.interfaces.ts +55 -36
  232. package/src/signer/methods/acquireDirectCertificate.ts +2 -2
  233. package/src/storage/StorageKnex.ts +137 -106
  234. package/src/storage/StorageProvider.ts +43 -30
  235. package/src/storage/StorageReader.ts +37 -21
  236. package/src/storage/StorageReaderWriter.ts +78 -65
  237. package/src/storage/StorageSyncReader.ts +35 -17
  238. package/src/storage/WalletStorageManager.ts +18 -12
  239. package/src/storage/index.all.ts +2 -2
  240. package/src/storage/index.client.ts +2 -2
  241. package/src/storage/methods/attemptToPostReqsToNetwork.ts +3 -3
  242. package/src/storage/methods/createAction.ts +29 -26
  243. package/src/storage/methods/getBeefForTransaction.ts +3 -3
  244. package/src/storage/methods/getSyncChunk.ts +28 -13
  245. package/src/storage/methods/internalizeAction.ts +19 -17
  246. package/src/storage/methods/listActions.ts +5 -5
  247. package/src/storage/methods/listCertificates.ts +2 -2
  248. package/src/storage/methods/listOutputs.ts +5 -5
  249. package/src/storage/methods/processAction.ts +21 -17
  250. package/src/storage/methods/purgeData.ts +17 -11
  251. package/src/storage/methods/reviewStatus.ts +4 -4
  252. package/src/storage/remoting/StorageClient.ts +250 -26
  253. package/src/storage/schema/entities/Certificate.ts +16 -17
  254. package/src/storage/schema/entities/CertificateField.ts +17 -18
  255. package/src/storage/schema/entities/Commission.ts +16 -20
  256. package/src/storage/schema/entities/EntityBase.ts +1 -1
  257. package/src/storage/schema/entities/MergeEntity.ts +7 -7
  258. package/src/storage/schema/entities/Output.ts +16 -20
  259. package/src/storage/schema/entities/OutputBasket.ts +16 -17
  260. package/src/storage/schema/entities/OutputTag.ts +16 -20
  261. package/src/storage/schema/entities/OutputTagMap.ts +17 -18
  262. package/src/storage/schema/entities/ProvenTx.ts +24 -28
  263. package/src/storage/schema/entities/ProvenTxReq.ts +42 -45
  264. package/src/storage/schema/entities/SyncState.ts +61 -38
  265. package/src/storage/schema/entities/Transaction.ts +23 -23
  266. package/src/storage/schema/entities/TxLabel.ts +16 -17
  267. package/src/storage/schema/entities/TxLabelMap.ts +16 -20
  268. package/src/storage/schema/entities/User.ts +15 -19
  269. package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +39 -318
  270. package/src/storage/schema/entities/__tests/CertificateTests.test.ts +29 -169
  271. package/src/storage/schema/entities/__tests/CommissionTests.test.ts +47 -325
  272. package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +35 -316
  273. package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +38 -318
  274. package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +36 -249
  275. package/src/storage/schema/entities/__tests/OutputTests.test.ts +30 -244
  276. package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +35 -101
  277. package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +27 -243
  278. package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +54 -122
  279. package/src/storage/schema/entities/__tests/TransactionTests.test.ts +53 -333
  280. package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +44 -177
  281. package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +19 -163
  282. package/src/storage/schema/entities/__tests/usersTests.test.ts +31 -179
  283. package/src/storage/schema/tables/Certificate.ts +4 -4
  284. package/src/storage/schema/tables/CertificateField.ts +1 -1
  285. package/src/storage/schema/tables/Commission.ts +1 -1
  286. package/src/storage/schema/tables/MonitorEvent.ts +1 -1
  287. package/src/storage/schema/tables/Output.ts +5 -5
  288. package/src/storage/schema/tables/OutputBasket.ts +1 -1
  289. package/src/storage/schema/tables/OutputTag.ts +1 -1
  290. package/src/storage/schema/tables/OutputTagMap.ts +1 -1
  291. package/src/storage/schema/tables/ProvenTx.ts +1 -1
  292. package/src/storage/schema/tables/ProvenTxReq.ts +2 -2
  293. package/src/storage/schema/tables/SyncState.ts +1 -1
  294. package/src/storage/schema/tables/{Settings.ts → TableSettings.ts} +3 -1
  295. package/src/storage/schema/tables/Transaction.ts +1 -1
  296. package/src/storage/schema/tables/TxLabel.ts +1 -1
  297. package/src/storage/schema/tables/TxLabelMap.ts +1 -1
  298. package/src/storage/schema/tables/User.ts +1 -1
  299. package/src/storage/schema/tables/index.ts +1 -1
  300. package/src/storage/sync/StorageMySQLDojoReader.ts +68 -50
  301. package/test/Wallet/certificate/listCertificates.test.ts +12 -8
  302. package/test/Wallet/live/walletLive.man.test.ts +6 -6
  303. package/test/monitor/Monitor.test.ts +8 -8
  304. package/test/storage/StorageMySQLDojoReader.man.test.ts +1 -1
  305. package/test/storage/insert.test.ts +2 -2
  306. package/test/storage/update.test.ts +30 -30
  307. package/test/storage/update2.test.ts +23 -24
  308. package/test/utils/TestUtilsWalletStorage.ts +103 -82
  309. package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +1 -2
  310. package/ts2md.json +1 -1
  311. package/out/src/storage/index.db.d.ts +0 -1
  312. package/out/src/storage/index.db.d.ts.map +0 -1
  313. package/out/src/storage/index.db.js +0 -2
  314. package/out/src/storage/index.db.js.map +0 -1
  315. package/out/src/storage/schema/tables/Settings.d.ts.map +0 -1
  316. package/out/src/storage/schema/tables/Settings.js.map +0 -1
  317. package/src/storage/index.db.ts +0 -0
@@ -1,10 +1,10 @@
1
1
  import * as bsv from '@bsv/sdk'
2
- import { entity, table, sdk } from '../../../../../src'
2
+ import { createSyncMap, sdk, SyncMap } from '../../../../../src'
3
3
  import {
4
4
  TestUtilsWalletStorage as _tu,
5
5
  TestWalletNoSetup
6
6
  } from '../../../../../test/utils/TestUtilsWalletStorage'
7
- import { ProvenTx } from '../../../../../src/storage/schema/entities/ProvenTx'
7
+ import { EntityProvenTx } from '../../../../../src/storage/schema/entities/ProvenTx'
8
8
 
9
9
  describe('ProvenTx class method tests', () => {
10
10
  jest.setTimeout(99999999)
@@ -122,7 +122,7 @@ describe('ProvenTx class method tests', () => {
122
122
  }
123
123
 
124
124
  // Call the method under test
125
- const result = await ProvenTx.fromTxid(txid, services)
125
+ const result = await EntityProvenTx.fromTxid(txid, services)
126
126
 
127
127
  // Validate the ProvenTx result
128
128
  expect(result.proven).toBeDefined()
@@ -145,7 +145,7 @@ describe('ProvenTx class method tests', () => {
145
145
  const services: sdk.WalletServices = ctx.services
146
146
 
147
147
  // Call the method under test
148
- const result = await ProvenTx.fromTxid(txid, services)
148
+ const result = await EntityProvenTx.fromTxid(txid, services)
149
149
 
150
150
  // Validate that ProvenTx could not be created
151
151
  expect(result.proven).toBeUndefined()
@@ -162,7 +162,7 @@ describe('ProvenTx class method tests', () => {
162
162
  const merkleProof = await services.getMerklePath(txid)
163
163
 
164
164
  // Call the method under test
165
- const result = await ProvenTx.fromTxid(txid, services)
165
+ const result = await EntityProvenTx.fromTxid(txid, services)
166
166
 
167
167
  // Validate the ProvenTx result
168
168
  expect(result.proven).toBeUndefined()
@@ -185,7 +185,7 @@ describe('ProvenTx class method tests', () => {
185
185
  }
186
186
 
187
187
  // Initialize the ProvenTx entity with mock data
188
- const provenTx = new ProvenTx(mockData)
188
+ const provenTx = new EntityProvenTx(mockData)
189
189
 
190
190
  // Validate getters
191
191
  expect(provenTx.provenTxId).toBe(mockData.provenTxId)
@@ -228,7 +228,7 @@ describe('ProvenTx class method tests', () => {
228
228
 
229
229
  // Validate overridden methods
230
230
  expect(provenTx.id).toBe(2)
231
- expect(provenTx.entityName).toBe('ProvenTx')
231
+ expect(provenTx.entityName).toBe('provenTx')
232
232
  expect(provenTx.entityTable).toBe('proven_txs')
233
233
 
234
234
  // Update id via overridden setter
@@ -242,7 +242,7 @@ describe('ProvenTx class method tests', () => {
242
242
  const ctx2 = ctxs2[0]
243
243
 
244
244
  // Insert a ProvenTx into the first database
245
- const provenTx1 = new ProvenTx({
245
+ const provenTx1 = new EntityProvenTx({
246
246
  provenTxId: 401,
247
247
  txid: 'valid-txid',
248
248
  created_at: new Date('2023-01-01'),
@@ -258,7 +258,7 @@ describe('ProvenTx class method tests', () => {
258
258
  await ctx1.activeStorage.insertProvenTx(provenTx1.toApi())
259
259
 
260
260
  // Insert a matching ProvenTx into the second database
261
- const provenTx2 = new ProvenTx({
261
+ const provenTx2 = new EntityProvenTx({
262
262
  provenTxId: 401,
263
263
  txid: 'valid-txid',
264
264
  created_at: new Date('2023-01-01'),
@@ -273,81 +273,8 @@ describe('ProvenTx class method tests', () => {
273
273
 
274
274
  await ctx2.activeStorage.insertProvenTx(provenTx2.toApi())
275
275
 
276
- // Create a valid SyncMap
277
- const syncMap: entity.SyncMap = {
278
- provenTx: {
279
- idMap: { [provenTx1.provenTxId]: provenTx2.provenTxId },
280
- entityName: 'ProvenTx',
281
- maxUpdated_at: undefined,
282
- count: 1
283
- },
284
- transaction: {
285
- idMap: {},
286
- entityName: 'Transaction',
287
- maxUpdated_at: undefined,
288
- count: 0
289
- },
290
- outputBasket: {
291
- idMap: {},
292
- entityName: 'OutputBasket',
293
- maxUpdated_at: undefined,
294
- count: 0
295
- },
296
- provenTxReq: {
297
- idMap: {},
298
- entityName: 'ProvenTxReq',
299
- maxUpdated_at: undefined,
300
- count: 0
301
- },
302
- txLabel: {
303
- idMap: {},
304
- entityName: 'TxLabel',
305
- maxUpdated_at: undefined,
306
- count: 0
307
- },
308
- txLabelMap: {
309
- idMap: {},
310
- entityName: 'TxLabelMap',
311
- maxUpdated_at: undefined,
312
- count: 0
313
- },
314
- output: {
315
- idMap: {},
316
- entityName: 'Output',
317
- maxUpdated_at: undefined,
318
- count: 0
319
- },
320
- outputTag: {
321
- idMap: {},
322
- entityName: 'OutputTag',
323
- maxUpdated_at: undefined,
324
- count: 0
325
- },
326
- outputTagMap: {
327
- idMap: {},
328
- entityName: 'OutputTagMap',
329
- maxUpdated_at: undefined,
330
- count: 0
331
- },
332
- certificate: {
333
- idMap: {},
334
- entityName: 'Certificate',
335
- maxUpdated_at: undefined,
336
- count: 0
337
- },
338
- certificateField: {
339
- idMap: {},
340
- entityName: 'CertificateField',
341
- maxUpdated_at: undefined,
342
- count: 0
343
- },
344
- commission: {
345
- idMap: {},
346
- entityName: 'Commission',
347
- maxUpdated_at: undefined,
348
- count: 0
349
- }
350
- }
276
+ const syncMap = createSyncMap()
277
+ syncMap.provenTx.idMap = { [provenTx1.provenTxId]: provenTx2.provenTxId }
351
278
 
352
279
  // Verify the ProvenTx entities match
353
280
  expect(provenTx1.equals(provenTx2.toApi(), syncMap)).toBe(true)
@@ -355,7 +282,7 @@ describe('ProvenTx class method tests', () => {
355
282
 
356
283
  // Test: equals identifies non-matching txid
357
284
  test('5_equals: identifies non-matching txid', async () => {
358
- const provenTx1 = new ProvenTx({
285
+ const provenTx1 = new EntityProvenTx({
359
286
  provenTxId: 102,
360
287
  txid: 'txid1',
361
288
  created_at: new Date('2023-01-01'),
@@ -368,7 +295,7 @@ describe('ProvenTx class method tests', () => {
368
295
  merkleRoot: 'merkle-root'
369
296
  })
370
297
 
371
- const provenTx2 = new ProvenTx({
298
+ const provenTx2 = new EntityProvenTx({
372
299
  provenTxId: 103,
373
300
  txid: 'txid2',
374
301
  created_at: new Date('2023-01-01'),
@@ -386,7 +313,7 @@ describe('ProvenTx class method tests', () => {
386
313
 
387
314
  // Test: equals identifies non-matching height
388
315
  test('6_equals: identifies non-matching height', async () => {
389
- const provenTx1 = new ProvenTx({
316
+ const provenTx1 = new EntityProvenTx({
390
317
  provenTxId: 104,
391
318
  txid: 'valid-txid',
392
319
  created_at: new Date('2023-01-01'),
@@ -399,7 +326,7 @@ describe('ProvenTx class method tests', () => {
399
326
  merkleRoot: 'merkle-root'
400
327
  })
401
328
 
402
- const provenTx2 = new ProvenTx({
329
+ const provenTx2 = new EntityProvenTx({
403
330
  provenTxId: 105,
404
331
  txid: 'valid-txid',
405
332
  created_at: new Date('2023-01-01'),
@@ -417,7 +344,7 @@ describe('ProvenTx class method tests', () => {
417
344
 
418
345
  // Test: equals identifies non-matching merklePath
419
346
  test('7_equals: identifies non-matching merklePath', async () => {
420
- const provenTx1 = new ProvenTx({
347
+ const provenTx1 = new EntityProvenTx({
421
348
  provenTxId: 106,
422
349
  txid: 'valid-txid',
423
350
  created_at: new Date('2023-01-01'),
@@ -430,7 +357,7 @@ describe('ProvenTx class method tests', () => {
430
357
  merkleRoot: 'merkle-root'
431
358
  })
432
359
 
433
- const provenTx2 = new ProvenTx({
360
+ const provenTx2 = new EntityProvenTx({
434
361
  provenTxId: 107,
435
362
  txid: 'valid-txid',
436
363
  created_at: new Date('2023-01-01'),
@@ -448,7 +375,7 @@ describe('ProvenTx class method tests', () => {
448
375
 
449
376
  // Test: equals identifies non-matching syncMap
450
377
  test('8_equals: identifies non-matching syncMap', async () => {
451
- const provenTx1 = new ProvenTx({
378
+ const provenTx1 = new EntityProvenTx({
452
379
  provenTxId: 108,
453
380
  txid: 'valid-txid',
454
381
  created_at: new Date('2023-01-01'),
@@ -461,7 +388,7 @@ describe('ProvenTx class method tests', () => {
461
388
  merkleRoot: 'merkle-root'
462
389
  })
463
390
 
464
- const provenTx2 = new ProvenTx({
391
+ const provenTx2 = new EntityProvenTx({
465
392
  provenTxId: 109,
466
393
  txid: 'valid-txid',
467
394
  created_at: new Date('2023-01-01'),
@@ -474,80 +401,8 @@ describe('ProvenTx class method tests', () => {
474
401
  merkleRoot: 'merkle-root'
475
402
  })
476
403
 
477
- const syncMap: entity.SyncMap = {
478
- provenTx: {
479
- idMap: { 108: 999 },
480
- entityName: 'ProvenTx',
481
- maxUpdated_at: undefined,
482
- count: 1
483
- },
484
- transaction: {
485
- idMap: {},
486
- entityName: 'Transaction',
487
- maxUpdated_at: undefined,
488
- count: 0
489
- },
490
- outputBasket: {
491
- idMap: {},
492
- entityName: 'OutputBasket',
493
- maxUpdated_at: undefined,
494
- count: 0
495
- },
496
- provenTxReq: {
497
- idMap: {},
498
- entityName: 'ProvenTxReq',
499
- maxUpdated_at: undefined,
500
- count: 0
501
- },
502
- txLabel: {
503
- idMap: {},
504
- entityName: 'TxLabel',
505
- maxUpdated_at: undefined,
506
- count: 0
507
- },
508
- txLabelMap: {
509
- idMap: {},
510
- entityName: 'TxLabelMap',
511
- maxUpdated_at: undefined,
512
- count: 0
513
- },
514
- output: {
515
- idMap: {},
516
- entityName: 'Output',
517
- maxUpdated_at: undefined,
518
- count: 0
519
- },
520
- outputTag: {
521
- idMap: {},
522
- entityName: 'OutputTag',
523
- maxUpdated_at: undefined,
524
- count: 0
525
- },
526
- outputTagMap: {
527
- idMap: {},
528
- entityName: 'OutputTagMap',
529
- maxUpdated_at: undefined,
530
- count: 0
531
- },
532
- certificate: {
533
- idMap: {},
534
- entityName: 'Certificate',
535
- maxUpdated_at: undefined,
536
- count: 0
537
- },
538
- certificateField: {
539
- idMap: {},
540
- entityName: 'CertificateField',
541
- maxUpdated_at: undefined,
542
- count: 0
543
- },
544
- commission: {
545
- idMap: {},
546
- entityName: 'Commission',
547
- maxUpdated_at: undefined,
548
- count: 0
549
- }
550
- }
404
+ const syncMap = createSyncMap()
405
+ syncMap.provenTx.idMap = { 108: 999 }
551
406
 
552
407
  expect(provenTx1.equals(provenTx2.toApi(), syncMap)).toBe(false)
553
408
  })
@@ -557,7 +412,7 @@ describe('ProvenTx class method tests', () => {
557
412
  const ctx2 = ctxs2[0]
558
413
 
559
414
  // Insert a ProvenTx record into the first database
560
- const tx1 = new ProvenTx({
415
+ const tx1 = new EntityProvenTx({
561
416
  provenTxId: 405,
562
417
  txid: 'txid1',
563
418
  created_at: new Date('2023-01-01'),
@@ -572,7 +427,7 @@ describe('ProvenTx class method tests', () => {
572
427
  await ctx1.activeStorage.insertProvenTx(tx1.toApi())
573
428
 
574
429
  // Insert a different ProvenTx record into the second database with a mismatched provenTxId
575
- const tx2 = new ProvenTx({
430
+ const tx2 = new EntityProvenTx({
576
431
  provenTxId: 406,
577
432
  txid: 'txid1',
578
433
  created_at: new Date('2023-01-01'),
@@ -594,7 +449,7 @@ describe('ProvenTx class method tests', () => {
594
449
  const ctx = ctxs[0]
595
450
 
596
451
  // Create a ProvenTx entity
597
- const provenTx = new ProvenTx({
452
+ const provenTx = new EntityProvenTx({
598
453
  provenTxId: 101,
599
454
  txid: 'txid1',
600
455
  created_at: new Date('2023-01-01'),
@@ -607,82 +462,11 @@ describe('ProvenTx class method tests', () => {
607
462
  merkleRoot: 'merkle-root-1'
608
463
  })
609
464
 
465
+ const mockSyncMap = createSyncMap()
466
+ mockSyncMap.provenTx.idMap = { [provenTx.provenTxId]: provenTx.provenTxId }
467
+
610
468
  // Create mock storage, syncMap, and trx token
611
469
  const mockStorage = ctx.activeStorage
612
- const mockSyncMap: entity.SyncMap = {
613
- provenTx: {
614
- idMap: { [provenTx.provenTxId]: provenTx.provenTxId },
615
- entityName: 'ProvenTx',
616
- maxUpdated_at: undefined,
617
- count: 1
618
- },
619
- transaction: {
620
- idMap: {},
621
- entityName: 'Transaction',
622
- maxUpdated_at: undefined,
623
- count: 0
624
- },
625
- outputBasket: {
626
- idMap: {},
627
- entityName: 'OutputBasket',
628
- maxUpdated_at: undefined,
629
- count: 0
630
- },
631
- provenTxReq: {
632
- idMap: {},
633
- entityName: 'ProvenTxReq',
634
- maxUpdated_at: undefined,
635
- count: 0
636
- },
637
- txLabel: {
638
- idMap: {},
639
- entityName: 'TxLabel',
640
- maxUpdated_at: undefined,
641
- count: 0
642
- },
643
- txLabelMap: {
644
- idMap: {},
645
- entityName: 'TxLabelMap',
646
- maxUpdated_at: undefined,
647
- count: 0
648
- },
649
- output: {
650
- idMap: {},
651
- entityName: 'Output',
652
- maxUpdated_at: undefined,
653
- count: 0
654
- },
655
- outputTag: {
656
- idMap: {},
657
- entityName: 'OutputTag',
658
- maxUpdated_at: undefined,
659
- count: 0
660
- },
661
- outputTagMap: {
662
- idMap: {},
663
- entityName: 'OutputTagMap',
664
- maxUpdated_at: undefined,
665
- count: 0
666
- },
667
- certificate: {
668
- idMap: {},
669
- entityName: 'Certificate',
670
- maxUpdated_at: undefined,
671
- count: 0
672
- },
673
- certificateField: {
674
- idMap: {},
675
- entityName: 'CertificateField',
676
- maxUpdated_at: undefined,
677
- count: 0
678
- },
679
- commission: {
680
- idMap: {},
681
- entityName: 'Commission',
682
- maxUpdated_at: undefined,
683
- count: 0
684
- }
685
- }
686
470
  const mockTrx: sdk.TrxToken = {}
687
471
 
688
472
  // Call the mergeExisting method
@@ -1,5 +1,11 @@
1
- import { SyncState } from '../../../../../src/storage/schema/entities/SyncState'
2
- import { entity, table, sdk } from '../../../../../src'
1
+ import { EntitySyncState } from '../../../../../src/storage/schema/entities/SyncState'
2
+ import {
3
+ createSyncMap,
4
+ EntityStorage,
5
+ sdk,
6
+ SyncMap,
7
+ TableSyncState
8
+ } from '../../../../../src'
3
9
  import {
4
10
  TestUtilsWalletStorage as _tu,
5
11
  TestWalletNoSetup
@@ -28,7 +34,7 @@ describe('SyncState class method tests', () => {
28
34
  // Test: Insert a new SyncState when id is 0
29
35
  test('0_inserts_new_sync_state', async () => {
30
36
  const ctx = ctxs[0]
31
- const syncState = new SyncState()
37
+ const syncState = new EntitySyncState()
32
38
  syncState.id = 0
33
39
 
34
40
  // Assign a unique value to refNum and valid userId
@@ -56,7 +62,7 @@ describe('SyncState class method tests', () => {
56
62
  // Test: Update an existing SyncState
57
63
  test('1_updates_existing_sync_state', async () => {
58
64
  const ctx = ctxs[0]
59
- const syncState = new SyncState()
65
+ const syncState = new EntitySyncState()
60
66
  syncState.id = 0
61
67
  // Assign a unique value to refNum and valid userId
62
68
  syncState.userId = 1
@@ -83,38 +89,17 @@ describe('SyncState class method tests', () => {
83
89
 
84
90
  // Test: Merge ID maps correctly
85
91
  test('2_merges_id_maps_correctly', async () => {
86
- const syncState = new SyncState()
87
-
88
- // Complete SyncMap with all required properties
89
- const inputSyncMap: entity.SyncMap = {
90
- provenTx: { idMap: { 1: 2 }, entityName: 'provenTx', count: 1 },
91
- outputBasket: { idMap: {}, entityName: 'outputBasket', count: 0 },
92
- transaction: { idMap: { 3: 4 }, entityName: 'transaction', count: 1 },
93
- provenTxReq: { idMap: {}, entityName: 'provenTxReq', count: 0 },
94
- txLabel: { idMap: {}, entityName: 'txLabel', count: 0 },
95
- txLabelMap: { idMap: {}, entityName: 'txLabelMap', count: 0 },
96
- output: { idMap: {}, entityName: 'output', count: 0 },
97
- outputTag: { idMap: {}, entityName: 'outputTag', count: 0 },
98
- outputTagMap: { idMap: {}, entityName: 'outputTagMap', count: 0 },
99
- certificate: { idMap: {}, entityName: 'certificate', count: 0 },
100
- certificateField: { idMap: {}, entityName: 'certificateField', count: 0 },
101
- commission: { idMap: {}, entityName: 'commission', count: 0 }
102
- }
92
+ const syncState = new EntitySyncState()
103
93
 
104
- syncState.syncMap = {
105
- provenTx: { idMap: { 1: 2 }, entityName: 'provenTx', count: 1 },
106
- outputBasket: { idMap: {}, entityName: 'outputBasket', count: 0 },
107
- transaction: { idMap: { 5: 6 }, entityName: 'transaction', count: 1 },
108
- provenTxReq: { idMap: {}, entityName: 'provenTxReq', count: 0 },
109
- txLabel: { idMap: {}, entityName: 'txLabel', count: 0 },
110
- txLabelMap: { idMap: {}, entityName: 'txLabelMap', count: 0 },
111
- output: { idMap: {}, entityName: 'output', count: 0 },
112
- outputTag: { idMap: {}, entityName: 'outputTag', count: 0 },
113
- outputTagMap: { idMap: {}, entityName: 'outputTagMap', count: 0 },
114
- certificate: { idMap: {}, entityName: 'certificate', count: 0 },
115
- certificateField: { idMap: {}, entityName: 'certificateField', count: 0 },
116
- commission: { idMap: {}, entityName: 'commission', count: 0 }
117
- }
94
+ const inputSyncMap = createSyncMap()
95
+ inputSyncMap.provenTx.idMap = { 1: 2 }
96
+ inputSyncMap.transaction.idMap = { 3: 4 }
97
+
98
+ syncState.syncMap = createSyncMap()
99
+ syncState.syncMap.provenTx.idMap = { 1: 2 }
100
+ syncState.syncMap.provenTx.count = 1
101
+ syncState.syncMap.transaction.idMap = { 5: 6 }
102
+ syncState.syncMap.transaction.count = 1
118
103
 
119
104
  syncState.mergeSyncMap(inputSyncMap)
120
105
 
@@ -126,37 +111,19 @@ describe('SyncState class method tests', () => {
126
111
 
127
112
  // Test: Throw error on conflicting mappings
128
113
  test('3_throws_error_on_conflicting_mappings', () => {
129
- const syncState = new SyncState()
130
-
131
- syncState.syncMap = {
132
- provenTx: { idMap: { 1: 2 }, entityName: 'provenTx', count: 1 },
133
- outputBasket: { idMap: {}, entityName: 'outputBasket', count: 0 },
134
- transaction: { idMap: { 3: 4 }, entityName: 'transaction', count: 1 },
135
- provenTxReq: { idMap: {}, entityName: 'provenTxReq', count: 0 },
136
- txLabel: { idMap: {}, entityName: 'txLabel', count: 0 },
137
- txLabelMap: { idMap: {}, entityName: 'txLabelMap', count: 0 },
138
- output: { idMap: {}, entityName: 'output', count: 0 },
139
- outputTag: { idMap: {}, entityName: 'outputTag', count: 0 },
140
- outputTagMap: { idMap: {}, entityName: 'outputTagMap', count: 0 },
141
- certificate: { idMap: {}, entityName: 'certificate', count: 0 },
142
- certificateField: { idMap: {}, entityName: 'certificateField', count: 0 },
143
- commission: { idMap: {}, entityName: 'commission', count: 0 }
144
- }
114
+ const syncState = new EntitySyncState()
145
115
 
146
- const conflictingSyncMap: entity.SyncMap = {
147
- provenTx: { idMap: { 1: 3 }, entityName: 'provenTx', count: 1 },
148
- outputBasket: { idMap: {}, entityName: 'outputBasket', count: 0 },
149
- transaction: { idMap: { 3: 4 }, entityName: 'transaction', count: 1 },
150
- provenTxReq: { idMap: {}, entityName: 'provenTxReq', count: 0 },
151
- txLabel: { idMap: {}, entityName: 'txLabel', count: 0 },
152
- txLabelMap: { idMap: {}, entityName: 'txLabelMap', count: 0 },
153
- output: { idMap: {}, entityName: 'output', count: 0 },
154
- outputTag: { idMap: {}, entityName: 'outputTag', count: 0 },
155
- outputTagMap: { idMap: {}, entityName: 'outputTagMap', count: 0 },
156
- certificate: { idMap: {}, entityName: 'certificate', count: 0 },
157
- certificateField: { idMap: {}, entityName: 'certificateField', count: 0 },
158
- commission: { idMap: {}, entityName: 'commission', count: 0 }
159
- }
116
+ syncState.syncMap = createSyncMap()
117
+ syncState.syncMap.provenTx.idMap = { 1: 2 }
118
+ syncState.syncMap.provenTx.count = 1
119
+ syncState.syncMap.transaction.idMap = { 3: 4 }
120
+ syncState.syncMap.transaction.count = 1
121
+
122
+ const conflictingSyncMap = createSyncMap()
123
+ conflictingSyncMap.provenTx.idMap = { 1: 3 }
124
+ conflictingSyncMap.provenTx.count = 1
125
+ conflictingSyncMap.transaction.idMap = { 3: 4 }
126
+ conflictingSyncMap.transaction.count = 1
160
127
 
161
128
  expect(() => syncState.mergeSyncMap(conflictingSyncMap)).toThrow()
162
129
  })
@@ -164,7 +131,7 @@ describe('SyncState class method tests', () => {
164
131
  // Test: Process a sync chunk correctly and update storage
165
132
  test('4_processes_sync_chunk_correctly', async () => {
166
133
  const ctx = ctxs[0]
167
- const syncState = new SyncState()
134
+ const syncState = new EntitySyncState()
168
135
 
169
136
  // Assign a unique value to refNum and valid userId
170
137
  syncState.userId = 1
@@ -218,13 +185,13 @@ describe('SyncState class method tests', () => {
218
185
 
219
186
  // Test: equals method always returns false
220
187
  test('6_equals_method_always_returns_false', () => {
221
- const syncState = new SyncState()
222
- expect(syncState.equals({} as table.SyncState)).toBe(false)
188
+ const syncState = new EntitySyncState()
189
+ expect(syncState.equals({} as TableSyncState)).toBe(false)
223
190
  })
224
191
 
225
192
  // Test: Getters and setters for SyncState properties
226
193
  test('7_getters_and_setters', () => {
227
- const syncState = new SyncState()
194
+ const syncState = new EntitySyncState()
228
195
 
229
196
  // Test created_at and updated_at
230
197
  const now = new Date()
@@ -269,7 +236,7 @@ describe('SyncState class method tests', () => {
269
236
 
270
237
  // Test: Derived properties apiErrorLocal, apiErrorOther, and apiSyncMap
271
238
  test('8_derived_properties', () => {
272
- const syncState = new SyncState()
239
+ const syncState = new EntitySyncState()
273
240
 
274
241
  // Test apiErrorLocal and apiErrorOther
275
242
  syncState.errorLocal = {
@@ -285,35 +252,26 @@ describe('SyncState class method tests', () => {
285
252
  expect(syncState.apiErrorLocal).toBe(JSON.stringify(syncState.errorLocal))
286
253
  expect(syncState.apiErrorOther).toBe(JSON.stringify(syncState.errorOther))
287
254
 
288
- // Test apiSyncMap with inline syncMap definition
289
- const syncMap: entity.SyncMap = {
290
- provenTx: { idMap: { 1: 2 }, entityName: 'provenTx', count: 1 },
291
- outputBasket: { idMap: {}, entityName: 'outputBasket', count: 0 },
292
- transaction: { idMap: { 3: 4 }, entityName: 'transaction', count: 1 },
293
- provenTxReq: { idMap: {}, entityName: 'provenTxReq', count: 0 },
294
- txLabel: { idMap: {}, entityName: 'txLabel', count: 0 },
295
- txLabelMap: { idMap: {}, entityName: 'txLabelMap', count: 0 },
296
- output: { idMap: {}, entityName: 'output', count: 0 },
297
- outputTag: { idMap: {}, entityName: 'outputTag', count: 0 },
298
- outputTagMap: { idMap: {}, entityName: 'outputTagMap', count: 0 },
299
- certificate: { idMap: {}, entityName: 'certificate', count: 0 },
300
- certificateField: { idMap: {}, entityName: 'certificateField', count: 0 },
301
- commission: { idMap: {}, entityName: 'commission', count: 0 }
302
- }
255
+ const syncMap = createSyncMap()
256
+ syncMap.provenTx.idMap = { 1: 2 }
257
+ syncMap.provenTx.count = 1
258
+ syncMap.transaction.idMap = { 3: 4 }
259
+ syncMap.transaction.count = 1
260
+
303
261
  syncState.syncMap = syncMap
304
262
  expect(syncState.apiSyncMap).toBe(JSON.stringify(syncMap))
305
263
  })
306
264
 
307
265
  // Test: id, entityName, and entityTable getters
308
266
  test('9_id_entityName_entityTable', () => {
309
- const syncState = new SyncState()
267
+ const syncState = new EntitySyncState()
310
268
 
311
269
  // Test id getter and setter
312
270
  syncState.id = 42
313
271
  expect(syncState.id).toBe(42)
314
272
 
315
273
  // Test entityName
316
- expect(syncState.entityName).toBe('table.SyncState')
274
+ expect(syncState.entityName).toBe('syncState')
317
275
 
318
276
  // Test entityTable
319
277
  expect(syncState.entityTable).toBe('sync_states')
@@ -321,23 +279,10 @@ describe('SyncState class method tests', () => {
321
279
 
322
280
  // Test: mergeNew method (does not perform any operations)
323
281
  test('10_mergeNew_does_nothing', async () => {
324
- const syncState = new SyncState()
325
- const mockStorage: entity.EntityStorage = {} as entity.EntityStorage
326
-
327
- const syncMap: entity.SyncMap = {
328
- provenTx: { idMap: {}, entityName: 'provenTx', count: 0 },
329
- outputBasket: { idMap: {}, entityName: 'outputBasket', count: 0 },
330
- transaction: { idMap: {}, entityName: 'transaction', count: 0 },
331
- provenTxReq: { idMap: {}, entityName: 'provenTxReq', count: 0 },
332
- txLabel: { idMap: {}, entityName: 'txLabel', count: 0 },
333
- txLabelMap: { idMap: {}, entityName: 'txLabelMap', count: 0 },
334
- output: { idMap: {}, entityName: 'output', count: 0 },
335
- outputTag: { idMap: {}, entityName: 'outputTag', count: 0 },
336
- outputTagMap: { idMap: {}, entityName: 'outputTagMap', count: 0 },
337
- certificate: { idMap: {}, entityName: 'certificate', count: 0 },
338
- certificateField: { idMap: {}, entityName: 'certificateField', count: 0 },
339
- commission: { idMap: {}, entityName: 'commission', count: 0 }
340
- }
282
+ const syncState = new EntitySyncState()
283
+ const mockStorage: EntityStorage = {} as EntityStorage
284
+
285
+ const syncMap = createSyncMap()
341
286
 
342
287
  await expect(
343
288
  syncState.mergeNew(mockStorage, 1, syncMap, undefined)
@@ -346,28 +291,15 @@ describe('SyncState class method tests', () => {
346
291
 
347
292
  // Test: mergeExisting method (always returns false)
348
293
  test('11_mergeExisting_always_returns_false', async () => {
349
- const syncState = new SyncState()
350
- const mockStorage: entity.EntityStorage = {} as entity.EntityStorage
351
-
352
- const syncMap: entity.SyncMap = {
353
- provenTx: { idMap: {}, entityName: 'provenTx', count: 0 },
354
- outputBasket: { idMap: {}, entityName: 'outputBasket', count: 0 },
355
- transaction: { idMap: {}, entityName: 'transaction', count: 0 },
356
- provenTxReq: { idMap: {}, entityName: 'provenTxReq', count: 0 },
357
- txLabel: { idMap: {}, entityName: 'txLabel', count: 0 },
358
- txLabelMap: { idMap: {}, entityName: 'txLabelMap', count: 0 },
359
- output: { idMap: {}, entityName: 'output', count: 0 },
360
- outputTag: { idMap: {}, entityName: 'outputTag', count: 0 },
361
- outputTagMap: { idMap: {}, entityName: 'outputTagMap', count: 0 },
362
- certificate: { idMap: {}, entityName: 'certificate', count: 0 },
363
- certificateField: { idMap: {}, entityName: 'certificateField', count: 0 },
364
- commission: { idMap: {}, entityName: 'commission', count: 0 }
365
- }
294
+ const syncState = new EntitySyncState()
295
+ const mockStorage: EntityStorage = {} as EntityStorage
296
+
297
+ const syncMap = createSyncMap()
366
298
 
367
299
  const result = await syncState.mergeExisting(
368
300
  mockStorage,
369
301
  new Date(),
370
- {} as table.SyncState,
302
+ {} as TableSyncState,
371
303
  syncMap,
372
304
  undefined
373
305
  )