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

@@ -41,6 +41,14 @@ export class CreateProjectInput {
@IsString()
@MaxLength(5000)
description?: string | null;
@Field({
nullable: true,
description: 'Readable by anyone, also without signing in',
})
@IsOptional()
@IsBoolean()
isPublic?: boolean;
}
@InputType()
@@ -57,6 +65,10 @@ export class UpdateProjectInput {
@IsString()
@MaxLength(5000)
description?: string | null;
@Field({ nullable: true })
@IsOptional()
@IsBoolean()
isPublic?: boolean;
}
@InputType()

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,

View File

@@ -9,9 +9,14 @@ import {
Resolver,
} from '@nestjs/graphql';
import { User } from '@task-stream/api/identity/domain';
import { AccessToken, CurrentUser } from '@task-stream/api/identity/presenters';
import {
AccessToken,
CurrentUser,
OptionalAuth,
} from '@task-stream/api/identity/presenters';
import { ProjectsService } from '@task-stream/api/tracker/application';
import { ProjectReadModel } from '@task-stream/api/tracker/domain';
import { viewerOf } from '../common/viewer';
import { fromSettingsPayload, toSettingsPayload } from '../common/settings';
import {
CreateProjectInput,
@@ -38,13 +43,24 @@ export class ProjectResolver {
return this.projects.findMine(me.id);
}
@Query(() => ProjectGql)
@OptionalAuth()
@Query(() => ProjectGql, {
description: 'A project of mine, or any public one (no sign-in needed)',
})
project(
@CurrentUser() me: User,
@CurrentUser() me: User | undefined,
@Args('idOrKey', { description: 'Project id or key (e.g. "TS")' })
idOrKey: string,
) {
return this.projects.findOne(me.id, idOrKey);
return this.projects.findOne(viewerOf(me), idOrKey);
}
@OptionalAuth()
@Query(() => [ProjectGql], {
description: 'Projects anyone can read, also without signing in',
})
publicProjects() {
return this.projects.findPublic();
}
@ResolveField(() => ProjectSettingsGql)
@@ -57,30 +73,36 @@ export class ProjectResolver {
'Statistics of the last `days` days (7-365): created vs resolved, cumulative flow, cycle/lead time, throughput and QA',
})
analytics(
@CurrentUser() me: User,
@CurrentUser() me: User | undefined,
@Parent() project: ProjectReadModel,
@Args('days', { type: () => Int, defaultValue: 90 }) days: number,
) {
return this.projects.analytics(me.id, project.id, days);
return this.projects.analytics(viewerOf(me), project.id, days);
}
@ResolveField(() => [ReleaseGql])
releases(@CurrentUser() me: User, @Parent() project: ProjectReadModel) {
return this.projects.releases(me.id, project.id);
releases(
@CurrentUser() me: User | undefined,
@Parent() project: ProjectReadModel,
) {
return this.projects.releases(viewerOf(me), project.id);
}
@ResolveField(() => ProjectStatsGql, {
description: 'Project tracking dashboard',
})
stats(@CurrentUser() me: User, @Parent() project: ProjectReadModel) {
return this.projects.stats(me.id, project.id);
stats(
@CurrentUser() me: User | undefined,
@Parent() project: ProjectReadModel,
) {
return this.projects.stats(viewerOf(me), project.id);
}
@ResolveField(() => [BoardColumnGql], {
description: 'Kanban board, one column per status',
})
board(
@CurrentUser() me: User,
@CurrentUser() me: User | undefined,
@Parent() project: ProjectReadModel,
@Args('releaseId', { type: () => ID, nullable: true }) releaseId?: string,
@Args('assigneeId', { type: () => ID, nullable: true }) assigneeId?: string,
@@ -88,7 +110,7 @@ export class ProjectResolver {
@Args('perColumn', { type: () => Int, defaultValue: 50 }) perColumn = 50,
) {
return this.projects.board(
me.id,
viewerOf(me),
{
projectId: project.id,
releaseId,
@@ -132,6 +154,18 @@ export class ProjectResolver {
);
}
@Mutation(() => CommandResultGql, {
description:
'Delete the project (owner only), with its tickets, comments and releases. `confirmKey` must be the project key.',
})
deleteProject(
@CurrentUser() me: User,
@Args('projectId', { type: () => ID }) projectId: string,
@Args('confirmKey') confirmKey: string,
) {
return this.projects.delete(me.id, projectId, confirmKey);
}
@Mutation(() => CommandResultGql, {
description: 'Add a Pireon user to the project',
})

View File

@@ -10,7 +10,11 @@ import {
} from '@nestjs/graphql';
import { User } from '@task-stream/api/identity/domain';
import { ReleaseReadModel } from '@task-stream/api/tracker/domain';
import { CurrentUser } from '@task-stream/api/identity/presenters';
import {
CurrentUser,
OptionalAuth,
} from '@task-stream/api/identity/presenters';
import { viewerOf } from '../common/viewer';
import {
IssuesService,
ReleasesService,
@@ -31,9 +35,13 @@ export class ReleaseResolver {
private readonly issuesService: IssuesService,
) {}
@OptionalAuth()
@Query(() => ReleaseGql)
release(@CurrentUser() me: User, @Args('id', { type: () => ID }) id: string) {
return this.releases.findOne(me.id, id);
release(
@CurrentUser() me: User | undefined,
@Args('id', { type: () => ID }) id: string,
) {
return this.releases.findOne(viewerOf(me), id);
}
@Query(() => [ReleaseGql], {
@@ -48,27 +56,33 @@ export class ReleaseResolver {
}
@ResolveField(() => ReleaseProgressGql)
progress(@CurrentUser() me: User, @Parent() release: ReleaseReadModel) {
return this.releases.progress(me.id, release.id);
progress(
@CurrentUser() me: User | undefined,
@Parent() release: ReleaseReadModel,
) {
return this.releases.progress(viewerOf(me), 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);
burnup(
@CurrentUser() me: User | undefined,
@Parent() release: ReleaseReadModel,
) {
return this.releases.burnup(viewerOf(me), release.id);
}
@ResolveField(() => IssuePageGql, {
description: 'Tickets included in this release',
})
issues(
@CurrentUser() me: User,
@CurrentUser() me: User | undefined,
@Parent() release: ReleaseReadModel,
@Args('limit', { type: () => Int, defaultValue: 100 }) limit: number,
@Args('offset', { type: () => Int, defaultValue: 0 }) offset: number,
) {
return this.issuesService.search(me.id, {
return this.issuesService.search(viewerOf(me), {
projectId: release.projectId,
releaseId: release.id,
limit,

View File

@@ -71,6 +71,8 @@ export class ProjectGql {
@Field() key!: string;
@Field() name!: string;
@Field(() => String, { nullable: true }) description!: string | null;
@Field({ description: 'Anyone can read it, also without signing in' })
isPublic!: boolean;
@Field(() => UserRefGql) owner!: UserRefGql;
@Field(() => [ProjectMemberGql]) members!: ProjectMemberGql[];
@Field() createdAt!: string;