dt-common-device 14.0.0 → 14.0.2
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/Integrations/twilio/twilio.service.d.ts +1 -2
- package/dist/Integrations/twilio/twilio.service.js +16 -20
- package/dist/alerts/alert.types.d.ts +5 -1
- package/dist/alerts/alert.types.js +4 -0
- package/dist/audit/AuditUtils.js +13 -0
- package/dist/audit/IAuditProperties.d.ts +7 -1
- package/dist/audit/IAuditProperties.js +1 -0
- package/dist/audit/PushAudit.d.ts +17 -1
- package/dist/audit/PushAudit.js +51 -9
- package/dist/config/config.d.ts +2 -1
- package/dist/config/config.js +14 -38
- package/dist/config/config.types.d.ts +3 -3
- package/dist/config/constants.js +1 -0
- package/dist/constants/ConnectionProviders.d.ts +4 -0
- package/dist/constants/ConnectionProviders.js +4 -0
- package/dist/constants/Event.d.ts +22 -0
- package/dist/constants/Event.js +22 -0
- package/dist/copilotQueue/utils/queueManager.js +2 -35
- package/dist/cronicle/Cronicle.service.d.ts +3 -3
- package/dist/cronicle/Cronicle.service.js +4 -3
- package/dist/cronicle/ICronicle.interface.d.ts +67 -0
- package/dist/db/db.js +32 -28
- package/dist/emails/emailService.js +23 -41
- package/dist/entities/admin/Admin.repository.d.ts +11 -2
- package/dist/entities/admin/Admin.repository.js +73 -2
- package/dist/entities/admin/Admin.service.d.ts +2 -1
- package/dist/entities/admin/Admin.service.js +12 -1
- package/dist/entities/admin/IAdmin.d.ts +40 -0
- package/dist/entities/connection/Connection.repository.d.ts +1 -0
- package/dist/entities/connection/Connection.repository.js +28 -1
- package/dist/entities/connection/Connection.service.d.ts +6 -0
- package/dist/entities/connection/Connection.service.js +15 -1
- package/dist/entities/connection/IConnection.d.ts +4 -1
- package/dist/entities/connection/IConnection.js +3 -0
- package/dist/entities/device/cloud/interfaces/IRawDevice.d.ts +3 -1
- package/dist/entities/device/cloud/interfaces/IRawDevice.js +2 -0
- package/dist/entities/device/local/interfaces/IDevice.d.ts +6 -0
- package/dist/entities/device/local/repository/Device.repository.d.ts +7 -0
- package/dist/entities/device/local/repository/Device.repository.js +11 -0
- package/dist/entities/device/local/services/Device.service.d.ts +8 -0
- package/dist/entities/device/local/services/Device.service.js +21 -0
- package/dist/entities/pms/IPms.d.ts +2 -1
- package/dist/entities/pms/IPms.js +1 -0
- package/dist/entities/pms/pms.service.js +22 -11
- package/dist/entities/property/Property.repository.d.ts +1 -0
- package/dist/entities/property/Property.repository.js +5 -0
- package/dist/entities/property/Property.service.d.ts +1 -0
- package/dist/entities/property/Property.service.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/issues/issue.types.d.ts +9 -2
- package/dist/issues/issue.types.js +8 -0
- package/dist/queue/entities/HybridHttpQueue.d.ts +0 -1
- package/dist/queue/entities/HybridHttpQueue.js +3 -5
- package/dist/queue/utils/queueUtils.d.ts +2 -2
- package/dist/queue/utils/queueUtils.js +16 -25
- package/dist/queue/utils/rateLimit.utils.js +19 -1
- package/dist/utils/http.utils.d.ts +3 -1
- package/dist/utils/http.utils.js +8 -0
- package/dist/webhookQueue/services/WebhookQueueService.js +3 -36
- package/package.json +3 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ISendSMSRequest } from "./interface/twilioInterface";
|
|
2
2
|
export declare class TwilioService {
|
|
3
|
-
private readonly
|
|
4
|
-
private readonly propertyRepository;
|
|
3
|
+
private readonly notificationService;
|
|
5
4
|
constructor();
|
|
6
5
|
sendSMS(data: ISendSMSRequest): Promise<any>;
|
|
7
6
|
}
|
|
@@ -76,10 +76,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
76
76
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
77
|
exports.TwilioService = void 0;
|
|
78
78
|
const typedi_1 = __importStar(require("typedi"));
|
|
79
|
-
const
|
|
80
|
-
const IConnection_1 = require("../../entities/connection/IConnection");
|
|
79
|
+
const Notification_service_1 = require("../../entities/notification/Notification.service");
|
|
81
80
|
const twilio_1 = __importDefault(require("twilio"));
|
|
82
|
-
const Property_repository_1 = require("../../entities/property/Property.repository");
|
|
83
81
|
let TwilioService = (() => {
|
|
84
82
|
let _classDecorators = [(0, typedi_1.Service)()];
|
|
85
83
|
let _classDescriptor;
|
|
@@ -87,36 +85,34 @@ let TwilioService = (() => {
|
|
|
87
85
|
let _classThis;
|
|
88
86
|
var TwilioService = _classThis = class {
|
|
89
87
|
constructor() {
|
|
90
|
-
this.
|
|
91
|
-
this.propertyRepository = typedi_1.default.get(Property_repository_1.PropertyRepository);
|
|
88
|
+
this.notificationService = typedi_1.default.get(Notification_service_1.NotificationService);
|
|
92
89
|
}
|
|
93
90
|
// -----------------------------
|
|
94
91
|
// Send SMS
|
|
95
92
|
// -----------------------------
|
|
96
93
|
async sendSMS(data) {
|
|
97
94
|
const { propertyId, message, toNumber } = data;
|
|
95
|
+
if (!propertyId) {
|
|
96
|
+
throw new Error("Property ID is required for sending SMS");
|
|
97
|
+
}
|
|
98
98
|
if (!toNumber) {
|
|
99
99
|
throw new Error("To number is required for sending SMS");
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
const response = await this.connectionRepository.queryConnections({
|
|
101
|
+
const connection = await this.notificationService.queryConnections({
|
|
103
102
|
propertyId,
|
|
104
|
-
connectionProvider:
|
|
103
|
+
connectionProvider: "twilio",
|
|
104
|
+
isEnable: true,
|
|
105
105
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const fromNumber = metaData?.fromNumber;
|
|
109
|
-
if (!fromNumber) {
|
|
110
|
-
throw new Error("From number not found");
|
|
106
|
+
if (!connection) {
|
|
107
|
+
throw new Error("Twilio connection not found for this property");
|
|
111
108
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
throw new Error("Property settings not found");
|
|
109
|
+
const { clientId, clientSecret, metaData } = connection;
|
|
110
|
+
if (!clientId || !clientSecret) {
|
|
111
|
+
throw new Error("Twilio credentials (clientId, clientSecret) not found");
|
|
116
112
|
}
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
119
|
-
throw new Error("
|
|
113
|
+
const fromNumber = metaData?.fromNumber;
|
|
114
|
+
if (!fromNumber || typeof fromNumber !== "string") {
|
|
115
|
+
throw new Error("From number not found");
|
|
120
116
|
}
|
|
121
117
|
//TODO: Need to do single tone pattern for the client
|
|
122
118
|
const client = (0, twilio_1.default)(clientId, clientSecret);
|
|
@@ -26,7 +26,9 @@ export declare enum AlertType {
|
|
|
26
26
|
DEVICE_ONLINE = "DEVICE_ONLINE",
|
|
27
27
|
ZONE_NOT_MAPPED_TO_ACCESS_GROUP = "ZONE_NOT_MAPPED_TO_ACCESS_GROUP",
|
|
28
28
|
INCORRECT_CODE_USED = "INCORRECT_CODE_USED",
|
|
29
|
-
RESERVATION_INACTIVE_ACCESSGROUP = "RESERVATION_INACTIVE_ACCESSGROUP"
|
|
29
|
+
RESERVATION_INACTIVE_ACCESSGROUP = "RESERVATION_INACTIVE_ACCESSGROUP",
|
|
30
|
+
ACCESS_GROUP_CREATED = "ACCESS_GROUP_CREATED",
|
|
31
|
+
ACCESS_GROUP_UPDATED = "ACCESS_GROUP_UPDATED"
|
|
30
32
|
}
|
|
31
33
|
export declare const AlertDescriptions: {
|
|
32
34
|
ACCOUNT_NEW_DEVICE: string;
|
|
@@ -44,6 +46,8 @@ export declare const AlertDescriptions: {
|
|
|
44
46
|
ZONE_NOT_MAPPED_TO_ACCESS_GROUP: string;
|
|
45
47
|
INCORRECT_CODE_USED: string;
|
|
46
48
|
RESERVATION_INACTIVE_ACCESSGROUP: string;
|
|
49
|
+
ACCESS_GROUP_CREATED: string;
|
|
50
|
+
ACCESS_GROUP_UPDATED: string;
|
|
47
51
|
};
|
|
48
52
|
export interface AlertDocument {
|
|
49
53
|
_id: string;
|
|
@@ -32,6 +32,8 @@ var AlertType;
|
|
|
32
32
|
AlertType["ZONE_NOT_MAPPED_TO_ACCESS_GROUP"] = "ZONE_NOT_MAPPED_TO_ACCESS_GROUP";
|
|
33
33
|
AlertType["INCORRECT_CODE_USED"] = "INCORRECT_CODE_USED";
|
|
34
34
|
AlertType["RESERVATION_INACTIVE_ACCESSGROUP"] = "RESERVATION_INACTIVE_ACCESSGROUP";
|
|
35
|
+
AlertType["ACCESS_GROUP_CREATED"] = "ACCESS_GROUP_CREATED";
|
|
36
|
+
AlertType["ACCESS_GROUP_UPDATED"] = "ACCESS_GROUP_UPDATED";
|
|
35
37
|
})(AlertType || (exports.AlertType = AlertType = {}));
|
|
36
38
|
exports.AlertDescriptions = {
|
|
37
39
|
[AlertType.ACCOUNT_NEW_DEVICE]: "The alert is raised when system detects a new device in the device cloud account.",
|
|
@@ -49,6 +51,8 @@ exports.AlertDescriptions = {
|
|
|
49
51
|
[AlertType.ZONE_NOT_MAPPED_TO_ACCESS_GROUP]: "The alert is raised when a zone is not mapped to an access group.",
|
|
50
52
|
[AlertType.INCORRECT_CODE_USED]: "The alert is raised when user uses the incorrect code on the device.",
|
|
51
53
|
[AlertType.RESERVATION_INACTIVE_ACCESSGROUP]: "The alert is raised when a reservation is received for an inactive access group.",
|
|
54
|
+
[AlertType.ACCESS_GROUP_CREATED]: "The alert is raised when an access group is created for the pms system.",
|
|
55
|
+
[AlertType.ACCESS_GROUP_UPDATED]: "The alert is raised when an access group is updated for the pms system."
|
|
52
56
|
};
|
|
53
57
|
// Re-export EntityType from issue.types.ts to avoid duplication
|
|
54
58
|
var issue_types_1 = require("../issues/issue.types");
|
package/dist/audit/AuditUtils.js
CHANGED
|
@@ -79,6 +79,7 @@ const typedi_1 = __importStar(require("typedi"));
|
|
|
79
79
|
const pms_1 = require("../entities/pms");
|
|
80
80
|
const admin_1 = require("../entities/admin");
|
|
81
81
|
const config_1 = require("../config/config");
|
|
82
|
+
const class_validator_1 = require("class-validator");
|
|
82
83
|
let AuditUtils = (() => {
|
|
83
84
|
let _classDecorators = [(0, typedi_1.Service)()];
|
|
84
85
|
let _classDescriptor;
|
|
@@ -223,6 +224,8 @@ let AuditUtils = (() => {
|
|
|
223
224
|
}
|
|
224
225
|
async getPropertyName(propertyId) {
|
|
225
226
|
try {
|
|
227
|
+
if (!(0, class_validator_1.isUUID)(propertyId))
|
|
228
|
+
return "property_not_found";
|
|
226
229
|
return await this.getCachedEntityData("property", propertyId, async () => {
|
|
227
230
|
const property = await typedi_1.default.get(property_1.LocalPropertyService).getProperty(propertyId);
|
|
228
231
|
return property?.name || "property_not_found";
|
|
@@ -254,6 +257,8 @@ let AuditUtils = (() => {
|
|
|
254
257
|
}
|
|
255
258
|
async getUserName(userId) {
|
|
256
259
|
try {
|
|
260
|
+
if (!(0, class_validator_1.isUUID)(userId))
|
|
261
|
+
return "user_not_found";
|
|
257
262
|
return await this.getCachedEntityData("user", userId, async () => {
|
|
258
263
|
const user = await typedi_1.default.get(admin_1.AdminService).getUser(userId);
|
|
259
264
|
if (!user)
|
|
@@ -268,6 +273,8 @@ let AuditUtils = (() => {
|
|
|
268
273
|
}
|
|
269
274
|
async getGuestName(guestId) {
|
|
270
275
|
try {
|
|
276
|
+
if (!(0, class_validator_1.isUUID)(guestId))
|
|
277
|
+
return "Guest User";
|
|
271
278
|
return await this.getCachedEntityData("guest", guestId, async () => {
|
|
272
279
|
const guest = await typedi_1.default.get(pms_1.PmsService).getGuest(guestId);
|
|
273
280
|
if (!guest)
|
|
@@ -296,6 +303,10 @@ let AuditUtils = (() => {
|
|
|
296
303
|
}
|
|
297
304
|
async getZoneName(zoneId) {
|
|
298
305
|
try {
|
|
306
|
+
if (zoneId === "triggered_externally")
|
|
307
|
+
return "zone_not_found";
|
|
308
|
+
if (!(0, class_validator_1.isUUID)(zoneId))
|
|
309
|
+
return "zone_not_found";
|
|
299
310
|
return await this.getCachedEntityData("zone", zoneId, async () => {
|
|
300
311
|
const zone = await typedi_1.default.get(admin_1.AdminService).getZone(zoneId);
|
|
301
312
|
if (!zone)
|
|
@@ -310,6 +321,8 @@ let AuditUtils = (() => {
|
|
|
310
321
|
}
|
|
311
322
|
async getAccessGroupName(accessGroupId) {
|
|
312
323
|
try {
|
|
324
|
+
if (!(0, class_validator_1.isUUID)(accessGroupId))
|
|
325
|
+
return "access_group_not_found";
|
|
313
326
|
return await this.getCachedEntityData("accessGroup", accessGroupId, async () => {
|
|
314
327
|
const accessGroup = await typedi_1.default.get(admin_1.AdminService).getAccessGroup(accessGroupId);
|
|
315
328
|
if (!accessGroup)
|
|
@@ -20,7 +20,8 @@ export declare enum Resource {
|
|
|
20
20
|
ACCESS_BLE = "accessBle",
|
|
21
21
|
EMERGENCY_CODE = "emergencyCode",
|
|
22
22
|
EMERGENCY_RFID = "emergencyRfid",
|
|
23
|
-
EMERGENCY_BLE = "emergencyBle"
|
|
23
|
+
EMERGENCY_BLE = "emergencyBle",
|
|
24
|
+
SERVER = "server"
|
|
24
25
|
}
|
|
25
26
|
export interface IAuditProperties {
|
|
26
27
|
resource: Resource;
|
|
@@ -45,3 +46,8 @@ export interface IAuditProperties {
|
|
|
45
46
|
eventData?: any;
|
|
46
47
|
[key: string]: any;
|
|
47
48
|
}
|
|
49
|
+
export type PartialAuditProperties = Omit<IAuditProperties, "resource" | "source" | "propertyId"> & {
|
|
50
|
+
resource?: Resource;
|
|
51
|
+
source?: Source;
|
|
52
|
+
propertyId?: string;
|
|
53
|
+
};
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import { IAuditProperties } from "./IAuditProperties";
|
|
1
|
+
import { IAuditProperties, PartialAuditProperties } from "./IAuditProperties";
|
|
2
|
+
/**
|
|
3
|
+
* Publishes an audit event. Failures are logged and swallowed so callers can
|
|
4
|
+
* fire-and-forget without causing unhandled promise rejections when the audit
|
|
5
|
+
* pipeline returns 5xx or times out (see e.g. Sentry DT-PMS-C).
|
|
6
|
+
* USE FOR PROPERTY LEVEL AUDITS
|
|
7
|
+
*/
|
|
2
8
|
export declare function pushAudit(data: {
|
|
3
9
|
auditType: string;
|
|
4
10
|
auditData: IAuditProperties;
|
|
5
11
|
}): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Publishes an audit event. Failures are logged and swallowed so callers can
|
|
14
|
+
* fire-and-forget without causing unhandled promise rejections when the audit
|
|
15
|
+
* pipeline returns 5xx or times out (see e.g. Sentry DT-PMS-C).
|
|
16
|
+
* USE FOR SYSTEM LEVEL AUDITS (If Property ID is not available)
|
|
17
|
+
*/
|
|
18
|
+
export declare function pushSystemAudit(data: {
|
|
19
|
+
auditType: string;
|
|
20
|
+
auditData: PartialAuditProperties;
|
|
21
|
+
}): Promise<void>;
|
package/dist/audit/PushAudit.js
CHANGED
|
@@ -4,17 +4,59 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.pushAudit = pushAudit;
|
|
7
|
+
exports.pushSystemAudit = pushSystemAudit;
|
|
7
8
|
const dt_audit_library_1 = require("dt-audit-library");
|
|
9
|
+
const config_1 = require("../config/config");
|
|
8
10
|
const AuditUtils_1 = require("./AuditUtils");
|
|
9
11
|
const typedi_1 = __importDefault(require("typedi"));
|
|
12
|
+
/**
|
|
13
|
+
* Publishes an audit event. Failures are logged and swallowed so callers can
|
|
14
|
+
* fire-and-forget without causing unhandled promise rejections when the audit
|
|
15
|
+
* pipeline returns 5xx or times out (see e.g. Sentry DT-PMS-C).
|
|
16
|
+
* USE FOR PROPERTY LEVEL AUDITS
|
|
17
|
+
*/
|
|
10
18
|
async function pushAudit(data) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
try {
|
|
20
|
+
const audit = await typedi_1.default.get(AuditUtils_1.AuditUtils).buildAuditProperties(data.auditData);
|
|
21
|
+
await (0, dt_audit_library_1.publishAudit)({
|
|
22
|
+
eventType: data.auditType,
|
|
23
|
+
properties: {
|
|
24
|
+
...audit,
|
|
25
|
+
timestamp: new Date().toISOString(),
|
|
26
|
+
env_type: process.env.NODE_ENV,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
const status = err?.response?.status;
|
|
32
|
+
const code = err?.code;
|
|
33
|
+
(0, config_1.getLogger)().error(`pushAudit failed for ${data.auditType}: ${err?.message ?? err}`, status != null || code != null
|
|
34
|
+
? { auditType: data.auditType, status, code }
|
|
35
|
+
: { auditType: data.auditType });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Publishes an audit event. Failures are logged and swallowed so callers can
|
|
40
|
+
* fire-and-forget without causing unhandled promise rejections when the audit
|
|
41
|
+
* pipeline returns 5xx or times out (see e.g. Sentry DT-PMS-C).
|
|
42
|
+
* USE FOR SYSTEM LEVEL AUDITS (If Property ID is not available)
|
|
43
|
+
*/
|
|
44
|
+
async function pushSystemAudit(data) {
|
|
45
|
+
try {
|
|
46
|
+
await (0, dt_audit_library_1.publishAudit)({
|
|
47
|
+
eventType: data.auditType,
|
|
48
|
+
properties: {
|
|
49
|
+
...data.auditData,
|
|
50
|
+
timestamp: new Date().toISOString(),
|
|
51
|
+
env_type: process.env.NODE_ENV,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
const status = err?.response?.status;
|
|
57
|
+
const code = err?.code;
|
|
58
|
+
(0, config_1.getLogger)().error(`pushSystemAudit failed for ${data.auditType}: ${err?.message ?? err}`, status != null || code != null
|
|
59
|
+
? { auditType: data.auditType, status, code }
|
|
60
|
+
: { auditType: data.auditType });
|
|
61
|
+
}
|
|
20
62
|
}
|
package/dist/config/config.d.ts
CHANGED
|
@@ -5,13 +5,14 @@ export declare function getConfig(): IConfig;
|
|
|
5
5
|
export declare function getDeviceServiceUrl(): string;
|
|
6
6
|
export declare function getAdminServiceUrl(): string;
|
|
7
7
|
export declare function getMonitoringServiceUrl(): string;
|
|
8
|
+
export declare function getNotificationServiceUrl(): string;
|
|
8
9
|
export declare function getSqsQueueUrl(): string;
|
|
9
10
|
export declare function getReservationSqsQueueUrl(): string;
|
|
10
11
|
export declare function getHeartbeatSqsQueueUrl(): string;
|
|
11
12
|
export declare function getIssueSqsQueueUrl(): string;
|
|
12
13
|
export declare function getEventSubscription(): InternalEventSubscription | null;
|
|
13
14
|
export declare function checkRequiredEnv(requiredEnvs: string[]): void;
|
|
14
|
-
export declare function ensureAuditInitialized(): void
|
|
15
|
+
export declare function ensureAuditInitialized(): Promise<void>;
|
|
15
16
|
export declare function getLogger(): ILogger;
|
|
16
17
|
/**
|
|
17
18
|
* Returns the PostgreSQL DB URI from environment variables.
|
package/dist/config/config.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -41,6 +8,7 @@ exports.getConfig = getConfig;
|
|
|
41
8
|
exports.getDeviceServiceUrl = getDeviceServiceUrl;
|
|
42
9
|
exports.getAdminServiceUrl = getAdminServiceUrl;
|
|
43
10
|
exports.getMonitoringServiceUrl = getMonitoringServiceUrl;
|
|
11
|
+
exports.getNotificationServiceUrl = getNotificationServiceUrl;
|
|
44
12
|
exports.getSqsQueueUrl = getSqsQueueUrl;
|
|
45
13
|
exports.getReservationSqsQueueUrl = getReservationSqsQueueUrl;
|
|
46
14
|
exports.getHeartbeatSqsQueueUrl = getHeartbeatSqsQueueUrl;
|
|
@@ -62,6 +30,7 @@ const db_1 = require("../db/db");
|
|
|
62
30
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
63
31
|
const events_1 = require("../events");
|
|
64
32
|
const constants_1 = require("./constants");
|
|
33
|
+
const notificationQueue_1 = require("../notificationQueue");
|
|
65
34
|
dotenv_1.default.config();
|
|
66
35
|
let config = null;
|
|
67
36
|
let auditInitialized = false;
|
|
@@ -134,7 +103,7 @@ async function initialize(cfg) {
|
|
|
134
103
|
}
|
|
135
104
|
}
|
|
136
105
|
// Initialize audit
|
|
137
|
-
ensureAuditInitialized();
|
|
106
|
+
await ensureAuditInitialized();
|
|
138
107
|
cfg.LOGGER.info("dt-common-device: Initialization completed successfully");
|
|
139
108
|
}
|
|
140
109
|
async function validateInternalEventHandler(cfg) {
|
|
@@ -194,6 +163,14 @@ function getMonitoringServiceUrl() {
|
|
|
194
163
|
}
|
|
195
164
|
return monitoringServiceUrl;
|
|
196
165
|
}
|
|
166
|
+
function getNotificationServiceUrl() {
|
|
167
|
+
const notificationServiceUrl = process.env.NOTIFICATION_SERVICE;
|
|
168
|
+
if (!notificationServiceUrl) {
|
|
169
|
+
getConfig().LOGGER.error("NOTIFICATION_SERVICE must be set in environment variables");
|
|
170
|
+
throw new Error("dt-common-device: NOTIFICATION_SERVICE must be set in environment variables");
|
|
171
|
+
}
|
|
172
|
+
return notificationServiceUrl;
|
|
173
|
+
}
|
|
197
174
|
function getSqsQueueUrl() {
|
|
198
175
|
if (constants_1.CONFIG_KEYS[sourceKey].env.includes("AWS_SQS_URL")) {
|
|
199
176
|
const sqsQueueUrl = process.env.AWS_SQS_URL;
|
|
@@ -247,7 +224,7 @@ function checkRequiredEnv(requiredEnvs) {
|
|
|
247
224
|
throw new Error(`Missing required environment variables: ${missing.join(", ")}`);
|
|
248
225
|
}
|
|
249
226
|
}
|
|
250
|
-
function ensureAuditInitialized() {
|
|
227
|
+
async function ensureAuditInitialized() {
|
|
251
228
|
if (auditInitialized)
|
|
252
229
|
return;
|
|
253
230
|
// const apiKey = process.env.POSTHOG_API_KEY;
|
|
@@ -260,7 +237,7 @@ function ensureAuditInitialized() {
|
|
|
260
237
|
getConfig().LOGGER.error("CLICKHOUSE_HOST, CLICKHOUSE_DATABASE, CLICKHOUSE_USERNAME, CLICKHOUSE_PASSWORD must be set in environment variables");
|
|
261
238
|
throw new Error("dt-common-device: CLICKHOUSE_HOST, CLICKHOUSE_DATABASE, CLICKHOUSE_USERNAME, CLICKHOUSE_PASSWORD must be set in environment variables");
|
|
262
239
|
}
|
|
263
|
-
(0, dt_audit_library_1.initializeAudit)({
|
|
240
|
+
await (0, dt_audit_library_1.initializeAudit)({
|
|
264
241
|
host,
|
|
265
242
|
database,
|
|
266
243
|
username,
|
|
@@ -352,8 +329,7 @@ async function shutdown() {
|
|
|
352
329
|
}
|
|
353
330
|
// Close notification queue connections
|
|
354
331
|
try {
|
|
355
|
-
|
|
356
|
-
await closeNotificationQueue();
|
|
332
|
+
await (0, notificationQueue_1.closeNotificationQueue)();
|
|
357
333
|
}
|
|
358
334
|
catch (error) {
|
|
359
335
|
getConfig().LOGGER.error("Failed to close notification queue", { error });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IInternalEvent } from "../events/interfaces/IInternalEvent";
|
|
2
2
|
export interface ILogger {
|
|
3
|
-
info(
|
|
4
|
-
warn(
|
|
5
|
-
error(
|
|
3
|
+
info(...args: any[]): void;
|
|
4
|
+
warn(...args: any[]): void;
|
|
5
|
+
error(...args: any[]): void;
|
|
6
6
|
}
|
|
7
7
|
type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE" | "REMOTE_SERVICE" | "SCHEDULE_SERVICE" | "MIGRATION" | "OPERATION_NODE_SERVICE" | "NOTIFICATION_SERVICE";
|
|
8
8
|
export type IConfig = {
|
package/dist/config/constants.js
CHANGED
|
@@ -2,6 +2,7 @@ export declare const CONNECTION_PROVIDERS: {
|
|
|
2
2
|
readonly DEVICETHREAD: "Devicethread";
|
|
3
3
|
readonly CLOUDBEDS: "Cloudbeds";
|
|
4
4
|
readonly STAYNTOUCH: "Stayntouch";
|
|
5
|
+
readonly INFOR: "Infor";
|
|
5
6
|
readonly HOTELKEY: "Hotelkey";
|
|
6
7
|
readonly YANOLJA: "Yanolja";
|
|
7
8
|
readonly SMOOBU: "Smoobu";
|
|
@@ -22,4 +23,7 @@ export declare const CONNECTION_PROVIDERS: {
|
|
|
22
23
|
readonly SIFELY: "Sifely";
|
|
23
24
|
readonly CHECKFRONT: "Checkfront";
|
|
24
25
|
readonly TWILIO: "Twilio";
|
|
26
|
+
readonly DAIKIN: "Daikin";
|
|
27
|
+
readonly HONEYWELL: "HoneyWell";
|
|
28
|
+
readonly ULTRALOCK: "UltraLock";
|
|
25
29
|
};
|
|
@@ -6,6 +6,7 @@ exports.CONNECTION_PROVIDERS = {
|
|
|
6
6
|
// PMS
|
|
7
7
|
CLOUDBEDS: "Cloudbeds",
|
|
8
8
|
STAYNTOUCH: "Stayntouch",
|
|
9
|
+
INFOR: "Infor",
|
|
9
10
|
HOTELKEY: "Hotelkey",
|
|
10
11
|
YANOLJA: "Yanolja",
|
|
11
12
|
SMOOBU: "Smoobu",
|
|
@@ -28,4 +29,7 @@ exports.CONNECTION_PROVIDERS = {
|
|
|
28
29
|
SIFELY: "Sifely",
|
|
29
30
|
CHECKFRONT: "Checkfront",
|
|
30
31
|
TWILIO: "Twilio",
|
|
32
|
+
DAIKIN: "Daikin",
|
|
33
|
+
HONEYWELL: "HoneyWell",
|
|
34
|
+
ULTRALOCK: "UltraLock",
|
|
31
35
|
};
|
|
@@ -73,6 +73,10 @@ export declare const DT_EVENT_TYPES: {
|
|
|
73
73
|
UNPROCESSED: string;
|
|
74
74
|
UNHANDLED: string;
|
|
75
75
|
};
|
|
76
|
+
MAINTENANCE_MODE: {
|
|
77
|
+
ENABLED: string;
|
|
78
|
+
DISABLED: string;
|
|
79
|
+
};
|
|
76
80
|
};
|
|
77
81
|
CONNECTION: {
|
|
78
82
|
CREATE: {
|
|
@@ -140,6 +144,15 @@ export declare const DT_EVENT_TYPES: {
|
|
|
140
144
|
SUCCESS: string;
|
|
141
145
|
FAILED: string;
|
|
142
146
|
};
|
|
147
|
+
MAINTENANCE_MODE: {
|
|
148
|
+
ENABLED: string;
|
|
149
|
+
DISABLED: string;
|
|
150
|
+
};
|
|
151
|
+
BULK_DELETE: {
|
|
152
|
+
ATTEMPT: string;
|
|
153
|
+
SUCCESS: string;
|
|
154
|
+
FAILED: string;
|
|
155
|
+
};
|
|
143
156
|
};
|
|
144
157
|
ZONE: {
|
|
145
158
|
CREATE: {
|
|
@@ -157,6 +170,15 @@ export declare const DT_EVENT_TYPES: {
|
|
|
157
170
|
SUCCESS: string;
|
|
158
171
|
FAILED: string;
|
|
159
172
|
};
|
|
173
|
+
MAINTENANCE_MODE: {
|
|
174
|
+
ENABLED: string;
|
|
175
|
+
DISABLED: string;
|
|
176
|
+
};
|
|
177
|
+
BULK_DELETE: {
|
|
178
|
+
ATTEMPT: string;
|
|
179
|
+
SUCCESS: string;
|
|
180
|
+
FAILED: string;
|
|
181
|
+
};
|
|
160
182
|
};
|
|
161
183
|
ISSUE: {
|
|
162
184
|
CREATE: {
|
package/dist/constants/Event.js
CHANGED
|
@@ -76,6 +76,10 @@ exports.DT_EVENT_TYPES = {
|
|
|
76
76
|
UNPROCESSED: "device.webhook.unprocessed",
|
|
77
77
|
UNHANDLED: "device.webhook.unhandled",
|
|
78
78
|
},
|
|
79
|
+
MAINTENANCE_MODE: {
|
|
80
|
+
ENABLED: "device.maintenance_mode.enabled",
|
|
81
|
+
DISABLED: "device.maintenance_mode.disabled",
|
|
82
|
+
},
|
|
79
83
|
},
|
|
80
84
|
CONNECTION: {
|
|
81
85
|
CREATE: {
|
|
@@ -143,6 +147,15 @@ exports.DT_EVENT_TYPES = {
|
|
|
143
147
|
SUCCESS: "accessgroup.delete.success",
|
|
144
148
|
FAILED: "accessgroup.delete.failed",
|
|
145
149
|
},
|
|
150
|
+
MAINTENANCE_MODE: {
|
|
151
|
+
ENABLED: "access_group.maintenance_mode.enabled",
|
|
152
|
+
DISABLED: "access_group.maintenance_mode.disabled",
|
|
153
|
+
},
|
|
154
|
+
BULK_DELETE: {
|
|
155
|
+
ATTEMPT: "accessgroup.bulk_delete.attempt",
|
|
156
|
+
SUCCESS: "accessgroup.bulk_delete.success",
|
|
157
|
+
FAILED: "accessgroup.bulk_delete.failed",
|
|
158
|
+
},
|
|
146
159
|
},
|
|
147
160
|
ZONE: {
|
|
148
161
|
CREATE: {
|
|
@@ -160,6 +173,15 @@ exports.DT_EVENT_TYPES = {
|
|
|
160
173
|
SUCCESS: "zone.delete.success",
|
|
161
174
|
FAILED: "zone.delete.failed",
|
|
162
175
|
},
|
|
176
|
+
MAINTENANCE_MODE: {
|
|
177
|
+
ENABLED: "zone.maintenance_mode.enabled",
|
|
178
|
+
DISABLED: "zone.maintenance_mode.disabled",
|
|
179
|
+
},
|
|
180
|
+
BULK_DELETE: {
|
|
181
|
+
ATTEMPT: "zone.bulk_delete.attempt",
|
|
182
|
+
SUCCESS: "zone.bulk_delete.success",
|
|
183
|
+
FAILED: "zone.bulk_delete.failed",
|
|
184
|
+
},
|
|
163
185
|
},
|
|
164
186
|
ISSUE: {
|
|
165
187
|
CREATE: {
|
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.QueueManager = void 0;
|
|
37
4
|
const redis_1 = require("../../db/redis");
|
|
@@ -44,7 +11,7 @@ class QueueManager {
|
|
|
44
11
|
if (queues.has(queueKey)) {
|
|
45
12
|
return queues.get(queueKey);
|
|
46
13
|
}
|
|
47
|
-
const { Queue } = await
|
|
14
|
+
const { Queue } = await import("bullmq");
|
|
48
15
|
const queue = new Queue(queueKey, {
|
|
49
16
|
connection: (0, redis_1.getRedisClient)(),
|
|
50
17
|
});
|
|
@@ -58,7 +25,7 @@ class QueueManager {
|
|
|
58
25
|
if (workers.has(queueKey)) {
|
|
59
26
|
return workers.get(queueKey);
|
|
60
27
|
}
|
|
61
|
-
const { Worker } = await
|
|
28
|
+
const { Worker } = await import("bullmq");
|
|
62
29
|
const worker = new Worker(queueKey, processor, {
|
|
63
30
|
connection: (0, redis_1.getRedisClient)(),
|
|
64
31
|
concurrency: 1, // Process one job at a time for FIFO ordering
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ICronicle } from "./ICronicle.interface";
|
|
1
|
+
import { ICronicle, ListSchedules } from "./ICronicle.interface";
|
|
2
2
|
export declare class CronicleService {
|
|
3
3
|
private readonly cronicleEndpoint;
|
|
4
4
|
private readonly cronicleApiKey;
|
|
5
5
|
constructor();
|
|
6
6
|
registerJob(payload: ICronicle): Promise<void>;
|
|
7
|
-
updateJob(payload: ICronicle): Promise<
|
|
7
|
+
updateJob(payload: ICronicle): Promise<any>;
|
|
8
8
|
getJob(jobId: string): Promise<any>;
|
|
9
9
|
getSchedules(filter: {
|
|
10
10
|
offset: number;
|
|
11
11
|
limit: number;
|
|
12
|
-
}): Promise<
|
|
12
|
+
}): Promise<ListSchedules | null>;
|
|
13
13
|
deleteJob(jobId: string): Promise<void>;
|
|
14
14
|
}
|
|
@@ -67,7 +67,7 @@ class CronicleService {
|
|
|
67
67
|
croniclePayload.title = name;
|
|
68
68
|
if (timezone)
|
|
69
69
|
croniclePayload.timeZone = timezone;
|
|
70
|
-
if (enabled)
|
|
70
|
+
if (enabled !== undefined)
|
|
71
71
|
croniclePayload.enabled = enabled ? 1 : 0;
|
|
72
72
|
if (target)
|
|
73
73
|
croniclePayload.target = target;
|
|
@@ -89,7 +89,8 @@ class CronicleService {
|
|
|
89
89
|
max_children: 1,
|
|
90
90
|
api_key: this.cronicleApiKey,
|
|
91
91
|
};
|
|
92
|
-
await axios_1.default.post(`${this.cronicleEndpoint}/update_event/v1`, payload);
|
|
92
|
+
const result = await axios_1.default.post(`${this.cronicleEndpoint}/update_event/v1`, payload);
|
|
93
|
+
return result.data;
|
|
93
94
|
}
|
|
94
95
|
catch (error) {
|
|
95
96
|
(0, config_1.getConfig)().LOGGER.error(`Failed to update Cronicle job: ${error.message}`);
|
|
@@ -119,7 +120,7 @@ class CronicleService {
|
|
|
119
120
|
}
|
|
120
121
|
catch (error) {
|
|
121
122
|
(0, config_1.getConfig)().LOGGER.error(`Failed to get schedules: ${error.message}`);
|
|
122
|
-
return;
|
|
123
|
+
return null;
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
async deleteJob(jobId) {
|