@mojaloop/sdk-scheme-adapter 12.2.3 → 13.0.1

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 (60) hide show
  1. package/.env.example +3 -0
  2. package/CHANGELOG.md +26 -0
  3. package/audit-resolve.json +71 -1
  4. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/trigger_templates/transaction_request_followup.json +2 -2
  5. package/docker/ml-testing-toolkit/spec_files/rules_callback/default.json +7 -7
  6. package/docker/ml-testing-toolkit/spec_files/rules_response/default.json +16 -16
  7. package/docker/ml-testing-toolkit/spec_files/rules_response/default_pisp_rules.json +5 -5
  8. package/docker/ml-testing-toolkit/spec_files/rules_validation/default.json +10 -10
  9. package/package.json +5 -3
  10. package/src/InboundServer/handlers.js +114 -52
  11. package/src/OutboundServer/api.yaml +54 -3
  12. package/src/OutboundServer/api_interfaces/openapi.d.ts +24 -3
  13. package/src/OutboundServer/api_template/components/schemas/accountsResponse.yaml +9 -0
  14. package/src/OutboundServer/api_template/components/schemas/transferRequest.yaml +3 -0
  15. package/src/OutboundServer/api_template/components/schemas/transferResponse.yaml +28 -2
  16. package/src/OutboundServer/api_template/components/schemas/transferStatusResponse.yaml +8 -1
  17. package/src/OutboundServer/handlers.js +4 -1
  18. package/src/OutboundServer/index.js +6 -4
  19. package/src/config.js +1 -1
  20. package/src/index.js +198 -8
  21. package/src/lib/cache.js +110 -52
  22. package/src/lib/metrics.js +148 -0
  23. package/src/lib/model/AccountsModel.js +13 -11
  24. package/src/lib/model/InboundTransfersModel.js +166 -24
  25. package/src/lib/model/OutboundRequestToPayModel.js +5 -6
  26. package/src/lib/model/OutboundRequestToPayTransferModel.js +2 -2
  27. package/src/lib/model/OutboundTransfersModel.js +314 -52
  28. package/src/lib/model/PartiesModel.js +1 -1
  29. package/src/lib/model/common/BackendError.js +28 -4
  30. package/src/lib/model/common/index.js +2 -1
  31. package/test/__mocks__/@mojaloop/sdk-standard-components.js +3 -2
  32. package/test/__mocks__/redis.js +4 -0
  33. package/test/integration/lib/Outbound/parties.test.js +1 -1
  34. package/test/unit/InboundServer.test.js +9 -9
  35. package/test/unit/TestServer.test.js +11 -13
  36. package/test/unit/api/accounts/data/postAccountsErrorMojaloopResponse.json +11 -3
  37. package/test/unit/api/accounts/data/postAccountsSuccessResponse.json +14 -0
  38. package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError1.json +13 -0
  39. package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError2.json +18 -0
  40. package/test/unit/api/accounts/utils.js +15 -1
  41. package/test/unit/api/transfers/data/getTransfersCommittedResponse.json +18 -15
  42. package/test/unit/api/transfers/data/getTransfersErrorNotFound.json +1 -0
  43. package/test/unit/api/transfers/data/postTransfersErrorMojaloopResponse.json +9 -0
  44. package/test/unit/api/transfers/data/postTransfersErrorTimeoutResponse.json +1 -0
  45. package/test/unit/api/transfers/data/postTransfersSuccessResponse.json +74 -47
  46. package/test/unit/api/transfers/utils.js +85 -4
  47. package/test/unit/api/utils.js +4 -1
  48. package/test/unit/data/commonHttpHeaders.json +1 -0
  49. package/test/unit/inboundApi/handlers.test.js +45 -14
  50. package/test/unit/index.test.js +95 -3
  51. package/test/unit/lib/model/AccountsModel.test.js +9 -6
  52. package/test/unit/lib/model/InboundTransfersModel.test.js +210 -30
  53. package/test/unit/lib/model/OutboundRequestToPayModel.test.js +1 -1
  54. package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +3 -3
  55. package/test/unit/lib/model/OutboundTransfersModel.test.js +862 -157
  56. package/test/unit/lib/model/data/defaultConfig.json +9 -9
  57. package/test/unit/lib/model/data/mockArguments.json +97 -40
  58. package/test/unit/lib/model/data/payeeParty.json +13 -11
  59. package/test/unit/lib/model/data/quoteResponse.json +36 -25
  60. package/test/unit/lib/model/data/transferFulfil.json +5 -3
@@ -159,7 +159,10 @@ const postQuotes = async (ctx) => {
159
159
  const sourceFspId = ctx.request.headers['fspiop-source'];
160
160
 
161
161
  // use the model to handle the request
162
- const response = await model.quoteRequest(ctx.request.body, sourceFspId);
162
+ const response = await model.quoteRequest({
163
+ body: ctx.request.body,
164
+ headers: ctx.request.headers,
165
+ }, sourceFspId);
163
166
 
164
167
  // log the result
165
168
  ctx.state.logger.push({ response }).log('Inbound transfers model handled POST /quotes request');
@@ -196,7 +199,10 @@ const postTransfers = async (ctx) => {
196
199
  const sourceFspId = ctx.request.headers['fspiop-source'];
197
200
 
198
201
  // use the model to handle the request
199
- const response = await model.prepareTransfer(ctx.request.body, sourceFspId);
202
+ const response = await model.prepareTransfer({
203
+ body: ctx.request.body,
204
+ headers: ctx.request.headers,
205
+ }, sourceFspId);
200
206
 
201
207
  // log the result
202
208
  ctx.state.logger.push({ response }).log('Inbound transfers model handled POST /transfers request');
@@ -299,8 +305,10 @@ const putAuthorizationsById = async (ctx) => {
299
305
  // publish an event onto the cache for subscribers to action
300
306
  await ctx.state.cache.publish(cacheId, {
301
307
  type: 'authorizationsResponse',
302
- data: ctx.request.body,
303
- headers: ctx.request.headers
308
+ data: {
309
+ body: ctx.request.body,
310
+ headers: ctx.request.headers
311
+ }
304
312
  });
305
313
  ctx.response.status = 200;
306
314
  };
@@ -313,7 +321,10 @@ const putParticipantsById = async (ctx) => {
313
321
  // publish an event onto the cache for subscribers to action
314
322
  await ctx.state.cache.publish(`ac_${ctx.state.path.params.ID}`, {
315
323
  type: 'accountsCreationSuccessfulResponse',
316
- data: ctx.request.body
324
+ data: {
325
+ body: ctx.request.body,
326
+ headers: ctx.request.headers
327
+ }
317
328
  });
318
329
 
319
330
  ctx.response.status = 200;
@@ -327,7 +338,10 @@ const putParticipantsByIdError = async (ctx) => {
327
338
  // publish an event onto the cache for subscribers to action
328
339
  await ctx.state.cache.publish(`ac_${ctx.state.path.params.ID}`, {
329
340
  type: 'accountsCreationErrorResponse',
330
- data: ctx.request.body
341
+ data: {
342
+ body: ctx.request.body,
343
+ headers: ctx.request.headers
344
+ }
331
345
  });
332
346
 
333
347
  ctx.response.status = 200;
@@ -347,7 +361,12 @@ const putParticipantsByTypeAndId = async (ctx) => {
347
361
 
348
362
  // publish an event onto the cache for subscribers to action
349
363
  const cacheId = `${idType}_${idValue}` + (idSubValue ? `_${idSubValue}` : '');
350
- await ctx.state.cache.publish(cacheId, ctx.request.body);
364
+ await ctx.state.cache.publish(cacheId, {
365
+ data: {
366
+ body: ctx.request.body,
367
+ headers: ctx.request.headers
368
+ }
369
+ });
351
370
  ctx.response.status = 200;
352
371
  } else {
353
372
  // SDK does not make participants requests so we should not expect any calls to this method
@@ -370,7 +389,12 @@ const putParticipantsByTypeAndIdError = async(ctx) => {
370
389
  // the subscriber will notice the body contains an errorInformation property
371
390
  // and recognise it as an error response
372
391
  const cacheId = `${idType}_${idValue}` + (idSubValue ? `_${idSubValue}` : '');
373
- await ctx.state.cache.publish(cacheId, ctx.request.body);
392
+ await ctx.state.cache.publish(cacheId, {
393
+ data: {
394
+ body: ctx.request.body,
395
+ headers: ctx.request.headers
396
+ }
397
+ });
374
398
 
375
399
  ctx.response.status = 200;
376
400
  ctx.response.body = '';
@@ -389,32 +413,10 @@ const putPartiesByTypeAndId = async (ctx) => {
389
413
  // publish an event onto the cache for subscribers to finish the action
390
414
  await PartiesModel.triggerDeferredJob({
391
415
  cache: ctx.state.cache,
392
- message: ctx.request.body,
393
- args: {
394
- type: idType,
395
- id: idValue,
396
- subId: idSubValue
397
- }
398
- });
399
-
400
- ctx.response.status = 200;
401
- };
402
-
403
- /**
404
- * Handles a PUT /parties/{Type}/{ID}/error request. This is an error response to a GET /parties/{Type}/{ID} request
405
- */
406
- const putPartiesByTypeAndIdError = async(ctx) => {
407
- const idType = ctx.state.path.params.Type;
408
- const idValue = ctx.state.path.params.ID;
409
- const idSubValue = ctx.state.path.params.SubId;
410
-
411
- // publish an event onto the cache for subscribers to action
412
- // note that we publish the event the same way we publish a success PUT
413
- // the subscriber will notice the body contains an errorInformation property
414
- // and recognizes it as an error response
415
- await PartiesModel.triggerDeferredJob({
416
- cache: ctx.state.cache,
417
- message: ctx.request.body,
416
+ message: {
417
+ headers: ctx.request.headers,
418
+ body: ctx.request.body
419
+ },
418
420
  args: {
419
421
  type: idType,
420
422
  id: idValue,
@@ -423,10 +425,8 @@ const putPartiesByTypeAndIdError = async(ctx) => {
423
425
  });
424
426
 
425
427
  ctx.response.status = 200;
426
- ctx.response.body = '';
427
428
  };
428
429
 
429
-
430
430
  /**
431
431
  * Handles a PUT /quotes/{ID}. This is a response to a POST /quotes request
432
432
  */
@@ -437,14 +437,19 @@ const putQuoteById = async (ctx) => {
437
437
  // publish an event onto the cache for subscribers to action
438
438
  await ctx.state.cache.publish(`qt_${ctx.state.path.params.ID}`, {
439
439
  type: 'quoteResponse',
440
- data: ctx.request.body,
441
- headers: ctx.request.headers
440
+ data: {
441
+ body: ctx.request.body,
442
+ headers: ctx.request.headers
443
+ }
442
444
  });
443
445
 
444
446
  // duplicate publication until legacy code refactored
445
447
  await QuotesModel.triggerDeferredJob({
446
448
  cache: ctx.state.cache,
447
- message: ctx.request.body,
449
+ message: {
450
+ headers: ctx.request.headers,
451
+ body: ctx.request.body
452
+ },
448
453
  args: {
449
454
  quoteId: ctx.state.path.params.ID
450
455
  }
@@ -464,7 +469,10 @@ const putQuotesByIdError = async (ctx) => {
464
469
  // publish an event onto the cache for subscribers to action
465
470
  await ctx.state.cache.publish(`qt_${ctx.state.path.params.ID}`, {
466
471
  type: 'quoteResponseError',
467
- data: ctx.request.body
472
+ data: {
473
+ body: ctx.request.body,
474
+ headers: ctx.request.headers
475
+ }
468
476
  });
469
477
 
470
478
  // duplicate publication until legacy code refactored
@@ -524,8 +532,10 @@ const putTransactionRequestsById = async (ctx) => {
524
532
  // publish an event onto the cache for subscribers to action
525
533
  await ctx.state.cache.publish(`txnreq_${ctx.state.path.params.ID}`, {
526
534
  type: 'transactionRequestResponse',
527
- data: ctx.request.body,
528
- headers: ctx.request.headers
535
+ data: {
536
+ body: ctx.request.body,
537
+ headers: ctx.request.headers
538
+ }
529
539
  });
530
540
 
531
541
  ctx.response.status = 200;
@@ -541,12 +551,18 @@ const putTransfersById = async (ctx) => {
541
551
  // publish an event onto the cache for subscribers to action
542
552
  await ctx.state.cache.publish(`tf_${ctx.state.path.params.ID}`, {
543
553
  type: 'transferFulfil',
544
- data: ctx.request.body
554
+ data: {
555
+ body: ctx.request.body,
556
+ headers: ctx.request.headers
557
+ }
545
558
  });
546
559
 
547
560
  await TransfersModel.triggerDeferredJob({
548
561
  cache: ctx.state.cache,
549
- message: ctx.request.body,
562
+ message: {
563
+ body: ctx.request.body,
564
+ headers: ctx.request.headers
565
+ },
550
566
  args: {
551
567
  transferId: ctx.state.path.params.ID,
552
568
  }
@@ -583,6 +599,35 @@ const patchTransfersById = async (ctx) => {
583
599
  log('Inbound transfers model handled PATCH /transfers/{ID} request');
584
600
  };
585
601
 
602
+ /**
603
+ * Handles a PUT /parties/{Type}/{ID}/error request. This is an error response to a GET /parties/{Type}/{ID} request
604
+ */
605
+ const putPartiesByTypeAndIdError = async(ctx) => {
606
+ const idType = ctx.state.path.params.Type;
607
+ const idValue = ctx.state.path.params.ID;
608
+ const idSubValue = ctx.state.path.params.SubId;
609
+
610
+ // publish an event onto the cache for subscribers to action
611
+ // note that we publish the event the same way we publish a success PUT
612
+ // the subscriber will notice the body contains an errorInformation property
613
+ // and recognizes it as an error response
614
+ await PartiesModel.triggerDeferredJob({
615
+ cache: ctx.state.cache,
616
+ message: {
617
+ headers: ctx.request.headers,
618
+ body: ctx.request.body
619
+ },
620
+ args: {
621
+ type: idType,
622
+ id: idValue,
623
+ subId: idSubValue
624
+ }
625
+ });
626
+
627
+ ctx.response.status = 200;
628
+ ctx.response.body = '';
629
+ };
630
+
586
631
  /**
587
632
  * Handles a PUT /transfers/{ID}/error. This is an error response to a POST /transfers request
588
633
  */
@@ -593,12 +638,18 @@ const putTransfersByIdError = async (ctx) => {
593
638
  // publish an event onto the cache for subscribers to action
594
639
  await ctx.state.cache.publish(`tf_${ctx.state.path.params.ID}`, {
595
640
  type: 'transferError',
596
- data: ctx.request.body
641
+ data: {
642
+ body: ctx.request.body,
643
+ headers: ctx.request.headers
644
+ }
597
645
  });
598
646
 
599
647
  await TransfersModel.triggerDeferredJob({
600
648
  cache: ctx.state.cache,
601
- message: ctx.request.body,
649
+ message: {
650
+ body: ctx.request.body,
651
+ headers: ctx.request.headers
652
+ },
602
653
  args: {
603
654
  transferId: ctx.state.path.params.ID,
604
655
  }
@@ -686,8 +737,10 @@ const putBulkQuotesById = async (ctx) => {
686
737
  // publish an event onto the cache for subscribers to action
687
738
  await ctx.state.cache.publish(`bulkQuotes_${ctx.state.path.params.ID}`, {
688
739
  type: 'bulkQuoteResponse',
689
- data: ctx.request.body,
690
- headers: ctx.request.headers
740
+ data: {
741
+ body: ctx.request.body,
742
+ headers: ctx.request.headers
743
+ }
691
744
  });
692
745
 
693
746
  ctx.response.status = 200;
@@ -700,7 +753,10 @@ const putBulkQuotesByIdError = async(ctx) => {
700
753
  // publish an event onto the cache for subscribers to action
701
754
  await ctx.state.cache.publish(`bulkQuotes_${ctx.state.path.params.ID}`, {
702
755
  type: 'bulkQuoteResponseError',
703
- data: ctx.request.body
756
+ data: {
757
+ body: ctx.request.body,
758
+ headers: ctx.request.headers
759
+ }
704
760
  });
705
761
 
706
762
  ctx.response.status = 200;
@@ -785,8 +841,10 @@ const putBulkTransfersById = async (ctx) => {
785
841
  // publish an event onto the cache for subscribers to action
786
842
  await ctx.state.cache.publish(`bulkTransfer_${ctx.state.path.params.ID}`, {
787
843
  type: 'bulkTransferResponse',
788
- data: ctx.request.body,
789
- headers: ctx.request.headers
844
+ data: {
845
+ body: ctx.request.body,
846
+ headers: ctx.request.headers
847
+ }
790
848
  });
791
849
 
792
850
  ctx.response.status = 200;
@@ -799,13 +857,17 @@ const putBulkTransfersByIdError = async(ctx) => {
799
857
  // publish an event onto the cache for subscribers to action
800
858
  await ctx.state.cache.publish(`bulkTransfer_${ctx.state.path.params.ID}`, {
801
859
  type: 'bulkTransferResponseError',
802
- data: ctx.request.body
860
+ data: {
861
+ body: ctx.request.body,
862
+ headers: ctx.request.headers
863
+ }
803
864
  });
804
865
 
805
866
  ctx.response.status = 200;
806
867
  ctx.response.body = '';
807
868
  };
808
869
 
870
+
809
871
  const healthCheck = async(ctx) => {
810
872
  ctx.response.status = 200;
811
873
  ctx.response.body = '';
@@ -1002,6 +1002,12 @@ components:
1002
1002
  $ref: '#/components/schemas/extensionListEmptiable'
1003
1003
  transferRequestExtensions:
1004
1004
  $ref: '#/components/schemas/extensionListEmptiable'
1005
+ skipPartyLookup:
1006
+ description: >-
1007
+ Set to true if supplying an FSPID for the payee party and no party
1008
+ resolution is needed. This may be useful is a previous party
1009
+ resolution has been performed.
1010
+ type: boolean
1005
1011
  CorrelationId:
1006
1012
  title: CorrelationId
1007
1013
  type: string
@@ -1273,8 +1279,24 @@ components:
1273
1279
  $ref: '#/components/schemas/transferStatus'
1274
1280
  quoteId:
1275
1281
  $ref: '#/components/schemas/CorrelationId'
1282
+ getPartiesResponse:
1283
+ type: object
1284
+ required:
1285
+ - body
1286
+ properties:
1287
+ body:
1288
+ type: object
1289
+ headers:
1290
+ type: object
1276
1291
  quoteResponse:
1277
- $ref: '#/components/schemas/QuotesIDPutResponse'
1292
+ type: object
1293
+ required:
1294
+ - body
1295
+ properties:
1296
+ body:
1297
+ $ref: '#/components/schemas/QuotesIDPutResponse'
1298
+ headers:
1299
+ type: object
1278
1300
  quoteResponseSource:
1279
1301
  type: string
1280
1302
  description: >
@@ -1283,7 +1305,14 @@ components:
1283
1305
  account in the case of a FOREX transfer. i.e. it may be a FOREX
1284
1306
  gateway.
1285
1307
  fulfil:
1286
- $ref: '#/components/schemas/TransfersIDPutResponse'
1308
+ type: object
1309
+ required:
1310
+ - body
1311
+ properties:
1312
+ body:
1313
+ $ref: '#/components/schemas/TransfersIDPutResponse'
1314
+ headers:
1315
+ type: object
1287
1316
  lastError:
1288
1317
  description: >
1289
1318
  Object representing the last error to occur during a transfer
@@ -1291,6 +1320,12 @@ components:
1291
1320
  entity in the scheme or an object representing other types of error
1292
1321
  e.g. exceptions that may occur inside the scheme adapter.
1293
1322
  $ref: '#/components/schemas/transferError'
1323
+ skipPartyLookup:
1324
+ description: >-
1325
+ Set to true if supplying an FSPID for the payee party and no party
1326
+ resolution is needed. This may be useful is a previous party
1327
+ resolution has been performed.
1328
+ type: boolean
1294
1329
  errorResponse:
1295
1330
  type: object
1296
1331
  properties:
@@ -1321,7 +1356,14 @@ components:
1321
1356
  currentState:
1322
1357
  $ref: '#/components/schemas/transferStatus'
1323
1358
  fulfil:
1324
- $ref: '#/components/schemas/TransfersIDPutResponse'
1359
+ type: object
1360
+ required:
1361
+ - body
1362
+ properties:
1363
+ body:
1364
+ $ref: '#/components/schemas/TransfersIDPutResponse'
1365
+ headers:
1366
+ type: object
1325
1367
  transferContinuationAcceptParty:
1326
1368
  type: object
1327
1369
  required:
@@ -1993,6 +2035,15 @@ components:
1993
2035
  $ref: '#/components/schemas/accountsCreationState'
1994
2036
  lastError:
1995
2037
  $ref: '#/components/schemas/transferError'
2038
+ postAccountsResponse:
2039
+ type: object
2040
+ required:
2041
+ - body
2042
+ properties:
2043
+ body:
2044
+ type: object
2045
+ headers:
2046
+ type: object
1996
2047
  errorAccountsResponse:
1997
2048
  allOf:
1998
2049
  - $ref: '#/components/schemas/errorResponse'
@@ -633,6 +633,8 @@ export interface components {
633
633
  note?: components["schemas"]["Note"];
634
634
  quoteRequestExtensions?: components["schemas"]["extensionListEmptiable"];
635
635
  transferRequestExtensions?: components["schemas"]["extensionListEmptiable"];
636
+ /** Set to true if supplying an FSPID for the payee party and no party resolution is needed. This may be useful is a previous party resolution has been performed. */
637
+ skipPartyLookup?: boolean;
636
638
  };
637
639
  /** Identifier that correlates all messages of the same sequence. The API data type UUID (Universally Unique Identifier) is a JSON String in canonical format, conforming to [RFC 4122](https://tools.ietf.org/html/rfc4122), that is restricted by a regular expression for interoperability reasons. A UUID is always 36 characters long, 32 hexadecimal symbols and 4 dashes (‘-‘). */
638
640
  CorrelationId: string;
@@ -728,12 +730,24 @@ export interface components {
728
730
  note?: components["schemas"]["Note"];
729
731
  currentState?: components["schemas"]["transferStatus"];
730
732
  quoteId?: components["schemas"]["CorrelationId"];
731
- quoteResponse?: components["schemas"]["QuotesIDPutResponse"];
733
+ getPartiesResponse?: {
734
+ body: { [key: string]: unknown };
735
+ headers?: { [key: string]: unknown };
736
+ };
737
+ quoteResponse?: {
738
+ body: components["schemas"]["QuotesIDPutResponse"];
739
+ headers?: { [key: string]: unknown };
740
+ };
732
741
  /** FSPID of the entity that supplied the quote response. This may not be the same as the FSPID of the entity which owns the end user account in the case of a FOREX transfer. i.e. it may be a FOREX gateway. */
733
742
  quoteResponseSource?: string;
734
- fulfil?: components["schemas"]["TransfersIDPutResponse"];
743
+ fulfil?: {
744
+ body: components["schemas"]["TransfersIDPutResponse"];
745
+ headers?: { [key: string]: unknown };
746
+ };
735
747
  /** Object representing the last error to occur during a transfer process. This may be a Mojaloop API error returned from another entity in the scheme or an object representing other types of error e.g. exceptions that may occur inside the scheme adapter. */
736
748
  lastError?: components["schemas"]["transferError"];
749
+ /** Set to true if supplying an FSPID for the payee party and no party resolution is needed. This may be useful is a previous party resolution has been performed. */
750
+ skipPartyLookup?: boolean;
737
751
  };
738
752
  errorResponse: {
739
753
  /** Error code as string. */
@@ -747,7 +761,10 @@ export interface components {
747
761
  transferStatusResponse: {
748
762
  transferId: components["schemas"]["CorrelationId"];
749
763
  currentState: components["schemas"]["transferStatus"];
750
- fulfil: components["schemas"]["TransfersIDPutResponse"];
764
+ fulfil: {
765
+ body: components["schemas"]["TransfersIDPutResponse"];
766
+ headers?: { [key: string]: unknown };
767
+ };
751
768
  };
752
769
  transferContinuationAcceptParty: {
753
770
  acceptParty: true;
@@ -1011,6 +1028,10 @@ export interface components {
1011
1028
  response?: components["schemas"]["accountCreationStatus"];
1012
1029
  currentState?: components["schemas"]["accountsCreationState"];
1013
1030
  lastError?: components["schemas"]["transferError"];
1031
+ postAccountsResponse?: {
1032
+ body: { [key: string]: unknown };
1033
+ headers?: { [key: string]: unknown };
1034
+ };
1014
1035
  };
1015
1036
  errorAccountsResponse: components["schemas"]["errorResponse"] & {
1016
1037
  executionState: components["schemas"]["accountsResponse"];
@@ -13,3 +13,12 @@ properties:
13
13
  $ref: ./accountsCreationState.yaml
14
14
  lastError:
15
15
  $ref: ./transferError.yaml
16
+ postAccountsResponse:
17
+ type: object
18
+ required:
19
+ - body
20
+ properties:
21
+ body:
22
+ type: object
23
+ headers:
24
+ type: object
@@ -35,3 +35,6 @@ properties:
35
35
  $ref: ./extensionListEmptiable.yaml
36
36
  transferRequestExtensions:
37
37
  $ref: ./extensionListEmptiable.yaml
38
+ skipPartyLookup:
39
+ description: Set to true if supplying an FSPID for the payee party and no party resolution is needed. This may be useful is a previous party resolution has been performed.
40
+ type: boolean
@@ -39,8 +39,24 @@ properties:
39
39
  quoteId:
40
40
  $ref: >-
41
41
  ../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/CorrelationId.yaml
42
+ getPartiesResponse:
43
+ type: object
44
+ required:
45
+ - body
46
+ properties:
47
+ body:
48
+ type: object
49
+ headers:
50
+ type: object
42
51
  quoteResponse:
43
- $ref: ./quote.yaml
52
+ type: object
53
+ required:
54
+ - body
55
+ properties:
56
+ body:
57
+ $ref: './quote.yaml'
58
+ headers:
59
+ type: object
44
60
  quoteResponseSource:
45
61
  type: string
46
62
  description: >
@@ -48,7 +64,14 @@ properties:
48
64
  same as the FSPID of the entity which owns the end user account in the
49
65
  case of a FOREX transfer. i.e. it may be a FOREX gateway.
50
66
  fulfil:
51
- $ref: ./transferFulfilment.yaml
67
+ type: object
68
+ required:
69
+ - body
70
+ properties:
71
+ body:
72
+ $ref: ./transferFulfilment.yaml
73
+ headers:
74
+ type: object
52
75
  lastError:
53
76
  description: >
54
77
  Object representing the last error to occur during a transfer process.
@@ -56,3 +79,6 @@ properties:
56
79
  scheme or an object representing other types of error e.g. exceptions that
57
80
  may occur inside the scheme adapter.
58
81
  $ref: ./transferError.yaml
82
+ skipPartyLookup:
83
+ description: Set to true if supplying an FSPID for the payee party and no party resolution is needed. This may be useful is a previous party resolution has been performed.
84
+ type: boolean
@@ -10,4 +10,11 @@ properties:
10
10
  currentState:
11
11
  $ref: ./transferStatus.yaml
12
12
  fulfil:
13
- $ref: ./transferFulfilment.yaml
13
+ type: object
14
+ required:
15
+ - body
16
+ properties:
17
+ body:
18
+ $ref: ./transferFulfilment.yaml
19
+ headers:
20
+ type: object
@@ -112,6 +112,7 @@ const postTransfers = async (ctx) => {
112
112
  cache: ctx.state.cache,
113
113
  logger: ctx.state.logger,
114
114
  wso2: ctx.state.wso2,
115
+ metricsClient: ctx.state.metricsClient,
115
116
  });
116
117
 
117
118
  // initialize the transfer model and start it running
@@ -144,6 +145,7 @@ const getTransfers = async (ctx) => {
144
145
  cache: ctx.state.cache,
145
146
  logger: ctx.state.logger,
146
147
  wso2: ctx.state.wso2,
148
+ metricsClient: ctx.state.metricsClient,
147
149
  });
148
150
 
149
151
  // initialize the transfer model and start it running
@@ -172,6 +174,7 @@ const putTransfers = async (ctx) => {
172
174
  cache: ctx.state.cache,
173
175
  logger: ctx.state.logger,
174
176
  wso2: ctx.state.wso2,
177
+ metricsClient: ctx.state.metricsClient,
175
178
  });
176
179
 
177
180
  // TODO: check the incoming body to reject party or quote when requested to do so
@@ -179,7 +182,7 @@ const putTransfers = async (ctx) => {
179
182
  // load the transfer model from cache and start it running again
180
183
  await model.load(ctx.state.path.params.transferId);
181
184
 
182
- const response = await model.run();
185
+ const response = await model.run(ctx.request.body);
183
186
 
184
187
  // return the result
185
188
  ctx.response.status = 200;
@@ -28,12 +28,13 @@ const middlewares = require('./middlewares');
28
28
  const endpointRegex = /\/.*/g;
29
29
 
30
30
  class OutboundApi extends EventEmitter {
31
- constructor(conf, logger, cache, validator) {
31
+ constructor(conf, logger, cache, validator, metricsClient) {
32
32
  super({ captureExceptions: true });
33
33
  this._logger = logger;
34
34
  this._api = new Koa();
35
35
  this._conf = conf;
36
36
  this._cache = cache;
37
+ this._metricsClient = metricsClient;
37
38
 
38
39
  this._wso2 = {
39
40
  auth: new WSO2Auth({
@@ -54,7 +55,7 @@ class OutboundApi extends EventEmitter {
54
55
  this._api.use(middlewares.createErrorHandler(this._logger));
55
56
  this._api.use(middlewares.createRequestIdGenerator());
56
57
  this._api.use(koaBody()); // outbound always expects application/json
57
- this._api.use(middlewares.applyState({ cache, wso2: this._wso2, conf }));
58
+ this._api.use(middlewares.applyState({ cache, wso2: this._wso2, conf, metricsClient }));
58
59
  this._api.use(middlewares.createLogger(this._logger));
59
60
 
60
61
  //Note that we strip off any path on peerEndpoint config after the origin.
@@ -91,7 +92,7 @@ class OutboundApi extends EventEmitter {
91
92
  }
92
93
 
93
94
  class OutboundServer extends EventEmitter {
94
- constructor(conf, logger, cache) {
95
+ constructor(conf, logger, cache, metricsClient) {
95
96
  super({ captureExceptions: true });
96
97
  this._validator = new Validate();
97
98
  this._conf = conf;
@@ -101,7 +102,8 @@ class OutboundServer extends EventEmitter {
101
102
  conf,
102
103
  this._logger.push({ component: 'api' }),
103
104
  cache,
104
- this._validator
105
+ this._validator,
106
+ metricsClient
105
107
  );
106
108
  this._api.on('error', (...args) => {
107
109
  this.emit('error', ...args);
package/src/config.js CHANGED
@@ -182,5 +182,5 @@ module.exports = {
182
182
  // the `transactionId` to retrieve the quote from cache
183
183
  allowDifferentTransferTransactionId: env.get('ALLOW_DIFFERENT_TRANSFER_TRANSACTION_ID').default('false').asBool(),
184
184
 
185
- pm4mlEnabled: env.get('PM4ML_ENABLED').default('false').asBool()
185
+ pm4mlEnabled: env.get('PM4ML_ENABLED').default('false').asBool(),
186
186
  };