dify/cli/src/commands/describe/app/run.ts
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

41 lines
1.5 KiB
TypeScript

import type { ActiveContext } from '@/auth/hosts'
import type { AppInfoCache } from '@/cache/app-info'
import type { HttpClient } from '@/http/types'
import type { IOStreams } from '@/sys/io/streams'
import { AppMetaClient } from '@/api/app-meta'
import { selectAppReader } from '@/api/app-reader'
import { runWithSpinner } from '@/sys/io/spinner'
import { nullStreams } from '@/sys/io/streams'
import { FieldInfo, FieldInputSchema, FieldParameters } from '@/types/app-meta'
import { AppDescribeOutput } from './handlers.js'
export type DescribeAppOptions = {
readonly appId: string
readonly workspace?: string
readonly format?: string
readonly refresh?: boolean
}
export type DescribeAppDeps = {
readonly active: ActiveContext
readonly http: HttpClient
readonly host: string
readonly io?: IOStreams
readonly cache?: AppInfoCache
readonly envLookup?: (k: string) => string | undefined
}
export async function runDescribeApp(
opts: DescribeAppOptions,
deps: DescribeAppDeps,
): Promise<AppDescribeOutput> {
const apps = selectAppReader(deps.active, deps.http)
const meta = new AppMetaClient({ apps, host: deps.host, cache: deps.cache })
const io = deps.io ?? nullStreams()
const result = await runWithSpinner({ io, label: 'Fetching app details' }, async () => {
if (opts.refresh === true) await meta.invalidate(opts.appId)
return meta.get(opts.appId, [FieldInfo, FieldParameters, FieldInputSchema])
})
return new AppDescribeOutput(result)
}