|
|
|
/******/ (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 = "c9fd12c9ae939f59622b"; // 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(15)(__webpack_require__.s = 15);
|
|
|
|
/******/ })
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ ([
|
|
|
|
/* 0 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('path');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 1 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var path = __webpack_require__(0);
|
|
|
|
var DATA_PATH = path.join(__dirname, '../data');
|
|
|
|
exports.DATA_PATH = DATA_PATH;
|
|
|
|
var ANALYTICS_PATH = path.join(__dirname, '../../src');
|
|
|
|
exports.ANALYTICS_PATH = ANALYTICS_PATH;
|
|
|
|
var ANOMALIES_PATH = path.join(ANALYTICS_PATH, 'anomalies');
|
|
|
|
exports.ANOMALIES_PATH = ANOMALIES_PATH;
|
|
|
|
var SEGMENTS_PATH = path.join(ANALYTICS_PATH, 'segments');
|
|
|
|
exports.SEGMENTS_PATH = SEGMENTS_PATH;
|
|
|
|
var METRICS_PATH = path.join(ANALYTICS_PATH, 'metrics');
|
|
|
|
exports.METRICS_PATH = METRICS_PATH;
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 2 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('babel-runtime/core-js/json/stringify');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 3 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('babel-runtime/regenerator');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 4 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('babel-runtime/core-js/promise');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 5 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var path = __webpack_require__(0);
|
|
|
|
var json_1 = __webpack_require__(6);
|
|
|
|
var config_1 = __webpack_require__(1);
|
|
|
|
var fs = __webpack_require__(9);
|
|
|
|
var crypto = __webpack_require__(12);
|
|
|
|
var anomaliesNameToIdMap = {};
|
|
|
|
function loadAnomaliesMap() {
|
|
|
|
var filename = path.join(config_1.ANOMALIES_PATH, "all_anomalies.json");
|
|
|
|
anomaliesNameToIdMap = json_1.getJsonDataSync(filename);
|
|
|
|
}
|
|
|
|
function saveAnomaliesMap() {
|
|
|
|
var 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) {
|
|
|
|
var hashString = anomaly.name + new Date().toString();
|
|
|
|
var anomalyId = crypto.createHash('md5').update(hashString).digest('hex');
|
|
|
|
anomaliesNameToIdMap[anomaly.name] = anomalyId;
|
|
|
|
saveAnomaliesMap();
|
|
|
|
// return anomalyId
|
|
|
|
// const anomalyId:AnomalyId = anomaly.name;
|
|
|
|
var 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) {
|
|
|
|
var filename = path.join(config_1.ANOMALIES_PATH, anomalyId + ".json");
|
|
|
|
fs.unlinkSync(filename);
|
|
|
|
}
|
|
|
|
exports.removeAnomaly = removeAnomaly;
|
|
|
|
function saveAnomaly(anomalyId, anomaly) {
|
|
|
|
var filename = path.join(config_1.ANOMALIES_PATH, anomalyId + ".json");
|
|
|
|
return json_1.writeJsonDataSync(filename, anomaly);
|
|
|
|
}
|
|
|
|
exports.saveAnomaly = saveAnomaly;
|
|
|
|
function loadAnomalyById(anomalyId) {
|
|
|
|
var 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) {
|
|
|
|
var anomalyId = getAnomalyIdByName(anomalyName);
|
|
|
|
return loadAnomalyById(anomalyId);
|
|
|
|
}
|
|
|
|
exports.loadAnomalyByName = loadAnomalyByName;
|
|
|
|
function saveAnomalyTypeInfo(info) {
|
|
|
|
console.log('Saving');
|
|
|
|
var 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) {
|
|
|
|
var 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) {
|
|
|
|
var info = loadAnomalyById(anomalyId);
|
|
|
|
info.last_prediction_time = lastPredictionTime;
|
|
|
|
saveAnomaly(anomalyId, info);
|
|
|
|
}
|
|
|
|
exports.setAnomalyPredictionTime = setAnomalyPredictionTime;
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 6 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var _stringify = __webpack_require__(2);
|
|
|
|
|
|
|
|
var _stringify2 = _interopRequireDefault(_stringify);
|
|
|
|
|
|
|
|
var _regenerator = __webpack_require__(3);
|
|
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
|
|
var _promise = __webpack_require__(4);
|
|
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = _promise2.default))(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 });
|
|
|
|
var fs = __webpack_require__(9);
|
|
|
|
function getJsonData(filename) {
|
|
|
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee() {
|
|
|
|
var data;
|
|
|
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context.prev = _context.next) {
|
|
|
|
case 0:
|
|
|
|
_context.next = 2;
|
|
|
|
return new _promise2.default(function (resolve, reject) {
|
|
|
|
fs.readFile(filename, 'utf8', function (err, data) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
reject('Can`t read file');
|
|
|
|
} else {
|
|
|
|
resolve(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
data = _context.sent;
|
|
|
|
_context.prev = 3;
|
|
|
|
return _context.abrupt("return", JSON.parse(data));
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
_context.prev = 7;
|
|
|
|
_context.t0 = _context["catch"](3);
|
|
|
|
|
|
|
|
console.error(_context.t0);
|
|
|
|
throw new Error('Wrong file format');
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
case "end":
|
|
|
|
return _context.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee, this, [[3, 7]]);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
exports.getJsonData = getJsonData;
|
|
|
|
function writeJsonData(filename, data) {
|
|
|
|
return new _promise2.default(function (resolve, reject) {
|
|
|
|
fs.writeFile(filename, (0, _stringify2.default)(data), 'utf8', function (err) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
reject('Cat`t write file');
|
|
|
|
} else {
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.writeJsonData = writeJsonData;
|
|
|
|
function getJsonDataSync(filename) {
|
|
|
|
var 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, (0, _stringify2.default)(data));
|
|
|
|
}
|
|
|
|
exports.writeJsonDataSync = writeJsonDataSync;
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 7 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('express');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 8 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('babel-runtime/core-js/get-iterator');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 9 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('fs');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 10 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var _regenerator = __webpack_require__(3);
|
|
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
|
|
var _stringify = __webpack_require__(2);
|
|
|
|
|
|
|
|
var _stringify2 = _interopRequireDefault(_stringify);
|
|
|
|
|
|
|
|
var _promise = __webpack_require__(4);
|
|
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = _promise2.default))(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 });
|
|
|
|
var child_process_1 = __webpack_require__(18);
|
|
|
|
var config_1 = __webpack_require__(1);
|
|
|
|
var anomalyType_1 = __webpack_require__(5);
|
|
|
|
var metrics_1 = __webpack_require__(13);
|
|
|
|
var segments_1 = __webpack_require__(11);
|
|
|
|
var event_stream_1 = __webpack_require__(19);
|
|
|
|
var 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', function (data) {
|
|
|
|
return console.error("worker stderr: " + data);
|
|
|
|
});
|
|
|
|
var taskMap = {};
|
|
|
|
var nextTaskId = 0;
|
|
|
|
function onMessage(data) {
|
|
|
|
console.log("worker stdout: " + data);
|
|
|
|
var response = JSON.parse(data);
|
|
|
|
var taskId = response.__task_id;
|
|
|
|
// let anomalyName = response.anomaly_name;
|
|
|
|
// let task = response.task;
|
|
|
|
var status = response.status;
|
|
|
|
if (status === 'success' || status === 'failed') {
|
|
|
|
if (taskId in taskMap) {
|
|
|
|
var resolver = taskMap[taskId];
|
|
|
|
resolver(response);
|
|
|
|
delete taskMap[taskId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function runTask(task) {
|
|
|
|
var anomaly = anomalyType_1.loadAnomalyById(task.anomaly_id);
|
|
|
|
task.metric = {
|
|
|
|
datasource: anomaly.metric.datasource,
|
|
|
|
targets: anomaly.metric.targets.map(function (t) {
|
|
|
|
return metrics_1.getTarget(t);
|
|
|
|
})
|
|
|
|
};
|
|
|
|
task.__task_id = nextTaskId++;
|
|
|
|
var command = (0, _stringify2.default)(task);
|
|
|
|
learnWorker.stdin.write(command + "\n");
|
|
|
|
return new _promise2.default(function (resolve, reject) {
|
|
|
|
taskMap[task.__task_id] = resolve;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function runLearning(anomalyId) {
|
|
|
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee() {
|
|
|
|
var segments, anomaly, analyticsType, preset, task, result;
|
|
|
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context.prev = _context.next) {
|
|
|
|
case 0:
|
|
|
|
segments = segments_1.getLabeledSegments(anomalyId);
|
|
|
|
|
|
|
|
anomalyType_1.setAnomalyStatus(anomalyId, 'learning');
|
|
|
|
anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
|
|
|
analyticsType = "anomalies";
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
task = {
|
|
|
|
type: 'learn',
|
|
|
|
anomaly_id: anomalyId,
|
|
|
|
analytics_type: analyticsType,
|
|
|
|
preset: preset,
|
|
|
|
segments: segments
|
|
|
|
};
|
|
|
|
_context.next = 11;
|
|
|
|
return runTask(task);
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
result = _context.sent;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
case 13:
|
|
|
|
case "end":
|
|
|
|
return _context.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee, this);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
exports.runLearning = runLearning;
|
|
|
|
function runPredict(anomalyId) {
|
|
|
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
|
|
|
|
var anomaly, analyticsType, preset, task, result, segments, lastOldSegment, firstNewSegment;
|
|
|
|
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context2.prev = _context2.next) {
|
|
|
|
case 0:
|
|
|
|
anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
|
|
|
analyticsType = "anomalies";
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
task = {
|
|
|
|
type: 'predict',
|
|
|
|
anomaly_id: anomalyId,
|
|
|
|
analytics_type: analyticsType,
|
|
|
|
preset: preset,
|
|
|
|
last_prediction_time: anomaly.last_prediction_time
|
|
|
|
};
|
|
|
|
_context2.next = 9;
|
|
|
|
return runTask(task);
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
result = _context2.sent;
|
|
|
|
|
|
|
|
if (!(result.status === 'failed')) {
|
|
|
|
_context2.next = 12;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _context2.abrupt("return", []);
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
// Merging segments
|
|
|
|
segments = segments_1.getLabeledSegments(anomalyId);
|
|
|
|
|
|
|
|
if (segments.length > 0 && result.segments.length > 0) {
|
|
|
|
lastOldSegment = segments[segments.length - 1];
|
|
|
|
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 _context2.abrupt("return", result.segments);
|
|
|
|
|
|
|
|
case 17:
|
|
|
|
case "end":
|
|
|
|
return _context2.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee2, this);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
exports.runPredict = runPredict;
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 11 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var _getIterator2 = __webpack_require__(8);
|
|
|
|
|
|
|
|
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var path = __webpack_require__(0);
|
|
|
|
var json_1 = __webpack_require__(6);
|
|
|
|
var config_1 = __webpack_require__(1);
|
|
|
|
var anomalyType_1 = __webpack_require__(5);
|
|
|
|
function getLabeledSegments(anomalyId) {
|
|
|
|
var filename = path.join(config_1.SEGMENTS_PATH, anomalyId + "_labeled.json");
|
|
|
|
var segments = [];
|
|
|
|
try {
|
|
|
|
segments = json_1.getJsonDataSync(filename);
|
|
|
|
var _iteratorNormalCompletion = true;
|
|
|
|
var _didIteratorError = false;
|
|
|
|
var _iteratorError = undefined;
|
|
|
|
|
|
|
|
try {
|
|
|
|
for (var _iterator = (0, _getIterator3.default)(segments), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
|
|
var segment = _step.value;
|
|
|
|
|
|
|
|
if (segment.labeled === undefined) {
|
|
|
|
segment.labeled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e.message);
|
|
|
|
}
|
|
|
|
return segments;
|
|
|
|
}
|
|
|
|
exports.getLabeledSegments = getLabeledSegments;
|
|
|
|
function getPredictedSegments(anomalyId) {
|
|
|
|
var filename = path.join(config_1.SEGMENTS_PATH, anomalyId + "_segments.json");
|
|
|
|
var jsonData = void 0;
|
|
|
|
try {
|
|
|
|
jsonData = json_1.getJsonDataSync(filename);
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e.message);
|
|
|
|
jsonData = [];
|
|
|
|
}
|
|
|
|
return jsonData;
|
|
|
|
}
|
|
|
|
exports.getPredictedSegments = getPredictedSegments;
|
|
|
|
function saveSegments(anomalyId, segments) {
|
|
|
|
var 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
|
|
|
|
var info = anomalyType_1.loadAnomalyById(anomalyId);
|
|
|
|
var segments = getLabeledSegments(anomalyId);
|
|
|
|
var nextId = info.next_id;
|
|
|
|
var addedIds = [];
|
|
|
|
var _iteratorNormalCompletion2 = true;
|
|
|
|
var _didIteratorError2 = false;
|
|
|
|
var _iteratorError2 = undefined;
|
|
|
|
|
|
|
|
try {
|
|
|
|
for (var _iterator2 = (0, _getIterator3.default)(addedSegments), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
|
|
var segment = _step2.value;
|
|
|
|
|
|
|
|
segment.id = nextId;
|
|
|
|
segment.labeled = labeled;
|
|
|
|
addedIds.push(nextId);
|
|
|
|
nextId++;
|
|
|
|
segments.push(segment);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError2 = true;
|
|
|
|
_iteratorError2 = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
|
|
_iterator2.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError2) {
|
|
|
|
throw _iteratorError2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
info.next_id = nextId;
|
|
|
|
saveSegments(anomalyId, segments);
|
|
|
|
anomalyType_1.saveAnomaly(anomalyId, info);
|
|
|
|
return addedIds;
|
|
|
|
}
|
|
|
|
exports.insertSegments = insertSegments;
|
|
|
|
function removeSegments(anomalyId, removedSegments) {
|
|
|
|
var segments = getLabeledSegments(anomalyId);
|
|
|
|
var _iteratorNormalCompletion3 = true;
|
|
|
|
var _didIteratorError3 = false;
|
|
|
|
var _iteratorError3 = undefined;
|
|
|
|
|
|
|
|
try {
|
|
|
|
var _loop = function _loop() {
|
|
|
|
var segmentId = _step3.value;
|
|
|
|
|
|
|
|
segments = segments.filter(function (el) {
|
|
|
|
return el.id !== segmentId;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
for (var _iterator3 = (0, _getIterator3.default)(removedSegments), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
|
|
_loop();
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError3 = true;
|
|
|
|
_iteratorError3 = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
|
|
|
_iterator3.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError3) {
|
|
|
|
throw _iteratorError3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
saveSegments(anomalyId, segments);
|
|
|
|
}
|
|
|
|
exports.removeSegments = removeSegments;
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 12 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('crypto');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 13 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var _stringify = __webpack_require__(2);
|
|
|
|
|
|
|
|
var _stringify2 = _interopRequireDefault(_stringify);
|
|
|
|
|
|
|
|
var _getIterator2 = __webpack_require__(8);
|
|
|
|
|
|
|
|
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var path = __webpack_require__(0);
|
|
|
|
var json_1 = __webpack_require__(6);
|
|
|
|
var config_1 = __webpack_require__(1);
|
|
|
|
var crypto = __webpack_require__(12);
|
|
|
|
function saveTargets(targets) {
|
|
|
|
var metrics = [];
|
|
|
|
var _iteratorNormalCompletion = true;
|
|
|
|
var _didIteratorError = false;
|
|
|
|
var _iteratorError = undefined;
|
|
|
|
|
|
|
|
try {
|
|
|
|
for (var _iterator = (0, _getIterator3.default)(targets), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
|
|
var target = _step.value;
|
|
|
|
|
|
|
|
metrics.push(saveTarget(target));
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return metrics;
|
|
|
|
}
|
|
|
|
exports.saveTargets = saveTargets;
|
|
|
|
function saveTarget(target) {
|
|
|
|
//const md5 = crypto.createHash('md5')
|
|
|
|
var targetId = crypto.createHash('md5').update((0, _stringify2.default)(target)).digest('hex');
|
|
|
|
var filename = path.join(config_1.METRICS_PATH, targetId + ".json");
|
|
|
|
json_1.writeJsonDataSync(filename, target);
|
|
|
|
return targetId;
|
|
|
|
}
|
|
|
|
function getTarget(targetId) {
|
|
|
|
var filename = path.join(config_1.METRICS_PATH, targetId + ".json");
|
|
|
|
return json_1.getJsonDataSync(filename);
|
|
|
|
}
|
|
|
|
exports.getTarget = getTarget;
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 14 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var _getIterator2 = __webpack_require__(8);
|
|
|
|
|
|
|
|
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
//import * as Telegraf from 'telegraf'
|
|
|
|
var path = __webpack_require__(0);
|
|
|
|
var config_1 = __webpack_require__(1);
|
|
|
|
var json_1 = __webpack_require__(6);
|
|
|
|
function sendNotification(anomalyName, active) {
|
|
|
|
console.log('Notification ' + anomalyName);
|
|
|
|
if (anomalyName in botConfig.subscriptions) {
|
|
|
|
var notificationMessage = void 0;
|
|
|
|
if (active) {
|
|
|
|
notificationMessage = 'Alert! Anomaly type ' + anomalyName;
|
|
|
|
} else {
|
|
|
|
notificationMessage = 'Ok! Anomaly type ' + anomalyName;
|
|
|
|
}
|
|
|
|
var _iteratorNormalCompletion = true;
|
|
|
|
var _didIteratorError = false;
|
|
|
|
var _iteratorError = undefined;
|
|
|
|
|
|
|
|
try {
|
|
|
|
for (var _iterator = (0, _getIterator3.default)(botConfig.subscriptions[anomalyName]), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
|
|
var SubscriberId = _step.value;
|
|
|
|
|
|
|
|
bot.telegram.sendMessage(SubscriberId, notificationMessage);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError) {
|
|
|
|
throw _iteratorError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.sendNotification = sendNotification;
|
|
|
|
function loadBotConfig() {
|
|
|
|
var filename = path.join(config_1.DATA_PATH, "bot_config.json");
|
|
|
|
var jsonData = void 0;
|
|
|
|
try {
|
|
|
|
jsonData = json_1.getJsonDataSync(filename);
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e.message);
|
|
|
|
jsonData = [];
|
|
|
|
}
|
|
|
|
return jsonData;
|
|
|
|
}
|
|
|
|
function saveBotConfig(botConfig) {
|
|
|
|
var filename = path.join(config_1.DATA_PATH, "bot_config.json");
|
|
|
|
try {
|
|
|
|
json_1.writeJsonDataSync(filename, botConfig);
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var commandArgs = function commandArgs(ctx, next) {
|
|
|
|
try {
|
|
|
|
if (ctx.updateType === 'message') {
|
|
|
|
var text = ctx.update.message.text;
|
|
|
|
if (text !== undefined && text.startsWith('/')) {
|
|
|
|
var match = text.match(/^\/([^\s]+)\s?(.+)?/);
|
|
|
|
var args = [];
|
|
|
|
var command = void 0;
|
|
|
|
if (match !== null) {
|
|
|
|
if (match[1]) {
|
|
|
|
command = match[1];
|
|
|
|
}
|
|
|
|
if (match[2]) {
|
|
|
|
args = match[2].split(' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctx.state.command = {
|
|
|
|
raw: text,
|
|
|
|
command: command,
|
|
|
|
args: args
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return next(ctx);
|
|
|
|
} catch (e) {}
|
|
|
|
};
|
|
|
|
function addNotification(ctx) {
|
|
|
|
console.log('addNotification');
|
|
|
|
var command = ctx.state.command;
|
|
|
|
var chatId = ctx.chat.id;
|
|
|
|
if (command.args.length > 0) {
|
|
|
|
var _iteratorNormalCompletion2 = true;
|
|
|
|
var _didIteratorError2 = false;
|
|
|
|
var _iteratorError2 = undefined;
|
|
|
|
|
|
|
|
try {
|
|
|
|
for (var _iterator2 = (0, _getIterator3.default)(command.args), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
|
|
var anomalyName = _step2.value;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError2 = true;
|
|
|
|
_iteratorError2 = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
|
|
_iterator2.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError2) {
|
|
|
|
throw _iteratorError2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
var command = ctx.state.command;
|
|
|
|
var chatId = ctx.chat.id;
|
|
|
|
if (command.args.length > 0) {
|
|
|
|
var _iteratorNormalCompletion3 = true;
|
|
|
|
var _didIteratorError3 = false;
|
|
|
|
var _iteratorError3 = undefined;
|
|
|
|
|
|
|
|
try {
|
|
|
|
for (var _iterator3 = (0, _getIterator3.default)(command.args), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
|
|
var anomalyName = _step3.value;
|
|
|
|
|
|
|
|
if (anomalyName in botConfig.subscriptions) {
|
|
|
|
botConfig.subscriptions[anomalyName] = botConfig.subscriptions[anomalyName].filter(function (el) {
|
|
|
|
return el !== chatId;
|
|
|
|
});
|
|
|
|
saveBotConfig(botConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
_didIteratorError3 = true;
|
|
|
|
_iteratorError3 = err;
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
|
|
|
_iterator3.return();
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (_didIteratorError3) {
|
|
|
|
throw _iteratorError3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 = require('telegraf');
|
|
|
|
var botConfig = void 0;
|
|
|
|
var bot = void 0;
|
|
|
|
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;
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 15 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var express = __webpack_require__(7);
|
|
|
|
var bodyParser = __webpack_require__(16);
|
|
|
|
var anomalies_1 = __webpack_require__(17);
|
|
|
|
var segments_1 = __webpack_require__(20);
|
|
|
|
var alerts_1 = __webpack_require__(21);
|
|
|
|
var notification_1 = __webpack_require__(14);
|
|
|
|
var app = express();
|
|
|
|
var 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('/', function (req, res) {
|
|
|
|
return res.send({ status: 'OK' });
|
|
|
|
});
|
|
|
|
app.listen(PORT, function () {
|
|
|
|
console.log("Server is running on :" + PORT);
|
|
|
|
});
|
|
|
|
notification_1.tgBotInit();
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 16 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('body-parser');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 17 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var _stringify = __webpack_require__(2);
|
|
|
|
|
|
|
|
var _stringify2 = _interopRequireDefault(_stringify);
|
|
|
|
|
|
|
|
var _regenerator = __webpack_require__(3);
|
|
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
|
|
var _promise = __webpack_require__(4);
|
|
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = _promise2.default))(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 });
|
|
|
|
var express = __webpack_require__(7);
|
|
|
|
var anomalyType_1 = __webpack_require__(5);
|
|
|
|
var analytics_1 = __webpack_require__(10);
|
|
|
|
var metrics_1 = __webpack_require__(13);
|
|
|
|
function sendAnomalyTypeStatus(req, res) {
|
|
|
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee() {
|
|
|
|
var id, name, anomaly;
|
|
|
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context.prev = _context.next) {
|
|
|
|
case 0:
|
|
|
|
id = req.query.id;
|
|
|
|
name = req.query.name;
|
|
|
|
_context.prev = 2;
|
|
|
|
anomaly = void 0;
|
|
|
|
|
|
|
|
if (id !== undefined) {
|
|
|
|
anomaly = anomalyType_1.loadAnomalyById(id);
|
|
|
|
} else {
|
|
|
|
anomaly = anomalyType_1.loadAnomalyByName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(anomaly === null)) {
|
|
|
|
_context.next = 8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
res.status(404).send({
|
|
|
|
code: 404,
|
|
|
|
message: 'Not found'
|
|
|
|
});
|
|
|
|
return _context.abrupt("return");
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
if (!(anomaly.status === undefined)) {
|
|
|
|
_context.next = 10;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('No status for ' + name);
|
|
|
|
|
|
|
|
case 10:
|
|
|
|
res.status(200).send({ status: anomaly.status, errorMessage: anomaly.error });
|
|
|
|
_context.next = 17;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 13:
|
|
|
|
_context.prev = 13;
|
|
|
|
_context.t0 = _context["catch"](2);
|
|
|
|
|
|
|
|
console.error(_context.t0);
|
|
|
|
// TODO: better send 404 when we know than isn`t found
|
|
|
|
res.status(500).send({ error: 'Can`t return anything' });
|
|
|
|
|
|
|
|
case 17:
|
|
|
|
case "end":
|
|
|
|
return _context.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee, this, [[2, 13]]);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
function getAnomaly(req, res) {
|
|
|
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
|
|
|
|
var id, name, anomaly, payload;
|
|
|
|
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context2.prev = _context2.next) {
|
|
|
|
case 0:
|
|
|
|
_context2.prev = 0;
|
|
|
|
id = req.query.id;
|
|
|
|
name = req.query.name;
|
|
|
|
anomaly = void 0;
|
|
|
|
|
|
|
|
if (id !== undefined) {
|
|
|
|
anomaly = anomalyType_1.loadAnomalyById(id);
|
|
|
|
} else {
|
|
|
|
anomaly = anomalyType_1.loadAnomalyByName(name.toLowerCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(anomaly === null)) {
|
|
|
|
_context2.next = 8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
res.status(404).send({
|
|
|
|
code: 404,
|
|
|
|
message: 'Not found'
|
|
|
|
});
|
|
|
|
return _context2.abrupt("return");
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
payload = (0, _stringify2.default)({
|
|
|
|
name: anomaly.name,
|
|
|
|
metric: anomaly.metric,
|
|
|
|
status: anomaly.status
|
|
|
|
});
|
|
|
|
|
|
|
|
res.status(200).send(payload);
|
|
|
|
_context2.next = 16;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
_context2.prev = 12;
|
|
|
|
_context2.t0 = _context2["catch"](0);
|
|
|
|
|
|
|
|
console.error(_context2.t0);
|
|
|
|
// TODO: better send 404 when we know than isn`t found
|
|
|
|
res.status(500).send('Can`t get anything');
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
case "end":
|
|
|
|
return _context2.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee2, this, [[0, 12]]);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
function createAnomaly(req, res) {
|
|
|
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
|
|
|
|
var metric, anomaly, anomalyId, payload;
|
|
|
|
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context3.prev = _context3.next) {
|
|
|
|
case 0:
|
|
|
|
try {
|
|
|
|
metric = {
|
|
|
|
datasource: req.body.metric.datasource,
|
|
|
|
targets: metrics_1.saveTargets(req.body.metric.targets)
|
|
|
|
};
|
|
|
|
anomaly = {
|
|
|
|
name: req.body.name,
|
|
|
|
panelUrl: req.body.panelUrl,
|
|
|
|
metric: metric,
|
|
|
|
datasource: req.body.datasource,
|
|
|
|
status: 'learning',
|
|
|
|
last_prediction_time: 0,
|
|
|
|
next_id: 0
|
|
|
|
};
|
|
|
|
anomalyId = anomalyType_1.insertAnomaly(anomaly);
|
|
|
|
|
|
|
|
if (anomalyId === null) {
|
|
|
|
res.status(403).send({
|
|
|
|
code: 403,
|
|
|
|
message: 'Already exists'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
payload = (0, _stringify2.default)({ anomaly_id: anomalyId });
|
|
|
|
|
|
|
|
res.status(200).send(payload);
|
|
|
|
analytics_1.runLearning(anomalyId);
|
|
|
|
} catch (e) {
|
|
|
|
res.status(500).send({
|
|
|
|
code: 500,
|
|
|
|
message: 'Internal error'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case "end":
|
|
|
|
return _context3.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee3, this);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
function deleteAnomaly(req, res) {
|
|
|
|
try {
|
|
|
|
var id = req.query.id;
|
|
|
|
var 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);
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 18 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('child_process');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 19 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('event-stream');
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 20 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var _regenerator = __webpack_require__(3);
|
|
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
|
|
var _stringify = __webpack_require__(2);
|
|
|
|
|
|
|
|
var _stringify2 = _interopRequireDefault(_stringify);
|
|
|
|
|
|
|
|
var _promise = __webpack_require__(4);
|
|
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = _promise2.default))(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 });
|
|
|
|
var express = __webpack_require__(7);
|
|
|
|
var segments_1 = __webpack_require__(11);
|
|
|
|
var analytics_1 = __webpack_require__(10);
|
|
|
|
var anomalyType_1 = __webpack_require__(5);
|
|
|
|
function sendSegments(req, res) {
|
|
|
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee() {
|
|
|
|
var anomalyId, anomaly, lastSegmentId, timeFrom, timeTo, segments, payload;
|
|
|
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context.prev = _context.next) {
|
|
|
|
case 0:
|
|
|
|
try {
|
|
|
|
anomalyId = req.query.anomaly_id;
|
|
|
|
anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
|
|
|
|
|
|
|
if (anomaly === null) {
|
|
|
|
anomalyId = anomalyType_1.getAnomalyIdByName(anomalyId);
|
|
|
|
}
|
|
|
|
lastSegmentId = req.query.last_segment;
|
|
|
|
timeFrom = req.query.from;
|
|
|
|
timeTo = req.query.to;
|
|
|
|
segments = segments_1.getLabeledSegments(anomalyId);
|
|
|
|
// Id filtering
|
|
|
|
|
|
|
|
if (lastSegmentId !== undefined) {
|
|
|
|
segments = segments.filter(function (el) {
|
|
|
|
return el.id > lastSegmentId;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// Time filtering
|
|
|
|
if (timeFrom !== undefined) {
|
|
|
|
segments = segments.filter(function (el) {
|
|
|
|
return el.finish > timeFrom;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (timeTo !== undefined) {
|
|
|
|
segments = segments.filter(function (el) {
|
|
|
|
return el.start < timeTo;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
payload = (0, _stringify2.default)({
|
|
|
|
segments: segments
|
|
|
|
});
|
|
|
|
|
|
|
|
res.status(200).send(payload);
|
|
|
|
} catch (e) {
|
|
|
|
res.status(500).send({
|
|
|
|
code: 500,
|
|
|
|
message: 'Internal error'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case "end":
|
|
|
|
return _context.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee, this);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
function updateSegments(req, res) {
|
|
|
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
|
|
|
|
var segmentsUpdate, anomalyId, anomalyName, addedIds, payload;
|
|
|
|
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context2.prev = _context2.next) {
|
|
|
|
case 0:
|
|
|
|
try {
|
|
|
|
segmentsUpdate = req.body;
|
|
|
|
anomalyId = segmentsUpdate.anomaly_id;
|
|
|
|
anomalyName = segmentsUpdate.name;
|
|
|
|
|
|
|
|
if (anomalyId === undefined) {
|
|
|
|
anomalyId = anomalyType_1.getAnomalyIdByName(anomalyName.toLowerCase());
|
|
|
|
}
|
|
|
|
addedIds = segments_1.insertSegments(anomalyId, segmentsUpdate.added_segments, true);
|
|
|
|
|
|
|
|
segments_1.removeSegments(anomalyId, segmentsUpdate.removed_segments);
|
|
|
|
payload = (0, _stringify2.default)({ added_ids: addedIds });
|
|
|
|
|
|
|
|
res.status(200).send(payload);
|
|
|
|
analytics_1.runLearning(anomalyId);
|
|
|
|
} catch (e) {
|
|
|
|
res.status(500).send({
|
|
|
|
code: 500,
|
|
|
|
message: 'Internal error'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case "end":
|
|
|
|
return _context2.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee2, this);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
exports.router = express.Router();
|
|
|
|
exports.router.get('/', sendSegments);
|
|
|
|
exports.router.patch('/', updateSegments);
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 21 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var express = __webpack_require__(7);
|
|
|
|
var anomalyType_1 = __webpack_require__(5);
|
|
|
|
var alerts_1 = __webpack_require__(22);
|
|
|
|
function getAlert(req, res) {
|
|
|
|
try {
|
|
|
|
var anomalyId = req.query.anomaly_id;
|
|
|
|
var anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
|
|
|
if (anomaly == null) {
|
|
|
|
anomalyId = anomalyType_1.getAnomalyIdByName(anomalyId.toLowerCase());
|
|
|
|
}
|
|
|
|
var alertsAnomalies = alerts_1.getAlertsAnomalies();
|
|
|
|
var pos = alertsAnomalies.indexOf(anomalyId);
|
|
|
|
var enable = pos !== -1;
|
|
|
|
res.status(200).send({
|
|
|
|
enable: enable
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
res.status(500).send({
|
|
|
|
code: 500,
|
|
|
|
message: 'Internal error'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function changeAlert(req, res) {
|
|
|
|
try {
|
|
|
|
var anomalyId = req.body.anomaly_id;
|
|
|
|
var enable = req.body.enable;
|
|
|
|
var anomaly = anomalyType_1.loadAnomalyById(anomalyId);
|
|
|
|
if (anomaly == null) {
|
|
|
|
anomalyId = anomalyType_1.getAnomalyIdByName(anomalyId.toLowerCase());
|
|
|
|
}
|
|
|
|
var alertsAnomalies = alerts_1.getAlertsAnomalies();
|
|
|
|
var 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);
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 22 */
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
var _set = __webpack_require__(23);
|
|
|
|
|
|
|
|
var _set2 = _interopRequireDefault(_set);
|
|
|
|
|
|
|
|
var _regenerator = __webpack_require__(3);
|
|
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
|
|
var _getIterator2 = __webpack_require__(8);
|
|
|
|
|
|
|
|
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
|
|
|
|
|
|
|
var _promise = __webpack_require__(4);
|
|
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = _promise2.default))(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 });
|
|
|
|
var json_1 = __webpack_require__(6);
|
|
|
|
var path = __webpack_require__(0);
|
|
|
|
var fs = __webpack_require__(9);
|
|
|
|
var config_1 = __webpack_require__(1);
|
|
|
|
var analytics_1 = __webpack_require__(10);
|
|
|
|
var notification_1 = __webpack_require__(14);
|
|
|
|
var segments_1 = __webpack_require__(11);
|
|
|
|
function getAlertsAnomalies() {
|
|
|
|
var 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) {
|
|
|
|
var segments = segments_1.getLabeledSegments(anomalyId);
|
|
|
|
var currentTime = new Date().getTime();
|
|
|
|
var activeAlert = activeAlerts.has(anomalyId);
|
|
|
|
var newActiveAlert = false;
|
|
|
|
if (segments.length > 0) {
|
|
|
|
var 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, /*#__PURE__*/_regenerator2.default.mark(function _callee() {
|
|
|
|
var alertsAnomalies, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, anomalyId;
|
|
|
|
|
|
|
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context.prev = _context.next) {
|
|
|
|
case 0:
|
|
|
|
alertsAnomalies = getAlertsAnomalies();
|
|
|
|
_iteratorNormalCompletion = true;
|
|
|
|
_didIteratorError = false;
|
|
|
|
_iteratorError = undefined;
|
|
|
|
_context.prev = 4;
|
|
|
|
_iterator = (0, _getIterator3.default)(alertsAnomalies);
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
|
|
|
_context.next = 20;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
anomalyId = _step.value;
|
|
|
|
_context.prev = 8;
|
|
|
|
_context.next = 11;
|
|
|
|
return analytics_1.runPredict(anomalyId);
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
processAlerts(anomalyId);
|
|
|
|
_context.next = 17;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 14:
|
|
|
|
_context.prev = 14;
|
|
|
|
_context.t0 = _context["catch"](8);
|
|
|
|
|
|
|
|
console.error(_context.t0);
|
|
|
|
|
|
|
|
case 17:
|
|
|
|
_iteratorNormalCompletion = true;
|
|
|
|
_context.next = 6;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 20:
|
|
|
|
_context.next = 26;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 22:
|
|
|
|
_context.prev = 22;
|
|
|
|
_context.t1 = _context["catch"](4);
|
|
|
|
_didIteratorError = true;
|
|
|
|
_iteratorError = _context.t1;
|
|
|
|
|
|
|
|
case 26:
|
|
|
|
_context.prev = 26;
|
|
|
|
_context.prev = 27;
|
|
|
|
|
|
|
|
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
|
|
_iterator.return();
|
|
|
|
}
|
|
|
|
|
|
|
|
case 29:
|
|
|
|
_context.prev = 29;
|
|
|
|
|
|
|
|
if (!_didIteratorError) {
|
|
|
|
_context.next = 32;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw _iteratorError;
|
|
|
|
|
|
|
|
case 32:
|
|
|
|
return _context.finish(29);
|
|
|
|
|
|
|
|
case 33:
|
|
|
|
return _context.finish(26);
|
|
|
|
|
|
|
|
case 34:
|
|
|
|
setTimeout(alertsTick, 5000);
|
|
|
|
|
|
|
|
case 35:
|
|
|
|
case "end":
|
|
|
|
return _context.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee, this, [[4, 22, 26, 34], [8, 14], [27,, 29, 33]]);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
var alertTimeout = 60000; // ms
|
|
|
|
var activeAlerts = new _set2.default();
|
|
|
|
setTimeout(alertsTick, 5000);
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 23 */
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
module.exports = require('babel-runtime/core-js/set');
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
/******/ ]);
|
|
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgYzlmZDEyYzlhZTkzOWY1OTYyMmIiLCJ3ZWJwYWNrOi8vL2V4dGVybmFsIFwicmVxdWlyZSgncGF0aCcpXCIiLCJ3ZWJwYWNrOi8vLy4vY29uZmlnLnRzIiwid2VicGFjazovLy9leHRlcm5hbCBcInJlcXVpcmUoJ2JhYmVsLXJ1bnRpbWUvY29yZS1qcy9qc29uL3N0cmluZ2lmeScpXCIiLCJ3ZWJwYWNrOi8vL2V4dGVybmFsIFwicmVxdWlyZSgnYmFiZWwtcnVudGltZS9yZWdlbmVyYXRvcicpXCIiLCJ3ZWJwYWNrOi8vL2V4dGVybmFsIFwicmVxdWlyZSgnYmFiZWwtcnVudGltZS9jb3JlLWpzL3Byb21pc2UnKVwiIiwid2VicGFjazovLy8uL3NlcnZpY2VzL2Fub21hbHlUeXBlLnRzIiwid2VicGFjazovLy8uL3NlcnZpY2VzL2pzb24udHMiLCJ3ZWJwYWNrOi8vL2V4dGVybmFsIFwicmVxdWlyZSgnZXhwcmVzcycpXCIiLCJ3ZWJwYWNrOi8vL2V4dGVybmFsIFwicmVxdWlyZSgnYmFiZWwtcnVudGltZS9jb3JlLWpzL2dldC1pdGVyYXRvcicpXCIiLCJ3ZWJwYWNrOi8vL2V4dGVybmFsIFwicmVxdWlyZSgnZnMnKVwiIiwid2VicGFjazovLy8uL3NlcnZpY2VzL2FuYWx5dGljcy50cyIsIndlYnBhY2s6Ly8vLi9zZXJ2aWNlcy9zZWdtZW50cy50cyIsIndlYnBhY2s6Ly8vZXh0ZXJuYWwgXCJyZXF1aXJlKCdjcnlwdG8nKVwiIiwid2VicGFjazovLy8uL3NlcnZpY2VzL21ldHJpY3MudHMiLCJ3ZWJwYWNrOi8vLy4vc2VydmljZXMvbm90aWZpY2F0aW9uLnRzIiwid2VicGFjazovLy8uL2luZGV4LnRzIiwid2VicGFjazovLy9leHRlcm5hbCBcInJlcXVpcmUoJ2JvZHktcGFyc2VyJylcIiIsIndlYnBhY2s6Ly8vLi9yb3V0ZXMvYW5vbWFsaWVzLnRzIiwid2VicGFjazovLy9leHRlcm5hbCBcInJlcXVpcmUoJ2NoaWxkX3Byb2Nlc3MnKVwiIiwid2VicGFjazovLy9leHRlcm5hbCBcInJlcXVpcmUoJ2V2ZW50LXN0cmVhbScpXCIiLCJ3ZWJwYWNrOi8vLy4vcm91dGVzL3NlZ21lbnRzLnRzIiwid2VicGFjazovLy8uL3JvdXRlcy9hbGVydHMudHMiLCJ3ZWJwYWNrOi8vLy4vc2VydmljZXMvYWxlcnRzLnRzIiwid2VicGFjazovLy9leHRlcm5hbCBcInJlcXVpcmUoJ2JhYmVsLXJ1bnRpbWUvY29yZS1qcy9zZXQnKVwiIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxvREFBNEM7QUFDNUM7QUFDQTtBQUNBOztBQUVBLDBDQUFrQztBQUNsQztBQUNBO0FBQ0EsWUFBSTtBQUNKO0FBQ0E7QUFDQTtBQUNBOztBQUVBLDZDQUFxQztBQUNyQztBQUNBOzs7O0FBSUE7QUFDQSxzREFBOEM7QUFDOUM7QUFDQTtBQUNBLG9DQUE0QjtBQUM1QixxQ0FBNkI7QUFDN0IseUNBQWlDOztBQUVqQywrQ0FBdUM7QUFDdkM7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxjQUFNO0FBQ047QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLGFBQUs7QUFDTDtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsY0FBTTtBQUNOO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxhQUFLOztBQUVMO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUEsOENBQXNDO0FBQ3RDO0FBQ0E7QUFDQSxxQ0FBNkI7QUFDN0IscUNBQTZCO0FBQzdCO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSw0QkFBb0IsZ0JBQWdCO0FBQ3BDO0FBQ0E7QUFDQTtBQUNBLGFBQUs7QUFDTDtBQUNBO0FBQ0E7QUFDQTtBQUNBLDRCQUFvQixnQkFBZ0I7QUFDcEM7QUFDQTtBQUNBO0FBQ0EsYUFBSztBQUNMO0FBQ0E7QUFDQSxhQUFLO0FBQ0w7QUFDQTtBQUNBLGFBQUs7QUFDTDtBQUNBO0FBQ0E7QUFDQSxhQUFLOztBQUVMO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLGFBQUs7QUFDTDtBQUNBO0FBQ0EsYUFBSztBQUNMO0FBQ0E7QUFDQTtBQUNBLGFBQUs7O0FBRUw7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBLHlCQUFpQiw4QkFBOEI7QUFDL0M7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLGFBQUs7QUFDTDtBQUNBO0FBQ0EsYUFBSztBQUNMO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsWUFBSTtBQUNKOztBQUVBLDREQUFvRDtBQUNwRDtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0EsWUFBSTtBQUNKO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLGFBQUs7QUFDTDtBQUNBO0FBQ0EsY0FBTTtBQUNOO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsWUFBSTtBQUNKO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLGFBQUs7QUFDTDtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSwyQkFBbUIsMkJBQTJCO0FBQzlDO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxlQUFPO0FBQ1A7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUF
|