@felloh-org/lambda-wrapper 1.1.74 → 1.2.0

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
@@ -8,6 +8,9 @@ plugins:
8
8
  extends:
9
9
  - "@felloh-org/eslint-config/mixins/base"
10
10
 
11
+ parserOptions:
12
+ ecmaVersion: 11
13
+
11
14
  ignorePatterns:
12
15
  - dist
13
16
  - tests
@@ -19,4 +22,3 @@ rules:
19
22
  camelcase: "off"
20
23
  import/no-dynamic-require: "off"
21
24
  global-require: "off"
22
-
@@ -19,7 +19,7 @@ var _bookingComponent = _interopRequireDefault(require("../booking-component"));
19
19
 
20
20
  var _paymentLink = _interopRequireDefault(require("../../payment/payment-link"));
21
21
 
22
- var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _descriptor15;
22
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _descriptor15, _descriptor16;
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
@@ -66,7 +66,10 @@ let Booking = (_dec = (0, _typeorm.Entity)({
66
66
  }), _dec18 = (0, _typeorm.DeleteDateColumn)({
67
67
  type: 'timestamp with time zone',
68
68
  nullable: true
69
- }), _dec19 = (0, _typeorm.OneToMany)(() => _paymentLink.default, paymentLink => paymentLink.booking), _dec(_class = (_class2 = class Booking {
69
+ }), _dec19 = (0, _typeorm.OneToMany)(() => _paymentLink.default, paymentLink => paymentLink.booking), _dec20 = (0, _typeorm.Column)({
70
+ type: "boolean",
71
+ default: false
72
+ }), _dec(_class = (_class2 = class Booking {
70
73
  constructor() {
71
74
  _initializerDefineProperty(this, "id", _descriptor, this);
72
75
 
@@ -97,13 +100,16 @@ let Booking = (_dec = (0, _typeorm.Entity)({
97
100
  _initializerDefineProperty(this, "deleted_at", _descriptor14, this);
98
101
 
99
102
  _initializerDefineProperty(this, "payment_links", _descriptor15, this);
103
+
104
+ _initializerDefineProperty(this, "is_temporary", _descriptor16, this);
100
105
  }
101
106
 
102
107
  /**
103
108
  * Get Public Data
104
- * @returns {{departure_date: string, created_at: Date, booking_reference: string, id: (*|string), customer_name: string, email: string, return_date: string}}
109
+ * @param showTemporaryFlag
110
+ * @returns {{components: [], departure_date: string, created_at: Date, organisation: null, booking_reference: string, gross_amount: number, transactions: [], payment_links: [], id: *|string, customer_name: string, user: null, email: string, return_date: string}}
105
111
  */
106
- getPublicData() {
112
+ getPublicData(showTemporaryFlag = false) {
107
113
  const response = {
108
114
  id: this.id,
109
115
  booking_reference: this.booking_reference,
@@ -120,6 +126,10 @@ let Booking = (_dec = (0, _typeorm.Entity)({
120
126
  organisation: null
121
127
  };
122
128
 
129
+ if (showTemporaryFlag === true) {
130
+ response.is_temporary = this.is_temporary;
131
+ }
132
+
123
133
  if (typeof this.transactions !== 'undefined') {
124
134
  response.transactions = this.transactions.map(transaction => transaction.getPublicCompactData());
125
135
  }
@@ -230,5 +240,12 @@ let Booking = (_dec = (0, _typeorm.Entity)({
230
240
  enumerable: true,
231
241
  writable: true,
232
242
  initializer: null
243
+ }), _descriptor16 = _applyDecoratedDescriptor(_class2.prototype, "is_temporary", [_dec20], {
244
+ configurable: true,
245
+ enumerable: true,
246
+ writable: true,
247
+ initializer: function () {
248
+ return false;
249
+ }
233
250
  })), _class2)) || _class);
234
251
  exports.default = Booking;
@@ -15,7 +15,9 @@ var _paymentProvider = _interopRequireDefault(require("../payment-provider"));
15
15
 
16
16
  var _transactionMethod = _interopRequireDefault(require("../transaction-method"));
17
17
 
18
- var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14;
18
+ var _organisationPaymentProviderMethod = _interopRequireDefault(require("../organisation-payment-provider-method"));
19
+
20
+ 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, _descriptor12, _descriptor13, _descriptor14;
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
@@ -37,37 +39,24 @@ let OrganisationPaymentProvider = (_dec = (0, _typeorm.Entity)({
37
39
  }), _dec6 = (0, _typeorm.ManyToOne)(() => _paymentProvider.default), _dec7 = (0, _typeorm.JoinColumn)({
38
40
  name: 'payment_provider_id',
39
41
  referencedColumnName: 'id'
40
- }), _dec8 = (0, _typeorm.ManyToMany)(() => _transactionMethod.default, {
41
- cascade: true
42
- }), _dec9 = (0, _typeorm.JoinTable)({
43
- name: "organisation_payment_provider_method",
44
- schema: "payment",
45
- joinColumn: {
46
- name: "organisation_payment_provider_id",
47
- referencedColumnName: "id"
48
- },
49
- inverseJoinColumn: {
50
- name: "transaction_method_id",
51
- referencedColumnName: "id"
52
- }
53
- }), _dec10 = (0, _typeorm.Column)({
42
+ }), _dec8 = (0, _typeorm.OneToMany)(() => _organisationPaymentProviderMethod.default, transactionMethod => transactionMethod.payment_provider), _dec9 = (0, _typeorm.Column)({
54
43
  type: "varchar",
55
44
  length: "150"
56
- }), _dec11 = (0, _typeorm.Column)({
45
+ }), _dec10 = (0, _typeorm.Column)({
57
46
  type: "json",
58
47
  nullable: true
59
- }), _dec12 = (0, _typeorm.Column)({
48
+ }), _dec11 = (0, _typeorm.Column)({
60
49
  type: "varchar",
61
50
  length: "512"
62
- }), _dec13 = (0, _typeorm.Column)({
51
+ }), _dec12 = (0, _typeorm.Column)({
63
52
  type: "varchar",
64
53
  length: "4"
65
- }), _dec14 = (0, _typeorm.Column)({
54
+ }), _dec13 = (0, _typeorm.Column)({
66
55
  type: "boolean",
67
56
  default: false
68
- }), _dec15 = (0, _typeorm.Column)({
57
+ }), _dec14 = (0, _typeorm.Column)({
69
58
  type: "int"
70
- }), _dec16 = (0, _typeorm.CreateDateColumn)(), _dec17 = (0, _typeorm.UpdateDateColumn)(), _dec18 = (0, _typeorm.DeleteDateColumn)(), _dec(_class = (_class2 = class OrganisationPaymentProvider {
59
+ }), _dec15 = (0, _typeorm.CreateDateColumn)(), _dec16 = (0, _typeorm.UpdateDateColumn)(), _dec17 = (0, _typeorm.DeleteDateColumn)(), _dec(_class = (_class2 = class OrganisationPaymentProvider {
71
60
  constructor() {
72
61
  _initializerDefineProperty(this, "id", _descriptor, this);
73
62
 
@@ -126,60 +115,60 @@ let OrganisationPaymentProvider = (_dec = (0, _typeorm.Entity)({
126
115
  initializer: function () {
127
116
  return _paymentProvider.default;
128
117
  }
129
- }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "transaction_methods", [_dec8, _dec9], {
118
+ }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "transaction_methods", [_dec8], {
130
119
  configurable: true,
131
120
  enumerable: true,
132
121
  writable: true,
133
122
  initializer: null
134
- }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "public_key", [_dec10], {
123
+ }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "public_key", [_dec9], {
135
124
  configurable: true,
136
125
  enumerable: true,
137
126
  writable: true,
138
127
  initializer: function () {
139
128
  return "";
140
129
  }
141
- }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "public_creds", [_dec11], {
130
+ }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "public_creds", [_dec10], {
142
131
  configurable: true,
143
132
  enumerable: true,
144
133
  writable: true,
145
134
  initializer: null
146
- }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "secret_key", [_dec12], {
135
+ }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "secret_key", [_dec11], {
147
136
  configurable: true,
148
137
  enumerable: true,
149
138
  writable: true,
150
139
  initializer: function () {
151
140
  return "";
152
141
  }
153
- }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "secret_key_last_four", [_dec13], {
142
+ }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "secret_key_last_four", [_dec12], {
154
143
  configurable: true,
155
144
  enumerable: true,
156
145
  writable: true,
157
146
  initializer: function () {
158
147
  return "";
159
148
  }
160
- }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "is_active", [_dec14], {
149
+ }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "is_active", [_dec13], {
161
150
  configurable: true,
162
151
  enumerable: true,
163
152
  writable: true,
164
153
  initializer: function () {
165
154
  return false;
166
155
  }
167
- }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "weight", [_dec15], {
156
+ }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "weight", [_dec14], {
168
157
  configurable: true,
169
158
  enumerable: true,
170
159
  writable: true,
171
160
  initializer: null
172
- }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec16], {
161
+ }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec15], {
173
162
  configurable: true,
174
163
  enumerable: true,
175
164
  writable: true,
176
165
  initializer: null
177
- }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "updated_at", [_dec17], {
166
+ }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "updated_at", [_dec16], {
178
167
  configurable: true,
179
168
  enumerable: true,
180
169
  writable: true,
181
170
  initializer: null
182
- }), _descriptor14 = _applyDecoratedDescriptor(_class2.prototype, "deleted_at", [_dec18], {
171
+ }), _descriptor14 = _applyDecoratedDescriptor(_class2.prototype, "deleted_at", [_dec17], {
183
172
  configurable: true,
184
173
  enumerable: true,
185
174
  writable: true,
@@ -0,0 +1,64 @@
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 _organisationPaymentProvider = _interopRequireDefault(require("../organisation-payment-provider"));
11
+
12
+ var _transactionMethod = _interopRequireDefault(require("../transaction-method"));
13
+
14
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _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 OrganisationPaymentProviderMethod = (_dec = (0, _typeorm.Entity)({
25
+ name: 'organisation_payment_provider_method',
26
+ schema: 'payment'
27
+ }), _dec2 = (0, _typeorm.ManyToOne)(() => _organisationPaymentProvider.default, {
28
+ primary: true
29
+ }), _dec3 = (0, _typeorm.JoinColumn)({
30
+ name: 'organisation_payment_provider_id',
31
+ referencedColumnName: 'id'
32
+ }), _dec4 = (0, _typeorm.ManyToOne)(() => _transactionMethod.default, {
33
+ primary: true
34
+ }), _dec5 = (0, _typeorm.JoinColumn)({
35
+ name: 'transaction_method_id',
36
+ referencedColumnName: 'id'
37
+ }), _dec6 = (0, _typeorm.Column)({
38
+ type: 'int'
39
+ }), _dec(_class = (_class2 = class OrganisationPaymentProviderMethod {
40
+ constructor() {
41
+ _initializerDefineProperty(this, "payment_provider", _descriptor, this);
42
+
43
+ _initializerDefineProperty(this, "transaction_method", _descriptor2, this);
44
+
45
+ _initializerDefineProperty(this, "weight", _descriptor3, this);
46
+ }
47
+
48
+ }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "payment_provider", [_dec2, _dec3], {
49
+ configurable: true,
50
+ enumerable: true,
51
+ writable: true,
52
+ initializer: null
53
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "transaction_method", [_dec4, _dec5], {
54
+ configurable: true,
55
+ enumerable: true,
56
+ writable: true,
57
+ initializer: null
58
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "weight", [_dec6], {
59
+ configurable: true,
60
+ enumerable: true,
61
+ writable: true,
62
+ initializer: null
63
+ })), _class2)) || _class);
64
+ exports.default = OrganisationPaymentProviderMethod;
@@ -89,9 +89,14 @@ let Organisation = (_dec = (0, _typeorm.Entity)({
89
89
  created_at: this.created_at,
90
90
  updated_at: this.updated_at,
91
91
  deleted_at: this.deleted_at,
92
- features: []
92
+ features: [],
93
+ parent: null
93
94
  };
94
95
 
96
+ if (this.parent !== null && typeof this.parent.getPublicCompactData === 'function') {
97
+ response.parent = this.parent.getPublicCompactData();
98
+ }
99
+
95
100
  if (this.organisation_feature !== null && this.organisation_feature.length >= 1) {
96
101
  response.features = this.organisation_feature.map(orgFeature => ({
97
102
  id: orgFeature.feature.id,
@@ -0,0 +1,25 @@
1
+ const { MigrationInterface, QueryRunner } = require("typeorm");
2
+
3
+ module.exports = class organisationPaymentProviderMethodWeight1661262743555 {
4
+ name = 'organisationPaymentProviderMethodWeight1661262743555'
5
+
6
+ async up(queryRunner) {
7
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" DROP CONSTRAINT "FK_5c73d00c542e73bc44fc84f5e1e"`);
8
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" DROP CONSTRAINT "FK_1027b1f5301948b2c8dc5121017"`);
9
+ await queryRunner.query(`DROP INDEX "payment"."IDX_1027b1f5301948b2c8dc512101"`);
10
+ await queryRunner.query(`DROP INDEX "payment"."IDX_5c73d00c542e73bc44fc84f5e1"`);
11
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" ADD "weight" integer NOT NULL`);
12
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" ADD CONSTRAINT "FK_1027b1f5301948b2c8dc5121017" FOREIGN KEY ("organisation_payment_provider_id") REFERENCES "payment"."organisation_payment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
13
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" ADD CONSTRAINT "FK_5c73d00c542e73bc44fc84f5e1e" FOREIGN KEY ("transaction_method_id") REFERENCES "payment"."transaction_method"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
14
+ }
15
+
16
+ async down(queryRunner) {
17
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" DROP CONSTRAINT "FK_5c73d00c542e73bc44fc84f5e1e"`);
18
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" DROP CONSTRAINT "FK_1027b1f5301948b2c8dc5121017"`);
19
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" DROP COLUMN "weight"`);
20
+ await queryRunner.query(`CREATE INDEX "IDX_5c73d00c542e73bc44fc84f5e1" ON "payment"."organisation_payment_provider_method" ("transaction_method_id") `);
21
+ await queryRunner.query(`CREATE INDEX "IDX_1027b1f5301948b2c8dc512101" ON "payment"."organisation_payment_provider_method" ("organisation_payment_provider_id") `);
22
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" ADD CONSTRAINT "FK_1027b1f5301948b2c8dc5121017" FOREIGN KEY ("organisation_payment_provider_id") REFERENCES "payment"."organisation_payment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
23
+ await queryRunner.query(`ALTER TABLE "payment"."organisation_payment_provider_method" ADD CONSTRAINT "FK_5c73d00c542e73bc44fc84f5e1e" FOREIGN KEY ("transaction_method_id") REFERENCES "payment"."transaction_method"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
24
+ }
25
+ }
@@ -0,0 +1,12 @@
1
+ const { MigrationInterface, QueryRunner } = require("typeorm");
2
+
3
+ module.exports = class bookingsIsTemporary1660741384852 {
4
+ name = 'bookingsIsTemporary1660741384852'
5
+
6
+ async up(queryRunner) {
7
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking" ADD "is_temporary" boolean NOT NULL DEFAULT false`);}
8
+
9
+ async down(queryRunner) {
10
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking" DROP COLUMN "is_temporary"`);
11
+ }
12
+ }
@@ -43,12 +43,27 @@ class User extends _dependencyAware.default {
43
43
  await this.initialise();
44
44
 
45
45
  if (typeof process.env.IS_OFFLINE !== 'undefined') {
46
- const sub = this.di.getEvent().requestContext.authorizer.claims.sub;
47
- return this.userRepository.findOne({
48
- cognito_sub: sub
49
- }, {
50
- relations: ['organisations']
51
- });
46
+ var _this$di$getEvent$req, _this$di$getEvent$req2, _this$di$getEvent$req3, _this$di$getEvent$req4, _this$di$getEvent$req5, _this$di$getEvent$req6;
47
+
48
+ const sub = (_this$di$getEvent$req = this.di.getEvent().requestContext) === null || _this$di$getEvent$req === void 0 ? void 0 : (_this$di$getEvent$req2 = _this$di$getEvent$req.authorizer) === null || _this$di$getEvent$req2 === void 0 ? void 0 : (_this$di$getEvent$req3 = _this$di$getEvent$req2.claims) === null || _this$di$getEvent$req3 === void 0 ? void 0 : _this$di$getEvent$req3.sub;
49
+
50
+ if (typeof sub !== 'undefined') {
51
+ return this.userRepository.findOne({
52
+ cognito_sub: sub
53
+ }, {
54
+ relations: ['organisations']
55
+ });
56
+ }
57
+
58
+ const userID = (_this$di$getEvent$req4 = this.di.getEvent().requestContext) === null || _this$di$getEvent$req4 === void 0 ? void 0 : (_this$di$getEvent$req5 = _this$di$getEvent$req4.authorizer) === null || _this$di$getEvent$req5 === void 0 ? void 0 : (_this$di$getEvent$req6 = _this$di$getEvent$req5.claims) === null || _this$di$getEvent$req6 === void 0 ? void 0 : _this$di$getEvent$req6.user_id;
59
+
60
+ if (typeof userID !== 'undefined') {
61
+ return this.userRepository.findOne({
62
+ id: userID
63
+ }, {
64
+ relations: ['organisations']
65
+ });
66
+ }
52
67
  }
53
68
 
54
69
  return JSON.parse(this.di.getEvent().requestContext.authorizer.user);
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@felloh-org/lambda-wrapper",
3
- "version": "1.1.74",
3
+ "version": "1.2.0",
4
4
  "description": "Lambda wrapper for all Felloh Serverless Projects",
5
5
  "main": "dist/index.js",
6
+ "engines": {
7
+ "node": ">=14"
8
+ },
6
9
  "scripts": {
7
10
  "build": "./node_modules/.bin/babel src --out-dir dist --copy-files --ignore src/migration",
8
11
  "build:orm": "./node_modules/.bin/babel src --out-dir dist --copy-files --ignore src/migration",