Merge branch 'main' into feat/improveSecretReferenceWarning

This commit is contained in:
carlosmonastyrski
2025-04-29 08:43:35 -03:00
376 changed files with 9209 additions and 1020 deletions
@@ -4,15 +4,20 @@ import { apiRequest } from "@app/config/request";
import { appConnectionKeys } from "@app/hooks/api/appConnections";
import {
TAwsConnectionIamUser,
TAwsConnectionKmsKey,
TAwsConnectionListIamUsersResponse,
TAwsConnectionListKmsKeysResponse,
TListAwsConnectionIamUsers,
TListAwsConnectionKmsKeys
} from "./types";
const awsConnectionKeys = {
all: [...appConnectionKeys.all, "aws"] as const,
listKmsKeys: (params: TListAwsConnectionKmsKeys) =>
[...awsConnectionKeys.all, "kms-keys", params] as const
[...awsConnectionKeys.all, "kms-keys", params] as const,
listIamUsers: (params: TListAwsConnectionIamUsers) =>
[...awsConnectionKeys.all, "iam-users", params] as const
};
export const useListAwsConnectionKmsKeys = (
@@ -40,3 +45,28 @@ export const useListAwsConnectionKmsKeys = (
...options
});
};
export const useListAwsConnectionIamUsers = (
{ connectionId }: TListAwsConnectionIamUsers,
options?: Omit<
UseQueryOptions<
TAwsConnectionIamUser[],
unknown,
TAwsConnectionIamUser[],
ReturnType<typeof awsConnectionKeys.listIamUsers>
>,
"queryKey" | "queryFn"
>
) => {
return useQuery({
queryKey: awsConnectionKeys.listIamUsers({ connectionId }),
queryFn: async () => {
const { data } = await apiRequest.get<TAwsConnectionListIamUsersResponse>(
`/api/v1/app-connections/aws/${connectionId}/users`
);
return data.iamUsers;
},
...options
});
};
@@ -14,3 +14,18 @@ export type TAwsConnectionKmsKey = {
export type TAwsConnectionListKmsKeysResponse = {
kmsKeys: TAwsConnectionKmsKey[];
};
export type TListAwsConnectionIamUsers = {
connectionId: string;
};
export type TAwsConnectionIamUser = {
arn: string;
UserName: string;
};
export type TAwsConnectionListIamUsersResponse = {
iamUsers: TAwsConnectionIamUser[];
};
export type TAwsIamUserSecret = TAwsConnectionIamUser;
@@ -12,5 +12,7 @@ export enum AppConnection {
MsSql = "mssql",
Camunda = "camunda",
Windmill = "windmill",
Auth0 = "auth0"
Auth0 = "auth0",
LDAP = "ldap",
TeamCity = "teamcity"
}
@@ -0,0 +1,2 @@
export * from "./queries";
export * from "./types";
@@ -0,0 +1,37 @@
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { appConnectionKeys } from "../queries";
import { TTeamCityProjectWithBuildTypes } from "./types";
const teamcityConnectionKeys = {
all: [...appConnectionKeys.all, "teamcity"] as const,
listProjects: (connectionId: string) =>
[...teamcityConnectionKeys.all, "projects", connectionId] as const
};
export const useTeamCityConnectionListProjects = (
connectionId: string,
options?: Omit<
UseQueryOptions<
TTeamCityProjectWithBuildTypes[],
unknown,
TTeamCityProjectWithBuildTypes[],
ReturnType<typeof teamcityConnectionKeys.listProjects>
>,
"queryKey" | "queryFn"
>
) => {
return useQuery({
queryKey: teamcityConnectionKeys.listProjects(connectionId),
queryFn: async () => {
const { data } = await apiRequest.get<TTeamCityProjectWithBuildTypes[]>(
`/api/v1/app-connections/teamcity/${connectionId}/projects`
);
return data;
},
...options
});
};
@@ -0,0 +1,13 @@
export type TTeamCityProject = {
id: string;
name: string;
};
export type TTeamCityProjectWithBuildTypes = TTeamCityProject & {
buildTypes: {
buildType: {
id: string;
name: string;
}[];
};
};
@@ -67,6 +67,14 @@ export type TAuth0ConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.Auth0;
};
export type TLdapConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.LDAP;
};
export type TTeamCityConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.TeamCity;
};
export type TAppConnectionOption =
| TAwsConnectionOption
| TGitHubConnectionOption
@@ -81,7 +89,8 @@ export type TAppConnectionOption =
| TMsSqlConnectionOption
| TCamundaConnectionOption
| TWindmillConnectionOption
| TAuth0ConnectionOption;
| TAuth0ConnectionOption
| TTeamCityConnectionOption;
export type TAppConnectionOptionMap = {
[AppConnection.AWS]: TAwsConnectionOption;
@@ -98,4 +107,6 @@ export type TAppConnectionOptionMap = {
[AppConnection.Camunda]: TCamundaConnectionOption;
[AppConnection.Windmill]: TWindmillConnectionOption;
[AppConnection.Auth0]: TAuth0ConnectionOption;
[AppConnection.LDAP]: TLdapConnectionOption;
[AppConnection.TeamCity]: TTeamCityConnectionOption;
};
@@ -9,8 +9,10 @@ import { TDatabricksConnection } from "./databricks-connection";
import { TGcpConnection } from "./gcp-connection";
import { TGitHubConnection } from "./github-connection";
import { THumanitecConnection } from "./humanitec-connection";
import { TLdapConnection } from "./ldap-connection";
import { TMsSqlConnection } from "./mssql-connection";
import { TPostgresConnection } from "./postgres-connection";
import { TTeamCityConnection } from "./teamcity-connection";
import { TTerraformCloudConnection } from "./terraform-cloud-connection";
import { TVercelConnection } from "./vercel-connection";
import { TWindmillConnection } from "./windmill-connection";
@@ -24,8 +26,10 @@ export * from "./databricks-connection";
export * from "./gcp-connection";
export * from "./github-connection";
export * from "./humanitec-connection";
export * from "./ldap-connection";
export * from "./mssql-connection";
export * from "./postgres-connection";
export * from "./teamcity-connection";
export * from "./terraform-cloud-connection";
export * from "./vercel-connection";
export * from "./windmill-connection";
@@ -44,7 +48,9 @@ export type TAppConnection =
| TMsSqlConnection
| TCamundaConnection
| TWindmillConnection
| TAuth0Connection;
| TAuth0Connection
| TLdapConnection
| TTeamCityConnection;
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
@@ -86,4 +92,6 @@ export type TAppConnectionMap = {
[AppConnection.Camunda]: TCamundaConnection;
[AppConnection.Windmill]: TWindmillConnection;
[AppConnection.Auth0]: TAuth0Connection;
[AppConnection.LDAP]: TLdapConnection;
[AppConnection.TeamCity]: TTeamCityConnection;
};
@@ -0,0 +1,21 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
export enum LdapConnectionMethod {
SimpleBind = "simple-bind"
}
export enum LdapConnectionProvider {
ActiveDirectory = "active-directory"
}
export type TLdapConnection = TRootAppConnection & { app: AppConnection.LDAP } & {
method: LdapConnectionMethod.SimpleBind;
credentials: {
provider: LdapConnectionProvider;
url: string;
dn: string;
sslRejectUnauthorized?: boolean;
sslCertificate?: string;
};
};
@@ -0,0 +1,14 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
export enum TeamCityConnectionMethod {
AccessToken = "access-token"
}
export type TTeamCityConnection = TRootAppConnection & { app: AppConnection.TeamCity } & {
method: TeamCityConnectionMethod.AccessToken;
credentials: {
accessToken: string;
instanceUrl: string;
};
};
@@ -0,0 +1 @@
export { useAssumeProjectPrivileges, useRemoveAssumeProjectPrivilege } from "./mutations";
@@ -0,0 +1,28 @@
import { useMutation } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TProjectAssumePrivilegesDTO } from "./types";
export const useAssumeProjectPrivileges = () =>
useMutation({
mutationFn: async ({ projectId, actorId, actorType }: TProjectAssumePrivilegesDTO) => {
const { data } = await apiRequest.post<{ message: string }>(
`/api/v1/workspace/${projectId}/assume-privileges`,
{ actorId, actorType }
);
return data;
}
});
export const useRemoveAssumeProjectPrivilege = () =>
useMutation({
mutationFn: async ({ projectId }: { projectId: string }) => {
const { data } = await apiRequest.delete<{ message: string }>(
`/api/v1/workspace/${projectId}/assume-privileges`
);
return data;
}
});
@@ -0,0 +1,7 @@
import { ActorType } from "../auditLogs/enums";
export type TProjectAssumePrivilegesDTO = {
projectId: string;
actorType: ActorType;
actorId: string;
};
@@ -0,0 +1,6 @@
export {
useCreateGithubSyncOrgConfig,
useDeleteGithubSyncOrgConfig,
useUpdateGithubSyncOrgConfig
} from "./mutations";
export { githubOrgSyncConfigQueryKeys } from "./queries";
@@ -0,0 +1,42 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { githubOrgSyncConfigQueryKeys } from "./queries";
import { TCreateGithubOrgSyncDTO, TUpdateGithubOrgSyncDTO } from "./types";
export const useCreateGithubSyncOrgConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (dto: TCreateGithubOrgSyncDTO) => {
return apiRequest.post("/api/v1/github-org-sync-config", dto);
},
onSuccess: () => {
queryClient.invalidateQueries(githubOrgSyncConfigQueryKeys.get());
}
});
};
export const useUpdateGithubSyncOrgConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (dto: TUpdateGithubOrgSyncDTO) => {
return apiRequest.patch("/api/v1/github-org-sync-config", dto);
},
onSuccess: () => {
queryClient.invalidateQueries(githubOrgSyncConfigQueryKeys.get());
}
});
};
export const useDeleteGithubSyncOrgConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: () => {
return apiRequest.delete("/api/v1/github-org-sync-config");
},
onSuccess: () => {
queryClient.invalidateQueries(githubOrgSyncConfigQueryKeys.get());
}
});
};
@@ -0,0 +1,20 @@
import { queryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TGithubOrgSyncConfig } from "./types";
export const githubOrgSyncConfigQueryKeys = {
allKey: () => ["github-org-sync-config"],
getKey: () => [...githubOrgSyncConfigQueryKeys.allKey(), "list"],
get: () =>
queryOptions({
queryKey: githubOrgSyncConfigQueryKeys.getKey(),
queryFn: async () => {
const { data } = await apiRequest.get<{ githubOrgSyncConfig: TGithubOrgSyncConfig }>(
"/api/v1/github-org-sync-config"
);
return data.githubOrgSyncConfig;
}
})
};
@@ -0,0 +1,20 @@
export type TGithubOrgSyncConfig = {
id: string;
orgId: string;
githubOrgAccessToken?: string;
githubOrgName: string;
createdAt: string;
isActive?: boolean;
};
export interface TCreateGithubOrgSyncDTO {
githubOrgName: string;
githubOrgAccessToken?: string;
isActive?: boolean;
}
export interface TUpdateGithubOrgSyncDTO {
githubOrgName?: string;
githubOrgAccessToken?: string;
isActive?: boolean;
}
+2
View File
@@ -1,6 +1,7 @@
export * from "./accessApproval";
export * from "./admin";
export * from "./apiKeys";
export * from "./assumePrivileges";
export * from "./auditLogs";
export * from "./auditLogStreams";
export * from "./auth";
@@ -11,6 +12,7 @@ export * from "./certificateTemplates";
export * from "./dynamicSecret";
export * from "./dynamicSecretLease";
export * from "./gateways";
export * from "./githubOrgSyncConfig";
export * from "./groups";
export * from "./identities";
export * from "./identityProjectAdditionalPrivilege";
+2 -1
View File
@@ -19,5 +19,6 @@ export type OIDCConfigData = {
export enum OIDCJWTSignatureAlgorithm {
RS256 = "RS256",
HS256 = "HS256",
RS512 = "RS512"
RS512 = "RS512",
EDDSA = "EdDSA"
}
+7
View File
@@ -10,6 +10,7 @@ import { ProjectPermissionSet } from "@app/context/ProjectPermissionContext/type
import { groupBy } from "@app/lib/fn/array";
import { omit } from "@app/lib/fn/object";
import { ActorType } from "../auditLogs/enums";
import { OrgUser, TProjectMembership } from "../users/types";
import {
TGetUserOrgPermissionsDTO,
@@ -137,6 +138,12 @@ export const fetchUserProjectPermissions = async ({
data: {
permissions: PackRule<RawRuleOf<MongoAbility<OrgPermissionSet>>>[];
membership: Omit<TProjectMembership, "roles"> & { roles: { role: string }[] };
assumedPrivilegeDetails?: {
actorId: string;
actorType: ActorType;
actorEmail: string;
actorName: string;
};
};
}>(`/api/v1/workspace/${workspaceId}/permissions`, {});
@@ -1,7 +1,9 @@
export enum SecretRotation {
PostgresCredentials = "postgres-credentials",
MsSqlCredentials = "mssql-credentials",
Auth0ClientSecret = "auth0-client-secret"
Auth0ClientSecret = "auth0-client-secret",
LdapPassword = "ldap-password",
AwsIamUserSecret = "aws-iam-user-secret"
}
export enum SecretRotationStatus {
@@ -0,0 +1,38 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
import {
TSecretRotationV2Base,
TSecretRotationV2GeneratedCredentialsResponseBase
} from "@app/hooks/api/secretRotationsV2/types/shared";
export type TAwsIamUserSecretRotation = TSecretRotationV2Base & {
type: SecretRotation.AwsIamUserSecret;
parameters: {
region?: string;
userName: string;
};
secretsMapping: {
accessKeyId: string;
secretAccessKey: string;
};
};
export type TAwsIamUserSecretRotationGeneratedCredentials = {
accessKeyId: string;
secretAccessKey: string;
};
export type TAwsIamUserSecretRotationGeneratedCredentialsResponse =
TSecretRotationV2GeneratedCredentialsResponseBase<
SecretRotation.AwsIamUserSecret,
TAwsIamUserSecretRotationGeneratedCredentials
>;
export type TAwsIamUserSecretRotationOption = {
name: string;
type: SecretRotation.AwsIamUserSecret;
connection: AppConnection.AWS;
template: {
secretsMapping: TAwsIamUserSecretRotation["secretsMapping"];
};
};
@@ -4,6 +4,16 @@ import {
TAuth0ClientSecretRotationGeneratedCredentialsResponse,
TAuth0ClientSecretRotationOption
} from "@app/hooks/api/secretRotationsV2/types/auth0-client-secret-rotation";
import {
TAwsIamUserSecretRotation,
TAwsIamUserSecretRotationGeneratedCredentialsResponse,
TAwsIamUserSecretRotationOption
} from "@app/hooks/api/secretRotationsV2/types/aws-iam-user-secret-rotation";
import {
TLdapPasswordRotation,
TLdapPasswordRotationGeneratedCredentialsResponse,
TLdapPasswordRotationOption
} from "@app/hooks/api/secretRotationsV2/types/ldap-password-rotation";
import {
TMsSqlCredentialsRotation,
TMsSqlCredentialsRotationGeneratedCredentialsResponse
@@ -20,13 +30,17 @@ export type TSecretRotationV2 = (
| TPostgresCredentialsRotation
| TMsSqlCredentialsRotation
| TAuth0ClientSecretRotation
| TLdapPasswordRotation
| TAwsIamUserSecretRotation
) & {
secrets: (SecretV3RawSanitized | null)[];
};
export type TSecretRotationV2Option =
| TSqlCredentialsRotationOption
| TAuth0ClientSecretRotationOption;
| TAuth0ClientSecretRotationOption
| TLdapPasswordRotationOption
| TAwsIamUserSecretRotationOption;
export type TListSecretRotationV2Options = { secretRotationOptions: TSecretRotationV2Option[] };
@@ -35,7 +49,9 @@ export type TSecretRotationV2Response = { secretRotation: TSecretRotationV2 };
export type TViewSecretRotationGeneratedCredentialsResponse =
| TPostgresCredentialsRotationGeneratedCredentialsResponse
| TMsSqlCredentialsRotationGeneratedCredentialsResponse
| TAuth0ClientSecretRotationGeneratedCredentialsResponse;
| TAuth0ClientSecretRotationGeneratedCredentialsResponse
| TLdapPasswordRotationGeneratedCredentialsResponse
| TAwsIamUserSecretRotationGeneratedCredentialsResponse;
export type TCreateSecretRotationV2DTO = DiscriminativePick<
TSecretRotationV2,
@@ -82,10 +98,14 @@ export type TSecretRotationOptionMap = {
[SecretRotation.PostgresCredentials]: TSqlCredentialsRotationOption;
[SecretRotation.MsSqlCredentials]: TSqlCredentialsRotationOption;
[SecretRotation.Auth0ClientSecret]: TAuth0ClientSecretRotationOption;
[SecretRotation.LdapPassword]: TLdapPasswordRotationOption;
[SecretRotation.AwsIamUserSecret]: TAwsIamUserSecretRotationOption;
};
export type TSecretRotationGeneratedCredentialsResponseMap = {
[SecretRotation.PostgresCredentials]: TPostgresCredentialsRotationGeneratedCredentialsResponse;
[SecretRotation.MsSqlCredentials]: TMsSqlCredentialsRotationGeneratedCredentialsResponse;
[SecretRotation.Auth0ClientSecret]: TAuth0ClientSecretRotationGeneratedCredentialsResponse;
[SecretRotation.LdapPassword]: TLdapPasswordRotationGeneratedCredentialsResponse;
[SecretRotation.AwsIamUserSecret]: TAwsIamUserSecretRotationGeneratedCredentialsResponse;
};
@@ -0,0 +1,37 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
import {
TSecretRotationV2Base,
TSecretRotationV2GeneratedCredentialsResponseBase
} from "@app/hooks/api/secretRotationsV2/types/shared";
export type TLdapPasswordRotation = TSecretRotationV2Base & {
type: SecretRotation.LdapPassword;
parameters: {
dn: string;
};
secretsMapping: {
dn: string;
password: string;
};
};
export type TLdapPasswordRotationGeneratedCredentials = {
dn: string;
password: string;
};
export type TLdapPasswordRotationGeneratedCredentialsResponse =
TSecretRotationV2GeneratedCredentialsResponseBase<
SecretRotation.LdapPassword,
TLdapPasswordRotationGeneratedCredentials
>;
export type TLdapPasswordRotationOption = {
name: string;
type: SecretRotation.LdapPassword;
connection: AppConnection.LDAP;
template: {
secretsMapping: TLdapPasswordRotation["secretsMapping"];
};
};
+2 -1
View File
@@ -10,7 +10,8 @@ export enum SecretSync {
TerraformCloud = "terraform-cloud",
Camunda = "camunda",
Vercel = "vercel",
Windmill = "windmill"
Windmill = "windmill",
TeamCity = "teamcity"
}
export enum SecretSyncStatus {
@@ -10,6 +10,7 @@ import { TDatabricksSync } from "./databricks-sync";
import { TGcpSync } from "./gcp-sync";
import { TGitHubSync } from "./github-sync";
import { THumanitecSync } from "./humanitec-sync";
import { TTeamCitySync } from "./teamcity-sync";
import { TTerraformCloudSync } from "./terraform-cloud-sync";
import { TVercelSync } from "./vercel-sync";
import { TWindmillSync } from "./windmill-sync";
@@ -32,7 +33,8 @@ export type TSecretSync =
| TTerraformCloudSync
| TCamundaSync
| TVercelSync
| TWindmillSync;
| TWindmillSync
| TTeamCitySync;
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
@@ -0,0 +1,16 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretSync } from "@app/hooks/api/secretSyncs";
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
export type TTeamCitySync = TRootSecretSync & {
destination: SecretSync.TeamCity;
destinationConfig: {
project: string;
buildConfig?: string;
};
connection: {
app: AppConnection.TeamCity;
name: string;
id: string;
};
};
@@ -83,6 +83,7 @@ export const useUpdateSecretV3 = ({
secretComment,
secretReminderRepeatDays,
secretReminderNote,
secretReminderRecipients,
newSecretName,
skipMultilineEncoding,
secretMetadata
@@ -93,6 +94,7 @@ export const useUpdateSecretV3 = ({
type,
secretReminderNote,
secretReminderRepeatDays,
secretReminderRecipients,
secretPath,
skipMultilineEncoding,
newSecretName,
@@ -80,6 +80,7 @@ export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => {
comment: el.secretComment || "",
reminderRepeatDays: el.secretReminderRepeatDays,
reminderNote: el.secretReminderNote,
secretReminderRecipients: el.secretReminderRecipients,
createdAt: el.createdAt,
updatedAt: el.updatedAt,
version: el.version,
+12
View File
@@ -7,6 +7,14 @@ export enum SecretType {
Personal = "personal"
}
export type SecretReminderRecipient = {
user: {
id: string;
username: string;
email: string;
};
id: string;
};
export type EncryptedSecret = {
id: string;
version: number;
@@ -42,6 +50,7 @@ export type SecretV3RawSanitized = {
comment?: string;
reminderRepeatDays?: number | null;
reminderNote?: string | null;
reminderRecipients?: string[];
tags?: WsTag[];
createdAt: string;
updatedAt: string;
@@ -55,6 +64,7 @@ export type SecretV3RawSanitized = {
secretMetadata?: { key: string; value: string }[];
isReminderEvent?: boolean;
isRotatedSecret?: boolean;
secretReminderRecipients?: SecretReminderRecipient[];
rotationId?: string;
};
@@ -80,6 +90,7 @@ export type SecretV3Raw = {
updatedAt: string;
isRotatedSecret?: boolean;
rotationId?: string;
secretReminderRecipients?: SecretReminderRecipient[];
};
export type SecretV3RawResponse = {
@@ -177,6 +188,7 @@ export type TUpdateSecretsV3DTO = {
secretReminderNote?: string | null;
tagIds?: string[];
secretMetadata?: { key: string; value: string }[];
secretReminderRecipients?: string[] | null;
};
export type TDeleteSecretsV3DTO = {
+3
View File
@@ -2,6 +2,7 @@ export type TSshHost = {
id: string;
projectId: string;
hostname: string;
alias: string | null;
userCertTtl: string;
hostCertTtl: string;
loginMappings: {
@@ -15,6 +16,7 @@ export type TSshHost = {
export type TCreateSshHostDTO = {
projectId: string;
hostname: string;
alias?: string;
userCertTtl?: string;
hostCertTtl?: string;
loginMappings: {
@@ -28,6 +30,7 @@ export type TCreateSshHostDTO = {
export type TUpdateSshHostDTO = {
sshHostId: string;
hostname?: string;
alias?: string;
userCertTtl?: string;
hostCertTtl?: string;
loginMappings?: {
@@ -12,6 +12,7 @@ export type SubscriptionPlan = {
customAlerts: boolean;
customRateLimits: boolean;
pitRecovery: boolean;
githubOrgSync: boolean;
ipAllowlisting: boolean;
rbac: boolean;
secretVersioning: boolean;
+1
View File
@@ -1,6 +1,7 @@
export {
useAddUserToWsE2EE,
useAddUserToWsNonE2EE,
useRevokeMySessionById,
useSendEmailVerificationCode,
useVerifyEmailVerificationCode
} from "./mutation";
+13
View File
@@ -171,3 +171,16 @@ export const useResendOrgMemberInvitation = () => {
}
});
};
export const useRevokeMySessionById = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (sessionId: string) => {
const { data } = await apiRequest.delete(`/api/v2/users/me/sessions/${sessionId}`);
return data;
},
onSuccess() {
queryClient.invalidateQueries({ queryKey: userKeys.mySessions });
}
});
};
+3 -1
View File
@@ -4,7 +4,8 @@ export {
useLeaveProject,
useMigrateProjectToV3,
useRequestProjectAccess,
useUpdateGroupWorkspaceRole
useUpdateGroupWorkspaceRole,
useUpdateProjectSshConfig
} from "./mutations";
export {
useAddIdentityToWorkspace,
@@ -14,6 +15,7 @@ export {
useDeleteUserFromWorkspace,
useDeleteWorkspace,
useDeleteWsEnvironment,
useGetProjectSshConfig,
useGetUpgradeProjectStatus,
useGetUserWorkspaceMemberships,
useGetUserWorkspaces,
+22 -1
View File
@@ -4,7 +4,11 @@ import { apiRequest } from "@app/config/request";
import { userKeys } from "../users/query-keys";
import { workspaceKeys } from "./query-keys";
import { TUpdateWorkspaceGroupRoleDTO } from "./types";
import {
TProjectSshConfig,
TUpdateProjectSshConfigDTO,
TUpdateWorkspaceGroupRoleDTO
} from "./types";
export const useAddGroupToWorkspace = () => {
const queryClient = useQueryClient();
@@ -117,3 +121,20 @@ export const useRequestProjectAccess = () => {
}
});
};
export const useUpdateProjectSshConfig = () => {
const queryClient = useQueryClient();
return useMutation<TProjectSshConfig, object, TUpdateProjectSshConfigDTO>({
mutationFn: ({ projectId, defaultUserSshCaId, defaultHostSshCaId }) => {
return apiRequest.patch(`/api/v1/workspace/${projectId}/ssh-config`, {
defaultUserSshCaId,
defaultHostSshCaId
});
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getProjectSshConfig(projectId)
});
}
});
};
+26 -3
View File
@@ -34,6 +34,7 @@ import {
TListProjectIdentitiesDTO,
ToggleAutoCapitalizationDTO,
ToggleDeleteProjectProtectionDTO,
TProjectSshConfig,
TSearchProjectsDTO,
TUpdateWorkspaceIdentityRoleDTO,
TUpdateWorkspaceUserRoleDTO,
@@ -430,9 +431,13 @@ export const useDeleteWsEnvironment = () => {
});
};
export const useGetWorkspaceUsers = (workspaceId: string, includeGroupMembers?: boolean) => {
export const useGetWorkspaceUsers = (
workspaceId: string,
includeGroupMembers?: boolean,
roles?: string[]
) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceUsers(workspaceId),
queryKey: workspaceKeys.getWorkspaceUsers(workspaceId, includeGroupMembers, roles),
queryFn: async () => {
const {
data: { users }
@@ -440,7 +445,11 @@ export const useGetWorkspaceUsers = (workspaceId: string, includeGroupMembers?:
`/api/v1/workspace/${workspaceId}/users`,
{
params: {
includeGroupMembers
includeGroupMembers,
roles:
roles && roles.length > 0
? roles.map((role) => encodeURIComponent(role)).join(",")
: undefined
}
}
);
@@ -887,3 +896,17 @@ export const useGetWorkspaceSlackConfig = ({ workspaceId }: { workspaceId: strin
enabled: Boolean(workspaceId)
});
};
export const useGetProjectSshConfig = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getProjectSshConfig(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<TProjectSshConfig>(
`/api/v1/workspace/${projectId}/ssh-config`
);
return data;
},
enabled: Boolean(projectId)
});
};
@@ -15,7 +15,8 @@ export const workspaceKeys = {
type ? ["workspaces", { type }] : (["workspaces"] as const),
getWorkspaceAuditLogs: (workspaceId: string) =>
[{ workspaceId }, "workspace-audit-logs"] as const,
getWorkspaceUsers: (workspaceId: string) => [{ workspaceId }, "workspace-users"] as const,
getWorkspaceUsers: (workspaceId: string, includeGroupMembers?: boolean, roles?: string[]) =>
[{ workspaceId, includeGroupMembers, roles }, "workspace-users"] as const,
getWorkspaceUserDetails: (workspaceId: string, membershipId: string) =>
[{ workspaceId, membershipId }, "workspace-user-details"] as const,
getWorkspaceIdentityMemberships: (workspaceId: string) =>
@@ -69,5 +70,6 @@ export const workspaceKeys = {
projectId: string;
}) => [...workspaceKeys.allWorkspaceSshCertificates(projectId), { offset, limit }] as const,
getWorkspaceSshCertificateTemplates: (projectId: string) =>
[{ projectId }, "workspace-ssh-certificate-templates"] as const
[{ projectId }, "workspace-ssh-certificate-templates"] as const,
getProjectSshConfig: (projectId: string) => [{ projectId }, "project-ssh-config"] as const
};
+15
View File
@@ -184,3 +184,18 @@ export type TSearchProjectsDTO = {
orderBy?: ProjectIdentityOrderBy;
orderDirection?: OrderByDirection;
};
export type TProjectSshConfig = {
id: string;
createdAt: string;
updatedAt: string;
projectId: string;
defaultUserSshCaId: string | null;
defaultHostSshCaId: string | null;
};
export type TUpdateProjectSshConfigDTO = {
projectId: string;
defaultUserSshCaId?: string;
defaultHostSshCaId?: string;
};