Skip to content

RepoSlot ​

Type, in @jr2/orchestrator/src/parts.ts. It is an export of @jr2/orchestrator, on the Authoring surface page, in Workspaces and Repos.

ts
type RepoSlot<TInput = unknown> =
  | typeof open
  | string
  | Binding
  | ((args: { input: TInput }) => string | Binding);

The value of one Repo Slot in workspace({ repos }). One of:

  • a url, or a Binding { url, ref }: the Machine names the Repo.
  • open: the Instance that registers the Machine binds it with customize(). jr2 up refuses a Workflow that leaves it open: refusing: workflow "<name>" leaves Repo Slot "<slot>" open — bind it where the Machine is registered: export const machine = customize(<import>, …) (ADR-0051), with the whole customize line to paste.
  • a function of the run input, ({ input }) => url or a Binding: each run chooses. The url must match an entry of git.credentials in jr2.config.ts, or the run cannot use it.

The key of the slot is a directory name under /work. It starts with a letter, and workspace() and customize() refuse a key that does not: <where>: Repo Slot key "<key>" is not a directory name — a slot becomes `/work/<slot>` and its order matters, so it starts with a letter and matches /^[A-Za-z][A-Za-z0-9._-]*$/ (ADR-0051). They refuse a value of another shape: <where>: Repo Slot "<slot>" is <what> — a slot is `open`, a url, `{ url, ref? }`, or a mapper `({ input }) => url | { url, ref? }` over the door (ADR-0051).

Example

ts
import { z } from "zod";
import { jr2Setup, open, workspace, type RepoSlot, type Workspaced } from "@jr2/orchestrator";

const runInput = z.object({ service: z.string() });
type RunInput = z.infer<typeof runInput>;

const service: RepoSlot<RunInput> = ({ input }) => `https://github.com/you/${input.service}.git`;

const body = jr2Setup({
  types: {} as { input: Workspaced<RunInput, "service" | "docs" | "config"> },
}).createMachine({
  id: "body",
  initial: "done",
  states: { done: { type: "final" } },
});

// A Machine for a package: the Instance that registers it binds `config`.
export const deploy = workspace(body, {
  input: runInput,
  repos: {
    service,
    docs: "https://github.com/you/docs.git",
    config: open,
  },
  spec: ({ input }) => ({ branch: `deploy/${input.service}` }),
});

See also

The docs of Kit version 0.5.1. Each page is also at its .md URL.