@felloh-org/lambda-wrapper 1.3.7 → 1.3.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/.eslintrc.yml CHANGED
@@ -22,3 +22,5 @@ rules:
22
22
  camelcase: "off"
23
23
  import/no-dynamic-require: "off"
24
24
  global-require: "off"
25
+ import/no-named-as-default: "off"
26
+ import/no-named-as-default-member: "off"
@@ -15,6 +15,8 @@ var _http = _interopRequireDefault(require("../service/http"));
15
15
 
16
16
  var _logger = _interopRequireDefault(require("../service/logger"));
17
17
 
18
+ var _paymentInitiationObject = _interopRequireDefault(require("../service/payment-initiation-object"));
19
+
18
20
  var _request = _interopRequireDefault(require("../service/request"));
19
21
 
20
22
  var _user = _interopRequireDefault(require("../service/user"));
@@ -29,6 +31,7 @@ const DEFINITIONS = {
29
31
  EVENT_BRIDGE: 'EVENT_BRIDGE',
30
32
  HTTP: 'HTTP',
31
33
  LOGGER: 'LOGGER',
34
+ PAYMENT_INITIATION_OBJECT: 'PAYMENT_INITIATION_OBJECT',
32
35
  REQUEST: 'REQUEST',
33
36
  USER: 'USER',
34
37
  WAREHOUSE: 'WAREHOUSE'
@@ -39,6 +42,7 @@ const Dependencies = {
39
42
  [DEFINITIONS.EVENT_BRIDGE]: _eventBridge.default,
40
43
  [DEFINITIONS.HTTP]: _http.default,
41
44
  [DEFINITIONS.LOGGER]: _logger.default,
45
+ [DEFINITIONS.PAYMENT_INITIATION_OBJECT]: _paymentInitiationObject.default,
42
46
  [DEFINITIONS.REQUEST]: _request.default,
43
47
  [DEFINITIONS.WAREHOUSE]: _warehouse.default,
44
48
  [DEFINITIONS.AUTHENTICATION]: _authentication.default,
@@ -9,11 +9,11 @@ var _typeorm = require("typeorm");
9
9
 
10
10
  var _user = _interopRequireDefault(require("../user"));
11
11
 
12
- var _bookingComponent = _interopRequireDefault(require("../../agent-data/booking-component"));
13
-
14
12
  var _organisationFeature = _interopRequireDefault(require("../organisation-feature"));
15
13
 
16
- var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11;
14
+ var _organisationType = _interopRequireDefault(require("../organisation-type"));
15
+
16
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12;
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
@@ -51,7 +51,10 @@ let Organisation = (_dec = (0, _typeorm.Entity)({
51
51
  name: "user_id",
52
52
  referencedColumnName: "id"
53
53
  }
54
- }), _dec12 = (0, _typeorm.TreeParent)(), _dec13 = (0, _typeorm.TreeChildren)(), _dec14 = (0, _typeorm.OneToMany)(() => _organisationFeature.default, organisationFeature => organisationFeature.organisation), _dec(_class = _dec2(_class = (_class2 = class Organisation {
54
+ }), _dec12 = (0, _typeorm.TreeParent)(), _dec13 = (0, _typeorm.TreeChildren)(), _dec14 = (0, _typeorm.OneToMany)(() => _organisationFeature.default, organisationFeature => organisationFeature.organisation), _dec15 = (0, _typeorm.ManyToOne)(() => _organisationType.default), _dec16 = (0, _typeorm.JoinColumn)({
55
+ name: 'type_id',
56
+ referencedColumnName: 'id'
57
+ }), _dec(_class = _dec2(_class = (_class2 = class Organisation {
55
58
  constructor() {
56
59
  _initializerDefineProperty(this, "id", _descriptor, this);
57
60
 
@@ -74,6 +77,8 @@ let Organisation = (_dec = (0, _typeorm.Entity)({
74
77
  _initializerDefineProperty(this, "children", _descriptor10, this);
75
78
 
76
79
  _initializerDefineProperty(this, "organisation_feature", _descriptor11, this);
80
+
81
+ _initializerDefineProperty(this, "organisation_type", _descriptor12, this);
77
82
  }
78
83
 
79
84
  propgate(id, name) {
@@ -179,5 +184,12 @@ let Organisation = (_dec = (0, _typeorm.Entity)({
179
184
  enumerable: true,
180
185
  writable: true,
181
186
  initializer: null
187
+ }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "organisation_type", [_dec15, _dec16], {
188
+ configurable: true,
189
+ enumerable: true,
190
+ writable: true,
191
+ initializer: function () {
192
+ return _organisationType.default;
193
+ }
182
194
  })), _class2)) || _class) || _class);
183
195
  exports.default = Organisation;
@@ -0,0 +1,44 @@
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 _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
11
+
12
+ 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 }); }
13
+
14
+ 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; }
15
+
16
+ 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.'); }
17
+
18
+ let OrganisationType = (_dec = (0, _typeorm.Entity)({
19
+ name: 'organisation_type',
20
+ schema: 'user'
21
+ }), _dec2 = (0, _typeorm.PrimaryGeneratedColumn)("uuid"), _dec3 = (0, _typeorm.Column)({
22
+ type: "varchar",
23
+ length: "150"
24
+ }), _dec(_class = (_class2 = class OrganisationType {
25
+ constructor() {
26
+ _initializerDefineProperty(this, "id", _descriptor, this);
27
+
28
+ _initializerDefineProperty(this, "name", _descriptor2, this);
29
+ }
30
+
31
+ }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
32
+ configurable: true,
33
+ enumerable: true,
34
+ writable: true,
35
+ initializer: null
36
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "name", [_dec3], {
37
+ configurable: true,
38
+ enumerable: true,
39
+ writable: true,
40
+ initializer: function () {
41
+ return "";
42
+ }
43
+ })), _class2)) || _class);
44
+ exports.default = OrganisationType;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ ECOMMERCE: 'ecommerce',
9
+ PAYMENT_LINK: 'payment-link'
10
+ };
11
+ exports.default = _default;
package/dist/index.js CHANGED
@@ -231,6 +231,12 @@ Object.defineProperty(exports, "OrganisationWebhookEntity", {
231
231
  return _organisationWebhook.default;
232
232
  }
233
233
  });
234
+ Object.defineProperty(exports, "PAYMENT_INITIATION_TYPES", {
235
+ enumerable: true,
236
+ get: function () {
237
+ return _paymentInitationTypes.default;
238
+ }
239
+ });
234
240
  Object.defineProperty(exports, "PaymentLinkEntity", {
235
241
  enumerable: true,
236
242
  get: function () {
@@ -636,6 +642,8 @@ var _organisationPayoutConfig = _interopRequireDefault(require("./entity/user/or
636
642
 
637
643
  var _transaction5 = _interopRequireDefault(require("./entity/nuvei/transaction"));
638
644
 
645
+ var _paymentInitationTypes = _interopRequireDefault(require("./enums/payment-initation-types"));
646
+
639
647
  var _registration = _interopRequireDefault(require("./event/user/registration"));
640
648
 
641
649
  var _changed = _interopRequireDefault(require("./event/user/password/changed"));
@@ -0,0 +1,17 @@
1
+ const { MigrationInterface, QueryRunner } = require("typeorm");
2
+
3
+ module.exports = class organisationType1669151569675 {
4
+ name = 'organisationType1669151569675'
5
+
6
+ async up(queryRunner) {
7
+ await queryRunner.query(`CREATE TABLE "user"."organisation_type" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying(150) NOT NULL, CONSTRAINT "PK_725a339dae75d88d0bb5c7307ff" PRIMARY KEY ("id"))`);
8
+ await queryRunner.query(`ALTER TABLE "user"."organisation" ADD "type_id" uuid`);
9
+ await queryRunner.query(`ALTER TABLE "user"."organisation" ADD CONSTRAINT "FK_725a339dae75d88d0bb5c7307ff" FOREIGN KEY ("type_id") REFERENCES "user"."organisation_type"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
10
+ }
11
+
12
+ async down(queryRunner) {
13
+ await queryRunner.query(`ALTER TABLE "user"."organisation" DROP CONSTRAINT "FK_725a339dae75d88d0bb5c7307ff"`);
14
+ await queryRunner.query(`ALTER TABLE "user"."organisation" DROP COLUMN "type_id"`);
15
+ await queryRunner.query(`DROP TABLE "user"."organisation_type"`);
16
+ }
17
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _dependencies = require("../../config/dependencies");
9
+
10
+ var _dependencyAware = _interopRequireDefault(require("../../dependency-injection/dependency-aware"));
11
+
12
+ var _currency = _interopRequireDefault(require("../../entity/bank/currency"));
13
+
14
+ var _ecommerce = _interopRequireDefault(require("../../entity/payment/ecommerce"));
15
+
16
+ var _paymentLink = _interopRequireDefault(require("../../entity/payment/payment-link"));
17
+
18
+ var _paymentInitationTypes = _interopRequireDefault(require("../../enums/payment-initation-types"));
19
+
20
+ var _response = _interopRequireDefault(require("../../model/response"));
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ /**
25
+ * Payment Initiation Object Service
26
+ */
27
+ class PaymentInitiationObject extends _dependencyAware.default {
28
+ /**
29
+ * Payment Initiation Constructor
30
+ * @param di
31
+ */
32
+ constructor(di) {
33
+ super(di);
34
+ this.initialised = false;
35
+ const that = this;
36
+
37
+ this.initialise = async () => {
38
+ if (that.initialised === false) {
39
+ const warehouse = di.get(_dependencies.DEFINITIONS.WAREHOUSE);
40
+ that.connection = await warehouse.connect();
41
+ that.paymentLinkRepository = await this.connection.getRepository(_paymentLink.default);
42
+ that.ecommerceRepository = await this.connection.getRepository(_ecommerce.default);
43
+ this.initialised = true;
44
+ }
45
+ };
46
+ }
47
+
48
+ async get(initiationObjectID, initiationType) {
49
+ await this.initialise();
50
+ let result = null;
51
+
52
+ if (initiationType === _paymentInitationTypes.default.PAYMENT_LINK) {
53
+ result = await this.paymentLinkRepository.createQueryBuilder('payment_link').leftJoinAndSelect('payment_link.organisation', 'organisation').leftJoinAndSelect('payment_link.booking', 'booking').leftJoinAndMapOne('payment_link.currency', _currency.default, 'currency_join', 'currency_join.id = payment_link.currency').where('payment_link.id = :initiation_object_ID', {
54
+ initiation_object_ID: initiationObjectID
55
+ }).getOne(); // Throw an error response if the payment link does not exist
56
+
57
+ if (!result) {
58
+ const notFoundResponse = new _response.default(null, 404);
59
+ notFoundResponse.addError({
60
+ title: 'Payment link not found',
61
+ message: 'The payment link entity that you are attempting to access does not exist',
62
+ documentation_url: 'https://developers.felloh.com/errors#error-responses',
63
+ type: 'not_found',
64
+ code: 'payment_link.not_found'
65
+ });
66
+ throw notFoundResponse;
67
+ }
68
+ } else if (initiationType === _paymentInitationTypes.default.ECOMMERCE) {
69
+ result = await this.ecommerceRepository.createQueryBuilder('ecommerce').leftJoinAndSelect('ecommerce.organisation', 'organisation').leftJoinAndSelect('ecommerce.booking', 'booking').leftJoinAndMapOne('ecommerce.currency', _currency.default, 'currency_join', 'currency_join.id = ecommerce.currency').where('ecommerce.id = :initiation_object_ID', {
70
+ initiation_object_ID: initiationObjectID
71
+ }).getOne(); // Throw an error response if the payment link does not exist
72
+
73
+ if (!result) {
74
+ const notFoundResponse = new _response.default(null, 404);
75
+ notFoundResponse.addError({
76
+ title: 'Ecommerce entity not found',
77
+ message: 'The ecommerce entity that you are attempting to access does not exist',
78
+ documentation_url: 'https://developers.felloh.com/errors#error-responses',
79
+ type: 'not_found',
80
+ code: 'ecommerce.not_found'
81
+ });
82
+ throw notFoundResponse;
83
+ }
84
+ } else {
85
+ const notFoundResponse = new _response.default(null, 501);
86
+ notFoundResponse.addError({
87
+ title: 'Payment initiation type not supported',
88
+ message: 'The payment initiation type that you provided is not supported',
89
+ documentation_url: 'https://developers.felloh.com/errors#error-responses',
90
+ type: 'not_found',
91
+ code: 'initiation_type.not_supported'
92
+ });
93
+ throw notFoundResponse;
94
+ }
95
+
96
+ return result;
97
+ }
98
+
99
+ }
100
+
101
+ exports.default = PaymentInitiationObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felloh-org/lambda-wrapper",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "Lambda wrapper for all Felloh Serverless Projects",
5
5
  "main": "dist/index.js",
6
6
  "engines": {