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,38 @@
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { IssueWorkflow } from '@task-stream/api/tracker/domain';
import { ReleaseIssuesRepository } from '../ports/release-issues.repository';
import { CommandResult, ack } from './command-result';
import { PublishReleaseCommand } from './publish-release.command';
import { WriteAccess } from './write-access';
@CommandHandler(PublishReleaseCommand)
export class PublishReleaseCommandHandler
implements ICommandHandler<PublishReleaseCommand>
{
constructor(
private readonly access: WriteAccess,
private readonly releaseIssues: ReleaseIssuesRepository,
) {}
async execute(command: PublishReleaseCommand): Promise<CommandResult> {
const release = await this.access.release(command.releaseId);
(await this.access.project(release.projectId)).assertCanManage(
command.actorId,
);
// Rebuilt from the event store (source of truth), not from the read model.
const candidates = await this.releaseIssues.findIssueIds(release.id);
const issues = await Promise.all(
candidates.map((id) => this.access.issue(id)),
);
const unfinished = issues.filter(
(issue) =>
issue.releaseId === release.id &&
!IssueWorkflow.isFinished(issue.status),
).length;
release.ship(command.actorId, unfinished, command.force);
await release.commitAndWait();
return ack(release);
}
}