@strayl/coregit 0.2.3 → 0.2.4

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.4",
4
4
  "description": "Official TypeScript SDK for the Coregit API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,28 @@
1
+ import type { HttpClient } from "./http";
2
+ import type {
3
+ CoregitResult,
4
+ CreateConnectionInput,
5
+ Connection,
6
+ ConnectionListResponse,
7
+ UpdateConnectionInput,
8
+ } from "./types";
9
+
10
+ export class ConnectionsClient {
11
+ constructor(private http: HttpClient) {}
12
+
13
+ create(input: CreateConnectionInput): Promise<CoregitResult<Connection>> {
14
+ return this.http.request<Connection>("POST", "/v1/connections", input);
15
+ }
16
+
17
+ list(): Promise<CoregitResult<ConnectionListResponse>> {
18
+ return this.http.request<ConnectionListResponse>("GET", "/v1/connections");
19
+ }
20
+
21
+ update(id: string, input: UpdateConnectionInput): Promise<CoregitResult<{ updated: boolean }>> {
22
+ return this.http.request<{ updated: boolean }>("PATCH", `/v1/connections/${encodeURIComponent(id)}`, input);
23
+ }
24
+
25
+ delete(id: string): Promise<CoregitResult<{ deleted: boolean }>> {
26
+ return this.http.request<{ deleted: boolean }>("DELETE", `/v1/connections/${encodeURIComponent(id)}`);
27
+ }
28
+ }
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ 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";
@@ -31,6 +32,7 @@ export class CoregitClient {
31
32
  readonly usage: UsageClient;
32
33
  readonly workspace: WorkspaceClient;
33
34
  readonly sync: SyncClient;
35
+ readonly connections: ConnectionsClient;
34
36
  readonly tokens: TokensClient;
35
37
  readonly webhooks: WebhooksClient;
36
38
  readonly search: SearchClient;
@@ -59,6 +61,7 @@ export class CoregitClient {
59
61
  this.usage = new UsageClient(http);
60
62
  this.workspace = new WorkspaceClient(http);
61
63
  this.sync = new SyncClient(http);
64
+ this.connections = new ConnectionsClient(http);
62
65
  this.tokens = new TokensClient(http);
63
66
  this.webhooks = new WebhooksClient(http);
64
67
  this.search = new SearchClient(http);
@@ -83,6 +86,7 @@ export { SnapshotsClient } from "./snapshots";
83
86
  export { UsageClient } from "./usage";
84
87
  export { WorkspaceClient } from "./workspace";
85
88
  export { SyncClient } from "./sync";
89
+ export { ConnectionsClient } from "./connections";
86
90
  export { TokensClient } from "./tokens";
87
91
  export { WebhooksClient } from "./webhooks";
88
92
  export { SearchClient } from "./search";
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
@@ -352,6 +352,33 @@ export interface ExecResult {
352
352
  execution_time_ms: number;
353
353
  }
354
354
 
355
+ // --- Connections ---
356
+
357
+ export interface CreateConnectionInput {
358
+ provider: "github" | "gitlab";
359
+ label: string;
360
+ access_token: string;
361
+ }
362
+
363
+ export interface Connection {
364
+ id: string;
365
+ provider: "github" | "gitlab";
366
+ label: string;
367
+ external_username: string;
368
+ last_synced_at: string | null;
369
+ created_at: string;
370
+ updated_at: string;
371
+ }
372
+
373
+ export interface ConnectionListResponse {
374
+ connections: Connection[];
375
+ }
376
+
377
+ export interface UpdateConnectionInput {
378
+ label?: string;
379
+ access_token?: string;
380
+ }
381
+
355
382
  // --- Sync ---
356
383
 
357
384
  export interface SyncInput {
@@ -365,6 +392,60 @@ export interface SyncResult {
365
392
  commit_sha: string | null;
366
393
  files_changed: number;
367
394
  deleted: number;
395
+ direction?: "import" | "export";
396
+ }
397
+
398
+ export interface CreateSyncConfigInput {
399
+ connection_id: string;
400
+ remote: string;
401
+ direction?: "import" | "export";
402
+ branch?: string;
403
+ auto_sync?: boolean;
404
+ }
405
+
406
+ export interface SyncConfig {
407
+ id: string;
408
+ repo_id: string;
409
+ connection_id: string;
410
+ provider: "github" | "gitlab";
411
+ remote: string;
412
+ branch: string;
413
+ direction: "import" | "export";
414
+ auto_sync: boolean;
415
+ last_synced_sha: string | null;
416
+ last_synced_at: string | null;
417
+ last_error: string | null;
418
+ webhook_id?: number | null;
419
+ connection?: {
420
+ label: string;
421
+ external_username: string;
422
+ };
423
+ }
424
+
425
+ export interface SyncConfigResponse {
426
+ config: SyncConfig | null;
427
+ }
428
+
429
+ export interface UpdateSyncConfigInput {
430
+ direction?: "import" | "export";
431
+ auto_sync?: boolean;
432
+ branch?: string;
433
+ remote?: string;
434
+ }
435
+
436
+ export interface SyncRun {
437
+ id: string;
438
+ status: "running" | "success" | "skipped" | "error";
439
+ message: string | null;
440
+ remote_sha: string | null;
441
+ commit_sha: string | null;
442
+ started_at: string;
443
+ completed_at: string | null;
444
+ }
445
+
446
+ export interface SyncHistoryResponse {
447
+ runs: SyncRun[];
448
+ next_cursor: string | null;
368
449
  }
369
450
 
370
451
  // --- Tokens ---