UNPKG

@elsikora/nestjs-crud-automator

Version:

A library for automating the creation of CRUD operations in NestJS.

22 lines (21 loc) 1.56 kB
import { IApiEntity } from '../../interface/entity'; import { Type } from '@nestjs/common'; import { IAuthGuard } from '@nestjs/passport'; import { TApiPropertyDescribeProperties } from '../../type/decorator/api/property'; import { EApiDtoType, EApiRouteType } from '../../enum/decorator/api'; /** * Creates property decorators for DTOs based on property metadata, entity information, and context. * Handles special cases for date properties and guard-based exposure rules. * @param {M} method - The API route type (CREATE, DELETE, GET, etc.) * @param {TApiPropertyDescribeProperties} propertyMetadata - Metadata describing the property * @param {IApiEntity<E>} entity - The entity metadata * @param {D} dtoType - The type of DTO (REQUEST, RESPONSE, etc.) * @param {string} propertyName - The name of the property * @param {Type<IAuthGuard>} [currentGuard] - Optional authentication guard * @param {Record<string, Type<unknown>>} [generatedDTOs] - Optional record of dynamically generated DTOs * @returns {Array<PropertyDecorator> | undefined} Array of property decorators or undefined if property should not be included * @template E - The entity type * @template M - The API route type * @template D - The DTO type */ export declare function DtoBuildDecorator<E, M extends EApiRouteType, D extends EApiDtoType>(method: M, propertyMetadata: TApiPropertyDescribeProperties, entity: IApiEntity<E>, dtoType: D, propertyName: string, currentGuard?: Type<IAuthGuard>, generatedDTOs?: Record<string, Type<unknown>>): Array<PropertyDecorator> | undefined;