From 054485d2fa264844930522ad4cb0ccd044e9fcdd Mon Sep 17 00:00:00 2001 From: Artem-Darius Atlas Date: Thu, 27 Jul 2023 22:14:10 +0300 Subject: [PATCH] fix: Prisma Args Types namespace --- apps/auth/src/prisma/prisma.module.ts | 2 ++ .../auth/src/prisma/service/prisma.service.ts | 4 ++-- apps/user-data/src/email/email.controller.ts | 16 +++++++-------- .../src/email/service/email.service.ts | 20 ++++++++----------- .../phone-number/phone-number.controller.ts | 20 ++++++++----------- .../service/phone-number.service.ts | 19 ++++++++---------- .../src/user/service/user.service.ts | 19 ++++++++---------- apps/user-data/src/user/user.controller.ts | 19 ++++++++---------- 8 files changed, 52 insertions(+), 67 deletions(-) diff --git a/apps/auth/src/prisma/prisma.module.ts b/apps/auth/src/prisma/prisma.module.ts index 44400fd..8ce4dd5 100644 --- a/apps/auth/src/prisma/prisma.module.ts +++ b/apps/auth/src/prisma/prisma.module.ts @@ -1,4 +1,6 @@ import { Global, Module } from "@nestjs/common"; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore import { PrismaService } from "./service/prisma.service"; @Global() diff --git a/apps/auth/src/prisma/service/prisma.service.ts b/apps/auth/src/prisma/service/prisma.service.ts index aaa764a..7f2678e 100644 --- a/apps/auth/src/prisma/service/prisma.service.ts +++ b/apps/auth/src/prisma/service/prisma.service.ts @@ -1,8 +1,8 @@ import { INestApplication, Injectable, OnModuleInit } from "@nestjs/common"; -import { PrismaClient } from "@prisma/client"; +import { AuthClient } from "@platform/prisma-clients"; @Injectable() -export class PrismaService extends PrismaClient implements OnModuleInit { +export class PrismaService extends AuthClient implements OnModuleInit { async onModuleInit() { await this.$connect(); } diff --git a/apps/user-data/src/email/email.controller.ts b/apps/user-data/src/email/email.controller.ts index 4cdddb4..d21a845 100644 --- a/apps/user-data/src/email/email.controller.ts +++ b/apps/user-data/src/email/email.controller.ts @@ -1,5 +1,5 @@ import { Body, Controller, HttpCode, Inject, Post, UseInterceptors } from "@nestjs/common"; -import { EmailFindUniqueArgs, EmailFindFirstArgs, EmailFindManyArgs, EmailUpdateArgs, EmailCountArgs, EmailCreateArgs, EmailDeleteArgs, Email } from "@platform/prisma-clients/user-data"; +import { Prisma, Email } from "@platform/prisma-clients/user-data"; import { EmailService } from "./service/email.service"; import { PrismaErrorInterceptor } from "../prisma/interceptor/prisma-error.interceptor"; @@ -11,43 +11,43 @@ export class EmailController { @Post("find/unique") @HttpCode(200) - async FindUnique(@Body() emailFindUniqueArgs: EmailFindUniqueArgs): Promise | null> { + async FindUnique(@Body() emailFindUniqueArgs: Prisma.EmailFindUniqueArgs): Promise | null> { return await this.email.FindUnique(emailFindUniqueArgs); } @Post("find/first") @HttpCode(200) - async FindFirst(@Body() emailFindFirstArgs: EmailFindFirstArgs): Promise | null> { + async FindFirst(@Body() emailFindFirstArgs: Prisma.EmailFindFirstArgs): Promise | null> { return await this.email.FindFirst(emailFindFirstArgs); } @Post("find/many") @HttpCode(200) - async FindMany(@Body() emailFindManyArgs: EmailFindManyArgs): Promise[]> { + async FindMany(@Body() emailFindManyArgs: Prisma.EmailFindManyArgs): Promise[]> { return await this.email.FindMany(emailFindManyArgs); } @Post("update") @HttpCode(200) - async Update(@Body() emailUpdateArgs: EmailUpdateArgs): Promise> { + async Update(@Body() emailUpdateArgs: Prisma.EmailUpdateArgs): Promise> { return await this.email.Update(emailUpdateArgs); } @Post("count") @HttpCode(200) - async Count(@Body() emailCountArgs: EmailCountArgs): Promise { + async Count(@Body() emailCountArgs: Prisma.EmailCountArgs): Promise { return await this.email.Count(emailCountArgs); } @Post("create") @HttpCode(200) - async Create(@Body() emailCreateArgs: EmailCreateArgs): Promise> { + async Create(@Body() emailCreateArgs: Prisma.EmailCreateArgs): Promise> { return await this.email.Create(emailCreateArgs); } @Post("delete") @HttpCode(200) - async Delete(@Body() emailDeleteArgs: EmailDeleteArgs): Promise> { + async Delete(@Body() emailDeleteArgs: Prisma.EmailDeleteArgs): Promise> { return await this.email.Delete(emailDeleteArgs); } } diff --git a/apps/user-data/src/email/service/email.service.ts b/apps/user-data/src/email/service/email.service.ts index 6bf6711..e8df5e7 100644 --- a/apps/user-data/src/email/service/email.service.ts +++ b/apps/user-data/src/email/service/email.service.ts @@ -1,10 +1,6 @@ import { Inject, Injectable } from "@nestjs/common"; import { PrismaService } from '../../prisma/service/prisma.service'; -import { UserDataClient as Prisma } from "@platform/prisma-clients"; -import { Email, EmailFindUniqueArgs, - EmailFindFirstArgs, EmailFindManyArgs, EmailUpdateArgs, - EmailCountArgs, EmailCreateArgs, EmailDeleteArgs - } from "@platform/prisma-clients/user-data"; +import { Email, Prisma } from "@platform/prisma-clients/user-data"; import { PrismaClientKnownRequestError } from "@prisma/client/runtime"; import { UniqueConstraintFailedError } from "../../prisma/error/unique-constraint-failed.error"; import { RecordNotFoundError } from "../../prisma/error/record-not-found.error"; @@ -14,19 +10,19 @@ export class EmailService { constructor(@Inject(PrismaService) private prisma: PrismaService) { } - async FindUnique(emailFindUniqueArgs: EmailFindUniqueArgs): Promise | null> { + async FindUnique(emailFindUniqueArgs: Prisma.EmailFindUniqueArgs): Promise | null> { return await this.prisma.email.findUnique(emailFindUniqueArgs); } - async FindFirst(emailFindFirstArgs: EmailFindFirstArgs): Promise | null> { + async FindFirst(emailFindFirstArgs: Prisma.EmailFindFirstArgs): Promise | null> { return await this.prisma.email.findFirst(emailFindFirstArgs); } - async FindMany(emailFindManyArgs: EmailFindManyArgs): Promise[]> { + async FindMany(emailFindManyArgs: Prisma.EmailFindManyArgs): Promise[]> { return await this.prisma.email.findMany(emailFindManyArgs); } - async Update(emailUpdateArgs: EmailUpdateArgs): Promise> { + async Update(emailUpdateArgs: Prisma.EmailUpdateArgs): Promise> { try { return await this.prisma.email.update(emailUpdateArgs); } catch (e) { @@ -38,11 +34,11 @@ export class EmailService { } } - async Count(emailCountArgs: EmailCountArgs): Promise { + async Count(emailCountArgs: Prisma.EmailCountArgs): Promise { return await this.prisma.email.count(emailCountArgs); } - async Create(emailCreateArgs: EmailCreateArgs): Promise> { + async Create(emailCreateArgs: Prisma.EmailCreateArgs): Promise> { try { return await this.prisma.email.create(emailCreateArgs); } catch (e) { @@ -53,7 +49,7 @@ export class EmailService { } } - async Delete(emailDeleteArgs: EmailDeleteArgs): Promise> { + async Delete(emailDeleteArgs: Prisma.EmailDeleteArgs): Promise> { try { return await this.prisma.email.delete(emailDeleteArgs); } catch (e) { diff --git a/apps/user-data/src/phone-number/phone-number.controller.ts b/apps/user-data/src/phone-number/phone-number.controller.ts index 185d5a2..80f6fca 100644 --- a/apps/user-data/src/phone-number/phone-number.controller.ts +++ b/apps/user-data/src/phone-number/phone-number.controller.ts @@ -1,9 +1,5 @@ import { Body, Controller, HttpCode, Inject, Post, UseInterceptors } from "@nestjs/common"; -import { UserDataClient as Prisma } from "@platform/prisma-clients"; -import { PhoneNumber, PhoneNumberFindUniqueArgs, - PhoneNumberFindFirstArgs, PhoneNumberFindManyArgs, PhoneNumberUpdateArgs, - PhoneNumberCountArgs, PhoneNumberCreateArgs, PhoneNumberDeleteArgs -} from "@platform/prisma-clients/user-data"; +import { PhoneNumber, Prisma } from "@platform/prisma-clients/user-data"; import { PhoneNumberService } from "./service/phone-number.service"; import { PrismaErrorInterceptor } from "../prisma/interceptor/prisma-error.interceptor"; @@ -15,43 +11,43 @@ export class PhoneNumberController { @Post("find/unique") @HttpCode(200) - async FindUnique(@Body() phoneNumberFindUniqueArgs: PhoneNumberFindUniqueArgs): Promise | null> { + async FindUnique(@Body() phoneNumberFindUniqueArgs: Prisma.PhoneNumberFindUniqueArgs): Promise | null> { return await this.phoneNumber.FindUnique(phoneNumberFindUniqueArgs); } @Post("find/first") @HttpCode(200) - async FindFirst(@Body() phoneNumberFindFirstArgs: PhoneNumberFindFirstArgs): Promise | null> { + async FindFirst(@Body() phoneNumberFindFirstArgs: Prisma.PhoneNumberFindFirstArgs): Promise | null> { return await this.phoneNumber.FindFirst(phoneNumberFindFirstArgs); } @Post("find/many") @HttpCode(200) - async FindMany(@Body() phoneNumberFindManyArgs: PhoneNumberFindManyArgs): Promise[]> { + async FindMany(@Body() phoneNumberFindManyArgs: Prisma.PhoneNumberFindManyArgs): Promise[]> { return await this.phoneNumber.FindMany(phoneNumberFindManyArgs); } @Post("update") @HttpCode(200) - async Update(@Body() phoneNumberUpdateArgs: PhoneNumberUpdateArgs): Promise> { + async Update(@Body() phoneNumberUpdateArgs: Prisma.PhoneNumberUpdateArgs): Promise> { return await this.phoneNumber.Update(phoneNumberUpdateArgs); } @Post("count") @HttpCode(200) - async Count(@Body() phoneNumberCountArgs: PhoneNumberCountArgs): Promise { + async Count(@Body() phoneNumberCountArgs: Prisma.PhoneNumberCountArgs): Promise { return await this.phoneNumber.Count(phoneNumberCountArgs); } @Post("create") @HttpCode(200) - async Create(@Body() phoneNumberCreateArgs: PhoneNumberCreateArgs): Promise> { + async Create(@Body() phoneNumberCreateArgs: Prisma.PhoneNumberCreateArgs): Promise> { return await this.phoneNumber.Create(phoneNumberCreateArgs); } @Post("delete") @HttpCode(200) - async Delete(@Body() phoneNumberDeleteArgs: PhoneNumberDeleteArgs): Promise> { + async Delete(@Body() phoneNumberDeleteArgs: Prisma.PhoneNumberDeleteArgs): Promise> { return await this.phoneNumber.Delete(phoneNumberDeleteArgs); } } diff --git a/apps/user-data/src/phone-number/service/phone-number.service.ts b/apps/user-data/src/phone-number/service/phone-number.service.ts index 9c396f9..13c3315 100644 --- a/apps/user-data/src/phone-number/service/phone-number.service.ts +++ b/apps/user-data/src/phone-number/service/phone-number.service.ts @@ -1,9 +1,6 @@ import { Inject, Injectable } from "@nestjs/common"; import { PrismaService } from "../../prisma/service/prisma.service"; -import { PhoneNumber, PhoneNumberFindUniqueArgs, - PhoneNumberFindFirstArgs, PhoneNumberFindManyArgs, PhoneNumberUpdateArgs, - PhoneNumberCountArgs, PhoneNumberCreateArgs, PhoneNumberDeleteArgs -} from "@platform/prisma-clients/user-data"; +import { PhoneNumber, Prisma } from "@platform/prisma-clients/user-data"; import { PrismaClientKnownRequestError } from "@prisma/client/runtime"; import { UniqueConstraintFailedError } from "../../prisma/error/unique-constraint-failed.error"; import { RecordNotFoundError } from "../../prisma/error/record-not-found.error"; @@ -13,19 +10,19 @@ export class PhoneNumberService { constructor(@Inject(PrismaService) private prisma: PrismaService) { } - async FindUnique(phoneNumberFindUniqueArgs: PhoneNumberFindUniqueArgs): Promise | null> { + async FindUnique(phoneNumberFindUniqueArgs: Prisma.PhoneNumberFindUniqueArgs): Promise | null> { return await this.prisma.phoneNumber.findUnique(phoneNumberFindUniqueArgs); } - async FindFirst(phoneNumberFindFirstArgs: PhoneNumberFindFirstArgs): Promise | null> { + async FindFirst(phoneNumberFindFirstArgs: Prisma.PhoneNumberFindFirstArgs): Promise | null> { return await this.prisma.phoneNumber.findFirst(phoneNumberFindFirstArgs); } - async FindMany(phoneNumberFindManyArgs: PhoneNumberFindManyArgs): Promise[]> { + async FindMany(phoneNumberFindManyArgs: Prisma.PhoneNumberFindManyArgs): Promise[]> { return await this.prisma.phoneNumber.findMany(phoneNumberFindManyArgs); } - async Update(phoneNumberUpdateArgs: PhoneNumberUpdateArgs): Promise> { + async Update(phoneNumberUpdateArgs: Prisma.PhoneNumberUpdateArgs): Promise> { try { return await this.prisma.phoneNumber.update(phoneNumberUpdateArgs); } catch (e) { @@ -37,11 +34,11 @@ export class PhoneNumberService { } } - async Count(phoneNumberCountArgs: PhoneNumberCountArgs): Promise { + async Count(phoneNumberCountArgs: Prisma.PhoneNumberCountArgs): Promise { return await this.prisma.phoneNumber.count(phoneNumberCountArgs); } - async Create(phoneNumberCreateArgs: PhoneNumberCreateArgs): Promise> { + async Create(phoneNumberCreateArgs: Prisma.PhoneNumberCreateArgs): Promise> { try { return await this.prisma.phoneNumber.create(phoneNumberCreateArgs); } catch (e) { @@ -52,7 +49,7 @@ export class PhoneNumberService { } } - async Delete(phoneNumberDeleteArgs: PhoneNumberDeleteArgs): Promise> { + async Delete(phoneNumberDeleteArgs: Prisma.PhoneNumberDeleteArgs): Promise> { try { return await this.prisma.phoneNumber.delete(phoneNumberDeleteArgs); } catch (e) { diff --git a/apps/user-data/src/user/service/user.service.ts b/apps/user-data/src/user/service/user.service.ts index 05fafd3..e688ded 100644 --- a/apps/user-data/src/user/service/user.service.ts +++ b/apps/user-data/src/user/service/user.service.ts @@ -1,9 +1,6 @@ import { Inject, Injectable } from "@nestjs/common"; import { PrismaService } from "../../prisma/service/prisma.service"; -import { User, UserFindUniqueArgs, - UserFindUniqueArgs, UserFindFirstArgs, UserFindManyArgs, - UserUpdateArgs, UserCountArgs, UserCreateArgs, UserDeleteArgs -} from "@platform/prisma-clients/user-data"; +import { User, Prisma } from "@platform/prisma-clients/user-data"; import { PrismaClientKnownRequestError } from "@prisma/client/runtime"; import { UniqueConstraintFailedError } from "../../prisma/error/unique-constraint-failed.error"; import { RecordNotFoundError } from "../../prisma/error/record-not-found.error"; @@ -13,19 +10,19 @@ export class UserService { constructor(@Inject(PrismaService) private prisma: PrismaService) { } - async FindUnique(userFindUniqueArgs: UserFindUniqueArgs): Promise | null> { + async FindUnique(userFindUniqueArgs: Prisma.UserFindUniqueArgs): Promise | null> { return await this.prisma.user.findUnique(userFindUniqueArgs); } - async FindFirst(userFindFirstArgs: UserFindFirstArgs): Promise | null> { + async FindFirst(userFindFirstArgs: Prisma.UserFindFirstArgs): Promise | null> { return await this.prisma.user.findFirst(userFindFirstArgs); } - async FindMany(userFindManyArgs: UserFindManyArgs): Promise[]> { + async FindMany(userFindManyArgs: Prisma.UserFindManyArgs): Promise[]> { return await this.prisma.user.findMany(userFindManyArgs); } - async Update(userUpdateArgs: UserUpdateArgs): Promise> { + async Update(userUpdateArgs: Prisma.UserUpdateArgs): Promise> { try { return await this.prisma.user.update(userUpdateArgs); } catch (e) { @@ -37,11 +34,11 @@ export class UserService { } } - async Count(userCountArgs: UserCountArgs): Promise { + async Count(userCountArgs: Prisma.UserCountArgs): Promise { return await this.prisma.user.count(userCountArgs); } - async Create(userCreateArgs: UserCreateArgs): Promise> { + async Create(userCreateArgs: Prisma.UserCreateArgs): Promise> { try { return await this.prisma.user.create(userCreateArgs); } catch (e) { @@ -52,7 +49,7 @@ export class UserService { } } - async Delete(userDeleteArgs: UserDeleteArgs): Promise> { + async Delete(userDeleteArgs: Prisma.UserDeleteArgs): Promise> { try { return await this.prisma.user.delete(userDeleteArgs); } catch (e) { diff --git a/apps/user-data/src/user/user.controller.ts b/apps/user-data/src/user/user.controller.ts index 110ddd0..a472d04 100644 --- a/apps/user-data/src/user/user.controller.ts +++ b/apps/user-data/src/user/user.controller.ts @@ -1,8 +1,5 @@ import { Body, Controller, HttpCode, Inject, Post, UseInterceptors } from "@nestjs/common"; -import { User, UserFindUniqueArgs, - UserFindUniqueArgs, UserFindFirstArgs, UserFindManyArgs, - UserUpdateArgs, UserCountArgs, UserCreateArgs, UserDeleteArgs -} from "@platform/prisma-clients/user-data"; +import { User, Prisma } from "@platform/prisma-clients/user-data"; import { UserService } from "./service/user.service"; import { PrismaErrorInterceptor } from "../prisma/interceptor/prisma-error.interceptor"; @@ -14,43 +11,43 @@ export class UserController { @Post("find/unique") @HttpCode(200) - async FindUnique(@Body() userFindUniqueArgs: UserFindUniqueArgs): Promise | null> { + async FindUnique(@Body() userFindUniqueArgs: Prisma.UserFindUniqueArgs): Promise | null> { return await this.user.FindUnique(userFindUniqueArgs); } @Post("find/first") @HttpCode(200) - async FindFirst(@Body() userFindFirstArgs: UserFindFirstArgs): Promise | null> { + async FindFirst(@Body() userFindFirstArgs: Prisma.UserFindFirstArgs): Promise | null> { return await this.user.FindFirst(userFindFirstArgs); } @Post("find/many") @HttpCode(200) - async FindMany(@Body() userFindManyArgs: UserFindManyArgs): Promise[]> { + async FindMany(@Body() userFindManyArgs: Prisma.UserFindManyArgs): Promise[]> { return await this.user.FindMany(userFindManyArgs); } @Post("update") @HttpCode(200) - async Update(@Body() userUpdateArgs: UserUpdateArgs): Promise> { + async Update(@Body() userUpdateArgs: Prisma.UserUpdateArgs): Promise> { return await this.user.Update(userUpdateArgs); } @Post("count") @HttpCode(200) - async Count(@Body() userCountArgs: UserCountArgs): Promise { + async Count(@Body() userCountArgs: Prisma.UserCountArgs): Promise { return await this.user.Count(userCountArgs); } @Post("create") @HttpCode(200) - async Create(@Body() userCreateArgs: UserCreateArgs): Promise> { + async Create(@Body() userCreateArgs: Prisma.UserCreateArgs): Promise> { return await this.user.Create(userCreateArgs); } @Post("delete") @HttpCode(200) - async Delete(@Body() userDeleteArgs: UserDeleteArgs): Promise> { + async Delete(@Body() userDeleteArgs: Prisma.UserDeleteArgs): Promise> { return await this.user.Delete(userDeleteArgs); } }