whitelabel-db 1.1.73 → 1.1.75
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/migrations/009-add-hotel-video.d.ts +3 -0
- package/dist/migrations/009-add-hotel-video.js +39 -0
- package/dist/models/Hotel.d.ts +1 -0
- package/dist/models/Hotel.js +28 -1
- package/dist/models/Search.d.ts +8 -0
- package/dist/models/Search.js +61 -0
- package/package.json +1 -1
- package/dist/libs/translation.d.ts +0 -4
- package/dist/libs/translation.js +0 -21
|
@@ -0,0 +1,39 @@
|
|
|
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: Add video column to static_hotels table.
|
|
14
|
+
const sequelize_1 = require("sequelize");
|
|
15
|
+
const up = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
try {
|
|
17
|
+
// Add all columns in parallel
|
|
18
|
+
yield queryInterface.addColumn('static_hotels', 'video', {
|
|
19
|
+
type: sequelize_1.DataTypes.STRING,
|
|
20
|
+
allowNull: true,
|
|
21
|
+
});
|
|
22
|
+
console.log('All columns added successfully.');
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error('Error while adding columns:', error.message);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
exports.up = up;
|
|
29
|
+
const down = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
// Remove columns
|
|
32
|
+
yield queryInterface.removeColumn('static_hotels', 'video');
|
|
33
|
+
console.log('All columns removed successfully.');
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error while removing columns:', error.message);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
exports.down = down;
|
package/dist/models/Hotel.d.ts
CHANGED
|
@@ -103,6 +103,7 @@ export declare class Hotel extends Model<Partial<Hotel>> {
|
|
|
103
103
|
reviewSentiment: ReviewSentiment;
|
|
104
104
|
isAccessible: boolean;
|
|
105
105
|
parking?: string;
|
|
106
|
+
video?: string;
|
|
106
107
|
accessibility: HotelAccessibility;
|
|
107
108
|
translations: HotelTranslation[];
|
|
108
109
|
static includeTranslations(options: any, language?: string): any;
|
package/dist/models/Hotel.js
CHANGED
|
@@ -68,7 +68,27 @@ let Hotel = class Hotel extends sequelize_typescript_1.Model {
|
|
|
68
68
|
}, {});
|
|
69
69
|
}
|
|
70
70
|
// Helper function to get translated value or fallback
|
|
71
|
-
const getNestedValue = (key) => {
|
|
71
|
+
const getNestedValue = (key) => {
|
|
72
|
+
try {
|
|
73
|
+
const translationValue = translation[key];
|
|
74
|
+
// Check if translation value is empty string, empty array, or empty object
|
|
75
|
+
if (!translationValue ||
|
|
76
|
+
translationValue === '' ||
|
|
77
|
+
(Array.isArray(translationValue) && translationValue.length === 0) ||
|
|
78
|
+
(typeof translationValue === 'object' &&
|
|
79
|
+
Object.keys(translationValue).length === 0)) {
|
|
80
|
+
// If it's empty, return the hotel object value
|
|
81
|
+
return hotel[key];
|
|
82
|
+
}
|
|
83
|
+
// Otherwise, return the translation value
|
|
84
|
+
return translationValue;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
// In case of an error, return the hotel value as a fallback
|
|
88
|
+
console.error(`Error getting translation for key "${key}":`, error);
|
|
89
|
+
return hotel[key];
|
|
90
|
+
}
|
|
91
|
+
};
|
|
72
92
|
return Object.assign(hotel, {
|
|
73
93
|
name: getNestedValue('name'),
|
|
74
94
|
hotelDescription: getNestedValue('hotelDescription'),
|
|
@@ -406,6 +426,13 @@ __decorate([
|
|
|
406
426
|
}),
|
|
407
427
|
__metadata("design:type", String)
|
|
408
428
|
], Hotel.prototype, "parking", void 0);
|
|
429
|
+
__decorate([
|
|
430
|
+
(0, sequelize_typescript_1.Column)({
|
|
431
|
+
type: sequelize_typescript_1.DataType.STRING,
|
|
432
|
+
allowNull: true,
|
|
433
|
+
}),
|
|
434
|
+
__metadata("design:type", String)
|
|
435
|
+
], Hotel.prototype, "video", void 0);
|
|
409
436
|
__decorate([
|
|
410
437
|
(0, sequelize_typescript_1.HasOne)(() => HotelAccessibility_1.HotelAccessibility),
|
|
411
438
|
__metadata("design:type", HotelAccessibility_1.HotelAccessibility)
|
|
@@ -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
package/dist/libs/translation.js
DELETED
|
@@ -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;
|