field-selection.d.ts 1.0 KB

12345678910111213141516171819202122
  1. import { FieldInstance, Location, Request, UnknownFieldInstance } from './base';
  2. export type SelectFields = (req: Request, fields: string[], locations: Location[]) => FieldInstance[];
  3. export declare const selectFields: SelectFields;
  4. export declare const selectUnknownFields: (req: Request, knownFields: string[], locations: Location[]) => UnknownFieldInstance[];
  5. /**
  6. * Reconstructs a field path from a list of path segments.
  7. *
  8. * Most segments will be concatenated by a dot, for example `['foo', 'bar']` becomes `foo.bar`.
  9. * However, a numeric segment will be wrapped in brackets to match regular JS array syntax:
  10. *
  11. * ```
  12. * reconstructFieldPath(['foo', 0, 'bar']) // foo[0].bar
  13. * ```
  14. *
  15. * Segments which have a special character such as `.` will be wrapped in brackets and quotes,
  16. * which also matches JS syntax for objects with such keys.
  17. *
  18. * ```
  19. * reconstructFieldPath(['foo', 'bar.baz', 'qux']) // foo["bar.baz"].qux
  20. * ```
  21. */
  22. export declare function reconstructFieldPath(segments: readonly string[]): string;