@strayl/coregit 0.2.4 → 0.2.6
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/package.json +1 -1
- package/src/audit.ts +18 -0
- package/src/branches.ts +3 -3
- package/src/connections.ts +5 -0
- package/src/index.ts +4 -0
- package/src/refs.ts +3 -3
- package/src/types.ts +52 -6
package/package.json
CHANGED
package/src/audit.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { CoregitResult, AuditListResponse, AuditListOptions } from "./types";
|
|
3
|
+
|
|
4
|
+
export class AuditClient {
|
|
5
|
+
constructor(private http: HttpClient) {}
|
|
6
|
+
|
|
7
|
+
list(opts?: AuditListOptions): Promise<CoregitResult<AuditListResponse>> {
|
|
8
|
+
const params = new URLSearchParams();
|
|
9
|
+
if (opts?.limit) params.set("limit", String(opts.limit));
|
|
10
|
+
if (opts?.cursor) params.set("cursor", opts.cursor);
|
|
11
|
+
if (opts?.action) params.set("action", opts.action);
|
|
12
|
+
if (opts?.resource_type) params.set("resource_type", opts.resource_type);
|
|
13
|
+
if (opts?.since) params.set("since", opts.since);
|
|
14
|
+
if (opts?.until) params.set("until", opts.until);
|
|
15
|
+
const qs = params.toString();
|
|
16
|
+
return this.http.request<AuditListResponse>("GET", `/v1/audit-log${qs ? `?${qs}` : ""}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/branches.ts
CHANGED
|
@@ -29,11 +29,11 @@ export class BranchesClient {
|
|
|
29
29
|
return this.http.request("DELETE", `${buildRepoPath(repo)}/branches/${encodeURIComponent(name)}`);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
merge(repo: RepoRef,
|
|
32
|
+
merge(repo: RepoRef, targetBranch: string, input: MergeInput): Promise<CoregitResult<MergeResult>> {
|
|
33
33
|
return this.http.request<MergeResult>(
|
|
34
34
|
"POST",
|
|
35
|
-
`${buildRepoPath(repo)}/branches/${encodeURIComponent(
|
|
36
|
-
|
|
35
|
+
`${buildRepoPath(repo)}/branches/${encodeURIComponent(targetBranch)}/merge`,
|
|
36
|
+
input,
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
}
|
package/src/connections.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
CreateConnectionInput,
|
|
5
5
|
Connection,
|
|
6
6
|
ConnectionListResponse,
|
|
7
|
+
ConnectionTestResult,
|
|
7
8
|
UpdateConnectionInput,
|
|
8
9
|
} from "./types";
|
|
9
10
|
|
|
@@ -22,6 +23,10 @@ export class ConnectionsClient {
|
|
|
22
23
|
return this.http.request<{ updated: boolean }>("PATCH", `/v1/connections/${encodeURIComponent(id)}`, input);
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
test(id: string): Promise<CoregitResult<ConnectionTestResult>> {
|
|
27
|
+
return this.http.request<ConnectionTestResult>("POST", `/v1/connections/${encodeURIComponent(id)}/test`);
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
delete(id: string): Promise<CoregitResult<{ deleted: boolean }>> {
|
|
26
31
|
return this.http.request<{ deleted: boolean }>("DELETE", `/v1/connections/${encodeURIComponent(id)}`);
|
|
27
32
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { ConnectionsClient } from "./connections";
|
|
|
15
15
|
import { TokensClient } from "./tokens";
|
|
16
16
|
import { WebhooksClient } from "./webhooks";
|
|
17
17
|
import { SearchClient } from "./search";
|
|
18
|
+
import { AuditClient } from "./audit";
|
|
18
19
|
import type { CoregitClientOptions } from "./types";
|
|
19
20
|
|
|
20
21
|
const DEFAULT_BASE_URL = "https://api.coregit.dev";
|
|
@@ -36,6 +37,7 @@ export class CoregitClient {
|
|
|
36
37
|
readonly tokens: TokensClient;
|
|
37
38
|
readonly webhooks: WebhooksClient;
|
|
38
39
|
readonly search: SearchClient;
|
|
40
|
+
readonly audit: AuditClient;
|
|
39
41
|
|
|
40
42
|
constructor(options: CoregitClientOptions) {
|
|
41
43
|
if (!options.apiKey) {
|
|
@@ -65,6 +67,7 @@ export class CoregitClient {
|
|
|
65
67
|
this.tokens = new TokensClient(http);
|
|
66
68
|
this.webhooks = new WebhooksClient(http);
|
|
67
69
|
this.search = new SearchClient(http);
|
|
70
|
+
this.audit = new AuditClient(http);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -90,3 +93,4 @@ export { ConnectionsClient } from "./connections";
|
|
|
90
93
|
export { TokensClient } from "./tokens";
|
|
91
94
|
export { WebhooksClient } from "./webhooks";
|
|
92
95
|
export { SearchClient } from "./search";
|
|
96
|
+
export { AuditClient } from "./audit";
|
package/src/refs.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { HttpClient } from "./http";
|
|
|
2
2
|
import type {
|
|
3
3
|
CoregitResult,
|
|
4
4
|
RefEntry,
|
|
5
|
-
|
|
5
|
+
RefsResponse,
|
|
6
6
|
RepoRef,
|
|
7
7
|
UpdateRefInput,
|
|
8
8
|
UpdateRefResult,
|
|
@@ -12,8 +12,8 @@ import { buildRepoPath } from "./repo-ref";
|
|
|
12
12
|
export class RefsClient {
|
|
13
13
|
constructor(private http: HttpClient) {}
|
|
14
14
|
|
|
15
|
-
list(repo: RepoRef): Promise<CoregitResult<
|
|
16
|
-
return this.http.request<
|
|
15
|
+
list(repo: RepoRef): Promise<CoregitResult<RefsResponse>> {
|
|
16
|
+
return this.http.request<RefsResponse>("GET", `${buildRepoPath(repo)}/refs`);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
get(repo: RepoRef, refPath: string): Promise<CoregitResult<RefEntry>> {
|
package/src/types.ts
CHANGED
|
@@ -81,7 +81,7 @@ export interface BranchListResponse {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export interface MergeInput {
|
|
84
|
-
|
|
84
|
+
source: string;
|
|
85
85
|
strategy?: "fast-forward" | "merge-commit" | "squash";
|
|
86
86
|
message?: string;
|
|
87
87
|
author?: { name: string; email: string };
|
|
@@ -149,10 +149,6 @@ export interface RefEntry {
|
|
|
149
149
|
sha: string;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
export interface RefListResponse {
|
|
153
|
-
refs: RefEntry[];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
152
|
export interface UpdateRefInput {
|
|
157
153
|
sha: string;
|
|
158
154
|
expected_sha?: string;
|
|
@@ -166,11 +162,26 @@ export interface UpdateRefResult {
|
|
|
166
162
|
|
|
167
163
|
// --- Commits ---
|
|
168
164
|
|
|
165
|
+
export interface EditOperation {
|
|
166
|
+
/** Replace lines [start, end] (1-based, inclusive). */
|
|
167
|
+
range?: [number, number];
|
|
168
|
+
/** Find this exact string and replace it. Must be unique in the file. */
|
|
169
|
+
old_string?: string;
|
|
170
|
+
/** Replacement content for old_string match. Omit to delete the match. */
|
|
171
|
+
new_string?: string;
|
|
172
|
+
/** New content for range-based edits. */
|
|
173
|
+
content?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
169
176
|
export interface FileChange {
|
|
170
177
|
path: string;
|
|
171
178
|
content?: string;
|
|
172
179
|
encoding?: "utf-8" | "base64";
|
|
173
|
-
action?: "create" | "
|
|
180
|
+
action?: "create" | "edit" | "delete" | "rename";
|
|
181
|
+
/** Surgical edits for action: "edit". */
|
|
182
|
+
edits?: EditOperation[];
|
|
183
|
+
/** New path for action: "rename". */
|
|
184
|
+
new_path?: string;
|
|
174
185
|
}
|
|
175
186
|
|
|
176
187
|
export interface CreateCommitInput {
|
|
@@ -318,6 +329,35 @@ export interface UsageDetailsResponse {
|
|
|
318
329
|
next_cursor?: string | null;
|
|
319
330
|
}
|
|
320
331
|
|
|
332
|
+
// --- Audit ---
|
|
333
|
+
|
|
334
|
+
export interface AuditEvent {
|
|
335
|
+
id: number;
|
|
336
|
+
actor_id: string;
|
|
337
|
+
actor_type: "master_key" | "scoped_token" | "internal";
|
|
338
|
+
action: string;
|
|
339
|
+
resource_type: string;
|
|
340
|
+
resource_id: string | null;
|
|
341
|
+
metadata: Record<string, unknown> | null;
|
|
342
|
+
ip_address: string | null;
|
|
343
|
+
request_id: string | null;
|
|
344
|
+
created_at: string;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface AuditListResponse {
|
|
348
|
+
events: AuditEvent[];
|
|
349
|
+
next_cursor: string | null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface AuditListOptions {
|
|
353
|
+
limit?: number;
|
|
354
|
+
cursor?: string;
|
|
355
|
+
action?: string;
|
|
356
|
+
resource_type?: string;
|
|
357
|
+
since?: string;
|
|
358
|
+
until?: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
321
361
|
// --- Pagination ---
|
|
322
362
|
|
|
323
363
|
export interface PaginationOptions {
|
|
@@ -374,6 +414,12 @@ export interface ConnectionListResponse {
|
|
|
374
414
|
connections: Connection[];
|
|
375
415
|
}
|
|
376
416
|
|
|
417
|
+
export interface ConnectionTestResult {
|
|
418
|
+
valid: boolean;
|
|
419
|
+
username?: string;
|
|
420
|
+
error?: string;
|
|
421
|
+
}
|
|
422
|
+
|
|
377
423
|
export interface UpdateConnectionInput {
|
|
378
424
|
label?: string;
|
|
379
425
|
access_token?: string;
|