whitelabel-db 1.0.35 → 1.0.37

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/dist/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export { Project } from './models/Project';
8
8
  export { Booking } from './models/Booking';
9
9
  export { Role } from './models/Role';
10
10
  export { LiteApiClient, HotelsRequest, AvailabilityResult, FullRateAvailabilityResult, RoomType, Rate, PrebookRateRequest, PrebookRate, CheckoutRequest, BookingInfo, CancelBooking, } from './libs/liteapi';
11
+ export { LiteApiClientV3, HotelsRequestV3, AvailabilityResultV3, FullRateAvailabilityResultV3, RoomTypeV3, RateV3, PrebookRateRequestV3, PrebookRateV3, CheckoutRequestV3, BookingInfoV3, CancelBookingV3, BookedRoomV3, } from './libs/liteapiv3';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LiteApiClient = exports.Role = exports.Booking = exports.Project = exports.User = exports.Hotel = exports.Country = exports.City = exports.Agency = exports.connect = void 0;
3
+ exports.LiteApiClientV3 = exports.LiteApiClient = exports.Role = exports.Booking = exports.Project = exports.User = exports.Hotel = exports.Country = exports.City = exports.Agency = exports.connect = void 0;
4
4
  var database_1 = require("./libs/database");
5
5
  Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return database_1.connect; } });
6
6
  var Agency_1 = require("./models/Agency");
@@ -21,3 +21,5 @@ var Role_1 = require("./models/Role");
21
21
  Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return Role_1.Role; } });
22
22
  var liteapi_1 = require("./libs/liteapi");
23
23
  Object.defineProperty(exports, "LiteApiClient", { enumerable: true, get: function () { return liteapi_1.LiteApiClient; } });
24
+ var liteapiv3_1 = require("./libs/liteapiv3");
25
+ Object.defineProperty(exports, "LiteApiClientV3", { enumerable: true, get: function () { return liteapiv3_1.LiteApiClientV3; } });
@@ -0,0 +1,192 @@
1
+ export interface OccupancyV3 {
2
+ adults: number;
3
+ rooms: number;
4
+ children?: number[];
5
+ }
6
+ export interface HotelsRequestV3 {
7
+ timeout: number;
8
+ hotelIds: string[];
9
+ occupancies: OccupancyV3[];
10
+ checkin: string;
11
+ checkout: string;
12
+ currency: string;
13
+ guestNationality: string;
14
+ }
15
+ export interface AvailabilityResultV3 {
16
+ hotelId: string;
17
+ currency: string;
18
+ price: number;
19
+ supplier: string;
20
+ supplierId: number;
21
+ }
22
+ export interface AmountV3 {
23
+ amount: number;
24
+ currency: string;
25
+ }
26
+ export interface RetailRateV3 {
27
+ total: AmountV3[];
28
+ taxesAndFees: number;
29
+ msp?: AmountV3[];
30
+ }
31
+ export interface CancellationPoliciesV3 {
32
+ cancelPolicyInfos: {
33
+ cancelTime: string;
34
+ amount: number;
35
+ currency: string;
36
+ type: string;
37
+ }[];
38
+ hotelRemarks: string[];
39
+ refundableTag: string;
40
+ }
41
+ export interface RateV3 {
42
+ rateId: string;
43
+ name: string;
44
+ maxOccupancy: number;
45
+ adultCount: number;
46
+ childCount: number;
47
+ boardType: string;
48
+ boardName: string;
49
+ remarks: string;
50
+ retailRate: RetailRateV3;
51
+ cancellationPolicies: CancellationPoliciesV3;
52
+ priceType?: string;
53
+ commission?: AmountV3[];
54
+ formattedCancellationPolicies?: {
55
+ policies: {
56
+ message: string;
57
+ highlight: boolean;
58
+ cancelTimeFrame: {
59
+ start: string;
60
+ end: string;
61
+ amount: number;
62
+ type?: string;
63
+ };
64
+ }[];
65
+ hasFreeCancellation: boolean;
66
+ };
67
+ }
68
+ export interface RoomTypeV3 {
69
+ roomTypeId: string;
70
+ rates: RateV3[];
71
+ supplier: string;
72
+ supplierId: number;
73
+ mappedRoomId?: string;
74
+ }
75
+ export interface FullRateAvailabilityResultV3 {
76
+ hotelId: string;
77
+ termsAndConditions: string;
78
+ roomTypes: RoomTypeV3[];
79
+ }
80
+ export interface PrebookRateRequestV3 {
81
+ rateIds: string[];
82
+ hotelId: string;
83
+ occupancies: OccupancyV3[];
84
+ currency: string;
85
+ guestNationality: string;
86
+ checkin: string;
87
+ checkout: string;
88
+ payWithStripe?: boolean;
89
+ }
90
+ export interface PrebookRateV3 {
91
+ prebookId: string;
92
+ hotelId: string;
93
+ currency: string;
94
+ termsAndConditions: string;
95
+ roomTypes: RoomTypeV3[];
96
+ msp: number;
97
+ commission: AmountV3[];
98
+ price: number;
99
+ priceType: string;
100
+ priceDifferencePercent: number;
101
+ cancellationChanged: boolean;
102
+ boardChanged: boolean;
103
+ supplier: string;
104
+ supplierId: number;
105
+ transactionId: string;
106
+ clientSecret: string;
107
+ }
108
+ export interface GuestInfoV3 {
109
+ guestFirstName: string;
110
+ guestLastName: string;
111
+ guestEmail: string;
112
+ }
113
+ export interface PaymentInfoV3 {
114
+ method: string;
115
+ transactionId?: string;
116
+ }
117
+ export interface UserV3 {
118
+ firstName: string;
119
+ lastName: string;
120
+ email: string;
121
+ }
122
+ export interface RateRequestV3 {
123
+ rateId: string;
124
+ remarks: string;
125
+ guest: UserV3[];
126
+ }
127
+ export interface CheckoutRequestV3 {
128
+ payment: PaymentInfoV3;
129
+ prebookId: string;
130
+ holder: UserV3;
131
+ rates: RateRequestV3[];
132
+ }
133
+ export interface BookedRoomV3 {
134
+ roomType: {
135
+ name: string;
136
+ };
137
+ adults: number;
138
+ children: number;
139
+ rate: {
140
+ maxOccupancy: number;
141
+ retailRate: RetailRateV3;
142
+ };
143
+ }
144
+ export interface BookingInfoV3 {
145
+ bookingId: string;
146
+ clientReference: string;
147
+ supplierBookingId: string;
148
+ supplierBookingName: string;
149
+ supplier: string;
150
+ supplierId: number;
151
+ status: string;
152
+ hotelConfirmationCode: string;
153
+ checkin: string;
154
+ checkout: string;
155
+ hotel: {
156
+ hotelId: string;
157
+ name: string;
158
+ };
159
+ bookedRooms: BookedRoomV3[];
160
+ guestInfo: GuestInfoV3;
161
+ createdAt: string;
162
+ cancellationPolicies: CancellationPoliciesV3;
163
+ price: number;
164
+ msp: number;
165
+ commission: number;
166
+ currency: string;
167
+ cancelledAmountWhenRequested: {
168
+ amount: number;
169
+ type: string;
170
+ };
171
+ }
172
+ export interface BookingConfirmationV3 {
173
+ prebookId: string;
174
+ transactionId: string;
175
+ }
176
+ export interface CancelBookingV3 {
177
+ bookingId: string;
178
+ status: string;
179
+ cancellation_fee: number;
180
+ refund_amount: number;
181
+ currency: string;
182
+ }
183
+ export declare class LiteApiClientV3 {
184
+ private apiKey;
185
+ constructor(apiKey: string);
186
+ getHotels(options: HotelsRequestV3): Promise<AvailabilityResultV3[]>;
187
+ getHotelById(hotelId: string): Promise<AvailabilityResultV3>;
188
+ getHotelsFullRate(options: HotelsRequestV3): Promise<FullRateAvailabilityResultV3[]>;
189
+ preBookedHotelRate(options: PrebookRateRequestV3): Promise<PrebookRateV3>;
190
+ bookHotelRate(options: CheckoutRequestV3): Promise<BookingInfoV3>;
191
+ cancelBooking(bookingId: string): Promise<CancelBookingV3>;
192
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.LiteApiClientV3 = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const baseUrl = 'https://api.liteapi.travel';
18
+ class LiteApiClientV3 {
19
+ constructor(apiKey) {
20
+ this.apiKey = apiKey;
21
+ }
22
+ getHotels(options) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return (yield (0, axios_1.default)({
25
+ url: `${baseUrl}/v3.0/hotels`,
26
+ params: options,
27
+ headers: {
28
+ 'X-API-Key': this.apiKey,
29
+ },
30
+ })).data.data;
31
+ });
32
+ }
33
+ getHotelById(hotelId) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ return (yield (0, axios_1.default)({
36
+ url: `${baseUrl}/v3.0/hotels/${hotelId}`,
37
+ headers: {
38
+ 'X-API-Key': this.apiKey,
39
+ },
40
+ })).data.data;
41
+ });
42
+ }
43
+ getHotelsFullRate(options) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ return (yield (0, axios_1.default)({
46
+ url: `${baseUrl}/v3.0/hotels/rates`,
47
+ params: options,
48
+ headers: {
49
+ 'X-API-Key': this.apiKey,
50
+ },
51
+ })).data.data;
52
+ });
53
+ }
54
+ preBookedHotelRate(options) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ return (yield (0, axios_1.default)({
57
+ method: 'post',
58
+ url: `${baseUrl}/v3.0/rates/prebook`,
59
+ data: options,
60
+ headers: {
61
+ 'X-API-Key': this.apiKey,
62
+ 'content-type': 'application/json',
63
+ },
64
+ })).data.data;
65
+ });
66
+ }
67
+ bookHotelRate(options) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ return (yield (0, axios_1.default)({
70
+ method: 'post',
71
+ url: `${baseUrl}/v3.0/rates/book`,
72
+ data: options,
73
+ headers: {
74
+ 'X-API-Key': this.apiKey,
75
+ 'content-type': 'application/json',
76
+ },
77
+ })).data.data;
78
+ });
79
+ }
80
+ cancelBooking(bookingId) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ return (yield (0, axios_1.default)({
83
+ method: 'put',
84
+ url: `${baseUrl}/v3.0/bookings/${bookingId}`,
85
+ headers: {
86
+ 'X-API-Key': this.apiKey,
87
+ 'content-type': 'application/json',
88
+ },
89
+ })).data.data;
90
+ });
91
+ }
92
+ }
93
+ exports.LiteApiClientV3 = LiteApiClientV3;
@@ -1,6 +1,7 @@
1
1
  import { Model } from 'sequelize-typescript';
2
2
  import { Agency } from './Agency';
3
3
  import { LiteApiClient } from '../libs/liteapi';
4
+ import { LiteApiClientV3 } from '../libs/liteapiv3';
4
5
  import { Booking } from './Booking';
5
6
  export declare class Project extends Model<Partial<Project>> {
6
7
  id: string;
@@ -11,6 +12,8 @@ export declare class Project extends Model<Partial<Project>> {
11
12
  agencyId?: string;
12
13
  agency?: Agency;
13
14
  bookings?: Booking[];
15
+ preferences?: object;
14
16
  generateSession(secret: string): string;
15
17
  getLiteApiClient(): LiteApiClient;
18
+ getLiteApiClientV3(): LiteApiClientV3;
16
19
  }
@@ -17,8 +17,10 @@ const sequelize_typescript_1 = require("sequelize-typescript");
17
17
  const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
18
18
  const Agency_1 = require("./Agency");
19
19
  const liteapi_1 = require("../libs/liteapi");
20
+ const liteapiv3_1 = require("../libs/liteapiv3");
20
21
  const Booking_1 = require("./Booking");
21
22
  const clients = {};
23
+ const clientV3 = {};
22
24
  let Project = class Project extends sequelize_typescript_1.Model {
23
25
  generateSession(secret) {
24
26
  return jsonwebtoken_1.default.sign({ id: this.id }, secret, {
@@ -42,6 +44,22 @@ let Project = class Project extends sequelize_typescript_1.Model {
42
44
  throw err;
43
45
  }
44
46
  }
47
+ getLiteApiClientV3() {
48
+ try {
49
+ let key = this.settings.liteApiKey;
50
+ if (!key || !key.length) {
51
+ key = process.env.LITEAPI_KEY;
52
+ }
53
+ if (!clientV3[key]) {
54
+ clientV3[key] = new liteapiv3_1.LiteApiClientV3(key);
55
+ }
56
+ return clientV3[key];
57
+ }
58
+ catch (err) {
59
+ console.log(err);
60
+ throw err;
61
+ }
62
+ }
45
63
  };
46
64
  exports.Project = Project;
47
65
  __decorate([
@@ -101,6 +119,14 @@ __decorate([
101
119
  (0, sequelize_typescript_1.HasMany)(() => Booking_1.Booking),
102
120
  __metadata("design:type", Array)
103
121
  ], Project.prototype, "bookings", void 0);
122
+ __decorate([
123
+ (0, sequelize_typescript_1.Column)({
124
+ type: sequelize_typescript_1.DataType.JSONB,
125
+ allowNull: false,
126
+ defaultValue: {},
127
+ }),
128
+ __metadata("design:type", Object)
129
+ ], Project.prototype, "preferences", void 0);
104
130
  exports.Project = Project = __decorate([
105
131
  (0, sequelize_typescript_1.Table)({
106
132
  tableName: 'projects',
@@ -0,0 +1,6 @@
1
+ import { Model } from 'sequelize-typescript';
2
+ export declare class UserRole extends Model<Partial<UserRole>> {
3
+ id: string;
4
+ name: string;
5
+ description?: string;
6
+ }
@@ -9,53 +9,38 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Search = void 0;
12
+ exports.UserRole = void 0;
13
+ const sequelize_1 = require("sequelize");
13
14
  const sequelize_typescript_1 = require("sequelize-typescript");
14
- let Search = class Search extends sequelize_typescript_1.Model {
15
+ let UserRole = class UserRole extends sequelize_typescript_1.Model {
15
16
  };
16
- exports.Search = Search;
17
+ exports.UserRole = UserRole;
17
18
  __decorate([
18
19
  sequelize_typescript_1.PrimaryKey,
19
- sequelize_typescript_1.Index,
20
20
  (0, sequelize_typescript_1.Column)({
21
- type: sequelize_typescript_1.DataType.STRING(32),
22
- }),
23
- __metadata("design:type", String)
24
- ], Search.prototype, "id", void 0);
25
- __decorate([
26
- (0, sequelize_typescript_1.Column)({
27
- type: sequelize_typescript_1.DataType.INTEGER,
21
+ type: sequelize_1.NUMBER,
28
22
  allowNull: false,
29
- defaultValue: 0,
23
+ autoIncrement: true,
30
24
  }),
31
- __metadata("design:type", Number)
32
- ], Search.prototype, "hits", void 0);
33
- __decorate([
34
- sequelize_typescript_1.Unique,
35
- sequelize_typescript_1.Index,
36
- (0, sequelize_typescript_1.Column)({
37
- type: sequelize_typescript_1.DataType.DATE,
38
- }),
39
- __metadata("design:type", Date)
40
- ], Search.prototype, "cacheUpdatedAt", void 0);
25
+ __metadata("design:type", String)
26
+ ], UserRole.prototype, "id", void 0);
41
27
  __decorate([
42
28
  sequelize_typescript_1.Unique,
43
- sequelize_typescript_1.Index,
44
29
  (0, sequelize_typescript_1.Column)({
45
- type: sequelize_typescript_1.DataType.DATE,
30
+ type: sequelize_typescript_1.DataType.STRING,
31
+ allowNull: false,
46
32
  }),
47
- __metadata("design:type", Date)
48
- ], Search.prototype, "cacheQueuedAt", void 0);
33
+ __metadata("design:type", String)
34
+ ], UserRole.prototype, "name", void 0);
49
35
  __decorate([
50
36
  (0, sequelize_typescript_1.Column)({
51
- type: sequelize_typescript_1.DataType.JSONB,
52
- allowNull: false,
53
- defaultValue: {},
37
+ type: sequelize_typescript_1.DataType.STRING,
38
+ allowNull: true,
54
39
  }),
55
- __metadata("design:type", Object)
56
- ], Search.prototype, "data", void 0);
57
- exports.Search = Search = __decorate([
40
+ __metadata("design:type", String)
41
+ ], UserRole.prototype, "description", void 0);
42
+ exports.UserRole = UserRole = __decorate([
58
43
  (0, sequelize_typescript_1.Table)({
59
- tableName: 'searches',
44
+ tableName: 'user_roles',
60
45
  })
61
- ], Search);
46
+ ], UserRole);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whitelabel-db",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,8 +0,0 @@
1
- import { Model } from 'sequelize-typescript';
2
- export declare class Search extends Model<Partial<Search>> {
3
- id: string;
4
- hits: number;
5
- cacheUpdatedAt?: Date;
6
- cacheQueuedAt?: Date;
7
- data?: object;
8
- }