whitelabel-db 1.1.85 → 1.1.86

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.
@@ -12,17 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.down = exports.up = void 0;
13
13
  function up(queryInterface) {
14
14
  return __awaiter(this, void 0, void 0, function* () {
15
- // Add unique constraints for upsert operations on main tables
16
- yield queryInterface.addConstraint('amenities', {
17
- fields: ['name'],
18
- type: 'unique',
19
- name: 'amenities_name_unique',
20
- });
21
- yield queryInterface.addConstraint('facilities', {
22
- fields: ['name'],
23
- type: 'unique',
24
- name: 'facilities_name_unique',
25
- });
26
15
  // Add unique constraints for upsert operations on translation tables
27
16
  yield queryInterface.addConstraint('amenity_translations', {
28
17
  fields: ['amenityId', 'language'],
@@ -34,15 +23,6 @@ function up(queryInterface) {
34
23
  type: 'unique',
35
24
  name: 'facility_translation_unique',
36
25
  });
37
- // Add additional indexes for better performance on upsert operations
38
- yield queryInterface.addIndex('amenities', ['name'], {
39
- name: 'idx_amenities_name',
40
- unique: true,
41
- });
42
- yield queryInterface.addIndex('facilities', ['name'], {
43
- name: 'idx_facilities_name',
44
- unique: true,
45
- });
46
26
  yield queryInterface.addIndex('amenity_translations', ['amenityId', 'language'], {
47
27
  name: 'idx_amenity_translation_upsert',
48
28
  unique: true,
@@ -68,13 +48,9 @@ function down(queryInterface) {
68
48
  yield queryInterface.removeIndex('hotel_facilities', 'idx_hotel_facilities_composite');
69
49
  yield queryInterface.removeIndex('amenity_translations', 'idx_amenity_translation_upsert');
70
50
  yield queryInterface.removeIndex('facility_translations', 'idx_facility_translation_upsert');
71
- yield queryInterface.removeIndex('amenities', 'idx_amenities_name');
72
- yield queryInterface.removeIndex('facilities', 'idx_facilities_name');
73
51
  // Remove constraints
74
52
  yield queryInterface.removeConstraint('amenity_translations', 'amenity_translation_unique');
75
53
  yield queryInterface.removeConstraint('facility_translations', 'facility_translation_unique');
76
- yield queryInterface.removeConstraint('amenities', 'amenities_name_unique');
77
- yield queryInterface.removeConstraint('facilities', 'facilities_name_unique');
78
54
  });
79
55
  }
80
56
  exports.down = down;
@@ -0,0 +1,47 @@
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
+ const sequelize_1 = require("sequelize");
14
+ function up(queryInterface) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ // Add hotelId column to room_amenities table
17
+ yield queryInterface.addColumn('room_amenities', 'hotelId', {
18
+ type: sequelize_1.DataTypes.STRING,
19
+ allowNull: true,
20
+ references: {
21
+ model: 'static_hotels',
22
+ key: 'id',
23
+ },
24
+ onUpdate: 'CASCADE',
25
+ onDelete: 'CASCADE',
26
+ });
27
+ // Add index for better performance
28
+ yield queryInterface.addIndex('room_amenities', ['hotelId'], {
29
+ name: 'idx_room_amenities_hotel_id',
30
+ });
31
+ // Add composite index for filtering
32
+ yield queryInterface.addIndex('room_amenities', ['hotelId', 'amenityId'], {
33
+ name: 'idx_room_amenities_hotel_amenity',
34
+ });
35
+ });
36
+ }
37
+ exports.up = up;
38
+ function down(queryInterface) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ // Remove indexes
41
+ yield queryInterface.removeIndex('room_amenities', 'idx_room_amenities_hotel_amenity');
42
+ yield queryInterface.removeIndex('room_amenities', 'idx_room_amenities_hotel_id');
43
+ // Remove column
44
+ yield queryInterface.removeColumn('room_amenities', 'hotelId');
45
+ });
46
+ }
47
+ exports.down = down;
@@ -4,6 +4,7 @@ import { HotelAccessibility } from './HotelAccessibility';
4
4
  import { HotelTranslation } from './HotelTranslation';
5
5
  import { HotelFacility } from './HotelFacility';
6
6
  import { Facility as FacilityModel } from './Facility';
7
+ import { RoomAmenity as RoomAmenityModel } from './RoomAmenity';
7
8
  export type HotelImage = {
8
9
  url: string;
9
10
  thumbnailUrl: string;
@@ -111,6 +112,7 @@ export declare class Hotel extends Model<Partial<Hotel>> {
111
112
  translations: HotelTranslation[];
112
113
  hotelFacilityRelations: HotelFacility[];
113
114
  normalizedFacilities: FacilityModel[];
115
+ roomAmenities: RoomAmenityModel[];
114
116
  static includeTranslations(options: any, language?: string): any;
115
117
  static applyTranslations(hotel: Hotel): Hotel;
116
118
  static findOneWithTranslation(options: any, language?: string): Promise<Hotel>;
@@ -24,6 +24,7 @@ const HotelAccessibility_1 = require("./HotelAccessibility");
24
24
  const HotelTranslation_1 = require("./HotelTranslation");
25
25
  const HotelFacility_1 = require("./HotelFacility");
26
26
  const Facility_1 = require("./Facility");
27
+ const RoomAmenity_1 = require("./RoomAmenity");
27
28
  let Hotel = class Hotel extends sequelize_typescript_1.Model {
28
29
  // Include translations in the options
29
30
  static includeTranslations(options, language) {
@@ -459,6 +460,10 @@ __decorate([
459
460
  (0, sequelize_typescript_1.BelongsToMany)(() => Facility_1.Facility, () => HotelFacility_1.HotelFacility),
460
461
  __metadata("design:type", Array)
461
462
  ], Hotel.prototype, "normalizedFacilities", void 0);
463
+ __decorate([
464
+ (0, sequelize_typescript_1.HasMany)(() => RoomAmenity_1.RoomAmenity),
465
+ __metadata("design:type", Array)
466
+ ], Hotel.prototype, "roomAmenities", void 0);
462
467
  exports.Hotel = Hotel = __decorate([
463
468
  (0, sequelize_typescript_1.Table)({
464
469
  tableName: 'static_hotels',
@@ -1,8 +1,11 @@
1
1
  import { Model } from 'sequelize-typescript';
2
2
  import { Amenity } from './Amenity';
3
+ import { Hotel } from './Hotel';
3
4
  export declare class RoomAmenity extends Model<Partial<RoomAmenity>> {
4
5
  roomId: number;
6
+ hotelId: string;
5
7
  amenityId: number;
6
8
  order: number;
7
9
  amenity: Amenity;
10
+ hotel: Hotel;
8
11
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.RoomAmenity = void 0;
13
13
  const sequelize_typescript_1 = require("sequelize-typescript");
14
14
  const Amenity_1 = require("./Amenity");
15
+ const Hotel_1 = require("./Hotel");
15
16
  let RoomAmenity = class RoomAmenity extends sequelize_typescript_1.Model {
16
17
  };
17
18
  exports.RoomAmenity = RoomAmenity;
@@ -23,6 +24,14 @@ __decorate([
23
24
  }),
24
25
  __metadata("design:type", Number)
25
26
  ], RoomAmenity.prototype, "roomId", void 0);
27
+ __decorate([
28
+ (0, sequelize_typescript_1.ForeignKey)(() => Hotel_1.Hotel),
29
+ (0, sequelize_typescript_1.Column)({
30
+ type: sequelize_typescript_1.DataType.STRING,
31
+ allowNull: true,
32
+ }),
33
+ __metadata("design:type", String)
34
+ ], RoomAmenity.prototype, "hotelId", void 0);
26
35
  __decorate([
27
36
  sequelize_typescript_1.PrimaryKey,
28
37
  (0, sequelize_typescript_1.ForeignKey)(() => Amenity_1.Amenity),
@@ -44,6 +53,10 @@ __decorate([
44
53
  (0, sequelize_typescript_1.BelongsTo)(() => Amenity_1.Amenity),
45
54
  __metadata("design:type", Amenity_1.Amenity)
46
55
  ], RoomAmenity.prototype, "amenity", void 0);
56
+ __decorate([
57
+ (0, sequelize_typescript_1.BelongsTo)(() => Hotel_1.Hotel),
58
+ __metadata("design:type", Hotel_1.Hotel)
59
+ ], RoomAmenity.prototype, "hotel", void 0);
47
60
  exports.RoomAmenity = RoomAmenity = __decorate([
48
61
  (0, sequelize_typescript_1.Table)({
49
62
  tableName: 'room_amenities',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whitelabel-db",
3
- "version": "1.1.85",
3
+ "version": "1.1.86",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,84 +0,0 @@
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
- }
@@ -1,413 +0,0 @@
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;