@mojaloop/central-ledger 19.14.0 → 20.1.0

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 (394) hide show
  1. package/.grype.yaml +3 -0
  2. package/.license-scanner.json +16 -0
  3. package/.ncurc.yaml +19 -13
  4. package/.nvmrc +1 -1
  5. package/.nycrc.yml +14 -2
  6. package/CHANGELOG.md +51 -0
  7. package/Dockerfile +13 -10
  8. package/README.md +39 -89
  9. package/audit-ci.jsonc +1 -1
  10. package/config/default.json +60 -3
  11. package/config/deprecated.default-settlement.json +160 -0
  12. package/docker/ml-api-adapter/default.json +28 -0
  13. package/docker-compose.yml +6 -0
  14. package/nodemon.json +6 -0
  15. package/package.json +128 -64
  16. package/{sbom-v19.13.2.csv → sbom-v20.0.0.csv} +886 -736
  17. package/scripts/_wait4_all.js +5 -5
  18. package/scripts/transferSettlementTemp/interchangeFeeCalculation.js +51 -0
  19. package/src/api/index.ts +30 -0
  20. package/src/api/interface/swagger.json +2249 -2054
  21. package/src/api/participants/routes.js +1 -1
  22. package/src/api/root/handler.int.ts +55 -0
  23. package/src/api/routes.js +7 -6
  24. package/src/api/server.ts +27 -0
  25. package/src/api/server.unit.ts +16 -0
  26. package/src/api/settlementModels/routes.js +4 -4
  27. package/src/domain/participant/index.d.ts +47 -0
  28. package/src/domain/participant/index.int.ts +724 -0
  29. package/src/domain/participant/index.js +4 -5
  30. package/src/domain/position/fx-prepare.js +1 -1
  31. package/src/domain/position/fx-timeout-reserved.js +6 -0
  32. package/src/domain/position/prepare.js +1 -1
  33. package/src/handlers/admin/handler.js +1 -1
  34. package/src/handlers/index.js +30 -0
  35. package/src/handlers/positions/handler.js +0 -2
  36. package/src/handlers/positions/handlerBatch.js +5 -5
  37. package/src/handlers/register.js +44 -29
  38. package/src/handlers/timeouts/handler.js +1 -4
  39. package/src/handlers/transfers/fx-abort.int.ts +209 -0
  40. package/src/handlers/transfers/fx-handlers.int.ts +275 -0
  41. package/src/handlers/transfers/fx-timeout.int.ts +284 -0
  42. package/src/handlers/transfers/handler.js +1 -3
  43. package/src/handlers/transfers/handlers.int.ts +538 -0
  44. package/src/handlers/transfers/prepare.int.ts +1283 -0
  45. package/src/handlers/transfers/prepare.js +2 -2
  46. package/src/knexfile.js +19 -0
  47. package/src/lib/cache.js +1 -1
  48. package/src/lib/config/index.ts +60 -0
  49. package/src/lib/config/resolver.ts +231 -0
  50. package/src/lib/config/resolver.unit.ts +72 -0
  51. package/src/lib/config/types.ts +372 -0
  52. package/src/lib/config/util.ts +523 -0
  53. package/src/lib/config/util.unit.ts +825 -0
  54. package/src/lib/migrator.js +3 -3
  55. package/src/lib/proxyCache.js +3 -3
  56. package/{migrations → src/migrations}/100100_event.js +1 -1
  57. package/{migrations → src/migrations}/110100_contactType.js +1 -1
  58. package/{migrations → src/migrations}/110200_currency.js +1 -1
  59. package/{migrations → src/migrations}/110201_currency-scale.js +1 -1
  60. package/{migrations → src/migrations}/110300_endpointType.js +1 -1
  61. package/{migrations → src/migrations}/110400_ledgerEntryType.js +1 -1
  62. package/{migrations → src/migrations}/110450_ledgerAccountType.js +1 -1
  63. package/{migrations → src/migrations}/110500_participantLimitType.js +1 -1
  64. package/{migrations → src/migrations}/110600_transferParticipantRoleType.js +1 -1
  65. package/{migrations → src/migrations}/110700_transferState.js +1 -1
  66. package/{migrations → src/migrations}/110900_settlementState.js +1 -1
  67. package/{migrations → src/migrations}/112000_bulkTransferState.js +1 -1
  68. package/{migrations → src/migrations}/112100_bulkProcessingState.js +1 -1
  69. package/{migrations → src/migrations}/200100_participant.js +1 -1
  70. package/{migrations → src/migrations}/200200_participantContact.js +1 -1
  71. package/{migrations → src/migrations}/200300_participantEndpoint.js +1 -1
  72. package/{migrations → src/migrations}/200400_participantParty.js +1 -1
  73. package/{migrations → src/migrations}/200600_token.js +1 -1
  74. package/{migrations → src/migrations}/200601_token-indexes.js +1 -1
  75. package/{migrations → src/migrations}/300100_transferDuplicateCheck.js +2 -2
  76. package/{migrations → src/migrations}/300150_bulkTransferDuplicateCheck.js +2 -2
  77. package/{migrations → src/migrations}/300200_transfer.js +2 -2
  78. package/{migrations → src/migrations}/300202_transfer-decimal184.js +1 -1
  79. package/{migrations → src/migrations}/300250_bulkTransfer.js +2 -3
  80. package/{migrations → src/migrations}/300275_bulkTransferAssociation.js +2 -3
  81. package/{migrations → src/migrations}/300300_ilpPacket.js +1 -1
  82. package/{migrations → src/migrations}/300400_transferStateChange.js +1 -1
  83. package/{migrations → src/migrations}/300450_bulkTransferStateChange.js +1 -1
  84. package/{migrations → src/migrations}/300500_segment.js +1 -1
  85. package/{migrations → src/migrations}/310100_participantCurrency.js +1 -1
  86. package/{migrations → src/migrations}/310200_transferParticipant.js +1 -1
  87. package/{migrations → src/migrations}/310202_transferParticipant-decimal184.js +1 -1
  88. package/{migrations → src/migrations}/310204_transferParticipant-participantId.js +2 -2
  89. package/{migrations → src/migrations}/310300_participantPosition.js +1 -1
  90. package/{migrations → src/migrations}/310302_participantPosition-decimal184.js +1 -1
  91. package/{migrations → src/migrations}/310400_participantPositionChange.js +1 -1
  92. package/{migrations → src/migrations}/310402_participantPositionChange-decimal184.js +1 -1
  93. package/{migrations → src/migrations}/310403_participantPositionChange-participantCurrencyId.js +2 -2
  94. package/{migrations → src/migrations}/310404_participantPositionChange-change.js +2 -2
  95. package/{migrations → src/migrations}/310500_participantLimit.js +1 -1
  96. package/{migrations → src/migrations}/310502_participantLimit-decimal184.js +1 -1
  97. package/{migrations → src/migrations}/400100_settlementWindow.js +1 -1
  98. package/{migrations → src/migrations}/400200_settlement.js +1 -1
  99. package/{migrations → src/migrations}/400300_settlementSettlementWindow.js +1 -1
  100. package/{migrations → src/migrations}/400301_settlementSettlementWindow-indexes.js +0 -1
  101. package/{migrations → src/migrations}/400400_settlementWindowStateChange.js +1 -1
  102. package/{migrations → src/migrations}/400500_settlementTransferParticipant.js +1 -1
  103. package/{migrations → src/migrations}/400502_settlementTransferParticipant-decimal184.js +1 -1
  104. package/{migrations → src/migrations}/400600_settlementParticipantCurrency.js +1 -1
  105. package/{migrations → src/migrations}/400602_settlementParticipantCurrency-decimal184.js +1 -1
  106. package/{migrations → src/migrations}/400700_settlementParticipantCurrencyStateChange.js +1 -1
  107. package/{migrations → src/migrations}/400800_settlementStateChange.js +1 -1
  108. package/{migrations → src/migrations}/400900_settlementWindowContent.js +1 -1
  109. package/{migrations → src/migrations}/401000_settlementWindowContentStateChange.js +1 -1
  110. package/{migrations → src/migrations}/401001_settlementWindowContentStateChange-indexes.js +6 -6
  111. package/{migrations → src/migrations}/401200_settlementContentAggregation.js +1 -1
  112. package/{migrations → src/migrations}/401300_settlementModel.js +1 -1
  113. package/{migrations → src/migrations}/410100_transferFulfilmentDuplicateCheck.js +1 -1
  114. package/{migrations → src/migrations}/410102_transferFulfilmentDuplicateCheck-dropForeignTransferId.js +1 -1
  115. package/{migrations → src/migrations}/410103_transferFulfilmentDuplicateCheck-hashNullable.js +1 -1
  116. package/{migrations → src/migrations}/410200_transferFulfilment.js +1 -1
  117. package/{migrations → src/migrations}/410202_transferFulfilment-ilpFulfilment.js +1 -1
  118. package/{migrations → src/migrations}/410203_transferFulfilment-foreignTransferFulfilmentId.js +1 -1
  119. package/{migrations → src/migrations}/410240_bulkTransferFulfilmentDuplicateCheck.js +1 -1
  120. package/{migrations → src/migrations}/410250_bulkTransferFulfilment.js +1 -1
  121. package/{migrations → src/migrations}/410300_transferExtension.js +1 -1
  122. package/{migrations → src/migrations}/410302_transferExtension-transferErrorId.js +1 -1
  123. package/{migrations → src/migrations}/410350_bulkTransferExtension.js +1 -1
  124. package/{migrations → src/migrations}/410400_transferTimeout.js +1 -1
  125. package/{migrations → src/migrations}/410450_transferErrorDuplicateCheck.js +1 -1
  126. package/{migrations → src/migrations}/410500_transferError.js +1 -1
  127. package/{migrations → src/migrations}/410502_transferError-foreignTransferErrorDuplicateCheckId.js +1 -1
  128. package/{migrations → src/migrations}/410550_bulkTransferError.js +1 -1
  129. package/{migrations → src/migrations}/410600_expiringTransfer.js +1 -1
  130. package/{migrations → src/migrations}/500401_quote-hotfix-2719.js +8 -8
  131. package/{migrations → src/migrations}/500501_feature-fixSubIdRef.js +12 -12
  132. package/{migrations → src/migrations}/500601_party-2480.js +3 -3
  133. package/{migrations → src/migrations}/501001_quoteExtension-quote-service-174.js +1 -2
  134. package/{migrations → src/migrations}/501002_quoteExtension-2522.js +3 -3
  135. package/{migrations → src/migrations}/600010_fxTransferType.js +1 -1
  136. package/{migrations → src/migrations}/600012_fxParticipantCurrencyType.js +1 -1
  137. package/{migrations → src/migrations}/600100_fxTransferDuplicateCheck.js +2 -2
  138. package/{migrations → src/migrations}/600110_fxTransferErrorDuplicateCheck.js.js +1 -1
  139. package/{migrations → src/migrations}/600200_fxTransfer.js +2 -2
  140. package/{migrations → src/migrations}/600400_fxTransferStateChange.js +1 -1
  141. package/{migrations → src/migrations}/600501_fxWatchList.js +2 -2
  142. package/{migrations → src/migrations}/600600_fxTransferFulfilmentDuplicateCheck.js +1 -1
  143. package/{migrations → src/migrations}/600700_fxTransferFulfilment.js +1 -1
  144. package/{migrations → src/migrations}/600800_fxTransferExtension.js +1 -1
  145. package/{migrations → src/migrations}/601400_fxTransferTimeout.js +1 -1
  146. package/{migrations → src/migrations}/601500_fxTransferError.js +1 -1
  147. package/{migrations → src/migrations}/610200_fxTransferParticipant.js +1 -1
  148. package/{migrations → src/migrations}/610202_fxTransferParticipant-participantId.js +2 -2
  149. package/{migrations → src/migrations}/610403_participantPositionChange-fxTransfer.js +1 -1
  150. package/{migrations → src/migrations}/800100_quotePartyView.js +1 -1
  151. package/{migrations → src/migrations}/800101_feature-fixSubIdRef.js +1 -1
  152. package/{migrations → src/migrations}/800200_quoteView.js +1 -1
  153. package/{migrations → src/migrations}/800300_quoteResponseView.js +1 -1
  154. package/{migrations → src/migrations}/900100_foreign-keys.js +18 -18
  155. package/{migrations → src/migrations}/900101_foreign-keys.js +6 -6
  156. package/{migrations → src/migrations}/910100_feature904DDL.js +7 -7
  157. package/{migrations → src/migrations}/910101_feature904DataMigration.js +1 -1
  158. package/{migrations → src/migrations}/910102_feature949DataMigration.js +1 -1
  159. package/{migrations → src/migrations}/910103_feature1093SettlementByCurrency.js +3 -3
  160. package/{migrations → src/migrations}/940101_quotePartyIdInfoExtension-2522.js +25 -25
  161. package/{migrations → src/migrations}/950101_transferParticipantStateChange.js +2 -2
  162. package/{migrations → src/migrations}/950102_settlementModel-adjustPosition.js +2 -2
  163. package/{migrations → src/migrations}/950103_dropTransferParticipantStateChange.js +3 -3
  164. package/{migrations → src/migrations}/950104_settlementModel-settlementAccountTypeId.js +3 -3
  165. package/src/migrations/950107_settlementWindowContent_foreign_settlementModel.js +63 -0
  166. package/{migrations → src/migrations}/950108_participantProxy.js +1 -2
  167. package/{migrations → src/migrations}/950120_fxQuoteConversionTerms_sourceAmount_nullable.js +1 -1
  168. package/{migrations → src/migrations}/960100_create_externalParticipant.js +2 -2
  169. package/{migrations → src/migrations}/960110_alter_transferParticipant__addFiled_externalParticipantId.js +2 -2
  170. package/{migrations → src/migrations}/961001_transferForwarded.js +1 -1
  171. package/{migrations → src/migrations}/961002_fxTransferForwarded.js +1 -1
  172. package/src/models/participant/externalParticipant.int.ts +85 -0
  173. package/src/models/participant/facade.js +4 -2
  174. package/src/models/participant/participantCurrencyCached.js +1 -1
  175. package/src/models/position/facade.js +8 -2
  176. package/src/models/transfer/facade.int.ts +139 -0
  177. package/src/models/transfer/facade.js +8 -3
  178. package/src/models/transfer/transferDuplicateCheck.js +2 -2
  179. package/src/models/transfer/transferError.int.ts +112 -0
  180. package/src/models/transfer/transferExtension.int.ts +137 -0
  181. package/src/models/transfer/transferStateChange.int.ts +117 -0
  182. package/{seeds → src/seeds}/participant.js +1 -1
  183. package/{seeds → src/seeds}/settlementInterchange.js +1 -0
  184. package/src/settlement/api/handlerRoutes.js +71 -0
  185. package/src/settlement/api/handlers/health.js +10 -0
  186. package/src/settlement/api/handlers/index.js +57 -0
  187. package/src/settlement/api/handlers/settlementWindows/{id}.js +103 -0
  188. package/src/settlement/api/handlers/settlementWindows.js +77 -0
  189. package/src/settlement/api/handlers/settlements/{id}.js +133 -0
  190. package/src/settlement/api/handlers/settlements/{sid}/participants/{pid}/accounts/{aid}.js +127 -0
  191. package/src/settlement/api/handlers/settlements/{sid}/participants/{pid}.js +127 -0
  192. package/src/settlement/api/handlers/settlements.js +114 -0
  193. package/src/settlement/api/openapiRouting.js +87 -0
  194. package/src/settlement/api/routes.js +176 -0
  195. package/src/settlement/domain/rules/index.js +46 -0
  196. package/src/settlement/domain/settlement/index.js +405 -0
  197. package/src/settlement/domain/settlementWindow/index.js +117 -0
  198. package/src/settlement/domain/transactions/index.js +83 -0
  199. package/src/settlement/domain/transferSettlement/index.js +57 -0
  200. package/src/settlement/handlers/deferredSettlement/handler.js +180 -0
  201. package/src/settlement/handlers/grossSettlement/handler.js +180 -0
  202. package/src/settlement/handlers/index.js +101 -0
  203. package/src/settlement/handlers/register.js +92 -0
  204. package/src/settlement/handlers/rules/handler.js +164 -0
  205. package/src/settlement/interface/swagger-handler.json +34 -0
  206. package/src/settlement/interface/swagger.json +1560 -0
  207. package/src/settlement/lib/db.js +32 -0
  208. package/src/settlement/lib/kafka/index.js +41 -0
  209. package/src/settlement/lib/kafka/producer.js +142 -0
  210. package/src/settlement/lib/scriptEngine.js +99 -0
  211. package/src/settlement/lib/scriptsLoader.js +175 -0
  212. package/src/settlement/lib/utility.js +243 -0
  213. package/src/settlement/models/ilpPackets/ilpPacket.js +42 -0
  214. package/src/settlement/models/lib/enums.js +192 -0
  215. package/src/settlement/models/misc/migrationLock.js +53 -0
  216. package/src/settlement/models/settlement/facade.js +1652 -0
  217. package/src/settlement/models/settlement/index.js +55 -0
  218. package/src/settlement/models/settlement/participantCurrency.js +48 -0
  219. package/src/settlement/models/settlement/settlement.js +49 -0
  220. package/src/settlement/models/settlement/settlementModel.js +44 -0
  221. package/src/settlement/models/settlement/settlementParticipantCurrency.js +61 -0
  222. package/src/settlement/models/settlement/settlementStateChange.js +44 -0
  223. package/src/settlement/models/settlement/settlementTransferParticipant.js +46 -0
  224. package/src/settlement/models/settlementWindow/facade.js +345 -0
  225. package/src/settlement/models/settlementWindow/index.js +47 -0
  226. package/src/settlement/models/settlementWindow/settlementWindowStateChange.js +55 -0
  227. package/src/settlement/models/settlementWindowContent/facade.js +79 -0
  228. package/src/settlement/models/settlementWindowContent/index.js +40 -0
  229. package/src/settlement/models/settlementWindowContent/settlementWindowContentStateChange.js +53 -0
  230. package/src/settlement/models/transferSettlement/facade.js +363 -0
  231. package/src/settlement/models/transferSettlement/index.js +42 -0
  232. package/src/settlement/shared/logger/index.js +7 -0
  233. package/src/settlement/shared/plugins.js +88 -0
  234. package/src/settlement/shared/setup.js +224 -0
  235. package/src/settlement/utils/truthyProperty.js +37 -0
  236. package/src/shared/legacyUtilShim.js +20 -0
  237. package/src/shared/plugins.js +3 -3
  238. package/src/shared/results.ts +22 -0
  239. package/src/shared/results.unit.ts +38 -0
  240. package/src/shared/setup.js +14 -1
  241. package/src/testing/api-helpers.ts +1222 -0
  242. package/src/testing/exec-async.ts +67 -0
  243. package/src/testing/harness.snapshot.sql +3895 -0
  244. package/src/testing/harness.test.ts +15 -0
  245. package/src/testing/harness.ts +1160 -0
  246. package/src/testing/kafka.ts +221 -0
  247. package/src/testing/prng.ts +82 -0
  248. package/src/testing/rdkafka.test.ts +263 -0
  249. package/src/testing/run.ts +559 -0
  250. package/src/testing/snapshot.test.ts +92 -0
  251. package/src/testing/snapshot.ts +549 -0
  252. package/src/testing/tap-stream.ts +164 -0
  253. package/src/testing/types.ts +95 -0
  254. package/src/testing/util.ts +333 -0
  255. package/src/types/central-services-error-handling.d.ts +72 -0
  256. package/src/types/central-services-stream.d.ts +148 -0
  257. package/test-integration.Dockerfile +0 -2
  258. package/test.Dockerfile +0 -2
  259. package/tsconfig.json +40 -0
  260. package/config/knexfile.js +0 -19
  261. package/migrations/950107_settlementWindowContent_foreign_settlementModel.js +0 -63
  262. package/src/api/index.js +0 -16
  263. package/src/lib/config.js +0 -81
  264. /package/{migrations → src/migrations}/110101_contactType-indexes.js +0 -0
  265. /package/{migrations → src/migrations}/110301_endpointType-indexes.js +0 -0
  266. /package/{migrations → src/migrations}/110401_ledgerEntryType-indexes.js +0 -0
  267. /package/{migrations → src/migrations}/110451_ledgerAccountType-indexes.js +0 -0
  268. /package/{migrations → src/migrations}/110501_participantLimitType-indexes.js +0 -0
  269. /package/{migrations → src/migrations}/110601_transferParticipantRoleType-indexes.js +0 -0
  270. /package/{migrations → src/migrations}/110800_settlementWindowState.js +0 -0
  271. /package/{migrations → src/migrations}/111000_amountType.js +0 -0
  272. /package/{migrations → src/migrations}/111001_amountType-indexes.js +0 -0
  273. /package/{migrations → src/migrations}/111100_balanceOfPayments.js +0 -0
  274. /package/{migrations → src/migrations}/111101_balanceOfPayments-indexes.js +0 -0
  275. /package/{migrations → src/migrations}/111200_partyIdentifierType.js +0 -0
  276. /package/{migrations → src/migrations}/111201_partyIdentifierType-indexes.js +0 -0
  277. /package/{migrations → src/migrations}/111300_partyType.js +0 -0
  278. /package/{migrations → src/migrations}/111301_partyType-indexes.js +0 -0
  279. /package/{migrations → src/migrations}/111400_quoteDuplicateCheck.js +0 -0
  280. /package/{migrations → src/migrations}/111500_transactionInitiator.js +0 -0
  281. /package/{migrations → src/migrations}/111501_transactionInitiator-indexes.js +0 -0
  282. /package/{migrations → src/migrations}/111600_transactionInitiatorType.js +0 -0
  283. /package/{migrations → src/migrations}/111601_transactionInitiatorType-indexes.js +0 -0
  284. /package/{migrations → src/migrations}/111700_settlementDelay.js +0 -0
  285. /package/{migrations → src/migrations}/111701_settlementDelay-indexes.js +0 -0
  286. /package/{migrations → src/migrations}/111800_settlementInterchange.js +0 -0
  287. /package/{migrations → src/migrations}/111801_settlementInterchange-indexes.js +0 -0
  288. /package/{migrations → src/migrations}/111900_settlementGranularity.js +0 -0
  289. /package/{migrations → src/migrations}/111901_settlementGranularity-indexes.js +0 -0
  290. /package/{migrations → src/migrations}/112101_bulkProcessingState-indexes.js +0 -0
  291. /package/{migrations → src/migrations}/200101_participant-indexes.js +0 -0
  292. /package/{migrations → src/migrations}/200201_participantContact-indexes.js +0 -0
  293. /package/{migrations → src/migrations}/200301_participantEndpoint-indexes.js +0 -0
  294. /package/{migrations → src/migrations}/200401_participantParty-indexes.js +0 -0
  295. /package/{migrations → src/migrations}/300201_transfer-indexes.js +0 -0
  296. /package/{migrations → src/migrations}/300251_bulkTransfer-indexes.js +0 -0
  297. /package/{migrations → src/migrations}/300276_bulkTransferAssociation-indexes.js +0 -0
  298. /package/{migrations → src/migrations}/300401_transferStateChange-indexes.js +0 -0
  299. /package/{migrations → src/migrations}/300451_bulkTransferStateChange-indexes.js +0 -0
  300. /package/{migrations → src/migrations}/300501_segment-indexes.js +0 -0
  301. /package/{migrations → src/migrations}/310101_participantCurrency-indexes.js +0 -0
  302. /package/{migrations → src/migrations}/310201_transferParticipant-indexes.js +0 -0
  303. /package/{migrations → src/migrations}/310203_transferParticipant-indexes.js +0 -0
  304. /package/{migrations → src/migrations}/310301_participantPosition-indexes.js +0 -0
  305. /package/{migrations → src/migrations}/310401_participantPositionChange-indexes.js +0 -0
  306. /package/{migrations → src/migrations}/310405_participantPositionChange-positionChange.js +0 -0
  307. /package/{migrations → src/migrations}/310406_participantPositionChange-positionChange-revert.js +0 -0
  308. /package/{migrations → src/migrations}/310501_participantLimit-indexes.js +0 -0
  309. /package/{migrations → src/migrations}/310503_participantLimit-indexes-composite.js +0 -0
  310. /package/{migrations → src/migrations}/400401_settlmentWindowStateChange-indexes.js +0 -0
  311. /package/{migrations → src/migrations}/400501_settlementTransferParticipant-indexes.js +0 -0
  312. /package/{migrations → src/migrations}/400601_settlementParticipantCurrency-indexes.js +0 -0
  313. /package/{migrations → src/migrations}/400701_settlementParticipantCurrencyStateChange-indexes.js +0 -0
  314. /package/{migrations → src/migrations}/400801_settlementStateChange-indexes.js +0 -0
  315. /package/{migrations → src/migrations}/401002_settlementWindowContent-indexes.js +0 -0
  316. /package/{migrations → src/migrations}/401201_settlementContentAggregation-indexes.js +0 -0
  317. /package/{migrations → src/migrations}/401301_settlementModel-indexes.js +0 -0
  318. /package/{migrations → src/migrations}/410101_transferFulfilmentDuplicateCheck-indexes.js +0 -0
  319. /package/{migrations → src/migrations}/410201_transferFulfilment-indexes.js +0 -0
  320. /package/{migrations → src/migrations}/410301_transferExtension-indexes.js +0 -0
  321. /package/{migrations → src/migrations}/410351_bulkTransferExtension-indexes.js +0 -0
  322. /package/{migrations → src/migrations}/410401_transferTimeout-indexes.js +0 -0
  323. /package/{migrations → src/migrations}/410501_transferError-indexes.js +0 -0
  324. /package/{migrations → src/migrations}/410551_bulkTransferError-indexes.js +0 -0
  325. /package/{migrations → src/migrations}/410601_expiringTransfer-indexes.js +0 -0
  326. /package/{migrations → src/migrations}/500100_transactionReference.js +0 -0
  327. /package/{migrations → src/migrations}/500101_transactionReference-indexes.js +0 -0
  328. /package/{migrations → src/migrations}/500200_transactionScenario.js +0 -0
  329. /package/{migrations → src/migrations}/500201_transactionScenario-indexes.js +0 -0
  330. /package/{migrations → src/migrations}/500300_transactionSubScenario.js +0 -0
  331. /package/{migrations → src/migrations}/500400_quote.js +0 -0
  332. /package/{migrations → src/migrations}/500500_quoteParty.js +0 -0
  333. /package/{migrations → src/migrations}/500600_party.js +0 -0
  334. /package/{migrations → src/migrations}/500700_quoteResponse.js +0 -0
  335. /package/{migrations → src/migrations}/500800_quoteResponseIlpPacket.js +0 -0
  336. /package/{migrations → src/migrations}/500900_geoCode.js +0 -0
  337. /package/{migrations → src/migrations}/501000_quoteExtension.js +0 -0
  338. /package/{migrations → src/migrations}/501100_quoteResponseDuplicateCheck.js +0 -0
  339. /package/{migrations → src/migrations}/501200_quoteError.js +0 -0
  340. /package/{migrations → src/migrations}/501300_transferRules.js +0 -0
  341. /package/{migrations → src/migrations}/600011_fxTransferType-indexes.js +0 -0
  342. /package/{migrations → src/migrations}/600013_fxParticipantCurrencyType-indexes.js +0 -0
  343. /package/{migrations → src/migrations}/600201_fxTransfer-indexes.js +0 -0
  344. /package/{migrations → src/migrations}/600401_fxTransferStateChange-indexes.js +0 -0
  345. /package/{migrations → src/migrations}/600502_fxWatchList-indexes.js +0 -0
  346. /package/{migrations → src/migrations}/600601_fxTransferFulfilmentDuplicateCheck-indexes.js +0 -0
  347. /package/{migrations → src/migrations}/600701_fxTransferFulfilment-indexes.js +0 -0
  348. /package/{migrations → src/migrations}/601401_fxTransferTimeout-indexes.js +0 -0
  349. /package/{migrations → src/migrations}/601501_fxTransferError-indexes.js +0 -0
  350. /package/{migrations → src/migrations}/610201_fxTransferParticipant-indexes.js +0 -0
  351. /package/{migrations → src/migrations}/910102_hotfix954.js +0 -0
  352. /package/{migrations → src/migrations}/940100_quotePartyIdInfoExtension.js +0 -0
  353. /package/{migrations → src/migrations}/950100_settlementContentAggregation-decimal184.js +0 -0
  354. /package/{migrations → src/migrations}/950106_unique_settlement_model_ledger_account_currency.js +0 -0
  355. /package/{migrations → src/migrations}/950109_fxQuote.js +0 -0
  356. /package/{migrations → src/migrations}/950110_fxQuoteResponse.js +0 -0
  357. /package/{migrations → src/migrations}/950111_fxQuoteError.js +0 -0
  358. /package/{migrations → src/migrations}/950113_fxQuoteDuplicateCheck.js +0 -0
  359. /package/{migrations → src/migrations}/950114_fxQuoteResponseDuplicateCheck.js +0 -0
  360. /package/{migrations → src/migrations}/950115_fxQuoteConversionTerms.js +0 -0
  361. /package/{migrations → src/migrations}/950116_fxQuoteConversionTermsExtension.js +0 -0
  362. /package/{migrations → src/migrations}/950117_fxQuoteResponseConversionTerms.js +0 -0
  363. /package/{migrations → src/migrations}/950118_fxQuoteResponseConversionTermsExtension.js +0 -0
  364. /package/{migrations → src/migrations}/950119_fxCharge.js +0 -0
  365. /package/{migrations → src/migrations}/960111_alter_fxTransferParticipant__addFiled_externalParticipantId.js +0 -0
  366. /package/{migrations → src/migrations}/960112_fxTransfer-indexes2.js +0 -0
  367. /package/{migrations → src/migrations}/960113_fxTransferExtension-indexes.js +0 -0
  368. /package/{migrations → src/migrations}/960114_fxTransferTimeout-indexes2.js +0 -0
  369. /package/{migrations → src/migrations}/961000_participantEndpoint_unique.js +0 -0
  370. /package/{migrations → src/migrations}/migration.template +0 -0
  371. /package/{seeds → src/seeds}/amountType.js +0 -0
  372. /package/{seeds → src/seeds}/balanceOfPayments.js +0 -0
  373. /package/{seeds → src/seeds}/bulkProcessingState.js +0 -0
  374. /package/{seeds → src/seeds}/bulkTransferState.js +0 -0
  375. /package/{seeds → src/seeds}/currency.js +0 -0
  376. /package/{seeds → src/seeds}/endpointType.js +0 -0
  377. /package/{seeds → src/seeds}/fxParticipantCurrencyType.js +0 -0
  378. /package/{seeds → src/seeds}/fxTransferType.js +0 -0
  379. /package/{seeds → src/seeds}/ledgerAccountType.js +0 -0
  380. /package/{seeds → src/seeds}/ledgerEntryType.js +0 -0
  381. /package/{seeds → src/seeds}/participantLimitType.js +0 -0
  382. /package/{seeds → src/seeds}/partyIdentifierType.js +0 -0
  383. /package/{seeds → src/seeds}/partyType.js +0 -0
  384. /package/{seeds → src/seeds}/settlementDelay.js +0 -0
  385. /package/{seeds → src/seeds}/settlementGranularity.js +0 -0
  386. /package/{seeds → src/seeds}/settlementState.js +0 -0
  387. /package/{seeds → src/seeds}/settlementWindow1State.js +0 -0
  388. /package/{seeds → src/seeds}/settlementWindow2Open.js +0 -0
  389. /package/{seeds → src/seeds}/transactionInitiator.js +0 -0
  390. /package/{seeds → src/seeds}/transactionInitiatorType.js +0 -0
  391. /package/{seeds → src/seeds}/transactionScenario.js +0 -0
  392. /package/{seeds → src/seeds}/transferParticipantRoleType.js +0 -0
  393. /package/{seeds → src/seeds}/transferState.js +0 -0
  394. /package/{seeds → src/seeds}/z1000_settlementModel-deprecated.js- +0 -0
@@ -0,0 +1,95 @@
1
+ /*****
2
+ License
3
+ --------------
4
+ Copyright © 2020-2026 Mojaloop Foundation
5
+ The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
10
+
11
+ Contributors
12
+ --------------
13
+ This is the official list of the Mojaloop project contributors for this file.
14
+ Names of the original copyright holders (individuals or organizations)
15
+ should be listed with a '*' in the first column. People who have
16
+ contributed from an organization can be listed under the organization
17
+ that actually holds the copyright for their contributions (see the
18
+ Mojaloop Foundation for an example). Those individuals should have
19
+ their names indented and be marked with a '-'. Email address can be added
20
+ optionally within square brackets <email>.
21
+
22
+ * TigerBeetle
23
+ - Lewis Daly <lewis@tigerbeetle.com>
24
+ --------------
25
+
26
+ ******/
27
+
28
+ export type TagTask = 'TEST_UNIT' | 'TEST_COVERAGE' | 'TEST_FUNCTIONAL' | 'TEST_INTEGRATION'
29
+
30
+ export type RunTask = {
31
+ tag: 'TEST_UNIT',
32
+ type: 'TAPE' | 'NATIVE' | 'BOTH',
33
+ output: 'DEFAULT' | 'XUNIT',
34
+ /* If set, will write the output to this file. */
35
+ outputPath?: string
36
+ } | {
37
+ tag: 'TEST_COVERAGE',
38
+ type: 'TAPE' | 'NATIVE' | 'BOTH',
39
+ onlyReport: boolean
40
+ } | {
41
+ tag: 'TEST_INTEGRATION',
42
+ }
43
+
44
+ export type RunTaskUnit = Extract<RunTask, { tag: 'TEST_UNIT' }>
45
+ export type RunTaskCoverage = Extract<RunTask, { tag: 'TEST_COVERAGE' }>
46
+ export type RunTaskIntegration = Extract<RunTask, { tag: 'TEST_INTEGRATION' }>
47
+
48
+ export type ResultTest = {
49
+ output: string,
50
+
51
+ /**
52
+ * `null` if the process exited early.
53
+ */
54
+ exitCode: number | null
55
+ }
56
+
57
+ /**
58
+ * Parsed TAP test result
59
+ */
60
+ export interface TapTest {
61
+ /** Test number in the sequence. */
62
+ number: number
63
+ /** Whether the test passed. */
64
+ ok: boolean
65
+ /** Test description. */
66
+ description: string
67
+ /** Directive. */
68
+ directive?: string
69
+ }
70
+
71
+ /**
72
+ * Parsed TAP stream
73
+ */
74
+ export interface ParsedTap {
75
+ /** TAP version. */
76
+ version?: number
77
+ /** Test plan (1..N). */
78
+ plan: { start: number; end: number } | null
79
+ /** Individual test results. */
80
+ tests: TapTest[]
81
+ /** Whether all tests passed. */
82
+ ok: boolean
83
+ /** Total test count. */
84
+ total: number
85
+ /** Number of passing tests. */
86
+ pass: number
87
+ /** Number of failing tests. */
88
+ fail: number
89
+ /** Number of skipped tests. */
90
+ skip: number
91
+ /** Number of not implemented tests. */
92
+ todo: number
93
+ }
94
+
95
+
@@ -0,0 +1,333 @@
1
+
2
+ import assert from 'node:assert'
3
+ import { spawn } from 'node:child_process'
4
+ import fs from 'node:fs'
5
+ import path from 'node:path'
6
+ import { createServer } from 'node:net';
7
+ import { Request, ReqRefDefaults } from '@hapi/hapi';
8
+ import { Snapshot } from './snapshot';
9
+
10
+ export const PROJECT_ROOT = path.resolve(__dirname, '../..')
11
+
12
+ export const TAP_XUNIT_BIN = path.join(PROJECT_ROOT, 'node_modules/.bin/tap-xunit')
13
+ /**
14
+ * @function enumeratePaths
15
+ * @description Iterate through a nested object and return the paths as a list of `|` delimited path
16
+ * strings.
17
+ * @example
18
+ *
19
+ * enumeratePaths({a:{b:{c: 123}}}) => ['a', 'a|b', 'a|b|c']
20
+ */
21
+ export function enumeratePaths(input: any): Array<string> {
22
+ const paths: Array<string> = []
23
+ const _enumerateNode = (input: any, path: string) => {
24
+ if (input === null || input === undefined) {
25
+ paths.push(path.replace(/\|$/, ''))
26
+ return
27
+ }
28
+ if (typeof input === 'string'
29
+ || typeof input === 'number'
30
+ || typeof input === 'boolean'
31
+ || typeof input === 'bigint'
32
+ ) {
33
+ paths.push(path.replace(/\|$/, ''))
34
+ return
35
+ }
36
+
37
+ assert(typeof input === 'object')
38
+
39
+ for (const leaf of Object.keys(input)) {
40
+ const node = input[leaf]
41
+ paths.push(path.replace(/\|$/, ''))
42
+ _enumerateNode(node, `${path}${leaf}|`)
43
+ }
44
+ return []
45
+ }
46
+
47
+ _enumerateNode(input, '')
48
+
49
+ // Deduplicate the intermediate paths.
50
+ return Object.keys(paths.reduce((acc: Record<string, true>, curr) => {
51
+ if (curr === '') return acc
52
+ acc[curr] = true
53
+ return acc
54
+ }, {}))
55
+ }
56
+
57
+ /**
58
+ * @function deleteAtPath
59
+ * @description Delete an element from a complex object. Replaces the object in place.
60
+ * @param path: `|` delimited path string
61
+ */
62
+ export function deleteAtPath(input: any, path: string): void {
63
+ const pathComponents = path.split('|')
64
+ assert(pathComponents.length > 0)
65
+ for (let pathComponent of pathComponents) {
66
+ if (pathComponent === pathComponents.at(-1)) {
67
+ delete input[pathComponent]
68
+ return
69
+ }
70
+ input = input[pathComponent]
71
+ }
72
+ }
73
+
74
+ /**
75
+ * @function replaceAtPath
76
+ * @description Replace an element with a new value from a complex object. Replaces the object in
77
+ * place.
78
+ * @param path: `|` delimited path string
79
+ */
80
+ export function replaceAtPath(input: any, path: string, newValue: any): void {
81
+ const pathComponents = path.split('|')
82
+ assert(pathComponents.length > 0)
83
+ for (let pathComponent of pathComponents) {
84
+ if (pathComponent === pathComponents.at(-1)) {
85
+ input[pathComponent] = newValue
86
+ return
87
+ }
88
+ input = input[pathComponent]
89
+ }
90
+ }
91
+
92
+ /**
93
+ * @function findFiles
94
+ * @description Find all files matching a glob pattern.
95
+ */
96
+ export function findFiles(baseDir: string, pattern: string): string[] {
97
+ const results: string[] = []
98
+
99
+ // Convert glob pattern to regex.
100
+ const regexPattern = pattern
101
+ .replaceAll('.', String.raw`\.`)
102
+ .replaceAll('**', '{{DOUBLESTAR}}')
103
+ .replaceAll('*', String.raw`[^/]*`)
104
+ .replaceAll('{{DOUBLESTAR}}', '.*')
105
+
106
+ const regex = new RegExp(`^${regexPattern}$`)
107
+
108
+ function walkDir(dir: string, relativePath: string = '') {
109
+ try {
110
+ const entries = fs.readdirSync(dir, { withFileTypes: true })
111
+
112
+ for (const entry of entries) {
113
+ const fullPath = path.join(dir, entry.name)
114
+ const relPath = relativePath ? `${relativePath}/${entry.name}` : entry.name
115
+
116
+ if (entry.isDirectory()) {
117
+ if (entry.name !== 'node_modules' && entry.name !== '.git') {
118
+ walkDir(fullPath, relPath)
119
+ }
120
+ } else if (entry.isFile()) {
121
+ if (regex.test(relPath)) {
122
+ results.push(relPath)
123
+ }
124
+ }
125
+ }
126
+ } catch (err: any) {
127
+ // Ignore permission errors.
128
+ console.error('findFiles() - ignoring err', err.message)
129
+ }
130
+ }
131
+
132
+ walkDir(baseDir)
133
+ return results
134
+ }
135
+
136
+ /**
137
+ * @function convertToXunit
138
+ * @description Convert TAP output to xunit XML format.
139
+ */
140
+ export async function convertToXunit(output: string, outputFile: string): Promise<void> {
141
+ return new Promise((resolve, reject) => {
142
+ const proc = spawn(TAP_XUNIT_BIN, [], {
143
+ cwd: PROJECT_ROOT,
144
+ stdio: ['pipe', 'pipe', 'pipe']
145
+ })
146
+
147
+ let xml = ''
148
+ let stderr = ''
149
+
150
+ proc.stdout.on('data', (data: Buffer) => {
151
+ xml += data.toString()
152
+ })
153
+
154
+ proc.stderr.on('data', (data: Buffer) => {
155
+ stderr += data.toString()
156
+ })
157
+
158
+ proc.on('close', (code) => {
159
+ if (code !== 0 || !xml) {
160
+ console.warn('Warning: Could not generate xunit report:', stderr)
161
+ reject(stderr)
162
+ return
163
+ }
164
+ // Ensure directory exists.
165
+ const dir = path.dirname(outputFile)
166
+ if (!fs.existsSync(dir)) {
167
+ fs.mkdirSync(dir, { recursive: true })
168
+ }
169
+ fs.writeFileSync(outputFile, xml)
170
+ console.log(`\nXUnit report written to: ${outputFile}`)
171
+ resolve()
172
+ })
173
+
174
+ proc.on('error', () => {
175
+ console.warn('Warning: tap-xunit not available')
176
+ resolve()
177
+ })
178
+
179
+ proc.stdin.write(output)
180
+ proc.stdin.end()
181
+ })
182
+ }
183
+
184
+ /**
185
+ * @function randomAvailablePort
186
+ * @description Finds a randomly available port by quickly running a server and stopping a server
187
+ * on port 0.
188
+ */
189
+ export async function randomAvailablePort(): Promise<number> {
190
+ return new Promise((resolve, reject) => {
191
+ const server = createServer();
192
+ server.listen(0)
193
+ server.on('listening', () => {
194
+ try {
195
+ const address = server.address() as unknown as { port: number }
196
+ assert.equal(typeof address, 'object')
197
+ assert(address.port)
198
+
199
+ server.close(() => {
200
+ resolve(address.port);
201
+ });
202
+ } catch (err) {
203
+ reject(err)
204
+ }
205
+ })
206
+
207
+ server.on('error', (err) => {
208
+ reject(err)
209
+ });
210
+ });
211
+ }
212
+
213
+ /**
214
+ * @description A hacky method to sleep in JS. For testing purposes only.
215
+ */
216
+ export async function sleepSeconds(seconds: number) {
217
+ return new Promise(resolve => setTimeout(resolve, seconds * 1000))
218
+ }
219
+
220
+ /**
221
+ * @function createRequest
222
+ *
223
+ * @description Create a mock hapi request handler
224
+ */
225
+ export const createRequest = (
226
+ { payload, params, query }: { payload: any, params: any, query: any }
227
+ ): Request<ReqRefDefaults> => {
228
+ const requestPayload = payload || {}
229
+ const requestParams = params || {}
230
+ const requestQuery = query || {}
231
+
232
+ const mock = {
233
+ payload: requestPayload,
234
+ params: requestParams,
235
+ query: requestQuery,
236
+ server: {
237
+ log: () => { },
238
+ methods: {}
239
+ }
240
+ } as unknown as Request<ReqRefDefaults>
241
+
242
+ return mock
243
+ }
244
+
245
+
246
+ /**
247
+ * @function unwrapResponse
248
+ *
249
+ * @description Unwrap the innner response body and code from an async Handler.
250
+ */
251
+ export const unwrapResponse = async (asyncFunction: (reply: any) => any) => {
252
+ let responseBody: any
253
+ let responseCode: number = -1
254
+ const nestedReply = {
255
+ response: (response: any) => {
256
+ responseBody = response
257
+ return {
258
+ code: (statusCode: number) => {
259
+ responseCode = statusCode
260
+ }
261
+ }
262
+ }
263
+ }
264
+ await asyncFunction(nestedReply)
265
+
266
+ return {
267
+ responseBody,
268
+ responseCode
269
+ }
270
+ }
271
+
272
+
273
+ // Re-typing this here so we don't need to import from ParticipantService
274
+ type GetAccountsResponseAccount = {
275
+ id: number,
276
+ value: string;
277
+ reservedValue: string;
278
+ }
279
+
280
+ /**
281
+ * Assert that the position account for the DFSP changed as expected.
282
+ */
283
+ export const assertPositionDiff = (
284
+ role: 'payer' | 'payee',
285
+ start: GetAccountsResponseAccount,
286
+ end: GetAccountsResponseAccount,
287
+ diff: {
288
+ pending?: number
289
+ posted?: number,
290
+ }
291
+ ) => {
292
+ assert(start)
293
+ assert(start.value)
294
+ assert(start.reservedValue)
295
+ assert(end)
296
+ assert(end.value)
297
+ assert(end.reservedValue)
298
+ assert(start.id === end.id, 'Did you get the accounts mixed up?')
299
+
300
+ if (!diff.pending) {
301
+ diff.pending = 0
302
+ }
303
+ if (!diff.posted) {
304
+ diff.posted = 0
305
+ }
306
+
307
+ const valuePostedStart = Number.parseFloat(start.value)
308
+ const valuePendingStart = Number.parseFloat(start.reservedValue)
309
+
310
+ const endExpected: GetAccountsResponseAccount = {
311
+ id: start.id,
312
+ reservedValue: (valuePendingStart + diff.pending).toFixed(4),
313
+ value: (valuePostedStart + diff.posted).toFixed(4)
314
+ }
315
+
316
+ const expectedStr = prettyPrintPosition(role, start, endExpected)
317
+ const actualStr = prettyPrintPosition(role, start, end)
318
+
319
+ Snapshot.from(expectedStr, { stripWhitespace: false, updateable: false })
320
+ .checkStringUnwrap(actualStr)
321
+ }
322
+
323
+ export const prettyPrintPosition = (
324
+ role: 'payer' | 'payee',
325
+ start: GetAccountsResponseAccount,
326
+ end: GetAccountsResponseAccount,
327
+ ) => {
328
+ const lenColumns = 15
329
+ return `
330
+ ${role} | ${'start'.padEnd(lenColumns)}| ${'end'.padEnd(lenColumns)}
331
+ pending | ${start.reservedValue.padEnd(lenColumns)}| ${end.reservedValue.padEnd(lenColumns)}
332
+ posted | ${start.value.padEnd(lenColumns)}| ${end.value.padEnd(lenColumns)}`
333
+ }
@@ -0,0 +1,72 @@
1
+ // Type definitions for @mojaloop/central-services-error-handling.
2
+
3
+ declare module '@mojaloop/central-services-error-handling' {
4
+ export interface FSPIOPApiErrorObject {
5
+ errorInformation: {
6
+ errorCode: string;
7
+ errorDescription: string;
8
+ extensionList?: {
9
+ extension: Array<{
10
+ key: string;
11
+ value: string;
12
+ }>;
13
+ };
14
+ };
15
+ }
16
+ export class FSPIOPError extends Error {
17
+ apiErrorCode: any
18
+ message: string
19
+ cause: any
20
+ extensions: any
21
+ replyTo: string
22
+ useMessageAsDescription: boolean
23
+
24
+ constructor(cause: any, message: string, replyTo: string, apiErrorCode: any, extensions?: any, useMessageAsDescription?: boolean);
25
+
26
+ toApiErrorObject(options?: { includeCauseExtension?: boolean; truncateExtensions?: boolean }): FSPIOPApiErrorObject;
27
+
28
+ toFullErrorObject(): any;
29
+ }
30
+
31
+ export namespace Factory {
32
+ export function createFSPIOPError(
33
+ apiErrorCode: any,
34
+ message?: string,
35
+ cause?: any,
36
+ replyTo?: string,
37
+ extensions?: any,
38
+ useDescriptionAsMessage?: boolean
39
+ ): FSPIOPError;
40
+
41
+ export function createInternalServerFSPIOPError(
42
+ message: string,
43
+ cause?: any,
44
+ replyTo?: string,
45
+ extensions?: any
46
+ ): FSPIOPError;
47
+
48
+ export function reformatFSPIOPError(
49
+ error: any,
50
+ apiErrorCode?: any,
51
+ replyTo?: string,
52
+ extensions?: any
53
+ ): FSPIOPError;
54
+
55
+ export function createFSPIOPErrorFromJoiError(error: any, cause?: any, replyTo?: string): FSPIOPError;
56
+ export function createFSPIOPErrorFromOpenapiError(error: any, replyTo?: string): FSPIOPError;
57
+ export function createFSPIOPErrorFromErrorInformation(errorInformation: any, cause?: any, replyTo?: string): FSPIOPError;
58
+ export function createFSPIOPErrorFromErrorCode(code: any, message?: string, cause?: any, replyTo?: string, extensions?: any): FSPIOPError;
59
+ export function validateFSPIOPErrorCode(code: any): any;
60
+ export function validateFSPIOPErrorGroups(code: any): boolean;
61
+ }
62
+
63
+ export namespace Enums {
64
+ export const FSPIOPErrorCodes: any
65
+ export function findFSPIOPErrorCode(code: any): any;
66
+ export function findErrorType(code: any): any;
67
+ }
68
+
69
+ export function validateRoutes(options?: any): any;
70
+ export const Handler: any
71
+ export const plugin: any
72
+ }
@@ -0,0 +1,148 @@
1
+ declare module '@mojaloop/central-services-stream' {
2
+ import { EventEmitter } from 'events'
3
+
4
+ export namespace Kafka {
5
+ interface ConsumerConfig {
6
+ rdkafkaConf?: Record<string, any>;
7
+ options?: {
8
+ mode?: 'consumer' | 'flow' | 'poll' | 'recursive';
9
+ messageCharset?: string;
10
+ messageAsJSON?: boolean;
11
+ sync?: boolean;
12
+ consumeTimeout?: number;
13
+ batchSize?: number;
14
+ concurrency?: number;
15
+ commitOffsetsOnFirstJoin?: boolean;
16
+ autoCommitEnable?: boolean;
17
+ autoCommitIntervalMs?: number;
18
+ eosCommit?: boolean;
19
+ consumeLoopTimeoutMs?: number;
20
+ };
21
+ }
22
+
23
+ interface ProducerConfig {
24
+ rdkafkaConf?: Record<string, any>;
25
+ options?: {
26
+ messageCharset?: string;
27
+ messageAsJSON?: boolean;
28
+ sync?: boolean;
29
+ pollIntervalMs?: number;
30
+ queueBufferingMaxMs?: number;
31
+ };
32
+ }
33
+
34
+ interface Message {
35
+ topic: string;
36
+ key?: string | Buffer;
37
+ value: string | Buffer;
38
+ partition?: number;
39
+ offset?: number;
40
+ timestamp?: number;
41
+ headers?: Record<string, string | Buffer>;
42
+ }
43
+
44
+ interface MessageProtocol {
45
+ content: any,
46
+ id: string,
47
+ from: string,
48
+ to: string,
49
+ metadata: any,
50
+ type: string,
51
+ pp?: string
52
+ }
53
+
54
+ interface MessageHandler {
55
+ (error: Error | null, message: Message): Promise<void> | void;
56
+ }
57
+
58
+ interface TopicConfiguration {
59
+ opaqueKey: any
60
+ topicName: string,
61
+ key?: string
62
+ partition?: number
63
+ }
64
+
65
+ class Consumer extends EventEmitter {
66
+ constructor(topics: string[], config: ConsumerConfig);
67
+
68
+ connect(): Promise<void>;
69
+ disconnect(callback?: () => void): void;
70
+ consume(handler: MessageHandler): Promise<any>;
71
+ commitMessageSync(message: Message): void;
72
+ commitMessage(message: Message): Promise<void>;
73
+ isConnected(): boolean;
74
+
75
+ on(event: 'error', listener: (error: Error) => void): this;
76
+ on(event: 'ready', listener: () => void): this;
77
+ on(event: 'disconnected', listener: () => void): this;
78
+ on(event: 'rebalance', listener: (assignment: any) => void): this;
79
+ on(event: string, listener: (...args: any[]) => void): this;
80
+
81
+ static createHandler(
82
+ topicName: string,
83
+ config: ConsumerConfig,
84
+ handler: MessageHandler
85
+ ): Promise<Consumer>;
86
+
87
+ static ENUMS: {
88
+ CONSUMER_MODES: {
89
+ consumer: 'consumer';
90
+ flow: 'flow';
91
+ poll: 'poll';
92
+ recursive: 'recursive';
93
+ };
94
+ }
95
+ }
96
+
97
+ class Producer extends EventEmitter {
98
+ constructor(config: ProducerConfig);
99
+
100
+ connect(): Promise<void>;
101
+ disconnect(callback?: () => void): void;
102
+ sendMessage(
103
+ message: MessageProtocol,
104
+ topicConf: TopicConfiguration,
105
+ customHeaders?: Array<{ [key: string]: string | Buffer }>
106
+ ): Promise<void>;
107
+ isConnected(): boolean;
108
+
109
+ on(event: 'error', listener: (error: Error) => void): this;
110
+ on(event: 'ready', listener: () => void): this;
111
+ on(event: 'disconnected', listener: () => void): this;
112
+ on(event: string, listener: (...args: any[]) => void): this;
113
+
114
+ static ENUMS: {
115
+ COMPRESSION_TYPES: {
116
+ none: 'none';
117
+ gzip: 'gzip';
118
+ snappy: 'snappy';
119
+ lz4: 'lz4';
120
+ };
121
+ }
122
+ }
123
+
124
+ namespace Protocol {
125
+ interface ProtocolMessage {
126
+ id: string;
127
+ from: string;
128
+ to: string;
129
+ type: string;
130
+ content: any;
131
+ metadata?: Record<string, any>;
132
+ }
133
+
134
+ function encode(message: ProtocolMessage): Buffer;
135
+ function decode(buffer: Buffer): ProtocolMessage;
136
+ }
137
+ }
138
+
139
+ export namespace Util {
140
+ namespace Consumer {
141
+ function getConsumerModeMap(): Record<string, any>;
142
+ }
143
+
144
+ namespace Producer {
145
+ function getCompressionMap(): Record<string, any>;
146
+ }
147
+ }
148
+ }
@@ -20,8 +20,6 @@ RUN apk del build-dependencies
20
20
 
21
21
  COPY src /opt/app/src
22
22
  COPY config /opt/app/config
23
- COPY migrations /opt/app/migrations
24
- COPY seeds /opt/app/seeds
25
23
  COPY test /opt/app/test
26
24
 
27
25
  # overwrite default.json with integration environment specific config
package/test.Dockerfile CHANGED
@@ -20,8 +20,6 @@ RUN apk del build-dependencies
20
20
 
21
21
  COPY src /opt/app/src
22
22
  COPY config /opt/app/config
23
- COPY migrations /opt/app/migrations
24
- COPY seeds /opt/app/seeds
25
23
  COPY test /opt/app/test
26
24
 
27
25
  EXPOSE 3001
package/tsconfig.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "compilerOptions": {
3
+ "sourceMap": true,
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "esModuleInterop": true,
7
+ "lib": [
8
+ "es2020",
9
+ "esnext",
10
+ ],
11
+ "types": [
12
+ "node"
13
+ ],
14
+ "module": "commonjs",
15
+ "target": "es2020",
16
+ "allowJs": true,
17
+ "skipLibCheck": true
18
+ },
19
+ "include": [
20
+ "src/**/*.ts",
21
+ "src/**/*.js",
22
+ ],
23
+ "exclude": [
24
+ "node_modules",
25
+ "src/**/*.d.ts"
26
+ ],
27
+ "ts-node": {
28
+ "compilerOptions": {
29
+ "sourceMap": true
30
+ },
31
+ "transpileOnly": true,
32
+ "experimentalResolver": false,
33
+ "files": true,
34
+ "ignore": [
35
+ "(?:^|/)node_modules/",
36
+ // We ignore .d.ts files as ts-node fails if it tries to execute them.
37
+ "\\.d\\.ts$"
38
+ ]
39
+ }
40
+ }