dify/web/features/deployments/create-release/ui/source-app-picker-value.ts
Stephen Zhou 48452aefbc
feat: app deploy (#35670)
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>
2026-06-17 09:28:43 +00:00

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,
}
}