mirror of
https://github.com/Infisical/infisical.git
synced 2025-03-28 15:29:21 +00:00
Draft
This commit is contained in:
@ -33,7 +33,9 @@ import { assignWorkspaceKeysToMembers, createProjectKey } from "./project-fns";
|
||||
import { TProjectQueueFactory } from "./project-queue";
|
||||
import {
|
||||
TCreateProjectDTO,
|
||||
TDeleteProjectBySlugDTO,
|
||||
TDeleteProjectDTO,
|
||||
TGetProjectBySlugDTO,
|
||||
TGetProjectDTO,
|
||||
TToggleProjectAutoCapitalizationDTO,
|
||||
TUpdateProjectDTO,
|
||||
@ -358,6 +360,27 @@ export const projectServiceFactory = ({
|
||||
return deletedProject;
|
||||
};
|
||||
|
||||
const deleteProjectBySlug = async ({ actor, actorId, actorOrgId, slug }: TDeleteProjectBySlugDTO) => {
|
||||
const project = await projectDAL.findOne({ slug });
|
||||
|
||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, project.id, actorOrgId);
|
||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Project);
|
||||
|
||||
const deletedProject = await projectDAL.transaction(async (tx) => {
|
||||
const delProject = await projectDAL.deleteById(project.id, tx);
|
||||
const projectGhostUser = await projectMembershipDAL.findProjectGhostUser(project.id).catch(() => null);
|
||||
|
||||
// Delete the org membership for the ghost user if it's found.
|
||||
if (projectGhostUser) {
|
||||
await userDAL.deleteById(projectGhostUser.id, tx);
|
||||
}
|
||||
|
||||
return delProject;
|
||||
});
|
||||
|
||||
return deletedProject;
|
||||
};
|
||||
|
||||
const getProjects = async (actorId: string) => {
|
||||
const workspaces = await projectDAL.findAllProjects(actorId);
|
||||
return workspaces;
|
||||
@ -450,8 +473,10 @@ export const projectServiceFactory = ({
|
||||
deleteProject,
|
||||
getProjects,
|
||||
updateProject,
|
||||
deleteProjectBySlug,
|
||||
getProjectUpgradeStatus,
|
||||
getAProject,
|
||||
getProjectBySlug,
|
||||
toggleAutoCapitalization,
|
||||
updateName,
|
||||
upgradeProject
|
||||
|
@ -36,6 +36,13 @@ export type TDeleteProjectBySlugDTO = {
|
||||
actorOrgId?: string;
|
||||
};
|
||||
|
||||
export type TDeleteProjectBySlugDTO = {
|
||||
slug: string;
|
||||
actor: ActorType;
|
||||
actorId: string;
|
||||
actorOrgId?: string;
|
||||
};
|
||||
|
||||
export type TGetProjectDTO = {
|
||||
filter: Filter;
|
||||
} & Omit<TProjectPermission, "projectId">;
|
||||
@ -47,6 +54,13 @@ export type TUpdateProjectNameDTO = {
|
||||
name: string;
|
||||
} & TProjectPermission;
|
||||
|
||||
export type TGetProjectBySlugDTO = {
|
||||
slug: string;
|
||||
actor: ActorType;
|
||||
actorId: string;
|
||||
actorOrgId?: string;
|
||||
};
|
||||
|
||||
export type TUpdateProjectDTO = {
|
||||
filter: Filter;
|
||||
update: {
|
||||
|
Reference in New Issue
Block a user