Open History to see the last commit
1import { WS_METHODS } from "@v12/contracts";
2import { Atom } from "effect/unstable/reactivity";
3
4import {
5 createAtomCommandScheduler,
6 createEnvironmentRpcCommand,
7 createEnvironmentRpcQueryAtomFamily,
8} from "./runtime.ts";
9import type { EnvironmentRegistry } from "../connection/registry.ts";
10import { vcsCommandConcurrency, vcsCommandScheduler } from "./vcsCommandScheduler.ts";
11
12export function createSourceControlEnvironmentAtoms<R, E>(
13 runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>,
14) {
15 const commandScheduler = createAtomCommandScheduler();
16 return {
17 discovery: createEnvironmentRpcQueryAtomFamily(runtime, {
18 label: "environment-data:server:source-control-discovery",
19 tag: WS_METHODS.serverDiscoverSourceControl,
20 }),
21 repository: createEnvironmentRpcQueryAtomFamily(runtime, {
22 label: "environment-data:source-control:repository",
23 tag: WS_METHODS.sourceControlLookupRepository,
24 }),
25 cloneRepository: createEnvironmentRpcCommand(runtime, {
26 label: "environment-data:source-control:clone-repository",
27 tag: WS_METHODS.sourceControlCloneRepository,
28 scheduler: commandScheduler,
29 concurrency: {
30 mode: "serial",
31 key: ({ environmentId }) => environmentId,
32 },
33 }),
34 publishRepository: createEnvironmentRpcCommand(runtime, {
35 label: "environment-data:source-control:publish-repository",
36 tag: WS_METHODS.sourceControlPublishRepository,
37 scheduler: vcsCommandScheduler,
38 concurrency: vcsCommandConcurrency,
39 }),
40 };
41}