-
Notifications
You must be signed in to change notification settings - Fork 267
feat: reworked documents revision & added soft deletion for documents & files #3454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "Document" ADD COLUMN "deletedAt" TIMESTAMP(3); | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "DocumentFile" ADD COLUMN "deletedAt" TIMESTAMP(3); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { ValidationError } from '@/errors'; | ||
| import { TProjectId, TProjectIds } from '@/types'; | ||
| import { PrismaTransaction, TProjectId, TProjectIds } from '@/types'; | ||
| import { WorkflowDefinitionService } from '@/workflow-defintion/workflow-definition.service'; | ||
| import { WorkflowRunDto } from '@/workflow/dtos/workflow-run'; | ||
| import { ajv } from '@/common/ajv/ajv.validator'; | ||
|
|
@@ -12,6 +12,12 @@ import { randomUUID } from 'crypto'; | |
| import { BusinessPosition } from '@prisma/client'; | ||
| import { ARRAY_MERGE_OPTION, BUILT_IN_EVENT } from '@ballerine/workflow-core'; | ||
| import { UboToEntityAdapter } from './types'; | ||
| import { assertIsValidProjectIds } from '@/project/project-scope.service'; | ||
| import { DocumentFileService } from '@/document-file/document-file.service'; | ||
| import { | ||
| beginTransactionIfNotExistCurry, | ||
| defaultPrismaTransactionOptions, | ||
| } from '@/prisma/prisma.util'; | ||
|
|
||
| @Injectable() | ||
| export class CaseManagementService { | ||
|
|
@@ -20,6 +26,7 @@ export class CaseManagementService { | |
| protected readonly workflowService: WorkflowService, | ||
| protected readonly prismaService: PrismaService, | ||
| protected readonly endUserService: EndUserService, | ||
| protected readonly documentFileService: DocumentFileService, | ||
| ) {} | ||
|
|
||
| async create( | ||
|
|
@@ -258,4 +265,55 @@ export class CaseManagementService { | |
| }); | ||
| }); | ||
| } | ||
|
|
||
| async caseRevision( | ||
| workflowId: string, | ||
| documentIds: string[], | ||
| projectIds: TProjectIds, | ||
| transaction: PrismaTransaction = this.prismaService, | ||
| ) { | ||
| assertIsValidProjectIds(projectIds); | ||
|
|
||
| const beginTransaction = beginTransactionIfNotExistCurry({ | ||
| prismaService: this.prismaService, | ||
| options: defaultPrismaTransactionOptions, | ||
| transaction, | ||
| }); | ||
|
|
||
| return beginTransaction(async transaction => { | ||
| const deletedDocumentFiles = await this.removeFilesFromDocuments( | ||
| documentIds, | ||
| projectIds, | ||
| transaction, | ||
| ); | ||
|
|
||
| await this.workflowService.event( | ||
| { | ||
| id: workflowId, | ||
| name: 'revision', | ||
| }, | ||
| projectIds, | ||
| projectIds[0]!, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate over null assertion.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| transaction, | ||
| ); | ||
|
|
||
| return deletedDocumentFiles; | ||
| }); | ||
| } | ||
|
|
||
| private async removeFilesFromDocuments( | ||
| documentIds: string[], | ||
| projectIds: TProjectIds, | ||
| transaction: PrismaTransaction, | ||
| ) { | ||
| assertIsValidProjectIds(projectIds); | ||
|
|
||
| const deletedDocumentFiles = await this.documentFileService.deleteManyByDocumentIds( | ||
| documentIds, | ||
| projectIds, | ||
| transaction, | ||
| ); | ||
|
|
||
| return deletedDocumentFiles; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.