dt-common-device 13.4.16 → 13.5.0
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/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,8 @@ let AuditUtils = (() => {
|
|
|
296
303
|
}
|
|
297
304
|
async getZoneName(zoneId) {
|
|
298
305
|
try {
|
|
306
|
+
if (!(0, class_validator_1.isUUID)(zoneId))
|
|
307
|
+
return "zone_not_found";
|
|
299
308
|
return await this.getCachedEntityData("zone", zoneId, async () => {
|
|
300
309
|
const zone = await typedi_1.default.get(admin_1.AdminService).getZone(zoneId);
|
|
301
310
|
if (!zone)
|
|
@@ -310,6 +319,8 @@ let AuditUtils = (() => {
|
|
|
310
319
|
}
|
|
311
320
|
async getAccessGroupName(accessGroupId) {
|
|
312
321
|
try {
|
|
322
|
+
if (!(0, class_validator_1.isUUID)(accessGroupId))
|
|
323
|
+
return "access_group_not_found";
|
|
313
324
|
return await this.getCachedEntityData("accessGroup", accessGroupId, async () => {
|
|
314
325
|
const accessGroup = await typedi_1.default.get(admin_1.AdminService).getAccessGroup(accessGroupId);
|
|
315
326
|
if (!accessGroup)
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { IAuditProperties } 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
|
+
*/
|
|
2
7
|
export declare function pushAudit(data: {
|
|
3
8
|
auditType: string;
|
|
4
9
|
auditData: IAuditProperties;
|
package/dist/audit/PushAudit.js
CHANGED
|
@@ -5,16 +5,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.pushAudit = pushAudit;
|
|
7
7
|
const dt_audit_library_1 = require("dt-audit-library");
|
|
8
|
+
const config_1 = require("../config/config");
|
|
8
9
|
const AuditUtils_1 = require("./AuditUtils");
|
|
9
10
|
const typedi_1 = __importDefault(require("typedi"));
|
|
11
|
+
/**
|
|
12
|
+
* Publishes an audit event. Failures are logged and swallowed so callers can
|
|
13
|
+
* fire-and-forget without causing unhandled promise rejections when the audit
|
|
14
|
+
* pipeline returns 5xx or times out (see e.g. Sentry DT-PMS-C).
|
|
15
|
+
*/
|
|
10
16
|
async function pushAudit(data) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
try {
|
|
18
|
+
const audit = await typedi_1.default.get(AuditUtils_1.AuditUtils).buildAuditProperties(data.auditData);
|
|
19
|
+
await (0, dt_audit_library_1.publishAudit)({
|
|
20
|
+
eventType: data.auditType,
|
|
21
|
+
properties: {
|
|
22
|
+
...audit,
|
|
23
|
+
timestamp: new Date().toISOString(),
|
|
24
|
+
env_type: process.env.NODE_ENV,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
const status = err?.response?.status;
|
|
30
|
+
const code = err?.code;
|
|
31
|
+
(0, config_1.getLogger)().error(`pushAudit failed for ${data.auditType}: ${err?.message ?? err}`, status != null || code != null
|
|
32
|
+
? { auditType: data.auditType, status, code }
|
|
33
|
+
: { auditType: data.auditType });
|
|
34
|
+
}
|
|
20
35
|
}
|
|
@@ -49,7 +49,8 @@ export declare enum EntitySubType {
|
|
|
49
49
|
SALTOSPACE = "SALTOSPACE",
|
|
50
50
|
SCHLAGE = "SCHLAGE",
|
|
51
51
|
LOCKLY = "LOCKLY",
|
|
52
|
-
SIFELY = "SIFELY"
|
|
52
|
+
SIFELY = "SIFELY",
|
|
53
|
+
GEOCODING = "GEOCODING"
|
|
53
54
|
}
|
|
54
55
|
export declare enum IssueStatus {
|
|
55
56
|
PENDING = "PENDING",
|
|
@@ -85,7 +86,8 @@ export declare enum IssueType {
|
|
|
85
86
|
LOW_GUEST_CODES = "LOW_GUEST_CODES",
|
|
86
87
|
PMS_CODE_NOT_DELIVERED = "PMS_CODE_NOT_DELIVERED",
|
|
87
88
|
SCHEDULE_CODE_NOT_ASSIGNED = "SCHEDULE_CODE_NOT_ASSIGNED",
|
|
88
|
-
MISSING_ACCESS_GROUP = "MISSING_ACCESS_GROUP"
|
|
89
|
+
MISSING_ACCESS_GROUP = "MISSING_ACCESS_GROUP",
|
|
90
|
+
GEOCODING_FAILED = "GEOCODING_FAILED"
|
|
89
91
|
}
|
|
90
92
|
export declare const IssueDescriptions: {
|
|
91
93
|
BATTERY_LOW: string;
|
|
@@ -101,6 +103,7 @@ export declare const IssueDescriptions: {
|
|
|
101
103
|
PMS_CODE_NOT_DELIVERED: string;
|
|
102
104
|
SCHEDULE_CODE_NOT_ASSIGNED: string;
|
|
103
105
|
MISSING_ACCESS_GROUP: string;
|
|
106
|
+
GEOCODING_FAILED: string;
|
|
104
107
|
};
|
|
105
108
|
export interface IssueDocument {
|
|
106
109
|
id: string;
|
|
@@ -60,6 +60,8 @@ var EntitySubType;
|
|
|
60
60
|
EntitySubType["SCHLAGE"] = "SCHLAGE";
|
|
61
61
|
EntitySubType["LOCKLY"] = "LOCKLY";
|
|
62
62
|
EntitySubType["SIFELY"] = "SIFELY";
|
|
63
|
+
// OTHER
|
|
64
|
+
EntitySubType["GEOCODING"] = "GEOCODING";
|
|
63
65
|
})(EntitySubType || (exports.EntitySubType = EntitySubType = {}));
|
|
64
66
|
var IssueStatus;
|
|
65
67
|
(function (IssueStatus) {
|
|
@@ -92,6 +94,7 @@ var IssueType;
|
|
|
92
94
|
IssueType["PMS_CODE_NOT_DELIVERED"] = "PMS_CODE_NOT_DELIVERED";
|
|
93
95
|
IssueType["SCHEDULE_CODE_NOT_ASSIGNED"] = "SCHEDULE_CODE_NOT_ASSIGNED";
|
|
94
96
|
IssueType["MISSING_ACCESS_GROUP"] = "MISSING_ACCESS_GROUP";
|
|
97
|
+
IssueType["GEOCODING_FAILED"] = "GEOCODING_FAILED";
|
|
95
98
|
})(IssueType || (exports.IssueType = IssueType = {}));
|
|
96
99
|
exports.IssueDescriptions = {
|
|
97
100
|
[IssueType.BATTERY_LOW]: "The issue is raised when the battery level is lower than the threshold.",
|
|
@@ -107,4 +110,5 @@ exports.IssueDescriptions = {
|
|
|
107
110
|
[IssueType.PMS_CODE_NOT_DELIVERED]: "The issue is raised when the code is not delivered to the PMS system.",
|
|
108
111
|
[IssueType.SCHEDULE_CODE_NOT_ASSIGNED]: "The issue is raised when the code is not assigned to a schedule.",
|
|
109
112
|
[IssueType.MISSING_ACCESS_GROUP]: "The issue is raised when the access group is missing from devicethread but present in PMS system.",
|
|
113
|
+
[IssueType.GEOCODING_FAILED]: "The issue is raised when the system fails to retrieve latitude and longitude from the provided property address.",
|
|
110
114
|
};
|
package/package.json
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dt-common-device",
|
|
3
|
-
"version": "13.
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"types": "dist/index.d.ts",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist",
|
|
8
|
-
"README.md",
|
|
9
|
-
"LICENSE"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"patch": "npm login && npm version patch && npm run build && npm publish && git push",
|
|
14
|
-
"minor": "npm login && npm version minor && npm run build && npm publish && git push",
|
|
15
|
-
"major": "npm login && npm version major && npm run build && npm publish && git push",
|
|
16
|
-
"security:audit": "npm audit --audit-level=moderate",
|
|
17
|
-
"security:fix": "npm audit fix",
|
|
18
|
-
"security:check": "npm audit && npm outdated",
|
|
19
|
-
"type-check": "tsc --noEmit"
|
|
20
|
-
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"device",
|
|
23
|
-
"iot",
|
|
24
|
-
"smart-devices",
|
|
25
|
-
"device-management"
|
|
26
|
-
],
|
|
27
|
-
"author": "DeviceThread Team",
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"description": "A secure and robust device management library for IoT applications",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "https://github.com/devicethread/dt-common-device.git"
|
|
33
|
-
},
|
|
34
|
-
"engines": {
|
|
35
|
-
"node": ">=16.0.0",
|
|
36
|
-
"npm": ">=8.0.0"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@types/lodash": "^4.17.19",
|
|
40
|
-
"@types/node": "^20.0.0",
|
|
41
|
-
"@types/pg": "8.15.4",
|
|
42
|
-
"ts-node": "^10.9.2",
|
|
43
|
-
"typescript": "^5.8.3"
|
|
44
|
-
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"@aws-sdk/client-s3": "3.1015.0",
|
|
47
|
-
"@aws-sdk/client-ses": "3.1003.0",
|
|
48
|
-
"axios": "1.10.0",
|
|
49
|
-
"bullmq": "5.56.4",
|
|
50
|
-
"
|
|
51
|
-
"dt-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dt-common-device",
|
|
3
|
+
"version": "13.5.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"patch": "npm login && npm version patch && npm run build && npm publish && git push",
|
|
14
|
+
"minor": "npm login && npm version minor && npm run build && npm publish && git push",
|
|
15
|
+
"major": "npm login && npm version major && npm run build && npm publish && git push",
|
|
16
|
+
"security:audit": "npm audit --audit-level=moderate",
|
|
17
|
+
"security:fix": "npm audit fix",
|
|
18
|
+
"security:check": "npm audit && npm outdated",
|
|
19
|
+
"type-check": "tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"device",
|
|
23
|
+
"iot",
|
|
24
|
+
"smart-devices",
|
|
25
|
+
"device-management"
|
|
26
|
+
],
|
|
27
|
+
"author": "DeviceThread Team",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"description": "A secure and robust device management library for IoT applications",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/devicethread/dt-common-device.git"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=16.0.0",
|
|
36
|
+
"npm": ">=8.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/lodash": "^4.17.19",
|
|
40
|
+
"@types/node": "^20.0.0",
|
|
41
|
+
"@types/pg": "8.15.4",
|
|
42
|
+
"ts-node": "^10.9.2",
|
|
43
|
+
"typescript": "^5.8.3"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@aws-sdk/client-s3": "3.1015.0",
|
|
47
|
+
"@aws-sdk/client-ses": "3.1003.0",
|
|
48
|
+
"axios": "1.10.0",
|
|
49
|
+
"bullmq": "5.56.4",
|
|
50
|
+
"class-validator": "0.15.1",
|
|
51
|
+
"dt-audit-library": "1.7.1",
|
|
52
|
+
"dt-pub-sub": "^1.0.0",
|
|
53
|
+
"ioredis": "5.6.1",
|
|
54
|
+
"lodash": "^4.17.21",
|
|
55
|
+
"mongoose": "8.17.1",
|
|
56
|
+
"pg": "8.16.3",
|
|
57
|
+
"svix": "1.84.1",
|
|
58
|
+
"twilio": "5.12.2",
|
|
59
|
+
"typedi": "0.10.0"
|
|
60
|
+
}
|
|
61
|
+
}
|