@vibe-flats/booking-engine-common-server 1.0.145 → 1.0.148
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/build/index.d.ts +2 -0
- package/build/index.js +4 -0
- package/build/src/models/channels.d.ts +2 -0
- package/build/src/models/channels.js +9 -0
- package/build/src/models/units.d.ts +1 -0
- package/build/src/models/units.js +2 -1
- package/build/src/utils/channel-cache.d.ts +4 -0
- package/build/src/utils/channel-cache.js +29 -0
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export * from './src/utils/vibe-price';
|
|
|
4
4
|
export * from './src/utils/monthly-diff';
|
|
5
5
|
export * from './src/utils/purge-unit-cache';
|
|
6
6
|
export * from './src/utils/cache';
|
|
7
|
+
export type { ChannelDocument } from './src/models/channels';
|
|
8
|
+
export { getChannel, DIRECT_CHANNEL_PUBLIC_ID } from './src/utils/channel-cache';
|
package/build/index.js
CHANGED
|
@@ -14,9 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DIRECT_CHANNEL_PUBLIC_ID = exports.getChannel = void 0;
|
|
17
18
|
__exportStar(require("./src/units-models"), exports);
|
|
18
19
|
__exportStar(require("./src/config/app"), exports);
|
|
19
20
|
__exportStar(require("./src/utils/vibe-price"), exports);
|
|
20
21
|
__exportStar(require("./src/utils/monthly-diff"), exports);
|
|
21
22
|
__exportStar(require("./src/utils/purge-unit-cache"), exports);
|
|
22
23
|
__exportStar(require("./src/utils/cache"), exports);
|
|
24
|
+
var channel_cache_1 = require("./src/utils/channel-cache");
|
|
25
|
+
Object.defineProperty(exports, "getChannel", { enumerable: true, get: function () { return channel_cache_1.getChannel; } });
|
|
26
|
+
Object.defineProperty(exports, "DIRECT_CHANNEL_PUBLIC_ID", { enumerable: true, get: function () { return channel_cache_1.DIRECT_CHANNEL_PUBLIC_ID; } });
|
|
@@ -8,6 +8,8 @@ export interface ChannelDocument extends mongoose.Document {
|
|
|
8
8
|
isDefault: boolean;
|
|
9
9
|
isExternal: boolean;
|
|
10
10
|
isActive: boolean;
|
|
11
|
+
excludeUtilities: boolean;
|
|
12
|
+
sourceOverride: string;
|
|
11
13
|
}
|
|
12
14
|
export declare const ChannelModel: (connection: mongoose.Connection) => mongoose.Model<ChannelDocument, {}, {}, {}, mongoose.Document<unknown, {}, ChannelDocument> & ChannelDocument & Required<{
|
|
13
15
|
_id: unknown;
|
|
@@ -42,6 +42,15 @@ const schema = new mongoose_1.default.Schema({
|
|
|
42
42
|
type: Boolean,
|
|
43
43
|
required: true,
|
|
44
44
|
default: true
|
|
45
|
+
},
|
|
46
|
+
excludeUtilities: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
required: false,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
sourceOverride: {
|
|
52
|
+
type: String,
|
|
53
|
+
required: false
|
|
45
54
|
}
|
|
46
55
|
}, {
|
|
47
56
|
timestamps: true
|
|
@@ -102,7 +102,8 @@ const schema = new mongoose_1.default.Schema({
|
|
|
102
102
|
airbnb: { type: String, required: false },
|
|
103
103
|
vrbo: { type: String, required: false },
|
|
104
104
|
booking: { type: String, required: false },
|
|
105
|
-
expedia: { type: String, required: false }
|
|
105
|
+
expedia: { type: String, required: false },
|
|
106
|
+
googleVacationRentals: { type: String, required: false }
|
|
106
107
|
}),
|
|
107
108
|
required: false,
|
|
108
109
|
_id: false
|
|
@@ -0,0 +1,29 @@
|
|
|
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.getChannel = exports.DIRECT_CHANNEL_PUBLIC_ID = void 0;
|
|
13
|
+
const units_models_1 = require("../units-models");
|
|
14
|
+
exports.DIRECT_CHANNEL_PUBLIC_ID = 'direct';
|
|
15
|
+
const CACHE_TTL_MS = 10 * 60 * 1000;
|
|
16
|
+
const cache = new Map();
|
|
17
|
+
const getChannel = (id, connection) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const cached = cache.get(id);
|
|
19
|
+
if (cached && Date.now() - cached.cachedAt < CACHE_TTL_MS) {
|
|
20
|
+
return cached.channel;
|
|
21
|
+
}
|
|
22
|
+
const { ChannelModel } = (0, units_models_1.unitsModels)(connection);
|
|
23
|
+
const channel = yield ChannelModel.findOne({
|
|
24
|
+
$or: [{ publicId: id }, { name: id }, { guestyId: id }]
|
|
25
|
+
});
|
|
26
|
+
cache.set(id, { channel, cachedAt: Date.now() });
|
|
27
|
+
return channel;
|
|
28
|
+
});
|
|
29
|
+
exports.getChannel = getChannel;
|