@leitwerk-dev/gitlab 0.2.0 → 0.3.0

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.
Files changed (43) hide show
  1. package/README.md +45 -5
  2. package/dist/capability.d.ts +5 -1
  3. package/dist/capability.d.ts.map +1 -1
  4. package/dist/chunk-H4JCQNDY.js +1162 -0
  5. package/dist/chunk-H4JCQNDY.js.map +1 -0
  6. package/dist/client.d.ts +230 -3
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/delivery-tools.d.ts +4 -0
  9. package/dist/delivery-tools.d.ts.map +1 -0
  10. package/dist/external.d.ts +80 -5
  11. package/dist/external.d.ts.map +1 -1
  12. package/dist/index.d.ts +13 -14
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +40 -20
  15. package/dist/index.js.map +1 -1
  16. package/dist/issue-watcher.d.ts +42 -0
  17. package/dist/issue-watcher.d.ts.map +1 -0
  18. package/dist/preflight.d.ts +10 -0
  19. package/dist/preflight.d.ts.map +1 -0
  20. package/dist/selection.d.ts +11 -1
  21. package/dist/selection.d.ts.map +1 -1
  22. package/dist/setup.d.ts +11 -0
  23. package/dist/setup.d.ts.map +1 -0
  24. package/dist/testing.d.ts +43 -4
  25. package/dist/testing.d.ts.map +1 -1
  26. package/dist/testing.js +139 -1
  27. package/dist/testing.js.map +1 -1
  28. package/dist/tools.d.ts +35 -4
  29. package/dist/tools.d.ts.map +1 -1
  30. package/package.json +7 -6
  31. package/src/capability.ts +5 -1
  32. package/src/client.ts +392 -20
  33. package/src/delivery-tools.ts +226 -0
  34. package/src/external.ts +200 -8
  35. package/src/index.ts +42 -26
  36. package/src/issue-watcher.ts +152 -0
  37. package/src/preflight.ts +70 -0
  38. package/src/selection.ts +19 -3
  39. package/src/setup.ts +22 -0
  40. package/src/testing.ts +161 -7
  41. package/src/tools.ts +106 -54
  42. package/dist/chunk-5GBBPAG5.js +0 -656
  43. package/dist/chunk-5GBBPAG5.js.map +0 -1
@@ -0,0 +1,226 @@
1
+ import { createHash } from "node:crypto";
2
+ import {
3
+ numberArg,
4
+ type ProcessProjectRepoLike,
5
+ projectParameters,
6
+ type ServerExtensionAPI,
7
+ stringArg,
8
+ } from "@leitwerk-dev/process-sdk";
9
+ import type { GitLabIntegration } from "./capability.js";
10
+ import {
11
+ ensureGitLabSeenReaction,
12
+ resolveGitLabBinding,
13
+ resolveGitLabRepositoryBinding,
14
+ } from "./tools.js";
15
+
16
+ export function registerGitLabDeliveryTools(
17
+ api: ServerExtensionAPI,
18
+ integration: GitLabIntegration,
19
+ projects: ProcessProjectRepoLike,
20
+ ) {
21
+ api.tool<Record<string, unknown>>({
22
+ name: "gitlab_ensure_merge_request",
23
+ description: "Create or reconcile and pin the process merge request",
24
+ parameters: projectParameters({ title: { type: "string" }, body: { type: "string" } }, [
25
+ "title",
26
+ "body",
27
+ ]),
28
+ async execute(ctx, args) {
29
+ const binding = resolveGitLabRepositoryBinding(ctx);
30
+ const client = integration.client(binding.profile);
31
+ const project = projects.getByInstanceAndKey(ctx.process.id, ctx.project?.key ?? "");
32
+ if (!project?.workBranch || project.workBranch === project.baseBranch)
33
+ throw new Error("A process feature branch is required");
34
+ const workBranch = project.workBranch;
35
+ const identity = {
36
+ writeType: "gitlab.ensure_mr",
37
+ dedupKey: `${binding.projectId}:${project.key}:${workBranch}:${project.baseBranch}`,
38
+ };
39
+ const marker = `<!-- leitwerk:gitlab:merge-request:${ctx.process.id}:${project.key} -->`;
40
+ const find = async () =>
41
+ (
42
+ await client.listBranchMergeRequests(
43
+ binding.projectId,
44
+ workBranch,
45
+ project.baseBranch,
46
+ ctx.signal,
47
+ )
48
+ ).find(
49
+ (mr) =>
50
+ mr.source_project_id === binding.projectId &&
51
+ mr.target_project_id === binding.projectId &&
52
+ mr.source_branch === project.workBranch &&
53
+ mr.target_branch === project.baseBranch &&
54
+ mr.description?.includes(marker),
55
+ );
56
+ const request = await ctx.externalWrites.ensure(identity, {
57
+ reconcile: async () => (await find()) ?? null,
58
+ execute: () =>
59
+ client.createMergeRequest(
60
+ binding.projectId,
61
+ {
62
+ title: stringArg(args, "title"),
63
+ description: `${stringArg(args, "body")}\n\n${marker}`,
64
+ source_branch: workBranch,
65
+ target_branch: project.baseBranch,
66
+ },
67
+ ctx.signal,
68
+ ),
69
+ toMetadata: (mr) => ({ iid: mr.iid, url: mr.web_url }),
70
+ });
71
+ const latest = projects.getByInstanceAndKey(ctx.process.id, project.key);
72
+ if (
73
+ !latest ||
74
+ latest.workBranch !== project.workBranch ||
75
+ latest.baseBranch !== project.baseBranch
76
+ )
77
+ throw new Error("Process repository binding changed during publication");
78
+ const metadata = latest.metadata ?? {};
79
+ const previous = metadata.gitlab as { iid?: number };
80
+ if (previous.iid && previous.iid !== request.iid)
81
+ throw new Error("Process is already bound to another merge request");
82
+ projects.update(latest.id, {
83
+ metadata: { ...metadata, gitlab: { ...previous, ...binding, iid: request.iid } },
84
+ externalId: String(request.iid),
85
+ externalUrl: request.web_url,
86
+ });
87
+ return request;
88
+ },
89
+ });
90
+ api.tool({
91
+ name: "gitlab_list_merge_request_feedback",
92
+ description: "Read human discussion feedback on the bound merge request",
93
+ parameters: projectParameters(),
94
+ async execute(ctx) {
95
+ const b = resolveGitLabBinding(ctx);
96
+ return integration.client(b.profile).listMergeRequestFeedback(b.projectId, b.iid, ctx.signal);
97
+ },
98
+ });
99
+ api.tool<Record<string, unknown>>({
100
+ name: "gitlab_acknowledge_feedback",
101
+ description: "Reconcile the bot's seen reaction on bound merge request feedback",
102
+ parameters: projectParameters({ noteId: { type: "integer" } }, ["noteId"]),
103
+ async execute(ctx, args) {
104
+ const b = resolveGitLabBinding(ctx);
105
+ const client = integration.client(b.profile);
106
+ const noteId = numberArg(args, "noteId");
107
+ if (
108
+ !(await client.listMergeRequestFeedback(b.projectId, b.iid, ctx.signal)).some(
109
+ (n) => n.id === noteId,
110
+ )
111
+ )
112
+ throw new Error("Note is not actionable feedback on the bound merge request");
113
+ await ensureGitLabSeenReaction({
114
+ client,
115
+ writes: ctx.externalWrites,
116
+ instanceId: ctx.process.id,
117
+ projectId: b.projectId,
118
+ iid: b.iid,
119
+ noteId,
120
+ signal: ctx.signal,
121
+ });
122
+ return { ok: true };
123
+ },
124
+ });
125
+ for (const name of [
126
+ "gitlab_get_issue",
127
+ "gitlab_add_issue_comment",
128
+ "gitlab_finalize_source_issue",
129
+ ] as const) {
130
+ api.tool<Record<string, unknown>>({
131
+ name,
132
+ description: "Read or reconcile the process source issue",
133
+ parameters: projectParameters(
134
+ {
135
+ issueNumber: { type: "integer" },
136
+ body: { type: "string" },
137
+ writeKey: { type: "string" },
138
+ merged: { type: "boolean" },
139
+ triggerLabel: { type: "string" },
140
+ doneLabel: { type: "string" },
141
+ },
142
+ ["issueNumber"],
143
+ ),
144
+ async execute(ctx, args) {
145
+ const b = resolveGitLabRepositoryBinding(ctx);
146
+ const client = integration.client(b.profile);
147
+ const iid = numberArg(args, "issueNumber");
148
+ const bound = (ctx.project?.metadata?.gitlab as { issueIid?: number })?.issueIid;
149
+ if (bound !== iid) throw new Error("Issue does not match the process source issue");
150
+ if (name === "gitlab_get_issue") return client.getIssue(b.projectId, iid, ctx.signal);
151
+ const key = stringArg(args, "writeKey");
152
+ const digest = createHash("sha256")
153
+ .update(JSON.stringify([client.baseUrl, b.projectId, iid, ctx.process.id, key]))
154
+ .digest("hex");
155
+ if (name === "gitlab_add_issue_comment") {
156
+ const marker = `<!-- leitwerk:gitlab:issue:${digest} -->`;
157
+ const note = await ctx.externalWrites.ensure(
158
+ { writeType: name, dedupKey: digest },
159
+ {
160
+ reconcile: async () =>
161
+ (await client.listIssueNotes(b.projectId, iid, ctx.signal)).find((n) =>
162
+ n.body.includes(marker),
163
+ ) ?? null,
164
+ execute: () =>
165
+ client.addIssueNote(
166
+ b.projectId,
167
+ iid,
168
+ `${stringArg(args, "body")}\n\n${marker}`,
169
+ ctx.signal,
170
+ ),
171
+ toMetadata: (note) => ({ noteId: note.id }),
172
+ },
173
+ );
174
+ return { noteId: note.id };
175
+ }
176
+ const merged = args.merged === true;
177
+ const trigger = stringArg(args, "triggerLabel");
178
+ const done = stringArg(args, "doneLabel");
179
+ if (merged) {
180
+ await ctx.externalWrites.ensure(
181
+ {
182
+ writeType: "gitlab.ensure_label",
183
+ dedupKey: JSON.stringify([client.baseUrl, b.projectId, done]),
184
+ },
185
+ {
186
+ reconcile: async () =>
187
+ (await client.listLabels(b.projectId, ctx.signal)).find((l) => l.name === done) ??
188
+ null,
189
+ execute: () => client.createLabel(b.projectId, done, ctx.signal),
190
+ toMetadata: (label) => ({ name: label.name }),
191
+ },
192
+ );
193
+ }
194
+ await ctx.externalWrites.ensure(
195
+ { writeType: name, dedupKey: digest },
196
+ {
197
+ reconcile: async () => {
198
+ const fresh = await client.getIssue(b.projectId, iid, ctx.signal);
199
+ return !fresh.labels.includes(trigger) &&
200
+ (!merged || (fresh.state === "closed" && fresh.labels.includes(done)))
201
+ ? fresh
202
+ : null;
203
+ },
204
+ execute: async () => {
205
+ const issue = await client.getIssue(b.projectId, iid, ctx.signal);
206
+ const labels = [
207
+ ...new Set([
208
+ ...issue.labels.filter((l) => l !== trigger),
209
+ ...(merged ? [done] : []),
210
+ ]),
211
+ ];
212
+ return client.updateIssue(
213
+ b.projectId,
214
+ iid,
215
+ { labels: labels.join(","), ...(merged ? { state_event: "close" as const } : {}) },
216
+ ctx.signal,
217
+ );
218
+ },
219
+ toMetadata: () => ({ issueIid: iid, merged }),
220
+ },
221
+ );
222
+ return { issueIid: iid, merged };
223
+ },
224
+ });
225
+ }
226
+ }
package/src/external.ts CHANGED
@@ -2,22 +2,84 @@ import {
2
2
  type CoreServerSetupDeps,
3
3
  createExternalSourcePollReporter,
4
4
  type ExternalActionSource,
5
+ type ExternalSourceArmingLike,
5
6
  } from "@leitwerk-dev/process-sdk";
7
+ import { type ConflictEvidence, conflictKey } from "@leitwerk-dev/repository-rebase";
6
8
  import { emptyPollResult, parseDurationMs } from "@leitwerk-dev/watcher-utils";
7
9
  import type { GitLabIntegration } from "./capability.js";
8
10
  import { type GitLabFeedback, type GitLabObservation, observeMergeRequest } from "./client.js";
11
+ import { createGitLabIssueDiscovery } from "./issue-watcher.js";
12
+ /** @public */
13
+ export interface GitLabDeliveryObservation extends GitLabObservation {
14
+ /** @public */
15
+ observationKey?: string;
16
+ /** @public */
17
+ feedback?: GitLabFeedback[];
18
+ /** @public */
19
+ conflict?: ConflictEvidence;
20
+ }
21
+ /** @public */
22
+ export const GITLAB_ISSUE_CANCELLED_KIND = "@leitwerk-dev/gitlab.issue-cancelled";
23
+ /** @public */
24
+ export interface GitLabIssueCancelledConfig {
25
+ /** @public */
26
+ profile: string;
27
+ /** @public */
28
+ projectId: number;
29
+ /** @public */
30
+ issueIid: number;
31
+ /** @public */
32
+ iid: number;
33
+ /** @public */
34
+ triggerLabel: string;
35
+ /** @public */
36
+ pollInterval?: string;
37
+ }
38
+ /** @internal */
9
39
  export const GITLAB_MR_KIND = "@leitwerk-dev/gitlab.merge-request";
40
+ /** @public */
10
41
  export interface GitLabSourceConfig {
42
+ /** @public */
11
43
  profile: string;
44
+ /** @public */
12
45
  projectId: number;
46
+ /** @public */
13
47
  iid: number;
48
+ /** @public */
14
49
  pollInterval?: string;
50
+ /** @public */
15
51
  afterKey?: string;
16
52
  /** Optional timer also wakes retry work when GitLab facts have not changed. */
53
+ /** @public */
17
54
  wakeAt?: number;
18
- feedback?: { afterId: number; since?: string; quietPeriodMs: number };
55
+ /** @public */
56
+ delivery?: {
57
+ /** @public */
58
+ headSha: string;
59
+ /** @public */
60
+ owner: string;
61
+ /** @public */
62
+ repo: string;
63
+ /** @public */
64
+ headBranch: string;
65
+ /** @public */
66
+ baseBranch: string;
67
+ /** @public */
68
+ lastConflictKey?: string | null;
69
+ };
70
+ /** @public */
71
+ /** @public */
72
+ feedback?: {
73
+ /** @public */
74
+ afterId: number;
75
+ /** @public */
76
+ since?: string;
77
+ /** @public */
78
+ quietPeriodMs: number;
79
+ };
19
80
  }
20
81
  /** A trailing quiet period survives restarts because it uses the newest unseen note's timestamp. */
82
+ /** @public */
21
83
  export function pendingGitLabFeedback(
22
84
  items: GitLabFeedback[],
23
85
  afterId: number,
@@ -26,6 +88,7 @@ export function pendingGitLabFeedback(
26
88
  const start = since ? Date.parse(since) : 0;
27
89
  return items.filter((item) => item.id > afterId && Date.parse(item.createdAt) >= start);
28
90
  }
91
+ /** @public */
29
92
  export function gitLabFeedbackReadyAt(
30
93
  items: GitLabFeedback[],
31
94
  quietPeriodMs: number,
@@ -34,7 +97,8 @@ export function gitLabFeedbackReadyAt(
34
97
  ? Math.max(...items.map((item) => Date.parse(item.createdAt))) + quietPeriodMs
35
98
  : null;
36
99
  }
37
- export const observationKey = ({ mr, pipeline }: GitLabObservation): string =>
100
+ /** @public */
101
+ export const observationKey = ({ mr, pipeline, targetHead }: GitLabObservation): string =>
38
102
  JSON.stringify([
39
103
  mr.state,
40
104
  mr.sha,
@@ -42,11 +106,47 @@ export const observationKey = ({ mr, pipeline }: GitLabObservation): string =>
42
106
  pipeline?.project_id,
43
107
  pipeline?.id,
44
108
  pipeline?.status,
109
+ mr.source_project_id,
110
+ mr.source_branch,
111
+ mr.target_project_id,
112
+ mr.target_branch,
113
+ targetHead,
114
+ mr.has_conflicts,
115
+ mr.merge_status,
116
+ mr.detailed_merge_status,
45
117
  ]);
118
+ /** @public */
46
119
  export const gitlabExternal = {
120
+ /** @public */
121
+ issueCancelled<P, S>(
122
+ /** @public */
123
+ /** @public */
124
+ resolve: (ctx: {
125
+ /** @public */
126
+ params: P;
127
+ /** @public */
128
+ state: S;
129
+ }) => GitLabIssueCancelledConfig,
130
+ ): ExternalActionSource<P, S, unknown> {
131
+ return {
132
+ kind: GITLAB_ISSUE_CANCELLED_KIND,
133
+ label: "GitLab source issue cancelled",
134
+ config: {},
135
+ inputMode: "none",
136
+ resolve,
137
+ };
138
+ },
139
+ /** @public */
47
140
  mergeRequest<P, S>(
48
- resolve: (ctx: { params: P; state: S }) => GitLabSourceConfig,
49
- ): ExternalActionSource<P, S, GitLabObservation> {
141
+ /** @public */
142
+ /** @public */
143
+ resolve: (ctx: {
144
+ /** @public */
145
+ params: P;
146
+ /** @public */
147
+ state: S;
148
+ }) => GitLabSourceConfig,
149
+ ): ExternalActionSource<P, S, GitLabDeliveryObservation> {
50
150
  return {
51
151
  kind: GITLAB_MR_KIND,
52
152
  label: "GitLab merge request",
@@ -57,13 +157,19 @@ export const gitlabExternal = {
57
157
  };
58
158
  },
59
159
  };
160
+ /** @internal */
60
161
  export function createGitLabProvider(
61
162
  deps: CoreServerSetupDeps,
62
163
  integration: GitLabIntegration,
63
- options: { now?: () => number } = {},
164
+ /** @public */
165
+ /** @public */
166
+ options: {
167
+ /** @internal */ now?: () => number;
168
+ } = {},
64
169
  ) {
65
170
  const schedule = new Map<string, { at: number; failures: number }>();
66
171
  const now = options.now ?? Date.now;
172
+ const discover = createGitLabIssueDiscovery(deps, integration, now);
67
173
  return deps.polling.create({
68
174
  id: "gitlab",
69
175
  pollInterval: () => "5s",
@@ -71,7 +177,27 @@ export function createGitLabProvider(
71
177
  defaultIntervalMs: 5000,
72
178
  async pollOnce() {
73
179
  const result = emptyPollResult();
74
- const report = createExternalSourcePollReporter(deps.externalSources, result);
180
+ try {
181
+ await discover(result);
182
+ } catch (error) {
183
+ result.errors.push(error instanceof Error ? error.message : "GitLab discovery failed");
184
+ }
185
+ const reporter = createExternalSourcePollReporter(deps.externalSources, result, {
186
+ forwardGeneration: true,
187
+ });
188
+ const current = (armed: ExternalSourceArmingLike) =>
189
+ [GITLAB_MR_KIND, GITLAB_ISSUE_CANCELLED_KIND].some((kind) =>
190
+ reporter.isCurrent(kind, armed),
191
+ );
192
+ const report = {
193
+ ...reporter,
194
+ fire(armed: ExternalSourceArmingLike, event: Record<string, unknown>, mergeKey: string) {
195
+ return current(armed) ? reporter.fire(armed, event, mergeKey) : Promise.resolve(false);
196
+ },
197
+ observe(armed: ExternalSourceArmingLike, input: Parameters<typeof reporter.observe>[1]) {
198
+ if (current(armed)) return reporter.observe(armed, input);
199
+ },
200
+ };
75
201
  await report.poll(GITLAB_MR_KIND, async (armed) => {
76
202
  const c = armed.resolved as unknown as GitLabSourceConfig;
77
203
  if (
@@ -90,7 +216,40 @@ export function createGitLabProvider(
90
216
  c.projectId,
91
217
  c.iid,
92
218
  );
93
- const observedKey = observationKey(observation);
219
+ let conflict: ConflictEvidence | undefined;
220
+ const client = integration.client(c.profile);
221
+ if (
222
+ c.delivery &&
223
+ observation.mr.state === "opened" &&
224
+ observation.mr.sha === c.delivery.headSha &&
225
+ (observation.mr.has_conflicts === true ||
226
+ observation.mr.detailed_merge_status === "conflict")
227
+ ) {
228
+ const mr = observation.mr;
229
+ const d = c.delivery;
230
+ if (
231
+ mr.source_project_id !== c.projectId ||
232
+ mr.target_project_id !== c.projectId ||
233
+ mr.source_branch !== d.headBranch ||
234
+ mr.target_branch !== d.baseBranch
235
+ )
236
+ throw new Error("GitLab merge request branches changed");
237
+ const base = await client.getBranch(c.projectId, d.baseBranch);
238
+ const evidence: ConflictEvidence = {
239
+ owner: d.owner,
240
+ repo: d.repo,
241
+ prNumber: c.iid,
242
+ headBranch: d.headBranch,
243
+ baseBranch: d.baseBranch,
244
+ headSha: mr.sha,
245
+ baseSha: base.commit.id,
246
+ url: mr.web_url,
247
+ };
248
+ if (conflictKey(evidence) !== d.lastConflictKey) conflict = evidence;
249
+ }
250
+ const observedKey =
251
+ observationKey(observation) +
252
+ (c.delivery ? `:${conflict ? conflictKey(conflict) : ""}` : "");
94
253
  const feedback =
95
254
  c.feedback && observation.mr.state === "opened"
96
255
  ? pendingGitLabFeedback(
@@ -104,6 +263,10 @@ export function createGitLabProvider(
104
263
  c.feedback?.quietPeriodMs ?? 120_000,
105
264
  );
106
265
  const feedbackReady = feedbackReadyAt !== null && feedbackReadyAt <= now();
266
+ if (c.delivery) {
267
+ const fresh = await client.getMergeRequest(c.projectId, c.iid);
268
+ if (fresh.sha !== observation.mr.sha || fresh.state !== observation.mr.state) return;
269
+ }
107
270
  await report.observe(armed, {
108
271
  observation: {
109
272
  summary: `${observation.mr.state} · ${observation.pipeline?.status ?? "no current pipeline"}`,
@@ -119,7 +282,16 @@ export function createGitLabProvider(
119
282
  )
120
283
  await report.fire(
121
284
  armed,
122
- { ...observation },
285
+ {
286
+ ...observation,
287
+ ...(c.delivery
288
+ ? {
289
+ observationKey: observedKey,
290
+ feedback: feedbackReady ? feedback : [],
291
+ ...(conflict ? { conflict } : {}),
292
+ }
293
+ : {}),
294
+ },
123
295
  `${observedKey}:${c.wakeAt ?? ""}:${feedbackReady ? feedback.map((item) => item.id).join(",") : ""}`,
124
296
  );
125
297
  schedule.set(key, {
@@ -138,6 +310,26 @@ export function createGitLabProvider(
138
310
  throw error;
139
311
  }
140
312
  });
313
+ await report.poll(GITLAB_ISSUE_CANCELLED_KIND, async (armed) => {
314
+ const c = armed.resolved as unknown as GitLabIssueCancelledConfig;
315
+ const key = `${armed.instanceId}:${armed.id}:${armed.generation ?? ""}`;
316
+ if ((schedule.get(key)?.at ?? 0) > now()) return;
317
+ const client = integration.client(c.profile);
318
+ const issue = await client.getIssue(c.projectId, c.issueIid);
319
+ if (issue.state !== "opened" || !issue.labels.includes(c.triggerLabel)) {
320
+ const mr = await client.getMergeRequest(c.projectId, c.iid);
321
+ if (mr.state !== "opened") return;
322
+ await report.fire(
323
+ armed,
324
+ { issue },
325
+ `${issue.iid}:${issue.state}:${issue.labels.includes(c.triggerLabel)}`,
326
+ );
327
+ }
328
+ schedule.set(key, {
329
+ at: now() + parseDurationMs(c.pollInterval ?? "30s", 30000),
330
+ failures: 0,
331
+ });
332
+ });
141
333
  return result;
142
334
  },
143
335
  });
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,33 @@ 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 type { GitLabDeliveryObservation } from "./external.js";
57
+ export {
58
+ gitLabFeedbackReadyAt,
59
+ gitlabExternal,
60
+ observationKey,
61
+ pendingGitLabFeedback,
62
+ } from "./external.js";
63
+ export type { GitLabIssueWatcherEvent } from "./issue-watcher.js";
64
+ export { gitlabIssueExternalId, gitlabIssueWatcherSource } from "./issue-watcher.js";
65
+ export type { GitLabSelection } from "./selection.js";
66
+ export {
67
+ parseGitLabSelection,
68
+ selectGitLabProjects,
69
+ } from "./selection.js";
70
+ export { ensureGitLabSeenReaction, resolveGitLabBinding } from "./tools.js";