Files
t3code/packages/client-runtime/src/state/sourceControl.ts
T

42 lines
1.5 KiB
TypeScript

import { WS_METHODS } from "@t3tools/contracts";
import { Atom } from "effect/unstable/reactivity";
import {
createAtomCommandScheduler,
createEnvironmentRpcCommand,
createEnvironmentRpcQueryAtomFamily,
} from "./runtime.ts";
import type { EnvironmentRegistry } from "../connection/registry.ts";
import { vcsCommandConcurrency, vcsCommandScheduler } from "./vcsCommandScheduler.ts";
export function createSourceControlEnvironmentAtoms<R, E>(
runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>,
) {
const commandScheduler = createAtomCommandScheduler();
return {
discovery: createEnvironmentRpcQueryAtomFamily(runtime, {
label: "environment-data:server:source-control-discovery",
tag: WS_METHODS.serverDiscoverSourceControl,
}),
repository: createEnvironmentRpcQueryAtomFamily(runtime, {
label: "environment-data:source-control:repository",
tag: WS_METHODS.sourceControlLookupRepository,
}),
cloneRepository: createEnvironmentRpcCommand(runtime, {
label: "environment-data:source-control:clone-repository",
tag: WS_METHODS.sourceControlCloneRepository,
scheduler: commandScheduler,
concurrency: {
mode: "serial",
key: ({ environmentId }) => environmentId,
},
}),
publishRepository: createEnvironmentRpcCommand(runtime, {
label: "environment-data:source-control:publish-repository",
tag: WS_METHODS.sourceControlPublishRepository,
scheduler: vcsCommandScheduler,
concurrency: vcsCommandConcurrency,
}),
};
}