whitelabel-db 1.1.84 → 1.1.85
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 +6 -0
- package/dist/index.js +14 -1
- package/dist/libs/database.js +12 -0
- package/dist/libs/entityService.d.ts +84 -0
- package/dist/libs/entityService.js +413 -0
- package/dist/migrations/015-create-facilities-tables.d.ts +3 -0
- package/dist/migrations/015-create-facilities-tables.js +119 -0
- package/dist/migrations/016-create-amenities-tables.d.ts +3 -0
- package/dist/migrations/016-create-amenities-tables.js +119 -0
- package/dist/migrations/017-add-upsert-indexes-amenities-facilities.d.ts +3 -0
- package/dist/migrations/017-add-upsert-indexes-amenities-facilities.js +80 -0
- package/dist/migrations/017-populate-facilities-amenities-optimized.d.ts +3 -0
- package/dist/migrations/017-populate-facilities-amenities-optimized.js +265 -0
- package/dist/migrations/017-populate-facilities-amenities.d.ts +3 -0
- package/dist/migrations/017-populate-facilities-amenities.js +265 -0
- package/dist/migrations/018-populate-translations-optimized.d.ts +3 -0
- package/dist/migrations/018-populate-translations-optimized.js +223 -0
- package/dist/migrations/018-populate-translations.d.ts +3 -0
- package/dist/migrations/018-populate-translations.js +223 -0
- package/dist/models/Amenity.d.ts +9 -0
- package/dist/models/Amenity.js +47 -0
- package/dist/models/AmenityTranslation.d.ts +8 -0
- package/dist/models/AmenityTranslation.js +52 -0
- package/dist/models/Facility.d.ts +11 -0
- package/dist/models/Facility.js +52 -0
- package/dist/models/FacilityTranslation.d.ts +8 -0
- package/dist/models/FacilityTranslation.js +52 -0
- package/dist/models/Hotel.d.ts +4 -0
- package/dist/models/Hotel.js +10 -0
- package/dist/models/HotelFacility.d.ts +9 -0
- package/dist/models/HotelFacility.js +49 -0
- package/dist/models/RoomAmenity.d.ts +8 -0
- package/dist/models/RoomAmenity.js +51 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,12 @@ export { HotelAccessibility } from './models/HotelAccessibility';
|
|
|
14
14
|
export { Referral } from './models/Referral';
|
|
15
15
|
export { Feedback } from './models/Feedback';
|
|
16
16
|
export { HotelRate } from './models/HotelRate';
|
|
17
|
+
export { Facility } from './models/Facility';
|
|
18
|
+
export { HotelFacility } from './models/HotelFacility';
|
|
19
|
+
export { FacilityTranslation } from './models/FacilityTranslation';
|
|
20
|
+
export { Amenity } from './models/Amenity';
|
|
21
|
+
export { RoomAmenity } from './models/RoomAmenity';
|
|
22
|
+
export { AmenityTranslation } from './models/AmenityTranslation';
|
|
17
23
|
export { LiteApiClient, HotelsRequest, AvailabilityResult, FullRateAvailabilityResult, RoomType, Rate, PrebookRateRequest, PrebookRate, CheckoutRequest, BookingInfo, CancelBooking, } from './libs/liteapi';
|
|
18
24
|
export { LiteApiClientV3, HotelsRequestV3, AvailabilityResultV3, FullRateAvailabilityResultV3, RoomTypeV3, RateV3, PrebookRateRequestV3, PrebookRateV3, CheckoutRequestV3, BookingInfoV3, CancelBookingV3, BookedRoomV3, OccupancyV3, GuestV3, GuestBookingV3, PromoCodeRequest, PromoCodeResponse, EsimplyPackage, Addon, AddonResponse, } from './libs/liteapiv3';
|
|
19
25
|
export { LiteApiUser, LiteApiUserRequest } from './libs/liteapiuser';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LiteApiUser = exports.LiteApiClientV3 = exports.LiteApiClient = exports.HotelRate = exports.Feedback = exports.Referral = exports.HotelAccessibility = exports.Guest = exports.HotelTranslation = exports.Role = exports.Booking = exports.Project = exports.User = exports.Hotel = exports.Country = exports.City = exports.Agency = exports.runMigrations = exports.connect = void 0;
|
|
3
|
+
exports.LiteApiUser = exports.LiteApiClientV3 = exports.LiteApiClient = exports.AmenityTranslation = exports.RoomAmenity = exports.Amenity = exports.FacilityTranslation = exports.HotelFacility = exports.Facility = exports.HotelRate = exports.Feedback = exports.Referral = exports.HotelAccessibility = exports.Guest = exports.HotelTranslation = exports.Role = exports.Booking = exports.Project = exports.User = exports.Hotel = exports.Country = exports.City = exports.Agency = exports.runMigrations = 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 migration_1 = require("./libs/migration");
|
|
@@ -33,6 +33,19 @@ var Feedback_1 = require("./models/Feedback");
|
|
|
33
33
|
Object.defineProperty(exports, "Feedback", { enumerable: true, get: function () { return Feedback_1.Feedback; } });
|
|
34
34
|
var HotelRate_1 = require("./models/HotelRate");
|
|
35
35
|
Object.defineProperty(exports, "HotelRate", { enumerable: true, get: function () { return HotelRate_1.HotelRate; } });
|
|
36
|
+
// New normalized models
|
|
37
|
+
var Facility_1 = require("./models/Facility");
|
|
38
|
+
Object.defineProperty(exports, "Facility", { enumerable: true, get: function () { return Facility_1.Facility; } });
|
|
39
|
+
var HotelFacility_1 = require("./models/HotelFacility");
|
|
40
|
+
Object.defineProperty(exports, "HotelFacility", { enumerable: true, get: function () { return HotelFacility_1.HotelFacility; } });
|
|
41
|
+
var FacilityTranslation_1 = require("./models/FacilityTranslation");
|
|
42
|
+
Object.defineProperty(exports, "FacilityTranslation", { enumerable: true, get: function () { return FacilityTranslation_1.FacilityTranslation; } });
|
|
43
|
+
var Amenity_1 = require("./models/Amenity");
|
|
44
|
+
Object.defineProperty(exports, "Amenity", { enumerable: true, get: function () { return Amenity_1.Amenity; } });
|
|
45
|
+
var RoomAmenity_1 = require("./models/RoomAmenity");
|
|
46
|
+
Object.defineProperty(exports, "RoomAmenity", { enumerable: true, get: function () { return RoomAmenity_1.RoomAmenity; } });
|
|
47
|
+
var AmenityTranslation_1 = require("./models/AmenityTranslation");
|
|
48
|
+
Object.defineProperty(exports, "AmenityTranslation", { enumerable: true, get: function () { return AmenityTranslation_1.AmenityTranslation; } });
|
|
36
49
|
var liteapi_1 = require("./libs/liteapi");
|
|
37
50
|
Object.defineProperty(exports, "LiteApiClient", { enumerable: true, get: function () { return liteapi_1.LiteApiClient; } });
|
|
38
51
|
var liteapiv3_1 = require("./libs/liteapiv3");
|
package/dist/libs/database.js
CHANGED
|
@@ -25,6 +25,12 @@ const HotelAccessibility_1 = require("../models/HotelAccessibility");
|
|
|
25
25
|
const Referral_1 = require("../models/Referral");
|
|
26
26
|
const Feedback_1 = require("../models/Feedback");
|
|
27
27
|
const HotelRate_1 = require("../models/HotelRate");
|
|
28
|
+
const Facility_1 = require("../models/Facility");
|
|
29
|
+
const HotelFacility_1 = require("../models/HotelFacility");
|
|
30
|
+
const FacilityTranslation_1 = require("../models/FacilityTranslation");
|
|
31
|
+
const Amenity_1 = require("../models/Amenity");
|
|
32
|
+
const RoomAmenity_1 = require("../models/RoomAmenity");
|
|
33
|
+
const AmenityTranslation_1 = require("../models/AmenityTranslation");
|
|
28
34
|
const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
35
|
const connection = new sequelize_typescript_1.Sequelize({
|
|
30
36
|
dialect: 'postgres',
|
|
@@ -48,6 +54,12 @@ const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, functio
|
|
|
48
54
|
Referral_1.Referral,
|
|
49
55
|
Feedback_1.Feedback,
|
|
50
56
|
HotelRate_1.HotelRate,
|
|
57
|
+
Facility_1.Facility,
|
|
58
|
+
HotelFacility_1.HotelFacility,
|
|
59
|
+
FacilityTranslation_1.FacilityTranslation,
|
|
60
|
+
Amenity_1.Amenity,
|
|
61
|
+
RoomAmenity_1.RoomAmenity,
|
|
62
|
+
AmenityTranslation_1.AmenityTranslation,
|
|
51
63
|
],
|
|
52
64
|
});
|
|
53
65
|
return connection
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Facility } from '../models/Facility';
|
|
2
|
+
import { Amenity } from '../models/Amenity';
|
|
3
|
+
import { RoomAmenity } from '../models/RoomAmenity';
|
|
4
|
+
import { Hotel } from '../models/Hotel';
|
|
5
|
+
export declare class FacilityService {
|
|
6
|
+
/**
|
|
7
|
+
* Get all facilities with optional language filter
|
|
8
|
+
*/
|
|
9
|
+
static getFacilities(language?: string): Promise<Facility[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Get facilities for a specific hotel
|
|
12
|
+
*/
|
|
13
|
+
static getHotelFacilities(hotelId: string, language?: string): Promise<Facility[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get hotels that have a specific facility
|
|
16
|
+
*/
|
|
17
|
+
static getHotelsByFacility(facilityId: number, language?: string): Promise<Hotel[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Search facilities by name
|
|
20
|
+
*/
|
|
21
|
+
static searchFacilities(searchTerm: string, language?: string): Promise<Facility[]>;
|
|
22
|
+
}
|
|
23
|
+
export declare class AmenityService {
|
|
24
|
+
/**
|
|
25
|
+
* Get all amenities with optional language filter
|
|
26
|
+
*/
|
|
27
|
+
static getAmenities(language?: string): Promise<Amenity[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Get amenities for a specific room
|
|
30
|
+
*/
|
|
31
|
+
static getRoomAmenities(roomId: number, language?: string): Promise<Amenity[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Get rooms that have a specific amenity
|
|
34
|
+
*/
|
|
35
|
+
static getRoomsByAmenity(amenityId: number): Promise<RoomAmenity[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Search amenities by name
|
|
38
|
+
*/
|
|
39
|
+
static searchAmenities(searchTerm: string, language?: string): Promise<Amenity[]>;
|
|
40
|
+
}
|
|
41
|
+
export declare class MappingService {
|
|
42
|
+
/**
|
|
43
|
+
* Map normalized facilities back to JSON format for backward compatibility
|
|
44
|
+
*/
|
|
45
|
+
static mapHotelFacilitiesToJson(hotelId: string, language?: string): Promise<any[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Map normalized amenities back to JSON format for backward compatibility
|
|
48
|
+
*/
|
|
49
|
+
static mapRoomAmenitiesToJson(roomId: number, language?: string): Promise<any[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Map hotel with normalized facilities and amenities to JSON format
|
|
52
|
+
*/
|
|
53
|
+
static mapHotelToJson(hotelId: string, language?: string): Promise<any>;
|
|
54
|
+
/**
|
|
55
|
+
* Map JSON facilities to normalized structure for insertion
|
|
56
|
+
*/
|
|
57
|
+
static mapJsonFacilitiesToNormalized(jsonFacilities: any[]): {
|
|
58
|
+
facilities: any[];
|
|
59
|
+
hotelFacilities: any[];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Map JSON amenities to normalized structure for insertion
|
|
63
|
+
*/
|
|
64
|
+
static mapJsonAmenitiesToNormalized(jsonAmenities: any[], roomId: number): {
|
|
65
|
+
amenities: any[];
|
|
66
|
+
roomAmenities: any[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Get facility mapping statistics
|
|
70
|
+
*/
|
|
71
|
+
static getFacilityMappingStats(): Promise<{
|
|
72
|
+
totalFacilities: number;
|
|
73
|
+
totalHotelFacilities: number;
|
|
74
|
+
facilitiesWithTranslations: number;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Get amenity mapping statistics
|
|
78
|
+
*/
|
|
79
|
+
static getAmenityMappingStats(): Promise<{
|
|
80
|
+
totalAmenities: number;
|
|
81
|
+
totalRoomAmenities: number;
|
|
82
|
+
amenitiesWithTranslations: number;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,413 @@
|
|
|
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.MappingService = exports.AmenityService = exports.FacilityService = void 0;
|
|
13
|
+
const sequelize_1 = require("sequelize");
|
|
14
|
+
const Facility_1 = require("../models/Facility");
|
|
15
|
+
const HotelFacility_1 = require("../models/HotelFacility");
|
|
16
|
+
const FacilityTranslation_1 = require("../models/FacilityTranslation");
|
|
17
|
+
const Amenity_1 = require("../models/Amenity");
|
|
18
|
+
const RoomAmenity_1 = require("../models/RoomAmenity");
|
|
19
|
+
const AmenityTranslation_1 = require("../models/AmenityTranslation");
|
|
20
|
+
const Hotel_1 = require("../models/Hotel");
|
|
21
|
+
const HotelTranslation_1 = require("../models/HotelTranslation");
|
|
22
|
+
class FacilityService {
|
|
23
|
+
/**
|
|
24
|
+
* Get all facilities with optional language filter
|
|
25
|
+
*/
|
|
26
|
+
static getFacilities(language) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const options = {
|
|
29
|
+
include: [],
|
|
30
|
+
};
|
|
31
|
+
if (language && language !== 'en') {
|
|
32
|
+
options.include.push({
|
|
33
|
+
model: FacilityTranslation_1.FacilityTranslation,
|
|
34
|
+
as: 'translations',
|
|
35
|
+
where: { language },
|
|
36
|
+
required: false,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return yield Facility_1.Facility.findAll(options);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get facilities for a specific hotel
|
|
44
|
+
*/
|
|
45
|
+
static getHotelFacilities(hotelId, language) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const options = {
|
|
48
|
+
include: [
|
|
49
|
+
{
|
|
50
|
+
model: HotelFacility_1.HotelFacility,
|
|
51
|
+
as: 'hotelFacilityRelations',
|
|
52
|
+
where: { hotelId },
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
if (language && language !== 'en') {
|
|
57
|
+
options.include.push({
|
|
58
|
+
model: FacilityTranslation_1.FacilityTranslation,
|
|
59
|
+
as: 'translations',
|
|
60
|
+
where: { language },
|
|
61
|
+
required: false,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return yield Facility_1.Facility.findAll(options);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get hotels that have a specific facility
|
|
69
|
+
*/
|
|
70
|
+
static getHotelsByFacility(facilityId, language) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const options = {
|
|
73
|
+
include: [
|
|
74
|
+
{
|
|
75
|
+
model: HotelFacility_1.HotelFacility,
|
|
76
|
+
as: 'hotelFacilityRelations',
|
|
77
|
+
where: { facilityId },
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
};
|
|
81
|
+
if (language && language !== 'en') {
|
|
82
|
+
options.include.push({
|
|
83
|
+
model: HotelTranslation_1.HotelTranslation,
|
|
84
|
+
as: 'translations',
|
|
85
|
+
where: { language },
|
|
86
|
+
required: false,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return yield Hotel_1.Hotel.findAll(options);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Search facilities by name
|
|
94
|
+
*/
|
|
95
|
+
static searchFacilities(searchTerm, language) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const options = {
|
|
98
|
+
where: {
|
|
99
|
+
name: {
|
|
100
|
+
[sequelize_1.Op.iLike]: `%${searchTerm}%`,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
include: [],
|
|
104
|
+
};
|
|
105
|
+
if (language && language !== 'en') {
|
|
106
|
+
options.include.push({
|
|
107
|
+
model: FacilityTranslation_1.FacilityTranslation,
|
|
108
|
+
as: 'translations',
|
|
109
|
+
where: {
|
|
110
|
+
language,
|
|
111
|
+
name: {
|
|
112
|
+
[sequelize_1.Op.iLike]: `%${searchTerm}%`,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: false,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return yield Facility_1.Facility.findAll(options);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.FacilityService = FacilityService;
|
|
123
|
+
class AmenityService {
|
|
124
|
+
/**
|
|
125
|
+
* Get all amenities with optional language filter
|
|
126
|
+
*/
|
|
127
|
+
static getAmenities(language) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const options = {
|
|
130
|
+
include: [],
|
|
131
|
+
};
|
|
132
|
+
if (language && language !== 'en') {
|
|
133
|
+
options.include.push({
|
|
134
|
+
model: AmenityTranslation_1.AmenityTranslation,
|
|
135
|
+
as: 'translations',
|
|
136
|
+
where: { language },
|
|
137
|
+
required: false,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return yield Amenity_1.Amenity.findAll(options);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get amenities for a specific room
|
|
145
|
+
*/
|
|
146
|
+
static getRoomAmenities(roomId, language) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
const options = {
|
|
149
|
+
include: [
|
|
150
|
+
{
|
|
151
|
+
model: RoomAmenity_1.RoomAmenity,
|
|
152
|
+
as: 'roomAmenities',
|
|
153
|
+
where: { roomId },
|
|
154
|
+
order: [['order', 'ASC']],
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
if (language && language !== 'en') {
|
|
159
|
+
options.include.push({
|
|
160
|
+
model: AmenityTranslation_1.AmenityTranslation,
|
|
161
|
+
as: 'translations',
|
|
162
|
+
where: { language },
|
|
163
|
+
required: false,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return yield Amenity_1.Amenity.findAll(options);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get rooms that have a specific amenity
|
|
171
|
+
*/
|
|
172
|
+
static getRoomsByAmenity(amenityId) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
return yield RoomAmenity_1.RoomAmenity.findAll({
|
|
175
|
+
where: { amenityId },
|
|
176
|
+
include: [
|
|
177
|
+
{
|
|
178
|
+
model: Amenity_1.Amenity,
|
|
179
|
+
as: 'amenity',
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Search amenities by name
|
|
187
|
+
*/
|
|
188
|
+
static searchAmenities(searchTerm, language) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
const options = {
|
|
191
|
+
where: {
|
|
192
|
+
name: {
|
|
193
|
+
[sequelize_1.Op.iLike]: `%${searchTerm}%`,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
include: [],
|
|
197
|
+
};
|
|
198
|
+
if (language && language !== 'en') {
|
|
199
|
+
options.include.push({
|
|
200
|
+
model: AmenityTranslation_1.AmenityTranslation,
|
|
201
|
+
as: 'translations',
|
|
202
|
+
where: {
|
|
203
|
+
language,
|
|
204
|
+
name: {
|
|
205
|
+
[sequelize_1.Op.iLike]: `%${searchTerm}%`,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
required: false,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return yield Amenity_1.Amenity.findAll(options);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.AmenityService = AmenityService;
|
|
216
|
+
class MappingService {
|
|
217
|
+
/**
|
|
218
|
+
* Map normalized facilities back to JSON format for backward compatibility
|
|
219
|
+
*/
|
|
220
|
+
static mapHotelFacilitiesToJson(hotelId, language) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
const hotelFacilities = yield HotelFacility_1.HotelFacility.findAll({
|
|
223
|
+
where: { hotelId },
|
|
224
|
+
include: [
|
|
225
|
+
{
|
|
226
|
+
model: Facility_1.Facility,
|
|
227
|
+
as: 'facility',
|
|
228
|
+
include: language && language !== 'en'
|
|
229
|
+
? [
|
|
230
|
+
{
|
|
231
|
+
model: FacilityTranslation_1.FacilityTranslation,
|
|
232
|
+
as: 'translations',
|
|
233
|
+
where: { language },
|
|
234
|
+
required: false,
|
|
235
|
+
},
|
|
236
|
+
]
|
|
237
|
+
: [],
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
});
|
|
241
|
+
return hotelFacilities.map((hf) => {
|
|
242
|
+
var _a;
|
|
243
|
+
const facility = hf.facility;
|
|
244
|
+
const translation = (_a = facility === null || facility === void 0 ? void 0 : facility.translations) === null || _a === void 0 ? void 0 : _a[0];
|
|
245
|
+
return {
|
|
246
|
+
id: facility === null || facility === void 0 ? void 0 : facility.id,
|
|
247
|
+
name: (translation === null || translation === void 0 ? void 0 : translation.name) || (facility === null || facility === void 0 ? void 0 : facility.name),
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Map normalized amenities back to JSON format for backward compatibility
|
|
254
|
+
*/
|
|
255
|
+
static mapRoomAmenitiesToJson(roomId, language) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
const roomAmenities = yield RoomAmenity_1.RoomAmenity.findAll({
|
|
258
|
+
where: { roomId },
|
|
259
|
+
include: [
|
|
260
|
+
{
|
|
261
|
+
model: Amenity_1.Amenity,
|
|
262
|
+
as: 'amenity',
|
|
263
|
+
include: language && language !== 'en'
|
|
264
|
+
? [
|
|
265
|
+
{
|
|
266
|
+
model: AmenityTranslation_1.AmenityTranslation,
|
|
267
|
+
as: 'translations',
|
|
268
|
+
where: { language },
|
|
269
|
+
required: false,
|
|
270
|
+
},
|
|
271
|
+
]
|
|
272
|
+
: [],
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
order: [['order', 'ASC']],
|
|
276
|
+
});
|
|
277
|
+
return roomAmenities.map((ra) => {
|
|
278
|
+
var _a;
|
|
279
|
+
const amenity = ra.amenity;
|
|
280
|
+
const translation = (_a = amenity === null || amenity === void 0 ? void 0 : amenity.translations) === null || _a === void 0 ? void 0 : _a[0];
|
|
281
|
+
return {
|
|
282
|
+
id: amenity === null || amenity === void 0 ? void 0 : amenity.id,
|
|
283
|
+
name: (translation === null || translation === void 0 ? void 0 : translation.name) || (amenity === null || amenity === void 0 ? void 0 : amenity.name),
|
|
284
|
+
order: ra.order,
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Map hotel with normalized facilities and amenities to JSON format
|
|
291
|
+
*/
|
|
292
|
+
static mapHotelToJson(hotelId, language) {
|
|
293
|
+
var _a, _b;
|
|
294
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
295
|
+
const hotel = yield Hotel_1.Hotel.findByPk(hotelId, {
|
|
296
|
+
include: [
|
|
297
|
+
{
|
|
298
|
+
model: HotelFacility_1.HotelFacility,
|
|
299
|
+
as: 'hotelFacilityRelations',
|
|
300
|
+
include: [
|
|
301
|
+
{
|
|
302
|
+
model: Facility_1.Facility,
|
|
303
|
+
as: 'facility',
|
|
304
|
+
include: language && language !== 'en'
|
|
305
|
+
? [
|
|
306
|
+
{
|
|
307
|
+
model: FacilityTranslation_1.FacilityTranslation,
|
|
308
|
+
as: 'translations',
|
|
309
|
+
where: { language },
|
|
310
|
+
required: false,
|
|
311
|
+
},
|
|
312
|
+
]
|
|
313
|
+
: [],
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
});
|
|
319
|
+
if (!hotel)
|
|
320
|
+
return null;
|
|
321
|
+
// Map facilities to JSON format
|
|
322
|
+
const facilities = ((_a = hotel.hotelFacilityRelations) === null || _a === void 0 ? void 0 : _a.map((hf) => {
|
|
323
|
+
var _a;
|
|
324
|
+
const facility = hf.facility;
|
|
325
|
+
const translation = (_a = facility === null || facility === void 0 ? void 0 : facility.translations) === null || _a === void 0 ? void 0 : _a[0];
|
|
326
|
+
return {
|
|
327
|
+
id: facility === null || facility === void 0 ? void 0 : facility.id,
|
|
328
|
+
name: (translation === null || translation === void 0 ? void 0 : translation.name) || (facility === null || facility === void 0 ? void 0 : facility.name),
|
|
329
|
+
};
|
|
330
|
+
})) || [];
|
|
331
|
+
// Map rooms with amenities to JSON format
|
|
332
|
+
const rooms = ((_b = hotel.rooms) === null || _b === void 0 ? void 0 : _b.map((room) => {
|
|
333
|
+
return Object.assign(Object.assign({}, room), { room_amenities: this.mapRoomAmenitiesToJson(room.id, language) });
|
|
334
|
+
})) || [];
|
|
335
|
+
return Object.assign(Object.assign({}, hotel.toJSON()), { facilities,
|
|
336
|
+
rooms });
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Map JSON facilities to normalized structure for insertion
|
|
341
|
+
*/
|
|
342
|
+
static mapJsonFacilitiesToNormalized(jsonFacilities) {
|
|
343
|
+
const facilities = [];
|
|
344
|
+
const hotelFacilities = [];
|
|
345
|
+
jsonFacilities.forEach((facility) => {
|
|
346
|
+
if (facility.id && facility.name) {
|
|
347
|
+
facilities.push({
|
|
348
|
+
id: facility.id,
|
|
349
|
+
name: facility.name,
|
|
350
|
+
createdAt: new Date(),
|
|
351
|
+
updatedAt: new Date(),
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
return { facilities, hotelFacilities };
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Map JSON amenities to normalized structure for insertion
|
|
359
|
+
*/
|
|
360
|
+
static mapJsonAmenitiesToNormalized(jsonAmenities, roomId) {
|
|
361
|
+
const amenities = [];
|
|
362
|
+
const roomAmenities = [];
|
|
363
|
+
jsonAmenities.forEach((amenity) => {
|
|
364
|
+
if (amenity.id && amenity.name) {
|
|
365
|
+
amenities.push({
|
|
366
|
+
id: amenity.id,
|
|
367
|
+
name: amenity.name,
|
|
368
|
+
createdAt: new Date(),
|
|
369
|
+
updatedAt: new Date(),
|
|
370
|
+
});
|
|
371
|
+
roomAmenities.push({
|
|
372
|
+
roomId,
|
|
373
|
+
amenityId: amenity.id,
|
|
374
|
+
order: amenity.order || 0,
|
|
375
|
+
createdAt: new Date(),
|
|
376
|
+
updatedAt: new Date(),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
return { amenities, roomAmenities };
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Get facility mapping statistics
|
|
384
|
+
*/
|
|
385
|
+
static getFacilityMappingStats() {
|
|
386
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
387
|
+
const totalFacilities = yield Facility_1.Facility.count();
|
|
388
|
+
const totalHotelFacilities = yield HotelFacility_1.HotelFacility.count();
|
|
389
|
+
const facilitiesWithTranslations = yield FacilityTranslation_1.FacilityTranslation.count();
|
|
390
|
+
return {
|
|
391
|
+
totalFacilities,
|
|
392
|
+
totalHotelFacilities,
|
|
393
|
+
facilitiesWithTranslations,
|
|
394
|
+
};
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Get amenity mapping statistics
|
|
399
|
+
*/
|
|
400
|
+
static getAmenityMappingStats() {
|
|
401
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
402
|
+
const totalAmenities = yield Amenity_1.Amenity.count();
|
|
403
|
+
const totalRoomAmenities = yield RoomAmenity_1.RoomAmenity.count();
|
|
404
|
+
const amenitiesWithTranslations = yield AmenityTranslation_1.AmenityTranslation.count();
|
|
405
|
+
return {
|
|
406
|
+
totalAmenities,
|
|
407
|
+
totalRoomAmenities,
|
|
408
|
+
amenitiesWithTranslations,
|
|
409
|
+
};
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
exports.MappingService = MappingService;
|