UNPKG

t-comm

Version:

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

100 lines (93 loc) 3.45 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib_es6 = require('../tslib.es6-01322ba9.js'); var axios = require('axios'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios); function createMRNote(_a) { var privateToken = _a.privateToken, gitApiPrefix = _a.gitApiPrefix, projectName = _a.projectName, mrId = _a.mrId, body = _a.body, path = _a.path, line = _a.line, _b = _a.lineType, lineType = _b === void 0 ? 'new' : _b, // 严重程度 可选值 0、1、2、3 // 0 : "default"(默认)1 : "slight"(轻微) // 2 : "normal"(一般)3 : "serious"(严重 _c = _a.risk, // 严重程度 可选值 0、1、2、3 // 0 : "default"(默认)1 : "slight"(轻微) // 2 : "normal"(一般)3 : "serious"(严重 risk = _c === void 0 ? 3 : _c, // 需解决 可选值 0、1、2 // 0 : "default"(默认) // 1 : "unresolved"(未解决) // 2 : "resolved"(已解决) _d = _a.resolveState, // 需解决 可选值 0、1、2 // 0 : "default"(默认) // 1 : "unresolved"(未解决) // 2 : "resolved"(已解决) resolveState = _d === void 0 ? 1 : _d, // 默认值为 true,发通知给相关用户 _e = _a.notifyEnabled, // 默认值为 true,发通知给相关用户 notifyEnabled = _e === void 0 ? true : _e; return tslib_es6.__awaiter(this, void 0, void 0, function () { return tslib_es6.__generator(this, function (_f) { if (!mrId || !projectName || !privateToken) { return [2 /*return*/, Promise.reject('参数不全')]; } return [2 /*return*/, new Promise(function (resolve, reject) { axios__default["default"]({ url: "".concat(gitApiPrefix, "/projects/").concat(encodeURIComponent(projectName), "/merge_requests/").concat(mrId, "/notes?private_token=").concat(privateToken), method: 'POST', data: { body: body, path: path, line: line, line_type: lineType, risk: risk, resolve_state: resolveState, notify_enabled: notifyEnabled } }).then(function (res) { resolve(res.data); })["catch"](function (err) { console.log('err', err); reject(err); }); })]; }); }); } function createMRComment(_a) { var projectName = _a.projectName, mrId = _a.mrId, data = _a.data, privateToken = _a.privateToken, gitApiPrefix = _a.gitApiPrefix; return tslib_es6.__awaiter(this, void 0, void 0, function () { return tslib_es6.__generator(this, function (_b) { return [2 /*return*/, new Promise(function (resolve, reject) { axios__default["default"]({ url: "".concat(gitApiPrefix, "/projects/").concat(encodeURIComponent(projectName), "/merge_request/").concat(mrId, "/comments?private_token=").concat(privateToken), method: 'POST', data: { note: data } }).then(function (res) { resolve(res.data); })["catch"](function (err) { console.log('err', err); reject(err); }); })]; }); }); } exports.createMRComment = createMRComment; exports.createMRNote = createMRNote;