plugin-document-understanding 1.1.14 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +29 -29
  2. package/client-v2.d.ts +2 -2
  3. package/client-v2.js +1 -1
  4. package/dist/client/{345.e6e484fb1974c3d3.js → 345.277fbb2b97424db5.js} +1 -1
  5. package/dist/client/index.js +1 -1
  6. package/dist/client-v2/{345.a8f28526ac21e02a.js → 345.2fa9834b46dd4531.js} +1 -1
  7. package/dist/client-v2/index.js +1 -1
  8. package/dist/externalVersion.js +8 -7
  9. package/dist/locale/en-US.json +3 -1
  10. package/dist/locale/zh-CN.json +3 -1
  11. package/dist/node_modules/form-data/lib/form_data.js +2 -2
  12. package/dist/node_modules/form-data/node_modules/es-define-property/.eslintrc +13 -0
  13. package/dist/node_modules/form-data/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  14. package/dist/node_modules/form-data/node_modules/es-define-property/.nycrc +9 -0
  15. package/dist/node_modules/form-data/node_modules/es-define-property/index.d.ts +3 -0
  16. package/dist/node_modules/form-data/node_modules/es-define-property/index.js +14 -0
  17. package/dist/node_modules/form-data/node_modules/es-define-property/package.json +81 -0
  18. package/dist/node_modules/form-data/node_modules/es-define-property/test/index.js +56 -0
  19. package/dist/node_modules/form-data/node_modules/es-object-atoms/.eslintrc +16 -0
  20. package/dist/node_modules/form-data/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
  21. package/dist/node_modules/form-data/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
  22. package/dist/node_modules/form-data/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
  23. package/dist/node_modules/form-data/node_modules/es-object-atoms/ToObject.d.ts +7 -0
  24. package/dist/node_modules/form-data/node_modules/es-object-atoms/ToObject.js +10 -0
  25. package/dist/node_modules/form-data/node_modules/es-object-atoms/index.d.ts +3 -0
  26. package/dist/node_modules/form-data/node_modules/es-object-atoms/index.js +4 -0
  27. package/dist/node_modules/form-data/node_modules/es-object-atoms/isObject.d.ts +3 -0
  28. package/dist/node_modules/form-data/node_modules/es-object-atoms/isObject.js +6 -0
  29. package/dist/node_modules/form-data/node_modules/es-object-atoms/package.json +80 -0
  30. package/dist/node_modules/form-data/node_modules/es-object-atoms/test/index.js +38 -0
  31. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/.eslintrc +13 -0
  32. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/.nycrc +9 -0
  33. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/index.d.ts +10 -0
  34. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/index.js +35 -0
  35. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/.eslintrc +5 -0
  36. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/.github/FUNDING.yml +12 -0
  37. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/.nycrc +13 -0
  38. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/index.d.ts +3 -0
  39. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/index.js +8 -0
  40. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/package.json +92 -0
  41. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/package.json +78 -0
  42. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/test/index.js +85 -0
  43. package/dist/node_modules/form-data/node_modules/get-intrinsic/.eslintrc +42 -0
  44. package/dist/node_modules/form-data/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  45. package/dist/node_modules/form-data/node_modules/get-intrinsic/.nycrc +9 -0
  46. package/dist/node_modules/form-data/node_modules/get-intrinsic/index.js +378 -0
  47. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/.eslintrc +11 -0
  48. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  49. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/.nycrc +9 -0
  50. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/index.d.ts +3 -0
  51. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/index.js +14 -0
  52. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/package.json +111 -0
  53. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/shams.d.ts +3 -0
  54. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/shams.js +45 -0
  55. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/index.js +22 -0
  56. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/shams/core-js.js +29 -0
  57. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
  58. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/tests.js +58 -0
  59. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/.eslintrc +5 -0
  60. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/.github/FUNDING.yml +12 -0
  61. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/.nycrc +13 -0
  62. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/index.d.ts +3 -0
  63. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/index.js +8 -0
  64. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/package.json +92 -0
  65. package/dist/node_modules/form-data/node_modules/get-intrinsic/package.json +97 -0
  66. package/dist/node_modules/form-data/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
  67. package/dist/node_modules/form-data/node_modules/gopd/.eslintrc +16 -0
  68. package/dist/node_modules/form-data/node_modules/gopd/.github/FUNDING.yml +12 -0
  69. package/dist/node_modules/form-data/node_modules/gopd/gOPD.d.ts +1 -0
  70. package/dist/node_modules/form-data/node_modules/gopd/gOPD.js +4 -0
  71. package/dist/node_modules/form-data/node_modules/gopd/index.d.ts +5 -0
  72. package/dist/node_modules/form-data/node_modules/gopd/index.js +15 -0
  73. package/dist/node_modules/form-data/node_modules/gopd/package.json +77 -0
  74. package/dist/node_modules/form-data/node_modules/gopd/test/index.js +36 -0
  75. package/dist/node_modules/form-data/node_modules/has-tostringtag/.eslintrc +5 -0
  76. package/dist/node_modules/form-data/node_modules/has-tostringtag/.github/FUNDING.yml +12 -0
  77. package/dist/node_modules/form-data/node_modules/has-tostringtag/.nycrc +13 -0
  78. package/dist/node_modules/form-data/node_modules/has-tostringtag/index.d.ts +3 -0
  79. package/dist/node_modules/form-data/node_modules/has-tostringtag/index.js +8 -0
  80. package/dist/node_modules/form-data/node_modules/has-tostringtag/package.json +108 -0
  81. package/dist/node_modules/form-data/node_modules/has-tostringtag/shams.d.ts +3 -0
  82. package/dist/node_modules/form-data/node_modules/has-tostringtag/shams.js +8 -0
  83. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/index.js +21 -0
  84. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/shams/core-js.js +31 -0
  85. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js +30 -0
  86. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/tests.js +15 -0
  87. package/dist/node_modules/form-data/node_modules/hasown/.github/FUNDING.yml +12 -0
  88. package/dist/node_modules/form-data/node_modules/hasown/.nycrc +13 -0
  89. package/dist/node_modules/form-data/node_modules/hasown/index.d.ts +3 -0
  90. package/dist/node_modules/form-data/node_modules/hasown/index.js +8 -0
  91. package/dist/node_modules/form-data/node_modules/hasown/package.json +91 -0
  92. package/dist/node_modules/form-data/package.json +1 -1
  93. package/dist/node_modules/mime-types/index.js +3 -3
  94. package/dist/node_modules/mime-types/package.json +1 -1
  95. package/dist/server/actions.js +45 -35
  96. package/package.json +57 -46
  97. package/src/client/index.tsx +15 -15
  98. package/src/client-v2/components/EndpointsTab.tsx +578 -578
  99. package/src/client-v2/components/JobsTab.tsx +294 -294
  100. package/src/client-v2/components/PipelinesTab.tsx +962 -962
  101. package/src/client-v2/components/PluginSettings.tsx +54 -50
  102. package/src/client-v2/components/ServiceConfigTab.tsx +139 -139
  103. package/src/client-v2/components/__tests__/PluginSettings.test.tsx +39 -0
  104. package/src/client-v2/index.tsx +1 -1
  105. package/src/client-v2/locale.ts +21 -21
  106. package/src/client-v2/models/index.ts +12 -12
  107. package/src/client-v2/plugin.tsx +31 -21
  108. package/src/client-v2/types.ts +32 -32
  109. package/src/index.ts +2 -2
  110. package/src/locale/en-US.json +3 -1
  111. package/src/locale/zh-CN.json +3 -1
  112. package/src/server/__tests__/actions.test.ts +121 -98
  113. package/src/server/__tests__/cluster-safety.test.ts +259 -259
  114. package/src/server/__tests__/document-understanding-service.test.ts +82 -82
  115. package/src/server/__tests__/dugate-integration.test.ts +221 -221
  116. package/src/server/__tests__/smoke.test.ts +78 -55
  117. package/src/server/__tests__/upload-security.test.ts +128 -0
  118. package/src/server/actions.ts +53 -51
  119. package/src/server/collections/config.ts +18 -18
  120. package/src/server/collections/endpoints.ts +33 -33
  121. package/src/server/collections/jobs.ts +42 -42
  122. package/src/server/collections/pipeline-steps.ts +27 -27
  123. package/src/server/collections/pipelines.ts +19 -19
  124. package/src/server/dugate-seed.ts +491 -491
  125. package/src/server/index.ts +1 -1
  126. package/src/server/plugin.ts +143 -143
  127. package/src/server/services/AsyncJobManager.ts +238 -238
  128. package/src/server/services/DocumentUnderstandingService.ts +332 -332
  129. package/src/server/services/ExternalApiClient.ts +178 -178
  130. package/src/server/services/PipelineExecutor.ts +593 -593
  131. package/src/server/tools/document-understanding-tool.ts +181 -181
  132. package/src/server/types.ts +90 -90
@@ -1,578 +1,578 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react';
2
- import {
3
- Table,
4
- Button,
5
- Modal,
6
- Form,
7
- Input,
8
- Select,
9
- Switch,
10
- message,
11
- InputNumber,
12
- Tabs,
13
- Space,
14
- Tag,
15
- Popconfirm,
16
- } from 'antd';
17
- import type { ColumnsType } from 'antd/es/table';
18
- import { PlusOutlined, DeleteOutlined, EditOutlined } from '@ant-design/icons';
19
- import { useFlowContext } from '@nocobase/flow-engine';
20
- import { useT } from '../locale';
21
- import { EndpointDef, unwrapData } from '../types';
22
-
23
- const { TextArea } = Input;
24
-
25
- interface HeaderRow {
26
- id: string;
27
- key: string;
28
- value: string;
29
- }
30
-
31
- const sanitizeHeaders = (headers?: Record<string, string>) =>
32
- Object.entries(headers || {}).reduce<Record<string, string>>((acc, [key, value]) => {
33
- const headerName = key.trim();
34
- if (headerName) {
35
- acc[headerName] = value;
36
- }
37
- return acc;
38
- }, {});
39
-
40
- const KeyValueEditor: React.FC<{ value?: Record<string, string>; onChange?: (v: Record<string, string>) => void }> = ({
41
- value,
42
- onChange,
43
- }) => {
44
- const t = useT();
45
- const [rows, setRows] = useState<HeaderRow[]>([]);
46
- const syncedRef = useRef<string>();
47
-
48
- // A half-typed row (blank name) has no representation in `value`, so resync only on a genuine
49
- // outside change. Comparing serialized content — not object identity — keeps such rows alive.
50
- const serialized = JSON.stringify(value ?? {});
51
-
52
- useEffect(() => {
53
- if (syncedRef.current === serialized) return;
54
- syncedRef.current = serialized;
55
- setRows(
56
- Object.entries(JSON.parse(serialized) as Record<string, string>).map(([key, rowValue], index) => ({
57
- id: `${key}_${index}`,
58
- key,
59
- value: String(rowValue ?? ''),
60
- })),
61
- );
62
- }, [serialized]);
63
-
64
- const emit = (nextRows: HeaderRow[]) => {
65
- setRows(nextRows);
66
- const nextValue = nextRows.reduce<Record<string, string>>((acc, row) => {
67
- const key = row.key.trim();
68
- if (key) {
69
- acc[key] = row.value;
70
- }
71
- return acc;
72
- }, {});
73
- syncedRef.current = JSON.stringify(nextValue);
74
- onChange?.(nextValue);
75
- };
76
-
77
- const update = (idx: number, key: string, val: string) => {
78
- const nextRows = [...rows];
79
- nextRows[idx] = { ...nextRows[idx], key, value: val };
80
- emit(nextRows);
81
- };
82
-
83
- const add = () => setRows([...rows, { id: `new_${Date.now()}_${Math.random()}`, key: '', value: '' }]);
84
-
85
- const remove = (idx: number) => {
86
- emit(rows.filter((_, rowIndex) => rowIndex !== idx));
87
- };
88
-
89
- return (
90
- <div>
91
- {rows.map((row, i) => (
92
- <Space key={row.id} style={{ display: 'flex', marginBottom: 4 }}>
93
- <Input
94
- placeholder={t('Header name')}
95
- aria-label={t('Header name')}
96
- value={row.key}
97
- onChange={(e) => update(i, e.target.value, row.value)}
98
- style={{ width: 180 }}
99
- />
100
- <Input
101
- placeholder={t('Value')}
102
- aria-label={t('Value')}
103
- value={row.value}
104
- onChange={(e) => update(i, row.key, e.target.value)}
105
- style={{ width: 220 }}
106
- />
107
- <Button
108
- size="small"
109
- danger
110
- icon={<DeleteOutlined />}
111
- onClick={() => remove(i)}
112
- aria-label={`${t('Delete')} ${row.key || t('Header name')}`}
113
- />
114
- </Space>
115
- ))}
116
- <Button size="small" type="dashed" icon={<PlusOutlined />} onClick={add}>
117
- {t('Add Header')}
118
- </Button>
119
- </div>
120
- );
121
- };
122
-
123
- const JsonEditor: React.FC<{ value?: unknown; onChange?: (v: unknown) => void; placeholder?: string }> = ({
124
- value,
125
- onChange,
126
- placeholder,
127
- }) => {
128
- const t = useT();
129
- const [text, setText] = useState('');
130
- const [error, setError] = useState('');
131
-
132
- useEffect(() => {
133
- if (!value) {
134
- setText('');
135
- return;
136
- }
137
- try {
138
- setText(typeof value === 'string' ? JSON.stringify(JSON.parse(value), null, 2) : JSON.stringify(value, null, 2));
139
- } catch {
140
- setText(typeof value === 'string' ? value : '');
141
- }
142
- }, [value]);
143
-
144
- const handleBlur = () => {
145
- if (!text.trim()) {
146
- setError('');
147
- onChange?.(null);
148
- return;
149
- }
150
- try {
151
- const parsed = JSON.parse(text);
152
- setError('');
153
- onChange?.(parsed);
154
- } catch {
155
- setError(t('Invalid JSON'));
156
- }
157
- };
158
-
159
- return (
160
- <div>
161
- <TextArea
162
- rows={6}
163
- value={text}
164
- onChange={(e) => setText(e.target.value)}
165
- onBlur={handleBlur}
166
- placeholder={placeholder || '{}'}
167
- status={error ? 'error' : undefined}
168
- style={{ fontFamily: 'monospace', fontSize: 12 }}
169
- />
170
- {error && (
171
- <div role="alert" style={{ color: '#ff4d4f', fontSize: 12 }}>
172
- {error}
173
- </div>
174
- )}
175
- </div>
176
- );
177
- };
178
-
179
- export const EndpointsTab = () => {
180
- const ctx = useFlowContext();
181
- const api = ctx.api;
182
- const t = useT();
183
- const [data, setData] = useState<EndpointDef[]>([]);
184
- const [loading, setLoading] = useState(false);
185
- const [visible, setVisible] = useState(false);
186
- const [form] = Form.useForm<Partial<EndpointDef>>();
187
- const [editingId, setEditingId] = useState<number | null>(null);
188
-
189
- const executionLabels: Record<string, string> = {
190
- sync: t('Synchronous'),
191
- polling: t('Polling'),
192
- webhook: t('Webhook'),
193
- };
194
-
195
- const fileModeLabels: Record<string, string> = {
196
- multipart: t('Multipart Upload'),
197
- base64: t('Base64 in JSON'),
198
- };
199
-
200
- const fetchEndpoints = useCallback(async () => {
201
- setLoading(true);
202
- try {
203
- const res = await api.request({ url: 'docUnderstanding:listEndpoints' });
204
- setData(unwrapData<EndpointDef[]>(res, []));
205
- } finally {
206
- setLoading(false);
207
- }
208
- }, [api]);
209
-
210
- useEffect(() => {
211
- fetchEndpoints();
212
- }, [fetchEndpoints]);
213
-
214
- const openEdit = (record: EndpointDef) => {
215
- setEditingId(record.id);
216
- form.setFieldsValue(record);
217
- setVisible(true);
218
- };
219
-
220
- const openAdd = () => {
221
- setEditingId(null);
222
- form.resetFields();
223
- setVisible(true);
224
- };
225
-
226
- const handleDelete = async (id: number) => {
227
- await api.request({
228
- url: 'docUnderstanding:deleteEndpoint',
229
- method: 'POST',
230
- params: { filterByTk: id },
231
- });
232
- message.success(t('Deleted'));
233
- fetchEndpoints();
234
- };
235
-
236
- const handleSave = async () => {
237
- try {
238
- const values = await form.validateFields();
239
- values.customHeaders = sanitizeHeaders(values.customHeaders);
240
- if (editingId) {
241
- await api.request({
242
- url: 'docUnderstanding:updateEndpoint',
243
- method: 'POST',
244
- params: { filterByTk: editingId },
245
- data: values,
246
- });
247
- } else {
248
- await api.request({
249
- url: 'docUnderstanding:createEndpoint',
250
- method: 'POST',
251
- data: values,
252
- });
253
- }
254
- message.success(t('Saved'));
255
- setVisible(false);
256
- fetchEndpoints();
257
- } catch {
258
- // Form validation errors are already surfaced inline by antd.
259
- }
260
- };
261
-
262
- const columns: ColumnsType<EndpointDef> = [
263
- { title: t('Name'), dataIndex: 'name', width: 150 },
264
- { title: t('Subpath'), dataIndex: 'subpath', width: 200 },
265
- {
266
- title: t('Method'),
267
- dataIndex: 'method',
268
- width: 80,
269
- render: (v: string) => <Tag>{v}</Tag>,
270
- },
271
- {
272
- title: t('Execution'),
273
- dataIndex: 'executionMode',
274
- width: 130,
275
- render: (v: string) => {
276
- const colors: Record<string, string> = { sync: 'green', polling: 'blue', webhook: 'purple' };
277
- return <Tag color={colors[v]}>{executionLabels[v] || v}</Tag>;
278
- },
279
- },
280
- {
281
- title: t('File'),
282
- dataIndex: 'fileInputMode',
283
- width: 130,
284
- render: (v: string) => (v === 'none' ? '-' : fileModeLabels[v] || v),
285
- },
286
- {
287
- title: t('Enabled'),
288
- dataIndex: 'enabled',
289
- width: 70,
290
- render: (v: boolean) => (v ? <Tag color="success">{t('Yes')}</Tag> : <Tag>{t('No')}</Tag>),
291
- },
292
- {
293
- title: t('Action'),
294
- width: 120,
295
- render: (_: unknown, record) => (
296
- <Space>
297
- <Button
298
- type="link"
299
- size="small"
300
- icon={<EditOutlined />}
301
- onClick={() => openEdit(record)}
302
- aria-label={`${t('Edit')} ${record.name}`}
303
- >
304
- {t('Edit')}
305
- </Button>
306
- <Popconfirm title={t('Delete this endpoint?')} okText={t('Delete')} onConfirm={() => handleDelete(record.id)}>
307
- <Button
308
- type="link"
309
- size="small"
310
- danger
311
- icon={<DeleteOutlined />}
312
- aria-label={`${t('Delete')} ${record.name}`}
313
- >
314
- {t('Delete')}
315
- </Button>
316
- </Popconfirm>
317
- </Space>
318
- ),
319
- },
320
- ];
321
-
322
- return (
323
- <div>
324
- <div style={{ marginBottom: 16 }}>
325
- <Button type="primary" icon={<PlusOutlined />} onClick={openAdd}>
326
- {t('Add Endpoint')}
327
- </Button>
328
- </div>
329
- <Table rowKey="id" columns={columns} dataSource={data} loading={loading} size="small" />
330
-
331
- <Modal
332
- title={editingId ? t('Edit Endpoint') : t('Add Endpoint')}
333
- open={visible}
334
- onOk={handleSave}
335
- onCancel={() => setVisible(false)}
336
- okText={t('Save')}
337
- cancelText={t('Cancel')}
338
- width={680}
339
- destroyOnClose
340
- >
341
- <Form form={form} layout="vertical" preserve={false}>
342
- <Tabs
343
- size="small"
344
- items={[
345
- {
346
- key: 'basic',
347
- label: t('Basic'),
348
- children: (
349
- <>
350
- <Form.Item name="name" label={t('Unique Name')} rules={[{ required: true }]}>
351
- <Input placeholder="ocr, classify, extract..." />
352
- </Form.Item>
353
- <Form.Item name="subpath" label={t('Subpath')} rules={[{ required: true }]}>
354
- <Input placeholder="/api/v1/ocr" />
355
- </Form.Item>
356
- <Form.Item name="description" label={t('Description')}>
357
- <TextArea rows={2} placeholder={t('What this endpoint does')} />
358
- </Form.Item>
359
- <Space size="large">
360
- <Form.Item name="method" label={t('HTTP Method')} initialValue="POST">
361
- <Select
362
- style={{ width: 120 }}
363
- options={[
364
- { value: 'GET', label: 'GET' },
365
- { value: 'POST', label: 'POST' },
366
- { value: 'PUT', label: 'PUT' },
367
- ]}
368
- />
369
- </Form.Item>
370
- <Form.Item name="enabled" label={t('Enabled')} valuePropName="checked" initialValue={true}>
371
- <Switch />
372
- </Form.Item>
373
- </Space>
374
- </>
375
- ),
376
- },
377
- {
378
- key: 'file',
379
- label: t('File Input'),
380
- children: (
381
- <>
382
- <Form.Item name="fileInputMode" label={t('File Input Mode')} initialValue="none">
383
- <Select
384
- style={{ width: 200 }}
385
- options={[
386
- { value: 'none', label: t('None') },
387
- { value: 'multipart', label: t('Multipart Upload') },
388
- { value: 'base64', label: t('Base64 in JSON') },
389
- ]}
390
- />
391
- </Form.Item>
392
- <Form.Item noStyle dependencies={['fileInputMode']}>
393
- {() =>
394
- form.getFieldValue('fileInputMode') !== 'none' ? (
395
- <>
396
- <Form.Item name="fileFieldName" label={t('File Field Name')} initialValue="file">
397
- <Input placeholder="file" style={{ width: 200 }} />
398
- </Form.Item>
399
- <Form.Item name="maxFiles" label={t('Max Files')} initialValue={1}>
400
- <InputNumber min={1} max={20} style={{ width: 120 }} />
401
- </Form.Item>
402
- </>
403
- ) : null
404
- }
405
- </Form.Item>
406
- </>
407
- ),
408
- },
409
- {
410
- key: 'gateway',
411
- label: t('Gateway / Discriminator'),
412
- children: (
413
- <>
414
- <Form.Item
415
- name="discriminatorField"
416
- label={t('Discriminator Field')}
417
- help={t(
418
- 'Form field that selects the API sub-case (e.g. mode/type/task/action/process). Sent automatically.',
419
- )}
420
- >
421
- <Input placeholder="mode" style={{ width: 200 }} />
422
- </Form.Item>
423
- <Form.Item
424
- name="discriminatorValue"
425
- label={t('Discriminator Value')}
426
- help={t('Value sent in the discriminator field (e.g. parse, invoice, disbursement).')}
427
- >
428
- <Input placeholder="parse" style={{ width: 200 }} />
429
- </Form.Item>
430
- <Form.Item
431
- name="syncQueryParam"
432
- label={t('Sync Query Param')}
433
- help={t(
434
- 'When set, the request appends ?<param>=true to ask for a synchronous response (e.g. sync).',
435
- )}
436
- >
437
- <Input placeholder="sync" style={{ width: 200 }} />
438
- </Form.Item>
439
- <Form.Item
440
- name="taskIdExtractPath"
441
- label={t('Task ID Extract Path')}
442
- help={t(
443
- 'JSON path of the async task id in the 202 response (e.g. name). Used when the response is 202 even in sync mode.',
444
- )}
445
- >
446
- <Input placeholder="name" style={{ width: 200 }} />
447
- </Form.Item>
448
- <Form.Item
449
- name="taskIdExtractRegex"
450
- label={t('Task ID Extract Regex')}
451
- help={t(
452
- 'Regex with one capture group to pull the task id from the extracted path value (e.g. operations/([^/]+)).',
453
- )}
454
- >
455
- <Input placeholder="operations/([^/]+)" style={{ width: 240 }} />
456
- </Form.Item>
457
- </>
458
- ),
459
- },
460
- {
461
- key: 'async',
462
- label: t('Async Config'),
463
- children: (
464
- <>
465
- <Form.Item name="executionMode" label={t('Execution Mode')} initialValue="sync">
466
- <Select
467
- style={{ width: 200 }}
468
- options={[
469
- { value: 'sync', label: t('Synchronous') },
470
- { value: 'polling', label: t('Polling') },
471
- { value: 'webhook', label: t('Webhook') },
472
- ]}
473
- />
474
- </Form.Item>
475
- <Form.Item noStyle dependencies={['executionMode']}>
476
- {() => {
477
- const mode = form.getFieldValue('executionMode');
478
- if (mode === 'sync') return null;
479
- return (
480
- <>
481
- <Form.Item
482
- name="pollTaskIdField"
483
- label={t('Task ID Field')}
484
- help={t('Field in response containing the async task ID')}
485
- initialValue="task_id"
486
- >
487
- <Input placeholder="task_id" />
488
- </Form.Item>
489
-
490
- {mode === 'polling' && (
491
- <>
492
- <Form.Item
493
- name="pollResultSubpath"
494
- label={t('Poll Result Subpath')}
495
- help={t('URL to poll for result. Use {taskId} as placeholder.')}
496
- rules={[{ required: true, message: t('Required for polling mode') }]}
497
- >
498
- <Input placeholder="/api/v1/tasks/{taskId}/result" />
499
- </Form.Item>
500
- <Form.Item
501
- name="pollResultField"
502
- label={t('Result Field')}
503
- help={t('Field in poll response containing the actual result')}
504
- >
505
- <Input placeholder="result" />
506
- </Form.Item>
507
- <Form.Item
508
- name="pollStatusField"
509
- label={t('Status Field (optional)')}
510
- help={t(
511
- 'Field to check completion status. If empty, any non-null result = complete.',
512
- )}
513
- >
514
- <Input placeholder="status" />
515
- </Form.Item>
516
- <Form.Item
517
- name="pollCompletedValue"
518
- label={t('Completed Value')}
519
- help={t("Value of status field that means 'done'")}
520
- initialValue="completed"
521
- >
522
- <Input placeholder="completed" />
523
- </Form.Item>
524
- <Space size="large">
525
- <Form.Item
526
- name="pollInterval"
527
- label={t('Poll Interval (ms)')}
528
- help={t('Override default')}
529
- >
530
- <InputNumber min={1000} step={1000} placeholder="5000" style={{ width: 150 }} />
531
- </Form.Item>
532
- <Form.Item
533
- name="pollTimeout"
534
- label={t('Poll Timeout (ms)')}
535
- help={t('Override default')}
536
- >
537
- <InputNumber min={5000} step={5000} placeholder="300000" style={{ width: 150 }} />
538
- </Form.Item>
539
- </Space>
540
- </>
541
- )}
542
- </>
543
- );
544
- }}
545
- </Form.Item>
546
- </>
547
- ),
548
- },
549
- {
550
- key: 'schema',
551
- label: t('Schema'),
552
- children: (
553
- <>
554
- <Form.Item name="requestBodySchema" label={t('Request Body Schema (JSON Schema)')}>
555
- <JsonEditor placeholder='{ "type": "object", "properties": { ... } }' />
556
- </Form.Item>
557
- <Form.Item name="responseSchema" label={t('Response Schema (JSON Schema)')}>
558
- <JsonEditor placeholder='{ "type": "object", "properties": { ... } }' />
559
- </Form.Item>
560
- </>
561
- ),
562
- },
563
- {
564
- key: 'headers',
565
- label: t('Custom Headers'),
566
- children: (
567
- <Form.Item name="customHeaders" label={t('Additional Headers')}>
568
- <KeyValueEditor />
569
- </Form.Item>
570
- ),
571
- },
572
- ]}
573
- />
574
- </Form>
575
- </Modal>
576
- </div>
577
- );
578
- };
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import {
3
+ Table,
4
+ Button,
5
+ Modal,
6
+ Form,
7
+ Input,
8
+ Select,
9
+ Switch,
10
+ message,
11
+ InputNumber,
12
+ Tabs,
13
+ Space,
14
+ Tag,
15
+ Popconfirm,
16
+ } from 'antd';
17
+ import type { ColumnsType } from 'antd/es/table';
18
+ import { PlusOutlined, DeleteOutlined, EditOutlined } from '@ant-design/icons';
19
+ import { useFlowContext } from '@nocobase/flow-engine';
20
+ import { useT } from '../locale';
21
+ import { EndpointDef, unwrapData } from '../types';
22
+
23
+ const { TextArea } = Input;
24
+
25
+ interface HeaderRow {
26
+ id: string;
27
+ key: string;
28
+ value: string;
29
+ }
30
+
31
+ const sanitizeHeaders = (headers?: Record<string, string>) =>
32
+ Object.entries(headers || {}).reduce<Record<string, string>>((acc, [key, value]) => {
33
+ const headerName = key.trim();
34
+ if (headerName) {
35
+ acc[headerName] = value;
36
+ }
37
+ return acc;
38
+ }, {});
39
+
40
+ const KeyValueEditor: React.FC<{ value?: Record<string, string>; onChange?: (v: Record<string, string>) => void }> = ({
41
+ value,
42
+ onChange,
43
+ }) => {
44
+ const t = useT();
45
+ const [rows, setRows] = useState<HeaderRow[]>([]);
46
+ const syncedRef = useRef<string>();
47
+
48
+ // A half-typed row (blank name) has no representation in `value`, so resync only on a genuine
49
+ // outside change. Comparing serialized content — not object identity — keeps such rows alive.
50
+ const serialized = JSON.stringify(value ?? {});
51
+
52
+ useEffect(() => {
53
+ if (syncedRef.current === serialized) return;
54
+ syncedRef.current = serialized;
55
+ setRows(
56
+ Object.entries(JSON.parse(serialized) as Record<string, string>).map(([key, rowValue], index) => ({
57
+ id: `${key}_${index}`,
58
+ key,
59
+ value: String(rowValue ?? ''),
60
+ })),
61
+ );
62
+ }, [serialized]);
63
+
64
+ const emit = (nextRows: HeaderRow[]) => {
65
+ setRows(nextRows);
66
+ const nextValue = nextRows.reduce<Record<string, string>>((acc, row) => {
67
+ const key = row.key.trim();
68
+ if (key) {
69
+ acc[key] = row.value;
70
+ }
71
+ return acc;
72
+ }, {});
73
+ syncedRef.current = JSON.stringify(nextValue);
74
+ onChange?.(nextValue);
75
+ };
76
+
77
+ const update = (idx: number, key: string, val: string) => {
78
+ const nextRows = [...rows];
79
+ nextRows[idx] = { ...nextRows[idx], key, value: val };
80
+ emit(nextRows);
81
+ };
82
+
83
+ const add = () => setRows([...rows, { id: `new_${Date.now()}_${Math.random()}`, key: '', value: '' }]);
84
+
85
+ const remove = (idx: number) => {
86
+ emit(rows.filter((_, rowIndex) => rowIndex !== idx));
87
+ };
88
+
89
+ return (
90
+ <div>
91
+ {rows.map((row, i) => (
92
+ <Space key={row.id} style={{ display: 'flex', marginBottom: 4 }}>
93
+ <Input
94
+ placeholder={t('Header name')}
95
+ aria-label={t('Header name')}
96
+ value={row.key}
97
+ onChange={(e) => update(i, e.target.value, row.value)}
98
+ style={{ width: 180 }}
99
+ />
100
+ <Input
101
+ placeholder={t('Value')}
102
+ aria-label={t('Value')}
103
+ value={row.value}
104
+ onChange={(e) => update(i, row.key, e.target.value)}
105
+ style={{ width: 220 }}
106
+ />
107
+ <Button
108
+ size="small"
109
+ danger
110
+ icon={<DeleteOutlined />}
111
+ onClick={() => remove(i)}
112
+ aria-label={`${t('Delete')} ${row.key || t('Header name')}`}
113
+ />
114
+ </Space>
115
+ ))}
116
+ <Button size="small" type="dashed" icon={<PlusOutlined />} onClick={add}>
117
+ {t('Add Header')}
118
+ </Button>
119
+ </div>
120
+ );
121
+ };
122
+
123
+ const JsonEditor: React.FC<{ value?: unknown; onChange?: (v: unknown) => void; placeholder?: string }> = ({
124
+ value,
125
+ onChange,
126
+ placeholder,
127
+ }) => {
128
+ const t = useT();
129
+ const [text, setText] = useState('');
130
+ const [error, setError] = useState('');
131
+
132
+ useEffect(() => {
133
+ if (!value) {
134
+ setText('');
135
+ return;
136
+ }
137
+ try {
138
+ setText(typeof value === 'string' ? JSON.stringify(JSON.parse(value), null, 2) : JSON.stringify(value, null, 2));
139
+ } catch {
140
+ setText(typeof value === 'string' ? value : '');
141
+ }
142
+ }, [value]);
143
+
144
+ const handleBlur = () => {
145
+ if (!text.trim()) {
146
+ setError('');
147
+ onChange?.(null);
148
+ return;
149
+ }
150
+ try {
151
+ const parsed = JSON.parse(text);
152
+ setError('');
153
+ onChange?.(parsed);
154
+ } catch {
155
+ setError(t('Invalid JSON'));
156
+ }
157
+ };
158
+
159
+ return (
160
+ <div>
161
+ <TextArea
162
+ rows={6}
163
+ value={text}
164
+ onChange={(e) => setText(e.target.value)}
165
+ onBlur={handleBlur}
166
+ placeholder={placeholder || '{}'}
167
+ status={error ? 'error' : undefined}
168
+ style={{ fontFamily: 'monospace', fontSize: 12 }}
169
+ />
170
+ {error && (
171
+ <div role="alert" style={{ color: '#ff4d4f', fontSize: 12 }}>
172
+ {error}
173
+ </div>
174
+ )}
175
+ </div>
176
+ );
177
+ };
178
+
179
+ export const EndpointsTab = () => {
180
+ const ctx = useFlowContext();
181
+ const api = ctx.api;
182
+ const t = useT();
183
+ const [data, setData] = useState<EndpointDef[]>([]);
184
+ const [loading, setLoading] = useState(false);
185
+ const [visible, setVisible] = useState(false);
186
+ const [form] = Form.useForm<Partial<EndpointDef>>();
187
+ const [editingId, setEditingId] = useState<number | null>(null);
188
+
189
+ const executionLabels: Record<string, string> = {
190
+ sync: t('Synchronous'),
191
+ polling: t('Polling'),
192
+ webhook: t('Webhook'),
193
+ };
194
+
195
+ const fileModeLabels: Record<string, string> = {
196
+ multipart: t('Multipart Upload'),
197
+ base64: t('Base64 in JSON'),
198
+ };
199
+
200
+ const fetchEndpoints = useCallback(async () => {
201
+ setLoading(true);
202
+ try {
203
+ const res = await api.request({ url: 'docUnderstanding:listEndpoints' });
204
+ setData(unwrapData<EndpointDef[]>(res, []));
205
+ } finally {
206
+ setLoading(false);
207
+ }
208
+ }, [api]);
209
+
210
+ useEffect(() => {
211
+ fetchEndpoints();
212
+ }, [fetchEndpoints]);
213
+
214
+ const openEdit = (record: EndpointDef) => {
215
+ setEditingId(record.id);
216
+ form.setFieldsValue(record);
217
+ setVisible(true);
218
+ };
219
+
220
+ const openAdd = () => {
221
+ setEditingId(null);
222
+ form.resetFields();
223
+ setVisible(true);
224
+ };
225
+
226
+ const handleDelete = async (id: number) => {
227
+ await api.request({
228
+ url: 'docUnderstanding:deleteEndpoint',
229
+ method: 'POST',
230
+ params: { filterByTk: id },
231
+ });
232
+ message.success(t('Deleted'));
233
+ fetchEndpoints();
234
+ };
235
+
236
+ const handleSave = async () => {
237
+ try {
238
+ const values = await form.validateFields();
239
+ values.customHeaders = sanitizeHeaders(values.customHeaders);
240
+ if (editingId) {
241
+ await api.request({
242
+ url: 'docUnderstanding:updateEndpoint',
243
+ method: 'POST',
244
+ params: { filterByTk: editingId },
245
+ data: values,
246
+ });
247
+ } else {
248
+ await api.request({
249
+ url: 'docUnderstanding:createEndpoint',
250
+ method: 'POST',
251
+ data: values,
252
+ });
253
+ }
254
+ message.success(t('Saved'));
255
+ setVisible(false);
256
+ fetchEndpoints();
257
+ } catch {
258
+ // Form validation errors are already surfaced inline by antd.
259
+ }
260
+ };
261
+
262
+ const columns: ColumnsType<EndpointDef> = [
263
+ { title: t('Name'), dataIndex: 'name', width: 150 },
264
+ { title: t('Subpath'), dataIndex: 'subpath', width: 200 },
265
+ {
266
+ title: t('Method'),
267
+ dataIndex: 'method',
268
+ width: 80,
269
+ render: (v: string) => <Tag>{v}</Tag>,
270
+ },
271
+ {
272
+ title: t('Execution'),
273
+ dataIndex: 'executionMode',
274
+ width: 130,
275
+ render: (v: string) => {
276
+ const colors: Record<string, string> = { sync: 'green', polling: 'blue', webhook: 'purple' };
277
+ return <Tag color={colors[v]}>{executionLabels[v] || v}</Tag>;
278
+ },
279
+ },
280
+ {
281
+ title: t('File'),
282
+ dataIndex: 'fileInputMode',
283
+ width: 130,
284
+ render: (v: string) => (v === 'none' ? '-' : fileModeLabels[v] || v),
285
+ },
286
+ {
287
+ title: t('Enabled'),
288
+ dataIndex: 'enabled',
289
+ width: 70,
290
+ render: (v: boolean) => (v ? <Tag color="success">{t('Yes')}</Tag> : <Tag>{t('No')}</Tag>),
291
+ },
292
+ {
293
+ title: t('Action'),
294
+ width: 120,
295
+ render: (_: unknown, record) => (
296
+ <Space>
297
+ <Button
298
+ type="link"
299
+ size="small"
300
+ icon={<EditOutlined />}
301
+ onClick={() => openEdit(record)}
302
+ aria-label={`${t('Edit')} ${record.name}`}
303
+ >
304
+ {t('Edit')}
305
+ </Button>
306
+ <Popconfirm title={t('Delete this endpoint?')} okText={t('Delete')} onConfirm={() => handleDelete(record.id)}>
307
+ <Button
308
+ type="link"
309
+ size="small"
310
+ danger
311
+ icon={<DeleteOutlined />}
312
+ aria-label={`${t('Delete')} ${record.name}`}
313
+ >
314
+ {t('Delete')}
315
+ </Button>
316
+ </Popconfirm>
317
+ </Space>
318
+ ),
319
+ },
320
+ ];
321
+
322
+ return (
323
+ <div>
324
+ <div style={{ marginBottom: 16 }}>
325
+ <Button type="primary" icon={<PlusOutlined />} onClick={openAdd}>
326
+ {t('Add Endpoint')}
327
+ </Button>
328
+ </div>
329
+ <Table rowKey="id" columns={columns} dataSource={data} loading={loading} size="small" />
330
+
331
+ <Modal
332
+ title={editingId ? t('Edit Endpoint') : t('Add Endpoint')}
333
+ open={visible}
334
+ onOk={handleSave}
335
+ onCancel={() => setVisible(false)}
336
+ okText={t('Save')}
337
+ cancelText={t('Cancel')}
338
+ width={680}
339
+ destroyOnClose
340
+ >
341
+ <Form form={form} layout="vertical" preserve={false}>
342
+ <Tabs
343
+ size="small"
344
+ items={[
345
+ {
346
+ key: 'basic',
347
+ label: t('Basic'),
348
+ children: (
349
+ <>
350
+ <Form.Item name="name" label={t('Unique Name')} rules={[{ required: true }]}>
351
+ <Input placeholder="ocr, classify, extract..." />
352
+ </Form.Item>
353
+ <Form.Item name="subpath" label={t('Subpath')} rules={[{ required: true }]}>
354
+ <Input placeholder="/api/v1/ocr" />
355
+ </Form.Item>
356
+ <Form.Item name="description" label={t('Description')}>
357
+ <TextArea rows={2} placeholder={t('What this endpoint does')} />
358
+ </Form.Item>
359
+ <Space size="large">
360
+ <Form.Item name="method" label={t('HTTP Method')} initialValue="POST">
361
+ <Select
362
+ style={{ width: 120 }}
363
+ options={[
364
+ { value: 'GET', label: 'GET' },
365
+ { value: 'POST', label: 'POST' },
366
+ { value: 'PUT', label: 'PUT' },
367
+ ]}
368
+ />
369
+ </Form.Item>
370
+ <Form.Item name="enabled" label={t('Enabled')} valuePropName="checked" initialValue={true}>
371
+ <Switch />
372
+ </Form.Item>
373
+ </Space>
374
+ </>
375
+ ),
376
+ },
377
+ {
378
+ key: 'file',
379
+ label: t('File Input'),
380
+ children: (
381
+ <>
382
+ <Form.Item name="fileInputMode" label={t('File Input Mode')} initialValue="none">
383
+ <Select
384
+ style={{ width: 200 }}
385
+ options={[
386
+ { value: 'none', label: t('None') },
387
+ { value: 'multipart', label: t('Multipart Upload') },
388
+ { value: 'base64', label: t('Base64 in JSON') },
389
+ ]}
390
+ />
391
+ </Form.Item>
392
+ <Form.Item noStyle dependencies={['fileInputMode']}>
393
+ {() =>
394
+ form.getFieldValue('fileInputMode') !== 'none' ? (
395
+ <>
396
+ <Form.Item name="fileFieldName" label={t('File Field Name')} initialValue="file">
397
+ <Input placeholder="file" style={{ width: 200 }} />
398
+ </Form.Item>
399
+ <Form.Item name="maxFiles" label={t('Max Files')} initialValue={1}>
400
+ <InputNumber min={1} max={20} style={{ width: 120 }} />
401
+ </Form.Item>
402
+ </>
403
+ ) : null
404
+ }
405
+ </Form.Item>
406
+ </>
407
+ ),
408
+ },
409
+ {
410
+ key: 'gateway',
411
+ label: t('Gateway / Discriminator'),
412
+ children: (
413
+ <>
414
+ <Form.Item
415
+ name="discriminatorField"
416
+ label={t('Discriminator Field')}
417
+ help={t(
418
+ 'Form field that selects the API sub-case (e.g. mode/type/task/action/process). Sent automatically.',
419
+ )}
420
+ >
421
+ <Input placeholder="mode" style={{ width: 200 }} />
422
+ </Form.Item>
423
+ <Form.Item
424
+ name="discriminatorValue"
425
+ label={t('Discriminator Value')}
426
+ help={t('Value sent in the discriminator field (e.g. parse, invoice, disbursement).')}
427
+ >
428
+ <Input placeholder="parse" style={{ width: 200 }} />
429
+ </Form.Item>
430
+ <Form.Item
431
+ name="syncQueryParam"
432
+ label={t('Sync Query Param')}
433
+ help={t(
434
+ 'When set, the request appends ?<param>=true to ask for a synchronous response (e.g. sync).',
435
+ )}
436
+ >
437
+ <Input placeholder="sync" style={{ width: 200 }} />
438
+ </Form.Item>
439
+ <Form.Item
440
+ name="taskIdExtractPath"
441
+ label={t('Task ID Extract Path')}
442
+ help={t(
443
+ 'JSON path of the async task id in the 202 response (e.g. name). Used when the response is 202 even in sync mode.',
444
+ )}
445
+ >
446
+ <Input placeholder="name" style={{ width: 200 }} />
447
+ </Form.Item>
448
+ <Form.Item
449
+ name="taskIdExtractRegex"
450
+ label={t('Task ID Extract Regex')}
451
+ help={t(
452
+ 'Regex with one capture group to pull the task id from the extracted path value (e.g. operations/([^/]+)).',
453
+ )}
454
+ >
455
+ <Input placeholder="operations/([^/]+)" style={{ width: 240 }} />
456
+ </Form.Item>
457
+ </>
458
+ ),
459
+ },
460
+ {
461
+ key: 'async',
462
+ label: t('Async Config'),
463
+ children: (
464
+ <>
465
+ <Form.Item name="executionMode" label={t('Execution Mode')} initialValue="sync">
466
+ <Select
467
+ style={{ width: 200 }}
468
+ options={[
469
+ { value: 'sync', label: t('Synchronous') },
470
+ { value: 'polling', label: t('Polling') },
471
+ { value: 'webhook', label: t('Webhook') },
472
+ ]}
473
+ />
474
+ </Form.Item>
475
+ <Form.Item noStyle dependencies={['executionMode']}>
476
+ {() => {
477
+ const mode = form.getFieldValue('executionMode');
478
+ if (mode === 'sync') return null;
479
+ return (
480
+ <>
481
+ <Form.Item
482
+ name="pollTaskIdField"
483
+ label={t('Task ID Field')}
484
+ help={t('Field in response containing the async task ID')}
485
+ initialValue="task_id"
486
+ >
487
+ <Input placeholder="task_id" />
488
+ </Form.Item>
489
+
490
+ {mode === 'polling' && (
491
+ <>
492
+ <Form.Item
493
+ name="pollResultSubpath"
494
+ label={t('Poll Result Subpath')}
495
+ help={t('URL to poll for result. Use {taskId} as placeholder.')}
496
+ rules={[{ required: true, message: t('Required for polling mode') }]}
497
+ >
498
+ <Input placeholder="/api/v1/tasks/{taskId}/result" />
499
+ </Form.Item>
500
+ <Form.Item
501
+ name="pollResultField"
502
+ label={t('Result Field')}
503
+ help={t('Field in poll response containing the actual result')}
504
+ >
505
+ <Input placeholder="result" />
506
+ </Form.Item>
507
+ <Form.Item
508
+ name="pollStatusField"
509
+ label={t('Status Field (optional)')}
510
+ help={t(
511
+ 'Field to check completion status. If empty, any non-null result = complete.',
512
+ )}
513
+ >
514
+ <Input placeholder="status" />
515
+ </Form.Item>
516
+ <Form.Item
517
+ name="pollCompletedValue"
518
+ label={t('Completed Value')}
519
+ help={t("Value of status field that means 'done'")}
520
+ initialValue="completed"
521
+ >
522
+ <Input placeholder="completed" />
523
+ </Form.Item>
524
+ <Space size="large">
525
+ <Form.Item
526
+ name="pollInterval"
527
+ label={t('Poll Interval (ms)')}
528
+ help={t('Override default')}
529
+ >
530
+ <InputNumber min={1000} step={1000} placeholder="5000" style={{ width: 150 }} />
531
+ </Form.Item>
532
+ <Form.Item
533
+ name="pollTimeout"
534
+ label={t('Poll Timeout (ms)')}
535
+ help={t('Override default')}
536
+ >
537
+ <InputNumber min={5000} step={5000} placeholder="300000" style={{ width: 150 }} />
538
+ </Form.Item>
539
+ </Space>
540
+ </>
541
+ )}
542
+ </>
543
+ );
544
+ }}
545
+ </Form.Item>
546
+ </>
547
+ ),
548
+ },
549
+ {
550
+ key: 'schema',
551
+ label: t('Schema'),
552
+ children: (
553
+ <>
554
+ <Form.Item name="requestBodySchema" label={t('Request Body Schema (JSON Schema)')}>
555
+ <JsonEditor placeholder='{ "type": "object", "properties": { ... } }' />
556
+ </Form.Item>
557
+ <Form.Item name="responseSchema" label={t('Response Schema (JSON Schema)')}>
558
+ <JsonEditor placeholder='{ "type": "object", "properties": { ... } }' />
559
+ </Form.Item>
560
+ </>
561
+ ),
562
+ },
563
+ {
564
+ key: 'headers',
565
+ label: t('Custom Headers'),
566
+ children: (
567
+ <Form.Item name="customHeaders" label={t('Additional Headers')}>
568
+ <KeyValueEditor />
569
+ </Form.Item>
570
+ ),
571
+ },
572
+ ]}
573
+ />
574
+ </Form>
575
+ </Modal>
576
+ </div>
577
+ );
578
+ };