1
- import { Expose , Type } from 'class-transformer' ;
2
- import {
3
- IsBoolean ,
4
- IsEnum ,
5
- IsObject ,
6
- IsOptional ,
7
- IsSemVer ,
8
- IsString ,
9
- IsUrl ,
10
- ValidateNested ,
11
- } from 'class-validator' ;
12
-
13
1
import {
14
2
CompatibilityValue ,
15
3
InjectInto ,
@@ -21,230 +9,164 @@ import {
21
9
StrictHeadersProps ,
22
10
SwitchValue ,
23
11
} from '../../types' ;
12
+ import { MutuallyExclusive } from '../../utils' ;
13
+ import {
14
+ IsEnumValue ,
15
+ IsMultiValue ,
16
+ IsNamedValue ,
17
+ IsNestedValue ,
18
+ IsRequiredValue ,
19
+ IsSingleValue ,
20
+ IsSwitchValue ,
21
+ IsURLValue ,
22
+ IsVersionValue ,
23
+ } from './decorators' ;
24
24
25
25
class Compatibility implements CompatibilityValue {
26
26
[ x : string ] : SingleValue ;
27
27
28
- @Expose ( )
29
- @IsOptional ( )
30
- @IsString ( )
31
- public readonly firefox ?: string ;
32
-
33
- @Expose ( )
34
- @IsOptional ( )
35
- @IsString ( )
36
- public readonly chrome ?: string ;
37
-
38
- @Expose ( )
39
- @IsOptional ( )
40
- @IsString ( )
41
- public readonly opera ?: string ;
42
-
43
- @Expose ( )
44
- @IsOptional ( )
45
- @IsString ( )
46
- public readonly safari ?: string ;
47
-
48
- @Expose ( )
49
- @IsOptional ( )
50
- @IsString ( )
51
- public readonly edge ?: string ;
28
+ @IsSingleValue ( )
29
+ public readonly firefox ?: SingleValue ;
30
+
31
+ @IsSingleValue ( )
32
+ public readonly chrome ?: SingleValue ;
33
+
34
+ @IsSingleValue ( )
35
+ public readonly opera ?: SingleValue ;
36
+
37
+ @IsSingleValue ( )
38
+ public readonly safari ?: SingleValue ;
39
+
40
+ @IsSingleValue ( )
41
+ public readonly edge ?: SingleValue ;
52
42
}
53
43
54
44
export class Headers implements StrictHeadersProps {
55
- @Expose ( )
56
- @IsString ( )
45
+ @IsRequiredValue ( )
57
46
public readonly name ! : SingleValue ;
58
47
59
- @Expose ( )
60
- @IsOptional ( )
61
- @IsSemVer ( )
48
+ @IsVersionValue ( )
62
49
public readonly version ?: SingleValue ;
63
50
64
- @Expose ( )
65
- @IsOptional ( )
66
- @IsString ( )
51
+ @IsSingleValue ( )
67
52
public readonly namespace ?: SingleValue ;
68
53
69
- @Expose ( )
70
- @IsOptional ( )
71
- @IsString ( )
54
+ @IsSingleValue ( )
72
55
public readonly author ?: SingleValue ;
73
56
74
- @Expose ( )
75
- @IsOptional ( )
76
- @IsString ( )
57
+ @IsSingleValue ( )
77
58
public readonly description ?: SingleValue ;
78
59
79
- @Expose ( )
80
- @IsOptional ( )
81
- @IsUrl ( )
60
+ @IsURLValue ( )
61
+ @MutuallyExclusive ( 'homepage' )
82
62
public readonly homepage ?: SingleValue ;
83
63
84
- @Expose ( )
85
- @IsOptional ( )
86
- @IsUrl ( )
64
+ @IsURLValue ( )
65
+ @MutuallyExclusive ( 'homepage' )
87
66
public readonly homepageURL ?: SingleValue ;
88
67
89
- @Expose ( )
90
- @IsOptional ( )
91
- @IsUrl ( )
68
+ @IsURLValue ( )
69
+ @MutuallyExclusive ( 'homepage' )
92
70
public readonly website ?: SingleValue ;
93
71
94
- @Expose ( )
95
- @IsOptional ( )
96
- @IsUrl ( )
72
+ @IsURLValue ( )
73
+ @MutuallyExclusive ( 'homepage' )
97
74
public readonly source ?: SingleValue ;
98
75
99
- @Expose ( )
100
- @IsOptional ( )
101
- @IsUrl ( )
76
+ @IsURLValue ( )
77
+ @MutuallyExclusive ( 'icon' )
102
78
public readonly icon ?: SingleValue ;
103
79
104
- @Expose ( )
105
- @IsOptional ( )
106
- @IsUrl ( )
80
+ @IsURLValue ( )
81
+ @MutuallyExclusive ( 'icon' )
107
82
public readonly iconURL ?: SingleValue ;
108
83
109
- @Expose ( )
110
- @IsOptional ( )
111
- @IsUrl ( )
84
+ @IsURLValue ( )
85
+ @MutuallyExclusive ( 'icon' )
112
86
public readonly defaulticon ?: SingleValue ;
113
87
114
- @Expose ( )
115
- @IsOptional ( )
116
- @IsUrl ( )
88
+ @IsURLValue ( )
89
+ @MutuallyExclusive ( 'icon64' )
117
90
public readonly icon64 ?: SingleValue ;
118
91
119
- @Expose ( )
120
- @IsOptional ( )
121
- @IsUrl ( )
92
+ @IsURLValue ( )
93
+ @MutuallyExclusive ( 'icon64' )
122
94
public readonly icon64URL ?: SingleValue ;
123
95
124
- @Expose ( )
125
- @IsOptional ( )
126
- @IsUrl ( )
96
+ @IsURLValue ( )
127
97
public readonly updateURL ?: SingleValue ;
128
98
129
- @Expose ( )
130
- @IsOptional ( )
131
- @IsUrl ( )
99
+ @IsURLValue ( )
100
+ @MutuallyExclusive ( 'downloadURL' )
132
101
public readonly downloadURL ?: SingleValue ;
133
102
134
- @Expose ( )
135
- @IsOptional ( )
136
- @IsUrl ( )
103
+ @IsURLValue ( )
104
+ @MutuallyExclusive ( 'downloadURL' )
137
105
public readonly installURL ?: SingleValue ;
138
106
139
- @Expose ( )
140
- @IsOptional ( )
141
- @IsUrl ( )
107
+ @IsURLValue ( )
142
108
public readonly supportURL ?: SingleValue ;
143
109
144
- @Expose ( )
145
- @IsOptional ( )
146
- @IsString ( { each : true } )
110
+ @IsMultiValue ( )
147
111
public readonly include ?: MultiValue ;
148
112
149
- @Expose ( )
150
- @IsOptional ( )
151
- @IsString ( { each : true } )
113
+ @IsMultiValue ( )
152
114
public readonly match ?: MultiValue ;
153
115
154
- @Expose ( )
155
- @IsOptional ( )
156
- @IsString ( { each : true } )
116
+ @IsMultiValue ( )
157
117
public readonly 'exclude-match' ?: MultiValue ;
158
118
159
- @Expose ( )
160
- @IsOptional ( )
161
- @IsString ( { each : true } )
119
+ @IsMultiValue ( )
162
120
public readonly exclude ?: MultiValue ;
163
121
164
- @Expose ( )
165
- @IsOptional ( )
166
- @IsString ( { each : true } )
122
+ @IsMultiValue ( )
167
123
public readonly require ?: MultiValue ;
168
124
169
- @Expose ( )
170
- @IsOptional ( )
171
- @IsObject ( )
125
+ @IsNamedValue ( )
172
126
public readonly resource ?: NamedValue ;
173
127
174
- @Expose ( )
175
- @IsOptional ( )
176
- @IsString ( { each : true } )
128
+ @IsMultiValue ( )
177
129
public readonly connect ?: MultiValue ;
178
130
179
- @Expose ( )
180
- @IsOptional ( )
181
- @IsString ( { each : true } )
131
+ @IsMultiValue ( )
182
132
public readonly grant ?: MultiValue ;
183
133
184
- @Expose ( )
185
- @IsOptional ( )
186
- @IsString ( { each : true } )
134
+ @IsMultiValue ( )
187
135
public readonly webRequest ?: MultiValue ;
188
136
189
- @Expose ( )
190
- @IsOptional ( )
191
- @IsBoolean ( )
137
+ @IsSwitchValue ( )
192
138
public readonly noframes ?: SwitchValue ;
193
139
194
- @Expose ( )
195
- @IsOptional ( )
196
- @IsBoolean ( )
140
+ @IsSwitchValue ( )
197
141
public readonly unwrap ?: SwitchValue ;
198
142
199
- @Expose ( )
200
- @IsOptional ( )
201
- @IsObject ( )
143
+ @IsNamedValue ( )
202
144
public readonly antifeature ?: NamedValue ;
203
145
204
- @Expose ( )
205
- @IsOptional ( )
206
- @IsEnum ( RunAt )
146
+ @IsEnumValue ( RunAt )
207
147
public readonly 'run-at' ?: RunAt ;
208
148
209
- @Expose ( )
210
- @IsOptional ( )
211
- @IsString ( )
149
+ @IsSingleValue ( )
212
150
public readonly copyright ?: SingleValue ;
213
151
214
- @Expose ( )
215
- @IsOptional ( )
216
- @IsEnum ( Sandbox )
152
+ @IsEnumValue ( Sandbox )
217
153
public readonly sandbox ?: Sandbox ;
218
154
219
- @Expose ( )
220
- @IsOptional ( )
221
- @IsEnum ( InjectInto )
155
+ @IsEnumValue ( InjectInto )
222
156
public readonly 'inject-into' ?: InjectInto ;
223
157
224
- @Expose ( )
225
- @IsOptional ( )
226
- @IsString ( )
158
+ @IsSingleValue ( )
227
159
public readonly license ?: SingleValue ;
228
160
229
- @Expose ( )
230
- @IsOptional ( )
231
- @IsUrl ( )
161
+ @IsURLValue ( )
232
162
public readonly contributionURL ?: SingleValue ;
233
163
234
- @Expose ( )
235
- @IsOptional ( )
236
- @IsString ( )
164
+ @IsSingleValue ( )
237
165
public readonly contributionAmount ?: SingleValue ;
238
166
239
- @Expose ( )
240
- @Type ( ( ) => Compatibility )
241
- @IsOptional ( )
242
- @ValidateNested ( )
167
+ @IsNestedValue ( Compatibility )
243
168
public readonly compatible ?: Compatibility ;
244
169
245
- @Expose ( )
246
- @Type ( ( ) => Compatibility )
247
- @IsOptional ( )
248
- @ValidateNested ( )
170
+ @IsNestedValue ( Compatibility )
249
171
public readonly incompatible ?: Compatibility ;
250
172
}
0 commit comments