dt-common-device 7.8.2 → 7.8.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.
|
@@ -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 () {
|
|
@@ -68,6 +68,8 @@ let AlertRepository = (() => {
|
|
|
68
68
|
query.isRead = filters.isRead;
|
|
69
69
|
if (!filters.includeDeleted)
|
|
70
70
|
query.isDeleted = false;
|
|
71
|
+
if (!filters.includeSnoozed)
|
|
72
|
+
query.snoozeUntil = { $exists: false, $eq: null };
|
|
71
73
|
if (filters.type) {
|
|
72
74
|
if (Array.isArray(filters.type)) {
|
|
73
75
|
query.type = { $in: filters.type };
|
|
@@ -78,7 +78,7 @@ export declare class AlertService {
|
|
|
78
78
|
/**
|
|
79
79
|
* Snooze an alert with business logic
|
|
80
80
|
*/
|
|
81
|
-
snoozeAlert(id: string,
|
|
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,
|
|
541
|
-
if (!id || !
|
|
542
|
-
throw new Error("Alert ID
|
|
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
|
}
|
|
@@ -747,6 +750,10 @@ let AlertService = (() => {
|
|
|
747
750
|
if (!enhancedFilters.includeDeleted) {
|
|
748
751
|
enhancedFilters.includeDeleted = false;
|
|
749
752
|
}
|
|
753
|
+
// Example: Always exclude snoozed alerts unless explicitly requested
|
|
754
|
+
if (!enhancedFilters.includeSnoozed) {
|
|
755
|
+
enhancedFilters.includeSnoozed = false;
|
|
756
|
+
}
|
|
750
757
|
return enhancedFilters;
|
|
751
758
|
}
|
|
752
759
|
};
|
|
@@ -72,7 +72,7 @@ export interface UpdateAlertData {
|
|
|
72
72
|
type?: AlertType;
|
|
73
73
|
isRead?: boolean;
|
|
74
74
|
isActive?: boolean;
|
|
75
|
-
snoozeUntil?:
|
|
75
|
+
snoozeUntil?: string;
|
|
76
76
|
updatedBy?: string;
|
|
77
77
|
}
|
|
78
78
|
export interface IAlertQuery {
|
|
@@ -87,6 +87,7 @@ export interface IAlertQuery {
|
|
|
87
87
|
isActive?: boolean;
|
|
88
88
|
isRead?: boolean;
|
|
89
89
|
includeDeleted?: boolean;
|
|
90
|
+
includeSnoozed?: boolean;
|
|
90
91
|
startDate?: string;
|
|
91
92
|
endDate?: string;
|
|
92
93
|
sort?: {
|