UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

83 lines (76 loc) 3.35 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib_es6 = require('../tslib.es6-01322ba9.js'); var axios = require('axios'); var devops_token = require('./token.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios); function getReviewingReviewers(res) { var _a, _b; if (res === void 0) { res = {}; } var stages = ((_a = res === null || res === void 0 ? void 0 : res.model) === null || _a === void 0 ? void 0 : _a.stages) || []; for (var _i = 0, stages_1 = stages; _i < stages_1.length; _i++) { var stage = stages_1[_i]; var containers = (stage === null || stage === void 0 ? void 0 : stage.containers) || []; for (var _c = 0, containers_1 = containers; _c < containers_1.length; _c++) { var container = containers_1[_c]; var elements = (container === null || container === void 0 ? void 0 : container.elements) || []; for (var _d = 0, elements_1 = elements; _d < elements_1.length; _d++) { var element = elements_1[_d]; if (((_b = element === null || element === void 0 ? void 0 : element.reviewUsers) === null || _b === void 0 ? void 0 : _b.length) && (element === null || element === void 0 ? void 0 : element.status) === 'REVIEWING') { return element.reviewUsers; } } } } return []; } function getPipelineBuildDetail(_a) { var _b; var projectId = _a.projectId, pipelineId = _a.pipelineId, buildId = _a.buildId, _c = _a.archiveFlag, archiveFlag = _c === void 0 ? false : _c, _d = _a.executeCount, executeCount = _d === void 0 ? '' : _d, secretInfo = _a.secretInfo, host = _a.host; return tslib_es6.__awaiter(this, void 0, void 0, function () { var appCode, appSecret, devopsUid, accessToken, resp; return tslib_es6.__generator(this, function (_e) { switch (_e.label) { case 0: appCode = secretInfo.appCode, appSecret = secretInfo.appSecret, devopsUid = secretInfo.devopsUid; return [4 /*yield*/, devops_token.getDevopsAccessToken({ secretInfo: secretInfo, host: host })]; case 1: accessToken = _e.sent(); return [4 /*yield*/, axios__default["default"]({ url: "".concat(host, "/prod/v4/apigw-app/projects/").concat(projectId, "/build_detail?buildId=").concat(buildId, "&pipelineId=").concat(pipelineId, "&archiveFlag=").concat(archiveFlag, "&executeCount=").concat(executeCount), method: 'GET', headers: { 'X-DEVOPS-UID': devopsUid, 'Content-Type': 'application/json', 'X-Bkapi-Authorization': JSON.stringify({ bk_app_code: appCode, bk_app_secret: appSecret, access_token: accessToken }) } })["catch"](function (err) { console.log('[getPipelineBuildDetail] err: ', err); })]; case 2: resp = _e.sent(); return [2 /*return*/, ((_b = resp.data) === null || _b === void 0 ? void 0 : _b.data) || {}]; } }); }); } exports.getPipelineBuildDetail = getPipelineBuildDetail; exports.getReviewingReviewers = getReviewingReviewers;