@buka/nestjs-type-helper
Version:
An easy to use nestjs config module
27 lines (26 loc) • 1.54 kB
TypeScript
import { SchemaObjectMetadata } from '@nestjs/swagger/dist/interfaces/schema-object-metadata.interface';
import { Type } from '@nestjs/common';
import { clonePluginMetadataFactory } from '@nestjs/swagger/dist/type-helpers/mapped-types.utils';
export { SchemaObjectMetadata } from '@nestjs/swagger/dist/interfaces/schema-object-metadata.interface';
/**
* 克隆 @nestjs/swagger Plugin 添加的元数据
*/
export declare const cloneSwaggerPluginMetadataFactory: typeof clonePluginMetadataFactory;
export declare function cloneMetadata(target: Function, source: Type<unknown>, keys: string[]): void;
/**
* 获取 @ApiProperty 添加的 Metadata
*/
export declare function getMetadataOfDecorator(classRef: Type<any>): Record<string, SchemaObjectMetadata>;
export declare function getMetadataOfDecorator(classRef: Type<any>, propertyKey: string): SchemaObjectMetadata | undefined;
/**
* Get all metadata of @ApiProperty() defined on the class.
*
* 可以利用这个函数,遍历 Dto/Entity 上定义的所有属性,而不需要去实例化一个对象
*/
export declare function getMetadata(classRef: Type<any>): Record<string, SchemaObjectMetadata>;
export declare function getMetadata(classRef: Type<any>, propertyKey: string): SchemaObjectMetadata;
/**
* Set @ApiProperty() to all properties of the class.
*/
export declare function overridePluginMetadata(classRef: Type<any>, props: Record<string, SchemaObjectMetadata>): void;
export declare function getMetadataType(metadata: SchemaObjectMetadata): string | Function;