@flusys/nestjs-task-manager 7.1.0 → 8.0.0-beta.1
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/config/index.d.ts +3 -3
- package/controllers/index.d.ts +5 -5
- package/controllers/task-board.controller.d.ts +3 -3
- package/controllers/task-comment.controller.d.ts +2 -2
- package/controllers/task-label.controller.d.ts +2 -2
- package/controllers/task-list.controller.d.ts +3 -3
- package/controllers/task.controller.d.ts +4 -4
- package/docs/index.d.ts +1 -1
- package/docs/task-manager-swagger.config.d.ts +1 -1
- package/dtos/index.d.ts +5 -5
- package/dtos/task-board.dto.d.ts +1 -1
- package/dtos/task.dto.d.ts +2 -2
- package/entities/index.d.ts +19 -19
- package/entities/task-board-with-company.entity.d.ts +1 -1
- package/fesm/234.js +1393 -0
- package/fesm/431.js +981 -0
- package/fesm/827.js +1054 -0
- package/fesm/988.js +881 -0
- package/fesm/config/index.js +156 -3
- package/fesm/controllers/index.js +21 -5
- package/fesm/docs/index.js +58 -1
- package/fesm/dtos/index.js +280 -5
- package/fesm/entities/index.js +26 -46
- package/fesm/gateways/index.js +288 -1
- package/fesm/index.js +440 -9
- package/fesm/interfaces/index.js +16 -2
- package/fesm/modules/index.js +210 -1
- package/fesm/runtime.js +85 -0
- package/fesm/services/index.js +53 -8
- package/gateways/index.d.ts +1 -1
- package/gateways/task-board.gateway.d.ts +3 -3
- package/index.d.ts +9 -9
- package/interfaces/index.d.ts +2 -2
- package/interfaces/task-manager-module.interface.d.ts +3 -3
- package/interfaces/task.interface.d.ts +2 -2
- package/modules/index.d.ts +1 -1
- package/modules/task-manager.module.d.ts +2 -2
- package/package.json +26 -36
- package/services/index.d.ts +8 -8
- package/services/task-activity.service.d.ts +1 -1
- package/services/task-board.service.d.ts +5 -5
- package/services/task-comment.service.d.ts +4 -4
- package/services/task-label.service.d.ts +4 -4
- package/services/task-list.service.d.ts +4 -4
- package/services/task-manager-config.service.d.ts +3 -3
- package/services/task-manager-datasource.provider.d.ts +3 -3
- package/services/task.service.d.ts +7 -7
- package/cjs/config/event-actions.js +0 -37
- package/cjs/config/index.js +0 -20
- package/cjs/config/message-keys.js +0 -92
- package/cjs/config/task-manager.constants.js +0 -11
- package/cjs/controllers/index.js +0 -22
- package/cjs/controllers/task-board.controller.js +0 -219
- package/cjs/controllers/task-board.controller.spec.js +0 -132
- package/cjs/controllers/task-comment.controller.js +0 -103
- package/cjs/controllers/task-comment.controller.spec.js +0 -86
- package/cjs/controllers/task-label.controller.js +0 -112
- package/cjs/controllers/task-label.controller.spec.js +0 -88
- package/cjs/controllers/task-list.controller.js +0 -158
- package/cjs/controllers/task-list.controller.spec.js +0 -112
- package/cjs/controllers/task.controller.js +0 -199
- package/cjs/controllers/task.controller.spec.js +0 -131
- package/cjs/docs/index.js +0 -18
- package/cjs/docs/task-manager-swagger.config.js +0 -43
- package/cjs/docs/task-manager-swagger.config.spec.js +0 -28
- package/cjs/dtos/index.js +0 -22
- package/cjs/dtos/task-board.dto.js +0 -310
- package/cjs/dtos/task-comment.dto.js +0 -131
- package/cjs/dtos/task-label.dto.js +0 -120
- package/cjs/dtos/task-list.dto.js +0 -198
- package/cjs/dtos/task.dto.js +0 -367
- package/cjs/entities/index.js +0 -72
- package/cjs/entities/index.spec.js +0 -30
- package/cjs/entities/task-activity.entity.js +0 -98
- package/cjs/entities/task-assignee.entity.js +0 -67
- package/cjs/entities/task-board-member.entity.js +0 -94
- package/cjs/entities/task-board-with-company.entity.js +0 -57
- package/cjs/entities/task-board.entity.js +0 -88
- package/cjs/entities/task-comment.entity.js +0 -80
- package/cjs/entities/task-label.entity.js +0 -72
- package/cjs/entities/task-list.entity.js +0 -104
- package/cjs/entities/task-task-label.entity.js +0 -67
- package/cjs/entities/task.entity.js +0 -151
- package/cjs/gateways/index.js +0 -18
- package/cjs/gateways/task-board.gateway.js +0 -167
- package/cjs/gateways/task-board.gateway.spec.js +0 -243
- package/cjs/index.js +0 -26
- package/cjs/interfaces/index.js +0 -19
- package/cjs/interfaces/task-manager-module.interface.js +0 -4
- package/cjs/interfaces/task.interface.js +0 -4
- package/cjs/modules/index.js +0 -18
- package/cjs/modules/task-manager.module.js +0 -135
- package/cjs/modules/task-manager.module.spec.js +0 -144
- package/cjs/services/index.js +0 -25
- package/cjs/services/task-activity.service.js +0 -76
- package/cjs/services/task-activity.service.spec.js +0 -125
- package/cjs/services/task-board.service.js +0 -247
- package/cjs/services/task-board.service.spec.js +0 -465
- package/cjs/services/task-comment.service.js +0 -103
- package/cjs/services/task-comment.service.spec.js +0 -160
- package/cjs/services/task-label.service.js +0 -97
- package/cjs/services/task-label.service.spec.js +0 -138
- package/cjs/services/task-list.service.js +0 -130
- package/cjs/services/task-list.service.spec.js +0 -284
- package/cjs/services/task-manager-config.service.js +0 -69
- package/cjs/services/task-manager-config.service.spec.js +0 -98
- package/cjs/services/task-manager-datasource.provider.js +0 -84
- package/cjs/services/task-manager-datasource.provider.spec.js +0 -131
- package/cjs/services/task.service.js +0 -398
- package/cjs/services/task.service.spec.js +0 -700
- package/fesm/config/event-actions.js +0 -16
- package/fesm/config/message-keys.js +0 -65
- package/fesm/config/task-manager.constants.js +0 -1
- package/fesm/controllers/task-board.controller.js +0 -209
- package/fesm/controllers/task-board.controller.spec.js +0 -128
- package/fesm/controllers/task-comment.controller.js +0 -93
- package/fesm/controllers/task-comment.controller.spec.js +0 -82
- package/fesm/controllers/task-label.controller.js +0 -102
- package/fesm/controllers/task-label.controller.spec.js +0 -84
- package/fesm/controllers/task-list.controller.js +0 -148
- package/fesm/controllers/task-list.controller.spec.js +0 -108
- package/fesm/controllers/task.controller.js +0 -189
- package/fesm/controllers/task.controller.spec.js +0 -127
- package/fesm/docs/task-manager-swagger.config.js +0 -33
- package/fesm/docs/task-manager-swagger.config.spec.js +0 -24
- package/fesm/dtos/task-board.dto.js +0 -277
- package/fesm/dtos/task-comment.dto.js +0 -110
- package/fesm/dtos/task-label.dto.js +0 -99
- package/fesm/dtos/task-list.dto.js +0 -174
- package/fesm/dtos/task.dto.js +0 -337
- package/fesm/entities/index.spec.js +0 -26
- package/fesm/entities/task-activity.entity.js +0 -88
- package/fesm/entities/task-assignee.entity.js +0 -57
- package/fesm/entities/task-board-member.entity.js +0 -76
- package/fesm/entities/task-board-with-company.entity.js +0 -47
- package/fesm/entities/task-board.entity.js +0 -78
- package/fesm/entities/task-comment.entity.js +0 -70
- package/fesm/entities/task-label.entity.js +0 -62
- package/fesm/entities/task-list.entity.js +0 -94
- package/fesm/entities/task-task-label.entity.js +0 -57
- package/fesm/entities/task.entity.js +0 -133
- package/fesm/gateways/task-board.gateway.js +0 -157
- package/fesm/gateways/task-board.gateway.spec.js +0 -239
- package/fesm/interfaces/task-manager-module.interface.js +0 -1
- package/fesm/interfaces/task.interface.js +0 -1
- package/fesm/modules/task-manager.module.js +0 -125
- package/fesm/modules/task-manager.module.spec.js +0 -140
- package/fesm/services/task-activity.service.js +0 -66
- package/fesm/services/task-activity.service.spec.js +0 -121
- package/fesm/services/task-board.service.js +0 -237
- package/fesm/services/task-board.service.spec.js +0 -461
- package/fesm/services/task-comment.service.js +0 -93
- package/fesm/services/task-comment.service.spec.js +0 -156
- package/fesm/services/task-label.service.js +0 -87
- package/fesm/services/task-label.service.spec.js +0 -134
- package/fesm/services/task-list.service.js +0 -120
- package/fesm/services/task-list.service.spec.js +0 -280
- package/fesm/services/task-manager-config.service.js +0 -59
- package/fesm/services/task-manager-config.service.spec.js +0 -94
- package/fesm/services/task-manager-datasource.provider.js +0 -74
- package/fesm/services/task-manager-datasource.provider.spec.js +0 -127
- package/fesm/services/task.service.js +0 -388
- package/fesm/services/task.service.spec.js +0 -696
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
function _define_property(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
15
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
18
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
-
}
|
|
20
|
-
function _ts_metadata(k, v) {
|
|
21
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
|
-
}
|
|
23
|
-
function _ts_param(paramIndex, decorator) {
|
|
24
|
-
return function(target, key) {
|
|
25
|
-
decorator(target, key, paramIndex);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
import { ApiService, HybridCache } from '@flusys/nestjs-shared/classes';
|
|
29
|
-
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
30
|
-
import { BadRequestException, Inject, Injectable, NotFoundException, Scope } from '@nestjs/common';
|
|
31
|
-
import { In, IsNull } from 'typeorm';
|
|
32
|
-
import { TASK_MANAGER_EVENT_ACTIONS, TASK_MANAGER_EVENT_ENTITIES, TASK_MANAGER_EVENT_MODULE, TASK_MESSAGES } from '../config';
|
|
33
|
-
import { Task, TaskAssignee, TaskLabel, TaskTaskLabel } from '../entities';
|
|
34
|
-
import { TaskActivityService } from './task-activity.service';
|
|
35
|
-
import { TaskBoardService } from './task-board.service';
|
|
36
|
-
import { TaskManagerDataSourceProvider } from './task-manager-datasource.provider';
|
|
37
|
-
export class TaskService extends ApiService {
|
|
38
|
-
/** Boards cache denormalized `total_tasks` / `total_lists`, so board caches go stale on any write here. */ async clearCacheForAll() {
|
|
39
|
-
await super.clearCacheForAll();
|
|
40
|
-
await this.utilsService.clearCache(TASK_MANAGER_EVENT_ENTITIES.TASK_BOARD, this.cacheManager);
|
|
41
|
-
}
|
|
42
|
-
async convertSingleDtoToEntity(dto, user) {
|
|
43
|
-
await this.ensureDataSourceRepository();
|
|
44
|
-
let entity = {};
|
|
45
|
-
if ('id' in dto && dto.id) {
|
|
46
|
-
const existing = await this.repository.findOne({
|
|
47
|
-
where: {
|
|
48
|
-
id: dto.id
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
if (!existing) throw new NotFoundException({
|
|
52
|
-
message: 'Task not found',
|
|
53
|
-
messageKey: TASK_MESSAGES.NOT_FOUND
|
|
54
|
-
});
|
|
55
|
-
entity = existing;
|
|
56
|
-
}
|
|
57
|
-
if (dto.assigneeIds?.length) {
|
|
58
|
-
const boardId = dto.boardId ?? entity.boardId;
|
|
59
|
-
const memberChecks = await Promise.all(dto.assigneeIds.map((id)=>this.boardService.isBoardMember(boardId, id)));
|
|
60
|
-
if (memberChecks.some((isMember)=>!isMember)) {
|
|
61
|
-
throw new BadRequestException({
|
|
62
|
-
message: 'Assignee is not a board member',
|
|
63
|
-
messageKey: TASK_MESSAGES.ASSIGNEE_NOT_BOARD_MEMBER
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if ('labelIds' in dto && dto.labelIds !== undefined) {
|
|
68
|
-
this.pendingLabelIds.push(dto.labelIds ?? []);
|
|
69
|
-
}
|
|
70
|
-
if ('assigneeIds' in dto && dto.assigneeIds !== undefined) {
|
|
71
|
-
this.pendingAssigneeIds.push(dto.assigneeIds ?? []);
|
|
72
|
-
} else {
|
|
73
|
-
this.pendingAssigneeIds.push(undefined);
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
...entity,
|
|
77
|
-
boardId: dto.boardId ?? entity.boardId,
|
|
78
|
-
listId: dto.listId ?? entity.listId,
|
|
79
|
-
title: dto.title ?? entity.title,
|
|
80
|
-
description: dto.description !== undefined ? dto.description ?? null : entity.description ?? null,
|
|
81
|
-
priority: dto.priority ?? entity.priority ?? 'MEDIUM',
|
|
82
|
-
dueDate: dto.dueDate !== undefined ? dto.dueDate ?? null : entity.dueDate ?? null,
|
|
83
|
-
position: entity.position ?? 0,
|
|
84
|
-
reporterId: entity.reporterId ?? user?.id ?? null,
|
|
85
|
-
parentTaskId: dto.parentTaskId !== undefined ? dto.parentTaskId ?? null : entity.parentTaskId ?? null,
|
|
86
|
-
estimatedHours: dto.estimatedHours !== undefined ? dto.estimatedHours ?? null : entity.estimatedHours ?? null
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
async afterInsertOperation(entities, _dto, user, _qr) {
|
|
90
|
-
await Promise.all(entities.map(async (entity, i)=>{
|
|
91
|
-
const assigneeIds = this.pendingAssigneeIds[i] ?? [];
|
|
92
|
-
const syncOps = [
|
|
93
|
-
this.syncLabels(entity.id, this.pendingLabelIds[i] ?? [])
|
|
94
|
-
];
|
|
95
|
-
if (assigneeIds.length > 0) {
|
|
96
|
-
syncOps.push(this.syncAssignees(entity.id, assigneeIds));
|
|
97
|
-
}
|
|
98
|
-
await Promise.all(syncOps);
|
|
99
|
-
}));
|
|
100
|
-
await Promise.all([
|
|
101
|
-
this.loadLabelsForTasks(entities),
|
|
102
|
-
this.loadAssigneesForTasks(entities)
|
|
103
|
-
]);
|
|
104
|
-
await Promise.all(entities.map((entity)=>this.activityService.log(entity.id, entity.boardId, user?.id ?? null, 'task.created', null, {
|
|
105
|
-
title: entity.title
|
|
106
|
-
})));
|
|
107
|
-
this.pendingLabelIds = [];
|
|
108
|
-
this.pendingAssigneeIds = [];
|
|
109
|
-
}
|
|
110
|
-
async afterUpdateOperation(entities, _dto, _user, _qr) {
|
|
111
|
-
await Promise.all(entities.map(async (entity, i)=>{
|
|
112
|
-
const syncOps = [];
|
|
113
|
-
if (this.pendingLabelIds[i] !== undefined) {
|
|
114
|
-
syncOps.push(this.syncLabels(entity.id, this.pendingLabelIds[i]));
|
|
115
|
-
}
|
|
116
|
-
if (this.pendingAssigneeIds[i] !== undefined) {
|
|
117
|
-
syncOps.push(this.syncAssignees(entity.id, this.pendingAssigneeIds[i]));
|
|
118
|
-
}
|
|
119
|
-
if (syncOps.length > 0) await Promise.all(syncOps);
|
|
120
|
-
}));
|
|
121
|
-
await this.loadLabelsForTasks(entities);
|
|
122
|
-
const entitiesWithAssigneeUpdates = entities.filter((_, i)=>this.pendingAssigneeIds[i] !== undefined);
|
|
123
|
-
if (entitiesWithAssigneeUpdates.length > 0) {
|
|
124
|
-
await this.loadAssigneesForTasks(entitiesWithAssigneeUpdates);
|
|
125
|
-
}
|
|
126
|
-
this.pendingLabelIds = [];
|
|
127
|
-
this.pendingAssigneeIds = [];
|
|
128
|
-
}
|
|
129
|
-
async getFilterQuery(query, filter, _user) {
|
|
130
|
-
for (const [key, value] of Object.entries(filter)){
|
|
131
|
-
if (key === 'boardId') {
|
|
132
|
-
query.andWhere('task.boardId = :boardId', {
|
|
133
|
-
boardId: value
|
|
134
|
-
});
|
|
135
|
-
} else if (key === 'listId') {
|
|
136
|
-
query.andWhere('task.listId = :listId', {
|
|
137
|
-
listId: value
|
|
138
|
-
});
|
|
139
|
-
} else if (key === 'assigneeId') {
|
|
140
|
-
query.innerJoin('task_assignee', 'ta', 'ta.task_id = task.id').andWhere('ta.user_id = :assigneeUserId', {
|
|
141
|
-
assigneeUserId: value
|
|
142
|
-
});
|
|
143
|
-
} else if (key === 'priority') {
|
|
144
|
-
query.andWhere('task.priority = :priority', {
|
|
145
|
-
priority: value
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
query,
|
|
151
|
-
isRaw: false
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
async getAll(search, filterAndPaginationDto, user) {
|
|
155
|
-
const result = await super.getAll(search, filterAndPaginationDto, user);
|
|
156
|
-
await this.loadLabelsForTasks(result.data);
|
|
157
|
-
await this.loadAssigneesForTasks(result.data);
|
|
158
|
-
return result;
|
|
159
|
-
}
|
|
160
|
-
async moveTask(dto, user) {
|
|
161
|
-
await this.ensureDataSourceRepository();
|
|
162
|
-
const task = await this.repository.findOne({
|
|
163
|
-
where: {
|
|
164
|
-
id: dto.taskId,
|
|
165
|
-
deletedAt: IsNull()
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
if (!task) throw new NotFoundException({
|
|
169
|
-
message: 'Task not found',
|
|
170
|
-
messageKey: TASK_MESSAGES.NOT_FOUND
|
|
171
|
-
});
|
|
172
|
-
const oldListId = task.listId;
|
|
173
|
-
task.listId = dto.targetListId;
|
|
174
|
-
task.position = dto.position ?? 0;
|
|
175
|
-
task.updatedById = user.id;
|
|
176
|
-
const saved = await this.repository.save(task);
|
|
177
|
-
await this.activityService.log(task.id, task.boardId, user.id, 'task.moved', {
|
|
178
|
-
listId: oldListId
|
|
179
|
-
}, {
|
|
180
|
-
listId: dto.targetListId
|
|
181
|
-
});
|
|
182
|
-
await Promise.all([
|
|
183
|
-
this.clearCacheForAll(),
|
|
184
|
-
this.clearCacheForId([
|
|
185
|
-
saved
|
|
186
|
-
])
|
|
187
|
-
]);
|
|
188
|
-
await this.publishDomainAction(TASK_MANAGER_EVENT_ACTIONS.MOVED, {
|
|
189
|
-
ids: [
|
|
190
|
-
saved.id
|
|
191
|
-
],
|
|
192
|
-
metadata: {
|
|
193
|
-
boardId: saved.boardId,
|
|
194
|
-
fromListId: oldListId,
|
|
195
|
-
toListId: dto.targetListId,
|
|
196
|
-
position: saved.position
|
|
197
|
-
},
|
|
198
|
-
user
|
|
199
|
-
});
|
|
200
|
-
return saved;
|
|
201
|
-
}
|
|
202
|
-
async assignTask(dto, user) {
|
|
203
|
-
await this.ensureDataSourceRepository();
|
|
204
|
-
const task = await this.repository.findOne({
|
|
205
|
-
where: {
|
|
206
|
-
id: dto.taskId,
|
|
207
|
-
deletedAt: IsNull()
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
if (!task) throw new NotFoundException({
|
|
211
|
-
message: 'Task not found',
|
|
212
|
-
messageKey: TASK_MESSAGES.NOT_FOUND
|
|
213
|
-
});
|
|
214
|
-
const memberChecks = await Promise.all(dto.assigneeIds.map((id)=>this.boardService.isBoardMember(task.boardId, id)));
|
|
215
|
-
if (memberChecks.some((isMember)=>!isMember)) {
|
|
216
|
-
throw new BadRequestException({
|
|
217
|
-
message: 'Assignee is not a board member',
|
|
218
|
-
messageKey: TASK_MESSAGES.ASSIGNEE_NOT_BOARD_MEMBER
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
const assigneeRepo = await this.ensureAssigneeRepository();
|
|
222
|
-
const oldRows = await assigneeRepo.find({
|
|
223
|
-
where: {
|
|
224
|
-
taskId: dto.taskId
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
const oldIds = oldRows.map((r)=>r.userId);
|
|
228
|
-
await this.syncAssignees(dto.taskId, dto.assigneeIds);
|
|
229
|
-
task.updatedById = user.id;
|
|
230
|
-
const saved = await this.repository.save(task);
|
|
231
|
-
await this.activityService.log(task.id, task.boardId, user.id, 'task.assigned', {
|
|
232
|
-
assigneeIds: oldIds
|
|
233
|
-
}, {
|
|
234
|
-
assigneeIds: dto.assigneeIds
|
|
235
|
-
});
|
|
236
|
-
await Promise.all([
|
|
237
|
-
this.clearCacheForAll(),
|
|
238
|
-
this.clearCacheForId([
|
|
239
|
-
saved
|
|
240
|
-
])
|
|
241
|
-
]);
|
|
242
|
-
saved.assignees = await this.loadAssigneesForTask(saved.id);
|
|
243
|
-
await this.publishDomainAction(TASK_MANAGER_EVENT_ACTIONS.ASSIGNED, {
|
|
244
|
-
ids: [
|
|
245
|
-
saved.id
|
|
246
|
-
],
|
|
247
|
-
metadata: {
|
|
248
|
-
boardId: saved.boardId,
|
|
249
|
-
previousAssigneeIds: oldIds,
|
|
250
|
-
assigneeIds: dto.assigneeIds
|
|
251
|
-
},
|
|
252
|
-
user
|
|
253
|
-
});
|
|
254
|
-
return saved;
|
|
255
|
-
}
|
|
256
|
-
async syncAssignees(taskId, userIds) {
|
|
257
|
-
const repo = await this.ensureAssigneeRepository();
|
|
258
|
-
await repo.delete({
|
|
259
|
-
taskId
|
|
260
|
-
});
|
|
261
|
-
if (userIds.length > 0) {
|
|
262
|
-
await repo.save(userIds.map((userId)=>repo.create({
|
|
263
|
-
taskId,
|
|
264
|
-
userId
|
|
265
|
-
})));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
async syncLabels(taskId, labelIds) {
|
|
269
|
-
const labelRepo = await this.ensureLabelRepository();
|
|
270
|
-
await labelRepo.delete({
|
|
271
|
-
taskId
|
|
272
|
-
});
|
|
273
|
-
if (labelIds.length > 0) {
|
|
274
|
-
const rows = labelIds.map((labelId)=>labelRepo.create({
|
|
275
|
-
taskId,
|
|
276
|
-
labelId
|
|
277
|
-
}));
|
|
278
|
-
await labelRepo.save(rows);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
async loadLabelsForTasks(tasks) {
|
|
282
|
-
if (tasks.length === 0) return;
|
|
283
|
-
const junctionRepo = await this.ensureLabelRepository();
|
|
284
|
-
const fullRepo = await this.ensureFullLabelRepository();
|
|
285
|
-
const taskIds = tasks.map((t)=>t.id);
|
|
286
|
-
const junctionRows = await junctionRepo.find({
|
|
287
|
-
where: {
|
|
288
|
-
taskId: In(taskIds),
|
|
289
|
-
deletedAt: IsNull()
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
const uniqueLabelIds = [
|
|
293
|
-
...new Set(junctionRows.map((r)=>r.labelId))
|
|
294
|
-
];
|
|
295
|
-
const fullLabels = uniqueLabelIds.length > 0 ? await fullRepo.find({
|
|
296
|
-
where: {
|
|
297
|
-
id: In(uniqueLabelIds),
|
|
298
|
-
deletedAt: IsNull()
|
|
299
|
-
}
|
|
300
|
-
}) : [];
|
|
301
|
-
const labelById = new Map(fullLabels.map((l)=>[
|
|
302
|
-
l.id,
|
|
303
|
-
l
|
|
304
|
-
]));
|
|
305
|
-
const byTask = new Map();
|
|
306
|
-
for (const row of junctionRows){
|
|
307
|
-
const label = labelById.get(row.labelId);
|
|
308
|
-
if (!label) continue;
|
|
309
|
-
const list = byTask.get(row.taskId) ?? [];
|
|
310
|
-
list.push(label);
|
|
311
|
-
byTask.set(row.taskId, list);
|
|
312
|
-
}
|
|
313
|
-
for (const task of tasks){
|
|
314
|
-
const taskLabels = byTask.get(task.id) ?? [];
|
|
315
|
-
task.labelIds = taskLabels.map((l)=>l.id);
|
|
316
|
-
task.labels = taskLabels;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
async loadAssigneesForTasks(tasks) {
|
|
320
|
-
if (tasks.length === 0) return;
|
|
321
|
-
const repo = await this.ensureAssigneeRepository();
|
|
322
|
-
const taskIds = tasks.map((t)=>t.id);
|
|
323
|
-
const rows = await repo.createQueryBuilder('ta').select('ta.task_id', 'taskId').addSelect('ta.user_id', 'userId').addSelect('u.name', 'userName').leftJoin('app_user', 'u', 'u.id = ta.user_id').where('ta.task_id IN (:...taskIds)', {
|
|
324
|
-
taskIds
|
|
325
|
-
}).getRawMany();
|
|
326
|
-
const byTask = new Map();
|
|
327
|
-
for (const row of rows){
|
|
328
|
-
const list = byTask.get(row.taskId) ?? [];
|
|
329
|
-
list.push({
|
|
330
|
-
userId: row.userId,
|
|
331
|
-
userName: row.userName ?? null
|
|
332
|
-
});
|
|
333
|
-
byTask.set(row.taskId, list);
|
|
334
|
-
}
|
|
335
|
-
for (const task of tasks){
|
|
336
|
-
task.assignees = byTask.get(task.id) ?? [];
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
async loadAssigneesForTask(taskId) {
|
|
340
|
-
const repo = await this.ensureAssigneeRepository();
|
|
341
|
-
const rows = await repo.createQueryBuilder('ta').select('ta.user_id', 'userId').addSelect('u.name', 'userName').leftJoin('app_user', 'u', 'u.id = ta.user_id').where('ta.task_id = :taskId', {
|
|
342
|
-
taskId
|
|
343
|
-
}).getRawMany();
|
|
344
|
-
return rows.map((r)=>({
|
|
345
|
-
userId: r.userId,
|
|
346
|
-
userName: r.userName ?? null
|
|
347
|
-
}));
|
|
348
|
-
}
|
|
349
|
-
async ensureLabelRepository() {
|
|
350
|
-
if (!this.taskLabelRepository) {
|
|
351
|
-
this.taskLabelRepository = await this.dataSourceProvider.getRepository(TaskTaskLabel);
|
|
352
|
-
}
|
|
353
|
-
return this.taskLabelRepository;
|
|
354
|
-
}
|
|
355
|
-
async ensureFullLabelRepository() {
|
|
356
|
-
if (!this.fullLabelRepository) {
|
|
357
|
-
this.fullLabelRepository = await this.dataSourceProvider.getRepository(TaskLabel);
|
|
358
|
-
}
|
|
359
|
-
return this.fullLabelRepository;
|
|
360
|
-
}
|
|
361
|
-
async ensureAssigneeRepository() {
|
|
362
|
-
if (!this.taskAssigneeRepository) {
|
|
363
|
-
this.taskAssigneeRepository = await this.dataSourceProvider.getRepository(TaskAssignee);
|
|
364
|
-
}
|
|
365
|
-
return this.taskAssigneeRepository;
|
|
366
|
-
}
|
|
367
|
-
constructor(cacheManager, utilsService, dataSourceProvider, boardService, activityService){
|
|
368
|
-
super(TASK_MANAGER_EVENT_ENTITIES.TASK, cacheManager, utilsService, TaskService.name, true, TASK_MANAGER_EVENT_MODULE, dataSourceProvider, Task), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "dataSourceProvider", void 0), _define_property(this, "boardService", void 0), _define_property(this, "activityService", void 0), _define_property(this, "taskLabelRepository", void 0), _define_property(this, "fullLabelRepository", void 0), _define_property(this, "taskAssigneeRepository", void 0), _define_property(this, "pendingLabelIds", void 0), _define_property(this, "pendingAssigneeIds", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.dataSourceProvider = dataSourceProvider, this.boardService = boardService, this.activityService = activityService, this.taskLabelRepository = null, this.fullLabelRepository = null, this.taskAssigneeRepository = null, this.pendingLabelIds = [], this.pendingAssigneeIds = [];
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
TaskService = _ts_decorate([
|
|
372
|
-
Injectable({
|
|
373
|
-
scope: Scope.REQUEST
|
|
374
|
-
}),
|
|
375
|
-
_ts_param(0, Inject('CACHE_INSTANCE')),
|
|
376
|
-
_ts_param(1, Inject(UtilsService)),
|
|
377
|
-
_ts_param(2, Inject(TaskManagerDataSourceProvider)),
|
|
378
|
-
_ts_param(3, Inject(TaskBoardService)),
|
|
379
|
-
_ts_param(4, Inject(TaskActivityService)),
|
|
380
|
-
_ts_metadata("design:type", Function),
|
|
381
|
-
_ts_metadata("design:paramtypes", [
|
|
382
|
-
typeof HybridCache === "undefined" ? Object : HybridCache,
|
|
383
|
-
typeof UtilsService === "undefined" ? Object : UtilsService,
|
|
384
|
-
typeof TaskManagerDataSourceProvider === "undefined" ? Object : TaskManagerDataSourceProvider,
|
|
385
|
-
typeof TaskBoardService === "undefined" ? Object : TaskBoardService,
|
|
386
|
-
typeof TaskActivityService === "undefined" ? Object : TaskActivityService
|
|
387
|
-
])
|
|
388
|
-
], TaskService);
|