kibana/x-pack/plugins/security_solution/common/machine_learning/helpers.ts
Frank Hassanabad 2f017b0e85
[Security Solution][Detection Engine] Remove RuleTypeSchema in favor of Type for TypeScript (#76586)
## Summary

Removes RuleTypeSchema in favor of Type for TypeScript. Does break out one function called `parseScheduleDates` into its own file to remove a circular ref issue.
2020-09-02 21:48:41 -06:00

26 lines
1.1 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { Type } from '../detection_engine/schemas/common/schemas';
// Based on ML Job/Datafeed States from x-pack/legacy/plugins/ml/common/constants/states.js
const enabledStates = ['started', 'opened'];
const loadingStates = ['starting', 'stopping', 'opening', 'closing'];
const failureStates = ['deleted', 'failed'];
export const isJobStarted = (jobState: string, datafeedState: string): boolean => {
return enabledStates.includes(jobState) && enabledStates.includes(datafeedState);
};
export const isJobLoading = (jobState: string, datafeedState: string): boolean => {
return loadingStates.includes(jobState) || loadingStates.includes(datafeedState);
};
export const isJobFailed = (jobState: string, datafeedState: string): boolean => {
return failureStates.includes(jobState) || failureStates.includes(datafeedState);
};
export const isMlRule = (ruleType: Type) => ruleType === 'machine_learning';