@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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- 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 +117 -32
- package/dist_ts/gitlab.classes.gitlabclient.js +278 -96
- 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/gitlab.interfaces.d.ts +114 -9
- package/dist_ts/gitlab.interfaces.js +4 -1
- package/dist_ts/index.d.ts +11 -1
- package/dist_ts/index.js +15 -1
- package/package.json +1 -1
- package/readme.md +468 -163
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/gitlab.classes.branch.ts +18 -0
- package/ts/gitlab.classes.gitlabclient.ts +354 -114
- 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/gitlab.interfaces.ts +162 -11
- package/ts/index.ts +25 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { IGitLabVariable, IGitLabPipelineVariable } from './gitlab.interfaces.js';
|
|
2
|
+
|
|
3
|
+
export class GitLabVariable {
|
|
4
|
+
public readonly key: string;
|
|
5
|
+
public readonly value: string;
|
|
6
|
+
public readonly variableType: string;
|
|
7
|
+
public readonly protected: boolean;
|
|
8
|
+
public readonly masked: boolean;
|
|
9
|
+
public readonly environmentScope: string;
|
|
10
|
+
|
|
11
|
+
constructor(raw: IGitLabVariable) {
|
|
12
|
+
this.key = raw.key || '';
|
|
13
|
+
this.value = raw.value || '';
|
|
14
|
+
this.variableType = raw.variable_type || 'env_var';
|
|
15
|
+
this.protected = raw.protected ?? false;
|
|
16
|
+
this.masked = raw.masked ?? false;
|
|
17
|
+
this.environmentScope = raw.environment_scope || '*';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toJSON(): IGitLabVariable {
|
|
21
|
+
return {
|
|
22
|
+
key: this.key,
|
|
23
|
+
value: this.value,
|
|
24
|
+
variable_type: this.variableType,
|
|
25
|
+
protected: this.protected,
|
|
26
|
+
masked: this.masked,
|
|
27
|
+
environment_scope: this.environmentScope,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class GitLabPipelineVariable {
|
|
33
|
+
public readonly key: string;
|
|
34
|
+
public readonly value: string;
|
|
35
|
+
public readonly variableType: string;
|
|
36
|
+
|
|
37
|
+
constructor(raw: IGitLabPipelineVariable) {
|
|
38
|
+
this.key = raw.key || '';
|
|
39
|
+
this.value = raw.value || '';
|
|
40
|
+
this.variableType = raw.variable_type || 'env_var';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
toJSON(): IGitLabPipelineVariable {
|
|
44
|
+
return {
|
|
45
|
+
key: this.key,
|
|
46
|
+
value: this.value,
|
|
47
|
+
variable_type: this.variableType,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-paginate a list endpoint.
|
|
3
|
+
* If opts includes a specific page, returns just that page (no auto-pagination).
|
|
4
|
+
*/
|
|
5
|
+
export async function autoPaginate<T>(
|
|
6
|
+
fetchPage: (page: number, perPage: number) => Promise<T[]>,
|
|
7
|
+
opts?: { page?: number; perPage?: number },
|
|
8
|
+
): Promise<T[]> {
|
|
9
|
+
const perPage = opts?.perPage || 50;
|
|
10
|
+
|
|
11
|
+
// If caller requests a specific page, return just that page
|
|
12
|
+
if (opts?.page) {
|
|
13
|
+
return fetchPage(opts.page, perPage);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Otherwise auto-paginate through all pages
|
|
17
|
+
const all: T[] = [];
|
|
18
|
+
let page = 1;
|
|
19
|
+
while (true) {
|
|
20
|
+
const items = await fetchPage(page, perPage);
|
|
21
|
+
all.push(...items);
|
|
22
|
+
if (items.length < perPage) break;
|
|
23
|
+
page++;
|
|
24
|
+
}
|
|
25
|
+
return all;
|
|
26
|
+
}
|
package/ts/gitlab.interfaces.ts
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Common
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
export interface ITestConnectionResult {
|
|
6
|
+
ok: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface IListOptions {
|
|
11
|
+
search?: string;
|
|
12
|
+
page?: number;
|
|
13
|
+
perPage?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Pipeline / Job list options
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
export interface IPipelineListOptions extends IListOptions {
|
|
21
|
+
/** Filter by pipeline status */
|
|
22
|
+
status?: string;
|
|
23
|
+
/** Filter by branch or tag ref */
|
|
24
|
+
ref?: string;
|
|
25
|
+
/** Filter by trigger source (push, web, trigger, schedule, api, external, pipeline, chat, merge_request_event, …) */
|
|
26
|
+
source?: string;
|
|
27
|
+
/** Filter by scope (running, pending, finished, branches, tags) */
|
|
28
|
+
scope?: string;
|
|
29
|
+
/** Filter by the user who triggered the pipeline */
|
|
30
|
+
username?: string;
|
|
31
|
+
/** Return pipelines updated after this ISO 8601 date */
|
|
32
|
+
updatedAfter?: string;
|
|
33
|
+
/** Return pipelines updated before this ISO 8601 date */
|
|
34
|
+
updatedBefore?: string;
|
|
35
|
+
/** Order by field (id, status, ref, updated_at, user_id). Default: id */
|
|
36
|
+
orderBy?: string;
|
|
37
|
+
/** Sort direction (asc, desc). Default: desc */
|
|
38
|
+
sort?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IJobListOptions extends IListOptions {
|
|
42
|
+
/** Filter by job scope(s) */
|
|
43
|
+
scope?: string[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// Users
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
|
|
1
50
|
export interface IGitLabUser {
|
|
2
51
|
id: number;
|
|
3
52
|
username: string;
|
|
@@ -8,6 +57,10 @@ export interface IGitLabUser {
|
|
|
8
57
|
state: string;
|
|
9
58
|
}
|
|
10
59
|
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
// Projects
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
|
|
11
64
|
export interface IGitLabProject {
|
|
12
65
|
id: number;
|
|
13
66
|
name: string;
|
|
@@ -20,6 +73,10 @@ export interface IGitLabProject {
|
|
|
20
73
|
last_activity_at: string;
|
|
21
74
|
}
|
|
22
75
|
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Groups
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
|
|
23
80
|
export interface IGitLabGroup {
|
|
24
81
|
id: number;
|
|
25
82
|
name: string;
|
|
@@ -29,6 +86,10 @@ export interface IGitLabGroup {
|
|
|
29
86
|
visibility: string;
|
|
30
87
|
}
|
|
31
88
|
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Variables
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
|
|
32
93
|
export interface IGitLabVariable {
|
|
33
94
|
key: string;
|
|
34
95
|
value: string;
|
|
@@ -44,32 +105,133 @@ export interface IVariableOptions {
|
|
|
44
105
|
environment_scope?: string;
|
|
45
106
|
}
|
|
46
107
|
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
// Protected Branches
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
|
|
47
112
|
export interface IGitLabProtectedBranch {
|
|
48
113
|
id: number;
|
|
49
114
|
name: string;
|
|
50
115
|
allow_force_push: boolean;
|
|
51
116
|
}
|
|
52
117
|
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Pipelines
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
|
|
53
122
|
export interface IGitLabPipeline {
|
|
54
123
|
id: number;
|
|
124
|
+
iid: number;
|
|
55
125
|
project_id: number;
|
|
56
126
|
status: string;
|
|
57
127
|
ref: string;
|
|
58
128
|
sha: string;
|
|
129
|
+
before_sha: string;
|
|
130
|
+
tag: boolean;
|
|
59
131
|
web_url: string;
|
|
60
132
|
duration: number;
|
|
133
|
+
queued_duration: number;
|
|
61
134
|
created_at: string;
|
|
135
|
+
updated_at: string;
|
|
136
|
+
started_at: string;
|
|
137
|
+
finished_at: string;
|
|
62
138
|
source: string;
|
|
139
|
+
coverage: string;
|
|
140
|
+
user: IGitLabUser;
|
|
141
|
+
detailed_status: {
|
|
142
|
+
icon: string;
|
|
143
|
+
text: string;
|
|
144
|
+
label: string;
|
|
145
|
+
group: string;
|
|
146
|
+
tooltip: string;
|
|
147
|
+
has_details: boolean;
|
|
148
|
+
details_path: string;
|
|
149
|
+
favicon: string;
|
|
150
|
+
};
|
|
151
|
+
yaml_errors: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface IGitLabPipelineVariable {
|
|
155
|
+
key: string;
|
|
156
|
+
value: string;
|
|
157
|
+
variable_type: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface IGitLabTestReport {
|
|
161
|
+
total_time: number;
|
|
162
|
+
total_count: number;
|
|
163
|
+
success_count: number;
|
|
164
|
+
failed_count: number;
|
|
165
|
+
skipped_count: number;
|
|
166
|
+
error_count: number;
|
|
167
|
+
test_suites: IGitLabTestSuite[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface IGitLabTestSuite {
|
|
171
|
+
name: string;
|
|
172
|
+
total_time: number;
|
|
173
|
+
total_count: number;
|
|
174
|
+
success_count: number;
|
|
175
|
+
failed_count: number;
|
|
176
|
+
skipped_count: number;
|
|
177
|
+
error_count: number;
|
|
178
|
+
test_cases: IGitLabTestCase[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface IGitLabTestCase {
|
|
182
|
+
status: string;
|
|
183
|
+
name: string;
|
|
184
|
+
classname: string;
|
|
185
|
+
execution_time: number;
|
|
186
|
+
system_output: string;
|
|
187
|
+
stack_trace: string;
|
|
63
188
|
}
|
|
64
189
|
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
// Jobs
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
|
|
65
194
|
export interface IGitLabJob {
|
|
66
195
|
id: number;
|
|
67
196
|
name: string;
|
|
68
197
|
stage: string;
|
|
69
198
|
status: string;
|
|
199
|
+
ref: string;
|
|
200
|
+
tag: boolean;
|
|
201
|
+
web_url: string;
|
|
202
|
+
created_at: string;
|
|
203
|
+
started_at: string;
|
|
204
|
+
finished_at: string;
|
|
70
205
|
duration: number;
|
|
206
|
+
queued_duration: number;
|
|
207
|
+
coverage: number;
|
|
208
|
+
allow_failure: boolean;
|
|
209
|
+
failure_reason: string;
|
|
210
|
+
pipeline: {
|
|
211
|
+
id: number;
|
|
212
|
+
project_id: number;
|
|
213
|
+
ref: string;
|
|
214
|
+
sha: string;
|
|
215
|
+
status: string;
|
|
216
|
+
};
|
|
217
|
+
user: IGitLabUser;
|
|
218
|
+
runner: {
|
|
219
|
+
id: number;
|
|
220
|
+
description: string;
|
|
221
|
+
active: boolean;
|
|
222
|
+
is_shared: boolean;
|
|
223
|
+
};
|
|
224
|
+
artifacts: {
|
|
225
|
+
filename: string;
|
|
226
|
+
size: number;
|
|
227
|
+
}[];
|
|
228
|
+
artifacts_expire_at: string;
|
|
71
229
|
}
|
|
72
230
|
|
|
231
|
+
// ---------------------------------------------------------------------------
|
|
232
|
+
// Branches & Tags
|
|
233
|
+
// ---------------------------------------------------------------------------
|
|
234
|
+
|
|
73
235
|
export interface IGitLabBranch {
|
|
74
236
|
name: string;
|
|
75
237
|
commit: {
|
|
@@ -83,14 +245,3 @@ export interface IGitLabTag {
|
|
|
83
245
|
id: string;
|
|
84
246
|
};
|
|
85
247
|
}
|
|
86
|
-
|
|
87
|
-
export interface ITestConnectionResult {
|
|
88
|
-
ok: boolean;
|
|
89
|
-
error?: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface IListOptions {
|
|
93
|
-
search?: string;
|
|
94
|
-
page?: number;
|
|
95
|
-
perPage?: number;
|
|
96
|
-
}
|
package/ts/index.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
+
// Main client
|
|
1
2
|
export { GitLabClient } from './gitlab.classes.gitlabclient.js';
|
|
3
|
+
|
|
4
|
+
// Domain classes
|
|
5
|
+
export { GitLabGroup } from './gitlab.classes.group.js';
|
|
6
|
+
export { GitLabProject } from './gitlab.classes.project.js';
|
|
7
|
+
export { GitLabPipeline } from './gitlab.classes.pipeline.js';
|
|
8
|
+
export { GitLabJob } from './gitlab.classes.job.js';
|
|
9
|
+
export { GitLabBranch } from './gitlab.classes.branch.js';
|
|
10
|
+
export { GitLabTag } from './gitlab.classes.tag.js';
|
|
11
|
+
export { GitLabProtectedBranch } from './gitlab.classes.protectedbranch.js';
|
|
12
|
+
export { GitLabVariable, GitLabPipelineVariable } from './gitlab.classes.variable.js';
|
|
13
|
+
export { GitLabTestReport, GitLabTestSuite, GitLabTestCase } from './gitlab.classes.testreport.js';
|
|
14
|
+
|
|
15
|
+
// Helpers
|
|
16
|
+
export { autoPaginate } from './gitlab.helpers.js';
|
|
17
|
+
|
|
18
|
+
// Interfaces (raw API types)
|
|
2
19
|
export type {
|
|
3
20
|
IGitLabUser,
|
|
4
21
|
IGitLabProject,
|
|
@@ -9,8 +26,16 @@ export type {
|
|
|
9
26
|
IGitLabTag,
|
|
10
27
|
IVariableOptions,
|
|
11
28
|
IGitLabPipeline,
|
|
29
|
+
IGitLabPipelineVariable,
|
|
30
|
+
IGitLabTestReport,
|
|
31
|
+
IGitLabTestSuite,
|
|
32
|
+
IGitLabTestCase,
|
|
12
33
|
IGitLabJob,
|
|
13
34
|
ITestConnectionResult,
|
|
14
35
|
IListOptions,
|
|
36
|
+
IPipelineListOptions,
|
|
37
|
+
IJobListOptions,
|
|
15
38
|
} from './gitlab.interfaces.js';
|
|
39
|
+
|
|
40
|
+
// Commit info
|
|
16
41
|
export { commitinfo } from './00_commitinfo_data.js';
|