merge change from db
This commit is contained in:
Submodule epess-database updated: 4f40a566c8...8c3fa0fbbc
@@ -17,6 +17,7 @@
|
||||
"prisma:push": "npx prisma db push --schema=./epess-database/prisma/schema.prisma",
|
||||
"prisma:reset": "npx prisma migrate reset --schema=./epess-database/prisma/schema.prisma",
|
||||
"prisma:seed": "npx prisma db seed --schema=./epess-database/prisma/schema.prisma",
|
||||
"prisma:format": "npx prisma format --schema=./epess-database/prisma/schema.prisma",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
"prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "jest",
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { MinioService } from 'src/Minio/minio.service';
|
||||
import { MinioService } from '../Minio/minio.service';
|
||||
import { CenterStatus } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
@@ -53,6 +53,7 @@ export class CenterSchema extends PothosSchema {
|
||||
description: 'The location of the center.',
|
||||
}),
|
||||
individual: t.exposeBoolean('individual', {
|
||||
nullable: true,
|
||||
description: 'Whether the center is an individual center.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', { type: 'DateTime' }),
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { ChatRoomType } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
export class ChatroomSchema extends PothosSchema {
|
||||
@@ -25,7 +26,8 @@ export class ChatroomSchema extends PothosSchema {
|
||||
id: t.exposeID('id', {
|
||||
description: 'The ID of the chat room.',
|
||||
}),
|
||||
type: t.exposeString('type', {
|
||||
type: t.expose('type', {
|
||||
type: ChatRoomType,
|
||||
description: 'The type of the chat room.',
|
||||
}),
|
||||
customerId: t.exposeID('customerId', {
|
||||
@@ -37,7 +39,10 @@ export class ChatroomSchema extends PothosSchema {
|
||||
centerStaffId: t.exposeID('centerStaffId', {
|
||||
description: 'The ID of the center staff member.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', { type: 'DateTime' }),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
description: 'The date and time the chat room was created.',
|
||||
}),
|
||||
message: t.relation('message', {
|
||||
description: 'The messages in the chat room.',
|
||||
}),
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
import SchemaBuilder from '@pothos/core';
|
||||
import { DateTimeResolver, JSONObjectResolver } from 'graphql-scalars';
|
||||
import PrismaPlugin, {
|
||||
PothosPrismaDatamodel,
|
||||
PrismaClient,
|
||||
} from '@pothos/plugin-prisma';
|
||||
import PrismaUtils from '@pothos/plugin-prisma-utils';
|
||||
import { Request, Response } from 'express';
|
||||
import type PrismaTypes from '../types/pothos.generated';
|
||||
import { getDatamodel } from '../types/pothos.generated';
|
||||
import { DateTimeResolver, JSONObjectResolver } from 'graphql-scalars';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
|
||||
import type { FileUpload } from 'graphql-upload/processRequest.js';
|
||||
import { PrismaCrudGenerator } from './graphql.generator';
|
||||
import { PubSub } from 'graphql-subscriptions';
|
||||
import SimpleObjectPlugin from '@pothos/plugin-simple-objects';
|
||||
import SmartSubscriptionPlugin, {
|
||||
subscribeOptionsFromIterator,
|
||||
} from '@pothos/plugin-smart-subscriptions';
|
||||
import RelayPlugin from '@pothos/plugin-relay';
|
||||
import ErrorsPlugin from '@pothos/plugin-errors';
|
||||
|
||||
import AuthzPlugin from '@pothos/plugin-authz';
|
||||
import ErrorsPlugin from '@pothos/plugin-errors';
|
||||
import type { FileUpload } from 'graphql-upload/processRequest.js';
|
||||
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaCrudGenerator } from './graphql.generator';
|
||||
import type PrismaTypes from '../types/pothos.generated';
|
||||
import PrismaUtils from '@pothos/plugin-prisma-utils';
|
||||
import { PubSub } from 'graphql-subscriptions';
|
||||
import RelayPlugin from '@pothos/plugin-relay';
|
||||
import SchemaBuilder from '@pothos/core';
|
||||
import SimpleObjectPlugin from '@pothos/plugin-simple-objects';
|
||||
import { User } from '@prisma/client';
|
||||
import { getDatamodel } from '../types/pothos.generated';
|
||||
|
||||
// import { rules } from '../common/graphql/common.graphql.auth-rule';
|
||||
|
||||
export interface SchemaContext {
|
||||
|
||||
@@ -1,35 +1,37 @@
|
||||
import { ApolloDriverConfig } from '@nestjs/apollo';
|
||||
import { Global, MiddlewareConsumer, Module } from '@nestjs/common';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { PothosModule } from '@smatch-corp/nestjs-pothos';
|
||||
import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver';
|
||||
|
||||
import { ApolloDriverConfig } from '@nestjs/apollo';
|
||||
import { Builder } from './graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { GraphQLValidationMiddleware } from '../middlewares/graphql.middleware';
|
||||
import { CommonModule } from '../common/common.module';
|
||||
import { PrismaModule } from '../Prisma/prisma.module';
|
||||
import { UserModule } from '../User/user.module';
|
||||
import { CategoryModule } from '../Category/category.module';
|
||||
import { CenterModule } from '../Center/center.module';
|
||||
import { ServiceModule } from '../Service/service.module';
|
||||
import { ChatroomModule } from '../ChatRoom/chatroom.module';
|
||||
import { CenterStaffModule } from '../CenterStaff/centerstaff.module';
|
||||
import { ChatroomModule } from '../ChatRoom/chatroom.module';
|
||||
import { CommonModule } from '../common/common.module';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { GraphQLValidationMiddleware } from '../middlewares/graphql.middleware';
|
||||
import { ManagedServiceModule } from '../ManagedService/managedservice.module';
|
||||
import { MessageModule } from '../Message/message.module';
|
||||
import { MilestoneModule } from '../Milestone/milestone.module';
|
||||
import { OrderModule } from '../Order/order.module';
|
||||
import { PaymentModule } from '../Payment/payment.module';
|
||||
import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver';
|
||||
import { PothosModule } from '@smatch-corp/nestjs-pothos';
|
||||
import { PrismaCrudGenerator } from './graphql.generator';
|
||||
import { PrismaModule } from '../Prisma/prisma.module';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { RefundTicketModule } from '../RefundTicket/refundticket.module';
|
||||
import { ResumeModule } from '../Resume/resume.module';
|
||||
import { ScheduleModule } from '../Schedule/schedule.module';
|
||||
import { ServiceAndCategoryModule } from '../ServiceAndCategory/serviceandcategory.module';
|
||||
import { ServiceFeedbackModule } from '../ServiceFeedback/servicefeedback.module';
|
||||
import { ServiceMeetingRoomModule } from '../ServiceMeetingRoom/servicemeetingroom.module';
|
||||
import { ServiceModule } from '../Service/service.module';
|
||||
import { UploadedFileModule } from '../UploadedFile/uploadedfile.module';
|
||||
import { UserModule } from '../User/user.module';
|
||||
import { WorkshopMeetingRoomModule } from '../WorkshopMeetingRoom/workshopmeetingroom.module';
|
||||
import { WorkshopModule } from '../Workshop/workshop.module';
|
||||
import { WorkshopOrganizationModule } from '../WorkshopOrganization/workshoporganization.module';
|
||||
import { WorkshopSubscriptionModule } from '../WorkshopSubscription/workshopsubscription.module';
|
||||
import { PrismaCrudGenerator } from './graphql.generator';
|
||||
import { OrderModule } from '../Order/order.module';
|
||||
import { PaymentModule } from '../Payment/payment.module';
|
||||
import { RefundTicketModule } from '../RefundTicket/refundticket.module';
|
||||
import { ServiceAndCategoryModule } from '../ServiceAndCategory/serviceandcategory.module';
|
||||
import { CategoryModule } from '../Category/category.module';
|
||||
import { ServiceFeedbackModule } from '../ServiceFeedback/servicefeedback.module';
|
||||
import { MilestoneModule } from '../Milestone/milestone.module';
|
||||
import { ScheduleModule } from '../Schedule/schedule.module';
|
||||
import { MessageModule } from '../Message/message.module';
|
||||
import { ServiceMeetingRoomModule } from '../ServiceMeetingRoom/servicemeetingroom.module';
|
||||
import { UploadedFileModule } from '../UploadedFile/uploadedfile.module';
|
||||
import { ManagedServiceModule } from '../ManagedService/managedservice.module';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
@@ -57,6 +59,7 @@ import { ManagedServiceModule } from '../ManagedService/managedservice.module';
|
||||
ServiceMeetingRoomModule,
|
||||
UploadedFileModule,
|
||||
ManagedServiceModule,
|
||||
WorkshopMeetingRoomModule,
|
||||
PothosModule.forRoot({
|
||||
builder: {
|
||||
inject: [PrismaService],
|
||||
|
||||
@@ -22,14 +22,21 @@ export class ManagedServiceSchema extends PothosSchema {
|
||||
return this.builder.prismaObject('ManagedService', {
|
||||
description: 'A managed service',
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id', {
|
||||
description: 'The ID of the managed service.',
|
||||
}),
|
||||
staffId: t.exposeID('staffId', {
|
||||
description: 'The ID of the staff member.',
|
||||
}),
|
||||
serviceId: t.exposeID('serviceId', {
|
||||
description: 'The ID of the service.',
|
||||
}),
|
||||
staff: t.relation('staff'),
|
||||
service: t.relation('service'),
|
||||
staff: t.relation('staff', {
|
||||
description: 'The staff member.',
|
||||
}),
|
||||
service: t.relation('service', {
|
||||
description: 'The service.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
@@ -40,7 +47,7 @@ export class ManagedServiceSchema extends PothosSchema {
|
||||
managedService: t.field({
|
||||
type: this.managedService(),
|
||||
args: this.builder.generator.findUniqueArgs('ManagedService'),
|
||||
resolve: async (parent, args, context) => {
|
||||
resolve: async (parent, args, ctx) => {
|
||||
return this.prisma.managedService.findUnique({
|
||||
where: args.where,
|
||||
});
|
||||
@@ -50,7 +57,7 @@ export class ManagedServiceSchema extends PothosSchema {
|
||||
managedServices: t.field({
|
||||
type: [this.managedService()],
|
||||
args: this.builder.generator.findManyArgs('ManagedService'),
|
||||
resolve: async (parent, args, context) => {
|
||||
resolve: async (parent, args, ctx) => {
|
||||
return this.prisma.managedService.findMany({
|
||||
where: args.filter ?? undefined,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
|
||||
@@ -26,12 +26,12 @@ export class OrderSchema extends PothosSchema {
|
||||
id: t.exposeID('id', {
|
||||
description: 'The ID of the order.',
|
||||
}),
|
||||
paymentId: t.exposeString('paymentId', {
|
||||
description: 'The ID of the payment.',
|
||||
}),
|
||||
userId: t.exposeID('userId', {
|
||||
description: 'The ID of the user.',
|
||||
}),
|
||||
paymentId: t.exposeString('paymentId', {
|
||||
description: 'The ID of the payment.',
|
||||
}),
|
||||
serviceId: t.exposeID('serviceId', {
|
||||
description: 'The ID of the service.',
|
||||
}),
|
||||
|
||||
@@ -32,7 +32,6 @@ export class PaymentSchema extends PothosSchema {
|
||||
}),
|
||||
status: t.expose('status', {
|
||||
type: PaymentStatus,
|
||||
nullable: false,
|
||||
description: 'The status of the payment.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PayosService } from './payos.service';
|
||||
import { PayosController } from './payos.controller';
|
||||
import { PayosService } from './payos.service';
|
||||
|
||||
@Module({
|
||||
providers: [PayosService],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
Logger,
|
||||
OnModuleInit,
|
||||
} from '@nestjs/common';
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { PaymentStatus } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
export class RefundTicketSchema extends PothosSchema {
|
||||
@@ -28,7 +29,8 @@ export class RefundTicketSchema extends PothosSchema {
|
||||
amount: t.exposeFloat('amount', {
|
||||
description: 'The amount of the refund ticket.',
|
||||
}),
|
||||
status: t.exposeString('status', {
|
||||
status: t.expose('status', {
|
||||
type: PaymentStatus,
|
||||
description: 'The status of the refund ticket.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
|
||||
@@ -72,12 +72,12 @@ export class ResumeSchema extends PothosSchema {
|
||||
fileUrl: t.exposeString('fileUrl', {
|
||||
description: 'The URL of the resume file.',
|
||||
}),
|
||||
actualFileName: t.exposeString('actualFileName', {
|
||||
description: 'The original name of the resume file.',
|
||||
}),
|
||||
type: t.exposeString('type', {
|
||||
description: 'The type of the resume file.',
|
||||
}),
|
||||
actualFileName: t.exposeString('actualFileName', {
|
||||
description: 'The original name of the resume file.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
nullable: true,
|
||||
|
||||
@@ -23,13 +23,11 @@ export class ScheduleSchema extends PothosSchema {
|
||||
return this.builder.prismaObject('Schedule', {
|
||||
description: 'A schedule in the system.',
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
serviceId: t.exposeID('serviceId', {
|
||||
description: 'The ID of the service the schedule belongs to.',
|
||||
nullable: false,
|
||||
id: t.exposeID('id', {
|
||||
description: 'The ID of the schedule.',
|
||||
}),
|
||||
service: t.relation('service', {
|
||||
description: 'The service the schedule belongs to.',
|
||||
managedServiceId: t.exposeID('managedServiceId', {
|
||||
description: 'The ID of the managed service the schedule belongs to.',
|
||||
nullable: false,
|
||||
}),
|
||||
scheduleStart: t.expose('ScheduleStart', {
|
||||
@@ -40,11 +38,17 @@ export class ScheduleSchema extends PothosSchema {
|
||||
type: 'DateTime',
|
||||
nullable: false,
|
||||
}),
|
||||
dates: t.relation('dates'),
|
||||
dates: t.relation('dates', {
|
||||
description: 'The dates of the schedule.',
|
||||
}),
|
||||
status: t.expose('status', {
|
||||
type: ScheduleStatus,
|
||||
nullable: false,
|
||||
}),
|
||||
managedService: t.relation('ManagedService', {
|
||||
description: 'The managed service the schedule belongs to.',
|
||||
nullable: false,
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,17 +58,14 @@ export class ServiceSchema extends PothosSchema {
|
||||
}),
|
||||
status: t.expose('status', {
|
||||
type: ServiceStatus,
|
||||
nullable: true,
|
||||
description: 'The status of the service.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
nullable: true,
|
||||
description: 'The date and time the service was created.',
|
||||
}),
|
||||
updatedAt: t.expose('updatedAt', {
|
||||
type: 'DateTime',
|
||||
nullable: true,
|
||||
description: 'The date and time the service was updated.',
|
||||
}),
|
||||
feedbacks: t.relation('feedbacks', {
|
||||
@@ -86,9 +83,6 @@ export class ServiceSchema extends PothosSchema {
|
||||
milestone: t.relation('milestone', {
|
||||
description: 'The milestone for the service.',
|
||||
}),
|
||||
schedule: t.relation('schedule', {
|
||||
description: 'The schedule for the service.',
|
||||
}),
|
||||
serviceAndCategory: t.relation('serviceAndCategory', {
|
||||
description: 'The service and category for the service.',
|
||||
}),
|
||||
|
||||
@@ -22,9 +22,15 @@ export class ServiceMeetingRoomSchema extends PothosSchema {
|
||||
return this.builder.prismaObject('ServiceMeetingRoom', {
|
||||
description: 'A service meeting room in the system.',
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
chattingRoomId: t.exposeString('chattingRoomId'),
|
||||
chattingRoom: t.relation('chattingRoom'),
|
||||
id: t.exposeID('id', {
|
||||
description: 'The ID of the service meeting room.',
|
||||
}),
|
||||
chattingRoomId: t.exposeString('chattingRoomId', {
|
||||
description: 'The ID of the chatting room.',
|
||||
}),
|
||||
chattingRoom: t.relation('chattingRoom', {
|
||||
description: 'The chatting room.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,12 +34,11 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
description: 'The original name of the file.',
|
||||
}),
|
||||
fileName: t.exposeString('fileName', {
|
||||
description: 'The name of the file.',
|
||||
description: 'The name of the file in minio.',
|
||||
}),
|
||||
// expose enum
|
||||
fileType: t.expose('fileType', {
|
||||
type: UploadedFileType,
|
||||
nullable: false,
|
||||
nullable: true,
|
||||
description: 'The type of the file.',
|
||||
}),
|
||||
fileUrl: t.exposeString('fileUrl', {
|
||||
@@ -53,6 +52,15 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
user: t.relation('user', {
|
||||
description: 'The user who uploaded the file.',
|
||||
}),
|
||||
Center: t.relation('Center', {
|
||||
description: 'The center that the file belongs to.',
|
||||
}),
|
||||
Service: t.relation('Service', {
|
||||
description: 'The service that the file belongs to.',
|
||||
}),
|
||||
Workshop: t.relation('Workshop', {
|
||||
description: 'The workshop that the file belongs to.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ export class UserSchema extends PothosSchema {
|
||||
description: 'The bank account number of the user.',
|
||||
}),
|
||||
role: t.exposeString('role', {
|
||||
nullable: true,
|
||||
description: 'The role of the user.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
|
||||
@@ -76,6 +76,10 @@ export class WorkshopSchema extends PothosSchema {
|
||||
staff: t.relation('staff', {
|
||||
description: 'The staff member who is leading the workshop.',
|
||||
}),
|
||||
meetingRoom: t.relation('WorkshopMeetingRoom', {
|
||||
nullable: true,
|
||||
description: 'The meeting room that the workshop is for.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ export class WorkshopMeetingRoomSchema extends PothosSchema {
|
||||
workshopId: t.exposeID('workshopId', {
|
||||
description: 'The ID of the workshop that the meeting room is for.',
|
||||
}),
|
||||
workshop: t.relation('workshop', {
|
||||
description: 'The workshop that the meeting room is for.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ export class WorkshopOrganizationSchema extends PothosSchema {
|
||||
service: t.relation('service', {
|
||||
description: 'The service that the organization is for.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
description:
|
||||
'The date and time the workshop organization was created.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@ export class WorkshopSubscriptionSchema extends PothosSchema {
|
||||
workshop: t.relation('workshop', {
|
||||
description: 'The workshop that the user subscribed to.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
description:
|
||||
'The date and time the workshop subscription was created.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
|
||||
import { AppModule } from './app.module';
|
||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js';
|
||||
import { clerkMiddleware } from '@clerk/express';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { clerkMiddleware } from '@clerk/express';
|
||||
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common';
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
|
||||
@Injectable()
|
||||
export class GraphQLValidationMiddleware implements NestMiddleware {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user