@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/dist/index.js CHANGED
@@ -1,49 +1,107 @@
1
1
  import {
2
- GITLAB_MR_KIND,
3
2
  GitLabClient,
4
- GitLabError,
5
- createGitLabProvider,
6
- ensureGitLabComment,
7
3
  ensureGitLabSeenReaction,
8
4
  gitLabFeedbackReadyAt,
9
5
  gitlabExternal,
10
6
  gitlabIntegration,
11
7
  gitlabRepositoryCredentials,
12
- index_default,
13
- manifest,
14
8
  observationKey,
15
9
  observeMergeRequest,
16
10
  parseGitLabProfiles,
17
- parseGitLabSelection,
18
11
  pendingGitLabFeedback,
19
- projectExcluded,
20
- registerGitLabTools,
21
12
  resolveGitLabBinding,
22
- selectGitLabProjects,
23
13
  setupGitLabIntegration
24
- } from "./chunk-5GBBPAG5.js";
14
+ } from "./chunk-64FNBSKH.js";
15
+
16
+ // src/index.ts
17
+ import { coreHostCapabilities } from "@leitwerk-dev/process-sdk";
18
+
19
+ // src/selection.ts
20
+ function parseGitLabSelection(raw) {
21
+ const list = (value) => {
22
+ if (value === void 0) return [];
23
+ if (!Array.isArray(value) || value.some(
24
+ (v) => typeof v !== "string" || !/^[a-zA-Z0-9_.-]+(?:\/[a-zA-Z0-9_.-]+)*$/.test(v) || v.split("/").some((p) => p === "." || p === "..")
25
+ ))
26
+ throw new Error("GitLab selectors require exact namespace paths");
27
+ return [...new Set(value)];
28
+ };
29
+ const pair = (value) => {
30
+ if (value !== void 0 && (!value || typeof value !== "object" || Array.isArray(value)))
31
+ throw new Error("GitLab selectors must be objects");
32
+ const item = value;
33
+ return { include: list(item?.include), exclude: list(item?.exclude) };
34
+ };
35
+ if (raw.all_accessible !== void 0 && typeof raw.all_accessible !== "boolean")
36
+ throw new Error("all_accessible must be a boolean");
37
+ const parsed = {
38
+ projects: pair(raw.projects),
39
+ groups: pair(raw.groups),
40
+ allAccessible: raw.all_accessible === true
41
+ };
42
+ if (!parsed.allAccessible && !parsed.projects.include.length && !parsed.groups.include.length)
43
+ throw new Error("GitLab requires explicit project/group includes or all_accessible: true");
44
+ return parsed;
45
+ }
46
+ function projectExcluded(selection, name) {
47
+ return selection.projects.exclude.includes(name) || selection.groups.exclude.some((group) => name.startsWith(`${group}/`));
48
+ }
49
+ async function selectGitLabProjects(client, selection) {
50
+ const candidates = selection.allAccessible ? await client.listProjects() : [];
51
+ for (const name of selection.projects.include) candidates.push(await client.getProject(name));
52
+ for (const group of selection.groups.include)
53
+ candidates.push(...await client.listGroupProjects(group));
54
+ return [
55
+ ...new Map(
56
+ candidates.filter((p) => !p.archived && !projectExcluded(selection, p.path_with_namespace)).map((p) => [p.id, p])
57
+ ).values()
58
+ ];
59
+ }
60
+
61
+ // src/index.ts
62
+ var manifest = {
63
+ /** @internal */
64
+ id: "gitlab",
65
+ /** @internal */
66
+ version: "0.1.9"
67
+ };
68
+ var extension = {
69
+ manifest,
70
+ setupServer(api, config) {
71
+ const profiles = parseGitLabProfiles(config);
72
+ const clients = new Map([...profiles].map(([id, profile]) => [id, new GitLabClient(profile)]));
73
+ setupGitLabIntegration(api, {
74
+ profiles: () => [...profiles.keys()],
75
+ client: (profile) => {
76
+ const client = clients.get(profile);
77
+ if (!client) throw new Error(`Unknown GitLab profile '${profile}'`);
78
+ return client;
79
+ }
80
+ });
81
+ const deps = api.get(coreHostCapabilities.serverSetup);
82
+ if (!deps || Array.isArray(deps)) return;
83
+ deps.repositoryCredentials.register({
84
+ kind: "git_https",
85
+ resolve(ref) {
86
+ const profile = ref.startsWith("gitlab:") ? profiles.get(ref.slice(7)) : void 0;
87
+ return profile ? { origin: profile.baseUrl, username: "oauth2", password: profile.token } : null;
88
+ }
89
+ });
90
+ }
91
+ };
92
+ var index_default = extension;
25
93
  export {
26
- GITLAB_MR_KIND,
27
- GitLabClient,
28
- GitLabError,
29
- createGitLabProvider,
30
94
  index_default as default,
31
- ensureGitLabComment,
32
95
  ensureGitLabSeenReaction,
33
96
  gitLabFeedbackReadyAt,
34
97
  gitlabExternal,
35
98
  gitlabIntegration,
36
99
  gitlabRepositoryCredentials,
37
- manifest,
38
100
  observationKey,
39
101
  observeMergeRequest,
40
- parseGitLabProfiles,
41
102
  parseGitLabSelection,
42
103
  pendingGitLabFeedback,
43
- projectExcluded,
44
- registerGitLabTools,
45
104
  resolveGitLabBinding,
46
- selectGitLabProjects,
47
- setupGitLabIntegration
105
+ selectGitLabProjects
48
106
  };
49
107
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/selection.ts"],"sourcesContent":["import type { LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\nimport { coreHostCapabilities } from \"@leitwerk-dev/process-sdk\";\nimport { GitLabClient, parseGitLabProfiles } from \"./client.js\";\nimport { setupGitLabIntegration } from \"./setup.js\";\n\n/** @internal */\nconst manifest = {\n\t/** @internal */\n\tid: \"gitlab\",\n\t/** @internal */\n\tversion: \"0.1.9\",\n} as const;\n/** @public */\nconst extension: LeitwerkExtensionModule = {\n\tmanifest,\n\tsetupServer(api, config) {\n\t\tconst profiles = parseGitLabProfiles(config);\n\t\tconst clients = new Map([...profiles].map(([id, profile]) => [id, new GitLabClient(profile)]));\n\t\tsetupGitLabIntegration(api, {\n\t\t\tprofiles: () => [...profiles.keys()],\n\t\t\tclient: (profile) => {\n\t\t\t\tconst client = clients.get(profile);\n\t\t\t\tif (!client) throw new Error(`Unknown GitLab profile '${profile}'`);\n\t\t\t\treturn client;\n\t\t\t},\n\t\t});\n\t\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\t\tif (!deps || Array.isArray(deps)) return;\n\t\tdeps.repositoryCredentials.register({\n\t\t\tkind: \"git_https\",\n\t\t\tresolve(ref) {\n\t\t\t\tconst profile = ref.startsWith(\"gitlab:\") ? profiles.get(ref.slice(7)) : undefined;\n\t\t\t\treturn profile\n\t\t\t\t\t? { origin: profile.baseUrl, username: \"oauth2\", password: profile.token }\n\t\t\t\t\t: null;\n\t\t\t},\n\t\t});\n\t},\n};\nexport default extension;\nexport type { GitLabIntegration } from \"./capability.js\";\nexport {\n\tgitlabIntegration,\n\tgitlabRepositoryCredentials,\n} from \"./capability.js\";\nexport type {\n\tGitLabDiff,\n\tGitLabFeedback,\n\tGitLabIdentity,\n\tGitLabJob,\n\tGitLabMergeRequest,\n\tGitLabObservation,\n\tGitLabProject,\n} from \"./client.js\";\nexport { observeMergeRequest } from \"./client.js\";\nexport {\n\tgitLabFeedbackReadyAt,\n\tgitlabExternal,\n\tobservationKey,\n\tpendingGitLabFeedback,\n} from \"./external.js\";\nexport type { GitLabSelection } from \"./selection.js\";\nexport {\n\tparseGitLabSelection,\n\tselectGitLabProjects,\n} from \"./selection.js\";\nexport { ensureGitLabSeenReaction, resolveGitLabBinding } from \"./tools.js\";\n","import type { GitLabClientLike, GitLabProject } from \"./client.js\";\n/** @public */\nexport interface GitLabSelection {\n\t/** @public */\n\tprojects: {\n\t\t/** @public */\n\t\tinclude: readonly string[];\n\t\t/** @internal */\n\t\texclude: readonly string[];\n\t};\n\t/** @public */\n\tgroups: {\n\t\t/** @public */\n\t\tinclude: readonly string[];\n\t\t/** @internal */\n\t\texclude: readonly string[];\n\t};\n\t/** @internal */\n\tallAccessible: boolean;\n}\n/** @public */\nexport function parseGitLabSelection(raw: Record<string, unknown>): GitLabSelection {\n\tconst list = (value: unknown): string[] => {\n\t\tif (value === undefined) return [];\n\t\tif (\n\t\t\t!Array.isArray(value) ||\n\t\t\tvalue.some(\n\t\t\t\t(v) =>\n\t\t\t\t\ttypeof v !== \"string\" ||\n\t\t\t\t\t!/^[a-zA-Z0-9_.-]+(?:\\/[a-zA-Z0-9_.-]+)*$/.test(v) ||\n\t\t\t\t\tv.split(\"/\").some((p: string) => p === \".\" || p === \"..\"),\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(\"GitLab selectors require exact namespace paths\");\n\t\treturn [...new Set(value as string[])];\n\t};\n\tconst pair = (value: unknown) => {\n\t\tif (value !== undefined && (!value || typeof value !== \"object\" || Array.isArray(value)))\n\t\t\tthrow new Error(\"GitLab selectors must be objects\");\n\t\tconst item = value as Record<string, unknown> | undefined;\n\t\treturn { include: list(item?.include), exclude: list(item?.exclude) };\n\t};\n\tif (raw.all_accessible !== undefined && typeof raw.all_accessible !== \"boolean\")\n\t\tthrow new Error(\"all_accessible must be a boolean\");\n\tconst parsed = {\n\t\tprojects: pair(raw.projects),\n\t\tgroups: pair(raw.groups),\n\t\tallAccessible: raw.all_accessible === true,\n\t};\n\tif (!parsed.allAccessible && !parsed.projects.include.length && !parsed.groups.include.length)\n\t\tthrow new Error(\"GitLab requires explicit project/group includes or all_accessible: true\");\n\treturn parsed;\n}\n/** @internal */\nexport function projectExcluded(selection: GitLabSelection, name: string): boolean {\n\treturn (\n\t\tselection.projects.exclude.includes(name) ||\n\t\tselection.groups.exclude.some((group) => name.startsWith(`${group}/`))\n\t);\n}\n/** Include union, subgroup expansion, exclusion precedence, stable-ID deduplication. @public */\nexport async function selectGitLabProjects(\n\tclient: GitLabClientLike,\n\tselection: GitLabSelection,\n): Promise<GitLabProject[]> {\n\tconst candidates: GitLabProject[] = selection.allAccessible ? await client.listProjects() : [];\n\tfor (const name of selection.projects.include) candidates.push(await client.getProject(name));\n\tfor (const group of selection.groups.include)\n\t\tcandidates.push(...(await client.listGroupProjects(group)));\n\treturn [\n\t\t...new Map(\n\t\t\tcandidates\n\t\t\t\t.filter((p) => !p.archived && !projectExcluded(selection, p.path_with_namespace))\n\t\t\t\t.map((p) => [p.id, p]),\n\t\t).values(),\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,SAAS,4BAA4B;;;ACoB9B,SAAS,qBAAqB,KAA+C;AACnF,QAAM,OAAO,CAAC,UAA6B;AAC1C,QAAI,UAAU,OAAW,QAAO,CAAC;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AC;AAAA,EACF;AACD;AACA,IAAO,gBAAQ;","names":[]}
@@ -1,17 +1,27 @@
1
1
  import type { GitLabClientLike, GitLabProject } from "./client.js";
2
+ /** @public */
2
3
  export interface GitLabSelection {
4
+ /** @public */
3
5
  projects: {
6
+ /** @public */
4
7
  include: readonly string[];
8
+ /** @internal */
5
9
  exclude: readonly string[];
6
10
  };
11
+ /** @public */
7
12
  groups: {
13
+ /** @public */
8
14
  include: readonly string[];
15
+ /** @internal */
9
16
  exclude: readonly string[];
10
17
  };
18
+ /** @internal */
11
19
  allAccessible: boolean;
12
20
  }
21
+ /** @public */
13
22
  export declare function parseGitLabSelection(raw: Record<string, unknown>): GitLabSelection;
23
+ /** @internal */
14
24
  export declare function projectExcluded(selection: GitLabSelection, name: string): boolean;
15
- /** Include union, subgroup expansion, exclusion precedence, stable-ID deduplication. */
25
+ /** Include union, subgroup expansion, exclusion precedence, stable-ID deduplication. @public */
16
26
  export declare function selectGitLabProjects(client: GitLabClientLike, selection: GitLabSelection): Promise<GitLabProject[]>;
17
27
  //# sourceMappingURL=selection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../src/selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,MAAM,WAAW,eAAe;IAC/B,QAAQ,EAAE;QAAE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;IACrE,MAAM,EAAE;QAAE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;IACnE,aAAa,EAAE,OAAO,CAAC;CACvB;AACD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,CA+BlF;AACD,wBAAgB,eAAe,CAAC,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKjF;AACD,wFAAwF;AACxF,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,eAAe,GACxB,OAAO,CAAC,aAAa,EAAE,CAAC,CAY1B"}
1
+ {"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../src/selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,cAAc;AACd,MAAM,WAAW,eAAe;IAC/B,cAAc;IACd,QAAQ,EAAE;QACT,cAAc;QACd,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QAC3B,gBAAgB;QAChB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;KAC3B,CAAC;IACF,cAAc;IACd,MAAM,EAAE;QACP,cAAc;QACd,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QAC3B,gBAAgB;QAChB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;KAC3B,CAAC;IACF,gBAAgB;IAChB,aAAa,EAAE,OAAO,CAAC;CACvB;AACD,cAAc;AACd,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,CA+BlF;AACD,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKjF;AACD,gGAAgG;AAChG,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,eAAe,GACxB,OAAO,CAAC,aAAa,EAAE,CAAC,CAY1B"}
@@ -0,0 +1,11 @@
1
+ import { type ServerExtensionAPI } from "@leitwerk-dev/process-sdk";
2
+ import { type GitLabIntegration } from "./capability.js";
3
+ /** Register shared tools and polling with an explicit integration. @public */
4
+ export declare function setupGitLabIntegration(api: ServerExtensionAPI, integration: GitLabIntegration, options?: {
5
+ /** @public */
6
+ now?: () => number;
7
+ }): {
8
+ /** @public */
9
+ poll(): Promise<import("@leitwerk-dev/watcher-utils").PollResult>;
10
+ } | undefined;
11
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,iBAAiB,CAAC;AAI5E,8EAA8E;AAC9E,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,kBAAkB,EACvB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE;IACR,cAAc;IACd,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACd;;;cAON"}
package/dist/testing.d.ts CHANGED
@@ -1,32 +1,56 @@
1
1
  import type { GitLabClientLike, GitLabDiff, GitLabFeedback, GitLabMergeRequest, GitLabNote, GitLabNoteReaction, GitLabPipeline, GitLabProject } from "./client.js";
2
- export type { GitLabClientLike, GitLabMergeRequest, GitLabPipeline, GitLabProject, } from "./client.js";
3
- export { setupGitLabIntegration } from "./index.js";
2
+ export { setupGitLabIntegration } from "./setup.js";
3
+ /** @public */
4
4
  interface LocalState {
5
+ /** @internal */
5
6
  projects: GitLabProject[];
7
+ /** @internal */
6
8
  mrs: GitLabMergeRequest[];
9
+ /** @internal */
7
10
  pipelines: GitLabPipeline[];
11
+ /** @public */
8
12
  notes: Record<string, GitLabNote[]>;
13
+ /** @internal */
9
14
  diffs: Record<string, GitLabDiff[]>;
15
+ /** @public */
10
16
  feedback?: Record<string, GitLabFeedback[]>;
17
+ /** @public */
11
18
  discussionNotes?: Record<string, GitLabNote[]>;
19
+ /** @public */
12
20
  reactions?: Record<string, GitLabNoteReaction[]>;
13
21
  }
14
- /** Persistent GitLab test boundary. Repository URLs use local Git's file transport. */
22
+ /** Persistent GitLab test boundary. Repository URLs use local Git's file transport. @public */
15
23
  export declare class LocalGitLabAdapter {
24
+ /** @internal */
16
25
  readonly root: string;
26
+ /** @internal */
17
27
  readonly baseUrl: string;
28
+ /** @public */
18
29
  state: LocalState;
30
+ /** @public */
19
31
  loseNextCommentResponse: boolean;
32
+ /** @public */
20
33
  loseNextReplyResponse: boolean;
34
+ /** @public */
21
35
  loseNextReactionResponse: boolean;
22
- constructor(root: string, baseUrl?: string);
36
+ /** @public */
37
+ constructor(
38
+ /** @internal */
39
+ root: string,
40
+ /** @internal */
41
+ baseUrl?: string);
42
+ /** @public */
23
43
  save(): void;
24
44
  private append;
25
45
  private project;
26
46
  private git;
47
+ /** @public */
27
48
  addProject(name: string, bare: string): GitLabProject;
49
+ /** @public */
28
50
  openMr(project: GitLabProject, branch: string): GitLabMergeRequest;
51
+ /** @public */
29
52
  pipeline(mr: GitLabMergeRequest, status: string): GitLabPipeline;
53
+ /** @public */
30
54
  client(): GitLabClientLike;
31
55
  }
32
56
  //# sourceMappingURL=testing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,MAAM,aAAa,CAAC;AAErB,YAAY,EACX,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,UAAU,UAAU;IACnB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,GAAG,EAAE,kBAAkB,EAAE,CAAC;IAC1B,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IACpC,KAAK,EAAE,MAAM,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mH1B"}
package/dist/testing.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  setupGitLabIntegration
3
- } from "./chunk-5GBBPAG5.js";
3
+ } from "./chunk-64FNBSKH.js";
4
4
 
5
5
  // src/testing.ts
6
6
  import { execFileSync } from "child_process";
7
7
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
8
8
  import path from "path";
9
9
  var LocalGitLabAdapter = class {
10
+ /** @public */
10
11
  constructor(root, baseUrl = "https://gitlab.test") {
11
12
  this.root = root;
12
13
  this.baseUrl = baseUrl;
@@ -16,10 +17,15 @@ var LocalGitLabAdapter = class {
16
17
  }
17
18
  root;
18
19
  baseUrl;
20
+ /** @public */
19
21
  state;
22
+ /** @public */
20
23
  loseNextCommentResponse = false;
24
+ /** @public */
21
25
  loseNextReplyResponse = false;
26
+ /** @public */
22
27
  loseNextReactionResponse = false;
28
+ /** @public */
23
29
  save() {
24
30
  writeFileSync(path.join(this.root, "gitlab.json"), JSON.stringify(this.state), { mode: 384 });
25
31
  }
@@ -50,6 +56,7 @@ var LocalGitLabAdapter = class {
50
56
  { encoding: "utf8" }
51
57
  ).trim();
52
58
  }
59
+ /** @public */
53
60
  addProject(name, bare) {
54
61
  const project = {
55
62
  id: this.state.projects.length + 1,
@@ -62,6 +69,7 @@ var LocalGitLabAdapter = class {
62
69
  this.save();
63
70
  return project;
64
71
  }
72
+ /** @public */
65
73
  openMr(project, branch) {
66
74
  const mr = {
67
75
  iid: this.state.mrs.length + 1,
@@ -81,6 +89,7 @@ var LocalGitLabAdapter = class {
81
89
  this.save();
82
90
  return mr;
83
91
  }
92
+ /** @public */
84
93
  pipeline(mr, status) {
85
94
  const value = {
86
95
  id: this.state.pipelines.length + 1,
@@ -95,6 +104,7 @@ var LocalGitLabAdapter = class {
95
104
  this.save();
96
105
  return value;
97
106
  }
107
+ /** @public */
98
108
  client() {
99
109
  const mr = (id, iid) => {
100
110
  const m = this.state.mrs.find((m2) => m2.project_id === id && m2.iid === 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\tGitLabMergeRequest,\n\tGitLabNote,\n\tGitLabNoteReaction,\n\tGitLabPipeline,\n\tGitLabProject,\n} from \"./client.js\";\n\nexport type {\n\tGitLabClientLike,\n\tGitLabMergeRequest,\n\tGitLabPipeline,\n\tGitLabProject,\n} from \"./client.js\";\nexport { setupGitLabIntegration } from \"./index.js\";\n\ninterface LocalState {\n\tprojects: GitLabProject[];\n\tmrs: GitLabMergeRequest[];\n\tpipelines: GitLabPipeline[];\n\tnotes: Record<string, GitLabNote[]>;\n\tdiffs: Record<string, GitLabDiff[]>;\n\tfeedback?: Record<string, GitLabFeedback[]>;\n\tdiscussionNotes?: Record<string, GitLabNote[]>;\n\treactions?: Record<string, GitLabNoteReaction[]>;\n}\n/** Persistent GitLab test boundary. Repository URLs use local Git's file transport. */\nexport class LocalGitLabAdapter {\n\tstate: LocalState;\n\tloseNextCommentResponse = false;\n\tloseNextReplyResponse = false;\n\tloseNextReactionResponse = false;\n\tconstructor(\n\t\treadonly root: string,\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\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\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\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\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\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\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 Error(\"Unknown test MR\");\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\tgetProject: async (id) => structuredClone(this.project(id)),\n\t\t\tlistProjects: async () => structuredClone(this.state.projects),\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\tsha: commit(mr(id, iid).source_project_id, mr(id, iid).source_branch).id,\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\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\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\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\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\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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MAClE;AAAA,MACA,mBAAmB,OAAO,IAAI,KAAK,WAClC,gBAAgB,KAAK,MAAM,YAAY,GAAG,EAAE,IAAI,GAAG,IAAI,MAAM,EAAE,KAAK,CAAC,CAAC;AAAA,MACvE,iBAAiB,OAAO,IAAI,KAAK,QAAQ,SAAS;AACjD,cAAM,MAAM,GAAG,EAAE,IAAI,GAAG,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,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\tGitLabMergeRequest,\n\tGitLabNote,\n\tGitLabNoteReaction,\n\tGitLabPipeline,\n\tGitLabProject,\n} from \"./client.js\";\n\nexport { setupGitLabIntegration } from \"./setup.js\";\n\n/** @public */\ninterface LocalState {\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/** @public */\n\treactions?: Record<string, GitLabNoteReaction[]>;\n}\n/** Persistent GitLab test boundary. Repository URLs use local Git's file transport. @public */\nexport class LocalGitLabAdapter {\n\t/** @public */\n\tstate: LocalState;\n\t/** @public */\n\tloseNextCommentResponse = false;\n\t/** @public */\n\tloseNextReplyResponse = false;\n\t/** @public */\n\tloseNextReactionResponse = 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\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\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 Error(\"Unknown test MR\");\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\tgetProject: async (id) => structuredClone(this.project(id)),\n\t\t\tlistProjects: async () => structuredClone(this.state.projects),\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\tsha: commit(mr(id, iid).source_project_id, mr(id, iid).source_branch).id,\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\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\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\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\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\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};\n\t}\n}\n"],"mappings":";;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,WAAW,cAAc,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G,IAAI,MAAM,EAAE,KAAK,CAAC,CAAC;AAAA,MACvE,iBAAiB,OAAO,IAAI,KAAK,QAAQ,SAAS;AACjD,cAAM,MAAM,GAAG,EAAE,IAAI,GAAG,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,IACD;AAAA,EACD;AACD;","names":["p","m","reaction"]}
package/dist/tools.d.ts CHANGED
@@ -1,33 +1,57 @@
1
- import { type ExternalWriteLogRepoLike } from "@leitwerk-dev/external-writes";
1
+ import type { ExternalWrites } from "@leitwerk-dev/external-writes";
2
2
  import { type IntegrationToolExecutionContext, type ServerExtensionAPI } from "@leitwerk-dev/process-sdk";
3
3
  import type { GitLabIntegration } from "./capability.js";
4
4
  import { type GitLabClientLike } from "./client.js";
5
+ /** @public */
5
6
  export declare function resolveGitLabBinding(ctx: Pick<IntegrationToolExecutionContext, "project" | "process">): {
7
+ /** @public */
6
8
  profile: string;
9
+ /** @public */
7
10
  projectId: number;
11
+ /** @public */
8
12
  iid: number;
9
13
  };
14
+ /** @internal */
10
15
  export declare function ensureGitLabComment(input: {
16
+ /** @internal */
11
17
  client: GitLabClientLike;
12
- writes: ExternalWriteLogRepoLike;
18
+ /** @internal */
19
+ writes: ExternalWrites;
20
+ /** @internal */
13
21
  instanceId: string;
22
+ /** @internal */
14
23
  projectId: number;
24
+ /** @internal */
15
25
  iid: number;
26
+ /** @internal */
16
27
  writeKey: string;
28
+ /** @internal */
17
29
  body: string;
30
+ /** @internal */
18
31
  discussionId?: string;
32
+ /** @internal */
19
33
  signal?: AbortSignal;
20
34
  }): Promise<{
35
+ /** @internal */
21
36
  marker: string;
22
37
  }>;
38
+ /** @public */
23
39
  export declare function ensureGitLabSeenReaction(input: {
40
+ /** @public */
24
41
  client: GitLabClientLike;
25
- writes: ExternalWriteLogRepoLike;
42
+ /** @public */
43
+ writes: ExternalWrites;
44
+ /** @public */
26
45
  instanceId: string;
46
+ /** @public */
27
47
  projectId: number;
48
+ /** @public */
28
49
  iid: number;
50
+ /** @public */
29
51
  noteId: number;
52
+ /** @public */
30
53
  signal?: AbortSignal;
31
54
  }): Promise<void>;
32
- export declare function registerGitLabTools(api: ServerExtensionAPI, integration: GitLabIntegration, writes: ExternalWriteLogRepoLike): void;
55
+ /** @internal */
56
+ export declare function registerGitLabTools(api: ServerExtensionAPI, integration: GitLabIntegration): void;
33
57
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,wBAAwB,EAE7B,MAAM,+BAA+B,CAAC;AACvC,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,EAAuB,MAAM,aAAa,CAAC;AACzE,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,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CAAC,IAAI,CAAC,CAsBhB;AACD,gBAAgB;AAChB,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,QAuE1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leitwerk-dev/gitlab",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "leitwerk": {
6
6
  "extension": {
@@ -25,11 +25,11 @@
25
25
  "build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
26
26
  },
27
27
  "dependencies": {
28
- "@leitwerk-dev/domain": "0.2.0",
29
- "@leitwerk-dev/external-writes": "0.2.0",
30
- "@leitwerk-dev/process-sdk": "0.2.0",
31
- "@leitwerk-dev/watcher-utils": "0.2.0",
32
- "@leitwerk-dev/test-support": "0.2.0"
28
+ "@leitwerk-dev/domain": "0.2.1",
29
+ "@leitwerk-dev/external-writes": "0.2.1",
30
+ "@leitwerk-dev/process-sdk": "0.2.1",
31
+ "@leitwerk-dev/watcher-utils": "0.2.1",
32
+ "@leitwerk-dev/test-support": "0.2.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "tsup": "^8.5.1",
package/src/capability.ts CHANGED
@@ -4,14 +4,18 @@ import {
4
4
  type RepositoryCredentialRequirement,
5
5
  } from "@leitwerk-dev/process-sdk";
6
6
  import type { GitLabClientLike } from "./client.js";
7
+ /** @public */
7
8
  export interface GitLabIntegration {
9
+ /** @public */
8
10
  profiles(): readonly string[];
11
+ /** @public */
9
12
  client(profile: string): GitLabClientLike;
10
13
  }
14
+ /** @public */
11
15
  export const gitlabIntegration = createCapabilityToken<GitLabIntegration>(
12
16
  "@leitwerk-dev/gitlab.integration",
13
17
  );
14
- /** Internal references are derived from the same profile as API access. */
18
+ /** Internal references are derived from the same profile as API access. @public */
15
19
  export function gitlabRepositoryCredentials(
16
20
  profile: string,
17
21
  projects: readonly RepositoryCredentialProject[],