feat: per-project workflow settings, statistics and "my work" home

Per-project settings (owners/admins, «Configuración» tab):
- Statuses with category (TODO, IN_PROGRESS, QA, DONE, CANCELLED), colour and
  "requires reason"; configurable transitions; ticket types (icon, colour) and
  areas. Defaults are the previous fixed values; projects created before keep
  them without migration.
- Values are archived, never deleted: tickets, history and statistics keep
  referring to them. Validated in the domain (ProjectSettingsChangedEvent).
- Releases, board, tracking and "my work" use categories, so custom statuses
  keep working. Status changes carry name/category metadata for history.
- GraphQL: status/type/area are strings (breaking for clients sending enum
  literals); Project.settings, updateProjectSettings, statusCategory,
  myIssues(categories). REST: PUT /projects/{project}/settings, category filters.
- Read model: statusCategory on issues (backfilled at startup).

Statistics («Estadísticas» tab):
- New issue_timeline projection; pure functions compute created vs resolved,
  cumulative flow, cycle/lead time (avg + p85), throughput per person, QA
  pass/fail and release burnup. GraphQL Project.analytics(days),
  Release.burnup; REST /projects/{project}/analytics, /releases/{id}/burnup.
- Web: SVG charts with validated light/dark palette, crosshair tooltip,
  keyboard navigation, legend and data table.

Home "Mi trabajo": my open tickets across projects grouped by category (QA
failures first), tickets waiting for QA, upcoming releases and "Ir a…".

Tests: domain/application specs, e2e scenario for settings and analytics,
facade tests. Docs, READMEs, schema.gql/openapi.json and Word/PDF updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 20:53:45 +02:00
parent 240ea9a539
commit 0e301ad545
143 changed files with 10291 additions and 1052 deletions

View File

@@ -0,0 +1,56 @@
import {
ProjectSettings,
SettingColor,
StatusCategory,
TypeIcon,
} from '@task-stream/api/tracker/domain';
/** Settings as the APIs carry them: transitions as a list instead of a map. */
export interface SettingsPayload {
statuses: {
id: string;
name: string;
category: StatusCategory;
color: string;
requiresReason: boolean;
archived: boolean;
}[];
transitions: { from: string; to: string[] }[];
issueTypes: {
id: string;
name: string;
icon: string;
color: string;
archived: boolean;
}[];
areas: { id: string; name: string; archived: boolean }[];
}
export function toSettingsPayload(settings: ProjectSettings): SettingsPayload {
return {
...settings,
transitions: settings.statuses.map((s) => ({
from: s.id,
to: settings.transitions[s.id] ?? [],
})),
};
}
/** Colours and icons are checked by the domain (validateProjectSettings). */
export function fromSettingsPayload(payload: SettingsPayload): ProjectSettings {
return {
statuses: payload.statuses.map((s) => ({
...s,
color: s.color as SettingColor,
})),
transitions: Object.fromEntries(
payload.transitions.map((t) => [t.from, t.to]),
),
issueTypes: payload.issueTypes.map((t) => ({
...t,
icon: t.icon as TypeIcon,
color: t.color as SettingColor,
})),
areas: payload.areas,
};
}

View File

@@ -1,12 +1,10 @@
import { registerEnumType } from '@nestjs/graphql';
import {
IssueArea,
IssueLinkType,
IssuePriority,
IssueStatus,
IssueType,
ProjectRole,
ReleaseStatus,
StatusCategory,
} from '@task-stream/api/tracker/domain';
export enum LinkDirection {
@@ -14,13 +12,12 @@ export enum LinkDirection {
INWARD = 'INWARD',
}
registerEnumType(IssueType, { name: 'IssueType' });
registerEnumType(IssueArea, {
name: 'IssueArea',
description: 'Team/layer: links FE ↔ BE ↔ QA work',
});
registerEnumType(IssuePriority, { name: 'IssuePriority' });
registerEnumType(IssueStatus, { name: 'IssueStatus' });
registerEnumType(StatusCategory, {
name: 'StatusCategory',
description:
'What a status means, whatever each project calls it. DONE and CANCELLED are finished.',
});
registerEnumType(IssueLinkType, { name: 'IssueLinkType' });
registerEnumType(ProjectRole, { name: 'ProjectRole' });
registerEnumType(ReleaseStatus, { name: 'ReleaseStatus' });

View File

@@ -1,14 +1,14 @@
import { Field, ID, InputType, Int } from '@nestjs/graphql';
import {
IssueArea,
IssueLinkType,
IssuePriority,
IssueStatus,
IssueType,
ProjectRole,
StatusCategory,
} from '@task-stream/api/tracker/domain';
import { Type } from 'class-transformer';
import {
ArrayMaxSize,
IsArray,
IsBoolean,
IsEnum,
IsInt,
@@ -22,8 +22,12 @@ import {
MaxLength,
Min,
MinLength,
ValidateNested,
} from 'class-validator';
/** Ids of statuses, types and areas (checked against the project's settings). */
const SETTING_ID = /^[A-Za-z][A-Za-z0-9_]{0,29}$/;
@InputType()
export class CreateProjectInput {
@Field({ description: '2-10 chars, e.g. "TS" → tickets TS-1, TS-2...' })
@@ -74,10 +78,10 @@ abstract class IssueFieldsInput {
@MaxLength(50000)
description?: string | null;
@Field(() => IssueArea, { nullable: true })
@Field(() => String, { nullable: true, description: 'An area id' })
@IsOptional()
@IsEnum(IssueArea)
area?: IssueArea | null;
@Matches(SETTING_ID)
area?: string | null;
@Field(() => IssuePriority, { nullable: true })
@IsOptional()
@@ -114,7 +118,9 @@ abstract class IssueFieldsInput {
@InputType()
export class CreateIssueInput extends IssueFieldsInput {
@Field(() => ID) @IsUUID() projectId!: string;
@Field(() => IssueType) @IsEnum(IssueType) type!: IssueType;
@Field({ description: 'A ticket type id' })
@Matches(SETTING_ID)
type!: string;
@Field() @IsString() @MinLength(1) @MaxLength(255) title!: string;
@Field(() => ID, { nullable: true }) @IsOptional() @IsString() assigneeId?:
| string
@@ -127,10 +133,10 @@ export class CreateIssueInput extends IssueFieldsInput {
@InputType()
export class UpdateIssueInput extends IssueFieldsInput {
@Field(() => ID) @IsUUID() issueId!: string;
@Field(() => IssueType, { nullable: true })
@Field({ nullable: true })
@IsOptional()
@IsEnum(IssueType)
type?: IssueType;
@Matches(SETTING_ID)
type?: string;
@Field({ nullable: true })
@IsOptional()
@IsString()
@@ -142,10 +148,12 @@ export class UpdateIssueInput extends IssueFieldsInput {
@InputType()
export class ChangeIssueStatusInput {
@Field(() => ID) @IsUUID() issueId!: string;
@Field(() => IssueStatus) @IsEnum(IssueStatus) status!: IssueStatus;
@Field({ description: 'A status id' })
@Matches(SETTING_ID)
status!: string;
@Field(() => String, {
nullable: true,
description: 'Required for QA_FAILED and CANCELLED',
description: 'Required by statuses with requiresReason',
})
@IsOptional()
@IsString()
@@ -163,18 +171,22 @@ export class LinkIssuesInput {
@InputType()
export class IssueFilterInput {
@Field(() => ID) @IsUUID() projectId!: string;
@Field(() => [IssueStatus], { nullable: true })
@Field(() => [String], { nullable: true })
@IsOptional()
@IsEnum(IssueStatus, { each: true })
statuses?: IssueStatus[];
@Field(() => [IssueType], { nullable: true })
@IsString({ each: true })
statuses?: string[];
@Field(() => [StatusCategory], { nullable: true })
@IsOptional()
@IsEnum(IssueType, { each: true })
types?: IssueType[];
@Field(() => [IssueArea], { nullable: true })
@IsEnum(StatusCategory, { each: true })
categories?: StatusCategory[];
@Field(() => [String], { nullable: true })
@IsOptional()
@IsEnum(IssueArea, { each: true })
areas?: IssueArea[];
@IsString({ each: true })
types?: string[];
@Field(() => [String], { nullable: true })
@IsOptional()
@IsString({ each: true })
areas?: string[];
@Field(() => [IssuePriority], { nullable: true })
@IsOptional()
@IsEnum(IssuePriority, { each: true })
@@ -237,3 +249,77 @@ export class UpdateReleaseInput {
@IsISO8601()
targetDate?: string | null;
}
/* Project settings (owners and admins). Values are archived, never deleted. */
@InputType()
export class WorkflowStatusInput {
@Field() @Matches(SETTING_ID) id!: string;
@Field() @IsString() @MinLength(1) @MaxLength(40) name!: string;
@Field(() => StatusCategory)
@IsEnum(StatusCategory)
category!: StatusCategory;
@Field() @IsString() color!: string;
@Field({ defaultValue: false }) @IsBoolean() requiresReason!: boolean;
@Field({ defaultValue: false }) @IsBoolean() archived!: boolean;
}
@InputType()
export class StatusTransitionsInput {
@Field() @Matches(SETTING_ID) from!: string;
@Field(() => [String])
@IsArray()
@ArrayMaxSize(50)
@Matches(SETTING_ID, { each: true })
to!: string[];
}
@InputType()
export class IssueTypeOptionInput {
@Field() @Matches(SETTING_ID) id!: string;
@Field() @IsString() @MinLength(1) @MaxLength(40) name!: string;
@Field() @IsString() icon!: string;
@Field() @IsString() color!: string;
@Field({ defaultValue: false }) @IsBoolean() archived!: boolean;
}
@InputType()
export class AreaOptionInput {
@Field() @Matches(SETTING_ID) id!: string;
@Field() @IsString() @MinLength(1) @MaxLength(40) name!: string;
@Field({ defaultValue: false }) @IsBoolean() archived!: boolean;
}
@InputType({
description:
'The whole configuration (replaces the previous one). Statuses go in board order.',
})
export class ProjectSettingsInput {
@Field(() => [WorkflowStatusInput])
@IsArray()
@ArrayMaxSize(50)
@ValidateNested({ each: true })
@Type(() => WorkflowStatusInput)
statuses!: WorkflowStatusInput[];
@Field(() => [StatusTransitionsInput])
@IsArray()
@ArrayMaxSize(50)
@ValidateNested({ each: true })
@Type(() => StatusTransitionsInput)
transitions!: StatusTransitionsInput[];
@Field(() => [IssueTypeOptionInput])
@IsArray()
@ArrayMaxSize(50)
@ValidateNested({ each: true })
@Type(() => IssueTypeOptionInput)
issueTypes!: IssueTypeOptionInput[];
@Field(() => [AreaOptionInput])
@IsArray()
@ArrayMaxSize(50)
@ValidateNested({ each: true })
@Type(() => AreaOptionInput)
areas!: AreaOptionInput[];
}

View File

@@ -13,11 +13,11 @@ import { CurrentUser } from '@task-stream/api/identity/presenters';
import {
CommentsService,
IssuesService,
WorkflowsService,
} from '@task-stream/api/tracker/application';
import {
IssueReadModel,
IssueStatus,
IssueWorkflow,
StatusCategory,
} from '@task-stream/api/tracker/domain';
import {
ChangeIssueStatusInput,
@@ -40,6 +40,7 @@ export class IssueResolver {
constructor(
private readonly issuesService: IssuesService,
private readonly commentsService: CommentsService,
private readonly workflows: WorkflowsService,
) {}
@Query(() => IssueGql)
@@ -61,6 +62,29 @@ export class IssueResolver {
return this.issuesService.search(me.id, { ...filter, limit, offset });
}
@Query(() => IssuePageGql, {
description:
'Tickets across all my projects: assigned to me (default) or any (e.g. categories [QA])',
})
myIssues(
@CurrentUser() me: User,
@Args('assignedToMe', { defaultValue: true }) assignedToMe: boolean,
@Args('statuses', { type: () => [String], nullable: true })
statuses: string[] | undefined,
@Args('categories', { type: () => [StatusCategory], nullable: true })
categories: StatusCategory[] | undefined,
@Args('limit', { type: () => Int, defaultValue: 50 }) limit: number,
@Args('offset', { type: () => Int, defaultValue: 0 }) offset: number,
) {
return this.issuesService.mine(me.id, {
assignedToMe,
statuses: statuses ?? undefined,
categories: categories ?? undefined,
limit,
offset,
});
}
@Query(() => [ActivityGql], {
description: 'Project activity feed (newest first)',
})
@@ -80,11 +104,11 @@ export class IssueResolver {
});
}
@ResolveField(() => [IssueStatus], {
description: 'Statuses this ticket can move to next',
@ResolveField(() => [String], {
description: "Statuses this ticket can move to next (project's workflow)",
})
allowedTransitions(@Parent() issue: IssueReadModel): readonly IssueStatus[] {
return IssueWorkflow.allowedFrom(issue.status);
allowedTransitions(@Parent() issue: IssueReadModel): Promise<string[]> {
return this.workflows.allowedTransitions(issue);
}
@ResolveField(() => [IssueGql], { description: 'Linked tickets I can see' })

View File

@@ -11,16 +11,20 @@ import {
import { User } from '@task-stream/api/identity/domain';
import { AccessToken, CurrentUser } from '@task-stream/api/identity/presenters';
import { ProjectsService } from '@task-stream/api/tracker/application';
import { IssueArea, ProjectReadModel } from '@task-stream/api/tracker/domain';
import { ProjectReadModel } from '@task-stream/api/tracker/domain';
import { fromSettingsPayload, toSettingsPayload } from '../common/settings';
import {
CreateProjectInput,
ProjectMemberInput,
ProjectSettingsInput,
UpdateProjectInput,
} from './inputs';
import {
BoardColumnGql,
CommandResultGql,
ProjectAnalyticsGql,
ProjectGql,
ProjectSettingsGql,
ProjectStatsGql,
ReleaseGql,
} from './types';
@@ -43,6 +47,23 @@ export class ProjectResolver {
return this.projects.findOne(me.id, idOrKey);
}
@ResolveField(() => ProjectSettingsGql)
settings(@Parent() project: ProjectReadModel) {
return toSettingsPayload(project.settings);
}
@ResolveField(() => ProjectAnalyticsGql, {
description:
'Statistics of the last `days` days (7-365): created vs resolved, cumulative flow, cycle/lead time, throughput and QA',
})
analytics(
@CurrentUser() me: User,
@Parent() project: ProjectReadModel,
@Args('days', { type: () => Int, defaultValue: 90 }) days: number,
) {
return this.projects.analytics(me.id, project.id, days);
}
@ResolveField(() => [ReleaseGql])
releases(@CurrentUser() me: User, @Parent() project: ProjectReadModel) {
return this.projects.releases(me.id, project.id);
@@ -63,7 +84,7 @@ export class ProjectResolver {
@Parent() project: ProjectReadModel,
@Args('releaseId', { type: () => ID, nullable: true }) releaseId?: string,
@Args('assigneeId', { type: () => ID, nullable: true }) assigneeId?: string,
@Args('area', { type: () => IssueArea, nullable: true }) area?: IssueArea,
@Args('area', { type: () => String, nullable: true }) area?: string,
@Args('perColumn', { type: () => Int, defaultValue: 50 }) perColumn = 50,
) {
return this.projects.board(
@@ -95,6 +116,22 @@ export class ProjectResolver {
return this.projects.update(me.id, projectId, changes);
}
@Mutation(() => CommandResultGql, {
description:
'Replace statuses, transitions, ticket types and areas (owners and admins). Values can be archived, not deleted.',
})
updateProjectSettings(
@CurrentUser() me: User,
@Args('projectId', { type: () => ID }) projectId: string,
@Args('settings') settings: ProjectSettingsInput,
) {
return this.projects.updateSettings(
me.id,
projectId,
fromSettingsPayload(settings),
);
}
@Mutation(() => CommandResultGql, {
description: 'Add a Pireon user to the project',
})

View File

@@ -19,6 +19,7 @@ import { CreateReleaseInput, UpdateReleaseInput } from './inputs';
import {
CommandResultGql,
IssuePageGql,
ReleaseBurnupGql,
ReleaseGql,
ReleaseProgressGql,
} from './types';
@@ -35,11 +36,29 @@ export class ReleaseResolver {
return this.releases.findOne(me.id, id);
}
@Query(() => [ReleaseGql], {
description:
'Planned releases of all my projects, soonest target date first',
})
upcomingReleases(
@CurrentUser() me: User,
@Args('limit', { type: () => Int, defaultValue: 10 }) limit: number,
) {
return this.releases.upcoming(me.id, limit);
}
@ResolveField(() => ReleaseProgressGql)
progress(@CurrentUser() me: User, @Parent() release: ReleaseReadModel) {
return this.releases.progress(me.id, release.id);
}
@ResolveField(() => ReleaseBurnupGql, {
description: 'Scope vs finished tickets, day by day',
})
burnup(@CurrentUser() me: User, @Parent() release: ReleaseReadModel) {
return this.releases.burnup(me.id, release.id);
}
@ResolveField(() => IssuePageGql, {
description: 'Tickets included in this release',
})

View File

@@ -1,12 +1,10 @@
import { Field, ID, Int, ObjectType } from '@nestjs/graphql';
import { Field, Float, ID, Int, ObjectType } from '@nestjs/graphql';
import {
IssueArea,
IssueLinkType,
IssuePriority,
IssueStatus,
IssueType,
ProjectRole,
ReleaseStatus,
StatusCategory,
} from '@task-stream/api/tracker/domain';
import { LinkDirection } from './enums';
@@ -22,6 +20,51 @@ export class ProjectMemberGql {
@Field(() => ProjectRole) role!: ProjectRole;
}
@ObjectType('WorkflowStatus')
export class WorkflowStatusGql {
@Field({ description: 'Stable id stored on tickets, e.g. IN_REVIEW' })
id!: string;
@Field() name!: string;
@Field(() => StatusCategory) category!: StatusCategory;
@Field({ description: 'Colour token: slate, violet, green…' }) color!: string;
@Field({ description: 'Entering it needs a reason' })
requiresReason!: boolean;
@Field({ description: 'No new tickets or transitions into it' })
archived!: boolean;
}
@ObjectType('StatusTransitions')
export class StatusTransitionsGql {
@Field() from!: string;
@Field(() => [String]) to!: string[];
}
@ObjectType('IssueTypeOption')
export class IssueTypeOptionGql {
@Field() id!: string;
@Field() name!: string;
@Field() icon!: string;
@Field() color!: string;
@Field() archived!: boolean;
}
@ObjectType('AreaOption')
export class AreaOptionGql {
@Field() id!: string;
@Field() name!: string;
@Field() archived!: boolean;
}
@ObjectType('ProjectSettings', {
description: 'Statuses (board order), transitions, ticket types and areas',
})
export class ProjectSettingsGql {
@Field(() => [WorkflowStatusGql]) statuses!: WorkflowStatusGql[];
@Field(() => [StatusTransitionsGql]) transitions!: StatusTransitionsGql[];
@Field(() => [IssueTypeOptionGql]) issueTypes!: IssueTypeOptionGql[];
@Field(() => [AreaOptionGql]) areas!: AreaOptionGql[];
}
@ObjectType('Project')
export class ProjectGql {
@Field(() => ID) id!: string;
@@ -59,11 +102,15 @@ export class IssueGql {
@Field() projectKey!: string;
@Field(() => Int) number!: number;
@Field({ description: 'Human key, e.g. TS-42' }) key!: string;
@Field(() => IssueType) type!: IssueType;
@Field(() => IssueArea, { nullable: true }) area!: IssueArea | null;
@Field({ description: "A ticket type id of the project's settings" })
type!: string;
@Field(() => String, { nullable: true, description: 'An area id' })
area!: string | null;
@Field() title!: string;
@Field(() => String, { nullable: true }) description!: string | null;
@Field(() => IssueStatus) status!: IssueStatus;
@Field({ description: "A status id of the project's settings" })
status!: string;
@Field(() => StatusCategory) statusCategory!: StatusCategory;
@Field(() => IssuePriority) priority!: IssuePriority;
@Field(() => UserRefGql) reporter!: UserRefGql;
@Field(() => UserRefGql, { nullable: true }) assignee!: UserRefGql | null;
@@ -88,7 +135,7 @@ export class IssuePageGql {
@ObjectType('BoardColumn')
export class BoardColumnGql {
@Field(() => IssueStatus) status!: IssueStatus;
@Field() status!: string;
@Field(() => [IssueGql]) issues!: IssueGql[];
@Field(() => Int) total!: number;
}
@@ -125,7 +172,7 @@ export class ReleaseGql {
@ObjectType('CountByStatus')
export class CountByStatusGql {
@Field(() => IssueStatus) key!: IssueStatus;
@Field({ description: 'Status id' }) key!: string;
@Field(() => Int) count!: number;
}
@@ -221,3 +268,77 @@ export class ProjectChangeGql {
@Field(() => ID) actorId!: string;
@Field(() => ProjectGql) project!: ProjectGql;
}
/* Statistics */
@ObjectType('CreatedResolved')
export class CreatedResolvedGql {
@Field({ description: 'Monday of the week (YYYY-MM-DD)' }) week!: string;
@Field(() => Int) created!: number;
@Field(() => Int) resolved!: number;
}
@ObjectType('FlowSeries')
export class FlowSeriesGql {
@Field() status!: string;
@Field(() => [Int]) counts!: number[];
}
@ObjectType('CumulativeFlow')
export class CumulativeFlowGql {
@Field(() => [String]) dates!: string[];
@Field(() => [FlowSeriesGql]) series!: FlowSeriesGql[];
}
@ObjectType('DurationStats')
export class DurationStatsGql {
@Field(() => Int) count!: number;
@Field(() => Float, { nullable: true }) averageDays!: number | null;
@Field(() => Float, {
nullable: true,
description: '85% of tickets take at most this long',
})
p85Days!: number | null;
}
@ObjectType('Throughput')
export class ThroughputGql {
@Field() week!: string;
@Field(() => UserRefGql, { nullable: true }) user!: UserRefGql | null;
@Field(() => Int) count!: number;
}
@ObjectType('QaStats')
export class QaStatsGql {
@Field(() => Int) passed!: number;
@Field(() => Int) failed!: number;
@Field(() => Float, { nullable: true }) failureRate!: number | null;
}
@ObjectType('ProjectAnalytics')
export class ProjectAnalyticsGql {
@Field() from!: string;
@Field() to!: string;
@Field(() => [CreatedResolvedGql]) createdVsResolved!: CreatedResolvedGql[];
@Field(() => CumulativeFlowGql, {
description: 'Tickets in each status at the end of every day',
})
cumulativeFlow!: CumulativeFlowGql;
@Field(() => DurationStatsGql, { description: 'Start of work → done' })
cycleTime!: DurationStatsGql;
@Field(() => DurationStatsGql, { description: 'Creation → done' })
leadTime!: DurationStatsGql;
@Field(() => [ThroughputGql], { description: 'Finished per person and week' })
throughput!: ThroughputGql[];
@Field(() => QaStatsGql) qa!: QaStatsGql;
}
@ObjectType('ReleaseBurnup')
export class ReleaseBurnupGql {
@Field(() => ID) releaseId!: string;
@Field(() => String, { nullable: true }) targetDate!: string | null;
@Field(() => [String]) dates!: string[];
@Field(() => [Int], { description: 'Tickets in the release (not cancelled)' })
scope!: number[];
@Field(() => [Int]) done!: number[];
}

View File

@@ -5,16 +5,17 @@ import {
PartialType,
} from '@nestjs/swagger';
import {
IssueArea,
IssueLinkType,
IssuePriority,
IssueStatus,
IssueType,
ProjectRole,
SETTING_COLORS,
StatusCategory,
TYPE_ICONS,
} from '@task-stream/api/tracker/domain';
import { Transform, Type } from 'class-transformer';
import {
ArrayMaxSize,
IsArray,
IsBoolean,
IsEnum,
IsIn,
@@ -29,6 +30,7 @@ import {
Min,
MinLength,
ValidateIf,
ValidateNested,
} from 'class-validator';
/* REST request bodies and query strings, validated like the GraphQL inputs. */
@@ -46,6 +48,9 @@ const toList = ({ value }: { value: unknown }) =>
const toBoolean = ({ value }: { value: unknown }) =>
value === undefined ? undefined : value === true || value === 'true';
/** Ids of statuses, types and areas (checked against the project's settings). */
const SETTING_ID = /^[A-Za-z][A-Za-z0-9_]{0,29}$/;
// ---- Projects ---------------------------------------------------------------
export class CreateProjectDto {
@@ -89,6 +94,121 @@ export class AddMemberDto {
role: ProjectRole = ProjectRole.MEMBER;
}
// ---- Project settings -------------------------------------------------------
export class WorkflowStatusBodyDto {
@ApiProperty({
example: 'IN_REVIEW',
description: 'Never change an existing id',
})
@Matches(SETTING_ID)
id!: string;
@ApiProperty({ example: 'En revisión', maxLength: 40 })
@IsString()
@MinLength(1)
@MaxLength(40)
name!: string;
@ApiProperty({ enum: StatusCategory, enumName: 'StatusCategory' })
@IsEnum(StatusCategory)
category!: StatusCategory;
@ApiProperty({ enum: SETTING_COLORS, enumName: 'SettingColor' })
@IsIn(SETTING_COLORS)
color!: string;
@ApiPropertyOptional({ default: false })
@IsOptional()
@IsBoolean()
requiresReason = false;
@ApiPropertyOptional({ default: false })
@IsOptional()
@IsBoolean()
archived = false;
}
export class StatusTransitionsBodyDto {
@ApiProperty({ example: 'IN_QA' }) @Matches(SETTING_ID) from!: string;
@ApiProperty({ type: [String], example: ['DONE', 'QA_FAILED'] })
@IsArray()
@ArrayMaxSize(50)
@Matches(SETTING_ID, { each: true })
to!: string[];
}
export class IssueTypeOptionBodyDto {
@ApiProperty({ example: 'SPIKE' }) @Matches(SETTING_ID) id!: string;
@ApiProperty({ example: 'Spike', maxLength: 40 })
@IsString()
@MinLength(1)
@MaxLength(40)
name!: string;
@ApiProperty({ enum: TYPE_ICONS, enumName: 'TypeIcon' })
@IsIn(TYPE_ICONS)
icon!: string;
@ApiProperty({ enum: SETTING_COLORS, enumName: 'SettingColor' })
@IsIn(SETTING_COLORS)
color!: string;
@ApiPropertyOptional({ default: false })
@IsOptional()
@IsBoolean()
archived = false;
}
export class AreaOptionBodyDto {
@ApiProperty({ example: 'DATA' }) @Matches(SETTING_ID) id!: string;
@ApiProperty({ example: 'Datos', maxLength: 40 })
@IsString()
@MinLength(1)
@MaxLength(40)
name!: string;
@ApiPropertyOptional({ default: false })
@IsOptional()
@IsBoolean()
archived = false;
}
export class ProjectSettingsBodyDto {
@ApiProperty({
type: [WorkflowStatusBodyDto],
description:
'In board order. Values cannot be removed: archive them instead.',
})
@IsArray()
@ArrayMaxSize(50)
@ValidateNested({ each: true })
@Type(() => WorkflowStatusBodyDto)
statuses!: WorkflowStatusBodyDto[];
@ApiProperty({ type: [StatusTransitionsBodyDto] })
@IsArray()
@ArrayMaxSize(50)
@ValidateNested({ each: true })
@Type(() => StatusTransitionsBodyDto)
transitions!: StatusTransitionsBodyDto[];
@ApiProperty({ type: [IssueTypeOptionBodyDto] })
@IsArray()
@ArrayMaxSize(50)
@ValidateNested({ each: true })
@Type(() => IssueTypeOptionBodyDto)
issueTypes!: IssueTypeOptionBodyDto[];
@ApiProperty({ type: [AreaOptionBodyDto] })
@IsArray()
@ArrayMaxSize(50)
@ValidateNested({ each: true })
@Type(() => AreaOptionBodyDto)
areas!: AreaOptionBodyDto[];
}
export class AnalyticsQueryDto {
@ApiPropertyOptional({ default: 90, minimum: 7, maximum: 365 })
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(7)
@Max(365)
days = 90;
}
export class ChangeMemberRoleDto {
@ApiProperty({ enum: ProjectRole, enumName: 'ProjectRole' })
@IsEnum(ProjectRole)
@@ -106,10 +226,10 @@ export class BoardQueryDto {
@IsString()
assigneeId?: string;
@ApiPropertyOptional({ enum: IssueArea, enumName: 'IssueArea' })
@ApiPropertyOptional({ example: 'FRONTEND', description: 'An area id' })
@IsOptional()
@IsEnum(IssueArea)
area?: IssueArea;
@Matches(SETTING_ID)
area?: string;
@ApiPropertyOptional({ default: 50, minimum: 1, maximum: 200 })
@IsOptional()
@@ -162,37 +282,79 @@ export class PageQueryDto {
// ---- Issues -----------------------------------------------------------------
export class MyIssuesQueryDto extends PageQueryDto {
@ApiPropertyOptional({
default: true,
description:
'true: tickets assigned to me. false: any ticket of my projects (e.g. ?assignedToMe=false&category=QA)',
})
@IsOptional()
@Transform(toBoolean)
@IsBoolean()
assignedToMe = true;
@ApiPropertyOptional({
type: [String],
description: 'Status ids. Repeat the parameter or separate with commas',
})
@IsOptional()
@Transform(toList)
@Matches(SETTING_ID, { each: true })
status?: string[];
@ApiPropertyOptional({
enum: StatusCategory,
enumName: 'StatusCategory',
isArray: true,
description: 'Whatever each project calls its statuses',
})
@IsOptional()
@Transform(toList)
@IsEnum(StatusCategory, { each: true })
category?: StatusCategory[];
}
export class UpcomingReleasesQueryDto {
@ApiPropertyOptional({ default: 10, minimum: 1, maximum: 50 })
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
@Max(50)
limit = 10;
}
export class IssueSearchQueryDto extends PageQueryDto {
@ApiPropertyOptional({
enum: IssueStatus,
enumName: 'IssueStatus',
isArray: true,
description: 'Repeat the parameter or separate with commas',
type: [String],
description: 'Status ids. Repeat the parameter or separate with commas',
})
@IsOptional()
@Transform(toList)
@IsEnum(IssueStatus, { each: true })
status?: IssueStatus[];
@Matches(SETTING_ID, { each: true })
status?: string[];
@ApiPropertyOptional({
enum: IssueType,
enumName: 'IssueType',
enum: StatusCategory,
enumName: 'StatusCategory',
isArray: true,
})
@IsOptional()
@Transform(toList)
@IsEnum(IssueType, { each: true })
type?: IssueType[];
@IsEnum(StatusCategory, { each: true })
category?: StatusCategory[];
@ApiPropertyOptional({
enum: IssueArea,
enumName: 'IssueArea',
isArray: true,
})
@ApiPropertyOptional({ type: [String], description: 'Ticket type ids' })
@IsOptional()
@Transform(toList)
@IsEnum(IssueArea, { each: true })
area?: IssueArea[];
@Matches(SETTING_ID, { each: true })
type?: string[];
@ApiPropertyOptional({ type: [String], description: 'Area ids' })
@IsOptional()
@Transform(toList)
@Matches(SETTING_ID, { each: true })
area?: string[];
@ApiPropertyOptional({
enum: IssuePriority,
@@ -241,13 +403,14 @@ class IssueFieldsDto {
description?: string | null;
@ApiPropertyOptional({
enum: IssueArea,
type: String,
nullable: true,
example: 'FRONTEND',
description: "An area id of the project's settings",
})
@IsOptional()
@IsEnum(IssueArea)
area?: IssueArea | null;
@Matches(SETTING_ID)
area?: string | null;
@ApiPropertyOptional({ enum: IssuePriority, enumName: 'IssuePriority' })
@IsOptional()
@@ -289,9 +452,12 @@ class IssueFieldsDto {
}
export class CreateIssueDto extends IssueFieldsDto {
@ApiProperty({ enum: IssueType, enumName: 'IssueType' })
@IsEnum(IssueType)
type!: IssueType;
@ApiProperty({
example: 'BUG',
description: "A ticket type id of the project's settings",
})
@Matches(SETTING_ID)
type!: string;
@ApiProperty({
example: 'El botón de pagar no responde en Safari',
@@ -318,10 +484,10 @@ export class CreateIssueDto extends IssueFieldsDto {
}
export class UpdateIssueDto extends IssueFieldsDto {
@ApiPropertyOptional({ enum: IssueType, enumName: 'IssueType' })
@ApiPropertyOptional({ example: 'FEATURE', description: 'A ticket type id' })
@IsOptional()
@IsEnum(IssueType)
type?: IssueType;
@Matches(SETTING_ID)
type?: string;
@ApiPropertyOptional({ maxLength: 255 })
@IsOptional()
@@ -332,14 +498,18 @@ export class UpdateIssueDto extends IssueFieldsDto {
}
export class ChangeStatusDto {
@ApiProperty({ enum: IssueStatus, enumName: 'IssueStatus' })
@IsEnum(IssueStatus)
status!: IssueStatus;
@ApiProperty({
example: 'IN_REVIEW',
description:
"A status id of the project's settings, among the ticket's allowedTransitions",
})
@Matches(SETTING_ID)
status!: string;
@ApiPropertyOptional({
type: String,
nullable: true,
description: 'Required for QA_FAILED and CANCELLED',
description: 'Required by statuses with requiresReason (e.g. QA_FAILED)',
})
@IsOptional()
@IsString()

View File

@@ -1,12 +1,12 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
IssueArea,
IssueLinkType,
IssuePriority,
IssueStatus,
IssueType,
ProjectRole,
ReleaseStatus,
SETTING_COLORS,
StatusCategory,
TYPE_ICONS,
} from '@task-stream/api/tracker/domain';
/*
@@ -25,6 +25,51 @@ export class ProjectMemberDto {
role!: ProjectRole;
}
export class WorkflowStatusDto {
@ApiProperty({ example: 'IN_REVIEW', description: 'Stable id on tickets' })
id!: string;
@ApiProperty({ example: 'En revisión' }) name!: string;
@ApiProperty({ enum: StatusCategory, enumName: 'StatusCategory' })
category!: StatusCategory;
@ApiProperty({ enum: SETTING_COLORS, enumName: 'SettingColor' })
color!: string;
@ApiProperty({ description: 'Entering it needs a reason' })
requiresReason!: boolean;
@ApiProperty({ description: 'No new tickets or transitions into it' })
archived!: boolean;
}
export class StatusTransitionsDto {
@ApiProperty({ example: 'IN_QA' }) from!: string;
@ApiProperty({ type: [String], example: ['DONE', 'QA_FAILED'] })
to!: string[];
}
export class IssueTypeOptionDto {
@ApiProperty({ example: 'BUG' }) id!: string;
@ApiProperty({ example: 'Bug' }) name!: string;
@ApiProperty({ enum: TYPE_ICONS, enumName: 'TypeIcon' }) icon!: string;
@ApiProperty({ enum: SETTING_COLORS, enumName: 'SettingColor' })
color!: string;
@ApiProperty() archived!: boolean;
}
export class AreaOptionDto {
@ApiProperty({ example: 'FRONTEND' }) id!: string;
@ApiProperty({ example: 'Frontend' }) name!: string;
@ApiProperty() archived!: boolean;
}
export class ProjectSettingsDto {
@ApiProperty({ type: [WorkflowStatusDto], description: 'In board order' })
statuses!: WorkflowStatusDto[];
@ApiProperty({ type: [StatusTransitionsDto] })
transitions!: StatusTransitionsDto[];
@ApiProperty({ type: [IssueTypeOptionDto] })
issueTypes!: IssueTypeOptionDto[];
@ApiProperty({ type: [AreaOptionDto] }) areas!: AreaOptionDto[];
}
export class ProjectDto {
@ApiProperty({ format: 'uuid' }) id!: string;
@ApiProperty({ example: 'WEB', description: 'Prefix of the ticket keys' })
@@ -33,6 +78,8 @@ export class ProjectDto {
@ApiProperty({ type: String, nullable: true }) description!: string | null;
@ApiProperty({ type: UserRefDto }) owner!: UserRefDto;
@ApiProperty({ type: [ProjectMemberDto] }) members!: ProjectMemberDto[];
@ApiProperty({ type: ProjectSettingsDto })
settings!: ProjectSettingsDto;
@ApiProperty({ format: 'date-time' }) createdAt!: string;
@ApiProperty({ format: 'date-time' }) updatedAt!: string;
@ApiProperty({ description: 'Version of the aggregate (event count)' })
@@ -63,20 +110,21 @@ export class IssueDto {
@ApiProperty({ example: 'WEB' }) projectKey!: string;
@ApiProperty({ example: 12 }) number!: number;
@ApiProperty({ example: 'WEB-12', description: 'Human key' }) key!: string;
@ApiProperty({ enum: IssueType, enumName: 'IssueType' }) type!: IssueType;
@ApiProperty({ enum: IssueArea, type: String, nullable: true })
area!: IssueArea | null;
@ApiProperty({ example: 'BUG', description: 'A ticket type id' })
type!: string;
@ApiProperty({ type: String, nullable: true, example: 'FRONTEND' })
area!: string | null;
@ApiProperty() title!: string;
@ApiProperty({ type: String, nullable: true }) description!: string | null;
@ApiProperty({ enum: IssueStatus, enumName: 'IssueStatus' })
status!: IssueStatus;
@ApiProperty({ example: 'IN_PROGRESS', description: 'A status id' })
status!: string;
@ApiProperty({ enum: StatusCategory, enumName: 'StatusCategory' })
statusCategory!: StatusCategory;
@ApiProperty({
enum: IssueStatus,
enumName: 'IssueStatus',
isArray: true,
description: 'Statuses this ticket can move to next',
type: [String],
description: "Statuses this ticket can move to next (project's workflow)",
})
allowedTransitions!: IssueStatus[];
allowedTransitions!: string[];
@ApiProperty({ enum: IssuePriority, enumName: 'IssuePriority' })
priority!: IssuePriority;
@ApiProperty({ type: UserRefDto }) reporter!: UserRefDto;
@@ -104,8 +152,7 @@ export class IssuePageDto {
}
export class BoardColumnDto {
@ApiProperty({ enum: IssueStatus, enumName: 'IssueStatus' })
status!: IssueStatus;
@ApiProperty({ example: 'IN_PROGRESS' }) status!: string;
@ApiProperty({ type: [IssueDto] }) issues!: IssueDto[];
@ApiProperty({ description: 'Tickets in the column (may exceed `issues`)' })
total!: number;
@@ -143,8 +190,8 @@ export class ReleaseDto {
}
export class CountByStatusDto {
@ApiProperty({ enum: IssueStatus, enumName: 'IssueStatus' })
key!: IssueStatus;
@ApiProperty({ example: 'IN_PROGRESS', description: 'Status id' })
key!: string;
@ApiProperty() count!: number;
}
@@ -213,3 +260,78 @@ export class CommandResultDto {
})
version!: number;
}
// ---- Statistics ---------------------------------------------------------------
export class CreatedResolvedDto {
@ApiProperty({ format: 'date', description: 'Monday of the week' })
week!: string;
@ApiProperty() created!: number;
@ApiProperty() resolved!: number;
}
export class FlowSeriesDto {
@ApiProperty({ example: 'IN_PROGRESS' }) status!: string;
@ApiProperty({ type: [Number], description: 'One value per date' })
counts!: number[];
}
export class CumulativeFlowDto {
@ApiProperty({ type: [String], format: 'date' }) dates!: string[];
@ApiProperty({ type: [FlowSeriesDto] }) series!: FlowSeriesDto[];
}
export class DurationStatsDto {
@ApiProperty() count!: number;
@ApiProperty({ type: Number, nullable: true }) averageDays!: number | null;
@ApiProperty({
type: Number,
nullable: true,
description: '85% of tickets take at most this long',
})
p85Days!: number | null;
}
export class ThroughputDto {
@ApiProperty({ format: 'date' }) week!: string;
@ApiProperty({ type: UserRefDto, nullable: true }) user!: UserRefDto | null;
@ApiProperty() count!: number;
}
export class QaStatsDto {
@ApiProperty({ description: 'Left QA to a done status' }) passed!: number;
@ApiProperty({ description: 'Left QA back to work' }) failed!: number;
@ApiProperty({ type: Number, nullable: true, minimum: 0, maximum: 1 })
failureRate!: number | null;
}
export class ProjectAnalyticsDto {
@ApiProperty({ format: 'date-time' }) from!: string;
@ApiProperty({ format: 'date-time' }) to!: string;
@ApiProperty({ type: [CreatedResolvedDto] })
createdVsResolved!: CreatedResolvedDto[];
@ApiProperty({
type: CumulativeFlowDto,
description: 'Tickets in each status at the end of every day',
})
cumulativeFlow!: CumulativeFlowDto;
@ApiProperty({ type: DurationStatsDto, description: 'Start of work → done' })
cycleTime!: DurationStatsDto;
@ApiProperty({ type: DurationStatsDto, description: 'Creation → done' })
leadTime!: DurationStatsDto;
@ApiProperty({ type: [ThroughputDto] }) throughput!: ThroughputDto[];
@ApiProperty({ type: QaStatsDto }) qa!: QaStatsDto;
}
export class ReleaseBurnupDto {
@ApiProperty({ format: 'uuid' }) releaseId!: string;
@ApiProperty({ type: String, nullable: true, format: 'date' })
targetDate!: string | null;
@ApiProperty({ type: [String], format: 'date' }) dates!: string[];
@ApiProperty({
type: [Number],
description: 'Tickets in the release (not cancelled)',
})
scope!: number[];
@ApiProperty({ type: [Number] }) done!: number[];
}

View File

@@ -39,6 +39,7 @@ import {
IssueSearchQueryDto,
LinkIssueDto,
LinkTypeParamDto,
MyIssuesQueryDto,
PageQueryDto,
SetIssueReleaseDto,
UpdateIssueDto,
@@ -50,7 +51,7 @@ import {
IssueDto,
IssuePageDto,
} from './dto/responses.dto';
import { Refs, toIssueDto } from './refs';
import { Refs } from './refs';
const PROJECT = ApiParam({
name: 'project',
@@ -74,6 +75,25 @@ export class IssuesController {
private readonly refs: Refs,
) {}
@Get('me/issues')
@ApiOperation({
summary: 'My work: tickets across all my projects',
description:
'Assigned to me by default; with assignedToMe=false, any ticket of my projects (e.g. waiting for QA).',
})
@ApiOkResponse({ type: IssuePageDto })
@ApiReadErrors()
async mine(@CurrentUser() me: User, @Query() query: MyIssuesQueryDto) {
const page = await this.issues.mine(me.id, {
assignedToMe: query.assignedToMe,
statuses: query.status,
categories: query.category,
limit: query.limit,
offset: query.offset,
});
return { ...page, items: await this.refs.issueDtos(page.items) };
}
@Get('projects/:project/issues')
@PROJECT
@ApiOperation({ summary: 'Search the tickets of a project' })
@@ -87,6 +107,7 @@ export class IssuesController {
const page = await this.issues.search(me.id, {
projectId: await this.refs.projectId(me.id, project),
statuses: query.status,
categories: query.category,
types: query.type,
areas: query.area,
priorities: query.priority,
@@ -98,7 +119,7 @@ export class IssuesController {
limit: query.limit,
offset: query.offset,
});
return { ...page, items: page.items.map(toIssueDto) };
return { ...page, items: await this.refs.issueDtos(page.items) };
}
@Post('projects/:project/issues')
@@ -106,7 +127,7 @@ export class IssuesController {
@ApiOperation({
summary: 'Create a ticket',
description:
'Starts in BACKLOG. The response carries its key (e.g. WEB-13).',
"Starts in the project's first active TODO-category status (BACKLOG by default). The response carries its key (e.g. WEB-13).",
})
@ApiCreatedResponse({ type: CommandResultDto })
@ApiCommandErrors()
@@ -127,7 +148,7 @@ export class IssuesController {
@ApiOkResponse({ type: IssueDto })
@ApiReadErrors()
async findOne(@CurrentUser() me: User, @Param('issue') issue: string) {
return toIssueDto(await this.issues.findOne(me.id, issue));
return this.refs.issueDto(await this.issues.findOne(me.id, issue));
}
@Patch('issues/:issue')

View File

@@ -6,6 +6,7 @@ import {
Param,
Patch,
Post,
Put,
Query,
} from '@nestjs/common';
import {
@@ -32,19 +33,23 @@ import {
import {
ActivityQueryDto,
AddMemberDto,
AnalyticsQueryDto,
BoardQueryDto,
ChangeMemberRoleDto,
CreateProjectDto,
ProjectSettingsBodyDto,
UpdateProjectDto,
} from './dto/requests.dto';
import {
ActivityDto,
BoardColumnDto,
CommandResultDto,
ProjectAnalyticsDto,
ProjectDto,
ProjectStatsDto,
} from './dto/responses.dto';
import { Refs, toIssueDto } from './refs';
import { fromSettingsPayload } from '../common/settings';
import { Refs, toProjectDto } from './refs';
const PROJECT = ApiParam({
name: 'project',
@@ -67,8 +72,8 @@ export class ProjectsController {
@ApiOperation({ summary: 'Projects where I am a member' })
@ApiOkResponse({ type: [ProjectDto] })
@ApiReadErrors()
mine(@CurrentUser() me: User) {
return this.projects.findMine(me.id);
async mine(@CurrentUser() me: User) {
return (await this.projects.findMine(me.id)).map(toProjectDto);
}
@Post()
@@ -81,11 +86,11 @@ export class ProjectsController {
@Get(':project')
@PROJECT
@ApiOperation({ summary: 'A project with its members' })
@ApiOperation({ summary: 'A project with its members and settings' })
@ApiOkResponse({ type: ProjectDto })
@ApiReadErrors()
findOne(@CurrentUser() me: User, @Param('project') project: string) {
return this.projects.findOne(me.id, project);
async findOne(@CurrentUser() me: User, @Param('project') project: string) {
return toProjectDto(await this.projects.findOne(me.id, project));
}
@Patch(':project')
@@ -105,6 +110,28 @@ export class ProjectsController {
);
}
@Put(':project/settings')
@PROJECT
@ApiOperation({
summary: 'Statuses, transitions, ticket types and areas (owner/admin)',
description:
'Replaces the whole configuration (send what GET /projects/{project} returns, changed). ' +
'Values can be added, renamed, reordered or archived, never removed: tickets and statistics keep referring to them.',
})
@ApiOkResponse({ type: CommandResultDto })
@ApiCommandErrors()
async updateSettings(
@CurrentUser() me: User,
@Param('project') project: string,
@Body() body: ProjectSettingsBodyDto,
) {
return this.projects.updateSettings(
me.id,
await this.refs.projectId(me.id, project),
fromSettingsPayload(body),
);
}
@Get(':project/board')
@PROJECT
@ApiOperation({ summary: 'Kanban board: one column per status' })
@@ -125,10 +152,12 @@ export class ProjectsController {
},
query.perColumn,
);
return columns.map((column) => ({
...column,
issues: column.issues.map(toIssueDto),
}));
return Promise.all(
columns.map(async (column) => ({
...column,
issues: await this.refs.issueDtos(column.issues),
})),
);
}
@Get(':project/stats')
@@ -145,6 +174,27 @@ export class ProjectsController {
);
}
@Get(':project/analytics')
@PROJECT
@ApiOperation({
summary: 'Statistics of the last `days` days',
description:
'Created vs resolved per week, cumulative flow per day, cycle and lead time, throughput per person and QA pass/fail.',
})
@ApiOkResponse({ type: ProjectAnalyticsDto })
@ApiReadErrors()
async analytics(
@CurrentUser() me: User,
@Param('project') project: string,
@Query() query: AnalyticsQueryDto,
) {
return this.projects.analytics(
me.id,
await this.refs.projectId(me.id, project),
query.days,
);
}
@Get(':project/activity')
@PROJECT
@ApiOperation({ summary: 'Activity feed (newest first)' })

View File

@@ -2,8 +2,13 @@ import { Injectable } from '@nestjs/common';
import {
IssuesService,
ProjectsService,
WorkflowsService,
} from '@task-stream/api/tracker/application';
import { IssueReadModel, IssueWorkflow } from '@task-stream/api/tracker/domain';
import {
IssueReadModel,
ProjectReadModel,
} from '@task-stream/api/tracker/domain';
import { toSettingsPayload } from '../common/settings';
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -17,6 +22,7 @@ export class Refs {
constructor(
private readonly projects: ProjectsService,
private readonly issues: IssuesService,
private readonly workflows: WorkflowsService,
) {}
async projectId(viewerId: string, ref: string): Promise<string> {
@@ -28,12 +34,21 @@ export class Refs {
if (UUID.test(ref)) return ref;
return (await this.issues.findOne(viewerId, ref)).id;
}
/** The ticket as the REST API returns it: read model + allowed transitions. */
async issueDto(issue: IssueReadModel) {
return {
...issue,
allowedTransitions: await this.workflows.allowedTransitions(issue),
};
}
issueDtos(issues: IssueReadModel[]) {
return Promise.all(issues.map((issue) => this.issueDto(issue)));
}
}
/** The ticket as the REST API returns it: read model + allowed transitions. */
export function toIssueDto(issue: IssueReadModel) {
return {
...issue,
allowedTransitions: IssueWorkflow.allowedFrom(issue.status),
};
/** The project as the REST API returns it: transitions as a list. */
export function toProjectDto(project: ProjectReadModel) {
return { ...project, settings: toSettingsPayload(project.settings) };
}

View File

@@ -33,15 +33,17 @@ import {
CreateReleaseDto,
PageQueryDto,
PublishReleaseDto,
UpcomingReleasesQueryDto,
UpdateReleaseDto,
} from './dto/requests.dto';
import {
CommandResultDto,
IssuePageDto,
ReleaseDto,
ReleaseBurnupDto,
ReleaseProgressDto,
} from './dto/responses.dto';
import { Refs, toIssueDto } from './refs';
import { Refs } from './refs';
const PROJECT = ApiParam({
name: 'project',
@@ -61,6 +63,16 @@ export class ReleasesController {
private readonly refs: Refs,
) {}
@Get('me/releases')
@ApiOperation({
summary: 'Planned releases of all my projects, soonest target date first',
})
@ApiOkResponse({ type: [ReleaseDto] })
@ApiReadErrors()
upcoming(@CurrentUser() me: User, @Query() query: UpcomingReleasesQueryDto) {
return this.releases.upcoming(me.id, query.limit);
}
@Get('projects/:project/releases')
@PROJECT
@ApiOperation({ summary: 'Releases of a project' })
@@ -117,6 +129,16 @@ export class ReleasesController {
return this.releases.progress(me.id, releaseId);
}
@Get('releases/:releaseId/burnup')
@ApiOperation({
summary: 'Burnup: tickets in the release and finished ones, day by day',
})
@ApiOkResponse({ type: ReleaseBurnupDto })
@ApiReadErrors()
burnup(@CurrentUser() me: User, @Param('releaseId') releaseId: string) {
return this.releases.burnup(me.id, releaseId);
}
@Get('releases/:releaseId/issues')
@ApiOperation({ summary: 'Tickets included in the release' })
@ApiOkResponse({ type: IssuePageDto })
@@ -133,7 +155,7 @@ export class ReleasesController {
limit: page.limit,
offset: page.offset,
});
return { ...found, items: found.items.map(toIssueDto) };
return { ...found, items: await this.refs.issueDtos(found.items) };
}
@Post('releases/:releaseId/publish')