whitelabel-db 1.4.5 → 1.6.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/dist/index.d.ts CHANGED
@@ -31,5 +31,5 @@ export { LoyaltyProgram } from './models/LoyaltyProgram';
31
31
  export { LoyaltyProgramTier } from './models/LoyaltyProgramTier';
32
32
  export { BookingLoyaltyRecord } from './models/BookingLoyaltyRecord';
33
33
  export { LiteApiClient, HotelsRequest, AvailabilityResult, FullRateAvailabilityResult, RoomType, Rate, PrebookRateRequest, PrebookRate, CheckoutRequest, BookingInfo, CancelBooking, } from './libs/liteapi';
34
- export { LiteApiClientV3, HotelsRequestV3, AvailabilityResultV3, FullRateAvailabilityResultV3, RoomTypeV3, RateV3, PrebookRateRequestV3, PrebookRateV3, CheckoutRequestV3, BookingInfoV3, CancelBookingV3, CancelBookingRequestV3, BookedRoomV3, OccupancyV3, GuestV3, GuestBookingV3, PromoCodeRequest, PromoCodeResponse, EsimplyPackage, Addon, AddonResponse, GetHotelRequestV3, HotelDataV3, HotelImageV3, CheckinCheckoutTimesV3, LocationV3, FacilityV3, RoomV3, BedTypeV3, RoomAmenityV3, RoomPhotoV3, PolicyV3, AccessibilityV3, AccessibilityAttributesV3, AccessibilityDisabilitiesV3, AccessibilityDisabilityScoresV3, SentimentAnalysisV3, SentimentCategoryV3, SemanticSearchRequestV3, SemanticSearchHotelV3, ConversationalHotelRequestV3, ConversationalHotelResponseV3, InitiatePaymentIntentV3, FinalizePaymentRequestV3, FinalizePaymentResponseV3, } from './libs/liteapiv3';
34
+ export { LiteApiClientV3, HotelsRequestV3, AvailabilityResultV3, FullRateAvailabilityResultV3, RoomTypeV3, RateV3, PrebookRateRequestV3, PrebookRateV3, CheckoutRequestV3, BookingInfoV3, CancelBookingV3, BookedRoomV3, OccupancyV3, GuestV3, GuestBookingV3, PromoCodeRequest, PromoCodeResponse, EsimplyPackage, Addon, AddonResponse, GetHotelRequestV3, HotelDataV3, HotelImageV3, CheckinCheckoutTimesV3, LocationV3, FacilityV3, RoomV3, BedTypeV3, RoomAmenityV3, RoomPhotoV3, PolicyV3, AccessibilityV3, AccessibilityAttributesV3, AccessibilityDisabilitiesV3, AccessibilityDisabilityScoresV3, SentimentAnalysisV3, SentimentCategoryV3, SemanticSearchRequestV3, SemanticSearchHotelV3, ConversationalHotelRequestV3, ConversationalHotelResponseV3, InitiatePaymentIntentV3, FinalizePaymentRequestV3, FinalizePaymentResponseV3, } from './libs/liteapiv3';
35
35
  export { LiteApiUser, LiteApiUserRequest } from './libs/liteapiuser';
@@ -13,7 +13,6 @@ export interface HotelsRequestV3 {
13
13
  guestNationality: string;
14
14
  rm?: boolean;
15
15
  trackingId?: string;
16
- sessionId?: string;
17
16
  }
18
17
  export interface AvailabilityResultV3 {
19
18
  hotelId: string;
@@ -114,7 +113,6 @@ export interface PrebookRateRequestV3 {
114
113
  useOwnSecretKey?: boolean;
115
114
  };
116
115
  trackingId?: string;
117
- sessionId?: string;
118
116
  voucherCode?: string;
119
117
  addons: Addon[];
120
118
  clientReference?: string;
@@ -192,7 +190,6 @@ export interface CheckoutRequestV3 {
192
190
  holder: UserV3;
193
191
  guests: GuestsRequestV3[];
194
192
  trackingId?: string;
195
- sessionId?: string;
196
193
  }
197
194
  export interface BookedRoomV3 {
198
195
  roomType: {
@@ -295,10 +292,6 @@ export interface BookingConfirmationV3 {
295
292
  prebookId: string;
296
293
  transactionId: string;
297
294
  }
298
- export interface CancelBookingRequestV3 {
299
- trackingId?: string;
300
- sessionId?: string;
301
- }
302
295
  export interface CancelBookingV3 {
303
296
  bookingId: string;
304
297
  status: string;
@@ -313,7 +306,7 @@ export interface InitiatePaymentIntentV3 {
313
306
  currency: string;
314
307
  transactionId: string;
315
308
  }
316
- export type FinalizePaymentRequestV3 = ({
309
+ export type FinalizePaymentRequestV3 = {
317
310
  method: 'CREDIT';
318
311
  } | {
319
312
  method: 'THIRD_PARTY';
@@ -321,9 +314,6 @@ export type FinalizePaymentRequestV3 = ({
321
314
  } | {
322
315
  method: 'TRANSACTION_ID';
323
316
  transactionId: string;
324
- }) & {
325
- trackingId?: string;
326
- sessionId?: string;
327
317
  };
328
318
  export interface FinalizePaymentResponseV3 {
329
319
  bookingId: string;
@@ -652,11 +642,8 @@ export declare class LiteApiClientV3 {
652
642
  getHotelsFullRate(options: HotelsRequestV3): Promise<FullRateAvailabilityResultV3[]>;
653
643
  preBookedHotelRate(options: PrebookRateRequestV3): Promise<PrebookRateV3>;
654
644
  bookHotelRate(options: CheckoutRequestV3): Promise<BookingInfoV3>;
655
- cancelBooking(bookingId: string, options?: CancelBookingRequestV3): Promise<CancelBookingV3>;
656
- initiatePaymentIntent(bookingId: string, options?: {
657
- trackingId?: string;
658
- sessionId?: string;
659
- }): Promise<InitiatePaymentIntentV3>;
645
+ cancelBooking(bookingId: string): Promise<CancelBookingV3>;
646
+ initiatePaymentIntent(bookingId: string): Promise<InitiatePaymentIntentV3>;
660
647
  finalizePayment(bookingId: string, data: FinalizePaymentRequestV3): Promise<FinalizePaymentResponseV3>;
661
648
  getBooking(bookingId: string, key?: string): Promise<BookingInfoV3>;
662
649
  getPrebook(prebookId: string, key?: string): Promise<PrebookRateV3>;
@@ -106,12 +106,11 @@ class LiteApiClientV3 {
106
106
  })).data.data;
107
107
  });
108
108
  }
109
- cancelBooking(bookingId, options) {
109
+ cancelBooking(bookingId) {
110
110
  return __awaiter(this, void 0, void 0, function* () {
111
111
  return (yield (0, axios_1.default)({
112
112
  method: 'put',
113
113
  url: `${this.bookingBaseUrl}/v3.0/bookings/${bookingId}`,
114
- data: options,
115
114
  headers: {
116
115
  'X-API-Key': this.apiKey,
117
116
  'content-type': 'application/json',
@@ -119,12 +118,11 @@ class LiteApiClientV3 {
119
118
  })).data.data;
120
119
  });
121
120
  }
122
- initiatePaymentIntent(bookingId, options) {
121
+ initiatePaymentIntent(bookingId) {
123
122
  return __awaiter(this, void 0, void 0, function* () {
124
123
  return (yield (0, axios_1.default)({
125
124
  method: 'post',
126
125
  url: `${this.bookingBaseUrl}/v3.0/bookings/${bookingId}/payments/initiate`,
127
- data: options,
128
126
  headers: {
129
127
  'X-API-Key': this.apiKey,
130
128
  'content-type': 'application/json',
@@ -0,0 +1,3 @@
1
+ import { QueryInterface } from 'sequelize';
2
+ export declare const up: (queryInterface: QueryInterface) => Promise<void>;
3
+ export declare const down: (queryInterface: QueryInterface) => Promise<void>;
@@ -0,0 +1,107 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.down = exports.up = void 0;
13
+ // Purpose: Bring flight_bookings to parity with bookings — add liteAPI snapshot
14
+ // columns, structured payment metadata, status/cancellation tracking, a
15
+ // contactEmail lookup column, and a nullable guestId FK (column only; guest
16
+ // auth wiring is a separate task — see TODO(guest-flights)).
17
+ const sequelize_1 = require("sequelize");
18
+ const TABLE_NAME = 'flight_bookings';
19
+ const jsonbColumns = [
20
+ 'liteApiBookingData',
21
+ 'liteApiPrebookData',
22
+ 'bookingInputData',
23
+ 'paymentData',
24
+ ];
25
+ const stringColumns = [
26
+ // NOT NULL with '' default — mirrors bookings.bookingStatus / paymentStatus
27
+ { name: 'bookingStatus', allowNull: false, defaultValue: '' },
28
+ { name: 'paymentStatus', allowNull: false, defaultValue: '' },
29
+ // Nullable — mirrors bookings payment columns
30
+ { name: 'paymentProvider', allowNull: true },
31
+ { name: 'paymentMethod', allowNull: true },
32
+ { name: 'refundStatus', allowNull: true },
33
+ { name: 'contactEmail', allowNull: true },
34
+ ];
35
+ const up = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
36
+ const tableDescription = yield queryInterface.describeTable(TABLE_NAME);
37
+ const existingColumns = Object.keys(tableDescription);
38
+ // JSONB snapshot/payment columns — NOT NULL, default {}
39
+ for (const name of jsonbColumns) {
40
+ if (!existingColumns.includes(name)) {
41
+ yield queryInterface.addColumn(TABLE_NAME, name, {
42
+ type: sequelize_1.DataTypes.JSONB,
43
+ allowNull: false,
44
+ defaultValue: {},
45
+ });
46
+ }
47
+ }
48
+ // String status/payment columns
49
+ for (const column of stringColumns) {
50
+ if (!existingColumns.includes(column.name)) {
51
+ yield queryInterface.addColumn(TABLE_NAME, column.name, Object.assign({ type: sequelize_1.DataTypes.STRING, allowNull: column.allowNull }, (column.defaultValue !== undefined
52
+ ? { defaultValue: column.defaultValue }
53
+ : {})));
54
+ }
55
+ }
56
+ // cancelledAt timestamp
57
+ if (!existingColumns.includes('cancelledAt')) {
58
+ yield queryInterface.addColumn(TABLE_NAME, 'cancelledAt', {
59
+ type: sequelize_1.DataTypes.DATE,
60
+ allowNull: true,
61
+ });
62
+ }
63
+ // guestId FK → guests.id (nullable, column only; not wired this phase)
64
+ if (!existingColumns.includes('guestId')) {
65
+ yield queryInterface.addColumn(TABLE_NAME, 'guestId', {
66
+ type: sequelize_1.DataTypes.UUID,
67
+ allowNull: true,
68
+ references: {
69
+ model: 'guests',
70
+ key: 'id',
71
+ },
72
+ onUpdate: 'CASCADE',
73
+ onDelete: 'SET NULL',
74
+ });
75
+ }
76
+ // Indexes for lookup columns (fail gracefully if they already exist)
77
+ const addIndexSafe = (columns, name) => __awaiter(void 0, void 0, void 0, function* () {
78
+ try {
79
+ yield queryInterface.addIndex(TABLE_NAME, columns, { name });
80
+ }
81
+ catch (error) {
82
+ const message = error instanceof Error ? error.message : String(error);
83
+ if (!message.includes('already exists')) {
84
+ throw error;
85
+ }
86
+ }
87
+ });
88
+ yield addIndexSafe(['contactEmail'], 'idx_flight_bookings_contact_email');
89
+ yield addIndexSafe(['guestId'], 'idx_flight_bookings_guest_id');
90
+ });
91
+ exports.up = up;
92
+ const down = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
93
+ const tableDescription = yield queryInterface.describeTable(TABLE_NAME);
94
+ const existingColumns = Object.keys(tableDescription);
95
+ const allColumns = [
96
+ ...jsonbColumns,
97
+ ...stringColumns.map((c) => c.name),
98
+ 'cancelledAt',
99
+ 'guestId',
100
+ ];
101
+ for (const name of allColumns) {
102
+ if (existingColumns.includes(name)) {
103
+ yield queryInterface.removeColumn(TABLE_NAME, name);
104
+ }
105
+ }
106
+ });
107
+ exports.down = down;
@@ -0,0 +1,3 @@
1
+ import { QueryInterface } from 'sequelize';
2
+ export declare const up: (queryInterface: QueryInterface) => Promise<void>;
3
+ export declare const down: (queryInterface: QueryInterface) => Promise<void>;
@@ -0,0 +1,67 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.down = exports.up = void 0;
13
+ // Purpose: Mirror the hotel `bookings` lifecycle for flights — the row is now
14
+ // created at PREBOOK time (before a bookingId exists), keyed by prebookId, then
15
+ // the bookingId is filled in at booking-creation. Adds a unique, indexed
16
+ // `prebookId` column and relaxes `bookingId` to nullable.
17
+ const sequelize_1 = require("sequelize");
18
+ const TABLE_NAME = 'flight_bookings';
19
+ const PREBOOK_ID_COLUMN = 'prebookId';
20
+ const up = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
21
+ const tableDescription = yield queryInterface.describeTable(TABLE_NAME);
22
+ const existingColumns = Object.keys(tableDescription);
23
+ if (!existingColumns.includes(PREBOOK_ID_COLUMN)) {
24
+ yield queryInterface.addColumn(TABLE_NAME, PREBOOK_ID_COLUMN, {
25
+ type: sequelize_1.DataTypes.STRING,
26
+ allowNull: true,
27
+ });
28
+ }
29
+ // bookingId is unknown until the booking is created — relax NOT NULL.
30
+ yield queryInterface.changeColumn(TABLE_NAME, 'bookingId', {
31
+ type: sequelize_1.DataTypes.STRING,
32
+ allowNull: true,
33
+ });
34
+ // Unique + lookup index on prebookId (fail gracefully if it already exists).
35
+ try {
36
+ yield queryInterface.addIndex(TABLE_NAME, [PREBOOK_ID_COLUMN], {
37
+ name: 'idx_flight_bookings_prebook_id',
38
+ unique: true,
39
+ });
40
+ }
41
+ catch (error) {
42
+ const message = error instanceof Error ? error.message : String(error);
43
+ if (!message.includes('already exists')) {
44
+ throw error;
45
+ }
46
+ }
47
+ });
48
+ exports.up = up;
49
+ const down = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
50
+ const tableDescription = yield queryInterface.describeTable(TABLE_NAME);
51
+ const existingColumns = Object.keys(tableDescription);
52
+ try {
53
+ yield queryInterface.removeIndex(TABLE_NAME, 'idx_flight_bookings_prebook_id');
54
+ }
55
+ catch (_a) {
56
+ // index may not exist — ignore
57
+ }
58
+ if (existingColumns.includes(PREBOOK_ID_COLUMN)) {
59
+ yield queryInterface.removeColumn(TABLE_NAME, PREBOOK_ID_COLUMN);
60
+ }
61
+ // Restore NOT NULL on bookingId. Note: only safe if no null rows remain.
62
+ yield queryInterface.changeColumn(TABLE_NAME, 'bookingId', {
63
+ type: sequelize_1.DataTypes.STRING,
64
+ allowNull: false,
65
+ });
66
+ });
67
+ exports.down = down;
@@ -1,12 +1,27 @@
1
1
  import { Model } from 'sequelize-typescript';
2
2
  import { Project } from './Project';
3
+ import { Guest } from './Guest';
3
4
  export declare class FlightBooking extends Model<Partial<FlightBooking>> {
4
5
  id: string;
5
- bookingId: string;
6
+ prebookId?: string;
7
+ bookingId?: string;
6
8
  projectId: string;
7
9
  project?: Project;
8
10
  ticketedEmailSent: boolean;
9
11
  cancelledEmailSent: boolean;
12
+ liteApiBookingData?: object;
13
+ liteApiPrebookData?: object;
14
+ bookingInputData?: object;
15
+ paymentData?: object;
16
+ bookingStatus?: string;
17
+ paymentStatus?: string;
18
+ paymentProvider?: string;
19
+ paymentMethod?: string;
20
+ refundStatus?: string;
21
+ cancelledAt?: Date;
22
+ contactEmail?: string;
23
+ guestId?: string;
24
+ guest?: Guest;
10
25
  createdAt: Date;
11
26
  updatedAt: Date;
12
27
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.FlightBooking = void 0;
13
13
  const sequelize_typescript_1 = require("sequelize-typescript");
14
14
  const Project_1 = require("./Project");
15
+ const Guest_1 = require("./Guest");
15
16
  let FlightBooking = class FlightBooking extends sequelize_typescript_1.Model {
16
17
  };
17
18
  exports.FlightBooking = FlightBooking;
@@ -26,9 +27,18 @@ __decorate([
26
27
  ], FlightBooking.prototype, "id", void 0);
27
28
  __decorate([
28
29
  sequelize_typescript_1.Unique,
30
+ sequelize_typescript_1.Index,
29
31
  (0, sequelize_typescript_1.Column)({
30
32
  type: sequelize_typescript_1.DataType.STRING,
31
- allowNull: false,
33
+ allowNull: true,
34
+ }),
35
+ __metadata("design:type", String)
36
+ ], FlightBooking.prototype, "prebookId", void 0);
37
+ __decorate([
38
+ sequelize_typescript_1.Unique,
39
+ (0, sequelize_typescript_1.Column)({
40
+ type: sequelize_typescript_1.DataType.STRING,
41
+ allowNull: true,
32
42
  }),
33
43
  __metadata("design:type", String)
34
44
  ], FlightBooking.prototype, "bookingId", void 0);
@@ -60,6 +70,103 @@ __decorate([
60
70
  }),
61
71
  __metadata("design:type", Boolean)
62
72
  ], FlightBooking.prototype, "cancelledEmailSent", void 0);
73
+ __decorate([
74
+ (0, sequelize_typescript_1.Column)({
75
+ type: sequelize_typescript_1.DataType.JSONB,
76
+ allowNull: false,
77
+ defaultValue: {},
78
+ }),
79
+ __metadata("design:type", Object)
80
+ ], FlightBooking.prototype, "liteApiBookingData", void 0);
81
+ __decorate([
82
+ (0, sequelize_typescript_1.Column)({
83
+ type: sequelize_typescript_1.DataType.JSONB,
84
+ allowNull: false,
85
+ defaultValue: {},
86
+ }),
87
+ __metadata("design:type", Object)
88
+ ], FlightBooking.prototype, "liteApiPrebookData", void 0);
89
+ __decorate([
90
+ (0, sequelize_typescript_1.Column)({
91
+ type: sequelize_typescript_1.DataType.JSONB,
92
+ allowNull: false,
93
+ defaultValue: {},
94
+ }),
95
+ __metadata("design:type", Object)
96
+ ], FlightBooking.prototype, "bookingInputData", void 0);
97
+ __decorate([
98
+ (0, sequelize_typescript_1.Column)({
99
+ type: sequelize_typescript_1.DataType.JSONB,
100
+ allowNull: false,
101
+ defaultValue: {},
102
+ }),
103
+ __metadata("design:type", Object)
104
+ ], FlightBooking.prototype, "paymentData", void 0);
105
+ __decorate([
106
+ (0, sequelize_typescript_1.Column)({
107
+ type: sequelize_typescript_1.DataType.STRING,
108
+ allowNull: false,
109
+ defaultValue: '',
110
+ }),
111
+ __metadata("design:type", String)
112
+ ], FlightBooking.prototype, "bookingStatus", void 0);
113
+ __decorate([
114
+ (0, sequelize_typescript_1.Column)({
115
+ type: sequelize_typescript_1.DataType.STRING,
116
+ allowNull: false,
117
+ defaultValue: '',
118
+ }),
119
+ __metadata("design:type", String)
120
+ ], FlightBooking.prototype, "paymentStatus", void 0);
121
+ __decorate([
122
+ (0, sequelize_typescript_1.Column)({
123
+ type: sequelize_typescript_1.DataType.STRING,
124
+ allowNull: true,
125
+ }),
126
+ __metadata("design:type", String)
127
+ ], FlightBooking.prototype, "paymentProvider", void 0);
128
+ __decorate([
129
+ (0, sequelize_typescript_1.Column)({
130
+ type: sequelize_typescript_1.DataType.STRING,
131
+ allowNull: true,
132
+ }),
133
+ __metadata("design:type", String)
134
+ ], FlightBooking.prototype, "paymentMethod", void 0);
135
+ __decorate([
136
+ (0, sequelize_typescript_1.Column)({
137
+ type: sequelize_typescript_1.DataType.STRING,
138
+ allowNull: true,
139
+ }),
140
+ __metadata("design:type", String)
141
+ ], FlightBooking.prototype, "refundStatus", void 0);
142
+ __decorate([
143
+ (0, sequelize_typescript_1.Column)({
144
+ type: sequelize_typescript_1.DataType.DATE,
145
+ allowNull: true,
146
+ }),
147
+ __metadata("design:type", Date)
148
+ ], FlightBooking.prototype, "cancelledAt", void 0);
149
+ __decorate([
150
+ sequelize_typescript_1.Index,
151
+ (0, sequelize_typescript_1.Column)({
152
+ type: sequelize_typescript_1.DataType.STRING,
153
+ allowNull: true,
154
+ }),
155
+ __metadata("design:type", String)
156
+ ], FlightBooking.prototype, "contactEmail", void 0);
157
+ __decorate([
158
+ (0, sequelize_typescript_1.ForeignKey)(() => Guest_1.Guest),
159
+ sequelize_typescript_1.Index,
160
+ (0, sequelize_typescript_1.Column)({
161
+ type: sequelize_typescript_1.DataType.UUID,
162
+ allowNull: true,
163
+ }),
164
+ __metadata("design:type", String)
165
+ ], FlightBooking.prototype, "guestId", void 0);
166
+ __decorate([
167
+ (0, sequelize_typescript_1.BelongsTo)(() => Guest_1.Guest),
168
+ __metadata("design:type", Guest_1.Guest)
169
+ ], FlightBooking.prototype, "guest", void 0);
63
170
  __decorate([
64
171
  (0, sequelize_typescript_1.Column)({
65
172
  type: sequelize_typescript_1.DataType.DATE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whitelabel-db",
3
- "version": "1.4.5",
3
+ "version": "1.6.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",