@leitwerk-dev/gitlab 0.0.0-bootstrap.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -1
- package/dist/LICENSE +13 -0
- package/dist/capability.d.ts +10 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/chunk-5GBBPAG5.js +656 -0
- package/dist/chunk-5GBBPAG5.js.map +1 -0
- package/dist/client.d.ts +179 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/external.d.ts +32 -0
- package/dist/external.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/merge-request.test-fixture.d.ts +3 -0
- package/dist/merge-request.test-fixture.d.ts.map +1 -0
- package/dist/selection.d.ts +17 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/testing.d.ts +32 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +209 -0
- package/dist/testing.js.map +1 -0
- package/dist/tools.d.ts +33 -0
- package/dist/tools.d.ts.map +1 -0
- package/package.json +54 -14
- package/src/capability.ts +24 -0
- package/src/client.ts +483 -0
- package/src/external.ts +144 -0
- package/src/index.ts +54 -0
- package/src/merge-request.test-fixture.ts +16 -0
- package/src/selection.ts +61 -0
- package/src/testing.ts +239 -0
- package/src/tools.ts +182 -0
package/README.md
CHANGED
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
# GitLab
|
|
2
|
+
|
|
3
|
+
`@leitwerk-dev/gitlab` supplies GitLab v4 API access and repository-scoped HTTPS Git authentication from one server-owned profile. Load this optional extension on the server and worker.
|
|
4
|
+
|
|
5
|
+
```yaml
|
|
6
|
+
extensions:
|
|
7
|
+
gitlab:
|
|
8
|
+
profiles:
|
|
9
|
+
example:
|
|
10
|
+
base_url: https://forge.test
|
|
11
|
+
token: env:GITLAB_TOKEN
|
|
12
|
+
# Optional, when /user cannot provide a usable commit identity:
|
|
13
|
+
# git_identity:
|
|
14
|
+
# name: Leitwerk Bot
|
|
15
|
+
# email: bot@example.net
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`base_url` must be an HTTPS origin without credentials, a query or a fragment. Supply a personal, project or group token with `api` and `write_repository` scopes and permission to push the selected source branches. Tokens stay on the server except for the selected repository's authenticated `worker.start` delivery. No separate Git credential configuration is needed. Missing tokens, identity or permissions are configuration errors.
|
|
19
|
+
|
|
20
|
+
## Public interface
|
|
21
|
+
|
|
22
|
+
- `GitLabClientLike` defines project/group discovery, MR metadata and paginated changes, branches/commits, pipelines, failed jobs, bounded traces, bot identity and notes. `GitLabClient` implements it using HTTPS, pagination and bounded transient read retries. Errors omit response bodies and credentials. Writes are reconciled by their caller rather than blindly repeated.
|
|
23
|
+
- `gitlabIntegration` exposes `profiles()` and `client(profile)` through the SDK capability registry. `setupGitLabIntegration()` registers an explicit adapter for tools and external observations.
|
|
24
|
+
- `gitlabRepositoryCredentials(profile, projects)` derives internal credential references. The core authorizes their HTTPS origin and exact repository path against the process projects.
|
|
25
|
+
- `selectGitLabProjects()` expands exact includes and groups, including subgroups, then applies exclusions. Includes form a union; stable project IDs remove duplicates. An explicit include or `all_accessible: true` is required.
|
|
26
|
+
- `observeMergeRequest()` selects the newest pipeline associated with the current MR source revision. Synthetic merge commits must contain that head as a parent. With no matching MR pipeline, it falls back to the current source branch's push pipeline. A newer pending result supersedes older terminal results.
|
|
27
|
+
- `gitlabExternal.mergeRequest()` reports MR closure/merge, source-head changes and CI observations. Its `afterKey` is the previous `observationKey()`. An optional `wakeAt` timestamp permits recovery timers without retaining a worker. Poll failures back off from 30 seconds to five minutes and surface diagnostics.
|
|
28
|
+
|
|
29
|
+
## Project-bound tools
|
|
30
|
+
|
|
31
|
+
Project metadata binds tools to `{ gitlab: { profile, projectId, iid } }`. Each call requires an authorized process project. Available tools are `gitlab_observe_merge_request`, `gitlab_get_changes`, `gitlab_get_identity`, `gitlab_list_failed_jobs`, `gitlab_get_job_trace`, `gitlab_comment`, and `gitlab_reply`. Job and pipeline reads verify membership in the bound MR's current pipeline. Traces cap individual reads at 256 KiB; truncation is explicit.
|
|
32
|
+
|
|
33
|
+
Comments require a stable business `writeKey`. `ensureGitLabComment()` combines it with the instance, project, MR and process IDs, appends a hidden marker, and uses `ensureWrite()`. It searches remote notes before creating a comment and after an uncertain write. `gitlab_reply` additionally requires `discussionId` and reconciles within that discussion. Repeating a call after losing either the response or the local write-log record reuses the same remote comment.
|
|
34
|
+
|
|
35
|
+
The MR external source can also observe review feedback using `feedback: { afterId, since, quietPeriodMs }`. It reads paginated discussions, preserving inline file/line context, and excludes system/resolved notes, the authenticated bot and accounts flagged as bots. Each new unseen note resets the trailing quiet period; a mature batch wakes the process even when the MR revision and CI status are unchanged. The process owns the durable cursor and decides when feedback is consumed. The provider recomputes timing from note timestamps after restart.
|
|
36
|
+
|
|
37
|
+
`ensureGitLabSeenReaction()` lets a process acknowledge an authorized MR comment with an eyes reaction. It reconciles the authenticated bot's reaction and records it with `ensureWrite()`. Other users' eyes reactions do not suppress the bot's acknowledgement; retries and restarts do not duplicate it. The calling process owns selection and lifecycle checks.
|
|
38
|
+
|
|
39
|
+
The extension contains no Renovate selection or repair policy. `./testing` exports a persistent `LocalGitLabAdapter` with real local repository ancestry for integration tests.
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2026 Leitwerk contributors.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type RepositoryCredentialProject, type RepositoryCredentialRequirement } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
import type { GitLabClientLike } from "./client.js";
|
|
3
|
+
export interface GitLabIntegration {
|
|
4
|
+
profiles(): readonly string[];
|
|
5
|
+
client(profile: string): GitLabClientLike;
|
|
6
|
+
}
|
|
7
|
+
export declare const gitlabIntegration: import("@leitwerk-dev/process-sdk").CapabilityToken<GitLabIntegration>;
|
|
8
|
+
/** Internal references are derived from the same profile as API access. */
|
|
9
|
+
export declare function gitlabRepositoryCredentials(profile: string, projects: readonly RepositoryCredentialProject[]): RepositoryCredentialRequirement[];
|
|
10
|
+
//# sourceMappingURL=capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,2BAA2B,EAChC,KAAK,+BAA+B,EACpC,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,MAAM,WAAW,iBAAiB;IACjC,QAAQ,IAAI,SAAS,MAAM,EAAE,CAAC;IAC9B,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAC1C;AACD,eAAO,MAAM,iBAAiB,wEAE7B,CAAC;AACF,2EAA2E;AAC3E,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,SAAS,2BAA2B,EAAE,GAC9C,+BAA+B,EAAE,CAMnC"}
|