@felloh-org/lambda-wrapper 1.0.26 → 1.0.29
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/.concourse/pipeline.yml +129 -0
- package/.concourse/private.yml +0 -0
- package/.gitattributes +1 -0
- package/dist/entity/trust-payments/chargeback/index.js +2 -1
- package/dist/entity/trust-payments/index.js +3 -1
- package/dist/entity/trust-payments/ingested-data/index.js +57 -0
- package/dist/index.js +8 -0
- package/dist/migration/trust-payments/1648137333608-trust_chargeback_due.js +13 -0
- package/dist/migration/trust-payments/1648204597084-trust_ftp_log.js +13 -0
- package/dist/service/warehouse.js +7 -5
- package/package.json +5 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# --------------------------------------------------------------------------------------------------
|
|
2
|
+
# Resource Types
|
|
3
|
+
# --------------------------------------------------------------------------------------------------
|
|
4
|
+
resource_types:
|
|
5
|
+
|
|
6
|
+
- name: pull-request
|
|
7
|
+
type: docker-image
|
|
8
|
+
source:
|
|
9
|
+
repository: teliaoss/github-pr-resource
|
|
10
|
+
|
|
11
|
+
- name: slack-notification
|
|
12
|
+
type: docker-image
|
|
13
|
+
source:
|
|
14
|
+
repository: mockersf/concourse-slack-notifier
|
|
15
|
+
tag: latest
|
|
16
|
+
|
|
17
|
+
# --------------------------------------------------------------------------------------------------
|
|
18
|
+
# Resources
|
|
19
|
+
# --------------------------------------------------------------------------------------------------
|
|
20
|
+
resources:
|
|
21
|
+
|
|
22
|
+
- name: concourse-scripts
|
|
23
|
+
type: git
|
|
24
|
+
source:
|
|
25
|
+
uri: git@github.com:felloh-org/concourse-scripts.git
|
|
26
|
+
branch: main
|
|
27
|
+
depth: 0
|
|
28
|
+
private_key: ((git.private_key))
|
|
29
|
+
|
|
30
|
+
- name: lambda-wrapper
|
|
31
|
+
type: git
|
|
32
|
+
source:
|
|
33
|
+
uri: git@github.com:felloh-org/lambda-wrapper.git
|
|
34
|
+
branch: main
|
|
35
|
+
depth: 0
|
|
36
|
+
private_key: ((git.private_key))
|
|
37
|
+
|
|
38
|
+
- name: slack-alert-deploy
|
|
39
|
+
type: slack-notification
|
|
40
|
+
source:
|
|
41
|
+
url: ((slack.channels.engineering-deployments))
|
|
42
|
+
|
|
43
|
+
# --------------------------------------------------------------------------------------------------
|
|
44
|
+
# Jobs
|
|
45
|
+
# --------------------------------------------------------------------------------------------------
|
|
46
|
+
jobs:
|
|
47
|
+
- name: 'migrations.staging'
|
|
48
|
+
serial: true
|
|
49
|
+
plan:
|
|
50
|
+
- in_parallel:
|
|
51
|
+
- get: lambda-wrapper
|
|
52
|
+
trigger: true
|
|
53
|
+
- get: concourse-scripts
|
|
54
|
+
- task: 'schema.create'
|
|
55
|
+
file: concourse-scripts/scripts/pulumi_npm_run/npm_run.yml
|
|
56
|
+
input_mapping:
|
|
57
|
+
repository: lambda-wrapper
|
|
58
|
+
params:
|
|
59
|
+
NPM_COMMAND: 'orm:schema:create'
|
|
60
|
+
AWS_ACCESS_KEY_ID: ((aws.keys.access))
|
|
61
|
+
AWS_SECRET_ACCESS_KEY: ((aws.keys.secret))
|
|
62
|
+
AWS_REGION: ((aws.region.primary))
|
|
63
|
+
WAREHOUSE_ARN: ((aws.rds.warehouse_arn.staging))
|
|
64
|
+
WAREHOUSE_SECRET_ARN: ((aws.secret_manager.warehouse_secret_arn.staging))
|
|
65
|
+
WAREHOUSE_DATABASE: 'felloh'
|
|
66
|
+
WAREHOUSE_SCHEMA: 'user'
|
|
67
|
+
- task: 'migrations.run'
|
|
68
|
+
file: concourse-scripts/scripts/pulumi_npm_run/npm_run.yml
|
|
69
|
+
input_mapping:
|
|
70
|
+
repository: lambda-wrapper
|
|
71
|
+
params:
|
|
72
|
+
NPM_COMMAND: 'orm:migration:run'
|
|
73
|
+
AWS_ACCESS_KEY_ID: ((aws.keys.access))
|
|
74
|
+
AWS_SECRET_ACCESS_KEY: ((aws.keys.secret))
|
|
75
|
+
AWS_REGION: ((aws.region.primary))
|
|
76
|
+
WAREHOUSE_ARN: ((aws.rds.warehouse_arn.staging))
|
|
77
|
+
WAREHOUSE_SECRET_ARN: ((aws.secret_manager.warehouse_secret_arn.staging))
|
|
78
|
+
WAREHOUSE_DATABASE: 'felloh'
|
|
79
|
+
WAREHOUSE_SCHEMA: 'user'
|
|
80
|
+
on_failure:
|
|
81
|
+
put: slack-alert-deploy
|
|
82
|
+
params:
|
|
83
|
+
alert_type: 'failed'
|
|
84
|
+
message: Staging deployment failed
|
|
85
|
+
|
|
86
|
+
- name: 'migrations.production'
|
|
87
|
+
serial: true
|
|
88
|
+
plan:
|
|
89
|
+
- in_parallel:
|
|
90
|
+
- get: lambda-wrapper
|
|
91
|
+
passed: ['migrations.staging']
|
|
92
|
+
trigger: true
|
|
93
|
+
- get: concourse-scripts
|
|
94
|
+
- task: 'schema.create'
|
|
95
|
+
file: concourse-scripts/scripts/pulumi_npm_run/npm_run.yml
|
|
96
|
+
input_mapping:
|
|
97
|
+
repository: lambda-wrapper
|
|
98
|
+
params:
|
|
99
|
+
NPM_COMMAND: 'orm:schema:create'
|
|
100
|
+
AWS_ACCESS_KEY_ID: ((aws.keys.access))
|
|
101
|
+
AWS_SECRET_ACCESS_KEY: ((aws.keys.secret))
|
|
102
|
+
AWS_REGION: ((aws.region.primary))
|
|
103
|
+
WAREHOUSE_ARN: ((aws.rds.warehouse_arn.production))
|
|
104
|
+
WAREHOUSE_SECRET_ARN: ((aws.secret_manager.warehouse_secret_arn.production))
|
|
105
|
+
WAREHOUSE_DATABASE: 'felloh'
|
|
106
|
+
WAREHOUSE_SCHEMA: 'user'
|
|
107
|
+
- task: 'migrations.run'
|
|
108
|
+
file: concourse-scripts/scripts/pulumi_npm_run/npm_run.yml
|
|
109
|
+
input_mapping:
|
|
110
|
+
repository: lambda-wrapper
|
|
111
|
+
params:
|
|
112
|
+
NPM_COMMAND: 'orm:migration:run'
|
|
113
|
+
AWS_ACCESS_KEY_ID: ((aws.keys.access))
|
|
114
|
+
AWS_SECRET_ACCESS_KEY: ((aws.keys.secret))
|
|
115
|
+
AWS_REGION: ((aws.region.primary))
|
|
116
|
+
WAREHOUSE_ARN: ((aws.rds.warehouse_arn.production))
|
|
117
|
+
WAREHOUSE_SECRET_ARN: ((aws.secret_manager.warehouse_secret_arn.production))
|
|
118
|
+
WAREHOUSE_DATABASE: 'felloh'
|
|
119
|
+
WAREHOUSE_SCHEMA: 'user'
|
|
120
|
+
on_success:
|
|
121
|
+
put: slack-alert-deploy
|
|
122
|
+
params:
|
|
123
|
+
alert_type: 'success'
|
|
124
|
+
message: Migrations deployment succeeded
|
|
125
|
+
on_failure:
|
|
126
|
+
put: slack-alert-deploy
|
|
127
|
+
params:
|
|
128
|
+
alert_type: 'failed'
|
|
129
|
+
message: Migrations deployment failed
|
|
Binary file
|
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.concourse/private.yml filter=git-crypt diff=git-crypt
|
|
@@ -39,7 +39,8 @@ let Chargeback = (_dec = (0, _typeorm.Entity)({
|
|
|
39
39
|
}), _dec8 = (0, _typeorm.Column)({
|
|
40
40
|
type: "int"
|
|
41
41
|
}), _dec9 = (0, _typeorm.Column)({
|
|
42
|
-
type: "date"
|
|
42
|
+
type: "date",
|
|
43
|
+
nullable: true
|
|
43
44
|
}), _dec10 = (0, _typeorm.Column)({
|
|
44
45
|
type: "date"
|
|
45
46
|
}), _dec11 = (0, _typeorm.Column)({
|
|
@@ -13,8 +13,10 @@ var _transaction = _interopRequireDefault(require("./transaction"));
|
|
|
13
13
|
|
|
14
14
|
var _chargeback = _interopRequireDefault(require("./chargeback"));
|
|
15
15
|
|
|
16
|
+
var _ingestedData = _interopRequireDefault(require("./ingested-data"));
|
|
17
|
+
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
|
-
const ENTITIES = [_batch.default, _merchant.default, _transaction.default, _chargeback.default];
|
|
20
|
+
const ENTITIES = [_batch.default, _merchant.default, _transaction.default, _chargeback.default, _ingestedData.default];
|
|
19
21
|
var _default = ENTITIES;
|
|
20
22
|
exports.default = _default;
|
|
@@ -0,0 +1,57 @@
|
|
|
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 _batch = _interopRequireDefault(require("../batch"));
|
|
11
|
+
|
|
12
|
+
var _merchant = _interopRequireDefault(require("../merchant"));
|
|
13
|
+
|
|
14
|
+
var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3;
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
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 }); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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.'); }
|
|
23
|
+
|
|
24
|
+
let Transaction = (_dec = (0, _typeorm.Entity)({
|
|
25
|
+
name: 'ingested_data',
|
|
26
|
+
schema: 'trust_payments'
|
|
27
|
+
}), _dec2 = (0, _typeorm.PrimaryColumn)("varchar"), _dec3 = (0, _typeorm.Column)({
|
|
28
|
+
type: "varchar",
|
|
29
|
+
length: 10
|
|
30
|
+
}), _dec4 = (0, _typeorm.CreateDateColumn)(), _dec(_class = (_class2 = class Transaction {
|
|
31
|
+
constructor() {
|
|
32
|
+
_initializerDefineProperty(this, "id", _descriptor, this);
|
|
33
|
+
|
|
34
|
+
_initializerDefineProperty(this, "type", _descriptor2, this);
|
|
35
|
+
|
|
36
|
+
_initializerDefineProperty(this, "created_at", _descriptor3, this);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
|
|
40
|
+
configurable: true,
|
|
41
|
+
enumerable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
initializer: function () {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "type", [_dec3], {
|
|
47
|
+
configurable: true,
|
|
48
|
+
enumerable: true,
|
|
49
|
+
writable: true,
|
|
50
|
+
initializer: null
|
|
51
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec4], {
|
|
52
|
+
configurable: true,
|
|
53
|
+
enumerable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
initializer: null
|
|
56
|
+
})), _class2)) || _class);
|
|
57
|
+
exports.default = Transaction;
|
package/dist/index.js
CHANGED
|
@@ -225,6 +225,12 @@ Object.defineProperty(exports, "TPChargebackEntity", {
|
|
|
225
225
|
return _chargeback.default;
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
|
+
Object.defineProperty(exports, "TPIngestedData", {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
get: function () {
|
|
231
|
+
return _ingestedData.default;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
228
234
|
Object.defineProperty(exports, "TPMerchantEntity", {
|
|
229
235
|
enumerable: true,
|
|
230
236
|
get: function () {
|
|
@@ -408,6 +414,8 @@ var _transaction4 = _interopRequireDefault(require("./entity/trust-payments/tran
|
|
|
408
414
|
|
|
409
415
|
var _chargeback = _interopRequireDefault(require("./entity/trust-payments/chargeback"));
|
|
410
416
|
|
|
417
|
+
var _ingestedData = _interopRequireDefault(require("./entity/trust-payments/ingested-data"));
|
|
418
|
+
|
|
411
419
|
var _organisation = _interopRequireDefault(require("./entity/user/organisation"));
|
|
412
420
|
|
|
413
421
|
var _role = _interopRequireDefault(require("./entity/user/role"));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class trustChargebackDue1648137333608 {
|
|
4
|
+
name = 'trustChargebackDue1648137333608'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE "trust_payments"."chargeback" ALTER COLUMN "due_date" DROP NOT NULL`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async down(queryRunner) {
|
|
11
|
+
await queryRunner.query(`ALTER TABLE "trust_payments"."chargeback" ALTER COLUMN "due_date" SET NOT NULL`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class trustFtpLog1648204597084 {
|
|
4
|
+
name = 'trustFtpLog1648204597084'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "trust_payments"."ingested_data" ("id" character varying NOT NULL, "type" character varying(10) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_95ecbf759d16d46c0d1b08fb7e0" PRIMARY KEY ("id"))`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async down(queryRunner) {
|
|
11
|
+
await queryRunner.query(`DROP TABLE "trust_payments"."ingested_data"`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -26,13 +26,15 @@ class Warehouse extends _dependencyAware.default {
|
|
|
26
26
|
this.connection = null;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
29
|
+
* Connect to the warehouse
|
|
30
|
+
* @param database
|
|
31
|
+
* @param cache
|
|
32
|
+
* @returns {Promise<null>}
|
|
31
33
|
*/
|
|
32
34
|
|
|
33
35
|
|
|
34
|
-
async connect() {
|
|
35
|
-
if (this.connection) {
|
|
36
|
+
async connect(database = null, cache = true) {
|
|
37
|
+
if (this.connection && cache === true) {
|
|
36
38
|
return this.connection;
|
|
37
39
|
}
|
|
38
40
|
|
|
@@ -41,7 +43,7 @@ class Warehouse extends _dependencyAware.default {
|
|
|
41
43
|
} catch (error) {
|
|
42
44
|
this.connection = await (0, _typeorm.createConnection)({
|
|
43
45
|
type: 'aurora-data-api-pg',
|
|
44
|
-
database: process.env.WAREHOUSE_DATABASE,
|
|
46
|
+
database: database !== null ? database : process.env.WAREHOUSE_DATABASE,
|
|
45
47
|
schema: process.env.WAREHOUSE_SCHEMA,
|
|
46
48
|
secretArn: process.env.WAREHOUSE_SECRET_ARN,
|
|
47
49
|
resourceArn: process.env.WAREHOUSE_ARN,
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@felloh-org/lambda-wrapper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.29",
|
|
4
4
|
"description": "Lambda wrapper for all Felloh Serverless Projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "./node_modules/.bin/babel src --out-dir dist --copy-files --ignore src/migration",
|
|
8
8
|
"build:orm": "./node_modules/.bin/babel src --out-dir dist --copy-files --ignore src/migration",
|
|
9
|
+
"concourse:deploy": "fly -t felloh-cicd set-pipeline -p lambda-wrapper -c .concourse/pipeline.yml -l .concourse/private.yml",
|
|
10
|
+
"concourse:login": "fly --target felloh-cicd login --insecure --concourse-url https://ci.services.felloh.org --team-name libraries",
|
|
11
|
+
"concourse:sync": "sudo fly -t ci sync",
|
|
9
12
|
"lint": "./node_modules/.bin/eslint ./src",
|
|
10
13
|
"orm:migration:generate": "rm -rf dist && yarn build:orm && ./node_modules/.bin/typeorm migration:generate -o -n",
|
|
11
14
|
"orm:migration:run": "rm -rf dist && yarn build:orm && ./node_modules/.bin/typeorm migration:run",
|
|
@@ -34,7 +37,6 @@
|
|
|
34
37
|
"babel-jest": "^26.3.3",
|
|
35
38
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
36
39
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
37
|
-
"dotenv": "^11.0.0",
|
|
38
40
|
"eslint": "^8.6.0",
|
|
39
41
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
40
42
|
"eslint-plugin-import": "^2.25.3",
|
|
@@ -52,6 +54,7 @@
|
|
|
52
54
|
"alai": "1.0.3",
|
|
53
55
|
"async": "^3.2.0",
|
|
54
56
|
"axios": "^0.21.1",
|
|
57
|
+
"dotenv": "^11.0.0",
|
|
55
58
|
"epsagon": "^1.104.2",
|
|
56
59
|
"typeorm": "^0.2.41",
|
|
57
60
|
"typeorm-aurora-data-api-driver": "^2.3.5",
|