diff --git a/libs/prisma/src/interfaces/config-module-options.interface.ts b/libs/prisma/src/interfaces/config-module-options.interface.ts index 7c8abba..ee1e371 100644 --- a/libs/prisma/src/interfaces/config-module-options.interface.ts +++ b/libs/prisma/src/interfaces/config-module-options.interface.ts @@ -1,19 +1,14 @@ import { PrismaService } from '../prisma.service'; -import { - PrismaCreateProcess, - PrismaDeleteProcess, - PrismaPaginationProcess, - PrismaReadProcess, - PrismaUpdateProcess, -} from '../processes'; -import { PrismaListProcess } from '../processes/list.process'; +// @TODO: Find way to use typesafe in each of the process property +// Known Issue: +// - You cannot be able modified the constructor extended to each process export interface PrismaModuleOptions { - delegate: (prisma: PrismaService) => unknown; - processCreate?: typeof PrismaCreateProcess; - processDelete?: typeof PrismaDeleteProcess; - processList?: typeof PrismaListProcess; - processPagination?: typeof PrismaPaginationProcess; - processRead?: typeof PrismaReadProcess; - processUpdate?: typeof PrismaUpdateProcess; + delegate: (prisma: PrismaService) => any; + processCreate?; + processDelete?; + processList?; + processPagination?; + processRead?; + processUpdate?; } diff --git a/src/example/custom/custom.module.ts b/src/example/custom/custom.module.ts index a9d59d4..c049dec 100644 --- a/src/example/custom/custom.module.ts +++ b/src/example/custom/custom.module.ts @@ -1,6 +1,6 @@ +import { PrismaModule } from '@aditama-labs/nest-autocrud/prisma'; import { Module } from '@nestjs/common'; import { PrismaClient } from '@prisma/client'; -import { PrismaModule } from 'libs'; import { CustomController } from './custom.controller'; import { CustomListProcess } from './domain/custom.list.process'; import { CustomReadProcess } from './domain/custom.read.process'; diff --git a/src/example/custom/domain/custom.read.process.ts b/src/example/custom/domain/custom.read.process.ts index 350b9c4..c22bd9f 100644 --- a/src/example/custom/domain/custom.read.process.ts +++ b/src/example/custom/domain/custom.read.process.ts @@ -1,9 +1,25 @@ -import { PrismaReadProcess } from '@aditama-labs/nest-autocrud/prisma'; +import { + PRISMA_DELEGATE, + PrismaReadProcess, + PrismaService, +} from '@aditama-labs/nest-autocrud/prisma'; +import { Inject, Injectable } from '@nestjs/common'; +@Injectable() export class CustomReadProcess extends PrismaReadProcess { + constructor( + @Inject(PRISMA_DELEGATE) + delegate, + @Inject() + private prisma: PrismaService, + ) { + super(delegate); + } + customResult; async before(): Promise { + console.log(await this.prisma.user.findMany()); console.log('The ID requested in path parameter', this.identityData); } async after(): Promise { diff --git a/src/example/simple/simple.module.ts b/src/example/simple/simple.module.ts index ff74a72..6026d09 100644 --- a/src/example/simple/simple.module.ts +++ b/src/example/simple/simple.module.ts @@ -1,6 +1,6 @@ +import { PrismaModule } from '@aditama-labs/nest-autocrud/prisma'; import { Module } from '@nestjs/common'; import { PrismaClient } from '@prisma/client'; -import { PrismaModule } from 'libs'; import { SimpleController } from './simple.controller'; @Module({