Merge remote-tracking branch 'origin/main' into feature/est-simpleenroll

This commit is contained in:
Sheen Capadngan
2024-08-27 02:13:59 +08:00
98 changed files with 2176 additions and 827 deletions
+1
View File
@@ -93,6 +93,7 @@ export type CompleteAccountDTO = {
salt: string;
verifier: string;
password: string;
tokenMetadata?: string;
};
export type CompleteAccountSignupDTO = CompleteAccountDTO & {
+1 -1
View File
@@ -8,4 +8,4 @@ export {
useSignIntermediate,
useUpdateCa
} from "./mutations";
export { useGetCaById, useGetCaCert, useGetCaCerts, useGetCaCrl, useGetCaCsr } from "./queries";
export { useGetCaById, useGetCaCert, useGetCaCerts, useGetCaCrls, useGetCaCsr } from "./queries";
+10 -8
View File
@@ -7,6 +7,7 @@ import { TCertificateAuthority } from "./types";
export const caKeys = {
getCaById: (caId: string) => [{ caId }, "ca"],
getCaCerts: (caId: string) => [{ caId }, "ca-cert"],
getCaCrls: (caId: string) => [{ caId }, "ca-crls"],
getCaCert: (caId: string) => [{ caId }, "ca-cert"],
getCaCsr: (caId: string) => [{ caId }, "ca-csr"],
getCaCrl: (caId: string) => [{ caId }, "ca-crl"],
@@ -74,16 +75,17 @@ export const useGetCaCsr = (caId: string) => {
});
};
export const useGetCaCrl = (caId: string) => {
export const useGetCaCrls = (caId: string) => {
return useQuery({
queryKey: caKeys.getCaCrl(caId),
queryKey: caKeys.getCaCrls(caId),
queryFn: async () => {
const {
data: { crl }
} = await apiRequest.get<{
crl: string;
}>(`/api/v1/pki/ca/${caId}/crl`);
return crl;
const { data } = await apiRequest.get<
{
id: string;
crl: string;
}[]
>(`/api/v1/pki/ca/${caId}/crls`);
return data;
},
enabled: Boolean(caId)
});
@@ -120,16 +120,22 @@ const fetchIntegrationAuthById = async (integrationAuthId: string) => {
const fetchIntegrationAuthApps = async ({
integrationAuthId,
teamId,
azureDevOpsOrgName,
workspaceSlug
}: {
integrationAuthId: string;
teamId?: string;
azureDevOpsOrgName?: string;
workspaceSlug?: string;
}) => {
const params: Record<string, string> = {};
if (teamId) {
params.teamId = teamId;
}
if (azureDevOpsOrgName) {
params.azureDevOpsOrgName = azureDevOpsOrgName;
}
if (workspaceSlug) {
params.workspaceSlug = workspaceSlug;
}
@@ -452,10 +458,12 @@ export const useGetIntegrationAuthById = (integrationAuthId: string) => {
export const useGetIntegrationAuthApps = ({
integrationAuthId,
teamId,
azureDevOpsOrgName,
workspaceSlug
}: {
integrationAuthId: string;
teamId?: string;
azureDevOpsOrgName?: string;
workspaceSlug?: string;
}) => {
return useQuery({
@@ -464,6 +472,7 @@ export const useGetIntegrationAuthApps = ({
fetchIntegrationAuthApps({
integrationAuthId,
teamId,
azureDevOpsOrgName,
workspaceSlug
}),
enabled: true
+1 -1
View File
@@ -47,7 +47,7 @@ export const roleQueryKeys = {
["user-project-permissions", { workspaceId }] as const
};
const getProjectRoles = async (projectId: string) => {
export const getProjectRoles = async (projectId: string) => {
const { data } = await apiRequest.get<{ roles: Array<Omit<TProjectRole, "permissions">> }>(
`/api/v1/workspace/${projectId}/roles`
);
@@ -9,7 +9,15 @@ export const useCreateSecretApprovalPolicy = () => {
const queryClient = useQueryClient();
return useMutation<{}, {}, TCreateSecretPolicyDTO>({
mutationFn: async ({ environment, workspaceId, approvals, approvers, secretPath, name, enforcementLevel }) => {
mutationFn: async ({
environment,
workspaceId,
approvals,
approvers,
secretPath,
name,
enforcementLevel
}) => {
const { data } = await apiRequest.post("/api/v1/secret-approvals", {
environment,
workspaceId,
+3 -2
View File
@@ -6,7 +6,7 @@ export {
} from "./mutation";
export {
fetchOrgUsers,
useAddUserToOrg,
useAddUsersToOrg,
useCreateAPIKey,
useDeleteAPIKey,
useDeleteMe,
@@ -26,4 +26,5 @@ export {
useRevokeMySessions,
useUpdateMfaEnabled,
useUpdateOrgMembership,
useUpdateUserAuthMethods} from "./queries";
useUpdateUserAuthMethods
} from "./queries";
+5 -2
View File
@@ -157,12 +157,15 @@ export const useGetOrgUsers = (orgId: string) =>
// mutation
// TODO(akhilmhdh): move all mutation to mutation file
export const useAddUserToOrg = () => {
export const useAddUsersToOrg = () => {
const queryClient = useQueryClient();
type Response = {
data: {
message: string;
completeInviteLink: string | undefined;
completeInviteLinks?: {
email: string;
link: string;
}[];
};
};
+4 -1
View File
@@ -149,7 +149,10 @@ export type DeletOrgMembershipDTO = {
};
export type AddUserToOrgDTO = {
inviteeEmail: string;
inviteeEmails: string[];
projectIds?: string[];
projectRoleSlug?: string;
organizationRoleSlug: string;
organizationId: string;
};
+8 -4
View File
@@ -138,8 +138,12 @@ export const useGetUpgradeProjectStatus = ({
});
};
const fetchUserWorkspaces = async () => {
const { data } = await apiRequest.get<{ workspaces: Workspace[] }>("/api/v1/workspace");
const fetchUserWorkspaces = async (includeRoles?: boolean) => {
const { data } = await apiRequest.get<{ workspaces: Workspace[] }>("/api/v1/workspace", {
params: {
includeRoles
}
});
return data.workspaces;
};
@@ -171,8 +175,8 @@ export const useGetWorkspaceById = (
});
};
export const useGetUserWorkspaces = () =>
useQuery(workspaceKeys.getAllUserWorkspace, fetchUserWorkspaces);
export const useGetUserWorkspaces = (includeRoles?: boolean) =>
useQuery(workspaceKeys.getAllUserWorkspace, () => fetchUserWorkspaces(includeRoles));
const fetchUserWorkspaceMemberships = async (orgId: string) => {
const { data } = await apiRequest.get<Record<string, Workspace[]>>(
@@ -1,3 +1,5 @@
import { TProjectRole } from "../roles/types";
export enum ProjectVersion {
V1 = 1,
V2 = 2,
@@ -22,6 +24,8 @@ export type Workspace = {
auditLogsRetentionDays: number;
slug: string;
createdAt: string;
roles?: TProjectRole[];
};
export type WorkspaceEnv = {