mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 19:44:52 +00:00
misc: moved to group project v3 for get with ID based
This commit is contained in:
@@ -10,13 +10,13 @@ export type TGroupProjectDALFactory = ReturnType<typeof groupProjectDALFactory>;
|
||||
export const groupProjectDALFactory = (db: TDbClient) => {
|
||||
const groupProjectOrm = ormify(db, TableName.GroupProjectMembership);
|
||||
|
||||
const findByProjectId = async (projectId: string, filter?: { groupSlug?: string }, tx?: Knex) => {
|
||||
const findByProjectId = async (projectId: string, filter?: { groupId?: string }, tx?: Knex) => {
|
||||
try {
|
||||
const docs = await (tx || db.replicaNode())(TableName.GroupProjectMembership)
|
||||
.where(`${TableName.GroupProjectMembership}.projectId`, projectId)
|
||||
.where((qb) => {
|
||||
if (filter?.groupSlug) {
|
||||
void qb.where(`${TableName.Groups}.slug`, "=", filter.groupSlug);
|
||||
if (filter?.groupId) {
|
||||
void qb.where(`${TableName.Groups}.id`, "=", filter.groupId);
|
||||
}
|
||||
})
|
||||
.join(TableName.Groups, `${TableName.GroupProjectMembership}.groupId`, `${TableName.Groups}.id`)
|
||||
|
||||
@@ -34,7 +34,7 @@ type TGroupProjectServiceFactoryDep = {
|
||||
"create" | "transaction" | "insertMany" | "delete"
|
||||
>;
|
||||
userGroupMembershipDAL: Pick<TUserGroupMembershipDALFactory, "findGroupMembersNotInProject">;
|
||||
projectDAL: Pick<TProjectDALFactory, "findOne" | "findProjectGhostUser">;
|
||||
projectDAL: Pick<TProjectDALFactory, "findOne" | "findProjectGhostUser" | "findById">;
|
||||
projectKeyDAL: Pick<TProjectKeyDALFactory, "findLatestProjectKey" | "delete" | "insertMany" | "transaction">;
|
||||
projectRoleDAL: Pick<TProjectRoleDALFactory, "find">;
|
||||
projectBotDAL: TProjectBotDALFactory;
|
||||
@@ -403,19 +403,17 @@ export const groupProjectServiceFactory = ({
|
||||
};
|
||||
|
||||
const getGroupInProject = async ({
|
||||
projectSlug,
|
||||
actor,
|
||||
actorId,
|
||||
actorAuthMethod,
|
||||
actorOrgId,
|
||||
groupSlug
|
||||
groupId,
|
||||
projectId
|
||||
}: TGetGroupInProjectDTO) => {
|
||||
const project = await projectDAL.findOne({
|
||||
slug: projectSlug
|
||||
});
|
||||
const project = await projectDAL.findById(projectId);
|
||||
|
||||
if (!project) {
|
||||
throw new NotFoundError({ message: `Failed to find project with slug ${projectSlug}` });
|
||||
throw new NotFoundError({ message: `Failed to find project with ID ${projectId}` });
|
||||
}
|
||||
|
||||
const { permission } = await permissionService.getProjectPermission(
|
||||
@@ -428,7 +426,7 @@ export const groupProjectServiceFactory = ({
|
||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Groups);
|
||||
|
||||
const [groupMembership] = await groupProjectDAL.findByProjectId(project.id, {
|
||||
groupSlug
|
||||
groupId
|
||||
});
|
||||
|
||||
if (!groupMembership) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TProjectSlugPermission } from "@app/lib/types";
|
||||
import { TProjectPermission, TProjectSlugPermission } from "@app/lib/types";
|
||||
|
||||
import { ProjectUserMembershipTemporaryMode } from "../project-membership/project-membership-types";
|
||||
|
||||
@@ -42,4 +42,4 @@ export type TDeleteProjectGroupDTO = {
|
||||
|
||||
export type TListProjectGroupDTO = TProjectSlugPermission;
|
||||
|
||||
export type TGetGroupInProjectDTO = TProjectSlugPermission & { groupSlug: string };
|
||||
export type TGetGroupInProjectDTO = TProjectPermission & { groupId: string };
|
||||
|
||||
Reference in New Issue
Block a user