Files
ragflow/web/src/pages/agent/gobal-variable-sheet/constant.ts
balibabu 971197d595 Feat: Set the outputs type of list operation. #10427 (#11366)
### What problem does this PR solve?

Feat: Set the outputs type of list operation. #10427

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
2025-11-19 13:59:43 +08:00

65 lines
1.8 KiB
TypeScript

import { FormFieldConfig, FormFieldType } from '@/components/dynamic-form';
import { buildSelectOptions } from '@/utils/component-util';
import { t } from 'i18next';
import { TypesWithArray } from '../constant';
export { TypesWithArray } from '../constant';
// const TypesWithoutArray = Object.values(JsonSchemaDataType).filter(
// (item) => item !== JsonSchemaDataType.Array,
// );
// const TypesWithArray = [
// ...TypesWithoutArray,
// ...TypesWithoutArray.map((item) => `array<${item}>`),
// ];
export const GlobalFormFields = [
{
label: t('flow.name'),
name: 'name',
placeholder: t('common.namePlaceholder'),
required: true,
validation: {
pattern: /^[a-zA-Z_]+$/,
message: t('flow.variableNameMessage'),
},
type: FormFieldType.Text,
},
{
label: t('flow.type'),
name: 'type',
placeholder: '',
required: true,
type: FormFieldType.Select,
options: buildSelectOptions(Object.values(TypesWithArray)),
},
{
label: t('flow.defaultValue'),
name: 'value',
placeholder: '',
type: FormFieldType.Textarea,
},
{
label: t('flow.description'),
name: 'description',
placeholder: t('flow.variableDescription'),
type: FormFieldType.Textarea,
},
] as FormFieldConfig[];
export const GlobalVariableFormDefaultValues = {
name: '',
type: TypesWithArray.String,
value: '',
description: '',
};
export const TypeMaps = {
[TypesWithArray.String]: FormFieldType.Textarea,
[TypesWithArray.Number]: FormFieldType.Number,
[TypesWithArray.Boolean]: FormFieldType.Checkbox,
[TypesWithArray.Object]: FormFieldType.Textarea,
[TypesWithArray.ArrayString]: FormFieldType.Textarea,
[TypesWithArray.ArrayNumber]: FormFieldType.Textarea,
[TypesWithArray.ArrayBoolean]: FormFieldType.Textarea,
[TypesWithArray.ArrayObject]: FormFieldType.Textarea,
};