Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.1 KB
Raw Blame
import type { MarketPlaceInputs, PluginsSearchParams } from '@dify/contracts/marketplace'
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
import { marketplaceQuery } from '@/service/marketplace'
import { getMarketplacePluginsInfiniteQueryOptions } from './query-options'
import { getMarketplaceCollectionsAndPlugins } from './utils'

export function useMarketplaceCollectionsAndPlugins(
  collectionsParams: MarketPlaceInputs['collections']['query'],
  enabled = true,
) {
  return useQuery({
    queryKey: marketplaceQuery.collections.queryKey({ input: { query: collectionsParams } }),
    queryFn: ({ signal }) => getMarketplaceCollectionsAndPlugins(collectionsParams, { signal }),
    enabled,
    // Matches the plugins query: the shared client default of 3 retries holds
    // isFetching true for ~7s of backoff, which the catalog renders as a
    // spinner indistinguishable from a hang.
    retry: false,
  })
}

export function useMarketplacePlugins(queryParams: PluginsSearchParams | undefined) {
  return useInfiniteQuery(getMarketplacePluginsInfiniteQueryOptions(queryParams))
}