@mojaloop/sdk-scheme-adapter 24.1.0 → 24.1.2
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/.yarn/cache/{@eslint-compat-npm-1.2.6-9efc700114-116c277749.zip → @eslint-compat-npm-1.2.7-b26d41d869-bdb5102a1e.zip} +0 -0
- package/.yarn/cache/@mojaloop-central-services-shared-npm-18.18.2-8137f1eb81-a820a25d55.zip +0 -0
- package/.yarn/cache/@mojaloop-central-services-shared-npm-18.19.0-e14673dce9-2d984e3fba.zip +0 -0
- package/.yarn/cache/{@mojaloop-event-sdk-npm-14.1.4-06eb082f24-5cab6c2cee.zip → @mojaloop-event-sdk-npm-14.1.5-97dbf6c0e3-9d5836df5a.zip} +0 -0
- package/.yarn/cache/@mojaloop-inter-scheme-proxy-cache-lib-npm-2.3.3-ca0069f863-f1f9e228ec.zip +0 -0
- package/.yarn/cache/@mojaloop-ml-schema-transformer-lib-npm-2.5.4-e84e9bcf4f-2ce61a546e.zip +0 -0
- package/.yarn/cache/@mojaloop-sdk-standard-components-npm-19.7.0-04e9d9d599-fefb01a635.zip +0 -0
- package/.yarn/cache/{@types-node-npm-22.13.4-80985669cb-39ecbd84fc.zip → @types-node-npm-22.13.5-4c5912eee2-8789d9bc3e.zip} +0 -0
- package/.yarn/cache/@typescript-eslint-eslint-plugin-npm-8.25.0-f1ecf3f166-8e6f525d9c.zip +0 -0
- package/.yarn/cache/@typescript-eslint-parser-npm-8.25.0-31c155428a-5de468b96b.zip +0 -0
- package/.yarn/cache/@typescript-eslint-scope-manager-npm-8.25.0-091dbcfc8f-0778232545.zip +0 -0
- package/.yarn/cache/@typescript-eslint-type-utils-npm-8.25.0-948ec177d4-ee4bccb650.zip +0 -0
- package/.yarn/cache/@typescript-eslint-types-npm-8.25.0-3b5d366120-958395fb20.zip +0 -0
- package/.yarn/cache/@typescript-eslint-typescript-estree-npm-8.25.0-3d5d32528c-b103847df2.zip +0 -0
- package/.yarn/cache/@typescript-eslint-utils-npm-8.25.0-8fbe62cef1-60572c8880.zip +0 -0
- package/.yarn/cache/@typescript-eslint-visitor-keys-npm-8.25.0-d1f59eb977-e9570dd2ff.zip +0 -0
- package/.yarn/cache/semver-npm-7.7.1-4572475307-586b825d36.zip +0 -0
- package/.yarn/cache/{ts-jest-npm-29.2.5-3012d53ff5-d60d1e1d80.zip → ts-jest-npm-29.2.6-81e5c09384-ff71b27e99.zip} +0 -0
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +14 -0
- package/modules/api-svc/package.json +4 -4
- package/modules/api-svc/src/OutboundServer/handlers.js +13 -17
- package/modules/api-svc/src/config.js +3 -2
- package/modules/api-svc/src/constants.js +0 -3
- package/modules/api-svc/src/index.js +10 -25
- package/modules/api-svc/src/lib/model/InboundTransfersModel.js +20 -23
- package/modules/api-svc/src/lib/model/OutboundBulkQuotesModel.js +8 -7
- package/modules/api-svc/src/lib/model/OutboundBulkTransfersModel.js +8 -7
- package/modules/api-svc/src/lib/model/OutboundRequestToPayModel.js +9 -6
- package/modules/api-svc/src/lib/model/OutboundTransfersModel.js +48 -40
- package/modules/api-svc/src/lib/utils.js +20 -1
- package/modules/api-svc/test/unit/config.test.js +1 -0
- package/modules/api-svc/test/unit/outboundApi/handlers.test.js +13 -85
- package/modules/outbound-command-event-handler/package.json +6 -6
- package/modules/outbound-domain-event-handler/package.json +4 -4
- package/modules/private-shared-lib/package.json +6 -6
- package/package.json +5 -5
- package/.yarn/cache/@typescript-eslint-eslint-plugin-npm-8.24.1-43fd154139-9627eb794d.zip +0 -0
- package/.yarn/cache/@typescript-eslint-parser-npm-8.24.1-fedd86ba37-859b78630a.zip +0 -0
- package/.yarn/cache/@typescript-eslint-scope-manager-npm-8.24.1-bbbd19850f-193c072cd0.zip +0 -0
- package/.yarn/cache/@typescript-eslint-type-utils-npm-8.24.1-a739e69814-18a4431890.zip +0 -0
- package/.yarn/cache/@typescript-eslint-types-npm-8.24.1-599b1de09d-6304b153de.zip +0 -0
- package/.yarn/cache/@typescript-eslint-typescript-estree-npm-8.24.1-006a219495-9a4055ebed.zip +0 -0
- package/.yarn/cache/@typescript-eslint-utils-npm-8.24.1-d8e526dcfa-87b62de9d0.zip +0 -0
- package/.yarn/cache/@typescript-eslint-visitor-keys-npm-8.24.1-7dbb0c7cb9-82b91cf090.zip +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/.yarn/cache/@mojaloop-inter-scheme-proxy-cache-lib-npm-2.3.3-ca0069f863-f1f9e228ec.zip
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
# Changelog: [mojaloop/sdk-scheme-adapter](https://github.com/mojaloop/sdk-scheme-adapter)
|
|
2
|
+
### [24.1.2](https://github.com/mojaloop/sdk-scheme-adapter/compare/v24.1.1...v24.1.2) (2025-02-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Chore
|
|
6
|
+
|
|
7
|
+
* fixed logLevel ([#547](https://github.com/mojaloop/sdk-scheme-adapter/issues/547)) ([f88a464](https://github.com/mojaloop/sdk-scheme-adapter/commit/f88a4642cad323dca80bbfd57a590b8c8bae9d87))
|
|
8
|
+
|
|
9
|
+
### [24.1.1](https://github.com/mojaloop/sdk-scheme-adapter/compare/v24.1.0...v24.1.1) (2025-02-25)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Chore
|
|
13
|
+
|
|
14
|
+
* **csi-1237:** improved logging ([#546](https://github.com/mojaloop/sdk-scheme-adapter/issues/546)) ([41af8db](https://github.com/mojaloop/sdk-scheme-adapter/commit/41af8dbc23412514a241c635888920ff27edfa6e))
|
|
15
|
+
|
|
2
16
|
## [24.1.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v24.0.8...v24.1.0) (2025-02-21)
|
|
3
17
|
|
|
4
18
|
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"@mojaloop/central-services-error-handling": "^13.0.6",
|
|
69
69
|
"@mojaloop/central-services-logger": "^11.5.5",
|
|
70
70
|
"@mojaloop/central-services-metrics": "^12.4.5",
|
|
71
|
-
"@mojaloop/central-services-shared": "^18.
|
|
72
|
-
"@mojaloop/event-sdk": "^14.1.
|
|
71
|
+
"@mojaloop/central-services-shared": "^18.19.0",
|
|
72
|
+
"@mojaloop/event-sdk": "^14.1.5",
|
|
73
73
|
"@mojaloop/logging-bc-client-lib": "0.5.8",
|
|
74
|
-
"@mojaloop/ml-schema-transformer-lib": "^2.5.
|
|
74
|
+
"@mojaloop/ml-schema-transformer-lib": "^2.5.4",
|
|
75
75
|
"@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^",
|
|
76
|
-
"@mojaloop/sdk-standard-components": "19.
|
|
76
|
+
"@mojaloop/sdk-standard-components": "19.7.0",
|
|
77
77
|
"ajv": "8.17.1",
|
|
78
78
|
"axios": "^1.7.9",
|
|
79
79
|
"body-parser": "^1.20.3",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
******/
|
|
30
30
|
'use strict';
|
|
31
31
|
|
|
32
|
-
const safeStringify = require('fast-safe-stringify');
|
|
33
32
|
const {
|
|
34
33
|
AccountsModel,
|
|
35
34
|
OutboundTransfersModel,
|
|
@@ -54,7 +53,7 @@ const { ReturnCodes } = Enum.Http;
|
|
|
54
53
|
* Error handling logic shared by outbound API handlers
|
|
55
54
|
*/
|
|
56
55
|
const handleError = (method, err, ctx, stateField) => {
|
|
57
|
-
ctx.state.logger.
|
|
56
|
+
ctx.state.logger.push({ err, stateField }).error(`Error handling ${method}`);
|
|
58
57
|
ctx.response.status = err.httpStatusCode || ReturnCodes.INTERNALSERVERERRROR.CODE;
|
|
59
58
|
ctx.response.body = {
|
|
60
59
|
message: err.message || 'Unspecified error',
|
|
@@ -72,6 +71,7 @@ const handleError = (method, err, ctx, stateField) => {
|
|
|
72
71
|
// the structure of the response object in depth to ascertain an underlying mojaloop API error code.
|
|
73
72
|
const errorInformation = err[stateField].lastError.mojaloopError.errorInformation;
|
|
74
73
|
ctx.response.body.statusCode = errorInformation.errorCode;
|
|
74
|
+
ctx.state.logger.warn('errorInformation - ', errorInformation);
|
|
75
75
|
|
|
76
76
|
// if we have been configured to use an error extensionList item as status code, look for it and use
|
|
77
77
|
// it if it is present...
|
|
@@ -125,13 +125,21 @@ const handleRequestSimpleTransfersInformationError = (method, err, ctx) =>
|
|
|
125
125
|
|
|
126
126
|
const createOutboundTransfersModel = (ctx) => new OutboundTransfersModel({
|
|
127
127
|
...ctx.state.conf,
|
|
128
|
-
...ctx.state.path?.params?.dfspId && {dfspId: ctx.state.path.params.dfspId},
|
|
128
|
+
...(ctx.state.path?.params?.dfspId && { dfspId: ctx.state.path.params.dfspId }),
|
|
129
129
|
cache: ctx.state.cache,
|
|
130
130
|
logger: ctx.state.logger,
|
|
131
131
|
wso2: ctx.state.wso2,
|
|
132
132
|
metricsClient: ctx.state.metricsClient,
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
+
const createOutboundBulkTransfersModel = (ctx) => new OutboundBulkTransfersModel({
|
|
136
|
+
...ctx.state.conf,
|
|
137
|
+
...(ctx.state.path?.params?.dfspId && { dfspId: ctx.state.path.params.dfspId }),
|
|
138
|
+
cache: ctx.state.cache,
|
|
139
|
+
logger: ctx.state.logger,
|
|
140
|
+
wso2: ctx.state.wso2,
|
|
141
|
+
});
|
|
142
|
+
|
|
135
143
|
/**
|
|
136
144
|
* Handler for outbound transfer request initiation
|
|
137
145
|
*/
|
|
@@ -222,13 +230,7 @@ const postBulkTransfers = async (ctx) => {
|
|
|
222
230
|
};
|
|
223
231
|
|
|
224
232
|
// use the bulk transfers model to execute asynchronous stages with the switch
|
|
225
|
-
const model =
|
|
226
|
-
...ctx.state.conf,
|
|
227
|
-
...ctx.state.path?.params?.dfspId && {dfspId: ctx.state.path.params.dfspId},
|
|
228
|
-
cache: ctx.state.cache,
|
|
229
|
-
logger: ctx.state.logger,
|
|
230
|
-
wso2: ctx.state.wso2,
|
|
231
|
-
});
|
|
233
|
+
const model = createOutboundBulkTransfersModel(ctx);
|
|
232
234
|
|
|
233
235
|
await model.initialize(bulkTransferRequest);
|
|
234
236
|
const response = await model.run();
|
|
@@ -254,13 +256,7 @@ const getBulkTransfers = async (ctx) => {
|
|
|
254
256
|
};
|
|
255
257
|
|
|
256
258
|
// use the bulk transfers model to execute asynchronous stages with the switch
|
|
257
|
-
const model =
|
|
258
|
-
...ctx.state.conf,
|
|
259
|
-
...ctx.state.path?.params?.dfspId && {dfspId: ctx.state.path.params.dfspId},
|
|
260
|
-
cache: ctx.state.cache,
|
|
261
|
-
logger: ctx.state.logger,
|
|
262
|
-
wso2: ctx.state.wso2,
|
|
263
|
-
});
|
|
259
|
+
const model = createOutboundBulkTransfersModel(ctx);
|
|
264
260
|
|
|
265
261
|
await model.initialize(bulkTransferRequest);
|
|
266
262
|
const response = await model.getBulkTransfer();
|
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
******/
|
|
27
27
|
'use strict';
|
|
28
28
|
|
|
29
|
-
const fs = require('fs');
|
|
30
29
|
require('dotenv').config();
|
|
30
|
+
const fs = require('node:fs');
|
|
31
31
|
const yaml = require('js-yaml');
|
|
32
32
|
const { from } = require('env-var');
|
|
33
|
+
const { Logger } = require('@mojaloop/sdk-standard-components').Logger;
|
|
33
34
|
const { API_TYPES, RESOURCE_VERSIONS_STRING } = require('./constants');
|
|
34
35
|
|
|
35
36
|
function getFileContent (path) {
|
|
@@ -88,7 +89,7 @@ module.exports = {
|
|
|
88
89
|
mgmtAPIWsPort: env.get('MGMT_API_WS_PORT').default('4005').asPortNumber()
|
|
89
90
|
},
|
|
90
91
|
idGenerator: env.get('ID_GENERATOR').default('{"type":"ulid"}').asJsonObject(),
|
|
91
|
-
logLevel: env.get('LOG_LEVEL').default('info').asEnum(
|
|
92
|
+
logLevel: env.get('LOG_LEVEL').default('info').asEnum(Logger.logLevels),
|
|
92
93
|
inbound: {
|
|
93
94
|
port: env.get('INBOUND_LISTEN_PORT').default('4000').asPortNumber(),
|
|
94
95
|
tls: {
|
|
@@ -38,11 +38,8 @@ const API_TYPES = Object.freeze({
|
|
|
38
38
|
iso20022: 'iso20022',
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
const SDK_LOGGER_HIERARCHY = ['verbose', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'];
|
|
42
|
-
|
|
43
41
|
module.exports = {
|
|
44
42
|
API_TYPES,
|
|
45
43
|
ISO_20022_HEADER_PART,
|
|
46
44
|
RESOURCE_VERSIONS_STRING,
|
|
47
|
-
SDK_LOGGER_HIERARCHY,
|
|
48
45
|
};
|
|
@@ -26,10 +26,8 @@
|
|
|
26
26
|
******/
|
|
27
27
|
'use strict';
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
const EventEmitter = require('events');
|
|
29
|
+
const EventEmitter = require('node:events');
|
|
31
30
|
const _ = require('lodash');
|
|
32
|
-
const { Logger } = require('@mojaloop/sdk-standard-components');
|
|
33
31
|
const { name, version } = require('../../../package.json');
|
|
34
32
|
|
|
35
33
|
const config = require('./config');
|
|
@@ -50,8 +48,7 @@ const Router = require('./lib/router');
|
|
|
50
48
|
const Validate = require('./lib/validate');
|
|
51
49
|
const Cache = require('./lib/cache');
|
|
52
50
|
const { SDKStateEnum } = require('./lib/model/common');
|
|
53
|
-
const { createAuthClient } = require('./lib/utils');
|
|
54
|
-
const { SDK_LOGGER_HIERARCHY } = require('./constants');
|
|
51
|
+
const { createAuthClient, createLogger } = require('./lib/utils');
|
|
55
52
|
|
|
56
53
|
const LOG_ID = {
|
|
57
54
|
INBOUND: { app: 'mojaloop-connector-inbound-api' },
|
|
@@ -65,19 +62,6 @@ const LOG_ID = {
|
|
|
65
62
|
CACHE: { component: 'cache' },
|
|
66
63
|
};
|
|
67
64
|
|
|
68
|
-
const createLogger = (conf) => new Logger.Logger({
|
|
69
|
-
context: {
|
|
70
|
-
// If we're running from a Mojaloop helm chart deployment, we'll have a SIM_NAME
|
|
71
|
-
simulator: process.env['SIM_NAME'],
|
|
72
|
-
hostname: hostname(),
|
|
73
|
-
},
|
|
74
|
-
opts: {
|
|
75
|
-
levels: SDK_LOGGER_HIERARCHY.slice(SDK_LOGGER_HIERARCHY.indexOf(conf.logLevel)),
|
|
76
|
-
isJsonOutput: conf.isJsonOutput,
|
|
77
|
-
},
|
|
78
|
-
stringify: Logger.buildStringify({ isJsonOutput: conf.isJsonOutput }),
|
|
79
|
-
});
|
|
80
|
-
|
|
81
65
|
const createCache = (config, logger) => new Cache({
|
|
82
66
|
cacheUrl: config.cacheUrl,
|
|
83
67
|
logger: logger.push(LOG_ID.CACHE),
|
|
@@ -376,9 +360,9 @@ class Server extends EventEmitter {
|
|
|
376
360
|
async function _GetUpdatedConfigFromMgmtAPI(conf, logger, client) {
|
|
377
361
|
logger.isInfoEnabled && logger.info(`Getting updated config from Management API at ${conf.control.mgmtAPIWsUrl}:${conf.control.mgmtAPIWsPort}...`);
|
|
378
362
|
const clientSendResponse = await client.send(ControlAgent.build.CONFIGURATION.READ());
|
|
379
|
-
logger.
|
|
363
|
+
logger.isDebugEnabled && logger.debug('client send returned:: ', clientSendResponse);
|
|
380
364
|
const responseRead = await client.receive();
|
|
381
|
-
logger.
|
|
365
|
+
logger.isDebugEnabled && logger.debug('client receive returned:: ', responseRead);
|
|
382
366
|
return responseRead.data;
|
|
383
367
|
}
|
|
384
368
|
|
|
@@ -387,16 +371,17 @@ async function start(config) {
|
|
|
387
371
|
|
|
388
372
|
if (config.pm4mlEnabled) {
|
|
389
373
|
const controlClient = await ControlAgent.Client.Create({
|
|
374
|
+
appConfig: config,
|
|
390
375
|
address: config.control.mgmtAPIWsUrl,
|
|
391
376
|
port: config.control.mgmtAPIWsPort,
|
|
392
|
-
logger
|
|
393
|
-
appConfig: config,
|
|
377
|
+
logger,
|
|
394
378
|
});
|
|
395
379
|
const updatedConfigFromMgmtAPI = await _GetUpdatedConfigFromMgmtAPI(config, logger, controlClient);
|
|
396
|
-
logger.isInfoEnabled && logger.push({ updatedConfigFromMgmtAPI }).info('updatedConfigFromMgmtAPI:');
|
|
380
|
+
logger.isInfoEnabled && logger.push({ updatedConfigFromMgmtAPIKeys: Object.keys(updatedConfigFromMgmtAPI) }).info('updatedConfigFromMgmtAPI keys:');
|
|
397
381
|
_.merge(config, updatedConfigFromMgmtAPI);
|
|
398
382
|
controlClient.terminate();
|
|
399
383
|
}
|
|
384
|
+
|
|
400
385
|
const svr = new Server(config, logger);
|
|
401
386
|
svr.on('error', (err) => {
|
|
402
387
|
logger.push({ err }).error('Unhandled server error');
|
|
@@ -405,7 +390,7 @@ async function start(config) {
|
|
|
405
390
|
|
|
406
391
|
// handle SIGTERM to exit gracefully
|
|
407
392
|
process.on('SIGTERM', async () => {
|
|
408
|
-
logger.
|
|
393
|
+
logger.info('SIGTERM received. Shutting down SDK...');
|
|
409
394
|
await svr.stop();
|
|
410
395
|
process.exit(0);
|
|
411
396
|
});
|
|
@@ -415,7 +400,7 @@ async function start(config) {
|
|
|
415
400
|
process.exit(1);
|
|
416
401
|
});
|
|
417
402
|
|
|
418
|
-
logger.
|
|
403
|
+
logger.push({ name, version }).info('SDK server is started!');
|
|
419
404
|
}
|
|
420
405
|
|
|
421
406
|
if (require.main === module) {
|
|
@@ -122,11 +122,10 @@ class InboundTransfersModel {
|
|
|
122
122
|
return this._mojaloopRequests.putAuthorizations(transactionRequestId, mlAuthorization, sourceFspId);
|
|
123
123
|
}
|
|
124
124
|
catch(err) {
|
|
125
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error('Error in getOTP');
|
|
125
|
+
this._logger.isErrorEnabled && this._logger.push({ err, transactionRequestId }).error('Error in getOTP');
|
|
126
126
|
const mojaloopError = await this._handleError(err);
|
|
127
127
|
this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
|
|
128
|
-
return this._mojaloopRequests.putAuthorizationsError(transactionRequestId,
|
|
129
|
-
mojaloopError, sourceFspId);
|
|
128
|
+
return this._mojaloopRequests.putAuthorizationsError(transactionRequestId, mojaloopError, sourceFspId);
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
|
|
@@ -148,7 +147,7 @@ class InboundTransfersModel {
|
|
|
148
147
|
sourceFspId);
|
|
149
148
|
}
|
|
150
149
|
catch(err) {
|
|
151
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error('Error in getParticipants');
|
|
150
|
+
this._logger.isErrorEnabled && this._logger.push({ err, idValue }).error('Error in getParticipants');
|
|
152
151
|
const mojaloopError = await this._handleError(err);
|
|
153
152
|
this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
|
|
154
153
|
return this._mojaloopRequests.putParticipantsError(idType, idValue, idSubValue,
|
|
@@ -189,7 +188,7 @@ class InboundTransfersModel {
|
|
|
189
188
|
|
|
190
189
|
}
|
|
191
190
|
catch(err) {
|
|
192
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error('Error in getParties');
|
|
191
|
+
this._logger.isErrorEnabled && this._logger.push({ err, idValue }).error('Error in getParties');
|
|
193
192
|
const mojaloopError = await this._handleError(err);
|
|
194
193
|
this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
|
|
195
194
|
return this._mojaloopRequests.putPartiesError(idType, idValue, idSubValue,
|
|
@@ -318,7 +317,7 @@ class InboundTransfersModel {
|
|
|
318
317
|
await this._backendRequests.putRequestToPayNotification(internalForm, transactionRequestId);
|
|
319
318
|
}
|
|
320
319
|
catch(err) {
|
|
321
|
-
this._logger.push({ err }).error('Error in putTransactionRequest');
|
|
320
|
+
this._logger.push({ err, transactionRequestId }).error('Error in putTransactionRequest');
|
|
322
321
|
const mojaloopError = await this._handleError(err);
|
|
323
322
|
this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
|
|
324
323
|
return await this._mojaloopRequests.putQuotesError(transactionRequestId,
|
|
@@ -339,19 +338,17 @@ class InboundTransfersModel {
|
|
|
339
338
|
if (!quoteResponse) {
|
|
340
339
|
const err = new Error('Quote Id not found');
|
|
341
340
|
const mojaloopError = await this._handleError(err, Errors.MojaloopApiErrorCodes.QUOTE_ID_NOT_FOUND);
|
|
342
|
-
this._logger.push({ mojaloopError }).
|
|
343
|
-
return await this._mojaloopRequests.putQuotesError(quoteId,
|
|
344
|
-
mojaloopError, sourceFspId);
|
|
341
|
+
this._logger.push({ mojaloopError, quoteId }).warn(`Sending error response to ${sourceFspId}`);
|
|
342
|
+
return await this._mojaloopRequests.putQuotesError(quoteId, mojaloopError, sourceFspId);
|
|
345
343
|
}
|
|
346
344
|
// Make a PUT /quotes/{ID} callback to the source fsp with the quote response
|
|
347
345
|
return this._mojaloopRequests.putQuotes(quoteId, quoteResponse, sourceFspId);
|
|
348
346
|
}
|
|
349
347
|
catch(err) {
|
|
350
|
-
this._logger.push({ err }).error('Error in getQuoteRequest');
|
|
348
|
+
this._logger.push({ err, quoteId }).error('Error in getQuoteRequest');
|
|
351
349
|
const mojaloopError = await this._handleError(err);
|
|
352
|
-
this._logger.
|
|
353
|
-
return await this._mojaloopRequests.putQuotesError(quoteId,
|
|
354
|
-
mojaloopError, sourceFspId);
|
|
350
|
+
this._logger.isVerboseEnabled && this._logger.push({ mojaloopError }).verbose(`Sending error response to ${sourceFspId}`);
|
|
351
|
+
return await this._mojaloopRequests.putQuotesError(quoteId, mojaloopError, sourceFspId);
|
|
355
352
|
}
|
|
356
353
|
}
|
|
357
354
|
|
|
@@ -378,7 +375,7 @@ class InboundTransfersModel {
|
|
|
378
375
|
return this._mojaloopRequests.putTransactionRequests(transactionRequest.transactionRequestId, mojaloopResponse, sourceFspId);
|
|
379
376
|
}
|
|
380
377
|
catch(err) {
|
|
381
|
-
this._logger.push({ err }).error(
|
|
378
|
+
this._logger.push({ err }).error(`Error in transactionRequest ${transactionRequest?.transactionRequestId}`);
|
|
382
379
|
const mojaloopError = await this._handleError(err);
|
|
383
380
|
this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
|
|
384
381
|
return this._mojaloopRequests.putTransactionRequestsError(transactionRequest.transactionRequestId,
|
|
@@ -491,7 +488,7 @@ class InboundTransfersModel {
|
|
|
491
488
|
await this._save();
|
|
492
489
|
return res;
|
|
493
490
|
} catch(err) {
|
|
494
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error(
|
|
491
|
+
this._logger.isErrorEnabled && this._logger.push({ err }).error(`Error in prepareTransfer: ${request?.body?.transferId}`);
|
|
495
492
|
const mojaloopError = await this._handleError(err);
|
|
496
493
|
this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
|
|
497
494
|
return await this._mojaloopRequests.putTransfersError(prepareRequest.transferId,
|
|
@@ -548,7 +545,7 @@ class InboundTransfersModel {
|
|
|
548
545
|
sourceFspId);
|
|
549
546
|
}
|
|
550
547
|
catch (err) {
|
|
551
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error('Error in getTransfers');
|
|
548
|
+
this._logger.isErrorEnabled && this._logger.push({ err, transferId }).error('Error in getTransfers');
|
|
552
549
|
const mojaloopError = await this._handleError(err);
|
|
553
550
|
this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
|
|
554
551
|
return this._mojaloopRequests.putTransfersError(transferId,
|
|
@@ -773,7 +770,7 @@ class InboundTransfersModel {
|
|
|
773
770
|
sourceFspId);
|
|
774
771
|
}
|
|
775
772
|
catch (err) {
|
|
776
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error('Error in getBulkQuote');
|
|
773
|
+
this._logger.isErrorEnabled && this._logger.push({ err, bulkQuoteId }).error('Error in getBulkQuote');
|
|
777
774
|
const mojaloopError = await this._handleError(err);
|
|
778
775
|
this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
|
|
779
776
|
return this._mojaloopRequests.putBulkQuotesError(bulkQuoteId,
|
|
@@ -951,7 +948,7 @@ class InboundTransfersModel {
|
|
|
951
948
|
sourceFspId);
|
|
952
949
|
}
|
|
953
950
|
catch (err) {
|
|
954
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error('Error in getBulkTransfer');
|
|
951
|
+
this._logger.isErrorEnabled && this._logger.push({ err, bulkTransferId }).error('Error in getBulkTransfer');
|
|
955
952
|
const mojaloopError = await this._handleError(err);
|
|
956
953
|
this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
|
|
957
954
|
return this._mojaloopRequests.putBulkTransfersError(bulkTransferId,
|
|
@@ -983,7 +980,7 @@ class InboundTransfersModel {
|
|
|
983
980
|
const res = await this._backendRequests.patchFxTransfersNotification(this.data,conversionId);
|
|
984
981
|
return res;
|
|
985
982
|
} catch (err) {
|
|
986
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error(`Error notifying backend of final conversionId state equal to: ${body.conversionState} `);
|
|
983
|
+
this._logger.isErrorEnabled && this._logger.push({ err, conversionId }).error(`Error notifying backend of final conversionId state equal to: ${body.conversionState} `);
|
|
987
984
|
}
|
|
988
985
|
}
|
|
989
986
|
/**
|
|
@@ -1022,7 +1019,7 @@ class InboundTransfersModel {
|
|
|
1022
1019
|
const res = await this._backendRequests.putTransfersNotification(this.data, transferId);
|
|
1023
1020
|
return res;
|
|
1024
1021
|
} catch (err) {
|
|
1025
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error(`Error notifying backend of final transfer state equal to: ${body.transferState}`);
|
|
1022
|
+
this._logger.isErrorEnabled && this._logger.push({ err, transferId }).error(`Error notifying backend of final transfer state equal to: ${body.transferState}`);
|
|
1026
1023
|
}
|
|
1027
1024
|
}
|
|
1028
1025
|
|
|
@@ -1097,7 +1094,7 @@ class InboundTransfersModel {
|
|
|
1097
1094
|
return data;
|
|
1098
1095
|
}
|
|
1099
1096
|
catch(err) {
|
|
1100
|
-
this._logger.isErrorEnabled && this._logger.push({ err }).error('Error loading transfer model');
|
|
1097
|
+
this._logger.isErrorEnabled && this._logger.push({ err, transferId }).error('Error loading transfer model');
|
|
1101
1098
|
throw err;
|
|
1102
1099
|
}
|
|
1103
1100
|
}
|
|
@@ -1105,13 +1102,13 @@ class InboundTransfersModel {
|
|
|
1105
1102
|
async saveFxState() { // fxQuote + fxTransfer
|
|
1106
1103
|
const key = this.makeFxQuoteCacheKey(this.data?.conversionId);
|
|
1107
1104
|
const res = await this._cache.set(key, this.data, this._cacheTtl);
|
|
1108
|
-
this._logger.push({ key, res }).
|
|
1105
|
+
this._logger.push({ key, res }).debug('fxState is saved in cache');
|
|
1109
1106
|
}
|
|
1110
1107
|
|
|
1111
1108
|
async loadFxState(conversionId) {
|
|
1112
1109
|
const key = this.makeFxQuoteCacheKey(conversionId);
|
|
1113
1110
|
const data = await this._cache.get(key);
|
|
1114
|
-
this._logger.push({ key, data }).
|
|
1111
|
+
this._logger.push({ key, data }).debug('fxState is loaded from cache');
|
|
1115
1112
|
return data;
|
|
1116
1113
|
}
|
|
1117
1114
|
|
|
@@ -455,43 +455,44 @@ class OutboundBulkQuotesModel {
|
|
|
455
455
|
* Returns a promise that resolves when the state machine has reached a terminal state
|
|
456
456
|
*/
|
|
457
457
|
async run() {
|
|
458
|
+
const log = this._logger.push({ bulkQuoteId: this.data.bulkQuoteId });
|
|
458
459
|
try {
|
|
459
460
|
// run transitions based on incoming state
|
|
460
461
|
switch(this.data.currentState) {
|
|
461
462
|
case 'start':
|
|
462
463
|
await this.stateMachine.requestBulkQuote();
|
|
463
|
-
|
|
464
|
+
log.isInfoEnabled && log.info('Quotes resolved for bulk quote');
|
|
464
465
|
break;
|
|
465
466
|
|
|
466
467
|
case 'getBulkQuote':
|
|
467
468
|
await this.stateMachine.getBulkQuote();
|
|
468
|
-
|
|
469
|
+
log.isInfoEnabled && log.info('Get bulk quote has been completed');
|
|
469
470
|
break;
|
|
470
471
|
|
|
471
472
|
case 'succeeded':
|
|
472
473
|
// all steps complete so return
|
|
473
|
-
|
|
474
|
+
log.isInfoEnabled && log.info('Bulk quoting completed successfully');
|
|
474
475
|
await this._save();
|
|
475
476
|
return this.getResponse();
|
|
476
477
|
|
|
477
478
|
case 'errored':
|
|
478
479
|
// stopped in errored state
|
|
479
|
-
|
|
480
|
+
log.isWarnEnabled && log.warn('State machine in errored state');
|
|
480
481
|
return;
|
|
481
482
|
}
|
|
482
483
|
|
|
483
484
|
// now call ourselves recursively to deal with the next transition
|
|
484
|
-
|
|
485
|
+
log.isVerboseEnabled && log.verbose(`Bulk quote model state machine transition completed in state: ${this.stateMachine.state}. Recursing to handle next transition.`);
|
|
485
486
|
return this.run();
|
|
486
487
|
}
|
|
487
488
|
catch(err) {
|
|
488
|
-
|
|
489
|
+
log.isErrorEnabled && log.push({ err }).error(`Error running bulk quote model: ${err?.message}`);
|
|
489
490
|
|
|
490
491
|
// as this function is recursive, we dont want to error the state machine multiple times
|
|
491
492
|
if(this.data.currentState !== 'errored') {
|
|
492
493
|
// err should not have a bulkQuoteState property here!
|
|
493
494
|
if(err.bulkQuoteState) {
|
|
494
|
-
|
|
495
|
+
log.isWarnEnabled && log.warn('State machine is broken');
|
|
495
496
|
}
|
|
496
497
|
// transition to errored state
|
|
497
498
|
await this.stateMachine.error(err);
|
|
@@ -448,43 +448,44 @@ class OutboundBulkTransfersModel {
|
|
|
448
448
|
* Returns a promise that resolves when the state machine has reached a terminal state
|
|
449
449
|
*/
|
|
450
450
|
async run() {
|
|
451
|
+
const log = this._logger.push({ bulkTransferId: this.data.bulkTransferId });
|
|
451
452
|
try {
|
|
452
453
|
// run transitions based on incoming state
|
|
453
454
|
switch(this.data.currentState) {
|
|
454
455
|
case 'start':
|
|
455
456
|
await this.stateMachine.executeBulkTransfer();
|
|
456
|
-
|
|
457
|
+
log.isInfoEnabled && log.info('Bulk transfer has been started');
|
|
457
458
|
break;
|
|
458
459
|
|
|
459
460
|
case 'getBulkTransfer':
|
|
460
461
|
await this.stateMachine.getBulkTransfer();
|
|
461
|
-
|
|
462
|
+
log.isInfoEnabled && log.info('Get bulk transfer has been completed');
|
|
462
463
|
break;
|
|
463
464
|
|
|
464
465
|
case 'succeeded':
|
|
465
466
|
// all steps complete so return
|
|
466
|
-
|
|
467
|
+
log.isInfoEnabled && log.info('Bulk transfer completed successfully');
|
|
467
468
|
await this._save();
|
|
468
469
|
return this.getResponse();
|
|
469
470
|
|
|
470
471
|
case 'errored':
|
|
471
472
|
// stopped in errored state
|
|
472
|
-
|
|
473
|
+
log.isWarnEnabled && log.warn('State machine in errored state');
|
|
473
474
|
return;
|
|
474
475
|
}
|
|
475
476
|
|
|
476
477
|
// now call ourselves recursively to deal with the next transition
|
|
477
|
-
|
|
478
|
+
log.isVerboseEnabled && log.verbose(`Bulk transfer model state machine transition completed in state: ${this.stateMachine.state}. Recursing to handle next transition.`);
|
|
478
479
|
return this.run();
|
|
479
480
|
}
|
|
480
481
|
catch(err) {
|
|
481
|
-
|
|
482
|
+
log.isErrorEnabled && log.push({ err }).error(`Error running bulk transfer model: ${err.message}`);
|
|
482
483
|
|
|
483
484
|
// as this function is recursive, we dont want to error the state machine multiple times
|
|
484
485
|
if(this.data.currentState !== 'errored') {
|
|
485
486
|
// err should not have a bulkTransferState property here!
|
|
486
487
|
if(err.bulkTransferState) {
|
|
487
|
-
|
|
488
|
+
log.isWarnEnabled && log.warn('State machine is broken');
|
|
488
489
|
}
|
|
489
490
|
// transition to errored state
|
|
490
491
|
await this.stateMachine.error(err);
|
|
@@ -426,16 +426,19 @@ class OutboundRequestToPayModel {
|
|
|
426
426
|
* Returns a promise that resolves when the state machine has reached a terminal state
|
|
427
427
|
*/
|
|
428
428
|
async run() {
|
|
429
|
+
const { transferId, transactionRequestId } = this.data;
|
|
430
|
+
const log = this._logger.push({ transferId, transactionRequestId });
|
|
429
431
|
try {
|
|
430
432
|
// run transitions based on incoming state
|
|
431
433
|
switch(this.data.currentState) {
|
|
432
434
|
case 'start':
|
|
433
435
|
// next transition is to resolvePayee
|
|
434
436
|
await this.stateMachine.resolvePayee();
|
|
435
|
-
|
|
437
|
+
log.isInfoEnabled && log.info('Payee resolved for RequestToPay transfer');
|
|
436
438
|
if(this.stateMachine.state === 'payeeResolved' && !this._autoAcceptR2PParty) {
|
|
437
439
|
//we break execution here and return the resolved party details to allow asynchronous accept or reject
|
|
438
440
|
//of the resolved party
|
|
441
|
+
log.isInfoEnabled && log.info('Waiting for asynchronous accept or reject of resolved party');
|
|
439
442
|
await this._save();
|
|
440
443
|
return this.getResponse();
|
|
441
444
|
}
|
|
@@ -444,12 +447,12 @@ class OutboundRequestToPayModel {
|
|
|
444
447
|
case 'payeeResolved':
|
|
445
448
|
// next transition is to requestQuote
|
|
446
449
|
await this.stateMachine.executeTransactionRequest();
|
|
447
|
-
|
|
450
|
+
log.isInfoEnabled && log.info('Transaction Request has been completed');
|
|
448
451
|
break;
|
|
449
452
|
|
|
450
453
|
case 'succeeded':
|
|
451
454
|
// all steps complete so return
|
|
452
|
-
|
|
455
|
+
log.isInfoEnabled && log.info('Transaction Request completed successfully');
|
|
453
456
|
await this._save();
|
|
454
457
|
return this.getResponse();
|
|
455
458
|
|
|
@@ -460,17 +463,17 @@ class OutboundRequestToPayModel {
|
|
|
460
463
|
}
|
|
461
464
|
|
|
462
465
|
// now call ourselves recursively to deal with the next transition
|
|
463
|
-
|
|
466
|
+
log.isVerboseEnabled && log.verbose(`RequestToPay model state machine transition completed in state: ${this.stateMachine.state}. Recursing to handle next transition.`);
|
|
464
467
|
return this.run();
|
|
465
468
|
}
|
|
466
469
|
catch(err) {
|
|
467
|
-
|
|
470
|
+
log.isErrorEnabled && log.error(`Error running RequestToPay model: ${err?.message}`);
|
|
468
471
|
|
|
469
472
|
// as this function is recursive, we dont want to error the state machine multiple times
|
|
470
473
|
if(this.data.currentState !== 'errored') {
|
|
471
474
|
// err should not have a lastError property here!
|
|
472
475
|
if(err.lastError) {
|
|
473
|
-
|
|
476
|
+
log.isWarnEnabled && log.warn('State machine is broken');
|
|
474
477
|
}
|
|
475
478
|
// transition to errored state
|
|
476
479
|
await this.stateMachine.error(err);
|