import { Schema } from './schema'; type PromiseOrLiteral = Promise | V; export type PropertyResolver = ((value: V | undefined, obj: T, context: C, status: ResolverStatus) => PromiseOrLiteral) & { [IS_VIRTUAL]?: boolean; }; export type VirtualResolver = (obj: T, context: C, status: ResolverStatus) => PromiseOrLiteral; export declare const IS_VIRTUAL: unique symbol; /** * Create a resolver for a virtual property. A virtual property is a property that * is computed and never has an initial value. * * @param virtualResolver The virtual resolver function * @returns The property resolver function */ export declare const virtual: (virtualResolver: VirtualResolver) => PropertyResolver; export type PropertyResolverMap = { [key in keyof T]?: PropertyResolver | ReturnType>; }; export type ResolverConverter = (obj: any, context: C, status: ResolverStatus) => PromiseOrLiteral; export interface ResolverOptions { schema?: Schema; /** * A converter function that is run before property resolvers * to transform the initial data into a different format. */ converter?: ResolverConverter; } export interface ResolverConfig extends ResolverOptions { /** * @deprecated Use the `validateData` and `validateQuery` hooks explicitly instead */ validate?: 'before' | 'after' | false; /** * The properties to resolve */ properties: PropertyResolverMap; } export interface ResolverStatus { path: string[]; originalContext?: C; properties?: (keyof T)[]; stack: PropertyResolver[]; } export declare class Resolver { readonly options: ResolverConfig; readonly _type: T; propertyNames: (keyof T)[]; virtualNames: (keyof T)[]; constructor(options: ResolverConfig); /** * Resolve a single property * * @param name The name of the property * @param data The current data * @param context The current resolver context * @param status The current resolver status * @returns The resolver property */ resolveProperty(name: K, data: D, context: C, status?: Partial>): Promise; convert(data: D, context: C, status?: Partial>): Promise; resolve(_data: D, context: C, status?: Partial>): Promise; } /** * Create a new resolver with ``. * * @param options The configuration for the returned resolver * @returns A new resolver instance */ export declare function resolve(properties: PropertyResolverMap, options?: ResolverOptions): Resolver; export declare function resolve(options: ResolverConfig): Resolver; export {};