whitelabel-db 1.1.85 → 1.1.87

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;
@@ -0,0 +1,31 @@
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 marketSegments column to projects table
17
+ yield queryInterface.addColumn('projects', 'marketSegments', {
18
+ type: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.JSONB),
19
+ allowNull: false,
20
+ defaultValue: [],
21
+ });
22
+ });
23
+ }
24
+ exports.up = up;
25
+ function down(queryInterface) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ // Remove marketSegments column
28
+ yield queryInterface.removeColumn('projects', 'marketSegments');
29
+ });
30
+ }
31
+ 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',
@@ -9,6 +9,7 @@ export declare class Project extends Model<Partial<Project>> {
9
9
  templateName: string;
10
10
  domain?: string;
11
11
  settings?: object;
12
+ marketSegments?: object[];
12
13
  seo?: object;
13
14
  agencyId?: string;
14
15
  agency?: Agency;
@@ -105,6 +105,14 @@ __decorate([
105
105
  }),
106
106
  __metadata("design:type", Object)
107
107
  ], Project.prototype, "settings", void 0);
108
+ __decorate([
109
+ (0, sequelize_typescript_1.Column)({
110
+ type: sequelize_typescript_1.DataType.ARRAY(sequelize_typescript_1.DataType.JSONB),
111
+ allowNull: false,
112
+ defaultValue: [],
113
+ }),
114
+ __metadata("design:type", Array)
115
+ ], Project.prototype, "marketSegments", void 0);
108
116
  __decorate([
109
117
  (0, sequelize_typescript_1.Column)({
110
118
  type: sequelize_typescript_1.DataType.JSONB,
@@ -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.87",
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
- }