@strayl/coregit 0.1.1 → 0.2.1
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 +2 -2
- package/dist/cherry-pick.d.ts.map +1 -1
- package/dist/cherry-pick.js +3 -2
- package/dist/cherry-pick.js.map +1 -1
- 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 +2 -2
- package/dist/compare.d.ts.map +1 -1
- package/dist/compare.js +3 -2
- package/dist/compare.js.map +1 -1
- 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 +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/refs.d.ts +5 -5
- package/dist/refs.d.ts.map +1 -1
- package/dist/refs.js +9 -8
- package/dist/refs.js.map +1 -1
- 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 +81 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/webhooks.d.ts +16 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +21 -0
- package/dist/webhooks.js.map +1 -0
- 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 +4 -3
- package/src/commits.ts +8 -6
- package/src/compare.ts +4 -3
- package/src/diff.ts +4 -3
- package/src/files.ts +8 -6
- package/src/index.ts +18 -1
- package/src/refs.ts +10 -8
- 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 +99 -1
- package/src/webhooks.ts +32 -0
- 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;
|
|
@@ -161,7 +167,7 @@ export interface FileChange {
|
|
|
161
167
|
path: string;
|
|
162
168
|
content?: string;
|
|
163
169
|
encoding?: "utf-8" | "base64";
|
|
164
|
-
action?: "delete";
|
|
170
|
+
action?: "create" | "modify" | "delete";
|
|
165
171
|
}
|
|
166
172
|
|
|
167
173
|
export interface CreateCommitInput {
|
|
@@ -310,3 +316,95 @@ export interface PaginationOptions {
|
|
|
310
316
|
limit?: number;
|
|
311
317
|
offset?: number;
|
|
312
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
|
+
ref?: string;
|
|
330
|
+
cwd?: string;
|
|
331
|
+
env?: Record<string, string>;
|
|
332
|
+
commit?: boolean;
|
|
333
|
+
commit_message?: string;
|
|
334
|
+
author?: { name: string; email: string };
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export interface ExecResult {
|
|
338
|
+
stdout: string;
|
|
339
|
+
stderr: string;
|
|
340
|
+
exit_code: number;
|
|
341
|
+
changed_files: string[];
|
|
342
|
+
commit_sha: string | null;
|
|
343
|
+
execution_time_ms: number;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// --- Sync ---
|
|
347
|
+
|
|
348
|
+
export interface SyncInput {
|
|
349
|
+
sync_id: string;
|
|
350
|
+
branch?: string;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface SyncResult {
|
|
354
|
+
synced: boolean;
|
|
355
|
+
remote_sha: string;
|
|
356
|
+
commit_sha: string | null;
|
|
357
|
+
files_changed: number;
|
|
358
|
+
deleted: number;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// --- Tokens ---
|
|
362
|
+
|
|
363
|
+
export interface CreateTokenInput {
|
|
364
|
+
name: string;
|
|
365
|
+
scopes: Record<string, string[]>;
|
|
366
|
+
expires_in: number;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export interface Token {
|
|
370
|
+
id: string;
|
|
371
|
+
token?: string;
|
|
372
|
+
name: string;
|
|
373
|
+
key_prefix: string;
|
|
374
|
+
scopes: Record<string, string[]>;
|
|
375
|
+
expires_at: string;
|
|
376
|
+
last_used?: string | null;
|
|
377
|
+
created_at: string;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export interface TokenListResponse {
|
|
381
|
+
tokens: Token[];
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// --- Webhooks ---
|
|
385
|
+
|
|
386
|
+
export type WebhookEvent = "push" | "repo.created" | "repo.deleted" | "branch.created" | "branch.deleted" | "*";
|
|
387
|
+
|
|
388
|
+
export interface CreateWebhookInput {
|
|
389
|
+
url: string;
|
|
390
|
+
events: WebhookEvent[];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export interface UpdateWebhookInput {
|
|
394
|
+
url?: string;
|
|
395
|
+
events?: WebhookEvent[];
|
|
396
|
+
active?: boolean;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export interface Webhook {
|
|
400
|
+
id: string;
|
|
401
|
+
url: string;
|
|
402
|
+
events: WebhookEvent[];
|
|
403
|
+
secret?: string;
|
|
404
|
+
active: boolean;
|
|
405
|
+
created_at?: string;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export interface WebhookListResponse {
|
|
409
|
+
webhooks: Webhook[];
|
|
410
|
+
}
|
package/src/webhooks.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type {
|
|
3
|
+
CoregitResult,
|
|
4
|
+
CreateWebhookInput,
|
|
5
|
+
UpdateWebhookInput,
|
|
6
|
+
Webhook,
|
|
7
|
+
WebhookListResponse,
|
|
8
|
+
} from "./types";
|
|
9
|
+
|
|
10
|
+
export class WebhooksClient {
|
|
11
|
+
constructor(private http: HttpClient) {}
|
|
12
|
+
|
|
13
|
+
create(input: CreateWebhookInput): Promise<CoregitResult<Webhook>> {
|
|
14
|
+
return this.http.request<Webhook>("POST", "/v1/webhooks", input);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
list(): Promise<CoregitResult<WebhookListResponse>> {
|
|
18
|
+
return this.http.request<WebhookListResponse>("GET", "/v1/webhooks");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get(id: string): Promise<CoregitResult<Webhook>> {
|
|
22
|
+
return this.http.request<Webhook>("GET", `/v1/webhooks/${encodeURIComponent(id)}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
update(id: string, input: UpdateWebhookInput): Promise<CoregitResult<{ updated: boolean }>> {
|
|
26
|
+
return this.http.request("PATCH", `/v1/webhooks/${encodeURIComponent(id)}`, input);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
delete(id: string): Promise<CoregitResult<{ deleted: boolean }>> {
|
|
30
|
+
return this.http.request("DELETE", `/v1/webhooks/${encodeURIComponent(id)}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
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
|
+
}
|