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.

910 B
Raw Blame
import { dehydrate } from '@tanstack/react-query'
import { cache } from 'react'
import { getQueryClient } from '@/app/get-query-client'
import { connection } from '@/next/server'
import { consoleQuery } from '@/service/console'
import 'server-only'

const getRequestQueryClient = cache(getQueryClient)

const systemFeaturesServerQueryOptions = () =>
  consoleQuery.systemFeatures.get.queryOptions({ staleTime: 'static' })

export const getOptionalSystemFeatures = async () => {
  await connection()
  const queryClient = getRequestQueryClient()
  const queryOptions = systemFeaturesServerQueryOptions()
  const queryState = queryClient.getQueryState(queryOptions.queryKey)

  if (queryState?.status === 'error' && queryState.data === undefined) return undefined

  return queryClient.query(queryOptions).catch(() => undefined)
}

export const dehydrateSystemFeatures = () => dehydrate(getRequestQueryClient())