Add attachments (#733)
* Add attachments v1 * Refacto * Add Policy checks * Fix tests * Remove generated files from git --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "AttachmentType" AS ENUM ('Image', 'Audio', 'Video', 'TextDocument', 'Spreadsheet', 'Archive', 'Other');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "attachments" (
|
||||
"id" TEXT NOT NULL,
|
||||
"fullPath" TEXT NOT NULL,
|
||||
"type" "AttachmentType" NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"authorId" TEXT NOT NULL,
|
||||
"activityId" TEXT NOT NULL,
|
||||
"workspaceId" TEXT NOT NULL,
|
||||
"deletedAt" TIMESTAMP(3),
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "attachments_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "comment_threads"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@ -18,97 +18,26 @@ generator nestgraphql {
|
||||
fields_Validator_model = true
|
||||
fields_Validator_from = "class-validator"
|
||||
|
||||
// CommentThread create: Only Allow targets createMany and comments createMany
|
||||
decorate_createCommentThreadTargets_type = "*CommentThreadTargetCreateNestedManyWithoutCommentThreadInput"
|
||||
decorate_createCommentThreadTargets_field = "!(createMany)"
|
||||
decorate_createCommentThreadTargets_name = "HideField"
|
||||
decorate_createCommentThreadTargets_from = "@nestjs/graphql"
|
||||
decorate_createCommentThreadTargets_arguments = "[]"
|
||||
// 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 = "[]"
|
||||
|
||||
decorate_createCommentThreadComments_type = "*CommentCreateNestedManyWithoutCommentThreadInput"
|
||||
decorate_createCommentThreadComments_field = "!(createMany)"
|
||||
decorate_createCommentThreadComments_name = "HideField"
|
||||
decorate_createCommentThreadComments_from = "@nestjs/graphql"
|
||||
decorate_createCommentThreadComments_arguments = "[]"
|
||||
// CommentThread: Only Allow targets createOrConnect / createMany
|
||||
decorate_commentThreadTargets_type = "*CommentThreadTarget*Input"
|
||||
decorate_commentThreadTargets_field = "*(update|upsert|updateMany|deleteMany)"
|
||||
decorate_commentThreadTargets_name = "HideField"
|
||||
decorate_commentThreadTargets_from = "@nestjs/graphql"
|
||||
decorate_commentThreadTargets_arguments = "[]"
|
||||
|
||||
// Comment create: Only Allow author connect and commentThread connect
|
||||
decorate_createCommentUser_type = "*UserCreateNestedOneWithoutCommentsInput"
|
||||
decorate_createCommentUser_field = "!(connect)"
|
||||
decorate_createCommentUser_name = "HideField"
|
||||
decorate_createCommentUser_from = "@nestjs/graphql"
|
||||
decorate_createCommentUser_arguments = "[]"
|
||||
|
||||
decorate_createCommentCommentThread_type = "*CommentThreadCreateNestedOneWithoutCommentsInput"
|
||||
decorate_createCommentCommentThread_field = "!(connect)"
|
||||
decorate_createCommentCommentThread_name = "HideField"
|
||||
decorate_createCommentCommentThread_from = "@nestjs/graphql"
|
||||
decorate_createCommentCommentThread_arguments = "[]"
|
||||
|
||||
// Person create: Only Allow company connect
|
||||
decorate_createPersonCompany_type = "*CompanyCreateNestedOneWithoutPeopleInput"
|
||||
decorate_createPersonCompany_field = "!(connect)"
|
||||
decorate_createPersonCompany_name = "HideField"
|
||||
decorate_createPersonCompany_from = "@nestjs/graphql"
|
||||
decorate_createPersonCompany_arguments = "[]"
|
||||
|
||||
// Person update: Only Allow company connect
|
||||
decorate_updatePersonCompany_type = "*CompanyUpdateOneWithoutPeopleNestedInput"
|
||||
decorate_updatePersonCompany_field = "!(connect)"
|
||||
decorate_updatePersonCompany_name = "HideField"
|
||||
decorate_updatePersonCompany_from = "@nestjs/graphql"
|
||||
decorate_updatePersonCompany_arguments = "[]"
|
||||
|
||||
// Company create: Only Allow people and accountOwner connect
|
||||
decorate_createCompanyUser_type = "*UserCreateNestedOneWithoutCompaniesInput"
|
||||
decorate_createCompanyUser_field = "!(connect)"
|
||||
decorate_createCompanyUser_name = "HideField"
|
||||
decorate_createCompanyUser_from = "@nestjs/graphql"
|
||||
decorate_createCompanyUser_arguments = "[]"
|
||||
|
||||
decorate_createCompanyPerson_type = "*PersonCreateNestedManyWithoutCompanyInput"
|
||||
decorate_createCompanyPerson_field = "!(connect)"
|
||||
decorate_createCompanyPerson_name = "HideField"
|
||||
decorate_createCompanyPerson_from = "@nestjs/graphql"
|
||||
decorate_createCompanyPerson_arguments = "[]"
|
||||
|
||||
// Company update: Only Allow action on people and accountOwner
|
||||
decorate_updateCompanyUser_type = "*UserUpdateOneWithoutCompaniesNestedInput"
|
||||
decorate_updateCompanyUser_field = "!(connect)"
|
||||
decorate_updateCompanyUser_name = "HideField"
|
||||
decorate_updateCompanyUser_from = "@nestjs/graphql"
|
||||
decorate_updateCompanyUser_arguments = "[]"
|
||||
|
||||
decorate_updateCompanyPerson_type = "*PersonUpdateManyWithoutCompanyNestedInput"
|
||||
decorate_updateCompanyPerson_field = "!(connect)"
|
||||
decorate_updateCompanyPerson_name = "HideField"
|
||||
decorate_updateCompanyPerson_from = "@nestjs/graphql"
|
||||
decorate_updateCompanyPerson_arguments = "[]"
|
||||
|
||||
// PipelineProgress create: Only Allow pipelineStage and pipeline connect
|
||||
decorate_createPipelineProgressPipeline_type = "*PipelineCreateNestedOneWithoutPipelineProgressesInput"
|
||||
decorate_createPipelineProgressPipeline_field = "!(connect)"
|
||||
decorate_createPipelineProgressPipeline_name = "HideField"
|
||||
decorate_createPipelineProgressPipeline_from = "@nestjs/graphql"
|
||||
decorate_createPipelineProgressPipeline_arguments = "[]"
|
||||
|
||||
decorate_createPipelineProgressPipelineStage_type = "*PipelineStageCreateNestedOneWithoutPipelineProgressesInput"
|
||||
decorate_createPipelineProgressPipelineStage_field = "!(connect)"
|
||||
decorate_createPipelineProgressPipelineStage_name = "HideField"
|
||||
decorate_createPipelineProgressPipelineStage_from = "@nestjs/graphql"
|
||||
decorate_createPipelineProgressPipelineStage_arguments = "[]"
|
||||
|
||||
// PipelineProgress update: Only Allow pipelineStage and pipeline connect
|
||||
decorate_updatePipelineProgressPipeline_type = "*PipelineUpdateOneRequiredWithoutPipelineProgressesNestedInput"
|
||||
decorate_updatePipelineProgressPipeline_field = "!(connect)"
|
||||
decorate_updatePipelineProgressPipeline_name = "HideField"
|
||||
decorate_updatePipelineProgressPipeline_from = "@nestjs/graphql"
|
||||
decorate_updatePipelineProgressPipeline_arguments = "[]"
|
||||
|
||||
decorate_updatePipelineProgressPipelineStage_type = "*PipelineStageUpdateOneRequiredWithoutPipelineProgressesNestedInput"
|
||||
decorate_updatePipelineProgressPipelineStage_field = "!(connect)"
|
||||
decorate_updatePipelineProgressPipelineStage_name = "HideField"
|
||||
decorate_updatePipelineProgressPipelineStage_from = "@nestjs/graphql"
|
||||
decorate_updatePipelineProgressPipelineStage_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*)"
|
||||
@ -180,8 +109,9 @@ model User {
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
authoredAttachments Attachment[] @relation(name: "authoredAttachments")
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
@ -386,6 +316,8 @@ model CommentThread {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
attachments Attachment[]
|
||||
|
||||
@@map("comment_threads")
|
||||
}
|
||||
|
||||
@ -527,3 +459,39 @@ model PipelineProgress {
|
||||
|
||||
@@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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user