Remove serverless functions on soft delete (#9438)

Delete workflow versions serverless functions when soft delete workflow
This commit is contained in:
martmull
2025-01-07 16:51:34 +01:00
committed by GitHub
parent 46f51577a3
commit 0c75b244ba
7 changed files with 81 additions and 31 deletions

View File

@ -122,10 +122,10 @@ export class ServerlessFunctionResolver {
try {
await this.checkFeatureFlag(workspaceId);
return await this.serverlessFunctionService.deleteOneServerlessFunction(
input.id,
return await this.serverlessFunctionService.deleteOneServerlessFunction({
id: input.id,
workspaceId,
);
});
} catch (error) {
serverlessFunctionGraphQLApiExceptionHandler(error);
}

View File

@ -205,7 +205,15 @@ export class ServerlessFunctionService {
});
}
async deleteOneServerlessFunction(id: string, workspaceId: string) {
async deleteOneServerlessFunction({
id,
workspaceId,
isHardDeletion = true,
}: {
id: string;
workspaceId: string;
isHardDeletion?: boolean;
}) {
const existingServerlessFunction =
await this.serverlessFunctionRepository.findOneBy({
id,
@ -219,16 +227,17 @@ export class ServerlessFunctionService {
);
}
await this.serverlessFunctionRepository.delete(id);
if (isHardDeletion) {
await this.serverlessFunctionRepository.delete(id);
await this.fileStorageService.delete({
folderPath: getServerlessFolder({
serverlessFunction: existingServerlessFunction,
}),
});
}
await this.serverlessService.delete(existingServerlessFunction);
await this.fileStorageService.delete({
folderPath: getServerlessFolder({
serverlessFunction: existingServerlessFunction,
}),
});
return existingServerlessFunction;
}