@venturialstd/gitlab 0.0.22 → 0.0.23
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/client/gitlab.client.d.ts +4 -4
- package/dist/client/gitlab.client.d.ts.map +1 -1
- package/dist/client/gitlab.client.js +5 -10
- package/dist/client/gitlab.client.js.map +1 -1
- package/dist/interfaces/gitlab-credentials.interface.d.ts +8 -0
- package/dist/interfaces/gitlab-credentials.interface.d.ts.map +1 -0
- package/dist/interfaces/gitlab-credentials.interface.js +3 -0
- package/dist/interfaces/gitlab-credentials.interface.js.map +1 -0
- package/dist/services/gitlab-project.service.d.ts +7 -6
- package/dist/services/gitlab-project.service.d.ts.map +1 -1
- package/dist/services/gitlab-project.service.js +30 -12
- package/dist/services/gitlab-project.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { HttpService } from '@nestjs/axios';
|
|
2
|
-
import { AppLogger
|
|
2
|
+
import { AppLogger } from '@venturialstd/core';
|
|
3
3
|
import { GITLAB_CLIENT_METHOD } from '../constants/gitlab-client.constant';
|
|
4
|
+
import { GitlabOptions } from '../interfaces/gitlab-credentials.interface';
|
|
4
5
|
export declare class GitlabClient {
|
|
5
6
|
private readonly httpService;
|
|
6
7
|
private readonly logger;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
request(method: GITLAB_CLIENT_METHOD, url: string, data?: unknown): Promise<any>;
|
|
8
|
+
constructor(httpService: HttpService, logger: AppLogger);
|
|
9
|
+
request(options: GitlabOptions, method: GITLAB_CLIENT_METHOD, url: string, data?: unknown): Promise<any>;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=gitlab.client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.client.d.ts","sourceRoot":"","sources":["../../src/client/gitlab.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"gitlab.client.d.ts","sourceRoot":"","sources":["../../src/client/gitlab.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAE3E,qBACa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,SAAS;IAG9B,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAuBhG"}
|
|
@@ -14,21 +14,17 @@ const axios_1 = require("@nestjs/axios");
|
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const core_1 = require("@venturialstd/core");
|
|
16
16
|
const rxjs_1 = require("rxjs");
|
|
17
|
-
const gitlab_settings_constants_1 = require("../constants/gitlab.settings.constants");
|
|
18
17
|
let GitlabClient = class GitlabClient {
|
|
19
18
|
httpService;
|
|
20
19
|
logger;
|
|
21
|
-
|
|
22
|
-
constructor(httpService, logger, settings) {
|
|
20
|
+
constructor(httpService, logger) {
|
|
23
21
|
this.httpService = httpService;
|
|
24
22
|
this.logger = logger;
|
|
25
|
-
this.settings = settings;
|
|
26
23
|
}
|
|
27
|
-
async request(method, url, data) {
|
|
28
|
-
const host =
|
|
29
|
-
const token = await this.settings.get(gitlab_settings_constants_1.GITLAB_SETTING_KEYS.GENERAL_API_TOKEN);
|
|
24
|
+
async request(options, method, url, data) {
|
|
25
|
+
const { host, token } = options.credentials;
|
|
30
26
|
if (!host || !token)
|
|
31
|
-
throw new Error('GitLab host or token
|
|
27
|
+
throw new Error('GitLab host or token not provided');
|
|
32
28
|
const fullUrl = `${host}${url}`;
|
|
33
29
|
try {
|
|
34
30
|
const response = await (0, rxjs_1.firstValueFrom)(this.httpService.request({
|
|
@@ -50,7 +46,6 @@ exports.GitlabClient = GitlabClient;
|
|
|
50
46
|
exports.GitlabClient = GitlabClient = __decorate([
|
|
51
47
|
(0, common_1.Injectable)(),
|
|
52
48
|
__metadata("design:paramtypes", [axios_1.HttpService,
|
|
53
|
-
core_1.AppLogger
|
|
54
|
-
core_1.SettingsService])
|
|
49
|
+
core_1.AppLogger])
|
|
55
50
|
], GitlabClient);
|
|
56
51
|
//# sourceMappingURL=gitlab.client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.client.js","sourceRoot":"","sources":["../../src/client/gitlab.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"gitlab.client.js","sourceRoot":"","sources":["../../src/client/gitlab.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAA4C;AAC5C,6CAA+C;AAC/C,+BAAsC;AAM/B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEJ;IACA;IAFnB,YACmB,WAAwB,EACxB,MAAiB;QADjB,gBAAW,GAAX,WAAW,CAAa;QACxB,WAAM,GAAN,MAAM,CAAW;IACjC,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,OAAsB,EAAE,MAA4B,EAAE,GAAW,EAAE,IAAc;QAC7F,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;QAE5C,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAE1E,MAAM,OAAO,GAAG,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC;QAEhC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAc,EACnC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;gBACvB,MAAM;gBACN,GAAG,EAAE,OAAO;gBACZ,IAAI;gBACJ,OAAO,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE;aACpC,CAAC,CACH,CAAC;YACF,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,gBAAgB,MAAM,IAAI,OAAO,EAAE,CAAC,CAAC;YACtD,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,MAAM,IAAI,OAAO,MAAM,GAAY,EAAE,CAAC,CAAC;YAC9E,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF,CAAA;AA7BY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAGqB,mBAAW;QAChB,gBAAS;GAHzB,YAAY,CA6BxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitlab-credentials.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/gitlab-credentials.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,iBAAiB,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitlab-credentials.interface.js","sourceRoot":"","sources":["../../src/interfaces/gitlab-credentials.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { GitlabClient } from '../client/gitlab.client';
|
|
2
|
+
import { GitlabOptions } from '../interfaces/gitlab-credentials.interface';
|
|
2
3
|
import { GitlabFileDiff, GitlabMergeRequest, GitlabMergeRequestChangesResponse, GitlabMergeRequestPayloadDiscussion } from '../interfaces/gitlab-project.interface';
|
|
3
4
|
export declare class GitlabProjectService {
|
|
4
5
|
private readonly client;
|
|
5
6
|
constructor(client: GitlabClient);
|
|
6
|
-
getMergeRequests(projectId: number): Promise<GitlabMergeRequest[]>;
|
|
7
|
-
getMergeRequestChanges(projectId: number, mrIid: number): Promise<GitlabMergeRequestChangesResponse>;
|
|
8
|
-
getMergeRequestDiffFilePlain(projectId: number, mrId: number): Promise<string>;
|
|
9
|
-
getMergeRequestDiff(projectId: number, mrId: number): Promise<GitlabFileDiff[]>;
|
|
10
|
-
createMergeRequestDiscussion(projectId: number, mrId: number, body: GitlabMergeRequestPayloadDiscussion): Promise<string>;
|
|
11
|
-
getFile(projectId: number, filePath: string, ref?: string): Promise<string>;
|
|
7
|
+
getMergeRequests(options: GitlabOptions | null, projectId: number): Promise<GitlabMergeRequest[]>;
|
|
8
|
+
getMergeRequestChanges(options: GitlabOptions | null, projectId: number, mrIid: number): Promise<GitlabMergeRequestChangesResponse>;
|
|
9
|
+
getMergeRequestDiffFilePlain(options: GitlabOptions | null, projectId: number, mrId: number): Promise<string>;
|
|
10
|
+
getMergeRequestDiff(options: GitlabOptions | null, projectId: number, mrId: number): Promise<GitlabFileDiff[]>;
|
|
11
|
+
createMergeRequestDiscussion(options: GitlabOptions | null, projectId: number, mrId: number, body: GitlabMergeRequestPayloadDiscussion): Promise<string>;
|
|
12
|
+
getFile(options: GitlabOptions | null, projectId: number, filePath: string, ref?: string): Promise<string>;
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=gitlab-project.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab-project.service.d.ts","sourceRoot":"","sources":["../../src/services/gitlab-project.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iCAAiC,EACjC,mCAA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,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,GAAG,SAAS,GACX,OAAO,CAAC,MAAM,CAAC;CAWnB"}
|
|
@@ -18,30 +18,48 @@ let GitlabProjectService = class GitlabProjectService {
|
|
|
18
18
|
constructor(client) {
|
|
19
19
|
this.client = client;
|
|
20
20
|
}
|
|
21
|
-
getMergeRequests(projectId) {
|
|
22
|
-
|
|
21
|
+
getMergeRequests(options, projectId) {
|
|
22
|
+
if (!options) {
|
|
23
|
+
throw new Error('GitlabOptions are required to create a discussion');
|
|
24
|
+
}
|
|
25
|
+
return this.client.request(options, gitlab_client_constant_1.GITLAB_CLIENT_METHOD.GET, `/projects/${projectId}/merge_requests?state=opened`);
|
|
23
26
|
}
|
|
24
|
-
getMergeRequestChanges(projectId, mrIid) {
|
|
25
|
-
|
|
27
|
+
getMergeRequestChanges(options, projectId, mrIid) {
|
|
28
|
+
if (!options) {
|
|
29
|
+
throw new Error('GitlabOptions are required to create a discussion');
|
|
30
|
+
}
|
|
31
|
+
return this.client.request(options, gitlab_client_constant_1.GITLAB_CLIENT_METHOD.GET, `/projects/${projectId}/merge_requests/${mrIid}/changes`);
|
|
26
32
|
}
|
|
27
|
-
getMergeRequestDiffFilePlain(projectId, mrId) {
|
|
28
|
-
|
|
33
|
+
getMergeRequestDiffFilePlain(options, projectId, mrId) {
|
|
34
|
+
if (!options) {
|
|
35
|
+
throw new Error('GitlabOptions are required to create a discussion');
|
|
36
|
+
}
|
|
37
|
+
return this.client.request(options, gitlab_client_constant_1.GITLAB_CLIENT_METHOD.GET, `/projects/${projectId}/merge_requests/${mrId}/raw_diffs`);
|
|
29
38
|
}
|
|
30
|
-
getMergeRequestDiff(projectId, mrId) {
|
|
31
|
-
|
|
39
|
+
getMergeRequestDiff(options, projectId, mrId) {
|
|
40
|
+
if (!options) {
|
|
41
|
+
throw new Error('GitlabOptions are required to create a discussion');
|
|
42
|
+
}
|
|
43
|
+
return this.client.request(options, gitlab_client_constant_1.GITLAB_CLIENT_METHOD.GET, `/projects/${projectId}/merge_requests/${mrId}/diffs`);
|
|
32
44
|
}
|
|
33
|
-
createMergeRequestDiscussion(projectId, mrId, body) {
|
|
45
|
+
createMergeRequestDiscussion(options, projectId, mrId, body) {
|
|
34
46
|
if (body.position) {
|
|
35
47
|
const hasLine = typeof body.position.new_line === 'number' || typeof body.position.old_line === 'number';
|
|
36
48
|
if (!hasLine) {
|
|
37
49
|
throw new Error('Position must include new_line or old_line');
|
|
38
50
|
}
|
|
39
51
|
}
|
|
40
|
-
|
|
52
|
+
if (!options) {
|
|
53
|
+
throw new Error('GitlabOptions are required to create a discussion');
|
|
54
|
+
}
|
|
55
|
+
return this.client.request(options, gitlab_client_constant_1.GITLAB_CLIENT_METHOD.POST, `/projects/${projectId}/merge_requests/${mrId}/discussions`, body);
|
|
41
56
|
}
|
|
42
|
-
getFile(projectId, filePath, ref = 'main') {
|
|
57
|
+
getFile(options, projectId, filePath, ref = 'main') {
|
|
43
58
|
const encoded = encodeURIComponent(filePath);
|
|
44
|
-
|
|
59
|
+
if (!options) {
|
|
60
|
+
throw new Error('GitlabOptions are required to create a discussion');
|
|
61
|
+
}
|
|
62
|
+
return this.client.request(options, gitlab_client_constant_1.GITLAB_CLIENT_METHOD.GET, `/projects/${projectId}/repository/files/${encoded}/raw?ref=${ref}`);
|
|
45
63
|
}
|
|
46
64
|
};
|
|
47
65
|
exports.GitlabProjectService = GitlabProjectService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab-project.service.js","sourceRoot":"","sources":["../../src/services/gitlab-project.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,2DAAuD;AACvD,gFAA2E;
|
|
1
|
+
{"version":3,"file":"gitlab-project.service.js","sourceRoot":"","sources":["../../src/services/gitlab-project.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,2DAAuD;AACvD,gFAA2E;AAUpE,IAAM,oBAAoB,G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