mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 02:16:34 +00:00
feat(native-integrations): microsoft teams
This commit is contained in:
@@ -1,13 +1,2 @@
|
||||
export {
|
||||
useDeleteSlackIntegration,
|
||||
useUpdateProjectSlackConfig,
|
||||
useUpdateSlackIntegration
|
||||
} from "./mutation";
|
||||
export {
|
||||
fetchSlackInstallUrl,
|
||||
fetchSlackReinstallUrl,
|
||||
useGetSlackIntegrationById,
|
||||
useGetSlackIntegrationChannels,
|
||||
useGetSlackIntegrations,
|
||||
useGetWorkflowIntegrations
|
||||
} from "./queries";
|
||||
export * from "./mutation";
|
||||
export * from "./queries";
|
||||
|
||||
@@ -5,8 +5,13 @@ import { apiRequest } from "@app/config/request";
|
||||
import { workspaceKeys } from "../workspace/query-keys";
|
||||
import { workflowIntegrationKeys } from "./queries";
|
||||
import {
|
||||
TCheckMicrosoftTeamsIntegrationInstallationStatusDTO,
|
||||
TCreateMicrosoftTeamsIntegrationDTO,
|
||||
TDeleteMicrosoftTeamsIntegrationIntegrationDTO,
|
||||
TDeleteProjectWorkflowIntegrationDTO,
|
||||
TDeleteSlackIntegrationDTO,
|
||||
TUpdateProjectSlackConfigDTO,
|
||||
TUpdateMicrosoftTeamsIntegrationDTO,
|
||||
TUpdateProjectWorkflowIntegrationConfigDTO,
|
||||
TUpdateSlackIntegrationDTO
|
||||
} from "./types";
|
||||
|
||||
@@ -28,6 +33,47 @@ export const useUpdateSlackIntegration = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateMicrosoftTeamsIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<object, object, TUpdateMicrosoftTeamsIntegrationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.patch(
|
||||
`/api/v1/workflow-integrations/microsoft-teams/${dto.id}`,
|
||||
dto
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId, id }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegration(id)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegrations(orgId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: workflowIntegrationKeys.getIntegrations(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
export const useCreateMicrosoftTeamsIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<object, object, TCreateMicrosoftTeamsIntegrationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/v1/workflow-integrations/microsoft-teams", dto);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegrations(orgId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: workflowIntegrationKeys.getIntegrations(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteSlackIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -44,21 +90,86 @@ export const useDeleteSlackIntegration = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateProjectSlackConfig = () => {
|
||||
export const useDeleteMicrosoftTeamsIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<object, object, TDeleteMicrosoftTeamsIntegrationIntegrationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete(
|
||||
`/api/v1/workflow-integrations/microsoft-teams/${dto.id}`
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId, id }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegration(id)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegrations(orgId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: workflowIntegrationKeys.getIntegrations(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateProjectWorkflowIntegrationConfig = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (dto: TUpdateProjectSlackConfigDTO) => {
|
||||
mutationFn: async (dto: TUpdateProjectWorkflowIntegrationConfigDTO) => {
|
||||
const { data } = await apiRequest.put(
|
||||
`/api/v1/workspace/${dto.workspaceId}/slack-config`,
|
||||
`/api/v1/workspace/${dto.workspaceId}/workflow-integration/${dto.integration}`,
|
||||
dto
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
onSuccess: (_, { workspaceId, integration }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceSlackConfig(workspaceId)
|
||||
queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteProjectWorkflowIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (dto: TDeleteProjectWorkflowIntegrationDTO) => {
|
||||
const { data } = await apiRequest.delete(
|
||||
`/api/v1/workspace/${dto.projectId}/workflow-integrations/${dto.integration}/${dto.integrationId}`
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId, integration }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useCheckMicrosoftTeamsIntegrationInstallationStatus = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (dto: TCheckMicrosoftTeamsIntegrationInstallationStatusDTO) => {
|
||||
const { data } = await apiRequest.post(
|
||||
`/api/v1/workflow-integrations/microsoft-teams/${dto.workflowIntegrationId}/installation-status`
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workflowIntegrationId, orgId }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegration(workflowIntegrationId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegrations(orgId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: workflowIntegrationKeys.getIntegrations(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,12 +2,27 @@ import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { SlackIntegration, SlackIntegrationChannel, WorkflowIntegration } from "./types";
|
||||
import {
|
||||
MicrosoftTeamsIntegration,
|
||||
MicrosoftTeamsIntegrationTeam,
|
||||
SlackIntegration,
|
||||
SlackIntegrationChannel,
|
||||
WorkflowIntegration
|
||||
} from "./types";
|
||||
|
||||
export const workflowIntegrationKeys = {
|
||||
getIntegrations: (orgId?: string) => [{ orgId }, "workflow-integrations"],
|
||||
getSlackIntegrations: (orgId?: string) => [{ orgId }, "slack-workflow-integrations"],
|
||||
getSlackIntegration: (id?: string) => [{ id }, "slack-workflow-integration"],
|
||||
getMicrosoftTeamsIntegrations: (orgId?: string) => [
|
||||
{ orgId },
|
||||
"microsoft-teams-workflow-integrations"
|
||||
],
|
||||
getMicrosoftTeamsIntegration: (id?: string) => [{ id }, "microsoft-teams-workflow-integration"],
|
||||
getMicrosoftTeamsIntegrationTeams: (id?: string) => [
|
||||
{ id },
|
||||
"microsoft-teams-workflow-integration-teams"
|
||||
],
|
||||
getSlackIntegrationChannels: (id?: string) => [{ id }, "slack-workflow-integration-channels"]
|
||||
};
|
||||
|
||||
@@ -66,13 +81,50 @@ export const fetchWorkflowIntegrations = async () => {
|
||||
return data;
|
||||
};
|
||||
|
||||
export const useGetSlackIntegrations = (orgId?: string) =>
|
||||
export const fetchMicrosoftTeamsIntegrations = async () => {
|
||||
const { data } = await apiRequest.get<MicrosoftTeamsIntegration[]>(
|
||||
"/api/v1/workflow-integrations/microsoft-teams"
|
||||
);
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export const fetchMicrosoftTeamsIntegrationById = async (id?: string) => {
|
||||
const { data } = await apiRequest.get<MicrosoftTeamsIntegration>(
|
||||
`/api/v1/workflow-integrations/microsoft-teams/${id}`
|
||||
);
|
||||
|
||||
return data;
|
||||
};
|
||||
export const fetchMicrosoftTeamsIntegrationTeams = async (id?: string) => {
|
||||
const { data } = await apiRequest.get<MicrosoftTeamsIntegrationTeam[]>(
|
||||
`/api/v1/workflow-integrations/microsoft-teams/${id}/teams`
|
||||
);
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export const useGetMicrosoftTeamsIntegrations = (orgId?: string) =>
|
||||
useQuery({
|
||||
queryKey: workflowIntegrationKeys.getSlackIntegrations(orgId),
|
||||
queryFn: () => fetchSlackIntegrations(),
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegrations(orgId),
|
||||
queryFn: () => fetchMicrosoftTeamsIntegrations(),
|
||||
enabled: Boolean(orgId)
|
||||
});
|
||||
|
||||
export const useGetMicrosoftTeamsIntegrationById = (id?: string) =>
|
||||
useQuery({
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegration(id),
|
||||
queryFn: () => fetchMicrosoftTeamsIntegrationById(id),
|
||||
enabled: Boolean(id)
|
||||
});
|
||||
|
||||
export const useGetMicrosoftTeamsIntegrationTeams = (id?: string) =>
|
||||
useQuery({
|
||||
queryKey: workflowIntegrationKeys.getMicrosoftTeamsIntegrationTeams(id),
|
||||
queryFn: () => fetchMicrosoftTeamsIntegrationTeams(id),
|
||||
enabled: Boolean(id)
|
||||
});
|
||||
|
||||
export const useGetSlackIntegrationById = (id?: string) =>
|
||||
useQuery({
|
||||
queryKey: workflowIntegrationKeys.getSlackIntegration(id),
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
export enum WorkflowIntegrationPlatform {
|
||||
SLACK = "slack"
|
||||
SLACK = "slack",
|
||||
MICROSOFT_TEAMS = "microsoft-teams"
|
||||
}
|
||||
|
||||
export type WorkflowIntegration = {
|
||||
id: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
status: WorkflowIntegrationStatus;
|
||||
integration: WorkflowIntegrationPlatform;
|
||||
};
|
||||
|
||||
export type MicrosoftTeamsIntegrationTeam = {
|
||||
teamId: string;
|
||||
teamName: string;
|
||||
channels: {
|
||||
channelId: string;
|
||||
channelName: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type SlackIntegration = {
|
||||
id: string;
|
||||
slug: string;
|
||||
@@ -16,6 +27,18 @@ export type SlackIntegration = {
|
||||
teamName: string;
|
||||
};
|
||||
|
||||
export enum WorkflowIntegrationStatus {
|
||||
Pending = "pending",
|
||||
Installed = "installed"
|
||||
}
|
||||
|
||||
export type MicrosoftTeamsIntegration = {
|
||||
id: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
tenantId: string;
|
||||
};
|
||||
|
||||
export type SlackIntegrationChannel = {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -28,25 +51,88 @@ export type TUpdateSlackIntegrationDTO = {
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export type TUpdateMicrosoftTeamsIntegrationDTO = {
|
||||
id: string;
|
||||
orgId: string;
|
||||
slug?: string;
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export type TCreateMicrosoftTeamsIntegrationDTO = {
|
||||
orgId: string;
|
||||
tenantId: string;
|
||||
slug: string;
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export type TDeleteSlackIntegrationDTO = {
|
||||
id: string;
|
||||
orgId: string;
|
||||
};
|
||||
|
||||
export type ProjectSlackConfig = {
|
||||
export type TDeleteMicrosoftTeamsIntegrationIntegrationDTO = {
|
||||
id: string;
|
||||
slackIntegrationId: string;
|
||||
isAccessRequestNotificationEnabled: boolean;
|
||||
accessRequestChannels: string;
|
||||
isSecretRequestNotificationEnabled: boolean;
|
||||
secretRequestChannels: string;
|
||||
orgId: string;
|
||||
};
|
||||
|
||||
export type TUpdateProjectSlackConfigDTO = {
|
||||
workspaceId: string;
|
||||
slackIntegrationId: string;
|
||||
isAccessRequestNotificationEnabled: boolean;
|
||||
accessRequestChannels: string;
|
||||
isSecretRequestNotificationEnabled: boolean;
|
||||
secretRequestChannels: string;
|
||||
export type ProjectWorkflowIntegrationConfig =
|
||||
| {
|
||||
id: string;
|
||||
integration: WorkflowIntegrationPlatform.SLACK;
|
||||
integrationId: string;
|
||||
isAccessRequestNotificationEnabled: boolean;
|
||||
accessRequestChannels: string;
|
||||
isSecretRequestNotificationEnabled: boolean;
|
||||
secretRequestChannels: string;
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
integration: WorkflowIntegrationPlatform.MICROSOFT_TEAMS;
|
||||
integrationId: string;
|
||||
isAccessRequestNotificationEnabled: boolean;
|
||||
isSecretRequestNotificationEnabled: boolean;
|
||||
accessRequestChannels: {
|
||||
teamId: string;
|
||||
channelIds: string[];
|
||||
};
|
||||
secretRequestChannels: {
|
||||
teamId: string;
|
||||
channelIds: string[];
|
||||
};
|
||||
};
|
||||
|
||||
export type TUpdateProjectWorkflowIntegrationConfigDTO =
|
||||
| {
|
||||
integration: WorkflowIntegrationPlatform.SLACK;
|
||||
workspaceId: string;
|
||||
integrationId: string;
|
||||
isAccessRequestNotificationEnabled: boolean;
|
||||
accessRequestChannels: string;
|
||||
isSecretRequestNotificationEnabled: boolean;
|
||||
secretRequestChannels: string;
|
||||
}
|
||||
| {
|
||||
integration: WorkflowIntegrationPlatform.MICROSOFT_TEAMS;
|
||||
workspaceId: string;
|
||||
integrationId: string;
|
||||
isAccessRequestNotificationEnabled: boolean;
|
||||
isSecretRequestNotificationEnabled: boolean;
|
||||
accessRequestChannels?: {
|
||||
teamId: string;
|
||||
channelIds: string[];
|
||||
};
|
||||
secretRequestChannels?: {
|
||||
teamId: string;
|
||||
channelIds: string[];
|
||||
};
|
||||
};
|
||||
export type TDeleteProjectWorkflowIntegrationDTO = {
|
||||
projectId: string;
|
||||
integration: WorkflowIntegrationPlatform;
|
||||
integrationId: string;
|
||||
};
|
||||
|
||||
export type TCheckMicrosoftTeamsIntegrationInstallationStatusDTO = {
|
||||
workflowIntegrationId: string;
|
||||
orgId: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user