@felloh-org/lambda-wrapper 1.1.26 → 1.1.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.
@@ -15,7 +15,9 @@ var _transaction = _interopRequireDefault(require("../../payment/transaction"));
15
15
 
16
16
  var _uuid = require("uuid");
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, _descriptor11, _descriptor12;
18
+ var _bookingComponent = _interopRequireDefault(require("../booking-component"));
19
+
20
+ 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, _descriptor13;
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
@@ -40,24 +42,24 @@ let Booking = (_dec = (0, _typeorm.Entity)({
40
42
  }), _dec6 = (0, _typeorm.JoinColumn)({
41
43
  name: 'user_id',
42
44
  referencedColumnName: 'id'
43
- }), _dec7 = (0, _typeorm.OneToMany)(() => _transaction.default, transaction => transaction.booking), _dec8 = (0, _typeorm.ManyToOne)(() => _organisation.default), _dec9 = (0, _typeorm.JoinColumn)({
45
+ }), _dec7 = (0, _typeorm.OneToMany)(() => _transaction.default, transaction => transaction.booking), _dec8 = (0, _typeorm.OneToMany)(() => _bookingComponent.default, bookingComponent => bookingComponent.booking), _dec9 = (0, _typeorm.ManyToOne)(() => _organisation.default), _dec10 = (0, _typeorm.JoinColumn)({
44
46
  name: 'organisation_id',
45
47
  referencedColumnName: 'id'
46
- }), _dec10 = (0, _typeorm.Column)({
47
- type: "varchar",
48
- length: "150"
49
48
  }), _dec11 = (0, _typeorm.Column)({
50
49
  type: "varchar",
51
50
  length: "150"
52
51
  }), _dec12 = (0, _typeorm.Column)({
52
+ type: "varchar",
53
+ length: "150"
54
+ }), _dec13 = (0, _typeorm.Column)({
53
55
  type: "date",
54
56
  nullable: true
55
- }), _dec13 = (0, _typeorm.Column)({
57
+ }), _dec14 = (0, _typeorm.Column)({
56
58
  type: "date",
57
59
  nullable: true
58
- }), _dec14 = (0, _typeorm.CreateDateColumn)({
60
+ }), _dec15 = (0, _typeorm.CreateDateColumn)({
59
61
  type: 'timestamp with time zone'
60
- }), _dec15 = (0, _typeorm.UpdateDateColumn)({
62
+ }), _dec16 = (0, _typeorm.UpdateDateColumn)({
61
63
  type: 'timestamp with time zone'
62
64
  }), _dec(_class = (_class2 = class Booking {
63
65
  constructor() {
@@ -71,19 +73,21 @@ let Booking = (_dec = (0, _typeorm.Entity)({
71
73
 
72
74
  _initializerDefineProperty(this, "transactions", _descriptor5, this);
73
75
 
74
- _initializerDefineProperty(this, "organisation", _descriptor6, this);
76
+ _initializerDefineProperty(this, "components", _descriptor6, this);
75
77
 
76
- _initializerDefineProperty(this, "customer_name", _descriptor7, this);
78
+ _initializerDefineProperty(this, "organisation", _descriptor7, this);
77
79
 
78
- _initializerDefineProperty(this, "booking_reference", _descriptor8, this);
80
+ _initializerDefineProperty(this, "customer_name", _descriptor8, this);
79
81
 
80
- _initializerDefineProperty(this, "departure_date", _descriptor9, this);
82
+ _initializerDefineProperty(this, "booking_reference", _descriptor9, this);
81
83
 
82
- _initializerDefineProperty(this, "return_date", _descriptor10, this);
84
+ _initializerDefineProperty(this, "departure_date", _descriptor10, this);
83
85
 
84
- _initializerDefineProperty(this, "created_at", _descriptor11, this);
86
+ _initializerDefineProperty(this, "return_date", _descriptor11, this);
85
87
 
86
- _initializerDefineProperty(this, "updated_at", _descriptor12, this);
88
+ _initializerDefineProperty(this, "created_at", _descriptor12, this);
89
+
90
+ _initializerDefineProperty(this, "updated_at", _descriptor13, this);
87
91
  }
88
92
 
89
93
  /**
@@ -106,6 +110,10 @@ let Booking = (_dec = (0, _typeorm.Entity)({
106
110
  response.transactions = this.transactions.map(transaction => transaction.getPublicCompactData());
107
111
  }
108
112
 
113
+ if (typeof this.components !== 'undefined') {
114
+ response.components = this.components.map(component => component.getPublicCompactData());
115
+ }
116
+
109
117
  if (this.user !== null && typeof this.user.id !== 'undefined') {
110
118
  response.user = this.user.getPublicCompactData();
111
119
  }
@@ -148,43 +156,48 @@ let Booking = (_dec = (0, _typeorm.Entity)({
148
156
  enumerable: true,
149
157
  writable: true,
150
158
  initializer: null
151
- }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "organisation", [_dec8, _dec9], {
159
+ }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "components", [_dec8], {
160
+ configurable: true,
161
+ enumerable: true,
162
+ writable: true,
163
+ initializer: null
164
+ }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "organisation", [_dec9, _dec10], {
152
165
  configurable: true,
153
166
  enumerable: true,
154
167
  writable: true,
155
168
  initializer: function () {
156
169
  return _organisation.default;
157
170
  }
158
- }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "customer_name", [_dec10], {
171
+ }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "customer_name", [_dec11], {
159
172
  configurable: true,
160
173
  enumerable: true,
161
174
  writable: true,
162
175
  initializer: function () {
163
176
  return "";
164
177
  }
165
- }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "booking_reference", [_dec11], {
178
+ }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "booking_reference", [_dec12], {
166
179
  configurable: true,
167
180
  enumerable: true,
168
181
  writable: true,
169
182
  initializer: function () {
170
183
  return "";
171
184
  }
172
- }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "departure_date", [_dec12], {
185
+ }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "departure_date", [_dec13], {
173
186
  configurable: true,
174
187
  enumerable: true,
175
188
  writable: true,
176
189
  initializer: null
177
- }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "return_date", [_dec13], {
190
+ }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "return_date", [_dec14], {
178
191
  configurable: true,
179
192
  enumerable: true,
180
193
  writable: true,
181
194
  initializer: null
182
- }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec14], {
195
+ }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec15], {
183
196
  configurable: true,
184
197
  enumerable: true,
185
198
  writable: true,
186
199
  initializer: null
187
- }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "updated_at", [_dec15], {
200
+ }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "updated_at", [_dec16], {
188
201
  configurable: true,
189
202
  enumerable: true,
190
203
  writable: true,
@@ -9,7 +9,15 @@ var _typeorm = require("typeorm");
9
9
 
10
10
  var _uuid = require("uuid");
11
11
 
12
- var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
12
+ var _supplier = _interopRequireDefault(require("../supplier"));
13
+
14
+ var _booking = _interopRequireDefault(require("../booking"));
15
+
16
+ var _organisation = _interopRequireDefault(require("../../user/organisation"));
17
+
18
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9;
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
21
 
14
22
  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 }); }
15
23
 
@@ -20,11 +28,67 @@ function _initializerWarningHelper(descriptor, context) { throw new Error('Decor
20
28
  let BookingComponent = (_dec = (0, _typeorm.Entity)({
21
29
  name: 'booking_component',
22
30
  schema: 'agent_data'
23
- }), _dec2 = (0, _typeorm.PrimaryColumn)("varchar"), _dec3 = (0, _typeorm.CreateDateColumn)(), _dec(_class = (_class2 = class BookingComponent {
31
+ }), _dec2 = (0, _typeorm.PrimaryColumn)("varchar"), _dec3 = (0, _typeorm.ManyToOne)(() => _booking.default), _dec4 = (0, _typeorm.JoinColumn)({
32
+ name: 'booking_id',
33
+ referencedColumnName: 'id'
34
+ }), _dec5 = (0, _typeorm.ManyToOne)(() => _supplier.default, {
35
+ nullable: true
36
+ }), _dec6 = (0, _typeorm.JoinColumn)({
37
+ name: 'supplier_id',
38
+ referencedColumnName: 'id'
39
+ }), _dec7 = (0, _typeorm.ManyToOne)(() => _organisation.default), _dec8 = (0, _typeorm.JoinColumn)({
40
+ name: 'organisation_id',
41
+ referencedColumnName: 'id'
42
+ }), _dec9 = (0, _typeorm.Column)({
43
+ type: "int",
44
+ nullable: true
45
+ }), _dec10 = (0, _typeorm.Column)({
46
+ type: "varchar",
47
+ length: "150",
48
+ nullable: true
49
+ }), _dec11 = (0, _typeorm.Column)({
50
+ type: "varchar",
51
+ length: "10",
52
+ nullable: true
53
+ }), _dec12 = (0, _typeorm.Column)({
54
+ type: "varchar",
55
+ length: "40"
56
+ }), _dec13 = (0, _typeorm.CreateDateColumn)(), _dec(_class = (_class2 = class BookingComponent {
24
57
  constructor() {
25
58
  _initializerDefineProperty(this, "id", _descriptor, this);
26
59
 
27
- _initializerDefineProperty(this, "created_at", _descriptor2, this);
60
+ _initializerDefineProperty(this, "booking", _descriptor2, this);
61
+
62
+ _initializerDefineProperty(this, "supplier", _descriptor3, this);
63
+
64
+ _initializerDefineProperty(this, "organisation", _descriptor4, this);
65
+
66
+ _initializerDefineProperty(this, "amount", _descriptor5, this);
67
+
68
+ _initializerDefineProperty(this, "booking_reference", _descriptor6, this);
69
+
70
+ _initializerDefineProperty(this, "destination_air", _descriptor7, this);
71
+
72
+ _initializerDefineProperty(this, "type", _descriptor8, this);
73
+
74
+ _initializerDefineProperty(this, "created_at", _descriptor9, this);
75
+ }
76
+
77
+ getPublicCompactData() {
78
+ const response = {
79
+ id: this.id,
80
+ supplier: this.supplier,
81
+ amount: this.amount,
82
+ booking_reference: this.booking_reference,
83
+ destination_air: this.destination_air,
84
+ type: this.type
85
+ };
86
+
87
+ if (this.organisation !== null && typeof this.organisation.id !== 'undefined') {
88
+ response.organisation = this.organisation.getPublicCompactData();
89
+ }
90
+
91
+ return response;
28
92
  }
29
93
 
30
94
  }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
@@ -34,7 +98,54 @@ let BookingComponent = (_dec = (0, _typeorm.Entity)({
34
98
  initializer: function () {
35
99
  return (0, _uuid.v4)();
36
100
  }
37
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec3], {
101
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "booking", [_dec3, _dec4], {
102
+ configurable: true,
103
+ enumerable: true,
104
+ writable: true,
105
+ initializer: function () {
106
+ return _booking.default;
107
+ }
108
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "supplier", [_dec5, _dec6], {
109
+ configurable: true,
110
+ enumerable: true,
111
+ writable: true,
112
+ initializer: function () {
113
+ return _supplier.default;
114
+ }
115
+ }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "organisation", [_dec7, _dec8], {
116
+ configurable: true,
117
+ enumerable: true,
118
+ writable: true,
119
+ initializer: function () {
120
+ return _organisation.default;
121
+ }
122
+ }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "amount", [_dec9], {
123
+ configurable: true,
124
+ enumerable: true,
125
+ writable: true,
126
+ initializer: null
127
+ }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "booking_reference", [_dec10], {
128
+ configurable: true,
129
+ enumerable: true,
130
+ writable: true,
131
+ initializer: function () {
132
+ return null;
133
+ }
134
+ }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "destination_air", [_dec11], {
135
+ configurable: true,
136
+ enumerable: true,
137
+ writable: true,
138
+ initializer: function () {
139
+ return null;
140
+ }
141
+ }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "type", [_dec12], {
142
+ configurable: true,
143
+ enumerable: true,
144
+ writable: true,
145
+ initializer: function () {
146
+ return null;
147
+ }
148
+ }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec13], {
38
149
  configurable: true,
39
150
  enumerable: true,
40
151
  writable: true,
@@ -11,7 +11,9 @@ var _organisation = _interopRequireDefault(require("../../user/organisation"));
11
11
 
12
12
  var _uuid = require("uuid");
13
13
 
14
- var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
14
+ var _bookingComponent = _interopRequireDefault(require("../booking-component"));
15
+
16
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
15
17
 
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
19
 
@@ -30,7 +32,7 @@ let Supplier = (_dec = (0, _typeorm.Entity)({
30
32
  }), _dec5 = (0, _typeorm.Column)({
31
33
  type: "varchar",
32
34
  length: "150"
33
- }), _dec6 = (0, _typeorm.CreateDateColumn)(), _dec(_class = (_class2 = class Supplier {
35
+ }), _dec6 = (0, _typeorm.OneToMany)(() => _bookingComponent.default, bookingComponent => bookingComponent.supplier), _dec7 = (0, _typeorm.CreateDateColumn)(), _dec(_class = (_class2 = class Supplier {
34
36
  constructor() {
35
37
  _initializerDefineProperty(this, "id", _descriptor, this);
36
38
 
@@ -38,7 +40,9 @@ let Supplier = (_dec = (0, _typeorm.Entity)({
38
40
 
39
41
  _initializerDefineProperty(this, "name", _descriptor3, this);
40
42
 
41
- _initializerDefineProperty(this, "created_at", _descriptor4, this);
43
+ _initializerDefineProperty(this, "components", _descriptor4, this);
44
+
45
+ _initializerDefineProperty(this, "created_at", _descriptor5, this);
42
46
  }
43
47
 
44
48
  getPublicData() {
@@ -70,7 +74,12 @@ let Supplier = (_dec = (0, _typeorm.Entity)({
70
74
  initializer: function () {
71
75
  return "";
72
76
  }
73
- }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec6], {
77
+ }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "components", [_dec6], {
78
+ configurable: true,
79
+ enumerable: true,
80
+ writable: true,
81
+ initializer: null
82
+ }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec7], {
74
83
  configurable: true,
75
84
  enumerable: true,
76
85
  writable: true,
@@ -0,0 +1,27 @@
1
+ const { MigrationInterface, QueryRunner } = require("typeorm");
2
+
3
+ module.exports = class bookingComponents1656421768668 {
4
+ name = 'bookingComponents1656421768668'
5
+
6
+ async up(queryRunner) {
7
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD "amount" integer`);
8
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD "booking_reference" character varying(150)`);
9
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD "destination_air" character varying(10)`);
10
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD "type" character varying(40) NOT NULL`);
11
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD "booking_id" character varying`);
12
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD "supplier_id" character varying`);
13
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD CONSTRAINT "FK_d243dfda8e27a088dc2661981d7" FOREIGN KEY ("booking_id") REFERENCES "agent_data"."booking"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
14
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD CONSTRAINT "FK_f9577f42fa4c57747cefb8927b1" FOREIGN KEY ("supplier_id") REFERENCES "agent_data"."supplier"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
15
+ }
16
+
17
+ async down(queryRunner) {
18
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP CONSTRAINT "FK_f9577f42fa4c57747cefb8927b1"`);
19
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP CONSTRAINT "FK_d243dfda8e27a088dc2661981d7"`);
20
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP COLUMN "supplier_id"`);
21
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP COLUMN "booking_id"`);
22
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP COLUMN "type"`);
23
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP COLUMN "destination_air"`);
24
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP COLUMN "booking_reference"`);
25
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP COLUMN "amount"`);
26
+ }
27
+ }
@@ -0,0 +1,15 @@
1
+ const { MigrationInterface, QueryRunner } = require("typeorm");
2
+
3
+ module.exports = class bookingComponentsOrganisation1656422133900 {
4
+ name = 'bookingComponentsOrganisation1656422133900'
5
+
6
+ async up(queryRunner) {
7
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD "organisation_id" character varying(150)`);
8
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" ADD CONSTRAINT "FK_73a6d52c40bb11da01800c5f7ed" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
9
+ }
10
+
11
+ async down(queryRunner) {
12
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP CONSTRAINT "FK_73a6d52c40bb11da01800c5f7ed"`);
13
+ await queryRunner.query(`ALTER TABLE "agent_data"."booking_component" DROP COLUMN "organisation_id"`);
14
+ }
15
+ }
@@ -7,6 +7,8 @@ exports.default = exports.REQUEST_TYPES = exports.HTTP_METHODS_WITH_PAYLOADS = e
7
7
 
8
8
  var _querystring = _interopRequireDefault(require("querystring"));
9
9
 
10
+ var _moment = _interopRequireDefault(require("moment"));
11
+
10
12
  var _useragent = _interopRequireDefault(require("useragent"));
11
13
 
12
14
  var _validate = _interopRequireDefault(require("validate.js/validate"));
@@ -24,6 +26,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
24
26
  /* eslint-disable class-methods-use-this */
25
27
 
26
28
  /* eslint-disable sonarjs/no-duplicate-string */
29
+ _validate.default.extend(_validate.default.validators.datetime, {
30
+ parse: value => +_moment.default.utc(value),
31
+ format: (value, options) => _moment.default.utc(value).format(options.dateOnly ? 'YYYY-MM-DD' : 'YYYY-MM-DD hh:mm:ss')
32
+ });
33
+
27
34
  const REQUEST_TYPES = {
28
35
  DELETE: 'DELETE',
29
36
  GET: 'GET',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felloh-org/lambda-wrapper",
3
- "version": "1.1.26",
3
+ "version": "1.1.29",
4
4
  "description": "Lambda wrapper for all Felloh Serverless Projects",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -56,6 +56,7 @@
56
56
  "axios": "^0.26.1",
57
57
  "dotenv": "^16.0.0",
58
58
  "epsagon": "^1.121.3",
59
+ "moment": "^2.29.3",
59
60
  "typeorm": "^0.2.41",
60
61
  "typeorm-aurora-data-api-driver": "^2.4.2",
61
62
  "useragent": "^2.3.0",