1 import type { Annotation } from 'codemirror/addon/lint/lint';
3 export enum FilterStatement {
8 export enum ConditionType {
12 RECIPIENT = 'recipient',
13 ATTACHMENTS = 'attachments',
16 export enum ConditionComparator {
17 CONTAINS = 'contains',
23 DOES_NOT_CONTAIN = '!contains',
24 DOES_NOT_START = '!starts',
25 DOES_NOT_END = '!ends',
26 DOES_NOT_MATCH = '!matches',
29 export const ConditionComparatorMap = new Map<ConditionComparator, ConditionComparator>([
30 [ConditionComparator.CONTAINS, ConditionComparator.DOES_NOT_CONTAIN],
31 [ConditionComparator.ENDS, ConditionComparator.DOES_NOT_END],
32 [ConditionComparator.MATCHES, ConditionComparator.DOES_NOT_MATCH],
33 [ConditionComparator.STARTS, ConditionComparator.DOES_NOT_START],
34 [ConditionComparator.IS, ConditionComparator.IS_NOT],
37 //Map the opposite to it's positive comparator
38 export const ConditionComparatorInvertedMap = new Map<ConditionComparator, ConditionComparator>();
39 ConditionComparatorMap.forEach((value, key) => ConditionComparatorInvertedMap.set(value, key));
41 /* Simple Modal Filter Model interfaces */
50 export interface Errors {
56 export interface Actions {
70 autoReply: string | null;
74 export interface Condition {
76 comparator: ConditionComparator;
81 defaultValue?: string;
84 export interface FilterModalModelBase {
91 export interface SimpleFilterModalModel extends FilterModalModelBase {
93 statement: FilterStatement;
95 conditions: Condition[];
99 export interface ErrorsSieve {
104 export interface AdvancedSimpleFilterModalModel extends FilterModalModelBase {
106 issues: Annotation[];
109 /* Expected API Format */
111 export interface FilterOperator {
113 value: FilterStatement;
116 export interface FilterRedirect {
121 export interface FilterActions {
127 Vacation?: string | null;
128 Redirects?: FilterRedirect[];
131 export interface FilterCondition {
133 value: ConditionComparator;
137 value: ConditionType;
143 export interface SimpleObject {
144 Operator: FilterOperator;
145 Conditions: FilterCondition[];
146 Actions: FilterActions;
149 export interface Filter {
155 Simple?: SimpleObject;
160 export type CreateFilter = Omit<Filter, 'Priority'>;