plugin-document-parser 1.0.1
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/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/01b8a5798a872638.js +10 -0
- package/dist/client/022be20abc96fdb4.js +10 -0
- package/dist/client/12e97e7a84d900e0.js +10 -0
- package/dist/client/index.js +10 -0
- package/dist/externalVersion.js +20 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +54 -0
- package/dist/locale/vi-VN.json +54 -0
- package/dist/node_modules/form-data/License +19 -0
- package/dist/node_modules/form-data/index.d.ts +62 -0
- package/dist/node_modules/form-data/lib/browser.js +4 -0
- package/dist/node_modules/form-data/lib/form_data.js +14 -0
- package/dist/node_modules/form-data/lib/populate.js +10 -0
- package/dist/node_modules/form-data/package.json +1 -0
- package/dist/server/collections/doc-parser-providers.js +137 -0
- package/dist/server/collections/doc-parser-settings.js +85 -0
- package/dist/server/index.js +51 -0
- package/dist/server/plugin.js +181 -0
- package/dist/server/resource/docParserProviders.js +91 -0
- package/dist/server/services/builtin-ai-handler.js +63 -0
- package/dist/server/services/external-ocr-client.js +189 -0
- package/dist/server/services/internal-parser-registry.js +82 -0
- package/dist/server/services/parse-router.js +273 -0
- package/package.json +33 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
- package/src/client/components/GlobalSettings.tsx +151 -0
- package/src/client/components/ProviderForm.tsx +266 -0
- package/src/client/components/ProviderList.tsx +193 -0
- package/src/client/components/SettingsPage.tsx +43 -0
- package/src/client/index.tsx +2 -0
- package/src/client/locale.ts +12 -0
- package/src/client/plugin.tsx +34 -0
- package/src/index.ts +2 -0
- package/src/locale/en-US.json +54 -0
- package/src/locale/vi-VN.json +54 -0
- package/src/server/collections/doc-parser-providers.ts +107 -0
- package/src/server/collections/doc-parser-settings.ts +59 -0
- package/src/server/index.ts +10 -0
- package/src/server/plugin.ts +172 -0
- package/src/server/resource/docParserProviders.ts +72 -0
- package/src/server/services/builtin-ai-handler.ts +49 -0
- package/src/server/services/external-ocr-client.ts +233 -0
- package/src/server/services/internal-parser-registry.ts +126 -0
- package/src/server/services/parse-router.ts +357 -0
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -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
|
+
|
|
10
|
+
"use strict";(self.webpackChunkplugin_document_parser=self.webpackChunkplugin_document_parser||[]).push([["264"],{928:function(e){e.exports=JSON.parse('{"Document Parser":"Document Parser","Processing Mode":"Processing Mode","Default (plugin-ai built-in)":"Default (plugin-ai built-in)","Internal (built-in document loaders)":"Internal (built-in document loaders)","External (OCR API provider)":"External (OCR API provider)","Active Provider":"Active Provider","Fallback to default on error":"Fallback to default on error","Pass images through to default":"Pass images through to default","OCR Providers":"OCR Providers","Add Provider":"Add Provider","Edit Provider":"Edit Provider","Delete Provider":"Delete Provider","Test Connection":"Test Connection","Provider Title":"Provider Title","API Endpoint":"API Endpoint","API Key":"API Key","Auth Type":"Auth Type","Bearer Token":"Bearer Token","API Key Header":"API Key Header","Basic Auth":"Basic Auth","Custom Header":"Custom Header","Header Name":"Header Name","Username":"Username","Password":"Password","Custom Headers":"Custom Headers","Request Format":"Request Format","Multipart Form Data":"Multipart Form Data","JSON Base64":"JSON Base64","Form Field Name":"Form Field Name","Base64 Field Path":"Base64 Field Path","Filename Field Path":"Filename Field Path","Mimetype Field Path":"Mimetype Field Path","Extra Request Body":"Extra Request Body","Response Text Path":"Response Text Path","Timeout (ms)":"Timeout (ms)","Supported MIME Types":"Supported MIME Types","Leave empty to handle all non-image types":"Leave empty to handle all non-image types","Connection successful":"Connection successful","Connection failed":"Connection failed","Global Settings":"Global Settings","Provider Configuration":"Provider Configuration","Enabled":"Enabled","No providers configured":"No providers configured","Please select a provider":"Please select a provider","Settings saved":"Settings saved","Provider saved":"Provider saved","Provider deleted":"Provider deleted","mode_default_desc":"Use the built-in attachment processing from plugin-ai (default behavior).","mode_internal_desc":"Parse documents using built-in loaders (PDF, DOCX, PPT, TXT) or custom parsers registered by other plugins.","mode_external_desc":"Send files to a configured external OCR/parse API and use the returned text as attachment content.","Index with DocPixie (when available)":"Index with DocPixie (when available)","docpixie_mode_desc":"When plugin-docpixie is active, automatically index attached documents and instruct the AI to use the docpixie:query tool instead of reading raw file content. Applies before the processing mode above."}')}}]);
|
|
@@ -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
|
+
|
|
10
|
+
"use strict";(self.webpackChunkplugin_document_parser=self.webpackChunkplugin_document_parser||[]).push([["637"],{346:function(n){n.exports=JSON.parse('{"Document Parser":"Tr\xecnh xử l\xfd t\xe0i liệu","Processing Mode":"Chế độ xử l\xfd","Default (plugin-ai built-in)":"Mặc định (plugin-ai t\xedch hợp sẵn)","Internal (built-in document loaders)":"Nội bộ (tr\xecnh đọc t\xe0i liệu t\xedch hợp)","External (OCR API provider)":"B\xean ngo\xe0i (nh\xe0 cung cấp OCR API)","Active Provider":"Nh\xe0 cung cấp đang d\xf9ng","Fallback to default on error":"D\xf9ng mặc định khi lỗi","Pass images through to default":"Chuyển h\xecnh ảnh qua xử l\xfd mặc định","OCR Providers":"Nh\xe0 cung cấp OCR","Add Provider":"Th\xeam nh\xe0 cung cấp","Edit Provider":"Chỉnh sửa nh\xe0 cung cấp","Delete Provider":"X\xf3a nh\xe0 cung cấp","Test Connection":"Kiểm tra kết nối","Provider Title":"T\xean nh\xe0 cung cấp","API Endpoint":"Địa chỉ API","API Key":"Kh\xf3a API","Auth Type":"Loại x\xe1c thực","Bearer Token":"Bearer Token","API Key Header":"Header API Key","Basic Auth":"Basic Auth","Custom Header":"Header t\xf9y chỉnh","Header Name":"T\xean header","Username":"T\xean đăng nhập","Password":"Mật khẩu","Custom Headers":"Headers t\xf9y chỉnh","Request Format":"Định dạng y\xeau cầu","Multipart Form Data":"Multipart Form Data","JSON Base64":"JSON Base64","Form Field Name":"T\xean trường form","Base64 Field Path":"Đường dẫn trường Base64","Filename Field Path":"Đường dẫn t\xean file","Mimetype Field Path":"Đường dẫn MIME type","Extra Request Body":"Body y\xeau cầu th\xeam","Response Text Path":"Đường dẫn text trong phản hồi","Timeout (ms)":"Timeout (ms)","Supported MIME Types":"MIME Types được hỗ trợ","Leave empty to handle all non-image types":"Để trống để xử l\xfd tất cả loại kh\xf4ng phải ảnh","Connection successful":"Kết nối th\xe0nh c\xf4ng","Connection failed":"Kết nối thất bại","Global Settings":"C\xe0i đặt chung","Provider Configuration":"Cấu h\xecnh nh\xe0 cung cấp","Enabled":"K\xedch hoạt","No providers configured":"Chưa c\xf3 nh\xe0 cung cấp n\xe0o","Please select a provider":"Vui l\xf2ng chọn nh\xe0 cung cấp","Settings saved":"Đ\xe3 lưu c\xe0i đặt","Provider saved":"Đ\xe3 lưu nh\xe0 cung cấp","Provider deleted":"Đ\xe3 x\xf3a nh\xe0 cung cấp","Index with DocPixie (when available)":"Lập chỉ mục qua DocPixie (nếu c\xf3)","docpixie_mode_desc":"Khi plugin-docpixie đang hoạt động, tự động lập chỉ mục t\xe0i liệu đ\xednh k\xe8m v\xe0 hướng dẫn AI d\xf9ng c\xf4ng cụ docpixie:query thay v\xec đọc nội dung th\xf4. Được \xe1p dụng trước chế độ xử l\xfd b\xean tr\xean.","mode_default_desc":"D\xf9ng chức năng xử l\xfd tệp đ\xednh k\xe8m mặc định của plugin-ai.","mode_internal_desc":"Ph\xe2n t\xedch t\xe0i liệu d\xf9ng tr\xecnh đọc t\xedch hợp (PDF, DOCX, PPT, TXT) hoặc c\xe1c parser t\xf9y chỉnh từ plugin kh\xe1c.","mode_external_desc":"Gửi tệp đến API OCR/parse b\xean ngo\xe0i đ\xe3 cấu h\xecnh v\xe0 d\xf9ng văn bản trả về l\xe0m nội dung đ\xednh k\xe8m."}')}}]);
|
|
@@ -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
|
+
|
|
10
|
+
"use strict";(self.webpackChunkplugin_document_parser=self.webpackChunkplugin_document_parser||[]).push([["998"],{945:function(e,t,r){r.r(t),r.d(t,{SettingsPage:function(){return w}});var n=r(156),a=r.n(n),l=r(721),o=r(482),i=r(772),u=r(990);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t,r,n,a,l,o){try{var i=e[l](o),u=i.value}catch(e){r(e);return}i.done?t(u):Promise.resolve(u).then(n,a)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){i=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(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 d=l.Typography.Text,p=function(){var e,t,r=(0,u.bV)().t,c=(0,i.useAPIClient)(),p=m(l.Form.useForm(),1)[0],f=m((0,n.useState)(!0),2),y=f[0],h=f[1],b=m((0,n.useState)(!1),2),v=b[0],E=b[1],g=m((0,n.useState)([]),2),P=g[0],S=g[1],F=m((0,n.useState)("default"),2),I=F[0],w=F[1];(0,n.useEffect)(function(){Promise.all([c.request({url:"docParserSettings:get"}),c.request({url:"docParserProviders:list",params:{pageSize:200}})]).then(function(e){var t,r,n,a,l=m(e,2),o=l[0],i=l[1],u=null!=(n=null==o||null==(t=o.data)?void 0:t.data)?n:{mode:"default",fallbackToDefault:!0,imagePassThrough:!0,includedExtnames:[]};p.setFieldsValue(u),w(u.mode),S(null!=(a=null==i||null==(r=i.data)?void 0:r.data)?a:[])}).finally(function(){return h(!1)})},[]);var x=(e=function(){var e,t,n;return function(e,t){var r,n,a,l,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(r)throw TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&u[0]?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){o.label=u[1];break}if(6===u[0]&&o.label<a[1]){o.label=a[1],a=u;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(u);break}a[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],n=0}finally{r=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:return[4,p.validateFields()];case 1:e=a.sent(),E(!0),a.label=2;case 2:return a.trys.push([2,4,5,6]),[4,c.request({url:"docParserSettings:save",method:"POST",data:e})];case 3:return a.sent(),l.message.success(r("Settings saved")),[3,6];case 4:return t=a.sent(),l.message.error(null!=(n=null==t?void 0:t.message)?n:"Save failed"),[3,6];case 5:return E(!1),[7];case 6:return[2]}})},t=function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function o(e){s(l,n,a,o,i,"next",e)}function i(e){s(l,n,a,o,i,"throw",e)}o(void 0)})},function(){return t.apply(this,arguments)});return y?a().createElement(l.Spin,{style:{display:"block",margin:"40px auto"}}):(r("mode_default_desc"),r("mode_internal_desc"),r("mode_external_desc"),a().createElement(l.Card,{bordered:!1},a().createElement(l.Form,{form:p,layout:"vertical",onValuesChange:function(e){e.mode&&w(e.mode)}},a().createElement(l.Form.Item,{name:"mode",label:r("Processing Mode")},a().createElement(l.Radio.Group,{style:{display:"flex",flexDirection:"column",gap:8}},a().createElement(l.Radio,{value:"default"},a().createElement(l.Space,{direction:"vertical",size:0},a().createElement(d,{strong:!0},r("Default (plugin-ai built-in)")),a().createElement(d,{type:"secondary",style:{fontSize:12}},r("mode_default_desc")))),a().createElement(l.Radio,{value:"internal"},a().createElement(l.Space,{direction:"vertical",size:0},a().createElement(d,{strong:!0},r("Internal (built-in document loaders)")),a().createElement(d,{type:"secondary",style:{fontSize:12}},r("mode_internal_desc")))),a().createElement(l.Radio,{value:"external"},a().createElement(l.Space,{direction:"vertical",size:0},a().createElement(d,{strong:!0},r("External (OCR API provider)")),a().createElement(d,{type:"secondary",style:{fontSize:12}},r("mode_external_desc")))))),"external"===I&&a().createElement(l.Form.Item,{name:"activeProviderId",label:r("Active Provider"),rules:[{required:!0,message:r("Please select a provider")}]},a().createElement(l.Select,{placeholder:r("Please select a provider"),options:P.filter(function(e){return e.enabled}).map(function(e){return{label:e.title,value:e.id}}),style:{maxWidth:400}})),a().createElement(l.Divider,null),a().createElement(l.Form.Item,{name:"fallbackToDefault",valuePropName:"checked",label:r("Fallback to default on error")},a().createElement(l.Switch,null)),a().createElement(l.Form.Item,{name:"imagePassThrough",valuePropName:"checked",label:r("Pass images through to default")},a().createElement(l.Switch,null)),a().createElement(l.Divider,null),a().createElement(l.Form.Item,{name:"useDocpixie",valuePropName:"checked",label:r("Index with DocPixie (when available)"),help:a().createElement(d,{type:"secondary"},r("docpixie_mode_desc"))},a().createElement(l.Switch,null)),a().createElement(l.Divider,null),a().createElement(l.Form.Item,null,a().createElement(l.Button,{type:"primary",icon:a().createElement(o.SaveOutlined,null),onClick:x,loading:v},r("Settings saved").replace("saved","Save"))))))};function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t,r,n,a,l,o){try{var i=e[l](o),u=i.value}catch(e){r(e);return}i.done?t(u):Promise.resolve(u).then(n,a)}var h=l.Typography.Text,b=l.Collapse.Panel,v=function(e){var t,r,o,i=e.initialValues,c=e.onSubmit,s=e.onCancel,m=e.submitting,d=(0,u.bV)().t,p=(t=l.Form.useForm(),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),l.length!==t);o=!0);}catch(e){i=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw n}}return l}}(t,1)||function(e,t){if(e){if("string"==typeof e)return f(e,1);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}}(t,1)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],v=l.Form.useWatch("authType",p),E=l.Form.useWatch("requestFormat",p);(0,n.useEffect)(function(){i&&p.setFieldsValue(i)},[i]);var g=(r=function(){return function(e,t){var r,n,a,l,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(r)throw TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&u[0]?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){o.label=u[1];break}if(6===u[0]&&o.label<a[1]){o.label=a[1],a=u;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(u);break}a[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],n=0}finally{r=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){switch(e.label){case 0:return[4,p.validateFields()];case 1:return[4,c(e.sent())];case 2:return e.sent(),[2]}})},o=function(){var e=this,t=arguments;return new Promise(function(n,a){var l=r.apply(e,t);function o(e){y(l,n,a,o,i,"next",e)}function i(e){y(l,n,a,o,i,"throw",e)}o(void 0)})},function(){return o.apply(this,arguments)});return a().createElement(l.Form,{form:p,layout:"vertical",initialValues:function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({enabled:!0,authType:"bearer",requestFormat:"multipart",responseTextPath:"text",timeout:6e4,requestConfig:{fileFieldName:"file"}},i)},a().createElement(l.Row,{gutter:16},a().createElement(l.Col,{span:18},a().createElement(l.Form.Item,{name:"title",label:d("Provider Title"),rules:[{required:!0}]},a().createElement(l.Input,null))),a().createElement(l.Col,{span:6},a().createElement(l.Form.Item,{name:"enabled",label:d("Enabled"),valuePropName:"checked"},a().createElement(l.Switch,null)))),a().createElement(l.Form.Item,{name:"apiEndpoint",label:d("API Endpoint"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"https://api.ocr-provider.com/v1/parse"})),a().createElement(l.Divider,{orientation:"left",plain:!0},d("Auth Type")),a().createElement(l.Form.Item,{name:"authType",label:d("Auth Type")},a().createElement(l.Select,{options:[{label:"None",value:"none"},{label:"Bearer Token",value:"bearer"},{label:"API Key Header",value:"api-key-header"},{label:"Basic Auth",value:"basic"},{label:"Custom Headers",value:"custom-headers"}],style:{maxWidth:260}})),("bearer"===v||"api-key-header"===v)&&a().createElement(l.Form.Item,{name:"apiKey",label:d("API Key")},a().createElement(l.Input.Password,null)),"api-key-header"===v&&a().createElement(l.Form.Item,{name:["authConfig","headerName"],label:d("Header Name")},a().createElement(l.Input,{placeholder:"X-Api-Key",style:{maxWidth:300}})),"basic"===v&&a().createElement(l.Row,{gutter:16},a().createElement(l.Col,{span:12},a().createElement(l.Form.Item,{name:["authConfig","username"],label:d("Username")},a().createElement(l.Input,null))),a().createElement(l.Col,{span:12},a().createElement(l.Form.Item,{name:["authConfig","password"],label:d("Password")},a().createElement(l.Input.Password,null)))),"custom-headers"===v&&a().createElement(l.Form.Item,{name:["authConfig","customHeaders"],label:d("Custom Headers"),help:a().createElement(h,{type:"secondary"},"JSON: ",'{"X-Tenant": "abc", "X-Secret": "xxx"}')},a().createElement(l.Input.TextArea,{rows:3,placeholder:'{"X-Tenant": "abc"}'})),a().createElement(l.Divider,{orientation:"left",plain:!0},d("Request Format")),a().createElement(l.Form.Item,{name:"requestFormat",label:d("Request Format")},a().createElement(l.Select,{options:[{label:d("Multipart Form Data"),value:"multipart"},{label:d("JSON Base64"),value:"json-base64"},{label:"URL (provider fetches)",value:"url"}],style:{maxWidth:260}})),"multipart"===E&&a().createElement(l.Row,{gutter:16},a().createElement(l.Col,{span:8},a().createElement(l.Form.Item,{name:["requestConfig","fileFieldName"],label:d("Form Field Name")},a().createElement(l.Input,{placeholder:"file"}))),a().createElement(l.Col,{span:8},a().createElement(l.Form.Item,{name:["requestConfig","filenameFieldName"],label:d("Filename Field Path")},a().createElement(l.Input,{placeholder:"(optional)"}))),a().createElement(l.Col,{span:8},a().createElement(l.Form.Item,{name:["requestConfig","mimetypeFieldName"],label:d("Mimetype Field Path")},a().createElement(l.Input,{placeholder:"(optional)"})))),"json-base64"===E&&a().createElement(l.Row,{gutter:16},a().createElement(l.Col,{span:8},a().createElement(l.Form.Item,{name:["requestConfig","base64FieldPath"],label:d("Base64 Field Path")},a().createElement(l.Input,{placeholder:"file"}))),a().createElement(l.Col,{span:8},a().createElement(l.Form.Item,{name:["requestConfig","filenameFieldPath"],label:d("Filename Field Path")},a().createElement(l.Input,{placeholder:"filename"}))),a().createElement(l.Col,{span:8},a().createElement(l.Form.Item,{name:["requestConfig","mimetypeFieldPath"],label:d("Mimetype Field Path")},a().createElement(l.Input,{placeholder:"mimetype"})))),"url"===E&&a().createElement(l.Form.Item,{name:["requestConfig","urlFieldPath"],label:d("Base64 Field Path").replace("Base64","URL")},a().createElement(l.Input,{placeholder:"url",style:{maxWidth:300}})),a().createElement(l.Collapse,{ghost:!0},a().createElement(b,{header:d("Extra Request Body"),key:"extra"},a().createElement(l.Form.Item,{name:["requestConfig","multipart"===E?"extraFields":"extraBody"],help:a().createElement(h,{type:"secondary"},"JSON object — merged into request body/fields")},a().createElement(l.Input.TextArea,{rows:4,placeholder:'{"lang": "vie+eng"}'})))),a().createElement(l.Divider,{orientation:"left",plain:!0},"Response"),a().createElement(l.Row,{gutter:16},a().createElement(l.Col,{span:16},a().createElement(l.Form.Item,{name:"responseTextPath",label:d("Response Text Path"),help:a().createElement(h,{type:"secondary"},'Dot-path, e.g. "data.text" or "result.pages.0.content"')},a().createElement(l.Input,{placeholder:"text"}))),a().createElement(l.Col,{span:8},a().createElement(l.Form.Item,{name:"timeout",label:d("Timeout (ms)")},a().createElement(l.InputNumber,{min:1e3,step:5e3,style:{width:"100%"}})))),a().createElement(l.Divider,{orientation:"left",plain:!0},"Scope"),a().createElement(l.Form.Item,{name:"supportedMimetypes",label:d("Supported MIME Types"),help:d("Leave empty to handle all non-image types")},a().createElement(l.Select,{mode:"tags",tokenSeparators:[","],placeholder:"application/pdf, application/vnd.openxmlformats...",style:{width:"100%"},options:[{label:"PDF",value:"application/pdf"},{label:"DOCX",value:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},{label:"XLSX",value:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},{label:"PPTX",value:"application/vnd.openxmlformats-officedocument.presentationml.presentation"},{label:"Plain text",value:"text/plain"},{label:"HTML",value:"text/html"}]})),a().createElement(l.Form.Item,{style:{marginBottom:0,marginTop:24}},a().createElement(l.Space,null,a().createElement(l.Button,{type:"primary",onClick:g,loading:m},"Save"),a().createElement(l.Button,{onClick:s},"Cancel"))))};function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function g(e,t,r,n,a,l,o){try{var i=e[l](o),u=i.value}catch(e){r(e);return}i.done?t(u):Promise.resolve(u).then(n,a)}function P(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function o(e){g(l,n,a,o,i,"next",e)}function i(e){g(l,n,a,o,i,"throw",e)}o(void 0)})}}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){i=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(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 F(e,t){var r,n,a,l,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(r)throw TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&u[0]?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){o.label=u[1];break}if(6===u[0]&&o.label<a[1]){o.label=a[1],a=u;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(u);break}a[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],n=0}finally{r=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var I=function(){var e,t,r,c,s=(0,u.bV)().t,m=(0,i.useAPIClient)(),d=S((0,n.useState)([]),2),p=d[0],f=d[1],y=S((0,n.useState)(!0),2),h=y[0],b=y[1],E=S((0,n.useState)(!1),2),g=E[0],I=E[1],w=S((0,n.useState)(null),2),x=w[0],C=w[1],T=S((0,n.useState)(!1),2),k=T[0],A=T[1],O=S((0,n.useState)(null),2),q=O[0],D=O[1],B=(e=P(function(){var e,t,r;return F(this,function(n){switch(n.label){case 0:b(!0),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,m.request({url:"docParserProviders:list",params:{pageSize:200}})];case 2:return f(null!=(r=null==(t=n.sent())||null==(e=t.data)?void 0:e.data)?r:[]),[3,4];case 3:return b(!1),[7];case 4:return[2]}})}),function(){return e.apply(this,arguments)});(0,n.useEffect)(function(){B()},[]);var R=function(e){C(e),I(!0)},j=(t=P(function(e){return F(this,function(t){switch(t.label){case 0:return[4,m.request({url:"docParserProviders:destroy",method:"DELETE",params:{filterByTk:e}})];case 1:return t.sent(),l.message.success(s("Provider deleted")),B(),[2]}})}),function(e){return t.apply(this,arguments)}),_=(r=P(function(e){return F(this,function(t){switch(t.label){case 0:A(!0),t.label=1;case 1:if(t.trys.push([1,,6,7]),!x)return[3,3];return[4,m.request({url:"docParserProviders:update",method:"POST",params:{filterByTk:x.id},data:e})];case 2:return t.sent(),[3,5];case 3:return[4,m.request({url:"docParserProviders:create",method:"POST",data:e})];case 4:t.sent(),t.label=5;case 5:return l.message.success(s("Provider saved")),I(!1),B(),[3,7];case 6:return A(!1),[7];case 7:return[2]}})}),function(e){return r.apply(this,arguments)}),N=(c=P(function(e){var t,r,n,a,o;return F(this,function(i){switch(i.label){case 0:D(e.id),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,m.request({url:"docParserProviders:testConnection",params:{filterByTk:e.id}})];case 2:return(null==(n=null==(r=i.sent())||null==(t=r.data)?void 0:t.data)?void 0:n.ok)?l.message.success("".concat(s("Connection successful")).concat(n.status?" (HTTP ".concat(n.status,")"):"")):l.message.error("".concat(s("Connection failed"),": ").concat(null!=(a=null==n?void 0:n.message)?a:"Unknown error")),[3,5];case 3:return o=i.sent(),l.message.error("".concat(s("Connection failed"),": ").concat(null==o?void 0:o.message)),[3,5];case 4:return D(null),[7];case 5:return[2]}})}),function(e){return c.apply(this,arguments)}),z=[{title:s("Provider Title"),dataIndex:"title",key:"title",render:function(e,t){return a().createElement(l.Space,null,a().createElement(l.Badge,{status:t.enabled?"success":"default"}),e)}},{title:s("API Endpoint"),dataIndex:"apiEndpoint",key:"apiEndpoint",ellipsis:!0},{title:s("Auth Type"),dataIndex:"authType",key:"authType",render:function(e){return a().createElement(l.Tag,null,e)}},{title:s("Request Format"),dataIndex:"requestFormat",key:"requestFormat",render:function(e){return a().createElement(l.Tag,{color:"blue"},e)}},{title:s("Enabled"),dataIndex:"enabled",key:"enabled",render:function(e){return e?a().createElement(o.CheckCircleOutlined,{style:{color:"#52c41a"}}):a().createElement(o.CloseCircleOutlined,{style:{color:"#ccc"}})}},{title:"Actions",key:"actions",render:function(e,t){return a().createElement(l.Space,null,a().createElement(l.Tooltip,{title:s("Test Connection")},a().createElement(l.Button,{size:"small",icon:a().createElement(o.ApiOutlined,null),loading:q===t.id,onClick:function(){return N(t)}})),a().createElement(l.Tooltip,{title:s("Edit Provider")},a().createElement(l.Button,{size:"small",icon:a().createElement(o.EditOutlined,null),onClick:function(){return R(t)}})),a().createElement(l.Popconfirm,{title:s("Delete Provider"),description:"Are you sure you want to delete this provider?",onConfirm:function(){return j(t.id)}},a().createElement(l.Tooltip,{title:s("Delete Provider")},a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(o.DeleteOutlined,null)}))))}}];return a().createElement(a().Fragment,null,a().createElement("div",{style:{marginBottom:16,display:"flex",justifyContent:"flex-end"}},a().createElement(l.Button,{type:"primary",icon:a().createElement(o.PlusOutlined,null),onClick:function(){C(null),I(!0)}},s("Add Provider"))),a().createElement(l.Table,{rowKey:"id",dataSource:p,columns:z,loading:h,pagination:!1,locale:{emptyText:s("No providers configured")},size:"middle"}),a().createElement(l.Modal,{open:g,title:x?s("Edit Provider"):s("Add Provider"),onCancel:function(){return I(!1)},footer:null,width:720,destroyOnClose:!0},a().createElement(v,{initialValues:null!=x?x:void 0,onSubmit:_,onCancel:function(){return I(!1)},submitting:k})))},w=function(){var e=(0,u.bV)().t,t=[{key:"global",label:a().createElement("span",null,a().createElement(o.SettingOutlined,null),e("Global Settings")),children:a().createElement(p,null)},{key:"providers",label:a().createElement("span",null,a().createElement(o.ApiOutlined,null),e("OCR Providers")),children:a().createElement("div",{style:{padding:"8px 0"}},a().createElement(I,null))}];return a().createElement("div",{style:{padding:24}},a().createElement(l.Tabs,{items:t,defaultActiveKey:"global"}))}}}]);
|
|
@@ -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
|
+
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("plugin-document-parser",["@nocobase/client","react","@ant-design/icons","antd","react-i18next"],t):"object"==typeof exports?exports["plugin-document-parser"]=t(require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):e["plugin-document-parser"]=t(e["@nocobase/client"],e.react,e["@ant-design/icons"],e.antd,e["react-i18next"])}(self,function(e,t,n,r,o){return function(){var u,i,c,a,f,s,l,p,d={990:function(e,t,n){"use strict";n.d(t,{A7:function(){return o},bV:function(){return u}}),n(772);var r=n(238),o="plugin-document-parser";function u(){return(0,r.useTranslation)(o)}},581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},967:function(e,t,n){var r={"./vi-VN.json":["346","637"],"./en-US.json":["928","264"]};function o(e){if(!n.o(r,e))return Promise.resolve().then(function(){var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t});var t=r[e],o=t[0];return n.e(t[1]).then(function(){return n.t(o,19)})}o.keys=function(){return Object.keys(r)},o.id=967,e.exports=o},482:function(e){"use strict";e.exports=n},772:function(t){"use strict";t.exports=e},721:function(e){"use strict";e.exports=r},156:function(e){"use strict";e.exports=t},238:function(e){"use strict";e.exports=o}},b={};function y(e){var t=b[e];if(void 0!==t)return t.exports;var n=b[e]={exports:{}};return d[e](n,n.exports,y),n.exports}y.m=d,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},i=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},y.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var n=Object.create(null);y.r(n);var r={};u=u||[null,i({}),i([]),i(i)];for(var o=2&t&&e;"object"==typeof o&&!~u.indexOf(o);o=i(o))Object.getOwnPropertyNames(o).forEach(function(t){r[t]=function(){return e[t]}});return r.default=function(){return e},y.d(n,r),n},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return""+({264:"01b8a5798a872638",637:"022be20abc96fdb4",998:"12e97e7a84d900e0"})[e]+".js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c={},a="plugin-document-parser:",y.l=function(e,t,n,r){if(c[e])return void c[e].push(t);if(void 0!==n)for(var o,u,i=document.getElementsByTagName("script"),f=0;f<i.length;f++){var s=i[f];if(s.getAttribute("src")==e||s.getAttribute("data-webpack")==a+n){o=s;break}}o||(u=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-webpack",a+n),o.src=e),c[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=c[e];if(delete c[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),u&&document.head.appendChild(o)},y.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(f=window.__webpack_public_path__||"/").endsWith("/")||(f+="/"),y.p=f+"static/plugins/plugin-document-parser/dist/client/",s={909:0},y.f.j=function(e,t){var n=y.o(s,e)?s[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=s[e]=[t,r]});t.push(n[2]=r);var o=y.p+y.u(e),u=Error();y.l(o,function(t){if(y.o(s,e)&&(0!==(n=s[e])&&(s[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;u.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",u.name="ChunkLoadError",u.type=r,u.request=o,n[1](u)}},"chunk-"+e,e)}},l=function(e,t){var n,r,o=t[0],u=t[1],i=t[2],c=0;if(o.some(function(e){return 0!==s[e]})){for(n in u)y.o(u,n)&&(y.m[n]=u[n]);i&&i(y)}for(e&&e(t);c<o.length;c++)r=o[c],y.o(s,r)&&s[r]&&s[r][0](),s[r]=0},(p=self.webpackChunkplugin_document_parser=self.webpackChunkplugin_document_parser||[]).forEach(l.bind(null,0)),p.push=l.bind(null,p.push.bind(p));var h={};return!function(){"use strict";y.r(h),y.d(h,{PluginDocumentParserClient:function(){return p},default:function(){return d}});var e=y(772),t=y(990),n=y(581);function r(e,t,n,r,o,u,i){try{var c=e[u](i),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise(function(o,u){var i=e.apply(t,n);function c(e){r(i,o,u,c,a,"next",e)}function a(e){r(i,o,u,c,a,"throw",e)}c(void 0)})}}function u(e,t,n){return(u=f()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(e){var t="function"==typeof Map?new Map:void 0;return(a=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 u(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function s(e,t){var n,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(u){return function(c){var a=[u,c];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}var l=(0,e.lazy)(function(){return n("imported_1bu5oln_component",y.e("998").then(y.bind(y,945)))},"SettingsPage"),p=function(e){var r;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function u(){var e,t;if(!(this instanceof u))throw TypeError("Cannot call a class as a function");return e=u,t=arguments,e=i(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,f()?Reflect.construct(e,t||[],i(this).constructor):e.apply(this,t))}return u.prototype=Object.create(e&&e.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),e&&c(u,e),r=[{key:"afterAdd",value:function(){var e=this;return o(function(){return s(this,function(t){switch(t.label){case 0:return[4,e.app.i18n.changeLanguage(e.app.i18n.language)];case 1:return t.sent(),[2]}})})()}},{key:"load",value:function(){var e=this;return o(function(){var r,o;return s(this,function(u){switch(u.label){case 0:r=e.app.i18n.language||"en-US",u.label=1;case 1:return u.trys.push([1,3,,4]),[4,y(967)("./".concat(r,".json")).catch(function(){return n("imported_12o1hlb_component",y.e("264").then(y.t.bind(y,928,19)))})];case 2:return o=u.sent(),e.app.i18n.addResourceBundle(r,t.A7,o.default||o,!0,!0),[3,4];case 3:return u.sent(),[3,4];case 4:return e.app.pluginSettingsManager.add(t.A7,{title:'{{t("Document Parser", { ns: "'+t.A7+'" })}}',icon:"FileTextOutlined",Component:l,aclSnippet:"pm.".concat(t.A7,".settings")}),[2]}})})()}}],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)}}(u.prototype,r),u}(a(e.Plugin)),d=p}(),h}()});
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
module.exports = {
|
|
11
|
+
"@nocobase/client": "2.0.32",
|
|
12
|
+
"react-i18next": "11.18.6",
|
|
13
|
+
"@nocobase/server": "2.0.32",
|
|
14
|
+
"@nocobase/actions": "2.0.32",
|
|
15
|
+
"axios": "1.14.0",
|
|
16
|
+
"react": "18.3.1",
|
|
17
|
+
"antd": "5.24.2",
|
|
18
|
+
"@ant-design/icons": "5.6.1",
|
|
19
|
+
"@nocobase/database": "2.0.32"
|
|
20
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var src_exports = {};
|
|
39
|
+
__export(src_exports, {
|
|
40
|
+
default: () => import_server.default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(src_exports);
|
|
43
|
+
__reExport(src_exports, require("./server"), module.exports);
|
|
44
|
+
var import_server = __toESM(require("./server"));
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
...require("./server")
|
|
48
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Document Parser": "Document Parser",
|
|
3
|
+
"Processing Mode": "Processing Mode",
|
|
4
|
+
"Default (plugin-ai built-in)": "Default (plugin-ai built-in)",
|
|
5
|
+
"Internal (built-in document loaders)": "Internal (built-in document loaders)",
|
|
6
|
+
"External (OCR API provider)": "External (OCR API provider)",
|
|
7
|
+
"Active Provider": "Active Provider",
|
|
8
|
+
"Fallback to default on error": "Fallback to default on error",
|
|
9
|
+
"Pass images through to default": "Pass images through to default",
|
|
10
|
+
"OCR Providers": "OCR Providers",
|
|
11
|
+
"Add Provider": "Add Provider",
|
|
12
|
+
"Edit Provider": "Edit Provider",
|
|
13
|
+
"Delete Provider": "Delete Provider",
|
|
14
|
+
"Test Connection": "Test Connection",
|
|
15
|
+
"Provider Title": "Provider Title",
|
|
16
|
+
"API Endpoint": "API Endpoint",
|
|
17
|
+
"API Key": "API Key",
|
|
18
|
+
"Auth Type": "Auth Type",
|
|
19
|
+
"Bearer Token": "Bearer Token",
|
|
20
|
+
"API Key Header": "API Key Header",
|
|
21
|
+
"Basic Auth": "Basic Auth",
|
|
22
|
+
"Custom Header": "Custom Header",
|
|
23
|
+
"Header Name": "Header Name",
|
|
24
|
+
"Username": "Username",
|
|
25
|
+
"Password": "Password",
|
|
26
|
+
"Custom Headers": "Custom Headers",
|
|
27
|
+
"Request Format": "Request Format",
|
|
28
|
+
"Multipart Form Data": "Multipart Form Data",
|
|
29
|
+
"JSON Base64": "JSON Base64",
|
|
30
|
+
"Form Field Name": "Form Field Name",
|
|
31
|
+
"Base64 Field Path": "Base64 Field Path",
|
|
32
|
+
"Filename Field Path": "Filename Field Path",
|
|
33
|
+
"Mimetype Field Path": "Mimetype Field Path",
|
|
34
|
+
"Extra Request Body": "Extra Request Body",
|
|
35
|
+
"Response Text Path": "Response Text Path",
|
|
36
|
+
"Timeout (ms)": "Timeout (ms)",
|
|
37
|
+
"Supported MIME Types": "Supported MIME Types",
|
|
38
|
+
"Leave empty to handle all non-image types": "Leave empty to handle all non-image types",
|
|
39
|
+
"Connection successful": "Connection successful",
|
|
40
|
+
"Connection failed": "Connection failed",
|
|
41
|
+
"Global Settings": "Global Settings",
|
|
42
|
+
"Provider Configuration": "Provider Configuration",
|
|
43
|
+
"Enabled": "Enabled",
|
|
44
|
+
"No providers configured": "No providers configured",
|
|
45
|
+
"Please select a provider": "Please select a provider",
|
|
46
|
+
"Settings saved": "Settings saved",
|
|
47
|
+
"Provider saved": "Provider saved",
|
|
48
|
+
"Provider deleted": "Provider deleted",
|
|
49
|
+
"mode_default_desc": "Use the built-in attachment processing from plugin-ai (default behavior).",
|
|
50
|
+
"mode_internal_desc": "Parse documents using built-in loaders (PDF, DOCX, PPT, TXT) or custom parsers registered by other plugins.",
|
|
51
|
+
"mode_external_desc": "Send files to a configured external OCR/parse API and use the returned text as attachment content.",
|
|
52
|
+
"Index with DocPixie (when available)": "Index with DocPixie (when available)",
|
|
53
|
+
"docpixie_mode_desc": "When plugin-docpixie is active, automatically index attached documents and instruct the AI to use the docpixie:query tool instead of reading raw file content. Applies before the processing mode above."
|
|
54
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Document Parser": "Trình xử lý tài liệu",
|
|
3
|
+
"Processing Mode": "Chế độ xử lý",
|
|
4
|
+
"Default (plugin-ai built-in)": "Mặc định (plugin-ai tích hợp sẵn)",
|
|
5
|
+
"Internal (built-in document loaders)": "Nội bộ (trình đọc tài liệu tích hợp)",
|
|
6
|
+
"External (OCR API provider)": "Bên ngoài (nhà cung cấp OCR API)",
|
|
7
|
+
"Active Provider": "Nhà cung cấp đang dùng",
|
|
8
|
+
"Fallback to default on error": "Dùng mặc định khi lỗi",
|
|
9
|
+
"Pass images through to default": "Chuyển hình ảnh qua xử lý mặc định",
|
|
10
|
+
"OCR Providers": "Nhà cung cấp OCR",
|
|
11
|
+
"Add Provider": "Thêm nhà cung cấp",
|
|
12
|
+
"Edit Provider": "Chỉnh sửa nhà cung cấp",
|
|
13
|
+
"Delete Provider": "Xóa nhà cung cấp",
|
|
14
|
+
"Test Connection": "Kiểm tra kết nối",
|
|
15
|
+
"Provider Title": "Tên nhà cung cấp",
|
|
16
|
+
"API Endpoint": "Địa chỉ API",
|
|
17
|
+
"API Key": "Khóa API",
|
|
18
|
+
"Auth Type": "Loại xác thực",
|
|
19
|
+
"Bearer Token": "Bearer Token",
|
|
20
|
+
"API Key Header": "Header API Key",
|
|
21
|
+
"Basic Auth": "Basic Auth",
|
|
22
|
+
"Custom Header": "Header tùy chỉnh",
|
|
23
|
+
"Header Name": "Tên header",
|
|
24
|
+
"Username": "Tên đăng nhập",
|
|
25
|
+
"Password": "Mật khẩu",
|
|
26
|
+
"Custom Headers": "Headers tùy chỉnh",
|
|
27
|
+
"Request Format": "Định dạng yêu cầu",
|
|
28
|
+
"Multipart Form Data": "Multipart Form Data",
|
|
29
|
+
"JSON Base64": "JSON Base64",
|
|
30
|
+
"Form Field Name": "Tên trường form",
|
|
31
|
+
"Base64 Field Path": "Đường dẫn trường Base64",
|
|
32
|
+
"Filename Field Path": "Đường dẫn tên file",
|
|
33
|
+
"Mimetype Field Path": "Đường dẫn MIME type",
|
|
34
|
+
"Extra Request Body": "Body yêu cầu thêm",
|
|
35
|
+
"Response Text Path": "Đường dẫn text trong phản hồi",
|
|
36
|
+
"Timeout (ms)": "Timeout (ms)",
|
|
37
|
+
"Supported MIME Types": "MIME Types được hỗ trợ",
|
|
38
|
+
"Leave empty to handle all non-image types": "Để trống để xử lý tất cả loại không phải ảnh",
|
|
39
|
+
"Connection successful": "Kết nối thành công",
|
|
40
|
+
"Connection failed": "Kết nối thất bại",
|
|
41
|
+
"Global Settings": "Cài đặt chung",
|
|
42
|
+
"Provider Configuration": "Cấu hình nhà cung cấp",
|
|
43
|
+
"Enabled": "Kích hoạt",
|
|
44
|
+
"No providers configured": "Chưa có nhà cung cấp nào",
|
|
45
|
+
"Please select a provider": "Vui lòng chọn nhà cung cấp",
|
|
46
|
+
"Settings saved": "Đã lưu cài đặt",
|
|
47
|
+
"Provider saved": "Đã lưu nhà cung cấp",
|
|
48
|
+
"Provider deleted": "Đã xóa nhà cung cấp",
|
|
49
|
+
"Index with DocPixie (when available)": "Lập chỉ mục qua DocPixie (nếu có)",
|
|
50
|
+
"docpixie_mode_desc": "Khi plugin-docpixie đang hoạt động, tự động lập chỉ mục tài liệu đính kèm và hướng dẫn AI dùng công cụ docpixie:query thay vì đọc nội dung thô. Được áp dụng trước chế độ xử lý bên trên.",
|
|
51
|
+
"mode_default_desc": "Dùng chức năng xử lý tệp đính kèm mặc định của plugin-ai.",
|
|
52
|
+
"mode_internal_desc": "Phân tích tài liệu dùng trình đọc tích hợp (PDF, DOCX, PPT, TXT) hoặc các parser tùy chỉnh từ plugin khác.",
|
|
53
|
+
"mode_external_desc": "Gửi tệp đến API OCR/parse bên ngoài đã cấu hình và dùng văn bản trả về làm nội dung đính kèm."
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
|
|
2
|
+
// Leon Yu <https://github.com/leonyu>
|
|
3
|
+
// BendingBender <https://github.com/BendingBender>
|
|
4
|
+
// Maple Miao <https://github.com/mapleeit>
|
|
5
|
+
|
|
6
|
+
/// <reference types="node" />
|
|
7
|
+
import * as stream from 'stream';
|
|
8
|
+
import * as http from 'http';
|
|
9
|
+
|
|
10
|
+
export = FormData;
|
|
11
|
+
|
|
12
|
+
// Extracted because @types/node doesn't export interfaces.
|
|
13
|
+
interface ReadableOptions {
|
|
14
|
+
highWaterMark?: number;
|
|
15
|
+
encoding?: string;
|
|
16
|
+
objectMode?: boolean;
|
|
17
|
+
read?(this: stream.Readable, size: number): void;
|
|
18
|
+
destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => void): void;
|
|
19
|
+
autoDestroy?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Options extends ReadableOptions {
|
|
23
|
+
writable?: boolean;
|
|
24
|
+
readable?: boolean;
|
|
25
|
+
dataSize?: number;
|
|
26
|
+
maxDataSize?: number;
|
|
27
|
+
pauseStreams?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare class FormData extends stream.Readable {
|
|
31
|
+
constructor(options?: Options);
|
|
32
|
+
append(key: string, value: any, options?: FormData.AppendOptions | string): void;
|
|
33
|
+
getHeaders(userHeaders?: FormData.Headers): FormData.Headers;
|
|
34
|
+
submit(
|
|
35
|
+
params: string | FormData.SubmitOptions,
|
|
36
|
+
callback?: (error: Error | null, response: http.IncomingMessage) => void
|
|
37
|
+
): http.ClientRequest;
|
|
38
|
+
getBuffer(): Buffer;
|
|
39
|
+
setBoundary(boundary: string): void;
|
|
40
|
+
getBoundary(): string;
|
|
41
|
+
getLength(callback: (err: Error | null, length: number) => void): void;
|
|
42
|
+
getLengthSync(): number;
|
|
43
|
+
hasKnownLength(): boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare namespace FormData {
|
|
47
|
+
interface Headers {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface AppendOptions {
|
|
52
|
+
header?: string | Headers;
|
|
53
|
+
knownLength?: number;
|
|
54
|
+
filename?: string;
|
|
55
|
+
filepath?: string;
|
|
56
|
+
contentType?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface SubmitOptions extends http.RequestOptions {
|
|
60
|
+
protocol?: 'https:' | 'http:';
|
|
61
|
+
}
|
|
62
|
+
}
|