dt-common-device 5.1.7 → 6.1.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.
- package/dist/alerts/Alert.model.d.ts +1 -6
- package/dist/alerts/Alert.model.js +1 -35
- package/dist/alerts/Alert.repository.d.ts +4 -46
- package/dist/alerts/Alert.repository.js +29 -102
- package/dist/alerts/Alert.service.d.ts +3 -35
- package/dist/alerts/Alert.service.js +39 -54
- package/dist/alerts/AlertBuilder.d.ts +10 -10
- package/dist/alerts/AlertBuilder.js +1 -0
- package/dist/alerts/alert.types.d.ts +15 -0
- package/dist/audit/AuditUtils.js +7 -10
- package/dist/config/config.js +5 -0
- package/dist/config/config.types.d.ts +1 -1
- package/dist/config/constants.d.ts +9 -0
- package/dist/config/constants.js +9 -0
- package/dist/constants/Event.d.ts +12 -0
- package/dist/constants/Event.js +12 -0
- package/dist/entities/admin/Admin.repository.d.ts +4 -0
- package/dist/entities/admin/Admin.repository.js +31 -0
- package/dist/entities/admin/Admin.service.d.ts +4 -0
- package/dist/entities/admin/Admin.service.js +124 -14
- package/dist/entities/admin/IAdmin.d.ts +39 -0
- package/dist/entities/admin/IAdmin.js +2 -0
- package/dist/entities/admin/index.d.ts +1 -0
- package/dist/entities/admin/index.js +1 -0
- package/dist/entities/device/local/interfaces/IDevice.d.ts +12 -0
- package/dist/entities/device/local/services/Device.service.d.ts +3 -4
- package/dist/entities/device/local/services/Device.service.js +59 -9
- package/dist/entities/pms/IPms.d.ts +26 -0
- package/dist/entities/pms/index.d.ts +1 -0
- package/dist/entities/pms/index.js +1 -0
- package/dist/entities/pms/pms.repository.d.ts +8 -0
- package/dist/entities/pms/pms.repository.js +98 -0
- package/dist/entities/pms/pms.service.d.ts +8 -0
- package/dist/entities/pms/pms.service.js +124 -0
- package/dist/events/BaseEventHandler.d.ts +2 -2
- package/dist/events/BaseEventHandler.js +21 -10
- package/dist/issues/Issue.model.d.ts +1 -5
- package/dist/issues/Issue.model.js +0 -28
- package/dist/issues/Issue.repository.d.ts +4 -42
- package/dist/issues/Issue.repository.js +29 -79
- package/dist/issues/Issue.service.d.ts +12 -40
- package/dist/issues/Issue.service.js +179 -145
- package/dist/issues/IssueBuilder.d.ts +11 -11
- package/dist/issues/IssueBuilder.js +10 -2
- package/dist/issues/IssueService.example.js +128 -15
- package/dist/issues/index.d.ts +1 -0
- package/dist/issues/index.js +1 -0
- package/dist/issues/issue.types.d.ts +17 -2
- package/package.json +1 -1
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
import { IssueRepository } from "./Issue.repository";
|
|
2
1
|
import { IIssueDocument } from "./Issue.model";
|
|
3
|
-
import { CreateIssueData, UpdateIssueData, AddCommentData,
|
|
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(
|
|
8
|
+
constructor();
|
|
10
9
|
/**
|
|
11
10
|
* Create a readiness issue using IssueBuilder
|
|
12
11
|
*/
|
|
13
|
-
createReadinessIssue(
|
|
12
|
+
createReadinessIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
14
13
|
/**
|
|
15
14
|
* Create an operations issue using IssueBuilder
|
|
16
15
|
*/
|
|
17
|
-
createOperationsIssue(
|
|
16
|
+
createOperationsIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
18
17
|
/**
|
|
19
18
|
* Create a security issue using IssueBuilder
|
|
20
19
|
*/
|
|
21
|
-
createSecurityIssue(
|
|
20
|
+
createSecurityIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
22
21
|
/**
|
|
23
22
|
* Create an energy issue using IssueBuilder
|
|
24
23
|
*/
|
|
25
|
-
createEnergyIssue(
|
|
24
|
+
createEnergyIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
26
25
|
/**
|
|
27
26
|
* Create a device-specific issue using IssueBuilder
|
|
28
27
|
*/
|
|
29
|
-
createDeviceIssue(
|
|
28
|
+
createDeviceIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
30
29
|
/**
|
|
31
30
|
* Create a hub-specific issue using IssueBuilder
|
|
32
31
|
*/
|
|
33
|
-
createHubIssue(
|
|
32
|
+
createHubIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
34
33
|
/**
|
|
35
34
|
* Create a user-specific issue using IssueBuilder
|
|
36
35
|
*/
|
|
37
|
-
createUserIssue(
|
|
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(
|
|
52
|
+
createMaintenanceIssue(data: CreateIssueData): Promise<IIssueDocument>;
|
|
54
53
|
/**
|
|
55
54
|
* Create an urgent issue using IssueBuilder
|
|
56
55
|
*/
|
|
57
|
-
createUrgentIssue(
|
|
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
|
-
|
|
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
|
*/
|
|
@@ -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.IssueService = void 0;
|
|
42
|
-
const typedi_1 = require("typedi");
|
|
75
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
76
|
+
const Issue_repository_1 = require("./Issue.repository");
|
|
43
77
|
const Issue_model_1 = require("./Issue.model");
|
|
44
78
|
const issue_types_1 = require("./issue.types");
|
|
45
79
|
const IssueBuilder_1 = require("./IssueBuilder");
|
|
@@ -49,183 +83,210 @@ let IssueService = (() => {
|
|
|
49
83
|
let _classExtraInitializers = [];
|
|
50
84
|
let _classThis;
|
|
51
85
|
var IssueService = _classThis = class {
|
|
52
|
-
constructor(
|
|
53
|
-
this.issueRepository =
|
|
86
|
+
constructor() {
|
|
87
|
+
this.issueRepository = typedi_1.default.get(Issue_repository_1.IssueRepository);
|
|
54
88
|
}
|
|
55
89
|
/**
|
|
56
90
|
* Create a readiness issue using IssueBuilder
|
|
57
91
|
*/
|
|
58
|
-
async createReadinessIssue(
|
|
92
|
+
async createReadinessIssue(data) {
|
|
59
93
|
const issueBuilder = IssueBuilder_1.IssueBuilder.createReadinessIssue()
|
|
60
|
-
.setPropertyId(propertyId)
|
|
61
|
-
.setTitle(title)
|
|
62
|
-
.setDescription(description)
|
|
63
|
-
.setCreatedBy(createdBy);
|
|
64
|
-
if (entityId)
|
|
65
|
-
issueBuilder.setEntityId(entityId);
|
|
66
|
-
if (entityType)
|
|
67
|
-
issueBuilder.setEntityType(entityType);
|
|
68
|
-
if (assignedTo)
|
|
69
|
-
issueBuilder.setAssignedTo(assignedTo);
|
|
70
|
-
if (dueDate)
|
|
71
|
-
issueBuilder.setDueDate(dueDate);
|
|
94
|
+
.setPropertyId(data.propertyId)
|
|
95
|
+
.setTitle(data.title)
|
|
96
|
+
.setDescription(data.description)
|
|
97
|
+
.setCreatedBy(data.createdBy);
|
|
98
|
+
if (data.entityId)
|
|
99
|
+
issueBuilder.setEntityId(data.entityId);
|
|
100
|
+
if (data.entityType)
|
|
101
|
+
issueBuilder.setEntityType(data.entityType);
|
|
102
|
+
if (data.assignedTo)
|
|
103
|
+
issueBuilder.setAssignedTo(data.assignedTo);
|
|
104
|
+
if (data.dueDate)
|
|
105
|
+
issueBuilder.setDueDate(data.dueDate);
|
|
72
106
|
return await this.createIssue(issueBuilder);
|
|
73
107
|
}
|
|
74
108
|
/**
|
|
75
109
|
* Create an operations issue using IssueBuilder
|
|
76
110
|
*/
|
|
77
|
-
async createOperationsIssue(
|
|
111
|
+
async createOperationsIssue(data) {
|
|
78
112
|
const issueBuilder = IssueBuilder_1.IssueBuilder.createOperationsIssue()
|
|
79
|
-
.setPropertyId(propertyId)
|
|
80
|
-
.setTitle(title)
|
|
81
|
-
.setDescription(description)
|
|
82
|
-
.setCreatedBy(createdBy);
|
|
83
|
-
if (entityId)
|
|
84
|
-
issueBuilder.setEntityId(entityId);
|
|
85
|
-
if (entityType)
|
|
86
|
-
issueBuilder.setEntityType(entityType);
|
|
87
|
-
if (assignedTo)
|
|
88
|
-
issueBuilder.setAssignedTo(assignedTo);
|
|
89
|
-
if (dueDate)
|
|
90
|
-
issueBuilder.setDueDate(dueDate);
|
|
113
|
+
.setPropertyId(data.propertyId)
|
|
114
|
+
.setTitle(data.title)
|
|
115
|
+
.setDescription(data.description)
|
|
116
|
+
.setCreatedBy(data.createdBy);
|
|
117
|
+
if (data.entityId)
|
|
118
|
+
issueBuilder.setEntityId(data.entityId);
|
|
119
|
+
if (data.entityType)
|
|
120
|
+
issueBuilder.setEntityType(data.entityType);
|
|
121
|
+
if (data.assignedTo)
|
|
122
|
+
issueBuilder.setAssignedTo(data.assignedTo);
|
|
123
|
+
if (data.dueDate)
|
|
124
|
+
issueBuilder.setDueDate(data.dueDate);
|
|
91
125
|
return await this.createIssue(issueBuilder);
|
|
92
126
|
}
|
|
93
127
|
/**
|
|
94
128
|
* Create a security issue using IssueBuilder
|
|
95
129
|
*/
|
|
96
|
-
async createSecurityIssue(
|
|
130
|
+
async createSecurityIssue(data) {
|
|
97
131
|
const issueBuilder = IssueBuilder_1.IssueBuilder.createSecurityIssue()
|
|
98
|
-
.setPropertyId(propertyId)
|
|
99
|
-
.setTitle(title)
|
|
100
|
-
.setDescription(description)
|
|
101
|
-
.setCreatedBy(createdBy);
|
|
102
|
-
if (entityId)
|
|
103
|
-
issueBuilder.setEntityId(entityId);
|
|
104
|
-
if (entityType)
|
|
105
|
-
issueBuilder.setEntityType(entityType);
|
|
106
|
-
if (assignedTo)
|
|
107
|
-
issueBuilder.setAssignedTo(assignedTo);
|
|
108
|
-
if (dueDate)
|
|
109
|
-
issueBuilder.setDueDate(dueDate);
|
|
132
|
+
.setPropertyId(data.propertyId)
|
|
133
|
+
.setTitle(data.title)
|
|
134
|
+
.setDescription(data.description)
|
|
135
|
+
.setCreatedBy(data.createdBy);
|
|
136
|
+
if (data.entityId)
|
|
137
|
+
issueBuilder.setEntityId(data.entityId);
|
|
138
|
+
if (data.entityType)
|
|
139
|
+
issueBuilder.setEntityType(data.entityType);
|
|
140
|
+
if (data.assignedTo)
|
|
141
|
+
issueBuilder.setAssignedTo(data.assignedTo);
|
|
142
|
+
if (data.dueDate)
|
|
143
|
+
issueBuilder.setDueDate(data.dueDate);
|
|
110
144
|
return await this.createIssue(issueBuilder);
|
|
111
145
|
}
|
|
112
146
|
/**
|
|
113
147
|
* Create an energy issue using IssueBuilder
|
|
114
148
|
*/
|
|
115
|
-
async createEnergyIssue(
|
|
149
|
+
async createEnergyIssue(data) {
|
|
116
150
|
const issueBuilder = IssueBuilder_1.IssueBuilder.createEnergyIssue()
|
|
117
|
-
.setPropertyId(propertyId)
|
|
118
|
-
.setTitle(title)
|
|
119
|
-
.setDescription(description)
|
|
120
|
-
.setCreatedBy(createdBy);
|
|
121
|
-
if (entityId)
|
|
122
|
-
issueBuilder.setEntityId(entityId);
|
|
123
|
-
if (entityType)
|
|
124
|
-
issueBuilder.setEntityType(entityType);
|
|
125
|
-
if (assignedTo)
|
|
126
|
-
issueBuilder.setAssignedTo(assignedTo);
|
|
127
|
-
if (dueDate)
|
|
128
|
-
issueBuilder.setDueDate(dueDate);
|
|
151
|
+
.setPropertyId(data.propertyId)
|
|
152
|
+
.setTitle(data.title)
|
|
153
|
+
.setDescription(data.description)
|
|
154
|
+
.setCreatedBy(data.createdBy);
|
|
155
|
+
if (data.entityId)
|
|
156
|
+
issueBuilder.setEntityId(data.entityId);
|
|
157
|
+
if (data.entityType)
|
|
158
|
+
issueBuilder.setEntityType(data.entityType);
|
|
159
|
+
if (data.assignedTo)
|
|
160
|
+
issueBuilder.setAssignedTo(data.assignedTo);
|
|
161
|
+
if (data.dueDate)
|
|
162
|
+
issueBuilder.setDueDate(data.dueDate);
|
|
129
163
|
return await this.createIssue(issueBuilder);
|
|
130
164
|
}
|
|
131
165
|
/**
|
|
132
166
|
* Create a device-specific issue using IssueBuilder
|
|
133
167
|
*/
|
|
134
|
-
async createDeviceIssue(
|
|
135
|
-
const issueBuilder = IssueBuilder_1.IssueBuilder.createDeviceIssue(
|
|
136
|
-
.setTitle(title)
|
|
137
|
-
.setDescription(description)
|
|
138
|
-
.setCreatedBy(
|
|
139
|
-
if (category)
|
|
140
|
-
issueBuilder.setCategory(category);
|
|
141
|
-
if (priority)
|
|
142
|
-
issueBuilder.setPriority(priority);
|
|
143
|
-
if (assignedTo)
|
|
144
|
-
issueBuilder.setAssignedTo(assignedTo);
|
|
145
|
-
if (dueDate)
|
|
146
|
-
issueBuilder.setDueDate(dueDate);
|
|
168
|
+
async createDeviceIssue(data) {
|
|
169
|
+
const issueBuilder = IssueBuilder_1.IssueBuilder.createDeviceIssue(data.entityId, data.propertyId)
|
|
170
|
+
.setTitle(data.title)
|
|
171
|
+
.setDescription(data.description)
|
|
172
|
+
.setCreatedBy(data.createdBy);
|
|
173
|
+
if (data.category)
|
|
174
|
+
issueBuilder.setCategory(data.category);
|
|
175
|
+
if (data.priority)
|
|
176
|
+
issueBuilder.setPriority(data.priority);
|
|
177
|
+
if (data.assignedTo)
|
|
178
|
+
issueBuilder.setAssignedTo(data.assignedTo);
|
|
179
|
+
if (data.dueDate)
|
|
180
|
+
issueBuilder.setDueDate(data.dueDate);
|
|
147
181
|
return await this.createIssue(issueBuilder);
|
|
148
182
|
}
|
|
149
183
|
/**
|
|
150
184
|
* Create a hub-specific issue using IssueBuilder
|
|
151
185
|
*/
|
|
152
|
-
async createHubIssue(
|
|
153
|
-
const issueBuilder = IssueBuilder_1.IssueBuilder.createHubIssue(
|
|
154
|
-
.setTitle(title)
|
|
155
|
-
.setDescription(description)
|
|
156
|
-
.setCreatedBy(createdBy);
|
|
157
|
-
if (category)
|
|
158
|
-
issueBuilder.setCategory(category);
|
|
159
|
-
if (priority)
|
|
160
|
-
issueBuilder.setPriority(priority);
|
|
161
|
-
if (assignedTo)
|
|
162
|
-
issueBuilder.setAssignedTo(assignedTo);
|
|
163
|
-
if (dueDate)
|
|
164
|
-
issueBuilder.setDueDate(dueDate);
|
|
186
|
+
async createHubIssue(data) {
|
|
187
|
+
const issueBuilder = IssueBuilder_1.IssueBuilder.createHubIssue(data.entityId, data.propertyId)
|
|
188
|
+
.setTitle(data.title)
|
|
189
|
+
.setDescription(data.description)
|
|
190
|
+
.setCreatedBy(data.createdBy);
|
|
191
|
+
if (data.category)
|
|
192
|
+
issueBuilder.setCategory(data.category);
|
|
193
|
+
if (data.priority)
|
|
194
|
+
issueBuilder.setPriority(data.priority);
|
|
195
|
+
if (data.assignedTo)
|
|
196
|
+
issueBuilder.setAssignedTo(data.assignedTo);
|
|
197
|
+
if (data.dueDate)
|
|
198
|
+
issueBuilder.setDueDate(data.dueDate);
|
|
165
199
|
return await this.createIssue(issueBuilder);
|
|
166
200
|
}
|
|
167
201
|
/**
|
|
168
202
|
* Create a user-specific issue using IssueBuilder
|
|
169
203
|
*/
|
|
170
|
-
async createUserIssue(
|
|
171
|
-
const issueBuilder = IssueBuilder_1.IssueBuilder.createUserIssue(
|
|
172
|
-
.setTitle(title)
|
|
173
|
-
.setDescription(description)
|
|
174
|
-
.setCreatedBy(createdBy);
|
|
175
|
-
if (category)
|
|
176
|
-
issueBuilder.setCategory(category);
|
|
177
|
-
if (priority)
|
|
178
|
-
issueBuilder.setPriority(priority);
|
|
179
|
-
if (assignedTo)
|
|
180
|
-
issueBuilder.setAssignedTo(assignedTo);
|
|
181
|
-
if (dueDate)
|
|
182
|
-
issueBuilder.setDueDate(dueDate);
|
|
204
|
+
async createUserIssue(data) {
|
|
205
|
+
const issueBuilder = IssueBuilder_1.IssueBuilder.createUserIssue(data.entityId, data.propertyId)
|
|
206
|
+
.setTitle(data.title)
|
|
207
|
+
.setDescription(data.description)
|
|
208
|
+
.setCreatedBy(data.createdBy);
|
|
209
|
+
if (data.category)
|
|
210
|
+
issueBuilder.setCategory(data.category);
|
|
211
|
+
if (data.priority)
|
|
212
|
+
issueBuilder.setPriority(data.priority);
|
|
213
|
+
if (data.assignedTo)
|
|
214
|
+
issueBuilder.setAssignedTo(data.assignedTo);
|
|
215
|
+
if (data.dueDate)
|
|
216
|
+
issueBuilder.setDueDate(data.dueDate);
|
|
183
217
|
return await this.createIssue(issueBuilder);
|
|
184
218
|
}
|
|
185
219
|
/**
|
|
186
220
|
* Create issue for device going offline longer than baseline
|
|
187
221
|
*/
|
|
188
222
|
async createDeviceOfflineIssue(device, source, reason) {
|
|
189
|
-
return await this.createDeviceIssue(
|
|
223
|
+
return await this.createDeviceIssue({
|
|
224
|
+
entityId: device.deviceId,
|
|
225
|
+
entityType: issue_types_1.EntityType.DEVICE,
|
|
226
|
+
propertyId: device.propertyId,
|
|
227
|
+
title: "Device Offline - Requires Attention",
|
|
228
|
+
description: `Device ${device.name} (${device.deviceId}) has been offline for longer than the baseline time. ${reason ? `Reason: ${reason}` : ""} This requires immediate attention to restore device functionality.`,
|
|
229
|
+
createdBy: source,
|
|
230
|
+
category: issue_types_1.IssuesCategory.OPERATIONS,
|
|
231
|
+
priority: issue_types_1.IssuePriority.HIGH,
|
|
232
|
+
});
|
|
190
233
|
}
|
|
191
234
|
/**
|
|
192
235
|
* Create issue for device battery level below threshold (READINESS + OPERATIONAL + ENERGY)
|
|
193
236
|
*/
|
|
194
237
|
async createDeviceBatteryIssue(device, batteryLevel, threshold, source) {
|
|
195
|
-
return await this.createDeviceIssue(
|
|
238
|
+
return await this.createDeviceIssue({
|
|
239
|
+
entityId: device.deviceId,
|
|
240
|
+
entityType: issue_types_1.EntityType.DEVICE,
|
|
241
|
+
propertyId: device.propertyId,
|
|
242
|
+
title: "Device Battery Low - Requires Attention",
|
|
243
|
+
description: `Device ${device.name} (${device.deviceId}) battery level is ${batteryLevel}%, which is below the property threshold of ${threshold}%. This requires immediate attention to replace or charge the device battery.`,
|
|
244
|
+
createdBy: source,
|
|
245
|
+
category: issue_types_1.IssuesCategory.ENERGY,
|
|
246
|
+
priority: issue_types_1.IssuePriority.MEDIUM,
|
|
247
|
+
});
|
|
196
248
|
}
|
|
197
249
|
/**
|
|
198
250
|
* Create issue for device malfunction (jammed or not accepting codes) (READINESS + OPERATIONAL)
|
|
199
251
|
*/
|
|
200
252
|
async createDeviceMalfunctionIssue(device, issueType, source, reason) {
|
|
201
|
-
return await this.createDeviceIssue(
|
|
253
|
+
return await this.createDeviceIssue({
|
|
254
|
+
entityId: device.deviceId,
|
|
255
|
+
entityType: issue_types_1.EntityType.DEVICE,
|
|
256
|
+
propertyId: device.propertyId,
|
|
257
|
+
title: `Device Malfunction - ${issueType} - Requires Attention`,
|
|
258
|
+
description: `Device ${device.name} (${device.deviceId}) has a malfunction: ${issueType}. ${reason ? `Reason: ${reason}` : ""} This requires immediate attention to resolve the device malfunction.`,
|
|
259
|
+
createdBy: source,
|
|
260
|
+
category: issue_types_1.IssuesCategory.OPERATIONS,
|
|
261
|
+
priority: issue_types_1.IssuePriority.HIGH,
|
|
262
|
+
});
|
|
202
263
|
}
|
|
203
264
|
/**
|
|
204
265
|
* Create a maintenance issue using IssueBuilder
|
|
205
266
|
*/
|
|
206
|
-
async createMaintenanceIssue(
|
|
207
|
-
const issueBuilder = IssueBuilder_1.IssueBuilder.createMaintenanceIssue(propertyId, entityId, entityType)
|
|
208
|
-
.setTitle(title)
|
|
209
|
-
.setDescription(description)
|
|
210
|
-
.setCreatedBy(createdBy);
|
|
211
|
-
if (assignedTo)
|
|
212
|
-
issueBuilder.setAssignedTo(assignedTo);
|
|
213
|
-
if (dueDate)
|
|
214
|
-
issueBuilder.setDueDate(dueDate);
|
|
267
|
+
async createMaintenanceIssue(data) {
|
|
268
|
+
const issueBuilder = IssueBuilder_1.IssueBuilder.createMaintenanceIssue(data.propertyId, data.entityId, data.entityType)
|
|
269
|
+
.setTitle(data.title)
|
|
270
|
+
.setDescription(data.description)
|
|
271
|
+
.setCreatedBy(data.createdBy);
|
|
272
|
+
if (data.assignedTo)
|
|
273
|
+
issueBuilder.setAssignedTo(data.assignedTo);
|
|
274
|
+
if (data.dueDate)
|
|
275
|
+
issueBuilder.setDueDate(data.dueDate);
|
|
215
276
|
return await this.createIssue(issueBuilder);
|
|
216
277
|
}
|
|
217
278
|
/**
|
|
218
279
|
* Create an urgent issue using IssueBuilder
|
|
219
280
|
*/
|
|
220
|
-
async createUrgentIssue(
|
|
221
|
-
const issueBuilder = IssueBuilder_1.IssueBuilder.createUrgentIssue(propertyId, entityId, entityType)
|
|
222
|
-
.setTitle(title)
|
|
223
|
-
.setDescription(description)
|
|
224
|
-
.setCreatedBy(createdBy);
|
|
225
|
-
if (assignedTo)
|
|
226
|
-
issueBuilder.setAssignedTo(assignedTo);
|
|
227
|
-
if (dueDate)
|
|
228
|
-
issueBuilder.setDueDate(dueDate);
|
|
281
|
+
async createUrgentIssue(data) {
|
|
282
|
+
const issueBuilder = IssueBuilder_1.IssueBuilder.createUrgentIssue(data.propertyId, data.entityId, data.entityType)
|
|
283
|
+
.setTitle(data.title)
|
|
284
|
+
.setDescription(data.description)
|
|
285
|
+
.setCreatedBy(data.createdBy);
|
|
286
|
+
if (data.assignedTo)
|
|
287
|
+
issueBuilder.setAssignedTo(data.assignedTo);
|
|
288
|
+
if (data.dueDate)
|
|
289
|
+
issueBuilder.setDueDate(data.dueDate);
|
|
229
290
|
return await this.createIssue(issueBuilder);
|
|
230
291
|
}
|
|
231
292
|
/**
|
|
@@ -274,12 +335,12 @@ let IssueService = (() => {
|
|
|
274
335
|
/**
|
|
275
336
|
* Get all issues with business logic filtering
|
|
276
337
|
*/
|
|
277
|
-
async
|
|
338
|
+
async query(filters) {
|
|
278
339
|
// Business logic: Validate filters
|
|
279
340
|
this.validateFilters(filters);
|
|
280
341
|
// Business logic: Apply business rules to filters
|
|
281
342
|
const enhancedFilters = this.applyBusinessRules(filters);
|
|
282
|
-
return await this.issueRepository.
|
|
343
|
+
return await this.issueRepository.query(enhancedFilters);
|
|
283
344
|
}
|
|
284
345
|
/**
|
|
285
346
|
* Update an issue with business logic validation
|
|
@@ -353,7 +414,7 @@ let IssueService = (() => {
|
|
|
353
414
|
});
|
|
354
415
|
}
|
|
355
416
|
// Add comment using the model instance methods
|
|
356
|
-
const issueModel = await Issue_model_1.IssueModel.findById(issueId);
|
|
417
|
+
const issueModel = await Issue_model_1.IssueModel.findById({ _id: issueId });
|
|
357
418
|
if (issueModel) {
|
|
358
419
|
issueModel.addComment(commentData);
|
|
359
420
|
return await issueModel.save();
|
|
@@ -465,15 +526,6 @@ let IssueService = (() => {
|
|
|
465
526
|
issueModel.unassign(unassignedBy);
|
|
466
527
|
return await issueModel.save();
|
|
467
528
|
}
|
|
468
|
-
/**
|
|
469
|
-
* Get issues by property with business logic
|
|
470
|
-
*/
|
|
471
|
-
async getIssuesByProperty(propertyId, includeDeleted = false) {
|
|
472
|
-
if (!propertyId) {
|
|
473
|
-
throw new Error("Property ID is required");
|
|
474
|
-
}
|
|
475
|
-
return await this.issueRepository.findByProperty(propertyId, includeDeleted);
|
|
476
|
-
}
|
|
477
529
|
/**
|
|
478
530
|
* Get issues assigned to a user with business logic
|
|
479
531
|
*/
|
|
@@ -483,24 +535,6 @@ let IssueService = (() => {
|
|
|
483
535
|
}
|
|
484
536
|
return await this.issueRepository.findByAssignee(assignedTo, includeDeleted);
|
|
485
537
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Get issues by entity
|
|
488
|
-
*/
|
|
489
|
-
async getIssuesByEntity(entityId, entityType, includeDeleted = false) {
|
|
490
|
-
return await this.issueRepository.findByEntity(entityId, entityType, includeDeleted);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Get issues by status
|
|
494
|
-
*/
|
|
495
|
-
async getIssuesByStatus(status, includeDeleted = false) {
|
|
496
|
-
return await this.issueRepository.findByStatus(status, includeDeleted);
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Get issues by priority
|
|
500
|
-
*/
|
|
501
|
-
async getIssuesByPriority(priority, includeDeleted = false) {
|
|
502
|
-
return await this.issueRepository.findByPriority(priority, includeDeleted);
|
|
503
|
-
}
|
|
504
538
|
/**
|
|
505
539
|
* Get overdue issues with business logic
|
|
506
540
|
*/
|
|
@@ -25,43 +25,43 @@ export declare class IssueBuilder {
|
|
|
25
25
|
/**
|
|
26
26
|
* Sets the issue category
|
|
27
27
|
*/
|
|
28
|
-
setCategory(category: IssuesCategory):
|
|
28
|
+
setCategory(category: IssuesCategory): this;
|
|
29
29
|
/**
|
|
30
30
|
* Sets the property ID
|
|
31
31
|
*/
|
|
32
|
-
setPropertyId(propertyId: string):
|
|
32
|
+
setPropertyId(propertyId: string): this;
|
|
33
33
|
/**
|
|
34
34
|
* Sets the issue title
|
|
35
35
|
*/
|
|
36
|
-
setTitle(title: string):
|
|
36
|
+
setTitle(title: string): this;
|
|
37
37
|
/**
|
|
38
38
|
* Sets the issue description
|
|
39
39
|
*/
|
|
40
|
-
setDescription(description: string):
|
|
40
|
+
setDescription(description: string): this;
|
|
41
41
|
/**
|
|
42
42
|
* Sets the entity ID (optional)
|
|
43
43
|
*/
|
|
44
|
-
setEntityId(entityId?: string):
|
|
44
|
+
setEntityId(entityId?: string): this;
|
|
45
45
|
/**
|
|
46
46
|
* Sets the entity type
|
|
47
47
|
*/
|
|
48
|
-
setEntityType(entityType: EntityType):
|
|
48
|
+
setEntityType(entityType: EntityType): this;
|
|
49
49
|
/**
|
|
50
50
|
* Sets the issue priority (optional, defaults to MEDIUM)
|
|
51
51
|
*/
|
|
52
|
-
setPriority(priority?: IssuePriority):
|
|
52
|
+
setPriority(priority?: IssuePriority): this;
|
|
53
53
|
/**
|
|
54
54
|
* Sets the user assigned to the issue (optional)
|
|
55
55
|
*/
|
|
56
|
-
setAssignedTo(assignedTo?: string):
|
|
56
|
+
setAssignedTo(assignedTo?: string): this;
|
|
57
57
|
/**
|
|
58
58
|
* Sets the user who created the issue (required)
|
|
59
59
|
*/
|
|
60
|
-
setCreatedBy(createdBy: string):
|
|
60
|
+
setCreatedBy(createdBy: string): this;
|
|
61
61
|
/**
|
|
62
62
|
* Sets the due date (optional)
|
|
63
63
|
*/
|
|
64
|
-
setDueDate(dueDate?: Date):
|
|
64
|
+
setDueDate(dueDate?: Date): this;
|
|
65
65
|
/**
|
|
66
66
|
* Validates that all required fields are present
|
|
67
67
|
*/
|
|
@@ -74,7 +74,7 @@ export declare class IssueBuilder {
|
|
|
74
74
|
/**
|
|
75
75
|
* Resets the builder to its initial state
|
|
76
76
|
*/
|
|
77
|
-
reset():
|
|
77
|
+
reset(): this;
|
|
78
78
|
/**
|
|
79
79
|
* Creates a new builder instance with predefined values for common issue types
|
|
80
80
|
*/
|
|
@@ -121,8 +121,16 @@ class IssueBuilder {
|
|
|
121
121
|
* Validates that all required fields are present
|
|
122
122
|
*/
|
|
123
123
|
validate() {
|
|
124
|
-
const requiredFields = [
|
|
125
|
-
|
|
124
|
+
const requiredFields = [
|
|
125
|
+
"category",
|
|
126
|
+
"propertyId",
|
|
127
|
+
"title",
|
|
128
|
+
"description",
|
|
129
|
+
"entityId",
|
|
130
|
+
"entityType",
|
|
131
|
+
"createdBy",
|
|
132
|
+
];
|
|
133
|
+
const missingFields = requiredFields.filter((field) => !this.data[field]);
|
|
126
134
|
if (missingFields.length > 0) {
|
|
127
135
|
throw new Error(`Missing required fields: ${missingFields.join(", ")}`);
|
|
128
136
|
}
|