@clickview/ship-it 0.0.32 → 0.0.33

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 (175) hide show
  1. package/Dockerfile +33 -33
  2. package/README.md +48 -48
  3. package/config.json +19 -19
  4. package/lib/config.json +20 -20
  5. package/lib/src/api-clients/git-lab/GitLabApiClient.js +439 -439
  6. package/lib/src/api-clients/git-lab/GitLabMapper.js +82 -82
  7. package/lib/src/api-clients/index.js +20 -20
  8. package/lib/src/api-clients/slack/SlackApiClient.js +206 -206
  9. package/lib/src/api-clients/team-city/TeamCityApiClient.js +100 -100
  10. package/lib/src/api-clients/trello/TrelloApiClient.js +145 -145
  11. package/lib/src/commands/BumpPackagesCommand.js +84 -84
  12. package/lib/src/commands/CreateBranchCommand.js +100 -100
  13. package/lib/src/commands/CreateMergeRequestCommand.js +107 -107
  14. package/lib/src/commands/CreateNotesAuditCommand.js +84 -84
  15. package/lib/src/commands/CreateReleaseNotesCommand.js +95 -95
  16. package/lib/src/commands/CreateTrelloCardsCommand.js +77 -77
  17. package/lib/src/commands/InstallPackagesCommand.js +76 -76
  18. package/lib/src/commands/ListProjectsCommand.js +76 -76
  19. package/lib/src/commands/ReleaseCommand.js +129 -129
  20. package/lib/src/commands/StartProjectBuildsCommand.js +76 -76
  21. package/lib/src/commands/StatusCommand.js +88 -88
  22. package/lib/src/commands/TagMasterCommand.js +76 -76
  23. package/lib/src/commands/ValidateMergeRequestCommand.js +76 -76
  24. package/lib/src/commands/VersionCommand.js +76 -76
  25. package/lib/src/commands/index.js +30 -30
  26. package/lib/src/constants/CommandTypeMapping.js +20 -20
  27. package/lib/src/constants/GitLabMemberIds.js +6 -6
  28. package/lib/src/constants/MonorepoPackageJsonFiles.js +17 -17
  29. package/lib/src/constants/MonorepoProjectNames.js +16 -16
  30. package/lib/src/constants/ProjectNames.js +68 -68
  31. package/lib/src/constants/SlackUserEmailList.js +13 -13
  32. package/lib/src/constants/TeamCityBuildIDs.js +45 -45
  33. package/lib/src/constants/index.js +19 -19
  34. package/lib/src/errors/ShipItError.js +32 -32
  35. package/lib/src/errors/index.js +17 -17
  36. package/lib/src/index.js +18 -18
  37. package/lib/src/interfaces/Config.js +2 -2
  38. package/lib/src/interfaces/MergeRequestState.js +2 -2
  39. package/lib/src/interfaces/ProjectNames.js +2 -2
  40. package/lib/src/interfaces/ShipItCommand.js +2 -2
  41. package/lib/src/interfaces/ShipItTask.js +2 -2
  42. package/lib/src/interfaces/VersionType.js +2 -2
  43. package/lib/src/interfaces/command-cli-options/MilestoneCommandCliOptions.js +2 -2
  44. package/lib/src/interfaces/command-cli-options/ReleaseCommandCliOptions.js +2 -2
  45. package/lib/src/interfaces/command-cli-options/StatusCommandCliOptions.js +2 -2
  46. package/lib/src/interfaces/command-cli-options/index.js +19 -19
  47. package/lib/src/interfaces/command-options/BaseCommandOptions.js +2 -2
  48. package/lib/src/interfaces/command-options/BumpPackagesCommandOptions.js +2 -2
  49. package/lib/src/interfaces/command-options/DockerMilestoneCommandOptions.js +2 -2
  50. package/lib/src/interfaces/command-options/MilestoneCommandOptions.js +2 -2
  51. package/lib/src/interfaces/command-options/ReleaseCommandOptions.js +2 -2
  52. package/lib/src/interfaces/command-options/StatusCommandOptions.js +2 -2
  53. package/lib/src/interfaces/command-options/ValidateMRCommandOptions.js +2 -2
  54. package/lib/src/interfaces/command-options/index.js +22 -22
  55. package/lib/src/interfaces/index.js +26 -26
  56. package/lib/src/interfaces/models/Branch.js +2 -2
  57. package/lib/src/interfaces/models/Commit.js +2 -2
  58. package/lib/src/interfaces/models/CommitFile.js +2 -2
  59. package/lib/src/interfaces/models/File.js +2 -2
  60. package/lib/src/interfaces/models/Label.js +2 -2
  61. package/lib/src/interfaces/models/MergeRequest.js +2 -2
  62. package/lib/src/interfaces/models/Milestone.js +2 -2
  63. package/lib/src/interfaces/models/Project.js +2 -2
  64. package/lib/src/interfaces/models/ProjectConfig.js +9 -9
  65. package/lib/src/interfaces/models/Release.js +2 -2
  66. package/lib/src/interfaces/models/Tag.js +2 -2
  67. package/lib/src/interfaces/models/index.js +26 -26
  68. package/lib/src/interfaces/view-models/MilestoneProject.js +2 -2
  69. package/lib/src/interfaces/view-models/index.js +17 -17
  70. package/lib/src/inversify.config.js +75 -75
  71. package/lib/src/services/GitLabService.js +508 -508
  72. package/lib/src/services/SlackService.js +142 -142
  73. package/lib/src/services/TeamCityService.js +37 -37
  74. package/lib/src/services/TrelloService.js +84 -84
  75. package/lib/src/services/index.js +20 -20
  76. package/lib/src/startup/AddMilestoneCommand.js +96 -96
  77. package/lib/src/startup/GetAction.js +68 -68
  78. package/lib/src/startup/SetupCommands.js +168 -168
  79. package/lib/src/tasks/BumpPackagesTask.js +229 -229
  80. package/lib/src/tasks/BumpVersionTxtTask.js +110 -110
  81. package/lib/src/tasks/CommitPackageVersionsTask.js +116 -116
  82. package/lib/src/tasks/CreateBranchTask.js +104 -104
  83. package/lib/src/tasks/CreateMergeRequestTask.js +118 -118
  84. package/lib/src/tasks/CreateNotesAuditTask.js +140 -140
  85. package/lib/src/tasks/CreateReleaseNotesTask.js +144 -144
  86. package/lib/src/tasks/InstallPackagesTask.js +407 -407
  87. package/lib/src/tasks/ListProjectsTask.js +87 -87
  88. package/lib/src/tasks/PopulateTrelloBoardTask.js +140 -140
  89. package/lib/src/tasks/StartMonorepoBuildTask.js +109 -109
  90. package/lib/src/tasks/StartProjectBuildsTask.js +170 -170
  91. package/lib/src/tasks/TagMasterTask.js +186 -186
  92. package/lib/src/tasks/ValidateCommitsTask.js +143 -143
  93. package/lib/src/tasks/ValidateDescriptionsTask.js +178 -178
  94. package/lib/src/tasks/ValidateMergeRequestTask.js +115 -115
  95. package/lib/src/tasks/ValidateTask.js +419 -419
  96. package/lib/src/tasks/VersionTask.js +98 -98
  97. package/lib/src/tasks/index.js +34 -34
  98. package/lib/src/types.js +57 -57
  99. package/lib/src/utils/BranchNames.js +11 -11
  100. package/lib/src/utils/Commits.js +55 -55
  101. package/lib/src/utils/Csv.js +54 -54
  102. package/lib/src/utils/Descriptions.js +274 -274
  103. package/lib/src/utils/GroupIds.js +6 -6
  104. package/lib/src/utils/Logger.js +62 -62
  105. package/lib/src/utils/ProjectIds.js +47 -47
  106. package/lib/src/utils/Versions.js +20 -20
  107. package/lib/src/utils/index.js +22 -22
  108. package/package.json +50 -50
  109. package/dist/F1/Analytics Web.md +0 -8
  110. package/dist/F1/AutoCaptions.md +0 -30
  111. package/dist/F1/Classroom.Api.md +0 -23
  112. package/dist/F1/ClickView Online.md +0 -17
  113. package/dist/F1/ClickView.Curator.md +0 -100
  114. package/dist/F1/ClickView.EmailService.md +0 -53
  115. package/dist/F1/ClickView.OnlineApi.md +0 -13
  116. package/dist/F1/Clients.md +0 -19
  117. package/dist/F1/Domain.Api.md +0 -23
  118. package/dist/F1/Exchange.Web.md +0 -8
  119. package/dist/F1/Image.Api.md +0 -8
  120. package/dist/F1/Integrations.Api.md +0 -23
  121. package/dist/F1/Krakend.md +0 -8
  122. package/dist/F1/Library Editor.md +0 -0
  123. package/dist/F1/Lite.md +0 -60
  124. package/dist/F1/Master.Api.md +0 -58
  125. package/dist/F1/Master.Auth.md +0 -22
  126. package/dist/F1/Objects.Api.md +0 -12
  127. package/dist/F1/Permissions.Api.md +0 -12
  128. package/dist/F1/RealtimeSalesforceSync.md +0 -14
  129. package/dist/F1/Release Notes.md +0 -990
  130. package/dist/F1/Search.Api.md +0 -12
  131. package/dist/F1/StreamableLearning.Web.md +0 -35
  132. package/dist/F1/Users.Api.md +0 -13
  133. package/dist/F1/VideoProcessorService.md +0 -23
  134. package/dist/F1/clickview.md +0 -321
  135. package/dist/F2/Analytics Web.md +0 -7
  136. package/dist/F2/Batch.Api.md +0 -27
  137. package/dist/F2/ClickView Online.md +0 -12
  138. package/dist/F2/ClickView.Curator.md +0 -166
  139. package/dist/F2/Clients.md +0 -14
  140. package/dist/F2/CurriculumIngestion.Api.md +0 -13
  141. package/dist/F2/Discover.Api.md +0 -64
  142. package/dist/F2/Domain.Api.md +0 -16
  143. package/dist/F2/Exchange.Web.md +0 -7
  144. package/dist/F2/Krakend.md +0 -12
  145. package/dist/F2/Library Editor.md +0 -11
  146. package/dist/F2/Lite.md +0 -30
  147. package/dist/F2/Objects.Api.md +0 -12
  148. package/dist/F2/Release Notes.md +0 -759
  149. package/dist/F2/Search.Api.md +0 -30
  150. package/dist/F2/Share.Api.md +0 -12
  151. package/dist/F2/StreamableLearning.Web.md +0 -14
  152. package/dist/F2/Subjects.API.md +0 -12
  153. package/dist/F2/Tv.Web.md +0 -8
  154. package/dist/F2/Users.Api.md +0 -21
  155. package/dist/F2/clickview.md +0 -200
  156. package/dist/F2/shortcode-api.md +0 -8
  157. package/dist/F3.1/Analytics Web.md +0 -8
  158. package/dist/F3.1/ClickView.Curator.md +0 -14
  159. package/dist/F3.1/Discover.Api.md +0 -14
  160. package/dist/F3.1/Domain.Api.md +0 -7
  161. package/dist/F3.1/Exchange.Web.md +0 -8
  162. package/dist/F3.1/Library Editor.md +0 -8
  163. package/dist/F3.1/Lite.md +0 -8
  164. package/dist/F3.1/Objects.Api.md +0 -7
  165. package/dist/F3.1/Release Notes.md +0 -207
  166. package/dist/F3.1/Search.Api.md +0 -14
  167. package/dist/F3.1/Share.Api.md +0 -10
  168. package/dist/F3.1/Subjects.API.md +0 -35
  169. package/dist/F3.1/VideoViews.Api.md +0 -7
  170. package/dist/F3.1/clickview.md +0 -28
  171. package/lib/src/commands/CreateTestingNotesCommand.js +0 -84
  172. package/lib/src/commands/StartConsumingProjectBuildsCommand.js +0 -76
  173. package/lib/src/tasks/CreateTestingNotesTask.js +0 -135
  174. package/lib/src/tasks/MergeMasterToDevTask.js +0 -147
  175. package/lib/src/tasks/StartConsumingProjectBuildsTask.js +0 -149
@@ -1,439 +1,439 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- var __generator = (this && this.__generator) || function (thisArg, body) {
24
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
- function verb(n) { return function (v) { return step([n, v]); }; }
27
- function step(op) {
28
- if (f) throw new TypeError("Generator is already executing.");
29
- while (_) try {
30
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
- if (y = 0, t) op = [op[0] & 2, t.value];
32
- switch (op[0]) {
33
- case 0: case 1: t = op; break;
34
- case 4: _.label++; return { value: op[1], done: false };
35
- case 5: _.label++; y = op[1]; op = [0]; continue;
36
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
- default:
38
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
- if (t[2]) _.ops.pop();
43
- _.trys.pop(); continue;
44
- }
45
- op = body.call(thisArg, _);
46
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
- }
49
- };
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.GitLabApiClient = void 0;
52
- require("reflect-metadata");
53
- var inversify_1 = require("inversify");
54
- var node_1 = require("@gitbeaker/node");
55
- var types_1 = require("../../types");
56
- var errors_1 = require("../../errors");
57
- var GitLabMapper_1 = require("./GitLabMapper");
58
- var GroupIds_1 = require("../../utils/GroupIds");
59
- var GitLabMemberIds_1 = require("../../constants/GitLabMemberIds");
60
- var GitLabApiClient = /** @class */ (function () {
61
- function GitLabApiClient(config) {
62
- this.config = config;
63
- this.client = new node_1.Gitlab({
64
- token: this.config.accessToken,
65
- host: this.config.url
66
- });
67
- }
68
- GitLabApiClient.prototype.getMergeRequests = function (options) {
69
- return __awaiter(this, void 0, void 0, function () {
70
- var milestone, projectIds, createdAfter, mergeRequests;
71
- return __generator(this, function (_a) {
72
- switch (_a.label) {
73
- case 0:
74
- milestone = options.milestone, projectIds = options.projectIds;
75
- if (!milestone && !(projectIds === null || projectIds === void 0 ? void 0 : projectIds.length))
76
- throw new errors_1.ShipItError('Must specify one of the following: Milestone or ProjectIds');
77
- createdAfter = new Date();
78
- createdAfter.setMonth(createdAfter.getMonth() - 3);
79
- return [4 /*yield*/, this.client.MergeRequests.all({
80
- milestone: milestone,
81
- createdAfter: createdAfter.toISOString(),
82
- scope: 'all'
83
- })];
84
- case 1:
85
- mergeRequests = _a.sent();
86
- return [2 /*return*/, mergeRequests.map(GitLabMapper_1.GitLabMapper.mergeRequest)];
87
- }
88
- });
89
- });
90
- };
91
- GitLabApiClient.prototype.getProjectsByIds = function (projectIds) {
92
- return __awaiter(this, void 0, void 0, function () {
93
- var promises, projects;
94
- var _this = this;
95
- return __generator(this, function (_a) {
96
- switch (_a.label) {
97
- case 0:
98
- promises = projectIds.map(function (p) { return _this.client.Projects.show(p); });
99
- return [4 /*yield*/, Promise.all(promises)];
100
- case 1:
101
- projects = _a.sent();
102
- return [2 /*return*/, projects.map(GitLabMapper_1.GitLabMapper.project)];
103
- }
104
- });
105
- });
106
- };
107
- GitLabApiClient.prototype.getLatestTags = function (projectId) {
108
- return __awaiter(this, void 0, void 0, function () {
109
- var tags;
110
- return __generator(this, function (_a) {
111
- switch (_a.label) {
112
- case 0: return [4 /*yield*/, this.client.Tags.all(projectId, { maxPages: 1, perPage: 20 })];
113
- case 1:
114
- tags = _a.sent();
115
- return [2 /*return*/, tags.map(GitLabMapper_1.GitLabMapper.tag)];
116
- }
117
- });
118
- });
119
- };
120
- GitLabApiClient.prototype.getTag = function (projectId, tagName) {
121
- return __awaiter(this, void 0, void 0, function () {
122
- var tag, _a;
123
- return __generator(this, function (_b) {
124
- switch (_b.label) {
125
- case 0:
126
- _b.trys.push([0, 2, , 3]);
127
- return [4 /*yield*/, this.client.Tags.show(projectId, tagName)];
128
- case 1:
129
- tag = _b.sent();
130
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.tag(tag)];
131
- case 2:
132
- _a = _b.sent();
133
- return [2 /*return*/, null];
134
- case 3: return [2 /*return*/];
135
- }
136
- });
137
- });
138
- };
139
- GitLabApiClient.prototype.createTag = function (projectId, tagName, sha) {
140
- return __awaiter(this, void 0, void 0, function () {
141
- var tag;
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
144
- case 0: return [4 /*yield*/, this.client.Tags.create(projectId, tagName, sha)];
145
- case 1:
146
- tag = _a.sent();
147
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.tag(tag)];
148
- }
149
- });
150
- });
151
- };
152
- GitLabApiClient.prototype.createRelease = function (projectId, release) {
153
- return __awaiter(this, void 0, void 0, function () {
154
- var newRelease;
155
- return __generator(this, function (_a) {
156
- switch (_a.label) {
157
- case 0: return [4 /*yield*/, this.client.Releases.create(projectId, {
158
- id: projectId,
159
- name: release.name,
160
- tag_name: release.tag,
161
- description: release.description,
162
- ref: release.ref
163
- })];
164
- case 1:
165
- newRelease = _a.sent();
166
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.release(newRelease)];
167
- }
168
- });
169
- });
170
- };
171
- GitLabApiClient.prototype.getCommitsForRelease = function (projectId, dateSince) {
172
- return __awaiter(this, void 0, void 0, function () {
173
- var commits;
174
- return __generator(this, function (_a) {
175
- switch (_a.label) {
176
- case 0: return [4 /*yield*/, this.client.Commits.all(projectId, {
177
- ref_name: 'dev',
178
- since: dateSince,
179
- /**
180
- * This allows us to get merge commits of MRs being accepted
181
- */
182
- first_parent: true
183
- })];
184
- case 1:
185
- commits = _a.sent();
186
- return [2 /*return*/, commits.map(GitLabMapper_1.GitLabMapper.commit)];
187
- }
188
- });
189
- });
190
- };
191
- GitLabApiClient.prototype.getBranch = function (projectId, branchName) {
192
- return __awaiter(this, void 0, void 0, function () {
193
- var branch, _a;
194
- return __generator(this, function (_b) {
195
- switch (_b.label) {
196
- case 0:
197
- _b.trys.push([0, 2, , 3]);
198
- return [4 /*yield*/, this.client.Branches.show(projectId, branchName)];
199
- case 1:
200
- branch = _b.sent();
201
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.branch(branch)];
202
- case 2:
203
- _a = _b.sent();
204
- return [2 /*return*/, null];
205
- case 3: return [2 /*return*/];
206
- }
207
- });
208
- });
209
- };
210
- GitLabApiClient.prototype.createBranch = function (projectId, branchName, branchFrom) {
211
- return __awaiter(this, void 0, void 0, function () {
212
- var newBranch;
213
- return __generator(this, function (_a) {
214
- switch (_a.label) {
215
- case 0: return [4 /*yield*/, this.client.Branches.create(projectId, branchName, branchFrom)];
216
- case 1:
217
- newBranch = _a.sent();
218
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.branch(newBranch)];
219
- }
220
- });
221
- });
222
- };
223
- GitLabApiClient.prototype.cherryPick = function (projectId, sha, branchName) {
224
- return __awaiter(this, void 0, void 0, function () {
225
- return __generator(this, function (_a) {
226
- switch (_a.label) {
227
- case 0: return [4 /*yield*/, this.client.Commits.cherryPick(projectId, sha, branchName)];
228
- case 1:
229
- _a.sent();
230
- return [2 /*return*/];
231
- }
232
- });
233
- });
234
- };
235
- GitLabApiClient.prototype.getMergeRequest = function (projectId, sourceBranch, targetBranch, state) {
236
- return __awaiter(this, void 0, void 0, function () {
237
- var opts, mergeRequests, mergeRequest;
238
- return __generator(this, function (_a) {
239
- switch (_a.label) {
240
- case 0:
241
- opts = {
242
- projectId: projectId,
243
- sourceBranch: sourceBranch,
244
- targetBranch: targetBranch
245
- };
246
- /**
247
- * We only care about open MRs, this allows us to close any MR and run the CLI again if needed
248
- */
249
- if (state)
250
- opts.state = state;
251
- return [4 /*yield*/, this.client.MergeRequests.all(opts)];
252
- case 1:
253
- mergeRequests = _a.sent();
254
- mergeRequest = mergeRequests[0];
255
- if (!mergeRequest)
256
- return [2 /*return*/, null];
257
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(mergeRequest)];
258
- }
259
- });
260
- });
261
- };
262
- GitLabApiClient.prototype.getMergeRequestById = function (projectId, mergeRequestId) {
263
- return __awaiter(this, void 0, void 0, function () {
264
- var mergeRequest;
265
- return __generator(this, function (_a) {
266
- switch (_a.label) {
267
- case 0: return [4 /*yield*/, this.client.MergeRequests.show(projectId, mergeRequestId)];
268
- case 1:
269
- mergeRequest = _a.sent();
270
- if (!mergeRequest)
271
- return [2 /*return*/, null];
272
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(mergeRequest)];
273
- }
274
- });
275
- });
276
- };
277
- GitLabApiClient.prototype.getReleaseMergeRequest = function (projectId, milestone) {
278
- return __awaiter(this, void 0, void 0, function () {
279
- var mergeRequests, releaseMR;
280
- return __generator(this, function (_a) {
281
- switch (_a.label) {
282
- case 0: return [4 /*yield*/, this.client.MergeRequests.all({
283
- projectId: projectId,
284
- targetBranch: 'master',
285
- /**
286
- * We only care about open MRs, this allows us to close any MR and run the CLI again if needed
287
- */
288
- state: 'opened',
289
- milestone: milestone
290
- })];
291
- case 1:
292
- mergeRequests = _a.sent();
293
- releaseMR = mergeRequests[0];
294
- if (!releaseMR)
295
- return [2 /*return*/, null];
296
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(releaseMR)];
297
- }
298
- });
299
- });
300
- };
301
- GitLabApiClient.prototype.createMergeRequest = function (projectId, sourceBranch, targetBranch, title, description, milestone) {
302
- return __awaiter(this, void 0, void 0, function () {
303
- var mergeRequest;
304
- return __generator(this, function (_a) {
305
- switch (_a.label) {
306
- case 0: return [4 /*yield*/, this.client.MergeRequests.create(projectId, sourceBranch, targetBranch, title, {
307
- description: description,
308
- milestoneId: milestone.id,
309
- assigneeId: GitLabMemberIds_1.GitLabMemberIds.SHIP_IT
310
- })];
311
- case 1:
312
- mergeRequest = _a.sent();
313
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(mergeRequest)];
314
- }
315
- });
316
- });
317
- };
318
- GitLabApiClient.prototype.AcceptMergeRequest = function (projectId, mergerequestIId) {
319
- return __awaiter(this, void 0, void 0, function () {
320
- var mergeRequest;
321
- return __generator(this, function (_a) {
322
- switch (_a.label) {
323
- case 0: return [4 /*yield*/, this.client.MergeRequests.accept(projectId, mergerequestIId)];
324
- case 1:
325
- mergeRequest = _a.sent();
326
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(mergeRequest)];
327
- }
328
- });
329
- });
330
- };
331
- GitLabApiClient.prototype.getFile = function (projectId, filePath, branchName) {
332
- return __awaiter(this, void 0, void 0, function () {
333
- var file, _a;
334
- return __generator(this, function (_b) {
335
- switch (_b.label) {
336
- case 0:
337
- _b.trys.push([0, 2, , 3]);
338
- return [4 /*yield*/, this.client.RepositoryFiles.show(projectId, filePath, branchName)];
339
- case 1:
340
- file = _b.sent();
341
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.file(file)];
342
- case 2:
343
- _a = _b.sent();
344
- return [2 /*return*/, null];
345
- case 3: return [2 /*return*/];
346
- }
347
- });
348
- });
349
- };
350
- GitLabApiClient.prototype.updateFile = function (projectId, filePath, branchName, content, commitMessage) {
351
- return __awaiter(this, void 0, void 0, function () {
352
- return __generator(this, function (_a) {
353
- switch (_a.label) {
354
- case 0: return [4 /*yield*/, this.client.RepositoryFiles.edit(projectId, filePath, branchName, content, commitMessage)];
355
- case 1:
356
- _a.sent();
357
- return [2 /*return*/];
358
- }
359
- });
360
- });
361
- };
362
- GitLabApiClient.prototype.commit = function (projectId, branchName, files, commitMessage) {
363
- return __awaiter(this, void 0, void 0, function () {
364
- return __generator(this, function (_a) {
365
- switch (_a.label) {
366
- case 0: return [4 /*yield*/, this.client.Commits.create(projectId, branchName, commitMessage, files.map(function (f) { return ({
367
- action: 'update',
368
- filePath: f.filePath,
369
- content: f.content
370
- }); }))];
371
- case 1:
372
- _a.sent();
373
- return [2 /*return*/];
374
- }
375
- });
376
- });
377
- };
378
- GitLabApiClient.prototype.getMilestone = function (milestoneName, projectId) {
379
- return __awaiter(this, void 0, void 0, function () {
380
- var groupMilestones, milestone, projectMilestones;
381
- return __generator(this, function (_a) {
382
- switch (_a.label) {
383
- case 0: return [4 /*yield*/, this.client.GroupMilestones.all(GroupIds_1.GroupIds.CLICKVIEW)];
384
- case 1:
385
- groupMilestones = _a.sent();
386
- milestone = groupMilestones.find(function (milestone) { return milestone.title === milestoneName; });
387
- if (milestone)
388
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.milestone(milestone)];
389
- if (!projectId)
390
- return [2 /*return*/, null];
391
- return [4 /*yield*/, this.client.ProjectMilestones.all(projectId)];
392
- case 2:
393
- projectMilestones = _a.sent();
394
- milestone = projectMilestones.find(function (milestone) { return milestone.title === milestoneName; });
395
- if (!milestone)
396
- return [2 /*return*/, null];
397
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.milestone(milestone)];
398
- }
399
- });
400
- });
401
- };
402
- GitLabApiClient.prototype.updateMilestone = function (projectId, mergeRequestId, newMilestoneId) {
403
- return __awaiter(this, void 0, void 0, function () {
404
- var updated;
405
- return __generator(this, function (_a) {
406
- switch (_a.label) {
407
- case 0: return [4 /*yield*/, this.client.MergeRequests.edit(projectId, mergeRequestId, {
408
- milestoneId: newMilestoneId,
409
- })];
410
- case 1:
411
- updated = _a.sent();
412
- if (!updated)
413
- return [2 /*return*/, null];
414
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.milestone(updated.milestone)];
415
- }
416
- });
417
- });
418
- };
419
- GitLabApiClient.prototype.getLabels = function (projectId) {
420
- return __awaiter(this, void 0, void 0, function () {
421
- var labels;
422
- return __generator(this, function (_a) {
423
- switch (_a.label) {
424
- case 0: return [4 /*yield*/, this.client.Labels.all(projectId)];
425
- case 1:
426
- labels = _a.sent();
427
- return [2 /*return*/, labels.map(GitLabMapper_1.GitLabMapper.label)];
428
- }
429
- });
430
- });
431
- };
432
- GitLabApiClient = __decorate([
433
- (0, inversify_1.injectable)(),
434
- __param(0, (0, inversify_1.inject)(types_1.MISC.GitLabConfig)),
435
- __metadata("design:paramtypes", [Object])
436
- ], GitLabApiClient);
437
- return GitLabApiClient;
438
- }());
439
- exports.GitLabApiClient = GitLabApiClient;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (_) try {
30
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.GitLabApiClient = void 0;
52
+ require("reflect-metadata");
53
+ var inversify_1 = require("inversify");
54
+ var node_1 = require("@gitbeaker/node");
55
+ var types_1 = require("../../types");
56
+ var errors_1 = require("../../errors");
57
+ var GitLabMapper_1 = require("./GitLabMapper");
58
+ var GroupIds_1 = require("../../utils/GroupIds");
59
+ var GitLabMemberIds_1 = require("../../constants/GitLabMemberIds");
60
+ var GitLabApiClient = /** @class */ (function () {
61
+ function GitLabApiClient(config) {
62
+ this.config = config;
63
+ this.client = new node_1.Gitlab({
64
+ token: this.config.accessToken,
65
+ host: this.config.url
66
+ });
67
+ }
68
+ GitLabApiClient.prototype.getMergeRequests = function (options) {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var milestone, projectIds, updatedAfter, mergeRequests;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ milestone = options.milestone, projectIds = options.projectIds;
75
+ if (!milestone && !(projectIds === null || projectIds === void 0 ? void 0 : projectIds.length))
76
+ throw new errors_1.ShipItError('Must specify one of the following: Milestone or ProjectIds');
77
+ updatedAfter = new Date();
78
+ updatedAfter.setMonth(updatedAfter.getMonth() - 3);
79
+ return [4 /*yield*/, this.client.MergeRequests.all({
80
+ milestone: milestone,
81
+ updatedAfter: updatedAfter.toISOString(),
82
+ scope: 'all'
83
+ })];
84
+ case 1:
85
+ mergeRequests = _a.sent();
86
+ return [2 /*return*/, mergeRequests.map(GitLabMapper_1.GitLabMapper.mergeRequest)];
87
+ }
88
+ });
89
+ });
90
+ };
91
+ GitLabApiClient.prototype.getProjectsByIds = function (projectIds) {
92
+ return __awaiter(this, void 0, void 0, function () {
93
+ var promises, projects;
94
+ var _this = this;
95
+ return __generator(this, function (_a) {
96
+ switch (_a.label) {
97
+ case 0:
98
+ promises = projectIds.map(function (p) { return _this.client.Projects.show(p); });
99
+ return [4 /*yield*/, Promise.all(promises)];
100
+ case 1:
101
+ projects = _a.sent();
102
+ return [2 /*return*/, projects.map(GitLabMapper_1.GitLabMapper.project)];
103
+ }
104
+ });
105
+ });
106
+ };
107
+ GitLabApiClient.prototype.getLatestTags = function (projectId) {
108
+ return __awaiter(this, void 0, void 0, function () {
109
+ var tags;
110
+ return __generator(this, function (_a) {
111
+ switch (_a.label) {
112
+ case 0: return [4 /*yield*/, this.client.Tags.all(projectId, { maxPages: 1, perPage: 20 })];
113
+ case 1:
114
+ tags = _a.sent();
115
+ return [2 /*return*/, tags.map(GitLabMapper_1.GitLabMapper.tag)];
116
+ }
117
+ });
118
+ });
119
+ };
120
+ GitLabApiClient.prototype.getTag = function (projectId, tagName) {
121
+ return __awaiter(this, void 0, void 0, function () {
122
+ var tag, _a;
123
+ return __generator(this, function (_b) {
124
+ switch (_b.label) {
125
+ case 0:
126
+ _b.trys.push([0, 2, , 3]);
127
+ return [4 /*yield*/, this.client.Tags.show(projectId, tagName)];
128
+ case 1:
129
+ tag = _b.sent();
130
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.tag(tag)];
131
+ case 2:
132
+ _a = _b.sent();
133
+ return [2 /*return*/, null];
134
+ case 3: return [2 /*return*/];
135
+ }
136
+ });
137
+ });
138
+ };
139
+ GitLabApiClient.prototype.createTag = function (projectId, tagName, sha) {
140
+ return __awaiter(this, void 0, void 0, function () {
141
+ var tag;
142
+ return __generator(this, function (_a) {
143
+ switch (_a.label) {
144
+ case 0: return [4 /*yield*/, this.client.Tags.create(projectId, tagName, sha)];
145
+ case 1:
146
+ tag = _a.sent();
147
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.tag(tag)];
148
+ }
149
+ });
150
+ });
151
+ };
152
+ GitLabApiClient.prototype.createRelease = function (projectId, release) {
153
+ return __awaiter(this, void 0, void 0, function () {
154
+ var newRelease;
155
+ return __generator(this, function (_a) {
156
+ switch (_a.label) {
157
+ case 0: return [4 /*yield*/, this.client.Releases.create(projectId, {
158
+ id: projectId,
159
+ name: release.name,
160
+ tag_name: release.tag,
161
+ description: release.description,
162
+ ref: release.ref
163
+ })];
164
+ case 1:
165
+ newRelease = _a.sent();
166
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.release(newRelease)];
167
+ }
168
+ });
169
+ });
170
+ };
171
+ GitLabApiClient.prototype.getCommitsForRelease = function (projectId, dateSince) {
172
+ return __awaiter(this, void 0, void 0, function () {
173
+ var commits;
174
+ return __generator(this, function (_a) {
175
+ switch (_a.label) {
176
+ case 0: return [4 /*yield*/, this.client.Commits.all(projectId, {
177
+ ref_name: 'dev',
178
+ since: dateSince,
179
+ /**
180
+ * This allows us to get merge commits of MRs being accepted
181
+ */
182
+ first_parent: true
183
+ })];
184
+ case 1:
185
+ commits = _a.sent();
186
+ return [2 /*return*/, commits.map(GitLabMapper_1.GitLabMapper.commit)];
187
+ }
188
+ });
189
+ });
190
+ };
191
+ GitLabApiClient.prototype.getBranch = function (projectId, branchName) {
192
+ return __awaiter(this, void 0, void 0, function () {
193
+ var branch, _a;
194
+ return __generator(this, function (_b) {
195
+ switch (_b.label) {
196
+ case 0:
197
+ _b.trys.push([0, 2, , 3]);
198
+ return [4 /*yield*/, this.client.Branches.show(projectId, branchName)];
199
+ case 1:
200
+ branch = _b.sent();
201
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.branch(branch)];
202
+ case 2:
203
+ _a = _b.sent();
204
+ return [2 /*return*/, null];
205
+ case 3: return [2 /*return*/];
206
+ }
207
+ });
208
+ });
209
+ };
210
+ GitLabApiClient.prototype.createBranch = function (projectId, branchName, branchFrom) {
211
+ return __awaiter(this, void 0, void 0, function () {
212
+ var newBranch;
213
+ return __generator(this, function (_a) {
214
+ switch (_a.label) {
215
+ case 0: return [4 /*yield*/, this.client.Branches.create(projectId, branchName, branchFrom)];
216
+ case 1:
217
+ newBranch = _a.sent();
218
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.branch(newBranch)];
219
+ }
220
+ });
221
+ });
222
+ };
223
+ GitLabApiClient.prototype.cherryPick = function (projectId, sha, branchName) {
224
+ return __awaiter(this, void 0, void 0, function () {
225
+ return __generator(this, function (_a) {
226
+ switch (_a.label) {
227
+ case 0: return [4 /*yield*/, this.client.Commits.cherryPick(projectId, sha, branchName)];
228
+ case 1:
229
+ _a.sent();
230
+ return [2 /*return*/];
231
+ }
232
+ });
233
+ });
234
+ };
235
+ GitLabApiClient.prototype.getMergeRequest = function (projectId, sourceBranch, targetBranch, state) {
236
+ return __awaiter(this, void 0, void 0, function () {
237
+ var opts, mergeRequests, mergeRequest;
238
+ return __generator(this, function (_a) {
239
+ switch (_a.label) {
240
+ case 0:
241
+ opts = {
242
+ projectId: projectId,
243
+ sourceBranch: sourceBranch,
244
+ targetBranch: targetBranch
245
+ };
246
+ /**
247
+ * We only care about open MRs, this allows us to close any MR and run the CLI again if needed
248
+ */
249
+ if (state)
250
+ opts.state = state;
251
+ return [4 /*yield*/, this.client.MergeRequests.all(opts)];
252
+ case 1:
253
+ mergeRequests = _a.sent();
254
+ mergeRequest = mergeRequests[0];
255
+ if (!mergeRequest)
256
+ return [2 /*return*/, null];
257
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(mergeRequest)];
258
+ }
259
+ });
260
+ });
261
+ };
262
+ GitLabApiClient.prototype.getMergeRequestById = function (projectId, mergeRequestId) {
263
+ return __awaiter(this, void 0, void 0, function () {
264
+ var mergeRequest;
265
+ return __generator(this, function (_a) {
266
+ switch (_a.label) {
267
+ case 0: return [4 /*yield*/, this.client.MergeRequests.show(projectId, mergeRequestId)];
268
+ case 1:
269
+ mergeRequest = _a.sent();
270
+ if (!mergeRequest)
271
+ return [2 /*return*/, null];
272
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(mergeRequest)];
273
+ }
274
+ });
275
+ });
276
+ };
277
+ GitLabApiClient.prototype.getReleaseMergeRequest = function (projectId, milestone) {
278
+ return __awaiter(this, void 0, void 0, function () {
279
+ var mergeRequests, releaseMR;
280
+ return __generator(this, function (_a) {
281
+ switch (_a.label) {
282
+ case 0: return [4 /*yield*/, this.client.MergeRequests.all({
283
+ projectId: projectId,
284
+ targetBranch: 'master',
285
+ /**
286
+ * We only care about open MRs, this allows us to close any MR and run the CLI again if needed
287
+ */
288
+ state: 'opened',
289
+ milestone: milestone
290
+ })];
291
+ case 1:
292
+ mergeRequests = _a.sent();
293
+ releaseMR = mergeRequests[0];
294
+ if (!releaseMR)
295
+ return [2 /*return*/, null];
296
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(releaseMR)];
297
+ }
298
+ });
299
+ });
300
+ };
301
+ GitLabApiClient.prototype.createMergeRequest = function (projectId, sourceBranch, targetBranch, title, description, milestone) {
302
+ return __awaiter(this, void 0, void 0, function () {
303
+ var mergeRequest;
304
+ return __generator(this, function (_a) {
305
+ switch (_a.label) {
306
+ case 0: return [4 /*yield*/, this.client.MergeRequests.create(projectId, sourceBranch, targetBranch, title, {
307
+ description: description,
308
+ milestoneId: milestone.id,
309
+ assigneeId: GitLabMemberIds_1.GitLabMemberIds.SHIP_IT
310
+ })];
311
+ case 1:
312
+ mergeRequest = _a.sent();
313
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(mergeRequest)];
314
+ }
315
+ });
316
+ });
317
+ };
318
+ GitLabApiClient.prototype.AcceptMergeRequest = function (projectId, mergerequestIId) {
319
+ return __awaiter(this, void 0, void 0, function () {
320
+ var mergeRequest;
321
+ return __generator(this, function (_a) {
322
+ switch (_a.label) {
323
+ case 0: return [4 /*yield*/, this.client.MergeRequests.accept(projectId, mergerequestIId)];
324
+ case 1:
325
+ mergeRequest = _a.sent();
326
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(mergeRequest)];
327
+ }
328
+ });
329
+ });
330
+ };
331
+ GitLabApiClient.prototype.getFile = function (projectId, filePath, branchName) {
332
+ return __awaiter(this, void 0, void 0, function () {
333
+ var file, _a;
334
+ return __generator(this, function (_b) {
335
+ switch (_b.label) {
336
+ case 0:
337
+ _b.trys.push([0, 2, , 3]);
338
+ return [4 /*yield*/, this.client.RepositoryFiles.show(projectId, filePath, branchName)];
339
+ case 1:
340
+ file = _b.sent();
341
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.file(file)];
342
+ case 2:
343
+ _a = _b.sent();
344
+ return [2 /*return*/, null];
345
+ case 3: return [2 /*return*/];
346
+ }
347
+ });
348
+ });
349
+ };
350
+ GitLabApiClient.prototype.updateFile = function (projectId, filePath, branchName, content, commitMessage) {
351
+ return __awaiter(this, void 0, void 0, function () {
352
+ return __generator(this, function (_a) {
353
+ switch (_a.label) {
354
+ case 0: return [4 /*yield*/, this.client.RepositoryFiles.edit(projectId, filePath, branchName, content, commitMessage)];
355
+ case 1:
356
+ _a.sent();
357
+ return [2 /*return*/];
358
+ }
359
+ });
360
+ });
361
+ };
362
+ GitLabApiClient.prototype.commit = function (projectId, branchName, files, commitMessage) {
363
+ return __awaiter(this, void 0, void 0, function () {
364
+ return __generator(this, function (_a) {
365
+ switch (_a.label) {
366
+ case 0: return [4 /*yield*/, this.client.Commits.create(projectId, branchName, commitMessage, files.map(function (f) { return ({
367
+ action: 'update',
368
+ filePath: f.filePath,
369
+ content: f.content
370
+ }); }))];
371
+ case 1:
372
+ _a.sent();
373
+ return [2 /*return*/];
374
+ }
375
+ });
376
+ });
377
+ };
378
+ GitLabApiClient.prototype.getMilestone = function (milestoneName, projectId) {
379
+ return __awaiter(this, void 0, void 0, function () {
380
+ var groupMilestones, milestone, projectMilestones;
381
+ return __generator(this, function (_a) {
382
+ switch (_a.label) {
383
+ case 0: return [4 /*yield*/, this.client.GroupMilestones.all(GroupIds_1.GroupIds.CLICKVIEW)];
384
+ case 1:
385
+ groupMilestones = _a.sent();
386
+ milestone = groupMilestones.find(function (milestone) { return milestone.title === milestoneName; });
387
+ if (milestone)
388
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.milestone(milestone)];
389
+ if (!projectId)
390
+ return [2 /*return*/, null];
391
+ return [4 /*yield*/, this.client.ProjectMilestones.all(projectId)];
392
+ case 2:
393
+ projectMilestones = _a.sent();
394
+ milestone = projectMilestones.find(function (milestone) { return milestone.title === milestoneName; });
395
+ if (!milestone)
396
+ return [2 /*return*/, null];
397
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.milestone(milestone)];
398
+ }
399
+ });
400
+ });
401
+ };
402
+ GitLabApiClient.prototype.updateMilestone = function (projectId, mergeRequestId, newMilestoneId) {
403
+ return __awaiter(this, void 0, void 0, function () {
404
+ var updated;
405
+ return __generator(this, function (_a) {
406
+ switch (_a.label) {
407
+ case 0: return [4 /*yield*/, this.client.MergeRequests.edit(projectId, mergeRequestId, {
408
+ milestoneId: newMilestoneId,
409
+ })];
410
+ case 1:
411
+ updated = _a.sent();
412
+ if (!updated)
413
+ return [2 /*return*/, null];
414
+ return [2 /*return*/, GitLabMapper_1.GitLabMapper.milestone(updated.milestone)];
415
+ }
416
+ });
417
+ });
418
+ };
419
+ GitLabApiClient.prototype.getLabels = function (projectId) {
420
+ return __awaiter(this, void 0, void 0, function () {
421
+ var labels;
422
+ return __generator(this, function (_a) {
423
+ switch (_a.label) {
424
+ case 0: return [4 /*yield*/, this.client.Labels.all(projectId)];
425
+ case 1:
426
+ labels = _a.sent();
427
+ return [2 /*return*/, labels.map(GitLabMapper_1.GitLabMapper.label)];
428
+ }
429
+ });
430
+ });
431
+ };
432
+ GitLabApiClient = __decorate([
433
+ (0, inversify_1.injectable)(),
434
+ __param(0, (0, inversify_1.inject)(types_1.MISC.GitLabConfig)),
435
+ __metadata("design:paramtypes", [Object])
436
+ ], GitLabApiClient);
437
+ return GitLabApiClient;
438
+ }());
439
+ exports.GitLabApiClient = GitLabApiClient;