UNPKG

stash-connector

Version:

Module to handle and work with Atlassian Stash projects and repositories throug REST API. Admin your repositories and projects in Stash easy. This project is not an Atlassian official project but use the Atlassian Stash REST API

959 lines 174 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { 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; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProjectsEndpoint = exports.ProjectAvatarEndpoint = exports.ProjectPermissionsAllEndpoint = exports.ProjectPermissionsGroupsEndpoint = exports.ProjectPermissionsUsersEndpoint = exports.ProjectPermissionsEndpoint = exports.ProjectReposEndpoint = exports.ProjectRepoBranchesDefaultEndpoint = exports.ProjectRepoBranchesEndpoint = exports.ProjectRepoRelatedEndpoint = exports.ProjectRepoRecreateEndpoint = exports.ProjectRepoForksEndpoint = exports.ProjectRepoBrowseEndpoint = exports.ProjectRepoFilesEndpoint = exports.ProjectRepoDiffEndpoint = exports.ProjectRepoChangesEndpoint = exports.ProjectRepoTagsEndpoint = exports.ProjectRepoPermissionsGroupsEndpoint = exports.ProjectRepoPermissionsUsersEndpoint = exports.ProjectRepoPermissionsEndpoint = exports.ProjectRepoCompareDiffEndpoint = exports.ProjectRepoCompareCommitsEndpoint = exports.ProjectRepoCompareChangesEndpoint = exports.ProjectRepoCompareEndpoint = exports.ProjectRepoCommitWatchEndpoint = exports.ProjectRepoCommitDiffEndpoint = exports.ProjectRepoCommitCommentsEndpoint = exports.ProjectRepoCommitChangesEndpoint = exports.ProjectRepoCommitsEndpoint = exports.ProjectRepoPullRequestWatchEndpoint = exports.ProjectRepoPullRequestTasksEndpoint = exports.ProjectRepoPullRequestParticipantEndpoint = exports.ProjectRepoPullRequestDiffEndpoint = exports.ProjectRepoPullRequestsCommitsEndpoint = exports.ProjectRepoPullRequestsCommentsEndpoint = exports.ProjectRepoPullRequestsChangesEndpoint = exports.ProjectRepoPullRequestsApproveEndpoint = exports.ProjectRepoPullRequestsReopenEndpoint = exports.ProjectRepoPullRequestsMergeEndpoint = exports.ProjectRepoPullRequestsDeclineEndpoint = exports.ProjectRepoPullRequestsActivitiesEndpoint = exports.ProjectRepoPullRequestsEndpoint = exports.ProjectRepoSettingsHooksSettingsEndpoint = exports.ProjectRepoSettingsHooksEndpoint = exports.ProjectRepoSettingsEndpoint = void 0; var types_1 = require("../types"); var ProjectInputImp = /** @class */ (function () { function ProjectInputImp(input) { this.key = input.key; this.name = input.name; this.description = input.description; this.avatar = input.avatar ? input.avatar.getAvatar() : undefined; } return ProjectInputImp; }()); /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/settings' */ var ProjectRepoSettingsEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoSettingsEndpoint, _super); function ProjectRepoSettingsEndpoint(auth, slug) { var _this = _super.call(this, auth, '/' + slug + '/settings') || this; /** * Contains all operations related with project repository settings hooks * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoSettingsHooksEndpoint} Get all operations about the project repository settings hooks */ _this.hooks = function () { return new ProjectRepoSettingsHooksEndpoint(_this.auth); }; return _this; } return ProjectRepoSettingsEndpoint; }(types_1.EndpointService)); exports.ProjectRepoSettingsEndpoint = ProjectRepoSettingsEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/settings/hooks' */ var ProjectRepoSettingsHooksEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoSettingsHooksEndpoint, _super); function ProjectRepoSettingsHooksEndpoint(auth) { var _this = _super.call(this, auth, '/hooks') || this; /** * Contains all operations related with project repository settings hooks configurations * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}/settings' * @param {string} hookKey Hook Key * @returns {ProjectRepoSettingsHooksSettingsEndpoint} Get all operations about the project repository settings hooks configurations */ _this.settings = function (hookKey) { return new ProjectRepoSettingsHooksSettingsEndpoint(_this.auth, hookKey); }; return _this; } /** * Retrieve a page of repository hooks for this repository * @param {string} [type] The optional type to filter by. Valid values are PRE_RECEIVE or POST_RECEIVE * @param {PageOptions} [pageOptions] Page options to paginate results (or obtain more results per page) * @returns {Promise<Page<HookOutput>>} Promise with the requested page data. */ ProjectRepoSettingsHooksEndpoint.prototype.list = function (type, pageOptions) { return __awaiter(this, void 0, void 0, function () { var request, result, error_1; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet({ pageOptions: pageOptions, }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); if (type) { request.addQueryParam('type', type); } return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_1 = _a.sent(); throw error_1; case 4: return [2 /*return*/]; } }); }); }; /** * Retrieve a repository hook for this repositories. * @param hookKey The key of the hook to retrieve * @returns {Promise<HookOutput>} Promise with the requested hook data */ ProjectRepoSettingsHooksEndpoint.prototype.get = function (hookKey) { return __awaiter(this, void 0, void 0, function () { var request, result, error_2; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet({ param: hookKey, }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_2 = _a.sent(); throw error_2; case 4: return [2 /*return*/]; } }); }); }; /** * Enable a repository hook for this repositories and optionally applying new configuration. * @param hookKey The key of the hook to enable * @returns {Promise<HookOutput>} Promise with the requested hook data */ ProjectRepoSettingsHooksEndpoint.prototype.enable = function (hookKey) { return __awaiter(this, void 0, void 0, function () { var request, result, error_3; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPut({ param: hookKey + '/enabled', }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_3 = _a.sent(); throw error_3; case 4: return [2 /*return*/]; } }); }); }; /** * Disable a repository hook for this repositories. * @param hookKey The key of the hook to disable * @returns {Promise<HookOutput>} Promise with the requested hook data */ ProjectRepoSettingsHooksEndpoint.prototype.disable = function (hookKey) { return __awaiter(this, void 0, void 0, function () { var request, result, error_4; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doDelete({ param: hookKey + '/enabled', }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_4 = _a.sent(); throw error_4; case 4: return [2 /*return*/]; } }); }); }; return ProjectRepoSettingsHooksEndpoint; }(types_1.EndpointService)); exports.ProjectRepoSettingsHooksEndpoint = ProjectRepoSettingsHooksEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}/settings' */ var ProjectRepoSettingsHooksSettingsEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoSettingsHooksSettingsEndpoint, _super); function ProjectRepoSettingsHooksSettingsEndpoint(auth, hookKey) { return _super.call(this, auth, '/' + hookKey + '/settings') || this; } /** * Retrieve the settings for a repository hook for this repositories * @returns {Promise<HookOutput>} Promise with the requested hook settings */ ProjectRepoSettingsHooksSettingsEndpoint.prototype.get = function () { return __awaiter(this, void 0, void 0, function () { var request, result, error_5; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet(); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_5 = _a.sent(); throw error_5; case 4: return [2 /*return*/]; } }); }); }; /** * Modify the settings for a repository hook for this repositories * @returns {Promise<HookOutput>} Promise with the requested hook settings */ ProjectRepoSettingsHooksSettingsEndpoint.prototype.update = function (hookSettings) { return __awaiter(this, void 0, void 0, function () { var request, result, error_6; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPost().asJson().withBody(hookSettings); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_6 = _a.sent(); throw error_6; case 4: return [2 /*return*/]; } }); }); }; return ProjectRepoSettingsHooksSettingsEndpoint; }(types_1.EndpointService)); exports.ProjectRepoSettingsHooksSettingsEndpoint = ProjectRepoSettingsHooksSettingsEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/pull-requests' */ var ProjectRepoPullRequestsEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoPullRequestsEndpoint, _super); function ProjectRepoPullRequestsEndpoint(auth, slug) { var _this = _super.call(this, auth, '/' + slug + '/pull-requests') || this; /** * Contains all operations related with project repository pull request activities * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestsActivitiesEndpoint} Get all operations about the project repositories pull request activities */ _this.activities = function (pullRequestId) { return new ProjectRepoPullRequestsActivitiesEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request declination * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/decline'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestsDeclineEndpoint} Get all operations about the project repositories pull request declination */ _this.decline = function (pullRequestId) { return new ProjectRepoPullRequestsDeclineEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request merge * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestsMergeEndpoint} Get all operations about the project repositories pull request merge */ _this.merge = function (pullRequestId) { return new ProjectRepoPullRequestsMergeEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request re-open * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/reopen'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestsReopenEndpoint} Get all operations about the project repositories pull request re-open */ _this.reopen = function (pullRequestId) { return new ProjectRepoPullRequestsReopenEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request approval * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/approve'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestsApproveEndpoint} Get all operations about the project repositories pull request approval */ _this.approval = function (pullRequestId) { return new ProjectRepoPullRequestsApproveEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request changes * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/changes'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestsChangesEndpoint} Get all operations about the project repositories pull request changes */ _this.changes = function (pullRequestId) { return new ProjectRepoPullRequestsChangesEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request comments * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestsCommentsEndpoint} Get all operations about the project repositories pull request comments */ _this.comments = function (pullRequestId) { return new ProjectRepoPullRequestsCommentsEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request commits * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/commits'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestsCommitsEndpoint} Get all operations about the project repositories pull request commits */ _this.commits = function (pullRequestId) { return new ProjectRepoPullRequestsCommitsEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request diff * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestDiffEndpoint} Get all operations about the project repositories pull request diff */ _this.diff = function (pullRequestId) { return new ProjectRepoPullRequestDiffEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request participants * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestParticipantEndpoint} Get all operations about the project repositories pull request participants */ _this.participants = function (pullRequestId) { return new ProjectRepoPullRequestParticipantEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request tasks * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/tasks'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestTasksEndpoint} Get all operations about the project repositories pull request tasks */ _this.tasks = function (pullRequestId) { return new ProjectRepoPullRequestTasksEndpoint(_this.auth, pullRequestId); }; /** * Contains all operations related with project repository pull request watch * All paths and operations from '/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/watch'. * @param {number} pullRequestId Pull Request Id * @returns {ProjectRepoPullRequestWatchEndpoint} Get all operations about the project repositories pull request watch */ _this.watch = function (pullRequestId) { return new ProjectRepoPullRequestWatchEndpoint(_this.auth, pullRequestId); }; return _this; } /** * Retrieve a page of pull requests to or from the specified repository. * @param {RepoPullRequestOptions} [pullRequestOptions] Pull Request options include the pagination options. - pageOptions: Page options to paginate results (or obtain more results per page) * @returns {Promise<Page<PullRequest>>} Promise with the requested page data. */ ProjectRepoPullRequestsEndpoint.prototype.list = function (pullRequestOptions) { return __awaiter(this, void 0, void 0, function () { var request, result, error_7; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet({ pageOptions: pullRequestOptions === null || pullRequestOptions === void 0 ? void 0 : pullRequestOptions.pageOptions, }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); this.processOptions(request, pullRequestOptions); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_7 = _a.sent(); throw error_7; case 4: return [2 /*return*/]; } }); }); }; /** * Create a new pull request between two branches. The branches may be in the same repository, or different ones. When using different repositories, they must still be in the same hierarchy * @param {PullRequestInput} [pullRequestInput] Pull Request data to create it * @returns {Promise<PullRequest>} Promise with the created pull request data. */ ProjectRepoPullRequestsEndpoint.prototype.create = function (pullRequestInput) { return __awaiter(this, void 0, void 0, function () { var request, result, error_8; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPost().asJson().withBody(pullRequestInput); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_8 = _a.sent(); throw error_8; case 4: return [2 /*return*/]; } }); }); }; /** * Retrieve a pull request * @param {number} [pullRequestId] Pull Request id to get it * @returns {Promise<PullRequest>} Promise with the requested pull request data. */ ProjectRepoPullRequestsEndpoint.prototype.get = function (pullRequestId) { return __awaiter(this, void 0, void 0, function () { var request, result, error_9; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet({ param: pullRequestId }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_9 = _a.sent(); throw error_9; case 4: return [2 /*return*/]; } }); }); }; /** * Update the title, description, reviewers or destination branch of an existing pull request * @param {number} [pullRequestId] Pull Request id to update it * @param {PullRequestInput} [pullRequestInput] Pull Request data to update it * @returns {Promise<PullRequest>} Promise with the updated pull request data. */ ProjectRepoPullRequestsEndpoint.prototype.update = function (pullRequestId, pullRequestInput) { return __awaiter(this, void 0, void 0, function () { var request, result, error_10; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPut({ param: pullRequestId }).asJson().withBody(pullRequestInput); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_10 = _a.sent(); throw error_10; case 4: return [2 /*return*/]; } }); }); }; return ProjectRepoPullRequestsEndpoint; }(types_1.EndpointService)); exports.ProjectRepoPullRequestsEndpoint = ProjectRepoPullRequestsEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities' */ var ProjectRepoPullRequestsActivitiesEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoPullRequestsActivitiesEndpoint, _super); function ProjectRepoPullRequestsActivitiesEndpoint(auth, pullRequestId) { return _super.call(this, auth, '/' + pullRequestId + '/activities') || this; } /** * Retrieve a page of activity associated with a pull request. Activity items include comments, approvals, rescopes (i.e. adding and removing of commits), merges and more * @param {PullRequestActivityOptions} activitiesOptions Pull Request Activities options include the pagination options. - pageOptions: Page options to paginate results (or obtain more results per page) * @returns {Promise<Page<PullRequestActivity>>} Promise with the requested page data. */ ProjectRepoPullRequestsActivitiesEndpoint.prototype.list = function (activitiesOptions) { return __awaiter(this, void 0, void 0, function () { var request, result, error_11; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet({ pageOptions: activitiesOptions.pageOptions, }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); this.processOptions(request, activitiesOptions); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_11 = _a.sent(); throw error_11; case 4: return [2 /*return*/]; } }); }); }; return ProjectRepoPullRequestsActivitiesEndpoint; }(types_1.EndpointService)); exports.ProjectRepoPullRequestsActivitiesEndpoint = ProjectRepoPullRequestsActivitiesEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/decline' */ var ProjectRepoPullRequestsDeclineEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoPullRequestsDeclineEndpoint, _super); function ProjectRepoPullRequestsDeclineEndpoint(auth, pullRequestId) { return _super.call(this, auth, '/' + pullRequestId + '/decline') || this; } /** * Decline a pull request * @param {number} [version] The current version of the pull request. If the server's version isn't the same as the specified version the operation will fail. To determine the current version of the pull request it should be fetched from the server prior to this operation * @returns {Promise<void>} If not throw errors, operation finishs succesfully. */ ProjectRepoPullRequestsDeclineEndpoint.prototype.execute = function (version) { return __awaiter(this, void 0, void 0, function () { var request, result, error_12; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPost(); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); if (version !== undefined) { request.addQueryParam('version', version); } return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/]; case 3: error_12 = _a.sent(); throw error_12; case 4: return [2 /*return*/]; } }); }); }; return ProjectRepoPullRequestsDeclineEndpoint; }(types_1.EndpointService)); exports.ProjectRepoPullRequestsDeclineEndpoint = ProjectRepoPullRequestsDeclineEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge' */ var ProjectRepoPullRequestsMergeEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoPullRequestsMergeEndpoint, _super); function ProjectRepoPullRequestsMergeEndpoint(auth, pullRequestId) { return _super.call(this, auth, '/' + pullRequestId + '/merge') || this; } /** * Test whether a pull request can be merged * @returns {Promise<PullRequest>} Return the pull request data and mergin status. */ ProjectRepoPullRequestsMergeEndpoint.prototype.test = function () { return __awaiter(this, void 0, void 0, function () { var request, result, error_13; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet(); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_13 = _a.sent(); throw error_13; case 4: return [2 /*return*/]; } }); }); }; /** * Merge the specified pull request * @param {number} [version] The current version of the pull request. If the server's version isn't the same as the specified version the operation will fail. To determine the current version of the pull request it should be fetched from the server prior to this operation. Look for the 'version' attribute in the returned JSON structure. * @returns {Promise<PullRequest>} Return the merged pull request data. */ ProjectRepoPullRequestsMergeEndpoint.prototype.execute = function (version) { return __awaiter(this, void 0, void 0, function () { var request, result, error_14; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPost().asJson(); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); if (version !== undefined) { request.addQueryParam('version', version); } return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_14 = _a.sent(); throw error_14; case 4: return [2 /*return*/]; } }); }); }; return ProjectRepoPullRequestsMergeEndpoint; }(types_1.EndpointService)); exports.ProjectRepoPullRequestsMergeEndpoint = ProjectRepoPullRequestsMergeEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/reopen' */ var ProjectRepoPullRequestsReopenEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoPullRequestsReopenEndpoint, _super); function ProjectRepoPullRequestsReopenEndpoint(auth, pullRequestId) { return _super.call(this, auth, '/' + pullRequestId + '/reopen') || this; } /** * Re-open a declined pull request * @param {number} [version] The current version of the pull request. If the server's version isn't the same as the specified version the operation will fail. To determine the current version of the pull request it should be fetched from the server prior to this operation * @returns {Promise<void>} If not throw errors, operation finishs succesfully. */ ProjectRepoPullRequestsReopenEndpoint.prototype.execute = function (version) { return __awaiter(this, void 0, void 0, function () { var request, result, error_15; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPost(); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); if (version !== undefined) { request.addQueryParam('version', version); } return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/]; case 3: error_15 = _a.sent(); throw error_15; case 4: return [2 /*return*/]; } }); }); }; return ProjectRepoPullRequestsReopenEndpoint; }(types_1.EndpointService)); exports.ProjectRepoPullRequestsReopenEndpoint = ProjectRepoPullRequestsReopenEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/approve' */ var ProjectRepoPullRequestsApproveEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoPullRequestsApproveEndpoint, _super); function ProjectRepoPullRequestsApproveEndpoint(auth, pullRequestId) { return _super.call(this, auth, '/' + pullRequestId + '/approve') || this; } /** * Approve a pull request as the current user. Implicitly adds the user as a participant if they are not already * @returns {Promise<Participant>} Return the participant data. */ ProjectRepoPullRequestsApproveEndpoint.prototype.execute = function () { return __awaiter(this, void 0, void 0, function () { var request, result, error_16; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPost(); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_16 = _a.sent(); throw error_16; case 4: return [2 /*return*/]; } }); }); }; /** * Remove approval from a pull request as the current user. This does not remove the user as a participant * @returns {Promise<Participant>} Return the participant data. */ ProjectRepoPullRequestsApproveEndpoint.prototype.delete = function () { return __awaiter(this, void 0, void 0, function () { var request, result, error_17; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doDelete(); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_17 = _a.sent(); throw error_17; case 4: return [2 /*return*/]; } }); }); }; return ProjectRepoPullRequestsApproveEndpoint; }(types_1.EndpointService)); exports.ProjectRepoPullRequestsApproveEndpoint = ProjectRepoPullRequestsApproveEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/changes' */ var ProjectRepoPullRequestsChangesEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoPullRequestsChangesEndpoint, _super); function ProjectRepoPullRequestsChangesEndpoint(auth, pullRequestId) { return _super.call(this, auth, '/' + pullRequestId + '/changes') || this; } /** * Gets changes for the specified PullRequest. * @param {boolean} [withComments] true to apply comment counts in the changes (the default); otherwise, false to stream changes without comment counts * @param {PageOptions} [pageOptions] Page options to paginate results (or obtain more results per page) * @returns {Promise<Page<RepoChangesOutput>>} Promise with the requested page data. */ ProjectRepoPullRequestsChangesEndpoint.prototype.list = function (withComments, pageOptions) { return __awaiter(this, void 0, void 0, function () { var request, result, error_18; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet({ pageOptions: pageOptions }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); if (withComments !== undefined) { request.addQueryParam('withComments', withComments); } return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_18 = _a.sent(); throw error_18; case 4: return [2 /*return*/]; } }); }); }; return ProjectRepoPullRequestsChangesEndpoint; }(types_1.EndpointService)); exports.ProjectRepoPullRequestsChangesEndpoint = ProjectRepoPullRequestsChangesEndpoint; /** * Class to manage and expose all endpoits and operations below '/rest/api/1.0/projects/{prokectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments' */ var ProjectRepoPullRequestsCommentsEndpoint = /** @class */ (function (_super) { __extends(ProjectRepoPullRequestsCommentsEndpoint, _super); function ProjectRepoPullRequestsCommentsEndpoint(auth, pullRequestId) { return _super.call(this, auth, '/' + pullRequestId + '/comments') || this; } /** * Retrieve a page of comments made in a specified pull request * @param {string} [filePath] File path * @param {PageOptions} [pageOptions] Page options to paginate results (or obtain more results per page) * @returns {Promise<Page<Comment>>} Promise with the requested page data. */ ProjectRepoPullRequestsCommentsEndpoint.prototype.list = function (filePath, pageOptions) { return __awaiter(this, void 0, void 0, function () { var request, result, error_19; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet({ param: filePath ? encodeURIComponent(filePath) : undefined, pageOptions: pageOptions, }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_19 = _a.sent(); throw error_19; case 4: return [2 /*return*/]; } }); }); }; /** * Add a new comment * @param {CommentInput} commentInput Comment input data to create new comment * @returns {Promise<Comment>} Promise with the created comment data. */ ProjectRepoPullRequestsCommentsEndpoint.prototype.create = function (commentInput) { return __awaiter(this, void 0, void 0, function () { var request, result, error_20; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPost().asJson().withBody(commentInput); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_20 = _a.sent(); throw error_20; case 4: return [2 /*return*/]; } }); }); }; /** * Get specific comment * @param {number} commentId Comment Id get comment data * @returns {Promise<Comment>} Promise with the requested comment data. */ ProjectRepoPullRequestsCommentsEndpoint.prototype.get = function (commentId) { return __awaiter(this, void 0, void 0, function () { var request, result, error_21; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doGet({ param: commentId }).asJson(); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_21 = _a.sent(); throw error_21; case 4: return [2 /*return*/]; } }); }); }; /** * Update specific comment * @param {number} commentId Comment Id get comment data * @param {string} text The comment text to update * @param {string} version The version of the comment to update. A version that must match the server's version of the comment or the update will fail * @returns {Promise<Comment>} Promise with the requested comment data. */ ProjectRepoPullRequestsCommentsEndpoint.prototype.update = function (commentId, text, version) { return __awaiter(this, void 0, void 0, function () { var request, result, error_22; return __generator(this, function (_a) { switch (_a.label) { case 0: request = this.doPut({ param: commentId }).asJson().withBody({ version: version, text: text, }); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, request.execute()]; case 2: result = _a.sent(); return [2 /*return*/, result.data]; case 3: error_22 = _a.sent(); throw error_22; case 4: return [2 /*return*/]; } }); }); }; /** * Delete specific comment and version * @param {number} commentId Comment Id delete * @param {number} [version] Comment version to delete * @returns {Promise<void>} If finish without errors, operation finish succesfully */ ProjectRepoPullRequestsCommentsEndpoint.prototype.delete = function (commentId, version) { return __awaiter(this, void 0, void 0, function () { var request, result, error_23; return __ge