diff --git a/package-lock.json b/package-lock.json index b1b11461..7bdbd8d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "central-settlement", - "version": "13.3.1", + "version": "13.3.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1920,9 +1920,9 @@ "dev": true }, "@nodelib/fs.walk": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.7.tgz", - "integrity": "sha512-BTIhocbPBSrRmHxOAJFtR18oLhxTtAFDAvL8hY1S3iU8k+E60W/YFs4jrixGzQjMpF4qPXxIQHcjVD9dz1C2QA==", + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, "requires": { "@nodelib/fs.scandir": "2.1.5", @@ -2261,9 +2261,9 @@ "dev": true }, "@types/lodash": { - "version": "4.14.170", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.170.tgz", - "integrity": "sha512-bpcvu/MKHHeYX+qeEN8GE7DIravODWdACVA1ctevD8CN24RhPZIKMn9ntfAsrvLfSX3cR5RrBKAbYm9bGs0A+Q==", + "version": "4.14.171", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.171.tgz", + "integrity": "sha512-7eQ2xYLLI/LsicL2nejW9Wyko3lcpN6O/z0ZLHrEQsg280zIdCv1t/0m6UtBjUHokCGBQ3gYTbHzDkZ1xOBwwg==", "dev": true }, "@types/long": { @@ -5200,9 +5200,9 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "fast-glob": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.6.tgz", - "integrity": "sha512-GnLuqj/pvQ7pX8/L4J84nijv6sAnlwvSDpMkJi9i7nPmPxGtRPkBSStfvDW5l6nMdX9VWe+pkKWFTgD+vF2QSQ==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz", + "integrity": "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -5234,6 +5234,12 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fast-memoize": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/fast-memoize/-/fast-memoize-2.5.2.tgz", + "integrity": "sha512-Ue0LwpDYErFbmNnZSF0UH6eImUwDmogUO1jyE+JbN2gsQz/jICm1Ve7t9QT0rNSsfJt+Hs4/S3GnsDVjL4HVrw==", + "dev": true + }, "fast-safe-stringify": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", @@ -8402,16 +8408,6 @@ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" }, - "mem": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/mem/-/mem-8.1.1.tgz", - "integrity": "sha512-qFCFUDs7U3b8mBDPyz5EToEKoAkgCzqquIgi9nkkR9bixxOVOre+09lbuH7+9Kn2NFpm56M3GUWVbU2hQgdACA==", - "dev": true, - "requires": { - "map-age-cleaner": "^0.1.3", - "mimic-fn": "^3.1.0" - } - }, "memory-pager": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", @@ -8495,12 +8491,6 @@ "mime-db": "1.46.0" } }, - "mimic-fn": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-3.1.0.tgz", - "integrity": "sha512-Ysbi9uYW9hFyfrThdDEQuykN4Ey6BuwPD2kpI5ES/nFTDn/98yxYNLZJcgUAKPT/mcrLLKaGzJR9YVxJrIdASQ==", - "dev": true - }, "mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", @@ -8890,9 +8880,9 @@ "dev": true }, "nodemon": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.9.tgz", - "integrity": "sha512-6O4k7C8f2HQArGpaPBOqGGddjzDLQAqCYmq3tKMeNIbz7Is/hOphMHy2dcY10sSq5wl3cqyn9Iz+Ep2j51JOLg==", + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.12.tgz", + "integrity": "sha512-egCTmNZdObdBxUBw6ZNwvZ/xzk24CKRs5K6d+5zbmrMr7rOpPmfPeF6OxM3DDpaRx331CQRFEktn+wrFFfBSOA==", "dev": true, "requires": { "chokidar": "^3.2.2", @@ -9065,15 +9055,16 @@ } }, "npm-check-updates": { - "version": "11.8.1", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-11.8.1.tgz", - "integrity": "sha512-EaKm356SXQ8vZtaFlhkNAUk5vQbILCh09RkpIkxyqHG1bh4roAyUVa+tgPuHi4o+TW7809G5mwxzlQuGXSQGjw==", + "version": "11.8.3", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-11.8.3.tgz", + "integrity": "sha512-NslIB6Af7GagVrN+bvBkObLyawIZfOnDnl8n9MHE+dFt0aChRYtvR6T2BLJKzOPIepCLmmh0NRR/qha0ExAELQ==", "dev": true, "requires": { "chalk": "^4.1.1", "cint": "^8.2.1", "cli-table": "^0.3.6", "commander": "^6.2.1", + "fast-memoize": "^2.5.2", "find-up": "5.0.0", "fp-and-or": "^0.1.3", "get-stdin": "^8.0.0", @@ -9083,7 +9074,6 @@ "jsonlines": "^0.1.1", "libnpmconfig": "^1.2.1", "lodash": "^4.17.21", - "mem": "^8.1.1", "minimatch": "^3.0.4", "p-map": "^4.0.0", "pacote": "^11.3.4", diff --git a/package.json b/package.json index 05b4cf3e..80a57dc1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "central-settlement", "description": "Central settlements hosted by a scheme to record and make settlements.", - "version": "13.3.1", + "version": "13.3.2", "license": "Apache-2.0", "private": false, "author": "ModusBox", @@ -56,7 +56,7 @@ }, "devDependencies": { "@hapi/joi": "17.1.1", - "@types/lodash": "4.14.170", + "@types/lodash": "4.14.171", "@mojaloop/central-services-metrics": "11.0.0", "ajv": "8.6.1", "ajv-keywords": "5.0.0", @@ -71,9 +71,9 @@ "jest": "27.0.6", "jest-junit": "12.2.0", "node-fetch": "2.6.1", - "nodemon": "2.0.9", + "nodemon": "2.0.12", "npm-audit-resolver": "2.3.1", - "npm-check-updates": "11.8.1", + "npm-check-updates": "11.8.3", "nyc": "15.1.0", "pre-commit": "1.2.2", "proxyquire": "2.1.3", diff --git a/src/api/handlers/settlementWindows/{id}.js b/src/api/handlers/settlementWindows/{id}.js index f4409a6e..c934ac40 100644 --- a/src/api/handlers/settlementWindows/{id}.js +++ b/src/api/handlers/settlementWindows/{id}.js @@ -68,7 +68,7 @@ module.exports = { const settlementWindowId = request.params.id try { const Enums = await request.server.methods.enums('settlementWindowStates') - return await settlementWindow.process({ settlementWindowId, reason }, Enums) + return await settlementWindow.process({ settlementWindowId, reason, request }, Enums) } catch (err) { request.server.log('error', err) return ErrorHandler.Factory.reformatFSPIOPError(err) diff --git a/src/domain/settlementWindow/index.js b/src/domain/settlementWindow/index.js index 9f91cd86..b80f2500 100644 --- a/src/domain/settlementWindow/index.js +++ b/src/domain/settlementWindow/index.js @@ -98,7 +98,7 @@ module.exports = { const state = StreamingProtocol.createEventState(Enum.Events.EventStatus.SUCCESS.status, Enum.Events.EventStatus.SUCCESS.code, Enum.Events.EventStatus.SUCCESS.description) const event = StreamingProtocol.createEventMetadata(Enum.Events.Event.Type.DEFERRED_SETTLEMENT, Enum.Events.Event.Action.CLOSE, state) const metadata = StreamingProtocol.createMetadata(eventId, event) - const messageProtocol = StreamingProtocol.createMessage(messageId, Enum.Http.Headers.FSPIOP.SWITCH.value, Enum.Http.Headers.FSPIOP.SWITCH.value, metadata, undefined, params) + const messageProtocol = StreamingProtocol.createMessage(messageId, Enum.Http.Headers.FSPIOP.SWITCH.value, Enum.Http.Headers.FSPIOP.SWITCH.value, metadata, params.request.headers, params) const topicConfig = KafkaUtil.createGeneralTopicConf(Config.KAFKA_CONFIG.TOPIC_TEMPLATES.GENERAL_TOPIC_TEMPLATE.TEMPLATE, Enum.Events.Event.Type.DEFERRED_SETTLEMENT, Enum.Events.Event.Action.CLOSE) const kafkaConfig = KafkaUtil.getKafkaConfig(Config.KAFKA_CONFIG, Enum.Kafka.Config.PRODUCER, Enum.Events.Event.Type.DEFERRED_SETTLEMENT.toUpperCase(), Enum.Events.Event.Action.CLOSE.toUpperCase()) await Producer.produceMessage(messageProtocol, topicConfig, kafkaConfig) diff --git a/test/integration/settlement_deferred_net_scenario/settlementTransfer.test.js b/test/integration/settlement_deferred_net_scenario/settlementTransfer.test.js index ad41e6e4..ed0191eb 100644 --- a/test/integration/settlement_deferred_net_scenario/settlementTransfer.test.js +++ b/test/integration/settlement_deferred_net_scenario/settlementTransfer.test.js @@ -126,7 +126,17 @@ Test('SettlementTransfer should', async settlementTransferTest => { settlementWindowId = res1[0].settlementWindowId test.ok(settlementWindowId > 0, '#1 retrieve the OPEN window') - params = { settlementWindowId: settlementWindowId, state: enums.settlementWindowStates.CLOSED, reason: 'text' } + params = { + settlementWindowId: settlementWindowId, + state: enums.settlementWindowStates.CLOSED, + reason: 'text', + request: { + headers: { + 'FSPIOP-Source': 'test', + 'FSPIOP-Destination': 'test' + } + } + } const res2 = await SettlementWindowService.process(params, enums.settlementWindowStates) const res3 = await SettlementWindowService.close(params.settlementWindowId, params.reason) test.ok(res3, '#2 close settlement window operation success') diff --git a/test/unit/domain/settlementWindow/index.test.js b/test/unit/domain/settlementWindow/index.test.js index a8bafdc5..67bf96ed 100644 --- a/test/unit/domain/settlementWindow/index.test.js +++ b/test/unit/domain/settlementWindow/index.test.js @@ -258,7 +258,7 @@ Test('SettlementWindowService', async (settlementWindowServiceTest) => { await settlementWindowServiceTest.test('process should', async processTest => { try { - const params = { id: 1 } + const params = { id: 1, request: { headers: { testHeader: 'testHeader' } } } const enums = {} const options = { logger: Logger } const settlementWindowIdMock = 1