@leitwerk-dev/gitlab 0.2.0 → 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/src/client.ts CHANGED
@@ -1,120 +1,274 @@
1
1
  import { asUnknownRecord } from "@leitwerk-dev/domain";
2
2
  import { repositoryHttpsUrl } from "@leitwerk-dev/process-sdk";
3
3
 
4
+ /** @internal */
4
5
  export interface GitLabProfile {
6
+ /** @internal */
5
7
  baseUrl: string;
8
+ /** @internal */
6
9
  token: string;
7
- gitIdentity?: { name: string; email: string };
10
+ /** @internal */
11
+ gitIdentity?: {
12
+ /** @internal */
13
+ name: string;
14
+ /** @internal */
15
+ email: string;
16
+ };
8
17
  }
18
+ /** @public */
9
19
  export interface GitLabProject {
20
+ /** @public */
10
21
  id: number;
22
+ /** @public */
11
23
  path_with_namespace: string;
24
+ /** @public */
12
25
  http_url_to_repo: string;
26
+ /** @public */
13
27
  web_url: string;
28
+ /** @internal */
14
29
  default_branch: string;
30
+ /** @public */
15
31
  archived?: boolean;
32
+ /** @internal */
16
33
  permissions?: {
17
- project_access?: { access_level: number } | null;
18
- group_access?: { access_level: number } | null;
34
+ /** @internal */
35
+ project_access?: {
36
+ /** @internal */
37
+ access_level: number;
38
+ } | null;
39
+ /** @internal */
40
+ group_access?: {
41
+ /** @internal */
42
+ access_level: number;
43
+ } | null;
19
44
  };
20
45
  }
46
+ /** @internal */
21
47
  export interface GitLabGroup {
48
+ /** @internal */
22
49
  id: number;
50
+ /** @internal */
23
51
  full_path: string;
24
52
  }
53
+ /** @public */
25
54
  export interface GitLabMergeRequest {
55
+ /** @public */
26
56
  iid: number;
57
+ /** @public */
27
58
  project_id: number;
59
+ /** @public */
28
60
  source_project_id: number;
61
+ /** @public */
29
62
  target_project_id: number;
63
+ /** @public */
30
64
  title: string;
65
+ /** @public */
31
66
  description: string | null;
67
+ /** @public */
32
68
  state: string;
69
+ /** @public */
33
70
  labels: string[];
71
+ /** @public */
34
72
  sha: string;
73
+ /** @public */
35
74
  source_branch: string;
75
+ /** @public */
36
76
  target_branch: string;
77
+ /** @public */
37
78
  web_url: string;
79
+ /** @public */
80
+ has_conflicts?: boolean;
81
+ /** @public */
82
+ merge_status?: string;
83
+ /** @public */
84
+ detailed_merge_status?: string;
85
+ /** @internal */
38
86
  merge_commit_sha?: string | null;
39
- diff_refs?: { base_sha: string; head_sha: string; start_sha: string };
87
+ /** @internal */
88
+ diff_refs?: {
89
+ /** @internal */
90
+ base_sha: string;
91
+ /** @internal */
92
+ head_sha: string;
93
+ /** @internal */
94
+ start_sha: string;
95
+ };
40
96
  }
97
+ /** @public */
41
98
  export interface GitLabCommit {
99
+ /** @public */
42
100
  id: string;
101
+ /** @internal */
43
102
  parent_ids: string[];
103
+ /** @internal */
44
104
  message: string;
105
+ /** @internal */
45
106
  web_url?: string;
46
107
  }
108
+ /** @public */
47
109
  export interface GitLabBranch {
110
+ /** @internal */
48
111
  name: string;
112
+ /** @public */
49
113
  can_push: boolean;
114
+ /** @internal */
50
115
  protected: boolean;
116
+ /** @public */
51
117
  commit: GitLabCommit;
52
118
  }
119
+ /** @public */
53
120
  export interface GitLabPipeline {
121
+ /** @public */
54
122
  id: number;
123
+ /** @public */
55
124
  project_id: number;
125
+ /** @public */
56
126
  sha: string;
127
+ /** @public */
57
128
  ref: string;
129
+ /** @public */
58
130
  status: string;
131
+ /** @internal */
59
132
  source?: string;
133
+ /** @public */
60
134
  web_url: string;
61
135
  }
136
+ /** @public */
62
137
  export interface GitLabJob {
138
+ /** @public */
63
139
  id: number;
140
+ /** @public */
64
141
  name: string;
142
+ /** @internal */
65
143
  status: string;
144
+ /** @public */
66
145
  web_url: string;
146
+ /** @public */
67
147
  failure_reason?: string;
68
148
  }
149
+ /** @public */
69
150
  export interface GitLabDiff {
151
+ /** @public */
70
152
  old_path: string;
153
+ /** @public */
71
154
  new_path: string;
155
+ /** @public */
72
156
  diff: string;
157
+ /** @public */
73
158
  new_file: boolean;
159
+ /** @public */
74
160
  deleted_file: boolean;
161
+ /** @public */
75
162
  renamed_file: boolean;
76
163
  }
164
+ /** @public */
77
165
  export interface GitLabNote {
166
+ /** @internal */
78
167
  id: number;
168
+ /** @public */
79
169
  body: string;
80
170
  }
171
+ /** @public */
81
172
  export interface GitLabNoteReaction {
173
+ /** @internal */
82
174
  id: number;
175
+ /** @internal */
83
176
  name: string;
84
- user: { username: string };
177
+ /** @internal */
178
+ user: {
179
+ /** @internal */
180
+ username: string;
181
+ };
85
182
  }
183
+ /** @public */
86
184
  export interface GitLabFeedback {
185
+ /** @public */
87
186
  id: number;
187
+ /** @public */
88
188
  discussionId: string;
189
+ /** @public */
89
190
  body: string;
191
+ /** @public */
90
192
  author: string;
193
+ /** @public */
91
194
  createdAt: string;
195
+ /** @public */
92
196
  path?: string;
197
+ /** @public */
93
198
  line?: number;
94
199
  }
200
+ /** @internal */
95
201
  export interface GitLabDiscussion {
202
+ /** @internal */
96
203
  id: string;
204
+ /** @internal */
97
205
  notes: (GitLabNote & {
206
+ /** @internal */
98
207
  system: boolean;
208
+ /** @internal */
99
209
  created_at: string;
100
- author: { username: string; bot?: boolean };
210
+ /** @internal */
211
+ author: {
212
+ /** @internal */
213
+ username: string;
214
+ /** @internal */
215
+ bot?: boolean;
216
+ };
217
+ /** @internal */
101
218
  resolved?: boolean;
102
- position?: { new_path?: string; old_path?: string; new_line?: number; old_line?: number };
219
+ /** @internal */
220
+ position?: {
221
+ /** @internal */
222
+ new_path?: string;
223
+ /** @internal */
224
+ old_path?: string;
225
+ /** @internal */
226
+ new_line?: number;
227
+ /** @internal */
228
+ old_line?: number;
229
+ };
103
230
  })[];
104
231
  }
232
+ /** @public */
105
233
  export interface GitLabIdentity {
234
+ /** @public */
106
235
  name: string;
236
+ /** @public */
107
237
  email: string;
238
+ /** @public */
108
239
  username: string;
109
240
  }
241
+ /** @public */
110
242
  export interface GitLabObservation {
243
+ /** @public */
111
244
  mr: GitLabMergeRequest;
245
+ /** @public */
112
246
  pipeline: GitLabPipeline | null;
247
+ /** @public Current target branch tip, not the diff's historical merge base. */
248
+ targetHead?: string;
249
+ }
250
+
251
+ /** @public */
252
+ export function gitLabMergeabilityPending(mr: GitLabMergeRequest): boolean {
253
+ return ["checking", "unchecked", "preparing"].includes(
254
+ mr.detailed_merge_status ?? mr.merge_status ?? "",
255
+ );
256
+ }
257
+
258
+ /** @public Only actionable Git conflicts/rebase requirements, not approvals or CI gates. */
259
+ export function gitLabMergeRepairReason(mr: GitLabMergeRequest): "conflict" | "rebase" | null {
260
+ if (gitLabMergeabilityPending(mr)) return null;
261
+ if (mr.has_conflicts || mr.detailed_merge_status === "conflict") return "conflict";
262
+ return mr.detailed_merge_status === "need_rebase" ? "rebase" : null;
113
263
  }
114
264
 
265
+ /** @internal */
115
266
  export class GitLabError extends Error {
267
+ /** @internal */
116
268
  constructor(
269
+ /** @internal */
117
270
  readonly status: number,
271
+ /** @internal */
118
272
  readonly retryable: boolean,
119
273
  ) {
120
274
  super(
@@ -122,6 +276,7 @@ export class GitLabError extends Error {
122
276
  );
123
277
  }
124
278
  }
279
+ /** @internal */
125
280
  export function parseGitLabProfiles(raw: unknown): Map<string, GitLabProfile> {
126
281
  const profiles = new Map<string, GitLabProfile>();
127
282
  for (const [name, value] of Object.entries(
@@ -159,15 +314,22 @@ export function parseGitLabProfiles(raw: unknown): Map<string, GitLabProfile> {
159
314
  const projectPath = (id: number | string) => `/projects/${encodeURIComponent(id)}`;
160
315
  const mrPath = (id: number, iid: number) => `${projectPath(id)}/merge_requests/${iid}`;
161
316
 
162
- /** GitLab v4 API. Errors deliberately omit response bodies, headers and tokens. */
317
+ /** GitLab v4 API. Errors deliberately omit response bodies, headers and tokens. @public */
163
318
  export class GitLabClient {
319
+ /** @public */
164
320
  readonly baseUrl: string;
165
321
  readonly #profile: GitLabProfile;
166
322
  readonly #fetch: typeof fetch;
167
323
  readonly #sleep: (ms: number) => Promise<unknown>;
324
+ /** @internal */
168
325
  constructor(
169
326
  profile: GitLabProfile,
170
- options: { fetch?: typeof fetch; sleep?: (ms: number) => Promise<unknown> } = {},
327
+ options: {
328
+ /** @internal */
329
+ fetch?: typeof fetch;
330
+ /** @internal */
331
+ sleep?: (ms: number) => Promise<unknown>;
332
+ } = {},
171
333
  ) {
172
334
  if (repositoryHttpsUrl(`${profile.baseUrl}/repository`).origin !== profile.baseUrl)
173
335
  throw new Error("GitLab requires an HTTPS origin baseUrl");
@@ -241,21 +403,26 @@ export class GitLabClient {
241
403
  }
242
404
  throw new Error("GitLab pagination limit exceeded; discovery incomplete");
243
405
  }
406
+ /** @public */
244
407
  getProject(id: number | string, signal?: AbortSignal): Promise<GitLabProject> {
245
408
  return this.request(projectPath(id), signal);
246
409
  }
410
+ /** @internal */
247
411
  listProjects(signal?: AbortSignal): Promise<GitLabProject[]> {
248
412
  return this.pages("/projects?archived=false", signal);
249
413
  }
414
+ /** @internal */
250
415
  getGroup(id: number | string, signal?: AbortSignal): Promise<GitLabGroup> {
251
416
  return this.request(`/groups/${encodeURIComponent(id)}`, signal);
252
417
  }
418
+ /** @internal */
253
419
  listGroupProjects(id: number | string, signal?: AbortSignal): Promise<GitLabProject[]> {
254
420
  return this.pages(
255
421
  `/groups/${encodeURIComponent(id)}/projects?include_subgroups=true&with_shared=false&archived=false`,
256
422
  signal,
257
423
  );
258
424
  }
425
+ /** @public */
259
426
  listMergeRequests(
260
427
  id: number,
261
428
  label: string,
@@ -266,21 +433,26 @@ export class GitLabClient {
266
433
  signal,
267
434
  );
268
435
  }
436
+ /** @internal */
269
437
  getMergeRequest(id: number, iid: number, signal?: AbortSignal): Promise<GitLabMergeRequest> {
270
438
  return this.request(mrPath(id, iid), signal);
271
439
  }
440
+ /** @public */
272
441
  getChanges(id: number, iid: number, signal?: AbortSignal): Promise<GitLabDiff[]> {
273
442
  return this.pages(`${mrPath(id, iid)}/diffs`, signal);
274
443
  }
444
+ /** @public */
275
445
  getBranch(id: number, branch: string, signal?: AbortSignal): Promise<GitLabBranch> {
276
446
  return this.request(
277
447
  `${projectPath(id)}/repository/branches/${encodeURIComponent(branch)}`,
278
448
  signal,
279
449
  );
280
450
  }
451
+ /** @internal */
281
452
  getCommit(id: number, sha: string, signal?: AbortSignal): Promise<GitLabCommit> {
282
453
  return this.request(`${projectPath(id)}/repository/commits/${encodeURIComponent(sha)}`, signal);
283
454
  }
455
+ /** @internal */
284
456
  listMergeRequestPipelines(
285
457
  id: number,
286
458
  iid: number,
@@ -288,6 +460,7 @@ export class GitLabClient {
288
460
  ): Promise<GitLabPipeline[]> {
289
461
  return this.pages(`${mrPath(id, iid)}/pipelines`, signal);
290
462
  }
463
+ /** @internal */
291
464
  listBranchPipelines(
292
465
  id: number,
293
466
  branch: string,
@@ -299,18 +472,22 @@ export class GitLabClient {
299
472
  signal,
300
473
  );
301
474
  }
475
+ /** @internal */
302
476
  getPipeline(id: number, pipeline: number, signal?: AbortSignal): Promise<GitLabPipeline> {
303
477
  return this.request(`${projectPath(id)}/pipelines/${pipeline}`, signal);
304
478
  }
479
+ /** @public */
305
480
  listFailedJobs(id: number, pipeline: number, signal?: AbortSignal): Promise<GitLabJob[]> {
306
481
  return this.pages(
307
482
  `${projectPath(id)}/pipelines/${pipeline}/jobs?scope[]=failed&include_retried=false`,
308
483
  signal,
309
484
  );
310
485
  }
486
+ /** @internal */
311
487
  listNotes(id: number, iid: number, signal?: AbortSignal): Promise<GitLabNote[]> {
312
488
  return this.pages(`${mrPath(id, iid)}/notes`, signal);
313
489
  }
490
+ /** @internal */
314
491
  getDiscussion(
315
492
  id: number,
316
493
  iid: number,
@@ -322,6 +499,7 @@ export class GitLabClient {
322
499
  signal,
323
500
  );
324
501
  }
502
+ /** @internal */
325
503
  replyToDiscussion(
326
504
  id: number,
327
505
  iid: number,
@@ -335,6 +513,7 @@ export class GitLabClient {
335
513
  { body },
336
514
  );
337
515
  }
516
+ /** @internal */
338
517
  listNoteReactions(
339
518
  id: number,
340
519
  iid: number,
@@ -343,6 +522,7 @@ export class GitLabClient {
343
522
  ): Promise<GitLabNoteReaction[]> {
344
523
  return this.pages(`${mrPath(id, iid)}/notes/${noteId}/award_emoji`, signal);
345
524
  }
525
+ /** @internal */
346
526
  addNoteReaction(
347
527
  id: number,
348
528
  iid: number,
@@ -352,6 +532,7 @@ export class GitLabClient {
352
532
  ): Promise<GitLabNoteReaction> {
353
533
  return this.request(`${mrPath(id, iid)}/notes/${noteId}/award_emoji`, signal, { name });
354
534
  }
535
+ /** @public */
355
536
  async listMergeRequestFeedback(
356
537
  id: number,
357
538
  iid: number,
@@ -391,9 +572,11 @@ export class GitLabClient {
391
572
  }
392
573
  return feedback.sort((a, b) => a.id - b.id);
393
574
  }
575
+ /** @internal */
394
576
  addNote(id: number, iid: number, body: string, signal?: AbortSignal): Promise<GitLabNote> {
395
577
  return this.request(`${mrPath(id, iid)}/notes`, signal, { body });
396
578
  }
579
+ /** @public */
397
580
  async resolveGitIdentity(signal?: AbortSignal): Promise<GitLabIdentity> {
398
581
  const user = await this.request<{
399
582
  name?: string;
@@ -409,12 +592,18 @@ export class GitLabClient {
409
592
  );
410
593
  return { name, email, username: user.username };
411
594
  }
595
+ /** @public */
412
596
  async getJobTrace(
413
597
  id: number,
414
598
  job: number,
415
599
  maxBytes = 65_536,
416
600
  signal?: AbortSignal,
417
- ): Promise<{ text: string; truncated: boolean }> {
601
+ ): Promise<{
602
+ /** @internal */
603
+ text: string;
604
+ /** @internal */
605
+ truncated: boolean;
606
+ }> {
418
607
  const limit = Math.min(262_144, Math.max(1, Math.floor(maxBytes) || 65_536));
419
608
  const response = await this.response(`${projectPath(id)}/jobs/${job}/trace`, signal);
420
609
  const reader = response.body?.getReader();
@@ -440,9 +629,35 @@ export class GitLabClient {
440
629
  return { text: Buffer.concat(chunks).toString("utf8"), truncated };
441
630
  }
442
631
  }
443
- export type GitLabClientLike = Pick<GitLabClient, keyof GitLabClient>;
632
+ /** @public */
633
+ export type GitLabClientLike = Pick<
634
+ GitLabClient,
635
+ | "addNote"
636
+ | "addNoteReaction"
637
+ | "baseUrl"
638
+ | "getBranch"
639
+ | "getChanges"
640
+ | "getCommit"
641
+ | "getDiscussion"
642
+ | "getGroup"
643
+ | "getJobTrace"
644
+ | "getMergeRequest"
645
+ | "getPipeline"
646
+ | "getProject"
647
+ | "listBranchPipelines"
648
+ | "listFailedJobs"
649
+ | "listGroupProjects"
650
+ | "listMergeRequestFeedback"
651
+ | "listMergeRequestPipelines"
652
+ | "listMergeRequests"
653
+ | "listNoteReactions"
654
+ | "listNotes"
655
+ | "listProjects"
656
+ | "replyToDiscussion"
657
+ | "resolveGitIdentity"
658
+ >;
444
659
 
445
- /** A pending current pipeline supersedes every older result. Synthetic merges must contain this source head. */
660
+ /** A pending current pipeline supersedes every older result. Synthetic merges must contain this source head. @public */
446
661
  export async function observeMergeRequest(
447
662
  client: GitLabClientLike,
448
663
  projectId: number,
@@ -451,6 +666,8 @@ export async function observeMergeRequest(
451
666
  ): Promise<GitLabObservation> {
452
667
  const mr = await client.getMergeRequest(projectId, iid, signal);
453
668
  if (mr.state !== "opened") return { mr, pipeline: null };
669
+ const targetHead = (await client.getBranch(mr.target_project_id, mr.target_branch, signal)).commit
670
+ .id;
454
671
  const associated = (await client.listMergeRequestPipelines(projectId, iid, signal)).sort(
455
672
  (a, b) => b.id - a.id,
456
673
  );
@@ -465,7 +682,8 @@ export async function observeMergeRequest(
465
682
  const commit = await client.getCommit(id, candidate.sha, signal);
466
683
  matches = commit.parent_ids.includes(mr.sha);
467
684
  }
468
- if (matches) return { mr, pipeline: await client.getPipeline(id, candidate.id, signal) };
685
+ if (matches)
686
+ return { mr, targetHead, pipeline: await client.getPipeline(id, candidate.id, signal) };
469
687
  }
470
688
  const candidates = await client.listBranchPipelines(
471
689
  mr.source_project_id,
@@ -478,6 +696,7 @@ export async function observeMergeRequest(
478
696
  .sort((a, b) => b.id - a.id)[0];
479
697
  return {
480
698
  mr,
699
+ targetHead,
481
700
  pipeline: latest ? await client.getPipeline(mr.source_project_id, latest.id, signal) : null,
482
701
  };
483
702
  }
package/src/external.ts CHANGED
@@ -6,18 +6,33 @@ import {
6
6
  import { emptyPollResult, parseDurationMs } from "@leitwerk-dev/watcher-utils";
7
7
  import type { GitLabIntegration } from "./capability.js";
8
8
  import { type GitLabFeedback, type GitLabObservation, observeMergeRequest } from "./client.js";
9
+ /** @internal */
9
10
  export const GITLAB_MR_KIND = "@leitwerk-dev/gitlab.merge-request";
11
+ /** @public */
10
12
  export interface GitLabSourceConfig {
13
+ /** @public */
11
14
  profile: string;
15
+ /** @public */
12
16
  projectId: number;
17
+ /** @public */
13
18
  iid: number;
19
+ /** @public */
14
20
  pollInterval?: string;
21
+ /** @public */
15
22
  afterKey?: string;
16
- /** Optional timer also wakes retry work when GitLab facts have not changed. */
23
+ /** Optional timer also wakes retry work when GitLab facts have not changed. @public */
17
24
  wakeAt?: number;
18
- feedback?: { afterId: number; since?: string; quietPeriodMs: number };
25
+ /** @public */
26
+ feedback?: {
27
+ /** @public */
28
+ afterId: number;
29
+ /** @public */
30
+ since?: string;
31
+ /** @public */
32
+ quietPeriodMs: number;
33
+ };
19
34
  }
20
- /** A trailing quiet period survives restarts because it uses the newest unseen note's timestamp. */
35
+ /** A trailing quiet period survives restarts because it uses the newest unseen note's timestamp. @public */
21
36
  export function pendingGitLabFeedback(
22
37
  items: GitLabFeedback[],
23
38
  afterId: number,
@@ -26,6 +41,7 @@ export function pendingGitLabFeedback(
26
41
  const start = since ? Date.parse(since) : 0;
27
42
  return items.filter((item) => item.id > afterId && Date.parse(item.createdAt) >= start);
28
43
  }
44
+ /** @public */
29
45
  export function gitLabFeedbackReadyAt(
30
46
  items: GitLabFeedback[],
31
47
  quietPeriodMs: number,
@@ -34,7 +50,8 @@ export function gitLabFeedbackReadyAt(
34
50
  ? Math.max(...items.map((item) => Date.parse(item.createdAt))) + quietPeriodMs
35
51
  : null;
36
52
  }
37
- export const observationKey = ({ mr, pipeline }: GitLabObservation): string =>
53
+ /** @public */
54
+ export const observationKey = ({ mr, pipeline, targetHead }: GitLabObservation): string =>
38
55
  JSON.stringify([
39
56
  mr.state,
40
57
  mr.sha,
@@ -42,25 +59,44 @@ export const observationKey = ({ mr, pipeline }: GitLabObservation): string =>
42
59
  pipeline?.project_id,
43
60
  pipeline?.id,
44
61
  pipeline?.status,
62
+ mr.source_project_id,
63
+ mr.source_branch,
64
+ mr.target_project_id,
65
+ mr.target_branch,
66
+ targetHead,
67
+ mr.has_conflicts,
68
+ mr.merge_status,
69
+ mr.detailed_merge_status,
45
70
  ]);
71
+ /** @public */
46
72
  export const gitlabExternal = {
73
+ /** @public */
47
74
  mergeRequest<P, S>(
48
- resolve: (ctx: { params: P; state: S }) => GitLabSourceConfig,
75
+ resolve: (ctx: {
76
+ /** @public */
77
+ params: P;
78
+ /** @public */
79
+ state: S;
80
+ }) => GitLabSourceConfig,
49
81
  ): ExternalActionSource<P, S, GitLabObservation> {
50
82
  return {
51
83
  kind: GITLAB_MR_KIND,
52
84
  label: "GitLab merge request",
53
- description: "Observe MR state, current source head and revision-correlated CI",
85
+ description: "Observe MR state, source/target heads, mergeability and revision-correlated CI",
54
86
  config: {},
55
87
  inputMode: "none",
56
88
  resolve,
57
89
  };
58
90
  },
59
91
  };
92
+ /** @internal */
60
93
  export function createGitLabProvider(
61
94
  deps: CoreServerSetupDeps,
62
95
  integration: GitLabIntegration,
63
- options: { now?: () => number } = {},
96
+ options: {
97
+ /** @internal */
98
+ now?: () => number;
99
+ } = {},
64
100
  ) {
65
101
  const schedule = new Map<string, { at: number; failures: number }>();
66
102
  const now = options.now ?? Date.now;
package/src/index.ts CHANGED
@@ -1,25 +1,16 @@
1
- import type { ExternalWriteLogRepoLike } from "@leitwerk-dev/external-writes";
2
- import {
3
- coreHostCapabilities,
4
- type LeitwerkExtensionModule,
5
- type ServerExtensionAPI,
6
- } from "@leitwerk-dev/process-sdk";
7
- import { type GitLabIntegration, gitlabIntegration } from "./capability.js";
1
+ import type { LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
2
+ import { coreHostCapabilities } from "@leitwerk-dev/process-sdk";
8
3
  import { GitLabClient, parseGitLabProfiles } from "./client.js";
9
- import { createGitLabProvider } from "./external.js";
10
- import { registerGitLabTools } from "./tools.js";
11
- export const manifest = { id: "gitlab", version: "0.1.9" } as const;
12
- export function setupGitLabIntegration(
13
- api: ServerExtensionAPI,
14
- integration: GitLabIntegration,
15
- options: { now?: () => number } = {},
16
- ) {
17
- api.provide(gitlabIntegration, integration);
18
- const deps = api.get(coreHostCapabilities.serverSetup);
19
- if (!deps || Array.isArray(deps)) return;
20
- registerGitLabTools(api, integration, deps.externalWrites as ExternalWriteLogRepoLike);
21
- return createGitLabProvider(deps, integration, options);
22
- }
4
+ import { setupGitLabIntegration } from "./setup.js";
5
+
6
+ /** @internal */
7
+ const manifest = {
8
+ /** @internal */
9
+ id: "gitlab",
10
+ /** @internal */
11
+ version: "0.1.9",
12
+ } as const;
13
+ /** @public */
23
14
  const extension: LeitwerkExtensionModule = {
24
15
  manifest,
25
16
  setupServer(api, config) {
@@ -47,8 +38,30 @@ const extension: LeitwerkExtensionModule = {
47
38
  },
48
39
  };
49
40
  export default extension;
50
- export * from "./capability.js";
51
- export * from "./client.js";
52
- export * from "./external.js";
53
- export * from "./selection.js";
54
- export * from "./tools.js";
41
+ export type { GitLabIntegration } from "./capability.js";
42
+ export {
43
+ gitlabIntegration,
44
+ gitlabRepositoryCredentials,
45
+ } from "./capability.js";
46
+ export type {
47
+ GitLabDiff,
48
+ GitLabFeedback,
49
+ GitLabIdentity,
50
+ GitLabJob,
51
+ GitLabMergeRequest,
52
+ GitLabObservation,
53
+ GitLabProject,
54
+ } from "./client.js";
55
+ export { observeMergeRequest } from "./client.js";
56
+ export {
57
+ gitLabFeedbackReadyAt,
58
+ gitlabExternal,
59
+ observationKey,
60
+ pendingGitLabFeedback,
61
+ } from "./external.js";
62
+ export type { GitLabSelection } from "./selection.js";
63
+ export {
64
+ parseGitLabSelection,
65
+ selectGitLabProjects,
66
+ } from "./selection.js";
67
+ export { ensureGitLabSeenReaction, resolveGitLabBinding } from "./tools.js";