plugin-document-understanding 1.1.16 → 2.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.
Files changed (82) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +19 -25
  3. package/dist/client/169.6888909107c553c3.js +10 -0
  4. package/dist/client/379.e29f5ced467ce23d.js +10 -0
  5. package/dist/client/867.3ed3b814115181ca.js +10 -0
  6. package/dist/client/index.js +1 -1
  7. package/dist/client-v2/169.53bf1be2ec192f0c.js +10 -0
  8. package/dist/client-v2/379.e75c4829567cdb89.js +10 -0
  9. package/dist/client-v2/867.66d7291e95f1de78.js +10 -0
  10. package/dist/client-v2/index.js +1 -1
  11. package/dist/externalVersion.js +9 -7
  12. package/dist/locale/en-US.json +126 -0
  13. package/dist/locale/vi-VN.json +130 -2
  14. package/dist/locale/zh-CN.json +127 -1
  15. package/dist/node_modules/form-data/package.json +1 -1
  16. package/dist/node_modules/mime-types/package.json +1 -1
  17. package/dist/server/actions.js +211 -11
  18. package/dist/server/collections/api-keys.js +55 -0
  19. package/dist/server/collections/artifacts.js +59 -0
  20. package/dist/server/collections/config.js +9 -3
  21. package/dist/server/collections/endpoints.js +3 -0
  22. package/dist/server/collections/jobs.js +7 -4
  23. package/dist/server/collections/operations.js +76 -0
  24. package/dist/server/contracts/du-contracts.js +828 -0
  25. package/dist/server/dugate-seed.js +98 -340
  26. package/dist/server/plugin.js +49 -7
  27. package/dist/server/routes/du-gateway-router.js +443 -0
  28. package/dist/server/services/ArtifactStorageService.js +459 -0
  29. package/dist/server/services/AsyncJobManager.js +1 -1
  30. package/dist/server/services/BuiltinBusinessEngine.js +1223 -0
  31. package/dist/server/services/DocumentUnderstandingService.js +151 -25
  32. package/dist/server/services/ExternalDuReworkClient.js +210 -0
  33. package/dist/server/services/OperationOrchestrator.js +1087 -0
  34. package/dist/server/services/PipelineExecutor.js +164 -43
  35. package/dist/server/tools/document-understanding-tool.js +49 -24
  36. package/dist/server/workflow/DocumentUnderstandingInstruction.js +292 -0
  37. package/package.json +8 -4
  38. package/src/client/index.tsx +11 -0
  39. package/src/client-v2/components/ApiKeysTab.tsx +198 -0
  40. package/src/client-v2/components/EndpointsTab.tsx +39 -2
  41. package/src/client-v2/components/JobsTab.tsx +136 -21
  42. package/src/client-v2/components/OperationsTab.tsx +586 -0
  43. package/src/client-v2/components/PluginSettings.tsx +12 -0
  44. package/src/client-v2/components/ServiceConfigTab.tsx +225 -65
  45. package/src/client-v2/components/__tests__/PluginSettings.test.tsx +4 -0
  46. package/src/client-v2/locale.ts +1 -8
  47. package/src/client-v2/models/index.ts +1 -8
  48. package/src/client-v2/plugin.tsx +12 -8
  49. package/src/client-v2/types.ts +13 -1
  50. package/src/client-v2/workflow/DocumentUnderstandingFieldset.tsx +122 -0
  51. package/src/client-v2/workflow/DocumentUnderstandingInstruction.tsx +49 -0
  52. package/src/locale/en-US.json +126 -0
  53. package/src/locale/vi-VN.json +130 -2
  54. package/src/locale/zh-CN.json +127 -1
  55. package/src/server/__tests__/actions.test.ts +1 -8
  56. package/src/server/__tests__/du-rework-gateway.test.ts +462 -0
  57. package/src/server/__tests__/dugate-integration.test.ts +79 -42
  58. package/src/server/__tests__/smoke.test.ts +1 -8
  59. package/src/server/__tests__/upload-security.test.ts +1 -8
  60. package/src/server/actions.ts +252 -36
  61. package/src/server/collections/api-keys.ts +35 -0
  62. package/src/server/collections/artifacts.ts +39 -0
  63. package/src/server/collections/config.ts +18 -2
  64. package/src/server/collections/endpoints.ts +12 -0
  65. package/src/server/collections/jobs.ts +16 -4
  66. package/src/server/collections/operations.ts +56 -0
  67. package/src/server/contracts/du-contracts.ts +1026 -0
  68. package/src/server/dugate-seed.ts +126 -453
  69. package/src/server/plugin.ts +64 -14
  70. package/src/server/routes/du-gateway-router.ts +465 -0
  71. package/src/server/services/ArtifactStorageService.ts +596 -0
  72. package/src/server/services/AsyncJobManager.ts +10 -1
  73. package/src/server/services/BuiltinBusinessEngine.ts +1544 -0
  74. package/src/server/services/DocumentUnderstandingService.ts +186 -44
  75. package/src/server/services/ExternalDuReworkClient.ts +222 -0
  76. package/src/server/services/OperationOrchestrator.ts +1359 -0
  77. package/src/server/services/PipelineExecutor.ts +245 -108
  78. package/src/server/tools/document-understanding-tool.ts +63 -45
  79. package/src/server/types.ts +101 -16
  80. package/src/server/workflow/DocumentUnderstandingInstruction.ts +308 -0
  81. package/dist/client/345.277fbb2b97424db5.js +0 -10
  82. package/dist/client-v2/345.2fa9834b46dd4531.js +0 -10
@@ -30,10 +30,15 @@ __export(actions_exports, {
30
30
  });
31
31
  module.exports = __toCommonJS(actions_exports);
32
32
  var import_utils = require("@nocobase/utils");
33
+ var import_du_contracts = require("./contracts/du-contracts");
33
34
  const uploadDocuments = (0, import_utils.koaMulter)({
34
35
  storage: import_utils.koaMulter.memoryStorage(),
35
36
  limits: { files: 5, fileSize: 20 * 1024 * 1024, fields: 2, fieldSize: 1024 * 1024, parts: 8 }
36
37
  }).any();
38
+ const uploadOperationDocuments = (0, import_utils.koaMulter)({
39
+ storage: import_utils.koaMulter.memoryStorage(),
40
+ limits: { files: 20, fileSize: 64 * 1024 * 1024, fields: 10, fieldSize: 2 * 1024 * 1024 }
41
+ }).any();
37
42
  function isRecord(value) {
38
43
  return typeof value === "object" && value !== null && !Array.isArray(value);
39
44
  }
@@ -50,6 +55,185 @@ const defineActions = (plugin) => {
50
55
  ctx.body = await service.getConfig();
51
56
  await next();
52
57
  },
58
+ async getHealth(ctx, next) {
59
+ ctx.body = await service.getGatewayHealth();
60
+ await next();
61
+ },
62
+ async listLlmServices(ctx, next) {
63
+ await service.ensureInitialized();
64
+ ctx.body = await service.orchestrator.builtinEngine.listAvailableLlmServices();
65
+ await next();
66
+ },
67
+ async listCatalog(ctx, next) {
68
+ ctx.body = import_du_contracts.DU_BUSINESS_CATALOG;
69
+ await next();
70
+ },
71
+ async syncCatalog(ctx, next) {
72
+ ctx.body = await service.syncCatalog();
73
+ await next();
74
+ },
75
+ async listApiKeys(ctx, next) {
76
+ await service.ensureInitialized();
77
+ ctx.body = await service.orchestrator.listApiKeys();
78
+ await next();
79
+ },
80
+ async issueApiKey(ctx, next) {
81
+ var _a, _b;
82
+ await service.ensureInitialized();
83
+ const { values } = ctx.action.params;
84
+ if (!isRecord(values)) {
85
+ ctx.throw(400, ctx.t("Invalid API key payload.", { ns: "plugin-document-understanding" }));
86
+ }
87
+ ctx.set("Cache-Control", "no-store");
88
+ ctx.body = await service.orchestrator.issueApiKey({
89
+ name: String(values.name || ""),
90
+ tenantId: typeof values.tenantId === "string" ? values.tenantId : "default",
91
+ allowedBusinesses: Array.isArray(values.allowedBusinesses) ? values.allowedBusinesses.map(String) : ["*"],
92
+ allowedActions: Array.isArray(values.allowedActions) ? values.allowedActions.map(String) : ["*"],
93
+ requestDefaults: isRecord(values.requestDefaults) ? values.requestDefaults : null,
94
+ lockedFields: Array.isArray(values.lockedFields) ? values.lockedFields.map(String) : null,
95
+ expiresAt: typeof values.expiresAt === "string" ? values.expiresAt : null,
96
+ userId: (_b = (_a = ctx.state) == null ? void 0 : _a.currentUser) == null ? void 0 : _b.id
97
+ });
98
+ await next();
99
+ },
100
+ async revokeApiKey(ctx, next) {
101
+ await service.ensureInitialized();
102
+ const { filterByTk } = ctx.action.params;
103
+ await service.orchestrator.revokeApiKey(Number(filterByTk));
104
+ ctx.body = { message: "ok" };
105
+ await next();
106
+ },
107
+ async listOperations(ctx, next) {
108
+ await service.ensureInitialized();
109
+ const { filter } = ctx.action.params;
110
+ const filterObj = isRecord(filter) ? filter : {};
111
+ const res = await service.orchestrator.listOperations({
112
+ tenantId: typeof filterObj.tenantId === "string" ? filterObj.tenantId : "*",
113
+ state: typeof filterObj.state === "string" ? filterObj.state : void 0,
114
+ businessId: typeof filterObj.businessId === "string" ? filterObj.businessId : void 0,
115
+ action: typeof filterObj.action === "string" ? filterObj.action : void 0,
116
+ limit: 50
117
+ });
118
+ ctx.body = res.items;
119
+ await next();
120
+ },
121
+ async getOperation(ctx, next) {
122
+ await service.ensureInitialized();
123
+ const { filterByTk } = ctx.action.params;
124
+ const op = await service.orchestrator.getOperationRecordOrThrow("*", String(filterByTk));
125
+ ctx.body = {
126
+ ...service.orchestrator.toOperationView(op),
127
+ outputPayload: op.outputPayload ?? null,
128
+ resultEnvelope: op.resultEnvelope ?? null
129
+ };
130
+ await next();
131
+ },
132
+ async submitOperation(ctx, next) {
133
+ var _a, _b, _c, _d;
134
+ await service.ensureInitialized();
135
+ let payload = ctx.action.params.values;
136
+ const uploadedArtifactIds = [];
137
+ if (ctx.request.is("multipart/form-data")) {
138
+ await uploadOperationDocuments(ctx, async () => void 0);
139
+ payload = ctx.request.body;
140
+ const files = ctx.request.files;
141
+ if (Array.isArray(files)) {
142
+ for (const file of files) {
143
+ if (isRecord(file) && Buffer.isBuffer(file.buffer)) {
144
+ const art = await service.orchestrator.artifactStorage.createReadyArtifactFromBuffer({
145
+ tenantId: "default",
146
+ fileName: String(file.originalname || "document.bin"),
147
+ mimeType: String(file.mimetype || "application/octet-stream"),
148
+ buffer: file.buffer,
149
+ userId: (_b = (_a = ctx.state) == null ? void 0 : _a.currentUser) == null ? void 0 : _b.id
150
+ });
151
+ uploadedArtifactIds.push(art.artifactId);
152
+ }
153
+ }
154
+ }
155
+ }
156
+ if (!isRecord(payload)) {
157
+ ctx.throw(400, ctx.t("Invalid operation payload.", { ns: "plugin-document-understanding" }));
158
+ }
159
+ const businessId = String(payload.businessId || "document-core");
160
+ const action = String(payload.action || "ingest");
161
+ let inputObj = payload.input ?? {};
162
+ if (typeof inputObj === "string") {
163
+ try {
164
+ inputObj = JSON.parse(inputObj);
165
+ } catch {
166
+ ctx.throw(400, ctx.t("Invalid JSON input.", { ns: "plugin-document-understanding" }));
167
+ }
168
+ }
169
+ let docSel = payload.documentSelection;
170
+ if (typeof docSel === "string" && docSel.trim()) {
171
+ try {
172
+ docSel = JSON.parse(docSel);
173
+ } catch {
174
+ ctx.throw(400, ctx.t("Invalid JSON input.", { ns: "plugin-document-understanding" }));
175
+ }
176
+ }
177
+ const explicitArtifacts = Array.isArray(payload.artifacts) ? payload.artifacts : [];
178
+ const mergedArtifacts = [
179
+ ...explicitArtifacts,
180
+ ...uploadedArtifactIds.map((artifactId) => ({ artifactId, role: "input" }))
181
+ ];
182
+ ctx.body = await service.orchestrator.submitOperation({
183
+ principal: {
184
+ kind: "nocobase_user",
185
+ tenantId: typeof payload.tenantId === "string" ? payload.tenantId : "default",
186
+ userId: (_d = (_c = ctx.state) == null ? void 0 : _c.currentUser) == null ? void 0 : _d.id,
187
+ allowedBusinesses: ["*"],
188
+ allowedActions: ["*"]
189
+ },
190
+ businessId,
191
+ action,
192
+ submission: {
193
+ input: isRecord(inputObj) ? inputObj : {},
194
+ artifacts: mergedArtifacts,
195
+ documentSelection: isRecord(docSel) ? docSel : void 0
196
+ }
197
+ });
198
+ await next();
199
+ },
200
+ async cancelOperation(ctx, next) {
201
+ await service.ensureInitialized();
202
+ const { filterByTk } = ctx.action.params;
203
+ ctx.body = await service.orchestrator.cancelOperation("*", String(filterByTk));
204
+ await next();
205
+ },
206
+ async resumeOperation(ctx, next) {
207
+ var _a;
208
+ await service.ensureInitialized();
209
+ const { filterByTk, values } = ctx.action.params;
210
+ const body = isRecord(values) ? values : {};
211
+ const input = isRecord(body.input) ? body.input : body;
212
+ const currentUser = (_a = ctx.state) == null ? void 0 : _a.currentUser;
213
+ const resumedBy = (currentUser == null ? void 0 : currentUser.email) || (currentUser == null ? void 0 : currentUser.username) || (currentUser == null ? void 0 : currentUser.nickname);
214
+ ctx.body = await service.orchestrator.resumeOperation({
215
+ tenantId: "*",
216
+ operationId: String(filterByTk),
217
+ waitId: typeof body.waitId === "string" ? body.waitId : void 0,
218
+ expectedStateVersion: body.expectedStateVersion !== void 0 ? Number(body.expectedStateVersion) : void 0,
219
+ input,
220
+ resumedBy
221
+ });
222
+ await next();
223
+ },
224
+ async getUsageSummary(ctx, next) {
225
+ await service.ensureInitialized();
226
+ const now = /* @__PURE__ */ new Date();
227
+ const defaultFrom = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3).toISOString();
228
+ const from = typeof ctx.action.params.from === "string" ? ctx.action.params.from : defaultFrom;
229
+ const to = typeof ctx.action.params.to === "string" ? ctx.action.params.to : new Date(now.getTime() + 6e4).toISOString();
230
+ ctx.body = await service.orchestrator.getUsageSummary({
231
+ tenantId: "*",
232
+ from,
233
+ to
234
+ });
235
+ await next();
236
+ },
53
237
  async listEndpoints(ctx, next) {
54
238
  ctx.body = await service.listEndpoints();
55
239
  await next();
@@ -147,21 +331,37 @@ const defineActions = (plugin) => {
147
331
  ctx.body = await service.listJobs(filter);
148
332
  await next();
149
333
  },
334
+ async cancelJob(ctx, next) {
335
+ const { filterByTk } = ctx.action.params;
336
+ ctx.body = await service.cancelJob(Number(filterByTk));
337
+ await next();
338
+ },
339
+ async resumeJob(ctx, next) {
340
+ var _a;
341
+ const { filterByTk, values } = ctx.action.params;
342
+ const body = isRecord(values) ? values : {};
343
+ const currentUser = (_a = ctx.state) == null ? void 0 : _a.currentUser;
344
+ ctx.body = await service.resumeJob(Number(filterByTk), body, (currentUser == null ? void 0 : currentUser.email) || (currentUser == null ? void 0 : currentUser.username));
345
+ await next();
346
+ },
150
347
  async webhookCallback(ctx, next) {
151
- const signature = ctx.request.headers["x-webhook-signature"];
152
- const { values } = ctx.action.params;
348
+ const legacySig = ctx.get("x-webhook-signature") || void 0;
349
+ const duSig = ctx.get("x-du-signature") || void 0;
350
+ const duTimestamp = ctx.get("x-du-timestamp") || void 0;
351
+ const duDeliveryId = ctx.get("x-du-delivery-id") || void 0;
352
+ const rawPayload = ctx.action.params.values || ctx.request.body;
153
353
  try {
154
- await service.handleWebhook(values || ctx.request.body, signature);
354
+ await service.handleWebhook(isRecord(rawPayload) ? rawPayload : {}, legacySig, {
355
+ signature: duSig,
356
+ timestamp: duTimestamp,
357
+ deliveryId: duDeliveryId
358
+ });
155
359
  ctx.body = { received: true };
156
360
  } catch (err) {
157
- plugin.app.logger.warn(`Webhook callback error: ${err.message}`);
158
- if (err.message.includes("signature")) {
159
- ctx.status = 401;
160
- ctx.body = { error: err.message };
161
- } else {
162
- ctx.status = 400;
163
- ctx.body = { error: err.message };
164
- }
361
+ const msg = err instanceof Error ? err.message : String(err);
362
+ plugin.app.logger.warn(`Webhook callback error: ${msg}`);
363
+ ctx.status = msg.includes("signature") ? 401 : 400;
364
+ ctx.body = { error: msg };
165
365
  }
166
366
  await next();
167
367
  }
@@ -0,0 +1,55 @@
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
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var api_keys_exports = {};
28
+ __export(api_keys_exports, {
29
+ default: () => api_keys_default
30
+ });
31
+ module.exports = __toCommonJS(api_keys_exports);
32
+ var api_keys_default = {
33
+ name: "doc_understanding_api_keys",
34
+ title: "Document Understanding API Keys",
35
+ fields: [
36
+ { type: "string", name: "name", length: 200 },
37
+ { type: "string", name: "keyPrefix", length: 32 },
38
+ { type: "string", name: "keyHash", unique: true, length: 128 },
39
+ { type: "string", name: "tenantId", length: 100, defaultValue: "default" },
40
+ { type: "json", name: "allowedBusinesses" },
41
+ { type: "json", name: "allowedActions" },
42
+ { type: "json", name: "requestDefaults" },
43
+ { type: "json", name: "lockedFields" },
44
+ { type: "string", name: "status", length: 20, defaultValue: "active" },
45
+ { type: "date", name: "expiresAt" },
46
+ { type: "date", name: "lastUsedAt" },
47
+ {
48
+ type: "belongsTo",
49
+ name: "createdBy",
50
+ target: "users",
51
+ foreignKey: "createdById"
52
+ }
53
+ ],
54
+ indexes: [{ fields: ["tenantId"] }, { fields: ["status"] }]
55
+ };
@@ -0,0 +1,59 @@
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
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var artifacts_exports = {};
28
+ __export(artifacts_exports, {
29
+ default: () => artifacts_default
30
+ });
31
+ module.exports = __toCommonJS(artifacts_exports);
32
+ var artifacts_default = {
33
+ name: "doc_understanding_artifacts",
34
+ title: "Document Understanding Artifacts",
35
+ fields: [
36
+ { type: "string", name: "artifactId", unique: true, length: 64 },
37
+ { type: "string", name: "tenantId", length: 100, defaultValue: "default" },
38
+ { type: "string", name: "operationId", length: 64 },
39
+ { type: "string", name: "role", length: 30, defaultValue: "input" },
40
+ { type: "string", name: "state", length: 20, defaultValue: "UPLOADING" },
41
+ { type: "string", name: "fileName", length: 500 },
42
+ { type: "string", name: "mimeType", length: 150 },
43
+ { type: "integer", name: "sizeBytes", defaultValue: 0 },
44
+ { type: "string", name: "hashSha256", length: 64 },
45
+ { type: "string", name: "storagePath", length: 1e3 },
46
+ { type: "string", name: "idempotencyKey", length: 200 },
47
+ {
48
+ type: "belongsTo",
49
+ name: "createdBy",
50
+ target: "users",
51
+ foreignKey: "createdById"
52
+ }
53
+ ],
54
+ indexes: [
55
+ { fields: ["tenantId", "artifactId"] },
56
+ { fields: ["operationId"] },
57
+ { fields: ["tenantId", "idempotencyKey"] }
58
+ ]
59
+ };
@@ -32,17 +32,23 @@ module.exports = __toCommonJS(config_exports);
32
32
  var config_default = {
33
33
  name: "doc_understanding_config",
34
34
  title: "Document Understanding Config",
35
- // Model name can be explicitly generated by NocoBase, but we define collection fields.
36
35
  fields: [
37
36
  { type: "string", name: "baseUrl", length: 500 },
38
37
  { type: "string", name: "authType", length: 20 },
39
- // 'api_key' | 'bearer' | 'custom_header' | 'none'
40
38
  { type: "string", name: "authKey", length: 500 },
41
39
  { type: "string", name: "authHeaderName", length: 100 },
42
40
  { type: "integer", name: "defaultTimeout", defaultValue: 3e4 },
43
41
  { type: "integer", name: "defaultRetries", defaultValue: 2 },
44
42
  { type: "integer", name: "pollInterval", defaultValue: 5e3 },
45
43
  { type: "integer", name: "pollTimeout", defaultValue: 3e5 },
46
- { type: "string", name: "webhookSecret", length: 500 }
44
+ { type: "string", name: "webhookSecret", length: 500 },
45
+ { type: "string", name: "engineMode", length: 30, defaultValue: "builtin" },
46
+ { type: "string", name: "llmService", length: 120 },
47
+ { type: "string", name: "llmModel", length: 120 },
48
+ { type: "string", name: "visionLlmService", length: 120 },
49
+ { type: "string", name: "visionLlmModel", length: 120 },
50
+ { type: "integer", name: "maxFileSizeBytes", defaultValue: 10485760 },
51
+ { type: "integer", name: "maxFilesPerRequest", defaultValue: 20 },
52
+ { type: "boolean", name: "publicGatewayEnabled", defaultValue: true }
47
53
  ]
48
54
  };
@@ -43,6 +43,9 @@ var endpoints_default = {
43
43
  { type: "string", name: "fileFieldName", length: 100, defaultValue: "file" },
44
44
  { type: "integer", name: "maxFiles", defaultValue: 1 },
45
45
  { type: "string", name: "executionMode", length: 20 },
46
+ { type: "string", name: "protocolMode", length: 30, defaultValue: "legacy_rest" },
47
+ { type: "string", name: "businessId", length: 100 },
48
+ { type: "string", name: "actionName", length: 100 },
46
49
  { type: "string", name: "discriminatorField", length: 50 },
47
50
  { type: "string", name: "discriminatorValue", length: 100 },
48
51
  { type: "string", name: "syncQueryParam", length: 50 },
@@ -39,18 +39,18 @@ var jobs_default = {
39
39
  target: "doc_understanding_pipelines",
40
40
  foreignKey: "pipelineId"
41
41
  },
42
- { type: "string", name: "status", length: 20, defaultValue: "pending" },
42
+ { type: "string", name: "status", length: 30, defaultValue: "pending" },
43
43
  { type: "json", name: "input" },
44
44
  { type: "integer", name: "currentStep" },
45
45
  { type: "json", name: "stepResults" },
46
46
  { type: "json", name: "finalResult" },
47
47
  { type: "text", name: "error" },
48
48
  { type: "json", name: "externalTaskIds" },
49
+ { type: "string", name: "operationId", length: 64 },
50
+ { type: "json", name: "waitState" },
51
+ { type: "json", name: "usage" },
49
52
  { type: "date", name: "startedAt" },
50
53
  { type: "date", name: "completedAt" },
51
- // Cluster ownership: which node is executing/polling this job, and until when
52
- // its lease is valid. Orphaned jobs (owner restarted or lease expired) are
53
- // failed or re-adopted by the maintenance sweep.
54
54
  { type: "string", name: "ownedBy", length: 255 },
55
55
  { type: "date", name: "leaseExpiresAt" },
56
56
  {
@@ -66,6 +66,9 @@ var jobs_default = {
66
66
  },
67
67
  {
68
68
  fields: ["leaseExpiresAt"]
69
+ },
70
+ {
71
+ fields: ["operationId"]
69
72
  }
70
73
  ]
71
74
  };
@@ -0,0 +1,76 @@
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
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var operations_exports = {};
28
+ __export(operations_exports, {
29
+ default: () => operations_default
30
+ });
31
+ module.exports = __toCommonJS(operations_exports);
32
+ var operations_default = {
33
+ name: "doc_understanding_operations",
34
+ title: "Document Understanding Operations",
35
+ fields: [
36
+ { type: "string", name: "operationId", unique: true, length: 64 },
37
+ { type: "string", name: "tenantId", length: 100, defaultValue: "default" },
38
+ { type: "string", name: "businessId", length: 100 },
39
+ { type: "string", name: "businessVersion", length: 32 },
40
+ { type: "string", name: "action", length: 100 },
41
+ { type: "string", name: "variant", length: 100 },
42
+ { type: "string", name: "state", length: 32, defaultValue: "ACCEPTED" },
43
+ { type: "integer", name: "stateVersion", defaultValue: 1 },
44
+ { type: "string", name: "correlationId", length: 128 },
45
+ { type: "string", name: "clientReference", length: 255 },
46
+ { type: "string", name: "idempotencyKey", length: 200 },
47
+ { type: "string", name: "requestFingerprint", length: 64 },
48
+ { type: "json", name: "submission" },
49
+ { type: "json", name: "progress" },
50
+ { type: "json", name: "waitState" },
51
+ { type: "json", name: "documentInputPlan" },
52
+ { type: "json", name: "documentInputCoverage" },
53
+ { type: "json", name: "resultEnvelope" },
54
+ { type: "json", name: "outputPayload" },
55
+ { type: "json", name: "usage" },
56
+ { type: "json", name: "warnings" },
57
+ { type: "json", name: "errorProblem" },
58
+ { type: "string", name: "externalOperationId", length: 128 },
59
+ { type: "date", name: "deadlineAt" },
60
+ { type: "date", name: "completedAt" },
61
+ { type: "string", name: "ownedBy", length: 255 },
62
+ { type: "date", name: "leaseExpiresAt" },
63
+ {
64
+ type: "belongsTo",
65
+ name: "createdBy",
66
+ target: "users",
67
+ foreignKey: "createdById"
68
+ }
69
+ ],
70
+ indexes: [
71
+ { fields: ["tenantId", "state"] },
72
+ { fields: ["tenantId", "businessId", "action"] },
73
+ { fields: ["tenantId", "idempotencyKey"] },
74
+ { fields: ["leaseExpiresAt"] }
75
+ ]
76
+ };