@elsikora/nestjs-crud-automator
Version:
A library for automating the creation of CRUD operations in NestJS.
22 lines (21 loc) • 1.47 kB
TypeScript
import { EApiDtoType, EApiRouteType } from '../../../enum/decorator/api';
import { IApiEntity } from '../../../interface/entity';
import { Type } from '@nestjs/common';
import { IAuthGuard } from '@nestjs/passport';
import { TApiPropertyDescribeProperties } from '../../../type/decorator/api/property';
/**
* Generates dynamic DTOs for object-type properties based on property metadata.
* Creates classes on the fly with appropriate decorators for each property and sets up
* proper inheritance and naming conventions.
* @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
* @returns {Record<string, Type<unknown>> | undefined} A record of generated DTO classes or undefined if generation not needed
* @template E - The entity type
* @template M - The API route type
* @template D - The DTO type
*/
export declare function DtoGenerateDynamic<E, M extends EApiRouteType, D extends EApiDtoType>(method: M, propertyMetadata: TApiPropertyDescribeProperties, entity: IApiEntity<E>, dtoType: D, _propertyName: string, currentGuard?: Type<IAuthGuard>): Record<string, Type<unknown>> | undefined;