@apiclient.xyz/gitlab 2.5.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.
- package/dist_ts/gitlab.classes.branch.d.ts +7 -0
- package/dist_ts/gitlab.classes.branch.js +13 -0
- package/dist_ts/gitlab.classes.gitlabclient.d.ts +112 -81
- package/dist_ts/gitlab.classes.gitlabclient.js +236 -156
- package/dist_ts/gitlab.classes.group.d.ts +47 -0
- package/dist_ts/gitlab.classes.group.js +97 -0
- package/dist_ts/gitlab.classes.job.d.ts +29 -0
- package/dist_ts/gitlab.classes.job.js +74 -0
- package/dist_ts/gitlab.classes.pipeline.d.ts +32 -0
- package/dist_ts/gitlab.classes.pipeline.js +87 -0
- package/dist_ts/gitlab.classes.project.d.ts +63 -0
- package/dist_ts/gitlab.classes.project.js +122 -0
- package/dist_ts/gitlab.classes.protectedbranch.d.ts +8 -0
- package/dist_ts/gitlab.classes.protectedbranch.js +15 -0
- package/dist_ts/gitlab.classes.tag.d.ts +7 -0
- package/dist_ts/gitlab.classes.tag.js +13 -0
- package/dist_ts/gitlab.classes.testreport.d.ts +34 -0
- package/dist_ts/gitlab.classes.testreport.js +67 -0
- package/dist_ts/gitlab.classes.variable.d.ts +18 -0
- package/dist_ts/gitlab.classes.variable.js +35 -0
- package/dist_ts/gitlab.helpers.d.ts +8 -0
- package/dist_ts/gitlab.helpers.js +23 -0
- package/dist_ts/index.d.ts +10 -0
- package/dist_ts/index.js +15 -1
- package/package.json +1 -1
- package/readme.md +468 -163
- package/ts/gitlab.classes.branch.ts +18 -0
- package/ts/gitlab.classes.gitlabclient.ts +297 -196
- package/ts/gitlab.classes.group.ts +137 -0
- package/ts/gitlab.classes.job.ts +104 -0
- package/ts/gitlab.classes.pipeline.ts +122 -0
- package/ts/gitlab.classes.project.ts +177 -0
- package/ts/gitlab.classes.protectedbranch.ts +21 -0
- package/ts/gitlab.classes.tag.ts +18 -0
- package/ts/gitlab.classes.testreport.ts +97 -0
- package/ts/gitlab.classes.variable.ts +50 -0
- package/ts/gitlab.helpers.ts +26 -0
- package/ts/index.ts +19 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { GitLabClient } from './gitlab.classes.gitlabclient.js';
|
|
2
|
+
import type { IGitLabGroup, IListOptions, IVariableOptions } from './gitlab.interfaces.js';
|
|
3
|
+
import { GitLabProject } from './gitlab.classes.project.js';
|
|
4
|
+
import { GitLabVariable } from './gitlab.classes.variable.js';
|
|
5
|
+
import { autoPaginate } from './gitlab.helpers.js';
|
|
6
|
+
|
|
7
|
+
export class GitLabGroup {
|
|
8
|
+
// Raw data
|
|
9
|
+
public readonly id: number;
|
|
10
|
+
public readonly name: string;
|
|
11
|
+
public readonly fullPath: string;
|
|
12
|
+
public readonly description: string;
|
|
13
|
+
public readonly webUrl: string;
|
|
14
|
+
public readonly visibility: string;
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
constructor(
|
|
18
|
+
private client: GitLabClient,
|
|
19
|
+
raw: IGitLabGroup,
|
|
20
|
+
) {
|
|
21
|
+
this.id = raw.id;
|
|
22
|
+
this.name = raw.name || '';
|
|
23
|
+
this.fullPath = raw.full_path || '';
|
|
24
|
+
this.description = raw.description || '';
|
|
25
|
+
this.webUrl = raw.web_url || '';
|
|
26
|
+
this.visibility = raw.visibility || 'private';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Projects
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
async getProjects(opts?: IListOptions): Promise<GitLabProject[]> {
|
|
34
|
+
return autoPaginate(
|
|
35
|
+
(page, perPage) => this.client.requestGetGroupProjects(this.id, { ...opts, page, perPage }),
|
|
36
|
+
opts,
|
|
37
|
+
).then(projects => projects.map(p => new GitLabProject(this.client, p)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Descendant Groups
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
async getDescendantGroups(opts?: IListOptions): Promise<GitLabGroup[]> {
|
|
45
|
+
return autoPaginate(
|
|
46
|
+
(page, perPage) => this.client.requestGetDescendantGroups(this.id, { ...opts, page, perPage }),
|
|
47
|
+
opts,
|
|
48
|
+
).then(groups => groups.map(g => new GitLabGroup(this.client, g)));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Variables (CI/CD)
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
async getVariables(): Promise<GitLabVariable[]> {
|
|
56
|
+
const vars = await this.client.requestGetGroupVariables(this.id);
|
|
57
|
+
return vars.map(v => new GitLabVariable(v));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async createVariable(key: string, value: string, opts?: IVariableOptions): Promise<GitLabVariable> {
|
|
61
|
+
const raw = await this.client.requestCreateGroupVariable(this.id, key, value, opts);
|
|
62
|
+
return new GitLabVariable(raw);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async updateVariable(key: string, value: string, opts?: IVariableOptions): Promise<GitLabVariable> {
|
|
66
|
+
const raw = await this.client.requestUpdateGroupVariable(this.id, key, value, opts);
|
|
67
|
+
return new GitLabVariable(raw);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async deleteVariable(key: string): Promise<void> {
|
|
71
|
+
await this.client.requestDeleteGroupVariable(this.id, key);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// Mutation
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Update group properties.
|
|
80
|
+
*/
|
|
81
|
+
async update(data: {
|
|
82
|
+
name?: string;
|
|
83
|
+
path?: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
visibility?: string;
|
|
86
|
+
}): Promise<void> {
|
|
87
|
+
await this.client.requestUpdateGroup(this.id, {
|
|
88
|
+
name: data.name,
|
|
89
|
+
path: data.path,
|
|
90
|
+
description: data.description,
|
|
91
|
+
visibility: data.visibility,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Upload an avatar image for this group (multipart FormData).
|
|
97
|
+
*/
|
|
98
|
+
async setAvatar(imageData: Uint8Array, filename: string): Promise<void> {
|
|
99
|
+
await this.client.requestSetGroupAvatar(this.id, imageData, filename);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Remove the group's avatar.
|
|
104
|
+
*/
|
|
105
|
+
async deleteAvatar(): Promise<void> {
|
|
106
|
+
await this.client.requestUpdateGroup(this.id, { avatar: '' });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Transfer this group to be a child of another group.
|
|
111
|
+
*/
|
|
112
|
+
async transfer(parentGroupId: number): Promise<void> {
|
|
113
|
+
await this.client.requestTransferGroup(this.id, parentGroupId);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Delete this group.
|
|
118
|
+
*/
|
|
119
|
+
async delete(): Promise<void> {
|
|
120
|
+
await this.client.requestDeleteGroup(this.id);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// Serialization
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
toJSON(): IGitLabGroup {
|
|
128
|
+
return {
|
|
129
|
+
id: this.id,
|
|
130
|
+
name: this.name,
|
|
131
|
+
full_path: this.fullPath,
|
|
132
|
+
description: this.description,
|
|
133
|
+
web_url: this.webUrl,
|
|
134
|
+
visibility: this.visibility,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { GitLabClient } from './gitlab.classes.gitlabclient.js';
|
|
2
|
+
import type { IGitLabJob } from './gitlab.interfaces.js';
|
|
3
|
+
|
|
4
|
+
export class GitLabJob {
|
|
5
|
+
// Raw data
|
|
6
|
+
public readonly id: number;
|
|
7
|
+
public readonly name: string;
|
|
8
|
+
public readonly stage: string;
|
|
9
|
+
public readonly status: string;
|
|
10
|
+
public readonly ref: string;
|
|
11
|
+
public readonly tag: boolean;
|
|
12
|
+
public readonly webUrl: string;
|
|
13
|
+
public readonly createdAt: string;
|
|
14
|
+
public readonly startedAt: string;
|
|
15
|
+
public readonly finishedAt: string;
|
|
16
|
+
public readonly duration: number;
|
|
17
|
+
public readonly queuedDuration: number;
|
|
18
|
+
public readonly coverage: number;
|
|
19
|
+
public readonly allowFailure: boolean;
|
|
20
|
+
public readonly failureReason: string;
|
|
21
|
+
|
|
22
|
+
/** @internal */
|
|
23
|
+
constructor(
|
|
24
|
+
private client: GitLabClient,
|
|
25
|
+
private projectId: number | string,
|
|
26
|
+
raw: IGitLabJob,
|
|
27
|
+
) {
|
|
28
|
+
this.id = raw.id;
|
|
29
|
+
this.name = raw.name || '';
|
|
30
|
+
this.stage = raw.stage || '';
|
|
31
|
+
this.status = raw.status || '';
|
|
32
|
+
this.ref = raw.ref || '';
|
|
33
|
+
this.tag = raw.tag ?? false;
|
|
34
|
+
this.webUrl = raw.web_url || '';
|
|
35
|
+
this.createdAt = raw.created_at || '';
|
|
36
|
+
this.startedAt = raw.started_at || '';
|
|
37
|
+
this.finishedAt = raw.finished_at || '';
|
|
38
|
+
this.duration = raw.duration || 0;
|
|
39
|
+
this.queuedDuration = raw.queued_duration || 0;
|
|
40
|
+
this.coverage = raw.coverage || 0;
|
|
41
|
+
this.allowFailure = raw.allow_failure ?? false;
|
|
42
|
+
this.failureReason = raw.failure_reason || '';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Log
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
async getLog(): Promise<string> {
|
|
50
|
+
return this.client.requestGetJobLog(this.projectId, this.id);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
// Actions
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
async retry(): Promise<GitLabJob> {
|
|
58
|
+
const raw = await this.client.requestRetryJob(this.projectId, this.id);
|
|
59
|
+
return new GitLabJob(this.client, this.projectId, raw);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async cancel(): Promise<GitLabJob> {
|
|
63
|
+
const raw = await this.client.requestCancelJob(this.projectId, this.id);
|
|
64
|
+
return new GitLabJob(this.client, this.projectId, raw);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async play(): Promise<GitLabJob> {
|
|
68
|
+
const raw = await this.client.requestPlayJob(this.projectId, this.id);
|
|
69
|
+
return new GitLabJob(this.client, this.projectId, raw);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async erase(): Promise<void> {
|
|
73
|
+
await this.client.requestEraseJob(this.projectId, this.id);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Serialization
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
toJSON(): IGitLabJob {
|
|
81
|
+
return {
|
|
82
|
+
id: this.id,
|
|
83
|
+
name: this.name,
|
|
84
|
+
stage: this.stage,
|
|
85
|
+
status: this.status,
|
|
86
|
+
ref: this.ref,
|
|
87
|
+
tag: this.tag,
|
|
88
|
+
web_url: this.webUrl,
|
|
89
|
+
created_at: this.createdAt,
|
|
90
|
+
started_at: this.startedAt,
|
|
91
|
+
finished_at: this.finishedAt,
|
|
92
|
+
duration: this.duration,
|
|
93
|
+
queued_duration: this.queuedDuration,
|
|
94
|
+
coverage: this.coverage,
|
|
95
|
+
allow_failure: this.allowFailure,
|
|
96
|
+
failure_reason: this.failureReason,
|
|
97
|
+
pipeline: { id: 0, project_id: 0, ref: '', sha: '', status: '' },
|
|
98
|
+
user: { id: 0, username: '', name: '', email: '', avatar_url: '', web_url: '', state: '' },
|
|
99
|
+
runner: { id: 0, description: '', active: false, is_shared: false },
|
|
100
|
+
artifacts: [],
|
|
101
|
+
artifacts_expire_at: '',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { GitLabClient } from './gitlab.classes.gitlabclient.js';
|
|
2
|
+
import type { IGitLabPipeline, IJobListOptions } from './gitlab.interfaces.js';
|
|
3
|
+
import { GitLabJob } from './gitlab.classes.job.js';
|
|
4
|
+
import { GitLabPipelineVariable } from './gitlab.classes.variable.js';
|
|
5
|
+
import { GitLabTestReport } from './gitlab.classes.testreport.js';
|
|
6
|
+
import { autoPaginate } from './gitlab.helpers.js';
|
|
7
|
+
|
|
8
|
+
export class GitLabPipeline {
|
|
9
|
+
// Raw data
|
|
10
|
+
public readonly id: number;
|
|
11
|
+
public readonly iid: number;
|
|
12
|
+
public readonly projectId: number;
|
|
13
|
+
public readonly status: string;
|
|
14
|
+
public readonly ref: string;
|
|
15
|
+
public readonly sha: string;
|
|
16
|
+
public readonly webUrl: string;
|
|
17
|
+
public readonly duration: number;
|
|
18
|
+
public readonly queuedDuration: number;
|
|
19
|
+
public readonly createdAt: string;
|
|
20
|
+
public readonly updatedAt: string;
|
|
21
|
+
public readonly startedAt: string;
|
|
22
|
+
public readonly finishedAt: string;
|
|
23
|
+
public readonly source: string;
|
|
24
|
+
public readonly tag: boolean;
|
|
25
|
+
|
|
26
|
+
/** @internal */
|
|
27
|
+
constructor(
|
|
28
|
+
private client: GitLabClient,
|
|
29
|
+
raw: IGitLabPipeline,
|
|
30
|
+
) {
|
|
31
|
+
this.id = raw.id;
|
|
32
|
+
this.iid = raw.iid || 0;
|
|
33
|
+
this.projectId = raw.project_id || 0;
|
|
34
|
+
this.status = raw.status || '';
|
|
35
|
+
this.ref = raw.ref || '';
|
|
36
|
+
this.sha = raw.sha || '';
|
|
37
|
+
this.webUrl = raw.web_url || '';
|
|
38
|
+
this.duration = raw.duration || 0;
|
|
39
|
+
this.queuedDuration = raw.queued_duration || 0;
|
|
40
|
+
this.createdAt = raw.created_at || '';
|
|
41
|
+
this.updatedAt = raw.updated_at || '';
|
|
42
|
+
this.startedAt = raw.started_at || '';
|
|
43
|
+
this.finishedAt = raw.finished_at || '';
|
|
44
|
+
this.source = raw.source || '';
|
|
45
|
+
this.tag = raw.tag ?? false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Jobs
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
async getJobs(opts?: IJobListOptions): Promise<GitLabJob[]> {
|
|
53
|
+
return autoPaginate(
|
|
54
|
+
(page, perPage) => this.client.requestGetPipelineJobs(this.projectId, this.id, { ...opts, page, perPage }),
|
|
55
|
+
opts,
|
|
56
|
+
).then(jobs => jobs.map(j => new GitLabJob(this.client, this.projectId, j)));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Variables & Test Report
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
async getVariables(): Promise<GitLabPipelineVariable[]> {
|
|
64
|
+
const vars = await this.client.requestGetPipelineVariables(this.projectId, this.id);
|
|
65
|
+
return vars.map(v => new GitLabPipelineVariable(v));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async getTestReport(): Promise<GitLabTestReport> {
|
|
69
|
+
const raw = await this.client.requestGetPipelineTestReport(this.projectId, this.id);
|
|
70
|
+
return new GitLabTestReport(raw);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// Actions
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
async retry(): Promise<GitLabPipeline> {
|
|
78
|
+
const raw = await this.client.requestRetryPipeline(this.projectId, this.id);
|
|
79
|
+
return new GitLabPipeline(this.client, raw);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async cancel(): Promise<GitLabPipeline> {
|
|
83
|
+
const raw = await this.client.requestCancelPipeline(this.projectId, this.id);
|
|
84
|
+
return new GitLabPipeline(this.client, raw);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async delete(): Promise<void> {
|
|
88
|
+
await this.client.requestDeletePipeline(this.projectId, this.id);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
// Serialization
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
|
|
95
|
+
toJSON(): IGitLabPipeline {
|
|
96
|
+
return {
|
|
97
|
+
id: this.id,
|
|
98
|
+
iid: this.iid,
|
|
99
|
+
project_id: this.projectId,
|
|
100
|
+
status: this.status,
|
|
101
|
+
ref: this.ref,
|
|
102
|
+
sha: this.sha,
|
|
103
|
+
before_sha: '',
|
|
104
|
+
tag: this.tag,
|
|
105
|
+
web_url: this.webUrl,
|
|
106
|
+
duration: this.duration,
|
|
107
|
+
queued_duration: this.queuedDuration,
|
|
108
|
+
created_at: this.createdAt,
|
|
109
|
+
updated_at: this.updatedAt,
|
|
110
|
+
started_at: this.startedAt,
|
|
111
|
+
finished_at: this.finishedAt,
|
|
112
|
+
source: this.source,
|
|
113
|
+
coverage: '',
|
|
114
|
+
user: { id: 0, username: '', name: '', email: '', avatar_url: '', web_url: '', state: '' },
|
|
115
|
+
detailed_status: {
|
|
116
|
+
icon: '', text: '', label: '', group: '', tooltip: '',
|
|
117
|
+
has_details: false, details_path: '', favicon: '',
|
|
118
|
+
},
|
|
119
|
+
yaml_errors: '',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { GitLabClient } from './gitlab.classes.gitlabclient.js';
|
|
2
|
+
import type { IGitLabProject, IListOptions, IVariableOptions, IPipelineListOptions } from './gitlab.interfaces.js';
|
|
3
|
+
import { GitLabBranch } from './gitlab.classes.branch.js';
|
|
4
|
+
import { GitLabTag } from './gitlab.classes.tag.js';
|
|
5
|
+
import { GitLabProtectedBranch } from './gitlab.classes.protectedbranch.js';
|
|
6
|
+
import { GitLabVariable } from './gitlab.classes.variable.js';
|
|
7
|
+
import { GitLabPipeline } from './gitlab.classes.pipeline.js';
|
|
8
|
+
import { autoPaginate } from './gitlab.helpers.js';
|
|
9
|
+
|
|
10
|
+
export class GitLabProject {
|
|
11
|
+
// Raw data
|
|
12
|
+
public readonly id: number;
|
|
13
|
+
public readonly name: string;
|
|
14
|
+
public readonly fullPath: string;
|
|
15
|
+
public readonly description: string;
|
|
16
|
+
public readonly defaultBranch: string;
|
|
17
|
+
public readonly webUrl: string;
|
|
18
|
+
public readonly visibility: string;
|
|
19
|
+
public readonly topics: string[];
|
|
20
|
+
public readonly lastActivityAt: string;
|
|
21
|
+
|
|
22
|
+
/** @internal */
|
|
23
|
+
constructor(
|
|
24
|
+
private client: GitLabClient,
|
|
25
|
+
raw: IGitLabProject,
|
|
26
|
+
) {
|
|
27
|
+
this.id = raw.id;
|
|
28
|
+
this.name = raw.name || '';
|
|
29
|
+
this.fullPath = raw.path_with_namespace || '';
|
|
30
|
+
this.description = raw.description || '';
|
|
31
|
+
this.defaultBranch = raw.default_branch || 'main';
|
|
32
|
+
this.webUrl = raw.web_url || '';
|
|
33
|
+
this.visibility = raw.visibility || 'private';
|
|
34
|
+
this.topics = raw.topics || [];
|
|
35
|
+
this.lastActivityAt = raw.last_activity_at || '';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Branches & Tags
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
async getBranches(opts?: IListOptions): Promise<GitLabBranch[]> {
|
|
43
|
+
return autoPaginate(
|
|
44
|
+
(page, perPage) => this.client.requestGetRepoBranches(this.id, { ...opts, page, perPage }),
|
|
45
|
+
opts,
|
|
46
|
+
).then(branches => branches.map(b => new GitLabBranch(b)));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async getTags(opts?: IListOptions): Promise<GitLabTag[]> {
|
|
50
|
+
return autoPaginate(
|
|
51
|
+
(page, perPage) => this.client.requestGetRepoTags(this.id, { ...opts, page, perPage }),
|
|
52
|
+
opts,
|
|
53
|
+
).then(tags => tags.map(t => new GitLabTag(t)));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async getProtectedBranches(): Promise<GitLabProtectedBranch[]> {
|
|
57
|
+
const branches = await this.client.requestGetProtectedBranches(this.id);
|
|
58
|
+
return branches.map(b => new GitLabProtectedBranch(b));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async unprotectBranch(branchName: string): Promise<void> {
|
|
62
|
+
await this.client.requestUnprotectBranch(this.id, branchName);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// Variables (CI/CD)
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
|
|
69
|
+
async getVariables(): Promise<GitLabVariable[]> {
|
|
70
|
+
const vars = await this.client.requestGetProjectVariables(this.id);
|
|
71
|
+
return vars.map(v => new GitLabVariable(v));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async createVariable(key: string, value: string, opts?: IVariableOptions): Promise<GitLabVariable> {
|
|
75
|
+
const raw = await this.client.requestCreateProjectVariable(this.id, key, value, opts);
|
|
76
|
+
return new GitLabVariable(raw);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async updateVariable(key: string, value: string, opts?: IVariableOptions): Promise<GitLabVariable> {
|
|
80
|
+
const raw = await this.client.requestUpdateProjectVariable(this.id, key, value, opts);
|
|
81
|
+
return new GitLabVariable(raw);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async deleteVariable(key: string): Promise<void> {
|
|
85
|
+
await this.client.requestDeleteProjectVariable(this.id, key);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Pipelines
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
async getPipelines(opts?: IPipelineListOptions): Promise<GitLabPipeline[]> {
|
|
93
|
+
return autoPaginate(
|
|
94
|
+
(page, perPage) => this.client.requestGetPipelines(this.id, { ...opts, page, perPage }),
|
|
95
|
+
opts,
|
|
96
|
+
).then(pipelines => pipelines.map(p => new GitLabPipeline(this.client, p)));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async triggerPipeline(
|
|
100
|
+
ref: string,
|
|
101
|
+
variables?: { key: string; value: string; variable_type?: string }[],
|
|
102
|
+
): Promise<GitLabPipeline> {
|
|
103
|
+
const raw = await this.client.requestTriggerPipeline(this.id, ref, variables);
|
|
104
|
+
return new GitLabPipeline(this.client, raw);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
// Mutation
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Update project properties.
|
|
113
|
+
*/
|
|
114
|
+
async update(data: {
|
|
115
|
+
name?: string;
|
|
116
|
+
path?: string;
|
|
117
|
+
description?: string;
|
|
118
|
+
defaultBranch?: string;
|
|
119
|
+
visibility?: string;
|
|
120
|
+
topics?: string[];
|
|
121
|
+
}): Promise<void> {
|
|
122
|
+
await this.client.requestUpdateProject(this.id, {
|
|
123
|
+
name: data.name,
|
|
124
|
+
path: data.path,
|
|
125
|
+
description: data.description,
|
|
126
|
+
default_branch: data.defaultBranch,
|
|
127
|
+
visibility: data.visibility,
|
|
128
|
+
topics: data.topics,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Upload an avatar image for this project (multipart FormData).
|
|
134
|
+
*/
|
|
135
|
+
async setAvatar(imageData: Uint8Array, filename: string): Promise<void> {
|
|
136
|
+
await this.client.requestSetProjectAvatar(this.id, imageData, filename);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Remove the project's avatar.
|
|
141
|
+
*/
|
|
142
|
+
async deleteAvatar(): Promise<void> {
|
|
143
|
+
await this.client.requestUpdateProject(this.id, { avatar: '' });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Transfer this project to a different namespace.
|
|
148
|
+
*/
|
|
149
|
+
async transfer(namespaceId: number): Promise<void> {
|
|
150
|
+
await this.client.requestTransferProject(this.id, namespaceId);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Delete this project.
|
|
155
|
+
*/
|
|
156
|
+
async delete(): Promise<void> {
|
|
157
|
+
await this.client.requestDeleteProject(this.id);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
// Serialization
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
|
|
164
|
+
toJSON(): IGitLabProject {
|
|
165
|
+
return {
|
|
166
|
+
id: this.id,
|
|
167
|
+
name: this.name,
|
|
168
|
+
path_with_namespace: this.fullPath,
|
|
169
|
+
description: this.description,
|
|
170
|
+
default_branch: this.defaultBranch,
|
|
171
|
+
web_url: this.webUrl,
|
|
172
|
+
visibility: this.visibility,
|
|
173
|
+
topics: this.topics,
|
|
174
|
+
last_activity_at: this.lastActivityAt,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IGitLabProtectedBranch } from './gitlab.interfaces.js';
|
|
2
|
+
|
|
3
|
+
export class GitLabProtectedBranch {
|
|
4
|
+
public readonly id: number;
|
|
5
|
+
public readonly name: string;
|
|
6
|
+
public readonly allowForcePush: boolean;
|
|
7
|
+
|
|
8
|
+
constructor(raw: IGitLabProtectedBranch) {
|
|
9
|
+
this.id = raw.id;
|
|
10
|
+
this.name = raw.name || '';
|
|
11
|
+
this.allowForcePush = raw.allow_force_push ?? false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
toJSON(): IGitLabProtectedBranch {
|
|
15
|
+
return {
|
|
16
|
+
id: this.id,
|
|
17
|
+
name: this.name,
|
|
18
|
+
allow_force_push: this.allowForcePush,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IGitLabTag } from './gitlab.interfaces.js';
|
|
2
|
+
|
|
3
|
+
export class GitLabTag {
|
|
4
|
+
public readonly name: string;
|
|
5
|
+
public readonly commitSha: string;
|
|
6
|
+
|
|
7
|
+
constructor(raw: IGitLabTag) {
|
|
8
|
+
this.name = raw.name || '';
|
|
9
|
+
this.commitSha = raw.commit?.id || '';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
toJSON(): IGitLabTag {
|
|
13
|
+
return {
|
|
14
|
+
name: this.name,
|
|
15
|
+
commit: { id: this.commitSha },
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { IGitLabTestReport, IGitLabTestSuite, IGitLabTestCase } from './gitlab.interfaces.js';
|
|
2
|
+
|
|
3
|
+
export class GitLabTestCase {
|
|
4
|
+
public readonly status: string;
|
|
5
|
+
public readonly name: string;
|
|
6
|
+
public readonly classname: string;
|
|
7
|
+
public readonly executionTime: number;
|
|
8
|
+
public readonly systemOutput: string;
|
|
9
|
+
public readonly stackTrace: string;
|
|
10
|
+
|
|
11
|
+
constructor(raw: IGitLabTestCase) {
|
|
12
|
+
this.status = raw.status || '';
|
|
13
|
+
this.name = raw.name || '';
|
|
14
|
+
this.classname = raw.classname || '';
|
|
15
|
+
this.executionTime = raw.execution_time || 0;
|
|
16
|
+
this.systemOutput = raw.system_output || '';
|
|
17
|
+
this.stackTrace = raw.stack_trace || '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toJSON(): IGitLabTestCase {
|
|
21
|
+
return {
|
|
22
|
+
status: this.status,
|
|
23
|
+
name: this.name,
|
|
24
|
+
classname: this.classname,
|
|
25
|
+
execution_time: this.executionTime,
|
|
26
|
+
system_output: this.systemOutput,
|
|
27
|
+
stack_trace: this.stackTrace,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class GitLabTestSuite {
|
|
33
|
+
public readonly name: string;
|
|
34
|
+
public readonly totalTime: number;
|
|
35
|
+
public readonly totalCount: number;
|
|
36
|
+
public readonly successCount: number;
|
|
37
|
+
public readonly failedCount: number;
|
|
38
|
+
public readonly skippedCount: number;
|
|
39
|
+
public readonly errorCount: number;
|
|
40
|
+
public readonly testCases: GitLabTestCase[];
|
|
41
|
+
|
|
42
|
+
constructor(raw: IGitLabTestSuite) {
|
|
43
|
+
this.name = raw.name || '';
|
|
44
|
+
this.totalTime = raw.total_time || 0;
|
|
45
|
+
this.totalCount = raw.total_count || 0;
|
|
46
|
+
this.successCount = raw.success_count || 0;
|
|
47
|
+
this.failedCount = raw.failed_count || 0;
|
|
48
|
+
this.skippedCount = raw.skipped_count || 0;
|
|
49
|
+
this.errorCount = raw.error_count || 0;
|
|
50
|
+
this.testCases = (raw.test_cases || []).map(tc => new GitLabTestCase(tc));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
toJSON(): IGitLabTestSuite {
|
|
54
|
+
return {
|
|
55
|
+
name: this.name,
|
|
56
|
+
total_time: this.totalTime,
|
|
57
|
+
total_count: this.totalCount,
|
|
58
|
+
success_count: this.successCount,
|
|
59
|
+
failed_count: this.failedCount,
|
|
60
|
+
skipped_count: this.skippedCount,
|
|
61
|
+
error_count: this.errorCount,
|
|
62
|
+
test_cases: this.testCases.map(tc => tc.toJSON()),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class GitLabTestReport {
|
|
68
|
+
public readonly totalTime: number;
|
|
69
|
+
public readonly totalCount: number;
|
|
70
|
+
public readonly successCount: number;
|
|
71
|
+
public readonly failedCount: number;
|
|
72
|
+
public readonly skippedCount: number;
|
|
73
|
+
public readonly errorCount: number;
|
|
74
|
+
public readonly testSuites: GitLabTestSuite[];
|
|
75
|
+
|
|
76
|
+
constructor(raw: IGitLabTestReport) {
|
|
77
|
+
this.totalTime = raw.total_time || 0;
|
|
78
|
+
this.totalCount = raw.total_count || 0;
|
|
79
|
+
this.successCount = raw.success_count || 0;
|
|
80
|
+
this.failedCount = raw.failed_count || 0;
|
|
81
|
+
this.skippedCount = raw.skipped_count || 0;
|
|
82
|
+
this.errorCount = raw.error_count || 0;
|
|
83
|
+
this.testSuites = (raw.test_suites || []).map(ts => new GitLabTestSuite(ts));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
toJSON(): IGitLabTestReport {
|
|
87
|
+
return {
|
|
88
|
+
total_time: this.totalTime,
|
|
89
|
+
total_count: this.totalCount,
|
|
90
|
+
success_count: this.successCount,
|
|
91
|
+
failed_count: this.failedCount,
|
|
92
|
+
skipped_count: this.skippedCount,
|
|
93
|
+
error_count: this.errorCount,
|
|
94
|
+
test_suites: this.testSuites.map(ts => ts.toJSON()),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|