@strayl/coregit 0.2.4 → 0.2.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strayl/coregit",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Official TypeScript SDK for the Coregit API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
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, sourceBranch: string, opts?: MergeInput): Promise<CoregitResult<MergeResult>> {
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(sourceBranch)}/merge`,
36
- opts,
35
+ `${buildRepoPath(repo)}/branches/${encodeURIComponent(targetBranch)}/merge`,
36
+ input,
37
37
  );
38
38
  }
39
39
  }
@@ -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
- RefListResponse,
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<RefListResponse>> {
16
- return this.http.request<RefListResponse>("GET", `${buildRepoPath(repo)}/refs`);
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
- target?: string;
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;
@@ -318,6 +314,35 @@ export interface UsageDetailsResponse {
318
314
  next_cursor?: string | null;
319
315
  }
320
316
 
317
+ // --- Audit ---
318
+
319
+ export interface AuditEvent {
320
+ id: number;
321
+ actor_id: string;
322
+ actor_type: "master_key" | "scoped_token" | "internal";
323
+ action: string;
324
+ resource_type: string;
325
+ resource_id: string | null;
326
+ metadata: Record<string, unknown> | null;
327
+ ip_address: string | null;
328
+ request_id: string | null;
329
+ created_at: string;
330
+ }
331
+
332
+ export interface AuditListResponse {
333
+ events: AuditEvent[];
334
+ next_cursor: string | null;
335
+ }
336
+
337
+ export interface AuditListOptions {
338
+ limit?: number;
339
+ cursor?: string;
340
+ action?: string;
341
+ resource_type?: string;
342
+ since?: string;
343
+ until?: string;
344
+ }
345
+
321
346
  // --- Pagination ---
322
347
 
323
348
  export interface PaginationOptions {
@@ -374,6 +399,12 @@ export interface ConnectionListResponse {
374
399
  connections: Connection[];
375
400
  }
376
401
 
402
+ export interface ConnectionTestResult {
403
+ valid: boolean;
404
+ username?: string;
405
+ error?: string;
406
+ }
407
+
377
408
  export interface UpdateConnectionInput {
378
409
  label?: string;
379
410
  access_token?: string;