@fibery/expression-utils 9.0.2 → 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.
@@ -445,18 +445,25 @@ const visitFieldExpression = ({
445
445
  });
446
446
  const defaultOnFieldNotFound = () => undefined;
447
447
  const defaultOnField = () => undefined;
448
- const fieldAccessVisitorTypeAware = ({
448
+ const fieldAccessVisitorTypeAwareInternal = ({
449
449
  typeObject,
450
+ rootTypeObject,
450
451
  onField = defaultOnField,
451
452
  onFieldNotFound = defaultOnFieldNotFound
452
453
  }) => {
453
- const visitor = createExpressionVisitor({
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 = fieldAccessVisitorTypeAware({
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
- return visitor;
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 fieldAccessVisitorTypeAware = ({
183
+ const fieldAccessVisitorTypeAwareInternal = ({
184
184
  typeObject,
185
+ rootTypeObject,
185
186
  onField = defaultOnField,
186
187
  onFieldNotFound = defaultOnFieldNotFound
187
188
  }) => {
188
- const visitor = createExpressionVisitor({
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 = fieldAccessVisitorTypeAware({
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
- return visitor;
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 = ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/expression-utils",
3
- "version": "9.0.2",
3
+ "version": "9.0.4",
4
4
  "description": "utils for working with fibery api expressions",
5
5
  "exports": {
6
6
  ".": "./lib/expression-utils.js",
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
- import {Schema, TypeObject} from "@fibery/schema";
2
+ import {Schema, TypeObject, FieldObject} from "@fibery/schema";
3
3
 
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
5
  export type $TSFixMe = any;