dify/web/features/deployments/components/env-var-bindings-utils.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

30 lines
831 B
TypeScript

import type { EnvVarSlot } from '@dify/contracts/enterprise/types.gen'
import type { EnvVarBindingSlot } from './env-var-bindings'
export function envVarBindingValueType(valueType?: EnvVarSlot['valueType'] | string): EnvVarBindingSlot['valueType'] {
switch (valueType) {
case 'ENV_VAR_VALUE_TYPE_NUMBER':
case 'number':
return 'number'
case 'ENV_VAR_VALUE_TYPE_SECRET':
case 'secret':
return 'secret'
default:
return 'string'
}
}
export function envVarBindingSlotFromContract(slot: EnvVarSlot): EnvVarBindingSlot | undefined {
const key = slot.key.trim()
if (!key)
return undefined
return {
...slot,
key,
valueType: envVarBindingValueType(slot.valueType),
hasDefaultValue: slot.defaultValue !== undefined,
hasLastValue: slot.lastValue !== undefined,
}
}