plugin-document-understanding 1.0.0
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.
- package/README.md +366 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/components/EndpointsTab.d.ts +2 -0
- package/dist/client/components/JobsTab.d.ts +2 -0
- package/dist/client/components/PipelinesTab.d.ts +2 -0
- package/dist/client/components/PluginSettings.d.ts +2 -0
- package/dist/client/components/ServiceConfigTab.d.ts +2 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/client/locale.d.ts +10 -0
- package/dist/client/models/index.d.ts +11 -0
- package/dist/client/plugin.d.ts +5 -0
- package/dist/externalVersion.js +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.json +121 -0
- package/dist/locale/vi-VN.json +121 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/server/actions.d.ts +16 -0
- package/dist/server/actions.js +109 -0
- package/dist/server/collections/config.d.ts +2 -0
- package/dist/server/collections/config.js +39 -0
- package/dist/server/collections/endpoints.d.ts +2 -0
- package/dist/server/collections/endpoints.js +47 -0
- package/dist/server/collections/jobs.d.ts +2 -0
- package/dist/server/collections/jobs.js +49 -0
- package/dist/server/collections/pipeline-steps.d.ts +2 -0
- package/dist/server/collections/pipeline-steps.js +47 -0
- package/dist/server/collections/pipelines.d.ts +2 -0
- package/dist/server/collections/pipelines.js +39 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/plugin.d.ts +15 -0
- package/dist/server/plugin.js +102 -0
- package/dist/server/services/AsyncJobManager.d.ts +23 -0
- package/dist/server/services/AsyncJobManager.js +117 -0
- package/dist/server/services/DocumentUnderstandingService.d.ts +32 -0
- package/dist/server/services/DocumentUnderstandingService.js +189 -0
- package/dist/server/services/ExternalApiClient.d.ts +26 -0
- package/dist/server/services/ExternalApiClient.js +128 -0
- package/dist/server/services/PipelineExecutor.d.ts +23 -0
- package/dist/server/services/PipelineExecutor.js +252 -0
- package/dist/server/tools/document-understanding-tool.d.ts +8 -0
- package/dist/server/tools/document-understanding-tool.js +105 -0
- package/dist/server/types.d.ts +68 -0
- package/dist/server/types.js +15 -0
- package/package.json +16 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
# @nocobase/plugin-document-understanding
|
|
2
|
+
|
|
3
|
+
Generic Document Processing Pipeline Orchestrator cho NocoBase 2.x.
|
|
4
|
+
Plugin cho phep cau hinh va thuc thi cac pipeline xu ly tai lieu thong qua external API services (OCR, classification, extraction, ...).
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Yeu cau
|
|
9
|
+
|
|
10
|
+
- NocoBase 2.x
|
|
11
|
+
- (Tuy chon) `@nocobase/plugin-ai` neu muon su dung AI tool integration
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Cai dat
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn nocobase pm add @nocobase/plugin-document-understanding
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Sau do vao **Settings > Plugin Manager**, tim plugin **Document Understanding** va bat **Enable**.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Huong dan su dung
|
|
26
|
+
|
|
27
|
+
Sau khi enable plugin, vao **Settings > Document Understanding** se thay giao dien voi 4 tab.
|
|
28
|
+
|
|
29
|
+
### Buoc 1: Cau hinh Service (Tab "Service Config")
|
|
30
|
+
|
|
31
|
+
Day la buoc bat buoc dau tien — plugin can biet external service cua ban o dau va xac thuc nhu the nao.
|
|
32
|
+
|
|
33
|
+
1. Mo tab **Service Config**
|
|
34
|
+
2. Dien cac truong:
|
|
35
|
+
|
|
36
|
+
| Truong | Mo ta | Vi du |
|
|
37
|
+
|--------|-------|-------|
|
|
38
|
+
| **Base URL** | URL goc cua external document processing service | `http://my-ocr-service:8000` |
|
|
39
|
+
| **Auth Type** | Phuong thuc xac thuc | `None`, `API Key`, `Bearer Token`, `Custom Header` |
|
|
40
|
+
| **API Key / Token** | Key hoac token (hien thi khi Auth Type khac None) | `sk-abc123...` |
|
|
41
|
+
| **Custom Header Name** | Ten header tuy chinh (khi chon Custom Header) | `X-Api-Key` |
|
|
42
|
+
| **Default Request Timeout** | Timeout mac dinh cho moi request (ms) | `30000` |
|
|
43
|
+
| **Default Retries** | So lan thu lai mac dinh khi loi | `2` |
|
|
44
|
+
| **Default Poll Interval** | Khoang thoi gian giua cac lan poll (ms) | `5000` |
|
|
45
|
+
| **Default Poll Timeout** | Thoi gian toi da cho poll (ms) | `300000` |
|
|
46
|
+
| **Webhook Secret** | Secret de verify webhook callback tu external service | (tuy chon) |
|
|
47
|
+
|
|
48
|
+
3. Nhan **Save Configuration**
|
|
49
|
+
|
|
50
|
+
### Buoc 2: Dang ky Endpoints (Tab "Endpoints")
|
|
51
|
+
|
|
52
|
+
Moi endpoint dai dien cho mot chuc nang cua external service (OCR, classify, extract, ...).
|
|
53
|
+
|
|
54
|
+
1. Mo tab **Endpoints**
|
|
55
|
+
2. Nhan **Add Endpoint**
|
|
56
|
+
3. Dien thong tin:
|
|
57
|
+
|
|
58
|
+
| Truong | Mo ta | Vi du |
|
|
59
|
+
|--------|-------|-------|
|
|
60
|
+
| **Unique Name** | Ten dinh danh (khong trung) | `ocr`, `classify`, `extract_table` |
|
|
61
|
+
| **Subpath** | Duong dan API tuong doi voi Base URL | `/api/v1/ocr` |
|
|
62
|
+
| **HTTP Method** | `GET` hoac `POST` | `POST` |
|
|
63
|
+
| **Execution Mode** | Cach thuc thi | Xem ben duoi |
|
|
64
|
+
| **File Input Mode** | Cach gui file | `None`, `Multipart`, `Base64` |
|
|
65
|
+
| **Enabled** | Bat/tat endpoint | `true` |
|
|
66
|
+
|
|
67
|
+
**Execution Mode giai thich:**
|
|
68
|
+
|
|
69
|
+
- **Synchronous**: Goi API, nhan ket qua ngay trong response. Phu hop cho cac task nhanh (< 30s).
|
|
70
|
+
- **Polling**: Goi API nhan `task_id`, sau do plugin tu dong poll ket qua theo interval. Dien them:
|
|
71
|
+
- `Poll Task ID Field`: truong trong response chua task_id (mac dinh: `task_id`)
|
|
72
|
+
- `Poll Result Field`: truong chua ket qua khi poll thanh cong
|
|
73
|
+
- `Poll Status Field` (tuy chon): truong chua trang thai, kiem tra xem task da xong chua
|
|
74
|
+
- `Poll Completed Value` (tuy chon): gia tri cua status field khi hoan thanh (mac dinh: `completed`)
|
|
75
|
+
- **Webhook**: Goi API nhan `task_id`, external service se goi lai webhook khi xong. Plugin tu dong xu ly callback.
|
|
76
|
+
|
|
77
|
+
**Vi du: Dang ky endpoint OCR dong bo**
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
Name: ocr
|
|
81
|
+
Subpath: /api/v1/ocr
|
|
82
|
+
Method: POST
|
|
83
|
+
Execution Mode: Synchronous
|
|
84
|
+
File Input: Multipart
|
|
85
|
+
Enabled: true
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Vi du: Dang ky endpoint classify bat dong bo (polling)**
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Name: classify
|
|
92
|
+
Subpath: /api/v1/classify
|
|
93
|
+
Method: POST
|
|
94
|
+
Execution Mode: Polling
|
|
95
|
+
Poll Task ID: task_id
|
|
96
|
+
Poll Result Field: result
|
|
97
|
+
File Input: None
|
|
98
|
+
Enabled: true
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Buoc 3: Tao Pipeline (Tab "Pipelines")
|
|
102
|
+
|
|
103
|
+
Pipeline la mot chuoi cac buoc (steps) goi lan luot cac endpoints da dang ky.
|
|
104
|
+
|
|
105
|
+
1. Mo tab **Pipelines**
|
|
106
|
+
2. Nhan **Add Pipeline**
|
|
107
|
+
3. Dien:
|
|
108
|
+
- **Name**: ten pipeline (vi du: `full_document_processing`)
|
|
109
|
+
- **Description**: mo ta
|
|
110
|
+
- **Enabled**: bat
|
|
111
|
+
|
|
112
|
+
**Cau hinh Steps (thong qua API hoac JSON):**
|
|
113
|
+
|
|
114
|
+
Hien tai giao dien UI cua Pipelines Tab chi ho tro CRUD co ban (name, description, enabled).
|
|
115
|
+
De cau hinh steps chi tiet, su dung REST API:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Tao pipeline voi steps
|
|
119
|
+
curl -X POST http://localhost:13000/api/docUnderstanding:createPipeline \
|
|
120
|
+
-H "Content-Type: application/json" \
|
|
121
|
+
-H "Authorization: Bearer <your-nocobase-token>" \
|
|
122
|
+
-d '{
|
|
123
|
+
"name": "full_document_processing",
|
|
124
|
+
"description": "OCR roi classify roi extract",
|
|
125
|
+
"enabled": true,
|
|
126
|
+
"steps": [
|
|
127
|
+
{
|
|
128
|
+
"stepOrder": 1,
|
|
129
|
+
"name": "OCR",
|
|
130
|
+
"endpointId": 1,
|
|
131
|
+
"inputMapping": {},
|
|
132
|
+
"outputAlias": "ocr_result",
|
|
133
|
+
"onError": "fail"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"stepOrder": 2,
|
|
137
|
+
"name": "Classify",
|
|
138
|
+
"endpointId": 2,
|
|
139
|
+
"inputMapping": {
|
|
140
|
+
"text": "$step[ocr_result].response.text"
|
|
141
|
+
},
|
|
142
|
+
"outputAlias": "classify_result",
|
|
143
|
+
"onError": "fail"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"stepOrder": 3,
|
|
147
|
+
"name": "Extract Table",
|
|
148
|
+
"endpointId": 3,
|
|
149
|
+
"inputMapping": {
|
|
150
|
+
"text": "$step[ocr_result].response.text",
|
|
151
|
+
"doc_type": "$step[classify_result].response.category"
|
|
152
|
+
},
|
|
153
|
+
"outputAlias": "extract_result",
|
|
154
|
+
"onError": "skip",
|
|
155
|
+
"condition": {
|
|
156
|
+
"field": "$step[classify_result].response.category",
|
|
157
|
+
"op": "eq",
|
|
158
|
+
"value": "invoice"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Input Mapping DSL:**
|
|
166
|
+
|
|
167
|
+
| Cu phap | Mo ta | Vi du |
|
|
168
|
+
|---------|-------|-------|
|
|
169
|
+
| `$input.fieldName` | Lay tu input goc cua pipeline | `$input.document_url` |
|
|
170
|
+
| `$step[alias].response.path` | Lay tu ket qua step truoc (theo alias) | `$step[ocr_result].response.text` |
|
|
171
|
+
| `$step[1].response.path` | Lay tu ket qua step truoc (theo so thu tu) | `$step[1].response.text` |
|
|
172
|
+
| `$files` | Toan bo files dau vao | `$files` |
|
|
173
|
+
| Gia tri co dinh | String literal | `"invoice"` |
|
|
174
|
+
|
|
175
|
+
**Condition operators ho tro:** `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `contains`
|
|
176
|
+
|
|
177
|
+
**onError options:** `fail` (dung pipeline), `skip` (bo qua step), `retry` (thu lai theo retryCount)
|
|
178
|
+
|
|
179
|
+
### Buoc 4: Chay Pipeline
|
|
180
|
+
|
|
181
|
+
**Cach 1: Qua REST API**
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Chay pipeline (tham so la pipelineId)
|
|
185
|
+
curl -X POST http://localhost:13000/api/docUnderstanding:executePipeline \
|
|
186
|
+
-H "Content-Type: application/json" \
|
|
187
|
+
-H "Authorization: Bearer <your-nocobase-token>" \
|
|
188
|
+
-d '{
|
|
189
|
+
"pipelineId": 1,
|
|
190
|
+
"input": {
|
|
191
|
+
"document_url": "https://example.com/invoice.pdf"
|
|
192
|
+
}
|
|
193
|
+
}'
|
|
194
|
+
|
|
195
|
+
# Response:
|
|
196
|
+
# { "jobId": 42 }
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Kiem tra trang thai job
|
|
201
|
+
curl http://localhost:13000/api/docUnderstanding:getJobStatus?jobId=42 \
|
|
202
|
+
-H "Authorization: Bearer <your-nocobase-token>"
|
|
203
|
+
|
|
204
|
+
# Response:
|
|
205
|
+
# {
|
|
206
|
+
# "id": 42,
|
|
207
|
+
# "status": "completed",
|
|
208
|
+
# "stepResults": { "ocr_result": {...}, "classify_result": {...} },
|
|
209
|
+
# "finalResult": {...}
|
|
210
|
+
# }
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Cach 2: Qua AI Employee (neu da cai plugin-ai)**
|
|
214
|
+
|
|
215
|
+
Khi `@nocobase/plugin-ai` duoc bat, **moi pipeline enabled se tu dong tro thanh mot AI tool/skill rieng biet**.
|
|
216
|
+
AI employee co the chon va goi truc tiep pipeline phu hop ma khong can biet pipeline name.
|
|
217
|
+
|
|
218
|
+
**Cach hoat dong:**
|
|
219
|
+
|
|
220
|
+
- Plugin dang ky mot **dynamic tools provider** voi AI tools manager.
|
|
221
|
+
- Moi khi AI can danh sach tools, provider se query tat ca pipeline co `enabled = true` va tao 1 tool cho moi pipeline.
|
|
222
|
+
- Tool name duoc sinh tu pipeline name: `doc_understanding.<sanitized_pipeline_name>`
|
|
223
|
+
- Vi du: pipeline "Full Document Processing" → tool `doc_understanding.full_document_processing`
|
|
224
|
+
- Moi tool co:
|
|
225
|
+
- **Title**: `Document: <pipeline name>`
|
|
226
|
+
- **Description**: mo ta pipeline + danh sach steps (vi du: "OCR → Classify → Extract")
|
|
227
|
+
- **Schema**: lay tu `inputSchema` cua pipeline (neu co), hoac fallback la `{ input: object }`
|
|
228
|
+
|
|
229
|
+
**Vi du: Ban co 3 pipelines enabled:**
|
|
230
|
+
|
|
231
|
+
| Pipeline | Tool name | Mo ta AI nhin thay |
|
|
232
|
+
|----------|-----------|-------------------|
|
|
233
|
+
| OCR Only | `doc_understanding.ocr_only` | "Thuc hien OCR tren tai lieu. Steps: OCR" |
|
|
234
|
+
| Invoice Processing | `doc_understanding.invoice_processing` | "Xu ly hoa don. Steps: OCR → Classify → Extract Table" |
|
|
235
|
+
| Contract Analysis | `doc_understanding.contract_analysis` | "Phan tich hop dong. Steps: OCR → NER → Summarize" |
|
|
236
|
+
|
|
237
|
+
**Khi nguoi dung hoi AI employee:**
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
User: "Phan tich hoa don nay giup toi"
|
|
241
|
+
|
|
242
|
+
AI tu dong chon tool: doc_understanding.invoice_processing
|
|
243
|
+
- input: { document_url: "..." }
|
|
244
|
+
|
|
245
|
+
→ Tra ve ket qua JSON sau khi pipeline chay xong (poll toi da 30s)
|
|
246
|
+
→ Neu chua xong, tra ve jobId de theo doi
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Luu y:**
|
|
250
|
+
- Chi pipeline co `enabled = true` moi duoc dang ky lam tool
|
|
251
|
+
- Khi ban tao/sua/xoa/bat/tat pipeline, danh sach tools tu dong cap nhat (dynamic, khong can restart)
|
|
252
|
+
- Neu pipeline co `inputSchema` duoc dinh nghia, AI se biet chinh xac can truyen tham so gi
|
|
253
|
+
- Moi tool hoat dong doc lap — AI employee co the chon dung tool phu hop theo ngu canh
|
|
254
|
+
|
|
255
|
+
**Tip: Dinh nghia inputSchema cho pipeline de AI hieu ro input can thiet:**
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
curl -X POST http://localhost:13000/api/docUnderstanding:updatePipeline/1 \
|
|
259
|
+
-H "Content-Type: application/json" \
|
|
260
|
+
-H "Authorization: Bearer <your-nocobase-token>" \
|
|
261
|
+
-d '{
|
|
262
|
+
"inputSchema": {
|
|
263
|
+
"type": "object",
|
|
264
|
+
"properties": {
|
|
265
|
+
"document_url": {
|
|
266
|
+
"type": "string",
|
|
267
|
+
"description": "URL cua tai lieu can xu ly"
|
|
268
|
+
},
|
|
269
|
+
"language": {
|
|
270
|
+
"type": "string",
|
|
271
|
+
"enum": ["vi", "en", "ja"],
|
|
272
|
+
"description": "Ngon ngu cua tai lieu"
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"required": ["document_url"]
|
|
276
|
+
}
|
|
277
|
+
}'
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Khi do AI se biet chinh xac can `document_url` (bat buoc) va `language` (tuy chon) khi goi tool.
|
|
281
|
+
|
|
282
|
+
### Buoc 5: Theo doi Jobs (Tab "Jobs history")
|
|
283
|
+
|
|
284
|
+
1. Mo tab **Jobs history**
|
|
285
|
+
2. Xem danh sach jobs voi trang thai:
|
|
286
|
+
- **pending**: Dang cho
|
|
287
|
+
- **running**: Dang chay
|
|
288
|
+
- **polling**: Dang cho ket qua tu external service
|
|
289
|
+
- **completed**: Hoan thanh
|
|
290
|
+
- **failed**: That bai
|
|
291
|
+
- **timeout**: Het thoi gian cho
|
|
292
|
+
3. Nhan **View Details** de xem chi tiet:
|
|
293
|
+
- Input da gui
|
|
294
|
+
- Ket qua tung step
|
|
295
|
+
- Ket qua cuoi cung
|
|
296
|
+
- Loi (neu co)
|
|
297
|
+
|
|
298
|
+
Tab tu dong refresh moi 10 giay.
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Webhook Callback
|
|
303
|
+
|
|
304
|
+
Neu endpoint su dung execution mode **Webhook**, external service can goi callback ve:
|
|
305
|
+
|
|
306
|
+
```
|
|
307
|
+
POST http://localhost:13000/api/docUnderstanding:webhookCallback
|
|
308
|
+
Content-Type: application/json
|
|
309
|
+
X-Webhook-Signature: sha256=<hmac-hex> (neu co cau hinh Webhook Secret)
|
|
310
|
+
|
|
311
|
+
{
|
|
312
|
+
"task_id": "abc-123",
|
|
313
|
+
"result": { ... }
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Plugin se tu dong match `task_id` voi job dang cho va tiep tuc pipeline.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## REST API Reference
|
|
322
|
+
|
|
323
|
+
| Action | Method | URL |
|
|
324
|
+
|--------|--------|-----|
|
|
325
|
+
| Lay config | GET | `/api/docUnderstanding:getConfig` |
|
|
326
|
+
| Cap nhat config | POST | `/api/docUnderstanding:updateConfig` |
|
|
327
|
+
| Danh sach endpoints | GET | `/api/docUnderstanding:listEndpoints` |
|
|
328
|
+
| Tao endpoint | POST | `/api/docUnderstanding:createEndpoint` |
|
|
329
|
+
| Sua endpoint | POST | `/api/docUnderstanding:updateEndpoint/{id}` |
|
|
330
|
+
| Xoa endpoint | DELETE | `/api/docUnderstanding:deleteEndpoint/{id}` |
|
|
331
|
+
| Danh sach pipelines | GET | `/api/docUnderstanding:listPipelines` |
|
|
332
|
+
| Tao pipeline | POST | `/api/docUnderstanding:createPipeline` |
|
|
333
|
+
| Sua pipeline | POST | `/api/docUnderstanding:updatePipeline/{id}` |
|
|
334
|
+
| Xoa pipeline | DELETE | `/api/docUnderstanding:deletePipeline/{id}` |
|
|
335
|
+
| Chay pipeline | POST | `/api/docUnderstanding:executePipeline` |
|
|
336
|
+
| Trang thai job | GET | `/api/docUnderstanding:getJobStatus?jobId={id}` |
|
|
337
|
+
| Danh sach jobs | GET | `/api/docUnderstanding:listJobs` |
|
|
338
|
+
| Webhook callback | POST | `/api/docUnderstanding:webhookCallback` |
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## Vi du: Pipeline OCR + Extract hoan chinh
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
1. Cau hinh Service Config:
|
|
346
|
+
Base URL: http://docai-service:8000
|
|
347
|
+
Auth Type: API Key
|
|
348
|
+
API Key: sk-my-secret-key
|
|
349
|
+
|
|
350
|
+
2. Tao 2 endpoints:
|
|
351
|
+
- "ocr": POST /ocr, Sync, Multipart
|
|
352
|
+
- "extract": POST /extract, Sync, None
|
|
353
|
+
|
|
354
|
+
3. Tao pipeline "ocr_and_extract" voi 2 steps:
|
|
355
|
+
Step 1: endpoint=ocr, outputAlias=ocr_out, onError=fail
|
|
356
|
+
Step 2: endpoint=extract, inputMapping={ "text": "$step[ocr_out].response.text" },
|
|
357
|
+
outputAlias=extract_out, onError=fail
|
|
358
|
+
|
|
359
|
+
4. Chay:
|
|
360
|
+
POST /api/docUnderstanding:executePipeline
|
|
361
|
+
{ "pipelineId": 1, "input": {} }
|
|
362
|
+
(gui file qua multipart neu can)
|
|
363
|
+
|
|
364
|
+
5. Kiem tra ket qua:
|
|
365
|
+
GET /api/docUnderstanding:getJobStatus?jobId=1
|
|
366
|
+
```
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-document-understanding",["react","@nocobase/client","@ant-design/icons","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-document-understanding"]=t(require("react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):e["@nocobase/plugin-document-understanding"]=t(e.react,e["@nocobase/client"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r){return function(){"use strict";var l={482:function(e){e.exports=n},772:function(e){e.exports=t},721:function(e){e.exports=r},156:function(t){t.exports=e}},a={};function o(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return l[e](n,n.exports,o),n.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return!function(){o.r(i),o.d(i,{default:function(){return X}});var e=o(772),t={},n=o(156),r=o.n(n),l=o(721),a=o(482);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t,n,r,l,a,o){try{var i=e[a](o),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,l)}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var a=[],o=!0,i=!1;try{for(l=l.call(e);!(o=(n=l.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==l.return||l.return()}finally{if(i)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var p=function(){var t,o,i=s(l.Form.useForm(),1)[0],u=(0,e.useAPIClient)(),p=s((0,n.useState)(!0),2),d=p[0],m=p[1],f=s((0,n.useState)(!1),2),y=f[0],h=f[1];(0,n.useEffect)(function(){u.request({url:"docUnderstanding:getConfig"}).then(function(e){var t=e.data;i.setFieldsValue((null==t?void 0:t.data)||{}),m(!1)}).catch(function(){return m(!1)})},[]);var b=(t=function(e){return function(e,t){var n,r,l,a,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var u=[a,i];if(n)throw TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(l=2&u[0]?r.return:u[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,u[1])).done)return l;switch(r=0,l&&(u=[2&u[0],l.value]),u[0]){case 0:case 1:l=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!l||u[1]>l[0]&&u[1]<l[3])){o.label=u[1];break}if(6===u[0]&&o.label<l[1]){o.label=l[1],l=u;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(u);break}l[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=l=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:h(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,u.request({url:"docUnderstanding:updateConfig",method:"POST",data:e})];case 2:return t.sent(),l.message.success("Configuration saved successfully"),[3,5];case 3:return t.sent(),l.message.error("Failed to save config"),[3,5];case 4:return h(!1),[7];case 5:return[2]}})},o=function(){var e=this,n=arguments;return new Promise(function(r,l){var a=t.apply(e,n);function o(e){c(a,r,l,o,i,"next",e)}function i(e){c(a,r,l,o,i,"throw",e)}o(void 0)})},function(e){return o.apply(this,arguments)});return d?r().createElement(l.Spin,{style:{marginTop:40}}):r().createElement(l.Form,{form:i,layout:"vertical",onFinish:b,style:{maxWidth:600}},r().createElement(l.Alert,{message:"Service Connection",description:"Configure the connection to your external document processing service. All endpoints will use this base URL and authentication.",type:"info",showIcon:!0,style:{marginBottom:24}}),r().createElement(l.Form.Item,{name:"baseUrl",label:"Base URL",rules:[{required:!0,message:"Base URL is required"}],help:"The root URL of your document processing API"},r().createElement(l.Input,{prefix:r().createElement(a.LinkOutlined,null),placeholder:"http://my-ocr-service:8000"})),r().createElement(l.Form.Item,{name:"authType",label:"Authentication Type",initialValue:"none"},r().createElement(l.Select,null,r().createElement(l.Select.Option,{value:"none"},"None"),r().createElement(l.Select.Option,{value:"api_key"},"API Key"),r().createElement(l.Select.Option,{value:"bearer"},"Bearer Token"),r().createElement(l.Select.Option,{value:"custom_header"},"Custom Header"))),r().createElement(l.Form.Item,{noStyle:!0,dependencies:["authType"]},function(){var e=i.getFieldValue("authType");return"none"===e?null:r().createElement(r().Fragment,null,"custom_header"===e&&r().createElement(l.Form.Item,{name:"authHeaderName",label:"Custom Header Name",rules:[{required:!0}]},r().createElement(l.Input,{placeholder:"X-Api-Key"})),r().createElement(l.Form.Item,{name:"authKey",label:"bearer"===e?"Bearer Token":"API Key",rules:[{required:!0}]},r().createElement(l.Input.Password,{placeholder:"Enter key or token"})))}),r().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},r().createElement(l.Form.Item,{name:"defaultTimeout",label:"Request Timeout (ms)",initialValue:3e4},r().createElement(l.InputNumber,{style:{width:"100%"},min:1e3,step:1e3})),r().createElement(l.Form.Item,{name:"defaultRetries",label:"Default Retries",initialValue:2},r().createElement(l.InputNumber,{style:{width:"100%"},min:0,max:10})),r().createElement(l.Form.Item,{name:"pollInterval",label:"Poll Interval (ms)",initialValue:5e3},r().createElement(l.InputNumber,{style:{width:"100%"},min:1e3,step:1e3})),r().createElement(l.Form.Item,{name:"pollTimeout",label:"Poll Timeout (ms)",initialValue:3e5},r().createElement(l.InputNumber,{style:{width:"100%"},min:5e3,step:5e3}))),r().createElement(l.Form.Item,{name:"webhookSecret",label:"Webhook Secret",help:"Used to verify HMAC-SHA256 signatures on incoming webhook callbacks"},r().createElement(l.Input.Password,{placeholder:"Optional: secret for webhook signature verification"})),r().createElement(l.Form.Item,null,r().createElement(l.Button,{type:"primary",htmlType:"submit",icon:r().createElement(a.SaveOutlined,null),loading:y},"Save Configuration")))};function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,l,a,o){try{var i=e[a](o),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,l)}function f(e){return function(){var t=this,n=arguments;return new Promise(function(r,l){var a=e.apply(t,n);function o(e){m(a,r,l,o,i,"next",e)}function i(e){m(a,r,l,o,i,"throw",e)}o(void 0)})}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var a=[],o=!0,i=!1;try{for(l=l.call(e);!(o=(n=l.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==l.return||l.return()}finally{if(i)throw r}}return a}}(e,t)||b(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||b(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}}function g(e,t){var n,r,l,a,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var u=[a,i];if(n)throw TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(l=2&u[0]?r.return:u[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,u[1])).done)return l;switch(r=0,l&&(u=[2&u[0],l.value]),u[0]){case 0:case 1:l=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!l||u[1]>l[0]&&u[1]<l[3])){o.label=u[1];break}if(6===u[0]&&o.label<l[1]){o.label=l[1],l=u;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(u);break}l[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=l=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var E=l.Input.TextArea,v=function(e){var t=e.value,n=void 0===t?{}:t,o=e.onChange,i=Object.entries(n),u=function(e,t,n){var r=h(i);r[e]=[t,n],null==o||o(Object.fromEntries(r))},c=function(e){var t=h(i);t.splice(e,1),null==o||o(Object.fromEntries(t))};return r().createElement("div",null,i.map(function(e,t){var n=y(e,2),o=n[0],i=n[1];return r().createElement(l.Space,{key:t,style:{display:"flex",marginBottom:4}},r().createElement(l.Input,{placeholder:"Header name",value:o,onChange:function(e){return u(t,e.target.value,i)},style:{width:180}}),r().createElement(l.Input,{placeholder:"Value",value:i,onChange:function(e){return u(t,o,e.target.value)},style:{width:220}}),r().createElement(l.Button,{size:"small",danger:!0,icon:r().createElement(a.DeleteOutlined,null),onClick:function(){return c(t)}}))}),r().createElement(l.Button,{size:"small",type:"dashed",icon:r().createElement(a.PlusOutlined,null),onClick:function(){var e,t;return null==o?void 0:o((e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},n),t=t={"":""},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e))}},"Add Header"))},S=function(e){var t=e.value,l=e.onChange,a=e.placeholder,o=y((0,n.useState)(""),2),i=o[0],u=o[1],c=y((0,n.useState)(""),2),s=c[0],p=c[1];return(0,n.useEffect)(function(){u(t?JSON.stringify(t,null,2):"")},[]),r().createElement("div",null,r().createElement(E,{rows:6,value:i,onChange:function(e){return u(e.target.value)},onBlur:function(){if(!i.trim()){p(""),null==l||l(null);return}try{var e=JSON.parse(i);p(""),null==l||l(e)}catch(e){p("Invalid JSON")}},placeholder:a||"{}",style:{fontFamily:"monospace",fontSize:12}}),s&&r().createElement("div",{style:{color:"#ff4d4f",fontSize:12}},s))},w=function(){var t,o,i,u=(0,e.useAPIClient)(),c=y((0,n.useState)([]),2),s=c[0],p=c[1],d=y((0,n.useState)(!1),2),m=d[0],h=d[1],b=y((0,n.useState)(!1),2),w=b[0],O=b[1],I=y(l.Form.useForm(),1)[0],k=y((0,n.useState)(null),2),T=k[0],x=k[1],P=(t=f(function(){var e;return g(this,function(t){switch(t.label){case 0:h(!0),t.label=1;case 1:return t.trys.push([1,,3,4]),[4,u.request({url:"docUnderstanding:listEndpoints"})];case 2:return p((null==(e=t.sent().data)?void 0:e.data)||[]),[3,4];case 3:return h(!1),[7];case 4:return[2]}})}),function(){return t.apply(this,arguments)});(0,n.useEffect)(function(){P()},[]);var C=function(e){x(e.id),I.setFieldsValue(e),O(!0)},F=(o=f(function(e){return g(this,function(t){switch(t.label){case 0:return[4,u.request({url:"docUnderstanding:deleteEndpoint",method:"POST",params:{filterByTk:e}})];case 1:return t.sent(),l.message.success("Deleted"),P(),[2]}})}),function(e){return o.apply(this,arguments)}),A=(i=f(function(){var e;return g(this,function(t){switch(t.label){case 0:return t.trys.push([0,6,,7]),[4,I.validateFields()];case 1:if(e=t.sent(),!T)return[3,3];return[4,u.request({url:"docUnderstanding:updateEndpoint",method:"POST",params:{filterByTk:T},data:e})];case 2:return t.sent(),[3,5];case 3:return[4,u.request({url:"docUnderstanding:createEndpoint",method:"POST",data:e})];case 4:t.sent(),t.label=5;case 5:return l.message.success("Saved"),O(!1),P(),[3,7];case 6:return t.sent(),[3,7];case 7:return[2]}})}),function(){return i.apply(this,arguments)}),j=[{title:"Name",dataIndex:"name",width:150},{title:"Subpath",dataIndex:"subpath",width:200},{title:"Method",dataIndex:"method",width:80,render:function(e){return r().createElement(l.Tag,null,e)}},{title:"Execution",dataIndex:"executionMode",width:100,render:function(e){return r().createElement(l.Tag,{color:{sync:"green",polling:"blue",webhook:"purple"}[e]},e)}},{title:"File",dataIndex:"fileInputMode",width:90,render:function(e){return"none"===e?"-":e}},{title:"Enabled",dataIndex:"enabled",width:70,render:function(e){return e?r().createElement(l.Tag,{color:"success"},"Yes"):r().createElement(l.Tag,null,"No")}},{title:"Action",width:120,render:function(e,t){return r().createElement(l.Space,null,r().createElement(l.Button,{type:"link",size:"small",icon:r().createElement(a.EditOutlined,null),onClick:function(){return C(t)}},"Edit"),r().createElement(l.Popconfirm,{title:"Delete this endpoint?",onConfirm:function(){return F(t.id)}},r().createElement(l.Button,{type:"link",size:"small",danger:!0,icon:r().createElement(a.DeleteOutlined,null)},"Delete")))}}];return r().createElement("div",null,r().createElement("div",{style:{marginBottom:16}},r().createElement(l.Button,{type:"primary",icon:r().createElement(a.PlusOutlined,null),onClick:function(){x(null),I.resetFields(),O(!0)}},"Add Endpoint")),r().createElement(l.Table,{rowKey:"id",columns:j,dataSource:s,loading:m,size:"small"}),r().createElement(l.Modal,{title:T?"Edit Endpoint":"Add Endpoint",open:w,onOk:A,onCancel:function(){return O(!1)},width:680,destroyOnClose:!0},r().createElement(l.Form,{form:I,layout:"vertical",preserve:!1},r().createElement(l.Tabs,{size:"small",items:[{key:"basic",label:"Basic",children:r().createElement(r().Fragment,null,r().createElement(l.Form.Item,{name:"name",label:"Unique Name",rules:[{required:!0}]},r().createElement(l.Input,{placeholder:"ocr, classify, extract..."})),r().createElement(l.Form.Item,{name:"subpath",label:"Subpath",rules:[{required:!0}]},r().createElement(l.Input,{placeholder:"/api/v1/ocr"})),r().createElement(l.Form.Item,{name:"description",label:"Description"},r().createElement(E,{rows:2,placeholder:"What this endpoint does"})),r().createElement(l.Space,{size:"large"},r().createElement(l.Form.Item,{name:"method",label:"HTTP Method",initialValue:"POST"},r().createElement(l.Select,{style:{width:120}},r().createElement(l.Select.Option,{value:"GET"},"GET"),r().createElement(l.Select.Option,{value:"POST"},"POST"),r().createElement(l.Select.Option,{value:"PUT"},"PUT"))),r().createElement(l.Form.Item,{name:"enabled",label:"Enabled",valuePropName:"checked",initialValue:!0},r().createElement(l.Switch,null))))},{key:"file",label:"File Input",children:r().createElement(r().Fragment,null,r().createElement(l.Form.Item,{name:"fileInputMode",label:"File Input Mode",initialValue:"none"},r().createElement(l.Select,{style:{width:200}},r().createElement(l.Select.Option,{value:"none"},"None"),r().createElement(l.Select.Option,{value:"multipart"},"Multipart Upload"),r().createElement(l.Select.Option,{value:"base64"},"Base64 in JSON"))),r().createElement(l.Form.Item,{noStyle:!0,dependencies:["fileInputMode"]},function(){return"none"!==I.getFieldValue("fileInputMode")?r().createElement(l.Form.Item,{name:"maxFiles",label:"Max Files",initialValue:1},r().createElement(l.InputNumber,{min:1,max:20,style:{width:120}})):null}))},{key:"async",label:"Async Config",children:r().createElement(r().Fragment,null,r().createElement(l.Form.Item,{name:"executionMode",label:"Execution Mode",initialValue:"sync"},r().createElement(l.Select,{style:{width:200}},r().createElement(l.Select.Option,{value:"sync"},"Synchronous"),r().createElement(l.Select.Option,{value:"polling"},"Polling"),r().createElement(l.Select.Option,{value:"webhook"},"Webhook"))),r().createElement(l.Form.Item,{noStyle:!0,dependencies:["executionMode"]},function(){var e=I.getFieldValue("executionMode");return"sync"===e?null:r().createElement(r().Fragment,null,r().createElement(l.Form.Item,{name:"pollTaskIdField",label:"Task ID Field",help:"Field in response containing the async task ID",initialValue:"task_id"},r().createElement(l.Input,{placeholder:"task_id"})),"polling"===e&&r().createElement(r().Fragment,null,r().createElement(l.Form.Item,{name:"pollResultSubpath",label:"Poll Result Subpath",help:"URL to poll for result. Use {taskId} as placeholder.",rules:[{required:!0,message:"Required for polling mode"}]},r().createElement(l.Input,{placeholder:"/api/v1/tasks/{taskId}/result"})),r().createElement(l.Form.Item,{name:"pollResultField",label:"Result Field",help:"Field in poll response containing the actual result"},r().createElement(l.Input,{placeholder:"result"})),r().createElement(l.Form.Item,{name:"pollStatusField",label:"Status Field (optional)",help:"Field to check completion status. If empty, any non-null result = complete."},r().createElement(l.Input,{placeholder:"status"})),r().createElement(l.Form.Item,{name:"pollCompletedValue",label:"Completed Value",help:"Value of status field that means 'done'",initialValue:"completed"},r().createElement(l.Input,{placeholder:"completed"})),r().createElement(l.Space,{size:"large"},r().createElement(l.Form.Item,{name:"pollInterval",label:"Poll Interval (ms)",help:"Override default"},r().createElement(l.InputNumber,{min:1e3,step:1e3,placeholder:"5000",style:{width:150}})),r().createElement(l.Form.Item,{name:"pollTimeout",label:"Poll Timeout (ms)",help:"Override default"},r().createElement(l.InputNumber,{min:5e3,step:5e3,placeholder:"300000",style:{width:150}})))))}))},{key:"schema",label:"Schema",children:r().createElement(r().Fragment,null,r().createElement(l.Form.Item,{name:"requestBodySchema",label:"Request Body Schema (JSON Schema)"},r().createElement(S,{placeholder:'{ "type": "object", "properties": { ... } }'})),r().createElement(l.Form.Item,{name:"responseSchema",label:"Response Schema (JSON Schema)"},r().createElement(S,{placeholder:'{ "type": "object", "properties": { ... } }'})))},{key:"headers",label:"Custom Headers",children:r().createElement(l.Form.Item,{name:"customHeaders",label:"Additional Headers"},r().createElement(v,null))}]}))))};function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function I(e,t,n,r,l,a,o){try{var i=e[a](o),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,l)}function k(e){return function(){var t=this,n=arguments;return new Promise(function(r,l){var a=e.apply(t,n);function o(e){I(a,r,l,o,i,"next",e)}function i(e){I(a,r,l,o,i,"throw",e)}o(void 0)})}}function T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function x(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function P(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var a=[],o=!0,i=!1;try{for(l=l.call(e);!(o=(n=l.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==l.return||l.return()}finally{if(i)throw r}}return a}}(e,t)||F(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||F(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return O(e,t)}}function A(e,t){var n,r,l,a,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var u=[a,i];if(n)throw TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(l=2&u[0]?r.return:u[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,u[1])).done)return l;switch(r=0,l&&(u=[2&u[0],l.value]),u[0]){case 0:case 1:l=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!l||u[1]>l[0]&&u[1]<l[3])){o.label=u[1];break}if(6===u[0]&&o.label<l[1]){o.label=l[1],l=u;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(u);break}l[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=l=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var j=l.Input.TextArea,B=l.Collapse.Panel,M=function(e){var t=e.value,l=e.onChange,a=e.placeholder,o=e.rows,i=P((0,n.useState)(""),2),u=i[0],c=i[1],s=P((0,n.useState)(""),2),p=s[0],d=s[1];return(0,n.useEffect)(function(){c(t?JSON.stringify(t,null,2):"")},[]),r().createElement("div",null,r().createElement(j,{rows:void 0===o?5:o,value:u,onChange:function(e){return c(e.target.value)},onBlur:function(){if(!u.trim()){d(""),null==l||l(null);return}try{var e=JSON.parse(u);d(""),null==l||l(e)}catch(e){d("Invalid JSON")}},placeholder:a||"{}",style:{fontFamily:"monospace",fontSize:12}}),p&&r().createElement("div",{style:{color:"#ff4d4f",fontSize:12}},p))},N=function(e){var t=e.steps,n=e.endpoints,o=e.onChange,i=function(e,n){var r,l=C(t),a=e+n;a<0||a>=l.length||(r=[l[a],l[e]],l[e]=r[0],l[a]=r[1],l.forEach(function(e,t){return e.stepOrder=t+1}),o(l))},u=function(e,n,r){var l=C(t);l[e][n]=r,o(l)},c=function(e){var n=t.filter(function(t,n){return n!==e});n.forEach(function(e,t){return e.stepOrder=t+1}),o(n)},s=function(){var e;o(C(t).concat([(e=t.length+1,{_key:"new_".concat(Date.now(),"_").concat(Math.random()),stepOrder:e,name:"",endpointId:null,inputMapping:null,outputAlias:"",condition:null,onError:"fail",retryCount:0})]))};return 0===t.length?r().createElement("div",{style:{textAlign:"center",padding:"20px 0"}},r().createElement(l.Empty,{description:"No steps yet",imageStyle:{height:40}}),r().createElement(l.Button,{type:"dashed",icon:r().createElement(a.PlusOutlined,null),onClick:s,style:{marginTop:8}},"Add First Step")):r().createElement("div",null,r().createElement(l.Collapse,{size:"small",defaultActiveKey:t.map(function(e){return e._key})},t.map(function(e,o){var s=n.find(function(t){return t.id===e.endpointId}),p=r().createElement(l.Space,{size:4,onClick:function(e){return e.stopPropagation()}},r().createElement(l.Button,{size:"small",disabled:0===o,icon:r().createElement(a.ArrowUpOutlined,null),onClick:function(){return i(o,-1)}}),r().createElement(l.Button,{size:"small",disabled:o===t.length-1,icon:r().createElement(a.ArrowDownOutlined,null),onClick:function(){return i(o,1)}}),r().createElement(l.Popconfirm,{title:"Remove step?",onConfirm:function(){return c(o)}},r().createElement(l.Button,{size:"small",danger:!0,icon:r().createElement(a.DeleteOutlined,null)}))),d=r().createElement(l.Space,null,r().createElement(l.Badge,{count:e.stepOrder,style:{backgroundColor:"#1677ff"}}),r().createElement("span",null,e.name||"(unnamed)"),s&&r().createElement(l.Tag,null,s.name),"skip"===e.onError&&r().createElement(l.Tooltip,{title:"Step can be skipped on error"},r().createElement(l.Tag,{color:"orange"},"skip on error")),e.condition&&r().createElement(l.Tooltip,{title:"Has condition"},r().createElement(l.Tag,{color:"purple"},"conditional")));return r().createElement(B,{key:e._key,header:d,extra:p},r().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},r().createElement("div",null,r().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4}},"Step Name *"),r().createElement(l.Input,{value:e.name,onChange:function(e){return u(o,"name",e.target.value)},placeholder:"OCR, Classify, Extract..."})),r().createElement("div",null,r().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4}},"Endpoint *"),r().createElement(l.Select,{value:e.endpointId,onChange:function(e){return u(o,"endpointId",e)},placeholder:"Select endpoint",style:{width:"100%"},options:n.map(function(e){return{value:e.id,label:"".concat(e.name," (").concat(e.method," ").concat(e.subpath,")")}})})),r().createElement("div",null,r().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4,marginTop:12}},"Output Alias"),r().createElement(l.Input,{value:e.outputAlias,onChange:function(e){return u(o,"outputAlias",e.target.value)},placeholder:"ocr_result"}),r().createElement("div",{style:{color:"#888",fontSize:11}},"Other steps reference this as: $step[",e.outputAlias||e.stepOrder,"].response.field")),r().createElement("div",null,r().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4,marginTop:12}},"On Error"),r().createElement(l.Space,null,r().createElement(l.Select,{value:e.onError,onChange:function(e){return u(o,"onError",e)},style:{width:120}},r().createElement(l.Select.Option,{value:"fail"},"Fail"),r().createElement(l.Select.Option,{value:"skip"},"Skip"),r().createElement(l.Select.Option,{value:"retry"},"Retry")),"retry"===e.onError&&r().createElement(l.InputNumber,{value:e.retryCount,onChange:function(e){return u(o,"retryCount",e||0)},min:1,max:10,addonBefore:"x",style:{width:100}})))),r().createElement("div",{style:{marginTop:12}},r().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4}},"Input Mapping (JSON)",r().createElement(l.Tooltip,{title:"Map endpoint input fields. Use $input.field, $step[alias].response.field, $files, or literal values."},r().createElement("span",{style:{fontWeight:"normal",color:"#888",marginLeft:6,cursor:"help"}},"?"))),r().createElement(M,{value:e.inputMapping,onChange:function(e){return u(o,"inputMapping",e)},placeholder:'{ "text": "$step[ocr_result].response.text", "lang": "vi" }',rows:3})),r().createElement("div",{style:{marginTop:12}},r().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4}},"Condition (optional JSON)",r().createElement(l.Tooltip,{title:'Only run this step if condition matches. Format: { "field": "$step[x].response.y", "op": "eq", "value": "..." }'},r().createElement("span",{style:{fontWeight:"normal",color:"#888",marginLeft:6,cursor:"help"}},"?"))),r().createElement(M,{value:e.condition,onChange:function(e){return u(o,"condition",e)},placeholder:'{ "field": "$step[classify].response.type", "op": "eq", "value": "invoice" }',rows:2})))})),r().createElement(l.Button,{type:"dashed",icon:r().createElement(a.PlusOutlined,null),onClick:s,style:{marginTop:8,width:"100%"}},"Add Step"))},q=function(){var t,o,i=(0,e.useAPIClient)(),u=P((0,n.useState)([]),2),c=u[0],s=u[1],p=P((0,n.useState)([]),2),d=p[0],m=p[1],f=P((0,n.useState)(!1),2),y=f[0],h=f[1],b=P((0,n.useState)(!1),2),g=b[0],E=b[1],v=P(l.Form.useForm(),1)[0],S=P((0,n.useState)(null),2),w=S[0],O=S[1],I=P((0,n.useState)([]),2),F=I[0],q=I[1],R=(0,n.useCallback)(k(function(){var e,t,n,r,l;return A(this,function(a){switch(a.label){case 0:h(!0),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,Promise.all([i.request({url:"docUnderstanding:listPipelines"}),i.request({url:"docUnderstanding:listEndpoints"})])];case 2:return r=(n=P.apply(void 0,[a.sent(),2]))[0],l=n[1],s((null==(e=r.data)?void 0:e.data)||[]),m((null==(t=l.data)?void 0:t.data)||[]),[3,4];case 3:return h(!1),[7];case 4:return[2]}})}),[i]);(0,n.useEffect)(function(){R()},[R]);var D=function(e){O(e.id),v.setFieldsValue({name:e.name,description:e.description,enabled:e.enabled,inputSchema:e.inputSchema,outputMapping:e.outputMapping}),q(C(e.steps||[]).sort(function(e,t){return e.stepOrder-t.stepOrder}).map(function(e){return{_key:"srv_".concat(e.id),id:e.id,stepOrder:e.stepOrder,name:e.name,endpointId:e.endpointId,inputMapping:e.inputMapping,outputAlias:e.outputAlias||"",condition:e.condition,onError:e.onError||"fail",retryCount:e.retryCount||0}})),E(!0)},U=(t=k(function(e){return A(this,function(t){switch(t.label){case 0:return[4,i.request({url:"docUnderstanding:deletePipeline",method:"POST",params:{filterByTk:e}})];case 1:return t.sent(),l.message.success("Deleted"),R(),[2]}})}),function(e){return t.apply(this,arguments)}),_=(o=k(function(){var e,t,n,r,a,o,u,c,s;return A(this,function(p){switch(p.label){case 0:return p.trys.push([0,6,,7]),[4,v.validateFields()];case 1:e=p.sent(),t=!0,n=!1,r=void 0;try{for(a=F[Symbol.iterator]();!(t=(o=a.next()).done);t=!0){if(!(u=o.value).name)return l.message.error("All steps must have a name"),[2];if(!u.endpointId)return l.message.error('Step "'.concat(u.name||u.stepOrder,'" must have an endpoint')),[2]}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}if(new Set(c=F.map(function(e){return e.outputAlias}).filter(Boolean)).size!==c.length)return l.message.error("Step output aliases must be unique"),[2];if(s=x(T({},e),{steps:F.map(function(e){return x(T({},e.id?{id:e.id}:{}),{stepOrder:e.stepOrder,name:e.name,endpointId:e.endpointId,inputMapping:e.inputMapping,outputAlias:e.outputAlias||void 0,condition:e.condition,onError:e.onError,retryCount:"retry"===e.onError?e.retryCount:0})})}),!w)return[3,3];return[4,i.request({url:"docUnderstanding:updatePipeline",method:"POST",params:{filterByTk:w},data:s})];case 2:return p.sent(),[3,5];case 3:return[4,i.request({url:"docUnderstanding:createPipeline",method:"POST",data:s})];case 4:p.sent(),p.label=5;case 5:return l.message.success("Saved"),E(!1),R(),[3,7];case 6:return p.sent(),[3,7];case 7:return[2]}})}),function(){return o.apply(this,arguments)}),z=[{title:"Name",dataIndex:"name",width:200},{title:"Steps",dataIndex:"steps",width:300,render:function(e){if(!e||0===e.length)return r().createElement(l.Tag,null,"0 steps");var t=C(e).sort(function(e,t){return e.stepOrder-t.stepOrder});return r().createElement(l.Space,{size:2,wrap:!0},t.map(function(e,t){return r().createElement(r().Fragment,{key:e.id},t>0&&r().createElement("span",{style:{color:"#ccc"}},"→"),r().createElement(l.Tag,null,e.name||"Step ".concat(e.stepOrder)))}))}},{title:"Enabled",dataIndex:"enabled",width:80,render:function(e){return e?r().createElement(l.Tag,{color:"success"},"Yes"):r().createElement(l.Tag,null,"No")}},{title:"AI Tool",width:100,render:function(e,t){var n;return t.enabled?r().createElement(l.Tooltip,{title:"Registered as: doc_understanding.".concat(null==(n=t.name)?void 0:n.toLowerCase().replace(/[^a-z0-9_]/g,"_"))},r().createElement(l.Tag,{color:"blue",icon:r().createElement(a.ThunderboltOutlined,null)},"Active")):r().createElement(l.Tag,null,"Inactive")}},{title:"Action",width:120,render:function(e,t){return r().createElement(l.Space,null,r().createElement(l.Button,{type:"link",size:"small",icon:r().createElement(a.EditOutlined,null),onClick:function(){return D(t)}},"Edit"),r().createElement(l.Popconfirm,{title:"Delete this pipeline?",onConfirm:function(){return U(t.id)}},r().createElement(l.Button,{type:"link",size:"small",danger:!0,icon:r().createElement(a.DeleteOutlined,null)},"Delete")))}}];return r().createElement("div",null,r().createElement("div",{style:{marginBottom:16}},r().createElement(l.Button,{type:"primary",icon:r().createElement(a.PlusOutlined,null),onClick:function(){O(null),v.resetFields(),q([]),E(!0)}},"Add Pipeline")),r().createElement(l.Table,{rowKey:"id",columns:z,dataSource:c,loading:y,size:"small"}),r().createElement(l.Modal,{title:w?"Edit Pipeline":"New Pipeline",open:g,onOk:_,onCancel:function(){return E(!1)},width:800,destroyOnClose:!0},r().createElement(l.Form,{form:v,layout:"vertical",preserve:!1},r().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},r().createElement(l.Form.Item,{name:"name",label:"Pipeline Name",rules:[{required:!0}]},r().createElement(l.Input,{placeholder:"full_document_processing"})),r().createElement(l.Form.Item,{name:"enabled",label:"Enabled",valuePropName:"checked",initialValue:!0},r().createElement(l.Switch,null))),r().createElement(l.Form.Item,{name:"description",label:"Description"},r().createElement(j,{rows:2,placeholder:"What this pipeline does"})),r().createElement(l.Card,{title:"Pipeline Steps",size:"small",style:{marginBottom:16},extra:r().createElement(l.Tag,{color:"blue"},F.length," step(s)")},r().createElement(N,{steps:F,endpoints:d,onChange:q})),r().createElement(l.Collapse,{size:"small",ghost:!0},r().createElement(B,{header:"Advanced: Input Schema & Output Mapping",key:"advanced"},r().createElement(l.Form.Item,{name:"inputSchema",label:"Input Schema (JSON Schema)",help:"Defines what input this pipeline accepts. Used by AI tool schema."},r().createElement(M,{placeholder:'{ "type": "object", "properties": { "document_url": { "type": "string" } }, "required": ["document_url"] }'})),r().createElement(l.Form.Item,{name:"outputMapping",label:"Output Mapping (JSON)",help:"Map final step results to pipeline output. If empty, all step results are returned."},r().createElement(M,{placeholder:'{ "text": "$step[ocr_result].response.text", "category": "$step[classify].response.category" }'})))))))};function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function D(e,t,n,r,l,a,o){try{var i=e[a](o),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,l)}function U(e){return function(){var t=this,n=arguments;return new Promise(function(r,l){var a=e.apply(t,n);function o(e){D(a,r,l,o,i,"next",e)}function i(e){D(a,r,l,o,i,"throw",e)}o(void 0)})}}function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var a=[],o=!0,i=!1;try{for(l=l.call(e);!(o=(n=l.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==l.return||l.return()}finally{if(i)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return R(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function z(e,t){var n,r,l,a,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var u=[a,i];if(n)throw TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(l=2&u[0]?r.return:u[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,u[1])).done)return l;switch(r=0,l&&(u=[2&u[0],l.value]),u[0]){case 0:case 1:l=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!l||u[1]>l[0]&&u[1]<l[3])){o.label=u[1];break}if(6===u[0]&&o.label<l[1]){o.label=l[1],l=u;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(u);break}l[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=l=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var V={pending:{color:"default",label:"Pending"},running:{color:"processing",label:"Running"},polling:{color:"processing",label:"Polling"},completed:{color:"success",label:"Completed"},failed:{color:"error",label:"Failed"},timeout:{color:"error",label:"Timeout"}},J=function(){var t,o,i=(0,e.useAPIClient)(),u=_((0,n.useState)([]),2),c=u[0],s=u[1],p=_((0,n.useState)([]),2),d=p[0],m=p[1],f=_((0,n.useState)(!1),2),y=f[0],h=f[1],b=_((0,n.useState)(!1),2),g=b[0],E=b[1],v=_((0,n.useState)(null),2),S=v[0],w=v[1],O=_((0,n.useState)(void 0),2),I=O[0],k=O[1],T=_((0,n.useState)(void 0),2),x=T[0],P=T[1],C=(0,n.useCallback)(U(function(){var e,t;return z(this,function(n){switch(n.label){case 0:h(!0),n.label=1;case 1:return n.trys.push([1,,3,4]),t={},I&&(t.status=I),x&&(t.pipelineId=x),[4,i.request({url:"docUnderstanding:listJobs",params:{filter:Object.keys(t).length>0?t:void 0}})];case 2:return s((null==(e=n.sent().data)?void 0:e.data)||[]),[3,4];case 3:return h(!1),[7];case 4:return[2]}})}),[i,I,x]),F=(0,n.useCallback)(U(function(){var e;return z(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,i.request({url:"docUnderstanding:listPipelines"})];case 1:return m((null==(e=t.sent().data)?void 0:e.data)||[]),[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}})}),[i]);(0,n.useEffect)(function(){F()},[F]),(0,n.useEffect)(function(){C();var e=setInterval(C,1e4);return function(){return clearInterval(e)}},[C]);var A=new Map(d.map(function(e){return[e.id,e.name]})),j=(t=U(function(e){var t;return z(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,i.request({url:"docUnderstanding:getJobStatus",params:{filterByTk:e.id}})];case 1:return w((null==(t=n.sent().data)?void 0:t.data)||e),[3,3];case 2:return n.sent(),w(e),[3,3];case 3:return E(!0),[2]}})}),function(e){return t.apply(this,arguments)}),B=[{title:"ID",dataIndex:"id",width:60},{title:"Pipeline",dataIndex:"pipelineId",width:180,render:function(e){return A.get(e)||"#".concat(e)}},{title:"Status",dataIndex:"status",width:100,render:function(e){var t=V[e]||{color:"default",label:e};return r().createElement(l.Tag,{color:t.color},t.label)}},{title:"Current Step",dataIndex:"currentStep",width:90,render:function(e,t){return"completed"===t.status?r().createElement(l.Tag,{color:"success"},"Done"):"failed"===t.status?r().createElement(l.Tag,{color:"error"},"Step ",e):r().createElement(l.Badge,{status:"processing",text:"Step ".concat(e)})}},{title:"Started",dataIndex:"startedAt",width:160,render:function(e){return e?new Date(e).toLocaleString():"-"}},{title:"Completed",dataIndex:"completedAt",width:160,render:function(e){return e?new Date(e).toLocaleString():"-"}},{title:"Action",width:80,render:function(e,t){return r().createElement(l.Button,{size:"small",icon:r().createElement(a.EyeOutlined,null),onClick:function(){return j(t)}},"View")}}];return r().createElement("div",null,r().createElement(l.Space,{style:{marginBottom:16},wrap:!0},r().createElement(l.Select,{allowClear:!0,placeholder:"Filter by status",value:I,onChange:k,style:{width:160},options:Object.entries(V).map(function(e){var t=_(e,2);return{value:t[0],label:t[1].label}})}),r().createElement(l.Select,{allowClear:!0,placeholder:"Filter by pipeline",value:x,onChange:P,style:{width:200},options:d.map(function(e){return{value:e.id,label:e.name}})}),r().createElement(l.Button,{icon:r().createElement(a.ReloadOutlined,null),onClick:C},"Refresh")),r().createElement(l.Table,{rowKey:"id",columns:B,dataSource:c,loading:y,size:"small",pagination:{pageSize:20}}),r().createElement(l.Drawer,{title:S?"Job #".concat(S.id," — ").concat(A.get(S.pipelineId)||"Unknown"):"Job Details",width:640,open:g,onClose:function(){return E(!1)}},S&&r().createElement("div",null,r().createElement("div",{style:{marginBottom:16}},r().createElement(l.Space,null,r().createElement(l.Tag,{color:null==(o=V[S.status])?void 0:o.color},S.status),S.startedAt&&r().createElement("span",null,"Started: ",new Date(S.startedAt).toLocaleString()),S.completedAt&&r().createElement("span",null,"Completed: ",new Date(S.completedAt).toLocaleString()))),S.error&&r().createElement("div",{style:{background:"#fff2f0",border:"1px solid #ffccc7",borderRadius:6,padding:12,marginBottom:16}},r().createElement("strong",{style:{color:"#cf1322"}},"Error:"),r().createElement("pre",{style:{margin:"4px 0 0",whiteSpace:"pre-wrap",color:"#cf1322"}},S.error)),r().createElement("h4",null,"Input"),r().createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:6,fontSize:12,maxHeight:200,overflow:"auto"}},JSON.stringify(S.input,null,2)),r().createElement("h4",{style:{marginTop:16}},"Step Results"),S.stepResults&&Object.keys(S.stepResults).length>0?Object.entries(S.stepResults).map(function(e){var t=_(e,2),n=t[0],a=t[1];return r().createElement("div",{key:n,style:{marginBottom:8}},r().createElement(l.Tag,{color:"blue"},n),r().createElement("pre",{style:{background:"#f5f5f5",padding:8,borderRadius:4,fontSize:11,maxHeight:150,overflow:"auto",marginTop:4}},JSON.stringify(a,null,2)))}):r().createElement("div",{style:{color:"#999"}},"No step results yet"),r().createElement("h4",{style:{marginTop:16}},"Final Result"),r().createElement("pre",{style:{background:"#f0f5ff",padding:12,borderRadius:6,fontSize:12,maxHeight:300,overflow:"auto"}},S.finalResult?JSON.stringify(S.finalResult,null,2):"(not yet available)"),S.externalTaskIds&&Object.keys(S.externalTaskIds).length>0&&r().createElement(r().Fragment,null,r().createElement("h4",{style:{marginTop:16}},"External Task IDs"),r().createElement("pre",{style:{background:"#f5f5f5",padding:8,borderRadius:4,fontSize:11}},JSON.stringify(S.externalTaskIds,null,2))))))},H=function(){return r().createElement("div",{style:{backgroundColor:"var(--nb-box-bg)",minHeight:"100vh"}},r().createElement(e.PageHeader,{title:"Document Understanding - Pipeline Orchestrator"}),r().createElement("div",{style:{padding:"0 24px 24px"}},r().createElement(l.Tabs,{defaultActiveKey:"config",items:[{key:"config",label:"Service Config",children:r().createElement(p,null)},{key:"endpoints",label:"Endpoints",children:r().createElement(w,null)},{key:"pipelines",label:"Pipelines",children:r().createElement(q,null)},{key:"jobs",label:"Jobs history",children:r().createElement(J,null)}]})))};function L(e,t,n,r,l,a,o){try{var i=e[a](o),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,l)}function W(e,t,n){return(W=Y()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var l=new(Function.bind.apply(e,r));return n&&K(l,n.prototype),l}).apply(null,arguments)}function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function K(e,t){return(K=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t="function"==typeof Map?new Map:void 0;return(G=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return W(e,arguments,$(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),K(n,e)})(e)}function Y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Y=function(){return!!e})()}var X=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=$(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,Y()?Reflect.construct(e,t||[],$(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&K(r,e),n=[{key:"load",value:function(){var e,n=this;return(e=function(){var e;return function(e,t){var n,r,l,a,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var u=[a,i];if(n)throw TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(l=2&u[0]?r.return:u[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,u[1])).done)return l;switch(r=0,l&&(u=[2&u[0],l.value]),u[0]){case 0:case 1:l=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!l||u[1]>l[0]&&u[1]<l[3])){o.label=u[1];break}if(6===u[0]&&o.label<l[1]){o.label=l[1],l=u;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(u);break}l[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=l=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){return null==(e=n.flowEngine)||e.registerModels(t),n.app.pluginSettingsManager.add("@nocobase/plugin-document-understanding",{title:"Document Understanding",icon:"FileOutlined",Component:H}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,l){var a=e.apply(t,n);function o(e){L(a,r,l,o,i,"next",e)}function i(e){L(a,r,l,o,i,"throw",e)}o(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(G(e.Plugin))}(),i}()});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useT(): (str: string) => any;
|
|
10
|
+
export declare function tExpr(key: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { ModelConstructor } from '@nocobase/flow-engine';
|
|
10
|
+
declare const _default: Record<string, ModelConstructor>;
|
|
11
|
+
export default _default;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var src_exports = {};
|
|
30
|
+
__export(src_exports, {
|
|
31
|
+
default: () => import_server.default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(src_exports);
|
|
34
|
+
__reExport(src_exports, require("./server"), module.exports);
|
|
35
|
+
var import_server = __toESM(require("./server"));
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
...require("./server")
|
|
39
|
+
});
|