@felloh-org/lambda-wrapper 1.0.1 → 1.0.2
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/.eslintignore +5 -0
- package/.eslintrc.yml +1 -0
- package/babel.config.js +20 -1
- package/cli/seed/create-schema.js +22 -0
- package/dist/config/dependencies.js +6 -2
- package/dist/entity/agent-data/booking/index.js +39 -0
- package/dist/entity/agent-data/booking-component/index.js +39 -0
- package/dist/entity/agent-data/booking-component-type/index.js +39 -0
- package/dist/entity/agent-data/customer/index.js +39 -0
- package/dist/entity/agent-data/index.js +24 -0
- package/dist/entity/agent-data/organisation-supplier/index.js +39 -0
- package/dist/entity/agent-data/organisation-supplier-type/index.js +39 -0
- package/dist/entity/index.js +22 -0
- package/dist/entity/nuapay/balance/index.js +65 -0
- package/dist/entity/nuapay/index.js +14 -0
- package/dist/entity/payment/index.js +22 -0
- package/dist/entity/payment/payment-link/index.js +39 -0
- package/dist/entity/payment/transaction/index.js +39 -0
- package/dist/entity/payment/transaction-event/index.js +39 -0
- package/dist/entity/payment/transaction-method/index.js +39 -0
- package/dist/entity/payment/transaction-status/index.js +39 -0
- package/dist/entity/payout/beneficiary/index.js +103 -0
- package/dist/entity/payout/beneficiary-organisation/index.js +69 -0
- package/dist/entity/payout/beneficiary-provider/index.js +91 -0
- package/dist/entity/payout/disbursal/index.js +39 -0
- package/dist/entity/payout/index.js +20 -0
- package/dist/entity/user/feature/index.js +63 -0
- package/dist/entity/user/index.js +26 -0
- package/dist/entity/user/organisation/index.js +111 -0
- package/dist/entity/user/organisation-feature/index.js +69 -0
- package/dist/entity/user/role/index.js +107 -0
- package/dist/entity/user/user/index.js +147 -0
- package/dist/entity/user/user-activity/index.js +82 -0
- package/dist/entity/user/user-role/index.js +83 -0
- package/dist/index.js +200 -0
- package/dist/migration/agent-data/1642121041760-inital.js +17 -0
- package/dist/migration/agent-data/1642121610577-organisation-suppliers.js +13 -0
- package/dist/migration/agent-data/1642121681610-organisation-suppliers-type.js +13 -0
- package/dist/migration/agent-data/1642122014731-booking-component-type.js +13 -0
- package/dist/migration/nuapay/1642200051764-initial.js +13 -0
- package/dist/migration/nuapay/1642201303413-add-fields-nuapay.js +15 -0
- package/dist/migration/payment/1642120204899-inital.js +21 -0
- package/dist/migration/payout/1642141038609-initial.js +15 -0
- package/dist/migration/payout/1642196506002-beneficiary.js +31 -0
- package/dist/migration/payout/1642199881916-breakout-beneficaries.js +25 -0
- package/dist/migration/user/1641774481300-initial.js +27 -0
- package/dist/migration/user/1641829697638-add_parent_org.js +25 -0
- package/dist/migration/user/1641901624008-add_roles.js +21 -0
- package/dist/migration/user/1641903059924-add_roles_kyc.js +13 -0
- package/dist/migration/user/1641903425025-roles-defaults.js +15 -0
- package/dist/migration/user/1641939221103-feature.js +13 -0
- package/dist/migration/user/1642019067334-organisation-feature.js +17 -0
- package/dist/migration/user/1642078564295-user-activity-relation.js +16 -0
- package/dist/service/warehouse.js +59 -0
- package/ormconfig.js +25 -0
- package/package.json +17 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class organisationSuppliers1642121610577 {
|
|
4
|
+
name = 'organisationSuppliers1642121610577'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "agent_data"."organisation_supplier" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_b7b35819e17fc7448d6e5d065c8" PRIMARY KEY ("id"))`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async down(queryRunner) {
|
|
11
|
+
await queryRunner.query(`DROP TABLE "agent_data"."organisation_supplier"`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class organisationSuppliersType1642121681610 {
|
|
4
|
+
name = 'organisationSuppliersType1642121681610'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "agent_data"."organisation_supplier_type" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_bfeb2ecd22d6fc50b3f8397f5a8" PRIMARY KEY ("id"))`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async down(queryRunner) {
|
|
11
|
+
await queryRunner.query(`DROP TABLE "agent_data"."organisation_supplier_type"`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class bookingComponentType1642122014731 {
|
|
4
|
+
name = 'bookingComponentType1642122014731'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "agent_data"."booking_component_type" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_31c60e2f5eb5eb274efbf1551cb" PRIMARY KEY ("id"))`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async down(queryRunner) {
|
|
11
|
+
await queryRunner.query(`DROP TABLE "agent_data"."booking_component_type"`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class initial1642200051764 {
|
|
4
|
+
name = 'initial1642200051764'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "nuapay"."balance" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_079dddd31a81672e8143a649ca0" PRIMARY KEY ("id"))`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async down(queryRunner) {
|
|
11
|
+
await queryRunner.query(`DROP TABLE "nuapay"."balance"`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class addFieldsNuapay1642201303413 {
|
|
4
|
+
name = 'addFieldsNuapay1642201303413'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE "nuapay"."balance" ADD "account_id" character varying(50) NOT NULL`);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "nuapay"."balance" ADD "amount" integer NOT NULL`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async down(queryRunner) {
|
|
12
|
+
await queryRunner.query(`ALTER TABLE "nuapay"."balance" DROP COLUMN "amount"`);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "nuapay"."balance" DROP COLUMN "account_id"`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class inital1642120204899 {
|
|
4
|
+
name = 'inital1642120204899'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "payment"."payment_Link" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_e4d1c6bb16b048b1bade8ef8a50" PRIMARY KEY ("id"))`);
|
|
8
|
+
await queryRunner.query(`CREATE TABLE "payment"."transaction" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_89eadb93a89810556e1cbcd6ab9" PRIMARY KEY ("id"))`);
|
|
9
|
+
await queryRunner.query(`CREATE TABLE "payment"."transaction_event" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_1b4101c76f4a2c8168aeb8f3bad" PRIMARY KEY ("id"))`);
|
|
10
|
+
await queryRunner.query(`CREATE TABLE "payment"."transaction_method" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_46299cdd290767885705d0645a0" PRIMARY KEY ("id"))`);
|
|
11
|
+
await queryRunner.query(`CREATE TABLE "payment"."transaction_status" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_05fbbdf6bc1db819f47975c8c0b" PRIMARY KEY ("id"))`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async down(queryRunner) {
|
|
15
|
+
await queryRunner.query(`DROP TABLE "payment"."transaction_status"`);
|
|
16
|
+
await queryRunner.query(`DROP TABLE "payment"."transaction_method"`);
|
|
17
|
+
await queryRunner.query(`DROP TABLE "payment"."transaction_event"`);
|
|
18
|
+
await queryRunner.query(`DROP TABLE "payment"."transaction"`);
|
|
19
|
+
await queryRunner.query(`DROP TABLE "payment"."payment_Link"`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class initial1642141038609 {
|
|
4
|
+
name = 'initial1642141038609'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "payout"."beneficiary" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_c7514d7fed62b8e619cb1840f41" PRIMARY KEY ("id"))`);
|
|
8
|
+
await queryRunner.query(`CREATE TABLE "payout"."disbursal" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_17430dba4af2e3f4381822191e6" PRIMARY KEY ("id"))`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async down(queryRunner) {
|
|
12
|
+
await queryRunner.query(`DROP TABLE "payout"."disbursal"`);
|
|
13
|
+
await queryRunner.query(`DROP TABLE "payout"."beneficiary"`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class beneficiary1642196506002 {
|
|
4
|
+
name = 'beneficiary1642196506002'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "payout"."beneficiary_provider" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "provider" character varying(15) NOT NULL, "provider_reference" character varying(50) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "beneficiary_id" uuid, CONSTRAINT "PK_2220d6b6016a2b9c411e660f041" PRIMARY KEY ("id"))`);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD "iban" character varying(15) NOT NULL`);
|
|
9
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD "bic" character varying(15) NOT NULL`);
|
|
10
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD "account_number" character varying(15) NOT NULL`);
|
|
11
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD "sort_code" character varying(10) NOT NULL`);
|
|
12
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD "bank_name" character varying(250) NOT NULL`);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD "account_holder_name" character varying(150) NOT NULL`);
|
|
14
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD "organisation_id" character varying(150)`);
|
|
15
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD CONSTRAINT "FK_ffd5169bc5af13fe1f7886c57c7" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
16
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary_provider" ADD CONSTRAINT "FK_317acae819f5e265f3db0d21828" FOREIGN KEY ("beneficiary_id") REFERENCES "payout"."beneficiary"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async down(queryRunner) {
|
|
20
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary_provider" DROP CONSTRAINT "FK_317acae819f5e265f3db0d21828"`);
|
|
21
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP CONSTRAINT "FK_ffd5169bc5af13fe1f7886c57c7"`);
|
|
22
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP COLUMN "organisation_id"`);
|
|
23
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP COLUMN "account_holder_name"`);
|
|
24
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP COLUMN "bank_name"`);
|
|
25
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP COLUMN "sort_code"`);
|
|
26
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP COLUMN "account_number"`);
|
|
27
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP COLUMN "bic"`);
|
|
28
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP COLUMN "iban"`);
|
|
29
|
+
await queryRunner.query(`DROP TABLE "payout"."beneficiary_provider"`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class breakoutBeneficaries1642199881916 {
|
|
4
|
+
name = 'breakoutBeneficaries1642199881916'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP CONSTRAINT "FK_ffd5169bc5af13fe1f7886c57c7"`);
|
|
8
|
+
await queryRunner.query(`CREATE TABLE "payout"."beneficiary_organisation" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "organisation_id" character varying(150), "beneficiary_id" uuid, CONSTRAINT "PK_ffd5169bc5af13fe1f7886c57c7" PRIMARY KEY ("id"))`);
|
|
9
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP COLUMN "account_holder_name"`);
|
|
10
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" DROP COLUMN "organisation_id"`);
|
|
11
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary_provider" ADD "account_name" character varying(150) NOT NULL`);
|
|
12
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary_organisation" ADD CONSTRAINT "FK_c24725d6eb6c8344a8fd0902ea9" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary_organisation" ADD CONSTRAINT "FK_e7ea971de48f59c01f33e0e3447" FOREIGN KEY ("beneficiary_id") REFERENCES "payout"."beneficiary"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async down(queryRunner) {
|
|
17
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary_organisation" DROP CONSTRAINT "FK_e7ea971de48f59c01f33e0e3447"`);
|
|
18
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary_organisation" DROP CONSTRAINT "FK_c24725d6eb6c8344a8fd0902ea9"`);
|
|
19
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary_provider" DROP COLUMN "account_name"`);
|
|
20
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD "organisation_id" character varying(150)`);
|
|
21
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD "account_holder_name" character varying(150) NOT NULL`);
|
|
22
|
+
await queryRunner.query(`DROP TABLE "payout"."beneficiary_organisation"`);
|
|
23
|
+
await queryRunner.query(`ALTER TABLE "payout"."beneficiary" ADD CONSTRAINT "FK_ffd5169bc5af13fe1f7886c57c7" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class initial1641774481300 {
|
|
4
|
+
name = 'initial1641774481300'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "user"."user" ("id" character varying NOT NULL, "email" character varying(150) NOT NULL, "mobile" character varying(50) NOT NULL, "status" character varying(20) NOT NULL, "first_name" character varying(50) NOT NULL, "last_name" character varying(50) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "deleted_at" TIMESTAMP, CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))`);
|
|
8
|
+
await queryRunner.query(`CREATE TABLE "user"."organisation" ("id" character varying(150) NOT NULL, "name" character varying(150) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "deleted_at" TIMESTAMP, CONSTRAINT "PK_c725ae234ef1b74cce43d2d00c1" PRIMARY KEY ("id"))`);
|
|
9
|
+
await queryRunner.query(`CREATE TABLE "user"."user_activity" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "user_id" uuid NOT NULL, "type" character varying(40) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_daec6d19443689bda7d7785dff5" PRIMARY KEY ("id"))`);
|
|
10
|
+
await queryRunner.query(`CREATE TABLE "user"."user_organisation" ("user_id" character varying NOT NULL, "organisation_id" character varying(150) NOT NULL, CONSTRAINT "PK_d599e115321426b27bca2a4b358" PRIMARY KEY ("user_id", "organisation_id"))`);
|
|
11
|
+
await queryRunner.query(`CREATE INDEX "IDX_81c4608739c8cf71fa1f96e11a" ON "user"."user_organisation" ("user_id") `);
|
|
12
|
+
await queryRunner.query(`CREATE INDEX "IDX_d9628e009b6d71bf677c04f849" ON "user"."user_organisation" ("organisation_id") `);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "user"."user_organisation" ADD CONSTRAINT "FK_81c4608739c8cf71fa1f96e11ae" FOREIGN KEY ("user_id") REFERENCES "user"."user"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
|
|
14
|
+
await queryRunner.query(`ALTER TABLE "user"."user_organisation" ADD CONSTRAINT "FK_d9628e009b6d71bf677c04f8494" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async down(queryRunner) {
|
|
18
|
+
await queryRunner.query(`ALTER TABLE "user"."user_organisation" DROP CONSTRAINT "FK_d9628e009b6d71bf677c04f8494"`);
|
|
19
|
+
await queryRunner.query(`ALTER TABLE "user"."user_organisation" DROP CONSTRAINT "FK_81c4608739c8cf71fa1f96e11ae"`);
|
|
20
|
+
await queryRunner.query(`DROP INDEX "user"."IDX_d9628e009b6d71bf677c04f849"`);
|
|
21
|
+
await queryRunner.query(`DROP INDEX "user"."IDX_81c4608739c8cf71fa1f96e11a"`);
|
|
22
|
+
await queryRunner.query(`DROP TABLE "user"."user_organisation"`);
|
|
23
|
+
await queryRunner.query(`DROP TABLE "user"."user_activity"`);
|
|
24
|
+
await queryRunner.query(`DROP TABLE "user"."organisation"`);
|
|
25
|
+
await queryRunner.query(`DROP TABLE "user"."user"`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class addParentOrg1641829697638 {
|
|
4
|
+
name = 'addParentOrg1641829697638'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "user"."organisation_closure" ("id_ancestor" character varying(150) NOT NULL, "id_descendant" character varying(150) NOT NULL, CONSTRAINT "PK_6210860cf458ba75ab41cd75f3e" PRIMARY KEY ("id_ancestor", "id_descendant"))`);
|
|
8
|
+
await queryRunner.query(`CREATE INDEX "IDX_782ab4746828e9670270126382" ON "user"."organisation_closure" ("id_ancestor") `);
|
|
9
|
+
await queryRunner.query(`CREATE INDEX "IDX_4ecfeb9b0f697a97953e950966" ON "user"."organisation_closure" ("id_descendant") `);
|
|
10
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation" ADD "parentId" character varying(150)`);
|
|
11
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation" ADD CONSTRAINT "FK_e0cce4f368b593650f8ecb27e8d" FOREIGN KEY ("parentId") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
12
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_closure" ADD CONSTRAINT "FK_782ab4746828e96702701263820" FOREIGN KEY ("id_ancestor") REFERENCES "user"."organisation"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_closure" ADD CONSTRAINT "FK_4ecfeb9b0f697a97953e950966b" FOREIGN KEY ("id_descendant") REFERENCES "user"."organisation"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async down(queryRunner) {
|
|
17
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_closure" DROP CONSTRAINT "FK_4ecfeb9b0f697a97953e950966b"`);
|
|
18
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_closure" DROP CONSTRAINT "FK_782ab4746828e96702701263820"`);
|
|
19
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation" DROP CONSTRAINT "FK_e0cce4f368b593650f8ecb27e8d"`);
|
|
20
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation" DROP COLUMN "parentId"`);
|
|
21
|
+
await queryRunner.query(`DROP INDEX "user"."IDX_4ecfeb9b0f697a97953e950966"`);
|
|
22
|
+
await queryRunner.query(`DROP INDEX "user"."IDX_782ab4746828e9670270126382"`);
|
|
23
|
+
await queryRunner.query(`DROP TABLE "user"."organisation_closure"`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class addRoles1641901624008 {
|
|
4
|
+
name = 'addRoles1641901624008'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "user"."role" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "machine_name" character varying(50) NOT NULL, "name" character varying(150) NOT NULL, "description" character varying(250) NOT NULL, "parent_only" boolean NOT NULL, "group" character varying(100) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_b36bcfe02fc8de3c57a8b2391c2" PRIMARY KEY ("id"))`);
|
|
8
|
+
await queryRunner.query(`CREATE TABLE "user"."user_role" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "user_id" character varying NOT NULL, "organisation_id" character varying(150) NOT NULL, "role_id" uuid NOT NULL, CONSTRAINT "PK_38abbb50a455f9a7da9651ce5d7" PRIMARY KEY ("id", "user_id", "organisation_id", "role_id"))`);
|
|
9
|
+
await queryRunner.query(`ALTER TABLE "user"."user_role" ADD CONSTRAINT "FK_d0e5815877f7395a198a4cb0a46" FOREIGN KEY ("user_id") REFERENCES "user"."user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
10
|
+
await queryRunner.query(`ALTER TABLE "user"."user_role" ADD CONSTRAINT "FK_fe76718250bdec1ebff3494c99b" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
11
|
+
await queryRunner.query(`ALTER TABLE "user"."user_role" ADD CONSTRAINT "FK_32a6fc2fcb019d8e3a8ace0f55f" FOREIGN KEY ("role_id") REFERENCES "user"."role"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async down(queryRunner) {
|
|
15
|
+
await queryRunner.query(`ALTER TABLE "user"."user_role" DROP CONSTRAINT "FK_32a6fc2fcb019d8e3a8ace0f55f"`);
|
|
16
|
+
await queryRunner.query(`ALTER TABLE "user"."user_role" DROP CONSTRAINT "FK_fe76718250bdec1ebff3494c99b"`);
|
|
17
|
+
await queryRunner.query(`ALTER TABLE "user"."user_role" DROP CONSTRAINT "FK_d0e5815877f7395a198a4cb0a46"`);
|
|
18
|
+
await queryRunner.query(`DROP TABLE "user"."user_role"`);
|
|
19
|
+
await queryRunner.query(`DROP TABLE "user"."role"`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class addRolesKyc1641903059924 {
|
|
4
|
+
name = 'addRolesKyc1641903059924'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE "user"."role" ADD "kyc_required" boolean NOT NULL`);;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async down(queryRunner) {
|
|
11
|
+
await queryRunner.query(`ALTER TABLE "user"."role" DROP COLUMN "kyc_required"`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class rolesDefaults1641903425025 {
|
|
4
|
+
name = 'rolesDefaults1641903425025'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE "user"."role" ALTER COLUMN "parent_only" SET DEFAULT false`);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "user"."role" ALTER COLUMN "kyc_required" SET DEFAULT false`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async down(queryRunner) {
|
|
12
|
+
await queryRunner.query(`ALTER TABLE "user"."role" ALTER COLUMN "kyc_required" DROP DEFAULT`);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "user"."role" ALTER COLUMN "parent_only" DROP DEFAULT`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class feature1641939221103 {
|
|
4
|
+
name = 'feature1641939221103'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "user"."feature" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "machine_name" character varying(50) NOT NULL, "name" character varying(150) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_03930932f909ca4be8e33d16a2d" PRIMARY KEY ("id"))`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async down(queryRunner) {
|
|
11
|
+
await queryRunner.query(`DROP TABLE "user"."feature"`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class organisationFeature1642019067334 {
|
|
4
|
+
name = 'organisationFeature1642019067334'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "user"."organisation_feature" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "organisation_id" character varying(150), "feature_id" uuid, CONSTRAINT "PK_ee793662f5baf61d42cf0213a5d" PRIMARY KEY ("id"))`);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_feature" ADD CONSTRAINT "FK_65a20c77a2387c9717c02efd4ab" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
9
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_feature" ADD CONSTRAINT "FK_a8920942bf7f3703d9968fa8eae" FOREIGN KEY ("feature_id") REFERENCES "user"."feature"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async down(queryRunner) {
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_feature" DROP CONSTRAINT "FK_a8920942bf7f3703d9968fa8eae"`);
|
|
14
|
+
await queryRunner.query(`ALTER TABLE "user"."organisation_feature" DROP CONSTRAINT "FK_65a20c77a2387c9717c02efd4ab"`);
|
|
15
|
+
await queryRunner.query(`DROP TABLE "user"."organisation_feature"`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class userActivityRelation1642078564295 {
|
|
4
|
+
name = 'userActivityRelation1642078564295'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE "user"."user_activity" DROP COLUMN "user_id"`);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "user"."user_activity" ADD "user_id" character varying NOT NULL`);
|
|
9
|
+
await queryRunner.query(`ALTER TABLE "user"."user_activity" ADD CONSTRAINT "FK_11108754ec780c670440e32baad" FOREIGN KEY ("user_id") REFERENCES "user"."user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);}
|
|
10
|
+
|
|
11
|
+
async down(queryRunner) {
|
|
12
|
+
await queryRunner.query(`ALTER TABLE "user"."user_activity" DROP CONSTRAINT "FK_11108754ec780c670440e32baad"`);
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "user"."user_activity" DROP COLUMN "user_id"`);
|
|
14
|
+
await queryRunner.query(`ALTER TABLE "user"."user_activity" ADD "user_id" uuid NOT NULL`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 _typeormAuroraDataApiDriver = _interopRequireDefault(require("typeorm-aurora-data-api-driver"));
|
|
11
|
+
|
|
12
|
+
var _dependencyAware = _interopRequireDefault(require("../dependency-injection/dependency-aware"));
|
|
13
|
+
|
|
14
|
+
var _entity = _interopRequireDefault(require("../entity"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
// eslint-disable-line no-unused-vars
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Warehouse Serv8ce
|
|
22
|
+
*/
|
|
23
|
+
class Warehouse extends _dependencyAware.default {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.connection = null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @returns {Promise<Connection>}
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
async connect() {
|
|
35
|
+
if (this.connection) {
|
|
36
|
+
return this.connection;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
this.connection = await (0, _typeorm.getConnection)();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
this.connection = await (0, _typeorm.createConnection)({
|
|
43
|
+
type: 'aurora-data-api-pg',
|
|
44
|
+
database: process.env.WAREHOUSE_DATABASE,
|
|
45
|
+
schema: process.env.WAREHOUSE_SCHEMA,
|
|
46
|
+
secretArn: process.env.WAREHOUSE_SECRET_ARN,
|
|
47
|
+
resourceArn: process.env.WAREHOUSE_ARN,
|
|
48
|
+
region: process.env.REGION,
|
|
49
|
+
entities: _entity.default,
|
|
50
|
+
logging: false
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return this.connection;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.default = Warehouse;
|
package/ormconfig.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const DotEnv = require('dotenv');
|
|
2
|
+
|
|
3
|
+
DotEnv.config();
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
"type": "aurora-data-api-pg",
|
|
7
|
+
"database": process.env.WAREHOUSE_DATABASE,
|
|
8
|
+
"secretArn": process.env.WAREHOUSE_SECRET_ARN,
|
|
9
|
+
"resourceArn": process.env.WAREHOUSE_ARN,
|
|
10
|
+
"region": process.env.REGION,
|
|
11
|
+
"synchronize": true,
|
|
12
|
+
"logging": false,
|
|
13
|
+
"schema": 'user',
|
|
14
|
+
"entities": [
|
|
15
|
+
__dirname + '/dist/entity/**/*.ts',
|
|
16
|
+
__dirname + '/dist/entity/**/*.js',
|
|
17
|
+
],
|
|
18
|
+
"migrations": [
|
|
19
|
+
__dirname + '/dist/migration/**/*.ts',
|
|
20
|
+
__dirname + '/dist/migration/**/*.js'
|
|
21
|
+
],
|
|
22
|
+
"cli": {
|
|
23
|
+
"migrationsDir": __dirname + '/src/migration'
|
|
24
|
+
},
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@felloh-org/lambda-wrapper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Lambda wrapper for all Felloh Serverless Projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"lint": "./node_modules/.bin/eslint ./src",
|
|
8
|
+
"orm:migration:generate": "rm -rf dist && yarn build:orm && ./node_modules/.bin/typeorm migration:generate -o -n",
|
|
9
|
+
"orm:migration:run": "rm -rf dist && yarn build:orm && ./node_modules/.bin/typeorm migration:run",
|
|
10
|
+
"orm:schema:create": "babel-node ./cli/seed/create-schema.js",
|
|
11
|
+
"orm:seed": "babel-node ./cli/seed/index.js",
|
|
8
12
|
"test": "jest --coverage",
|
|
9
|
-
"build": "./node_modules/.bin/babel src --out-dir dist --copy-files"
|
|
13
|
+
"build": "./node_modules/.bin/babel src --out-dir dist --copy-files --ignore src/migration",
|
|
14
|
+
"build:orm": "./node_modules/.bin/babel src --out-dir dist --copy-files --ignore src/migration"
|
|
10
15
|
},
|
|
11
16
|
"author": "Felloh",
|
|
12
17
|
"license": "MIT",
|
|
@@ -15,6 +20,8 @@
|
|
|
15
20
|
"@babel/core": "^7.12.10",
|
|
16
21
|
"@babel/eslint-parser": "^7.16.5",
|
|
17
22
|
"@babel/node": "^7.12.10",
|
|
23
|
+
"@babel/plugin-proposal-decorators": "^7.16.7",
|
|
24
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
18
25
|
"@babel/plugin-syntax-flow": "^7.12.1",
|
|
19
26
|
"@babel/plugin-transform-flow-strip-types": "^7.12.10",
|
|
20
27
|
"@babel/preset-env": "^7.12.11",
|
|
@@ -23,14 +30,18 @@
|
|
|
23
30
|
"aws-sdk": ">=2.831.0",
|
|
24
31
|
"babel-eslint": "^10.1.0",
|
|
25
32
|
"babel-jest": "^26.3.3",
|
|
26
|
-
"
|
|
33
|
+
"babel-plugin-module-resolver": "^4.1.0",
|
|
34
|
+
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
35
|
+
"dotenv": "^11.0.0",
|
|
36
|
+
"eslint": "^8.6.0",
|
|
27
37
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
28
38
|
"eslint-plugin-import": "^2.25.3",
|
|
29
39
|
"eslint-plugin-sonarjs": "^0.11.0",
|
|
30
40
|
"eslint-plugin-unicorn": "^39.0.0",
|
|
31
41
|
"jest": "^26.6.3",
|
|
32
42
|
"nyc": "^15.1.0",
|
|
33
|
-
"semantic-release": "^17.3.7"
|
|
43
|
+
"semantic-release": "^17.3.7",
|
|
44
|
+
"transform-class-properties": "^1.0.0-beta"
|
|
34
45
|
},
|
|
35
46
|
"peerDependencies": {
|
|
36
47
|
"aws-sdk": ">=2.831.0"
|
|
@@ -40,6 +51,8 @@
|
|
|
40
51
|
"async": "^3.2.0",
|
|
41
52
|
"axios": "^0.21.1",
|
|
42
53
|
"epsagon": "^1.104.2",
|
|
54
|
+
"typeorm": "^0.2.41",
|
|
55
|
+
"typeorm-aurora-data-api-driver": "^2.3.5",
|
|
43
56
|
"useragent": "2.3.0",
|
|
44
57
|
"uuid": "^8.2.0",
|
|
45
58
|
"validate.js": "0.13.1",
|