From 3691ee70580442efdc2bda555c47ec35222b0abf Mon Sep 17 00:00:00 2001 From: x032205 Date: Sun, 26 Oct 2025 00:48:01 -0400 Subject: [PATCH] fix lint & type check issues --- .../ee/routes/v1/pam-resource-routers/index.ts | 10 +++++----- .../secret-approval-policy-service.ts | 15 +++++++-------- backend/src/server/routes/index.ts | 2 +- frontend/src/hooks/api/pam/types/index.ts | 4 ++-- .../PamAccountForm/MySQLAccountForm.tsx | 4 ++-- .../PamAccountForm/PostgresAccountForm.tsx | 6 +++--- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/backend/src/ee/routes/v1/pam-resource-routers/index.ts b/backend/src/ee/routes/v1/pam-resource-routers/index.ts index c6c0afcca..821532598 100644 --- a/backend/src/ee/routes/v1/pam-resource-routers/index.ts +++ b/backend/src/ee/routes/v1/pam-resource-routers/index.ts @@ -1,14 +1,14 @@ +import { + CreateMySQLResourceSchema, + MySQLResourceSchema, + UpdateMySQLResourceSchema +} from "@app/ee/services/pam-resource/mysql/mysql-resource-schemas"; import { PamResource } from "@app/ee/services/pam-resource/pam-resource-enums"; import { CreatePostgresResourceSchema, SanitizedPostgresResourceSchema, UpdatePostgresResourceSchema } from "@app/ee/services/pam-resource/postgres/postgres-resource-schemas"; -import { - CreateMySQLResourceSchema, - MySQLResourceSchema, - UpdateMySQLResourceSchema -} from "@app/ee/services/pam-resource/mysql/mysql-resource-schemas"; import { registerPamResourceEndpoints } from "./pam-resource-endpoints"; diff --git a/backend/src/ee/services/secret-approval-policy/secret-approval-policy-service.ts b/backend/src/ee/services/secret-approval-policy/secret-approval-policy-service.ts index dcccea190..ac6e6bfb1 100644 --- a/backend/src/ee/services/secret-approval-policy/secret-approval-policy-service.ts +++ b/backend/src/ee/services/secret-approval-policy/secret-approval-policy-service.ts @@ -40,7 +40,7 @@ type TSecretApprovalPolicyServiceFactoryDep = { secretApprovalPolicyDAL: TSecretApprovalPolicyDALFactory; projectEnvDAL: Pick; userDAL: Pick; - projectMembershipDAL: Pick; + projectMembershipDAL: Pick; secretApprovalPolicyApproverDAL: TSecretApprovalPolicyApproverDALFactory; secretApprovalPolicyBypasserDAL: TSecretApprovalPolicyBypasserDALFactory; licenseService: Pick; @@ -62,12 +62,11 @@ export const secretApprovalPolicyServiceFactory = ({ licenseService, secretApprovalRequestDAL }: TSecretApprovalPolicyServiceFactoryDep) => { - const verifyProjectUserMembership = async (userIds: string[], projectId: string) => { + const verifyProjectUserMembership = async (userIds: string[], orgId: string, projectId: string) => { if (userIds.length === 0) return; - const projectMemberships = await projectMembershipDAL.find({ - $in: { userId: userIds }, - projectId - }); + const projectMemberships = (await projectMembershipDAL.findProjectMembershipsByUserIds(orgId, userIds)).filter( + (v) => v.projectId === projectId + ); if (projectMemberships.length !== userIds.length) { const projectMemberUserIds = new Set(projectMemberships.map((member) => member.userId)); @@ -253,7 +252,7 @@ export const secretApprovalPolicyServiceFactory = ({ userApproverIds = userApproverIds.concat(approverUsers.map((user) => user.id)); } - await verifyProjectUserMembership(userApproverIds, projectId); + await verifyProjectUserMembership(userApproverIds, actorOrgId, projectId); await secretApprovalPolicyApproverDAL.insertMany( userApproverIds.map((approverUserId) => ({ @@ -447,7 +446,7 @@ export const secretApprovalPolicyServiceFactory = ({ userApproverIds = userApproverIds.concat(approverUsers.map((user) => user.id)); } - await verifyProjectUserMembership(userApproverIds, secretApprovalPolicy.projectId); + await verifyProjectUserMembership(userApproverIds, actorOrgId, secretApprovalPolicy.projectId); await secretApprovalPolicyApproverDAL.insertMany( userApproverIds.map((approverUserId) => ({ diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts index bf2a3c10a..824a278d6 100644 --- a/backend/src/server/routes/index.ts +++ b/backend/src/server/routes/index.ts @@ -1504,7 +1504,7 @@ export const registerRoutes = async ( accessApprovalRequestDAL, accessApprovalRequestReviewerDAL, additionalPrivilegeDAL, - membershipUserDAL + projectMembershipDAL }); const accessApprovalRequestService = accessApprovalRequestServiceFactory({ diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.ts index 23cdf389d..1b1890cbd 100644 --- a/frontend/src/hooks/api/pam/types/index.ts +++ b/frontend/src/hooks/api/pam/types/index.ts @@ -1,9 +1,9 @@ import { PamResourceType, PamSessionStatus } from "../enums"; -import { TPostgresAccount, TPostgresResource } from "./postgres-resource"; import { TMySQLAccount, TMySQLResource } from "./mysql-resource"; +import { TPostgresAccount, TPostgresResource } from "./postgres-resource"; -export * from "./postgres-resource"; export * from "./mysql-resource"; +export * from "./postgres-resource"; export type TPamResource = TPostgresResource | TMySQLResource; diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MySQLAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MySQLAccountForm.tsx index 131da7ef3..e30c79e24 100644 --- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MySQLAccountForm.tsx +++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MySQLAccountForm.tsx @@ -1,14 +1,14 @@ -import { zodResolver } from "@hookform/resolvers/zod"; import { FormProvider, useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { Button, ModalClose } from "@app/components/v2"; import { PamResourceType, TMySQLAccount } from "@app/hooks/api/pam"; import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants"; -import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccountFields"; import { BaseSqlAccountSchema } from "./shared/sql-account-schemas"; import { SqlAccountFields } from "./shared/SqlAccountFields"; +import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccountFields"; type Props = { account?: TMySQLAccount; diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx index 6d361877e..e7d2d902b 100644 --- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx +++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx @@ -1,6 +1,6 @@ -import { zodResolver } from "@hookform/resolvers/zod"; import { useEffect, useState } from "react"; import { FormProvider, useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { Button, ModalClose } from "@app/components/v2"; @@ -12,10 +12,10 @@ import { } from "@app/hooks/api/pam"; import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants"; -import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccountFields"; -import { RotateAccountFields, rotateAccountFieldsSchema } from "./RotateAccountFields"; import { BaseSqlAccountSchema } from "./shared/sql-account-schemas"; import { SqlAccountFields } from "./shared/SqlAccountFields"; +import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccountFields"; +import { RotateAccountFields, rotateAccountFieldsSchema } from "./RotateAccountFields"; type Props = { account?: TPostgresAccount;