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.
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 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 | ||
| Merge main into rm-agents: mirroring removal, open signups, free-tier limits, the g1t CLI and runner fixes, with the agent removal kept. The CLI's table of operations is regenerated from the API without the agent, customize and AI credit operations; no CLI command used them. | 14 | /** Where a project's code lives: a repository hosted on g1t. */ |
| 15 | export type ProjectSource = { kind: "hosted"; repoId: string; repo: RepoPath; rootDir: string; defaultBranch: string }; | |
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 16 | |
| 17 | export type Project = { | |
| 18 | id: string; | |
| 19 | /** The workspace's slug. */ | |
| 20 | workspace: string; | |
| 21 | /** Unique in its workspace; the project's address is `g1t.sh/<workspace>/<slug>`. */ | |
| 22 | slug: string; | |
| 23 | name: string; | |
| 24 | /** The project's own description, or its repository's while it has none. */ | |
| 25 | description: string | null; | |
| 26 | /** Whether `description` is its repository's, following it as it changes. */ | |
| 27 | descriptionInherited: boolean; | |
| 28 | source: ProjectSource; | |
| 29 | /** Whether its repository is private: only people with a role on it can see it. */ | |
| 30 | private: boolean; | |
| 31 | /** Whether its repository is archived: read-only, kept for reference. */ | |
| 32 | archived: boolean; | |
| 33 | /** Whether it is the project its repository's workflows read secrets from. */ | |
| 34 | primary: boolean; | |
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 35 | /** What a person set it to be; each part null while it is left to detection. */ |
| 36 | setting: ProjectSetting; | |
| 37 | /** What it is: from `setting`, or for what is left out, from its deployments, packages and files. */ | |
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 38 | kind: ProjectKind; |
| 39 | /** Why it is that kind. */ | |
| 40 | kindReason: KindReason; | |
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 41 | /** |
| 42 | * Where it runs: `g1t` when g1t deploys it (Deployments, on g1t.page), | |
| 43 | * `elsewhere` when it is deployed by other means, at `productionUrl`. | |
| 44 | * Null for what is not deployed (a library, a tool) and for an app nobody | |
| 45 | * has said yet while Deployments are off. | |
| 46 | */ | |
| 47 | runs: ProjectRuns | null; | |
| 48 | /** Where production is when it runs elsewhere; null when nobody has given one. */ | |
| 49 | productionUrl: string | null; | |
| Merge branch 'worktree-agent-a5b0d9e2733e9e382' | 50 | /** |
| 51 | * An image of production someone uploaded, shown on its overview when | |
| 52 | * there is no screenshot, or instead of one when `preferred`. Null when | |
| 53 | * none was uploaded. | |
| 54 | */ | |
| 55 | productionImage: ProductionImage | null; | |
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 56 | /** What detection decides, whatever the setting is, to show beside it. */ |
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 57 | detected: { kind: ProjectKind; reason: KindReason }; |
| 58 | /** The ecosystem its files say it publishes to, for how to publish; null when none says. */ | |
| 59 | ecosystem: ProjectEcosystem | null; | |
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 60 | /** Its homepage, docs and other links, shown wherever the project is. */ |
| 61 | links: ProjectLinks; | |
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 62 | createdBy: string; |
| 63 | /** RFC 3339. */ | |
| 64 | createdAt: string; | |
| 65 | updatedAt: string; | |
| Projects: when each was last pushed, and how active it is lately | 66 | /** RFC 3339: when its repository was last pushed to; null until it is, after projects began keeping it. */ |
| 67 | pushedAt: string | null; | |
| 68 | /** | |
| 69 | * How active it is lately: each push, issue or pull request opened or | |
| 70 | * closed, review, comment and deployment counts one, halving every week. | |
| 71 | * 0 for none. | |
| 72 | */ | |
| 73 | activity: number; | |
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 74 | }; |
| 75 | ||
| 76 | /** | |
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 77 | * What a project is. An app (or a site) runs somewhere and gets a |
| 78 | * production card; a library is published and installed; a tool, such as | |
| 79 | * a CLI, ships as releases people install; docs are documentation or site | |
| 80 | * content; other is anything else, such as configuration or research. | |
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 81 | */ |
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 82 | export type ProjectKind = "app" | "library" | "tool" | "docs" | "other"; |
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 83 | |
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 84 | /** Every kind, in the order pages offer them. */ |
| 85 | export const PROJECT_KINDS: readonly ProjectKind[] = ["app", "library", "tool", "docs", "other"]; | |
| 86 | ||
| 87 | /** Where an app or a site runs: deployed by g1t on g1t.page, or deployed by other means. */ | |
| 88 | export type ProjectRuns = "g1t" | "elsewhere"; | |
| 89 | ||
| 90 | /** What a person set; null for each part left to detection. */ | |
| 91 | export type ProjectSetting = { kind: ProjectKind | null; runs: ProjectRuns | null }; | |
| 92 | ||
| 93 | /** One of a project's own links: a label and an http(s) address. */ | |
| 94 | export type ProjectLink = { label: string; url: string }; | |
| 95 | ||
| 96 | export type ProjectLinks = { | |
| 97 | /** Its homepage: its own, or its repository's website while it has none. */ | |
| 98 | homepage: string | null; | |
| 99 | /** Whether `homepage` is its repository's website, following it as it changes. */ | |
| 100 | homepageInherited: boolean; | |
| 101 | /** Where its documentation is read. */ | |
| 102 | docs: string | null; | |
| 103 | /** Any others, in the order given, at most `MAX_PROJECT_LINKS`. */ | |
| 104 | custom: ProjectLink[]; | |
| 105 | }; | |
| 106 | ||
| Merge branch 'worktree-agent-a5b0d9e2733e9e382' | 107 | /** |
| 108 | * An uploaded image of a project's production. `file` is the SHA-256 of | |
| 109 | * its bytes: it is served from the usercontent origin at | |
| 110 | * `/production-images/<file>`. | |
| 111 | */ | |
| 112 | export type ProductionImage = { file: string; contentType: string; preferred: boolean }; | |
| 113 | ||
| 114 | /** The largest production image taken, in bytes. */ | |
| 115 | export const MAX_PRODUCTION_IMAGE_BYTES = 5 * 1024 * 1024; | |
| 116 | ||
| 117 | /** The types a production image may be, read from its bytes. */ | |
| 118 | export const PRODUCTION_IMAGE_TYPES: readonly string[] = ["image/png", "image/jpeg", "image/webp"]; | |
| 119 | ||
| 120 | /** | |
| 121 | * A change to a project's production image. `image` is the new one's bytes | |
| 122 | * in base64, or null to remove it (and with it the preference); left out, | |
| 123 | * it stays. `preferred` shows it instead of a screenshot. | |
| 124 | */ | |
| 125 | export type ProductionImageChange = { image?: string | null; preferred?: boolean }; | |
| 126 | ||
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 127 | /** How many links of its own a project keeps besides its homepage and docs. */ |
| 128 | export const MAX_PROJECT_LINKS = 10; | |
| 129 | /** The longest link label. */ | |
| 130 | export const MAX_LINK_LABEL = 40; | |
| 131 | /** The longest link address. */ | |
| 132 | export const MAX_LINK_URL = 255; | |
| 133 | ||
| 134 | /** A change to a project; only what is given changes. */ | |
| 135 | export type ProjectChanges = { | |
| 136 | name?: string; | |
| 137 | /** Null or blank goes back to the repository's. */ | |
| 138 | description?: string | null; | |
| 139 | rootDir?: string; | |
| 140 | /** What it is; `auto` leaves it to detection. Anything but an app or docs stops it running anywhere. */ | |
| 141 | kind?: ProjectKind | "auto"; | |
| 142 | /** Where it runs; `auto` leaves it to Deployments. Setting it makes it an app unless it is docs. */ | |
| 143 | runs?: ProjectRuns | "auto"; | |
| 144 | /** Production's address when it runs elsewhere; null or blank clears it. */ | |
| 145 | productionUrl?: string | null; | |
| 146 | /** Null or blank goes back to the repository's website. */ | |
| 147 | homepage?: string | null; | |
| 148 | /** Null or blank clears it. */ | |
| 149 | docsUrl?: string | null; | |
| 150 | /** Replaces its other links. */ | |
| 151 | links?: ProjectLink[]; | |
| 152 | }; | |
| 153 | ||
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 154 | /** |
| 155 | * What decided the kind: the setting, Deployments being on, a package its | |
| 156 | * repository publishes, its files, or nothing (an app, by default). | |
| 157 | * `detail` says it in a sentence. | |
| 158 | */ | |
| 159 | export type KindReason = { by: "set" | "deployments" | "packages" | "files" | "default"; detail: string }; | |
| 160 | ||
| 161 | /** Where a library's files say it is published. */ | |
| 162 | export type ProjectEcosystem = "composer" | "npm" | "cargo" | "go" | "python"; | |
| 163 | ||
| 164 | export type NewProject = { | |
| 165 | name: string; | |
| 166 | description?: string | null; | |
| 167 | /** The hosted repository it builds from. */ | |
| 168 | repo: RepoPath; | |
| 169 | /** Where in the repository it lives; empty for the whole repository. */ | |
| 170 | rootDir?: string; | |
| 171 | }; | |
| 172 | ||
| Projects: pinned and recent projects, per person per workspace | 173 | /** |
| 174 | * What a person keeps at hand in a workspace: the projects they pinned, in | |
| 175 | * their order, then the ones they opened last that they have not pinned. | |
| 176 | * Only projects they can still see. | |
| 177 | */ | |
| 178 | export type ProjectShortcuts = { pinned: Project[]; recent: Project[] }; | |
| 179 | ||
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 180 | export interface ProjectsApi { |
| 181 | /** A workspace's projects, by name. Members, or anyone for public repositories. */ | |
| 182 | list(workspace: string, viewer: Viewer): Promise<Result<Project[]>>; | |
| 183 | get(workspace: string, slug: string, viewer: Viewer): Promise<Result<Project>>; | |
| 184 | /** The projects built from a repository, its primary one first. For services. */ | |
| 185 | byRepo(repoId: string): Promise<Project[]>; | |
| 186 | /** Members only. */ | |
| 187 | create(actor: User, workspace: string, input: NewProject): Promise<Result<Project>>; | |
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 188 | /** |
| 189 | * Members with a role that may change its settings. Making it something | |
| 190 | * that does not run (a library, a tool, other) while Deployments are on | |
| 191 | * is refused: they are turned off first. | |
| 192 | */ | |
| 193 | update(actor: User, workspace: string, slug: string, changes: ProjectChanges): Promise<Result<Project>>; | |
| Merge branch 'worktree-agent-a5b0d9e2733e9e382' | 194 | /** |
| 195 | * Uploads, replaces or removes its production image, or says whether it | |
| 196 | * is shown instead of a screenshot. Whoever may change the project's | |
| 197 | * settings, as for its production address. | |
| 198 | */ | |
| 199 | setProductionImage(actor: User, workspace: string, slug: string, change: ProductionImageChange): Promise<Result<Project>>; | |
| 200 | /** | |
| 201 | * For the screenshot service's daily refresh: every production address | |
| 202 | * of a project deployed elsewhere that shows a screenshot (not an | |
| 203 | * uploaded image instead), once each. | |
| 204 | */ | |
| 205 | externalProductions(): Promise<string[]>; | |
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 206 | /** For deployments: Deployments were turned on or off for the project. */ |
| 207 | deploymentsChanged(projectId: string, enabled: boolean): Promise<void>; | |
| Projects: pinned and recent projects, per person per workspace | 208 | /** A person's pinned and recent projects in a workspace. Empty for anyone else. */ |
| 209 | shortcuts(workspace: string, viewer: Viewer): Promise<ProjectShortcuts>; | |
| 210 | /** | |
| 211 | * Pins a project the person can see, at `position` (0 first) or at the | |
| 212 | * end; pinning one already pinned moves it. A person's own, at most 8 a | |
| 213 | * workspace. Returns their pins, in order. | |
| 214 | */ | |
| 215 | pin(actor: User, workspace: string, slug: string, position?: number | null): Promise<Result<Project[]>>; | |
| 216 | /** Unpins it. Returns their pins, in order. */ | |
| 217 | unpin(actor: User, workspace: string, slug: string): Promise<Result<Project[]>>; | |
| 218 | /** Puts their pins in this order: every pinned project's slug, once. */ | |
| 219 | reorderPins(actor: User, workspace: string, slugs: string[]): Promise<Result<Project[]>>; | |
| 220 | /** The person opened the project: it leads their recent ones. */ | |
| 221 | visited(actor: User, projectId: string): Promise<void>; | |
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 222 | /** |
| 223 | * For lists of public repositories, such as Explore: each one's own | |
| 224 | * project's address to show, by `namespace/name` in lower case: | |
| 225 | * production when it is deployed elsewhere, else its homepage, else its | |
| 226 | * docs. Repositories without one are left out. At most 100 asked at once. | |
| 227 | */ | |
| 228 | publicLinks(repos: RepoPath[]): Promise<Record<string, string>>; | |
| Artifacts: an hourly view of operations and errors, and SSH must meter its git before it ships | 229 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.