@@ -10,11 +10,10 @@ export interface IFilterPattern {
10
10
/**
11
11
* Base class for patterns that only match JSON log events.
12
12
*/
13
- export abstract class JSONPattern implements IFilterPattern {
13
+ export abstract class JsonPattern implements IFilterPattern {
14
14
// This is a separate class so we have some type safety where users can't
15
15
// combine text patterns and JSON patterns with an 'and' operation.
16
- constructor ( public readonly jsonPatternString : string ) {
17
- }
16
+ constructor ( public readonly jsonPatternString : string ) { }
18
17
19
18
public get logPatternString ( ) : string {
20
19
return '{ ' + this . jsonPatternString + ' }' ;
@@ -92,7 +91,7 @@ export class FilterPattern {
92
91
* @param comparison Comparison to carry out. Either = or !=.
93
92
* @param value The string value to compare to. May use '*' as wildcard at start or end of string.
94
93
*/
95
- public static stringValue ( jsonField : string , comparison : string , value : string ) : JSONPattern {
94
+ public static stringValue ( jsonField : string , comparison : string , value : string ) : JsonPattern {
96
95
return new JSONStringPattern ( jsonField , comparison , value ) ;
97
96
}
98
97
@@ -114,7 +113,7 @@ export class FilterPattern {
114
113
* @param comparison Comparison to carry out. One of =, !=, <, <=, >, >=.
115
114
* @param value The numerical value to compare to
116
115
*/
117
- public static numberValue ( jsonField : string , comparison : string , value : number ) : JSONPattern {
116
+ public static numberValue ( jsonField : string , comparison : string , value : number ) : JsonPattern {
118
117
return new JSONNumberPattern ( jsonField , comparison , value ) ;
119
118
}
120
119
@@ -123,7 +122,7 @@ export class FilterPattern {
123
122
*
124
123
* @param jsonField Field inside JSON. Example: "$.myField"
125
124
*/
126
- public static isNull ( jsonField : string ) : JSONPattern {
125
+ public static isNull ( jsonField : string ) : JsonPattern {
127
126
return new JSONPostfixPattern ( jsonField , 'IS NULL' ) ;
128
127
}
129
128
@@ -132,7 +131,7 @@ export class FilterPattern {
132
131
*
133
132
* @param jsonField Field inside JSON. Example: "$.myField"
134
133
*/
135
- public static notExists ( jsonField : string ) : JSONPattern {
134
+ public static notExists ( jsonField : string ) : JsonPattern {
136
135
return new JSONPostfixPattern ( jsonField , 'NOT EXISTS' ) ;
137
136
}
138
137
@@ -143,7 +142,7 @@ export class FilterPattern {
143
142
*
144
143
* @param jsonField Field inside JSON. Example: "$.myField"
145
144
*/
146
- public static exists ( jsonField : string ) : JSONPattern {
145
+ public static exists ( jsonField : string ) : JsonPattern {
147
146
return new JSONStringPattern ( jsonField , '=' , '*' ) ;
148
147
}
149
148
@@ -153,14 +152,14 @@ export class FilterPattern {
153
152
* @param jsonField Field inside JSON. Example: "$.myField"
154
153
* @param value The value to match
155
154
*/
156
- public static booleanValue ( jsonField : string , value : boolean ) : JSONPattern {
155
+ public static booleanValue ( jsonField : string , value : boolean ) : JsonPattern {
157
156
return new JSONPostfixPattern ( jsonField , value ? 'IS TRUE' : 'IS FALSE' ) ;
158
157
}
159
158
160
159
/**
161
160
* A JSON log pattern that matches if all given JSON log patterns match
162
161
*/
163
- public static all ( ...patterns : JSONPattern [ ] ) : JSONPattern {
162
+ public static all ( ...patterns : JsonPattern [ ] ) : JsonPattern {
164
163
if ( patterns . length === 0 ) { throw new Error ( 'Must supply at least one pattern, or use allEvents() to match all events.' ) ; }
165
164
if ( patterns . length === 1 ) { return patterns [ 0 ] ; }
166
165
return new JSONAggregatePattern ( '&&' , patterns ) ;
@@ -169,7 +168,7 @@ export class FilterPattern {
169
168
/**
170
169
* A JSON log pattern that matches if any of the given JSON log patterns match
171
170
*/
172
- public static any ( ...patterns : JSONPattern [ ] ) : JSONPattern {
171
+ public static any ( ...patterns : JsonPattern [ ] ) : JsonPattern {
173
172
if ( patterns . length === 0 ) { throw new Error ( 'Must supply at least one pattern' ) ; }
174
173
if ( patterns . length === 1 ) { return patterns [ 0 ] ; }
175
174
return new JSONAggregatePattern ( '||' , patterns ) ;
@@ -220,7 +219,7 @@ class TextLogPattern implements IFilterPattern {
220
219
/**
221
220
* A string comparison for JSON values
222
221
*/
223
- class JSONStringPattern extends JSONPattern {
222
+ class JSONStringPattern extends JsonPattern {
224
223
public constructor ( jsonField : string , comparison : string , value : string ) {
225
224
comparison = validateStringOperator ( comparison ) ;
226
225
super ( `${ jsonField } ${ comparison } ${ quoteTerm ( value ) } ` ) ;
@@ -230,7 +229,7 @@ class JSONStringPattern extends JSONPattern {
230
229
/**
231
230
* A number comparison for JSON values
232
231
*/
233
- class JSONNumberPattern extends JSONPattern {
232
+ class JSONNumberPattern extends JsonPattern {
234
233
public constructor ( jsonField : string , comparison : string , value : number ) {
235
234
comparison = validateNumericalOperator ( comparison ) ;
236
235
super ( `${ jsonField } ${ comparison } ${ value } ` ) ;
@@ -240,7 +239,7 @@ class JSONNumberPattern extends JSONPattern {
240
239
/**
241
240
* A postfix operator for JSON patterns
242
241
*/
243
- class JSONPostfixPattern extends JSONPattern {
242
+ class JSONPostfixPattern extends JsonPattern {
244
243
public constructor ( jsonField : string , postfix : string ) {
245
244
// No validation, we assume these are generated by trusted factory functions
246
245
super ( `${ jsonField } ${ postfix } ` ) ;
@@ -250,8 +249,8 @@ class JSONPostfixPattern extends JSONPattern {
250
249
/**
251
250
* Combines multiple other JSON patterns with an operator
252
251
*/
253
- class JSONAggregatePattern extends JSONPattern {
254
- public constructor ( operator : string , patterns : JSONPattern [ ] ) {
252
+ class JSONAggregatePattern extends JsonPattern {
253
+ public constructor ( operator : string , patterns : JsonPattern [ ] ) {
255
254
if ( operator !== '&&' && operator !== '||' ) {
256
255
throw new Error ( 'Operator must be one of && or ||' ) ;
257
256
}
0 commit comments