dt-common-device 7.6.4 → 7.6.5

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.
@@ -71,7 +71,7 @@ export declare class AlertService {
71
71
  /**
72
72
  * Deactivate an alert with business logic
73
73
  */
74
- deactivateAlert(id: string, updatedBy: string): Promise<IAlertDocument | null>;
74
+ deactivateAlert(query: IAlertQuery, updatedBy: string): Promise<IAlertDocument | null>;
75
75
  /**
76
76
  * Snooze an alert with business logic
77
77
  */
@@ -483,15 +483,20 @@ let AlertService = (() => {
483
483
  /**
484
484
  * Deactivate an alert with business logic
485
485
  */
486
- async deactivateAlert(id, updatedBy) {
487
- if (!id || !updatedBy) {
488
- throw new Error("Alert ID and updated by user are required");
486
+ async deactivateAlert(query, updatedBy) {
487
+ if (!query || !updatedBy)
488
+ throw new Error("Alert query and updated by user are required");
489
+ const alerts = await this.queryAlerts(query);
490
+ if (!alerts.length)
491
+ return null;
492
+ if (alerts.length > 1) {
493
+ throw new Error("Multiple alerts found, please specify a more specific query");
489
494
  }
490
- const alertModel = await Alert_model_1.AlertModel.findById(id);
491
- if (!alertModel)
495
+ const alert = await Alert_model_1.AlertModel.findById(alerts[0]._id);
496
+ if (!alert)
492
497
  return null;
493
- alertModel.deactivate(updatedBy);
494
- return await alertModel.save();
498
+ alert.deactivate(updatedBy);
499
+ return await alert.save();
495
500
  }
496
501
  /**
497
502
  * Snooze an alert with business logic
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "7.6.4",
3
+ "version": "7.6.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [