mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-10 07:58:15 -05:00
lint & a few fixes
This commit is contained in:
10
backend/src/@types/knex.d.ts
vendored
10
backend/src/@types/knex.d.ts
vendored
@@ -597,16 +597,16 @@ import {
|
||||
TWorkflowIntegrationsInsert,
|
||||
TWorkflowIntegrationsUpdate
|
||||
} from "@app/db/schemas";
|
||||
import {
|
||||
TCertificateRequests,
|
||||
TCertificateRequestsInsert,
|
||||
TCertificateRequestsUpdate
|
||||
} from "@app/db/schemas/certificate-requests";
|
||||
import {
|
||||
TAccessApprovalPoliciesEnvironments,
|
||||
TAccessApprovalPoliciesEnvironmentsInsert,
|
||||
TAccessApprovalPoliciesEnvironmentsUpdate
|
||||
} from "@app/db/schemas/access-approval-policies-environments";
|
||||
import {
|
||||
TCertificateRequests,
|
||||
TCertificateRequestsInsert,
|
||||
TCertificateRequestsUpdate
|
||||
} from "@app/db/schemas/certificate-requests";
|
||||
import {
|
||||
TIdentityAuthTemplates,
|
||||
TIdentityAuthTemplatesInsert,
|
||||
|
||||
@@ -12,7 +12,6 @@ import { registerDynamicSecretLeaseRouter } from "./dynamic-secret-lease-router"
|
||||
import { registerKubernetesDynamicSecretLeaseRouter } from "./dynamic-secret-lease-routers/kubernetes-lease-router";
|
||||
import { registerDynamicSecretRouter } from "./dynamic-secret-router";
|
||||
import { registerExternalKmsRouter } from "./external-kms-router";
|
||||
|
||||
import { EXTERNAL_KMS_REGISTER_ROUTER_MAP } from "./external-kms-routers";
|
||||
import { registerGatewayRouter } from "./gateway-router";
|
||||
import { registerGithubOrgSyncRouter } from "./github-org-sync-router";
|
||||
|
||||
@@ -219,7 +219,7 @@ export const approvalRequestDALFactory = (db: TDbClient) => {
|
||||
.whereIn("requestId", requestIds)
|
||||
.orderBy("stepNumber", "asc");
|
||||
|
||||
const stepsByRequestId: Record<string, any[]> = {};
|
||||
const stepsByRequestId: Record<string, ApprovalPolicyStep[]> = {};
|
||||
|
||||
if (steps.length) {
|
||||
const stepIds = steps.map((step) => step.id);
|
||||
|
||||
@@ -6,9 +6,9 @@ import {
|
||||
ApprovalRequestsSchema,
|
||||
ApprovalRequestStepsSchema
|
||||
} from "@app/db/schemas";
|
||||
import { ms } from "@app/lib/ms";
|
||||
|
||||
import { ApproverType } from "./approval-policy-enums";
|
||||
import { ms } from "@app/lib/ms";
|
||||
|
||||
const ApprovalPolicyStepSchema = z.object({
|
||||
name: z.string().min(1).max(128).nullable().optional(),
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ActionProjectType, ProjectMembershipRole, TApprovalPolicies, TApprovalR
|
||||
import { TUserGroupMembershipDALFactory } from "@app/ee/services/group/user-group-membership-dal";
|
||||
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
|
||||
import { BadRequestError, ForbiddenRequestError } from "@app/lib/errors";
|
||||
import { ms } from "@app/lib/ms";
|
||||
import { OrgServiceActor } from "@app/lib/types";
|
||||
import { TNotificationServiceFactory } from "@app/services/notification/notification-service";
|
||||
import { NotificationType } from "@app/services/notification/notification-types";
|
||||
@@ -31,7 +32,6 @@ import {
|
||||
TCreateRequestDTO,
|
||||
TUpdatePolicyDTO
|
||||
} from "./approval-policy-types";
|
||||
import { ms } from "@app/lib/ms";
|
||||
|
||||
type TApprovalPolicyServiceFactoryDep = {
|
||||
approvalPolicyDAL: TApprovalPolicyDALFactory;
|
||||
@@ -66,7 +66,7 @@ export const approvalPolicyServiceFactory = ({
|
||||
|
||||
const userIdsToNotify = new Set<string>();
|
||||
|
||||
for (const approver of step.approvers) {
|
||||
for await (const approver of step.approvers) {
|
||||
if (approver.type === ApproverType.User) {
|
||||
userIdsToNotify.add(approver.id);
|
||||
} else if (approver.type === ApproverType.Group) {
|
||||
@@ -519,7 +519,7 @@ export const approvalPolicyServiceFactory = ({
|
||||
}
|
||||
|
||||
const { updatedRequest, nextStepToNotify } = await approvalRequestDAL.transaction(async (tx) => {
|
||||
let nextStepToNotify = null;
|
||||
let nextStepToNotifyInner = null;
|
||||
|
||||
// Create approval
|
||||
await approvalRequestApprovalsDAL.create(
|
||||
@@ -565,7 +565,7 @@ export const approvalPolicyServiceFactory = ({
|
||||
);
|
||||
|
||||
if (nextStep.notifyApprovers) {
|
||||
nextStepToNotify = nextStep;
|
||||
nextStepToNotifyInner = nextStep;
|
||||
}
|
||||
} else {
|
||||
// All steps completed
|
||||
@@ -581,7 +581,7 @@ export const approvalPolicyServiceFactory = ({
|
||||
}
|
||||
}
|
||||
|
||||
return { updatedRequest: request, nextStepToNotify };
|
||||
return { updatedRequest: request, nextStepToNotify: nextStepToNotifyInner };
|
||||
});
|
||||
|
||||
if (nextStepToNotify) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import picomatch from "picomatch";
|
||||
|
||||
import { ms } from "@app/lib/ms";
|
||||
|
||||
import { ApprovalRequestGrantStatus } from "../approval-policy-enums";
|
||||
import {
|
||||
TApprovalRequestFactoryCanAccess,
|
||||
@@ -9,7 +11,6 @@ import {
|
||||
TApprovalResourceFactory
|
||||
} from "../approval-policy-types";
|
||||
import { TPamAccessPolicy, TPamAccessPolicyInputs, TPamAccessRequestData } from "./pam-access-policy-types";
|
||||
import { ms } from "@app/lib/ms";
|
||||
|
||||
export const pamAccessPolicyFactory: TApprovalResourceFactory<
|
||||
TPamAccessPolicyInputs,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { ms } from "@app/lib/ms";
|
||||
|
||||
import {
|
||||
|
||||
@@ -19,8 +19,8 @@ import {
|
||||
CertExtendedKeyUsageType,
|
||||
CertIncludeType,
|
||||
CertKeyUsageType,
|
||||
CertSubjectAttributeType,
|
||||
CertSubjectAlternativeNameType
|
||||
CertSubjectAlternativeNameType,
|
||||
CertSubjectAttributeType
|
||||
} from "@app/services/certificate-common/certificate-constants";
|
||||
import { TCertificateProfileDALFactory } from "@app/services/certificate-profile/certificate-profile-dal";
|
||||
import { EnrollmentType, IssuerType } from "@app/services/certificate-profile/certificate-profile-types";
|
||||
|
||||
@@ -68,12 +68,6 @@ export const ROUTE_PATHS = Object.freeze({
|
||||
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/networking"
|
||||
)
|
||||
},
|
||||
Pam: {
|
||||
ApprovalRequestDetailPage: setRoute(
|
||||
"/organizations/$orgId/projects/pam/$projectId/approval-requests/$approvalRequestId",
|
||||
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/pam/$projectId/_pam-layout/approval-requests/$approvalRequestId"
|
||||
)
|
||||
},
|
||||
SecretManager: {
|
||||
ApprovalPage: setRoute(
|
||||
"/organizations/$orgId/projects/secret-management/$projectId/approval",
|
||||
@@ -368,6 +362,10 @@ export const ROUTE_PATHS = Object.freeze({
|
||||
PamSessionByIDPage: setRoute(
|
||||
"/organizations/$orgId/projects/pam/$projectId/sessions/$sessionId",
|
||||
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/pam/$projectId/_pam-layout/sessions/$sessionId"
|
||||
),
|
||||
ApprovalRequestDetailPage: setRoute(
|
||||
"/organizations/$orgId/projects/pam/$projectId/approval-requests/$approvalRequestId",
|
||||
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/pam/$projectId/_pam-layout/approval-requests/$approvalRequestId"
|
||||
)
|
||||
},
|
||||
Public: {
|
||||
|
||||
@@ -5,9 +5,9 @@ export {
|
||||
} from "./mutations";
|
||||
export { approvalPolicyQuery } from "./queries";
|
||||
export {
|
||||
type ApprovalPolicyStep,
|
||||
ApprovalPolicyType,
|
||||
ApproverType,
|
||||
type ApprovalPolicyStep,
|
||||
type PamAccessPolicyConditions,
|
||||
type PamAccessPolicyConstraints,
|
||||
type TApprovalPolicy,
|
||||
|
||||
@@ -5,10 +5,10 @@ export {
|
||||
} from "./mutations";
|
||||
export { approvalRequestQuery } from "./queries";
|
||||
export {
|
||||
ApprovalRequestStatus,
|
||||
ApprovalRequestStepStatus,
|
||||
type ApprovalRequestApproval,
|
||||
ApprovalRequestStatus,
|
||||
type ApprovalRequestStep,
|
||||
ApprovalRequestStepStatus,
|
||||
type PamAccessRequestData,
|
||||
type TApprovalRequest,
|
||||
type TApproveApprovalRequestDTO,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Helmet } from "react-helmet";
|
||||
import { useNavigate, useSearch } from "@tanstack/react-router";
|
||||
|
||||
import { PageHeader, Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
||||
import { useOrganization, useProject } from "@app/context";
|
||||
import { ApprovalControlTabs } from "@app/types/project";
|
||||
import { useNavigate, useSearch } from "@tanstack/react-router";
|
||||
import { PolicyTab } from "./components/PolicyTab";
|
||||
|
||||
import { ApprovalRequestTab } from "./components/ApprovalRequestTab";
|
||||
import { PolicyTab } from "./components/PolicyTab";
|
||||
|
||||
const Page = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
faSearch
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { formatDistance } from "date-fns";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
@@ -39,14 +39,13 @@ import {
|
||||
import { Badge } from "@app/components/v3";
|
||||
import { useOrganization, useProject, useUser } from "@app/context";
|
||||
import { usePagination } from "@app/hooks";
|
||||
import { ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
|
||||
import { ApprovalPolicyType, ApproverType } from "@app/hooks/api/approvalPolicies";
|
||||
import {
|
||||
approvalRequestQuery,
|
||||
ApprovalRequestStatus,
|
||||
ApprovalRequestStepStatus,
|
||||
TApprovalRequest
|
||||
} from "@app/hooks/api/approvalRequests";
|
||||
import { ApproverType } from "@app/hooks/api/approvalPolicies";
|
||||
|
||||
type Filter = {
|
||||
status: "open" | "closed";
|
||||
@@ -119,7 +118,9 @@ export const RequestsTable = () => {
|
||||
})
|
||||
);
|
||||
|
||||
const { page, perPage, setPage, setPerPage, offset } = usePagination();
|
||||
const { page, perPage, setPage, setPerPage, offset } = usePagination("", {
|
||||
initPerPage: 10
|
||||
});
|
||||
|
||||
const filteredRequests = useMemo(() => {
|
||||
let filtered = requests;
|
||||
@@ -376,7 +377,9 @@ export const RequestsTable = () => {
|
||||
{!isRequestsLoading && !filteredRequests?.length && (
|
||||
<EmptyState
|
||||
title={
|
||||
requests.length ? "No approval requests match search..." : "No approval requests found"
|
||||
requests.length
|
||||
? "No approval requests match search..."
|
||||
: "No approval requests found"
|
||||
}
|
||||
icon={requests.length ? faSearch : faFileCircleQuestion}
|
||||
/>
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
faUsers
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import {
|
||||
@@ -36,7 +37,6 @@ import {
|
||||
ApproverType
|
||||
} from "@app/hooks/api/approvalPolicies";
|
||||
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
type Props = {
|
||||
handlePopUpOpen: (
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ApproverType } from "@app/hooks/api/approvalPolicies";
|
||||
import { z } from "zod";
|
||||
|
||||
import { ApproverType } from "@app/hooks/api/approvalPolicies";
|
||||
|
||||
export const PolicyFormSchema = z.object({
|
||||
name: z.string().min(1, "Policy name is required").max(128),
|
||||
maxRequestTtlSeconds: z.number().min(3600).max(2592000).nullable().optional(),
|
||||
|
||||
@@ -5,10 +5,10 @@ import { createNotification } from "@app/components/notifications";
|
||||
import { Button, DeleteActionModal } from "@app/components/v2";
|
||||
import { useProject } from "@app/context";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useDeleteApprovalPolicy, ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
|
||||
import { ApprovalPolicyType, useDeleteApprovalPolicy } from "@app/hooks/api/approvalPolicies";
|
||||
|
||||
import { PolicyModal } from "./PolicyModal";
|
||||
import { PoliciesTable } from "./PoliciesTable";
|
||||
import { PolicyModal } from "./PolicyModal";
|
||||
|
||||
export const PolicySection = () => {
|
||||
const { currentProject } = useProject();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useMemo } from "react";
|
||||
import { Controller, useFieldArray, useFormContext } from "react-hook-form";
|
||||
import { MultiValue } from "react-select";
|
||||
import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
|
||||
@@ -12,10 +13,7 @@ import { ApproverType } from "@app/hooks/api/approvalPolicies";
|
||||
import { TPolicyForm } from "../PolicySchema";
|
||||
|
||||
export const PolicyApprovalSteps = () => {
|
||||
const {
|
||||
control,
|
||||
formState: { errors }
|
||||
} = useFormContext<TPolicyForm>();
|
||||
const { control } = useFormContext<TPolicyForm>();
|
||||
|
||||
const { currentProject } = useProject();
|
||||
const projectId = currentProject?.id || "";
|
||||
@@ -55,7 +53,7 @@ export const PolicyApprovalSteps = () => {
|
||||
<div className="space-y-4">
|
||||
<div className="mb-3 flex items-center justify-between">
|
||||
<div>
|
||||
<label className="text-sm font-medium text-mineshaft-200">Approval Steps</label>
|
||||
<span className="text-sm font-medium text-mineshaft-200">Approval Steps</span>
|
||||
<p className="text-xs text-mineshaft-400">
|
||||
Define the approval workflow with sequential steps
|
||||
</p>
|
||||
@@ -157,7 +155,9 @@ export const PolicyApprovalSteps = () => {
|
||||
label="User Approvers"
|
||||
isError={Boolean(error)}
|
||||
errorText={
|
||||
error?.message && userApprovers.length === 0 && groupApprovers.length === 0
|
||||
error?.message &&
|
||||
userApprovers.length === 0 &&
|
||||
groupApprovers.length === 0
|
||||
? error?.message
|
||||
: undefined
|
||||
}
|
||||
@@ -175,7 +175,10 @@ export const PolicyApprovalSteps = () => {
|
||||
value={userApprovers}
|
||||
onChange={(selected) => {
|
||||
const newApprovers = [
|
||||
...(selected || []),
|
||||
...((selected as MultiValue<{
|
||||
type: ApproverType;
|
||||
id: string;
|
||||
}>) || []),
|
||||
...groupApprovers
|
||||
];
|
||||
onChange(newApprovers);
|
||||
@@ -187,7 +190,9 @@ export const PolicyApprovalSteps = () => {
|
||||
label="Group Approvers"
|
||||
isError={Boolean(error)}
|
||||
errorText={
|
||||
error?.message && userApprovers.length === 0 && groupApprovers.length === 0
|
||||
error?.message &&
|
||||
userApprovers.length === 0 &&
|
||||
groupApprovers.length === 0
|
||||
? error?.message
|
||||
: undefined
|
||||
}
|
||||
@@ -205,7 +210,10 @@ export const PolicyApprovalSteps = () => {
|
||||
onChange={(selected) => {
|
||||
const newApprovers = [
|
||||
...userApprovers,
|
||||
...(selected || [])
|
||||
...((selected as MultiValue<{
|
||||
type: ApproverType;
|
||||
id: string;
|
||||
}>) || [])
|
||||
];
|
||||
onChange(newApprovers);
|
||||
}}
|
||||
@@ -225,7 +233,7 @@ export const PolicyApprovalSteps = () => {
|
||||
<div className="rounded border border-dashed border-mineshaft-600 bg-mineshaft-800/50 p-8 text-center">
|
||||
<p className="text-sm text-mineshaft-400">No approval steps defined</p>
|
||||
<p className="mt-1 text-xs text-mineshaft-500">
|
||||
Click "Add Step" to create your first approval step
|
||||
Click "Add Step" to create your first approval step
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
|
||||
import { Button, FormControl, IconButton, Input } from "@app/components/v2";
|
||||
|
||||
import { TPolicyForm } from "../PolicySchema";
|
||||
|
||||
export const PolicyConstraintsStep = () => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
|
||||
import { FormControl, Input } from "@app/components/v2";
|
||||
|
||||
import { TPolicyForm } from "../PolicySchema";
|
||||
|
||||
export const PolicyDetailsStep = () => {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export { PolicyModal } from "./PolicyModal";
|
||||
export { PoliciesTable } from "./PoliciesTable";
|
||||
export { PolicyModal } from "./PolicyModal";
|
||||
export { PolicySection } from "./PolicySection";
|
||||
|
||||
Reference in New Issue
Block a user