-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueryLanguage.ts
282 lines (232 loc) · 6.73 KB
/
queryLanguage.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
import * as ConstrainedTypes from './constrainedTypes';
import { EntityUid } from './entity';
/**
* Namespace regrouping public interfaces exposed to users, related to query language
*/
export namespace QueryLanguage {
/**
* All properties are optional
*/
export interface IQueryOptions {
/**
* Number of items to skip
*/
skip?: ConstrainedTypes.AbsInt0;
/**
* Number of items to get
*/
limit?: ConstrainedTypes.AbsIntInf0;
/**
* To use with {@link QueryOptions.limit `limit`} and without {@link QueryOptions.skip `skip`}. Skips `page` pages of `limit` elements
*/
page?: ConstrainedTypes.AbsInt0;
/**
* Flag indicating if adapter input should be remapped or not. TODO Remapping doc
*/
remapInput?: boolean;
/**
* Flag indicating if adapter output should be remapped or not. TODO Remapping doc
*/
remapOutput?: boolean;
}
/**
* By default, all conditions in a single SelectQueryCondition are combined with an `AND` operator.
*/
export interface ISelectQueryCondition {
/**
* Alias for {@link SelectQueryCondition.$equals}
*/
'==': any;
/**
* See {@link SelectQueryCondition.$equals}
*/
$equals: any;
/**
* Alias for {@link SelectQueryCondition.$diff}
*/
'!=': any;
/**
* See {@link SelectQueryCondition.$diff}
*/
$diff: any;
/**
* Alias for {@link SelectQueryCondition.$exists}
*/
'~': boolean;
/**
* See {@link SelectQueryCondition.$exists}
*/
$exists: boolean;
/**
* Alias for {@link SelectQueryCondition.$less}
*/
'<': number;
/**
* See {@link SelectQueryCondition.$less}
*/
$less: number;
/**
* Alias for {@link SelectQueryCondition.$lessEqual}
*/
'<=': number;
/**
* See {@link SelectQueryCondition.$lessEqual}
*/
$lessEqual: number;
/**
* Alias for {@link SelectQueryCondition.$greater}
*/
'>': number;
/**
* See {@link SelectQueryCondition.$greater}
*/
$greater: number;
/**
* Alias for {@link SelectQueryCondition.$greaterEqual}
*/
'>=': number;
/**
* See {@link SelectQueryCondition.$greaterEqual}
*/
$greaterEqual: number;
/**
* Alias for {@link SelectQueryCondition.$or}
*/
'||': SelectQueryOrCondition[];
/**
* See {@link SelectQueryCondition.$or}
*/
$or: SelectQueryOrCondition[];
/**
* Alias for {@link SelectQueryCondition.$and}
*/
'&&': SelectQueryOrCondition[];
/**
* See {@link SelectQueryCondition.$and}
*/
$and: SelectQueryOrCondition[];
/**
* Alias for {@link SelectQueryCondition.$xor}
*/
'^^': SelectQueryOrCondition[];
/**
* See {@link SelectQueryCondition.$xor}
*/
$xor: SelectQueryOrCondition[];
/**
* Alias for {@link SelectQueryCondition.$not}
*/
'!': SelectQueryOrCondition;
/**
* See {@link SelectQueryCondition.$not}
*/
$not: SelectQueryOrCondition;
/**
* See {@link SelectQueryCondition.$contains}
*/
$contains: SelectQueryOrCondition | string | any;
/**
* See {@link SelectQueryCondition.$in}
*/
$in: any[];
}
export interface ISelectQuery {
/**
* Fields to search. If not providing an object, find items with a property value that equals this value
*/
[key: string]: any | ISelectQueryCondition;
}
export type SelectQueryOrCondition = ISelectQuery | ISelectQueryCondition;
export type SearchQuery = SelectQueryOrCondition | EntityUid;
}
/**
* Namespace regrouping private & internal interfaces used by Diaspora, related to query language. Its public counterpart is [[QueryLanguage]]
* @internal
*/
export namespace _QueryLanguage {
/**
* Generated by Diaspora
*/
export interface IQueryOptions {
/**
* Number of items to skip
*/
skip: ConstrainedTypes.AbsInt0;
/**
* Number of items to get
*/
limit: ConstrainedTypes.AbsIntInf0;
/**
* Flag indicating if adapter input should be remapped or not. TODO Remapping doc
*/
remapInput: boolean;
/**
* Flag indicating if adapter output should be remapped or not. TODO Remapping doc
*/
remapOutput: boolean;
}
/**
* By default, all conditions in a single SelectQueryCondition are combined with an `AND` operator.
*/
export interface ISelectQueryCondition {
/**
* Match if item value is equal to this. Objects and array are compared deeply. Canonical form of {@link Raw.SelectQueryCondition['==']}
*/
$equals: any;
/**
* Match if item value is different to this. Objects and array are compared deeply. Canonical form of {@link Raw.SelectQueryCondition['!=']}
*/
$diff: any;
/**
* If `true`, match items where this prop is defined. If `false`, match when prop is null or not set. Canonical form of {@link Raw.SelectQueryCondition['~']}
*/
$exists: boolean;
/**
* Match if item value is less than this. Canonical form of {@link Raw.SelectQueryCondition['<']}
*/
$less: number;
/**
* Match if item value is less than this or equals to this. Canonical form of {@link Raw.SelectQueryCondition['<=']}
*/
$lessEqual: number;
/**
* Match if item value is greater than this. Canonical form of {@link Raw.SelectQueryCondition['>']}
*/
$greater: number;
/**
* Match if item value is greater than this or equals to this. Canonical form of {@link Raw.SelectQueryCondition['>=']}
*/
$greaterEqual: number;
/**
* Match if *one of* the conditions in the array is true. Canonical form of {@link Raw.SelectQueryCondition['||']} **NOT IMPLEMENTED YET**
*/
$or: SelectQueryOrCondition[];
/**
* Match if *all* the conditions in the array are true. Optional, because several conditions in a single SelectQueryCondition are combined with an `AND` operator. Canonical form of {@link Raw.SelectQueryCondition['&&']} **NOT IMPLEMENTED YET**
*/
$and: SelectQueryOrCondition[];
/**
* Match if *a single* of the conditions in the array is true. Canonical form of {@link Raw.SelectQueryCondition['^^']} **NOT IMPLEMENTED YET**
*/
$xor: SelectQueryOrCondition[];
/**
* Invert the condition Canonical form of {@link Raw.SelectQueryCondition['!']} **NOT IMPLEMENTED YET**
*/
$not: SelectQueryOrCondition;
/**
* On *array*, it will check if item contains the query. On *string*, it will check if query is included in item using GLOB. **NOT IMPLEMENTED YET**
*/
$contains: SelectQueryOrCondition | string | any;
/**
* Check if item value is contained (using deep comparaison) in query. **NOT IMPLEMENTED YET**
*/
$in: any[];
}
export interface ISelectQuery {
/**
* Fields to search. If not providing an object, find items with a property value that equals this value
*/
[key: string]: any | ISelectQueryCondition;
}
export type SelectQueryOrCondition = ISelectQuery | ISelectQueryCondition;
}