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>
30 lines
831 B
TypeScript
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,
|
|
}
|
|
}
|