@strayl/coregit 0.2.3 → 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.3",
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
  }
@@ -0,0 +1,33 @@
1
+ import type { HttpClient } from "./http";
2
+ import type {
3
+ CoregitResult,
4
+ CreateConnectionInput,
5
+ Connection,
6
+ ConnectionListResponse,
7
+ ConnectionTestResult,
8
+ UpdateConnectionInput,
9
+ } from "./types";
10
+
11
+ export class ConnectionsClient {
12
+ constructor(private http: HttpClient) {}
13
+
14
+ create(input: CreateConnectionInput): Promise<CoregitResult<Connection>> {
15
+ return this.http.request<Connection>("POST", "/v1/connections", input);
16
+ }
17
+
18
+ list(): Promise<CoregitResult<ConnectionListResponse>> {
19
+ return this.http.request<ConnectionListResponse>("GET", "/v1/connections");
20
+ }
21
+
22
+ update(id: string, input: UpdateConnectionInput): Promise<CoregitResult<{ updated: boolean }>> {
23
+ return this.http.request<{ updated: boolean }>("PATCH", `/v1/connections/${encodeURIComponent(id)}`, input);
24
+ }
25
+
26
+ test(id: string): Promise<CoregitResult<ConnectionTestResult>> {
27
+ return this.http.request<ConnectionTestResult>("POST", `/v1/connections/${encodeURIComponent(id)}/test`);
28
+ }
29
+
30
+ delete(id: string): Promise<CoregitResult<{ deleted: boolean }>> {
31
+ return this.http.request<{ deleted: boolean }>("DELETE", `/v1/connections/${encodeURIComponent(id)}`);
32
+ }
33
+ }
package/src/index.ts CHANGED
@@ -11,9 +11,11 @@ import { SnapshotsClient } from "./snapshots";
11
11
  import { UsageClient } from "./usage";
12
12
  import { WorkspaceClient } from "./workspace";
13
13
  import { SyncClient } from "./sync";
14
+ import { ConnectionsClient } from "./connections";
14
15
  import { TokensClient } from "./tokens";
15
16
  import { WebhooksClient } from "./webhooks";
16
17
  import { SearchClient } from "./search";
18
+ import { AuditClient } from "./audit";
17
19
  import type { CoregitClientOptions } from "./types";
18
20
 
19
21
  const DEFAULT_BASE_URL = "https://api.coregit.dev";
@@ -31,9 +33,11 @@ export class CoregitClient {
31
33
  readonly usage: UsageClient;
32
34
  readonly workspace: WorkspaceClient;
33
35
  readonly sync: SyncClient;
36
+ readonly connections: ConnectionsClient;
34
37
  readonly tokens: TokensClient;
35
38
  readonly webhooks: WebhooksClient;
36
39
  readonly search: SearchClient;
40
+ readonly audit: AuditClient;
37
41
 
38
42
  constructor(options: CoregitClientOptions) {
39
43
  if (!options.apiKey) {
@@ -59,9 +63,11 @@ export class CoregitClient {
59
63
  this.usage = new UsageClient(http);
60
64
  this.workspace = new WorkspaceClient(http);
61
65
  this.sync = new SyncClient(http);
66
+ this.connections = new ConnectionsClient(http);
62
67
  this.tokens = new TokensClient(http);
63
68
  this.webhooks = new WebhooksClient(http);
64
69
  this.search = new SearchClient(http);
70
+ this.audit = new AuditClient(http);
65
71
  }
66
72
  }
67
73
 
@@ -83,6 +89,8 @@ export { SnapshotsClient } from "./snapshots";
83
89
  export { UsageClient } from "./usage";
84
90
  export { WorkspaceClient } from "./workspace";
85
91
  export { SyncClient } from "./sync";
92
+ export { ConnectionsClient } from "./connections";
86
93
  export { TokensClient } from "./tokens";
87
94
  export { WebhooksClient } from "./webhooks";
88
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/sync.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import type { HttpClient } from "./http";
2
- import type { CoregitResult, SyncInput, SyncResult, RepoRef } from "./types";
2
+ import type {
3
+ CoregitResult,
4
+ SyncInput,
5
+ SyncResult,
6
+ RepoRef,
7
+ CreateSyncConfigInput,
8
+ SyncConfig,
9
+ SyncConfigResponse,
10
+ UpdateSyncConfigInput,
11
+ SyncHistoryResponse,
12
+ } from "./types";
3
13
  import { buildRepoPath } from "./repo-ref";
4
14
 
5
15
  export class SyncClient {
@@ -8,4 +18,28 @@ export class SyncClient {
8
18
  trigger(repo: RepoRef, input: SyncInput): Promise<CoregitResult<SyncResult>> {
9
19
  return this.http.request<SyncResult>("POST", `${buildRepoPath(repo)}/sync`, input);
10
20
  }
21
+
22
+ createConfig(repo: RepoRef, input: CreateSyncConfigInput): Promise<CoregitResult<SyncConfig>> {
23
+ return this.http.request<SyncConfig>("POST", `${buildRepoPath(repo)}/sync/config`, input);
24
+ }
25
+
26
+ getConfig(repo: RepoRef): Promise<CoregitResult<SyncConfigResponse>> {
27
+ return this.http.request<SyncConfigResponse>("GET", `${buildRepoPath(repo)}/sync/config`);
28
+ }
29
+
30
+ updateConfig(repo: RepoRef, input: UpdateSyncConfigInput): Promise<CoregitResult<{ updated: boolean }>> {
31
+ return this.http.request<{ updated: boolean }>("PATCH", `${buildRepoPath(repo)}/sync/config`, input);
32
+ }
33
+
34
+ deleteConfig(repo: RepoRef): Promise<CoregitResult<{ deleted: boolean }>> {
35
+ return this.http.request<{ deleted: boolean }>("DELETE", `${buildRepoPath(repo)}/sync/config`);
36
+ }
37
+
38
+ history(repo: RepoRef, opts?: { limit?: number; cursor?: string }): Promise<CoregitResult<SyncHistoryResponse>> {
39
+ const params = new URLSearchParams();
40
+ if (opts?.limit !== undefined) params.set("limit", String(opts.limit));
41
+ if (opts?.cursor) params.set("cursor", opts.cursor);
42
+ const qs = params.toString();
43
+ return this.http.request<SyncHistoryResponse>("GET", `${buildRepoPath(repo)}/sync/history${qs ? `?${qs}` : ""}`);
44
+ }
11
45
  }
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 {
@@ -352,6 +377,39 @@ export interface ExecResult {
352
377
  execution_time_ms: number;
353
378
  }
354
379
 
380
+ // --- Connections ---
381
+
382
+ export interface CreateConnectionInput {
383
+ provider: "github" | "gitlab";
384
+ label: string;
385
+ access_token: string;
386
+ }
387
+
388
+ export interface Connection {
389
+ id: string;
390
+ provider: "github" | "gitlab";
391
+ label: string;
392
+ external_username: string;
393
+ last_synced_at: string | null;
394
+ created_at: string;
395
+ updated_at: string;
396
+ }
397
+
398
+ export interface ConnectionListResponse {
399
+ connections: Connection[];
400
+ }
401
+
402
+ export interface ConnectionTestResult {
403
+ valid: boolean;
404
+ username?: string;
405
+ error?: string;
406
+ }
407
+
408
+ export interface UpdateConnectionInput {
409
+ label?: string;
410
+ access_token?: string;
411
+ }
412
+
355
413
  // --- Sync ---
356
414
 
357
415
  export interface SyncInput {
@@ -365,6 +423,60 @@ export interface SyncResult {
365
423
  commit_sha: string | null;
366
424
  files_changed: number;
367
425
  deleted: number;
426
+ direction?: "import" | "export";
427
+ }
428
+
429
+ export interface CreateSyncConfigInput {
430
+ connection_id: string;
431
+ remote: string;
432
+ direction?: "import" | "export";
433
+ branch?: string;
434
+ auto_sync?: boolean;
435
+ }
436
+
437
+ export interface SyncConfig {
438
+ id: string;
439
+ repo_id: string;
440
+ connection_id: string;
441
+ provider: "github" | "gitlab";
442
+ remote: string;
443
+ branch: string;
444
+ direction: "import" | "export";
445
+ auto_sync: boolean;
446
+ last_synced_sha: string | null;
447
+ last_synced_at: string | null;
448
+ last_error: string | null;
449
+ webhook_id?: number | null;
450
+ connection?: {
451
+ label: string;
452
+ external_username: string;
453
+ };
454
+ }
455
+
456
+ export interface SyncConfigResponse {
457
+ config: SyncConfig | null;
458
+ }
459
+
460
+ export interface UpdateSyncConfigInput {
461
+ direction?: "import" | "export";
462
+ auto_sync?: boolean;
463
+ branch?: string;
464
+ remote?: string;
465
+ }
466
+
467
+ export interface SyncRun {
468
+ id: string;
469
+ status: "running" | "success" | "skipped" | "error";
470
+ message: string | null;
471
+ remote_sha: string | null;
472
+ commit_sha: string | null;
473
+ started_at: string;
474
+ completed_at: string | null;
475
+ }
476
+
477
+ export interface SyncHistoryResponse {
478
+ runs: SyncRun[];
479
+ next_cursor: string | null;
368
480
  }
369
481
 
370
482
  // --- Tokens ---