/
types.ts
102 lines (87 loc) · 2.86 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* 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 { ActionGroup } from '../../alerting/common';
import { ActionType } from '../../actions/common';
import { TypeRegistry } from './application/type_registry';
import {
SanitizedAlert as Alert,
AlertAction,
AlertTaskState,
RawAlertInstance,
} from '../../../plugins/alerting/common';
export { Alert, AlertAction, AlertTaskState, RawAlertInstance };
export { ActionType };
export type ActionTypeIndex = Record<string, ActionType>;
export type AlertTypeIndex = Record<string, AlertType>;
export type ActionTypeRegistryContract = PublicMethodsOf<TypeRegistry<ActionTypeModel>>;
export type AlertTypeRegistryContract = PublicMethodsOf<TypeRegistry<AlertTypeModel>>;
export interface ActionConnectorFieldsProps<TActionCOnnector> {
action: TActionCOnnector;
editActionConfig: (property: string, value: any) => void;
editActionSecrets: (property: string, value: any) => void;
errors: { [key: string]: string[] };
}
export interface ActionParamsProps<TParams> {
actionParams: TParams;
index: number;
editAction: (property: string, value: any, index: number) => void;
errors: { [key: string]: string[] };
messageVariables?: string[];
defaultMessage?: string;
}
export interface Pagination {
index: number;
size: number;
}
export interface ActionTypeModel {
id: string;
iconClass: string;
selectMessage: string;
actionTypeTitle?: string;
validateConnector: (connector: any) => ValidationResult;
validateParams: (actionParams: any) => ValidationResult;
actionConnectorFields: React.FunctionComponent<any> | null;
actionParamsFields: any;
}
export interface ValidationResult {
errors: Record<string, any>;
}
export interface ActionConnector {
secrets: Record<string, any>;
id: string;
actionTypeId: string;
name: string;
referencedByCount?: number;
config: Record<string, any>;
}
export type ActionConnectorWithoutId = Omit<ActionConnector, 'id'>;
export interface ActionConnectorTableItem extends ActionConnector {
actionType: ActionType['name'];
}
export interface AlertType {
id: string;
name: string;
actionGroups: ActionGroup[];
actionVariables: string[];
defaultActionGroupId: ActionGroup['id'];
}
export type SanitizedAlertType = Omit<AlertType, 'apiKey'>;
export type AlertWithoutId = Omit<Alert, 'id'>;
export interface AlertTableItem extends Alert {
alertType: AlertType['name'];
tagsText: string;
}
export interface AlertTypeModel {
id: string;
name: string;
iconClass: string;
validate: (alertParams: any) => ValidationResult;
alertParamsExpression: React.FunctionComponent<any>;
defaultActionMessage?: string;
}
export interface IErrorObject {
[key: string]: string[];
}