@felloh-org/lambda-wrapper 1.10.7 → 1.10.9
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/dependency-injection/dependency-injection.js +28 -0
- package/dist/entity/agent-data/booking/index.js +1 -1
- package/dist/entity/user/index.js +3 -1
- package/dist/entity/user/organisation-partner/index.js +67 -0
- package/dist/index.js +8 -0
- package/dist/migration/1684765687786-org_partner_table.js +17 -0
- package/dist/service/logger.js +20 -8
- package/dist/wrapper/index.js +14 -22
- package/package.json +2 -1
|
@@ -21,6 +21,7 @@ class DependencyInjection {
|
|
|
21
21
|
constructor(configuration, event, context) {
|
|
22
22
|
this.event = event;
|
|
23
23
|
this.context = context;
|
|
24
|
+
this.lumigo = null;
|
|
24
25
|
this.dependencies = {};
|
|
25
26
|
this.configuration = configuration;
|
|
26
27
|
|
|
@@ -129,6 +130,33 @@ class DependencyInjection {
|
|
|
129
130
|
get definitions() {
|
|
130
131
|
return this.configuration.DEFINITIONS;
|
|
131
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Set Lumigo
|
|
135
|
+
* @param lumigo
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
setLumigo(lumigo) {
|
|
140
|
+
this.lumigo = lumigo;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get Lumigo
|
|
144
|
+
* @return {null}
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
getLumigo() {
|
|
149
|
+
return this.lumigo;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Check to see whether lumigo is enabled
|
|
153
|
+
* @return {boolean}
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
lumigoIsEnabled() {
|
|
158
|
+
return this.lumigo !== null;
|
|
159
|
+
}
|
|
132
160
|
|
|
133
161
|
}
|
|
134
162
|
|
|
@@ -136,7 +136,7 @@ let Booking = (_dec = (0, _typeorm.Entity)({
|
|
|
136
136
|
/**
|
|
137
137
|
* Get Public Data
|
|
138
138
|
* @param showTemporaryFlag
|
|
139
|
-
* @
|
|
139
|
+
* @return {{components: [], departure_date: string, created_at: Date, organisation: null, booking_reference: string, gross_amount: number, transactions: [], payment_links: [], atol_receipt_number: string, currency: string, id: *|string, customer_name: string, user: null, email: string, return_date: string}}
|
|
140
140
|
*/
|
|
141
141
|
getPublicData(showTemporaryFlag = false) {
|
|
142
142
|
const response = {
|
|
@@ -29,8 +29,10 @@ var _organisationPayoutConfig = _interopRequireDefault(require("./organisation-p
|
|
|
29
29
|
|
|
30
30
|
var _organisationType = _interopRequireDefault(require("./organisation-type"));
|
|
31
31
|
|
|
32
|
+
var _organisationPartner = _interopRequireDefault(require("./organisation-partner"));
|
|
33
|
+
|
|
32
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
35
|
|
|
34
|
-
const ENTITIES = [_organisation.default, _role.default, _userRole.default, _user.default, _userActivity.default, _feature.default, _organisationFeature.default, _loginLink.default, _webhookTypes.default, _organisationWebhook.default, _organisationPayoutConfig.default, _organisationType.default];
|
|
36
|
+
const ENTITIES = [_organisation.default, _role.default, _userRole.default, _user.default, _userActivity.default, _feature.default, _organisationFeature.default, _loginLink.default, _webhookTypes.default, _organisationWebhook.default, _organisationPayoutConfig.default, _organisationType.default, _organisationPartner.default];
|
|
35
37
|
var _default = ENTITIES;
|
|
36
38
|
exports.default = _default;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _typeorm = require("typeorm");
|
|
9
|
+
|
|
10
|
+
var _organisation = _interopRequireDefault(require("../organisation"));
|
|
11
|
+
|
|
12
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
17
|
+
|
|
18
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
19
|
+
|
|
20
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); }
|
|
21
|
+
|
|
22
|
+
let OrganisationPartner = (_dec = (0, _typeorm.Entity)({
|
|
23
|
+
name: 'organisation_partner',
|
|
24
|
+
schema: 'user'
|
|
25
|
+
}), _dec2 = (0, _typeorm.PrimaryGeneratedColumn)("uuid"), _dec3 = (0, _typeorm.ManyToOne)(() => _organisation.default), _dec4 = (0, _typeorm.JoinColumn)({
|
|
26
|
+
name: 'partner_organisation_id',
|
|
27
|
+
referencedColumnName: 'id'
|
|
28
|
+
}), _dec5 = (0, _typeorm.ManyToOne)(() => _organisation.default), _dec6 = (0, _typeorm.JoinColumn)({
|
|
29
|
+
name: 'organisation_id',
|
|
30
|
+
referencedColumnName: 'id'
|
|
31
|
+
}), _dec7 = (0, _typeorm.CreateDateColumn)(), _dec(_class = (_class2 = class OrganisationPartner {
|
|
32
|
+
constructor() {
|
|
33
|
+
_initializerDefineProperty(this, "id", _descriptor, this);
|
|
34
|
+
|
|
35
|
+
_initializerDefineProperty(this, "partner_organisation", _descriptor2, this);
|
|
36
|
+
|
|
37
|
+
_initializerDefineProperty(this, "organisation", _descriptor3, this);
|
|
38
|
+
|
|
39
|
+
_initializerDefineProperty(this, "created_at", _descriptor4, this);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
|
|
43
|
+
configurable: true,
|
|
44
|
+
enumerable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
initializer: null
|
|
47
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "partner_organisation", [_dec3, _dec4], {
|
|
48
|
+
configurable: true,
|
|
49
|
+
enumerable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
initializer: function () {
|
|
52
|
+
return _organisation.default;
|
|
53
|
+
}
|
|
54
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "organisation", [_dec5, _dec6], {
|
|
55
|
+
configurable: true,
|
|
56
|
+
enumerable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
initializer: function () {
|
|
59
|
+
return _organisation.default;
|
|
60
|
+
}
|
|
61
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec7], {
|
|
62
|
+
configurable: true,
|
|
63
|
+
enumerable: true,
|
|
64
|
+
writable: true,
|
|
65
|
+
initializer: null
|
|
66
|
+
})), _class2)) || _class);
|
|
67
|
+
exports.default = OrganisationPartner;
|
package/dist/index.js
CHANGED
|
@@ -249,6 +249,12 @@ Object.defineProperty(exports, "OrganisationFeatureEntity", {
|
|
|
249
249
|
return _organisationFeature.default;
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
|
+
Object.defineProperty(exports, "OrganisationPartnerEntity", {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function () {
|
|
255
|
+
return _organisationPartner.default;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
252
258
|
Object.defineProperty(exports, "OrganisationPaymentProviderEntity", {
|
|
253
259
|
enumerable: true,
|
|
254
260
|
get: function () {
|
|
@@ -736,6 +742,8 @@ var _organisationWebhook = _interopRequireDefault(require("./entity/user/organis
|
|
|
736
742
|
|
|
737
743
|
var _organisationPayoutConfig = _interopRequireDefault(require("./entity/user/organisation-payout-config"));
|
|
738
744
|
|
|
745
|
+
var _organisationPartner = _interopRequireDefault(require("./entity/user/organisation-partner"));
|
|
746
|
+
|
|
739
747
|
var _batch2 = _interopRequireDefault(require("./entity/nuvei/batch"));
|
|
740
748
|
|
|
741
749
|
var _merchant2 = _interopRequireDefault(require("./entity/nuvei/merchant"));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class orgPartnerTable1684765687786 {
|
|
4
|
+
name = 'orgPartnerTable1684765687786'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "user"."organisation_partner" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "partner_organisation_id" character varying(150), "organisation_id" character varying(150), CONSTRAINT "PK_0a648f4b349e30778c0cf423396" PRIMARY KEY ("id"))`);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_partner" ADD CONSTRAINT "FK_5e3d4cbb29e29ecb143e6a6b355" FOREIGN KEY ("partner_organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
9
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_partner" ADD CONSTRAINT "FK_061ace0a686facc89cdbe4500b1" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async down(queryRunner) {
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_partner" DROP CONSTRAINT "FK_061ace0a686facc89cdbe4500b1"`);
|
|
14
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_partner" DROP CONSTRAINT "FK_5e3d4cbb29e29ecb143e6a6b355"`);
|
|
15
|
+
await queryRunner.query(`DROP TABLE "user"."organisation_partner"`);
|
|
16
|
+
}
|
|
17
|
+
}
|
package/dist/service/logger.js
CHANGED
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _epsagon = _interopRequireDefault(require("epsagon"));
|
|
9
|
-
|
|
10
8
|
var _winston = _interopRequireDefault(require("winston"));
|
|
11
9
|
|
|
12
10
|
var _dependencyAware = _interopRequireDefault(require("../dependency-injection/dependency-aware"));
|
|
@@ -19,6 +17,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
17
|
class Logger extends _dependencyAware.default {
|
|
20
18
|
constructor(di) {
|
|
21
19
|
super(di);
|
|
20
|
+
this.lumigo = di.getLumigo();
|
|
21
|
+
this.lumigoIsEnabled = di.lumigoIsEnabled();
|
|
22
22
|
this.winston = null;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
@@ -136,8 +136,10 @@ class Logger extends _dependencyAware.default {
|
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
error(error, message = '') {
|
|
139
|
-
if (
|
|
140
|
-
|
|
139
|
+
if (this.lumigoIsEnabled) {
|
|
140
|
+
this.lumigo.error('error', {
|
|
141
|
+
err: error
|
|
142
|
+
});
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
this.logger.log('error', message, {
|
|
@@ -154,6 +156,10 @@ class Logger extends _dependencyAware.default {
|
|
|
154
156
|
|
|
155
157
|
|
|
156
158
|
info(message) {
|
|
159
|
+
if (this.lumigoIsEnabled) {
|
|
160
|
+
this.lumigo.info(message);
|
|
161
|
+
}
|
|
162
|
+
|
|
157
163
|
this.logger.log('info', this.processMessage(message));
|
|
158
164
|
}
|
|
159
165
|
/**
|
|
@@ -172,6 +178,12 @@ class Logger extends _dependencyAware.default {
|
|
|
172
178
|
warning(error) {
|
|
173
179
|
const softWarningValues = ['true', '1'];
|
|
174
180
|
|
|
181
|
+
if (this.lumigoIsEnabled) {
|
|
182
|
+
this.lumigo.info('warning', {
|
|
183
|
+
err: error
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
175
187
|
if (softWarningValues.includes(process.env.LOGGER_SOFT_WARNING)) {
|
|
176
188
|
return this.info(error);
|
|
177
189
|
}
|
|
@@ -187,8 +199,8 @@ class Logger extends _dependencyAware.default {
|
|
|
187
199
|
|
|
188
200
|
|
|
189
201
|
label(descriptor, silent = false) {
|
|
190
|
-
if (
|
|
191
|
-
|
|
202
|
+
if (this.lumigoIsEnabled) {
|
|
203
|
+
this.lumigo.addExecutionTag(descriptor);
|
|
192
204
|
}
|
|
193
205
|
|
|
194
206
|
if (silent === false) {
|
|
@@ -205,8 +217,8 @@ class Logger extends _dependencyAware.default {
|
|
|
205
217
|
|
|
206
218
|
|
|
207
219
|
metric(descriptor, stat, silent = false) {
|
|
208
|
-
if (
|
|
209
|
-
|
|
220
|
+
if (this.lumigoIsEnabled) {
|
|
221
|
+
this.lumigo.addExecutionTag(descriptor, stat);
|
|
210
222
|
}
|
|
211
223
|
|
|
212
224
|
if (silent === false) {
|
package/dist/wrapper/index.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.handleSuccess = exports.handleError = exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _tracer = _interopRequireDefault(require("@lumigo/tracer"));
|
|
9
9
|
|
|
10
10
|
var _dependencies = require("../config/dependencies");
|
|
11
11
|
|
|
@@ -38,19 +38,7 @@ const handleSuccess = (di, outcome) => {
|
|
|
38
38
|
return outcome;
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
* logging in Epsagon and generating
|
|
43
|
-
* a response reflecting the `code`
|
|
44
|
-
* of the error, if defined.
|
|
45
|
-
*
|
|
46
|
-
* Note about Epsagon:
|
|
47
|
-
* Epsagon generates alerts for logs on level ERROR.
|
|
48
|
-
* This means that logger.error will produce an alert.
|
|
49
|
-
* To avoid not meaningful notifications, most likely
|
|
50
|
-
* coming from tests, we log INFO unless either:
|
|
51
|
-
*
|
|
52
|
-
* 1. `error.raiseOnEpsagon` is defined & truthy
|
|
53
|
-
* 2. `error.code` is defined and `error.code >= 500`.
|
|
41
|
+
* Handle an error
|
|
54
42
|
*
|
|
55
43
|
* @param {DependencyInjection} di
|
|
56
44
|
* @param {Error} error
|
|
@@ -97,8 +85,17 @@ const handleError = (di, error) => {
|
|
|
97
85
|
exports.handleError = handleError;
|
|
98
86
|
|
|
99
87
|
const wrapper = (configuration, handler, throwError = false) => {
|
|
88
|
+
let lumigo = null;
|
|
89
|
+
|
|
90
|
+
if (typeof process.env.LUMIGO_TOKEN === 'string' && process.env.LUMIGO_TOKEN !== 'undefined') {
|
|
91
|
+
lumigo = (0, _tracer.default)({
|
|
92
|
+
token: process.env.LUMIGO_TOKEN
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
100
96
|
let instance = (event, context, callback) => {
|
|
101
97
|
const di = new _dependencyInjection.default(configuration, event, context);
|
|
98
|
+
di.setLumigo(lumigo);
|
|
102
99
|
const request = di.get(_dependencies.DEFINITIONS.REQUEST);
|
|
103
100
|
const logger = di.get(_dependencies.DEFINITIONS.LOGGER);
|
|
104
101
|
context.callbackWaitsForEmptyEventLoop = false; // If the event is to trigger a warm up, then don't bother returning the function.
|
|
@@ -146,16 +143,11 @@ const wrapper = (configuration, handler, throwError = false) => {
|
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
return outcome;
|
|
149
|
-
}; // If the
|
|
146
|
+
}; // If the Lumigo token is enabled, then wrap the instance in the Lumigo wrapper
|
|
150
147
|
|
|
151
148
|
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
token: process.env.EPSAGON_TOKEN,
|
|
155
|
-
appName: process.env.EPSAGON_SERVICE_NAME
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
instance = _epsagon.default.lambdaWrapper(instance);
|
|
149
|
+
if (lumigo !== null) {
|
|
150
|
+
instance = lumigo.trace(instance);
|
|
159
151
|
}
|
|
160
152
|
|
|
161
153
|
return instance;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@felloh-org/lambda-wrapper",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.9",
|
|
4
4
|
"description": "Lambda wrapper for all Felloh Serverless Projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"aws-sdk": ">=2.831.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
+
"@lumigo/tracer": "^1.83.0",
|
|
57
58
|
"alai": "^1.0.3",
|
|
58
59
|
"async": "^3.2.3",
|
|
59
60
|
"axios": "^0.26.1",
|