generator client { provider = "prisma-client-js" engineType = "binary" } datasource db { provider = "postgresql" url = env("PG_DATABASE_URL") } generator nestgraphql { provider = "node node_modules/prisma-nestjs-graphql" output = "../../src/core/@generated" noAtomicOperations = true // field validator fields_Validator_input = true fields_Validator_output = true fields_Validator_model = true fields_Validator_from = "class-validator" // All relations, only allow connect decorate_all_type = "!(CommentThreadTarget*Input|UserSettingsUpdateOneRequiredWithoutUserNestedInput)" decorate_all_field = "*(create|connectOrCreate|update|upsert|delete|createMany|updateMany|deleteMany)" decorate_all_name = "HideField" decorate_all_from = "@nestjs/graphql" decorate_all_arguments = "[]" // CommentThread: Only Allow targets createOrConnect / createMany decorate_commentThreadTargets_type = "*CommentThreadTarget*Input" decorate_commentThreadTargets_field = "*(update|upsert|updateMany)" decorate_commentThreadTargets_name = "HideField" decorate_commentThreadTargets_from = "@nestjs/graphql" decorate_commentThreadTargets_arguments = "[]" // CommentThread: Only Allow targets createOrConnect / createMany decorate_userSettings_type = "*UserSettingsUpdateOneRequiredWithoutUserNestedInput" decorate_userSettings_field = "!(update)" decorate_userSettings_name = "HideField" decorate_userSettings_from = "@nestjs/graphql" decorate_userSettings_arguments = "[]" // Disable _count on all models except Aggregation use case decorate_count_type = "!(*Aggregate*|*GroupBy*|*OrderBy*)" decorate_count_field = "_count" decorate_count_name = "HideField" decorate_count_from = "@nestjs/graphql" decorate_count_arguments = "[]" // create data validator decorate_classValidator_type = "@(Create|Update|Upsert)*Args" decorate_classValidator_field = "@(data|[A-Z]*)" decorate_classValidator_name = ValidateNested decorate_classValidator_from = "class-validator" decorate_classValidator_arguments = "['{each: true}']" // create data transformer decorate_classTransformer_type = "@(Create|Update|Upsert)*Args" decorate_classTransformer_field = "@(data|[A-Z]*)" decorate_classTransformer_from = "class-transformer" decorate_classTransformer_arguments = "['() => {propertyType.0}']" decorate_classTransformer_name = Type } model User { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) /// @Validator.IsString() /// @Validator.IsOptional() firstName String? /// @Validator.IsString() /// @Validator.IsOptional() lastName String? /// @Validator.IsEmail() /// @Validator.IsOptional() email String @unique /// @Validator.IsBoolean() /// @Validator.IsOptional() emailVerified Boolean @default(false) /// @Validator.IsString() /// @Validator.IsOptional() avatarUrl String? /// @Validator.IsString() /// @Validator.IsOptional() locale String /// @Validator.IsString() /// @Validator.IsOptional() phoneNumber String? /// @Validator.IsDate() /// @Validator.IsOptional() lastSeen DateTime? /// @Validator.IsBoolean() /// @Validator.IsOptional() disabled Boolean @default(false) /// @TypeGraphQL.omit(input: true, output: true) passwordHash String? /// @Validator.IsJSON() /// @Validator.IsOptional() metadata Json? /// @TypeGraphQL.omit(input: true) workspaceMember WorkspaceMember? companies Company[] /// @TypeGraphQL.omit(input: true, output: true) refreshTokens RefreshToken[] comments Comment[] authoredCommentThreads CommentThread[] @relation(name: "authoredCommentThreads") assignedCommentThreads CommentThread[] @relation(name: "assignedCommentThreads") settings UserSettings @relation(fields: [settingsId], references: [id]) settingsId String @unique /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt authoredAttachments Attachment[] @relation(name: "authoredAttachments") @@map("users") } enum ColorScheme { Light Dark System } model UserSettings { id String @id @default(uuid()) /// @Validator.IsString() /// @Validator.IsOptional() colorScheme ColorScheme @default(System) /// @Validator.IsString() locale String user User? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("user_settings") } /// @TypeGraphQL.omit(input: true) model Workspace { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) /// @Validator.IsString() /// @Validator.IsOptional() domainName String? /// @Validator.IsString() /// @Validator.IsOptional() displayName String? /// @Validator.IsString() /// @Validator.IsOptional() logo String? /// @Validator.IsString() /// @Validator.IsOptional() inviteHash String? workspaceMember WorkspaceMember[] companies Company[] people Person[] commentThreads CommentThread[] comments Comment[] pipelines Pipeline[] pipelineStages PipelineStage[] pipelineProgresses PipelineProgress[] /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("workspaces") } model WorkspaceMember { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) user User @relation(fields: [userId], references: [id]) userId String @unique /// @TypeGraphQL.omit(input: true, output: false) workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) workspaceId String /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("workspace_members") } model Company { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) /// @Validator.IsString() /// @Validator.IsOptional() name String /// @Validator.IsString() /// @Validator.IsOptional() domainName String /// @Validator.IsString() /// @Validator.IsOptional() linkedinUrl String? /// @Validator.IsString() /// @Validator.IsOptional() address String /// @Validator.IsNumber() /// @Validator.IsOptional() employees Int? people Person[] accountOwner User? @relation(fields: [accountOwnerId], references: [id]) accountOwnerId String? /// @TypeGraphQL.omit(input: true, output: true) workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) workspaceId String /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("companies") } model Person { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) /// @Validator.IsString() /// @Validator.IsOptional() firstName String? /// @Validator.IsString() /// @Validator.IsOptional() lastName String? /// @Validator.IsString() /// @Validator.IsOptional() email String? /// @Validator.IsString() /// @Validator.IsOptional() linkedinUrl String? /// @Validator.IsString() /// @Validator.IsOptional() jobTitle String? /// @Validator.IsString() /// @Validator.IsOptional() phone String? /// @Validator.IsString() /// @Validator.IsOptional() city String? company Company? @relation(fields: [companyId], references: [id]) companyId String? /// @TypeGraphQL.omit(input: true, output: true) workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) workspaceId String pipelineProgresses PipelineProgress[] /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("people") } model RefreshToken { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) /// @Validator.IsBoolean() /// @Validator.IsOptional() isRevoked Boolean @default(false) /// @TypeGraphQL.omit(input: true, output: true) user User @relation(fields: [userId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) userId String expiresAt DateTime /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("refresh_tokens") } enum ActivityType { Note Task } model CommentThread { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) commentThreadTargets CommentThreadTarget[] comments Comment[] /// @TypeGraphQL.omit(input: true, output: true) workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) workspaceId String authorId String author User @relation(fields: [authorId], references: [id], name: "authoredCommentThreads") body String? title String? type ActivityType @default(Note) reminderAt DateTime? dueAt DateTime? completedAt DateTime? assignee User? @relation(fields: [assigneeId], references: [id], name: "assignedCommentThreads") assigneeId String? /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt attachments Attachment[] @@map("comment_threads") } model Comment { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) /// @Validator.IsString() body String author User @relation(fields: [authorId], references: [id]) authorId String commentThread CommentThread @relation(fields: [commentThreadId], references: [id], onDelete: Cascade) commentThreadId String /// @TypeGraphQL.omit(input: true, output: true) workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) workspaceId String /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("comments") } enum CommentableType { Person Company } model CommentThreadTarget { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) commentThread CommentThread @relation(fields: [commentThreadId], references: [id], onDelete: Cascade) commentThreadId String commentableType CommentableType commentableId String /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("comment_thread_targets") } model Pipeline { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) /// @Validator.IsString() name String /// @Validator.IsString() icon String pipelineStages PipelineStage[] pipelineProgresses PipelineProgress[] pipelineProgressableType PipelineProgressableType @default(Company) /// @TypeGraphQL.omit(input: true, output: true) workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) workspaceId String /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("pipelines") } model PipelineStage { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) /// @Validator.IsString() /// @Validator.IsOptional() name String /// @Validator.IsString() /// @Validator.IsOptional() type String /// @Validator.IsOptional() /// @Validator.IsString() color String /// @Validator.IsNumber() /// @Validator.IsOptional() index Int? pipelineProgresses PipelineProgress[] /// pipeline Pipeline @relation(fields: [pipelineId], references: [id]) pipelineId String /// @TypeGraphQL.omit(input: true, output: true) workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) workspaceId String /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("pipeline_stages") } enum PipelineProgressableType { Person Company } model PipelineProgress { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) amount Int? closeDate DateTime? probability Int? pipeline Pipeline @relation(fields: [pipelineId], references: [id]) pipelineId String pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id]) pipelineStageId String pointOfContact Person? @relation(fields: [pointOfContactId], references: [id]) pointOfContactId String? progressableType PipelineProgressableType progressableId String /// @TypeGraphQL.omit(input: true, output: true) workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) workspaceId String /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("pipeline_progresses") } enum AttachmentType { Image Audio Video TextDocument Spreadsheet Archive Other } model Attachment { /// @Validator.IsString() /// @Validator.IsOptional() id String @id @default(uuid()) fullPath String type AttachmentType name String authorId String author User @relation(fields: [authorId], references: [id], name: "authoredAttachments") activityId String activity CommentThread @relation(fields: [activityId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) workspaceId String /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("attachments") }