create.config.ts 5.26 KB
import { ProtocolEnum, ProtocolNameEnum, RequestMethodEnum } from '../../../enum/form';
import { RestApiCallFieldsEnum, RestApiCallFieldsNameEnum } from '../../../enum/formField/external';
import { FormSchema } from '/@/components/Form';

export const formSchemas: FormSchema[] = [
  {
    field: RestApiCallFieldsEnum.REST_ENDPOINT_URL_PATTERN,
    label: RestApiCallFieldsNameEnum.REST_ENDPOINT_URL_PATTERN,
    component: 'Input',
    required: true,
    helpMessage:
      'Hint: use ${metadataKey} for value from metadata, $[messageKey] for value from message body',
    componentProps: {
      placeholder: `请输入${RestApiCallFieldsNameEnum.REST_ENDPOINT_URL_PATTERN}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.REQUEST_METHOD,
    label: RestApiCallFieldsNameEnum.REQUEST_METHOD,
    component: 'Select',
    required: true,
    componentProps: {
      options: Object.keys(RequestMethodEnum).map((value) => ({ label: value, value })),
      getPopupContainer: () => document.body,
      placeholder: `请选择${RestApiCallFieldsNameEnum.REQUEST_METHOD}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.ENABLE_PROXY,
    label: '',
    component: 'Checkbox',
    renderComponentContent: () => ({
      default: () => RestApiCallFieldsNameEnum.ENABLE_PROXY,
    }),
  },
  {
    field: RestApiCallFieldsEnum.USE_SIMPLE_CLIENT_HTTP_FACTORY,
    label: '',
    component: 'Checkbox',
    show: ({ model }) => !model[RestApiCallFieldsEnum.ENABLE_PROXY],
    renderComponentContent: () => ({
      default: () => RestApiCallFieldsNameEnum.USE_SIMPLE_CLIENT_HTTP_FACTORY,
    }),
  },
  {
    field: RestApiCallFieldsEnum.IGNORE_REQUEST_BODY,
    label: '',
    component: 'Checkbox',
    renderComponentContent: () => ({
      default: () => RestApiCallFieldsNameEnum.IGNORE_REQUEST_BODY,
    }),
  },
  {
    field: RestApiCallFieldsEnum.USE_SYSTEM_PROXY_PROPERTIES,
    label: '',
    component: 'Checkbox',
    show: ({ model }) => model[RestApiCallFieldsEnum.ENABLE_PROXY],
    renderComponentContent: () => ({
      default: () => RestApiCallFieldsNameEnum.USE_SYSTEM_PROXY_PROPERTIES,
    }),
  },
  {
    field: RestApiCallFieldsEnum.PROXY_SCHEME,
    label: RestApiCallFieldsNameEnum.PROXY_SCHEME,
    component: 'Select',
    required: true,
    colProps: { span: 8 },
    componentProps: {
      options: Object.keys(ProtocolEnum).map((value) => ({
        label: ProtocolNameEnum[value],
        value,
      })),
      getPopupContainer: () => document.body,
      placeholder: `请选择${RestApiCallFieldsEnum.PROXY_SCHEME}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.PROXY_HOST,
    label: RestApiCallFieldsNameEnum.PROXY_HOST,
    component: 'Input',
    required: true,
    colProps: { span: 8 },
    componentProps: {
      placeholder: `请输入${RestApiCallFieldsNameEnum.PROXY_HOST}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.PROXY_PORT,
    label: RestApiCallFieldsNameEnum.PROXY_PORT,
    component: 'InputNumber',
    required: true,
    colProps: { span: 8 },
    componentProps: {
      placeholder: `请输入${RestApiCallFieldsNameEnum.PROXY_HOST}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.PROXY_USER,
    label: RestApiCallFieldsNameEnum.PROXY_USER,
    component: 'Input',
    componentProps: {
      placeholder: `请输入${RestApiCallFieldsNameEnum.PROXY_USER}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.PROXY_PASSWORD,
    label: RestApiCallFieldsNameEnum.PROXY_PASSWORD,
    component: 'Input',
    componentProps: {
      placeholder: `请输入${RestApiCallFieldsNameEnum.PROXY_PASSWORD}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.READ_TIMEOUT_MS,
    label: RestApiCallFieldsNameEnum.READ_TIMEOUT_MS,
    component: 'InputNumber',
    componentProps: {
      min: 0,
      placeholder: `请输入${RestApiCallFieldsNameEnum.READ_TIMEOUT_MS}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.MAX_PARALLEL_REQUESTS_COUNT,
    label: RestApiCallFieldsNameEnum.MAX_PARALLEL_REQUESTS_COUNT,
    component: 'InputNumber',
    componentProps: {
      min: 0,
      placeholder: `请输入${RestApiCallFieldsNameEnum.MAX_PARALLEL_REQUESTS_COUNT}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.HEADERS,
    label: RestApiCallFieldsNameEnum.HEADERS,
    component: 'Input',
    slot: RestApiCallFieldsEnum.HEADERS,
  },
  {
    field: RestApiCallFieldsEnum.USE_REDIS_QUEUE_FOR_MSG_PERSISTENCE,
    label: '',
    component: 'Checkbox',
    renderComponentContent: () => ({
      default: () => RestApiCallFieldsNameEnum.USE_REDIS_QUEUE_FOR_MSG_PERSISTENCE,
    }),
  },
  {
    field: RestApiCallFieldsEnum.TRIM_QUEUE,
    label: '',
    component: 'Checkbox',
    ifShow: ({ model }) => model[RestApiCallFieldsEnum.USE_REDIS_QUEUE_FOR_MSG_PERSISTENCE],
    renderComponentContent: () => ({
      default: () => RestApiCallFieldsNameEnum.TRIM_QUEUE,
    }),
  },
  {
    field: RestApiCallFieldsEnum.MAX_QUEUE_SIZE,
    label: RestApiCallFieldsNameEnum.MAX_QUEUE_SIZE,
    component: 'InputNumber',
    ifShow: ({ model }) => model[RestApiCallFieldsEnum.USE_REDIS_QUEUE_FOR_MSG_PERSISTENCE],
    componentProps: {
      min: 0,
      placeholder: `请输入${RestApiCallFieldsNameEnum.MAX_QUEUE_SIZE}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.CREDENTIALS,
    label: RestApiCallFieldsNameEnum.CREDENTIALS,
    component: 'Input',
    slot: RestApiCallFieldsEnum.CREDENTIALS,
  },
];