dt-common-device 7.8.2 → 7.8.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.
@@ -197,10 +197,10 @@ AlertSchema.statics.findExpiredSnooze = function (includeDeleted = false) {
197
197
  };
198
198
  // Virtual for snooze status
199
199
  AlertSchema.virtual("isSnoozed").get(function () {
200
- return this.snoozeUntil && this.snoozeUntil > new Date();
200
+ return this.snoozeUntil && new Date(this.snoozeUntil) > new Date();
201
201
  });
202
202
  AlertSchema.virtual("isSnoozeExpired").get(function () {
203
- return this.snoozeUntil && this.snoozeUntil <= new Date();
203
+ return this.snoozeUntil && new Date(this.snoozeUntil) <= new Date();
204
204
  });
205
205
  // Virtual for soft delete status (different name to avoid conflict)
206
206
  AlertSchema.virtual("isNotDeleted").get(function () {
@@ -78,7 +78,7 @@ export declare class AlertService {
78
78
  /**
79
79
  * Snooze an alert with business logic
80
80
  */
81
- snoozeAlert(id: string, until: Date, updatedBy: string): Promise<IAlertDocument | null>;
81
+ snoozeAlert(id: string, updatedBy: string, until?: Date): Promise<IAlertDocument | null>;
82
82
  /**
83
83
  * Unsnooze an alert with business logic
84
84
  */
@@ -350,7 +350,7 @@ let AlertService = (() => {
350
350
  }
351
351
  // Business logic: Validate snooze date is in the future
352
352
  if (processedAlertData.snoozeUntil &&
353
- processedAlertData.snoozeUntil <= new Date()) {
353
+ new Date(processedAlertData.snoozeUntil) <= new Date()) {
354
354
  throw new Error("Snooze date must be in the future");
355
355
  }
356
356
  const existingAlert = await this.queryAlerts({
@@ -419,7 +419,7 @@ let AlertService = (() => {
419
419
  }
420
420
  const alert = await this.alertRepository.findById(id, includeDeleted);
421
421
  // Business logic: Check if alert is snoozed and expired
422
- if (alert?.snoozeUntil && alert.snoozeUntil <= new Date()) {
422
+ if (alert?.snoozeUntil && new Date(alert.snoozeUntil) <= new Date()) {
423
423
  console.warn(`Alert ${id} snooze has expired`);
424
424
  }
425
425
  return alert;
@@ -455,7 +455,7 @@ let AlertService = (() => {
455
455
  }
456
456
  // Business logic: Handle snooze validation
457
457
  if (updateData.snoozeUntil) {
458
- this.validateSnoozeDate(updateData.snoozeUntil);
458
+ this.validateSnoozeDate(new Date(updateData.snoozeUntil));
459
459
  }
460
460
  return await this.alertRepository.update(id, updateData);
461
461
  }
@@ -537,9 +537,12 @@ let AlertService = (() => {
537
537
  /**
538
538
  * Snooze an alert with business logic
539
539
  */
540
- async snoozeAlert(id, until, updatedBy) {
541
- if (!id || !until || !updatedBy) {
542
- throw new Error("Alert ID, snooze date, and updated by user are required");
540
+ async snoozeAlert(id, updatedBy, until) {
541
+ if (!id || !updatedBy) {
542
+ throw new Error("Alert ID and updated by user are required");
543
+ }
544
+ if (!until) {
545
+ until = new Date(Date.now() + 1000 * 60 * 60 * 24); // 1 day
543
546
  }
544
547
  // Business logic: Validate snooze date
545
548
  this.validateSnoozeDate(until);
@@ -726,7 +729,7 @@ let AlertService = (() => {
726
729
  }
727
730
  }
728
731
  validateSnoozeDate(snoozeUntil) {
729
- if (snoozeUntil <= new Date()) {
732
+ if (snoozeUntil && snoozeUntil <= new Date()) {
730
733
  throw new Error("Snooze date must be in the future");
731
734
  }
732
735
  }
@@ -72,7 +72,7 @@ export interface UpdateAlertData {
72
72
  type?: AlertType;
73
73
  isRead?: boolean;
74
74
  isActive?: boolean;
75
- snoozeUntil?: Date;
75
+ snoozeUntil?: string;
76
76
  updatedBy?: string;
77
77
  }
78
78
  export interface IAlertQuery {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "7.8.2",
3
+ "version": "7.8.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [