@leitwerk-dev/gitlab 0.4.0 → 0.4.2

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/dist/testing.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  GitLabError,
4
4
  createGitLabMaintenance,
5
5
  setupGitLabIntegration
6
- } from "./chunk-YPCOVBQS.js";
6
+ } from "./chunk-KW4UOHAM.js";
7
7
 
8
8
  // src/testing.ts
9
9
  import { execFileSync } from "child_process";
@@ -35,6 +35,8 @@ var LocalGitLabAdapter = class {
35
35
  /** @public */
36
36
  loseNextLabelResponse = false;
37
37
  /** @public */
38
+ loseNextApprovalResponse = false;
39
+ /** @public */
38
40
  save() {
39
41
  writeFileSync(path.join(this.root, "gitlab.json"), JSON.stringify(this.state), { mode: 384 });
40
42
  }
@@ -294,9 +296,40 @@ var LocalGitLabAdapter = class {
294
296
  has_conflicts: this.conflicts(mr(id, iid)),
295
297
  sha: this.git(mr(id, iid).source_project_id, ["rev-parse", mr(id, iid).source_branch])
296
298
  }),
299
+ getMergeRequestApprovals: async (id, iid) => ({
300
+ user_has_approved: this.state.approvedSha?.[`${id}:${iid}`] !== void 0
301
+ }),
302
+ approveMergeRequest: async (id, iid, sha) => {
303
+ const request = mr(id, iid);
304
+ const head = commit(request.source_project_id, request.source_branch).id;
305
+ if (head !== sha) throw new Error("SHA does not match HEAD of source branch");
306
+ const key = `${id}:${iid}`;
307
+ this.state.approvedSha ??= {};
308
+ if (this.state.approvedSha[key] === sha) return { sha };
309
+ this.state.approvedSha[key] = sha;
310
+ this.save();
311
+ if (this.loseNextApprovalResponse) {
312
+ this.loseNextApprovalResponse = false;
313
+ throw new Error("Response lost after approval");
314
+ }
315
+ return { sha };
316
+ },
317
+ unapproveMergeRequest: async (id, iid) => {
318
+ const request = mr(id, iid);
319
+ const head = commit(request.source_project_id, request.source_branch).id;
320
+ const key = `${id}:${iid}`;
321
+ if (this.state.approvedSha?.[key] === void 0) return { sha: head };
322
+ delete this.state.approvedSha[key];
323
+ this.save();
324
+ if (this.loseNextApprovalResponse) {
325
+ this.loseNextApprovalResponse = false;
326
+ throw new Error("Response lost after unapprove");
327
+ }
328
+ return { sha: head };
329
+ },
297
330
  listMergeRequests: async (id, label) => structuredClone(
298
331
  this.state.mrs.filter(
299
- (m) => m.project_id === id && m.state === "opened" && m.labels.includes(label)
332
+ (m) => (id === null || m.project_id === id) && m.state === "opened" && label.split(",").every((name) => m.labels.includes(name))
300
333
  )
301
334
  ),
302
335
  listMergeRequestLabelEvents: async (id, iid) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n\tGitLabClientLike,\n\tGitLabDiff,\n\tGitLabFeedback,\n\tGitLabIssue,\n\tGitLabLabelEvent,\n\tGitLabMergeRequest,\n\tGitLabNote,\n\tGitLabNoteReaction,\n\tGitLabPipeline,\n\tGitLabProject,\n} from \"./client.js\";\nimport { GitLabError } from \"./client.js\";\n\nexport { GITLAB_MR_KIND } from \"./external.js\";\nexport { createGitLabMaintenance } from \"./maintenance.js\";\nexport { setupGitLabIntegration } from \"./setup.js\";\n\n/** @public */\ninterface LocalState {\n\t/** @public */\n\tissues?: GitLabIssue[];\n\t/** @public */\n\tissueNotes?: Record<string, GitLabNote[]>;\n\t/** @public */\n\tlabels?: Record<string, string[]>;\n\t/** @internal */\n\tlabelEvents?: Record<string, GitLabLabelEvent[]>;\n\t/** @internal */\n\tprojects: GitLabProject[];\n\t/** @internal */\n\tmrs: GitLabMergeRequest[];\n\t/** @internal */\n\tpipelines: GitLabPipeline[];\n\t/** @public */\n\tnotes: Record<string, GitLabNote[]>;\n\t/** @internal */\n\tdiffs: Record<string, GitLabDiff[]>;\n\t/** @public */\n\tfeedback?: Record<string, GitLabFeedback[]>;\n\t/** @public */\n\tdiscussionNotes?: Record<string, GitLabNote[]>;\n\t/** @internal */\n\tdiscussionResolved?: Record<string, boolean>;\n\t/** @public */\n\treactions?: Record<string, GitLabNoteReaction[]>;\n}\n/** Persistent GitLab test boundary. Repository URLs use local Git's file transport. */\n/** @public */\nexport class LocalGitLabAdapter {\n\t/** @public */\n\tstate: LocalState;\n\t/** @public */\n\tloseNextCommentResponse = false;\n\t/** @public */\n\tloseNextMergeRequestResponse = false;\n\t/** @internal */\n\tloseNextIssueResponse = false;\n\t/** @public */\n\tloseNextReplyResponse = false;\n\t/** @public */\n\tloseNextReactionResponse = false;\n\t/** @public */\n\tloseNextLabelResponse = false;\n\t/** @public */\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly root: string,\n\t\t/** @internal */\n\t\treadonly baseUrl = \"https://gitlab.test\",\n\t) {\n\t\tmkdirSync(root, { recursive: true });\n\t\tconst file = path.join(root, \"gitlab.json\");\n\t\tthis.state = existsSync(file)\n\t\t\t? JSON.parse(readFileSync(file, \"utf8\"))\n\t\t\t: { projects: [], mrs: [], pipelines: [], notes: {}, diffs: {} };\n\t}\n\t/** @public */\n\tsave() {\n\t\twriteFileSync(path.join(this.root, \"gitlab.json\"), JSON.stringify(this.state), { mode: 0o600 });\n\t}\n\tprivate append<T>(items: T[], item: T, kind: \"Comment\" | \"Reply\" | \"Reaction\"): T {\n\t\titems.push(item);\n\t\tthis.save();\n\t\tconst flag = `loseNext${kind}Response` as const;\n\t\tif (this[flag]) {\n\t\t\tthis[flag] = false;\n\t\t\tconst action = {\n\t\t\t\tComment: \"comment write\",\n\t\t\t\tReply: \"discussion reply\",\n\t\t\t\tReaction: \"reaction write\",\n\t\t\t};\n\t\t\tthrow new Error(`Response lost after ${action[kind]}`);\n\t\t}\n\t\treturn item;\n\t}\n\tprivate project(id: number | string) {\n\t\tconst p = this.state.projects.find((p) => p.id === id || p.path_with_namespace === id);\n\t\tif (!p) throw new Error(\"Unknown test project\");\n\t\treturn p;\n\t}\n\tprivate git(id: number, args: string[]) {\n\t\treturn execFileSync(\n\t\t\t\"git\",\n\t\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"--git-dir\", this.project(id).http_url_to_repo, ...args],\n\t\t\t{ encoding: \"utf8\" },\n\t\t).trim();\n\t}\n\t/** @public */\n\taddProject(name: string, bare: string): GitLabProject {\n\t\tconst project: GitLabProject = {\n\t\t\tid: this.state.projects.length + 1,\n\t\t\tpath_with_namespace: name,\n\t\t\thttp_url_to_repo: bare,\n\t\t\tssh_url_to_repo: bare,\n\t\t\tweb_url: `${this.baseUrl}/${name}`,\n\t\t\tdefault_branch: \"main\",\n\t\t};\n\t\tthis.state.projects.push(project);\n\t\tthis.save();\n\t\treturn project;\n\t}\n\t/** @public */\n\topenMr(project: GitLabProject, branch: string): GitLabMergeRequest {\n\t\tconst mr: GitLabMergeRequest = {\n\t\t\tiid: this.state.mrs.length + 1,\n\t\t\tproject_id: project.id,\n\t\t\ttarget_project_id: project.id,\n\t\t\tsource_project_id: project.id,\n\t\t\ttitle: \"Update dependency\",\n\t\t\tdescription: \"Renovate upgrade\",\n\t\t\tstate: \"opened\",\n\t\t\tlabels: [\"renovate\"],\n\t\t\tsha: this.git(project.id, [\"rev-parse\", branch]),\n\t\t\tsource_branch: branch,\n\t\t\ttarget_branch: \"main\",\n\t\t\tweb_url: `${project.web_url}/-/merge_requests/${this.state.mrs.length + 1}`,\n\t\t};\n\t\tthis.state.mrs.push(mr);\n\t\tthis.save();\n\t\treturn mr;\n\t}\n\t/** @public */\n\tpipeline(mr: GitLabMergeRequest, status: string): GitLabPipeline {\n\t\tconst value: GitLabPipeline = {\n\t\t\tid: this.state.pipelines.length + 1,\n\t\t\tproject_id: mr.source_project_id,\n\t\t\tsha: this.git(mr.source_project_id, [\"rev-parse\", mr.source_branch]),\n\t\t\tref: mr.source_branch,\n\t\t\tstatus,\n\t\t\tsource: \"merge_request_event\",\n\t\t\tweb_url: `${this.project(mr.source_project_id).web_url}/-/pipelines/${this.state.pipelines.length + 1}`,\n\t\t};\n\t\tthis.state.pipelines.push(value);\n\t\tthis.save();\n\t\treturn value;\n\t}\n\t/** @public */\n\tcreateIssue(projectId: number, title: string, labels: string[] = [\"use-leitwerk\"]): GitLabIssue {\n\t\tthis.state.issues ??= [];\n\t\tconst project = this.project(projectId);\n\t\tconst iid = this.state.issues.filter((i) => i.project_id === projectId).length + 1;\n\t\tconst issue: GitLabIssue = {\n\t\t\tid: this.state.issues.length + 1,\n\t\t\tiid,\n\t\t\tproject_id: projectId,\n\t\t\ttitle,\n\t\t\tdescription: \"\",\n\t\t\tweb_url: `${project.web_url}/-/issues/${iid}`,\n\t\t\tstate: \"opened\",\n\t\t\tlabels,\n\t\t};\n\t\tthis.state.issues.push(issue);\n\t\tthis.save();\n\t\treturn issue;\n\t}\n\t/** @public */\n\tmerge(request: GitLabMergeRequest) {\n\t\tconst base = this.git(request.project_id, [\"rev-parse\", request.target_branch]);\n\t\tconst head = this.git(request.project_id, [\"rev-parse\", request.source_branch]);\n\t\tconst tree = this.git(request.project_id, [\"merge-tree\", \"--write-tree\", base, head]);\n\t\tconst commit = this.git(request.project_id, [\n\t\t\t\"-c\",\n\t\t\t\"user.name=Leitwerk Bot\",\n\t\t\t\"-c\",\n\t\t\t\"user.email=bot@gitlab.test\",\n\t\t\t\"commit-tree\",\n\t\t\ttree,\n\t\t\t\"-p\",\n\t\t\tbase,\n\t\t\t\"-p\",\n\t\t\thead,\n\t\t\t\"-m\",\n\t\t\trequest.title,\n\t\t]);\n\t\tthis.git(request.project_id, [\n\t\t\t\"update-ref\",\n\t\t\t`refs/heads/${request.target_branch}`,\n\t\t\tcommit,\n\t\t\tbase,\n\t\t]);\n\t\trequest.state = \"merged\";\n\t\trequest.merge_commit_sha = commit;\n\t\tthis.save();\n\t}\n\tprivate conflicts(request: GitLabMergeRequest): boolean {\n\t\ttry {\n\t\t\tthis.git(request.project_id, [\n\t\t\t\t\"merge-tree\",\n\t\t\t\t\"--write-tree\",\n\t\t\t\trequest.target_branch,\n\t\t\t\trequest.source_branch,\n\t\t\t]);\n\t\t\treturn false;\n\t\t} catch {\n\t\t\treturn true;\n\t\t}\n\t}\n\t/** @public */\n\tclient(): GitLabClientLike {\n\t\tconst mr = (id: number, iid: number) => {\n\t\t\tconst m = this.state.mrs.find((m) => m.project_id === id && m.iid === iid);\n\t\t\tif (!m) throw new GitLabError(404, false);\n\t\t\treturn m;\n\t\t};\n\t\tconst commit = (id: number, ref: string) => ({\n\t\t\tid: this.git(id, [\"rev-parse\", ref]),\n\t\t\tparent_ids: this.git(id, [\"show\", \"-s\", \"--format=%P\", ref]).split(\" \").filter(Boolean),\n\t\t\tmessage: this.git(id, [\"show\", \"-s\", \"--format=%B\", ref]),\n\t\t});\n\t\treturn {\n\t\t\tbaseUrl: this.baseUrl,\n\t\t\tlistIssues: async (id, _signal, state = \"opened\") =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\t(this.state.issues ?? []).filter(\n\t\t\t\t\t\t(i) => i.project_id === id && (state === \"all\" || i.state === \"opened\"),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tcreateIssue: async (id, input) => {\n\t\t\t\tconst issue = this.createIssue(\n\t\t\t\t\tid,\n\t\t\t\t\tinput.title,\n\t\t\t\t\tinput.labels ? input.labels.split(\",\") : [],\n\t\t\t\t);\n\t\t\t\tissue.description = input.description;\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextIssueResponse) {\n\t\t\t\t\tthis.loseNextIssueResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after issue write\");\n\t\t\t\t}\n\t\t\t\treturn structuredClone(issue);\n\t\t\t},\n\t\t\tgetIssue: async (id, iid) => {\n\t\t\t\tconst issue = (this.state.issues ?? []).find((i) => i.project_id === id && i.iid === iid);\n\t\t\t\tif (!issue) throw new Error(\"Unknown local GitLab issue\");\n\t\t\t\treturn structuredClone(issue);\n\t\t\t},\n\t\t\tupdateIssue: async (id, iid, patch) => {\n\t\t\t\tconst issue = (this.state.issues ?? []).find((i) => i.project_id === id && i.iid === iid);\n\t\t\t\tif (!issue) throw new Error(\"Unknown local GitLab issue\");\n\t\t\t\tif (patch.labels !== undefined) issue.labels = patch.labels ? patch.labels.split(\",\") : [];\n\t\t\t\tif (patch.state_event === \"close\") issue.state = \"closed\";\n\t\t\t\tthis.save();\n\t\t\t\treturn structuredClone(issue);\n\t\t\t},\n\t\t\tlistIssueNotes: async (id, iid) =>\n\t\t\t\tstructuredClone(this.state.issueNotes?.[`${id}:${iid}`] ?? []),\n\t\t\taddIssueNote: async (id, iid, body) => {\n\t\t\t\tthis.state.issueNotes ??= {};\n\t\t\t\tthis.state.issueNotes[`${id}:${iid}`] ??= [];\n\t\t\t\tconst notes = this.state.issueNotes[`${id}:${iid}`];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Comment\");\n\t\t\t},\n\t\t\tlistLabels: async (id) => (this.state.labels?.[id] ?? []).map((name) => ({ name })),\n\t\t\tcreateLabel: async (id, name) => {\n\t\t\t\tthis.state.labels ??= {};\n\t\t\t\tthis.state.labels[id] ??= [];\n\t\t\t\tconst labels = this.state.labels[id];\n\t\t\t\tif (!labels.includes(name)) labels.push(name);\n\t\t\t\tthis.save();\n\t\t\t\treturn { name };\n\t\t\t},\n\t\t\tlistBranchMergeRequests: async (id, source, target) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.mrs.filter(\n\t\t\t\t\t\t(m) => m.project_id === id && m.source_branch === source && m.target_branch === target,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tcreateMergeRequest: async (id, input) => {\n\t\t\t\tconst request = this.openMr(this.project(id), input.source_branch);\n\t\t\t\tObject.assign(request, {\n\t\t\t\t\ttitle: input.title,\n\t\t\t\t\tdescription: input.description,\n\t\t\t\t\ttarget_branch: input.target_branch,\n\t\t\t\t\tlabels: [],\n\t\t\t\t});\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextMergeRequestResponse) {\n\t\t\t\t\tthis.loseNextMergeRequestResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after merge request creation\");\n\t\t\t\t}\n\t\t\t\treturn structuredClone(request);\n\t\t\t},\n\t\t\tpreflightRepository: async (id, baseBranch, workBranch) => {\n\t\t\t\tthis.git(id, [\"rev-parse\", `refs/heads/${baseBranch}`]);\n\t\t\t\tthis.git(id, [\"check-ref-format\", `refs/heads/${workBranch}`]);\n\t\t\t\tthis.git(id, [\n\t\t\t\t\t\"push\",\n\t\t\t\t\t\"--dry-run\",\n\t\t\t\t\tthis.project(id).http_url_to_repo,\n\t\t\t\t\t`${baseBranch}:refs/heads/${workBranch}`,\n\t\t\t\t]);\n\t\t\t},\n\n\t\t\tgetProject: async (id) => structuredClone(this.project(id)),\n\t\t\tlistRepositoryTree: async (id, ref, directory = \"\") =>\n\t\t\t\tthis.git(id, [\"ls-tree\", ref, ...(directory ? [`${directory}/`] : [])])\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.map((line) => {\n\t\t\t\t\t\tconst [details, filePath] = line.split(\"\\t\");\n\t\t\t\t\t\tconst [, type, objectId] = details.split(\" \");\n\t\t\t\t\t\treturn { path: filePath, type, id: objectId };\n\t\t\t\t\t}),\n\t\t\tgetRepositoryFile: async (id, ref, filePath) => ({\n\t\t\t\tfile_path: filePath,\n\t\t\t\tcontent: Buffer.from(this.git(id, [\"show\", `${ref}:${filePath}`])).toString(\"base64\"),\n\t\t\t\tencoding: \"base64\",\n\t\t\t\tlast_commit_id: this.git(id, [\"log\", \"-1\", \"--format=%H\", ref, \"--\", filePath]),\n\t\t\t}),\n\t\t\tlistProjects: async () => structuredClone(this.state.projects),\n\t\t\tsearchProjects: async (search) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.projects\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(project) =>\n\t\t\t\t\t\t\t\t!project.archived &&\n\t\t\t\t\t\t\t\tproject.path_with_namespace.toLowerCase().includes(search.trim().toLowerCase()),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.slice(0, 100),\n\t\t\t\t),\n\t\t\tgetGroup: async (id) => ({ id: 1, full_path: String(id) }),\n\t\t\tlistGroupProjects: async (group) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.projects.filter((p) => p.path_with_namespace.startsWith(`${group}/`)),\n\t\t\t\t),\n\t\t\tgetMergeRequest: async (id, iid) => ({\n\t\t\t\t...structuredClone(mr(id, iid)),\n\t\t\t\thas_conflicts: this.conflicts(mr(id, iid)),\n\t\t\t\tsha: this.git(mr(id, iid).source_project_id, [\"rev-parse\", mr(id, iid).source_branch]),\n\t\t\t}),\n\t\t\tlistMergeRequests: async (id, label) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.mrs.filter(\n\t\t\t\t\t\t(m) => m.project_id === id && m.state === \"opened\" && m.labels.includes(label),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tlistMergeRequestLabelEvents: async (id, iid) => {\n\t\t\t\tmr(id, iid);\n\t\t\t\treturn structuredClone(this.state.labelEvents?.[`${id}:${iid}`] ?? []);\n\t\t\t},\n\t\t\tupdateMergeRequestLabels: async (id, iid, patch) => {\n\t\t\t\tconst request = mr(id, iid);\n\t\t\t\tthis.state.labelEvents ??= {};\n\t\t\t\tthis.state.labelEvents[`${id}:${iid}`] ??= [];\n\t\t\t\tconst events = this.state.labelEvents[`${id}:${iid}`];\n\t\t\t\tfor (const [action, labels] of [\n\t\t\t\t\t[\"add\", patch.add_labels],\n\t\t\t\t\t[\"remove\", patch.remove_labels],\n\t\t\t\t] as const) {\n\t\t\t\t\tfor (const name of labels?.split(\",\").filter(Boolean) ?? []) {\n\t\t\t\t\t\tif (request.labels.includes(name) === (action === \"add\")) continue;\n\t\t\t\t\t\trequest.labels =\n\t\t\t\t\t\t\taction === \"add\"\n\t\t\t\t\t\t\t\t? [...request.labels, name]\n\t\t\t\t\t\t\t\t: request.labels.filter((label) => label !== name);\n\t\t\t\t\t\tevents.push({\n\t\t\t\t\t\t\tid: Math.max(0, ...events.map((event) => event.id)) + 1,\n\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\tlabel: { name },\n\t\t\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextLabelResponse) {\n\t\t\t\t\tthis.loseNextLabelResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after label write\");\n\t\t\t\t}\n\t\t\t\treturn structuredClone(request);\n\t\t\t},\n\t\t\tgetBranch: async (id, branch) => ({\n\t\t\t\tname: branch,\n\t\t\t\tcan_push: true,\n\t\t\t\tprotected: false,\n\t\t\t\tcommit: commit(id, branch),\n\t\t\t}),\n\t\t\tgetCommit: async (id, ref) => commit(id, ref),\n\t\t\tgetMergeBase: async (id, refs) => commit(id, this.git(id, [\"merge-base\", ...refs])),\n\t\t\tgetChanges: async (id, iid) => structuredClone(this.state.diffs[`${id}:${iid}`] ?? []),\n\t\t\tlistMergeRequestPipelines: async (id, iid) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.pipelines.filter(\n\t\t\t\t\t\t(p) =>\n\t\t\t\t\t\t\tp.project_id === mr(id, iid).source_project_id && p.ref === mr(id, iid).source_branch,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tlistBranchPipelines: async (id, branch, sha) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.pipelines.filter(\n\t\t\t\t\t\t(p) => p.project_id === id && p.ref === branch && p.sha === sha && p.source === \"push\",\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tgetPipeline: async (id, pipeline) => {\n\t\t\t\tconst p = this.state.pipelines.find((p) => p.project_id === id && p.id === pipeline);\n\t\t\t\tif (!p) throw new Error(\"Unknown test pipeline\");\n\t\t\t\treturn structuredClone(p);\n\t\t\t},\n\t\t\tlistFailedJobs: async (id, pipeline) => [\n\t\t\t\t{\n\t\t\t\t\tid: pipeline * 100,\n\t\t\t\t\tname: \"test\",\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\tweb_url: `${this.project(id).web_url}/-/jobs/${pipeline * 100}`,\n\t\t\t\t\tfailure_reason: \"script_failure\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tgetJobTrace: async () => ({\n\t\t\t\ttext: \"Expected new dependency API; test failed\",\n\t\t\t\ttruncated: false,\n\t\t\t}),\n\t\t\tresolveGitIdentity: async () => ({\n\t\t\t\tname: \"Leitwerk Bot\",\n\t\t\t\temail: \"bot@gitlab.test\",\n\t\t\t\tusername: \"bot\",\n\t\t\t}),\n\t\t\tlistNotes: async (id, iid) => structuredClone(this.state.notes[`${id}:${iid}`] ?? []),\n\t\t\tlistMergeRequestFeedback: async (id, iid) =>\n\t\t\t\tstructuredClone(this.state.feedback?.[`${id}:${iid}`] ?? []),\n\t\t\tgetDiscussion: async (id, iid, discussionId) => ({\n\t\t\t\tid: discussionId,\n\t\t\t\tnotes: (this.state.discussionNotes?.[`${id}:${iid}:${discussionId}`] ?? []).map((note) => ({\n\t\t\t\t\t...structuredClone(note),\n\t\t\t\t\tsystem: false,\n\t\t\t\t\tresolved: this.state.discussionResolved?.[`${id}:${iid}:${discussionId}`] === true,\n\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t})),\n\t\t\t}),\n\t\t\tlistDiscussions: async (id, iid) =>\n\t\t\t\tObject.entries(this.state.discussionNotes ?? {})\n\t\t\t\t\t.filter(([key]) => key.startsWith(`${id}:${iid}:`))\n\t\t\t\t\t.map(([key, notes]) => ({\n\t\t\t\t\t\tid: key.slice(`${id}:${iid}:`.length),\n\t\t\t\t\t\tnotes: notes.map((note) => ({\n\t\t\t\t\t\t\t...structuredClone(note),\n\t\t\t\t\t\t\tsystem: false,\n\t\t\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t\t\t})),\n\t\t\t\t\t})),\n\t\t\taddDiscussion: async (id, iid, body, position) => {\n\t\t\t\tthis.state.discussionNotes ??= {};\n\t\t\t\tconst discussionId = `discussion-${Object.keys(this.state.discussionNotes).length + 1}`;\n\t\t\t\tconst note = {\n\t\t\t\t\tid: 1,\n\t\t\t\t\tbody,\n\t\t\t\t\tsystem: false,\n\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t\tposition,\n\t\t\t\t};\n\t\t\t\tthis.state.discussionNotes[`${id}:${iid}:${discussionId}`] = [note];\n\t\t\t\tthis.save();\n\t\t\t\treturn { id: discussionId, notes: [note] };\n\t\t\t},\n\t\t\treplyToDiscussion: async (id, iid, discussionId, body) => {\n\t\t\t\tconst key = `${id}:${iid}:${discussionId}`;\n\t\t\t\tthis.state.discussionNotes ??= {};\n\t\t\t\tthis.state.discussionNotes[key] ??= [];\n\t\t\t\tconst notes = this.state.discussionNotes[key];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Reply\");\n\t\t\t},\n\t\t\tresolveDiscussion: async (id, iid, discussionId) => {\n\t\t\t\tconst key = `${id}:${iid}:${discussionId}`;\n\t\t\t\tthis.state.discussionResolved ??= {};\n\t\t\t\tthis.state.discussionResolved[key] = true;\n\t\t\t\tthis.save();\n\t\t\t\treturn {\n\t\t\t\t\tid: discussionId,\n\t\t\t\t\tnotes: (this.state.discussionNotes?.[key] ?? []).map((note) => ({\n\t\t\t\t\t\t...structuredClone(note),\n\t\t\t\t\t\tsystem: false,\n\t\t\t\t\t\tresolved: true,\n\t\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t\t})),\n\t\t\t\t};\n\t\t\t},\n\t\t\tlistNoteReactions: async (id, iid, noteId) =>\n\t\t\t\tstructuredClone(this.state.reactions?.[`${id}:${iid}:${noteId}`] ?? []),\n\t\t\taddNoteReaction: async (id, iid, noteId, name) => {\n\t\t\t\tconst key = `${id}:${iid}:${noteId}`;\n\t\t\t\tthis.state.reactions ??= {};\n\t\t\t\tthis.state.reactions[key] ??= [];\n\t\t\t\tconst reactions = this.state.reactions[key];\n\t\t\t\tif (\n\t\t\t\t\treactions.some((reaction) => reaction.name === name && reaction.user.username === \"bot\")\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\"Reaction already exists\");\n\t\t\t\tconst reaction = { id: reactions.length + 1, name, user: { username: \"bot\" } };\n\t\t\t\treturn this.append(reactions, reaction, \"Reaction\");\n\t\t\t},\n\t\t\taddNote: async (id, iid, body) => {\n\t\t\t\tconst key = `${id}:${iid}`;\n\t\t\t\tthis.state.notes[key] ??= [];\n\t\t\t\tconst notes = this.state.notes[key];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Comment\");\n\t\t\t},\n\t\t\tupdateNote: async (id, iid, noteId, body) => {\n\t\t\t\tconst note = (this.state.notes[`${id}:${iid}`] ?? []).find((item) => item.id === noteId);\n\t\t\t\tif (!note) throw new Error(\"Unknown test note\");\n\t\t\t\tnote.body = body;\n\t\t\t\tthis.save();\n\t\t\t\treturn structuredClone(note);\n\t\t\t},\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,OAAO,UAAU;AAkDV,IAAM,qBAAN,MAAyB;AAAA;AAAA,EAgB/B,YAEU,MAEA,UAAU,uBAClB;AAHQ;AAEA;AAET,cAAU,MAAM,EAAE,WAAW,KAAK,CAAC;AACnC,UAAM,OAAO,KAAK,KAAK,MAAM,aAAa;AAC1C,SAAK,QAAQ,WAAW,IAAI,IACzB,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC,IACrC,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,EACjE;AAAA,EATU;AAAA,EA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,KAAM,OAAM,IAAI,MAAM,mBAAmB;AAC9C,aAAK,OAAO;AACZ,aAAK,KAAK;AACV,eAAO,gBAAgB,IAAI;AAAA,MAC5B;AAAA,IACD;AAAA,EACD;AACD;","names":["p","m","reaction"]}
1
+ {"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n\tGitLabClientLike,\n\tGitLabDiff,\n\tGitLabFeedback,\n\tGitLabIssue,\n\tGitLabLabelEvent,\n\tGitLabMergeRequest,\n\tGitLabNote,\n\tGitLabNoteReaction,\n\tGitLabPipeline,\n\tGitLabProject,\n} from \"./client.js\";\nimport { GitLabError } from \"./client.js\";\n\nexport { GITLAB_MR_KIND } from \"./external.js\";\nexport { createGitLabMaintenance } from \"./maintenance.js\";\nexport { setupGitLabIntegration } from \"./setup.js\";\n\n/** @public */\ninterface LocalState {\n\t/** @public */\n\tissues?: GitLabIssue[];\n\t/** @public */\n\tissueNotes?: Record<string, GitLabNote[]>;\n\t/** @public */\n\tlabels?: Record<string, string[]>;\n\t/** @internal */\n\tlabelEvents?: Record<string, GitLabLabelEvent[]>;\n\t/** @internal */\n\tprojects: GitLabProject[];\n\t/** @internal */\n\tmrs: GitLabMergeRequest[];\n\t/** @internal */\n\tpipelines: GitLabPipeline[];\n\t/** @public */\n\tnotes: Record<string, GitLabNote[]>;\n\t/** @internal */\n\tdiffs: Record<string, GitLabDiff[]>;\n\t/** @public */\n\tfeedback?: Record<string, GitLabFeedback[]>;\n\t/** @public */\n\tdiscussionNotes?: Record<string, GitLabNote[]>;\n\t/** @internal */\n\tdiscussionResolved?: Record<string, boolean>;\n\t/** @public */\n\treactions?: Record<string, GitLabNoteReaction[]>;\n\t/** SHA the bot approved. Stays set across later commits until unapprove. @public */\n\tapprovedSha?: Record<string, string>;\n}\n/** Persistent GitLab test boundary. Repository URLs use local Git's file transport. */\n/** @public */\nexport class LocalGitLabAdapter {\n\t/** @public */\n\tstate: LocalState;\n\t/** @public */\n\tloseNextCommentResponse = false;\n\t/** @public */\n\tloseNextMergeRequestResponse = false;\n\t/** @internal */\n\tloseNextIssueResponse = false;\n\t/** @public */\n\tloseNextReplyResponse = false;\n\t/** @public */\n\tloseNextReactionResponse = false;\n\t/** @public */\n\tloseNextLabelResponse = false;\n\t/** @public */\n\tloseNextApprovalResponse = false;\n\t/** @public */\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly root: string,\n\t\t/** @internal */\n\t\treadonly baseUrl = \"https://gitlab.test\",\n\t) {\n\t\tmkdirSync(root, { recursive: true });\n\t\tconst file = path.join(root, \"gitlab.json\");\n\t\tthis.state = existsSync(file)\n\t\t\t? JSON.parse(readFileSync(file, \"utf8\"))\n\t\t\t: { projects: [], mrs: [], pipelines: [], notes: {}, diffs: {} };\n\t}\n\t/** @public */\n\tsave() {\n\t\twriteFileSync(path.join(this.root, \"gitlab.json\"), JSON.stringify(this.state), { mode: 0o600 });\n\t}\n\tprivate append<T>(items: T[], item: T, kind: \"Comment\" | \"Reply\" | \"Reaction\"): T {\n\t\titems.push(item);\n\t\tthis.save();\n\t\tconst flag = `loseNext${kind}Response` as const;\n\t\tif (this[flag]) {\n\t\t\tthis[flag] = false;\n\t\t\tconst action = {\n\t\t\t\tComment: \"comment write\",\n\t\t\t\tReply: \"discussion reply\",\n\t\t\t\tReaction: \"reaction write\",\n\t\t\t};\n\t\t\tthrow new Error(`Response lost after ${action[kind]}`);\n\t\t}\n\t\treturn item;\n\t}\n\tprivate project(id: number | string) {\n\t\tconst p = this.state.projects.find((p) => p.id === id || p.path_with_namespace === id);\n\t\tif (!p) throw new Error(\"Unknown test project\");\n\t\treturn p;\n\t}\n\tprivate git(id: number, args: string[]) {\n\t\treturn execFileSync(\n\t\t\t\"git\",\n\t\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"--git-dir\", this.project(id).http_url_to_repo, ...args],\n\t\t\t{ encoding: \"utf8\" },\n\t\t).trim();\n\t}\n\t/** @public */\n\taddProject(name: string, bare: string): GitLabProject {\n\t\tconst project: GitLabProject = {\n\t\t\tid: this.state.projects.length + 1,\n\t\t\tpath_with_namespace: name,\n\t\t\thttp_url_to_repo: bare,\n\t\t\tssh_url_to_repo: bare,\n\t\t\tweb_url: `${this.baseUrl}/${name}`,\n\t\t\tdefault_branch: \"main\",\n\t\t};\n\t\tthis.state.projects.push(project);\n\t\tthis.save();\n\t\treturn project;\n\t}\n\t/** @public */\n\topenMr(project: GitLabProject, branch: string): GitLabMergeRequest {\n\t\tconst mr: GitLabMergeRequest = {\n\t\t\tiid: this.state.mrs.length + 1,\n\t\t\tproject_id: project.id,\n\t\t\ttarget_project_id: project.id,\n\t\t\tsource_project_id: project.id,\n\t\t\ttitle: \"Update dependency\",\n\t\t\tdescription: \"Renovate upgrade\",\n\t\t\tstate: \"opened\",\n\t\t\tlabels: [\"renovate\"],\n\t\t\tsha: this.git(project.id, [\"rev-parse\", branch]),\n\t\t\tsource_branch: branch,\n\t\t\ttarget_branch: \"main\",\n\t\t\tweb_url: `${project.web_url}/-/merge_requests/${this.state.mrs.length + 1}`,\n\t\t};\n\t\tthis.state.mrs.push(mr);\n\t\tthis.save();\n\t\treturn mr;\n\t}\n\t/** @public */\n\tpipeline(mr: GitLabMergeRequest, status: string): GitLabPipeline {\n\t\tconst value: GitLabPipeline = {\n\t\t\tid: this.state.pipelines.length + 1,\n\t\t\tproject_id: mr.source_project_id,\n\t\t\tsha: this.git(mr.source_project_id, [\"rev-parse\", mr.source_branch]),\n\t\t\tref: mr.source_branch,\n\t\t\tstatus,\n\t\t\tsource: \"merge_request_event\",\n\t\t\tweb_url: `${this.project(mr.source_project_id).web_url}/-/pipelines/${this.state.pipelines.length + 1}`,\n\t\t};\n\t\tthis.state.pipelines.push(value);\n\t\tthis.save();\n\t\treturn value;\n\t}\n\t/** @public */\n\tcreateIssue(projectId: number, title: string, labels: string[] = [\"use-leitwerk\"]): GitLabIssue {\n\t\tthis.state.issues ??= [];\n\t\tconst project = this.project(projectId);\n\t\tconst iid = this.state.issues.filter((i) => i.project_id === projectId).length + 1;\n\t\tconst issue: GitLabIssue = {\n\t\t\tid: this.state.issues.length + 1,\n\t\t\tiid,\n\t\t\tproject_id: projectId,\n\t\t\ttitle,\n\t\t\tdescription: \"\",\n\t\t\tweb_url: `${project.web_url}/-/issues/${iid}`,\n\t\t\tstate: \"opened\",\n\t\t\tlabels,\n\t\t};\n\t\tthis.state.issues.push(issue);\n\t\tthis.save();\n\t\treturn issue;\n\t}\n\t/** @public */\n\tmerge(request: GitLabMergeRequest) {\n\t\tconst base = this.git(request.project_id, [\"rev-parse\", request.target_branch]);\n\t\tconst head = this.git(request.project_id, [\"rev-parse\", request.source_branch]);\n\t\tconst tree = this.git(request.project_id, [\"merge-tree\", \"--write-tree\", base, head]);\n\t\tconst commit = this.git(request.project_id, [\n\t\t\t\"-c\",\n\t\t\t\"user.name=Leitwerk Bot\",\n\t\t\t\"-c\",\n\t\t\t\"user.email=bot@gitlab.test\",\n\t\t\t\"commit-tree\",\n\t\t\ttree,\n\t\t\t\"-p\",\n\t\t\tbase,\n\t\t\t\"-p\",\n\t\t\thead,\n\t\t\t\"-m\",\n\t\t\trequest.title,\n\t\t]);\n\t\tthis.git(request.project_id, [\n\t\t\t\"update-ref\",\n\t\t\t`refs/heads/${request.target_branch}`,\n\t\t\tcommit,\n\t\t\tbase,\n\t\t]);\n\t\trequest.state = \"merged\";\n\t\trequest.merge_commit_sha = commit;\n\t\tthis.save();\n\t}\n\tprivate conflicts(request: GitLabMergeRequest): boolean {\n\t\ttry {\n\t\t\tthis.git(request.project_id, [\n\t\t\t\t\"merge-tree\",\n\t\t\t\t\"--write-tree\",\n\t\t\t\trequest.target_branch,\n\t\t\t\trequest.source_branch,\n\t\t\t]);\n\t\t\treturn false;\n\t\t} catch {\n\t\t\treturn true;\n\t\t}\n\t}\n\t/** @public */\n\tclient(): GitLabClientLike {\n\t\tconst mr = (id: number, iid: number) => {\n\t\t\tconst m = this.state.mrs.find((m) => m.project_id === id && m.iid === iid);\n\t\t\tif (!m) throw new GitLabError(404, false);\n\t\t\treturn m;\n\t\t};\n\t\tconst commit = (id: number, ref: string) => ({\n\t\t\tid: this.git(id, [\"rev-parse\", ref]),\n\t\t\tparent_ids: this.git(id, [\"show\", \"-s\", \"--format=%P\", ref]).split(\" \").filter(Boolean),\n\t\t\tmessage: this.git(id, [\"show\", \"-s\", \"--format=%B\", ref]),\n\t\t});\n\t\treturn {\n\t\t\tbaseUrl: this.baseUrl,\n\t\t\tlistIssues: async (id, _signal, state = \"opened\") =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\t(this.state.issues ?? []).filter(\n\t\t\t\t\t\t(i) => i.project_id === id && (state === \"all\" || i.state === \"opened\"),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tcreateIssue: async (id, input) => {\n\t\t\t\tconst issue = this.createIssue(\n\t\t\t\t\tid,\n\t\t\t\t\tinput.title,\n\t\t\t\t\tinput.labels ? input.labels.split(\",\") : [],\n\t\t\t\t);\n\t\t\t\tissue.description = input.description;\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextIssueResponse) {\n\t\t\t\t\tthis.loseNextIssueResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after issue write\");\n\t\t\t\t}\n\t\t\t\treturn structuredClone(issue);\n\t\t\t},\n\t\t\tgetIssue: async (id, iid) => {\n\t\t\t\tconst issue = (this.state.issues ?? []).find((i) => i.project_id === id && i.iid === iid);\n\t\t\t\tif (!issue) throw new Error(\"Unknown local GitLab issue\");\n\t\t\t\treturn structuredClone(issue);\n\t\t\t},\n\t\t\tupdateIssue: async (id, iid, patch) => {\n\t\t\t\tconst issue = (this.state.issues ?? []).find((i) => i.project_id === id && i.iid === iid);\n\t\t\t\tif (!issue) throw new Error(\"Unknown local GitLab issue\");\n\t\t\t\tif (patch.labels !== undefined) issue.labels = patch.labels ? patch.labels.split(\",\") : [];\n\t\t\t\tif (patch.state_event === \"close\") issue.state = \"closed\";\n\t\t\t\tthis.save();\n\t\t\t\treturn structuredClone(issue);\n\t\t\t},\n\t\t\tlistIssueNotes: async (id, iid) =>\n\t\t\t\tstructuredClone(this.state.issueNotes?.[`${id}:${iid}`] ?? []),\n\t\t\taddIssueNote: async (id, iid, body) => {\n\t\t\t\tthis.state.issueNotes ??= {};\n\t\t\t\tthis.state.issueNotes[`${id}:${iid}`] ??= [];\n\t\t\t\tconst notes = this.state.issueNotes[`${id}:${iid}`];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Comment\");\n\t\t\t},\n\t\t\tlistLabels: async (id) => (this.state.labels?.[id] ?? []).map((name) => ({ name })),\n\t\t\tcreateLabel: async (id, name) => {\n\t\t\t\tthis.state.labels ??= {};\n\t\t\t\tthis.state.labels[id] ??= [];\n\t\t\t\tconst labels = this.state.labels[id];\n\t\t\t\tif (!labels.includes(name)) labels.push(name);\n\t\t\t\tthis.save();\n\t\t\t\treturn { name };\n\t\t\t},\n\t\t\tlistBranchMergeRequests: async (id, source, target) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.mrs.filter(\n\t\t\t\t\t\t(m) => m.project_id === id && m.source_branch === source && m.target_branch === target,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tcreateMergeRequest: async (id, input) => {\n\t\t\t\tconst request = this.openMr(this.project(id), input.source_branch);\n\t\t\t\tObject.assign(request, {\n\t\t\t\t\ttitle: input.title,\n\t\t\t\t\tdescription: input.description,\n\t\t\t\t\ttarget_branch: input.target_branch,\n\t\t\t\t\tlabels: [],\n\t\t\t\t});\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextMergeRequestResponse) {\n\t\t\t\t\tthis.loseNextMergeRequestResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after merge request creation\");\n\t\t\t\t}\n\t\t\t\treturn structuredClone(request);\n\t\t\t},\n\t\t\tpreflightRepository: async (id, baseBranch, workBranch) => {\n\t\t\t\tthis.git(id, [\"rev-parse\", `refs/heads/${baseBranch}`]);\n\t\t\t\tthis.git(id, [\"check-ref-format\", `refs/heads/${workBranch}`]);\n\t\t\t\tthis.git(id, [\n\t\t\t\t\t\"push\",\n\t\t\t\t\t\"--dry-run\",\n\t\t\t\t\tthis.project(id).http_url_to_repo,\n\t\t\t\t\t`${baseBranch}:refs/heads/${workBranch}`,\n\t\t\t\t]);\n\t\t\t},\n\n\t\t\tgetProject: async (id) => structuredClone(this.project(id)),\n\t\t\tlistRepositoryTree: async (id, ref, directory = \"\") =>\n\t\t\t\tthis.git(id, [\"ls-tree\", ref, ...(directory ? [`${directory}/`] : [])])\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.map((line) => {\n\t\t\t\t\t\tconst [details, filePath] = line.split(\"\\t\");\n\t\t\t\t\t\tconst [, type, objectId] = details.split(\" \");\n\t\t\t\t\t\treturn { path: filePath, type, id: objectId };\n\t\t\t\t\t}),\n\t\t\tgetRepositoryFile: async (id, ref, filePath) => ({\n\t\t\t\tfile_path: filePath,\n\t\t\t\tcontent: Buffer.from(this.git(id, [\"show\", `${ref}:${filePath}`])).toString(\"base64\"),\n\t\t\t\tencoding: \"base64\",\n\t\t\t\tlast_commit_id: this.git(id, [\"log\", \"-1\", \"--format=%H\", ref, \"--\", filePath]),\n\t\t\t}),\n\t\t\tlistProjects: async () => structuredClone(this.state.projects),\n\t\t\tsearchProjects: async (search) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.projects\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(project) =>\n\t\t\t\t\t\t\t\t!project.archived &&\n\t\t\t\t\t\t\t\tproject.path_with_namespace.toLowerCase().includes(search.trim().toLowerCase()),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.slice(0, 100),\n\t\t\t\t),\n\t\t\tgetGroup: async (id) => ({ id: 1, full_path: String(id) }),\n\t\t\tlistGroupProjects: async (group) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.projects.filter((p) => p.path_with_namespace.startsWith(`${group}/`)),\n\t\t\t\t),\n\t\t\tgetMergeRequest: async (id, iid) => ({\n\t\t\t\t...structuredClone(mr(id, iid)),\n\t\t\t\thas_conflicts: this.conflicts(mr(id, iid)),\n\t\t\t\tsha: this.git(mr(id, iid).source_project_id, [\"rev-parse\", mr(id, iid).source_branch]),\n\t\t\t}),\n\t\t\tgetMergeRequestApprovals: async (id, iid) => ({\n\t\t\t\tuser_has_approved: this.state.approvedSha?.[`${id}:${iid}`] !== undefined,\n\t\t\t}),\n\t\t\tapproveMergeRequest: async (id, iid, sha) => {\n\t\t\t\tconst request = mr(id, iid);\n\t\t\t\tconst head = commit(request.source_project_id, request.source_branch).id;\n\t\t\t\tif (head !== sha) throw new Error(\"SHA does not match HEAD of source branch\");\n\t\t\t\tconst key = `${id}:${iid}`;\n\t\t\t\tthis.state.approvedSha ??= {};\n\t\t\t\tif (this.state.approvedSha[key] === sha) return { sha };\n\t\t\t\tthis.state.approvedSha[key] = sha;\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextApprovalResponse) {\n\t\t\t\t\tthis.loseNextApprovalResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after approval\");\n\t\t\t\t}\n\t\t\t\treturn { sha };\n\t\t\t},\n\t\t\tunapproveMergeRequest: async (id, iid) => {\n\t\t\t\tconst request = mr(id, iid);\n\t\t\t\tconst head = commit(request.source_project_id, request.source_branch).id;\n\t\t\t\tconst key = `${id}:${iid}`;\n\t\t\t\tif (this.state.approvedSha?.[key] === undefined) return { sha: head };\n\t\t\t\tdelete this.state.approvedSha[key];\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextApprovalResponse) {\n\t\t\t\t\tthis.loseNextApprovalResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after unapprove\");\n\t\t\t\t}\n\t\t\t\treturn { sha: head };\n\t\t\t},\n\t\t\tlistMergeRequests: async (id, label) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.mrs.filter(\n\t\t\t\t\t\t(m) =>\n\t\t\t\t\t\t\t(id === null || m.project_id === id) &&\n\t\t\t\t\t\t\tm.state === \"opened\" &&\n\t\t\t\t\t\t\tlabel.split(\",\").every((name) => m.labels.includes(name)),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tlistMergeRequestLabelEvents: async (id, iid) => {\n\t\t\t\tmr(id, iid);\n\t\t\t\treturn structuredClone(this.state.labelEvents?.[`${id}:${iid}`] ?? []);\n\t\t\t},\n\t\t\tupdateMergeRequestLabels: async (id, iid, patch) => {\n\t\t\t\tconst request = mr(id, iid);\n\t\t\t\tthis.state.labelEvents ??= {};\n\t\t\t\tthis.state.labelEvents[`${id}:${iid}`] ??= [];\n\t\t\t\tconst events = this.state.labelEvents[`${id}:${iid}`];\n\t\t\t\tfor (const [action, labels] of [\n\t\t\t\t\t[\"add\", patch.add_labels],\n\t\t\t\t\t[\"remove\", patch.remove_labels],\n\t\t\t\t] as const) {\n\t\t\t\t\tfor (const name of labels?.split(\",\").filter(Boolean) ?? []) {\n\t\t\t\t\t\tif (request.labels.includes(name) === (action === \"add\")) continue;\n\t\t\t\t\t\trequest.labels =\n\t\t\t\t\t\t\taction === \"add\"\n\t\t\t\t\t\t\t\t? [...request.labels, name]\n\t\t\t\t\t\t\t\t: request.labels.filter((label) => label !== name);\n\t\t\t\t\t\tevents.push({\n\t\t\t\t\t\t\tid: Math.max(0, ...events.map((event) => event.id)) + 1,\n\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\tlabel: { name },\n\t\t\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextLabelResponse) {\n\t\t\t\t\tthis.loseNextLabelResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after label write\");\n\t\t\t\t}\n\t\t\t\treturn structuredClone(request);\n\t\t\t},\n\t\t\tgetBranch: async (id, branch) => ({\n\t\t\t\tname: branch,\n\t\t\t\tcan_push: true,\n\t\t\t\tprotected: false,\n\t\t\t\tcommit: commit(id, branch),\n\t\t\t}),\n\t\t\tgetCommit: async (id, ref) => commit(id, ref),\n\t\t\tgetMergeBase: async (id, refs) => commit(id, this.git(id, [\"merge-base\", ...refs])),\n\t\t\tgetChanges: async (id, iid) => structuredClone(this.state.diffs[`${id}:${iid}`] ?? []),\n\t\t\tlistMergeRequestPipelines: async (id, iid) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.pipelines.filter(\n\t\t\t\t\t\t(p) =>\n\t\t\t\t\t\t\tp.project_id === mr(id, iid).source_project_id && p.ref === mr(id, iid).source_branch,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tlistBranchPipelines: async (id, branch, sha) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.pipelines.filter(\n\t\t\t\t\t\t(p) => p.project_id === id && p.ref === branch && p.sha === sha && p.source === \"push\",\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tgetPipeline: async (id, pipeline) => {\n\t\t\t\tconst p = this.state.pipelines.find((p) => p.project_id === id && p.id === pipeline);\n\t\t\t\tif (!p) throw new Error(\"Unknown test pipeline\");\n\t\t\t\treturn structuredClone(p);\n\t\t\t},\n\t\t\tlistFailedJobs: async (id, pipeline) => [\n\t\t\t\t{\n\t\t\t\t\tid: pipeline * 100,\n\t\t\t\t\tname: \"test\",\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\tweb_url: `${this.project(id).web_url}/-/jobs/${pipeline * 100}`,\n\t\t\t\t\tfailure_reason: \"script_failure\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tgetJobTrace: async () => ({\n\t\t\t\ttext: \"Expected new dependency API; test failed\",\n\t\t\t\ttruncated: false,\n\t\t\t}),\n\t\t\tresolveGitIdentity: async () => ({\n\t\t\t\tname: \"Leitwerk Bot\",\n\t\t\t\temail: \"bot@gitlab.test\",\n\t\t\t\tusername: \"bot\",\n\t\t\t}),\n\t\t\tlistNotes: async (id, iid) => structuredClone(this.state.notes[`${id}:${iid}`] ?? []),\n\t\t\tlistMergeRequestFeedback: async (id, iid) =>\n\t\t\t\tstructuredClone(this.state.feedback?.[`${id}:${iid}`] ?? []),\n\t\t\tgetDiscussion: async (id, iid, discussionId) => ({\n\t\t\t\tid: discussionId,\n\t\t\t\tnotes: (this.state.discussionNotes?.[`${id}:${iid}:${discussionId}`] ?? []).map((note) => ({\n\t\t\t\t\t...structuredClone(note),\n\t\t\t\t\tsystem: false,\n\t\t\t\t\tresolved: this.state.discussionResolved?.[`${id}:${iid}:${discussionId}`] === true,\n\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t})),\n\t\t\t}),\n\t\t\tlistDiscussions: async (id, iid) =>\n\t\t\t\tObject.entries(this.state.discussionNotes ?? {})\n\t\t\t\t\t.filter(([key]) => key.startsWith(`${id}:${iid}:`))\n\t\t\t\t\t.map(([key, notes]) => ({\n\t\t\t\t\t\tid: key.slice(`${id}:${iid}:`.length),\n\t\t\t\t\t\tnotes: notes.map((note) => ({\n\t\t\t\t\t\t\t...structuredClone(note),\n\t\t\t\t\t\t\tsystem: false,\n\t\t\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t\t\t})),\n\t\t\t\t\t})),\n\t\t\taddDiscussion: async (id, iid, body, position) => {\n\t\t\t\tthis.state.discussionNotes ??= {};\n\t\t\t\tconst discussionId = `discussion-${Object.keys(this.state.discussionNotes).length + 1}`;\n\t\t\t\tconst note = {\n\t\t\t\t\tid: 1,\n\t\t\t\t\tbody,\n\t\t\t\t\tsystem: false,\n\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t\tposition,\n\t\t\t\t};\n\t\t\t\tthis.state.discussionNotes[`${id}:${iid}:${discussionId}`] = [note];\n\t\t\t\tthis.save();\n\t\t\t\treturn { id: discussionId, notes: [note] };\n\t\t\t},\n\t\t\treplyToDiscussion: async (id, iid, discussionId, body) => {\n\t\t\t\tconst key = `${id}:${iid}:${discussionId}`;\n\t\t\t\tthis.state.discussionNotes ??= {};\n\t\t\t\tthis.state.discussionNotes[key] ??= [];\n\t\t\t\tconst notes = this.state.discussionNotes[key];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Reply\");\n\t\t\t},\n\t\t\tresolveDiscussion: async (id, iid, discussionId) => {\n\t\t\t\tconst key = `${id}:${iid}:${discussionId}`;\n\t\t\t\tthis.state.discussionResolved ??= {};\n\t\t\t\tthis.state.discussionResolved[key] = true;\n\t\t\t\tthis.save();\n\t\t\t\treturn {\n\t\t\t\t\tid: discussionId,\n\t\t\t\t\tnotes: (this.state.discussionNotes?.[key] ?? []).map((note) => ({\n\t\t\t\t\t\t...structuredClone(note),\n\t\t\t\t\t\tsystem: false,\n\t\t\t\t\t\tresolved: true,\n\t\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t\t})),\n\t\t\t\t};\n\t\t\t},\n\t\t\tlistNoteReactions: async (id, iid, noteId) =>\n\t\t\t\tstructuredClone(this.state.reactions?.[`${id}:${iid}:${noteId}`] ?? []),\n\t\t\taddNoteReaction: async (id, iid, noteId, name) => {\n\t\t\t\tconst key = `${id}:${iid}:${noteId}`;\n\t\t\t\tthis.state.reactions ??= {};\n\t\t\t\tthis.state.reactions[key] ??= [];\n\t\t\t\tconst reactions = this.state.reactions[key];\n\t\t\t\tif (\n\t\t\t\t\treactions.some((reaction) => reaction.name === name && reaction.user.username === \"bot\")\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\"Reaction already exists\");\n\t\t\t\tconst reaction = { id: reactions.length + 1, name, user: { username: \"bot\" } };\n\t\t\t\treturn this.append(reactions, reaction, \"Reaction\");\n\t\t\t},\n\t\t\taddNote: async (id, iid, body) => {\n\t\t\t\tconst key = `${id}:${iid}`;\n\t\t\t\tthis.state.notes[key] ??= [];\n\t\t\t\tconst notes = this.state.notes[key];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Comment\");\n\t\t\t},\n\t\t\tupdateNote: async (id, iid, noteId, body) => {\n\t\t\t\tconst note = (this.state.notes[`${id}:${iid}`] ?? []).find((item) => item.id === noteId);\n\t\t\t\tif (!note) throw new Error(\"Unknown test note\");\n\t\t\t\tnote.body = body;\n\t\t\t\tthis.save();\n\t\t\t\treturn structuredClone(note);\n\t\t\t},\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,OAAO,UAAU;AAoDV,IAAM,qBAAN,MAAyB;AAAA;AAAA,EAkB/B,YAEU,MAEA,UAAU,uBAClB;AAHQ;AAEA;AAET,cAAU,MAAM,EAAE,WAAW,KAAK,CAAC;AACnC,UAAM,OAAO,KAAK,KAAK,MAAM,aAAa;AAC1C,SAAK,QAAQ,WAAW,IAAI,IACzB,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC,IACrC,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,EACjE;AAAA,EATU;AAAA,EAEA;AAAA;AAAA,EApBV;AAAA;AAAA,EAEA,0BAA0B;AAAA;AAAA,EAE1B,+BAA+B;AAAA;AAAA,EAE/B,wBAAwB;AAAA;AAAA,EAExB,wBAAwB;AAAA;AAAA,EAExB,2BAA2B;AAAA;AAAA,EAE3B,wBAAwB;AAAA;AAAA,EAExB,2BAA2B;AAAA;AAAA,EAe3B,OAAO;AACN,kBAAc,KAAK,KAAK,KAAK,MAAM,aAAa,GAAG,KAAK,UAAU,KAAK,KAAK,GAAG,EAAE,MAAM,IAAM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,IAAI,MAAM;AAClC,aAAK,MAAM,cAAc,CAAC;AAC1B,aAAK,MAAM,UAAU,GAAG,MAAM,CAAC;AAC/B,cAAM,YAAY,KAAK,MAAM,UAAU,GAAG;AAC1C,YACC,UAAU,KAAK,CAACE,cAAaA,UAAS,SAAS,QAAQA,UAAS,KAAK,aAAa,KAAK;AAEvF,gBAAM,IAAI,MAAM,yBAAyB;AAC1C,cAAM,WAAW,EAAE,IAAI,UAAU,SAAS,GAAG,MAAM,MAAM,EAAE,UAAU,MAAM,EAAE;AAC7E,eAAO,KAAK,OAAO,WAAW,UAAU,UAAU;AAAA,MACnD;AAAA,MACA,SAAS,OAAO,IAAI,KAAK,SAAS;AACjC,cAAM,MAAM,GAAG,EAAE,IAAI,GAAG;AACxB,aAAK,MAAM,MAAM,GAAG,MAAM,CAAC;AAC3B,cAAM,QAAQ,KAAK,MAAM,MAAM,GAAG;AAClC,eAAO,KAAK,OAAO,OAAO,EAAE,IAAI,MAAM,SAAS,GAAG,KAAK,GAAG,SAAS;AAAA,MACpE;AAAA,MACA,YAAY,OAAO,IAAI,KAAK,QAAQ,SAAS;AAC5C,cAAM,QAAQ,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,SAAS,KAAK,OAAO,MAAM;AACvF,YAAI,CAAC,KAAM,OAAM,IAAI,MAAM,mBAAmB;AAC9C,aAAK,OAAO;AACZ,aAAK,KAAK;AACV,eAAO,gBAAgB,IAAI;AAAA,MAC5B;AAAA,IACD;AAAA,EACD;AACD;","names":["p","m","reaction"]}
package/dist/tools.d.ts CHANGED
@@ -137,6 +137,50 @@ export declare function ensureGitLabResolveDiscussion(input: {
137
137
  discussionId: string;
138
138
  resolved: boolean;
139
139
  }>;
140
+ /** @internal */
141
+ export declare function ensureGitLabApproval(input: {
142
+ /** @internal */
143
+ client: GitLabClientLike;
144
+ /** @internal */
145
+ writes: ExternalWrites;
146
+ /** @internal */
147
+ instanceId: string;
148
+ /** @internal */
149
+ projectId: number;
150
+ /** @internal */
151
+ iid: number;
152
+ /** @internal */
153
+ writeKey: string;
154
+ /** @internal */
155
+ sha: string;
156
+ /** @internal */
157
+ signal?: AbortSignal;
158
+ }): Promise<{
159
+ sha: string;
160
+ approved: boolean;
161
+ }>;
162
+ /** @internal */
163
+ export declare function ensureGitLabUnapproval(input: {
164
+ /** @internal */
165
+ client: GitLabClientLike;
166
+ /** @internal */
167
+ writes: ExternalWrites;
168
+ /** @internal */
169
+ instanceId: string;
170
+ /** @internal */
171
+ projectId: number;
172
+ /** @internal */
173
+ iid: number;
174
+ /** @internal */
175
+ writeKey: string;
176
+ /** @internal */
177
+ sha: string;
178
+ /** @internal */
179
+ signal?: AbortSignal;
180
+ }): Promise<{
181
+ sha: string;
182
+ unapproved: boolean;
183
+ }>;
140
184
  /** @public */
141
185
  export declare function ensureGitLabSeenReaction(input: {
142
186
  /** @public */
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EACN,KAAK,+BAA+B,EAGpC,KAAK,kBAAkB,EAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,KAAK,gBAAgB,EAAoC,MAAM,aAAa,CAAC;AAatF,cAAc;AACd,wBAAgB,8BAA8B,CAC7C,GAAG,EAAE,IAAI,CAAC,+BAA+B,EAAE,SAAS,GAAG,SAAS,CAAC,EACjE,WAAW,CAAC,EAAE,iBAAiB,GAC7B;IACF,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;CAClB,CAsBA;AACD,cAAc;AACd,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,IAAI,CAAC,+BAA+B,EAAE,SAAS,GA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AW,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhB;AACD,gBAAgB;AAChB,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,kBAAkB,EACvB,WAAW,EAAE,iBAAiB,EAC9B,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,+BAA+B,KAAK,OAAO,CAAC,IAAI,CAAC,QAoOrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leitwerk-dev/gitlab",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "leitwerk": {
6
6
  "extension": {
@@ -25,12 +25,12 @@
25
25
  "build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
26
26
  },
27
27
  "dependencies": {
28
- "@leitwerk-dev/domain": "0.4.0",
29
- "@leitwerk-dev/external-writes": "0.4.0",
30
- "@leitwerk-dev/process-sdk": "0.4.0",
31
- "@leitwerk-dev/watcher-utils": "0.4.0",
32
- "@leitwerk-dev/test-support": "0.4.0",
33
- "@leitwerk-dev/coding": "0.4.0"
28
+ "@leitwerk-dev/domain": "0.4.2",
29
+ "@leitwerk-dev/external-writes": "0.4.2",
30
+ "@leitwerk-dev/process-sdk": "0.4.2",
31
+ "@leitwerk-dev/watcher-utils": "0.4.2",
32
+ "@leitwerk-dev/test-support": "0.4.2",
33
+ "@leitwerk-dev/coding": "0.4.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "tsup": "^8.5.1",
package/src/client.ts CHANGED
@@ -291,6 +291,8 @@ export interface GitLabObservation {
291
291
  mr: GitLabMergeRequest;
292
292
  /** @public */
293
293
  pipeline: GitLabPipeline | null;
294
+ /** Source head verified against pipeline/merge-result ancestry. @internal */
295
+ pipelineSourceHead?: string;
294
296
  /** @public */
295
297
  targetHead?: string;
296
298
  }
@@ -732,21 +734,53 @@ export class GitLabClient {
732
734
  signal,
733
735
  );
734
736
  }
735
- /** @public */
737
+ /** Open MRs matching every comma-separated label; null selects all accessible projects. @public */
736
738
  listMergeRequests(
737
- id: number,
739
+ id: number | null,
738
740
  label: string,
739
741
  signal?: AbortSignal,
740
742
  ): Promise<GitLabMergeRequest[]> {
741
- return this.pages(
742
- `${projectPath(id)}/merge_requests?state=opened&labels=${encodeURIComponent(label)}`,
743
- signal,
744
- );
743
+ const path = id === null ? "/merge_requests" : `${projectPath(id)}/merge_requests`;
744
+ return this.pages(`${path}?state=opened&scope=all&labels=${encodeURIComponent(label)}`, signal);
745
745
  }
746
746
  /** @internal */
747
747
  getMergeRequest(id: number, iid: number, signal?: AbortSignal): Promise<GitLabMergeRequest> {
748
748
  return this.request(mrPath(id, iid), signal);
749
749
  }
750
+ /** @internal */
751
+ getMergeRequestApprovals(
752
+ id: number,
753
+ iid: number,
754
+ signal?: AbortSignal,
755
+ ): Promise<{
756
+ /** @internal */
757
+ user_has_approved: boolean;
758
+ }> {
759
+ return this.request(`${mrPath(id, iid)}/approvals`, signal);
760
+ }
761
+ /** @internal */
762
+ approveMergeRequest(
763
+ id: number,
764
+ iid: number,
765
+ sha: string,
766
+ signal?: AbortSignal,
767
+ ): Promise<{
768
+ /** @internal */
769
+ sha: string;
770
+ }> {
771
+ return this.request(`${mrPath(id, iid)}/approve`, signal, { sha });
772
+ }
773
+ /** @internal */
774
+ unapproveMergeRequest(
775
+ id: number,
776
+ iid: number,
777
+ signal?: AbortSignal,
778
+ ): Promise<{
779
+ /** @internal */
780
+ sha: string;
781
+ }> {
782
+ return this.request(`${mrPath(id, iid)}/unapprove`, signal, {});
783
+ }
750
784
  /** Read every label transition, including changes between watcher polls. @public */
751
785
  listMergeRequestLabelEvents(
752
786
  id: number,
@@ -1046,6 +1080,9 @@ export type GitLabClientLike = Pick<
1046
1080
  | "getGroup"
1047
1081
  | "getJobTrace"
1048
1082
  | "getMergeRequest"
1083
+ | "getMergeRequestApprovals"
1084
+ | "approveMergeRequest"
1085
+ | "unapproveMergeRequest"
1049
1086
  | "listMergeRequestLabelEvents"
1050
1087
  | "updateMergeRequestLabels"
1051
1088
  | "getPipeline"
@@ -1099,7 +1136,12 @@ export async function observeMergeRequest(
1099
1136
  matches = commit.parent_ids.includes(mr.sha);
1100
1137
  }
1101
1138
  if (matches)
1102
- return { mr, targetHead, pipeline: await client.getPipeline(id, candidate.id, signal) };
1139
+ return {
1140
+ mr,
1141
+ targetHead,
1142
+ pipeline: await client.getPipeline(id, candidate.id, signal),
1143
+ pipelineSourceHead: mr.sha,
1144
+ };
1103
1145
  }
1104
1146
  const candidates = await client.listBranchPipelines(
1105
1147
  mr.source_project_id,
@@ -1114,5 +1156,6 @@ export async function observeMergeRequest(
1114
1156
  mr,
1115
1157
  targetHead,
1116
1158
  pipeline: latest ? await client.getPipeline(mr.source_project_id, latest.id, signal) : null,
1159
+ ...(latest ? { pipelineSourceHead: mr.sha } : {}),
1117
1160
  };
1118
1161
  }
package/src/index.ts CHANGED
@@ -76,7 +76,6 @@ export {
76
76
  type GitLabMaintenance,
77
77
  type GitLabMaintenanceContext,
78
78
  type GitLabMaintenanceDecision,
79
- type GitLabMaintenanceDestinations,
80
79
  type GitLabMaintenanceEvent,
81
80
  type GitLabMaintenanceMessage,
82
81
  type GitLabMaintenanceRecord,
@@ -52,15 +52,6 @@ export interface GitLabMaintenanceEvent<S> {
52
52
  state: S;
53
53
  }
54
54
  /** @public */
55
- export interface GitLabMaintenanceDestinations {
56
- /** @public */
57
- feedback: string;
58
- /** @public */
59
- conflict: string;
60
- /** @public */
61
- ci: string;
62
- }
63
- /** @public */
64
55
  export interface GitLabMaintainedBinding {
65
56
  /** Process repository key. @public */ projectKey: string;
66
57
  /** @public */ profile: string;
@@ -92,7 +83,7 @@ export interface GitLabMaintenanceContext<P, S> {
92
83
  /** @public */
93
84
  export interface GitLabMaintenanceDecision<S> {
94
85
  /** @public */ state: S;
95
- /** Destination key, or an additional recovery action declared by the process. @public */ action?: string;
86
+ /** External action identity declared by the process. @public */ action?: string;
96
87
  /** Process-specific event fields supplied to its external edge. @public */ event?: Record<
97
88
  string,
98
89
  unknown
@@ -113,7 +104,6 @@ export interface GitLabMaintainedProcess<
113
104
  /** @public */ processId: string;
114
105
  /** @public */ paramsCodec: Codec<P>;
115
106
  /** @public */ stateCodec: Codec<S>;
116
- /** External edge identities for business work. @public */ destinations: GitLabMaintenanceDestinations;
117
107
  /** Defaults to gitlabMaintenanceSource. @public */ sourceKind?: string;
118
108
  /** Defaults to each project's GitLab metadata. @public */ bindings?(
119
109
  ctx: GitLabMaintenanceContext<P, S>,
@@ -137,7 +127,7 @@ export interface GitLabMaintainedProcess<
137
127
  ctx: GitLabMaintenanceContext<P, S>,
138
128
  binding: GitLabMaintainedBinding,
139
129
  ): Promise<boolean>;
140
- /** Optional bounded infrastructure retry; repair budgets remain process policy. @public */
130
+ /** @deprecated Startup recovery uses the server's fixed budget. @public */
141
131
  retry?: GitLabMaintenanceRetry;
142
132
  /** Pure repair policy; shared maintenance supplies settled feedback and observations. @public */
143
133
  observe(
@@ -180,7 +170,7 @@ export interface GitLabMaintainedProcess<
180
170
  }
181
171
  /** @public */
182
172
  export interface GitLabMaintenanceRetry {
183
- /** Maximum automatic retries per failed business execution. @public */
173
+ /** @deprecated Ignored; the server allows three unaccepted starts per episode. @public */
184
174
  maxAttempts: number;
185
175
  }
186
176
  /** Durable activation and observation, kept separately from worker-owned outcome snapshots. @public */
@@ -609,13 +599,11 @@ export function createGitLabMaintenance(
609
599
  fresh.lifecycleStatus === "waiting" &&
610
600
  unchangedWork(fresh, ctx.process)
611
601
  ) {
612
- const destination =
613
- policy.destinations[decision.action as keyof typeof policy.destinations] ??
614
- decision.action;
615
602
  const armed = deps.externalSources
616
603
  .listArmed(policy.sourceKind ?? GITLAB_MAINTAINED_KIND)
617
604
  .find(
618
- (item) => item.instanceId === process.id && item.externalActionId === destination,
605
+ (item) =>
606
+ item.instanceId === process.id && item.externalActionId === decision.action,
619
607
  );
620
608
  if (armed) {
621
609
  await service.assertOwnership(fresh.id, binding.projectKey, ctx.signal);
@@ -645,37 +633,11 @@ export function createGitLabMaintenance(
645
633
  if (
646
634
  fresh &&
647
635
  eligible &&
648
- policy.retry &&
649
636
  fresh.lifecycleStatus === "error" &&
650
- fresh.currentExecution
637
+ fresh.currentExecution?.kind === "worker_start"
651
638
  ) {
652
- const retry = asUnknownRecord(fresh.metadata?.gitlabMaintenanceRetry) ?? {};
653
- const attempts = Number(retry.attempts ?? 0);
654
- if (retry.executionId !== fresh.currentExecution.id) {
655
- await observe(fresh, {
656
- metadata: {
657
- gitlabMaintenanceRetry: {
658
- attempts,
659
- executionId: fresh.currentExecution.id,
660
- nextAt: now() + Math.min(300_000, 30_000 * 2 ** attempts),
661
- attempted: false,
662
- },
663
- },
664
- preserveUpdatedAt: true,
665
- });
666
- } else if (
667
- !retry.attempted &&
668
- attempts < policy.retry.maxAttempts &&
669
- Number(retry.nextAt) <= now()
670
- ) {
671
- await service.assertOwnership(fresh.id, binding.projectKey, ctx.signal);
672
- const saved = await observe(fresh, {
673
- metadata: {
674
- gitlabMaintenanceRetry: { ...retry, attempts: attempts + 1, attempted: true },
675
- },
676
- });
677
- if (saved.ok) await deps.commands.retryProcess(fresh.id);
678
- }
639
+ await service.assertOwnership(fresh.id, binding.projectKey, ctx.signal);
640
+ await deps.commands.retryStartupAutomatically(fresh.id, fresh.currentExecution.id);
679
641
  } else if (
680
642
  fresh?.lifecycleStatus === "waiting" &&
681
643
  !fresh.currentExecution &&