ml-testing-toolkit 18.17.0-snapshot.8 → 18.17.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
# Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
|
|
2
|
+
## [18.17.0](https://github.com/mojaloop/ml-testing-toolkit/compare/v18.16.6...v18.17.0) (2026-01-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add transfer store for timeout interscheme get test ([#362](https://github.com/mojaloop/ml-testing-toolkit/issues/362)) ([48cb7c6](https://github.com/mojaloop/ml-testing-toolkit/commit/48cb7c6bbf1feb1289cb42f15b490cf06b71f68a))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* remove unsupported mongodb options ([#361](https://github.com/mojaloop/ml-testing-toolkit/issues/361)) ([7f7b7bb](https://github.com/mojaloop/ml-testing-toolkit/commit/7f7b7bb12dfd28e21cb7b8d2375df4bf11ff0618))
|
|
13
|
+
|
|
2
14
|
### [18.16.6](https://github.com/mojaloop/ml-testing-toolkit/compare/v18.16.5...v18.16.6) (2026-01-08)
|
|
3
15
|
|
|
4
16
|
|
package/package.json
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
const { ilpFactory, ILP_VERSIONS } = require('@mojaloop/sdk-standard-components').Ilp
|
|
31
31
|
const customLogger = require('../../requestLogger')
|
|
32
32
|
const { logger } = require('../../logger')
|
|
33
|
+
const objectStore = require('../../objectStore')
|
|
33
34
|
|
|
34
35
|
let ilpObj = null
|
|
35
36
|
let ilpV4Obj = null
|
|
@@ -143,27 +144,24 @@ const handleTransferIlp = (context, response) => {
|
|
|
143
144
|
|
|
144
145
|
customLogger.logMessage('debug', 'Generated callback body', { additionalData: { context, response } })
|
|
145
146
|
if (context.request.method === 'get' && response.method === 'put' && pathMatch.test(response.path)) {
|
|
146
|
-
customLogger.logMessage('debug', 'Returning stored fulfilment if exists for transfer GET')
|
|
147
147
|
const transferId = response.path.match(pathMatch)[1]
|
|
148
|
-
|
|
149
|
-
const storedTransfer =
|
|
150
|
-
customLogger.logMessage('debug', 'Stored transfer fetched for fulfilment', { additionalData: {
|
|
151
|
-
// Check if stored request exists and is within 30 seconds
|
|
148
|
+
// Use objectStore to get the stored transfer
|
|
149
|
+
const storedTransfer = objectStore.get('storedTransfers', transferId)
|
|
150
|
+
customLogger.logMessage('debug', 'Stored transfer fetched for fulfilment', { additionalData: { transferId } })
|
|
152
151
|
if (storedTransfer) {
|
|
153
|
-
if (storedTransfer.request
|
|
154
|
-
customLogger.logMessage('debug', 'Stored transfer has ilpPacket. Generating fulfilment.', { additionalData: { transferId, ilpPacket: storedTransfer.request.ilpPacket } })
|
|
155
|
-
const generatedFulfilment = ilpObj.calculateFulfil(storedTransfer.request.ilpPacket).replace('"', '')
|
|
152
|
+
if (storedTransfer.data?.request?.ilpPacket) {
|
|
153
|
+
customLogger.logMessage('debug', 'Stored transfer has ilpPacket. Generating fulfilment.', { additionalData: { transferId, ilpPacket: storedTransfer.data.request.ilpPacket } })
|
|
154
|
+
const generatedFulfilment = ilpObj.calculateFulfil(storedTransfer.data.request.ilpPacket).replace('"', '')
|
|
156
155
|
response.body.fulfilment = generatedFulfilment
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const generatedFulfilment = ilpV4Obj.calculateFulfil(storedTransfer.request.CdtTrfTxInf.VrfctnOfTerms.IlpV4PrepPacket).replace('"', '')
|
|
156
|
+
} else if (storedTransfer.data?.request?.CdtTrfTxInf?.VrfctnOfTerms?.IlpV4PrepPacket) {
|
|
157
|
+
customLogger.logMessage('debug', 'Stored transfer has IlpV4PrepPacket. Generating fulfilment.', { additionalData: { transferId } })
|
|
158
|
+
const generatedFulfilment = ilpV4Obj.calculateFulfil(storedTransfer.data.request.CdtTrfTxInf.VrfctnOfTerms.IlpV4PrepPacket).replace('"', '')
|
|
161
159
|
response.body.TxInfAndSts.ExctnConf = generatedFulfilment
|
|
162
|
-
customLogger.logMessage('debug', 'ExctnConf set in response body', { additionalData: { transferId, ExctnConf: generatedFulfilment } })
|
|
163
160
|
} else {
|
|
164
|
-
customLogger.logMessage('warn', 'No ILP packet or IlpV4PrepPacket found in stored transfer request', { additionalData: { transferId
|
|
161
|
+
customLogger.logMessage('warn', 'No ILP packet or IlpV4PrepPacket found in stored transfer request', { additionalData: { transferId } })
|
|
165
162
|
}
|
|
166
|
-
|
|
163
|
+
// Remove the stored transfer from objectStore regardless of success or failure
|
|
164
|
+
objectStore.deleteObject('storedTransfers', transferId)
|
|
167
165
|
} else {
|
|
168
166
|
delete response.body.fulfilment
|
|
169
167
|
}
|
|
@@ -323,9 +323,6 @@ const generateAsyncCallback = async (item, context, req) => {
|
|
|
323
323
|
const fxTransferPathMatch = /\/fxTransfers(?:\/([^/]+))?$/
|
|
324
324
|
customLogger.logMessage('debug', 'Processing transfer request', { additionalData: { method: req.method, path: req.path }, request: req })
|
|
325
325
|
if (req.method === 'post' && (transferPathMatch.test(req.path) || fxTransferPathMatch.test(req.path))) {
|
|
326
|
-
if (!context.storedTransfers) {
|
|
327
|
-
context.storedTransfers = {}
|
|
328
|
-
}
|
|
329
326
|
const isFxTransfer = fxTransferPathMatch.test(req.path)
|
|
330
327
|
let transferId = (req.payload && req.payload.transferId) || (req.payload && req.payload.commitRequestId)
|
|
331
328
|
if (!transferId && req.payload && req.payload.CdtTrfTxInf && req.payload.CdtTrfTxInf.PmtId && req.payload.CdtTrfTxInf.PmtId.TxId) {
|
|
@@ -333,9 +330,17 @@ const generateAsyncCallback = async (item, context, req) => {
|
|
|
333
330
|
}
|
|
334
331
|
customLogger.logMessage('debug', 'Storing transfer for validation', { additionalData: { transferId }, request: req })
|
|
335
332
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
333
|
+
// Use objectStore to store the transfer only when a valid transferId is resolved
|
|
334
|
+
if (transferId) {
|
|
335
|
+
objectStore.push('storedTransfers', transferId, {
|
|
336
|
+
request: req.payload,
|
|
337
|
+
type: isFxTransfer ? 'fxTransfer' : 'transfer'
|
|
338
|
+
})
|
|
339
|
+
} else {
|
|
340
|
+
customLogger.logMessage('warn', 'Skipping storing transfer: transferId could not be resolved from payload', {
|
|
341
|
+
additionalData: { method: req.method, path: req.path },
|
|
342
|
+
request: req
|
|
343
|
+
})
|
|
339
344
|
}
|
|
340
345
|
}
|
|
341
346
|
|
package/src/lib/objectStore.js
CHANGED
|
@@ -29,13 +29,15 @@
|
|
|
29
29
|
******/
|
|
30
30
|
|
|
31
31
|
const _ = require('lodash')
|
|
32
|
+
const { logger } = require('./logger')
|
|
32
33
|
|
|
33
34
|
const storedObject = {
|
|
34
35
|
data: {
|
|
35
36
|
transactions: {},
|
|
36
37
|
inboundEnvironment: {},
|
|
37
38
|
requests: {},
|
|
38
|
-
callbacks: {}
|
|
39
|
+
callbacks: {},
|
|
40
|
+
storedTransfers: {}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -76,13 +78,17 @@ const push = (key, item, value, user) => {
|
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
const clear = (object, interval) => {
|
|
79
|
-
|
|
80
|
-
for (const
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
try {
|
|
82
|
+
for (const context in storedObject) {
|
|
83
|
+
for (const item in storedObject[context][object]) {
|
|
84
|
+
const timeDiff = Date.now() - storedObject[context][object][item].insertedDate
|
|
85
|
+
if (timeDiff > interval) {
|
|
86
|
+
delete storedObject[context][object][item]
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
logger.error('Error clearing old objects', err)
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
|
|
@@ -96,6 +102,15 @@ const popObject = (key, item, user) => {
|
|
|
96
102
|
return null
|
|
97
103
|
}
|
|
98
104
|
|
|
105
|
+
const deleteObject = (key, item, user) => {
|
|
106
|
+
const context = init(key, user)
|
|
107
|
+
if (Object.prototype.hasOwnProperty.call(storedObject[context][key], item)) {
|
|
108
|
+
delete storedObject[context][key][item]
|
|
109
|
+
return true
|
|
110
|
+
}
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
|
|
99
114
|
const clearOldObjects = () => {
|
|
100
115
|
const interval = 10 * 60 * 1000
|
|
101
116
|
clear('transactions', interval)
|
|
@@ -103,6 +118,7 @@ const clearOldObjects = () => {
|
|
|
103
118
|
clear('callbacks', interval)
|
|
104
119
|
clear('requestsHistory', interval)
|
|
105
120
|
clear('callbacksHistory', interval)
|
|
121
|
+
clear('storedTransfers', interval)
|
|
106
122
|
}
|
|
107
123
|
|
|
108
124
|
const initObjectStore = (initConfig = null) => {
|
|
@@ -116,7 +132,9 @@ module.exports = {
|
|
|
116
132
|
set,
|
|
117
133
|
get,
|
|
118
134
|
initObjectStore,
|
|
135
|
+
init,
|
|
119
136
|
push,
|
|
120
137
|
clear,
|
|
121
|
-
popObject
|
|
138
|
+
popObject,
|
|
139
|
+
deleteObject
|
|
122
140
|
}
|