Remote

tcmts.cli.sync.Remote · #g4wtyao7 · type

What one codebase can ask of another.

import type { LockEntry } from "#codebase/tcmts/cli/codebase";
import type { ContributionView } from "#codebase/tcmts/cli/contributions";
import type { ConflictRecord } from "#codebase/tcmts/cli/merge";
import type {
  BranchState, Caller, NamespaceNode, NewContribution, Output, SharedLint, SharedResult,
} from "#codebase/tcmts/cli/sync";
import type { DefRecord } from "#codebase/tcmts/core/types";
import type { Causal, Contribution, Release } from "#codebase/tcmts/store";

export interface Remote {
  readonly label: string;
  /** which of these component hashes are absent */
  missing(components: string[]): Promise<string[]>;
  /** full components containing these definition hashes */
  get(hashes: string[]): Promise<DefRecord[]>;
  put(records: DefRecord[]): Promise<{ stored: number }>;
  /** its package lock: the versions (and tarball hashes) its code runs on */
  packages(): Promise<LockEntry[]>;
  /** lock entries for code about to be sent (before `put`, so it's verified on those versions) */
  putPackages(entries: LockEntry[]): Promise<void>;
  branch(name: string): Promise<BranchState | null>;
  /**
   * move a branch to a causal it has, only if its head is still `expect` (null: the branch must not exist), with the
   * sides of its conflicts
   */
  setBranch(
    name: string,
    head: string,
    expect: string | null,
    command: string,
    conflicts?: Record<string, ConflictRecord>,
  ): Promise<void>;
  /** every causal in a causal's history */
  ancestors(head: string): Promise<string[]>;
  missingCausals(hashes: string[]): Promise<string[]>;
  getCausals(hashes: string[]): Promise<Causal[]>;
  /** causals, parents before children, whose namespaces (and definitions) were sent first */
  putCausals(causals: Causal[]): Promise<void>;
  missingNamespaces(hashes: string[]): Promise<string[]>;
  getNamespaces(hashes: string[]): Promise<NamespaceNode[]>;
  putNamespaces(nodes: NamespaceNode[]): Promise<void>;
  releases(): Promise<Release[]>;
  /** releases whose history was sent first */
  putReleases(releases: Release[]): Promise<void>;
  /** contributions: branches proposed for merging, reviewed and merged there */
  contributions(all: boolean): Promise<Contribution[]>;
  contribution(id: number): Promise<ContributionView>;
  openContribution(c: NewContribution): Promise<{ id: number; created: boolean }>;
  comment(id: number, c: { author: string; body: string; about?: string | null }): Promise<void>;
  mergeContribution(id: number, author: string): Promise<{ mergedAs: string; todo: number }>;
  closeContribution(id: number, author: string, reopen?: boolean): Promise<void>;
  run(hash: string, args: string[], out: Output): Promise<number>;
  /** the keys it has tests' results under, for these test hashes */
  resultKeys(hashes: string[]): Promise<[string, string][]>;
  /** its results for these tests, under these keys (the ones it has) */
  results(pairs: [string, string][]): Promise<SharedResult[]>;
  /** results of tests it has, sent: kept where it has none for the key */
  putResults(results: SharedResult[]): Promise<void>;
  /** the keys it has lint findings under, for these definitions */
  lintKeys(hashes: string[]): Promise<[string, string][]>;
  /** its lint findings for these definitions, under these keys (the ones it has) */
  lints(pairs: [string, string][]): Promise<SharedLint[]>;
  /** lint findings of definitions it has, sent: kept where it has none for the key */
  putLints(lints: SharedLint[]): Promise<void>;
  /** who it takes this side to be: a codebase directory, or a server's own token, is its maintainer */
  whoami(): Promise<Caller>;
  /** the contributors it knows (the maintainer's to ask) */
  users(): Promise<{ handle: string; added: number }[]>;
  /** add a contributor, or give one a new token: their token */
  addUser(handle: string): Promise<string>;
  /** remove a contributor: whether there was one */
  removeUser(handle: string): Promise<boolean>;
}

uses

used by