You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1722 lines
165 KiB
1722 lines
165 KiB
6 years ago
|
/******/ (function(modules) { // webpackBootstrap
|
||
|
/******/ function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars
|
||
|
/******/ var chunk = require("./" + "" + chunkId + "." + hotCurrentHash + ".hot-update.js");
|
||
|
/******/ hotAddUpdateChunk(chunk.id, chunk.modules);
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ function hotDownloadManifest() { // eslint-disable-line no-unused-vars
|
||
|
/******/ try {
|
||
|
/******/ var update = require("./" + "" + hotCurrentHash + ".hot-update.json");
|
||
|
/******/ } catch(e) {
|
||
|
/******/ return Promise.resolve();
|
||
|
/******/ }
|
||
|
/******/ return Promise.resolve(update);
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
|
||
|
/******/ delete installedChunks[chunkId];
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/
|
||
|
/******/
|
||
|
/******/ var hotApplyOnUpdate = true;
|
||
|
/******/ var hotCurrentHash = "3d58b995ebbd83d30ba0"; // eslint-disable-line no-unused-vars
|
||
|
/******/ var hotRequestTimeout = 10000;
|
||
|
/******/ var hotCurrentModuleData = {};
|
||
|
/******/ var hotCurrentChildModule; // eslint-disable-line no-unused-vars
|
||
|
/******/ var hotCurrentParents = []; // eslint-disable-line no-unused-vars
|
||
|
/******/ var hotCurrentParentsTemp = []; // eslint-disable-line no-unused-vars
|
||
|
/******/
|
||
|
/******/ function hotCreateRequire(moduleId) { // eslint-disable-line no-unused-vars
|
||
|
/******/ var me = installedModules[moduleId];
|
||
|
/******/ if(!me) return __webpack_require__;
|
||
|
/******/ var fn = function(request) {
|
||
|
/******/ if(me.hot.active) {
|
||
|
/******/ if(installedModules[request]) {
|
||
|
/******/ if(installedModules[request].parents.indexOf(moduleId) < 0)
|
||
|
/******/ installedModules[request].parents.push(moduleId);
|
||
|
/******/ } else {
|
||
|
/******/ hotCurrentParents = [moduleId];
|
||
|
/******/ hotCurrentChildModule = request;
|
||
|
/******/ }
|
||
|
/******/ if(me.children.indexOf(request) < 0)
|
||
|
/******/ me.children.push(request);
|
||
|
/******/ } else {
|
||
|
/******/ console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
|
||
|
/******/ hotCurrentParents = [];
|
||
|
/******/ }
|
||
|
/******/ return __webpack_require__(request);
|
||
|
/******/ };
|
||
|
/******/ var ObjectFactory = function ObjectFactory(name) {
|
||
|
/******/ return {
|
||
|
/******/ configurable: true,
|
||
|
/******/ enumerable: true,
|
||
|
/******/ get: function() {
|
||
|
/******/ return __webpack_require__[name];
|
||
|
/******/ },
|
||
|
/******/ set: function(value) {
|
||
|
/******/ __webpack_require__[name] = value;
|
||
|
/******/ }
|
||
|
/******/ };
|
||
|
/******/ };
|
||
|
/******/ for(var name in __webpack_require__) {
|
||
|
/******/ if(Object.prototype.hasOwnProperty.call(__webpack_require__, name) && name !== "e") {
|
||
|
/******/ Object.defineProperty(fn, name, ObjectFactory(name));
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ fn.e = function(chunkId) {
|
||
|
/******/ if(hotStatus === "ready")
|
||
|
/******/ hotSetStatus("prepare");
|
||
|
/******/ hotChunksLoading++;
|
||
|
/******/ return __webpack_require__.e(chunkId).then(finishChunkLoading, function(err) {
|
||
|
/******/ finishChunkLoading();
|
||
|
/******/ throw err;
|
||
|
/******/ });
|
||
|
/******/
|
||
|
/******/ function finishChunkLoading() {
|
||
|
/******/ hotChunksLoading--;
|
||
|
/******/ if(hotStatus === "prepare") {
|
||
|
/******/ if(!hotWaitingFilesMap[chunkId]) {
|
||
|
/******/ hotEnsureUpdateChunk(chunkId);
|
||
|
/******/ }
|
||
|
/******/ if(hotChunksLoading === 0 && hotWaitingFiles === 0) {
|
||
|
/******/ hotUpdateDownloaded();
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ };
|
||
|
/******/ return fn;
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ function hotCreateModule(moduleId) { // eslint-disable-line no-unused-vars
|
||
|
/******/ var hot = {
|
||
|
/******/ // private stuff
|
||
|
/******/ _acceptedDependencies: {},
|
||
|
/******/ _declinedDependencies: {},
|
||
|
/******/ _selfAccepted: false,
|
||
|
/******/ _selfDeclined: false,
|
||
|
/******/ _disposeHandlers: [],
|
||
|
/******/ _main: hotCurrentChildModule !== moduleId,
|
||
|
/******/
|
||
|
/******/ // Module API
|
||
|
/******/ active: true,
|
||
|
/******/ accept: function(dep, callback) {
|
||
|
/******/ if(typeof dep === "undefined")
|
||
|
/******/ hot._selfAccepted = true;
|
||
|
/******/ else if(typeof dep === "function")
|
||
|
/******/ hot._selfAccepted = dep;
|
||
|
/******/ else if(typeof dep === "object")
|
||
|
/******/ for(var i = 0; i < dep.length; i++)
|
||
|
/******/ hot._acceptedDependencies[dep[i]] = callback || function() {};
|
||
|
/******/ else
|
||
|
/******/ hot._acceptedDependencies[dep] = callback || function() {};
|
||
|
/******/ },
|
||
|
/******/ decline: function(dep) {
|
||
|
/******/ if(typeof dep === "undefined")
|
||
|
/******/ hot._selfDeclined = true;
|
||
|
/******/ else if(typeof dep === "object")
|
||
|
/******/ for(var i = 0; i < dep.length; i++)
|
||
|
/******/ hot._declinedDependencies[dep[i]] = true;
|
||
|
/******/ else
|
||
|
/******/ hot._declinedDependencies[dep] = true;
|
||
|
/******/ },
|
||
|
/******/ dispose: function(callback) {
|
||
|
/******/ hot._disposeHandlers.push(callback);
|
||
|
/******/ },
|
||
|
/******/ addDisposeHandler: function(callback) {
|
||
|
/******/ hot._disposeHandlers.push(callback);
|
||
|
/******/ },
|
||
|
/******/ removeDisposeHandler: function(callback) {
|
||
|
/******/ var idx = hot._disposeHandlers.indexOf(callback);
|
||
|
/******/ if(idx >= 0) hot._disposeHandlers.splice(idx, 1);
|
||
|
/******/ },
|
||
|
/******/
|
||
|
/******/ // Management API
|
||
|
/******/ check: hotCheck,
|
||
|
/******/ apply: hotApply,
|
||
|
/******/ status: function(l) {
|
||
|
/******/ if(!l) return hotStatus;
|
||
|
/******/ hotStatusHandlers.push(l);
|
||
|
/******/ },
|
||
|
/******/ addStatusHandler: function(l) {
|
||
|
/******/ hotStatusHandlers.push(l);
|
||
|
/******/ },
|
||
|
/******/ removeStatusHandler: function(l) {
|
||
|
/******/ var idx = hotStatusHandlers.indexOf(l);
|
||
|
/******/ if(idx >= 0) hotStatusHandlers.splice(idx, 1);
|
||
|
/******/ },
|
||
|
/******/
|
||
|
/******/ //inherit from previous dispose call
|
||
|
/******/ data: hotCurrentModuleData[moduleId]
|
||
|
/******/ };
|
||
|
/******/ hotCurrentChildModule = undefined;
|
||
|
/******/ return hot;
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ var hotStatusHandlers = [];
|
||
|
/******/ var hotStatus = "idle";
|
||
|
/******/
|
||
|
/******/ function hotSetStatus(newStatus) {
|
||
|
/******/ hotStatus = newStatus;
|
||
|
/******/ for(var i = 0; i < hotStatusHandlers.length; i++)
|
||
|
/******/ hotStatusHandlers[i].call(null, newStatus);
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // while downloading
|
||
|
/******/ var hotWaitingFiles = 0;
|
||
|
/******/ var hotChunksLoading = 0;
|
||
|
/******/ var hotWaitingFilesMap = {};
|
||
|
/******/ var hotRequestedFilesMap = {};
|
||
|
/******/ var hotAvailableFilesMap = {};
|
||
|
/******/ var hotDeferred;
|
||
|
/******/
|
||
|
/******/ // The update info
|
||
|
/******/ var hotUpdate, hotUpdateNewHash;
|
||
|
/******/
|
||
|
/******/ function toModuleId(id) {
|
||
|
/******/ var isNumber = (+id) + "" === id;
|
||
|
/******/ return isNumber ? +id : id;
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ function hotCheck(apply) {
|
||
|
/******/ if(hotStatus !== "idle") throw new Error("check() is only allowed in idle status");
|
||
|
/******/ hotApplyOnUpdate = apply;
|
||
|
/******/ hotSetStatus("check");
|
||
|
/******/ return hotDownloadManifest(hotRequestTimeout).then(function(update) {
|
||
|
/******/ if(!update) {
|
||
|
/******/ hotSetStatus("idle");
|
||
|
/******/ return null;
|
||
|
/******/ }
|
||
|
/******/ hotRequestedFilesMap = {};
|
||
|
/******/ hotWaitingFilesMap = {};
|
||
|
/******/ hotAvailableFilesMap = update.c;
|
||
|
/******/ hotUpdateNewHash = update.h;
|
||
|
/******/
|
||
|
/******/ hotSetStatus("prepare");
|
||
|
/******/ var promise = new Promise(function(resolve, reject) {
|
||
|
/******/ hotDeferred = {
|
||
|
/******/ resolve: resolve,
|
||
|
/******/ reject: reject
|
||
|
/******/ };
|
||
|
/******/ });
|
||
|
/******/ hotUpdate = {};
|
||
|
/******/ var chunkId = 0;
|
||
|
/******/ { // eslint-disable-line no-lone-blocks
|
||
|
/******/ /*globals chunkId */
|
||
|
/******/ hotEnsureUpdateChunk(chunkId);
|
||
|
/******/ }
|
||
|
/******/ if(hotStatus === "prepare" && hotChunksLoading === 0 && hotWaitingFiles === 0) {
|
||
|
/******/ hotUpdateDownloaded();
|
||
|
/******/ }
|
||
|
/******/ return promise;
|
||
|
/******/ });
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ function hotAddUpdateChunk(chunkId, moreModules) { // eslint-disable-line no-unused-vars
|
||
|
/******/ if(!hotAvailableFilesMap[chunkId] || !hotRequestedFilesMap[chunkId])
|
||
|
/******/ return;
|
||
|
/******/ hotRequestedFilesMap[chunkId] = false;
|
||
|
/******/ for(var moduleId in moreModules) {
|
||
|
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
|
||
|
/******/ hotUpdate[moduleId] = moreModules[moduleId];
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ if(--hotWaitingFiles === 0 && hotChunksLoading === 0) {
|
||
|
/******/ hotUpdateDownloaded();
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ function hotEnsureUpdateChunk(chunkId) {
|
||
|
/******/ if(!hotAvailableFilesMap[chunkId]) {
|
||
|
/******/ hotWaitingFilesMap[chunkId] = true;
|
||
|
/******/ } else {
|
||
|
/******/ hotRequestedFilesMap[chunkId] = true;
|
||
|
/******/ hotWaitingFiles++;
|
||
|
/******/ hotDownloadUpdateChunk(chunkId);
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ function hotUpdateDownloaded() {
|
||
|
/******/ hotSetStatus("ready");
|
||
|
/******/ var deferred = hotDeferred;
|
||
|
/******/ hotDeferred = null;
|
||
|
/******/ if(!deferred) return;
|
||
|
/******/ if(hotApplyOnUpdate) {
|
||
|
/******/ // Wrap deferred object in Promise to mark it as a well-handled Promise to
|
||
|
/******/ // avoid triggering uncaught exception warning in Chrome.
|
||
|
/******/ // See https://bugs.chromium.org/p/chromium/issues/detail?id=465666
|
||
|
/******/ Promise.resolve().then(function() {
|
||
|
/******/ return hotApply(hotApplyOnUpdate);
|
||
|
/******/ }).then(
|
||
|
/******/ function(result) {
|
||
|
/******/ deferred.resolve(result);
|
||
|
/******/ },
|
||
|
/******/ function(err) {
|
||
|
/******/ deferred.reject(err);
|
||
|
/******/ }
|
||
|
/******/ );
|
||
|
/******/ } else {
|
||
|
/******/ var outdatedModules = [];
|
||
|
/******/ for(var id in hotUpdate) {
|
||
|
/******/ if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
|
||
|
/******/ outdatedModules.push(toModuleId(id));
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ deferred.resolve(outdatedModules);
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ function hotApply(options) {
|
||
|
/******/ if(hotStatus !== "ready") throw new Error("apply() is only allowed in ready status");
|
||
|
/******/ options = options || {};
|
||
|
/******/
|
||
|
/******/ var cb;
|
||
|
/******/ var i;
|
||
|
/******/ var j;
|
||
|
/******/ var module;
|
||
|
/******/ var moduleId;
|
||
|
/******/
|
||
|
/******/ function getAffectedStuff(updateModuleId) {
|
||
|
/******/ var outdatedModules = [updateModuleId];
|
||
|
/******/ var outdatedDependencies = {};
|
||
|
/******/
|
||
|
/******/ var queue = outdatedModules.slice().map(function(id) {
|
||
|
/******/ return {
|
||
|
/******/ chain: [id],
|
||
|
/******/ id: id
|
||
|
/******/ };
|
||
|
/******/ });
|
||
|
/******/ while(queue.length > 0) {
|
||
|
/******/ var queueItem = queue.pop();
|
||
|
/******/ var moduleId = queueItem.id;
|
||
|
/******/ var chain = queueItem.chain;
|
||
|
/******/ module = installedModules[moduleId];
|
||
|
/******/ if(!module || module.hot._selfAccepted)
|
||
|
/******/ continue;
|
||
|
/******/ if(module.hot._selfDeclined) {
|
||
|
/******/ return {
|
||
|
/******/ type: "self-declined",
|
||
|
/******/ chain: chain,
|
||
|
/******/ moduleId: moduleId
|
||
|
/******/ };
|
||
|
/******/ }
|
||
|
/******/ if(module.hot._main) {
|
||
|
/******/ return {
|
||
|
/******/ type: "unaccepted",
|
||
|
/******/ chain: chain,
|
||
|
/******/ moduleId: moduleId
|
||
|
/******/ };
|
||
|
/******/ }
|
||
|
/******/ for(var i = 0; i < module.parents.length; i++) {
|
||
|
/******/ var parentId = module.parents[i];
|
||
|
/******/ var parent = installedModules[parentId];
|
||
|
/******/ if(!parent) continue;
|
||
|
/******/ if(parent.hot._declinedDependencies[moduleId]) {
|
||
|
/******/ return {
|
||
|
/******/ type: "declined",
|
||
|
/******/ chain: chain.concat([parentId]),
|
||
|
/******/ moduleId: moduleId,
|
||
|
/******/ parentId: parentId
|
||
|
/******/ };
|
||
|
/******/ }
|
||
|
/******/ if(outdatedModules.indexOf(parentId) >= 0) continue;
|
||
|
/******/ if(parent.hot._acceptedDependencies[moduleId]) {
|
||
|
/******/ if(!outdatedDependencies[parentId])
|
||
|
/******/ outdatedDependencies[parentId] = [];
|
||
|
/******/ addAllToSet(outdatedDependencies[parentId], [moduleId]);
|
||
|
/******/ continue;
|
||
|
/******/ }
|
||
|
/******/ delete outdatedDependencies[parentId];
|
||
|
/******/ outdatedModules.push(parentId);
|
||
|
/******/ queue.push({
|
||
|
/******/ chain: chain.concat([parentId]),
|
||
|
/******/ id: parentId
|
||
|
/******/ });
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ return {
|
||
|
/******/ type: "accepted",
|
||
|
/******/ moduleId: updateModuleId,
|
||
|
/******/ outdatedModules: outdatedModules,
|
||
|
/******/ outdatedDependencies: outdatedDependencies
|
||
|
/******/ };
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ function addAllToSet(a, b) {
|
||
|
/******/ for(var i = 0; i < b.length; i++) {
|
||
|
/******/ var item = b[i];
|
||
|
/******/ if(a.indexOf(item) < 0)
|
||
|
/******/ a.push(item);
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // at begin all updates modules are outdated
|
||
|
/******/ // the "outdated" status can propagate to parents if they don't accept the children
|
||
|
/******/ var outdatedDependencies = {};
|
||
|
/******/ var outdatedModules = [];
|
||
|
/******/ var appliedUpdate = {};
|
||
|
/******/
|
||
|
/******/ var warnUnexpectedRequire = function warnUnexpectedRequire() {
|
||
|
/******/ console.warn("[HMR] unexpected require(" + result.moduleId + ") to disposed module");
|
||
|
/******/ };
|
||
|
/******/
|
||
|
/******/ for(var id in hotUpdate) {
|
||
|
/******/ if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
|
||
|
/******/ moduleId = toModuleId(id);
|
||
|
/******/ var result;
|
||
|
/******/ if(hotUpdate[id]) {
|
||
|
/******/ result = getAffectedStuff(moduleId);
|
||
|
/******/ } else {
|
||
|
/******/ result = {
|
||
|
/******/ type: "disposed",
|
||
|
/******/ moduleId: id
|
||
|
/******/ };
|
||
|
/******/ }
|
||
|
/******/ var abortError = false;
|
||
|
/******/ var doApply = false;
|
||
|
/******/ var doDispose = false;
|
||
|
/******/ var chainInfo = "";
|
||
|
/******/ if(result.chain) {
|
||
|
/******/ chainInfo = "\nUpdate propagation: " + result.chain.join(" -> ");
|
||
|
/******/ }
|
||
|
/******/ switch(result.type) {
|
||
|
/******/ case "self-declined":
|
||
|
/******/ if(options.onDeclined)
|
||
|
/******/ options.onDeclined(result);
|
||
|
/******/ if(!options.ignoreDeclined)
|
||
|
/******/ abortError = new Error("Aborted because of self decline: " + result.moduleId + chainInfo);
|
||
|
/******/ break;
|
||
|
/******/ case "declined":
|
||
|
/******/ if(options.onDeclined)
|
||
|
/******/ options.onDeclined(result);
|
||
|
/******/ if(!options.ignoreDeclined)
|
||
|
/******/ abortError = new Error("Aborted because of declined dependency: " + result.moduleId + " in " + result.parentId + chainInfo);
|
||
|
/******/ break;
|
||
|
/******/ case "unaccepted":
|
||
|
/******/ if(options.onUnaccepted)
|
||
|
/******/ options.onUnaccepted(result);
|
||
|
/******/ if(!options.ignoreUnaccepted)
|
||
|
/******/ abortError = new Error("Aborted because " + moduleId + " is not accepted" + chainInfo);
|
||
|
/******/ break;
|
||
|
/******/ case "accepted":
|
||
|
/******/ if(options.onAccepted)
|
||
|
/******/ options.onAccepted(result);
|
||
|
/******/ doApply = true;
|
||
|
/******/ break;
|
||
|
/******/ case "disposed":
|
||
|
/******/ if(options.onDisposed)
|
||
|
/******/ options.onDisposed(result);
|
||
|
/******/ doDispose = true;
|
||
|
/******/ break;
|
||
|
/******/ default:
|
||
|
/******/ throw new Error("Unexception type " + result.type);
|
||
|
/******/ }
|
||
|
/******/ if(abortError) {
|
||
|
/******/ hotSetStatus("abort");
|
||
|
/******/ return Promise.reject(abortError);
|
||
|
/******/ }
|
||
|
/******/ if(doApply) {
|
||
|
/******/ appliedUpdate[moduleId] = hotUpdate[moduleId];
|
||
|
/******/ addAllToSet(outdatedModules, result.outdatedModules);
|
||
|
/******/ for(moduleId in result.outdatedDependencies) {
|
||
|
/******/ if(Object.prototype.hasOwnProperty.call(result.outdatedDependencies, moduleId)) {
|
||
|
/******/ if(!outdatedDependencies[moduleId])
|
||
|
/******/ outdatedDependencies[moduleId] = [];
|
||
|
/******/ addAllToSet(outdatedDependencies[moduleId], result.outdatedDependencies[moduleId]);
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ if(doDispose) {
|
||
|
/******/ addAllToSet(outdatedModules, [result.moduleId]);
|
||
|
/******/ appliedUpdate[moduleId] = warnUnexpectedRequire;
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // Store self accepted outdated modules to require them later by the module system
|
||
|
/******/ var outdatedSelfAcceptedModules = [];
|
||
|
/******/ for(i = 0; i < outdatedModules.length; i++) {
|
||
|
/******/ moduleId = outdatedModules[i];
|
||
|
/******/ if(installedModules[moduleId] && installedModules[moduleId].hot._selfAccepted)
|
||
|
/******/ outdatedSelfAcceptedModules.push({
|
||
|
/******/ module: moduleId,
|
||
|
/******/ errorHandler: installedModules[moduleId].hot._selfAccepted
|
||
|
/******/ });
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // Now in "dispose" phase
|
||
|
/******/ hotSetStatus("dispose");
|
||
|
/******/ Object.keys(hotAvailableFilesMap).forEach(function(chunkId) {
|
||
|
/******/ if(hotAvailableFilesMap[chunkId] === false) {
|
||
|
/******/ hotDisposeChunk(chunkId);
|
||
|
/******/ }
|
||
|
/******/ });
|
||
|
/******/
|
||
|
/******/ var idx;
|
||
|
/******/ var queue = outdatedModules.slice();
|
||
|
/******/ while(queue.length > 0) {
|
||
|
/******/ moduleId = queue.pop();
|
||
|
/******/ module = installedModules[moduleId];
|
||
|
/******/ if(!module) continue;
|
||
|
/******/
|
||
|
/******/ var data = {};
|
||
|
/******/
|
||
|
/******/ // Call dispose handlers
|
||
|
/******/ var disposeHandlers = module.hot._disposeHandlers;
|
||
|
/******/ for(j = 0; j < disposeHandlers.length; j++) {
|
||
|
/******/ cb = disposeHandlers[j];
|
||
|
/******/ cb(data);
|
||
|
/******/ }
|
||
|
/******/ hotCurrentModuleData[moduleId] = data;
|
||
|
/******/
|
||
|
/******/ // disable module (this disables requires from this module)
|
||
|
/******/ module.hot.active = false;
|
||
|
/******/
|
||
|
/******/ // remove module from cache
|
||
|
/******/ delete installedModules[moduleId];
|
||
|
/******/
|
||
|
/******/ // when disposing there is no need to call dispose handler
|
||
|
/******/ delete outdatedDependencies[moduleId];
|
||
|
/******/
|
||
|
/******/ // remove "parents" references from all children
|
||
|
/******/ for(j = 0; j < module.children.length; j++) {
|
||
|
/******/ var child = installedModules[module.children[j]];
|
||
|
/******/ if(!child) continue;
|
||
|
/******/ idx = child.parents.indexOf(moduleId);
|
||
|
/******/ if(idx >= 0) {
|
||
|
/******/ child.parents.splice(idx, 1);
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // remove outdated dependency from module children
|
||
|
/******/ var dependency;
|
||
|
/******/ var moduleOutdatedDependencies;
|
||
|
/******/ for(moduleId in outdatedDependencies) {
|
||
|
/******/ if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) {
|
||
|
/******/ module = installedModules[moduleId];
|
||
|
/******/ if(module) {
|
||
|
/******/ moduleOutdatedDependencies = outdatedDependencies[moduleId];
|
||
|
/******/ for(j = 0; j < moduleOutdatedDependencies.length; j++) {
|
||
|
/******/ dependency = moduleOutdatedDependencies[j];
|
||
|
/******/ idx = module.children.indexOf(dependency);
|
||
|
/******/ if(idx >= 0) module.children.splice(idx, 1);
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // Not in "apply" phase
|
||
|
/******/ hotSetStatus("apply");
|
||
|
/******/
|
||
|
/******/ hotCurrentHash = hotUpdateNewHash;
|
||
|
/******/
|
||
|
/******/ // insert new code
|
||
|
/******/ for(moduleId in appliedUpdate) {
|
||
|
/******/ if(Object.prototype.hasOwnProperty.call(appliedUpdate, moduleId)) {
|
||
|
/******/ modules[moduleId] = appliedUpdate[moduleId];
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // call accept handlers
|
||
|
/******/ var error = null;
|
||
|
/******/ for(moduleId in outdatedDependencies) {
|
||
|
/******/ if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) {
|
||
|
/******/ module = installedModules[moduleId];
|
||
|
/******/ if(module) {
|
||
|
/******/ moduleOutdatedDependencies = outdatedDependencies[moduleId];
|
||
|
/******/ var callbacks = [];
|
||
|
/******/ for(i = 0; i < moduleOutdatedDependencies.length; i++) {
|
||
|
/******/ dependency = moduleOutdatedDependencies[i];
|
||
|
/******/ cb = module.hot._acceptedDependencies[dependency];
|
||
|
/******/ if(cb) {
|
||
|
/******/ if(callbacks.indexOf(cb) >= 0) continue;
|
||
|
/******/ callbacks.push(cb);
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ for(i = 0; i < callbacks.length; i++) {
|
||
|
/******/ cb = callbacks[i];
|
||
|
/******/ try {
|
||
|
/******/ cb(moduleOutdatedDependencies);
|
||
|
/******/ } catch(err) {
|
||
|
/******/ if(options.onErrored) {
|
||
|
/******/ options.onErrored({
|
||
|
/******/ type: "accept-errored",
|
||
|
/******/ moduleId: moduleId,
|
||
|
/******/ dependencyId: moduleOutdatedDependencies[i],
|
||
|
/******/ error: err
|
||
|
/******/ });
|
||
|
/******/ }
|
||
|
/******/ if(!options.ignoreErrored) {
|
||
|
/******/ if(!error)
|
||
|
/******/ error = err;
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // Load self accepted modules
|
||
|
/******/ for(i = 0; i < outdatedSelfAcceptedModules.length; i++) {
|
||
|
/******/ var item = outdatedSelfAcceptedModules[i];
|
||
|
/******/ moduleId = item.module;
|
||
|
/******/ hotCurrentParents = [moduleId];
|
||
|
/******/ try {
|
||
|
/******/ __webpack_require__(moduleId);
|
||
|
/******/ } catch(err) {
|
||
|
/******/ if(typeof item.errorHandler === "function") {
|
||
|
/******/ try {
|
||
|
/******/ item.errorHandler(err);
|
||
|
/******/ } catch(err2) {
|
||
|
/******/ if(options.onErrored) {
|
||
|
/******/ options.onErrored({
|
||
|
/******/ type: "self-accept-error-handler-errored",
|
||
|
/******/ moduleId: moduleId,
|
||
|
/******/ error: err2,
|
||
|
/******/ orginalError: err, // TODO remove in webpack 4
|
||
|
/******/ originalError: err
|
||
|
/******/ });
|
||
|
/******/ }
|
||
|
/******/ if(!options.ignoreErrored) {
|
||
|
/******/ if(!error)
|
||
|
/******/ error = err2;
|
||
|
/******/ }
|
||
|
/******/ if(!error)
|
||
|
/******/ error = err;
|
||
|
/******/ }
|
||
|
/******/ } else {
|
||
|
/******/ if(options.onErrored) {
|
||
|
/******/ options.onErrored({
|
||
|
/******/ type: "self-accept-errored",
|
||
|
/******/ moduleId: moduleId,
|
||
|
/******/ error: err
|
||
|
/******/ });
|
||
|
/******/ }
|
||
|
/******/ if(!options.ignoreErrored) {
|
||
|
/******/ if(!error)
|
||
|
/******/ error = err;
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // handle errors in accept handlers and self accepted module load
|
||
|
/******/ if(error) {
|
||
|
/******/ hotSetStatus("fail");
|
||
|
/******/ return Promise.reject(error);
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ hotSetStatus("idle");
|
||
|
/******/ return new Promise(function(resolve) {
|
||
|
/******/ resolve(outdatedModules);
|
||
|
/******/ });
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/ // The module cache
|
||
|
/******/ var installedModules = {};
|
||
|
/******/
|
||
|
/******/ // The require function
|
||
|
/******/ function __webpack_require__(moduleId) {
|
||
|
/******/
|
||
|
/******/ // Check if module is in cache
|
||
|
/******/ if(installedModules[moduleId]) {
|
||
|
/******/ return installedModules[moduleId].exports;
|
||
|
/******/ }
|
||
|
/******/ // Create a new module (and put it into the cache)
|
||
|
/******/ var module = installedModules[moduleId] = {
|
||
|
/******/ i: moduleId,
|
||
|
/******/ l: false,
|
||
|
/******/ exports: {},
|
||
|
/******/ hot: hotCreateModule(moduleId),
|
||
|
/******/ parents: (hotCurrentParentsTemp = hotCurrentParents, hotCurrentParents = [], hotCurrentParentsTemp),
|
||
|
/******/ children: []
|
||
|
/******/ };
|
||
|
/******/
|
||
|
/******/ // Execute the module function
|
||
|
/******/ modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
|
||
|
/******/
|
||
|
/******/ // Flag the module as loaded
|
||
|
/******/ module.l = true;
|
||
|
/******/
|
||
|
/******/ // Return the exports of the module
|
||
|
/******/ return module.exports;
|
||
|
/******/ }
|
||
|
/******/
|
||
|
/******/
|
||
|
/******/ // expose the modules object (__webpack_modules__)
|
||
|
/******/ __webpack_require__.m = modules;
|
||
|
/******/
|
||
|
/******/ // expose the module cache
|
||
|
/******/ __webpack_require__.c = installedModules;
|
||
|
/******/
|
||
|
/******/ // define getter function for harmony exports
|
||
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
||
|
/******/ Object.defineProperty(exports, name, {
|
||
|
/******/ configurable: false,
|
||
|
/******/ enumerable: true,
|
||
|
/******/ get: getter
|
||
|
/******/ });
|
||
|
/******/ }
|
||
|
/******/ };
|
||
|
/******/
|
||
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||
|
/******/ __webpack_require__.n = function(module) {
|
||
|
/******/ var getter = module && module.__esModule ?
|
||
|
/******/ function getDefault() { return module['default']; } :
|
||
|
/******/ function getModuleExports() { return module; };
|
||
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
||
|
/******/ return getter;
|
||
|
/******/ };
|
||
|
/******/
|
||
|
/******/ // Object.prototype.hasOwnProperty.call
|
||
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||
|
/******/
|
||
|
/******/ // __webpack_public_path__
|
||
|
/******/ __webpack_require__.p = "";
|
||
|
/******/
|
||
|
/******/ // __webpack_hash__
|
||
|
/******/ __webpack_require__.h = function() { return hotCurrentHash; };
|
||
|
/******/
|
||
|
/******/ // Load entry module and return exports
|
||
|
/******/ return hotCreateRequire(11)(__webpack_require__.s = 11);
|
||
|
/******/ })
|
||
|
/************************************************************************/
|
||
|
/******/ ([
|
||
|
/* 0 */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = require('path');
|
||
|
|
||
|
/***/ }),
|
||
|
/* 1 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const path = __webpack_require__(0);
|
||
|
const DATA_PATH = path.join(__dirname, '../data');
|
||
|
exports.DATA_PATH = DATA_PATH;
|
||
|
const ANALYTICS_PATH = path.join(__dirname, '../../src');
|
||
|
exports.ANALYTICS_PATH = ANALYTICS_PATH;
|
||
|
const ANOMALIES_PATH = path.join(ANALYTICS_PATH, 'anomalies');
|
||
|
exports.ANOMALIES_PATH = ANOMALIES_PATH;
|
||
|
const SEGMENTS_PATH = path.join(ANALYTICS_PATH, 'segments');
|
||
|
exports.SEGMENTS_PATH = SEGMENTS_PATH;
|
||
|
const METRICS_PATH = path.join(ANALYTICS_PATH, 'metrics');
|
||
|
exports.METRICS_PATH = METRICS_PATH;
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 2 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const path = __webpack_require__(0);
|
||
|
const json_1 = __webpack_require__(3);
|
||
|
const config_1 = __webpack_require__(1);
|
||
|
const fs = __webpack_require__(5);
|
||
|
const crypto = __webpack_require__(8);
|
||
|
let anomaliesNameToIdMap = {};
|
||
|
function loadAnomaliesMap() {
|
||
|
let filename = path.join(config_1.ANOMALIES_PATH, `all_anomalies.json`);
|
||
|
anomaliesNameToIdMap = json_1.getJsonDataSync(filename);
|
||
|
}
|
||
|
function saveAnomaliesMap() {
|
||
|
let filename = path.join(config_1.ANOMALIES_PATH, `all_anomalies.json`);
|
||
|
json_1.writeJsonDataSync(filename, anomaliesNameToIdMap);
|
||
|
}
|
||
|
function getAnomalyIdByName(anomalyName) {
|
||
|
loadAnomaliesMap();
|
||
|
anomalyName = anomalyName.toLowerCase();
|
||
|
if (anomalyName in anomaliesNameToIdMap) {
|
||
|
return anomaliesNameToIdMap[anomalyName];
|
||
|
}
|
||
|
return anomalyName;
|
||
|
}
|
||
|
exports.getAnomalyIdByName = getAnomalyIdByName;
|
||
|
function insertAnomaly(anomaly) {
|
||
|
const hashString = anomaly.name + (new Date()).toString();
|
||
|
const anomalyId = crypto.createHash('md5').update(hashString).digest('hex');
|
||
|
anomaliesNameToIdMap[anomaly.name] = anomalyId;
|
||
|
saveAnomaliesMap();
|
||
|
// return anomalyId
|
||
|
// const anomalyId:AnomalyId = anomaly.name;
|
||
|
let filename = path.join(config_1.ANOMALIES_PATH, `${anomalyId}.json`);
|
||
|
if (fs.existsSync(filename)) {
|
||
|
return null;
|
||
|
}
|
||
|
saveAnomaly(anomalyId, anomaly);
|
||
|
return anomalyId;
|
||
|
}
|
||
|
exports.insertAnomaly = insertAnomaly;
|
||
|
function removeAnomaly(anomalyId) {
|
||
|
let filename = path.join(config_1.ANOMALIES_PATH, `${anomalyId}.json`);
|
||
|
fs.unlinkSync(filename);
|
||
|
}
|
||
|
exports.removeAnomaly = removeAnomaly;
|
||
|
function saveAnomaly(anomalyId, anomaly) {
|
||
|
let filename = path.join(config_1.ANOMALIES_PATH, `${anomalyId}.json`);
|
||
|
return json_1.writeJsonDataSync(filename, anomaly);
|
||
|
}
|
||
|
exports.saveAnomaly = saveAnomaly;
|
||
|
function loadAnomalyById(anomalyId) {
|
||
|
let filename = path.join(config_1.ANOMALIES_PATH, `${anomalyId}.json`);
|
||
|
if (!fs.existsSync(filename)) {
|
||
|
return null;
|
||
|
}
|
||
|
return json_1.getJsonDataSync(filename);
|
||
|
}
|
||
|
exports.loadAnomalyById = loadAnomalyById;
|
||
|
function loadAnomalyByName(anomalyName) {
|
||
|
let anomalyId = getAnomalyIdByName(anomalyName);
|
||
|
return loadAnomalyById(anomalyId);
|
||
|
}
|
||
|
exports.loadAnomalyByName = loadAnomalyByName;
|
||
|
function saveAnomalyTypeInfo(info) {
|
||
|
console.log('Saving');
|
||
|
let filename = path.join(config_1.ANOMALIES_PATH, `${info.name}.json`);
|
||
|
if (info.next_id === undefined) {
|
||
|
info.next_id = 0;
|
||
|
}
|
||
|
if (info.last_prediction_time === undefined) {
|
||
|
info.last_prediction_time = 0;
|
||
|
}
|
||
|
return json_1.writeJsonDataSync(filename, info);
|
||
|
}
|
||
|
exports.saveAnomalyTypeInfo = saveAnomalyTypeInfo;
|
||
|
function getAnomalyTypeInfo(name) {
|
||
|
return json_1.getJsonDataSync(path.join(config_1.ANOMALIES_PATH, `${name}.json`));
|
||
|
}
|
||
|
exports.getAnomalyTypeInfo = getAnomalyTypeInfo;
|
||
|
function setAnomalyStatus(anomalyId, status, error) {
|
||
|
let info = loadAnomalyById(anomalyId);
|
||
|
info.status = status;
|
||
|
if (error !== undefined) {
|
||
|
info.error = error;
|
||
|
}
|
||
|
else {
|
||
|
info.error = '';
|
||
|
}
|
||
|
saveAnomaly(anomalyId, info);
|
||
|
}
|
||
|
exports.setAnomalyStatus = setAnomalyStatus;
|
||
|
function setAnomalyPredictionTime(anomalyId, lastPredictionTime) {
|
||
|
let info = loadAnomalyById(anomalyId);
|
||
|
info.last_prediction_time = lastPredictionTime;
|
||
|
saveAnomaly(anomalyId, info);
|
||
|
}
|
||
|
exports.setAnomalyPredictionTime = setAnomalyPredictionTime;
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 3 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const fs = __webpack_require__(5);
|
||
|
function getJsonData(filename) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
var data = yield new Promise((resolve, reject) => {
|
||
|
fs.readFile(filename, 'utf8', (err, data) => {
|
||
|
if (err) {
|
||
|
console.error(err);
|
||
|
reject('Can`t read file');
|
||
|
}
|
||
|
else {
|
||
|
resolve(data);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
try {
|
||
|
return JSON.parse(data);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e);
|
||
|
throw new Error('Wrong file format');
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
exports.getJsonData = getJsonData;
|
||
|
function writeJsonData(filename, data) {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
fs.writeFile(filename, JSON.stringify(data), 'utf8', (err) => {
|
||
|
if (err) {
|
||
|
console.error(err);
|
||
|
reject('Cat`t write file');
|
||
|
}
|
||
|
else {
|
||
|
resolve();
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
exports.writeJsonData = writeJsonData;
|
||
|
function getJsonDataSync(filename) {
|
||
|
let data = fs.readFileSync(filename, 'utf8');
|
||
|
try {
|
||
|
return JSON.parse(data);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e);
|
||
|
throw new Error('Wrong file format');
|
||
|
}
|
||
|
}
|
||
|
exports.getJsonDataSync = getJsonDataSync;
|
||
|
function writeJsonDataSync(filename, data) {
|
||
|
fs.writeFileSync(filename, JSON.stringify(data));
|
||
|
}
|
||
|
exports.writeJsonDataSync = writeJsonDataSync;
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 4 */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = require('express');
|
||
|
|
||
|
/***/ }),
|
||
|
/* 5 */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = require('fs');
|
||
|
|
||
|
/***/ }),
|
||
|
/* 6 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const child_process_1 = __webpack_require__(14);
|
||
|
const config_1 = __webpack_require__(1);
|
||
|
const anomalyType_1 = __webpack_require__(2);
|
||
|
const metrics_1 = __webpack_require__(9);
|
||
|
const segments_1 = __webpack_require__(7);
|
||
|
const event_stream_1 = __webpack_require__(15);
|
||
|
const learnWorker = child_process_1.spawn('python3', ['worker.py'], { cwd: config_1.ANALYTICS_PATH });
|
||
|
learnWorker.stdout.pipe(event_stream_1.split())
|
||
|
.pipe(event_stream_1.mapSync(function (line) {
|
||
|
onMessage(line);
|
||
|
}));
|
||
|
learnWorker.stderr.on('data', data => console.error(`worker stderr: ${data}`));
|
||
|
const taskMap = {};
|
||
|
let nextTaskId = 0;
|
||
|
function onMessage(data) {
|
||
|
console.log(`worker stdout: ${data}`);
|
||
|
let response = JSON.parse(data);
|
||
|
let taskId = response.__task_id;
|
||
|
// let anomalyName = response.anomaly_name;
|
||
|
// let task = response.task;
|
||
|
let status = response.status;
|
||
|
if (status === 'success' || status === 'failed') {
|
||
|
if (taskId in taskMap) {
|
||
|
let resolver = taskMap[taskId];
|
||
|
resolver(response);
|
||
|
delete taskMap[taskId];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function runTask(task) {
|
||
|
let anomaly = anomalyType_1.loadAnomalyById(task.anomaly_id);
|
||
|
task.metric = {
|
||
|
datasource: anomaly.metric.datasource,
|
||
|
targets: anomaly.metric.targets.map(t => metrics_1.getTarget(t))
|
||
|
};
|
||
|
task.__task_id = nextTaskId++;
|
||
|
let command = JSON.stringify(task);
|
||
|
learnWorker.stdin.write(`${command}\n`);
|
||
|
return new Promise((resolve, reject) => {
|
||
|
taskMap[task.__task_id] = resolve;
|
||
|
});
|
||
|
}
|
||
|
function runLearning(anomalyId) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
let segments = segments_1.getLabeledSegments(anomalyId);
|
||
|
anomalyType_1.setAnomalyStatus(anomalyId, 'learning');
|
||
|
let anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
||
|
let analyticsType = "anomalies";
|
||
|
let preset = undefined;
|
||
|
if (anomaly.name.includes("jumps")) {
|
||
|
analyticsType = "patterns";
|
||
|
preset = "steps";
|
||
|
}
|
||
|
if (anomaly.name.includes("cliffs") || anomaly.name.includes("drops")) {
|
||
|
analyticsType = "patterns";
|
||
|
preset = "cliffs";
|
||
|
}
|
||
|
if (anomaly.name.includes("peaks")) {
|
||
|
analyticsType = "patterns";
|
||
|
preset = "peaks";
|
||
|
}
|
||
|
let task = {
|
||
|
type: 'learn',
|
||
|
anomaly_id: anomalyId,
|
||
|
analytics_type: analyticsType,
|
||
|
preset,
|
||
|
segments: segments
|
||
|
};
|
||
|
let result = yield runTask(task);
|
||
|
if (result.status === 'success') {
|
||
|
anomalyType_1.setAnomalyStatus(anomalyId, 'ready');
|
||
|
segments_1.insertSegments(anomalyId, result.segments, false);
|
||
|
anomalyType_1.setAnomalyPredictionTime(anomalyId, result.last_prediction_time);
|
||
|
}
|
||
|
else {
|
||
|
anomalyType_1.setAnomalyStatus(anomalyId, 'failed', result.error);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
exports.runLearning = runLearning;
|
||
|
function runPredict(anomalyId) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
let anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
||
|
let analyticsType = "anomalies";
|
||
|
let preset = undefined;
|
||
|
if (anomaly.name.includes("jump")) {
|
||
|
analyticsType = "patterns";
|
||
|
preset = "steps";
|
||
|
}
|
||
|
if (anomaly.name.includes("cliffs") || anomaly.name.includes("drops")) {
|
||
|
analyticsType = "patterns";
|
||
|
preset = "cliffs";
|
||
|
}
|
||
|
if (anomaly.name.includes("peaks")) {
|
||
|
analyticsType = "patterns";
|
||
|
preset = "peaks";
|
||
|
}
|
||
|
let task = {
|
||
|
type: 'predict',
|
||
|
anomaly_id: anomalyId,
|
||
|
analytics_type: analyticsType,
|
||
|
preset,
|
||
|
last_prediction_time: anomaly.last_prediction_time
|
||
|
};
|
||
|
let result = yield runTask(task);
|
||
|
if (result.status === 'failed') {
|
||
|
return [];
|
||
|
}
|
||
|
// Merging segments
|
||
|
let segments = segments_1.getLabeledSegments(anomalyId);
|
||
|
if (segments.length > 0 && result.segments.length > 0) {
|
||
|
let lastOldSegment = segments[segments.length - 1];
|
||
|
let firstNewSegment = result.segments[0];
|
||
|
if (firstNewSegment.start <= lastOldSegment.finish) {
|
||
|
result.segments[0].start = lastOldSegment.start;
|
||
|
segments_1.removeSegments(anomalyId, [lastOldSegment.id]);
|
||
|
}
|
||
|
}
|
||
|
segments_1.insertSegments(anomalyId, result.segments, false);
|
||
|
anomalyType_1.setAnomalyPredictionTime(anomalyId, result.last_prediction_time);
|
||
|
return result.segments;
|
||
|
});
|
||
|
}
|
||
|
exports.runPredict = runPredict;
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 7 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const path = __webpack_require__(0);
|
||
|
const json_1 = __webpack_require__(3);
|
||
|
const config_1 = __webpack_require__(1);
|
||
|
const anomalyType_1 = __webpack_require__(2);
|
||
|
function getLabeledSegments(anomalyId) {
|
||
|
let filename = path.join(config_1.SEGMENTS_PATH, `${anomalyId}_labeled.json`);
|
||
|
let segments = [];
|
||
|
try {
|
||
|
segments = json_1.getJsonDataSync(filename);
|
||
|
for (let segment of segments) {
|
||
|
if (segment.labeled === undefined) {
|
||
|
segment.labeled = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e.message);
|
||
|
}
|
||
|
return segments;
|
||
|
}
|
||
|
exports.getLabeledSegments = getLabeledSegments;
|
||
|
function getPredictedSegments(anomalyId) {
|
||
|
let filename = path.join(config_1.SEGMENTS_PATH, `${anomalyId}_segments.json`);
|
||
|
let jsonData;
|
||
|
try {
|
||
|
jsonData = json_1.getJsonDataSync(filename);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e.message);
|
||
|
jsonData = [];
|
||
|
}
|
||
|
return jsonData;
|
||
|
}
|
||
|
exports.getPredictedSegments = getPredictedSegments;
|
||
|
function saveSegments(anomalyId, segments) {
|
||
|
let filename = path.join(config_1.SEGMENTS_PATH, `${anomalyId}_labeled.json`);
|
||
|
try {
|
||
|
return json_1.writeJsonDataSync(filename, segments);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e.message);
|
||
|
throw new Error('Can`t write to db');
|
||
|
}
|
||
|
}
|
||
|
exports.saveSegments = saveSegments;
|
||
|
function insertSegments(anomalyId, addedSegments, labeled) {
|
||
|
// Set status
|
||
|
let info = anomalyType_1.loadAnomalyById(anomalyId);
|
||
|
let segments = getLabeledSegments(anomalyId);
|
||
|
let nextId = info.next_id;
|
||
|
let addedIds = [];
|
||
|
for (let segment of addedSegments) {
|
||
|
segment.id = nextId;
|
||
|
segment.labeled = labeled;
|
||
|
addedIds.push(nextId);
|
||
|
nextId++;
|
||
|
segments.push(segment);
|
||
|
}
|
||
|
info.next_id = nextId;
|
||
|
saveSegments(anomalyId, segments);
|
||
|
anomalyType_1.saveAnomaly(anomalyId, info);
|
||
|
return addedIds;
|
||
|
}
|
||
|
exports.insertSegments = insertSegments;
|
||
|
function removeSegments(anomalyId, removedSegments) {
|
||
|
let segments = getLabeledSegments(anomalyId);
|
||
|
for (let segmentId of removedSegments) {
|
||
|
segments = segments.filter(el => el.id !== segmentId);
|
||
|
}
|
||
|
saveSegments(anomalyId, segments);
|
||
|
}
|
||
|
exports.removeSegments = removeSegments;
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 8 */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = require('crypto');
|
||
|
|
||
|
/***/ }),
|
||
|
/* 9 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const path = __webpack_require__(0);
|
||
|
const json_1 = __webpack_require__(3);
|
||
|
const config_1 = __webpack_require__(1);
|
||
|
const crypto = __webpack_require__(8);
|
||
|
function saveTargets(targets) {
|
||
|
let metrics = [];
|
||
|
for (let target of targets) {
|
||
|
metrics.push(saveTarget(target));
|
||
|
}
|
||
|
return metrics;
|
||
|
}
|
||
|
exports.saveTargets = saveTargets;
|
||
|
function saveTarget(target) {
|
||
|
//const md5 = crypto.createHash('md5')
|
||
|
const targetId = crypto.createHash('md5').update(JSON.stringify(target)).digest('hex');
|
||
|
let filename = path.join(config_1.METRICS_PATH, `${targetId}.json`);
|
||
|
json_1.writeJsonDataSync(filename, target);
|
||
|
return targetId;
|
||
|
}
|
||
|
function getTarget(targetId) {
|
||
|
let filename = path.join(config_1.METRICS_PATH, `${targetId}.json`);
|
||
|
return json_1.getJsonDataSync(filename);
|
||
|
}
|
||
|
exports.getTarget = getTarget;
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 10 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
//import * as Telegraf from 'telegraf'
|
||
|
const path = __webpack_require__(0);
|
||
|
const config_1 = __webpack_require__(1);
|
||
|
const json_1 = __webpack_require__(3);
|
||
|
function sendNotification(anomalyName, active) {
|
||
|
console.log('Notification ' + anomalyName);
|
||
|
if (anomalyName in botConfig.subscriptions) {
|
||
|
let notificationMessage;
|
||
|
if (active) {
|
||
|
notificationMessage = 'Alert! Anomaly type ' + anomalyName;
|
||
|
}
|
||
|
else {
|
||
|
notificationMessage = 'Ok! Anomaly type ' + anomalyName;
|
||
|
}
|
||
|
for (let SubscriberId of botConfig.subscriptions[anomalyName]) {
|
||
|
bot.telegram.sendMessage(SubscriberId, notificationMessage);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
exports.sendNotification = sendNotification;
|
||
|
function loadBotConfig() {
|
||
|
let filename = path.join(config_1.DATA_PATH, `bot_config.json`);
|
||
|
let jsonData;
|
||
|
try {
|
||
|
jsonData = json_1.getJsonDataSync(filename);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e.message);
|
||
|
jsonData = [];
|
||
|
}
|
||
|
return jsonData;
|
||
|
}
|
||
|
function saveBotConfig(botConfig) {
|
||
|
let filename = path.join(config_1.DATA_PATH, `bot_config.json`);
|
||
|
try {
|
||
|
json_1.writeJsonDataSync(filename, botConfig);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e.message);
|
||
|
}
|
||
|
}
|
||
|
const commandArgs = (ctx, next) => {
|
||
|
try {
|
||
|
if (ctx.updateType === 'message') {
|
||
|
const text = ctx.update.message.text;
|
||
|
if (text !== undefined && text.startsWith('/')) {
|
||
|
const match = text.match(/^\/([^\s]+)\s?(.+)?/);
|
||
|
let args = [];
|
||
|
let command;
|
||
|
if (match !== null) {
|
||
|
if (match[1]) {
|
||
|
command = match[1];
|
||
|
}
|
||
|
if (match[2]) {
|
||
|
args = match[2].split(' ');
|
||
|
}
|
||
|
}
|
||
|
ctx.state.command = {
|
||
|
raw: text,
|
||
|
command,
|
||
|
args,
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
return next(ctx);
|
||
|
}
|
||
|
catch (e) {
|
||
|
}
|
||
|
};
|
||
|
function addNotification(ctx) {
|
||
|
console.log('addNotification');
|
||
|
let command = ctx.state.command;
|
||
|
let chatId = ctx.chat.id;
|
||
|
if (command.args.length > 0) {
|
||
|
for (let anomalyName of command.args) {
|
||
|
if (!(anomalyName in botConfig.subscriptions)) {
|
||
|
botConfig.subscriptions[anomalyName] = [];
|
||
|
}
|
||
|
if (botConfig.subscriptions[anomalyName].includes(chatId)) {
|
||
|
return ctx.reply('You are already subscribed on alerts from anomaly ' + command.args);
|
||
|
}
|
||
|
else {
|
||
|
botConfig.subscriptions[anomalyName].push(chatId);
|
||
|
saveBotConfig(botConfig);
|
||
|
}
|
||
|
}
|
||
|
return ctx.reply('You have been successfully subscribed on alerts from anomaly ' + command.args);
|
||
|
}
|
||
|
else {
|
||
|
return ctx.reply('You should use syntax: \/addNotification <anomaly_name>');
|
||
|
}
|
||
|
}
|
||
|
function removeNotification(ctx) {
|
||
|
let command = ctx.state.command;
|
||
|
let chatId = ctx.chat.id;
|
||
|
if (command.args.length > 0) {
|
||
|
for (let anomalyName of command.args) {
|
||
|
if (anomalyName in botConfig.subscriptions) {
|
||
|
botConfig.subscriptions[anomalyName] = botConfig.subscriptions[anomalyName].filter(el => el !== chatId);
|
||
|
saveBotConfig(botConfig);
|
||
|
}
|
||
|
}
|
||
|
return ctx.reply('You have been successfully unsubscribed from alerts from ' + command.args);
|
||
|
}
|
||
|
else {
|
||
|
return ctx.reply('You should use syntax: \/removeNotification <anomaly_name>');
|
||
|
}
|
||
|
}
|
||
|
const Telegraf = __webpack_require__(19);
|
||
|
let botConfig;
|
||
|
let bot;
|
||
|
function tgBotInit() {
|
||
|
try {
|
||
|
botConfig = loadBotConfig();
|
||
|
bot = new Telegraf(botConfig.token);
|
||
|
bot.use(commandArgs);
|
||
|
bot.command('addNotification', addNotification);
|
||
|
bot.command('removeNotification', removeNotification);
|
||
|
bot.startPolling();
|
||
|
}
|
||
|
catch (e) {
|
||
|
// TODO: handle exception
|
||
|
}
|
||
|
}
|
||
|
exports.tgBotInit = tgBotInit;
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 11 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const express = __webpack_require__(4);
|
||
|
const bodyParser = __webpack_require__(12);
|
||
|
const anomalies_1 = __webpack_require__(13);
|
||
|
const segments_1 = __webpack_require__(16);
|
||
|
const alerts_1 = __webpack_require__(17);
|
||
|
const notification_1 = __webpack_require__(10);
|
||
|
const app = express();
|
||
|
const PORT = process.env.HASTIC_PORT || 8000;
|
||
|
app.use(bodyParser.json());
|
||
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||
|
app.use(function (req, res, next) {
|
||
|
res.header('Access-Control-Allow-Origin', '*');
|
||
|
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
||
|
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
|
||
|
next();
|
||
|
});
|
||
|
app.use('/anomalies', anomalies_1.router);
|
||
|
app.use('/segments', segments_1.router);
|
||
|
app.use('/alerts', alerts_1.router);
|
||
|
app.use('/', (req, res) => res.send({ status: 'OK' }));
|
||
|
app.listen(PORT, () => {
|
||
|
console.log(`Server is running on :${PORT}`);
|
||
|
});
|
||
|
notification_1.tgBotInit();
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 12 */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = require('body-parser');
|
||
|
|
||
|
/***/ }),
|
||
|
/* 13 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const express = __webpack_require__(4);
|
||
|
const anomalyType_1 = __webpack_require__(2);
|
||
|
const analytics_1 = __webpack_require__(6);
|
||
|
const metrics_1 = __webpack_require__(9);
|
||
|
function sendAnomalyTypeStatus(req, res) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
let id = req.query.id;
|
||
|
let name = req.query.name;
|
||
|
try {
|
||
|
let anomaly;
|
||
|
if (id !== undefined) {
|
||
|
anomaly = anomalyType_1.loadAnomalyById(id);
|
||
|
}
|
||
|
else {
|
||
|
anomaly = anomalyType_1.loadAnomalyByName(name);
|
||
|
}
|
||
|
if (anomaly === null) {
|
||
|
res.status(404).send({
|
||
|
code: 404,
|
||
|
message: 'Not found'
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
if (anomaly.status === undefined) {
|
||
|
throw new Error('No status for ' + name);
|
||
|
}
|
||
|
res.status(200).send({ status: anomaly.status, errorMessage: anomaly.error });
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e);
|
||
|
// TODO: better send 404 when we know than isn`t found
|
||
|
res.status(500).send({ error: 'Can`t return anything' });
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
function getAnomaly(req, res) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
try {
|
||
|
let id = req.query.id;
|
||
|
let name = req.query.name;
|
||
|
let anomaly;
|
||
|
if (id !== undefined) {
|
||
|
anomaly = anomalyType_1.loadAnomalyById(id);
|
||
|
}
|
||
|
else {
|
||
|
anomaly = anomalyType_1.loadAnomalyByName(name.toLowerCase());
|
||
|
}
|
||
|
if (anomaly === null) {
|
||
|
res.status(404).send({
|
||
|
code: 404,
|
||
|
message: 'Not found'
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
let payload = JSON.stringify({
|
||
|
name: anomaly.name,
|
||
|
metric: anomaly.metric,
|
||
|
status: anomaly.status
|
||
|
});
|
||
|
res.status(200).send(payload);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e);
|
||
|
// TODO: better send 404 when we know than isn`t found
|
||
|
res.status(500).send('Can`t get anything');
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
function createAnomaly(req, res) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
try {
|
||
|
const metric = {
|
||
|
datasource: req.body.metric.datasource,
|
||
|
targets: metrics_1.saveTargets(req.body.metric.targets)
|
||
|
};
|
||
|
const anomaly = {
|
||
|
name: req.body.name,
|
||
|
panelUrl: req.body.panelUrl,
|
||
|
metric: metric,
|
||
|
datasource: req.body.datasource,
|
||
|
status: 'learning',
|
||
|
last_prediction_time: 0,
|
||
|
next_id: 0
|
||
|
};
|
||
|
let anomalyId = anomalyType_1.insertAnomaly(anomaly);
|
||
|
if (anomalyId === null) {
|
||
|
res.status(403).send({
|
||
|
code: 403,
|
||
|
message: 'Already exists'
|
||
|
});
|
||
|
}
|
||
|
let payload = JSON.stringify({ anomaly_id: anomalyId });
|
||
|
res.status(200).send(payload);
|
||
|
analytics_1.runLearning(anomalyId);
|
||
|
}
|
||
|
catch (e) {
|
||
|
res.status(500).send({
|
||
|
code: 500,
|
||
|
message: 'Internal error'
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
function deleteAnomaly(req, res) {
|
||
|
try {
|
||
|
let id = req.query.id;
|
||
|
let name = req.query.name;
|
||
|
if (id !== undefined) {
|
||
|
anomalyType_1.removeAnomaly(id);
|
||
|
}
|
||
|
else {
|
||
|
anomalyType_1.removeAnomaly(name.toLowerCase());
|
||
|
}
|
||
|
res.status(200).send({
|
||
|
code: 200,
|
||
|
message: 'Success'
|
||
|
});
|
||
|
}
|
||
|
catch (e) {
|
||
|
res.status(500).send({
|
||
|
code: 500,
|
||
|
message: 'Internal error'
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
exports.router = express.Router();
|
||
|
exports.router.get('/status', sendAnomalyTypeStatus);
|
||
|
exports.router.get('/', getAnomaly);
|
||
|
exports.router.post('/', createAnomaly);
|
||
|
exports.router.delete('/', deleteAnomaly);
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 14 */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = require('child_process');
|
||
|
|
||
|
/***/ }),
|
||
|
/* 15 */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = require('event-stream');
|
||
|
|
||
|
/***/ }),
|
||
|
/* 16 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const express = __webpack_require__(4);
|
||
|
const segments_1 = __webpack_require__(7);
|
||
|
const analytics_1 = __webpack_require__(6);
|
||
|
const anomalyType_1 = __webpack_require__(2);
|
||
|
function sendSegments(req, res) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
try {
|
||
|
let anomalyId = req.query.anomaly_id;
|
||
|
let anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
||
|
if (anomaly === null) {
|
||
|
anomalyId = anomalyType_1.getAnomalyIdByName(anomalyId);
|
||
|
}
|
||
|
let lastSegmentId = req.query.last_segment;
|
||
|
let timeFrom = req.query.from;
|
||
|
let timeTo = req.query.to;
|
||
|
let segments = segments_1.getLabeledSegments(anomalyId);
|
||
|
// Id filtering
|
||
|
if (lastSegmentId !== undefined) {
|
||
|
segments = segments.filter(el => el.id > lastSegmentId);
|
||
|
}
|
||
|
// Time filtering
|
||
|
if (timeFrom !== undefined) {
|
||
|
segments = segments.filter(el => el.finish > timeFrom);
|
||
|
}
|
||
|
if (timeTo !== undefined) {
|
||
|
segments = segments.filter(el => el.start < timeTo);
|
||
|
}
|
||
|
let payload = JSON.stringify({
|
||
|
segments
|
||
|
});
|
||
|
res.status(200).send(payload);
|
||
|
}
|
||
|
catch (e) {
|
||
|
res.status(500).send({
|
||
|
code: 500,
|
||
|
message: 'Internal error'
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
function updateSegments(req, res) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
try {
|
||
|
let segmentsUpdate = req.body;
|
||
|
let anomalyId = segmentsUpdate.anomaly_id;
|
||
|
let anomalyName = segmentsUpdate.name;
|
||
|
if (anomalyId === undefined) {
|
||
|
anomalyId = anomalyType_1.getAnomalyIdByName(anomalyName.toLowerCase());
|
||
|
}
|
||
|
let addedIds = segments_1.insertSegments(anomalyId, segmentsUpdate.added_segments, true);
|
||
|
segments_1.removeSegments(anomalyId, segmentsUpdate.removed_segments);
|
||
|
let payload = JSON.stringify({ added_ids: addedIds });
|
||
|
res.status(200).send(payload);
|
||
|
analytics_1.runLearning(anomalyId);
|
||
|
}
|
||
|
catch (e) {
|
||
|
res.status(500).send({
|
||
|
code: 500,
|
||
|
message: 'Internal error'
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
exports.router = express.Router();
|
||
|
exports.router.get('/', sendSegments);
|
||
|
exports.router.patch('/', updateSegments);
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 17 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const express = __webpack_require__(4);
|
||
|
const anomalyType_1 = __webpack_require__(2);
|
||
|
const alerts_1 = __webpack_require__(18);
|
||
|
function getAlert(req, res) {
|
||
|
try {
|
||
|
let anomalyId = req.query.anomaly_id;
|
||
|
let anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
||
|
if (anomaly == null) {
|
||
|
anomalyId = anomalyType_1.getAnomalyIdByName(anomalyId.toLowerCase());
|
||
|
}
|
||
|
let alertsAnomalies = alerts_1.getAlertsAnomalies();
|
||
|
let pos = alertsAnomalies.indexOf(anomalyId);
|
||
|
let enable = (pos !== -1);
|
||
|
res.status(200).send({
|
||
|
enable
|
||
|
});
|
||
|
}
|
||
|
catch (e) {
|
||
|
res.status(500).send({
|
||
|
code: 500,
|
||
|
message: 'Internal error'
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
function changeAlert(req, res) {
|
||
|
try {
|
||
|
let anomalyId = req.body.anomaly_id;
|
||
|
let enable = req.body.enable;
|
||
|
let anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
||
|
if (anomaly == null) {
|
||
|
anomalyId = anomalyType_1.getAnomalyIdByName(anomalyId.toLowerCase());
|
||
|
}
|
||
|
let alertsAnomalies = alerts_1.getAlertsAnomalies();
|
||
|
let pos = alertsAnomalies.indexOf(anomalyId);
|
||
|
if (enable && pos == -1) {
|
||
|
alertsAnomalies.push(anomalyId);
|
||
|
alerts_1.saveAlertsAnomalies(alertsAnomalies);
|
||
|
}
|
||
|
else if (!enable && pos > -1) {
|
||
|
alertsAnomalies.splice(pos, 1);
|
||
|
alerts_1.saveAlertsAnomalies(alertsAnomalies);
|
||
|
}
|
||
|
res.status(200).send({
|
||
|
status: 'Ok'
|
||
|
});
|
||
|
}
|
||
|
catch (e) {
|
||
|
res.status(500).send({
|
||
|
code: 500,
|
||
|
message: 'Internal error'
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
exports.router = express.Router();
|
||
|
exports.router.get('/', getAlert);
|
||
|
exports.router.post('/', changeAlert);
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 18 */
|
||
|
/***/ (function(module, exports, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const json_1 = __webpack_require__(3);
|
||
|
const path = __webpack_require__(0);
|
||
|
const fs = __webpack_require__(5);
|
||
|
const config_1 = __webpack_require__(1);
|
||
|
const analytics_1 = __webpack_require__(6);
|
||
|
const notification_1 = __webpack_require__(10);
|
||
|
const segments_1 = __webpack_require__(7);
|
||
|
function getAlertsAnomalies() {
|
||
|
let filename = path.join(config_1.ANOMALIES_PATH, `alerts_anomalies.json`);
|
||
|
if (!fs.existsSync(filename)) {
|
||
|
saveAlertsAnomalies([]);
|
||
|
}
|
||
|
return json_1.getJsonDataSync(path.join(config_1.ANOMALIES_PATH, `alerts_anomalies.json`));
|
||
|
}
|
||
|
exports.getAlertsAnomalies = getAlertsAnomalies;
|
||
|
function saveAlertsAnomalies(anomalies) {
|
||
|
return json_1.writeJsonDataSync(path.join(config_1.ANOMALIES_PATH, `alerts_anomalies.json`), anomalies);
|
||
|
}
|
||
|
exports.saveAlertsAnomalies = saveAlertsAnomalies;
|
||
|
function processAlerts(anomalyId) {
|
||
|
let segments = segments_1.getLabeledSegments(anomalyId);
|
||
|
const currentTime = new Date().getTime();
|
||
|
const activeAlert = activeAlerts.has(anomalyId);
|
||
|
let newActiveAlert = false;
|
||
|
if (segments.length > 0) {
|
||
|
let lastSegment = segments[segments.length - 1];
|
||
|
if (lastSegment.finish >= currentTime - alertTimeout) {
|
||
|
newActiveAlert = true;
|
||
|
}
|
||
|
}
|
||
|
if (!activeAlert && newActiveAlert) {
|
||
|
activeAlerts.add(anomalyId);
|
||
|
notification_1.sendNotification(anomalyId, true);
|
||
|
}
|
||
|
else if (activeAlert && !newActiveAlert) {
|
||
|
activeAlerts.delete(anomalyId);
|
||
|
notification_1.sendNotification(anomalyId, false);
|
||
|
}
|
||
|
}
|
||
|
function alertsTick() {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
let alertsAnomalies = getAlertsAnomalies();
|
||
|
for (let anomalyId of alertsAnomalies) {
|
||
|
try {
|
||
|
yield analytics_1.runPredict(anomalyId);
|
||
|
processAlerts(anomalyId);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e);
|
||
|
}
|
||
|
}
|
||
|
setTimeout(alertsTick, 5000);
|
||
|
});
|
||
|
}
|
||
|
const alertTimeout = 60000; // ms
|
||
|
const activeAlerts = new Set();
|
||
|
setTimeout(alertsTick, 5000);
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
/* 19 */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = require('telegraf');
|
||
|
|
||
|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