dt-common-device 3.1.1 → 3.1.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.
Files changed (52) hide show
  1. package/dist/admin/Admin.repository.d.ts +7 -0
  2. package/dist/admin/Admin.repository.js +182 -0
  3. package/dist/admin/Admin.service.d.ts +5 -0
  4. package/dist/admin/Admin.service.js +17 -0
  5. package/dist/admin/index.d.ts +1 -0
  6. package/dist/{device → admin}/index.js +1 -4
  7. package/dist/audit/AuditProperties.d.ts +16 -0
  8. package/dist/audit/AuditUtils.d.ts +2 -0
  9. package/dist/audit/AuditUtils.js +36 -0
  10. package/dist/config/config.js +4 -0
  11. package/dist/config/config.types.d.ts +2 -0
  12. package/dist/device/cloud/entities/DeviceFactory.js +73 -14
  13. package/dist/device/local/events/EventHandler.js +6 -6
  14. package/dist/device/local/events/Events.d.ts +33 -12
  15. package/dist/device/local/events/Events.js +33 -12
  16. package/dist/device/local/services/Device.service.js +294 -239
  17. package/dist/device/local/services/Hub.service.js +92 -38
  18. package/dist/events/BaseEventHandler.js +6 -1
  19. package/dist/events/DeviceEventHandler.js +6 -1
  20. package/dist/events/EventHandler.js +158 -104
  21. package/dist/events/EventProcessingService.js +8 -3
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +2 -0
  24. package/dist/microservice/MicroServiceFactory.d.ts +1 -1
  25. package/dist/microservice/MicroServiceFactory.js +5 -3
  26. package/dist/property/Property.service.js +86 -27
  27. package/dist/queue/services/QueueService.js +6 -1
  28. package/dist/queue/utils/rateLimit.utils.js +9 -9
  29. package/dist/utils/http.utils.d.ts +2 -0
  30. package/dist/utils/http.utils.js +30 -0
  31. package/package.json +1 -1
  32. package/dist/device/cloud/interface.d.ts +0 -101
  33. package/dist/device/cloud/interface.js +0 -3
  34. package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +0 -7
  35. package/dist/device/cloud/interfaces/IDeviceConnectionService.js +0 -3
  36. package/dist/device/cloud/interfaces/IDevicesService.d.ts +0 -9
  37. package/dist/device/cloud/services/Device.service.d.ts +0 -39
  38. package/dist/device/cloud/services/Device.service.js +0 -9
  39. package/dist/device/cloud/services/DeviceCloudService.d.ts +0 -42
  40. package/dist/device/cloud/services/DeviceCloudService.js +0 -59
  41. package/dist/device/cloud/services/DeviceHub.service.d.ts +0 -3
  42. package/dist/device/cloud/services/DeviceHub.service.js +0 -6
  43. package/dist/device/cloud/services/Hub.service.d.ts +0 -25
  44. package/dist/device/cloud/services/Hub.service.js +0 -9
  45. package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +0 -38
  46. package/dist/device/cloud/services/SmartThingsDeviceService.js +0 -52
  47. package/dist/device/index.d.ts +0 -4
  48. package/dist/device/local/interface.d.ts +0 -0
  49. package/dist/device/local/interface.js +0 -1
  50. package/dist/device/local/services/DeviceHub.service.d.ts +0 -11
  51. package/dist/device/local/services/DeviceHub.service.js +0 -40
  52. /package/dist/{device/cloud/interfaces/IDevicesService.js → audit/AuditProperties.js} +0 -0
@@ -0,0 +1,7 @@
1
+ export declare class AdminRepository {
2
+ private readonly axiosInstance;
3
+ private readonly deviceRepository;
4
+ private readonly postgres;
5
+ constructor();
6
+ getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[]>;
7
+ }
@@ -0,0 +1,182 @@
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 __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
19
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
20
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
21
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
22
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
23
+ var _, done = false;
24
+ for (var i = decorators.length - 1; i >= 0; i--) {
25
+ var context = {};
26
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
27
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
28
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
29
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
30
+ if (kind === "accessor") {
31
+ if (result === void 0) continue;
32
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
33
+ if (_ = accept(result.get)) descriptor.get = _;
34
+ if (_ = accept(result.set)) descriptor.set = _;
35
+ if (_ = accept(result.init)) initializers.unshift(_);
36
+ }
37
+ else if (_ = accept(result)) {
38
+ if (kind === "field") initializers.unshift(_);
39
+ else descriptor[key] = _;
40
+ }
41
+ }
42
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
43
+ done = true;
44
+ };
45
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
46
+ var useValue = arguments.length > 2;
47
+ for (var i = 0; i < initializers.length; i++) {
48
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
49
+ }
50
+ return useValue ? value : void 0;
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
+ })();
69
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
70
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
71
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
72
+ };
73
+ Object.defineProperty(exports, "__esModule", { value: true });
74
+ exports.AdminRepository = void 0;
75
+ const typedi_1 = __importStar(require("typedi"));
76
+ const utils_1 = require("../utils");
77
+ const Device_repository_1 = require("../device/local/repository/Device.repository");
78
+ const db_1 = require("../db/db");
79
+ const interfaces_1 = require("../device/cloud/interfaces");
80
+ let AdminRepository = (() => {
81
+ let _classDecorators = [(0, typedi_1.Service)()];
82
+ let _classDescriptor;
83
+ let _classExtraInitializers = [];
84
+ let _classThis;
85
+ var AdminRepository = _classThis = class {
86
+ constructor() {
87
+ this.axiosInstance = (0, utils_1.getCloudServiceAxiosInstance)();
88
+ this.deviceRepository = typedi_1.default.get(Device_repository_1.DeviceRepository);
89
+ this.postgres = (0, db_1.getPostgresClient)();
90
+ }
91
+ async getZonesByAccessGroupIds(accessGroupIds) {
92
+ const result = await this.postgres.query(`SELECT "zc".*, "z"."id", "z"."name"
93
+ FROM "dt_zones_collection_map" "zc"
94
+ INNER JOIN "dt_zones" "z" ON "zc"."zoneId" = "z"."id"
95
+ WHERE "zc"."collectionId" = ANY($1)`, [accessGroupIds]);
96
+ const response = result.rows;
97
+ const _zones = (nestedZones, allzones = []) => {
98
+ nestedZones.forEach((z) => {
99
+ const onlyZone = { ...z };
100
+ delete onlyZone.childZones;
101
+ allzones.push(onlyZone);
102
+ if (!Array.isArray(z.childZones)) {
103
+ if (z.childZones.id)
104
+ z.childZones = [z.childZones];
105
+ }
106
+ if (z.childZones.length) {
107
+ _zones(z.childZones, allzones);
108
+ }
109
+ });
110
+ return allzones.map((e) => e.id);
111
+ };
112
+ // const zones = _zones(response);
113
+ const zoneIds = response.map((el) => el.id);
114
+ const collectionZone = [];
115
+ for (let i = 0; i < response.length; i++) {
116
+ let zoneIds = [];
117
+ const zones = await this.axiosInstance.get(`/zones/child?zoneId=${response[i].zoneId}`);
118
+ zoneIds.push(response[i].zoneId);
119
+ if (zones.childZones?.length > 0) {
120
+ const nestedZoneIds = new Set(_zones(zones.childZones));
121
+ zoneIds = [...zoneIds, ...nestedZoneIds];
122
+ }
123
+ if (collectionZone.length == 0) {
124
+ const obj = {
125
+ collectionId: response[i].collectionId,
126
+ zoneIds,
127
+ };
128
+ collectionZone.push(obj);
129
+ }
130
+ else {
131
+ const obj = collectionZone.find((e) => e.collectionId == response[i].collectionId);
132
+ if (obj) {
133
+ obj.zoneIds = [...obj.zoneIds, ...zoneIds];
134
+ }
135
+ else {
136
+ collectionZone.push({
137
+ collectionId: response[i].collectionId,
138
+ zoneIds,
139
+ });
140
+ }
141
+ }
142
+ }
143
+ let _zoneIds = collectionZone.flatMap((e) => {
144
+ return e.zoneIds.map((z) => z);
145
+ });
146
+ if (_zoneIds.length === 0)
147
+ return [];
148
+ const deviecDetail = await this.deviceRepository.queryDevices({
149
+ zoneIds: _zoneIds,
150
+ excludeDeviceType: interfaces_1.DeviceType.HUB
151
+ });
152
+ const _collectionZone = collectionZone.map((e) => {
153
+ const zones = e.zoneIds;
154
+ let devices = [];
155
+ zones.forEach((element) => {
156
+ const device = deviecDetail.filter((d) => d.zoneId == element);
157
+ // Add collectionId to each device
158
+ device.forEach((dev) => {
159
+ dev.collectionId = e.collectionId;
160
+ });
161
+ const _devices = devices.concat(device);
162
+ devices = _devices;
163
+ });
164
+ e.devices = devices;
165
+ e.parentZone = response;
166
+ return e;
167
+ });
168
+ const collectionZoneDevices = Array.from(new Set(_collectionZone));
169
+ return collectionZoneDevices;
170
+ }
171
+ };
172
+ __setFunctionName(_classThis, "AdminRepository");
173
+ (() => {
174
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
175
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
176
+ AdminRepository = _classThis = _classDescriptor.value;
177
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
178
+ __runInitializers(_classThis, _classExtraInitializers);
179
+ })();
180
+ return AdminRepository = _classThis;
181
+ })();
182
+ exports.AdminRepository = AdminRepository;
@@ -0,0 +1,5 @@
1
+ export declare class AdminService {
2
+ private readonly adminRepository;
3
+ constructor();
4
+ getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[]>;
5
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AdminService = void 0;
7
+ const typedi_1 = __importDefault(require("typedi"));
8
+ const Admin_repository_1 = require("./Admin.repository");
9
+ class AdminService {
10
+ constructor() {
11
+ this.adminRepository = typedi_1.default.get(Admin_repository_1.AdminRepository);
12
+ }
13
+ async getZonesByAccessGroupIds(accessGroupIds) {
14
+ return await this.adminRepository.getZonesByAccessGroupIds(accessGroupIds);
15
+ }
16
+ }
17
+ exports.AdminService = AdminService;
@@ -0,0 +1 @@
1
+ export * from "./Admin.service";
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // DeviceThread Common Library - Device Module
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -15,6 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
15
  };
17
16
  Object.defineProperty(exports, "__esModule", { value: true });
18
- // Export cloud device interfaces
19
- __exportStar(require("./cloud/interface"), exports);
20
- __exportStar(require("./cloud/types"), exports);
17
+ __exportStar(require("./Admin.service"), exports);
@@ -0,0 +1,16 @@
1
+ export interface AuditProperties {
2
+ resource: string;
3
+ propertyId: string;
4
+ propertyName?: string;
5
+ userId?: string;
6
+ userName?: string;
7
+ deviceId: string;
8
+ deviceName: string;
9
+ zoneId?: string;
10
+ zoneName?: string;
11
+ accessGroupId?: string;
12
+ accessGroupName?: string;
13
+ scheduleId?: string;
14
+ scheduleName?: string;
15
+ [key: string]: any;
16
+ }
@@ -0,0 +1,2 @@
1
+ import { AuditProperties } from "./AuditProperties";
2
+ export declare function buildAuditProperties(input: AuditProperties): Record<string, any>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAuditProperties = buildAuditProperties;
4
+ const AUDIT_FIELDS = [
5
+ "resource",
6
+ "propertyId",
7
+ "propertyName",
8
+ "userId",
9
+ "userName",
10
+ "deviceId",
11
+ "deviceName",
12
+ "zoneId",
13
+ "zoneName",
14
+ "accessGroupId",
15
+ "accessGroupName",
16
+ "scheduleId",
17
+ "scheduleName",
18
+ ];
19
+ function buildAuditProperties(input) {
20
+ // Normalize keys to camelCase for matching
21
+ const normalized = { ...input };
22
+ // Build the audit object with all standard fields
23
+ const audit = {};
24
+ for (const field of AUDIT_FIELDS) {
25
+ // Try to find a matching key in input (case-insensitive)
26
+ const foundKey = Object.keys(normalized).find((k) => k.toLowerCase() === field.toLowerCase());
27
+ audit[field] = foundKey ? normalized[foundKey] : undefined;
28
+ }
29
+ // Merge in all other event-specific data (but don't overwrite audit fields)
30
+ for (const key of Object.keys(normalized)) {
31
+ if (!audit.hasOwnProperty(key)) {
32
+ audit[key] = normalized[key];
33
+ }
34
+ }
35
+ return audit;
36
+ }
@@ -37,6 +37,9 @@ async function initialize(cfg) {
37
37
  if (cfg.ENERGY_SERVICE && !(0, http_utils_1.validateServiceUrl)(cfg.ENERGY_SERVICE)) {
38
38
  throw new Error(`Invalid ENERGY_SERVICE URL: ${cfg.ENERGY_SERVICE}`);
39
39
  }
40
+ if (cfg.REMOTE_SERVICE && !(0, http_utils_1.validateServiceUrl)(cfg.REMOTE_SERVICE)) {
41
+ throw new Error(`Invalid REMOTE_SERVICE URL: ${cfg.REMOTE_SERVICE}`);
42
+ }
40
43
  // Initialize internal event subscription if handler is provided
41
44
  if (cfg.INTERNAL_EVENT_HANDLER) {
42
45
  try {
@@ -97,6 +100,7 @@ function checkRequiredEnv() {
97
100
  "REDIS_PORT",
98
101
  "POSTHOG_API_KEY",
99
102
  "POSTHOG_HOST",
103
+ "CLOUD_SERVICE_API_KEY",
100
104
  ];
101
105
  const missing = requiredEnv.filter((key) => !process.env[key]);
102
106
  if (missing.length > 0) {
@@ -12,8 +12,10 @@ export type IConfig = {
12
12
  ADMIN_SERVICE?: string;
13
13
  ACCESS_SERVICE?: string;
14
14
  ENERGY_SERVICE?: string;
15
+ REMOTE_SERVICE?: string;
15
16
  INTERNAL_EVENT_HANDLER: IInternalEvent;
16
17
  LOGGER: ILogger;
18
+ CLOUD_SERVICE_API_KEY: string;
17
19
  [key: string]: any;
18
20
  };
19
21
  export {};
@@ -1,21 +1,80 @@
1
1
  "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
2
43
  Object.defineProperty(exports, "__esModule", { value: true });
3
44
  exports.DeviceFactory = void 0;
4
45
  const Device_service_1 = require("../../local/services/Device.service");
5
- class DeviceFactory {
6
- constructor() {
7
- this.localDeviceService = new Device_service_1.LocalDeviceService();
8
- }
9
- async getDevice(deviceId) {
10
- try {
11
- return await this.localDeviceService.getDevice(deviceId);
46
+ const typedi_1 = __importDefault(require("typedi"));
47
+ const typedi_2 = require("typedi");
48
+ let DeviceFactory = (() => {
49
+ let _classDecorators = [(0, typedi_2.Service)()];
50
+ let _classDescriptor;
51
+ let _classExtraInitializers = [];
52
+ let _classThis;
53
+ var DeviceFactory = _classThis = class {
54
+ constructor() {
55
+ // Use dependency injection instead of creating new instance
56
+ this.localDeviceService = typedi_1.default.get(Device_service_1.LocalDeviceService);
12
57
  }
13
- catch (error) {
14
- // Log the error for debugging purposes
15
- console.error(`DeviceFactory: Failed to get device ${deviceId}:`, error);
16
- // Re-throw the error with additional context
17
- throw new Error(`DeviceFactory: Unable to retrieve device ${deviceId}. ${error instanceof Error ? error.message : "Unknown error occurred"}`);
58
+ async getDevice(deviceId) {
59
+ try {
60
+ return await this.localDeviceService.getDevice(deviceId);
61
+ }
62
+ catch (error) {
63
+ // Log the error for debugging purposes
64
+ console.error(`DeviceFactory: Failed to get device ${deviceId}:`, error);
65
+ // Re-throw the error with additional context
66
+ throw new Error(`DeviceFactory: Unable to retrieve device ${deviceId}. ${error instanceof Error ? error.message : "Unknown error occurred"}`);
67
+ }
18
68
  }
19
- }
20
- }
69
+ };
70
+ __setFunctionName(_classThis, "DeviceFactory");
71
+ (() => {
72
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
73
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
74
+ DeviceFactory = _classThis = _classDescriptor.value;
75
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
76
+ __runInitializers(_classThis, _classExtraInitializers);
77
+ })();
78
+ return DeviceFactory = _classThis;
79
+ })();
21
80
  exports.DeviceFactory = DeviceFactory;
@@ -9,9 +9,9 @@ class EventHandler {
9
9
  this.source = "dt-common-device";
10
10
  }
11
11
  async onDeviceCreate(body) {
12
- await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.CREATED, body, this.source);
12
+ await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS, body, this.source);
13
13
  const payload = {
14
- eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.CREATED,
14
+ eventType: Events_1.DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS,
15
15
  properties: {
16
16
  ...body,
17
17
  },
@@ -19,9 +19,9 @@ class EventHandler {
19
19
  await (0, dt_audit_library_1.publishAudit)(payload);
20
20
  }
21
21
  async onDeviceUpdate(deviceId, body) {
22
- await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED, { deviceId, body }, this.source);
22
+ await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS, { deviceId, body }, this.source);
23
23
  const payload = {
24
- eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.UPDATED,
24
+ eventType: Events_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS,
25
25
  properties: {
26
26
  ...body,
27
27
  },
@@ -29,9 +29,9 @@ class EventHandler {
29
29
  await (0, dt_audit_library_1.publishAudit)(payload);
30
30
  }
31
31
  async onDeviceDelete(deviceId) {
32
- await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.DELETED, { deviceId }, this.source);
32
+ await dt_pub_sub_1.eventDispatcher.publishEvent(Events_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS, { deviceId }, this.source);
33
33
  const payload = {
34
- eventType: Events_1.DT_EVENT_TYPES.DEVICE.DEVICE.DELETED,
34
+ eventType: Events_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS,
35
35
  properties: {
36
36
  deviceId,
37
37
  },
@@ -1,9 +1,16 @@
1
1
  export declare const DT_EVENT_TYPES: {
2
2
  DEVICE: {
3
- DEVICE: {
4
- CREATED: string;
5
- UPDATED: string;
6
- DELETED: string;
3
+ CREATE: {
4
+ SUCCESS: string;
5
+ FAILED: string;
6
+ };
7
+ UPDATE: {
8
+ SUCCESS: string;
9
+ FAILED: string;
10
+ };
11
+ DELETE: {
12
+ SUCCESS: string;
13
+ FAILED: string;
7
14
  };
8
15
  STATE: {
9
16
  SET: string;
@@ -34,17 +41,31 @@ export declare const DT_EVENT_TYPES: {
34
41
  };
35
42
  };
36
43
  CONNECTION: {
37
- CONNECTION: {
38
- CREATED: string;
39
- UPDATED: string;
40
- DELETED: string;
44
+ CREATE: {
45
+ SUCCESS: string;
46
+ FAILED: string;
47
+ };
48
+ UPDATE: {
49
+ SUCCESS: string;
50
+ FAILED: string;
51
+ };
52
+ DELETE: {
53
+ SUCCESS: string;
54
+ FAILED: string;
41
55
  };
42
56
  };
43
57
  PROPERTY: {
44
- PROPERTY: {
45
- CREATED: string;
46
- UPDATED: string;
47
- DELETED: string;
58
+ CREATE: {
59
+ SUCCESS: string;
60
+ FAILED: string;
61
+ };
62
+ UPDATE: {
63
+ SUCCESS: string;
64
+ FAILED: string;
65
+ };
66
+ DELETE: {
67
+ SUCCESS: string;
68
+ FAILED: string;
48
69
  };
49
70
  PREFERENCES: {
50
71
  UPDATED: string;
@@ -3,10 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DT_EVENT_TYPES = void 0;
4
4
  exports.DT_EVENT_TYPES = {
5
5
  DEVICE: {
6
- DEVICE: {
7
- CREATED: "device.device.created",
8
- UPDATED: "device.device.updated",
9
- DELETED: "device.device.deleted",
6
+ CREATE: {
7
+ SUCCESS: "device.create.success",
8
+ FAILED: "device.create.failed",
9
+ },
10
+ UPDATE: {
11
+ SUCCESS: "device.update.success",
12
+ FAILED: "device.update.failed",
13
+ },
14
+ DELETE: {
15
+ SUCCESS: "device.delete.success",
16
+ FAILED: "device.delete.failed",
10
17
  },
11
18
  STATE: {
12
19
  SET: "device.state.set",
@@ -37,17 +44,31 @@ exports.DT_EVENT_TYPES = {
37
44
  },
38
45
  },
39
46
  CONNECTION: {
40
- CONNECTION: {
41
- CREATED: "connection.connection.created",
42
- UPDATED: "connection.connection.updated",
43
- DELETED: "connection.connection.deleted",
47
+ CREATE: {
48
+ SUCCESS: "connection.create.success",
49
+ FAILED: "connection.create.failed",
50
+ },
51
+ UPDATE: {
52
+ SUCCESS: "connection.update.success",
53
+ FAILED: "connection.update.failed",
54
+ },
55
+ DELETE: {
56
+ SUCCESS: "connection.delete.success",
57
+ FAILED: "connection.delete.failed",
44
58
  },
45
59
  },
46
60
  PROPERTY: {
47
- PROPERTY: {
48
- CREATED: "property.property.created",
49
- UPDATED: "property.property.updated",
50
- DELETED: "property.property.deleted",
61
+ CREATE: {
62
+ SUCCESS: "property.create.success",
63
+ FAILED: "property.create.failed",
64
+ },
65
+ UPDATE: {
66
+ SUCCESS: "property.update.success",
67
+ FAILED: "property.update.failed",
68
+ },
69
+ DELETE: {
70
+ SUCCESS: "property.delete.success",
71
+ FAILED: "property.delete.failed",
51
72
  },
52
73
  PREFERENCES: {
53
74
  UPDATED: "property.preferences.updated",