dt-common-device 3.1.1 → 3.1.4

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.
@@ -1,4 +1,42 @@
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
+ };
2
40
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
41
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
42
  };
@@ -6,48 +44,64 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
44
  exports.LocalHubService = void 0;
7
45
  const Hub_repository_1 = require("../repository/Hub.repository");
8
46
  const typedi_1 = __importDefault(require("typedi"));
9
- class LocalHubService {
10
- constructor() {
11
- this.hubRepository = typedi_1.default.get(Hub_repository_1.HubRepository);
12
- }
13
- async addHub(body) {
14
- return await this.hubRepository.addHub(body);
15
- }
16
- async getHubs(hubIds) {
17
- if (!hubIds.length) {
18
- throw new Error("At least one hub ID is required");
47
+ const typedi_2 = require("typedi");
48
+ let LocalHubService = (() => {
49
+ let _classDecorators = [(0, typedi_2.Service)()];
50
+ let _classDescriptor;
51
+ let _classExtraInitializers = [];
52
+ let _classThis;
53
+ var LocalHubService = _classThis = class {
54
+ constructor() {
55
+ this.hubRepository = typedi_1.default.get(Hub_repository_1.HubRepository);
19
56
  }
20
- return await this.hubRepository.getHubs(hubIds);
21
- }
22
- async getHub(hubId) {
23
- if (!hubId) {
24
- throw new Error("Hub ID is required");
57
+ async addHub(body) {
58
+ return await this.hubRepository.addHub(body);
25
59
  }
26
- return await this.hubRepository.getHub(hubId);
27
- }
28
- async updateHub(hubId, body) {
29
- if (!hubId) {
30
- throw new Error("Hub ID is required");
60
+ async getHubs(hubIds) {
61
+ if (!hubIds.length) {
62
+ throw new Error("At least one hub ID is required");
63
+ }
64
+ return await this.hubRepository.getHubs(hubIds);
31
65
  }
32
- return await this.hubRepository.updateHub(hubId, body);
33
- }
34
- async getStatus(hubId) {
35
- if (!hubId) {
36
- throw new Error("Hub ID is required");
66
+ async getHub(hubId) {
67
+ if (!hubId) {
68
+ throw new Error("Hub ID is required");
69
+ }
70
+ return await this.hubRepository.getHub(hubId);
37
71
  }
38
- return await this.hubRepository.getStatus(hubId);
39
- }
40
- async deleteHub(hubId) {
41
- if (!hubId) {
42
- throw new Error("Hub ID is required");
72
+ async updateHub(hubId, body) {
73
+ if (!hubId) {
74
+ throw new Error("Hub ID is required");
75
+ }
76
+ return await this.hubRepository.updateHub(hubId, body);
43
77
  }
44
- return await this.hubRepository.deleteHub(hubId);
45
- }
46
- async deleteAllHubs(hubIds) {
47
- if (!hubIds.length) {
48
- throw new Error("At least one hub ID is required");
78
+ async getStatus(hubId) {
79
+ if (!hubId) {
80
+ throw new Error("Hub ID is required");
81
+ }
82
+ return await this.hubRepository.getStatus(hubId);
49
83
  }
50
- return await this.hubRepository.deleteAllHubs(hubIds);
51
- }
52
- }
84
+ async deleteHub(hubId) {
85
+ if (!hubId) {
86
+ throw new Error("Hub ID is required");
87
+ }
88
+ return await this.hubRepository.deleteHub(hubId);
89
+ }
90
+ async deleteAllHubs(hubIds) {
91
+ if (!hubIds.length) {
92
+ throw new Error("At least one hub ID is required");
93
+ }
94
+ return await this.hubRepository.deleteAllHubs(hubIds);
95
+ }
96
+ };
97
+ __setFunctionName(_classThis, "LocalHubService");
98
+ (() => {
99
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
100
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
101
+ LocalHubService = _classThis = _classDescriptor.value;
102
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
103
+ __runInitializers(_classThis, _classExtraInitializers);
104
+ })();
105
+ return LocalHubService = _classThis;
106
+ })();
53
107
  exports.LocalHubService = LocalHubService;
@@ -1,14 +1,19 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.BaseEventHandler = void 0;
4
7
  const config_1 = require("../config/config");
5
8
  const Device_service_1 = require("../device/local/services/Device.service");
9
+ const typedi_1 = __importDefault(require("typedi"));
6
10
  class BaseEventHandler {
7
11
  constructor(supportedEventTypes, priority = 100) {
8
12
  this.supportedEventTypes = supportedEventTypes;
9
13
  this.priority = priority;
10
14
  this.logger = (0, config_1.getConfig)().LOGGER;
11
- this.localDeviceService = new Device_service_1.LocalDeviceService();
15
+ // Use dependency injection instead of creating new instance
16
+ this.localDeviceService = typedi_1.default.get(Device_service_1.LocalDeviceService);
12
17
  }
13
18
  /**
14
19
  * Handle a single event - to be implemented by specific handlers
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.DeviceEventHandler = void 0;
4
7
  const constants_1 = require("../constants");
5
8
  const Event_1 = require("../constants/Event");
6
9
  const services_1 = require("../device/local/services");
7
10
  const BaseEventHandler_1 = require("./BaseEventHandler");
11
+ const typedi_1 = __importDefault(require("typedi"));
8
12
  class DeviceEventHandler extends BaseEventHandler_1.BaseEventHandler {
9
13
  constructor() {
10
14
  super([
@@ -15,7 +19,8 @@ class DeviceEventHandler extends BaseEventHandler_1.BaseEventHandler {
15
19
  Event_1.DT_EVENT_TYPES.DEVICE.BATTERY.LOW,
16
20
  Event_1.DT_EVENT_TYPES.DEVICE.BATTERY.CHANGED,
17
21
  ], 100);
18
- this.localHubService = new services_1.LocalHubService();
22
+ // Use dependency injection instead of creating new instance
23
+ this.localHubService = typedi_1.default.get(services_1.LocalHubService);
19
24
  }
20
25
  async onEvent(event) {
21
26
  this.logger.info("[DT | CDL]:[DeviceEventHandler]: Processing event", {
@@ -1,111 +1,165 @@
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
+ };
2
40
  Object.defineProperty(exports, "__esModule", { value: true });
3
41
  exports.EventHandler = void 0;
4
42
  const dt_pub_sub_1 = require("dt-pub-sub");
5
43
  const dt_audit_library_1 = require("dt-audit-library");
6
44
  const Event_1 = require("../constants/Event");
7
- class EventHandler {
8
- constructor() {
9
- this.source = "dt-common-device";
10
- }
11
- async onDeviceCreate(body) {
12
- // TODO: For Future Consumption
13
- // await eventDispatcher.publishEvent(
14
- // DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS,
15
- // body,
16
- // this.source
17
- // );
18
- const payload = {
19
- eventType: Event_1.DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS,
20
- properties: {
21
- ...body,
22
- },
23
- };
24
- await (0, dt_audit_library_1.publishAudit)(payload);
25
- }
26
- async onDeviceUpdate(deviceId, body) {
27
- await dt_pub_sub_1.eventDispatcher.publishEvent(Event_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS, { deviceId, body }, this.source);
28
- const payload = {
29
- eventType: Event_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS,
30
- properties: {
31
- ...body,
32
- },
33
- };
34
- await (0, dt_audit_library_1.publishAudit)(payload);
35
- }
36
- async onDeviceDelete(deviceId) {
37
- await dt_pub_sub_1.eventDispatcher.publishEvent(Event_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS, { deviceId }, this.source);
38
- const payload = {
39
- eventType: Event_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS,
40
- properties: {
41
- deviceId,
42
- },
43
- };
44
- await (0, dt_audit_library_1.publishAudit)(payload);
45
- }
46
- async onStateChange(deviceId, state) {
47
- // TODO: For Future Consumption
48
- /* await eventDispatcher.publishEvent(
49
- DT_EVENT_TYPES.DEVICE.STATE.SET,
50
- { deviceId, state },
51
- this.source
52
- ); */
53
- const payload = {
54
- eventType: Event_1.DT_EVENT_TYPES.DEVICE.STATE.SET,
55
- properties: {
56
- deviceId,
57
- state,
58
- },
59
- };
60
- await (0, dt_audit_library_1.publishAudit)(payload);
61
- }
62
- async onStatusChange(deviceId, status) {
63
- // TODO: For Future Consumption
64
- /* await eventDispatcher.publishEvent(
65
- DT_EVENT_TYPES.DEVICE.STATUS.SET,
66
- { deviceId, status },
67
- this.source
68
- ); */
69
- const payload = {
70
- eventType: Event_1.DT_EVENT_TYPES.DEVICE.STATUS.SET,
71
- properties: {
72
- deviceId,
73
- status,
74
- },
75
- };
76
- await (0, dt_audit_library_1.publishAudit)(payload);
77
- }
78
- async onBatteryLevelChange(deviceId, batteryLevel) {
79
- // TODO: For Future Consumption
80
- /* await eventDispatcher.publishEvent(
81
- DT_EVENT_TYPES.DEVICE.BATTERY.SET,
82
- { deviceId, batteryLevel },
83
- this.source
84
- ); */
85
- const payload = {
86
- eventType: Event_1.DT_EVENT_TYPES.DEVICE.BATTERY.SET,
87
- properties: {
88
- deviceId,
89
- batteryLevel,
90
- },
91
- };
92
- await (0, dt_audit_library_1.publishAudit)(payload);
93
- }
94
- async onDeviceMetaChange(deviceId, metaData) {
95
- // TODO: For Future Consumption
96
- /* await eventDispatcher.publishEvent(
97
- DT_EVENT_TYPES.DEVICE.META_DATA.SET,
98
- { deviceId, metaData },
99
- this.source
100
- ); */
101
- const payload = {
102
- eventType: Event_1.DT_EVENT_TYPES.DEVICE.META_DATA.SET,
103
- properties: {
104
- deviceId,
105
- metaData,
106
- },
107
- };
108
- await (0, dt_audit_library_1.publishAudit)(payload);
109
- }
110
- }
45
+ const typedi_1 = require("typedi");
46
+ let EventHandler = (() => {
47
+ let _classDecorators = [(0, typedi_1.Service)()];
48
+ let _classDescriptor;
49
+ let _classExtraInitializers = [];
50
+ let _classThis;
51
+ var EventHandler = _classThis = class {
52
+ constructor() {
53
+ this.source = "dt-common-device";
54
+ }
55
+ async onDeviceCreate(body) {
56
+ // TODO: For Future Consumption
57
+ // await eventDispatcher.publishEvent(
58
+ // DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS,
59
+ // body,
60
+ // this.source
61
+ // );
62
+ const payload = {
63
+ eventType: Event_1.DT_EVENT_TYPES.DEVICE.CREATE.SUCCESS,
64
+ properties: {
65
+ ...body,
66
+ },
67
+ };
68
+ await (0, dt_audit_library_1.publishAudit)(payload);
69
+ }
70
+ async onDeviceUpdate(deviceId, body) {
71
+ await dt_pub_sub_1.eventDispatcher.publishEvent(Event_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS, { deviceId, body }, this.source);
72
+ const payload = {
73
+ eventType: Event_1.DT_EVENT_TYPES.DEVICE.UPDATE.SUCCESS,
74
+ properties: {
75
+ ...body,
76
+ },
77
+ };
78
+ await (0, dt_audit_library_1.publishAudit)(payload);
79
+ }
80
+ async onDeviceDelete(deviceId) {
81
+ await dt_pub_sub_1.eventDispatcher.publishEvent(Event_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS, { deviceId }, this.source);
82
+ const payload = {
83
+ eventType: Event_1.DT_EVENT_TYPES.DEVICE.DELETE.SUCCESS,
84
+ properties: {
85
+ deviceId,
86
+ },
87
+ };
88
+ await (0, dt_audit_library_1.publishAudit)(payload);
89
+ }
90
+ async onStateChange(deviceId, state) {
91
+ // TODO: For Future Consumption
92
+ /* await eventDispatcher.publishEvent(
93
+ DT_EVENT_TYPES.DEVICE.STATE.SET,
94
+ { deviceId, state },
95
+ this.source
96
+ ); */
97
+ const payload = {
98
+ eventType: Event_1.DT_EVENT_TYPES.DEVICE.STATE.SET,
99
+ properties: {
100
+ deviceId,
101
+ state,
102
+ },
103
+ };
104
+ await (0, dt_audit_library_1.publishAudit)(payload);
105
+ }
106
+ async onStatusChange(deviceId, status) {
107
+ // TODO: For Future Consumption
108
+ /* await eventDispatcher.publishEvent(
109
+ DT_EVENT_TYPES.DEVICE.STATUS.SET,
110
+ { deviceId, status },
111
+ this.source
112
+ ); */
113
+ const payload = {
114
+ eventType: Event_1.DT_EVENT_TYPES.DEVICE.STATUS.SET,
115
+ properties: {
116
+ deviceId,
117
+ status,
118
+ },
119
+ };
120
+ await (0, dt_audit_library_1.publishAudit)(payload);
121
+ }
122
+ async onBatteryLevelChange(deviceId, batteryLevel) {
123
+ // TODO: For Future Consumption
124
+ /* await eventDispatcher.publishEvent(
125
+ DT_EVENT_TYPES.DEVICE.BATTERY.SET,
126
+ { deviceId, batteryLevel },
127
+ this.source
128
+ ); */
129
+ const payload = {
130
+ eventType: Event_1.DT_EVENT_TYPES.DEVICE.BATTERY.SET,
131
+ properties: {
132
+ deviceId,
133
+ batteryLevel,
134
+ },
135
+ };
136
+ await (0, dt_audit_library_1.publishAudit)(payload);
137
+ }
138
+ async onDeviceMetaChange(deviceId, metaData) {
139
+ // TODO: For Future Consumption
140
+ /* await eventDispatcher.publishEvent(
141
+ DT_EVENT_TYPES.DEVICE.META_DATA.SET,
142
+ { deviceId, metaData },
143
+ this.source
144
+ ); */
145
+ const payload = {
146
+ eventType: Event_1.DT_EVENT_TYPES.DEVICE.META_DATA.SET,
147
+ properties: {
148
+ deviceId,
149
+ metaData,
150
+ },
151
+ };
152
+ await (0, dt_audit_library_1.publishAudit)(payload);
153
+ }
154
+ };
155
+ __setFunctionName(_classThis, "EventHandler");
156
+ (() => {
157
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
158
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
159
+ EventHandler = _classThis = _classDescriptor.value;
160
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
161
+ __runInitializers(_classThis, _classExtraInitializers);
162
+ })();
163
+ return EventHandler = _classThis;
164
+ })();
111
165
  exports.EventHandler = EventHandler;
@@ -37,12 +37,16 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
37
37
  if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
38
  return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
39
  };
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
40
43
  Object.defineProperty(exports, "__esModule", { value: true });
41
44
  exports.EventProcessingService = void 0;
42
45
  const typedi_1 = require("typedi");
43
46
  const DeviceEventHandler_1 = require("./DeviceEventHandler");
44
47
  const config_1 = require("../config/config");
45
48
  const EventHandlerOrchestrator_1 = require("./EventHandlerOrchestrator");
49
+ const typedi_2 = __importDefault(require("typedi"));
46
50
  let EventProcessingService = (() => {
47
51
  let _classDecorators = [(0, typedi_1.Service)()];
48
52
  let _classDescriptor;
@@ -53,7 +57,8 @@ let EventProcessingService = (() => {
53
57
  this.deviceEventTransformerFactory = deviceEventTransformerFactory;
54
58
  this.deviceHandlers = new Map();
55
59
  this.handlerOrchestrator = new EventHandlerOrchestrator_1.EventHandlerOrchestrator();
56
- this.deviceEventHandler = new DeviceEventHandler_1.DeviceEventHandler();
60
+ // Use dependency injection instead of creating new instance
61
+ this.deviceEventHandler = typedi_2.default.get(DeviceEventHandler_1.DeviceEventHandler);
57
62
  this.logger = (0, config_1.getConfig)().LOGGER;
58
63
  this.initializeDeviceHandlers();
59
64
  this.initializeHandlers();
@@ -70,9 +75,9 @@ let EventProcessingService = (() => {
70
75
  */
71
76
  initializeHandlers() {
72
77
  try {
73
- // Register generic handler for common events
78
+ // Register generic handler for common events - reuse existing instance
74
79
  this.handlerOrchestrator.registerHandlers([
75
- new DeviceEventHandler_1.DeviceEventHandler(), // Priority 100 - handles common events first
80
+ this.deviceEventHandler, // Use existing instance instead of creating new one
76
81
  ]);
77
82
  this.logger.info("Base event handlers initialized successfully");
78
83
  }
@@ -2,7 +2,7 @@ import { SERVICE_NAME } from "../constants";
2
2
  import { DeviceType } from "../device/cloud/interfaces";
3
3
  export declare class MicroServiceFactory {
4
4
  private readonly deviceType;
5
- private static instance;
5
+ private static instances;
6
6
  constructor(deviceType: DeviceType);
7
7
  getMicroService(): SERVICE_NAME;
8
8
  static getInstance(deviceType: DeviceType): MicroServiceFactory;
@@ -22,10 +22,12 @@ class MicroServiceFactory {
22
22
  }
23
23
  }
24
24
  static getInstance(deviceType) {
25
- if (!MicroServiceFactory.instance) {
26
- MicroServiceFactory.instance = new MicroServiceFactory(deviceType);
25
+ // Use device type as key to allow multiple instances for different device types
26
+ if (!MicroServiceFactory.instances.has(deviceType)) {
27
+ MicroServiceFactory.instances.set(deviceType, new MicroServiceFactory(deviceType));
27
28
  }
28
- return MicroServiceFactory.instance;
29
+ return MicroServiceFactory.instances.get(deviceType);
29
30
  }
30
31
  }
31
32
  exports.MicroServiceFactory = MicroServiceFactory;
33
+ MicroServiceFactory.instances = new Map();