@felloh-org/lambda-wrapper 1.10.8 → 1.10.10
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/saltedge/account/index.js +39 -19
- package/dist/migration/saltedge/1686156816151-saltedge_multi_account.js +21 -0
- package/dist/migration/saltedge/1686157077928-saltedge_multi_account_fix.js +19 -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
|
|
|
@@ -15,7 +15,7 @@ var _account = _interopRequireDefault(require("../../bank/account"));
|
|
|
15
15
|
|
|
16
16
|
var _lead = _interopRequireDefault(require("../lead"));
|
|
17
17
|
|
|
18
|
-
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10;
|
|
18
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11;
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
@@ -40,22 +40,35 @@ let Account = (_dec = (0, _typeorm.Entity)({
|
|
|
40
40
|
}), _dec7 = (0, _typeorm.ManyToOne)(() => _organisation.default), _dec8 = (0, _typeorm.JoinColumn)({
|
|
41
41
|
name: 'organisation_id',
|
|
42
42
|
referencedColumnName: 'id'
|
|
43
|
-
}), _dec9 = (0, _typeorm.
|
|
43
|
+
}), _dec9 = (0, _typeorm.ManyToMany)(() => _organisation.default, () => {}, {
|
|
44
|
+
cascade: true
|
|
45
|
+
}), _dec10 = (0, _typeorm.JoinTable)({
|
|
46
|
+
name: "account_organisation",
|
|
47
|
+
schema: "saltedge",
|
|
48
|
+
joinColumn: {
|
|
49
|
+
name: "account_id",
|
|
50
|
+
referencedColumnName: "id"
|
|
51
|
+
},
|
|
52
|
+
inverseJoinColumn: {
|
|
53
|
+
name: "organisation_id",
|
|
54
|
+
referencedColumnName: "id"
|
|
55
|
+
}
|
|
56
|
+
}), _dec11 = (0, _typeorm.ManyToOne)(() => _account.default), _dec12 = (0, _typeorm.JoinColumn)({
|
|
44
57
|
name: 'iban',
|
|
45
58
|
referencedColumnName: 'iban',
|
|
46
59
|
nullable: true
|
|
47
|
-
}),
|
|
60
|
+
}), _dec13 = (0, _typeorm.Column)({
|
|
48
61
|
type: "varchar",
|
|
49
62
|
length: "150",
|
|
50
63
|
nullable: true
|
|
51
|
-
}),
|
|
64
|
+
}), _dec14 = (0, _typeorm.CreateDateColumn)({
|
|
52
65
|
type: 'timestamp with time zone'
|
|
53
|
-
}),
|
|
66
|
+
}), _dec15 = (0, _typeorm.UpdateDateColumn)({
|
|
54
67
|
type: 'timestamp with time zone'
|
|
55
|
-
}),
|
|
68
|
+
}), _dec16 = (0, _typeorm.Column)({
|
|
56
69
|
type: "int",
|
|
57
70
|
nullable: true
|
|
58
|
-
}),
|
|
71
|
+
}), _dec17 = (0, _typeorm.Column)({
|
|
59
72
|
type: "varchar",
|
|
60
73
|
length: "5",
|
|
61
74
|
nullable: true
|
|
@@ -69,17 +82,19 @@ let Account = (_dec = (0, _typeorm.Entity)({
|
|
|
69
82
|
|
|
70
83
|
_initializerDefineProperty(this, "organisation", _descriptor4, this);
|
|
71
84
|
|
|
72
|
-
_initializerDefineProperty(this, "
|
|
85
|
+
_initializerDefineProperty(this, "organisations", _descriptor5, this);
|
|
86
|
+
|
|
87
|
+
_initializerDefineProperty(this, "iban", _descriptor6, this);
|
|
73
88
|
|
|
74
|
-
_initializerDefineProperty(this, "name",
|
|
89
|
+
_initializerDefineProperty(this, "name", _descriptor7, this);
|
|
75
90
|
|
|
76
|
-
_initializerDefineProperty(this, "created_at",
|
|
91
|
+
_initializerDefineProperty(this, "created_at", _descriptor8, this);
|
|
77
92
|
|
|
78
|
-
_initializerDefineProperty(this, "updated_at",
|
|
93
|
+
_initializerDefineProperty(this, "updated_at", _descriptor9, this);
|
|
79
94
|
|
|
80
|
-
_initializerDefineProperty(this, "balance",
|
|
95
|
+
_initializerDefineProperty(this, "balance", _descriptor10, this);
|
|
81
96
|
|
|
82
|
-
_initializerDefineProperty(this, "currency",
|
|
97
|
+
_initializerDefineProperty(this, "currency", _descriptor11, this);
|
|
83
98
|
}
|
|
84
99
|
|
|
85
100
|
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
|
|
@@ -110,36 +125,41 @@ let Account = (_dec = (0, _typeorm.Entity)({
|
|
|
110
125
|
initializer: function () {
|
|
111
126
|
return _organisation.default;
|
|
112
127
|
}
|
|
113
|
-
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "
|
|
128
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "organisations", [_dec9, _dec10], {
|
|
129
|
+
configurable: true,
|
|
130
|
+
enumerable: true,
|
|
131
|
+
writable: true,
|
|
132
|
+
initializer: null
|
|
133
|
+
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "iban", [_dec11, _dec12], {
|
|
114
134
|
configurable: true,
|
|
115
135
|
enumerable: true,
|
|
116
136
|
writable: true,
|
|
117
137
|
initializer: function () {
|
|
118
138
|
return _account.default;
|
|
119
139
|
}
|
|
120
|
-
}),
|
|
140
|
+
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "name", [_dec13], {
|
|
121
141
|
configurable: true,
|
|
122
142
|
enumerable: true,
|
|
123
143
|
writable: true,
|
|
124
144
|
initializer: function () {
|
|
125
145
|
return "";
|
|
126
146
|
}
|
|
127
|
-
}),
|
|
147
|
+
}), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec14], {
|
|
128
148
|
configurable: true,
|
|
129
149
|
enumerable: true,
|
|
130
150
|
writable: true,
|
|
131
151
|
initializer: null
|
|
132
|
-
}),
|
|
152
|
+
}), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "updated_at", [_dec15], {
|
|
133
153
|
configurable: true,
|
|
134
154
|
enumerable: true,
|
|
135
155
|
writable: true,
|
|
136
156
|
initializer: null
|
|
137
|
-
}),
|
|
157
|
+
}), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "balance", [_dec16], {
|
|
138
158
|
configurable: true,
|
|
139
159
|
enumerable: true,
|
|
140
160
|
writable: true,
|
|
141
161
|
initializer: null
|
|
142
|
-
}),
|
|
162
|
+
}), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "currency", [_dec17], {
|
|
143
163
|
configurable: true,
|
|
144
164
|
enumerable: true,
|
|
145
165
|
writable: true,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class saltedgeMultiAccount1686156816151 {
|
|
4
|
+
name = 'saltedgeMultiAccount1686156816151'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "saltedge"."account_organisation" ("organisation_id" character varying(150) NOT NULL, "account_id" character varying(150) NOT NULL, CONSTRAINT "PK_1a2b2a8074c5ea92b737c43968e" PRIMARY KEY ("organisation_id", "account_id"))`);
|
|
8
|
+
await queryRunner.query(`CREATE INDEX "IDX_397eb56a86a22ebf84f02fdd36" ON "saltedge"."account_organisation" ("organisation_id") `);
|
|
9
|
+
await queryRunner.query(`CREATE INDEX "IDX_500714c83d3da008280f975581" ON "saltedge"."account_organisation" ("account_id") `);
|
|
10
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" ADD CONSTRAINT "FK_397eb56a86a22ebf84f02fdd361" FOREIGN KEY ("organisation_id") REFERENCES "saltedge"."account"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
|
11
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" ADD CONSTRAINT "FK_500714c83d3da008280f9755811" FOREIGN KEY ("account_id") REFERENCES "user"."organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async down(queryRunner) {
|
|
15
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" DROP CONSTRAINT "FK_500714c83d3da008280f9755811"`);
|
|
16
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" DROP CONSTRAINT "FK_397eb56a86a22ebf84f02fdd361"`);
|
|
17
|
+
await queryRunner.query(`DROP INDEX "saltedge"."IDX_500714c83d3da008280f975581"`);
|
|
18
|
+
await queryRunner.query(`DROP INDEX "saltedge"."IDX_397eb56a86a22ebf84f02fdd36"`);
|
|
19
|
+
await queryRunner.query(`DROP TABLE "saltedge"."account_organisation"`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class saltedgeMultiAccountFix1686157077928 {
|
|
4
|
+
name = 'saltedgeMultiAccountFix1686157077928'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" DROP CONSTRAINT "FK_397eb56a86a22ebf84f02fdd361"`);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" DROP CONSTRAINT "FK_500714c83d3da008280f9755811"`);
|
|
9
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" ADD CONSTRAINT "FK_500714c83d3da008280f9755811" FOREIGN KEY ("account_id") REFERENCES "saltedge"."account"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
|
10
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" ADD CONSTRAINT "FK_397eb56a86a22ebf84f02fdd361" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async down(queryRunner) {
|
|
14
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" DROP CONSTRAINT "FK_397eb56a86a22ebf84f02fdd361"`);
|
|
15
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" DROP CONSTRAINT "FK_500714c83d3da008280f9755811"`);
|
|
16
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" ADD CONSTRAINT "FK_500714c83d3da008280f9755811" FOREIGN KEY ("account_id") REFERENCES "user"."organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
|
17
|
+
await queryRunner.query(`ALTER TABLE "saltedge"."account_organisation" ADD CONSTRAINT "FK_397eb56a86a22ebf84f02fdd361" FOREIGN KEY ("organisation_id") REFERENCES "saltedge"."account"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
|
18
|
+
}
|
|
19
|
+
}
|
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.10",
|
|
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",
|