feat: epics, subtasks and checklists

Tickets can hang from another one of the same project, three levels deep
at most (epic → ticket → subtask). The ticket page lists its subtasks with
their progress, creates new ones and moves the ticket under an epic; a new
Épicas tab shows every epic and how far it has got. Each ticket also gets a
checklist for the small steps that don't deserve a ticket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 13:52:43 +02:00
parent 75323115fb
commit d4da33d4e8
84 changed files with 4719 additions and 79 deletions

View File

@@ -140,6 +140,13 @@ export class CreateIssueInput extends IssueFieldsInput {
@Field(() => ID, { nullable: true }) @IsOptional() @IsUUID() releaseId?:
| string
| null;
@Field(() => ID, {
nullable: true,
description: 'Epic or ticket of the same project the new one breaks down',
})
@IsOptional()
@IsUUID()
parentId?: string | null;
}
@InputType()
@@ -173,6 +180,25 @@ export class ChangeIssueStatusInput {
reason?: string | null;
}
@InputType()
export class AddChecklistItemInput {
@Field(() => ID) @IsUUID() issueId!: string;
@Field() @IsString() @MinLength(1) @MaxLength(300) text!: string;
}
@InputType()
export class UpdateChecklistItemInput {
@Field(() => ID) @IsUUID() issueId!: string;
@Field(() => ID) @IsUUID() itemId!: string;
@Field({ nullable: true })
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(300)
text?: string;
@Field({ nullable: true }) @IsOptional() @IsBoolean() done?: boolean;
}
@InputType()
export class LinkIssuesInput {
@Field(() => ID) @IsUUID() issueId!: string;
@@ -216,6 +242,13 @@ export class IssueFilterInput {
@IsOptional()
@IsString({ each: true })
labels?: string[];
@Field(() => ID, {
nullable: true,
description: 'Only the tickets hanging from this one',
})
@IsOptional()
@IsUUID()
parentId?: string;
@Field({ nullable: true, description: 'Matches key, title or description' })
@IsOptional()
@IsString()

View File

@@ -23,10 +23,12 @@ import {
StatusCategory,
} from '@task-stream/api/tracker/domain';
import {
AddChecklistItemInput,
ChangeIssueStatusInput,
CreateIssueInput,
IssueFilterInput,
LinkIssuesInput,
UpdateChecklistItemInput,
UpdateIssueInput,
} from './inputs';
import { withoutNulls } from '../common/issue-input';
@@ -35,6 +37,7 @@ import {
ActivityGql,
CommandResultGql,
CommentPageGql,
EpicGql,
IssueGql,
IssuePageGql,
} from './types';
@@ -72,6 +75,18 @@ export class IssueResolver {
});
}
@OptionalAuth()
@Query(() => [EpicGql], {
description:
"A project's epics: top-level tickets that group others, with the progress of those",
})
epics(
@CurrentUser() me: User | undefined,
@Args('projectId', { type: () => ID }) projectId: string,
) {
return this.issuesService.epics(viewerOf(me), projectId);
}
@Query(() => IssuePageGql, {
description:
'Tickets across all my projects: assigned to me (default) or any (e.g. categories [QA])',
@@ -238,6 +253,56 @@ export class IssueResolver {
return this.issuesService.unlink(me.id, input);
}
@Mutation(() => CommandResultGql, {
description:
'Place a ticket under an epic or another ticket of the same project (null: back to the top). Three levels at most: epic → ticket → subtask.',
})
setIssueParent(
@CurrentUser() me: User,
@Args('issueId', { type: () => ID }) issueId: string,
@Args('parentId', { type: () => ID, nullable: true })
parentId: string | null,
) {
return this.issuesService.setParent(me.id, issueId, parentId ?? null);
}
@Mutation(() => CommandResultGql, {
description: "Add a step to a ticket's checklist",
})
addChecklistItem(
@CurrentUser() me: User,
@Args('input') input: AddChecklistItemInput,
) {
return this.issuesService.addChecklistItem(
me.id,
input.issueId,
input.text,
);
}
@Mutation(() => CommandResultGql, {
description: 'Reword, tick or untick a checklist step',
})
updateChecklistItem(
@CurrentUser() me: User,
@Args('input') input: UpdateChecklistItemInput,
) {
const { issueId, itemId, text, done } = input;
return this.issuesService.updateChecklistItem(me.id, issueId, itemId, {
...(text != null && { text }),
...(done != null && { done }),
});
}
@Mutation(() => CommandResultGql)
removeChecklistItem(
@CurrentUser() me: User,
@Args('issueId', { type: () => ID }) issueId: string,
@Args('itemId', { type: () => ID }) itemId: string,
) {
return this.issuesService.removeChecklistItem(me.id, issueId, itemId);
}
@Mutation(() => CommandResultGql, {
description: 'Put a ticket in a release (null removes it)',
})

View File

@@ -116,6 +116,23 @@ export class ReleaseRefGql {
@Field() name!: string;
}
@ObjectType('ChecklistItem', {
description:
'A step inside a ticket that does not deserve a ticket of its own',
})
export class ChecklistItemGql {
@Field(() => ID) id!: string;
@Field() text!: string;
@Field() done!: boolean;
}
@ObjectType('IssueParent', { description: 'The ticket another one hangs from' })
export class IssueParentGql {
@Field(() => ID) id!: string;
@Field() key!: string;
@Field() title!: string;
}
@ObjectType('Issue')
export class IssueGql {
@Field(() => ID) id!: string;
@@ -145,12 +162,37 @@ export class IssueGql {
@Field(() => [AttachmentGql]) attachments!: AttachmentGql[];
@Field(() => [UserRefGql], { description: 'People following the ticket' })
watchers!: UserRefGql[];
@Field(() => IssueParentGql, {
nullable: true,
description: 'The epic or ticket this one breaks down',
})
parent!: IssueParentGql | null;
@Field(() => [ChecklistItemGql]) checklist!: ChecklistItemGql[];
@Field(() => Int) commentCount!: number;
@Field() createdAt!: string;
@Field() updatedAt!: string;
@Field(() => Int) version!: number;
}
@ObjectType('ChildProgress', {
description: 'How far the tickets hanging from one have got',
})
export class ChildProgressGql {
@Field(() => Int) total!: number;
@Field(() => Int, { description: 'Done or cancelled' }) finished!: number;
@Field(() => Int) percent!: number;
@Field(() => Int) storyPoints!: number;
@Field(() => Int) finishedStoryPoints!: number;
}
@ObjectType('Epic', {
description: 'A top-level ticket that groups others, with their progress',
})
export class EpicGql {
@Field(() => IssueGql) issue!: IssueGql;
@Field(() => ChildProgressGql) progress!: ChildProgressGql;
}
@ObjectType('IssuePage')
export class IssuePageGql {
@Field(() => [IssueGql]) items!: IssueGql[];

View File

@@ -408,6 +408,14 @@ export class IssueSearchQueryDto extends PageQueryDto {
@IsString({ each: true })
label?: string[];
@ApiPropertyOptional({
description: 'Only the tickets hanging from this one (id or key)',
example: 'WEB-3',
})
@IsOptional()
@IsString()
parent?: string;
@ApiPropertyOptional({ description: 'Matches key, title or description' })
@IsOptional()
@IsString()
@@ -501,6 +509,17 @@ export class CreateIssueDto extends IssueFieldsDto {
@IsOptional()
@IsString()
releaseId?: string | null;
@ApiPropertyOptional({
type: String,
nullable: true,
example: 'WEB-3',
description:
'Epic or ticket of the same project the new one breaks down (id or key)',
})
@IsOptional()
@IsString()
parent?: string | null;
}
export class UpdateIssueDto extends IssueFieldsDto {
@@ -560,6 +579,41 @@ export class SetIssueReleaseDto {
releaseId!: string | null;
}
export class SetIssueParentDto {
@ApiProperty({
type: String,
nullable: true,
example: 'WEB-3',
description:
'Epic or ticket of the same project (id or key), or null to take it back to the top',
})
@ValidateIf((dto: SetIssueParentDto) => dto.parent !== null)
@IsString()
parent!: string | null;
}
export class ChecklistItemBodyDto {
@ApiProperty({ example: 'Actualizar el changelog', maxLength: 300 })
@IsString()
@MinLength(1)
@MaxLength(300)
text!: string;
}
export class UpdateChecklistItemDto {
@ApiPropertyOptional({ maxLength: 300 })
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(300)
text?: string;
@ApiPropertyOptional()
@IsOptional()
@IsBoolean()
done?: boolean;
}
export class LinkIssueDto {
@ApiProperty({ enum: IssueLinkType, enumName: 'IssueLinkType' })
@IsEnum(IssueLinkType)

View File

@@ -123,6 +123,18 @@ export class AttachmentDto {
commentId!: string | null;
}
export class ChecklistItemDto {
@ApiProperty({ format: 'uuid' }) id!: string;
@ApiProperty({ example: 'Actualizar el changelog' }) text!: string;
@ApiProperty() done!: boolean;
}
export class IssueParentDto {
@ApiProperty({ format: 'uuid' }) id!: string;
@ApiProperty({ example: 'WEB-3' }) key!: string;
@ApiProperty({ example: 'Pago con tarjeta' }) title!: string;
}
export class IssueDto {
@ApiProperty({ format: 'uuid' }) id!: string;
@ApiProperty({ format: 'uuid' }) projectId!: string;
@@ -161,6 +173,13 @@ export class IssueDto {
@ApiProperty({ type: [AttachmentDto] }) attachments!: AttachmentDto[];
@ApiProperty({ type: [UserRefDto], description: 'People following it' })
watchers!: UserRefDto[];
@ApiProperty({
type: IssueParentDto,
nullable: true,
description: 'The epic or ticket this one breaks down',
})
parent!: IssueParentDto | null;
@ApiProperty({ type: [ChecklistItemDto] }) checklist!: ChecklistItemDto[];
@ApiProperty() commentCount!: number;
@ApiProperty({ format: 'date-time' }) createdAt!: string;
@ApiProperty({ format: 'date-time' }) updatedAt!: string;
@@ -233,6 +252,19 @@ export class CountByAssigneeDto {
@ApiProperty() count!: number;
}
export class ChildProgressDto {
@ApiProperty() total!: number;
@ApiProperty({ description: 'Done or cancelled' }) finished!: number;
@ApiProperty({ minimum: 0, maximum: 100 }) percent!: number;
@ApiProperty() storyPoints!: number;
@ApiProperty() finishedStoryPoints!: number;
}
export class EpicDto {
@ApiProperty({ type: IssueDto }) issue!: IssueDto;
@ApiProperty({ type: ChildProgressDto }) progress!: ChildProgressDto;
}
export class ReleaseProgressDto {
@ApiProperty() total!: number;
@ApiProperty() finished!: number;

View File

@@ -4,6 +4,7 @@ import {
Delete,
Get,
Param,
ParseUUIDPipe,
Patch,
Post,
Put,
@@ -35,6 +36,7 @@ import { withoutNulls } from '../common/issue-input';
import {
AssignIssueDto,
ChangeStatusDto,
ChecklistItemBodyDto,
CommentBodyDto,
CreateIssueDto,
IssueSearchQueryDto,
@@ -42,13 +44,16 @@ import {
LinkTypeParamDto,
MyIssuesQueryDto,
PageQueryDto,
SetIssueParentDto,
SetIssueReleaseDto,
UpdateChecklistItemDto,
UpdateIssueDto,
} from './dto/requests.dto';
import {
ActivityDto,
CommandResultDto,
CommentPageDto,
EpicDto,
IssueDto,
IssuePageDto,
} from './dto/responses.dto';
@@ -139,6 +144,9 @@ export class IssuesController {
) {
const page = await this.issues.search(viewerOf(me), {
projectId: await this.refs.projectId(viewerOf(me), project),
parentId: query.parent
? await this.refs.issueId(viewerOf(me), query.parent)
: undefined,
statuses: query.status,
categories: query.category,
types: query.type,
@@ -169,12 +177,40 @@ export class IssuesController {
@Param('project') project: string,
@Body() body: CreateIssueDto,
) {
const { parent, ...fields } = body;
return this.issues.create(me.id, {
...withoutNulls(body),
...withoutNulls(fields),
projectId: await this.refs.projectId(me.id, project),
parentId: parent ? await this.refs.issueId(me.id, parent) : null,
});
}
@Get('projects/:project/epics')
@ApiOptionalPireonAuth()
@PROJECT
@ApiOperation({
summary: 'Epics: top-level tickets that group others',
description:
'With the progress of the tickets hanging from each one (done or cancelled, and story points).',
})
@ApiOkResponse({ type: [EpicDto] })
@ApiReadErrors()
async epics(
@CurrentUser() me: User | undefined,
@Param('project') project: string,
) {
const epics = await this.issues.epics(
viewerOf(me),
await this.refs.projectId(viewerOf(me), project),
);
return Promise.all(
epics.map(async (epic) => ({
...epic,
issue: await this.refs.issueDto(epic.issue),
})),
);
}
@Get('issues/:issue')
@ApiOptionalPireonAuth()
@ISSUE
@@ -266,6 +302,82 @@ export class IssuesController {
);
}
@Put('issues/:issue/parent')
@ISSUE
@ApiOperation({
summary: 'Place the ticket under an epic or another ticket',
description:
'Same project, three levels at most (epic → ticket → subtask), no loops. null takes it back to the top.',
})
@ApiOkResponse({ type: CommandResultDto })
@ApiCommandErrors()
async setParent(
@CurrentUser() me: User,
@Param('issue') issue: string,
@Body() body: SetIssueParentDto,
) {
return this.issues.setParent(
me.id,
await this.refs.issueId(me.id, issue),
body.parent ? await this.refs.issueId(me.id, body.parent) : null,
);
}
@Post('issues/:issue/checklist')
@ISSUE
@ApiOperation({ summary: "Add a step to the ticket's checklist" })
@ApiCreatedResponse({ type: CommandResultDto })
@ApiCommandErrors()
async addChecklistItem(
@CurrentUser() me: User,
@Param('issue') issue: string,
@Body() body: ChecklistItemBodyDto,
) {
return this.issues.addChecklistItem(
me.id,
await this.refs.issueId(me.id, issue),
body.text,
);
}
@Patch('issues/:issue/checklist/:item')
@ISSUE
@ApiParam({ name: 'item', format: 'uuid' })
@ApiOperation({ summary: 'Reword, tick or untick a checklist step' })
@ApiOkResponse({ type: CommandResultDto })
@ApiCommandErrors()
async updateChecklistItem(
@CurrentUser() me: User,
@Param('issue') issue: string,
@Param('item', ParseUUIDPipe) item: string,
@Body() body: UpdateChecklistItemDto,
) {
return this.issues.updateChecklistItem(
me.id,
await this.refs.issueId(me.id, issue),
item,
body,
);
}
@Delete('issues/:issue/checklist/:item')
@ISSUE
@ApiParam({ name: 'item', format: 'uuid' })
@ApiOperation({ summary: 'Remove a checklist step' })
@ApiOkResponse({ type: CommandResultDto })
@ApiCommandErrors()
async removeChecklistItem(
@CurrentUser() me: User,
@Param('issue') issue: string,
@Param('item', ParseUUIDPipe) item: string,
) {
return this.issues.removeChecklistItem(
me.id,
await this.refs.issueId(me.id, issue),
item,
);
}
@Post('issues/:issue/links')
@ISSUE
@ApiOperation({