Merge branch 'INDA-330-pii-update' into 'main'
[ProtonMail-WebClient.git] / packages / sieve / fixtures / v2Complex.ts
blob612d408849c6e5df599914bfbe8e10be4b4fc94b
1 import type { SimpleObject } from '@proton/components/containers/filters/interfaces';
2 import { ConditionComparator, ConditionType, FilterStatement } from '@proton/components/containers/filters/interfaces';
4 const tree = [
5     {
6         List: ['include', 'environment', 'variables', 'relational', 'comparator-i;ascii-numeric', 'spamtest'],
7         Type: 'Require',
8     },
9     {
10         List: ['fileinto', 'imap4flags'],
11         Type: 'Require',
12     },
13     {
14         Text: '# Generated: Do not run this script on spam messages',
15         Type: 'Comment',
16     },
17     {
18         If: {
19             Tests: [
20                 {
21                     Name: 'vnd.proton.spam-threshold',
22                     Keys: ['*'],
23                     Format: null,
24                     Match: {
25                         Type: 'Matches',
26                     },
27                     Type: 'Environment',
28                 },
29                 {
30                     Value: {
31                         Value: '${1}',
32                         Type: 'VariableString',
33                     },
34                     Flags: [],
35                     Format: {
36                         Type: 'ASCIINumeric',
37                     },
38                     Match: {
39                         Comparator: 'ge',
40                         Type: 'GreaterEqualsValue',
41                     },
42                     Type: 'SpamTest',
43                 },
44             ],
45             Type: 'AllOf',
46         },
47         Then: [
48             {
49                 Type: 'Return',
50             },
51         ],
52         Type: 'If',
53     },
54     {
55         Text: '/**\r\n * @type or\r\n * @comparator starts\r\n * @comparator starts\r\n * @comparator ends\r\n * @comparator default\r\n */',
56         Type: 'Comment',
57     },
58     {
59         If: {
60             Tests: [
61                 {
62                     Headers: ['Subject'],
63                     Keys: ['subject*'],
64                     Match: {
65                         Type: 'Matches',
66                     },
67                     Format: {
68                         Type: 'UnicodeCaseMap',
69                     },
70                     Type: 'Header',
71                 },
72                 {
73                     Headers: ['From'],
74                     Keys: ['\\\\*\\\\?\\\\sender\\\\\\\\?\\\\**'],
75                     Match: {
76                         Type: 'Matches',
77                     },
78                     Format: {
79                         Type: 'UnicodeCaseMap',
80                     },
81                     AddressPart: {
82                         Type: 'All',
83                     },
84                     Type: 'Address',
85                 },
86                 {
87                     Headers: ['To', 'Cc', 'Bcc'],
88                     Keys: ['*\\\\*\\\\?\\\\recipient\\\\\\\\?\\\\*'],
89                     Match: {
90                         Type: 'Matches',
91                     },
92                     Format: {
93                         Type: 'UnicodeCaseMap',
94                     },
95                     AddressPart: {
96                         Type: 'All',
97                     },
98                     Type: 'Address',
99                 },
100                 {
101                     Headers: ['X-Attached'],
102                     Type: 'Exists',
103                 },
104             ],
105             Type: 'AnyOf',
106         },
107         Then: [
108             {
109                 Flags: ['\\Seen'],
110                 Type: 'AddFlag',
111             },
112             {
113                 Type: 'Keep',
114             },
115         ],
116         Type: 'If',
117     },
120 const simple: SimpleObject = {
121     Operator: {
122         label: 'Any',
123         value: FilterStatement.ANY,
124     },
125     Conditions: [
126         {
127             Type: {
128                 label: 'Subject',
129                 value: ConditionType.SUBJECT,
130             },
131             Comparator: {
132                 label: 'begins with',
133                 value: ConditionComparator.STARTS,
134             },
135             Values: ['subject'],
136         },
137         {
138             Type: {
139                 label: 'Sender',
140                 value: ConditionType.SENDER,
141             },
142             Comparator: {
143                 label: 'begins with',
144                 value: ConditionComparator.STARTS,
145             },
146             Values: ['*?\\sender\\?*'],
147         },
148         {
149             Type: {
150                 label: 'Recipient',
151                 value: ConditionType.RECIPIENT,
152             },
153             Comparator: {
154                 label: 'ends with',
155                 value: ConditionComparator.ENDS,
156             },
157             Values: ['*?\\recipient\\?*'],
158         },
159         {
160             Type: {
161                 label: 'Attachments',
162                 value: ConditionType.ATTACHMENTS,
163             },
164             Comparator: {
165                 label: 'contains',
166                 value: ConditionComparator.CONTAINS,
167             },
168             Values: [],
169         },
170     ],
171     Actions: {
172         FileInto: [],
173         Mark: {
174             Read: true,
175             Starred: false,
176         },
177     },
180 export default { tree, simple };