staging-tester / ocean-landing-serve / src/ lib/ migration.ts

// Sizes are whole megabytes; GitHub reports repository size in kilobytes, rounded here for display.
export const fileLimitMb = 1024;

export type SourceRepo = {
	org: string;
	name: string;
	visibility: 'public' | 'private';
	sizeMb: number;
	lfsMb: number;
	largest: { path: string; mb: number };
	issues: number;
	pulls: number;
	releases: number;
	wiki: boolean;
	archived: boolean;
	forkOf: string | null;
	pushedAt: string;
	people: string[];
	// What a move leaves on GitHub, listed so the switch can say what to re-create.
	behind: { webhooks: number; deployKeys: number; workflows: number };
	// The GitHub App installation that can read it, and the facts GitHub's repository list does not carry.
	installation: number;
	unknown: string[];
};

export type GithubOrg = { name: string; access: 'ok' | 'removed'; removedAt: string | null };

export type Person = { login: string; kind: 'person' | 'bot'; email: string | null };

export type Stage = 'queued' | 'code' | 'items' | 'check' | 'ready' | 'switched';
// Only a file over the limit is stored; lost GitHub access is read from the organization, so one reauthorization clears every move it stopped.
export type Blocker = { kind: 'file'; path: string; mb: number } | { kind: 'access'; org: string; since: string };
export type AfterSwitch = 'archive' | 'mirror' | 'leave';

export type Move = {
	id: string;
	from: { org: string; name: string } | { url: string };
	as: string;
	visibility: 'public' | 'private';
	stage: Stage;
	// Progress inside the current stage: megabytes for code, issues plus pull requests for items.
	done: number;
	total: number;
	blocker: Blocker | null;
	copiedAt: string | null;
	// Commits pushed on GitHub since the last copy, carried over by the final copy at the switch.
	since: number;
	pushers: number;
	switchedAt: string | null;
	after: AfterSwitch | null;
	brings: { items: boolean; releases: boolean; wiki: boolean };
	// A switch the server has accepted and is still finishing.
	switching: boolean;
	error: string | null;
	note: string | null;
};