feat: public projects, project deletion and sagas

Public projects:
- Project.isPublic (create/update, owners and admins). Anyone can read a
  public project without a token: project, board, tickets, comments,
  history, releases, activity, tracking and statistics, over GraphQL and
  REST. Writes stay for members (401 anonymous, 403 outsiders).
- @OptionalAuth() / @ApiOptionalPireonAuth(): anonymous callers allowed,
  invalid tokens still rejected. ReadAccess lets anonymous viewers read
  public projects only; linked tickets are filtered by visibility.
- publicProjects (GraphQL) and GET /api/explore/projects (REST).
- Web: «Explorar» page, project pages open without a session (read-only
  notice, sign-in hints), public badge, visibility switch in settings,
  no realtime subscriptions without a session.

Project deletion:
- Owner only, confirming the key (deleteProject / DELETE
  /api/projects/{project}?confirm=KEY). The key is freed; the read model
  drops the project and members are notified (web goes home).

Sagas (run by the EventsBridge after projections, durable and ordered):
- ProjectDeletionSaga: project deleted → delete its tickets and releases;
  ticket deleted → purge its comments and drop links from other tickets.
- ReleaseArchivedSaga: unfinished tickets leave an archived release.
- UserDeactivatedSaga: the Pireon webhook records UserDeactivatedEvent in
  the event store (EventRecorder); the tracker unassigns that user's open
  tickets as the system actor.
- Internal idempotent commands; domain refusals are logged and skipped,
  concurrency conflicts retried. Affected streams come from the event store
  (TrackerStreamsRepository).

Tests: domain lifecycle specs, saga specs run like the bridge, facade
tests, e2e for public access, cascade deletion, archived releases and
deactivation webhook. 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-07 07:04:20 +02:00
parent 0e301ad545
commit e656222b54
164 changed files with 3862 additions and 414 deletions

View File

@@ -9,7 +9,10 @@ import {
Resolver,
} from '@nestjs/graphql';
import { User } from '@task-stream/api/identity/domain';
import { CurrentUser } from '@task-stream/api/identity/presenters';
import {
CurrentUser,
OptionalAuth,
} from '@task-stream/api/identity/presenters';
import {
CommentsService,
IssuesService,
@@ -27,6 +30,7 @@ import {
UpdateIssueInput,
} from './inputs';
import { withoutNulls } from '../common/issue-input';
import { viewerOf } from '../common/viewer';
import {
ActivityGql,
CommandResultGql,
@@ -43,23 +47,29 @@ export class IssueResolver {
private readonly workflows: WorkflowsService,
) {}
@OptionalAuth()
@Query(() => IssueGql)
issue(
@CurrentUser() me: User,
@CurrentUser() me: User | undefined,
@Args('idOrKey', { description: 'Issue id or key (e.g. "TS-42")' })
idOrKey: string,
) {
return this.issuesService.findOne(me.id, idOrKey);
return this.issuesService.findOne(viewerOf(me), idOrKey);
}
@OptionalAuth()
@Query(() => IssuePageGql, { name: 'issues' })
searchIssues(
@CurrentUser() me: User,
@CurrentUser() me: User | undefined,
@Args('filter') filter: IssueFilterInput,
@Args('limit', { type: () => Int, defaultValue: 50 }) limit: number,
@Args('offset', { type: () => Int, defaultValue: 0 }) offset: number,
) {
return this.issuesService.search(me.id, { ...filter, limit, offset });
return this.issuesService.search(viewerOf(me), {
...filter,
limit,
offset,
});
}
@Query(() => IssuePageGql, {
@@ -85,18 +95,19 @@ export class IssueResolver {
});
}
@OptionalAuth()
@Query(() => [ActivityGql], {
description: 'Project activity feed (newest first)',
})
activity(
@CurrentUser() me: User,
@CurrentUser() me: User | undefined,
@Args('projectId', { type: () => ID }) projectId: string,
@Args('issueId', { type: () => ID, nullable: true }) issueId?: string,
@Args('limit', { type: () => Int, defaultValue: 50 }) limit = 50,
@Args('before', { nullable: true, description: 'ISO date cursor' })
before?: string,
) {
return this.issuesService.activity(me.id, {
return this.issuesService.activity(viewerOf(me), {
projectId,
issueId,
limit,
@@ -112,31 +123,34 @@ export class IssueResolver {
}
@ResolveField(() => [IssueGql], { description: 'Linked tickets I can see' })
linkedIssues(@CurrentUser() me: User, @Parent() issue: IssueReadModel) {
linkedIssues(
@CurrentUser() me: User | undefined,
@Parent() issue: IssueReadModel,
) {
if (issue.links.length === 0) return [];
return this.issuesService.findMany(
me.id,
viewerOf(me),
issue.links.map((l) => l.issueId),
);
}
@ResolveField(() => CommentPageGql)
comments(
@CurrentUser() me: User,
@CurrentUser() me: User | undefined,
@Parent() issue: IssueReadModel,
@Args('limit', { type: () => Int, defaultValue: 50 }) limit: number,
@Args('offset', { type: () => Int, defaultValue: 0 }) offset: number,
) {
return this.commentsService.list(me.id, issue.id, limit, offset);
return this.commentsService.list(viewerOf(me), issue.id, limit, offset);
}
@ResolveField(() => [ActivityGql], { description: 'History of this ticket' })
history(
@CurrentUser() me: User,
@CurrentUser() me: User | undefined,
@Parent() issue: IssueReadModel,
@Args('limit', { type: () => Int, defaultValue: 50 }) limit: number,
) {
return this.issuesService.activity(me.id, {
return this.issuesService.activity(viewerOf(me), {
projectId: issue.projectId,
issueId: issue.id,
limit,