pr_01m47d15m3e54sn21z27rpy5n9/packages/contracts/src/projects.ts
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Projects: what a workspace builds and runs, first on every page | 1 | import type { User, Viewer } from "./identity"; |
| 2 | import type { RepoPath } from "./repos"; | |
| 3 | import type { Result } from "./result"; | |
| 4 | ||
| 5 | /** | |
| 6 | * Projects: the thing a workspace builds and runs. A project has exactly | |
| 7 | * one source, where its code lives; everything about running it | |
| 8 | * (deployments, environments, domains, secrets and variables) belongs to | |
| 9 | * the project, while branches, pull requests and review stay with the | |
| 10 | * repository. One repository may carry several projects, each from its own | |
| 11 | * root directory. Every repository on g1t gets a project of its own name. | |
| 12 | */ | |
| 13 | ||
| 14 | /** Where a project's code lives. */ | |
| 15 | export type ProjectSource = | |
| 16 | /** A repository hosted on g1t. */ | |
| 17 | | { kind: "hosted"; repoId: string; repo: RepoPath; rootDir: string; defaultBranch: string } | |
| 18 | /** Mirrored from another host; coming next. */ | |
| 19 | | { kind: "mirror"; provider: "github" | "gitlab" | "bitbucket"; url: string; rootDir: string }; | |
| 20 | ||
| 21 | export type Project = { | |
| 22 | id: string; | |
| 23 | /** The workspace's slug. */ | |
| 24 | workspace: string; | |
| 25 | /** Unique in its workspace; the project's address is `g1t.sh/<workspace>/<slug>`. */ | |
| 26 | slug: string; | |
| 27 | name: string; | |
| 28 | description: string | null; | |
| 29 | source: ProjectSource; | |
| 30 | /** Whether only the workspace's members can see it: its repository is private. */ | |
| 31 | private: boolean; | |
| 32 | /** Whether it is the project its repository's workflows read secrets from. */ | |
| 33 | primary: boolean; | |
| 34 | createdBy: string; | |
| 35 | /** RFC 3339. */ | |
| 36 | createdAt: string; | |
| 37 | updatedAt: string; | |
| 38 | }; | |
| 39 | ||
| 40 | export type NewProject = { | |
| 41 | name: string; | |
| 42 | description?: string | null; | |
| 43 | /** The hosted repository it builds from. */ | |
| 44 | repo: RepoPath; | |
| 45 | /** Where in the repository it lives; empty for the whole repository. */ | |
| 46 | rootDir?: string; | |
| 47 | }; | |
| 48 | ||
| 49 | export interface ProjectsApi { | |
| 50 | /** A workspace's projects, by name. Members, or anyone for public repositories. */ | |
| 51 | list(workspace: string, viewer: Viewer): Promise<Result<Project[]>>; | |
| 52 | get(workspace: string, slug: string, viewer: Viewer): Promise<Result<Project>>; | |
| 53 | /** The projects built from a repository, its primary one first. For services. */ | |
| 54 | byRepo(repoId: string): Promise<Project[]>; | |
| 55 | /** Members only. */ | |
| 56 | create(actor: User, workspace: string, input: NewProject): Promise<Result<Project>>; | |
| 57 | /** Members only. */ | |
| 58 | update( | |
| 59 | actor: User, | |
| 60 | workspace: string, | |
| 61 | slug: string, | |
| 62 | changes: { name?: string; description?: string | null; rootDir?: string }, | |
| 63 | ): Promise<Result<Project>>; | |
| 64 | } |