@felloh-org/lambda-wrapper 1.0.14 → 1.0.18
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/cli/seed/create-schema.js +2 -0
- package/dist/entity/agent-data/booking/index.js +26 -0
- package/dist/entity/agent-data/supplier/index.js +8 -0
- package/dist/entity/bank/disbursal/index.js +59 -6
- package/dist/entity/bank/index.js +3 -3
- package/dist/entity/bank/ledger/index.js +125 -0
- package/dist/entity/bank/settled-transaction/index.js +97 -0
- package/dist/entity/index.js +5 -1
- package/dist/entity/payment/index.js +5 -1
- package/dist/entity/payment/organisation-payment-provider/index.js +131 -0
- package/dist/entity/payment/payment-link/index.js +38 -0
- package/dist/entity/{bank/beneficiary-organisation → payment/payment-provider}/index.js +17 -30
- package/dist/entity/payment/transaction/index.js +64 -7
- package/dist/entity/total-processing/index.js +16 -0
- package/dist/entity/total-processing/transaction/index.js +126 -0
- package/dist/entity/total-processing/transaction-metadata/index.js +138 -0
- package/dist/entity/trust-payments/batch/index.js +85 -0
- package/dist/entity/trust-payments/chargeback/index.js +128 -0
- package/dist/entity/trust-payments/index.js +20 -0
- package/dist/entity/{bank/beneficiary-provider → trust-payments/merchant}/index.js +28 -27
- package/dist/entity/trust-payments/transaction/index.js +152 -0
- package/dist/entity/user/organisation/index.js +9 -6
- package/dist/entity/user/user/index.js +21 -3
- package/dist/event/user/password/changed/index.js +0 -1
- package/dist/index.js +100 -36
- package/dist/migration/bank/1642313073694-bank-initial.js +0 -10
- package/dist/migration/bank/1645101410250-bank_disbursal.js +28 -0
- package/dist/migration/bank/1645102501719-bank_disbursal_unique.js +17 -0
- package/dist/migration/bank/1645103420324-ledger.js +19 -0
- package/dist/migration/bank/1645103864454-ledger-defaults.js +15 -0
- package/dist/migration/bank/1645108723739-bank-settled-transaction.js +19 -0
- package/dist/migration/payment/1643717852114-payment-providers.js +19 -0
- package/dist/migration/payment/1643718714719-payment-providers-method.js +15 -0
- package/dist/migration/payment/1643719203328-payment-providers-method.js +22 -0
- package/dist/migration/payment/1644395533722-transaction_provider.js +15 -0
- package/dist/migration/payment/1644396011044-transaction_provider_ref.js +13 -0
- package/dist/migration/total-processing/1644309449035-tpro_transactions.js +13 -0
- package/dist/migration/total-processing/1644411639660-total_processing_entity.js +13 -0
- package/dist/migration/total-processing/1644842797566-relations.js +19 -0
- package/dist/migration/total-processing/1644926407236-tp_rec_nullable.js +13 -0
- package/dist/migration/total-processing/1644933594682-tp_rec_status.js +13 -0
- package/dist/migration/total-processing/1645010756173-tp_transaction_metadata.js +15 -0
- package/dist/migration/trust-payments/1644016335590-tp_merchants.js +13 -0
- package/dist/migration/trust-payments/1644018105481-tp_add_batch.js +15 -0
- package/dist/migration/trust-payments/1644020330502-tp_transaction.js +17 -0
- package/dist/migration/trust-payments/1644791277717-chargeback.js +15 -0
- package/dist/model/response/index.js +26 -32
- package/dist/model/response/status-codes.js +66 -0
- package/dist/service/event-bridge.js +11 -2
- package/dist/wrapper/index.js +9 -1
- package/package.json +2 -1
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.RESPONSE_HEADERS =
|
|
6
|
+
exports.default = exports.RESPONSE_HEADERS = void 0;
|
|
7
|
+
|
|
8
|
+
var _uuid = require("uuid");
|
|
7
9
|
|
|
8
10
|
var _ = _interopRequireDefault(require(".."));
|
|
9
11
|
|
|
12
|
+
var _statusCodes = _interopRequireDefault(require("./status-codes"));
|
|
13
|
+
|
|
10
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
15
|
|
|
12
16
|
/**
|
|
@@ -20,19 +24,11 @@ const RESPONSE_HEADERS = {
|
|
|
20
24
|
'Access-Control-Allow-Credentials': true // Required for cookies, authorization headers with HTTPS
|
|
21
25
|
|
|
22
26
|
};
|
|
23
|
-
/**
|
|
24
|
-
* Default message provided as part of response
|
|
25
|
-
*
|
|
26
|
-
* @type {string}
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
exports.RESPONSE_HEADERS = RESPONSE_HEADERS;
|
|
30
|
-
const DEFAULT_MESSAGE = 'success';
|
|
31
27
|
/**
|
|
32
28
|
* class ResponseModel
|
|
33
29
|
*/
|
|
34
30
|
|
|
35
|
-
exports.
|
|
31
|
+
exports.RESPONSE_HEADERS = RESPONSE_HEADERS;
|
|
36
32
|
|
|
37
33
|
class Index extends _.default {
|
|
38
34
|
/**
|
|
@@ -40,13 +36,18 @@ class Index extends _.default {
|
|
|
40
36
|
*
|
|
41
37
|
* @param data
|
|
42
38
|
* @param code
|
|
43
|
-
* @param message
|
|
44
39
|
*/
|
|
45
|
-
constructor(data = null, code =
|
|
40
|
+
constructor(data = null, code = 200) {
|
|
46
41
|
super();
|
|
47
42
|
this.body = {
|
|
48
43
|
data: data !== null ? data : {},
|
|
49
|
-
|
|
44
|
+
errors: {},
|
|
45
|
+
meta: {
|
|
46
|
+
code: code !== null ? code : {},
|
|
47
|
+
reason: _statusCodes.default[code].reason,
|
|
48
|
+
message: _statusCodes.default[code].message,
|
|
49
|
+
request_id: (0, _uuid.v4)()
|
|
50
|
+
}
|
|
50
51
|
};
|
|
51
52
|
this.code = code !== null ? code : {};
|
|
52
53
|
}
|
|
@@ -79,37 +80,30 @@ class Index extends _.default {
|
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
setCode(code) {
|
|
83
|
+
this.body.meta.reason = _statusCodes.default[code].reason;
|
|
84
|
+
this.body.meta.message = _statusCodes.default[code].message;
|
|
82
85
|
this.code = code;
|
|
86
|
+
this.body.meta.code = code;
|
|
83
87
|
}
|
|
84
88
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
getCode() {
|
|
92
|
-
return this.code;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Set message
|
|
96
|
-
*
|
|
97
|
-
* @param message
|
|
89
|
+
* Set a meta variable
|
|
90
|
+
* @param key
|
|
91
|
+
* @param value
|
|
98
92
|
*/
|
|
99
93
|
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
this.body.
|
|
95
|
+
setMetaVariable(key, value) {
|
|
96
|
+
this.body.meta[key] = value;
|
|
103
97
|
}
|
|
104
98
|
/**
|
|
105
|
-
* Get
|
|
99
|
+
* Get Status Code
|
|
106
100
|
*
|
|
107
|
-
* @returns {
|
|
101
|
+
* @returns {*}
|
|
108
102
|
*/
|
|
109
103
|
|
|
110
104
|
|
|
111
|
-
|
|
112
|
-
return this.
|
|
105
|
+
getCode() {
|
|
106
|
+
return this.code;
|
|
113
107
|
}
|
|
114
108
|
/**
|
|
115
109
|
* Geneate a response
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const ERRORS = {
|
|
8
|
+
200: {
|
|
9
|
+
reason: 'OK',
|
|
10
|
+
message: 'The request was successful'
|
|
11
|
+
},
|
|
12
|
+
201: {
|
|
13
|
+
reason: 'Created',
|
|
14
|
+
message: 'The request was successful, and a new resource was created'
|
|
15
|
+
},
|
|
16
|
+
204: {
|
|
17
|
+
reason: 'No Content',
|
|
18
|
+
message: 'The request was successful, but there is no response to send back'
|
|
19
|
+
},
|
|
20
|
+
400: {
|
|
21
|
+
reason: 'Bad Request',
|
|
22
|
+
message: 'The request was invalid, for example due to missing headers'
|
|
23
|
+
},
|
|
24
|
+
401: {
|
|
25
|
+
reason: 'Unauthorized',
|
|
26
|
+
message: 'An access token was not provided, or the provided token was invalid'
|
|
27
|
+
},
|
|
28
|
+
403: {
|
|
29
|
+
reason: 'Forbidden',
|
|
30
|
+
message: 'A valid access token was provided, but it did not have sufficient permissions'
|
|
31
|
+
},
|
|
32
|
+
404: {
|
|
33
|
+
reason: 'Not Found',
|
|
34
|
+
message: 'The requested resource does not exist'
|
|
35
|
+
},
|
|
36
|
+
406: {
|
|
37
|
+
reason: 'Not Acceptable',
|
|
38
|
+
message: 'The response type you requested with your Accept header is not supported'
|
|
39
|
+
},
|
|
40
|
+
422: {
|
|
41
|
+
reason: 'Unprocessable Entity',
|
|
42
|
+
message: 'A validation error occurred'
|
|
43
|
+
},
|
|
44
|
+
429: {
|
|
45
|
+
reason: 'Too Many Requests',
|
|
46
|
+
message: 'You made too many requests to the API in a short period of time'
|
|
47
|
+
},
|
|
48
|
+
500: {
|
|
49
|
+
reason: 'Internal Server Error',
|
|
50
|
+
message: 'Something went wrong on our side. Contact support or try again later.'
|
|
51
|
+
},
|
|
52
|
+
502: {
|
|
53
|
+
reason: 'Bad Gateway',
|
|
54
|
+
message: 'The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.'
|
|
55
|
+
},
|
|
56
|
+
503: {
|
|
57
|
+
reason: 'Service Unavailable',
|
|
58
|
+
message: 'The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay. Try again later.'
|
|
59
|
+
},
|
|
60
|
+
504: {
|
|
61
|
+
reason: 'Gateway Timeout',
|
|
62
|
+
message: 'The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request. Try again later.'
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var _default = ERRORS;
|
|
66
|
+
exports.default = _default;
|
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
9
9
|
|
|
10
|
+
var _dependencies = require("../config/dependencies");
|
|
11
|
+
|
|
10
12
|
var _dependencyAware = _interopRequireDefault(require("../dependency-injection/dependency-aware"));
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -20,8 +22,15 @@ const Eventbridge = new _awsSdk.default.EventBridge({
|
|
|
20
22
|
|
|
21
23
|
class EventBridge extends _dependencyAware.default {
|
|
22
24
|
async put(eventModel) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
+
const Logger = this.getContainer().get(_dependencies.DEFINITIONS.LOGGER);
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const currentUser = JSON.parse(this.getContainer().getEvent().requestContext.authorizer.userEntity);
|
|
29
|
+
eventModel.setUserBy(currentUser);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
Logger.info('no current user to event bridge event');
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
await Eventbridge.putEvents({
|
|
26
35
|
Entries: [eventModel.getBase()]
|
|
27
36
|
}).promise();
|
package/dist/wrapper/index.js
CHANGED
|
@@ -24,7 +24,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
24
|
* @param outcome
|
|
25
25
|
*/
|
|
26
26
|
const handleSuccess = (di, outcome) => {
|
|
27
|
-
const logger = di.get(_dependencies.DEFINITIONS.LOGGER);
|
|
27
|
+
const logger = di.get(_dependencies.DEFINITIONS.LOGGER);
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const requestID = JSON.parse(outcome.body).meta.request_id;
|
|
31
|
+
logger.metric('lambda.request_id', requestID);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
logger.info('unable to set request id');
|
|
34
|
+
} // Outcome may be undefined as not all lambdas have a return value.
|
|
35
|
+
|
|
28
36
|
|
|
29
37
|
logger.metric('lambda.statusCode', outcome && outcome.statusCode || 200);
|
|
30
38
|
return outcome;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@felloh-org/lambda-wrapper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Lambda wrapper for all Felloh Serverless Projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"orm:migration:generate": "rm -rf dist && yarn build:orm && ./node_modules/.bin/typeorm migration:generate -o -n",
|
|
11
11
|
"orm:migration:run": "rm -rf dist && yarn build:orm && ./node_modules/.bin/typeorm migration:run",
|
|
12
12
|
"orm:schema:create": "babel-node ./cli/seed/create-schema.js",
|
|
13
|
+
"orm:revert": "rm -rf dist && yarn build:orm && ./node_modules/.bin/typeorm migration:revert",
|
|
13
14
|
"orm:seed": "babel-node ./cli/seed/index.js",
|
|
14
15
|
"start": "yarn build -w",
|
|
15
16
|
"test": "jest --coverage"
|