@apiclient.xyz/gitlab 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/gitlab.classes.branch.d.ts +7 -0
  3. package/dist_ts/gitlab.classes.branch.js +13 -0
  4. package/dist_ts/gitlab.classes.gitlabclient.d.ts +117 -32
  5. package/dist_ts/gitlab.classes.gitlabclient.js +278 -96
  6. package/dist_ts/gitlab.classes.group.d.ts +47 -0
  7. package/dist_ts/gitlab.classes.group.js +97 -0
  8. package/dist_ts/gitlab.classes.job.d.ts +29 -0
  9. package/dist_ts/gitlab.classes.job.js +74 -0
  10. package/dist_ts/gitlab.classes.pipeline.d.ts +32 -0
  11. package/dist_ts/gitlab.classes.pipeline.js +87 -0
  12. package/dist_ts/gitlab.classes.project.d.ts +63 -0
  13. package/dist_ts/gitlab.classes.project.js +122 -0
  14. package/dist_ts/gitlab.classes.protectedbranch.d.ts +8 -0
  15. package/dist_ts/gitlab.classes.protectedbranch.js +15 -0
  16. package/dist_ts/gitlab.classes.tag.d.ts +7 -0
  17. package/dist_ts/gitlab.classes.tag.js +13 -0
  18. package/dist_ts/gitlab.classes.testreport.d.ts +34 -0
  19. package/dist_ts/gitlab.classes.testreport.js +67 -0
  20. package/dist_ts/gitlab.classes.variable.d.ts +18 -0
  21. package/dist_ts/gitlab.classes.variable.js +35 -0
  22. package/dist_ts/gitlab.helpers.d.ts +8 -0
  23. package/dist_ts/gitlab.helpers.js +23 -0
  24. package/dist_ts/gitlab.interfaces.d.ts +114 -9
  25. package/dist_ts/gitlab.interfaces.js +4 -1
  26. package/dist_ts/index.d.ts +11 -1
  27. package/dist_ts/index.js +15 -1
  28. package/package.json +1 -1
  29. package/readme.md +468 -163
  30. package/ts/00_commitinfo_data.ts +1 -1
  31. package/ts/gitlab.classes.branch.ts +18 -0
  32. package/ts/gitlab.classes.gitlabclient.ts +354 -114
  33. package/ts/gitlab.classes.group.ts +137 -0
  34. package/ts/gitlab.classes.job.ts +104 -0
  35. package/ts/gitlab.classes.pipeline.ts +122 -0
  36. package/ts/gitlab.classes.project.ts +177 -0
  37. package/ts/gitlab.classes.protectedbranch.ts +21 -0
  38. package/ts/gitlab.classes.tag.ts +18 -0
  39. package/ts/gitlab.classes.testreport.ts +97 -0
  40. package/ts/gitlab.classes.variable.ts +50 -0
  41. package/ts/gitlab.helpers.ts +26 -0
  42. package/ts/gitlab.interfaces.ts +162 -11
  43. package/ts/index.ts +25 -0
package/readme.md CHANGED
@@ -1,16 +1,82 @@
1
1
  # @apiclient.xyz/gitlab
2
2
 
3
- A TypeScript client for the GitLab API, providing easy access to projects, groups, CI/CD variables, and pipelines.
3
+ A powerful, fully-typed TypeScript client for the GitLab API 🚀
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@apiclient.xyz/gitlab.svg)](https://www.npmjs.com/package/@apiclient.xyz/gitlab)
6
+ [![license](https://img.shields.io/npm/l/@apiclient.xyz/gitlab.svg)](./LICENSE)
7
+
8
+ `@apiclient.xyz/gitlab` gives you a clean, object-oriented interface to the GitLab REST API. It wraps projects, groups, pipelines, jobs, CI/CD variables, branches, tags, protected branches, and test reports into rich domain classes with full auto-pagination support. Works with any GitLab instance -- cloud or self-hosted.
9
+
10
+ ## Issue Reporting and Security
11
+
12
+ For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
4
13
 
5
14
  ## Install
6
15
 
7
16
  ```bash
8
17
  npm install @apiclient.xyz/gitlab
18
+ # or
19
+ pnpm install @apiclient.xyz/gitlab
9
20
  ```
10
21
 
11
- ## Usage
22
+ ## Quick Start ⚡
23
+
24
+ ```typescript
25
+ import { GitLabClient } from '@apiclient.xyz/gitlab';
26
+
27
+ const client = new GitLabClient('https://gitlab.example.com', 'your-private-token');
28
+
29
+ // Verify connectivity
30
+ const { ok, error } = await client.testConnection();
31
+ console.log(ok ? '✅ Connected!' : `❌ ${error}`);
32
+
33
+ // Grab all your projects
34
+ const projects = await client.getProjects();
35
+ for (const project of projects) {
36
+ console.log(`${project.name} — ${project.webUrl}`);
37
+ }
38
+ ```
39
+
40
+ That's it. No boilerplate, no callback soup, just straightforward async/await.
41
+
42
+ ## Core Concepts 🧠
43
+
44
+ ### Rich Domain Objects
45
+
46
+ Every API response is wrapped in a **domain class** that exposes typed properties and chainable methods. You never deal with raw JSON unless you want to -- every class has a `.toJSON()` escape hatch.
47
+
48
+ ```
49
+ GitLabClient
50
+ ├── GitLabGroup → .getProjects(), .getVariables(), .update(), .delete(), ...
51
+ ├── GitLabProject → .getPipelines(), .getBranches(), .getVariables(), .triggerPipeline(), ...
52
+ │ ├── GitLabBranch
53
+ │ ├── GitLabTag
54
+ │ ├── GitLabProtectedBranch
55
+ │ └── GitLabVariable
56
+ ├── GitLabPipeline → .getJobs(), .getTestReport(), .retry(), .cancel(), .delete()
57
+ │ ├── GitLabJob → .getLog(), .retry(), .cancel(), .play(), .erase()
58
+ │ ├── GitLabPipelineVariable
59
+ │ └── GitLabTestReport
60
+ │ └── GitLabTestSuite
61
+ │ └── GitLabTestCase
62
+ └── GitLabVariable
63
+ ```
64
+
65
+ ### Auto-Pagination 🔄
66
+
67
+ List endpoints automatically page through **all** results by default. Need just one page? Pass `{ page: N }` explicitly.
68
+
69
+ ```typescript
70
+ // Fetches ALL groups (auto-paginates transparently)
71
+ const allGroups = await client.getGroups();
72
+
73
+ // Fetches only page 2, 10 per page
74
+ const page2 = await client.getGroups({ page: 2, perPage: 10 });
75
+ ```
12
76
 
13
- All examples below use ESM imports and async/await.
77
+ The `autoPaginate` helper is also exported if you want to use it in custom integrations.
78
+
79
+ ## Usage
14
80
 
15
81
  ### Creating a Client
16
82
 
@@ -20,7 +86,7 @@ import { GitLabClient } from '@apiclient.xyz/gitlab';
20
86
  const client = new GitLabClient('https://gitlab.example.com', 'your-private-token');
21
87
  ```
22
88
 
23
- The constructor accepts the base URL of your GitLab instance and a personal access token (or project/group token) used for authentication via the `PRIVATE-TOKEN` header.
89
+ The constructor takes the base URL of your GitLab instance and a personal access token (or project/group token) for `PRIVATE-TOKEN` header authentication.
24
90
 
25
91
  ### Testing the Connection
26
92
 
@@ -34,263 +100,502 @@ if (result.ok) {
34
100
  }
35
101
  ```
36
102
 
37
- ### Listing Projects
103
+ ---
38
104
 
39
- Retrieve projects you are a member of, ordered by most recently updated.
105
+ ### Groups 🏢
106
+
107
+ #### List All Groups
108
+
109
+ ```typescript
110
+ const groups = await client.getGroups();
111
+
112
+ // Search by name
113
+ const devGroups = await client.getGroups({ search: 'platform' });
114
+
115
+ for (const group of devGroups) {
116
+ console.log(`${group.id} — ${group.fullPath} (${group.visibility})`);
117
+ }
118
+ ```
119
+
120
+ #### Get a Single Group
121
+
122
+ ```typescript
123
+ const group = await client.getGroup('my-org/my-team');
124
+ console.log(group.name, group.webUrl);
125
+ ```
126
+
127
+ #### Create a Group
128
+
129
+ ```typescript
130
+ const newGroup = await client.createGroup('backend-team', 'backend-team');
131
+
132
+ // Create a sub-group under an existing parent
133
+ const subGroup = await client.createGroup('api-squad', 'api-squad', parentGroup.id);
134
+ ```
135
+
136
+ #### Group Operations
137
+
138
+ ```typescript
139
+ // Update properties
140
+ await group.update({ description: 'The backend crew 🔧', visibility: 'internal' });
141
+
142
+ // Upload / remove avatar
143
+ await group.setAvatar(imageBytes, 'logo.png');
144
+ await group.deleteAvatar();
145
+
146
+ // Transfer to another parent group
147
+ await group.transfer(targetGroupId);
148
+
149
+ // List descendant sub-groups
150
+ const children = await group.getDescendantGroups();
151
+
152
+ // List projects inside the group
153
+ const projects = await group.getProjects({ search: 'api' });
154
+
155
+ // Delete
156
+ await group.delete();
157
+ ```
158
+
159
+ ---
160
+
161
+ ### Projects 📦
162
+
163
+ #### List All Projects
40
164
 
41
165
  ```typescript
42
- // First page, default 50 per page
43
166
  const projects = await client.getProjects();
44
167
 
45
168
  // Search with pagination
46
- const filtered = await client.getProjects({
47
- search: 'my-service',
48
- page: 1,
49
- perPage: 20,
50
- });
169
+ const matches = await client.getProjects({ search: 'my-service', perPage: 20 });
51
170
 
52
- for (const project of filtered) {
53
- console.log(`${project.id} - ${project.path_with_namespace}`);
171
+ for (const p of matches) {
172
+ console.log(`${p.id} ${p.fullPath} [${p.defaultBranch}]`);
54
173
  }
55
174
  ```
56
175
 
57
- ### Listing Groups
176
+ #### Get a Single Project
58
177
 
59
178
  ```typescript
60
- const groups = await client.getGroups();
179
+ // By numeric ID
180
+ const project = await client.getProject(42);
181
+
182
+ // By full path
183
+ const project = await client.getProject('my-org/my-repo');
184
+ ```
185
+
186
+ #### Create a Project
187
+
188
+ ```typescript
189
+ const project = await client.createProject('new-service', {
190
+ namespaceId: group.id,
191
+ visibility: 'internal',
192
+ description: 'Our shiny new microservice',
193
+ });
194
+ ```
61
195
 
62
- // Search groups by name
63
- const matchingGroups = await client.getGroups({ search: 'platform' });
196
+ #### Project Operations
64
197
 
65
- for (const group of matchingGroups) {
66
- console.log(`${group.id} - ${group.full_path}`);
198
+ ```typescript
199
+ // Update properties
200
+ await project.update({
201
+ description: 'Updated description',
202
+ defaultBranch: 'develop',
203
+ topics: ['typescript', 'api'],
204
+ });
205
+
206
+ // Avatar management
207
+ await project.setAvatar(imageBytes, 'project-logo.png');
208
+ await project.deleteAvatar();
209
+
210
+ // Transfer to a different namespace
211
+ await project.transfer(otherNamespaceId);
212
+
213
+ // Delete
214
+ await project.delete();
215
+ ```
216
+
217
+ ---
218
+
219
+ ### Branches & Tags 🌿
220
+
221
+ ```typescript
222
+ // List all branches (auto-paginated)
223
+ const branches = await project.getBranches();
224
+ for (const b of branches) {
225
+ console.log(`${b.name} @ ${b.commitSha}`);
226
+ }
227
+
228
+ // List all tags
229
+ const tags = await project.getTags();
230
+ for (const t of tags) {
231
+ console.log(`${t.name} @ ${t.commitSha}`);
67
232
  }
68
233
  ```
69
234
 
70
- ### Managing Project Variables
235
+ #### Protected Branches 🔒
71
236
 
72
237
  ```typescript
73
- const projectId = 42;
238
+ const protectedBranches = await project.getProtectedBranches();
239
+ for (const pb of protectedBranches) {
240
+ console.log(`${pb.name} — force push: ${pb.allowForcePush}`);
241
+ }
242
+
243
+ // Remove branch protection
244
+ await project.unprotectBranch('develop');
245
+ ```
246
+
247
+ ---
74
248
 
75
- // List all variables
76
- const vars = await client.getProjectVariables(projectId);
249
+ ### CI/CD Variables 🔑
77
250
 
78
- // Create a variable
79
- await client.createProjectVariable(projectId, 'DATABASE_URL', 'postgres://...', {
251
+ Variables work identically on both projects and groups.
252
+
253
+ #### Project Variables
254
+
255
+ ```typescript
256
+ // List all
257
+ const vars = await project.getVariables();
258
+
259
+ // Create
260
+ const dbVar = await project.createVariable('DATABASE_URL', 'postgres://localhost/db', {
80
261
  protected: true,
81
262
  masked: true,
82
263
  environment_scope: 'production',
83
264
  });
84
265
 
85
- // Update a variable
86
- await client.updateProjectVariable(projectId, 'DATABASE_URL', 'postgres://new-host/...', {
266
+ // Update
267
+ await project.updateVariable('DATABASE_URL', 'postgres://newhost/db', {
87
268
  protected: true,
88
269
  });
89
270
 
90
- // Delete a variable
91
- await client.deleteProjectVariable(projectId, 'DATABASE_URL');
271
+ // Delete
272
+ await project.deleteVariable('DATABASE_URL');
92
273
  ```
93
274
 
94
- ### Managing Group Variables
95
-
96
- The group variable API mirrors the project variable API.
275
+ #### Group Variables
97
276
 
98
277
  ```typescript
99
- const groupId = 7;
278
+ const groupVars = await group.getVariables();
100
279
 
101
- // List all variables
102
- const groupVars = await client.getGroupVariables(groupId);
103
-
104
- // Create a variable
105
- await client.createGroupVariable(groupId, 'NPM_TOKEN', 'tok-xxx', {
280
+ await group.createVariable('NPM_TOKEN', 'tok-xxx', {
106
281
  protected: false,
107
282
  masked: true,
108
283
  environment_scope: '*',
109
284
  });
110
285
 
111
- // Update a variable
112
- await client.updateGroupVariable(groupId, 'NPM_TOKEN', 'tok-yyy', {
113
- masked: true,
286
+ await group.updateVariable('NPM_TOKEN', 'tok-yyy');
287
+ await group.deleteVariable('NPM_TOKEN');
288
+ ```
289
+
290
+ Each `GitLabVariable` instance exposes typed properties:
291
+
292
+ ```typescript
293
+ console.log(dbVar.key); // 'DATABASE_URL'
294
+ console.log(dbVar.value); // 'postgres://...'
295
+ console.log(dbVar.variableType); // 'env_var'
296
+ console.log(dbVar.protected); // true
297
+ console.log(dbVar.masked); // true
298
+ console.log(dbVar.environmentScope); // 'production'
299
+ ```
300
+
301
+ ---
302
+
303
+ ### Pipelines 🚀
304
+
305
+ #### List & Filter Pipelines
306
+
307
+ ```typescript
308
+ // Recent pipelines (auto-paginated)
309
+ const pipelines = await project.getPipelines();
310
+
311
+ // Advanced filtering
312
+ const failed = await project.getPipelines({
313
+ status: 'failed',
314
+ ref: 'main',
315
+ source: 'push',
316
+ orderBy: 'updated_at',
317
+ sort: 'desc',
318
+ updatedAfter: '2025-01-01T00:00:00Z',
114
319
  });
115
320
 
116
- // Delete a variable
117
- await client.deleteGroupVariable(groupId, 'NPM_TOKEN');
321
+ for (const p of failed) {
322
+ console.log(`Pipeline #${p.id} [${p.status}] on ${p.ref} — ${p.webUrl}`);
323
+ }
324
+ ```
325
+
326
+ #### Trigger a Pipeline
327
+
328
+ ```typescript
329
+ const pipeline = await project.triggerPipeline('main', [
330
+ { key: 'DEPLOY_ENV', value: 'staging' },
331
+ ]);
332
+ console.log(`Triggered pipeline #${pipeline.id}`);
118
333
  ```
119
334
 
120
- ### Working with Pipelines
335
+ #### Pipeline Actions
121
336
 
122
337
  ```typescript
123
- const projectId = 42;
338
+ // Retry all failed jobs
339
+ const retried = await pipeline.retry();
124
340
 
125
- // List recent pipelines
126
- const pipelines = await client.getPipelines(projectId, { page: 1, perPage: 10 });
341
+ // Cancel a running pipeline
342
+ const cancelled = await pipeline.cancel();
343
+
344
+ // Delete a pipeline
345
+ await pipeline.delete();
346
+ ```
127
347
 
128
- for (const pipeline of pipelines) {
129
- console.log(`Pipeline #${pipeline.id} [${pipeline.status}] on ${pipeline.ref}`);
348
+ #### Pipeline Variables & Test Reports
349
+
350
+ ```typescript
351
+ // Get variables used in a pipeline run
352
+ const pipelineVars = await pipeline.getVariables();
353
+ for (const v of pipelineVars) {
354
+ console.log(`${v.key} = ${v.value} (${v.variableType})`);
130
355
  }
131
356
 
132
- // Get jobs for a specific pipeline
133
- const jobs = await client.getPipelineJobs(projectId, pipelines[0].id);
357
+ // Get the test report
358
+ const report = await pipeline.getTestReport();
359
+ console.log(`Tests: ${report.totalCount} total, ${report.successCount} passed, ${report.failedCount} failed`);
360
+
361
+ for (const suite of report.testSuites) {
362
+ console.log(` Suite "${suite.name}": ${suite.totalCount} tests (${suite.failedCount} failures)`);
363
+ for (const tc of suite.testCases) {
364
+ if (tc.status === 'failed') {
365
+ console.log(` ❌ ${tc.name}: ${tc.systemOutput}`);
366
+ }
367
+ }
368
+ }
369
+ ```
370
+
371
+ ---
372
+
373
+ ### Jobs ⚙️
374
+
375
+ ```typescript
376
+ // Get all jobs for a pipeline
377
+ const jobs = await pipeline.getJobs();
378
+
379
+ // Filter by scope
380
+ const failedJobs = await pipeline.getJobs({ scope: ['failed'] });
381
+
134
382
  for (const job of jobs) {
135
- console.log(` Job "${job.name}" (${job.stage}): ${job.status}`);
383
+ console.log(`Job "${job.name}" (${job.stage}) ${job.status} [${job.duration}s]`);
136
384
  }
385
+ ```
386
+
387
+ #### Job Actions
137
388
 
138
- // Read the raw log output of a job
139
- const log = await client.getJobLog(projectId, jobs[0].id);
389
+ ```typescript
390
+ // Read the raw log output
391
+ const log = await job.getLog();
140
392
  console.log(log);
141
393
 
142
- // Retry a failed pipeline
143
- await client.retryPipeline(projectId, pipelines[0].id);
394
+ // Retry a failed job
395
+ const retriedJob = await job.retry();
144
396
 
145
- // Cancel a running pipeline
146
- await client.cancelPipeline(projectId, pipelines[0].id);
397
+ // Cancel a running job
398
+ const cancelledJob = await job.cancel();
399
+
400
+ // Trigger a manual job
401
+ const played = await job.play();
402
+
403
+ // Erase job artifacts and trace
404
+ await job.erase();
405
+ ```
406
+
407
+ #### Job Properties
408
+
409
+ Each `GitLabJob` exposes rich metadata:
410
+
411
+ ```typescript
412
+ job.id // number
413
+ job.name // 'build'
414
+ job.stage // 'test'
415
+ job.status // 'success' | 'failed' | 'running' | ...
416
+ job.ref // 'main'
417
+ job.tag // false
418
+ job.webUrl // full URL to the job
419
+ job.duration // seconds
420
+ job.queuedDuration // seconds waiting in queue
421
+ job.coverage // code coverage percentage
422
+ job.allowFailure // whether failure is acceptable
423
+ job.failureReason // reason for failure, if any
147
424
  ```
148
425
 
149
- ## API Reference
426
+ ---
427
+
428
+ ## API Reference 📚
150
429
 
151
430
  ### `GitLabClient`
152
431
 
153
- | Method | Signature | Returns | Description |
154
- |---|---|---|---|
155
- | `constructor` | `(baseUrl: string, token: string)` | `GitLabClient` | Create a new client instance. |
156
- | `testConnection` | `()` | `Promise<ITestConnectionResult>` | Verify the token and connectivity. |
157
- | `getProjects` | `(opts?: IListOptions)` | `Promise<IGitLabProject[]>` | List projects you are a member of. |
158
- | `getGroups` | `(opts?: IListOptions)` | `Promise<IGitLabGroup[]>` | List accessible groups. |
159
- | `getProjectVariables` | `(projectId: number \| string)` | `Promise<IGitLabVariable[]>` | List all CI/CD variables for a project. |
160
- | `createProjectVariable` | `(projectId: number \| string, key: string, value: string, opts?: IVariableOptions)` | `Promise<IGitLabVariable>` | Create a CI/CD variable on a project. |
161
- | `updateProjectVariable` | `(projectId: number \| string, key: string, value: string, opts?: IVariableOptions)` | `Promise<IGitLabVariable>` | Update an existing project variable. |
162
- | `deleteProjectVariable` | `(projectId: number \| string, key: string)` | `Promise<void>` | Delete a project variable. |
163
- | `getGroupVariables` | `(groupId: number \| string)` | `Promise<IGitLabVariable[]>` | List all CI/CD variables for a group. |
164
- | `createGroupVariable` | `(groupId: number \| string, key: string, value: string, opts?: IVariableOptions)` | `Promise<IGitLabVariable>` | Create a CI/CD variable on a group. |
165
- | `updateGroupVariable` | `(groupId: number \| string, key: string, value: string, opts?: IVariableOptions)` | `Promise<IGitLabVariable>` | Update an existing group variable. |
166
- | `deleteGroupVariable` | `(groupId: number \| string, key: string)` | `Promise<void>` | Delete a group variable. |
167
- | `getPipelines` | `(projectId: number \| string, opts?: IListOptions)` | `Promise<IGitLabPipeline[]>` | List pipelines for a project, newest first. |
168
- | `getPipelineJobs` | `(projectId: number \| string, pipelineId: number)` | `Promise<IGitLabJob[]>` | Get all jobs for a pipeline. |
169
- | `getJobLog` | `(projectId: number \| string, jobId: number)` | `Promise<string>` | Retrieve the raw trace/log of a job. |
170
- | `retryPipeline` | `(projectId: number \| string, pipelineId: number)` | `Promise<void>` | Retry all failed jobs in a pipeline. |
171
- | `cancelPipeline` | `(projectId: number \| string, pipelineId: number)` | `Promise<void>` | Cancel a running pipeline. |
172
-
173
- ## Types
432
+ | Method | Returns | Description |
433
+ |---|---|---|
434
+ | `new GitLabClient(baseUrl, token)` | `GitLabClient` | Create a client instance |
435
+ | `.testConnection()` | `Promise<ITestConnectionResult>` | Verify token and connectivity |
436
+ | `.getGroups(opts?)` | `Promise<GitLabGroup[]>` | List all accessible groups (auto-paginated) |
437
+ | `.getGroup(fullPath)` | `Promise<GitLabGroup>` | Get a single group by full path |
438
+ | `.createGroup(name, path, parentId?)` | `Promise<GitLabGroup>` | Create a new group |
439
+ | `.getProjects(opts?)` | `Promise<GitLabProject[]>` | List your projects (auto-paginated) |
440
+ | `.getProject(idOrPath)` | `Promise<GitLabProject>` | Get a single project by ID or path |
441
+ | `.createProject(name, opts?)` | `Promise<GitLabProject>` | Create a new project |
442
+
443
+ ### `GitLabGroup`
444
+
445
+ | Method | Returns | Description |
446
+ |---|---|---|
447
+ | `.getProjects(opts?)` | `Promise<GitLabProject[]>` | List projects in the group |
448
+ | `.getDescendantGroups(opts?)` | `Promise<GitLabGroup[]>` | List descendant sub-groups |
449
+ | `.getVariables()` | `Promise<GitLabVariable[]>` | List CI/CD variables |
450
+ | `.createVariable(key, value, opts?)` | `Promise<GitLabVariable>` | Create a CI/CD variable |
451
+ | `.updateVariable(key, value, opts?)` | `Promise<GitLabVariable>` | Update a CI/CD variable |
452
+ | `.deleteVariable(key)` | `Promise<void>` | Delete a CI/CD variable |
453
+ | `.update(data)` | `Promise<void>` | Update group properties |
454
+ | `.setAvatar(imageData, filename)` | `Promise<void>` | Upload avatar image |
455
+ | `.deleteAvatar()` | `Promise<void>` | Remove avatar |
456
+ | `.transfer(parentGroupId)` | `Promise<void>` | Transfer to another parent group |
457
+ | `.delete()` | `Promise<void>` | Delete the group |
458
+ | `.toJSON()` | `IGitLabGroup` | Serialize to raw interface |
459
+
460
+ ### `GitLabProject`
461
+
462
+ | Method | Returns | Description |
463
+ |---|---|---|
464
+ | `.getBranches(opts?)` | `Promise<GitLabBranch[]>` | List repository branches |
465
+ | `.getTags(opts?)` | `Promise<GitLabTag[]>` | List repository tags |
466
+ | `.getProtectedBranches()` | `Promise<GitLabProtectedBranch[]>` | List protected branches |
467
+ | `.unprotectBranch(name)` | `Promise<void>` | Remove branch protection |
468
+ | `.getVariables()` | `Promise<GitLabVariable[]>` | List CI/CD variables |
469
+ | `.createVariable(key, value, opts?)` | `Promise<GitLabVariable>` | Create a CI/CD variable |
470
+ | `.updateVariable(key, value, opts?)` | `Promise<GitLabVariable>` | Update a CI/CD variable |
471
+ | `.deleteVariable(key)` | `Promise<void>` | Delete a CI/CD variable |
472
+ | `.getPipelines(opts?)` | `Promise<GitLabPipeline[]>` | List pipelines (with rich filtering) |
473
+ | `.triggerPipeline(ref, variables?)` | `Promise<GitLabPipeline>` | Trigger a new pipeline |
474
+ | `.update(data)` | `Promise<void>` | Update project properties |
475
+ | `.setAvatar(imageData, filename)` | `Promise<void>` | Upload avatar image |
476
+ | `.deleteAvatar()` | `Promise<void>` | Remove avatar |
477
+ | `.transfer(namespaceId)` | `Promise<void>` | Transfer to another namespace |
478
+ | `.delete()` | `Promise<void>` | Delete the project |
479
+ | `.toJSON()` | `IGitLabProject` | Serialize to raw interface |
480
+
481
+ ### `GitLabPipeline`
482
+
483
+ | Method | Returns | Description |
484
+ |---|---|---|
485
+ | `.getJobs(opts?)` | `Promise<GitLabJob[]>` | List jobs (with scope filtering) |
486
+ | `.getVariables()` | `Promise<GitLabPipelineVariable[]>` | Get pipeline variables |
487
+ | `.getTestReport()` | `Promise<GitLabTestReport>` | Get the test report |
488
+ | `.retry()` | `Promise<GitLabPipeline>` | Retry failed jobs |
489
+ | `.cancel()` | `Promise<GitLabPipeline>` | Cancel the pipeline |
490
+ | `.delete()` | `Promise<void>` | Delete the pipeline |
491
+ | `.toJSON()` | `IGitLabPipeline` | Serialize to raw interface |
492
+
493
+ ### `GitLabJob`
494
+
495
+ | Method | Returns | Description |
496
+ |---|---|---|
497
+ | `.getLog()` | `Promise<string>` | Get raw job trace/log |
498
+ | `.retry()` | `Promise<GitLabJob>` | Retry the job |
499
+ | `.cancel()` | `Promise<GitLabJob>` | Cancel the job |
500
+ | `.play()` | `Promise<GitLabJob>` | Trigger a manual job |
501
+ | `.erase()` | `Promise<void>` | Erase artifacts and trace |
502
+ | `.toJSON()` | `IGitLabJob` | Serialize to raw interface |
503
+
504
+ ### Value Classes
505
+
506
+ | Class | Key Properties |
507
+ |---|---|
508
+ | `GitLabBranch` | `name`, `commitSha` |
509
+ | `GitLabTag` | `name`, `commitSha` |
510
+ | `GitLabProtectedBranch` | `id`, `name`, `allowForcePush` |
511
+ | `GitLabVariable` | `key`, `value`, `variableType`, `protected`, `masked`, `environmentScope` |
512
+ | `GitLabPipelineVariable` | `key`, `value`, `variableType` |
513
+ | `GitLabTestReport` | `totalTime`, `totalCount`, `successCount`, `failedCount`, `skippedCount`, `errorCount`, `testSuites` |
514
+ | `GitLabTestSuite` | `name`, `totalTime`, `totalCount`, `successCount`, `failedCount`, `skippedCount`, `errorCount`, `testCases` |
515
+ | `GitLabTestCase` | `status`, `name`, `classname`, `executionTime`, `systemOutput`, `stackTrace` |
516
+
517
+ ---
518
+
519
+ ## TypeScript Interfaces 🏗️
520
+
521
+ All raw GitLab API shapes are exported as TypeScript interfaces so you can use them in your own type definitions.
174
522
 
175
523
  ### `IListOptions`
176
524
 
177
- Pagination and search options used by `getProjects`, `getGroups`, and `getPipelines`.
178
-
179
525
  ```typescript
180
526
  interface IListOptions {
181
527
  search?: string; // Filter results by keyword
182
528
  page?: number; // Page number (default: 1)
183
- perPage?: number; // Items per page (default: 50 for projects/groups, 30 for pipelines)
529
+ perPage?: number; // Items per page (default: 50)
184
530
  }
185
531
  ```
186
532
 
187
- ### `IVariableOptions`
533
+ ### `IPipelineListOptions`
188
534
 
189
- Options when creating or updating CI/CD variables.
535
+ Extends `IListOptions` with pipeline-specific filters:
190
536
 
191
537
  ```typescript
192
- interface IVariableOptions {
193
- protected?: boolean; // Only expose to protected branches/tags (default: false)
194
- masked?: boolean; // Mask the value in job logs (default: false)
195
- environment_scope?: string; // Environment scope (default: '*' for all environments)
538
+ interface IPipelineListOptions extends IListOptions {
539
+ status?: string; // Filter by pipeline status
540
+ ref?: string; // Filter by branch/tag ref
541
+ source?: string; // Filter by trigger source (push, web, schedule, api, ...)
542
+ scope?: string; // Filter by scope (running, pending, finished, branches, tags)
543
+ username?: string; // Filter by the triggering user
544
+ updatedAfter?: string; // ISO 8601 date — only pipelines updated after this
545
+ updatedBefore?: string; // ISO 8601 date — only pipelines updated before this
546
+ orderBy?: string; // Order by field (id, status, ref, updated_at, user_id)
547
+ sort?: string; // Sort direction (asc, desc)
196
548
  }
197
549
  ```
198
550
 
199
- ### `ITestConnectionResult`
551
+ ### `IJobListOptions`
200
552
 
201
553
  ```typescript
202
- interface ITestConnectionResult {
203
- ok: boolean;
204
- error?: string; // Present when ok is false
554
+ interface IJobListOptions extends IListOptions {
555
+ scope?: string[]; // Filter by job scope(s): created, pending, running, failed, success, ...
205
556
  }
206
557
  ```
207
558
 
208
- ### `IGitLabProject`
559
+ ### `IVariableOptions`
209
560
 
210
561
  ```typescript
211
- interface IGitLabProject {
212
- id: number;
213
- name: string;
214
- path_with_namespace: string;
215
- description: string;
216
- default_branch: string;
217
- web_url: string;
218
- visibility: string;
219
- topics: string[];
220
- last_activity_at: string;
562
+ interface IVariableOptions {
563
+ protected?: boolean; // Only expose to protected branches/tags
564
+ masked?: boolean; // Mask the value in job logs
565
+ environment_scope?: string; // Environment scope (default: '*')
221
566
  }
222
567
  ```
223
568
 
224
- ### `IGitLabGroup`
569
+ ### `ITestConnectionResult`
225
570
 
226
571
  ```typescript
227
- interface IGitLabGroup {
228
- id: number;
229
- name: string;
230
- full_path: string;
231
- description: string;
232
- web_url: string;
233
- visibility: string;
572
+ interface ITestConnectionResult {
573
+ ok: boolean;
574
+ error?: string; // Present when ok is false
234
575
  }
235
576
  ```
236
577
 
237
- ### `IGitLabVariable`
578
+ All raw data interfaces (`IGitLabProject`, `IGitLabGroup`, `IGitLabPipeline`, `IGitLabJob`, `IGitLabVariable`, `IGitLabBranch`, `IGitLabTag`, `IGitLabProtectedBranch`, `IGitLabPipelineVariable`, `IGitLabTestReport`, `IGitLabTestSuite`, `IGitLabTestCase`, `IGitLabUser`) are also exported for advanced use cases.
238
579
 
239
- ```typescript
240
- interface IGitLabVariable {
241
- key: string;
242
- value: string;
243
- variable_type: string;
244
- protected: boolean;
245
- masked: boolean;
246
- environment_scope: string;
247
- }
248
- ```
580
+ ---
249
581
 
250
- ### `IGitLabPipeline`
582
+ ## License and Legal Information
251
583
 
252
- ```typescript
253
- interface IGitLabPipeline {
254
- id: number;
255
- project_id: number;
256
- status: string;
257
- ref: string;
258
- sha: string;
259
- web_url: string;
260
- duration: number;
261
- created_at: string;
262
- source: string;
263
- }
264
- ```
584
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
265
585
 
266
- ### `IGitLabJob`
586
+ **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
267
587
 
268
- ```typescript
269
- interface IGitLabJob {
270
- id: number;
271
- name: string;
272
- stage: string;
273
- status: string;
274
- duration: number;
275
- }
276
- ```
588
+ ### Trademarks
277
589
 
278
- ### `IGitLabUser`
590
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
279
591
 
280
- Returned internally by `testConnection` to verify credentials.
592
+ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
281
593
 
282
- ```typescript
283
- interface IGitLabUser {
284
- id: number;
285
- username: string;
286
- name: string;
287
- email: string;
288
- avatar_url: string;
289
- web_url: string;
290
- state: string;
291
- }
292
- ```
594
+ ### Company Information
595
+
596
+ Task Venture Capital GmbH
597
+ Registered at District Court Bremen HRB 35230 HB, Germany
293
598
 
294
- ## License
599
+ For any legal inquiries or further information, please contact us via email at hello@task.vc.
295
600
 
296
- MIT
601
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.