@felloh-org/lambda-wrapper 1.0.15 → 1.0.16
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/dist/entity/agent-data/booking/index.js +26 -0
- package/dist/entity/agent-data/supplier/index.js +8 -0
- package/dist/entity/payment/payment-link/index.js +38 -0
- package/dist/entity/payment/transaction/index.js +30 -0
- package/dist/entity/user/organisation/index.js +7 -0
- package/dist/entity/user/user/index.js +20 -0
- package/dist/model/response/index.js +19 -1
- package/dist/wrapper/index.js +9 -1
- package/package.json +1 -1
|
@@ -72,6 +72,32 @@ let Booking = (_dec = (0, _typeorm.Entity)({
|
|
|
72
72
|
_initializerDefineProperty(this, "created_at", _descriptor10, this);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Get Public Data
|
|
77
|
+
* @returns {{departure_date: string, created_at: Date, booking_reference: string, id: (*|string), customer_name: string, email: string, return_date: string}}
|
|
78
|
+
*/
|
|
79
|
+
getPublicData() {
|
|
80
|
+
const response = {
|
|
81
|
+
id: this.id,
|
|
82
|
+
booking_reference: this.booking_reference,
|
|
83
|
+
created_at: this.created_at,
|
|
84
|
+
customer_name: this.customer_name,
|
|
85
|
+
departure_date: this.departure_date,
|
|
86
|
+
return_date: this.return_date,
|
|
87
|
+
email: this.email
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
if (typeof this.transactions !== 'undefined') {
|
|
91
|
+
response.transactions = this.transactions.map(transaction => transaction.getPublicCompactData());
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (typeof this.user.id !== 'undefined') {
|
|
95
|
+
response.user = this.user.getPublicCompactData();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return response;
|
|
99
|
+
}
|
|
100
|
+
|
|
75
101
|
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
|
|
76
102
|
configurable: true,
|
|
77
103
|
enumerable: true,
|
|
@@ -41,6 +41,14 @@ let Supplier = (_dec = (0, _typeorm.Entity)({
|
|
|
41
41
|
_initializerDefineProperty(this, "created_at", _descriptor4, this);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
getPublicData() {
|
|
45
|
+
return {
|
|
46
|
+
id: this.id,
|
|
47
|
+
name: this.name,
|
|
48
|
+
created_at: this.created_at
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
|
|
45
53
|
configurable: true,
|
|
46
54
|
enumerable: true,
|
|
@@ -94,6 +94,44 @@ let PaymentLink = (_dec = (0, _typeorm.Entity)({
|
|
|
94
94
|
return date;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
getPublicData() {
|
|
98
|
+
const response = {
|
|
99
|
+
id: this.id,
|
|
100
|
+
amount: this.amount,
|
|
101
|
+
description: this.description,
|
|
102
|
+
success_url: this.success_url,
|
|
103
|
+
failure_url: this.failure_url,
|
|
104
|
+
cancel_url: this.cancel_url,
|
|
105
|
+
customer_name: this.customer_name,
|
|
106
|
+
expires_at: this.expires_at,
|
|
107
|
+
created_at: this.created_at
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
if (this.booking !== null) {
|
|
111
|
+
response.booking = this.booking.getPublicData();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (typeof this.transactions !== 'undefined') {
|
|
115
|
+
response.transactions = this.transactions.map(transaction => transaction.getPublicCompactData());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (this.user !== null) {
|
|
119
|
+
response.user = this.user.getPublicCompactData();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return response;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
getPublicCompactData() {
|
|
126
|
+
return {
|
|
127
|
+
id: this.id,
|
|
128
|
+
amount: this.amount,
|
|
129
|
+
description: this.description,
|
|
130
|
+
expires_at: this.expires_at,
|
|
131
|
+
created_at: this.created_at
|
|
132
|
+
}``;
|
|
133
|
+
}
|
|
134
|
+
|
|
97
135
|
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
|
|
98
136
|
configurable: true,
|
|
99
137
|
enumerable: true,
|
|
@@ -86,6 +86,36 @@ let Transaction = (_dec = (0, _typeorm.Entity)({
|
|
|
86
86
|
_initializerDefineProperty(this, "created_at", _descriptor11, this);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
getPublicData() {
|
|
90
|
+
const response = {
|
|
91
|
+
id: this.id,
|
|
92
|
+
amount: this.amount,
|
|
93
|
+
status: this.status.id,
|
|
94
|
+
method: this.method.id,
|
|
95
|
+
type: this.type.id,
|
|
96
|
+
created_at: this.created_at,
|
|
97
|
+
completed_at: this.completed_at
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
if (this.booking !== null) {
|
|
101
|
+
response.booking = this.booking.getPublicData();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getPublicCompactData() {
|
|
108
|
+
return {
|
|
109
|
+
id: this.id,
|
|
110
|
+
amount: this.amount,
|
|
111
|
+
status: this.status.id,
|
|
112
|
+
method: this.method.id,
|
|
113
|
+
type: this.type.id,
|
|
114
|
+
created_at: this.created_at,
|
|
115
|
+
completed_at: this.completed_at
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
89
119
|
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
|
|
90
120
|
configurable: true,
|
|
91
121
|
enumerable: true,
|
|
@@ -63,6 +63,13 @@ let Organisation = (_dec = (0, _typeorm.Entity)({
|
|
|
63
63
|
this.name = name;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
getPublicCompactData() {
|
|
67
|
+
return {
|
|
68
|
+
id: this.id,
|
|
69
|
+
name: this.name
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec3], {
|
|
67
74
|
configurable: true,
|
|
68
75
|
enumerable: true,
|
|
@@ -95,6 +95,26 @@ let User = (_dec = (0, _typeorm.Entity)({
|
|
|
95
95
|
this.last_name = lastName;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
getPublicData() {
|
|
99
|
+
return {
|
|
100
|
+
id: this.id,
|
|
101
|
+
email: this.email,
|
|
102
|
+
mobile: this.mobile,
|
|
103
|
+
status: this.status,
|
|
104
|
+
first_name: this.first_name,
|
|
105
|
+
last_name: this.last_name,
|
|
106
|
+
created_at: this.created_at,
|
|
107
|
+
updated_at: this.updated_at
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getPublicCompactData() {
|
|
112
|
+
return {
|
|
113
|
+
id: this.id,
|
|
114
|
+
email: this.email
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
98
118
|
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
|
|
99
119
|
configurable: true,
|
|
100
120
|
enumerable: true,
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.RESPONSE_HEADERS = exports.DEFAULT_MESSAGE = void 0;
|
|
7
7
|
|
|
8
|
+
var _uuid = require("uuid");
|
|
9
|
+
|
|
8
10
|
var _ = _interopRequireDefault(require(".."));
|
|
9
11
|
|
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -46,7 +48,12 @@ class Index extends _.default {
|
|
|
46
48
|
super();
|
|
47
49
|
this.body = {
|
|
48
50
|
data: data !== null ? data : {},
|
|
49
|
-
|
|
51
|
+
errors: {},
|
|
52
|
+
meta: {
|
|
53
|
+
code: code !== null ? code : {},
|
|
54
|
+
message: message !== null ? message : DEFAULT_MESSAGE,
|
|
55
|
+
request_id: (0, _uuid.v4)()
|
|
56
|
+
}
|
|
50
57
|
};
|
|
51
58
|
this.code = code !== null ? code : {};
|
|
52
59
|
}
|
|
@@ -80,6 +87,17 @@ class Index extends _.default {
|
|
|
80
87
|
|
|
81
88
|
setCode(code) {
|
|
82
89
|
this.code = code;
|
|
90
|
+
this.body.meta.code = code;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Set a meta variable
|
|
94
|
+
* @param key
|
|
95
|
+
* @param value
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
setMetaVariable(key, value) {
|
|
100
|
+
this.body.meta[key] = value;
|
|
83
101
|
}
|
|
84
102
|
/**
|
|
85
103
|
* Get Status Code
|
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;
|