flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/packages/contracts/src/deployments.ts

211 lines8,251 bytesCodeBlame

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.

Deployments: a preview for every pull request, production on g1t.page1import type { User, Viewer } from "./identity";
2import type { Result } from "./result";
3
4/**
Projects: what a workspace builds and runs, first on every page5 * Deployments: a project's production, deployed from its default branch on
6 * every push, and a live preview of every branch with an open pull request.
7 * Apps run as Workers in a Workers for Platforms namespace, so an app no
8 * one visits costs nothing. A paid feature: the workspace turns it on with
9 * a monthly plan (see `Feature` in `./billing`), and each project then
10 * chooses for itself.
Deployments: a preview for every pull request, production on g1t.page11 */
12
13/** The domain apps are served on. Never g1t.sh, so they share no cookies with it. */
14export const DEPLOYMENTS_DOMAIN = "g1t.page";
15
Projects: what a workspace builds and runs, first on every page16/** A project, as deployments name it. */
17export type ProjectRef = { workspace: string; slug: string };
18
19/** A project's deployment settings. */
Deployments: a preview for every pull request, production on g1t.page20export type DeploySettings = {
Projects: what a workspace builds and runs, first on every page21 /** Whether this project deploys at all. Off until someone turns it on. */
Deployments: a preview for every pull request, production on g1t.page22 enabled: boolean;
Projects: what a workspace builds and runs, first on every page23 /** A preview for every branch with an open pull request. */
Deployments: a preview for every pull request, production on g1t.page24 previews: boolean;
25 /** The default branch deployed to production on every push. */
26 production: boolean;
27 /** Runs instead of the project's own `build` script. */
28 buildCommand: string | null;
29 /** What to serve, for a static site; found by itself when null. */
30 outputDir: string | null;
31 /** A preview no one has visited in this many days is taken down. */
32 idleDays: number;
33 /** Where production is served. */
34 productionUrl: string;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains35 /**
36 * The project's own domain for production, once it is active: the first
37 * custom domain added that serves the app rather than redirecting. Null
38 * until one is.
39 */
40 primaryDomain: string | null;
Deployments: a preview for every pull request, production on g1t.page41};
42
43export type DeployKind = "preview" | "production";
44
45export type DeployStatus =
46 /** Waiting for a sandbox. */
47 | "queued"
48 | "building"
Builds say Replaced or Down once they are no longer live49 /** What its app serves now. */
Deployments: a preview for every pull request, production on g1t.page50 | "ready"
Builds say Replaced or Down once they are no longer live51 /** Built and served, until a newer build of the same app replaced it. */
52 | "replaced"
53 /** Built and served, until its app was taken down. */
54 | "down"
Deployments: a preview for every pull request, production on g1t.page55 | "failed"
56 /** Not built: the workspace's plan is off, or the build was replaced. */
57 | "skipped";
58
59/** One build of one commit, and where it went. */
60export type Deployment = {
61 id: string;
62 kind: DeployKind;
Projects: what a workspace builds and runs, first on every page63 /** For a preview: the branch, or `pr-<n>` for a pull request from a fork. */
64 branch: string | null;
65 /** For a preview: its pull request. */
Deployments: a preview for every pull request, production on g1t.page66 number: number | null;
67 commit: string;
68 status: DeployStatus;
69 url: string;
70 /** Why it failed or was skipped. */
71 error: string | null;
72 /** What the build could not provide, such as bindings not provisioned yet. */
73 warnings: string[];
74 /** How long the build ran, in seconds; charged at the container price. */
75 buildSeconds: number | null;
76 createdBy: string;
77 /** RFC 3339. */
78 createdAt: string;
79 finishedAt: string | null;
80};
81
Projects: what a workspace builds and runs, first on every page82/** An app that is up: production, or one branch's preview. */
Deployments: a preview for every pull request, production on g1t.page83export type LiveApp = {
84 kind: DeployKind;
Projects: what a workspace builds and runs, first on every page85 branch: string | null;
Deployments: a preview for every pull request, production on g1t.page86 number: number | null;
87 url: string;
88 commit: string;
89 /** RFC 3339: when it was last deployed. */
90 deployedAt: string;
91};
92
Projects: what a workspace builds and runs, first on every page93/** One project at a glance, for the workspace's page. */
94export type ProjectDeploys = {
95 slug: string;
96 enabled: boolean;
97 production: LiveApp | null;
98 previews: number;
99 /** The newest build, whatever its status. */
100 latest: Deployment | null;
101};
102
Deployments: a preview for every pull request, production on g1t.page103/** What a workspace's apps used this month against its plan. */
104export type DeployUsage = {
105 /** `YYYY-MM`. */
106 month: string;
107 requests: number;
108 cpuMs: number;
109 /** Apps up now, and the most at once this month. */
110 apps: number;
111 peakApps: number;
112 buildSeconds: number;
113 /** Charged so far this month for builds, in millionths of a dollar. */
114 buildMicros: number;
115 /** RFC 3339: when requests and CPU time were last counted. */
116 countedAt: string | null;
117};
118
Agents and memory, checks and conflicts, profiles, slug renames, custom domains119/** Where custom domains point: a hostname on g1t.page that routes to the dispatcher. */
120export const CUSTOM_DOMAIN_TARGET = "domains.g1t.page";
121
122/**
123 * A custom domain's state: `pending` until its DNS points at g1t (or its
124 * ownership record is found), `verifying` while its certificate is
125 * issued, then `active`. `failed` says why in `error`; `removing` is on
126 * its way out.
127 */
128export type DomainStatus = "pending" | "verifying" | "active" | "failed" | "removing";
129
130/** A DNS record the domain's owner adds at their DNS provider. */
131export type DomainRecord = {
132 /** `ALIAS` stands for a flattened CNAME at the apex, whatever the provider calls it. */
133 type: "CNAME" | "TXT" | "ALIAS";
134 /** The record's full name. */
135 name: string;
136 value: string;
137 /** What it is for, in a few words. */
138 purpose: string;
139};
140
141/** A hostname of the project's own, serving its production. */
142export type Domain = {
143 id: string;
144 hostname: string;
145 /** What it serves: `production`. */
146 target: "production";
147 status: DomainStatus;
148 /** Cloudflare's state for its certificate, as given. */
149 sslStatus: string | null;
150 /** Whether it is a registrable domain itself (`example.com`), which needs a flattened CNAME. */
151 apex: boolean;
152 /** Every record to add: where traffic goes, then any Cloudflare asks for. */
153 records: DomainRecord[];
154 /** A hostname this one redirects to (308, path and query kept), for a www/apex pair. */
155 redirectTo: string | null;
156 /** Why it is not active yet, or failed. */
157 error: string | null;
158 createdBy: string;
159 createdAt: string;
160 verifiedAt: string | null;
161};
162
163export type ProjectDomains = {
164 domains: Domain[];
165 /** The hostname every domain points at. */
166 target: string;
167 /** False until custom domains are switched on for g1t.page; `notice` says so. */
168 available: boolean;
169 notice: string | null;
170 /** Custom domains the Deployments plan includes, across the workspace; more are charged by the month. */
171 included: number;
172 /** The workspace's custom domains now. */
173 used: number;
174};
175
Deployments: a preview for every pull request, production on g1t.page176export interface DeploymentsApi {
177 /** Members of the workspace only. */
Projects: what a workspace builds and runs, first on every page178 settings(project: ProjectRef, viewer: Viewer): Promise<Result<DeploySettings>>;
179 /** Members only. Turning deployments on needs the workspace's plan. */
180 updateSettings(actor: User, project: ProjectRef, changes: Partial<DeploySettings>): Promise<Result<DeploySettings>>;
181 /** The newest builds first, and what is up now. Members only. */
182 list(project: ProjectRef, viewer: Viewer): Promise<Result<{ deployments: Deployment[]; live: LiveApp[] }>>;
183 /** One build, with its log. Members only. */
184 get(project: ProjectRef, id: string, viewer: Viewer): Promise<Result<Deployment & { log: string | null }>>;
185 /** Builds production (`branch` null), or a branch's preview, again from its head. */
186 redeploy(actor: User, project: ProjectRef, branch: string | null): Promise<Result<Deployment>>;
Project dependencies: addresses, preview stacks, Affects, and agents who know187 /**
188 * Builds previews of the projects that use this one, under the same
189 * branch, each pointed at this branch's preview. Answers at once with the
190 * names of the projects being built; the builds go on in the
191 * background. Members only.
192 */
193 stack(actor: User, project: ProjectRef, branch: string): Promise<Result<string[]>>;
Projects: what a workspace builds and runs, first on every page194 /** Takes production (`branch` null), or a branch's preview, down now. */
195 takeDown(actor: User, project: ProjectRef, branch: string | null): Promise<Result<true>>;
196 /** Every project of a workspace at a glance. Members only. */
197 overview(workspace: string, viewer: Viewer): Promise<Result<ProjectDeploys[]>>;
Deployments: a preview for every pull request, production on g1t.page198 /** What the workspace's apps used this month. Members only. */
199 usage(workspace: string, viewer: Viewer): Promise<Result<DeployUsage>>;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains200 /** The project's custom domains. Members only. */
201 domains(project: ProjectRef, viewer: Viewer): Promise<Result<ProjectDomains>>;
202 /**
203 * Adds a custom domain for production. With `twin`, its www or apex twin
204 * is added too, redirecting to it. Members only; needs the Deployments plan.
205 */
206 addDomain(actor: User, project: ProjectRef, hostname: string, options?: { twin?: boolean }): Promise<Result<Domain[]>>;
207 /** Removes a custom domain, and any domain redirecting to it. Members only. */
208 removeDomain(actor: User, project: ProjectRef, id: string): Promise<Result<true>>;
209 /** Asks Cloudflare to check the domain again now. Members only. */
210 refreshDomain(actor: User, project: ProjectRef, id: string): Promise<Result<Domain>>;
Deployments: a preview for every pull request, production on g1t.page211}