@steedos/odata-v4-parser 3.0.13-beta.3 → 3.0.13-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/expressions.js +131 -131
- package/lib/expressions.js.map +1 -1
- package/lib/json.js +69 -69
- package/lib/json.js.map +1 -1
- package/lib/lexer.js +30 -25
- package/lib/lexer.js.map +1 -1
- package/lib/nameOrIdentifier.js +180 -218
- package/lib/nameOrIdentifier.js.map +1 -1
- package/lib/odataUri.js +7 -7
- package/lib/odataUri.js.map +1 -1
- package/lib/parser.js +18 -21
- package/lib/parser.js.map +1 -1
- package/lib/primitiveLiteral.js +129 -129
- package/lib/primitiveLiteral.js.map +1 -1
- package/lib/query.js +162 -162
- package/lib/query.js.map +1 -1
- package/lib/resourcePath.js +65 -65
- package/lib/resourcePath.js.map +1 -1
- package/lib/utils.js +3 -3
- package/package.json +2 -2
- package/tsconfig.json +3 -7
package/lib/expressions.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Expressions = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const lexer_1 = require("./lexer");
|
|
6
|
+
const primitiveLiteral_1 = require("./primitiveLiteral");
|
|
7
|
+
const nameOrIdentifier_1 = require("./nameOrIdentifier");
|
|
8
|
+
const json_1 = require("./json");
|
|
9
9
|
var Expressions;
|
|
10
10
|
(function (Expressions) {
|
|
11
11
|
function commonExpr(value, index) {
|
|
12
|
-
|
|
12
|
+
let token = primitiveLiteral_1.default.primitiveLiteral(value, index) ||
|
|
13
13
|
parameterAlias(value, index) ||
|
|
14
14
|
json_1.default.arrayOrObject(value, index) ||
|
|
15
15
|
rootExpr(value, index) ||
|
|
@@ -21,7 +21,7 @@ var Expressions;
|
|
|
21
21
|
castExpr(value, index);
|
|
22
22
|
if (!token)
|
|
23
23
|
return;
|
|
24
|
-
|
|
24
|
+
let expr = addExpr(value, token.next) ||
|
|
25
25
|
subExpr(value, token.next) ||
|
|
26
26
|
mulExpr(value, token.next) ||
|
|
27
27
|
divExpr(value, token.next) ||
|
|
@@ -40,14 +40,14 @@ var Expressions;
|
|
|
40
40
|
}
|
|
41
41
|
Expressions.commonExpr = commonExpr;
|
|
42
42
|
function boolCommonExpr(value, index) {
|
|
43
|
-
|
|
43
|
+
let token = isofExpr(value, index) ||
|
|
44
44
|
boolMethodCallExpr(value, index) ||
|
|
45
45
|
notExpr(value, index) ||
|
|
46
46
|
commonExpr(value, index) ||
|
|
47
47
|
boolParenExpr(value, index);
|
|
48
48
|
if (!token)
|
|
49
49
|
return;
|
|
50
|
-
|
|
50
|
+
let commonMoreExpr = undefined;
|
|
51
51
|
if (token.type === lexer_1.default.TokenType.CommonExpression) {
|
|
52
52
|
commonMoreExpr = eqExpr(value, token.next) ||
|
|
53
53
|
neExpr(value, token.next) ||
|
|
@@ -68,10 +68,10 @@ var Expressions;
|
|
|
68
68
|
token.raw = utils_1.default.stringify(value, token.position, token.next);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
let expr = andExpr(value, token.next) ||
|
|
72
72
|
orExpr(value, token.next);
|
|
73
73
|
if (expr) {
|
|
74
|
-
|
|
74
|
+
let left = lexer_1.default.clone(token);
|
|
75
75
|
token.next = expr.value.next;
|
|
76
76
|
token.value = {
|
|
77
77
|
left: left,
|
|
@@ -92,42 +92,42 @@ var Expressions;
|
|
|
92
92
|
}
|
|
93
93
|
Expressions.boolCommonExpr = boolCommonExpr;
|
|
94
94
|
function andExpr(value, index) {
|
|
95
|
-
|
|
95
|
+
let rws = lexer_1.default.RWS(value, index);
|
|
96
96
|
if (rws === index || !utils_1.default.equals(value, rws, "and"))
|
|
97
97
|
return;
|
|
98
|
-
|
|
98
|
+
let start = index;
|
|
99
99
|
index = rws + 3;
|
|
100
100
|
rws = lexer_1.default.RWS(value, index);
|
|
101
101
|
if (rws === index)
|
|
102
102
|
return;
|
|
103
103
|
index = rws;
|
|
104
|
-
|
|
104
|
+
let token = boolCommonExpr(value, index);
|
|
105
105
|
if (!token)
|
|
106
106
|
return;
|
|
107
107
|
return lexer_1.default.tokenize(value, start, index, token, lexer_1.default.TokenType.AndExpression);
|
|
108
108
|
}
|
|
109
109
|
Expressions.andExpr = andExpr;
|
|
110
110
|
function orExpr(value, index) {
|
|
111
|
-
|
|
111
|
+
let rws = lexer_1.default.RWS(value, index);
|
|
112
112
|
if (rws === index || !utils_1.default.equals(value, rws, "or"))
|
|
113
113
|
return;
|
|
114
|
-
|
|
114
|
+
let start = index;
|
|
115
115
|
index = rws + 2;
|
|
116
116
|
rws = lexer_1.default.RWS(value, index);
|
|
117
117
|
if (rws === index)
|
|
118
118
|
return;
|
|
119
119
|
index = rws;
|
|
120
|
-
|
|
120
|
+
let token = boolCommonExpr(value, index);
|
|
121
121
|
if (!token)
|
|
122
122
|
return;
|
|
123
123
|
return lexer_1.default.tokenize(value, start, index, token, lexer_1.default.TokenType.OrExpression);
|
|
124
124
|
}
|
|
125
125
|
Expressions.orExpr = orExpr;
|
|
126
126
|
function leftRightExpr(value, index, expr, tokenType) {
|
|
127
|
-
|
|
127
|
+
let rws = lexer_1.default.RWS(value, index);
|
|
128
128
|
if (rws === index)
|
|
129
129
|
return;
|
|
130
|
-
|
|
130
|
+
let start = index;
|
|
131
131
|
index = rws;
|
|
132
132
|
if (!utils_1.default.equals(value, index, expr))
|
|
133
133
|
return;
|
|
@@ -136,7 +136,7 @@ var Expressions;
|
|
|
136
136
|
if (rws === index)
|
|
137
137
|
return;
|
|
138
138
|
index = rws;
|
|
139
|
-
|
|
139
|
+
let token = commonExpr(value, index);
|
|
140
140
|
if (!token)
|
|
141
141
|
return;
|
|
142
142
|
return lexer_1.default.tokenize(value, start, index, token.value, tokenType);
|
|
@@ -167,12 +167,12 @@ var Expressions;
|
|
|
167
167
|
function modExpr(value, index) { return leftRightExpr(value, index, "mod", lexer_1.default.TokenType.ModExpression); }
|
|
168
168
|
Expressions.modExpr = modExpr;
|
|
169
169
|
function inExpr(value, index) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
const expr = 'in';
|
|
171
|
+
const tokenType = lexer_1.default.TokenType.InExpression;
|
|
172
|
+
let rws = lexer_1.default.RWS(value, index);
|
|
173
173
|
if (rws === index)
|
|
174
174
|
return;
|
|
175
|
-
|
|
175
|
+
let start = index;
|
|
176
176
|
index = rws;
|
|
177
177
|
if (!utils_1.default.equals(value, index, expr))
|
|
178
178
|
return;
|
|
@@ -181,7 +181,7 @@ var Expressions;
|
|
|
181
181
|
if (rws === index)
|
|
182
182
|
return;
|
|
183
183
|
index = rws;
|
|
184
|
-
|
|
184
|
+
let token = boolCommonExpr(value, index);
|
|
185
185
|
if (!token)
|
|
186
186
|
return;
|
|
187
187
|
return lexer_1.default.tokenize(value, start, index, token.value, tokenType);
|
|
@@ -190,12 +190,12 @@ var Expressions;
|
|
|
190
190
|
function notInExpr(value, index) {
|
|
191
191
|
if (!utils_1.default.equals(value, index + 1, "notin"))
|
|
192
192
|
return;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
const expr = 'notin';
|
|
194
|
+
const tokenType = lexer_1.default.TokenType.NotInExpression;
|
|
195
|
+
let rws = lexer_1.default.RWS(value, index);
|
|
196
196
|
if (rws === index)
|
|
197
197
|
return;
|
|
198
|
-
|
|
198
|
+
let start = index;
|
|
199
199
|
index = rws;
|
|
200
200
|
if (!utils_1.default.equals(value, index, expr))
|
|
201
201
|
return;
|
|
@@ -204,7 +204,7 @@ var Expressions;
|
|
|
204
204
|
if (rws === index)
|
|
205
205
|
return;
|
|
206
206
|
index = rws;
|
|
207
|
-
|
|
207
|
+
let token = boolCommonExpr(value, index);
|
|
208
208
|
if (!token)
|
|
209
209
|
return;
|
|
210
210
|
return lexer_1.default.tokenize(value, start, index, token.value, tokenType);
|
|
@@ -213,30 +213,30 @@ var Expressions;
|
|
|
213
213
|
function notExpr(value, index) {
|
|
214
214
|
if (!utils_1.default.equals(value, index, "not"))
|
|
215
215
|
return;
|
|
216
|
-
|
|
216
|
+
let start = index;
|
|
217
217
|
index += 3;
|
|
218
|
-
|
|
218
|
+
let rws = lexer_1.default.RWS(value, index);
|
|
219
219
|
if (rws === index)
|
|
220
220
|
return;
|
|
221
221
|
index = rws;
|
|
222
|
-
|
|
222
|
+
let token = boolCommonExpr(value, index);
|
|
223
223
|
if (!token)
|
|
224
224
|
return;
|
|
225
225
|
return lexer_1.default.tokenize(value, start, token.next, token, lexer_1.default.TokenType.NotExpression);
|
|
226
226
|
}
|
|
227
227
|
Expressions.notExpr = notExpr;
|
|
228
228
|
function boolParenExpr(value, index) {
|
|
229
|
-
|
|
229
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
230
230
|
if (!open)
|
|
231
231
|
return;
|
|
232
|
-
|
|
232
|
+
let start = index;
|
|
233
233
|
index = open;
|
|
234
234
|
index = lexer_1.default.BWS(value, index);
|
|
235
|
-
|
|
235
|
+
let token = boolCommonExpr(value, index);
|
|
236
236
|
if (!token)
|
|
237
237
|
return;
|
|
238
238
|
index = lexer_1.default.BWS(value, token.next);
|
|
239
|
-
|
|
239
|
+
let close = lexer_1.default.CLOSE(value, index);
|
|
240
240
|
if (!close)
|
|
241
241
|
return;
|
|
242
242
|
index = close;
|
|
@@ -244,17 +244,17 @@ var Expressions;
|
|
|
244
244
|
}
|
|
245
245
|
Expressions.boolParenExpr = boolParenExpr;
|
|
246
246
|
function parenExpr(value, index) {
|
|
247
|
-
|
|
247
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
248
248
|
if (!open)
|
|
249
249
|
return;
|
|
250
|
-
|
|
250
|
+
let start = index;
|
|
251
251
|
index = open;
|
|
252
252
|
index = lexer_1.default.BWS(value, index);
|
|
253
|
-
|
|
253
|
+
let token = commonExpr(value, index);
|
|
254
254
|
if (!token)
|
|
255
255
|
return;
|
|
256
256
|
index = lexer_1.default.BWS(value, token.next);
|
|
257
|
-
|
|
257
|
+
let close = lexer_1.default.CLOSE(value, index);
|
|
258
258
|
if (!close)
|
|
259
259
|
return;
|
|
260
260
|
index = close;
|
|
@@ -305,25 +305,25 @@ var Expressions;
|
|
|
305
305
|
max = min;
|
|
306
306
|
if (!utils_1.default.equals(value, index, method))
|
|
307
307
|
return;
|
|
308
|
-
|
|
308
|
+
let start = index;
|
|
309
309
|
index += method.length;
|
|
310
|
-
|
|
310
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
311
311
|
if (!open)
|
|
312
312
|
return;
|
|
313
313
|
index = open;
|
|
314
314
|
index = lexer_1.default.BWS(value, index);
|
|
315
|
-
|
|
315
|
+
let parameters;
|
|
316
316
|
if (min > 0) {
|
|
317
317
|
parameters = [];
|
|
318
318
|
while (parameters.length < max) {
|
|
319
|
-
|
|
319
|
+
let expr = commonExpr(value, index);
|
|
320
320
|
if (parameters.length < min && !expr)
|
|
321
321
|
return;
|
|
322
322
|
else if (expr) {
|
|
323
323
|
parameters.push(expr.value);
|
|
324
324
|
index = expr.next;
|
|
325
325
|
index = lexer_1.default.BWS(value, index);
|
|
326
|
-
|
|
326
|
+
let comma = lexer_1.default.COMMA(value, index);
|
|
327
327
|
if (parameters.length < min && !comma)
|
|
328
328
|
return;
|
|
329
329
|
if (comma)
|
|
@@ -337,7 +337,7 @@ var Expressions;
|
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
index = lexer_1.default.BWS(value, index);
|
|
340
|
-
|
|
340
|
+
let close = lexer_1.default.CLOSE(value, index);
|
|
341
341
|
if (!close)
|
|
342
342
|
return;
|
|
343
343
|
index = close;
|
|
@@ -412,29 +412,29 @@ var Expressions;
|
|
|
412
412
|
function isofExpr(value, index) {
|
|
413
413
|
if (!utils_1.default.equals(value, index, "isof"))
|
|
414
414
|
return;
|
|
415
|
-
|
|
415
|
+
let start = index;
|
|
416
416
|
index += 4;
|
|
417
|
-
|
|
417
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
418
418
|
if (!open)
|
|
419
419
|
return;
|
|
420
420
|
index = open;
|
|
421
421
|
index = lexer_1.default.BWS(value, index);
|
|
422
|
-
|
|
422
|
+
let expr = commonExpr(value, index);
|
|
423
423
|
if (expr) {
|
|
424
424
|
index = expr.next;
|
|
425
425
|
index = lexer_1.default.BWS(value, index);
|
|
426
|
-
|
|
426
|
+
let comma = lexer_1.default.COMMA(value, index);
|
|
427
427
|
if (!comma)
|
|
428
428
|
return;
|
|
429
429
|
index = comma;
|
|
430
430
|
index = lexer_1.default.BWS(value, index);
|
|
431
431
|
}
|
|
432
|
-
|
|
432
|
+
let typeName = nameOrIdentifier_1.default.qualifiedTypeName(value, index);
|
|
433
433
|
if (!typeName)
|
|
434
434
|
return;
|
|
435
435
|
index = typeName.next;
|
|
436
436
|
index = lexer_1.default.BWS(value, index);
|
|
437
|
-
|
|
437
|
+
let close = lexer_1.default.CLOSE(value, index);
|
|
438
438
|
if (!close)
|
|
439
439
|
return;
|
|
440
440
|
index = close;
|
|
@@ -447,29 +447,29 @@ var Expressions;
|
|
|
447
447
|
function castExpr(value, index) {
|
|
448
448
|
if (!utils_1.default.equals(value, index, "cast"))
|
|
449
449
|
return;
|
|
450
|
-
|
|
450
|
+
let start = index;
|
|
451
451
|
index += 4;
|
|
452
|
-
|
|
452
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
453
453
|
if (!open)
|
|
454
454
|
return;
|
|
455
455
|
index = open;
|
|
456
456
|
index = lexer_1.default.BWS(value, index);
|
|
457
|
-
|
|
457
|
+
let expr = commonExpr(value, index);
|
|
458
458
|
if (expr) {
|
|
459
459
|
index = expr.next;
|
|
460
460
|
index = lexer_1.default.BWS(value, index);
|
|
461
|
-
|
|
461
|
+
let comma = lexer_1.default.COMMA(value, index);
|
|
462
462
|
if (!comma)
|
|
463
463
|
return;
|
|
464
464
|
index = comma;
|
|
465
465
|
index = lexer_1.default.BWS(value, index);
|
|
466
466
|
}
|
|
467
|
-
|
|
467
|
+
let typeName = nameOrIdentifier_1.default.qualifiedTypeName(value, index);
|
|
468
468
|
if (!typeName)
|
|
469
469
|
return;
|
|
470
470
|
index = typeName.next;
|
|
471
471
|
index = lexer_1.default.BWS(value, index);
|
|
472
|
-
|
|
472
|
+
let close = lexer_1.default.CLOSE(value, index);
|
|
473
473
|
if (!close)
|
|
474
474
|
return;
|
|
475
475
|
index = close;
|
|
@@ -482,19 +482,19 @@ var Expressions;
|
|
|
482
482
|
function negateExpr(value, index) {
|
|
483
483
|
if (value[index] !== 0x2d)
|
|
484
484
|
return;
|
|
485
|
-
|
|
485
|
+
let start = index;
|
|
486
486
|
index++;
|
|
487
487
|
index = lexer_1.default.BWS(value, index);
|
|
488
|
-
|
|
488
|
+
let expr = commonExpr(value, index);
|
|
489
489
|
if (!expr)
|
|
490
490
|
return;
|
|
491
491
|
return lexer_1.default.tokenize(value, start, expr.next, expr, lexer_1.default.TokenType.NegateExpression);
|
|
492
492
|
}
|
|
493
493
|
Expressions.negateExpr = negateExpr;
|
|
494
494
|
function firstMemberExpr(value, index) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
495
|
+
let token = inscopeVariableExpr(value, index);
|
|
496
|
+
let member;
|
|
497
|
+
let start = index;
|
|
498
498
|
if (token) {
|
|
499
499
|
if (value[token.next] === 0x2f) {
|
|
500
500
|
index = token.next + 1;
|
|
@@ -513,14 +513,14 @@ var Expressions;
|
|
|
513
513
|
}
|
|
514
514
|
Expressions.firstMemberExpr = firstMemberExpr;
|
|
515
515
|
function memberExpr(value, index) {
|
|
516
|
-
|
|
517
|
-
|
|
516
|
+
let start = index;
|
|
517
|
+
let token = nameOrIdentifier_1.default.qualifiedEntityTypeName(value, index);
|
|
518
518
|
if (token) {
|
|
519
519
|
if (value[token.next] !== 0x2f)
|
|
520
520
|
return;
|
|
521
521
|
index = token.next + 1;
|
|
522
522
|
}
|
|
523
|
-
|
|
523
|
+
let next = propertyPathExpr(value, index) ||
|
|
524
524
|
boundFunctionExpr(value, index);
|
|
525
525
|
if (!next)
|
|
526
526
|
return;
|
|
@@ -528,11 +528,11 @@ var Expressions;
|
|
|
528
528
|
}
|
|
529
529
|
Expressions.memberExpr = memberExpr;
|
|
530
530
|
function propertyPathExpr(value, index) {
|
|
531
|
-
|
|
532
|
-
|
|
531
|
+
let token = nameOrIdentifier_1.default.odataIdentifier(value, index);
|
|
532
|
+
let start = index;
|
|
533
533
|
if (token) {
|
|
534
534
|
index = token.next;
|
|
535
|
-
|
|
535
|
+
let nav = collectionPathExpr(value, token.next) ||
|
|
536
536
|
collectionNavigationExpr(value, token.next) ||
|
|
537
537
|
singleNavigationExpr(value, token.next) ||
|
|
538
538
|
complexPathExpr(value, token.next) ||
|
|
@@ -565,10 +565,10 @@ var Expressions;
|
|
|
565
565
|
return lexer_1.default.tokenize(value, index, index + 3, "$it", lexer_1.default.TokenType.ImplicitVariableExpression);
|
|
566
566
|
}
|
|
567
567
|
Expressions.implicitVariableExpr = implicitVariableExpr;
|
|
568
|
-
|
|
569
|
-
|
|
568
|
+
let isLambdaPredicate = false;
|
|
569
|
+
let hasLambdaVariableExpr = false;
|
|
570
570
|
function lambdaVariableExpr(value, index) {
|
|
571
|
-
|
|
571
|
+
let token = nameOrIdentifier_1.default.odataIdentifier(value, index, lexer_1.default.TokenType.LambdaVariableExpression);
|
|
572
572
|
if (token) {
|
|
573
573
|
hasLambdaVariableExpr = true;
|
|
574
574
|
return token;
|
|
@@ -577,7 +577,7 @@ var Expressions;
|
|
|
577
577
|
Expressions.lambdaVariableExpr = lambdaVariableExpr;
|
|
578
578
|
function lambdaPredicateExpr(value, index) {
|
|
579
579
|
isLambdaPredicate = true;
|
|
580
|
-
|
|
580
|
+
let token = boolCommonExpr(value, index);
|
|
581
581
|
isLambdaPredicate = false;
|
|
582
582
|
if (token && hasLambdaVariableExpr) {
|
|
583
583
|
hasLambdaVariableExpr = false;
|
|
@@ -588,19 +588,19 @@ var Expressions;
|
|
|
588
588
|
function anyExpr(value, index) {
|
|
589
589
|
if (!utils_1.default.equals(value, index, "any"))
|
|
590
590
|
return;
|
|
591
|
-
|
|
591
|
+
let start = index;
|
|
592
592
|
index += 3;
|
|
593
|
-
|
|
593
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
594
594
|
if (!open)
|
|
595
595
|
return;
|
|
596
596
|
index = open;
|
|
597
597
|
index = lexer_1.default.BWS(value, index);
|
|
598
|
-
|
|
599
|
-
|
|
598
|
+
let variable = lambdaVariableExpr(value, index);
|
|
599
|
+
let predicate;
|
|
600
600
|
if (variable) {
|
|
601
601
|
index = variable.next;
|
|
602
602
|
index = lexer_1.default.BWS(value, index);
|
|
603
|
-
|
|
603
|
+
let colon = lexer_1.default.COLON(value, index);
|
|
604
604
|
if (!colon)
|
|
605
605
|
return;
|
|
606
606
|
index = colon;
|
|
@@ -611,7 +611,7 @@ var Expressions;
|
|
|
611
611
|
index = predicate.next;
|
|
612
612
|
}
|
|
613
613
|
index = lexer_1.default.BWS(value, index);
|
|
614
|
-
|
|
614
|
+
let close = lexer_1.default.CLOSE(value, index);
|
|
615
615
|
if (!close)
|
|
616
616
|
return;
|
|
617
617
|
index = close;
|
|
@@ -624,29 +624,29 @@ var Expressions;
|
|
|
624
624
|
function allExpr(value, index) {
|
|
625
625
|
if (!utils_1.default.equals(value, index, "all"))
|
|
626
626
|
return;
|
|
627
|
-
|
|
627
|
+
let start = index;
|
|
628
628
|
index += 3;
|
|
629
|
-
|
|
629
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
630
630
|
if (!open)
|
|
631
631
|
return;
|
|
632
632
|
index = open;
|
|
633
633
|
index = lexer_1.default.BWS(value, index);
|
|
634
|
-
|
|
634
|
+
let variable = lambdaVariableExpr(value, index);
|
|
635
635
|
if (!variable)
|
|
636
636
|
return;
|
|
637
637
|
index = variable.next;
|
|
638
638
|
index = lexer_1.default.BWS(value, index);
|
|
639
|
-
|
|
639
|
+
let colon = lexer_1.default.COLON(value, index);
|
|
640
640
|
if (!colon)
|
|
641
641
|
return;
|
|
642
642
|
index = colon;
|
|
643
643
|
index = lexer_1.default.BWS(value, index);
|
|
644
|
-
|
|
644
|
+
let predicate = lambdaPredicateExpr(value, index);
|
|
645
645
|
if (!predicate)
|
|
646
646
|
return;
|
|
647
647
|
index = predicate.next;
|
|
648
648
|
index = lexer_1.default.BWS(value, index);
|
|
649
|
-
|
|
649
|
+
let close = lexer_1.default.CLOSE(value, index);
|
|
650
650
|
if (!close)
|
|
651
651
|
return;
|
|
652
652
|
index = close;
|
|
@@ -657,8 +657,8 @@ var Expressions;
|
|
|
657
657
|
}
|
|
658
658
|
Expressions.allExpr = allExpr;
|
|
659
659
|
function collectionNavigationExpr(value, index) {
|
|
660
|
-
|
|
661
|
-
|
|
660
|
+
let start = index;
|
|
661
|
+
let entity, predicate, navigation, path;
|
|
662
662
|
if (value[index] === 0x2f) {
|
|
663
663
|
index++;
|
|
664
664
|
entity = nameOrIdentifier_1.default.qualifiedEntityTypeName(value, index);
|
|
@@ -694,18 +694,18 @@ var Expressions;
|
|
|
694
694
|
}
|
|
695
695
|
Expressions.keyPredicate = keyPredicate;
|
|
696
696
|
function simpleKey(value, index, metadataContext) {
|
|
697
|
-
|
|
697
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
698
698
|
if (!open)
|
|
699
699
|
return;
|
|
700
|
-
|
|
700
|
+
let start = index;
|
|
701
701
|
index = open;
|
|
702
|
-
|
|
702
|
+
let token = keyPropertyValue(value, index);
|
|
703
703
|
if (!token)
|
|
704
704
|
return;
|
|
705
|
-
|
|
705
|
+
let close = lexer_1.default.CLOSE(value, token.next);
|
|
706
706
|
if (!close)
|
|
707
707
|
return;
|
|
708
|
-
|
|
708
|
+
let key;
|
|
709
709
|
if (typeof metadataContext === "object" &&
|
|
710
710
|
metadataContext.key &&
|
|
711
711
|
metadataContext.key.propertyRefs &&
|
|
@@ -717,25 +717,25 @@ var Expressions;
|
|
|
717
717
|
}
|
|
718
718
|
Expressions.simpleKey = simpleKey;
|
|
719
719
|
function compoundKey(value, index) {
|
|
720
|
-
|
|
720
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
721
721
|
if (!open)
|
|
722
722
|
return;
|
|
723
|
-
|
|
723
|
+
let start = index;
|
|
724
724
|
index = open;
|
|
725
|
-
|
|
725
|
+
let pair = keyValuePair(value, index);
|
|
726
726
|
if (!pair)
|
|
727
727
|
return;
|
|
728
|
-
|
|
728
|
+
let keys = [];
|
|
729
729
|
while (pair) {
|
|
730
730
|
keys.push(pair);
|
|
731
|
-
|
|
731
|
+
let comma = lexer_1.default.COMMA(value, pair.next);
|
|
732
732
|
if (comma)
|
|
733
733
|
pair = keyValuePair(value, comma);
|
|
734
734
|
else
|
|
735
735
|
pair = null;
|
|
736
736
|
}
|
|
737
737
|
index = keys[keys.length - 1].next;
|
|
738
|
-
|
|
738
|
+
let close = lexer_1.default.CLOSE(value, index);
|
|
739
739
|
if (!close)
|
|
740
740
|
return;
|
|
741
741
|
index = close;
|
|
@@ -743,14 +743,14 @@ var Expressions;
|
|
|
743
743
|
}
|
|
744
744
|
Expressions.compoundKey = compoundKey;
|
|
745
745
|
function keyValuePair(value, index) {
|
|
746
|
-
|
|
746
|
+
let prop = nameOrIdentifier_1.default.primitiveKeyProperty(value, index) ||
|
|
747
747
|
keyPropertyAlias(value, index);
|
|
748
748
|
if (!prop)
|
|
749
749
|
return;
|
|
750
|
-
|
|
750
|
+
let eq = lexer_1.default.EQ(value, prop.next);
|
|
751
751
|
if (!eq)
|
|
752
752
|
return;
|
|
753
|
-
|
|
753
|
+
let val = keyPropertyValue(value, eq);
|
|
754
754
|
if (val)
|
|
755
755
|
return lexer_1.default.tokenize(value, index, val.next, {
|
|
756
756
|
key: prop,
|
|
@@ -759,7 +759,7 @@ var Expressions;
|
|
|
759
759
|
}
|
|
760
760
|
Expressions.keyValuePair = keyValuePair;
|
|
761
761
|
function keyPropertyValue(value, index) {
|
|
762
|
-
|
|
762
|
+
let token = primitiveLiteral_1.default.primitiveLiteral(value, index);
|
|
763
763
|
if (token) {
|
|
764
764
|
token.type = lexer_1.default.TokenType.KeyPropertyValue;
|
|
765
765
|
return token;
|
|
@@ -771,13 +771,13 @@ var Expressions;
|
|
|
771
771
|
function singleNavigationExpr(value, index) {
|
|
772
772
|
if (value[index] !== 0x2f)
|
|
773
773
|
return;
|
|
774
|
-
|
|
774
|
+
let member = memberExpr(value, index + 1);
|
|
775
775
|
if (member)
|
|
776
776
|
return lexer_1.default.tokenize(value, index, member.next, member, lexer_1.default.TokenType.SingleNavigationExpression);
|
|
777
777
|
}
|
|
778
778
|
Expressions.singleNavigationExpr = singleNavigationExpr;
|
|
779
779
|
function collectionPathExpr(value, index) {
|
|
780
|
-
|
|
780
|
+
let token = countExpr(value, index);
|
|
781
781
|
if (!token) {
|
|
782
782
|
if (value[index] === 0x2f) {
|
|
783
783
|
token = boundFunctionExpr(value, index + 1) ||
|
|
@@ -792,15 +792,15 @@ var Expressions;
|
|
|
792
792
|
function complexPathExpr(value, index) {
|
|
793
793
|
if (value[index] !== 0x2f)
|
|
794
794
|
return;
|
|
795
|
-
|
|
795
|
+
let start = index;
|
|
796
796
|
index++;
|
|
797
|
-
|
|
797
|
+
let token = nameOrIdentifier_1.default.qualifiedComplexTypeName(value, index);
|
|
798
798
|
if (token) {
|
|
799
799
|
if (value[token.next] !== 0x2f)
|
|
800
800
|
return;
|
|
801
801
|
index = token.next + 1;
|
|
802
802
|
}
|
|
803
|
-
|
|
803
|
+
let expr = propertyPathExpr(value, index) ||
|
|
804
804
|
boundFunctionExpr(value, index);
|
|
805
805
|
if (expr)
|
|
806
806
|
return lexer_1.default.tokenize(value, start, expr.next, token ? [token, expr] : [expr], lexer_1.default.TokenType.ComplexPathExpression);
|
|
@@ -809,29 +809,29 @@ var Expressions;
|
|
|
809
809
|
function singlePathExpr(value, index) {
|
|
810
810
|
if (value[index] !== 0x2f)
|
|
811
811
|
return;
|
|
812
|
-
|
|
812
|
+
let boundFunction = boundFunctionExpr(value, index + 1);
|
|
813
813
|
if (boundFunction)
|
|
814
814
|
return lexer_1.default.tokenize(value, index, boundFunction.next, boundFunction, lexer_1.default.TokenType.SinglePathExpression);
|
|
815
815
|
}
|
|
816
816
|
Expressions.singlePathExpr = singlePathExpr;
|
|
817
817
|
function functionExpr(value, index) {
|
|
818
|
-
|
|
818
|
+
let namespaceNext = nameOrIdentifier_1.default.namespace(value, index);
|
|
819
819
|
if (namespaceNext === index || value[namespaceNext] !== 0x2e)
|
|
820
820
|
return;
|
|
821
|
-
|
|
821
|
+
let start = index;
|
|
822
822
|
index = namespaceNext + 1;
|
|
823
|
-
|
|
823
|
+
let token = nameOrIdentifier_1.default.odataIdentifier(value, index);
|
|
824
824
|
if (!token)
|
|
825
825
|
return;
|
|
826
826
|
token.position = start;
|
|
827
827
|
token.value.namespace = utils_1.default.stringify(value, start, namespaceNext);
|
|
828
828
|
token.raw = utils_1.default.stringify(value, start, token.next);
|
|
829
829
|
index = token.next;
|
|
830
|
-
|
|
830
|
+
let params = functionExprParameters(value, index);
|
|
831
831
|
if (!params)
|
|
832
832
|
return;
|
|
833
833
|
index = params.next;
|
|
834
|
-
|
|
834
|
+
let expr = collectionPathExpr(value, index) ||
|
|
835
835
|
collectionNavigationExpr(value, index) ||
|
|
836
836
|
singleNavigationExpr(value, index) ||
|
|
837
837
|
complexPathExpr(value, index) ||
|
|
@@ -848,16 +848,16 @@ var Expressions;
|
|
|
848
848
|
function boundFunctionExpr(value, index) { return functionExpr(value, index); }
|
|
849
849
|
Expressions.boundFunctionExpr = boundFunctionExpr;
|
|
850
850
|
function functionExprParameters(value, index) {
|
|
851
|
-
|
|
851
|
+
let open = lexer_1.default.OPEN(value, index);
|
|
852
852
|
if (!open)
|
|
853
853
|
return;
|
|
854
|
-
|
|
854
|
+
let start = index;
|
|
855
855
|
index = open;
|
|
856
|
-
|
|
857
|
-
|
|
856
|
+
let params = [];
|
|
857
|
+
let expr = functionExprParameter(value, index);
|
|
858
858
|
while (expr) {
|
|
859
859
|
params.push(expr);
|
|
860
|
-
|
|
860
|
+
let comma = lexer_1.default.COMMA(value, expr.next);
|
|
861
861
|
if (comma) {
|
|
862
862
|
index = comma;
|
|
863
863
|
expr = functionExprParameter(value, index);
|
|
@@ -869,7 +869,7 @@ var Expressions;
|
|
|
869
869
|
expr = null;
|
|
870
870
|
}
|
|
871
871
|
}
|
|
872
|
-
|
|
872
|
+
let close = lexer_1.default.CLOSE(value, index);
|
|
873
873
|
if (!close)
|
|
874
874
|
return;
|
|
875
875
|
index = close;
|
|
@@ -877,15 +877,15 @@ var Expressions;
|
|
|
877
877
|
}
|
|
878
878
|
Expressions.functionExprParameters = functionExprParameters;
|
|
879
879
|
function functionExprParameter(value, index) {
|
|
880
|
-
|
|
880
|
+
let name = parameterName(value, index);
|
|
881
881
|
if (!name)
|
|
882
882
|
return;
|
|
883
|
-
|
|
883
|
+
let eq = lexer_1.default.EQ(value, name.next);
|
|
884
884
|
if (!name || !eq)
|
|
885
885
|
return;
|
|
886
|
-
|
|
886
|
+
let start = index;
|
|
887
887
|
index = eq;
|
|
888
|
-
|
|
888
|
+
let param = parameterAlias(value, index) ||
|
|
889
889
|
parameterValue(value, index);
|
|
890
890
|
if (!param)
|
|
891
891
|
return;
|
|
@@ -898,16 +898,16 @@ var Expressions;
|
|
|
898
898
|
function parameterName(value, index) { return nameOrIdentifier_1.default.odataIdentifier(value, index, lexer_1.default.TokenType.ParameterName); }
|
|
899
899
|
Expressions.parameterName = parameterName;
|
|
900
900
|
function parameterAlias(value, index) {
|
|
901
|
-
|
|
901
|
+
let at = lexer_1.default.AT(value, index);
|
|
902
902
|
if (!at)
|
|
903
903
|
return;
|
|
904
|
-
|
|
904
|
+
let id = nameOrIdentifier_1.default.odataIdentifier(value, at);
|
|
905
905
|
if (id)
|
|
906
906
|
return lexer_1.default.tokenize(value, index, id.next, id.value, lexer_1.default.TokenType.ParameterAlias);
|
|
907
907
|
}
|
|
908
908
|
Expressions.parameterAlias = parameterAlias;
|
|
909
909
|
function parameterValue(value, index) {
|
|
910
|
-
|
|
910
|
+
let token = json_1.default.arrayOrObject(value, index) ||
|
|
911
911
|
commonExpr(value, index);
|
|
912
912
|
if (token)
|
|
913
913
|
return lexer_1.default.tokenize(value, index, token.next, token.value, lexer_1.default.TokenType.ParameterValue);
|
|
@@ -931,10 +931,10 @@ var Expressions;
|
|
|
931
931
|
function rootExpr(value, index) {
|
|
932
932
|
if (!utils_1.default.equals(value, index, "$root/"))
|
|
933
933
|
return;
|
|
934
|
-
|
|
934
|
+
let start = index;
|
|
935
935
|
index += 6;
|
|
936
|
-
|
|
937
|
-
|
|
936
|
+
let entitySet = nameOrIdentifier_1.default.entitySetName(value, index);
|
|
937
|
+
let predicate, entity, token;
|
|
938
938
|
if (entitySet)
|
|
939
939
|
predicate = keyPredicate(value, entitySet.next);
|
|
940
940
|
if (!(entitySet && predicate)) {
|
|
@@ -951,7 +951,7 @@ var Expressions;
|
|
|
951
951
|
keys: predicate
|
|
952
952
|
};
|
|
953
953
|
index = (predicate || entity).next;
|
|
954
|
-
|
|
954
|
+
let nav = singleNavigationExpr(value, index);
|
|
955
955
|
if (nav)
|
|
956
956
|
index = nav.next;
|
|
957
957
|
return lexer_1.default.tokenize(value, start, index, {
|