UNPKG

nestjs-prisma-base

Version:

A comprehensive NestJS package providing base classes, utilities, and decorators for building CRUD APIs with Prisma ORM integration, featuring pagination, search, filtering, relation loading, configurable DTOs, and modular composition capabilities.

69 lines (68 loc) 3.17 kB
export type Constructor<T = {}> = new (...args: any[]) => T; export interface MixinConfig { swagger?: { enabled?: boolean; includeExamples?: boolean; includeDescriptions?: boolean; }; validation?: { enabled?: boolean; optional?: boolean; }; } export declare function WithTimestamps<T extends Constructor>(Base: T, config?: MixinConfig): { new (...args: any[]): { createdAt?: Date; updatedAt?: Date; }; } & T; export declare function WithSoftDelete<T extends Constructor>(Base: T, config?: MixinConfig): { new (...args: any[]): { deletedAt?: Date; isActive?: boolean; }; } & T; export declare function WithAuditFields<T extends Constructor>(Base: T, config?: MixinConfig): { new (...args: any[]): { createdBy?: number; updatedBy?: number; }; } & T; export declare function WithVersioning<T extends Constructor>(Base: T, config?: MixinConfig): { new (...args: any[]): { version?: number; }; } & T; export declare function WithId<T extends Constructor>(Base: T, config?: MixinConfig): { new (...args: any[]): { id?: number; }; } & T; export declare function WithMessage<T extends Constructor>(Base: T, config?: MixinConfig & { fieldName?: string; defaultMessage?: string; maxLength?: number; }): { new (...args: any[]): { message?: string; }; } & T; export type MixinType<T> = T extends Constructor<infer U> ? U : never; export type ComposedMixin<T extends readonly Constructor[]> = T extends readonly [infer First, ...infer Rest] ? First extends Constructor<infer U> ? Rest extends readonly Constructor[] ? Constructor<U> & ComposedMixin<Rest> : Constructor<U> : never : Constructor<{}>; export declare function composeMixins<T extends Constructor>(Base: T, ...mixins: Array<(base: Constructor) => Constructor>): T; export declare class MixinCombinations { static WithFullAuditTrail<T extends Constructor>(Base: T, config?: MixinConfig): T; static WithFullAuditTrailAndMessage<T extends Constructor>(Base: T, config?: MixinConfig): T; static WithSoftDeleteAndTimestamps<T extends Constructor>(Base: T, config?: MixinConfig): T; static WithSoftDeleteTimestampsAndMessage<T extends Constructor>(Base: T, config?: MixinConfig): T; static WithStandardEntity<T extends Constructor>(Base: T, config?: MixinConfig): T; static WithStandardEntityAndMessage<T extends Constructor>(Base: T, config?: MixinConfig): T; static WithCompleteEntity<T extends Constructor>(Base: T, config?: MixinConfig): T; static WithCompleteEntityAndMessage<T extends Constructor>(Base: T, config?: MixinConfig): T; static WithResponseEntity<T extends Constructor>(Base: T, config?: MixinConfig): T; static WithMinimalResponse<T extends Constructor>(Base: T, config?: MixinConfig): T; } export declare function DisableSwagger<T extends Constructor>(Base: T): T; export declare function DisableValidation<T extends Constructor>(Base: T): T; export declare function hasSwaggerDisabled(target: any): boolean; export declare function hasValidationDisabled(target: any): boolean;