dt-common-device 5.1.6 → 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 +10 -1
  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
@@ -0,0 +1,124 @@
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
+ });
18
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
19
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
20
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
21
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
22
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
23
+ var _, done = false;
24
+ for (var i = decorators.length - 1; i >= 0; i--) {
25
+ var context = {};
26
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
27
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
28
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
29
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
30
+ if (kind === "accessor") {
31
+ if (result === void 0) continue;
32
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
33
+ if (_ = accept(result.get)) descriptor.get = _;
34
+ if (_ = accept(result.set)) descriptor.set = _;
35
+ if (_ = accept(result.init)) initializers.unshift(_);
36
+ }
37
+ else if (_ = accept(result)) {
38
+ if (kind === "field") initializers.unshift(_);
39
+ else descriptor[key] = _;
40
+ }
41
+ }
42
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
43
+ done = true;
44
+ };
45
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
46
+ var useValue = arguments.length > 2;
47
+ for (var i = 0; i < initializers.length; i++) {
48
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
49
+ }
50
+ return useValue ? value : void 0;
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
+ })();
69
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
70
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
71
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
72
+ };
73
+ Object.defineProperty(exports, "__esModule", { value: true });
74
+ exports.PmsService = void 0;
75
+ const typedi_1 = __importStar(require("typedi"));
76
+ const pms_repository_1 = require("./pms.repository");
77
+ let PmsService = (() => {
78
+ let _classDecorators = [(0, typedi_1.Service)()];
79
+ let _classDescriptor;
80
+ let _classExtraInitializers = [];
81
+ let _classThis;
82
+ var PmsService = _classThis = class {
83
+ constructor() {
84
+ this.pmsRepository = typedi_1.default.get(pms_repository_1.PmsRepository);
85
+ }
86
+ async getSchedule(scheduleId) {
87
+ if (!scheduleId) {
88
+ throw new Error("Schedule ID is required");
89
+ }
90
+ const schedule = await this.pmsRepository.getSchedule(scheduleId);
91
+ if (!schedule)
92
+ return null;
93
+ return schedule;
94
+ }
95
+ async getGuest(guestId) {
96
+ if (!guestId) {
97
+ throw new Error("Guest ID is required");
98
+ }
99
+ const guest = await this.pmsRepository.getGuest(guestId);
100
+ if (!guest)
101
+ return null;
102
+ return guest;
103
+ }
104
+ async getGuestId(scheduleId) {
105
+ if (!scheduleId) {
106
+ throw new Error("Schedule ID is required");
107
+ }
108
+ const guestId = await this.pmsRepository.getGuestId(scheduleId);
109
+ if (!guestId)
110
+ return null;
111
+ return guestId;
112
+ }
113
+ };
114
+ __setFunctionName(_classThis, "PmsService");
115
+ (() => {
116
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
117
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
118
+ PmsService = _classThis = _classDescriptor.value;
119
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
120
+ __runInitializers(_classThis, _classExtraInitializers);
121
+ })();
122
+ return PmsService = _classThis;
123
+ })();
124
+ exports.PmsService = PmsService;
@@ -15,12 +15,12 @@ export declare abstract class BaseEventHandler implements IEventHandler {
15
15
  handleEvent(event: DeviceEvent): Promise<void>;
16
16
  beforeEvent(event: DeviceEvent): Promise<void>;
17
17
  abstract onEvent(event: DeviceEvent): Promise<void>;
18
- afterEvent(event: DeviceEvent): Promise<void>;
18
+ afterEvent(deviceId: string, event: DeviceEvent, auditBody: IAuditProperties, actionPayload: any, eventType?: string): Promise<void>;
19
19
  /**
20
20
  * Handle multiple events - default implementation processes them sequentially
21
21
  */
22
22
  handleEvents(events: DeviceEvent[]): Promise<void>;
23
- onStateChange(deviceId: string, state: Record<string, any>, event: DeviceEvent, auditProperties: IAuditProperties, eventType?: string): Promise<void>;
23
+ onStateChange(deviceId: string, state: Record<string, any>, auditProperties: IAuditProperties, eventType?: string): Promise<void>;
24
24
  /**
25
25
  * Check if this handler can process the given event type
26
26
  */
@@ -7,6 +7,9 @@ exports.BaseEventHandler = void 0;
7
7
  const config_1 = require("../config/config");
8
8
  const Device_service_1 = require("../entities/device/local/services/Device.service");
9
9
  const typedi_1 = __importDefault(require("typedi"));
10
+ const IAuditProperties_1 = require("../audit/IAuditProperties");
11
+ const audit_1 = require("../audit");
12
+ const constants_1 = require("../constants");
10
13
  class BaseEventHandler {
11
14
  constructor(supportedEventTypes, priority = 100) {
12
15
  this.supportedEventTypes = supportedEventTypes;
@@ -32,19 +35,29 @@ class BaseEventHandler {
32
35
  throw error;
33
36
  }
34
37
  finally {
35
- await this.afterEvent(event);
38
+ await this.afterEvent(event.deviceId, event, {
39
+ resource: IAuditProperties_1.Resource.DEVICE,
40
+ source: constants_1.Source.CLOUD_EVENT,
41
+ propertyId: event.data.propertyId || "",
42
+ deviceId: event.deviceId,
43
+ }, {}, event.eventName);
36
44
  }
37
45
  }
38
46
  async beforeEvent(event) {
39
47
  this.logger.info("[DT | CDL]:[BaseEventHandler]: Before event - Handle Before Event");
40
48
  }
41
- async afterEvent(event) {
42
- this.logger.info("[DT | CDL]:[BaseEventHandler]: After event - Event processing completed", {
43
- eventName: event.eventName,
44
- deviceId: event.deviceId,
45
- handler: this.constructor.name,
49
+ async afterEvent(deviceId, event, auditBody, actionPayload, eventType) {
50
+ await (0, audit_1.pushAudit)({
51
+ auditType: eventType || constants_1.DT_EVENT_TYPES.DEVICE.STATE.CHANGED,
52
+ auditData: {
53
+ ...event.data,
54
+ ...auditBody,
55
+ deviceId,
56
+ actionPayload,
57
+ connectionProvider: event.connectionProvider,
58
+ },
46
59
  });
47
- //TODO: Implement AUDIT Here!
60
+ this.logger.info("[DT | CDL]:[BaseEventHandler]: After event - Event processing completed");
48
61
  }
49
62
  /**
50
63
  * Handle multiple events - default implementation processes them sequentially
@@ -65,11 +78,9 @@ class BaseEventHandler {
65
78
  this.logger.error(`${this.constructor.name}: handleEvents Error`, error);
66
79
  }
67
80
  }
68
- // TODO: Check AuditBody for this function
69
- async onStateChange(deviceId, state, event, auditProperties, eventType) {
81
+ async onStateChange(deviceId, state, auditProperties, eventType) {
70
82
  try {
71
83
  await this.localDeviceService.setState(deviceId, state, auditProperties, eventType);
72
- await this.afterEvent(event);
73
84
  }
74
85
  catch (error) {
75
86
  this.logger.error(`[DT | CDL]:[BaseEventHandler]: Error during state change: ${error.message || error.toString()}`);
@@ -1,5 +1,5 @@
1
1
  import mongoose, { Model } from "mongoose";
2
- import { EntityType, IssueStatus, IssuePriority, IssueDocument as IIssueDocument, CreateIssueData, UpdateIssueData, AddCommentData } from "./issue.types";
2
+ import { IssueDocument as IIssueDocument, CreateIssueData, UpdateIssueData, AddCommentData } from "./issue.types";
3
3
  interface IIssueMethods {
4
4
  addComment(commentData: AddCommentData): void;
5
5
  updateComment(commentId: string, content: string, userId: string): boolean;
@@ -10,11 +10,7 @@ interface IIssueMethods {
10
10
  unassign(unassignedBy: string): void;
11
11
  }
12
12
  interface IIssueModel extends Model<IIssueDocument, {}, IIssueMethods> {
13
- findByProperty(propertyId: string, includeDeleted?: boolean): Promise<IIssueDocument[]>;
14
13
  findByAssignee(assignedTo: string, includeDeleted?: boolean): Promise<IIssueDocument[]>;
15
- findByEntity(entityId: string, entityType: EntityType, includeDeleted?: boolean): Promise<IIssueDocument[]>;
16
- findByStatus(status: IssueStatus, includeDeleted?: boolean): Promise<IIssueDocument[]>;
17
- findByPriority(priority: IssuePriority, includeDeleted?: boolean): Promise<IIssueDocument[]>;
18
14
  findOverdue(includeDeleted?: boolean): Promise<IIssueDocument[]>;
19
15
  findUpcoming(days?: number, includeDeleted?: boolean): Promise<IIssueDocument[]>;
20
16
  }
@@ -188,13 +188,6 @@ IssueSchema.methods.unassign = function (unassignedBy) {
188
188
  this.updatedBy = unassignedBy;
189
189
  };
190
190
  // Static methods
191
- IssueSchema.statics.findByProperty = function (propertyId, includeDeleted = false) {
192
- const query = { propertyId };
193
- if (!includeDeleted) {
194
- query.isDeleted = false;
195
- }
196
- return this.find(query).sort({ createdAt: -1 });
197
- };
198
191
  IssueSchema.statics.findByAssignee = function (assignedTo, includeDeleted = false) {
199
192
  const query = { assignedTo };
200
193
  if (!includeDeleted) {
@@ -202,27 +195,6 @@ IssueSchema.statics.findByAssignee = function (assignedTo, includeDeleted = fals
202
195
  }
203
196
  return this.find(query).sort({ priority: -1, createdAt: -1 });
204
197
  };
205
- IssueSchema.statics.findByEntity = function (entityId, entityType, includeDeleted = false) {
206
- const query = { entityId, entityType };
207
- if (!includeDeleted) {
208
- query.isDeleted = false;
209
- }
210
- return this.find(query).sort({ createdAt: -1 });
211
- };
212
- IssueSchema.statics.findByStatus = function (status, includeDeleted = false) {
213
- const query = { status };
214
- if (!includeDeleted) {
215
- query.isDeleted = false;
216
- }
217
- return this.find(query).sort({ priority: -1, createdAt: -1 });
218
- };
219
- IssueSchema.statics.findByPriority = function (priority, includeDeleted = false) {
220
- const query = { priority };
221
- if (!includeDeleted) {
222
- query.isDeleted = false;
223
- }
224
- return this.find(query).sort({ createdAt: -1 });
225
- };
226
198
  IssueSchema.statics.findOverdue = function (includeDeleted = false) {
227
199
  const query = {
228
200
  dueDate: { $lt: new Date() },
@@ -1,6 +1,7 @@
1
1
  import { IIssueDocument } from "./Issue.model";
2
- import { CreateIssueData, UpdateIssueData, IssueStatus, IssuePriority, IssuesCategory, EntityType } from "./issue.types";
2
+ import { CreateIssueData, UpdateIssueData, IssuePriority, IssuesCategory, IIssueQuery } from "./issue.types";
3
3
  export declare class IssueRepository {
4
+ private buildQuery;
4
5
  /**
5
6
  * Create a new issue
6
7
  */
@@ -12,21 +13,7 @@ export declare class IssueRepository {
12
13
  /**
13
14
  * Find all issues with filters
14
15
  */
15
- findAll(filters?: {
16
- propertyId?: string;
17
- assignedTo?: string;
18
- status?: IssueStatus;
19
- priority?: IssuePriority;
20
- category?: IssuesCategory;
21
- entityType?: EntityType;
22
- entityId?: string;
23
- includeDeleted?: boolean;
24
- limit?: number;
25
- skip?: number;
26
- sort?: {
27
- [key: string]: 1 | -1;
28
- };
29
- }): Promise<IIssueDocument[]>;
16
+ query(filters?: IIssueQuery): Promise<IIssueDocument[]>;
30
17
  /**
31
18
  * Update an issue
32
19
  */
@@ -42,36 +29,11 @@ export declare class IssueRepository {
42
29
  /**
43
30
  * Count issues with filters
44
31
  */
45
- count(filters?: {
46
- propertyId?: string;
47
- assignedTo?: string;
48
- status?: IssueStatus;
49
- priority?: IssuePriority;
50
- category?: IssuesCategory;
51
- entityType?: EntityType;
52
- entityId?: string;
53
- includeDeleted?: boolean;
54
- }): Promise<number>;
55
- /**
56
- * Find issues by property
57
- */
58
- findByProperty(propertyId: string, includeDeleted?: boolean): Promise<IIssueDocument[]>;
32
+ count(filters?: IIssueQuery): Promise<number>;
59
33
  /**
60
34
  * Find issues by assignee
61
35
  */
62
36
  findByAssignee(assignedTo: string, includeDeleted?: boolean): Promise<IIssueDocument[]>;
63
- /**
64
- * Find issues by entity
65
- */
66
- findByEntity(entityId: string, entityType: EntityType, includeDeleted?: boolean): Promise<IIssueDocument[]>;
67
- /**
68
- * Find issues by status
69
- */
70
- findByStatus(status: IssueStatus, includeDeleted?: boolean): Promise<IIssueDocument[]>;
71
- /**
72
- * Find issues by priority
73
- */
74
- findByPriority(priority: IssuePriority, includeDeleted?: boolean): Promise<IIssueDocument[]>;
75
37
  /**
76
38
  * Find overdue issues
77
39
  */
@@ -48,6 +48,32 @@ let IssueRepository = (() => {
48
48
  let _classExtraInitializers = [];
49
49
  let _classThis;
50
50
  var IssueRepository = _classThis = class {
51
+ async buildQuery(filters) {
52
+ const query = {};
53
+ if (filters.propertyId)
54
+ query.propertyId = filters.propertyId;
55
+ if (filters.assignedTo)
56
+ query.assignedTo = filters.assignedTo;
57
+ if (filters.status)
58
+ query.status = filters.status;
59
+ if (filters.priority)
60
+ query.priority = filters.priority;
61
+ if (filters.category)
62
+ query.category = filters.category;
63
+ if (filters.entityType)
64
+ query.entityType = filters.entityType;
65
+ if (filters.entityId)
66
+ query.entityId = filters.entityId;
67
+ if (!filters.includeDeleted)
68
+ query.isDeleted = false;
69
+ if (filters.sort)
70
+ query.sort = filters.sort;
71
+ if (filters.limit)
72
+ query.limit = filters.limit;
73
+ if (filters.skip)
74
+ query.skip = filters.skip;
75
+ return query;
76
+ }
51
77
  /**
52
78
  * Create a new issue
53
79
  */
@@ -83,25 +109,9 @@ let IssueRepository = (() => {
83
109
  /**
84
110
  * Find all issues with filters
85
111
  */
86
- async findAll(filters = {}) {
112
+ async query(filters = {}) {
87
113
  try {
88
- const query = {};
89
- if (filters.propertyId)
90
- query.propertyId = filters.propertyId;
91
- if (filters.assignedTo)
92
- query.assignedTo = filters.assignedTo;
93
- if (filters.status)
94
- query.status = filters.status;
95
- if (filters.priority)
96
- query.priority = filters.priority;
97
- if (filters.category)
98
- query.category = filters.category;
99
- if (filters.entityType)
100
- query.entityType = filters.entityType;
101
- if (filters.entityId)
102
- query.entityId = filters.entityId;
103
- if (!filters.includeDeleted)
104
- query.isDeleted = false;
114
+ const query = await this.buildQuery(filters);
105
115
  const queryBuilder = Issue_model_1.IssueModel.find(query);
106
116
  if (filters.sort) {
107
117
  queryBuilder.sort(filters.sort);
@@ -163,40 +173,13 @@ let IssueRepository = (() => {
163
173
  */
164
174
  async count(filters = {}) {
165
175
  try {
166
- const query = {};
167
- if (filters.propertyId)
168
- query.propertyId = filters.propertyId;
169
- if (filters.assignedTo)
170
- query.assignedTo = filters.assignedTo;
171
- if (filters.status)
172
- query.status = filters.status;
173
- if (filters.priority)
174
- query.priority = filters.priority;
175
- if (filters.category)
176
- query.category = filters.category;
177
- if (filters.entityType)
178
- query.entityType = filters.entityType;
179
- if (filters.entityId)
180
- query.entityId = filters.entityId;
181
- if (!filters.includeDeleted)
182
- query.isDeleted = false;
176
+ const query = await this.buildQuery(filters);
183
177
  return await Issue_model_1.IssueModel.countDocuments(query);
184
178
  }
185
179
  catch (error) {
186
180
  throw new Error(`Failed to count issues: ${error instanceof Error ? error.message : "Unknown error"}`);
187
181
  }
188
182
  }
189
- /**
190
- * Find issues by property
191
- */
192
- async findByProperty(propertyId, includeDeleted = false) {
193
- try {
194
- return await Issue_model_1.IssueModel.findByProperty(propertyId, includeDeleted);
195
- }
196
- catch (error) {
197
- throw new Error(`Failed to find issues by property: ${error instanceof Error ? error.message : "Unknown error"}`);
198
- }
199
- }
200
183
  /**
201
184
  * Find issues by assignee
202
185
  */
@@ -208,39 +191,6 @@ let IssueRepository = (() => {
208
191
  throw new Error(`Failed to find issues by assignee: ${error instanceof Error ? error.message : "Unknown error"}`);
209
192
  }
210
193
  }
211
- /**
212
- * Find issues by entity
213
- */
214
- async findByEntity(entityId, entityType, includeDeleted = false) {
215
- try {
216
- return await Issue_model_1.IssueModel.findByEntity(entityId, entityType, includeDeleted);
217
- }
218
- catch (error) {
219
- throw new Error(`Failed to find issues by entity: ${error instanceof Error ? error.message : "Unknown error"}`);
220
- }
221
- }
222
- /**
223
- * Find issues by status
224
- */
225
- async findByStatus(status, includeDeleted = false) {
226
- try {
227
- return await Issue_model_1.IssueModel.findByStatus(status, includeDeleted);
228
- }
229
- catch (error) {
230
- throw new Error(`Failed to find issues by status: ${error instanceof Error ? error.message : "Unknown error"}`);
231
- }
232
- }
233
- /**
234
- * Find issues by priority
235
- */
236
- async findByPriority(priority, includeDeleted = false) {
237
- try {
238
- return await Issue_model_1.IssueModel.findByPriority(priority, includeDeleted);
239
- }
240
- catch (error) {
241
- throw new Error(`Failed to find issues by priority: ${error instanceof Error ? error.message : "Unknown error"}`);
242
- }
243
- }
244
194
  /**
245
195
  * Find overdue issues
246
196
  */
@@ -1,40 +1,39 @@
1
- import { IssueRepository } from "./Issue.repository";
2
1
  import { IIssueDocument } from "./Issue.model";
3
- import { CreateIssueData, UpdateIssueData, AddCommentData, IssueStatus, IssuePriority, IssuesCategory, EntityType } from "./issue.types";
2
+ import { CreateIssueData, UpdateIssueData, AddCommentData, IssuePriority, IssuesCategory, IIssueQuery } from "./issue.types";
4
3
  import { IssueBuilder } from "./IssueBuilder";
5
4
  import { Source } from "../constants/Service";
6
5
  import { IDevice } from "../entities/device/local/interfaces";
7
6
  export declare class IssueService {
8
7
  private readonly issueRepository;
9
- constructor(issueRepository: IssueRepository);
8
+ constructor();
10
9
  /**
11
10
  * Create a readiness issue using IssueBuilder
12
11
  */
13
- createReadinessIssue(propertyId: string, title: string, description: string, createdBy: string, entityId?: string, entityType?: EntityType, assignedTo?: string, dueDate?: Date): Promise<IIssueDocument>;
12
+ createReadinessIssue(data: CreateIssueData): Promise<IIssueDocument>;
14
13
  /**
15
14
  * Create an operations issue using IssueBuilder
16
15
  */
17
- createOperationsIssue(propertyId: string, title: string, description: string, createdBy: string, entityId?: string, entityType?: EntityType, assignedTo?: string, dueDate?: Date): Promise<IIssueDocument>;
16
+ createOperationsIssue(data: CreateIssueData): Promise<IIssueDocument>;
18
17
  /**
19
18
  * Create a security issue using IssueBuilder
20
19
  */
21
- createSecurityIssue(propertyId: string, title: string, description: string, createdBy: string, entityId?: string, entityType?: EntityType, assignedTo?: string, dueDate?: Date): Promise<IIssueDocument>;
20
+ createSecurityIssue(data: CreateIssueData): Promise<IIssueDocument>;
22
21
  /**
23
22
  * Create an energy issue using IssueBuilder
24
23
  */
25
- createEnergyIssue(propertyId: string, title: string, description: string, createdBy: string, entityId?: string, entityType?: EntityType, assignedTo?: string, dueDate?: Date): Promise<IIssueDocument>;
24
+ createEnergyIssue(data: CreateIssueData): Promise<IIssueDocument>;
26
25
  /**
27
26
  * Create a device-specific issue using IssueBuilder
28
27
  */
29
- createDeviceIssue(deviceId: string, propertyId: string, title: string, description: string, source: Source, category?: IssuesCategory, priority?: IssuePriority, assignedTo?: string, dueDate?: Date): Promise<IIssueDocument>;
28
+ createDeviceIssue(data: CreateIssueData): Promise<IIssueDocument>;
30
29
  /**
31
30
  * Create a hub-specific issue using IssueBuilder
32
31
  */
33
- createHubIssue(hubId: string, propertyId: string, title: string, description: string, createdBy: string, category?: IssuesCategory, priority?: IssuePriority, assignedTo?: string, dueDate?: Date): Promise<IIssueDocument>;
32
+ createHubIssue(data: CreateIssueData): Promise<IIssueDocument>;
34
33
  /**
35
34
  * Create a user-specific issue using IssueBuilder
36
35
  */
37
- createUserIssue(userId: string, propertyId: string, title: string, description: string, createdBy: string, category?: IssuesCategory, priority?: IssuePriority, assignedTo?: string, dueDate?: Date): Promise<IIssueDocument>;
36
+ createUserIssue(data: CreateIssueData): Promise<IIssueDocument>;
38
37
  /**
39
38
  * Create issue for device going offline longer than baseline
40
39
  */
@@ -50,11 +49,11 @@ export declare class IssueService {
50
49
  /**
51
50
  * Create a maintenance issue using IssueBuilder
52
51
  */
53
- createMaintenanceIssue(propertyId: string, title: string, description: string, createdBy: string, entityId?: string, entityType?: EntityType, assignedTo?: string, dueDate?: Date): Promise<IIssueDocument>;
52
+ createMaintenanceIssue(data: CreateIssueData): Promise<IIssueDocument>;
54
53
  /**
55
54
  * Create an urgent issue using IssueBuilder
56
55
  */
57
- createUrgentIssue(propertyId: string, title: string, description: string, createdBy: string, entityId?: string, entityType?: EntityType, assignedTo?: string, dueDate?: Date): Promise<IIssueDocument>;
56
+ createUrgentIssue(data: CreateIssueData): Promise<IIssueDocument>;
58
57
  /**
59
58
  * Create a new issue with business logic validation
60
59
  * Accepts either a CreateIssueData object or an IssueBuilder instance
@@ -67,18 +66,7 @@ export declare class IssueService {
67
66
  /**
68
67
  * Get all issues with business logic filtering
69
68
  */
70
- getIssues(filters?: {
71
- propertyId?: string;
72
- assignedTo?: string;
73
- status?: IssueStatus;
74
- priority?: IssuePriority;
75
- category?: IssuesCategory;
76
- entityType?: EntityType;
77
- entityId?: string;
78
- includeDeleted?: boolean;
79
- limit?: number;
80
- skip?: number;
81
- }): Promise<IIssueDocument[]>;
69
+ query(filters: IIssueQuery): Promise<IIssueDocument[]>;
82
70
  /**
83
71
  * Update an issue with business logic validation
84
72
  */
@@ -119,26 +107,10 @@ export declare class IssueService {
119
107
  * Unassign an issue
120
108
  */
121
109
  unassignIssue(id: string, unassignedBy: string): Promise<IIssueDocument | null>;
122
- /**
123
- * Get issues by property with business logic
124
- */
125
- getIssuesByProperty(propertyId: string, includeDeleted?: boolean): Promise<IIssueDocument[]>;
126
110
  /**
127
111
  * Get issues assigned to a user with business logic
128
112
  */
129
113
  getIssuesByAssignee(assignedTo: string, includeDeleted?: boolean): Promise<IIssueDocument[]>;
130
- /**
131
- * Get issues by entity
132
- */
133
- getIssuesByEntity(entityId: string, entityType: EntityType, includeDeleted?: boolean): Promise<IIssueDocument[]>;
134
- /**
135
- * Get issues by status
136
- */
137
- getIssuesByStatus(status: IssueStatus, includeDeleted?: boolean): Promise<IIssueDocument[]>;
138
- /**
139
- * Get issues by priority
140
- */
141
- getIssuesByPriority(priority: IssuePriority, includeDeleted?: boolean): Promise<IIssueDocument[]>;
142
114
  /**
143
115
  * Get overdue issues with business logic
144
116
  */