UNPKG

zephyr-agent

Version:
72 lines (71 loc) • 3.15 kB
"use strict"; var __webpack_require__ = {}; (()=>{ __webpack_require__.d = (exports1, getters, values)=>{ var define = (defs, kind)=>{ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { enumerable: true, [kind]: defs[key] }); }; define(getters, "get"); define(values, "value"); }; })(); (()=>{ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); })(); (()=>{ __webpack_require__.r = (exports1)=>{ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { value: 'Module' }); Object.defineProperty(exports1, '__esModule', { value: true }); }; })(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { zeUploadBuildStats: ()=>zeUploadBuildStats }); const external_zephyr_edge_contract_namespaceObject = require("zephyr-edge-contract"); const external_node_crypto_namespaceObject = require("node:crypto"); const index_js_namespaceObject = require("../errors/index.js"); const http_request_js_namespaceObject = require("../http/http-request.js"); const external_logging_index_js_namespaceObject = require("../logging/index.js"); const token_js_namespaceObject = require("../node-persist/token.js"); async function zeUploadBuildStats(dashData) { external_logging_index_js_namespaceObject.ze_log.upload('Uploading build stats to Zephyr...', dashData); const token = await (0, token_js_namespaceObject.getToken)(); const url = new URL(external_zephyr_edge_contract_namespaceObject.ze_api_gateway.build_stats, (0, external_zephyr_edge_contract_namespaceObject.ZE_API_ENDPOINT)()); const idempotencyKey = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(`${dashData.id}\0${dashData.app.buildId}`).digest('hex'); const [ok, cause, res] = await (0, http_request_js_namespaceObject.makeRequest)(url, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}`, Accept: 'application/json', 'Idempotency-Key': idempotencyKey }, credentialToken: token }, JSON.stringify(dashData)); if (!ok || 'ok' !== res.status) throw new index_js_namespaceObject.ZephyrError(index_js_namespaceObject.ZeErrors.ERR_FAILED_UPLOAD, { type: 'build stats', cause, data: { url: url.toString() } }); external_logging_index_js_namespaceObject.ze_log.upload('Build stats uploaded to Zephyr...'); return res.targets ?? []; } exports.zeUploadBuildStats = __webpack_exports__.zeUploadBuildStats; for(var __rspack_i in __webpack_exports__)if (-1 === [ "zeUploadBuildStats" ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i]; Object.defineProperty(exports, '__esModule', { value: true }); //# sourceMappingURL=ze-upload-build-stats.js.map