flagon-io/g1t

public

Git for AI scale: a forge for thousands of agents working on the same code at once.

g1t/packages/contracts/src/deployments.ts

206 lines8,058 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"
49 | "ready"
50 | "failed"
51 /** Not built: the workspace's plan is off, or the build was replaced. */
52 | "skipped";
53
54/** One build of one commit, and where it went. */
55export type Deployment = {
56 id: string;
57 kind: DeployKind;
Projects: what a workspace builds and runs, first on every page58 /** For a preview: the branch, or `pr-<n>` for a pull request from a fork. */
59 branch: string | null;
60 /** For a preview: its pull request. */
Deployments: a preview for every pull request, production on g1t.page61 number: number | null;
62 commit: string;
63 status: DeployStatus;
64 url: string;
65 /** Why it failed or was skipped. */
66 error: string | null;
67 /** What the build could not provide, such as bindings not provisioned yet. */
68 warnings: string[];
69 /** How long the build ran, in seconds; charged at the container price. */
70 buildSeconds: number | null;
71 createdBy: string;
72 /** RFC 3339. */
73 createdAt: string;
74 finishedAt: string | null;
75};
76
Projects: what a workspace builds and runs, first on every page77/** An app that is up: production, or one branch's preview. */
Deployments: a preview for every pull request, production on g1t.page78export type LiveApp = {
79 kind: DeployKind;
Projects: what a workspace builds and runs, first on every page80 branch: string | null;
Deployments: a preview for every pull request, production on g1t.page81 number: number | null;
82 url: string;
83 commit: string;
84 /** RFC 3339: when it was last deployed. */
85 deployedAt: string;
86};
87
Projects: what a workspace builds and runs, first on every page88/** One project at a glance, for the workspace's page. */
89export type ProjectDeploys = {
90 slug: string;
91 enabled: boolean;
92 production: LiveApp | null;
93 previews: number;
94 /** The newest build, whatever its status. */
95 latest: Deployment | null;
96};
97
Deployments: a preview for every pull request, production on g1t.page98/** What a workspace's apps used this month against its plan. */
99export type DeployUsage = {
100 /** `YYYY-MM`. */
101 month: string;
102 requests: number;
103 cpuMs: number;
104 /** Apps up now, and the most at once this month. */
105 apps: number;
106 peakApps: number;
107 buildSeconds: number;
108 /** Charged so far this month for builds, in millionths of a dollar. */
109 buildMicros: number;
110 /** RFC 3339: when requests and CPU time were last counted. */
111 countedAt: string | null;
112};
113
Agents and memory, checks and conflicts, profiles, slug renames, custom domains114/** Where custom domains point: a hostname on g1t.page that routes to the dispatcher. */
115export const CUSTOM_DOMAIN_TARGET = "domains.g1t.page";
116
117/**
118 * A custom domain's state: `pending` until its DNS points at g1t (or its
119 * ownership record is found), `verifying` while its certificate is
120 * issued, then `active`. `failed` says why in `error`; `removing` is on
121 * its way out.
122 */
123export type DomainStatus = "pending" | "verifying" | "active" | "failed" | "removing";
124
125/** A DNS record the domain's owner adds at their DNS provider. */
126export type DomainRecord = {
127 /** `ALIAS` stands for a flattened CNAME at the apex, whatever the provider calls it. */
128 type: "CNAME" | "TXT" | "ALIAS";
129 /** The record's full name. */
130 name: string;
131 value: string;
132 /** What it is for, in a few words. */
133 purpose: string;
134};
135
136/** A hostname of the project's own, serving its production. */
137export type Domain = {
138 id: string;
139 hostname: string;
140 /** What it serves: `production`. */
141 target: "production";
142 status: DomainStatus;
143 /** Cloudflare's state for its certificate, as given. */
144 sslStatus: string | null;
145 /** Whether it is a registrable domain itself (`example.com`), which needs a flattened CNAME. */
146 apex: boolean;
147 /** Every record to add: where traffic goes, then any Cloudflare asks for. */
148 records: DomainRecord[];
149 /** A hostname this one redirects to (308, path and query kept), for a www/apex pair. */
150 redirectTo: string | null;
151 /** Why it is not active yet, or failed. */
152 error: string | null;
153 createdBy: string;
154 createdAt: string;
155 verifiedAt: string | null;
156};
157
158export type ProjectDomains = {
159 domains: Domain[];
160 /** The hostname every domain points at. */
161 target: string;
162 /** False until custom domains are switched on for g1t.page; `notice` says so. */
163 available: boolean;
164 notice: string | null;
165 /** Custom domains the Deployments plan includes, across the workspace; more are charged by the month. */
166 included: number;
167 /** The workspace's custom domains now. */
168 used: number;
169};
170
Deployments: a preview for every pull request, production on g1t.page171export interface DeploymentsApi {
172 /** Members of the workspace only. */
Projects: what a workspace builds and runs, first on every page173 settings(project: ProjectRef, viewer: Viewer): Promise<Result<DeploySettings>>;
174 /** Members only. Turning deployments on needs the workspace's plan. */
175 updateSettings(actor: User, project: ProjectRef, changes: Partial<DeploySettings>): Promise<Result<DeploySettings>>;
176 /** The newest builds first, and what is up now. Members only. */
177 list(project: ProjectRef, viewer: Viewer): Promise<Result<{ deployments: Deployment[]; live: LiveApp[] }>>;
178 /** One build, with its log. Members only. */
179 get(project: ProjectRef, id: string, viewer: Viewer): Promise<Result<Deployment & { log: string | null }>>;
180 /** Builds production (`branch` null), or a branch's preview, again from its head. */
181 redeploy(actor: User, project: ProjectRef, branch: string | null): Promise<Result<Deployment>>;
Project dependencies: addresses, preview stacks, Affects, and agents who know182 /**
183 * Builds previews of the projects that use this one, under the same
184 * branch, each pointed at this branch's preview. Answers at once with the
185 * names of the projects being built; the builds go on in the
186 * background. Members only.
187 */
188 stack(actor: User, project: ProjectRef, branch: string): Promise<Result<string[]>>;
Projects: what a workspace builds and runs, first on every page189 /** Takes production (`branch` null), or a branch's preview, down now. */
190 takeDown(actor: User, project: ProjectRef, branch: string | null): Promise<Result<true>>;
191 /** Every project of a workspace at a glance. Members only. */
192 overview(workspace: string, viewer: Viewer): Promise<Result<ProjectDeploys[]>>;
Deployments: a preview for every pull request, production on g1t.page193 /** What the workspace's apps used this month. Members only. */
194 usage(workspace: string, viewer: Viewer): Promise<Result<DeployUsage>>;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains195 /** The project's custom domains. Members only. */
196 domains(project: ProjectRef, viewer: Viewer): Promise<Result<ProjectDomains>>;
197 /**
198 * Adds a custom domain for production. With `twin`, its www or apex twin
199 * is added too, redirecting to it. Members only; needs the Deployments plan.
200 */
201 addDomain(actor: User, project: ProjectRef, hostname: string, options?: { twin?: boolean }): Promise<Result<Domain[]>>;
202 /** Removes a custom domain, and any domain redirecting to it. Members only. */
203 removeDomain(actor: User, project: ProjectRef, id: string): Promise<Result<true>>;
204 /** Asks Cloudflare to check the domain again now. Members only. */
205 refreshDomain(actor: User, project: ProjectRef, id: string): Promise<Result<Domain>>;
Deployments: a preview for every pull request, production on g1t.page206}