whitelabel-db 1.1.89 → 1.1.91
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 +1 -0
- package/dist/index.js +3 -1
- package/dist/libs/database.js +2 -0
- package/dist/migrations/021-add-analytics-indexes.d.ts +3 -0
- package/dist/migrations/021-add-analytics-indexes.js +91 -0
- package/dist/models/AnalyticsSummary.d.ts +13 -0
- package/dist/models/AnalyticsSummary.js +122 -0
- package/dist/models/Booking.d.ts +1 -1
- package/dist/models/Booking.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ 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 { AnalyticsSummary } from './models/AnalyticsSummary';
|
|
17
18
|
export { Facility } from './models/Facility';
|
|
18
19
|
export { HotelFacility } from './models/HotelFacility';
|
|
19
20
|
export { FacilityTranslation } from './models/FacilityTranslation';
|
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.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;
|
|
3
|
+
exports.LiteApiUser = exports.LiteApiClientV3 = exports.LiteApiClient = exports.AmenityTranslation = exports.RoomAmenity = exports.Amenity = exports.FacilityTranslation = exports.HotelFacility = exports.Facility = exports.AnalyticsSummary = 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,8 @@ 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
|
+
var AnalyticsSummary_1 = require("./models/AnalyticsSummary");
|
|
37
|
+
Object.defineProperty(exports, "AnalyticsSummary", { enumerable: true, get: function () { return AnalyticsSummary_1.AnalyticsSummary; } });
|
|
36
38
|
// New normalized models
|
|
37
39
|
var Facility_1 = require("./models/Facility");
|
|
38
40
|
Object.defineProperty(exports, "Facility", { enumerable: true, get: function () { return Facility_1.Facility; } });
|
package/dist/libs/database.js
CHANGED
|
@@ -31,6 +31,7 @@ const FacilityTranslation_1 = require("../models/FacilityTranslation");
|
|
|
31
31
|
const Amenity_1 = require("../models/Amenity");
|
|
32
32
|
const RoomAmenity_1 = require("../models/RoomAmenity");
|
|
33
33
|
const AmenityTranslation_1 = require("../models/AmenityTranslation");
|
|
34
|
+
const AnalyticsSummary_1 = require("../models/AnalyticsSummary");
|
|
34
35
|
const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
36
|
const connection = new sequelize_typescript_1.Sequelize({
|
|
36
37
|
dialect: 'postgres',
|
|
@@ -60,6 +61,7 @@ const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, functio
|
|
|
60
61
|
Amenity_1.Amenity,
|
|
61
62
|
RoomAmenity_1.RoomAmenity,
|
|
62
63
|
AmenityTranslation_1.AmenityTranslation,
|
|
64
|
+
AnalyticsSummary_1.AnalyticsSummary,
|
|
63
65
|
],
|
|
64
66
|
});
|
|
65
67
|
return connection
|
|
@@ -0,0 +1,91 @@
|
|
|
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 up = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
// Create basic indexes for better query performance
|
|
16
|
+
yield queryInterface.addIndex('analytics_summary', ['dimension_type', 'dimension_value'], {
|
|
17
|
+
name: 'idx_analytics_dimension',
|
|
18
|
+
});
|
|
19
|
+
yield queryInterface.addIndex('analytics_summary', ['date_grain', 'period_start'], {
|
|
20
|
+
name: 'idx_analytics_period',
|
|
21
|
+
});
|
|
22
|
+
// Add individual column indexes
|
|
23
|
+
yield queryInterface.addIndex('analytics_summary', ['dimension_type'], {
|
|
24
|
+
name: 'idx_analytics_summary_dimension_type',
|
|
25
|
+
});
|
|
26
|
+
yield queryInterface.addIndex('analytics_summary', ['dimension_value'], {
|
|
27
|
+
name: 'idx_analytics_summary_dimension_value',
|
|
28
|
+
});
|
|
29
|
+
yield queryInterface.addIndex('analytics_summary', ['date_grain'], {
|
|
30
|
+
name: 'idx_analytics_summary_date_grain',
|
|
31
|
+
});
|
|
32
|
+
yield queryInterface.addIndex('analytics_summary', ['period_start'], {
|
|
33
|
+
name: 'idx_analytics_summary_period_start',
|
|
34
|
+
});
|
|
35
|
+
yield queryInterface.addIndex('analytics_summary', ['metric'], {
|
|
36
|
+
name: 'idx_analytics_summary_metric',
|
|
37
|
+
});
|
|
38
|
+
yield queryInterface.addIndex('analytics_summary', ['sub_dimension'], {
|
|
39
|
+
name: 'idx_analytics_summary_sub_dimension',
|
|
40
|
+
});
|
|
41
|
+
// Add partial indexes for specific dimension types and date grains
|
|
42
|
+
yield queryInterface.sequelize.query(`
|
|
43
|
+
CREATE INDEX IF NOT EXISTS idx_analytics_summary_hotel_daily
|
|
44
|
+
ON analytics_summary(dimension_type, dimension_value, date_grain, period_start)
|
|
45
|
+
WHERE dimension_type = 'hotel' AND date_grain = 'daily';
|
|
46
|
+
`);
|
|
47
|
+
yield queryInterface.sequelize.query(`
|
|
48
|
+
CREATE INDEX IF NOT EXISTS idx_analytics_summary_city_daily
|
|
49
|
+
ON analytics_summary(dimension_type, dimension_value, date_grain, period_start)
|
|
50
|
+
WHERE dimension_type = 'city' AND date_grain = 'daily';
|
|
51
|
+
`);
|
|
52
|
+
yield queryInterface.sequelize.query(`
|
|
53
|
+
CREATE INDEX IF NOT EXISTS idx_analytics_summary_country_daily
|
|
54
|
+
ON analytics_summary(dimension_type, dimension_value, date_grain, period_start)
|
|
55
|
+
WHERE dimension_type = 'country' AND date_grain = 'daily';
|
|
56
|
+
`);
|
|
57
|
+
console.log('Analytics summary indexes added successfully.');
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error('Error while adding analytics summary indexes:', error.message);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
exports.up = up;
|
|
65
|
+
const down = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
try {
|
|
67
|
+
// Remove individual column indexes
|
|
68
|
+
yield queryInterface.removeIndex('analytics_summary', 'idx_analytics_summary_dimension_type');
|
|
69
|
+
yield queryInterface.removeIndex('analytics_summary', 'idx_analytics_summary_dimension_value');
|
|
70
|
+
yield queryInterface.removeIndex('analytics_summary', 'idx_analytics_summary_date_grain');
|
|
71
|
+
yield queryInterface.removeIndex('analytics_summary', 'idx_analytics_summary_period_start');
|
|
72
|
+
yield queryInterface.removeIndex('analytics_summary', 'idx_analytics_summary_metric');
|
|
73
|
+
yield queryInterface.removeIndex('analytics_summary', 'idx_analytics_summary_sub_dimension');
|
|
74
|
+
// Remove partial indexes
|
|
75
|
+
yield queryInterface.sequelize.query(`
|
|
76
|
+
DROP INDEX IF EXISTS idx_analytics_summary_hotel_daily;
|
|
77
|
+
`);
|
|
78
|
+
yield queryInterface.sequelize.query(`
|
|
79
|
+
DROP INDEX IF EXISTS idx_analytics_summary_city_daily;
|
|
80
|
+
`);
|
|
81
|
+
yield queryInterface.sequelize.query(`
|
|
82
|
+
DROP INDEX IF EXISTS idx_analytics_summary_country_daily;
|
|
83
|
+
`);
|
|
84
|
+
console.log('Analytics summary indexes removed successfully.');
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.error('Error while removing analytics summary indexes:', error.message);
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
exports.down = down;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Model } from 'sequelize-typescript';
|
|
2
|
+
export declare class AnalyticsSummary extends Model<Partial<AnalyticsSummary>> {
|
|
3
|
+
dimension_type: string;
|
|
4
|
+
dimension_value: string;
|
|
5
|
+
sub_dimension?: string;
|
|
6
|
+
date_grain: string;
|
|
7
|
+
period_start: Date;
|
|
8
|
+
metric: string;
|
|
9
|
+
value: number;
|
|
10
|
+
created_at: Date;
|
|
11
|
+
updated_at: Date;
|
|
12
|
+
static upsertMetric(dimensionType: string, dimensionValue: string, subDimension: string | undefined, dateGrain: 'daily' | 'monthly', periodStart: Date, metric: string, value: number): Promise<[AnalyticsSummary, boolean | null]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.AnalyticsSummary = void 0;
|
|
22
|
+
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
23
|
+
let AnalyticsSummary = class AnalyticsSummary extends sequelize_typescript_1.Model {
|
|
24
|
+
// Helper methods for common queries
|
|
25
|
+
static upsertMetric(dimensionType, dimensionValue, subDimension, dateGrain, periodStart, metric, value) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return this.upsert({
|
|
28
|
+
dimension_type: dimensionType,
|
|
29
|
+
dimension_value: dimensionValue,
|
|
30
|
+
sub_dimension: subDimension,
|
|
31
|
+
date_grain: dateGrain,
|
|
32
|
+
period_start: periodStart,
|
|
33
|
+
metric,
|
|
34
|
+
value,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.AnalyticsSummary = AnalyticsSummary;
|
|
40
|
+
__decorate([
|
|
41
|
+
sequelize_typescript_1.PrimaryKey,
|
|
42
|
+
(0, sequelize_typescript_1.Column)({
|
|
43
|
+
type: sequelize_typescript_1.DataType.STRING,
|
|
44
|
+
allowNull: false,
|
|
45
|
+
comment: 'What is being measured (hotel, city, country)',
|
|
46
|
+
}),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], AnalyticsSummary.prototype, "dimension_type", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
sequelize_typescript_1.PrimaryKey,
|
|
51
|
+
(0, sequelize_typescript_1.Column)({
|
|
52
|
+
type: sequelize_typescript_1.DataType.STRING,
|
|
53
|
+
allowNull: false,
|
|
54
|
+
comment: 'ID or name (e.g. hotel_abc, Paris)',
|
|
55
|
+
}),
|
|
56
|
+
__metadata("design:type", String)
|
|
57
|
+
], AnalyticsSummary.prototype, "dimension_value", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, sequelize_typescript_1.Column)({
|
|
60
|
+
type: sequelize_typescript_1.DataType.STRING,
|
|
61
|
+
allowNull: true,
|
|
62
|
+
comment: 'Secondary group (e.g., France for city)',
|
|
63
|
+
}),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], AnalyticsSummary.prototype, "sub_dimension", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
sequelize_typescript_1.PrimaryKey,
|
|
68
|
+
(0, sequelize_typescript_1.Column)({
|
|
69
|
+
type: sequelize_typescript_1.DataType.STRING,
|
|
70
|
+
allowNull: false,
|
|
71
|
+
comment: 'Granularity (daily, monthly)',
|
|
72
|
+
}),
|
|
73
|
+
__metadata("design:type", String)
|
|
74
|
+
], AnalyticsSummary.prototype, "date_grain", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
sequelize_typescript_1.PrimaryKey,
|
|
77
|
+
(0, sequelize_typescript_1.Column)({
|
|
78
|
+
type: sequelize_typescript_1.DataType.DATEONLY,
|
|
79
|
+
allowNull: false,
|
|
80
|
+
}),
|
|
81
|
+
__metadata("design:type", Date)
|
|
82
|
+
], AnalyticsSummary.prototype, "period_start", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
sequelize_typescript_1.PrimaryKey,
|
|
85
|
+
(0, sequelize_typescript_1.Column)({
|
|
86
|
+
type: sequelize_typescript_1.DataType.STRING,
|
|
87
|
+
allowNull: false,
|
|
88
|
+
}),
|
|
89
|
+
__metadata("design:type", String)
|
|
90
|
+
], AnalyticsSummary.prototype, "metric", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, sequelize_typescript_1.Column)({
|
|
93
|
+
type: sequelize_typescript_1.DataType.DECIMAL(20, 2),
|
|
94
|
+
allowNull: false,
|
|
95
|
+
comment: 'Aggregated value (e.g., 122 bookings)',
|
|
96
|
+
}),
|
|
97
|
+
__metadata("design:type", Number)
|
|
98
|
+
], AnalyticsSummary.prototype, "value", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, sequelize_typescript_1.Column)({
|
|
101
|
+
type: sequelize_typescript_1.DataType.DATE,
|
|
102
|
+
allowNull: false,
|
|
103
|
+
defaultValue: sequelize_typescript_1.DataType.NOW,
|
|
104
|
+
}),
|
|
105
|
+
__metadata("design:type", Date)
|
|
106
|
+
], AnalyticsSummary.prototype, "created_at", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
(0, sequelize_typescript_1.Column)({
|
|
109
|
+
type: sequelize_typescript_1.DataType.DATE,
|
|
110
|
+
allowNull: false,
|
|
111
|
+
defaultValue: sequelize_typescript_1.DataType.NOW,
|
|
112
|
+
}),
|
|
113
|
+
__metadata("design:type", Date)
|
|
114
|
+
], AnalyticsSummary.prototype, "updated_at", void 0);
|
|
115
|
+
exports.AnalyticsSummary = AnalyticsSummary = __decorate([
|
|
116
|
+
(0, sequelize_typescript_1.Table)({
|
|
117
|
+
tableName: 'analytics_summary',
|
|
118
|
+
timestamps: true,
|
|
119
|
+
createdAt: 'created_at',
|
|
120
|
+
updatedAt: 'updated_at',
|
|
121
|
+
})
|
|
122
|
+
], AnalyticsSummary);
|
package/dist/models/Booking.d.ts
CHANGED
package/dist/models/Booking.js
CHANGED
|
@@ -182,7 +182,7 @@ __decorate([
|
|
|
182
182
|
allowNull: true,
|
|
183
183
|
}),
|
|
184
184
|
__metadata("design:type", String)
|
|
185
|
-
], Booking.prototype, "
|
|
185
|
+
], Booking.prototype, "source", void 0);
|
|
186
186
|
__decorate([
|
|
187
187
|
(0, sequelize_typescript_1.Column)({
|
|
188
188
|
type: sequelize_typescript_1.DataType.STRING,
|