@fibery/expression-utils 9.0.3 → 9.0.4
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/expression-utils.js +23 -4
- package/lib/visitors.js +23 -4
- package/package.json +1 -1
package/lib/expression-utils.js
CHANGED
|
@@ -445,18 +445,25 @@ const visitFieldExpression = ({
|
|
|
445
445
|
});
|
|
446
446
|
const defaultOnFieldNotFound = () => undefined;
|
|
447
447
|
const defaultOnField = () => undefined;
|
|
448
|
-
const
|
|
448
|
+
const fieldAccessVisitorTypeAwareInternal = ({
|
|
449
449
|
typeObject,
|
|
450
|
+
rootTypeObject,
|
|
450
451
|
onField = defaultOnField,
|
|
451
452
|
onFieldNotFound = defaultOnFieldNotFound
|
|
452
453
|
}) => {
|
|
453
|
-
|
|
454
|
+
return createExpressionVisitor({
|
|
454
455
|
visitFieldExpression: expression => visitFieldExpression({
|
|
455
456
|
typeObject,
|
|
456
457
|
expression,
|
|
457
458
|
onField,
|
|
458
459
|
onFieldNotFound
|
|
459
460
|
}).expression,
|
|
461
|
+
visitFromRootFieldExpression: ([fromRootKeyword, ...rest]) => [fromRootKeyword, ...rest.map(x => fieldAccessVisitorTypeAwareInternal({
|
|
462
|
+
typeObject: rootTypeObject,
|
|
463
|
+
rootTypeObject,
|
|
464
|
+
onField,
|
|
465
|
+
onFieldNotFound
|
|
466
|
+
}).visitExpression(x))],
|
|
460
467
|
visitQueryExpression: subQueryExpression => {
|
|
461
468
|
const {
|
|
462
469
|
"q/from": fromExpression,
|
|
@@ -471,8 +478,9 @@ const fieldAccessVisitorTypeAware = ({
|
|
|
471
478
|
onFieldNotFound
|
|
472
479
|
});
|
|
473
480
|
if (fromVisitResult != null && fromVisitResult.typeObject) {
|
|
474
|
-
const subQueryVisitor =
|
|
481
|
+
const subQueryVisitor = fieldAccessVisitorTypeAwareInternal({
|
|
475
482
|
typeObject: fromVisitResult == null ? void 0 : fromVisitResult.typeObject,
|
|
483
|
+
rootTypeObject,
|
|
476
484
|
onField,
|
|
477
485
|
onFieldNotFound
|
|
478
486
|
});
|
|
@@ -493,7 +501,18 @@ const fieldAccessVisitorTypeAware = ({
|
|
|
493
501
|
return subQueryExpression;
|
|
494
502
|
}
|
|
495
503
|
});
|
|
496
|
-
|
|
504
|
+
};
|
|
505
|
+
const fieldAccessVisitorTypeAware = ({
|
|
506
|
+
typeObject,
|
|
507
|
+
onField = defaultOnField,
|
|
508
|
+
onFieldNotFound = defaultOnFieldNotFound
|
|
509
|
+
}) => {
|
|
510
|
+
return fieldAccessVisitorTypeAwareInternal({
|
|
511
|
+
typeObject,
|
|
512
|
+
rootTypeObject: typeObject,
|
|
513
|
+
onField,
|
|
514
|
+
onFieldNotFound
|
|
515
|
+
});
|
|
497
516
|
};
|
|
498
517
|
|
|
499
518
|
const defaultIdsWithNamesOnFieldNotFound = ({
|
package/lib/visitors.js
CHANGED
|
@@ -180,18 +180,25 @@ const visitFieldExpression = ({
|
|
|
180
180
|
});
|
|
181
181
|
const defaultOnFieldNotFound = () => undefined;
|
|
182
182
|
const defaultOnField = () => undefined;
|
|
183
|
-
const
|
|
183
|
+
const fieldAccessVisitorTypeAwareInternal = ({
|
|
184
184
|
typeObject,
|
|
185
|
+
rootTypeObject,
|
|
185
186
|
onField = defaultOnField,
|
|
186
187
|
onFieldNotFound = defaultOnFieldNotFound
|
|
187
188
|
}) => {
|
|
188
|
-
|
|
189
|
+
return createExpressionVisitor({
|
|
189
190
|
visitFieldExpression: expression => visitFieldExpression({
|
|
190
191
|
typeObject,
|
|
191
192
|
expression,
|
|
192
193
|
onField,
|
|
193
194
|
onFieldNotFound
|
|
194
195
|
}).expression,
|
|
196
|
+
visitFromRootFieldExpression: ([fromRootKeyword, ...rest]) => [fromRootKeyword, ...rest.map(x => fieldAccessVisitorTypeAwareInternal({
|
|
197
|
+
typeObject: rootTypeObject,
|
|
198
|
+
rootTypeObject,
|
|
199
|
+
onField,
|
|
200
|
+
onFieldNotFound
|
|
201
|
+
}).visitExpression(x))],
|
|
195
202
|
visitQueryExpression: subQueryExpression => {
|
|
196
203
|
const {
|
|
197
204
|
"q/from": fromExpression,
|
|
@@ -206,8 +213,9 @@ const fieldAccessVisitorTypeAware = ({
|
|
|
206
213
|
onFieldNotFound
|
|
207
214
|
});
|
|
208
215
|
if (fromVisitResult != null && fromVisitResult.typeObject) {
|
|
209
|
-
const subQueryVisitor =
|
|
216
|
+
const subQueryVisitor = fieldAccessVisitorTypeAwareInternal({
|
|
210
217
|
typeObject: fromVisitResult == null ? void 0 : fromVisitResult.typeObject,
|
|
218
|
+
rootTypeObject,
|
|
211
219
|
onField,
|
|
212
220
|
onFieldNotFound
|
|
213
221
|
});
|
|
@@ -228,7 +236,18 @@ const fieldAccessVisitorTypeAware = ({
|
|
|
228
236
|
return subQueryExpression;
|
|
229
237
|
}
|
|
230
238
|
});
|
|
231
|
-
|
|
239
|
+
};
|
|
240
|
+
const fieldAccessVisitorTypeAware = ({
|
|
241
|
+
typeObject,
|
|
242
|
+
onField = defaultOnField,
|
|
243
|
+
onFieldNotFound = defaultOnFieldNotFound
|
|
244
|
+
}) => {
|
|
245
|
+
return fieldAccessVisitorTypeAwareInternal({
|
|
246
|
+
typeObject,
|
|
247
|
+
rootTypeObject: typeObject,
|
|
248
|
+
onField,
|
|
249
|
+
onFieldNotFound
|
|
250
|
+
});
|
|
232
251
|
};
|
|
233
252
|
|
|
234
253
|
const defaultIdsWithNamesOnFieldNotFound = ({
|