Skip to content
19 linesCodeBlameRaw
1/**
2 * Who may do what with a project: each method's capability on the
3 * project's repository. Seeing a project takes Read; changing it (its name,
4 * root directory and settings) takes Maintain (`manage_settings`).
5 * Types only, so the table is tested apart from the service.
6 */
7
8import type { Capability, RepoRef } from "@g1t/contracts";
9
10export const NEEDS = {
11 get: "read",
12 create: "manage_settings",
13 update: "manage_settings",
14} as const satisfies Record<string, Capability>;
15
16/** The repository a stored project's permission comes from. */
17export function repoRef(row: { repo_id: string; repo_namespace: string; repo_private: number | boolean }): RepoRef {
18 return { id: row.repo_id, namespace: row.repo_namespace, isPrivate: !!row.repo_private };
19}