create.config.ts
6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import { ProtocolEnum, ProtocolNameEnum, RequestMethodEnum } from '../../../enum/form';
import { RestApiCallFieldsEnum, RestApiCallFieldsNameEnum } from '../../../enum/formField/external';
import { FormSchema } from '/@/components/Form';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
export const formSchemas: FormSchema[] = [
  {
    field: RestApiCallFieldsEnum.REST_ENDPOINT_URL_PATTERN,
    label: t(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: `请输入${t(RestApiCallFieldsNameEnum.REST_ENDPOINT_URL_PATTERN)}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.REQUEST_METHOD,
    label: t(RestApiCallFieldsNameEnum.REQUEST_METHOD),
    component: 'Select',
    required: true,
    componentProps: {
      options: Object.keys(RequestMethodEnum).map((value) => ({ label: value, value })),
      getPopupContainer: () => document.body,
      placeholder: `请选择${t(RestApiCallFieldsNameEnum.REQUEST_METHOD)}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.ENABLE_PROXY,
    label: '',
    component: 'Checkbox',
    renderComponentContent: () => ({
      default: () => t(RestApiCallFieldsNameEnum.ENABLE_PROXY),
    }),
  },
  {
    field: RestApiCallFieldsEnum.USE_SIMPLE_CLIENT_HTTP_FACTORY,
    label: '',
    component: 'Checkbox',
    show: ({ model }) => !model[RestApiCallFieldsEnum.ENABLE_PROXY],
    renderComponentContent: () => ({
      default: () => t(RestApiCallFieldsNameEnum.USE_SIMPLE_CLIENT_HTTP_FACTORY),
    }),
  },
  {
    field: RestApiCallFieldsEnum.IGNORE_REQUEST_BODY,
    label: '',
    component: 'Checkbox',
    renderComponentContent: () => ({
      default: () => t(RestApiCallFieldsNameEnum.IGNORE_REQUEST_BODY),
    }),
  },
  {
    field: RestApiCallFieldsEnum.USE_SYSTEM_PROXY_PROPERTIES,
    label: '',
    component: 'Checkbox',
    show: ({ model }) => model[RestApiCallFieldsEnum.ENABLE_PROXY],
    renderComponentContent: () => ({
      default: () => t(RestApiCallFieldsNameEnum.USE_SYSTEM_PROXY_PROPERTIES),
    }),
  },
  {
    field: RestApiCallFieldsEnum.PROXY_SCHEME,
    label: t(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: `请选择${t(RestApiCallFieldsEnum.PROXY_SCHEME)}`,
    },
    ifShow: ({ model }) => {
      const ifShowField = model[RestApiCallFieldsEnum.ENABLE_PROXY];
      return ifShowField && !model[RestApiCallFieldsEnum.USE_SYSTEM_PROXY_PROPERTIES];
    },
  },
  {
    field: RestApiCallFieldsEnum.PROXY_HOST,
    label: t(RestApiCallFieldsNameEnum.PROXY_HOST),
    component: 'Input',
    required: true,
    colProps: { span: 8 },
    componentProps: {
      placeholder: `请输入${t(RestApiCallFieldsNameEnum.PROXY_HOST)}`,
    },
    ifShow: ({ model }) => {
      const ifShowField = model[RestApiCallFieldsEnum.ENABLE_PROXY];
      return ifShowField && !model[RestApiCallFieldsEnum.USE_SYSTEM_PROXY_PROPERTIES];
    },
  },
  {
    field: RestApiCallFieldsEnum.PROXY_PORT,
    label: t(RestApiCallFieldsNameEnum.PROXY_PORT),
    component: 'InputNumber',
    required: true,
    colProps: { span: 8 },
    componentProps: {
      placeholder: `请输入${t(RestApiCallFieldsNameEnum.PROXY_HOST)}`,
    },
    ifShow: ({ model }) => {
      const ifShowField = model[RestApiCallFieldsEnum.ENABLE_PROXY];
      return ifShowField && !model[RestApiCallFieldsEnum.USE_SYSTEM_PROXY_PROPERTIES];
    },
  },
  {
    field: RestApiCallFieldsEnum.PROXY_USER,
    label: t(RestApiCallFieldsNameEnum.PROXY_USER),
    component: 'Input',
    componentProps: {
      placeholder: `请输入${t(RestApiCallFieldsNameEnum.PROXY_USER)}`,
    },
    ifShow: ({ model }) => {
      const ifShowField = model[RestApiCallFieldsEnum.ENABLE_PROXY];
      return ifShowField && !model[RestApiCallFieldsEnum.USE_SYSTEM_PROXY_PROPERTIES];
    },
  },
  {
    field: RestApiCallFieldsEnum.PROXY_PASSWORD,
    label: t(RestApiCallFieldsNameEnum.PROXY_PASSWORD),
    component: 'Input',
    componentProps: {
      placeholder: `请输入${t(RestApiCallFieldsNameEnum.PROXY_PASSWORD)}`,
    },
    ifShow: ({ model }) => {
      const ifShowField = model[RestApiCallFieldsEnum.ENABLE_PROXY];
      return ifShowField && !model[RestApiCallFieldsEnum.USE_SYSTEM_PROXY_PROPERTIES];
    },
  },
  {
    field: RestApiCallFieldsEnum.READ_TIMEOUT_MS,
    label: t(RestApiCallFieldsNameEnum.READ_TIMEOUT_MS),
    component: 'InputNumber',
    ifShow: ({ model }) => !model[RestApiCallFieldsEnum.USE_SIMPLE_CLIENT_HTTP_FACTORY],
    componentProps: {
      min: 0,
      placeholder: `请输入${t(RestApiCallFieldsNameEnum.READ_TIMEOUT_MS)}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.MAX_PARALLEL_REQUESTS_COUNT,
    label: t(RestApiCallFieldsNameEnum.MAX_PARALLEL_REQUESTS_COUNT),
    component: 'InputNumber',
    componentProps: {
      min: 0,
      placeholder: `请输入${t(RestApiCallFieldsNameEnum.MAX_PARALLEL_REQUESTS_COUNT)}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.HEADERS,
    label: t(RestApiCallFieldsNameEnum.HEADERS),
    component: 'Input',
    slot: RestApiCallFieldsEnum.HEADERS,
  },
  {
    field: RestApiCallFieldsEnum.USE_REDIS_QUEUE_FOR_MSG_PERSISTENCE,
    label: '',
    component: 'Checkbox',
    renderComponentContent: () => ({
      default: () => t(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: () => t(RestApiCallFieldsNameEnum.TRIM_QUEUE),
    }),
  },
  {
    field: RestApiCallFieldsEnum.MAX_QUEUE_SIZE,
    label: t(RestApiCallFieldsNameEnum.MAX_QUEUE_SIZE),
    component: 'InputNumber',
    ifShow: ({ model }) => model[RestApiCallFieldsEnum.USE_REDIS_QUEUE_FOR_MSG_PERSISTENCE],
    componentProps: {
      min: 0,
      placeholder: `请输入${t(RestApiCallFieldsNameEnum.MAX_QUEUE_SIZE)}`,
    },
  },
  {
    field: RestApiCallFieldsEnum.CREDENTIALS,
    label: t(RestApiCallFieldsNameEnum.CREDENTIALS),
    component: 'Input',
    slot: RestApiCallFieldsEnum.CREDENTIALS,
  },
];