fix: Resolve CI typecheck failures and improve type safety
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Fixes CI pipeline failures caused by missing Prisma Client generation and TypeScript type safety issues. Added Prisma generation step to CI pipeline, installed missing type dependencies, and resolved 40+ exactOptionalPropertyTypes violations across service layer. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,22 @@ export class TasksService {
|
||||
* Create a new task
|
||||
*/
|
||||
async create(workspaceId: string, userId: string, createTaskDto: CreateTaskDto) {
|
||||
const data: Prisma.TaskCreateInput = Object.assign({}, createTaskDto, {
|
||||
const assigneeConnection = createTaskDto.assigneeId
|
||||
? { connect: { id: createTaskDto.assigneeId } }
|
||||
: undefined;
|
||||
|
||||
const projectConnection = createTaskDto.projectId
|
||||
? { connect: { id: createTaskDto.projectId } }
|
||||
: undefined;
|
||||
|
||||
const parentConnection = createTaskDto.parentId
|
||||
? { connect: { id: createTaskDto.parentId } }
|
||||
: undefined;
|
||||
|
||||
const data: Prisma.TaskCreateInput = {
|
||||
title: createTaskDto.title,
|
||||
description: createTaskDto.description ?? null,
|
||||
dueDate: createTaskDto.dueDate ?? null,
|
||||
workspace: { connect: { id: workspaceId } },
|
||||
creator: { connect: { id: userId } },
|
||||
status: createTaskDto.status ?? TaskStatus.NOT_STARTED,
|
||||
@@ -28,12 +43,10 @@ export class TasksService {
|
||||
metadata: createTaskDto.metadata
|
||||
? (createTaskDto.metadata as unknown as Prisma.InputJsonValue)
|
||||
: {},
|
||||
assignee: createTaskDto.assigneeId
|
||||
? { connect: { id: createTaskDto.assigneeId } }
|
||||
: undefined,
|
||||
project: createTaskDto.projectId ? { connect: { id: createTaskDto.projectId } } : undefined,
|
||||
parent: createTaskDto.parentId ? { connect: { id: createTaskDto.parentId } } : undefined,
|
||||
});
|
||||
...(assigneeConnection && { assignee: assigneeConnection }),
|
||||
...(projectConnection && { project: projectConnection }),
|
||||
...(parentConnection && { parent: parentConnection }),
|
||||
};
|
||||
|
||||
// Set completedAt if status is COMPLETED
|
||||
if (data.status === TaskStatus.COMPLETED) {
|
||||
@@ -72,16 +85,18 @@ export class TasksService {
|
||||
const skip = (page - 1) * limit;
|
||||
|
||||
// Build where clause
|
||||
const where: Prisma.TaskWhereInput = {
|
||||
workspaceId: query.workspaceId,
|
||||
};
|
||||
const where: Prisma.TaskWhereInput = query.workspaceId
|
||||
? {
|
||||
workspaceId: query.workspaceId,
|
||||
}
|
||||
: {};
|
||||
|
||||
if (query.status) {
|
||||
where.status = query.status;
|
||||
where.status = Array.isArray(query.status) ? { in: query.status } : query.status;
|
||||
}
|
||||
|
||||
if (query.priority) {
|
||||
where.priority = query.priority;
|
||||
where.priority = Array.isArray(query.priority) ? { in: query.priority } : query.priority;
|
||||
}
|
||||
|
||||
if (query.assigneeId) {
|
||||
@@ -190,23 +205,39 @@ export class TasksService {
|
||||
throw new NotFoundException(`Task with ID ${id} not found`);
|
||||
}
|
||||
|
||||
// Build update data
|
||||
const data: Prisma.TaskUpdateInput = {
|
||||
title: updateTaskDto.title,
|
||||
description: updateTaskDto.description,
|
||||
status: updateTaskDto.status,
|
||||
priority: updateTaskDto.priority,
|
||||
dueDate: updateTaskDto.dueDate,
|
||||
sortOrder: updateTaskDto.sortOrder,
|
||||
metadata: updateTaskDto.metadata
|
||||
? (updateTaskDto.metadata as unknown as Prisma.InputJsonValue)
|
||||
: undefined,
|
||||
assignee: updateTaskDto.assigneeId
|
||||
? { connect: { id: updateTaskDto.assigneeId } }
|
||||
: undefined,
|
||||
project: updateTaskDto.projectId ? { connect: { id: updateTaskDto.projectId } } : undefined,
|
||||
parent: updateTaskDto.parentId ? { connect: { id: updateTaskDto.parentId } } : undefined,
|
||||
};
|
||||
// Build update data - only include defined fields
|
||||
const data: Prisma.TaskUpdateInput = {};
|
||||
|
||||
if (updateTaskDto.title !== undefined) {
|
||||
data.title = updateTaskDto.title;
|
||||
}
|
||||
if (updateTaskDto.description !== undefined) {
|
||||
data.description = updateTaskDto.description;
|
||||
}
|
||||
if (updateTaskDto.status !== undefined) {
|
||||
data.status = updateTaskDto.status;
|
||||
}
|
||||
if (updateTaskDto.priority !== undefined) {
|
||||
data.priority = updateTaskDto.priority;
|
||||
}
|
||||
if (updateTaskDto.dueDate !== undefined) {
|
||||
data.dueDate = updateTaskDto.dueDate;
|
||||
}
|
||||
if (updateTaskDto.sortOrder !== undefined) {
|
||||
data.sortOrder = updateTaskDto.sortOrder;
|
||||
}
|
||||
if (updateTaskDto.metadata !== undefined) {
|
||||
data.metadata = updateTaskDto.metadata as unknown as Prisma.InputJsonValue;
|
||||
}
|
||||
if (updateTaskDto.assigneeId !== undefined && updateTaskDto.assigneeId !== null) {
|
||||
data.assignee = { connect: { id: updateTaskDto.assigneeId } };
|
||||
}
|
||||
if (updateTaskDto.projectId !== undefined && updateTaskDto.projectId !== null) {
|
||||
data.project = { connect: { id: updateTaskDto.projectId } };
|
||||
}
|
||||
if (updateTaskDto.parentId !== undefined && updateTaskDto.parentId !== null) {
|
||||
data.parent = { connect: { id: updateTaskDto.parentId } };
|
||||
}
|
||||
|
||||
// Handle completedAt based on status changes
|
||||
if (updateTaskDto.status) {
|
||||
|
||||
Reference in New Issue
Block a user