dt-common-device 5.1.7 → 6.0.0

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.
Files changed (49) hide show
  1. package/dist/alerts/Alert.model.d.ts +1 -6
  2. package/dist/alerts/Alert.model.js +1 -35
  3. package/dist/alerts/Alert.repository.d.ts +4 -46
  4. package/dist/alerts/Alert.repository.js +29 -102
  5. package/dist/alerts/Alert.service.d.ts +3 -35
  6. package/dist/alerts/Alert.service.js +39 -54
  7. package/dist/alerts/AlertBuilder.d.ts +10 -10
  8. package/dist/alerts/AlertBuilder.js +1 -0
  9. package/dist/alerts/alert.types.d.ts +15 -0
  10. package/dist/audit/AuditUtils.js +7 -10
  11. package/dist/config/config.js +5 -0
  12. package/dist/config/config.types.d.ts +1 -1
  13. package/dist/config/constants.d.ts +9 -0
  14. package/dist/config/constants.js +9 -0
  15. package/dist/constants/Event.d.ts +12 -0
  16. package/dist/constants/Event.js +12 -0
  17. package/dist/entities/admin/Admin.repository.d.ts +4 -0
  18. package/dist/entities/admin/Admin.repository.js +31 -0
  19. package/dist/entities/admin/Admin.service.d.ts +4 -0
  20. package/dist/entities/admin/Admin.service.js +27 -0
  21. package/dist/entities/admin/IAdmin.d.ts +39 -0
  22. package/dist/entities/admin/IAdmin.js +2 -0
  23. package/dist/entities/admin/index.d.ts +1 -0
  24. package/dist/entities/admin/index.js +1 -0
  25. package/dist/entities/device/local/interfaces/IDevice.d.ts +12 -0
  26. package/dist/entities/device/local/services/Device.service.d.ts +3 -4
  27. package/dist/entities/device/local/services/Device.service.js +59 -9
  28. package/dist/entities/pms/IPms.d.ts +26 -0
  29. package/dist/entities/pms/index.d.ts +1 -0
  30. package/dist/entities/pms/index.js +1 -0
  31. package/dist/entities/pms/pms.repository.d.ts +8 -0
  32. package/dist/entities/pms/pms.repository.js +98 -0
  33. package/dist/entities/pms/pms.service.d.ts +8 -0
  34. package/dist/entities/pms/pms.service.js +124 -0
  35. package/dist/events/BaseEventHandler.d.ts +2 -2
  36. package/dist/events/BaseEventHandler.js +21 -10
  37. package/dist/issues/Issue.model.d.ts +1 -5
  38. package/dist/issues/Issue.model.js +0 -28
  39. package/dist/issues/Issue.repository.d.ts +4 -42
  40. package/dist/issues/Issue.repository.js +29 -79
  41. package/dist/issues/Issue.service.d.ts +12 -40
  42. package/dist/issues/Issue.service.js +179 -145
  43. package/dist/issues/IssueBuilder.d.ts +11 -11
  44. package/dist/issues/IssueBuilder.js +10 -2
  45. package/dist/issues/IssueService.example.js +128 -15
  46. package/dist/issues/index.d.ts +1 -0
  47. package/dist/issues/index.js +1 -0
  48. package/dist/issues/issue.types.d.ts +17 -2
  49. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import mongoose, { Model } from "mongoose";
2
- import { AlertCategory, AlertSeverity, EntityType, AlertDocument as IAlertDocument, CreateAlertData, UpdateAlertData } from "./alert.types";
2
+ import { AlertCategory, AlertDocument as IAlertDocument, CreateAlertData, UpdateAlertData } from "./alert.types";
3
3
  interface IAlertMethods {
4
4
  markAsRead(updatedBy: string): void;
5
5
  markAsUnread(updatedBy: string): void;
@@ -9,12 +9,7 @@ interface IAlertMethods {
9
9
  unsnooze(updatedBy: string): void;
10
10
  }
11
11
  interface IAlertModel extends Model<IAlertDocument, {}, IAlertMethods> {
12
- findByProperty(propertyId: string, includeDeleted?: boolean): Promise<IAlertDocument[]>;
13
- findByEntity(entityId: string, entityType: EntityType, includeDeleted?: boolean): Promise<IAlertDocument[]>;
14
12
  findByCategory(category: AlertCategory, includeDeleted?: boolean): Promise<IAlertDocument[]>;
15
- findBySeverity(severity: AlertSeverity, includeDeleted?: boolean): Promise<IAlertDocument[]>;
16
- findActive(includeDeleted?: boolean): Promise<IAlertDocument[]>;
17
- findUnread(includeDeleted?: boolean): Promise<IAlertDocument[]>;
18
13
  findSnoozed(includeDeleted?: boolean): Promise<IAlertDocument[]>;
19
14
  findExpiredSnooze(includeDeleted?: boolean): Promise<IAlertDocument[]>;
20
15
  }
@@ -67,6 +67,7 @@ const AlertSchema = new mongoose_1.Schema({
67
67
  entityId: {
68
68
  type: String,
69
69
  index: true,
70
+ required: true,
70
71
  },
71
72
  entityType: {
72
73
  type: String,
@@ -155,20 +156,6 @@ AlertSchema.methods.unsnooze = function (updatedBy) {
155
156
  this.updatedBy = updatedBy;
156
157
  };
157
158
  // Static methods
158
- AlertSchema.statics.findByProperty = function (propertyId, includeDeleted = false) {
159
- const query = { propertyId };
160
- if (!includeDeleted) {
161
- query.isDeleted = false;
162
- }
163
- return this.find(query).sort({ createdAt: -1 });
164
- };
165
- AlertSchema.statics.findByEntity = function (entityId, entityType, includeDeleted = false) {
166
- const query = { entityId, entityType };
167
- if (!includeDeleted) {
168
- query.isDeleted = false;
169
- }
170
- return this.find(query).sort({ createdAt: -1 });
171
- };
172
159
  AlertSchema.statics.findByCategory = function (category, includeDeleted = false) {
173
160
  const query = { category: { $in: [category] } };
174
161
  if (!includeDeleted) {
@@ -176,27 +163,6 @@ AlertSchema.statics.findByCategory = function (category, includeDeleted = false)
176
163
  }
177
164
  return this.find(query).sort({ createdAt: -1 });
178
165
  };
179
- AlertSchema.statics.findBySeverity = function (severity, includeDeleted = false) {
180
- const query = { severity };
181
- if (!includeDeleted) {
182
- query.isDeleted = false;
183
- }
184
- return this.find(query).sort({ severity: -1, createdAt: -1 });
185
- };
186
- AlertSchema.statics.findActive = function (includeDeleted = false) {
187
- const query = { isActive: true };
188
- if (!includeDeleted) {
189
- query.isDeleted = false;
190
- }
191
- return this.find(query).sort({ severity: -1, createdAt: -1 });
192
- };
193
- AlertSchema.statics.findUnread = function (includeDeleted = false) {
194
- const query = { isRead: false };
195
- if (!includeDeleted) {
196
- query.isDeleted = false;
197
- }
198
- return this.find(query).sort({ severity: -1, createdAt: -1 });
199
- };
200
166
  AlertSchema.statics.findSnoozed = function (includeDeleted = false) {
201
167
  const query = { snoozeUntil: { $exists: true, $ne: null } };
202
168
  if (!includeDeleted) {
@@ -1,6 +1,7 @@
1
1
  import { IAlertDocument } from "./Alert.model";
2
- import { CreateAlertData, UpdateAlertData, AlertCategory, AlertSeverity, EntityType } from "./alert.types";
2
+ import { CreateAlertData, UpdateAlertData, AlertCategory, AlertSeverity, IAlertQuery } from "./alert.types";
3
3
  export declare class AlertRepository {
4
+ private buildQuery;
4
5
  /**
5
6
  * Create a new alert
6
7
  */
@@ -12,21 +13,7 @@ export declare class AlertRepository {
12
13
  /**
13
14
  * Find all alerts with filters
14
15
  */
15
- findAll(filters?: {
16
- propertyId?: string;
17
- category?: AlertCategory | AlertCategory[];
18
- severity?: AlertSeverity;
19
- entityType?: EntityType;
20
- entityId?: string;
21
- isActive?: boolean;
22
- isRead?: boolean;
23
- includeDeleted?: boolean;
24
- limit?: number;
25
- skip?: number;
26
- sort?: {
27
- [key: string]: 1 | -1;
28
- };
29
- }): Promise<IAlertDocument[]>;
16
+ query(filters?: IAlertQuery): Promise<IAlertDocument[]>;
30
17
  /**
31
18
  * Update an alert
32
19
  */
@@ -42,40 +29,11 @@ export declare class AlertRepository {
42
29
  /**
43
30
  * Count alerts with filters
44
31
  */
45
- count(filters?: {
46
- propertyId?: string;
47
- category?: AlertCategory | AlertCategory[];
48
- severity?: AlertSeverity;
49
- entityType?: EntityType;
50
- entityId?: string;
51
- isActive?: boolean;
52
- isRead?: boolean;
53
- includeDeleted?: boolean;
54
- }): Promise<number>;
55
- /**
56
- * Find alerts by property
57
- */
58
- findByProperty(propertyId: string, includeDeleted?: boolean): Promise<IAlertDocument[]>;
59
- /**
60
- * Find alerts by entity
61
- */
62
- findByEntity(entityId: string, entityType: EntityType, includeDeleted?: boolean): Promise<IAlertDocument[]>;
32
+ count(filters?: IAlertQuery): Promise<number>;
63
33
  /**
64
34
  * Find alerts by category
65
35
  */
66
36
  findByCategory(category: AlertCategory | AlertCategory[], includeDeleted?: boolean): Promise<IAlertDocument[]>;
67
- /**
68
- * Find alerts by severity
69
- */
70
- findBySeverity(severity: AlertSeverity, includeDeleted?: boolean): Promise<IAlertDocument[]>;
71
- /**
72
- * Find active alerts
73
- */
74
- findActive(includeDeleted?: boolean): Promise<IAlertDocument[]>;
75
- /**
76
- * Find unread alerts
77
- */
78
- findUnread(includeDeleted?: boolean): Promise<IAlertDocument[]>;
79
37
  /**
80
38
  * Find snoozed alerts
81
39
  */
@@ -48,6 +48,32 @@ let AlertRepository = (() => {
48
48
  let _classExtraInitializers = [];
49
49
  let _classThis;
50
50
  var AlertRepository = _classThis = class {
51
+ async buildQuery(filters = {}) {
52
+ const query = {};
53
+ if (filters.propertyId)
54
+ query.propertyId = filters.propertyId;
55
+ if (filters.category) {
56
+ if (Array.isArray(filters.category)) {
57
+ query.category = { $in: filters.category };
58
+ }
59
+ else {
60
+ query.category = { $in: [filters.category] };
61
+ }
62
+ }
63
+ if (filters.severity)
64
+ query.severity = filters.severity;
65
+ if (filters.entityType)
66
+ query.entityType = filters.entityType;
67
+ if (filters.entityId)
68
+ query.entityId = filters.entityId;
69
+ if (filters.isActive !== undefined)
70
+ query.isActive = filters.isActive;
71
+ if (filters.isRead !== undefined)
72
+ query.isRead = filters.isRead;
73
+ if (!filters.includeDeleted)
74
+ query.isDeleted = false;
75
+ return query;
76
+ }
51
77
  /**
52
78
  * Create a new alert
53
79
  */
@@ -84,31 +110,9 @@ let AlertRepository = (() => {
84
110
  /**
85
111
  * Find all alerts with filters
86
112
  */
87
- async findAll(filters = {}) {
113
+ async query(filters = {}) {
88
114
  try {
89
- const query = {};
90
- if (filters.propertyId)
91
- query.propertyId = filters.propertyId;
92
- if (filters.category) {
93
- if (Array.isArray(filters.category)) {
94
- query.category = { $in: filters.category };
95
- }
96
- else {
97
- query.category = { $in: [filters.category] };
98
- }
99
- }
100
- if (filters.severity)
101
- query.severity = filters.severity;
102
- if (filters.entityType)
103
- query.entityType = filters.entityType;
104
- if (filters.entityId)
105
- query.entityId = filters.entityId;
106
- if (filters.isActive !== undefined)
107
- query.isActive = filters.isActive;
108
- if (filters.isRead !== undefined)
109
- query.isRead = filters.isRead;
110
- if (!filters.includeDeleted)
111
- query.isDeleted = false;
115
+ const query = await this.buildQuery(filters);
112
116
  const queryBuilder = Alert_model_1.AlertModel.find(query);
113
117
  if (filters.sort) {
114
118
  queryBuilder.sort(filters.sort);
@@ -170,57 +174,13 @@ let AlertRepository = (() => {
170
174
  */
171
175
  async count(filters = {}) {
172
176
  try {
173
- const query = {};
174
- if (filters.propertyId)
175
- query.propertyId = filters.propertyId;
176
- if (filters.category) {
177
- if (Array.isArray(filters.category)) {
178
- query.category = { $in: filters.category };
179
- }
180
- else {
181
- query.category = { $in: [filters.category] };
182
- }
183
- }
184
- if (filters.severity)
185
- query.severity = filters.severity;
186
- if (filters.entityType)
187
- query.entityType = filters.entityType;
188
- if (filters.entityId)
189
- query.entityId = filters.entityId;
190
- if (filters.isActive !== undefined)
191
- query.isActive = filters.isActive;
192
- if (filters.isRead !== undefined)
193
- query.isRead = filters.isRead;
194
- if (!filters.includeDeleted)
195
- query.isDeleted = false;
177
+ const query = await this.buildQuery(filters);
196
178
  return await Alert_model_1.AlertModel.countDocuments(query);
197
179
  }
198
180
  catch (error) {
199
181
  throw new Error(`Failed to count alerts: ${error instanceof Error ? error.message : "Unknown error"}`);
200
182
  }
201
183
  }
202
- /**
203
- * Find alerts by property
204
- */
205
- async findByProperty(propertyId, includeDeleted = false) {
206
- try {
207
- return await Alert_model_1.AlertModel.findByProperty(propertyId, includeDeleted);
208
- }
209
- catch (error) {
210
- throw new Error(`Failed to find alerts by property: ${error instanceof Error ? error.message : "Unknown error"}`);
211
- }
212
- }
213
- /**
214
- * Find alerts by entity
215
- */
216
- async findByEntity(entityId, entityType, includeDeleted = false) {
217
- try {
218
- return await Alert_model_1.AlertModel.findByEntity(entityId, entityType, includeDeleted);
219
- }
220
- catch (error) {
221
- throw new Error(`Failed to find alerts by entity: ${error instanceof Error ? error.message : "Unknown error"}`);
222
- }
223
- }
224
184
  /**
225
185
  * Find alerts by category
226
186
  */
@@ -242,39 +202,6 @@ let AlertRepository = (() => {
242
202
  throw new Error(`Failed to find alerts by category: ${error instanceof Error ? error.message : "Unknown error"}`);
243
203
  }
244
204
  }
245
- /**
246
- * Find alerts by severity
247
- */
248
- async findBySeverity(severity, includeDeleted = false) {
249
- try {
250
- return await Alert_model_1.AlertModel.findBySeverity(severity, includeDeleted);
251
- }
252
- catch (error) {
253
- throw new Error(`Failed to find alerts by severity: ${error instanceof Error ? error.message : "Unknown error"}`);
254
- }
255
- }
256
- /**
257
- * Find active alerts
258
- */
259
- async findActive(includeDeleted = false) {
260
- try {
261
- return await Alert_model_1.AlertModel.findActive(includeDeleted);
262
- }
263
- catch (error) {
264
- throw new Error(`Failed to find active alerts: ${error instanceof Error ? error.message : "Unknown error"}`);
265
- }
266
- }
267
- /**
268
- * Find unread alerts
269
- */
270
- async findUnread(includeDeleted = false) {
271
- try {
272
- return await Alert_model_1.AlertModel.findUnread(includeDeleted);
273
- }
274
- catch (error) {
275
- throw new Error(`Failed to find unread alerts: ${error instanceof Error ? error.message : "Unknown error"}`);
276
- }
277
- }
278
205
  /**
279
206
  * Find snoozed alerts
280
207
  */
@@ -1,12 +1,11 @@
1
- import { AlertRepository } from "./Alert.repository";
2
1
  import { IAlertDocument } from "./Alert.model";
3
- import { CreateAlertData, UpdateAlertData, AlertCategory, AlertSeverity, EntityType } from "./alert.types";
2
+ import { CreateAlertData, UpdateAlertData, AlertCategory, AlertSeverity, EntityType, IAlertQuery } from "./alert.types";
4
3
  import { Source } from "../constants/Service";
5
4
  import { AlertBuilder } from "./AlertBuilder";
6
5
  import { IDevice } from "../entities/device/local/interfaces";
7
6
  export declare class AlertService {
8
7
  private readonly alertRepository;
9
- constructor(alertRepository: AlertRepository);
8
+ constructor();
10
9
  /**
11
10
  * Create a readiness alert using AlertBuilder
12
11
  */
@@ -59,18 +58,7 @@ export declare class AlertService {
59
58
  /**
60
59
  * Get all alerts with business logic filtering
61
60
  */
62
- getAlerts(filters?: {
63
- propertyId?: string;
64
- category?: AlertCategory | AlertCategory[];
65
- severity?: AlertSeverity;
66
- entityType?: EntityType;
67
- entityId?: string;
68
- isActive?: boolean;
69
- isRead?: boolean;
70
- includeDeleted?: boolean;
71
- limit?: number;
72
- skip?: number;
73
- }): Promise<IAlertDocument[]>;
61
+ queryAlerts(filters?: IAlertQuery): Promise<IAlertDocument[]>;
74
62
  /**
75
63
  * Update an alert with business logic validation
76
64
  */
@@ -103,30 +91,10 @@ export declare class AlertService {
103
91
  * Unsnooze an alert with business logic
104
92
  */
105
93
  unsnoozeAlert(id: string, updatedBy: string): Promise<IAlertDocument | null>;
106
- /**
107
- * Get alerts by property with business logic
108
- */
109
- getAlertsByProperty(propertyId: string, includeDeleted?: boolean): Promise<IAlertDocument[]>;
110
- /**
111
- * Get alerts by entity with business logic
112
- */
113
- getAlertsByEntity(entityId: string, entityType: EntityType, includeDeleted?: boolean): Promise<IAlertDocument[]>;
114
94
  /**
115
95
  * Get alerts by category with business logic
116
96
  */
117
97
  getAlertsByCategory(category: AlertCategory | AlertCategory[], includeDeleted?: boolean): Promise<IAlertDocument[]>;
118
- /**
119
- * Get alerts by severity with business logic
120
- */
121
- getAlertsBySeverity(severity: AlertSeverity, includeDeleted?: boolean): Promise<IAlertDocument[]>;
122
- /**
123
- * Get active alerts with business logic
124
- */
125
- getActiveAlerts(includeDeleted?: boolean): Promise<IAlertDocument[]>;
126
- /**
127
- * Get unread alerts with business logic
128
- */
129
- getUnreadAlerts(includeDeleted?: boolean): Promise<IAlertDocument[]>;
130
98
  /**
131
99
  * Get snoozed alerts with business logic
132
100
  */
@@ -1,4 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
19
  function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
20
  var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
@@ -33,13 +49,31 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
33
49
  }
34
50
  return useValue ? value : void 0;
35
51
  };
52
+ var __importStar = (this && this.__importStar) || (function () {
53
+ var ownKeys = function(o) {
54
+ ownKeys = Object.getOwnPropertyNames || function (o) {
55
+ var ar = [];
56
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
57
+ return ar;
58
+ };
59
+ return ownKeys(o);
60
+ };
61
+ return function (mod) {
62
+ if (mod && mod.__esModule) return mod;
63
+ var result = {};
64
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
65
+ __setModuleDefault(result, mod);
66
+ return result;
67
+ };
68
+ })();
36
69
  var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
70
  if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
71
  return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
72
  };
40
73
  Object.defineProperty(exports, "__esModule", { value: true });
41
74
  exports.AlertService = void 0;
42
- const typedi_1 = require("typedi");
75
+ const typedi_1 = __importStar(require("typedi"));
76
+ const Alert_repository_1 = require("./Alert.repository");
43
77
  const Alert_model_1 = require("./Alert.model");
44
78
  const alert_types_1 = require("./alert.types");
45
79
  const AlertBuilder_1 = require("./AlertBuilder");
@@ -49,8 +83,8 @@ let AlertService = (() => {
49
83
  let _classExtraInitializers = [];
50
84
  let _classThis;
51
85
  var AlertService = _classThis = class {
52
- constructor(alertRepository) {
53
- this.alertRepository = alertRepository;
86
+ constructor() {
87
+ this.alertRepository = typedi_1.default.get(Alert_repository_1.AlertRepository);
54
88
  }
55
89
  /**
56
90
  * Create a readiness alert using AlertBuilder
@@ -213,12 +247,12 @@ let AlertService = (() => {
213
247
  /**
214
248
  * Get all alerts with business logic filtering
215
249
  */
216
- async getAlerts(filters = {}) {
250
+ async queryAlerts(filters = {}) {
217
251
  // Business logic: Validate filters
218
252
  this.validateFilters(filters);
219
253
  // Business logic: Apply business rules to filters
220
254
  const enhancedFilters = this.applyBusinessRules(filters);
221
- return await this.alertRepository.findAll(enhancedFilters);
255
+ return await this.alertRepository.query(enhancedFilters);
222
256
  }
223
257
  /**
224
258
  * Update an alert with business logic validation
@@ -338,24 +372,6 @@ let AlertService = (() => {
338
372
  alertModel.unsnooze(updatedBy);
339
373
  return await alertModel.save();
340
374
  }
341
- /**
342
- * Get alerts by property with business logic
343
- */
344
- async getAlertsByProperty(propertyId, includeDeleted = false) {
345
- if (!propertyId) {
346
- throw new Error("Property ID is required");
347
- }
348
- return await this.alertRepository.findByProperty(propertyId, includeDeleted);
349
- }
350
- /**
351
- * Get alerts by entity with business logic
352
- */
353
- async getAlertsByEntity(entityId, entityType, includeDeleted = false) {
354
- if (!entityId || !entityType) {
355
- throw new Error("Entity ID and entity type are required");
356
- }
357
- return await this.alertRepository.findByEntity(entityId, entityType, includeDeleted);
358
- }
359
375
  /**
360
376
  * Get alerts by category with business logic
361
377
  */
@@ -365,37 +381,6 @@ let AlertService = (() => {
365
381
  }
366
382
  return await this.alertRepository.findByCategory(category, includeDeleted);
367
383
  }
368
- /**
369
- * Get alerts by severity with business logic
370
- */
371
- async getAlertsBySeverity(severity, includeDeleted = false) {
372
- if (!severity) {
373
- throw new Error("Alert severity is required");
374
- }
375
- return await this.alertRepository.findBySeverity(severity, includeDeleted);
376
- }
377
- /**
378
- * Get active alerts with business logic
379
- */
380
- async getActiveAlerts(includeDeleted = false) {
381
- const activeAlerts = await this.alertRepository.findActive(includeDeleted);
382
- // Business logic: Log active alerts for monitoring
383
- if (activeAlerts.length > 0) {
384
- console.log(`Found ${activeAlerts.length} active alerts`);
385
- }
386
- return activeAlerts;
387
- }
388
- /**
389
- * Get unread alerts with business logic
390
- */
391
- async getUnreadAlerts(includeDeleted = false) {
392
- const unreadAlerts = await this.alertRepository.findUnread(includeDeleted);
393
- // Business logic: Log unread alerts for monitoring
394
- if (unreadAlerts.length > 0) {
395
- console.warn(`Found ${unreadAlerts.length} unread alerts`);
396
- }
397
- return unreadAlerts;
398
- }
399
384
  /**
400
385
  * Get snoozed alerts with business logic
401
386
  */
@@ -23,39 +23,39 @@ export declare class AlertBuilder {
23
23
  /**
24
24
  * Sets the alert category
25
25
  */
26
- setCategory(category: AlertCategory | AlertCategory[]): AlertBuilder;
26
+ setCategory(category: AlertCategory | AlertCategory[]): this;
27
27
  /**
28
28
  * Sets the property ID
29
29
  */
30
- setPropertyId(propertyId: string): AlertBuilder;
30
+ setPropertyId(propertyId: string): this;
31
31
  /**
32
32
  * Sets the alert title
33
33
  */
34
- setTitle(title: string): AlertBuilder;
34
+ setTitle(title: string): this;
35
35
  /**
36
36
  * Sets the alert description
37
37
  */
38
- setDescription(description: string): AlertBuilder;
38
+ setDescription(description: string): this;
39
39
  /**
40
40
  * Sets the entity ID (optional)
41
41
  */
42
- setEntityId(entityId?: string): AlertBuilder;
42
+ setEntityId(entityId?: string): this;
43
43
  /**
44
44
  * Sets the entity type
45
45
  */
46
- setEntityType(entityType: EntityType): AlertBuilder;
46
+ setEntityType(entityType: EntityType): this;
47
47
  /**
48
48
  * Sets the alert severity (optional, defaults to MEDIUM)
49
49
  */
50
- setSeverity(severity?: AlertSeverity): AlertBuilder;
50
+ setSeverity(severity?: AlertSeverity): this;
51
51
  /**
52
52
  * Sets the user who created the alert (optional)
53
53
  */
54
- setCreatedBy(createdBy?: string): AlertBuilder;
54
+ setCreatedBy(createdBy?: string): this;
55
55
  /**
56
56
  * Sets the snooze until date (optional)
57
57
  */
58
- setSnoozeUntil(snoozeUntil?: Date): AlertBuilder;
58
+ setSnoozeUntil(snoozeUntil?: Date): this;
59
59
  /**
60
60
  * Validates that all required fields are present
61
61
  */
@@ -68,7 +68,7 @@ export declare class AlertBuilder {
68
68
  /**
69
69
  * Resets the builder to its initial state
70
70
  */
71
- reset(): AlertBuilder;
71
+ reset(): this;
72
72
  /**
73
73
  * Creates a new builder instance with predefined values for common alert types
74
74
  */
@@ -115,6 +115,7 @@ class AlertBuilder {
115
115
  "title",
116
116
  "description",
117
117
  "entityType",
118
+ "entityId",
118
119
  ];
119
120
  const missingFields = requiredFields.filter((field) => !this.data[field]);
120
121
  if (missingFields.length > 0) {
@@ -54,4 +54,19 @@ export interface UpdateAlertData {
54
54
  snoozeUntil?: Date;
55
55
  updatedBy?: string;
56
56
  }
57
+ export interface IAlertQuery {
58
+ propertyId?: string;
59
+ category?: AlertCategory | AlertCategory[];
60
+ severity?: AlertSeverity;
61
+ entityType?: EntityType;
62
+ entityId?: string;
63
+ isActive?: boolean;
64
+ isRead?: boolean;
65
+ includeDeleted?: boolean;
66
+ sort?: {
67
+ [key: string]: 1 | -1;
68
+ };
69
+ limit?: number;
70
+ skip?: number;
71
+ }
57
72
  export { EntityType } from "../issues/issue.types";
@@ -74,13 +74,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
74
74
  exports.AuditUtils = void 0;
75
75
  const property_1 = require("../entities/property");
76
76
  const redis_utils_1 = require("../utils/redis.utils");
77
- const User_service_1 = require("../entities/user/User.service");
78
77
  const services_1 = require("../entities/device/local/services");
79
- const accessGroup_1 = require("../entities/accessGroup");
80
- const zone_1 = require("../entities/zone");
81
- const schedules_1 = require("../entities/schedules");
82
- const guest_1 = require("../entities/guest");
83
78
  const typedi_1 = __importStar(require("typedi"));
79
+ const pms_1 = require("../entities/pms");
80
+ const admin_1 = require("../entities/admin");
84
81
  let AuditUtils = (() => {
85
82
  let _classDecorators = [(0, typedi_1.Service)()];
86
83
  let _classDescriptor;
@@ -209,7 +206,7 @@ let AuditUtils = (() => {
209
206
  }
210
207
  async getUserName(userId) {
211
208
  return this.getCachedEntityData("user", userId, async () => {
212
- const user = await typedi_1.default.get(User_service_1.UserService).getUser(userId);
209
+ const user = await typedi_1.default.get(admin_1.AdminService).getUser(userId);
213
210
  if (!user)
214
211
  return "";
215
212
  return `${user?.firstName || ""} ${user?.lastName || ""}`.trim();
@@ -217,7 +214,7 @@ let AuditUtils = (() => {
217
214
  }
218
215
  async getGuestName(guestId) {
219
216
  return this.getCachedEntityData("guest", guestId, async () => {
220
- const guest = await typedi_1.default.get(guest_1.GuestService).getGuest(guestId);
217
+ const guest = await typedi_1.default.get(pms_1.PmsService).getGuest(guestId);
221
218
  if (!guest)
222
219
  return "";
223
220
  return `${guest?.firstName || ""} ${guest?.lastName || ""}`.trim();
@@ -233,7 +230,7 @@ let AuditUtils = (() => {
233
230
  }
234
231
  async getZoneName(zoneId) {
235
232
  return this.getCachedEntityData("zone", zoneId, async () => {
236
- const zone = await typedi_1.default.get(zone_1.ZoneService).getZone(zoneId);
233
+ const zone = await typedi_1.default.get(admin_1.AdminService).getZone(zoneId);
237
234
  if (!zone)
238
235
  return "";
239
236
  return zone?.name || "";
@@ -241,7 +238,7 @@ let AuditUtils = (() => {
241
238
  }
242
239
  async getAccessGroupName(accessGroupId) {
243
240
  return this.getCachedEntityData("accessGroup", accessGroupId, async () => {
244
- const accessGroup = await typedi_1.default.get(accessGroup_1.AccessGroupService).getAccessGroup(accessGroupId);
241
+ const accessGroup = await typedi_1.default.get(admin_1.AdminService).getAccessGroup(accessGroupId);
245
242
  if (!accessGroup)
246
243
  return "";
247
244
  return accessGroup?.name || "";
@@ -249,7 +246,7 @@ let AuditUtils = (() => {
249
246
  }
250
247
  async getScheduleDetails(scheduleId) {
251
248
  return this.getCachedEntityData("schedule", scheduleId, async () => {
252
- const schedule = await typedi_1.default.get(schedules_1.ScheduleService).getSchedule(scheduleId);
249
+ const schedule = await typedi_1.default.get(pms_1.PmsService).getSchedule(scheduleId);
253
250
  if (!schedule) {
254
251
  return {
255
252
  scheduleStartDate: "",