mirror of
https://github.com/langgenius/dify.git
synced 2026-11-11 22:02:23 +08:00
Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: zhaohao1004 <zhaohao1004@gmail.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: FFXN <lizy@dify.ai>
25 lines
910 B
TypeScript
25 lines
910 B
TypeScript
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())
|