mirror of
https://github.com/langgenius/dify.git
synced 2026-06-23 12:31:13 +08:00
Co-authored-by: zhangx1n <zhangxin@dify.ai> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
24 lines
807 B
TypeScript
24 lines
807 B
TypeScript
import type { App } from '@/types/app'
|
|
import { isWorkflowAppMode } from './source-app-mode'
|
|
|
|
export type SourceAppPickerValue = Pick<App, 'id' | 'name'> & Partial<Pick<App, 'icon_type' | 'icon' | 'icon_background' | 'icon_url' | 'mode'>>
|
|
|
|
export function workflowSourceAppPickerValue(value: unknown, fallbackId: string): SourceAppPickerValue | undefined {
|
|
if (!value || typeof value !== 'object')
|
|
return undefined
|
|
|
|
const record = value as Record<string, unknown>
|
|
const mode = typeof record.mode === 'string' ? record.mode : undefined
|
|
if (!isWorkflowAppMode(mode))
|
|
return undefined
|
|
|
|
const id = typeof record.id === 'string' && record.id ? record.id : fallbackId
|
|
const name = typeof record.name === 'string' && record.name ? record.name : id
|
|
|
|
return {
|
|
id,
|
|
name,
|
|
mode,
|
|
}
|
|
}
|