import { CustomDecorator, Type } from '@nestjs/common'; /** * @publicApi */ export interface CreateDecoratorOptions { /** * The key for the metadata. * @default uid(21) */ key?: string; /** * The transform function to apply to the metadata value. * @default value => value */ transform?: (value: TParam) => TTransformed; } type CreateDecoratorWithTransformOptions = CreateDecoratorOptions & Required, 'transform'>>; /** * @publicApi */ export type ReflectableDecorator = ((opts?: TParam) => CustomDecorator) & { KEY: string; }; /** * Helper class providing Nest reflection capabilities. * * @see [Reflection](https://docs.nestjs.com/guards#putting-it-all-together) * * @publicApi */ export declare class Reflector { /** * Creates a decorator that can be used to decorate classes and methods with metadata. * Can be used as a strongly-typed alternative to `@SetMetadata`. * @param options Decorator options. * @returns A decorator function. */ static createDecorator(options?: CreateDecoratorOptions): ReflectableDecorator; static createDecorator(options: CreateDecoratorWithTransformOptions): ReflectableDecorator; /** * Retrieve metadata for a reflectable decorator for a specified target. * * @example * `const roles = this.reflector.get(Roles, context.getHandler());` * * @param decorator reflectable decorator created through `Reflector.createDecorator` * @param target context (decorated object) to retrieve metadata from * */ get>(decorator: T, target: Type | Function): T extends ReflectableDecorator ? R : unknown; /** * Retrieve metadata for a specified key for a specified target. * * @example * `const roles = this.reflector.get('roles', context.getHandler());` * * @param metadataKey lookup key for metadata to retrieve * @param target context (decorated object) to retrieve metadata from * */ get(metadataKey: TKey, target: Type | Function): TResult; /** * Retrieve metadata for a specified decorator for a specified set of targets. * * @param decorator lookup decorator for metadata to retrieve * @param targets context (decorated objects) to retrieve metadata from * */ getAll(decorator: ReflectableDecorator, targets: (Type | Function)[]): TTransformed extends Array ? TTransformed : TTransformed[]; /** * Retrieve metadata for a specified key for a specified set of targets. * * @param metadataKey lookup key for metadata to retrieve * @param targets context (decorated objects) to retrieve metadata from * */ getAll(metadataKey: TKey, targets: (Type | Function)[]): TResult; /** * Retrieve metadata for a specified decorator for a specified set of targets and merge results. * * @param decorator lookup decorator for metadata to retrieve * @param targets context (decorated objects) to retrieve metadata from * */ getAllAndMerge(decorator: ReflectableDecorator, targets: (Type | Function)[]): TTransformed extends Array ? TTransformed : TTransformed extends object ? TTransformed : TTransformed[]; /** * Retrieve metadata for a specified key for a specified set of targets and merge results. * * @param metadataKey lookup key for metadata to retrieve * @param targets context (decorated objects) to retrieve metadata from * */ getAllAndMerge(metadataKey: TKey, targets: (Type | Function)[]): TResult; /** * Retrieve metadata for a specified decorator for a specified set of targets and return a first not undefined value. * * @param decorator lookup decorator for metadata to retrieve * @param targets context (decorated objects) to retrieve metadata from * */ getAllAndOverride(decorator: ReflectableDecorator, targets: (Type | Function)[]): TTransformed; /** * Retrieve metadata for a specified key for a specified set of targets and return a first not undefined value. * * @param metadataKey lookup key for metadata to retrieve * @param targets context (decorated objects) to retrieve metadata from * */ getAllAndOverride(metadataKey: TKey, targets: (Type | Function)[]): TResult; } export {};