plugin-document-understanding 1.1.7 → 1.1.9

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.
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@nocobase/client")):"function"==typeof define&&define.amd?define("plugin-document-understanding",["@nocobase/client"],e):"object"==typeof exports?exports["plugin-document-understanding"]=e(require("@nocobase/client")):t["plugin-document-understanding"]=e(t["@nocobase/client"])}(self,function(t){return function(){"use strict";var e={342:function(e){e.exports=t}},n={};function r(t){var o=n[t];if(void 0!==o)return o.exports;var i=n[t]={exports:{}};return e[t](i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.g.importScripts&&(o=r.g.location+"");var o,i=r.g.document;if(!o&&i&&(i.currentScript&&"SCRIPT"===i.currentScript.tagName.toUpperCase()&&(o=i.currentScript.src),!o)){var u=i.getElementsByTagName("script");if(u.length)for(var c=u.length-1;c>-1&&(!o||!/^http(s?):/.test(o));)o=u[c--].src}if(!o)throw Error("Automatic publicPath is not supported in this browser");r.p=o.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var a={};return!function(){var t="",e="u">typeof document?document.currentScript:null;if(e&&e.src&&(t=e.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!t){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),t=n+"static/plugins/plugin-document-understanding/dist/client/")}if(!t){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(t=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",c=u.indexOf(i);t=c>=0?u.slice(0,c+1):"/"}t&&(t=t.replace(RegExp("/"+o+"/?$"),"/")),t||(t="/"),"/"!==t.charAt(t.length-1)&&(t+="/"),t+="static/plugins/plugin-document-understanding/dist/client/"}r.p=t}(),!function(){r.r(a),r.d(a,{PluginDocumentUnderstandingClient:function(){return l}});var t=r(342);function e(t,e,n,r,o,i,u){try{var c=t[i](u),a=c.value}catch(t){n(t);return}c.done?e(a):Promise.resolve(a).then(r,o)}function n(t,e,r){return(n=c()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&i(o,n.prototype),o}).apply(null,arguments)}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return n(t,arguments,o(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,t)})(t)}function c(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(c=function(){return!!t})()}var l=function(t){var n;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function r(){var t,e;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return t=r,e=arguments,t=o(t),function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,c()?Reflect.construct(t,e||[],o(this).constructor):t.apply(this,e))}return r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),t&&i(r,t),n=[{key:"load",value:function(){var t;return(t=function(){return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=e.call(t,i)}catch(t){l=[6,t],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(t){return[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var u=t.apply(n,r);function c(t){e(u,o,i,c,a,"next",t)}function a(t){e(u,o,i,c,a,"throw",t)}c(void 0)})})()}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,n),r}(u(t.Plugin));a.default=l}(),a}()});
10
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@nocobase/client")):"function"==typeof define&&define.amd?define("plugin-document-understanding",["@nocobase/client"],e):"object"==typeof exports?exports["plugin-document-understanding"]=e(require("@nocobase/client")):t["plugin-document-understanding"]=e(t["@nocobase/client"])}(self,function(t){return function(){"use strict";var e={342:function(e){e.exports=t}},n={};function r(t){var o=n[t];if(void 0!==o)return o.exports;var i=n[t]={exports:{}};return e[t](i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.g.importScripts&&(o=r.g.location+"");var o,i=r.g.document;if(!o&&i&&(i.currentScript&&"SCRIPT"===i.currentScript.tagName.toUpperCase()&&(o=i.currentScript.src),!o)){var u=i.getElementsByTagName("script");if(u.length)for(var c=u.length-1;c>-1&&(!o||!/^http(s?):/.test(o));)o=u[c--].src}if(!o)throw Error("Automatic publicPath is not supported in this browser");r.p=o.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var a={};return!function(){var t="",e="u">typeof document?document.currentScript:null;if(e&&e.src){var n=e.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-document-understanding/dist/client/")>=0&&(t=n.replace(/\/[^\/]+$/,"/"))}if(!t){var o=window.__webpack_public_path__||"";o&&("/"!==o.charAt(o.length-1)&&(o+="/"),t=o+"static/plugins/plugin-document-understanding/dist/client/")}if(!t){var i=window.__nocobase_modern_client_prefix__||"v",u="/"+(i=String(i).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(t=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var c=window.location.pathname||"/",a=c.indexOf(u);t=a>=0?c.slice(0,a+1):"/"}t&&(t=t.replace(RegExp("/"+i+"/?$"),"/")),t||(t="/"),"/"!==t.charAt(t.length-1)&&(t+="/"),t+="static/plugins/plugin-document-understanding/dist/client/"}r.p=t}(),!function(){r.r(a),r.d(a,{PluginDocumentUnderstandingClient:function(){return l}});var t=r(342);function e(t,e,n,r,o,i,u){try{var c=t[i](u),a=c.value}catch(t){n(t);return}c.done?e(a):Promise.resolve(a).then(r,o)}function n(t,e,r){return(n=c()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&i(o,n.prototype),o}).apply(null,arguments)}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return n(t,arguments,o(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,t)})(t)}function c(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(c=function(){return!!t})()}var l=function(t){var n;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function r(){var t,e;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return t=r,e=arguments,t=o(t),function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,c()?Reflect.construct(t,e||[],o(this).constructor):t.apply(this,e))}return r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),t&&i(r,t),n=[{key:"load",value:function(){var t;return(t=function(){return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=e.call(t,i)}catch(t){l=[6,t],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(t){return[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var u=t.apply(n,r);function c(t){e(u,o,i,c,a,"next",t)}function a(t){e(u,o,i,c,a,"throw",t)}c(void 0)})})()}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,n),r}(u(t.Plugin));a.default=l}(),a}()});
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("plugin-document-understanding/client-v2",["@nocobase/client-v2","react","antd","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["plugin-document-understanding/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["plugin-document-understanding/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,u,c,a={375:function(e){e.exports=r},485:function(t){t.exports=e},694:function(e){e.exports=o},59:function(e){e.exports=n},155:function(e){e.exports=t}},l={};function s(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return a[e](n,n.exports,s),n.exports}s.m=a,s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=function(e){return Promise.all(Object.keys(s.f).reduce(function(t,n){return s.f[n](e,t),t},[]))},s.u=function(e){return""+e+".9b984a25b2fc7c14.js"},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={},s.l=function(e,t,n,r){if(f[e])return void f[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="plugin-document-understanding/client-v2:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-rspack","plugin-document-understanding/client-v2:"+n),o.src=e),f[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=f[e];if(delete f[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),i&&document.head.appendChild(o)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(p=s.g.location+"");var f,p,d=s.g.document;if(!p&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(p=d.currentScript.src),!p)){var b=d.getElementsByTagName("script");if(b.length)for(var g=b.length-1;g>-1&&(!p||!/^http(s?):/.test(p));)p=b[g--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");s.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},s.f.j=function(e,t){var n=s.o(i,e)?i[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=s.p+s.u(e),u=Error();s.l(o,function(t){if(s.o(i,e)&&(0!==(n=i[e])&&(i[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)}},u=function(e,t){var n,r,o=t[0],u=t[1],c=t[2],a=0;if(o.some(function(e){return 0!==i[e]})){for(n in u)s.o(u,n)&&(s.m[n]=u[n]);c&&c(s)}for(e&&e(t);a<o.length;a++)r=o[a],s.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(c=self.webpackChunkplugin_document_understanding_client_v2=self.webpackChunkplugin_document_understanding_client_v2||[]).forEach(u.bind(null,0)),c.push=u.bind(null,c.push.bind(c));var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/plugin-document-understanding/dist/client-v2/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",u=i.indexOf(o);e=u>=0?i.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-document-understanding/dist/client-v2/"}s.p=e}(),!function(){s.r(v),s.d(v,{default:function(){return c}});var e=s(485);function t(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function n(e,t,r){return(n=u()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=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,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}var c=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,u()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.addMenuItem({key:"document-understanding",title:this.t("Document Understanding"),icon:"FileSearchOutlined",aclSnippet:"pm.document-understanding"}),this.pluginSettingsManager.addPageTabItem({menuKey:"document-understanding",key:"index",title:this.t("Document Understanding"),componentLoader:function(){return s.e("794").then(s.bind(s,441))}}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var u=e.apply(n,r);function c(e){t(u,o,i,c,a,"next",e)}function a(e){t(u,o,i,c,a,"throw",e)}c(void 0)})}).call(this)}}],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)}}(i.prototype,n),i}(i(e.Plugin))}(),v}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("plugin-document-understanding/client-v2",["@nocobase/client-v2","react","antd","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["plugin-document-understanding/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["plugin-document-understanding/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,u,c,a={375:function(e){e.exports=r},485:function(t){t.exports=e},694:function(e){e.exports=o},59:function(e){e.exports=n},155:function(e){e.exports=t}},l={};function s(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return a[e](n,n.exports,s),n.exports}s.m=a,s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=function(e){return Promise.all(Object.keys(s.f).reduce(function(t,n){return s.f[n](e,t),t},[]))},s.u=function(e){return""+e+".9b984a25b2fc7c14.js"},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={},s.l=function(e,t,n,r){if(f[e])return void f[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="plugin-document-understanding/client-v2:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-rspack","plugin-document-understanding/client-v2:"+n),o.src=e),f[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=f[e];if(delete f[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),i&&document.head.appendChild(o)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(p=s.g.location+"");var f,p,d=s.g.document;if(!p&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(p=d.currentScript.src),!p)){var b=d.getElementsByTagName("script");if(b.length)for(var g=b.length-1;g>-1&&(!p||!/^http(s?):/.test(p));)p=b[g--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");s.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},s.f.j=function(e,t){var n=s.o(i,e)?i[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=s.p+s.u(e),u=Error();s.l(o,function(t){if(s.o(i,e)&&(0!==(n=i[e])&&(i[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)}},u=function(e,t){var n,r,o=t[0],u=t[1],c=t[2],a=0;if(o.some(function(e){return 0!==i[e]})){for(n in u)s.o(u,n)&&(s.m[n]=u[n]);c&&c(s)}for(e&&e(t);a<o.length;a++)r=o[a],s.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(c=self.webpackChunkplugin_document_understanding_client_v2=self.webpackChunkplugin_document_understanding_client_v2||[]).forEach(u.bind(null,0)),c.push=u.bind(null,c.push.bind(c));var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-document-understanding/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-document-understanding/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",c=u.indexOf(i);e=c>=0?u.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-document-understanding/dist/client-v2/"}s.p=e}(),!function(){s.r(v),s.d(v,{default:function(){return c}});var e=s(485);function t(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function n(e,t,r){return(n=u()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=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,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}var c=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,u()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.addMenuItem({key:"document-understanding",title:this.t("Document Understanding"),icon:"FileSearchOutlined",aclSnippet:"pm.document-understanding"}),this.pluginSettingsManager.addPageTabItem({menuKey:"document-understanding",key:"index",title:this.t("Document Understanding"),componentLoader:function(){return s.e("794").then(s.bind(s,441))}}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var u=e.apply(n,r);function c(e){t(u,o,i,c,a,"next",e)}function a(e){t(u,o,i,c,a,"throw",e)}c(void 0)})}).call(this)}}],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)}}(i.prototype,n),i}(i(e.Plugin))}(),v}()});
@@ -8,14 +8,14 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.6",
12
- "@nocobase/flow-engine": "2.1.6",
13
- "@nocobase/client-v2": "2.1.6",
14
- "@nocobase/actions": "2.1.6",
15
- "@nocobase/server": "2.1.6",
11
+ "@nocobase/client": "2.1.34",
12
+ "@nocobase/flow-engine": "2.1.34",
13
+ "@nocobase/client-v2": "2.1.34",
14
+ "@nocobase/actions": "2.1.34",
15
+ "@nocobase/server": "2.1.34",
16
16
  "react": "18.2.0",
17
17
  "antd": "5.24.2",
18
18
  "@ant-design/icons": "5.6.1",
19
- "@nocobase/database": "2.1.6",
20
- "axios": "1.18.0"
19
+ "@nocobase/database": "2.1.34",
20
+ "axios": "1.18.1"
21
21
  };
@@ -34,7 +34,7 @@ const defineActions = (plugin) => {
34
34
  const service = plugin.service;
35
35
  return {
36
36
  async getConfig(ctx, next) {
37
- ctx.body = await service.getConfig();
37
+ ctx.body = await service.getConfigForClient();
38
38
  await next();
39
39
  },
40
40
  async updateConfig(ctx, next) {
@@ -35,31 +35,27 @@ var import_path = require("path");
35
35
  var import_DocumentUnderstandingService = require("./services/DocumentUnderstandingService");
36
36
  var import_actions = require("./actions");
37
37
  var import_document_understanding_tool = require("./tools/document-understanding-tool");
38
- const isAiPluginLike = (plugin) => {
39
- var _a, _b;
40
- const candidate = plugin;
41
- return typeof ((_b = (_a = candidate == null ? void 0 : candidate.ai) == null ? void 0 : _a.toolsManager) == null ? void 0 : _b.registerDynamicTools) === "function";
38
+ const isAiManagerLike = (manager) => {
39
+ var _a;
40
+ const candidate = manager;
41
+ return typeof ((_a = candidate == null ? void 0 : candidate.toolsManager) == null ? void 0 : _a.registerDynamicTools) === "function";
42
42
  };
43
43
  class PluginDocumentUnderstandingServer extends import_server.Plugin {
44
44
  service;
45
+ aiToolsRegistered = false;
46
+ registerAIToolsAfterStart = () => this.registerAITools();
45
47
  async afterAdd() {
46
48
  }
47
49
  async beforeLoad() {
48
- }
49
- async load() {
50
50
  await this.db.import({
51
51
  directory: (0, import_path.resolve)(__dirname, "collections")
52
52
  });
53
+ }
54
+ async load() {
53
55
  this.service = new import_DocumentUnderstandingService.DocumentUnderstandingService(this.app, this.db);
54
- this.app.on("afterStart", async () => {
55
- try {
56
- await this.service.initialize({ recoverJobs: true });
57
- } catch (err) {
58
- this.app.logger.warn("Document Understanding plugin not configured yet, skip init.", err);
59
- }
60
- });
61
56
  this.registerActions();
62
57
  this.registerAITools();
58
+ this.app.on("afterStart", this.registerAIToolsAfterStart);
63
59
  this.app.acl.registerSnippet({
64
60
  name: `pm.${this.name}`,
65
61
  actions: ["docUnderstanding:*"]
@@ -89,18 +85,36 @@ class PluginDocumentUnderstandingServer extends import_server.Plugin {
89
85
  });
90
86
  }
91
87
  registerAITools() {
88
+ if (this.aiToolsRegistered) return;
92
89
  try {
93
- const aiPlugin = this.app.pm.get("@nocobase/plugin-ai");
94
- if (!isAiPluginLike(aiPlugin)) {
90
+ const aiManager = this.app.aiManager;
91
+ if (!isAiManagerLike(aiManager)) {
95
92
  this.app.logger.warn("Document Understanding: plugin-ai not available, skip AI tool registration.");
96
93
  return;
97
94
  }
98
- aiPlugin.ai.toolsManager.registerDynamicTools((0, import_document_understanding_tool.createDynamicPipelineToolsProvider)(this.service));
95
+ const runtimeState = this.app;
96
+ runtimeState.documentUnderstandingService = this.service;
97
+ if (!runtimeState.documentUnderstandingToolProviderRegistered) {
98
+ aiManager.toolsManager.registerDynamicTools(async (register) => {
99
+ const currentService = runtimeState.documentUnderstandingService;
100
+ if (!currentService) return;
101
+ await (0, import_document_understanding_tool.createDynamicPipelineToolsProvider)(currentService)(register);
102
+ });
103
+ runtimeState.documentUnderstandingToolProviderRegistered = true;
104
+ }
105
+ this.aiToolsRegistered = true;
99
106
  this.app.logger.info("Document Understanding: Dynamic pipeline tools provider registered.");
100
107
  } catch (err) {
101
108
  this.app.logger.warn("Document Understanding: Failed to register AI tools, continue without it.", err);
102
109
  }
103
110
  }
111
+ async afterStart() {
112
+ try {
113
+ await this.service.initialize({ recoverJobs: true });
114
+ } catch (err) {
115
+ this.app.logger.warn("Document Understanding plugin not configured yet, skip init.", err);
116
+ }
117
+ }
104
118
  async install() {
105
119
  }
106
120
  async afterEnable() {
@@ -109,6 +123,16 @@ class PluginDocumentUnderstandingServer extends import_server.Plugin {
109
123
  }
110
124
  async remove() {
111
125
  }
126
+ async beforeStop() {
127
+ var _a, _b, _c, _d, _e;
128
+ (_b = (_a = this.app).off) == null ? void 0 : _b.call(_a, "afterStart", this.registerAIToolsAfterStart);
129
+ (_d = (_c = this.app).removeListener) == null ? void 0 : _d.call(_c, "afterStart", this.registerAIToolsAfterStart);
130
+ (_e = this.service) == null ? void 0 : _e.destroy();
131
+ const runtimeState = this.app;
132
+ if (runtimeState.documentUnderstandingService === this.service) {
133
+ runtimeState.documentUnderstandingService = void 0;
134
+ }
135
+ }
112
136
  }
113
137
  var plugin_default = PluginDocumentUnderstandingServer;
114
138
  // Annotate the CommonJS export names for ESM import in node:
@@ -124,14 +124,31 @@ class DocumentUnderstandingService {
124
124
  async getConfig() {
125
125
  return this.ensureConfig();
126
126
  }
127
+ async getConfigForClient() {
128
+ const { authKey, webhookSecret, ...config } = await this.ensureConfig();
129
+ return {
130
+ ...config,
131
+ hasAuthKey: Boolean(authKey),
132
+ hasWebhookSecret: Boolean(webhookSecret)
133
+ };
134
+ }
127
135
  async updateConfig(data) {
128
136
  const configRepo = this.db.getRepository("doc_understanding_config");
129
137
  const conf = await configRepo.findOne();
130
138
  if (conf) {
131
- await configRepo.update({ filterByTk: conf.id, values: data });
139
+ const values = { ...data };
140
+ if (!values.authKey) delete values.authKey;
141
+ if (!values.webhookSecret) delete values.webhookSecret;
142
+ await configRepo.update({ filterByTk: conf.id, values });
132
143
  }
133
144
  await this.initialize();
134
145
  }
146
+ destroy() {
147
+ var _a;
148
+ (_a = this.jobManager) == null ? void 0 : _a.destroy();
149
+ this.initialized = false;
150
+ this.startupRecoveryCompleted = false;
151
+ }
135
152
  async listEndpoints() {
136
153
  await this.ensureInitialized();
137
154
  return this.db.getRepository("doc_understanding_endpoints").find({ sort: "sortOrder" });
@@ -203,14 +220,16 @@ class DocumentUnderstandingService {
203
220
  const job = await this.pipelineExecutor.execute(pipelineId, input, files, userId);
204
221
  return { jobId: job.id };
205
222
  }
206
- async getJobStatus(jobId) {
207
- const job = await this.db.getRepository("doc_understanding_jobs").findOne({ filterByTk: jobId });
223
+ async getJobStatus(jobId, userId) {
224
+ const filter = userId ? { id: jobId, createdById: userId } : { id: jobId };
225
+ const job = await this.db.getRepository("doc_understanding_jobs").findOne({ filter });
208
226
  if (!job) throw new Error("Job not found");
209
227
  return job;
210
228
  }
211
- async listJobs(filters) {
229
+ async listJobs(filters, userId) {
230
+ const filter = userId ? { ...filters || {}, createdById: userId } : filters;
212
231
  return this.db.getRepository("doc_understanding_jobs").find({
213
- filter: filters,
232
+ filter,
214
233
  sort: ["-createdAt"]
215
234
  });
216
235
  }
@@ -42,7 +42,6 @@ __export(PipelineExecutor_exports, {
42
42
  module.exports = __toCommonJS(PipelineExecutor_exports);
43
43
  var import_fs = require("fs");
44
44
  var import_path = require("path");
45
- var import_axios = __toESM(require("axios"));
46
45
  var import_mime_types = __toESM(require("mime-types"));
47
46
  const UPLOAD_ROOTS = [(0, import_path.resolve)(process.cwd(), "storage", "uploads")];
48
47
  const isInsidePath = (basePath, targetPath) => targetPath === basePath || targetPath.startsWith(`${basePath}${import_path.sep}`);
@@ -92,7 +91,7 @@ class PipelineExecutor {
92
91
  this.logger = logger;
93
92
  }
94
93
  async resolveFile(urlOrPath, fieldName = "file") {
95
- var _a, _b;
94
+ var _a, _b, _c, _d;
96
95
  if (!urlOrPath || typeof urlOrPath !== "string") return null;
97
96
  try {
98
97
  const localPath = resolveUploadFilePath(urlOrPath);
@@ -107,39 +106,11 @@ class PipelineExecutor {
107
106
  };
108
107
  }
109
108
  if (urlOrPath.startsWith("http://") || urlOrPath.startsWith("https://")) {
110
- const response = await import_axios.default.get(urlOrPath, { responseType: "arraybuffer" });
111
- const buffer = Buffer.from(response.data);
112
- let filename = "file";
113
- const disposition = response.headers["content-disposition"];
114
- if (disposition && disposition.includes("filename=")) {
115
- const match = disposition.match(/filename="?([^";]+)"?/);
116
- if (match == null ? void 0 : match[1]) {
117
- filename = match[1];
118
- }
119
- } else {
120
- const base = (0, import_path.basename)(new URL(urlOrPath).pathname);
121
- if (base && base.includes(".")) {
122
- filename = base;
123
- }
124
- }
125
- const contentType = response.headers["content-type"] || "application/octet-stream";
126
- const mimeType = contentType.split(";")[0].trim();
127
- if (!filename.includes(".")) {
128
- const extension = import_mime_types.default.extension(mimeType);
129
- if (extension) {
130
- filename = `${filename}.${extension}`;
131
- }
132
- }
133
- return {
134
- fieldName,
135
- buffer,
136
- filename,
137
- mimeType
138
- };
109
+ (_b = (_a = this.logger).warn) == null ? void 0 : _b.call(_a, "Ignoring remote file URL; use a NocoBase upload URL instead.");
139
110
  }
140
111
  } catch (err) {
141
112
  const message = err instanceof Error ? err.message : String(err);
142
- (_b = (_a = this.logger).warn) == null ? void 0 : _b.call(_a, `Failed to resolve file input: ${message}`);
113
+ (_d = (_c = this.logger).warn) == null ? void 0 : _d.call(_c, `Failed to resolve file input: ${message}`);
143
114
  }
144
115
  return null;
145
116
  }
@@ -151,6 +122,7 @@ class PipelineExecutor {
151
122
  appends: ["steps", "steps.endpoint"]
152
123
  });
153
124
  if (!pipeline) throw new Error(`Pipeline ${pipelineId} not found`);
125
+ if (!pipeline.enabled) throw new Error(`Pipeline ${pipelineId} is disabled`);
154
126
  const job = await jobsRepo.create({
155
127
  values: {
156
128
  pipelineId,
@@ -232,6 +204,7 @@ class PipelineExecutor {
232
204
  return job;
233
205
  }
234
206
  async runSteps(job, steps, context, startFromOrder = 1) {
207
+ var _a;
235
208
  const jobsRepo = this.db.getRepository("doc_understanding_jobs");
236
209
  let currentOrder = startFromOrder;
237
210
  try {
@@ -244,6 +217,9 @@ class PipelineExecutor {
244
217
  if (!this.evaluateCondition(step.condition, context)) {
245
218
  continue;
246
219
  }
220
+ if (!((_a = step.endpoint) == null ? void 0 : _a.enabled)) {
221
+ throw new Error(`Endpoint for step ${step.name} is disabled`);
222
+ }
247
223
  const mappedBody = this.resolveMapping(step.inputMapping || {}, context);
248
224
  let retries = step.onError === "retry" ? step.retryCount || 0 : 0;
249
225
  let success = false;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "displayName": "Document Understanding",
4
4
  "displayName.zh-CN": "文档理解",
5
5
  "description": "Configure external document processing endpoints, chain them into pipelines, and expose enabled pipelines as AI tools.",
6
- "version": "1.1.7",
6
+ "version": "1.1.9",
7
7
  "license": "Apache-2.0",
8
8
  "main": "dist/server/index.js",
9
9
  "files": [
@@ -0,0 +1,71 @@
1
+ import { DocumentUnderstandingService } from '../services/DocumentUnderstandingService';
2
+
3
+ describe('DocumentUnderstandingService configuration exposure', () => {
4
+ const config = {
5
+ id: 1,
6
+ baseUrl: 'https://processor.example.com',
7
+ authType: 'bearer',
8
+ authKey: 'super-secret-token',
9
+ webhookSecret: 'webhook-secret',
10
+ defaultTimeout: 30000,
11
+ defaultRetries: 2,
12
+ pollInterval: 5000,
13
+ pollTimeout: 300000,
14
+ };
15
+
16
+ it('does not expose stored secrets to a browser caller', async () => {
17
+ const db = {
18
+ getRepository: () => ({ findOne: vi.fn().mockResolvedValue(config) }),
19
+ };
20
+ const service = new DocumentUnderstandingService({ logger: {} } as never, db as never);
21
+
22
+ await expect(service.getConfigForClient()).resolves.toEqual({
23
+ id: 1,
24
+ baseUrl: 'https://processor.example.com',
25
+ authType: 'bearer',
26
+ authHeaderName: undefined,
27
+ defaultTimeout: 30000,
28
+ defaultRetries: 2,
29
+ pollInterval: 5000,
30
+ pollTimeout: 300000,
31
+ hasAuthKey: true,
32
+ hasWebhookSecret: true,
33
+ });
34
+ });
35
+
36
+ it('keeps existing secrets when an update omits them', async () => {
37
+ const update = vi.fn().mockResolvedValue(undefined);
38
+ const db = {
39
+ getRepository: () => ({ findOne: vi.fn().mockResolvedValue(config), update }),
40
+ };
41
+ const service = new DocumentUnderstandingService({ logger: {} } as never, db as never);
42
+
43
+ await service.updateConfig({ baseUrl: 'https://new-processor.example.com', authKey: '' });
44
+
45
+ expect(update).toHaveBeenCalledWith({
46
+ filterByTk: 1,
47
+ values: { baseUrl: 'https://new-processor.example.com' },
48
+ });
49
+ });
50
+ });
51
+
52
+ function createExecutor(pipeline: Record<string, unknown>) {
53
+ const jobsRepo = { create: vi.fn() };
54
+ const db = {
55
+ getRepository: vi.fn((name: string) =>
56
+ name === 'doc_understanding_pipelines' ? { findOne: vi.fn().mockResolvedValue(pipeline) } : jobsRepo,
57
+ ),
58
+ };
59
+ return { db, jobsRepo };
60
+ }
61
+
62
+ describe('Pipeline execution guards', () => {
63
+ it('rejects a disabled pipeline before creating a job', async () => {
64
+ const { db, jobsRepo } = createExecutor({ id: 1, enabled: false, steps: [] });
65
+ const { PipelineExecutor } = await import('../services/PipelineExecutor');
66
+ const executor = new PipelineExecutor(db as never, {} as never, {} as never, { error: vi.fn() });
67
+
68
+ await expect(executor.execute(1, {})).rejects.toThrow('disabled');
69
+ expect(jobsRepo.create).not.toHaveBeenCalled();
70
+ });
71
+ });
@@ -1,6 +1,9 @@
1
1
  import { mkdirSync, rmSync, writeFileSync } from 'fs';
2
2
  import { resolve } from 'path';
3
- import { resolveUploadFilePath } from '../services/PipelineExecutor';
3
+ import axios from 'axios';
4
+ import { AsyncJobManager } from '../services/AsyncJobManager';
5
+ import { ExternalApiClient } from '../services/ExternalApiClient';
6
+ import { PipelineExecutor, resolveUploadFilePath } from '../services/PipelineExecutor';
4
7
 
5
8
  describe('PipelineExecutor upload path resolution', () => {
6
9
  const uploadsRoot = resolve(process.cwd(), 'storage', 'uploads');
@@ -30,4 +33,23 @@ describe('PipelineExecutor upload path resolution', () => {
30
33
  it('maps upload URLs by pathname only', () => {
31
34
  expect(resolveUploadFilePath('https://example.com/uploads/du-test/sample.txt?token=secret')).toBe(samplePath);
32
35
  });
36
+
37
+ it('does not resolve arbitrary remote URLs as upload files', () => {
38
+ expect(resolveUploadFilePath('https://evil.example/private.pdf')).toBeNull();
39
+ });
40
+ });
41
+
42
+ describe('PipelineExecutor remote file handling', () => {
43
+ it('does not fetch arbitrary remote URLs', async () => {
44
+ const getSpy = vi.spyOn(axios, 'get');
45
+ const executor = new PipelineExecutor(
46
+ { getRepository: vi.fn() } as never,
47
+ {} as ExternalApiClient,
48
+ {} as AsyncJobManager,
49
+ { error: vi.fn(), warn: vi.fn() },
50
+ );
51
+
52
+ await expect((executor as any).resolveFile('https://evil.example/private.pdf')).resolves.toBeNull();
53
+ expect(getSpy).not.toHaveBeenCalled();
54
+ });
33
55
  });
@@ -36,7 +36,7 @@ export const defineActions = (plugin: DocumentUnderstandingPluginLike) => {
36
36
 
37
37
  return {
38
38
  async getConfig(ctx: Context, next: () => Promise<any>) {
39
- ctx.body = await service.getConfig();
39
+ ctx.body = await service.getConfigForClient();
40
40
  await next();
41
41
  },
42
42
 
@@ -6,49 +6,46 @@ import { createDynamicPipelineToolsProvider } from './tools/document-understandi
6
6
 
7
7
  type DynamicToolsProvider = ReturnType<typeof createDynamicPipelineToolsProvider>;
8
8
 
9
- interface AiPluginLike {
10
- ai?: {
11
- toolsManager?: {
12
- registerDynamicTools: (provider: DynamicToolsProvider) => void;
13
- };
9
+ interface AiManagerLike {
10
+ toolsManager?: {
11
+ registerDynamicTools: (provider: DynamicToolsProvider) => void;
14
12
  };
15
13
  }
16
14
 
17
- const isAiPluginLike = (plugin: unknown): plugin is AiPluginLike => {
18
- const candidate = plugin as AiPluginLike;
19
- return typeof candidate?.ai?.toolsManager?.registerDynamicTools === 'function';
15
+ interface DocumentToolRuntimeState {
16
+ documentUnderstandingToolProviderRegistered?: boolean;
17
+ documentUnderstandingService?: DocumentUnderstandingService;
18
+ }
19
+
20
+ const isAiManagerLike = (manager: unknown): manager is AiManagerLike => {
21
+ const candidate = manager as AiManagerLike;
22
+ return typeof candidate?.toolsManager?.registerDynamicTools === 'function';
20
23
  };
21
24
 
22
25
  export class PluginDocumentUnderstandingServer extends Plugin {
23
26
  public service!: DocumentUnderstandingService;
27
+ private aiToolsRegistered = false;
28
+ private readonly registerAIToolsAfterStart = () => this.registerAITools();
24
29
 
25
30
  async afterAdd() {}
26
31
 
27
- async beforeLoad() {}
28
-
29
- async load() {
30
- // 1. Import collections
32
+ async beforeLoad() {
31
33
  await this.db.import({
32
34
  directory: resolve(__dirname, 'collections'),
33
35
  });
36
+ }
34
37
 
35
- // 2. Create service
38
+ async load() {
39
+ // Collections are imported in beforeLoad so database metadata exists before
40
+ // resources and runtime services are registered.
36
41
  this.service = new DocumentUnderstandingService(this.app, this.db);
37
42
 
38
- // Defer initialization to after app has loaded database so config exists
39
- this.app.on('afterStart', async () => {
40
- try {
41
- await this.service.initialize({ recoverJobs: true });
42
- } catch (err) {
43
- this.app.logger.warn('Document Understanding plugin not configured yet, skip init.', err);
44
- }
45
- });
46
-
47
- // 3. Register REST actions
43
+ // Register REST actions
48
44
  this.registerActions();
49
45
 
50
46
  // 4. Register AI tool (graceful)
51
47
  this.registerAITools();
48
+ this.app.on('afterStart', this.registerAIToolsAfterStart);
52
49
 
53
50
  // 5. ACL
54
51
  this.app.acl.registerSnippet({
@@ -83,19 +80,38 @@ export class PluginDocumentUnderstandingServer extends Plugin {
83
80
  }
84
81
 
85
82
  private registerAITools() {
83
+ if (this.aiToolsRegistered) return;
86
84
  try {
87
- const aiPlugin = this.app.pm.get('@nocobase/plugin-ai');
88
- if (!isAiPluginLike(aiPlugin)) {
85
+ const aiManager = (this.app as typeof this.app & { aiManager?: unknown }).aiManager;
86
+ if (!isAiManagerLike(aiManager)) {
89
87
  this.app.logger.warn('Document Understanding: plugin-ai not available, skip AI tool registration.');
90
88
  return;
91
89
  }
92
- aiPlugin.ai.toolsManager.registerDynamicTools(createDynamicPipelineToolsProvider(this.service));
90
+ const runtimeState = this.app as typeof this.app & DocumentToolRuntimeState;
91
+ runtimeState.documentUnderstandingService = this.service;
92
+ if (!runtimeState.documentUnderstandingToolProviderRegistered) {
93
+ aiManager.toolsManager.registerDynamicTools(async (register) => {
94
+ const currentService = runtimeState.documentUnderstandingService;
95
+ if (!currentService) return;
96
+ await createDynamicPipelineToolsProvider(currentService)(register);
97
+ });
98
+ runtimeState.documentUnderstandingToolProviderRegistered = true;
99
+ }
100
+ this.aiToolsRegistered = true;
93
101
  this.app.logger.info('Document Understanding: Dynamic pipeline tools provider registered.');
94
102
  } catch (err) {
95
103
  this.app.logger.warn('Document Understanding: Failed to register AI tools, continue without it.', err);
96
104
  }
97
105
  }
98
106
 
107
+ async afterStart() {
108
+ try {
109
+ await this.service.initialize({ recoverJobs: true });
110
+ } catch (err) {
111
+ this.app.logger.warn('Document Understanding plugin not configured yet, skip init.', err);
112
+ }
113
+ }
114
+
99
115
  async install() {}
100
116
 
101
117
  async afterEnable() {}
@@ -103,6 +119,16 @@ export class PluginDocumentUnderstandingServer extends Plugin {
103
119
  async afterDisable() {}
104
120
 
105
121
  async remove() {}
122
+
123
+ async beforeStop() {
124
+ this.app.off?.('afterStart', this.registerAIToolsAfterStart);
125
+ this.app.removeListener?.('afterStart', this.registerAIToolsAfterStart);
126
+ this.service?.destroy();
127
+ const runtimeState = this.app as typeof this.app & DocumentToolRuntimeState;
128
+ if (runtimeState.documentUnderstandingService === this.service) {
129
+ runtimeState.documentUnderstandingService = undefined;
130
+ }
131
+ }
106
132
  }
107
133
 
108
134
  export default PluginDocumentUnderstandingServer;
@@ -4,7 +4,7 @@ import { Database, Repository } from '@nocobase/database';
4
4
  import { ExternalApiClient, FileInput } from './ExternalApiClient';
5
5
  import { AsyncJobManager } from './AsyncJobManager';
6
6
  import { PipelineExecutor } from './PipelineExecutor';
7
- import { ServiceConfig, EndpointDef, PipelineDef, JobState } from '../types';
7
+ import { ClientServiceConfig, ServiceConfig, EndpointDef, PipelineDef, JobState } from '../types';
8
8
 
9
9
  export class DocumentUnderstandingService {
10
10
  private app: Application;
@@ -101,16 +101,34 @@ export class DocumentUnderstandingService {
101
101
  return this.ensureConfig();
102
102
  }
103
103
 
104
+ async getConfigForClient(): Promise<ClientServiceConfig> {
105
+ const { authKey, webhookSecret, ...config } = await this.ensureConfig();
106
+ return {
107
+ ...config,
108
+ hasAuthKey: Boolean(authKey),
109
+ hasWebhookSecret: Boolean(webhookSecret),
110
+ };
111
+ }
112
+
104
113
  async updateConfig(data: Partial<ServiceConfig>): Promise<void> {
105
114
  const configRepo = this.db.getRepository<any>('doc_understanding_config');
106
115
  const conf = await configRepo.findOne();
107
116
  if (conf) {
108
- await configRepo.update({ filterByTk: conf.id, values: data });
117
+ const values = { ...data };
118
+ if (!values.authKey) delete values.authKey;
119
+ if (!values.webhookSecret) delete values.webhookSecret;
120
+ await configRepo.update({ filterByTk: conf.id, values });
109
121
  }
110
122
  // Reinitialize to pick up new config
111
123
  await this.initialize();
112
124
  }
113
125
 
126
+ destroy(): void {
127
+ this.jobManager?.destroy();
128
+ this.initialized = false;
129
+ this.startupRecoveryCompleted = false;
130
+ }
131
+
114
132
  async listEndpoints(): Promise<EndpointDef[]> {
115
133
  await this.ensureInitialized();
116
134
  return this.db.getRepository<any>('doc_understanding_endpoints').find({ sort: 'sortOrder' });
@@ -200,15 +218,17 @@ export class DocumentUnderstandingService {
200
218
  return { jobId: job.id };
201
219
  }
202
220
 
203
- async getJobStatus(jobId: number): Promise<JobState> {
204
- const job = await this.db.getRepository<any>('doc_understanding_jobs').findOne({ filterByTk: jobId });
221
+ async getJobStatus(jobId: number, userId?: number): Promise<JobState> {
222
+ const filter = userId ? { id: jobId, createdById: userId } : { id: jobId };
223
+ const job = await this.db.getRepository<any>('doc_understanding_jobs').findOne({ filter });
205
224
  if (!job) throw new Error('Job not found');
206
225
  return job;
207
226
  }
208
227
 
209
- async listJobs(filters?: any): Promise<JobState[]> {
228
+ async listJobs(filters?: Record<string, unknown>, userId?: number): Promise<JobState[]> {
229
+ const filter = userId ? { ...(filters || {}), createdById: userId } : filters;
210
230
  return this.db.getRepository<any>('doc_understanding_jobs').find({
211
- filter: filters,
231
+ filter,
212
232
  sort: ['-createdAt'],
213
233
  });
214
234
  }
@@ -1,7 +1,6 @@
1
1
  import { existsSync, realpathSync, readFileSync, statSync } from 'fs';
2
2
  import { basename, resolve, sep } from 'path';
3
3
  import { Database } from '@nocobase/database';
4
- import axios from 'axios';
5
4
  import mime from 'mime-types';
6
5
  import { ExternalApiClient, FileInput } from './ExternalApiClient';
7
6
  import { AsyncJobManager } from './AsyncJobManager';
@@ -100,39 +99,10 @@ export class PipelineExecutor {
100
99
  };
101
100
  }
102
101
 
102
+ // Only files in NocoBase's upload storage are accepted. Fetching arbitrary
103
+ // HTTP(S) URLs here would turn a user/AI-provided value into an SSRF primitive.
103
104
  if (urlOrPath.startsWith('http://') || urlOrPath.startsWith('https://')) {
104
- const response = await axios.get(urlOrPath, { responseType: 'arraybuffer' });
105
- const buffer = Buffer.from(response.data);
106
-
107
- let filename = 'file';
108
- const disposition = response.headers['content-disposition'];
109
- if (disposition && disposition.includes('filename=')) {
110
- const match = disposition.match(/filename="?([^";]+)"?/);
111
- if (match?.[1]) {
112
- filename = match[1];
113
- }
114
- } else {
115
- const base = basename(new URL(urlOrPath).pathname);
116
- if (base && base.includes('.')) {
117
- filename = base;
118
- }
119
- }
120
-
121
- const contentType = response.headers['content-type'] || 'application/octet-stream';
122
- const mimeType = contentType.split(';')[0].trim();
123
- if (!filename.includes('.')) {
124
- const extension = mime.extension(mimeType);
125
- if (extension) {
126
- filename = `${filename}.${extension}`;
127
- }
128
- }
129
-
130
- return {
131
- fieldName,
132
- buffer,
133
- filename,
134
- mimeType,
135
- };
105
+ this.logger.warn?.('Ignoring remote file URL; use a NocoBase upload URL instead.');
136
106
  }
137
107
  } catch (err) {
138
108
  const message = err instanceof Error ? err.message : String(err);
@@ -157,6 +127,7 @@ export class PipelineExecutor {
157
127
  });
158
128
 
159
129
  if (!pipeline) throw new Error(`Pipeline ${pipelineId} not found`);
130
+ if (!pipeline.enabled) throw new Error(`Pipeline ${pipelineId} is disabled`);
160
131
 
161
132
  // Create Job
162
133
  const job = await jobsRepo.create({
@@ -282,6 +253,10 @@ export class PipelineExecutor {
282
253
  continue; // Skip step
283
254
  }
284
255
 
256
+ if (!step.endpoint?.enabled) {
257
+ throw new Error(`Endpoint for step ${step.name} is disabled`);
258
+ }
259
+
285
260
  const mappedBody = this.resolveMapping(step.inputMapping || {}, context);
286
261
  let retries = step.onError === 'retry' ? step.retryCount || 0 : 0;
287
262
  let success = false;
@@ -11,6 +11,11 @@ export interface ServiceConfig {
11
11
  webhookSecret?: string;
12
12
  }
13
13
 
14
+ export type ClientServiceConfig = Omit<ServiceConfig, 'authKey' | 'webhookSecret'> & {
15
+ hasAuthKey: boolean;
16
+ hasWebhookSecret: boolean;
17
+ };
18
+
14
19
  export interface EndpointDef {
15
20
  id: number;
16
21
  name: string;