| 1 | /** |
| 2 | * A repository's About, as its Files page shows it beside the files: its |
| 3 | * license, security policy and languages, its contributors, its stars and |
| 4 | * its releases. Mirrors `crates/contracts/src/about.rs`. |
| 5 | * |
| 6 | * What is read from files and history is worked out in the background for |
| 7 | * the default branch's head and kept by commit: an answer can be for an |
| 8 | * older commit (`commit` is not `head`) while the newer one is worked out, |
| 9 | * or `pending` when nothing has been worked out yet. |
| 10 | */ |
| 11 | import type { Repo } from "./repos"; |
| 12 | |
| 13 | export type LanguageShare = { |
| 14 | name: string; |
| 15 | /** `#rrggbb`, the color it is known by. */ |
| 16 | color: string | null; |
| 17 | bytes: number; |
| 18 | /** Of the bytes counted, to one decimal place. */ |
| 19 | percent: number; |
| 20 | }; |
| 21 | |
| 22 | export type License = { |
| 23 | /** `MIT`, `Apache-2.0`; null when the text is not one g1t recognizes. */ |
| 24 | spdxId: string | null; |
| 25 | /** "MIT License", or "Other". */ |
| 26 | name: string; |
| 27 | /** The file it was read from: `LICENSE`. */ |
| 28 | path: string; |
| 29 | }; |
| 30 | |
| 31 | /** `user`: matched to an account. `g1t`: g1t itself. `agent`: a known coding agent or bot (./coding-agents.ts). `author`: the name on the commits. */ |
| 32 | export type ContributorKind = "user" | "g1t" | "agent" | "author"; |
| 33 | |
| 34 | /** Commits in the week starting on Monday `week` (`YYYY-MM-DD`, UTC). */ |
| 35 | export type WeekCommits = { week: string; commits: number }; |
| 36 | |
| 37 | export type Contributor = { |
| 38 | kind: ContributorKind; |
| 39 | name: string; |
| 40 | username?: string | null; |
| 41 | avatar?: string | null; |
| 42 | /** The coding agent's id, for an `agent`. */ |
| 43 | agent?: string | null; |
| 44 | commits: number; |
| 45 | firstAt: string; |
| 46 | lastAt: string; |
| 47 | /** Only for the most active contributors, on the Contributors page. */ |
| 48 | weeks: WeekCommits[]; |
| 49 | }; |
| 50 | |
| 51 | export type Freshness = { |
| 52 | /** The default branch's head; null for an empty repository. */ |
| 53 | head: string | null; |
| 54 | /** The commit the answer was worked out for. */ |
| 55 | commit: string | null; |
| 56 | computedAt: string | null; |
| 57 | /** Nothing worked out yet: ask again shortly. */ |
| 58 | pending: boolean; |
| 59 | /** Too large to read in full: counts what was read. */ |
| 60 | partial: boolean; |
| 61 | }; |
| 62 | |
| 63 | export type Languages = Freshness & { languages: LanguageShare[] }; |
| 64 | |
| 65 | export type Contributors = Freshness & { |
| 66 | total: number; |
| 67 | /** The commits read. */ |
| 68 | commits: number; |
| 69 | contributors: Contributor[]; |
| 70 | /** Every commit read, by week, oldest first, empty weeks included. */ |
| 71 | weeks: WeekCommits[]; |
| 72 | }; |
| 73 | |
| 74 | export type Release = { |
| 75 | id: string; |
| 76 | tagName: string; |
| 77 | /** The commit the tag named. */ |
| 78 | target: string; |
| 79 | name: string | null; |
| 80 | /** Markdown. */ |
| 81 | body: string; |
| 82 | draft: boolean; |
| 83 | prerelease: boolean; |
| 84 | author: string | null; |
| 85 | createdAt: string; |
| 86 | /** Null while it is a draft. */ |
| 87 | publishedAt: string | null; |
| 88 | latest: boolean; |
| 89 | }; |
| 90 | |
| 91 | export const MAX_RELEASE_NAME_CHARS = 200; |
| 92 | export const MAX_RELEASE_BODY_CHARS = 125_000; |
| 93 | |
| 94 | export type Stargazer = { username: string; avatar: string | null; starredAt: string }; |
| 95 | export type StarredRepo = { repo: Repo; starredAt: string; stars: number }; |
| 96 | export type Stars = { starred: boolean; stars: number }; |
| 97 | |
| 98 | export type RepoAbout = Freshness & { |
| 99 | license: License | null; |
| 100 | /** Path of SECURITY.md, when it has one. */ |
| 101 | securityPolicy: string | null; |
| 102 | languages: LanguageShare[]; |
| 103 | /** How many contributors there are. */ |
| 104 | contributors: number; |
| 105 | /** The most active, without their weeks. */ |
| 106 | topContributors: Contributor[]; |
| 107 | stars: number; |
| 108 | starred: boolean; |
| 109 | /** Releases the viewer can see. */ |
| 110 | releases: number; |
| 111 | latestRelease: Release | null; |
| 112 | }; |
| 113 | |
| 114 | export type NewRelease = { |
| 115 | tagName: string; |
| 116 | /** A branch or commit for a tag that does not exist yet; the default branch when absent. */ |
| 117 | target?: string | null; |
| 118 | name?: string | null; |
| 119 | body?: string | null; |
| 120 | draft?: boolean; |
| 121 | prerelease?: boolean; |
| 122 | }; |
| 123 | |
| 124 | export type ReleaseChange = { name?: string; body?: string; draft?: boolean; prerelease?: boolean }; |