Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

SourceControlProvider.ts

74 lines2.7 KB

1import { Context, Effect } from "effect";
2import type {
3 ChangeRequest,
4 ChangeRequestState,
5 SourceControlProviderError,
6 SourceControlProviderInfo,
7 SourceControlProviderKind,
8 SourceControlRepositoryCloneUrls,
9 SourceControlRepositoryVisibility,
10} from "@t3tools/contracts";
11​
12export interface SourceControlProviderContext {
13 readonly provider: SourceControlProviderInfo;
14 readonly remoteName: string;
15 readonly remoteUrl: string;
17​
18export interface SourceControlRefSelector {
19 readonly refName: string;
20 readonly owner?: string;
21 readonly repository?: string;
23​
24export interface SourceControlProviderShape {
25 readonly kind: SourceControlProviderKind;
26 readonly listChangeRequests: (input: {
27 readonly cwd: string;
28 readonly context?: SourceControlProviderContext;
29 readonly source?: SourceControlRefSelector;
30 readonly headSelector: string;
31 readonly state: ChangeRequestState | "all";
32 readonly limit?: number;
33 }) => Effect.Effect<ReadonlyArray<ChangeRequest>, SourceControlProviderError>;
34 readonly getChangeRequest: (input: {
35 readonly cwd: string;
36 readonly context?: SourceControlProviderContext;
37 readonly reference: string;
38 }) => Effect.Effect<ChangeRequest, SourceControlProviderError>;
39 readonly createChangeRequest: (input: {
40 readonly cwd: string;
41 readonly context?: SourceControlProviderContext;
42 readonly source?: SourceControlRefSelector;
43 readonly target?: SourceControlRefSelector;
44 readonly baseRefName: string;
45 readonly headSelector: string;
46 readonly title: string;
47 readonly bodyFile: string;
48 }) => Effect.Effect<void, SourceControlProviderError>;
49 readonly getRepositoryCloneUrls: (input: {
50 readonly cwd: string;
51 readonly context?: SourceControlProviderContext;
52 readonly repository: string;
53 }) => Effect.Effect<SourceControlRepositoryCloneUrls, SourceControlProviderError>;
54 readonly createRepository: (input: {
55 readonly cwd: string;
56 readonly repository: string;
57 readonly visibility: SourceControlRepositoryVisibility;
58 }) => Effect.Effect<SourceControlRepositoryCloneUrls, SourceControlProviderError>;
59 readonly getDefaultBranch: (input: {
60 readonly cwd: string;
61 readonly context?: SourceControlProviderContext;
62 }) => Effect.Effect<string | null, SourceControlProviderError>;
63 readonly checkoutChangeRequest: (input: {
64 readonly cwd: string;
65 readonly context?: SourceControlProviderContext;
66 readonly reference: string;
67 readonly force?: boolean;
68 }) => Effect.Effect<void, SourceControlProviderError>;
70​
71export class SourceControlProvider extends Context.Service<
72 SourceControlProvider,
73 SourceControlProviderShape
74>()("t3/source-control/SourceControlProvider") {}