plugin-document-understanding 1.1.14 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +29 -29
  2. package/client-v2.d.ts +2 -2
  3. package/client-v2.js +1 -1
  4. package/dist/client/{345.e6e484fb1974c3d3.js → 345.277fbb2b97424db5.js} +1 -1
  5. package/dist/client/index.js +1 -1
  6. package/dist/client-v2/{345.a8f28526ac21e02a.js → 345.2fa9834b46dd4531.js} +1 -1
  7. package/dist/client-v2/index.js +1 -1
  8. package/dist/externalVersion.js +8 -7
  9. package/dist/locale/en-US.json +3 -1
  10. package/dist/locale/zh-CN.json +3 -1
  11. package/dist/node_modules/form-data/lib/form_data.js +2 -2
  12. package/dist/node_modules/form-data/node_modules/es-define-property/.eslintrc +13 -0
  13. package/dist/node_modules/form-data/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  14. package/dist/node_modules/form-data/node_modules/es-define-property/.nycrc +9 -0
  15. package/dist/node_modules/form-data/node_modules/es-define-property/index.d.ts +3 -0
  16. package/dist/node_modules/form-data/node_modules/es-define-property/index.js +14 -0
  17. package/dist/node_modules/form-data/node_modules/es-define-property/package.json +81 -0
  18. package/dist/node_modules/form-data/node_modules/es-define-property/test/index.js +56 -0
  19. package/dist/node_modules/form-data/node_modules/es-object-atoms/.eslintrc +16 -0
  20. package/dist/node_modules/form-data/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
  21. package/dist/node_modules/form-data/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
  22. package/dist/node_modules/form-data/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
  23. package/dist/node_modules/form-data/node_modules/es-object-atoms/ToObject.d.ts +7 -0
  24. package/dist/node_modules/form-data/node_modules/es-object-atoms/ToObject.js +10 -0
  25. package/dist/node_modules/form-data/node_modules/es-object-atoms/index.d.ts +3 -0
  26. package/dist/node_modules/form-data/node_modules/es-object-atoms/index.js +4 -0
  27. package/dist/node_modules/form-data/node_modules/es-object-atoms/isObject.d.ts +3 -0
  28. package/dist/node_modules/form-data/node_modules/es-object-atoms/isObject.js +6 -0
  29. package/dist/node_modules/form-data/node_modules/es-object-atoms/package.json +80 -0
  30. package/dist/node_modules/form-data/node_modules/es-object-atoms/test/index.js +38 -0
  31. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/.eslintrc +13 -0
  32. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/.nycrc +9 -0
  33. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/index.d.ts +10 -0
  34. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/index.js +35 -0
  35. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/.eslintrc +5 -0
  36. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/.github/FUNDING.yml +12 -0
  37. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/.nycrc +13 -0
  38. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/index.d.ts +3 -0
  39. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/index.js +8 -0
  40. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/package.json +92 -0
  41. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/package.json +78 -0
  42. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/test/index.js +85 -0
  43. package/dist/node_modules/form-data/node_modules/get-intrinsic/.eslintrc +42 -0
  44. package/dist/node_modules/form-data/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  45. package/dist/node_modules/form-data/node_modules/get-intrinsic/.nycrc +9 -0
  46. package/dist/node_modules/form-data/node_modules/get-intrinsic/index.js +378 -0
  47. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/.eslintrc +11 -0
  48. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  49. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/.nycrc +9 -0
  50. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/index.d.ts +3 -0
  51. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/index.js +14 -0
  52. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/package.json +111 -0
  53. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/shams.d.ts +3 -0
  54. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/shams.js +45 -0
  55. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/index.js +22 -0
  56. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/shams/core-js.js +29 -0
  57. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
  58. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/tests.js +58 -0
  59. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/.eslintrc +5 -0
  60. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/.github/FUNDING.yml +12 -0
  61. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/.nycrc +13 -0
  62. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/index.d.ts +3 -0
  63. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/index.js +8 -0
  64. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/package.json +92 -0
  65. package/dist/node_modules/form-data/node_modules/get-intrinsic/package.json +97 -0
  66. package/dist/node_modules/form-data/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
  67. package/dist/node_modules/form-data/node_modules/gopd/.eslintrc +16 -0
  68. package/dist/node_modules/form-data/node_modules/gopd/.github/FUNDING.yml +12 -0
  69. package/dist/node_modules/form-data/node_modules/gopd/gOPD.d.ts +1 -0
  70. package/dist/node_modules/form-data/node_modules/gopd/gOPD.js +4 -0
  71. package/dist/node_modules/form-data/node_modules/gopd/index.d.ts +5 -0
  72. package/dist/node_modules/form-data/node_modules/gopd/index.js +15 -0
  73. package/dist/node_modules/form-data/node_modules/gopd/package.json +77 -0
  74. package/dist/node_modules/form-data/node_modules/gopd/test/index.js +36 -0
  75. package/dist/node_modules/form-data/node_modules/has-tostringtag/.eslintrc +5 -0
  76. package/dist/node_modules/form-data/node_modules/has-tostringtag/.github/FUNDING.yml +12 -0
  77. package/dist/node_modules/form-data/node_modules/has-tostringtag/.nycrc +13 -0
  78. package/dist/node_modules/form-data/node_modules/has-tostringtag/index.d.ts +3 -0
  79. package/dist/node_modules/form-data/node_modules/has-tostringtag/index.js +8 -0
  80. package/dist/node_modules/form-data/node_modules/has-tostringtag/package.json +108 -0
  81. package/dist/node_modules/form-data/node_modules/has-tostringtag/shams.d.ts +3 -0
  82. package/dist/node_modules/form-data/node_modules/has-tostringtag/shams.js +8 -0
  83. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/index.js +21 -0
  84. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/shams/core-js.js +31 -0
  85. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js +30 -0
  86. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/tests.js +15 -0
  87. package/dist/node_modules/form-data/node_modules/hasown/.github/FUNDING.yml +12 -0
  88. package/dist/node_modules/form-data/node_modules/hasown/.nycrc +13 -0
  89. package/dist/node_modules/form-data/node_modules/hasown/index.d.ts +3 -0
  90. package/dist/node_modules/form-data/node_modules/hasown/index.js +8 -0
  91. package/dist/node_modules/form-data/node_modules/hasown/package.json +91 -0
  92. package/dist/node_modules/form-data/package.json +1 -1
  93. package/dist/node_modules/mime-types/index.js +3 -3
  94. package/dist/node_modules/mime-types/package.json +1 -1
  95. package/dist/server/actions.js +45 -35
  96. package/package.json +57 -46
  97. package/src/client/index.tsx +15 -15
  98. package/src/client-v2/components/EndpointsTab.tsx +578 -578
  99. package/src/client-v2/components/JobsTab.tsx +294 -294
  100. package/src/client-v2/components/PipelinesTab.tsx +962 -962
  101. package/src/client-v2/components/PluginSettings.tsx +54 -50
  102. package/src/client-v2/components/ServiceConfigTab.tsx +139 -139
  103. package/src/client-v2/components/__tests__/PluginSettings.test.tsx +39 -0
  104. package/src/client-v2/index.tsx +1 -1
  105. package/src/client-v2/locale.ts +21 -21
  106. package/src/client-v2/models/index.ts +12 -12
  107. package/src/client-v2/plugin.tsx +31 -21
  108. package/src/client-v2/types.ts +32 -32
  109. package/src/index.ts +2 -2
  110. package/src/locale/en-US.json +3 -1
  111. package/src/locale/zh-CN.json +3 -1
  112. package/src/server/__tests__/actions.test.ts +121 -98
  113. package/src/server/__tests__/cluster-safety.test.ts +259 -259
  114. package/src/server/__tests__/document-understanding-service.test.ts +82 -82
  115. package/src/server/__tests__/dugate-integration.test.ts +221 -221
  116. package/src/server/__tests__/smoke.test.ts +78 -55
  117. package/src/server/__tests__/upload-security.test.ts +128 -0
  118. package/src/server/actions.ts +53 -51
  119. package/src/server/collections/config.ts +18 -18
  120. package/src/server/collections/endpoints.ts +33 -33
  121. package/src/server/collections/jobs.ts +42 -42
  122. package/src/server/collections/pipeline-steps.ts +27 -27
  123. package/src/server/collections/pipelines.ts +19 -19
  124. package/src/server/dugate-seed.ts +491 -491
  125. package/src/server/index.ts +1 -1
  126. package/src/server/plugin.ts +143 -143
  127. package/src/server/services/AsyncJobManager.ts +238 -238
  128. package/src/server/services/DocumentUnderstandingService.ts +332 -332
  129. package/src/server/services/ExternalApiClient.ts +178 -178
  130. package/src/server/services/PipelineExecutor.ts +593 -593
  131. package/src/server/tools/document-understanding-tool.ts +181 -181
  132. package/src/server/types.ts +90 -90
@@ -1 +1 @@
1
- {"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"2.1.35","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"1.52.0"},"devDependencies":{"eslint":"7.32.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.25.4","eslint-plugin-markdown":"2.2.1","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"5.2.0","eslint-plugin-standard":"4.1.0","mocha":"9.2.2","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-05-21T19:00:25.493Z"}
1
+ {"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"2.1.35","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"1.52.0"},"devDependencies":{"eslint":"7.32.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.25.4","eslint-plugin-markdown":"2.2.1","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"5.2.0","eslint-plugin-standard":"4.1.0","mocha":"9.2.2","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-11-14T07:21:41.279Z"}
@@ -29,7 +29,14 @@ __export(actions_exports, {
29
29
  defineActions: () => defineActions
30
30
  });
31
31
  module.exports = __toCommonJS(actions_exports);
32
- var import_fs = require("fs");
32
+ var import_utils = require("@nocobase/utils");
33
+ const uploadDocuments = (0, import_utils.koaMulter)({
34
+ storage: import_utils.koaMulter.memoryStorage(),
35
+ limits: { files: 5, fileSize: 20 * 1024 * 1024, fields: 2, fieldSize: 1024 * 1024, parts: 8 }
36
+ }).any();
37
+ function isRecord(value) {
38
+ return typeof value === "object" && value !== null && !Array.isArray(value);
39
+ }
33
40
  const defineActions = (plugin) => {
34
41
  const service = plugin.service;
35
42
  return {
@@ -86,45 +93,48 @@ const defineActions = (plugin) => {
86
93
  await next();
87
94
  },
88
95
  async executePipeline(ctx, next) {
89
- var _a, _b, _c;
90
- const { values } = ctx.action.params;
91
- const pipelineId = values == null ? void 0 : values.pipelineId;
92
- const input = (values == null ? void 0 : values.input) || {};
93
- const userId = (_b = (_a = ctx.state) == null ? void 0 : _a.currentUser) == null ? void 0 : _b.id;
96
+ var _a, _b;
97
+ let values = ctx.action.params.values;
94
98
  const multipartFiles = [];
95
- const request = ctx.request;
96
- const filesObj = request.files || ((_c = request.body) == null ? void 0 : _c.files);
97
- if (filesObj) {
98
- const addFile = (key, file) => {
99
- const filePath = file.path || file.filepath;
100
- const fileName = file.name || file.originalFilename || "file";
101
- const mimeType = file.type || file.mimetype || "application/octet-stream";
102
- if (filePath && (0, import_fs.existsSync)(filePath)) {
103
- try {
104
- multipartFiles.push({
105
- fieldName: key,
106
- buffer: (0, import_fs.readFileSync)(filePath),
107
- filename: fileName,
108
- mimeType
109
- });
110
- } catch (err) {
111
- plugin.app.logger.warn("Failed to read uploaded multipart file", err);
112
- }
113
- }
114
- };
115
- if (typeof filesObj === "object") {
116
- for (const [key, value] of Object.entries(filesObj)) {
117
- if (Array.isArray(value)) {
118
- for (const f of value) {
119
- addFile(key, f);
120
- }
121
- } else {
122
- addFile(key, value);
99
+ if (ctx.request.is("multipart/form-data")) {
100
+ try {
101
+ await uploadDocuments(ctx, async () => void 0);
102
+ } catch (error) {
103
+ const limited = isRecord(error) && typeof error.code === "string" && error.code.startsWith("LIMIT_");
104
+ ctx.throw(limited ? 413 : 400, ctx.t("Invalid document upload.", { ns: "plugin-document-understanding" }));
105
+ }
106
+ values = ctx.request.body;
107
+ const files = ctx.request.files;
108
+ if (Array.isArray(files)) {
109
+ for (const file of files) {
110
+ if (!isRecord(file) || !Buffer.isBuffer(file.buffer)) {
111
+ ctx.throw(400, ctx.t("Invalid document upload.", { ns: "plugin-document-understanding" }));
123
112
  }
113
+ multipartFiles.push({
114
+ fieldName: String(file.fieldname),
115
+ buffer: file.buffer,
116
+ filename: String(file.originalname),
117
+ mimeType: String(file.mimetype)
118
+ });
124
119
  }
125
120
  }
126
121
  }
127
- ctx.body = await service.executePipeline(pipelineId, input, multipartFiles, userId);
122
+ if (!isRecord(values) || Object.prototype.hasOwnProperty.call(values, "files")) {
123
+ ctx.throw(400, ctx.t("Invalid pipeline input.", { ns: "plugin-document-understanding" }));
124
+ }
125
+ const pipelineId = Number(values.pipelineId);
126
+ let input = values.input ?? {};
127
+ if (ctx.request.is("multipart/form-data") && typeof input === "string") {
128
+ try {
129
+ input = JSON.parse(input);
130
+ } catch {
131
+ ctx.throw(400, ctx.t("Invalid pipeline input.", { ns: "plugin-document-understanding" }));
132
+ }
133
+ }
134
+ if (!Number.isSafeInteger(pipelineId) || pipelineId <= 0 || !isRecord(input)) {
135
+ ctx.throw(400, ctx.t("Invalid pipeline input.", { ns: "plugin-document-understanding" }));
136
+ }
137
+ ctx.body = await service.executePipeline(pipelineId, input, multipartFiles, (_b = (_a = ctx.state) == null ? void 0 : _a.currentUser) == null ? void 0 : _b.id);
128
138
  await next();
129
139
  },
130
140
  async getJobStatus(ctx, next) {
package/package.json CHANGED
@@ -1,46 +1,57 @@
1
- {
2
- "name": "plugin-document-understanding",
3
- "displayName": "Document Understanding",
4
- "displayName.zh-CN": "文档理解",
5
- "description": "Configure external document processing endpoints, chain them into pipelines, and expose enabled pipelines as AI tools.",
6
- "version": "1.1.14",
7
- "license": "Apache-2.0",
8
- "main": "dist/server/index.js",
9
- "files": [
10
- "dist",
11
- "client.js",
12
- "client.d.ts",
13
- "client-v2.js",
14
- "client-v2.d.ts",
15
- "server.js",
16
- "server.d.ts",
17
- "README.md",
18
- "src"
19
- ],
20
- "nocobase": {
21
- "supportedVersions": [
22
- "2.x"
23
- ],
24
- "editionLevel": 0
25
- },
26
- "dependencies": {
27
- "axios": "^1.6.0"
28
- },
29
- "peerDependencies": {
30
- "@langchain/core": "^0.3.0",
31
- "@nocobase/actions": "2.x",
32
- "@nocobase/client": "2.x",
33
- "@nocobase/client-v2": "2.x",
34
- "@nocobase/database": "2.x",
35
- "@nocobase/flow-engine": "2.x",
36
- "@nocobase/plugin-ai": "2.x",
37
- "@nocobase/server": "2.x"
38
- },
39
- "keywords": [
40
- "AI",
41
- "document",
42
- "OCR",
43
- "pipeline",
44
- "orchestrator"
45
- ]
46
- }
1
+ {
2
+ "name": "plugin-document-understanding",
3
+ "displayName": "Document Understanding",
4
+ "displayName.zh-CN": "文档理解",
5
+ "description": "Configure external document processing endpoints, chain them into pipelines, and expose enabled pipelines as AI tools.",
6
+ "version": "1.1.16",
7
+ "license": "Apache-2.0",
8
+ "main": "dist/server/index.js",
9
+ "files": [
10
+ "dist",
11
+ "client.js",
12
+ "client.d.ts",
13
+ "client-v2.js",
14
+ "client-v2.d.ts",
15
+ "server.js",
16
+ "server.d.ts",
17
+ "README.md",
18
+ "src"
19
+ ],
20
+ "nocobase": {
21
+ "supportedVersions": [
22
+ "2.x"
23
+ ],
24
+ "editionLevel": 0
25
+ },
26
+ "dependencies": {
27
+ "axios": "^1.6.0"
28
+ },
29
+ "peerDependencies": {
30
+ "@langchain/core": "^0.3.0",
31
+ "@nocobase/actions": "2.x",
32
+ "@nocobase/client": "2.x",
33
+ "@nocobase/client-v2": "2.x",
34
+ "@nocobase/database": "2.x",
35
+ "@nocobase/flow-engine": "2.x",
36
+ "@nocobase/plugin-ai": "2.x",
37
+ "@nocobase/server": "2.x",
38
+ "@nocobase/utils": "2.x"
39
+ },
40
+ "keywords": [
41
+ "AI",
42
+ "document",
43
+ "OCR",
44
+ "pipeline",
45
+ "orchestrator"
46
+ ],
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/OrgGem/nocobase-beta.git",
50
+ "directory": "packages/plugins/plugin-document-understanding"
51
+ },
52
+ "gitHead": "17ea36f39a1627b876d55e11a4bb032a6b17e748",
53
+ "publishConfig": {
54
+ "access": "public",
55
+ "registry": "https://registry.npmjs.org/"
56
+ }
57
+ }
@@ -1,15 +1,15 @@
1
- import React from 'react';
2
- import { Plugin } from '@nocobase/client';
3
-
4
- export class PluginDocumentUnderstandingClient extends Plugin {
5
- async load() {
6
- this.pluginSettingsManager.add('document-understanding', {
7
- title: this.t('Document Understanding'),
8
- icon: 'FileSearchOutlined',
9
- Component: React.lazy(() => import('../client-v2/components/PluginSettings')),
10
- aclSnippet: 'pm.document-understanding',
11
- });
12
- }
13
- }
14
-
15
- export default PluginDocumentUnderstandingClient;
1
+ import React from 'react';
2
+ import { Plugin } from '@nocobase/client';
3
+
4
+ export class PluginDocumentUnderstandingClient extends Plugin {
5
+ async load() {
6
+ this.pluginSettingsManager.add('document-understanding', {
7
+ title: this.t('Document Understanding'),
8
+ icon: 'FileSearchOutlined',
9
+ Component: React.lazy(() => import('../client-v2/components/PluginSettings')),
10
+ aclSnippet: 'pm.document-understanding',
11
+ });
12
+ }
13
+ }
14
+
15
+ export default PluginDocumentUnderstandingClient;