dt-common-device 4.0.11 → 5.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/alerts/Alert.service.d.ts +1 -1
- package/dist/audit/AuditUtils.d.ts +26 -2
- package/dist/audit/AuditUtils.js +255 -32
- package/dist/audit/IAuditProperties.d.ts +5 -1
- package/dist/audit/IAuditProperties.js +2 -0
- package/dist/config/config.d.ts +10 -3
- package/dist/config/config.js +120 -47
- package/dist/config/config.types.d.ts +1 -8
- package/dist/db/db.d.ts +2 -0
- package/dist/db/db.js +23 -1
- package/dist/events/BaseEventHandler.d.ts +3 -3
- package/dist/events/BaseEventHandler.js +1 -1
- package/dist/events/DeviceEventHandler.d.ts +1 -1
- package/dist/events/DeviceEventHandler.js +6 -3
- package/dist/events/EventHandler.d.ts +10 -9
- package/dist/events/EventHandler.js +50 -9
- package/dist/events/InternalEventSubscription.js +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +10 -8
- package/dist/issues/Issue.service.d.ts +1 -1
- package/dist/microservice/MicroServiceFactory.d.ts +1 -1
- package/dist/microservice/MicroServiceFactory.js +1 -1
- package/dist/queue/utils/rateLimit.utils.js +1 -1
- package/dist/utils/http.utils.d.ts +1 -2
- package/dist/utils/http.utils.js +5 -28
- package/package.json +1 -1
- package/dist/admin/Admin.repository.d.ts +0 -7
- package/dist/admin/Admin.repository.js +0 -182
- package/dist/admin/Admin.service.d.ts +0 -5
- package/dist/admin/Admin.service.js +0 -17
- package/dist/admin/index.d.ts +0 -1
- package/dist/admin/index.js +0 -17
- package/dist/audit/AuditProperties.d.ts +0 -16
- package/dist/audit/AuditProperties.js +0 -2
- package/dist/connection/Connection.repository.d.ts +0 -8
- package/dist/connection/Connection.repository.js +0 -92
- package/dist/connection/Connection.service.d.ts +0 -8
- package/dist/connection/Connection.service.js +0 -32
- package/dist/connection/IConnection.d.ts +0 -28
- package/dist/connection/IConnection.js +0 -16
- package/dist/connection/index.d.ts +0 -2
- package/dist/connection/index.js +0 -18
- package/dist/device/cloud/entities/CloudConnection.d.ts +0 -6
- package/dist/device/cloud/entities/CloudConnection.js +0 -6
- package/dist/device/cloud/entities/CloudDevice.d.ts +0 -16
- package/dist/device/cloud/entities/CloudDevice.js +0 -26
- package/dist/device/cloud/entities/CloudDeviceService.d.ts +0 -5
- package/dist/device/cloud/entities/CloudDeviceService.js +0 -9
- package/dist/device/cloud/entities/DeviceFactory.d.ts +0 -7
- package/dist/device/cloud/entities/DeviceFactory.js +0 -80
- package/dist/device/cloud/entities/index.d.ts +0 -3
- package/dist/device/cloud/entities/index.js +0 -19
- package/dist/device/cloud/interface.d.ts +0 -101
- package/dist/device/cloud/interface.js +0 -3
- package/dist/device/cloud/interfaces/ICloudConnection.d.ts +0 -5
- package/dist/device/cloud/interfaces/ICloudConnection.js +0 -2
- package/dist/device/cloud/interfaces/ICloudDevice.d.ts +0 -9
- package/dist/device/cloud/interfaces/ICloudDevice.js +0 -2
- package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +0 -4
- package/dist/device/cloud/interfaces/ICloudDeviceService.js +0 -2
- package/dist/device/cloud/interfaces/IConnectionService.d.ts +0 -7
- package/dist/device/cloud/interfaces/IConnectionService.js +0 -2
- package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +0 -7
- package/dist/device/cloud/interfaces/IDeviceConnectionService.js +0 -3
- package/dist/device/cloud/interfaces/IDeviceFactory.d.ts +0 -4
- package/dist/device/cloud/interfaces/IDeviceFactory.js +0 -2
- package/dist/device/cloud/interfaces/IDeviceService.d.ts +0 -8
- package/dist/device/cloud/interfaces/IDeviceService.js +0 -2
- package/dist/device/cloud/interfaces/IDevicesService.d.ts +0 -9
- package/dist/device/cloud/interfaces/IDevicesService.js +0 -2
- package/dist/device/cloud/interfaces/IHubService.d.ts +0 -5
- package/dist/device/cloud/interfaces/IHubService.js +0 -2
- package/dist/device/cloud/interfaces/IRawDataTransformer.d.ts +0 -4
- package/dist/device/cloud/interfaces/IRawDataTransformer.js +0 -2
- package/dist/device/cloud/interfaces/IRawDevice.d.ts +0 -17
- package/dist/device/cloud/interfaces/IRawDevice.js +0 -11
- package/dist/device/cloud/interfaces/index.d.ts +0 -5
- package/dist/device/cloud/interfaces/index.js +0 -21
- package/dist/device/cloud/services/CloudDevice.service.d.ts +0 -5
- package/dist/device/cloud/services/CloudDevice.service.js +0 -9
- package/dist/device/cloud/services/Connection.service.d.ts +0 -8
- package/dist/device/cloud/services/Connection.service.js +0 -6
- package/dist/device/cloud/services/Device.service.d.ts +0 -39
- package/dist/device/cloud/services/Device.service.js +0 -9
- package/dist/device/cloud/services/DeviceCloudService.d.ts +0 -42
- package/dist/device/cloud/services/DeviceCloudService.js +0 -59
- package/dist/device/cloud/services/DeviceHub.service.d.ts +0 -3
- package/dist/device/cloud/services/DeviceHub.service.js +0 -6
- package/dist/device/cloud/services/Hub.service.d.ts +0 -25
- package/dist/device/cloud/services/Hub.service.js +0 -9
- package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +0 -38
- package/dist/device/cloud/services/SmartThingsDeviceService.js +0 -52
- package/dist/device/cloud/services/index.d.ts +0 -2
- package/dist/device/cloud/services/index.js +0 -18
- package/dist/device/cloud/types.d.ts +0 -52
- package/dist/device/cloud/types.js +0 -15
- package/dist/device/index.d.ts +0 -4
- package/dist/device/index.js +0 -20
- package/dist/device/local/entities/AlertBuilder.d.ts +0 -87
- package/dist/device/local/entities/AlertBuilder.example.d.ts +0 -11
- package/dist/device/local/entities/AlertBuilder.example.js +0 -117
- package/dist/device/local/entities/AlertBuilder.js +0 -179
- package/dist/device/local/entities/IssueBuilder.d.ts +0 -109
- package/dist/device/local/entities/IssueBuilder.example.d.ts +0 -16
- package/dist/device/local/entities/IssueBuilder.example.js +0 -196
- package/dist/device/local/entities/IssueBuilder.js +0 -237
- package/dist/device/local/entities/index.d.ts +0 -2
- package/dist/device/local/entities/index.js +0 -7
- package/dist/device/local/events/EventHandler.d.ts +0 -11
- package/dist/device/local/events/EventHandler.js +0 -86
- package/dist/device/local/events/Events.d.ts +0 -54
- package/dist/device/local/events/Events.js +0 -57
- package/dist/device/local/events/index.d.ts +0 -2
- package/dist/device/local/events/index.js +0 -7
- package/dist/device/local/handler/EventHandler.d.ts +0 -7
- package/dist/device/local/handler/EventHandler.js +0 -44
- package/dist/device/local/interface.d.ts +0 -0
- package/dist/device/local/interface.js +0 -1
- package/dist/device/local/interfaces/IConnection.d.ts +0 -26
- package/dist/device/local/interfaces/IConnection.js +0 -14
- package/dist/device/local/interfaces/IDevice.d.ts +0 -68
- package/dist/device/local/interfaces/IDevice.js +0 -10
- package/dist/device/local/interfaces/IDtDevice.d.ts +0 -16
- package/dist/device/local/interfaces/IDtDevice.js +0 -2
- package/dist/device/local/interfaces/IHub.d.ts +0 -46
- package/dist/device/local/interfaces/IHub.js +0 -2
- package/dist/device/local/interfaces/IProperty.d.ts +0 -29
- package/dist/device/local/interfaces/IProperty.js +0 -2
- package/dist/device/local/interfaces/ISchedule.d.ts +0 -25
- package/dist/device/local/interfaces/ISchedule.js +0 -2
- package/dist/device/local/interfaces/index.d.ts +0 -3
- package/dist/device/local/interfaces/index.js +0 -19
- package/dist/device/local/models/Alert.model.d.ts +0 -28
- package/dist/device/local/models/Alert.model.js +0 -222
- package/dist/device/local/models/Issue.model.d.ts +0 -28
- package/dist/device/local/models/Issue.model.js +0 -260
- package/dist/device/local/repository/Alert.repository.d.ts +0 -106
- package/dist/device/local/repository/Alert.repository.js +0 -374
- package/dist/device/local/repository/Connection.repository.d.ts +0 -8
- package/dist/device/local/repository/Connection.repository.js +0 -92
- package/dist/device/local/repository/Device.repository.d.ts +0 -30
- package/dist/device/local/repository/Device.repository.js +0 -325
- package/dist/device/local/repository/Hub.repository.d.ts +0 -13
- package/dist/device/local/repository/Hub.repository.js +0 -139
- package/dist/device/local/repository/Issue.repository.d.ts +0 -113
- package/dist/device/local/repository/Issue.repository.js +0 -401
- package/dist/device/local/repository/Property.repository.d.ts +0 -8
- package/dist/device/local/repository/Property.repository.js +0 -95
- package/dist/device/local/repository/Schedule.repository.d.ts +0 -9
- package/dist/device/local/repository/Schedule.repository.js +0 -109
- package/dist/device/local/services/Alert.service.d.ts +0 -137
- package/dist/device/local/services/Alert.service.js +0 -475
- package/dist/device/local/services/AlertService.example.d.ts +0 -55
- package/dist/device/local/services/AlertService.example.js +0 -148
- package/dist/device/local/services/Connection.service.d.ts +0 -8
- package/dist/device/local/services/Connection.service.js +0 -32
- package/dist/device/local/services/Device.service.d.ts +0 -40
- package/dist/device/local/services/Device.service.js +0 -391
- package/dist/device/local/services/DeviceHub.service.d.ts +0 -11
- package/dist/device/local/services/DeviceHub.service.js +0 -40
- package/dist/device/local/services/Hub.service.d.ts +0 -12
- package/dist/device/local/services/Hub.service.js +0 -107
- package/dist/device/local/services/Issue.service.d.ts +0 -168
- package/dist/device/local/services/Issue.service.js +0 -642
- package/dist/device/local/services/IssueService.example.d.ts +0 -68
- package/dist/device/local/services/IssueService.example.js +0 -177
- package/dist/device/local/services/Property.service.d.ts +0 -8
- package/dist/device/local/services/Property.service.js +0 -36
- package/dist/device/local/services/Schedule.service.d.ts +0 -9
- package/dist/device/local/services/Schedule.service.js +0 -26
- package/dist/device/local/services/index.d.ts +0 -3
- package/dist/device/local/services/index.js +0 -19
- package/dist/pms/IPms.d.ts +0 -6
- package/dist/pms/IPms.js +0 -10
- package/dist/pms/index.d.ts +0 -1
- package/dist/pms/index.js +0 -17
- package/dist/property/IProperty.d.ts +0 -29
- package/dist/property/IProperty.js +0 -2
- package/dist/property/Property.repository.d.ts +0 -8
- package/dist/property/Property.repository.js +0 -109
- package/dist/property/Property.service.d.ts +0 -8
- package/dist/property/Property.service.js +0 -124
- package/dist/property/index.d.ts +0 -2
- package/dist/property/index.js +0 -18
- package/dist/queue/interfaces/IHttpRequestJob.d.ts +0 -9
- package/dist/queue/interfaces/IHttpRequestJob.js +0 -2
- package/dist/types/alert.types.d.ts +0 -57
- package/dist/types/alert.types.js +0 -22
- package/dist/types/config.types.d.ts +0 -19
- package/dist/types/config.types.js +0 -2
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.js +0 -19
- package/dist/types/issue.types.d.ts +0 -90
- package/dist/types/issue.types.js +0 -40
- package/dist/utils/http-utils.d.ts +0 -13
- package/dist/utils/http-utils.js +0 -117
package/dist/db/db.js
CHANGED
|
@@ -5,11 +5,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.connectDatabase = void 0;
|
|
7
7
|
exports.getPostgresClient = getPostgresClient;
|
|
8
|
+
exports.getAccessPostgresClient = getAccessPostgresClient;
|
|
9
|
+
exports.getPmsPostgresClient = getPmsPostgresClient;
|
|
8
10
|
const pg_1 = require("pg");
|
|
9
11
|
const config_1 = require("../config/config");
|
|
10
12
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
11
13
|
function getPostgresClient() {
|
|
12
|
-
const URI = (0, config_1.
|
|
14
|
+
const URI = (0, config_1.getAdminPostgresDbUri)();
|
|
15
|
+
let pool = null;
|
|
16
|
+
if (!pool) {
|
|
17
|
+
pool = new pg_1.Pool({
|
|
18
|
+
connectionString: URI,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return pool;
|
|
22
|
+
}
|
|
23
|
+
function getAccessPostgresClient() {
|
|
24
|
+
const URI = (0, config_1.getAccessPostgresDbUri)();
|
|
25
|
+
let pool = null;
|
|
26
|
+
if (!pool) {
|
|
27
|
+
pool = new pg_1.Pool({
|
|
28
|
+
connectionString: URI,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return pool;
|
|
32
|
+
}
|
|
33
|
+
function getPmsPostgresClient() {
|
|
34
|
+
const URI = (0, config_1.getPmsPostgresDbUri)();
|
|
13
35
|
let pool = null;
|
|
14
36
|
if (!pool) {
|
|
15
37
|
pool = new pg_1.Pool({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DeviceEvent } from "./interfaces/DeviceEvent";
|
|
2
2
|
import { IEventHandler } from "./interfaces/IEventHandler";
|
|
3
3
|
import { ILogger } from "../config/config.types";
|
|
4
|
-
import { LocalDeviceService } from "../device/local/services/Device.service";
|
|
5
|
-
import {
|
|
4
|
+
import { LocalDeviceService } from "../entities/device/local/services/Device.service";
|
|
5
|
+
import { IAuditProperties } from "../audit/IAuditProperties";
|
|
6
6
|
export declare abstract class BaseEventHandler implements IEventHandler {
|
|
7
7
|
protected readonly supportedEventTypes: string[];
|
|
8
8
|
protected readonly priority: number;
|
|
@@ -20,7 +20,7 @@ export declare abstract class BaseEventHandler implements IEventHandler {
|
|
|
20
20
|
* Handle multiple events - default implementation processes them sequentially
|
|
21
21
|
*/
|
|
22
22
|
handleEvents(events: DeviceEvent[]): Promise<void>;
|
|
23
|
-
onStateChange(deviceId: string, state: Record<string, any>, event: DeviceEvent, auditProperties:
|
|
23
|
+
onStateChange(deviceId: string, state: Record<string, any>, event: DeviceEvent, auditProperties: IAuditProperties): Promise<void>;
|
|
24
24
|
/**
|
|
25
25
|
* Check if this handler can process the given event type
|
|
26
26
|
*/
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.BaseEventHandler = void 0;
|
|
7
7
|
const config_1 = require("../config/config");
|
|
8
|
-
const Device_service_1 = require("../device/local/services/Device.service");
|
|
8
|
+
const Device_service_1 = require("../entities/device/local/services/Device.service");
|
|
9
9
|
const typedi_1 = __importDefault(require("typedi"));
|
|
10
10
|
class BaseEventHandler {
|
|
11
11
|
constructor(supportedEventTypes, priority = 100) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDevice } from "../device/local/interfaces";
|
|
1
|
+
import { IDevice } from "../entities/device/local/interfaces";
|
|
2
2
|
import { BaseEventHandler } from "./BaseEventHandler";
|
|
3
3
|
import { DeviceEvent } from "./interfaces/DeviceEvent";
|
|
4
4
|
export declare class DeviceEventHandler extends BaseEventHandler {
|
|
@@ -72,9 +72,10 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
72
72
|
};
|
|
73
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
74
|
exports.DeviceEventHandler = void 0;
|
|
75
|
+
const IAuditProperties_1 = require("../audit/IAuditProperties");
|
|
75
76
|
const constants_1 = require("../constants");
|
|
76
77
|
const Event_1 = require("../constants/Event");
|
|
77
|
-
const services_1 = require("../device/local/services");
|
|
78
|
+
const services_1 = require("../entities/device/local/services");
|
|
78
79
|
const BaseEventHandler_1 = require("./BaseEventHandler");
|
|
79
80
|
const typedi_1 = __importStar(require("typedi"));
|
|
80
81
|
let DeviceEventHandler = (() => {
|
|
@@ -136,7 +137,8 @@ let DeviceEventHandler = (() => {
|
|
|
136
137
|
deviceId: deviceData.deviceId,
|
|
137
138
|
deviceName: deviceData.name,
|
|
138
139
|
propertyId: deviceData.propertyId,
|
|
139
|
-
resource:
|
|
140
|
+
resource: IAuditProperties_1.Resource.DEVICE,
|
|
141
|
+
source: constants_1.Source.CLOUD_EVENT,
|
|
140
142
|
});
|
|
141
143
|
break;
|
|
142
144
|
case Event_1.DT_EVENT_TYPES.DEVICE.BATTERY.CHANGED:
|
|
@@ -144,7 +146,8 @@ let DeviceEventHandler = (() => {
|
|
|
144
146
|
deviceId: deviceData.deviceId,
|
|
145
147
|
deviceName: deviceData.name,
|
|
146
148
|
propertyId: deviceData.propertyId,
|
|
147
|
-
resource:
|
|
149
|
+
resource: IAuditProperties_1.Resource.DEVICE,
|
|
150
|
+
source: constants_1.Source.CLOUD_EVENT,
|
|
148
151
|
});
|
|
149
152
|
break;
|
|
150
153
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IStatus, IStatusQuery } from "../device/local/interfaces";
|
|
1
|
+
import { IAuditProperties } from "../audit/IAuditProperties";
|
|
2
|
+
import { IStatus, IStatusQuery } from "../entities/device/local/interfaces";
|
|
3
3
|
export declare class EventHandler {
|
|
4
4
|
private readonly source;
|
|
5
|
+
private readonly auditUtils;
|
|
5
6
|
constructor();
|
|
6
7
|
onDeviceCreate(body: any): Promise<void>;
|
|
7
|
-
onDeviceUpdate(deviceId: string, body: any, auditBody:
|
|
8
|
-
onDeviceDelete(deviceId: string, auditBody:
|
|
9
|
-
onStateChange(deviceId: string, state: any, auditProperties:
|
|
10
|
-
onStatusChange(deviceId: string, status: any, auditProperties:
|
|
11
|
-
onStatusChangeMany(query: IStatusQuery, status: IStatus, auditProperties:
|
|
12
|
-
onBatteryLevelChange(deviceId: string, batteryLevel: number, auditProperties:
|
|
13
|
-
onDeviceMetaChange(deviceId: string, metaData: Record<string, any>, auditProperties:
|
|
8
|
+
onDeviceUpdate(deviceId: string, body: any, auditBody: IAuditProperties): Promise<void>;
|
|
9
|
+
onDeviceDelete(deviceId: string, auditBody: IAuditProperties): Promise<void>;
|
|
10
|
+
onStateChange(deviceId: string, state: any, auditProperties: IAuditProperties): Promise<void>;
|
|
11
|
+
onStatusChange(deviceId: string, status: any, auditProperties: IAuditProperties): Promise<void>;
|
|
12
|
+
onStatusChangeMany(query: IStatusQuery, status: IStatus, auditProperties: IAuditProperties): Promise<void>;
|
|
13
|
+
onBatteryLevelChange(deviceId: string, batteryLevel: number, auditProperties: IAuditProperties): Promise<void>;
|
|
14
|
+
onDeviceMetaChange(deviceId: string, metaData: Record<string, any>, auditProperties: IAuditProperties): Promise<void>;
|
|
14
15
|
}
|
|
@@ -1,4 +1,20 @@
|
|
|
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
|
+
});
|
|
2
18
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
19
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
20
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -33,6 +49,23 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
33
49
|
}
|
|
34
50
|
return useValue ? value : void 0;
|
|
35
51
|
};
|
|
52
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
53
|
+
var ownKeys = function(o) {
|
|
54
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
55
|
+
var ar = [];
|
|
56
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
57
|
+
return ar;
|
|
58
|
+
};
|
|
59
|
+
return ownKeys(o);
|
|
60
|
+
};
|
|
61
|
+
return function (mod) {
|
|
62
|
+
if (mod && mod.__esModule) return mod;
|
|
63
|
+
var result = {};
|
|
64
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
65
|
+
__setModuleDefault(result, mod);
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
})();
|
|
36
69
|
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
70
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
71
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
@@ -41,7 +74,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
74
|
exports.EventHandler = void 0;
|
|
42
75
|
const dt_audit_library_1 = require("dt-audit-library");
|
|
43
76
|
const Event_1 = require("../constants/Event");
|
|
44
|
-
const typedi_1 = require("typedi");
|
|
77
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
45
78
|
const AuditUtils_1 = require("../audit/AuditUtils");
|
|
46
79
|
// TODO: For all the Event handlers, we need to publish the respective events for External Consumption
|
|
47
80
|
let EventHandler = (() => {
|
|
@@ -52,32 +85,40 @@ let EventHandler = (() => {
|
|
|
52
85
|
var EventHandler = _classThis = class {
|
|
53
86
|
constructor() {
|
|
54
87
|
this.source = "dt-common-device";
|
|
88
|
+
this.auditUtils = typedi_1.default.get(AuditUtils_1.AuditUtils);
|
|
55
89
|
}
|
|
56
90
|
async onDeviceCreate(body) {
|
|
57
91
|
const payload = {
|
|
58
92
|
eventType: Event_1.DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS,
|
|
59
|
-
properties:
|
|
93
|
+
properties: await this.auditUtils.buildAuditProperties(body),
|
|
60
94
|
};
|
|
61
95
|
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
62
96
|
}
|
|
63
97
|
async onDeviceUpdate(deviceId, body, auditBody) {
|
|
64
98
|
const payload = {
|
|
65
99
|
eventType: Event_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS,
|
|
66
|
-
properties:
|
|
100
|
+
properties: await this.auditUtils.buildAuditProperties({
|
|
101
|
+
...auditBody,
|
|
102
|
+
deviceId,
|
|
103
|
+
...body,
|
|
104
|
+
}),
|
|
67
105
|
};
|
|
68
106
|
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
69
107
|
}
|
|
70
108
|
async onDeviceDelete(deviceId, auditBody) {
|
|
71
109
|
const payload = {
|
|
72
110
|
eventType: Event_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS,
|
|
73
|
-
properties:
|
|
111
|
+
properties: await this.auditUtils.buildAuditProperties({
|
|
112
|
+
...auditBody,
|
|
113
|
+
deviceId,
|
|
114
|
+
}),
|
|
74
115
|
};
|
|
75
116
|
await (0, dt_audit_library_1.publishAudit)(payload);
|
|
76
117
|
}
|
|
77
118
|
async onStateChange(deviceId, state, auditProperties) {
|
|
78
119
|
const payload = {
|
|
79
120
|
eventType: Event_1.DT_EVENT_TYPES.DEVICE.STATE.SET,
|
|
80
|
-
properties:
|
|
121
|
+
properties: await this.auditUtils.buildAuditProperties({
|
|
81
122
|
...auditProperties,
|
|
82
123
|
deviceId,
|
|
83
124
|
...state,
|
|
@@ -88,7 +129,7 @@ let EventHandler = (() => {
|
|
|
88
129
|
async onStatusChange(deviceId, status, auditProperties) {
|
|
89
130
|
const payload = {
|
|
90
131
|
eventType: Event_1.DT_EVENT_TYPES.DEVICE.STATUS.SET,
|
|
91
|
-
properties:
|
|
132
|
+
properties: await this.auditUtils.buildAuditProperties({
|
|
92
133
|
...auditProperties,
|
|
93
134
|
deviceId,
|
|
94
135
|
...status,
|
|
@@ -99,7 +140,7 @@ let EventHandler = (() => {
|
|
|
99
140
|
async onStatusChangeMany(query, status, auditProperties) {
|
|
100
141
|
const payload = {
|
|
101
142
|
eventType: Event_1.DT_EVENT_TYPES.DEVICE.STATUS.UPDATED,
|
|
102
|
-
properties:
|
|
143
|
+
properties: await this.auditUtils.buildAuditProperties({
|
|
103
144
|
...auditProperties,
|
|
104
145
|
...query,
|
|
105
146
|
...status,
|
|
@@ -110,7 +151,7 @@ let EventHandler = (() => {
|
|
|
110
151
|
async onBatteryLevelChange(deviceId, batteryLevel, auditProperties) {
|
|
111
152
|
const payload = {
|
|
112
153
|
eventType: Event_1.DT_EVENT_TYPES.DEVICE.BATTERY.SET,
|
|
113
|
-
properties:
|
|
154
|
+
properties: await this.auditUtils.buildAuditProperties({
|
|
114
155
|
...auditProperties,
|
|
115
156
|
deviceId,
|
|
116
157
|
batteryLevel,
|
|
@@ -121,7 +162,7 @@ let EventHandler = (() => {
|
|
|
121
162
|
async onDeviceMetaChange(deviceId, metaData, auditProperties) {
|
|
122
163
|
const payload = {
|
|
123
164
|
eventType: Event_1.DT_EVENT_TYPES.DEVICE.META_DATA.SET,
|
|
124
|
-
properties:
|
|
165
|
+
properties: await this.auditUtils.buildAuditProperties({
|
|
125
166
|
...auditProperties,
|
|
126
167
|
deviceId,
|
|
127
168
|
metaData,
|
|
@@ -17,7 +17,7 @@ class InternalEventSubscription {
|
|
|
17
17
|
this.internalEventHandler = internalEventHandler;
|
|
18
18
|
this.isInitialized = false;
|
|
19
19
|
this.isSubscribed = false;
|
|
20
|
-
this.sqsQueueUrl = (0, config_1.
|
|
20
|
+
this.sqsQueueUrl = (0, config_1.getSqsQueueUrl)() || "";
|
|
21
21
|
this.logger = (0, config_1.getConfig)().LOGGER;
|
|
22
22
|
this.isInitialized = true;
|
|
23
23
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
export * from "./microservice";
|
|
2
2
|
export * from "./constants";
|
|
3
|
-
export { CloudDevice, CloudDeviceService, DeviceFactory, } from "./device/cloud/entities";
|
|
4
|
-
export { LocalDeviceService, LocalHubService, LocalScheduleService, } from "./device/local/services";
|
|
5
|
-
export * from "./device/local/interfaces";
|
|
6
|
-
export * from "./device/cloud/interfaces";
|
|
7
|
-
export * from "./admin";
|
|
8
|
-
export * from "./connection";
|
|
9
|
-
export * from "./property";
|
|
3
|
+
export { CloudDevice, CloudDeviceService, DeviceFactory, } from "./entities/device/cloud/entities";
|
|
4
|
+
export { LocalDeviceService, LocalHubService, LocalScheduleService, } from "./entities/device/local/services";
|
|
5
|
+
export * from "./entities/device/local/interfaces";
|
|
6
|
+
export * from "./entities/device/cloud/interfaces";
|
|
7
|
+
export * from "./entities/admin";
|
|
8
|
+
export * from "./entities/connection";
|
|
9
|
+
export * from "./entities/property";
|
|
10
10
|
export * from "./events";
|
|
11
11
|
export * from "./events/interfaces";
|
|
12
12
|
export * from "./alerts";
|
|
13
13
|
export * from "./issues";
|
|
14
14
|
export * from "./utils";
|
|
15
15
|
export * from "./queue";
|
|
16
|
-
export * from "./pms";
|
|
16
|
+
export * from "./entities/pms";
|
|
17
|
+
export * from "./audit";
|
|
17
18
|
export { initialize, getConfig, shutdown } from "./config/config";
|
package/dist/index.js
CHANGED
|
@@ -21,22 +21,22 @@ __exportStar(require("./microservice"), exports);
|
|
|
21
21
|
// CONSTANTS EXPORTS
|
|
22
22
|
__exportStar(require("./constants"), exports);
|
|
23
23
|
// DEVICE EXPORTS
|
|
24
|
-
var entities_1 = require("./device/cloud/entities");
|
|
24
|
+
var entities_1 = require("./entities/device/cloud/entities");
|
|
25
25
|
Object.defineProperty(exports, "CloudDevice", { enumerable: true, get: function () { return entities_1.CloudDevice; } });
|
|
26
26
|
Object.defineProperty(exports, "CloudDeviceService", { enumerable: true, get: function () { return entities_1.CloudDeviceService; } });
|
|
27
27
|
Object.defineProperty(exports, "DeviceFactory", { enumerable: true, get: function () { return entities_1.DeviceFactory; } });
|
|
28
|
-
var services_1 = require("./device/local/services");
|
|
28
|
+
var services_1 = require("./entities/device/local/services");
|
|
29
29
|
Object.defineProperty(exports, "LocalDeviceService", { enumerable: true, get: function () { return services_1.LocalDeviceService; } });
|
|
30
30
|
Object.defineProperty(exports, "LocalHubService", { enumerable: true, get: function () { return services_1.LocalHubService; } });
|
|
31
31
|
Object.defineProperty(exports, "LocalScheduleService", { enumerable: true, get: function () { return services_1.LocalScheduleService; } });
|
|
32
|
-
__exportStar(require("./device/local/interfaces"), exports);
|
|
33
|
-
__exportStar(require("./device/cloud/interfaces"), exports);
|
|
32
|
+
__exportStar(require("./entities/device/local/interfaces"), exports);
|
|
33
|
+
__exportStar(require("./entities/device/cloud/interfaces"), exports);
|
|
34
34
|
// ADMIN EXPORTS
|
|
35
|
-
__exportStar(require("./admin"), exports);
|
|
35
|
+
__exportStar(require("./entities/admin"), exports);
|
|
36
36
|
// CONNECTION EXPORTS
|
|
37
|
-
__exportStar(require("./connection"), exports);
|
|
37
|
+
__exportStar(require("./entities/connection"), exports);
|
|
38
38
|
// PROPERTY EXPORTS
|
|
39
|
-
__exportStar(require("./property"), exports);
|
|
39
|
+
__exportStar(require("./entities/property"), exports);
|
|
40
40
|
// EVENTS EXPORTS
|
|
41
41
|
__exportStar(require("./events"), exports);
|
|
42
42
|
__exportStar(require("./events/interfaces"), exports);
|
|
@@ -49,7 +49,9 @@ __exportStar(require("./utils"), exports);
|
|
|
49
49
|
// QUEUE EXPORTS
|
|
50
50
|
__exportStar(require("./queue"), exports);
|
|
51
51
|
// PMS EXPORTS
|
|
52
|
-
__exportStar(require("./pms"), exports);
|
|
52
|
+
__exportStar(require("./entities/pms"), exports);
|
|
53
|
+
// AUDIT EXPORTS
|
|
54
|
+
__exportStar(require("./audit"), exports);
|
|
53
55
|
// CONFIG EXPORTS
|
|
54
56
|
var config_1 = require("./config/config");
|
|
55
57
|
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return config_1.initialize; } });
|
|
@@ -3,7 +3,7 @@ import { IIssueDocument } from "./Issue.model";
|
|
|
3
3
|
import { CreateIssueData, UpdateIssueData, AddCommentData, IssueStatus, IssuePriority, IssuesCategory, EntityType } from "./issue.types";
|
|
4
4
|
import { IssueBuilder } from "./IssueBuilder";
|
|
5
5
|
import { Source } from "../constants/Service";
|
|
6
|
-
import { IDevice } from "../device/local/interfaces";
|
|
6
|
+
import { IDevice } from "../entities/device/local/interfaces";
|
|
7
7
|
export declare class IssueService {
|
|
8
8
|
private readonly issueRepository;
|
|
9
9
|
constructor(issueRepository: IssueRepository);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SERVICE_NAME } from "../constants";
|
|
2
|
-
import { DeviceType } from "../device/cloud/interfaces";
|
|
2
|
+
import { DeviceType } from "../entities/device/cloud/interfaces";
|
|
3
3
|
export declare class MicroServiceFactory {
|
|
4
4
|
private readonly deviceType;
|
|
5
5
|
private static instances;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MicroServiceFactory = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
|
-
const interfaces_1 = require("../device/cloud/interfaces");
|
|
5
|
+
const interfaces_1 = require("../entities/device/cloud/interfaces");
|
|
6
6
|
class MicroServiceFactory {
|
|
7
7
|
constructor(deviceType) {
|
|
8
8
|
this.deviceType = deviceType;
|
|
@@ -64,7 +64,7 @@ class RateLimitUtils {
|
|
|
64
64
|
provider: constants_1.CONNECTION_PROVIDERS.SCHLAGE,
|
|
65
65
|
});
|
|
66
66
|
configs.set(constants_1.CONNECTION_PROVIDERS.SMARTTHINGS, {
|
|
67
|
-
maxRequests:
|
|
67
|
+
maxRequests: 250,
|
|
68
68
|
windowMs: 60000, // 1 minute
|
|
69
69
|
provider: constants_1.CONNECTION_PROVIDERS.SMARTTHINGS,
|
|
70
70
|
});
|
|
@@ -7,8 +7,7 @@ export declare function validateServiceUrl(url: string): boolean;
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function createAxiosInstance(baseURL?: string): import("axios").AxiosInstance;
|
|
9
9
|
export declare function getDeviceServiceAxiosInstance(): any;
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function getCloudServiceAxiosInstance(): any;
|
|
10
|
+
export declare function getAdminServiceAxiosInstance(): any;
|
|
12
11
|
/**
|
|
13
12
|
* Retry function for failed HTTP requests
|
|
14
13
|
*/
|
package/dist/utils/http.utils.js
CHANGED
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.validateServiceUrl = validateServiceUrl;
|
|
7
7
|
exports.createAxiosInstance = createAxiosInstance;
|
|
8
8
|
exports.getDeviceServiceAxiosInstance = getDeviceServiceAxiosInstance;
|
|
9
|
-
exports.
|
|
10
|
-
exports.getCloudServiceAxiosInstance = getCloudServiceAxiosInstance;
|
|
9
|
+
exports.getAdminServiceAxiosInstance = getAdminServiceAxiosInstance;
|
|
11
10
|
exports.retryRequest = retryRequest;
|
|
12
11
|
const config_1 = require("../config/config");
|
|
13
12
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -36,7 +35,7 @@ function createAxiosInstance(baseURL) {
|
|
|
36
35
|
headers: {
|
|
37
36
|
"Content-Type": "application/json",
|
|
38
37
|
"User-Agent": "dt-common-device/1.3.0",
|
|
39
|
-
"x-api-key": (0, config_1.
|
|
38
|
+
"x-api-key": (0, config_1.getDTApiKey)(),
|
|
40
39
|
},
|
|
41
40
|
});
|
|
42
41
|
// Add request interceptor for logging
|
|
@@ -84,39 +83,17 @@ function createAxiosInstance(baseURL) {
|
|
|
84
83
|
let deviceServiceAxiosInstance = null;
|
|
85
84
|
function getDeviceServiceAxiosInstance() {
|
|
86
85
|
if (!deviceServiceAxiosInstance) {
|
|
87
|
-
|
|
88
|
-
if (!DEVICE_SERVICE) {
|
|
89
|
-
throw new Error("DEVICE_SERVICE is not configured. Call initialize() first with DEVICE_SERVICE.");
|
|
90
|
-
}
|
|
91
|
-
deviceServiceAxiosInstance = createAxiosInstance(DEVICE_SERVICE);
|
|
86
|
+
deviceServiceAxiosInstance = createAxiosInstance((0, config_1.getDeviceServiceUrl)());
|
|
92
87
|
}
|
|
93
88
|
return deviceServiceAxiosInstance;
|
|
94
89
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Centralized axios instance for access service
|
|
97
|
-
*/
|
|
98
|
-
let accessServiceAxiosInstance = null;
|
|
99
|
-
function getAccessServiceAxiosInstance() {
|
|
100
|
-
if (!accessServiceAxiosInstance) {
|
|
101
|
-
const { ACCESS_SERVICE } = (0, config_1.getConfig)();
|
|
102
|
-
if (!ACCESS_SERVICE) {
|
|
103
|
-
throw new Error("ACCESS_SERVICE is not configured. Call initialize() first with ACCESS_SERVICE.");
|
|
104
|
-
}
|
|
105
|
-
accessServiceAxiosInstance = createAxiosInstance(ACCESS_SERVICE);
|
|
106
|
-
}
|
|
107
|
-
return accessServiceAxiosInstance;
|
|
108
|
-
}
|
|
109
90
|
/**
|
|
110
91
|
* Centralized axios instance for cloud service (smart-cloud)
|
|
111
92
|
*/
|
|
112
93
|
let cloudServiceAxiosInstance = null;
|
|
113
|
-
function
|
|
114
|
-
const { ADMIN_SERVICE } = (0, config_1.getConfig)();
|
|
94
|
+
function getAdminServiceAxiosInstance() {
|
|
115
95
|
if (!cloudServiceAxiosInstance) {
|
|
116
|
-
|
|
117
|
-
throw new Error("ADMIN_SERVICE is not configured. Call initialize() first with ADMIN_SERVICE.");
|
|
118
|
-
}
|
|
119
|
-
cloudServiceAxiosInstance = createAxiosInstance(ADMIN_SERVICE);
|
|
96
|
+
cloudServiceAxiosInstance = createAxiosInstance((0, config_1.getAdminServiceUrl)());
|
|
120
97
|
}
|
|
121
98
|
return cloudServiceAxiosInstance;
|
|
122
99
|
}
|
package/package.json
CHANGED