@strayl/coregit 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/branches.d.ts +6 -6
- package/dist/branches.d.ts.map +1 -1
- package/dist/branches.js +11 -10
- package/dist/branches.js.map +1 -1
- package/dist/cherry-pick.d.ts +8 -0
- package/dist/cherry-pick.d.ts.map +1 -0
- package/dist/cherry-pick.js +10 -0
- package/dist/cherry-pick.js.map +1 -0
- package/dist/commits.d.ts +4 -4
- package/dist/commits.d.ts.map +1 -1
- package/dist/commits.js +7 -6
- package/dist/commits.js.map +1 -1
- package/dist/compare.d.ts +8 -0
- package/dist/compare.d.ts.map +1 -0
- package/dist/compare.js +11 -0
- package/dist/compare.js.map +1 -0
- package/dist/diff.d.ts +2 -2
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +3 -2
- package/dist/diff.js.map +1 -1
- package/dist/files.d.ts +4 -4
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +7 -6
- package/dist/files.js.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/refs.d.ts +15 -0
- package/dist/refs.d.ts.map +1 -0
- package/dist/refs.js +19 -0
- package/dist/refs.js.map +1 -0
- package/dist/repo-ref.d.ts +3 -0
- package/dist/repo-ref.d.ts.map +1 -0
- package/dist/repo-ref.js +7 -0
- package/dist/repo-ref.js.map +1 -0
- package/dist/repos.d.ts +5 -5
- package/dist/repos.d.ts.map +1 -1
- package/dist/repos.js +9 -6
- package/dist/repos.js.map +1 -1
- package/dist/snapshots.d.ts +6 -6
- package/dist/snapshots.d.ts.map +1 -1
- package/dist/snapshots.js +11 -10
- package/dist/snapshots.js.map +1 -1
- package/dist/sync.d.ts +8 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +10 -0
- package/dist/sync.js.map +1 -0
- package/dist/tokens.d.ts +13 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +15 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +122 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/workspace.d.ts +8 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +10 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +1 -1
- package/src/branches.ts +12 -10
- package/src/cherry-pick.ts +15 -0
- package/src/commits.ts +8 -6
- package/src/compare.ts +12 -0
- package/src/diff.ts +4 -3
- package/src/files.ts +8 -6
- package/src/index.ts +25 -0
- package/src/refs.ts +30 -0
- package/src/repo-ref.ts +8 -0
- package/src/repos.ts +11 -8
- package/src/snapshots.ts +12 -10
- package/src/sync.ts +11 -0
- package/src/tokens.ts +18 -0
- package/src/types.ts +144 -2
- package/src/workspace.ts +11 -0
package/src/repos.ts
CHANGED
|
@@ -2,11 +2,13 @@ import type { HttpClient } from "./http";
|
|
|
2
2
|
import type {
|
|
3
3
|
CoregitResult,
|
|
4
4
|
CreateRepoInput,
|
|
5
|
-
PaginationOptions,
|
|
6
5
|
Repo,
|
|
6
|
+
RepoListOptions,
|
|
7
7
|
RepoListResponse,
|
|
8
|
+
RepoRef,
|
|
8
9
|
UpdateRepoInput,
|
|
9
10
|
} from "./types";
|
|
11
|
+
import { buildRepoPath } from "./repo-ref";
|
|
10
12
|
|
|
11
13
|
export class ReposClient {
|
|
12
14
|
constructor(private http: HttpClient) {}
|
|
@@ -15,23 +17,24 @@ export class ReposClient {
|
|
|
15
17
|
return this.http.request<Repo>("POST", "/v1/repos", input);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
list(opts?:
|
|
20
|
+
list(opts?: RepoListOptions): Promise<CoregitResult<RepoListResponse>> {
|
|
19
21
|
const params = new URLSearchParams();
|
|
20
22
|
if (opts?.limit !== undefined) params.set("limit", String(opts.limit));
|
|
21
23
|
if (opts?.offset !== undefined) params.set("offset", String(opts.offset));
|
|
24
|
+
if (opts?.namespace) params.set("namespace", opts.namespace);
|
|
22
25
|
const qs = params.toString();
|
|
23
26
|
return this.http.request<RepoListResponse>("GET", `/v1/repos${qs ? `?${qs}` : ""}`);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
get(
|
|
27
|
-
return this.http.request<Repo>("GET",
|
|
29
|
+
get(repo: RepoRef): Promise<CoregitResult<Repo>> {
|
|
30
|
+
return this.http.request<Repo>("GET", buildRepoPath(repo));
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
update(
|
|
31
|
-
return this.http.request<Repo>("PATCH",
|
|
33
|
+
update(repo: RepoRef, input: UpdateRepoInput): Promise<CoregitResult<Repo>> {
|
|
34
|
+
return this.http.request<Repo>("PATCH", buildRepoPath(repo), input);
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
delete(
|
|
35
|
-
return this.http.request<{ deleted: boolean }>("DELETE",
|
|
37
|
+
delete(repo: RepoRef): Promise<CoregitResult<{ deleted: boolean }>> {
|
|
38
|
+
return this.http.request<{ deleted: boolean }>("DELETE", buildRepoPath(repo));
|
|
36
39
|
}
|
|
37
40
|
}
|
package/src/snapshots.ts
CHANGED
|
@@ -2,35 +2,37 @@ import type { HttpClient } from "./http";
|
|
|
2
2
|
import type {
|
|
3
3
|
CoregitResult,
|
|
4
4
|
CreateSnapshotInput,
|
|
5
|
+
RepoRef,
|
|
5
6
|
RestoreInput,
|
|
6
7
|
RestoreResult,
|
|
7
8
|
Snapshot,
|
|
8
9
|
SnapshotListResponse,
|
|
9
10
|
} from "./types";
|
|
11
|
+
import { buildRepoPath } from "./repo-ref";
|
|
10
12
|
|
|
11
13
|
export class SnapshotsClient {
|
|
12
14
|
constructor(private http: HttpClient) {}
|
|
13
15
|
|
|
14
|
-
create(
|
|
15
|
-
return this.http.request<Snapshot>("POST",
|
|
16
|
+
create(repo: RepoRef, input: CreateSnapshotInput): Promise<CoregitResult<Snapshot>> {
|
|
17
|
+
return this.http.request<Snapshot>("POST", `${buildRepoPath(repo)}/snapshots`, input);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
list(
|
|
19
|
-
return this.http.request<SnapshotListResponse>("GET",
|
|
20
|
+
list(repo: RepoRef): Promise<CoregitResult<SnapshotListResponse>> {
|
|
21
|
+
return this.http.request<SnapshotListResponse>("GET", `${buildRepoPath(repo)}/snapshots`);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
get(
|
|
23
|
-
return this.http.request<Snapshot>("GET",
|
|
24
|
+
get(repo: RepoRef, name: string): Promise<CoregitResult<Snapshot>> {
|
|
25
|
+
return this.http.request<Snapshot>("GET", `${buildRepoPath(repo)}/snapshots/${encodeURIComponent(name)}`);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
delete(
|
|
27
|
-
return this.http.request("DELETE",
|
|
28
|
+
delete(repo: RepoRef, name: string): Promise<CoregitResult<{ deleted: boolean }>> {
|
|
29
|
+
return this.http.request("DELETE", `${buildRepoPath(repo)}/snapshots/${encodeURIComponent(name)}`);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
restore(
|
|
32
|
+
restore(repo: RepoRef, name: string, opts?: RestoreInput): Promise<CoregitResult<RestoreResult>> {
|
|
31
33
|
return this.http.request<RestoreResult>(
|
|
32
34
|
"POST",
|
|
33
|
-
|
|
35
|
+
`${buildRepoPath(repo)}/snapshots/${encodeURIComponent(name)}/restore`,
|
|
34
36
|
opts,
|
|
35
37
|
);
|
|
36
38
|
}
|
package/src/sync.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { CoregitResult, SyncInput, SyncResult, RepoRef } from "./types";
|
|
3
|
+
import { buildRepoPath } from "./repo-ref";
|
|
4
|
+
|
|
5
|
+
export class SyncClient {
|
|
6
|
+
constructor(private http: HttpClient) {}
|
|
7
|
+
|
|
8
|
+
trigger(repo: RepoRef, input: SyncInput): Promise<CoregitResult<SyncResult>> {
|
|
9
|
+
return this.http.request<SyncResult>("POST", `${buildRepoPath(repo)}/sync`, input);
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/tokens.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { CoregitResult, CreateTokenInput, Token, TokenListResponse } from "./types";
|
|
3
|
+
|
|
4
|
+
export class TokensClient {
|
|
5
|
+
constructor(private http: HttpClient) {}
|
|
6
|
+
|
|
7
|
+
create(input: CreateTokenInput): Promise<CoregitResult<Token>> {
|
|
8
|
+
return this.http.request<Token>("POST", "/v1/tokens", input);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
list(): Promise<CoregitResult<TokenListResponse>> {
|
|
12
|
+
return this.http.request<TokenListResponse>("GET", "/v1/tokens");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
revoke(id: string): Promise<CoregitResult<{ id: string; revoked: boolean }>> {
|
|
16
|
+
return this.http.request("DELETE", `/v1/tokens/${encodeURIComponent(id)}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -18,10 +18,15 @@ export interface CoregitError {
|
|
|
18
18
|
status?: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// --- Repo Ref ---
|
|
22
|
+
|
|
23
|
+
export type RepoRef = string | { namespace: string; slug: string };
|
|
24
|
+
|
|
21
25
|
// --- Repos ---
|
|
22
26
|
|
|
23
27
|
export interface CreateRepoInput {
|
|
24
28
|
slug: string;
|
|
29
|
+
namespace?: string;
|
|
25
30
|
description?: string;
|
|
26
31
|
default_branch?: string;
|
|
27
32
|
visibility?: "public" | "private";
|
|
@@ -36,6 +41,7 @@ export interface UpdateRepoInput {
|
|
|
36
41
|
|
|
37
42
|
export interface Repo {
|
|
38
43
|
id: string;
|
|
44
|
+
namespace: string | null;
|
|
39
45
|
slug: string;
|
|
40
46
|
description: string | null;
|
|
41
47
|
default_branch: string;
|
|
@@ -73,13 +79,86 @@ export interface BranchListResponse {
|
|
|
73
79
|
|
|
74
80
|
export interface MergeInput {
|
|
75
81
|
target?: string;
|
|
76
|
-
strategy?:
|
|
82
|
+
strategy?: "fast-forward" | "merge-commit" | "squash";
|
|
83
|
+
message?: string;
|
|
84
|
+
author?: { name: string; email: string };
|
|
85
|
+
expected_sha?: string;
|
|
77
86
|
}
|
|
78
87
|
|
|
79
88
|
export interface MergeResult {
|
|
80
89
|
merged: boolean;
|
|
81
90
|
sha: string;
|
|
82
91
|
strategy: string;
|
|
92
|
+
merge_sha?: string;
|
|
93
|
+
conflicts?: string[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// --- Compare ---
|
|
97
|
+
|
|
98
|
+
export interface CompareCommit {
|
|
99
|
+
sha: string;
|
|
100
|
+
message: string;
|
|
101
|
+
author: string;
|
|
102
|
+
email: string;
|
|
103
|
+
date: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface CompareResponse {
|
|
107
|
+
base: string;
|
|
108
|
+
head: string;
|
|
109
|
+
merge_base: string;
|
|
110
|
+
ahead_by: number;
|
|
111
|
+
behind_by: number;
|
|
112
|
+
commits: CompareCommit[];
|
|
113
|
+
files: DiffFile[];
|
|
114
|
+
total_files_changed: number;
|
|
115
|
+
total_additions: number;
|
|
116
|
+
total_deletions: number;
|
|
117
|
+
mergeable: boolean | null;
|
|
118
|
+
conflicts: string[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// --- Cherry-Pick ---
|
|
122
|
+
|
|
123
|
+
export interface CherryPickInput {
|
|
124
|
+
base: string;
|
|
125
|
+
head: string;
|
|
126
|
+
onto: string;
|
|
127
|
+
branch?: string;
|
|
128
|
+
expected_sha?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface CherryPickResult {
|
|
132
|
+
success: boolean;
|
|
133
|
+
head_sha: string | null;
|
|
134
|
+
onto_sha: string;
|
|
135
|
+
commits_created: number;
|
|
136
|
+
branch?: string;
|
|
137
|
+
branch_updated?: boolean;
|
|
138
|
+
conflicts?: string[];
|
|
139
|
+
last_clean_sha?: string | null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// --- Refs ---
|
|
143
|
+
|
|
144
|
+
export interface RefEntry {
|
|
145
|
+
ref: string;
|
|
146
|
+
sha: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface RefListResponse {
|
|
150
|
+
refs: RefEntry[];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface UpdateRefInput {
|
|
154
|
+
sha: string;
|
|
155
|
+
expected_sha?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface UpdateRefResult {
|
|
159
|
+
ref: string;
|
|
160
|
+
sha: string;
|
|
161
|
+
previous_sha: string | null;
|
|
83
162
|
}
|
|
84
163
|
|
|
85
164
|
// --- Commits ---
|
|
@@ -88,7 +167,7 @@ export interface FileChange {
|
|
|
88
167
|
path: string;
|
|
89
168
|
content?: string;
|
|
90
169
|
encoding?: "utf-8" | "base64";
|
|
91
|
-
action?: "delete";
|
|
170
|
+
action?: "create" | "modify" | "delete";
|
|
92
171
|
}
|
|
93
172
|
|
|
94
173
|
export interface CreateCommitInput {
|
|
@@ -237,3 +316,66 @@ export interface PaginationOptions {
|
|
|
237
316
|
limit?: number;
|
|
238
317
|
offset?: number;
|
|
239
318
|
}
|
|
319
|
+
|
|
320
|
+
export interface RepoListOptions extends PaginationOptions {
|
|
321
|
+
namespace?: string;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// --- Workspace ---
|
|
325
|
+
|
|
326
|
+
export interface ExecInput {
|
|
327
|
+
command: string;
|
|
328
|
+
branch?: string;
|
|
329
|
+
cwd?: string;
|
|
330
|
+
env?: Record<string, string>;
|
|
331
|
+
commit?: boolean;
|
|
332
|
+
commit_message?: string;
|
|
333
|
+
author?: { name: string; email: string };
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface ExecResult {
|
|
337
|
+
stdout: string;
|
|
338
|
+
stderr: string;
|
|
339
|
+
exit_code: number;
|
|
340
|
+
changed_files: string[];
|
|
341
|
+
commit_sha: string | null;
|
|
342
|
+
execution_time_ms: number;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// --- Sync ---
|
|
346
|
+
|
|
347
|
+
export interface SyncInput {
|
|
348
|
+
sync_id: string;
|
|
349
|
+
branch?: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface SyncResult {
|
|
353
|
+
synced: boolean;
|
|
354
|
+
remote_sha: string;
|
|
355
|
+
commit_sha: string | null;
|
|
356
|
+
files_changed: number;
|
|
357
|
+
deleted: number;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// --- Tokens ---
|
|
361
|
+
|
|
362
|
+
export interface CreateTokenInput {
|
|
363
|
+
name: string;
|
|
364
|
+
scopes: Record<string, string[]>;
|
|
365
|
+
expires_in: number;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export interface Token {
|
|
369
|
+
id: string;
|
|
370
|
+
token?: string;
|
|
371
|
+
name: string;
|
|
372
|
+
key_prefix: string;
|
|
373
|
+
scopes: Record<string, string[]>;
|
|
374
|
+
expires_at: string;
|
|
375
|
+
last_used?: string | null;
|
|
376
|
+
created_at: string;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export interface TokenListResponse {
|
|
380
|
+
tokens: Token[];
|
|
381
|
+
}
|
package/src/workspace.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { CoregitResult, ExecInput, ExecResult, RepoRef } from "./types";
|
|
3
|
+
import { buildRepoPath } from "./repo-ref";
|
|
4
|
+
|
|
5
|
+
export class WorkspaceClient {
|
|
6
|
+
constructor(private http: HttpClient) {}
|
|
7
|
+
|
|
8
|
+
exec(repo: RepoRef, input: ExecInput): Promise<CoregitResult<ExecResult>> {
|
|
9
|
+
return this.http.request<ExecResult>("POST", `${buildRepoPath(repo)}/exec`, input);
|
|
10
|
+
}
|
|
11
|
+
}
|