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/projects.ts

94 lines3,856 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.

Projects: what a workspace builds and runs, first on every page1import type { User, Viewer } from "./identity";
2import type { RepoPath } from "./repos";
3import 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. */
15export 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
21export 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
40export 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
Project dependencies: addresses, preview stacks, Affects, and agents who know49/** One end of a dependency, as a page shows it. */
50export type DependencyLink = {
51 slug: string;
52 name: string;
53 /** The variable carrying the other project's address, such as `API_URL`. */
54 as: string | null;
55 /** Declared on the site, or in the project's `.g1t/project.yml`. */
56 source: "ui" | "file";
57};
58
59/** What a project uses, and what uses it. */
60export type Dependencies = { dependsOn: DependencyLink[]; usedBy: DependencyLink[] };
61
62/** A project's dependencies by id, for services. */
63export type ProjectGraph = {
64 dependsOn: { id: string; slug: string; workspace: string; as: string | null }[];
65 usedBy: { id: string; slug: string; workspace: string; as: string | null }[];
66};
67
Projects: what a workspace builds and runs, first on every page68export interface ProjectsApi {
69 /** A workspace's projects, by name. Members, or anyone for public repositories. */
70 list(workspace: string, viewer: Viewer): Promise<Result<Project[]>>;
71 get(workspace: string, slug: string, viewer: Viewer): Promise<Result<Project>>;
72 /** The projects built from a repository, its primary one first. For services. */
73 byRepo(repoId: string): Promise<Project[]>;
74 /** Members only. */
75 create(actor: User, workspace: string, input: NewProject): Promise<Result<Project>>;
76 /** Members only. */
77 update(
78 actor: User,
79 workspace: string,
80 slug: string,
81 changes: { name?: string; description?: string | null; rootDir?: string },
82 ): Promise<Result<Project>>;
Project dependencies: addresses, preview stacks, Affects, and agents who know83 /** What a project uses and what uses it. Whoever may see the project. */
84 dependencies(workspace: string, slug: string, viewer: Viewer): Promise<Result<Dependencies>>;
85 /**
86 * `slug` uses `on`, with `as` the variable that carries `on`'s address.
87 * Members only; refused if it would make a cycle.
88 */
89 addDependency(actor: User, workspace: string, slug: string, on: string, as: string | null): Promise<Result<Dependencies>>;
90 /** Members only. A dependency from `.g1t/project.yml` is changed there. */
91 removeDependency(actor: User, workspace: string, slug: string, on: string): Promise<Result<Dependencies>>;
92 /** For services: a project's dependencies by id. */
93 graph(projectId: string): Promise<ProjectGraph>;
Projects: what a workspace builds and runs, first on every page94}