whitelabel-db 1.7.0 → 1.8.1
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/libs/database.d.ts +11 -0
- package/dist/libs/database.js +12 -2
- package/dist/migrations/040-add-experience-booking-refund-data.d.ts +3 -0
- package/dist/migrations/040-add-experience-booking-refund-data.js +36 -0
- package/dist/models/ExperienceBooking.d.ts +2 -0
- package/dist/models/ExperienceBooking.js +15 -0
- package/package.json +1 -1
package/dist/libs/database.d.ts
CHANGED
|
@@ -4,5 +4,16 @@ export interface ConnectionDetails {
|
|
|
4
4
|
username: string;
|
|
5
5
|
password: string;
|
|
6
6
|
dbname: string;
|
|
7
|
+
/**
|
|
8
|
+
* Optional connection-pool overrides. Defaults (max 20 / acquire 30s) are
|
|
9
|
+
* sized for crawler bursts against the SSR path; callers can tune per env
|
|
10
|
+
* without another release (WL-126).
|
|
11
|
+
*/
|
|
12
|
+
pool?: {
|
|
13
|
+
max?: number;
|
|
14
|
+
min?: number;
|
|
15
|
+
acquire?: number;
|
|
16
|
+
idle?: number;
|
|
17
|
+
};
|
|
7
18
|
}
|
|
8
19
|
export declare const connect: (connectionDetails: ConnectionDetails) => Promise<Sequelize>;
|
package/dist/libs/database.js
CHANGED
|
@@ -44,7 +44,7 @@ const LoyaltyProgramTier_1 = require("../models/LoyaltyProgramTier");
|
|
|
44
44
|
const BookingLoyaltyRecord_1 = require("../models/BookingLoyaltyRecord");
|
|
45
45
|
const migration_1 = require("./migration");
|
|
46
46
|
const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
var _a;
|
|
47
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
48
48
|
const connection = new sequelize_typescript_1.Sequelize({
|
|
49
49
|
dialect: 'postgres',
|
|
50
50
|
host: connectionDetails.host,
|
|
@@ -52,6 +52,16 @@ const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, functio
|
|
|
52
52
|
password: connectionDetails.password,
|
|
53
53
|
database: connectionDetails.dbname,
|
|
54
54
|
logging: false,
|
|
55
|
+
// Connection pool. Without this Sequelize defaults to max 5, which the
|
|
56
|
+
// per-worker SSR path exhausts under crawler bursts -> acquire timeouts ->
|
|
57
|
+
// 5xx (WL-126). acquire (30s) is intentionally below the load balancer's
|
|
58
|
+
// idle timeout so callers return a controlled 503 before the LB emits 502.
|
|
59
|
+
pool: {
|
|
60
|
+
max: (_b = (_a = connectionDetails.pool) === null || _a === void 0 ? void 0 : _a.max) !== null && _b !== void 0 ? _b : 20,
|
|
61
|
+
min: (_d = (_c = connectionDetails.pool) === null || _c === void 0 ? void 0 : _c.min) !== null && _d !== void 0 ? _d : 2,
|
|
62
|
+
acquire: (_f = (_e = connectionDetails.pool) === null || _e === void 0 ? void 0 : _e.acquire) !== null && _f !== void 0 ? _f : 30000,
|
|
63
|
+
idle: (_h = (_g = connectionDetails.pool) === null || _g === void 0 ? void 0 : _g.idle) !== null && _h !== void 0 ? _h : 10000,
|
|
64
|
+
},
|
|
55
65
|
models: [
|
|
56
66
|
User_1.User,
|
|
57
67
|
Agency_1.Agency,
|
|
@@ -108,7 +118,7 @@ const connect = (connectionDetails) => __awaiter(void 0, void 0, void 0, functio
|
|
|
108
118
|
// a separate index on them will fail
|
|
109
119
|
const errorMessage = (syncError === null || syncError === void 0 ? void 0 : syncError.message) || '';
|
|
110
120
|
const errorSql = (syncError === null || syncError === void 0 ? void 0 : syncError.sql) || '';
|
|
111
|
-
const originalCode = ((
|
|
121
|
+
const originalCode = ((_j = syncError === null || syncError === void 0 ? void 0 : syncError.original) === null || _j === void 0 ? void 0 : _j.code) || '';
|
|
112
122
|
if ((errorMessage.includes('already exists') &&
|
|
113
123
|
errorSql.includes('CREATE INDEX')) ||
|
|
114
124
|
originalCode === '42P07' || // duplicate_table
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
const TABLE_NAME = 'experience_bookings';
|
|
15
|
+
const PROJECT_GUEST_INDEX = 'idx_experience_bookings_project_guest';
|
|
16
|
+
const up = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
yield queryInterface.addColumn(TABLE_NAME, 'liteApiCancelBookingData', {
|
|
18
|
+
type: sequelize_1.DataTypes.JSONB,
|
|
19
|
+
allowNull: false,
|
|
20
|
+
defaultValue: {},
|
|
21
|
+
});
|
|
22
|
+
yield queryInterface.addColumn(TABLE_NAME, 'lastCancellationDate', {
|
|
23
|
+
type: sequelize_1.DataTypes.DATE,
|
|
24
|
+
allowNull: true,
|
|
25
|
+
});
|
|
26
|
+
yield queryInterface.addIndex(TABLE_NAME, ['projectId', 'guestId'], {
|
|
27
|
+
name: PROJECT_GUEST_INDEX,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
exports.up = up;
|
|
31
|
+
const down = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
yield queryInterface.removeIndex(TABLE_NAME, PROJECT_GUEST_INDEX);
|
|
33
|
+
yield queryInterface.removeColumn(TABLE_NAME, 'lastCancellationDate');
|
|
34
|
+
yield queryInterface.removeColumn(TABLE_NAME, 'liteApiCancelBookingData');
|
|
35
|
+
});
|
|
36
|
+
exports.down = down;
|
|
@@ -18,7 +18,9 @@ export declare class ExperienceBooking extends Model<Partial<ExperienceBooking>>
|
|
|
18
18
|
paymentProvider?: string;
|
|
19
19
|
paymentMethod?: string;
|
|
20
20
|
refundStatus?: string;
|
|
21
|
+
liteApiCancelBookingData?: object;
|
|
21
22
|
cancelledAt?: Date;
|
|
23
|
+
lastCancellationDate?: Date;
|
|
22
24
|
contactEmail?: string;
|
|
23
25
|
guestId?: string;
|
|
24
26
|
guest?: Guest;
|
|
@@ -138,6 +138,14 @@ __decorate([
|
|
|
138
138
|
}),
|
|
139
139
|
__metadata("design:type", String)
|
|
140
140
|
], ExperienceBooking.prototype, "refundStatus", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
(0, sequelize_typescript_1.Column)({
|
|
143
|
+
type: sequelize_typescript_1.DataType.JSONB,
|
|
144
|
+
allowNull: false,
|
|
145
|
+
defaultValue: {},
|
|
146
|
+
}),
|
|
147
|
+
__metadata("design:type", Object)
|
|
148
|
+
], ExperienceBooking.prototype, "liteApiCancelBookingData", void 0);
|
|
141
149
|
__decorate([
|
|
142
150
|
(0, sequelize_typescript_1.Column)({
|
|
143
151
|
type: sequelize_typescript_1.DataType.DATE,
|
|
@@ -145,6 +153,13 @@ __decorate([
|
|
|
145
153
|
}),
|
|
146
154
|
__metadata("design:type", Date)
|
|
147
155
|
], ExperienceBooking.prototype, "cancelledAt", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
(0, sequelize_typescript_1.Column)({
|
|
158
|
+
type: sequelize_typescript_1.DataType.DATE,
|
|
159
|
+
allowNull: true,
|
|
160
|
+
}),
|
|
161
|
+
__metadata("design:type", Date)
|
|
162
|
+
], ExperienceBooking.prototype, "lastCancellationDate", void 0);
|
|
148
163
|
__decorate([
|
|
149
164
|
sequelize_typescript_1.Index,
|
|
150
165
|
(0, sequelize_typescript_1.Column)({
|