ProjectsModule · library/project/src/access.ts:15

ProjectAccess

component

No JSDoc comment in source yet.

API

@Component({ key: "@prismshadow/penguin-server#ProjectAccess" })
export class ProjectAccess implements Access {
  @Use() private readonly projects!: Projects;
  @Use() private readonly members!: Members;
  @Use() private readonly projectConfig!: ProjectConfigStore;
  find(userId: string, projectId: string): (ProjectRow & { role: ProjectRole }) | null;
  requireProjectAccess(userId: string, projectId: string): ProjectRow & { role: ProjectRole };
  canAccess(userId: string, projectId: string): boolean;
  requireProjectOwner(userId: string, projectId: string): ProjectRow;
  accessibleProjectIds(userId: string): string[];
  async listProjects(userId: string): Promise<ProjectSummary[]>;
}

Dependencies & Wiring

Extracted from class decorators
implementsinterfaces
@Userequires (3)
projects: Projects · members: Members · projectConfig: ProjectConfigStore

Methods (6)

find

find(userId: string, projectId: string): (ProjectRow & { role: ProjectRole }) | null

The sole implementation of the owner / member check: the row with a role when accessible, otherwise null. Every other member here is a wrapper around it.

@paramuserIdstring
@paramprojectIdstring
@returns(ProjectRow & { role: ProjectRole }) | null

requireProjectAccess

requireProjectAccess(userId: string, projectId: string): ProjectRow & { role: ProjectRole }

Accessible by owner or member; otherwise 404 (does not leak Project existence).

@paramuserIdstring
@paramprojectIdstring
@returnsProjectRow & { role: ProjectRole }

canAccess

canAccess(userId: string, projectId: string): boolean

The non-throwing form, for error attribution — where another 404 would only break error handling.

@paramuserIdstring
@paramprojectIdstring
@returnsboolean

requireProjectOwner

requireProjectOwner(userId: string, projectId: string): ProjectRow

Owner only: 403 when known accessible as a member; 404 when not accessible.

@paramuserIdstring
@paramprojectIdstring
@returnsProjectRow

accessibleProjectIds

accessibleProjectIds(userId: string): string[]

Every project_id the user may reach (owned + granted).

@paramuserIdstring
@returnsstring[]

listProjects

async listProjects(userId: string): Promise<ProjectSummary[]>

Owned + granted Projects with their display names.

@paramuserIdstring
@returnsPromise<ProjectSummary[]>