whitelabel-db 1.1.65 → 1.1.67

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.
@@ -361,14 +361,14 @@ export declare class LiteApiClientV3 {
361
361
  private baseUrl;
362
362
  private bookingBaseUrl;
363
363
  private voucherBaseUrl;
364
- constructor(apiKey: string, useProduction?: boolean);
364
+ constructor(apiKey: string, env?: string | boolean);
365
365
  getHotels(options: HotelsRequestV3): Promise<AvailabilityResultV3[]>;
366
366
  getHotelById(hotelId: string): Promise<AvailabilityResultV3>;
367
367
  getHotelsFullRate(options: HotelsRequestV3): Promise<FullRateAvailabilityResultV3[]>;
368
368
  preBookedHotelRate(options: PrebookRateRequestV3): Promise<PrebookRateV3>;
369
369
  bookHotelRate(options: CheckoutRequestV3): Promise<BookingInfoV3>;
370
370
  cancelBooking(bookingId: string): Promise<CancelBookingV3>;
371
- getBooking(bookingId: string): Promise<BookingInfoV3>;
371
+ getBooking(bookingId: string, key?: string): Promise<BookingInfoV3>;
372
372
  getGuests(): Promise<GuestV3[]>;
373
373
  getGuest(guestId: number): Promise<GuestV3>;
374
374
  getGuestBookings(guestId: number): Promise<GuestBookingV3[]>;
@@ -14,18 +14,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.LiteApiClientV3 = void 0;
16
16
  const axios_1 = __importDefault(require("axios"));
17
+ const environments = {
18
+ dev: {
19
+ baseUrl: 'https://api.dev.liteapi.travel',
20
+ bookingBaseUrl: 'https://book.dev.liteapi.travel',
21
+ voucherBaseUrl: 'https://da.dev.liteapi.travel',
22
+ },
23
+ staging: {
24
+ baseUrl: 'https://api.staging.liteapi.travel',
25
+ bookingBaseUrl: 'https://book.staging.liteapi.travel',
26
+ voucherBaseUrl: 'https://da.staging.liteapi.travel',
27
+ },
28
+ production: {
29
+ baseUrl: 'https://api.liteapi.travel',
30
+ bookingBaseUrl: 'https://book.liteapi.travel',
31
+ voucherBaseUrl: 'https://da.liteapi.travel',
32
+ },
33
+ };
17
34
  class LiteApiClientV3 {
18
- constructor(apiKey, useProduction = true) {
35
+ constructor(apiKey, env = true) {
36
+ if (typeof env === 'boolean') {
37
+ env = env ? 'production' : 'dev';
38
+ }
39
+ const currentEnv = env;
40
+ const { baseUrl, bookingBaseUrl, voucherBaseUrl } = environments[currentEnv] || environments.production;
19
41
  this.apiKey = apiKey;
20
- this.baseUrl = useProduction
21
- ? 'https://api.liteapi.travel'
22
- : 'https://api.dev.liteapi.travel';
23
- this.bookingBaseUrl = useProduction
24
- ? 'https://book.liteapi.travel'
25
- : 'https://book.dev.liteapi.travel';
26
- this.voucherBaseUrl = useProduction
27
- ? 'https://da.liteapi.travel'
28
- : 'https://da.dev.liteapi.travel';
42
+ this.baseUrl = baseUrl;
43
+ this.bookingBaseUrl = bookingBaseUrl;
44
+ this.voucherBaseUrl = voucherBaseUrl;
29
45
  }
30
46
  getHotels(options) {
31
47
  return __awaiter(this, void 0, void 0, function* () {
@@ -99,13 +115,13 @@ class LiteApiClientV3 {
99
115
  })).data.data;
100
116
  });
101
117
  }
102
- getBooking(bookingId) {
118
+ getBooking(bookingId, key) {
103
119
  return __awaiter(this, void 0, void 0, function* () {
104
120
  return (yield (0, axios_1.default)({
105
121
  method: 'get',
106
122
  url: `${this.bookingBaseUrl}/v3.0/bookings/${bookingId}`,
107
123
  headers: {
108
- 'X-API-Key': this.apiKey,
124
+ 'X-API-Key': key || this.apiKey,
109
125
  'content-type': 'application/json',
110
126
  },
111
127
  })).data.data;
@@ -0,0 +1,8 @@
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
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Search = void 0;
13
+ const sequelize_typescript_1 = require("sequelize-typescript");
14
+ let Search = class Search extends sequelize_typescript_1.Model {
15
+ };
16
+ exports.Search = Search;
17
+ __decorate([
18
+ sequelize_typescript_1.PrimaryKey,
19
+ sequelize_typescript_1.Index,
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,
28
+ allowNull: false,
29
+ defaultValue: 0,
30
+ }),
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);
41
+ __decorate([
42
+ sequelize_typescript_1.Unique,
43
+ sequelize_typescript_1.Index,
44
+ (0, sequelize_typescript_1.Column)({
45
+ type: sequelize_typescript_1.DataType.DATE,
46
+ }),
47
+ __metadata("design:type", Date)
48
+ ], Search.prototype, "cacheQueuedAt", void 0);
49
+ __decorate([
50
+ (0, sequelize_typescript_1.Column)({
51
+ type: sequelize_typescript_1.DataType.JSONB,
52
+ allowNull: false,
53
+ defaultValue: {},
54
+ }),
55
+ __metadata("design:type", Object)
56
+ ], Search.prototype, "data", void 0);
57
+ exports.Search = Search = __decorate([
58
+ (0, sequelize_typescript_1.Table)({
59
+ tableName: 'searches',
60
+ })
61
+ ], Search);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whitelabel-db",
3
- "version": "1.1.65",
3
+ "version": "1.1.67",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +0,0 @@
1
- import { IncludeOptions } from 'sequelize';
2
- export declare function getTranslationFallback(language: string | undefined, attributes: string[]): {
3
- include: IncludeOptions[];
4
- };
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTranslationFallback = void 0;
4
- const sequelize_1 = require("sequelize");
5
- const HotelTranslation_1 = require("../models/HotelTranslation");
6
- function getTranslationFallback(language = 'en', attributes) {
7
- return {
8
- include: [
9
- {
10
- model: HotelTranslation_1.HotelTranslation,
11
- as: 'translations',
12
- attributes,
13
- where: {
14
- [sequelize_1.Op.or]: [{ language }],
15
- },
16
- required: false,
17
- },
18
- ],
19
- };
20
- }
21
- exports.getTranslationFallback = getTranslationFallback;