first commit

This commit is contained in:
2026-10-03 13:40:26 +02:00
parent 732a5b5a16
commit 566f415fa7
555 changed files with 62704 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
import { Injectable } from '@nestjs/common';
import { CommandBus, QueryBus } from '@nestjs/cqrs';
import {
ProjectReadModel,
ProjectRole,
ProjectStatsReadModel,
ReleaseReadModel,
} from '@task-stream/api/tracker/domain';
import { AddProjectMemberCommand } from './commands/add-project-member.command';
import { ChangeProjectMemberRoleCommand } from './commands/change-project-member-role.command';
import { CommandResult } from './commands/command-result';
import { CreateProjectCommand } from './commands/create-project.command';
import { RemoveProjectMemberCommand } from './commands/remove-project-member.command';
import { UpdateProjectCommand } from './commands/update-project.command';
import { IssueFilter } from './ports/find-issues.repository';
import { BoardColumn, GetBoardQuery } from './queries/get-board.query';
import { GetMyProjectsQuery } from './queries/get-my-projects.query';
import { GetProjectStatsQuery } from './queries/get-project-stats.query';
import { GetProjectQuery } from './queries/get-project.query';
import { GetReleasesQuery } from './queries/get-releases.query';
@Injectable()
export class ProjectsService {
constructor(
private readonly commandBus: CommandBus,
private readonly queryBus: QueryBus,
) {}
create(
actorId: string,
input: { key: string; name: string; description?: string | null },
): Promise<CommandResult> {
return this.commandBus.execute(
new CreateProjectCommand(
actorId,
input.key,
input.name,
input.description,
),
);
}
update(
actorId: string,
projectId: string,
changes: { name?: string; description?: string | null },
): Promise<CommandResult> {
return this.commandBus.execute(
new UpdateProjectCommand(actorId, projectId, changes),
);
}
addMember(
actorId: string,
input: { projectId: string; userId: string; role: ProjectRole },
accessToken?: string,
): Promise<CommandResult> {
return this.commandBus.execute(
new AddProjectMemberCommand(
actorId,
input.projectId,
input.userId,
input.role,
accessToken,
),
);
}
changeMemberRole(
actorId: string,
input: { projectId: string; userId: string; role: ProjectRole },
): Promise<CommandResult> {
return this.commandBus.execute(
new ChangeProjectMemberRoleCommand(
actorId,
input.projectId,
input.userId,
input.role,
),
);
}
removeMember(
actorId: string,
projectId: string,
userId: string,
): Promise<CommandResult> {
return this.commandBus.execute(
new RemoveProjectMemberCommand(actorId, projectId, userId),
);
}
findMine(viewerId: string): Promise<ProjectReadModel[]> {
return this.queryBus.execute(new GetMyProjectsQuery(viewerId));
}
findOne(viewerId: string, idOrKey: string): Promise<ProjectReadModel> {
return this.queryBus.execute(new GetProjectQuery(viewerId, idOrKey));
}
stats(viewerId: string, projectId: string): Promise<ProjectStatsReadModel> {
return this.queryBus.execute(new GetProjectStatsQuery(viewerId, projectId));
}
board(
viewerId: string,
filter: Omit<IssueFilter, 'statuses' | 'limit' | 'offset'>,
perColumn?: number,
): Promise<BoardColumn[]> {
return this.queryBus.execute(
new GetBoardQuery(viewerId, filter, perColumn),
);
}
releases(viewerId: string, projectId: string): Promise<ReleaseReadModel[]> {
return this.queryBus.execute(new GetReleasesQuery(viewerId, projectId));
}
}