feat: introduce trigger functionality (#27644)

Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: Stream <Stream_2@qq.com>
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: zhsama <torvalds@linux.do>
Co-authored-by: Harry <xh001x@hotmail.com>
Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: yessenia <yessenia.contact@gmail.com>
Co-authored-by: hjlarry <hjlarry@163.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: WTW0313 <twwu@dify.ai>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Yeuoly
2025-11-12 17:59:37 +08:00
committed by GitHub
parent ca7794305b
commit b76e17b25d
785 changed files with 41186 additions and 3725 deletions

View File

@@ -84,8 +84,9 @@ const useInvalidToolsKeyMap: Record<string, QueryKey> = {
[CollectionType.workflow]: useAllWorkflowToolsKey,
[CollectionType.mcp]: useAllMCPToolsKey,
}
export const useInvalidToolsByType = (type: CollectionType | string) => {
return useInvalid(useInvalidToolsKeyMap[type])
export const useInvalidToolsByType = (type?: CollectionType | string) => {
const queryKey = type ? useInvalidToolsKeyMap[type] : undefined
return useInvalid(queryKey)
}
export const useCreateMCP = () => {
@@ -339,3 +340,53 @@ export const useRAGRecommendedPlugins = () => {
export const useInvalidateRAGRecommendedPlugins = () => {
return useInvalid(useRAGRecommendedPluginListKey)
}
// App Triggers API hooks
export type AppTrigger = {
id: string
trigger_type: 'trigger-webhook' | 'trigger-schedule' | 'trigger-plugin'
title: string
node_id: string
provider_name: string
icon: string
status: 'enabled' | 'disabled' | 'unauthorized'
created_at: string
updated_at: string
}
export const useAppTriggers = (appId: string | undefined, options?: any) => {
return useQuery<{ data: AppTrigger[] }>({
queryKey: [NAME_SPACE, 'app-triggers', appId],
queryFn: () => get<{ data: AppTrigger[] }>(`/apps/${appId}/triggers`),
enabled: !!appId,
...options, // Merge additional options while maintaining backward compatibility
})
}
export const useInvalidateAppTriggers = () => {
const queryClient = useQueryClient()
return (appId: string) => {
queryClient.invalidateQueries({
queryKey: [NAME_SPACE, 'app-triggers', appId],
})
}
}
export const useUpdateTriggerStatus = () => {
return useMutation({
mutationKey: [NAME_SPACE, 'update-trigger-status'],
mutationFn: (payload: {
appId: string
triggerId: string
enableTrigger: boolean
}) => {
const { appId, triggerId, enableTrigger } = payload
return post<AppTrigger>(`/apps/${appId}/trigger-enable`, {
body: {
trigger_id: triggerId,
enable_trigger: enableTrigger,
},
})
},
})
}