dt-common-device 7.10.2 → 7.10.3

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.
@@ -142,20 +142,9 @@ let LocalDeviceService = (() => {
142
142
  if (body.state?.batteryPercentage?.value) {
143
143
  await this.setBatteryLevel(deviceId, body.state?.batteryPercentage?.value, auditBody?.source || Service_1.Source.SYSTEM, auditBody);
144
144
  }
145
- (0, audit_1.pushAudit)({
146
- auditType,
147
- auditData: {
148
- deviceId,
149
- zoneId: device.zoneId,
150
- deviceType: device.deviceType,
151
- deviceName: device.name,
152
- deviceStatus: device.status,
153
- ...auditBody,
154
- oldStatus: device.status,
155
- newStatus: body.status,
156
- },
157
- });
158
145
  }
146
+ delete body.state?.batteryPercentage;
147
+ delete body.status;
159
148
  await this.deviceRepository.updateDevice(deviceId, body);
160
149
  return await this.eventHandler.onDeviceUpdate(deviceId, body, auditBody);
161
150
  }
@@ -278,6 +267,7 @@ let LocalDeviceService = (() => {
278
267
  await this.eventHandler.onStatusChangeMany(query, newStatus, auditBody, eventType);
279
268
  }
280
269
  async handleOfflineStatus(device, oldStatus, newStatus, source, auditBody, reason, currentTime) {
270
+ currentTime = currentTime ?? new Date().toISOString();
281
271
  const isExistingStatusOnline = oldStatus?.liveStatus === "ONLINE";
282
272
  const isExistingStatusOffline = oldStatus?.liveStatus === "OFFLINE";
283
273
  if (isExistingStatusOnline) {
@@ -317,6 +307,7 @@ let LocalDeviceService = (() => {
317
307
  }
318
308
  }
319
309
  async handleOnlineStatus(device, oldStatus, newStatus, source, auditBody, reason, currentTime) {
310
+ currentTime = currentTime ?? new Date().toISOString();
320
311
  const isExistingStatusOnline = oldStatus?.online === true;
321
312
  const isExistingStatusOffline = oldStatus?.online === false;
322
313
  if (isExistingStatusOnline) {
@@ -333,14 +324,6 @@ let LocalDeviceService = (() => {
333
324
  newStatus.error = {}; // Clear the error
334
325
  await this.deviceRepository.setStatus(device.deviceId, newStatus);
335
326
  await this.eventHandler.onStatusChange(device.deviceId, newStatus, auditBody, constants_1.DT_EVENT_TYPES.DEVICE.STATUS.ONLINE);
336
- // Resolve issue if exists
337
- await this.issueService.performIssueAction({
338
- entityId: device.deviceId,
339
- entityType: issue_types_1.EntityType.DEVICE,
340
- type: issue_types_1.IssueType.DEVICE_OFFLINE,
341
- propertyId: device.propertyId,
342
- zoneId: device.zoneId,
343
- }, "resolve", source);
344
327
  }
345
328
  }
346
329
  else if (isExistingStatusOffline) {
@@ -27,6 +27,9 @@ class InternalEventSubscription {
27
27
  try {
28
28
  const eventType = message["detail-type"];
29
29
  const eventData = message.detail;
30
+ //TODO: To be sent with event data, to delete the message if processing is failed!
31
+ const eventToken = message.receiptHandle;
32
+ console.log('eventToken', eventToken);
30
33
  this.logger.info(`Received internal event: ${eventType} ${eventData}`);
31
34
  switch (eventType) {
32
35
  case InternalEventType.HEARTBEAT:
@@ -401,7 +401,7 @@ let IssueService = (() => {
401
401
  type: processedIssueData.type,
402
402
  });
403
403
  if (existingIssue.length > 0) {
404
- await (0, audit_1.pushAudit)({
404
+ (0, audit_1.pushAudit)({
405
405
  auditType: constants_1.DT_EVENT_TYPES.ISSUE.CREATE.SKIPPED,
406
406
  auditData: {
407
407
  reason: "Issue already exists",
@@ -417,7 +417,7 @@ let IssueService = (() => {
417
417
  return null;
418
418
  }
419
419
  const issue = await this.issueRepository.create(processedIssueData);
420
- await (0, audit_1.pushAudit)({
420
+ (0, audit_1.pushAudit)({
421
421
  auditType: constants_1.DT_EVENT_TYPES.ISSUE.CREATE.SUCCESS,
422
422
  auditData: {
423
423
  resource: audit_1.Resource.ISSUE,
@@ -436,7 +436,7 @@ let IssueService = (() => {
436
436
  return issue;
437
437
  }
438
438
  catch (error) {
439
- await (0, audit_1.pushAudit)({
439
+ (0, audit_1.pushAudit)({
440
440
  auditType: constants_1.DT_EVENT_TYPES.ISSUE.CREATE.FAILED,
441
441
  auditData: {
442
442
  resource: audit_1.Resource.ISSUE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "7.10.2",
3
+ "version": "7.10.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [