plugin-document-understanding 1.1.16 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +19 -25
- package/dist/client/169.6888909107c553c3.js +10 -0
- package/dist/client/379.e29f5ced467ce23d.js +10 -0
- package/dist/client/867.3ed3b814115181ca.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/169.53bf1be2ec192f0c.js +10 -0
- package/dist/client-v2/379.e75c4829567cdb89.js +10 -0
- package/dist/client-v2/867.66d7291e95f1de78.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +9 -7
- package/dist/locale/en-US.json +126 -0
- package/dist/locale/vi-VN.json +130 -2
- package/dist/locale/zh-CN.json +127 -1
- package/dist/node_modules/form-data/package.json +1 -1
- package/dist/node_modules/mime-types/package.json +1 -1
- package/dist/server/actions.js +211 -11
- package/dist/server/collections/api-keys.js +55 -0
- package/dist/server/collections/artifacts.js +59 -0
- package/dist/server/collections/config.js +9 -3
- package/dist/server/collections/endpoints.js +3 -0
- package/dist/server/collections/jobs.js +7 -4
- package/dist/server/collections/operations.js +76 -0
- package/dist/server/contracts/du-contracts.js +828 -0
- package/dist/server/dugate-seed.js +98 -340
- package/dist/server/plugin.js +49 -7
- package/dist/server/routes/du-gateway-router.js +443 -0
- package/dist/server/services/ArtifactStorageService.js +459 -0
- package/dist/server/services/AsyncJobManager.js +1 -1
- package/dist/server/services/BuiltinBusinessEngine.js +1223 -0
- package/dist/server/services/DocumentUnderstandingService.js +151 -25
- package/dist/server/services/ExternalDuReworkClient.js +210 -0
- package/dist/server/services/OperationOrchestrator.js +1087 -0
- package/dist/server/services/PipelineExecutor.js +164 -43
- package/dist/server/tools/document-understanding-tool.js +49 -24
- package/dist/server/workflow/DocumentUnderstandingInstruction.js +292 -0
- package/package.json +8 -4
- package/src/client/index.tsx +11 -0
- package/src/client-v2/components/ApiKeysTab.tsx +198 -0
- package/src/client-v2/components/EndpointsTab.tsx +39 -2
- package/src/client-v2/components/JobsTab.tsx +136 -21
- package/src/client-v2/components/OperationsTab.tsx +586 -0
- package/src/client-v2/components/PluginSettings.tsx +12 -0
- package/src/client-v2/components/ServiceConfigTab.tsx +225 -65
- package/src/client-v2/components/__tests__/PluginSettings.test.tsx +4 -0
- package/src/client-v2/locale.ts +1 -8
- package/src/client-v2/models/index.ts +1 -8
- package/src/client-v2/plugin.tsx +12 -8
- package/src/client-v2/types.ts +13 -1
- package/src/client-v2/workflow/DocumentUnderstandingFieldset.tsx +122 -0
- package/src/client-v2/workflow/DocumentUnderstandingInstruction.tsx +49 -0
- package/src/locale/en-US.json +126 -0
- package/src/locale/vi-VN.json +130 -2
- package/src/locale/zh-CN.json +127 -1
- package/src/server/__tests__/actions.test.ts +1 -8
- package/src/server/__tests__/du-rework-gateway.test.ts +462 -0
- package/src/server/__tests__/dugate-integration.test.ts +79 -42
- package/src/server/__tests__/smoke.test.ts +1 -8
- package/src/server/__tests__/upload-security.test.ts +1 -8
- package/src/server/actions.ts +252 -36
- package/src/server/collections/api-keys.ts +35 -0
- package/src/server/collections/artifacts.ts +39 -0
- package/src/server/collections/config.ts +18 -2
- package/src/server/collections/endpoints.ts +12 -0
- package/src/server/collections/jobs.ts +16 -4
- package/src/server/collections/operations.ts +56 -0
- package/src/server/contracts/du-contracts.ts +1026 -0
- package/src/server/dugate-seed.ts +126 -453
- package/src/server/plugin.ts +64 -14
- package/src/server/routes/du-gateway-router.ts +465 -0
- package/src/server/services/ArtifactStorageService.ts +596 -0
- package/src/server/services/AsyncJobManager.ts +10 -1
- package/src/server/services/BuiltinBusinessEngine.ts +1544 -0
- package/src/server/services/DocumentUnderstandingService.ts +186 -44
- package/src/server/services/ExternalDuReworkClient.ts +222 -0
- package/src/server/services/OperationOrchestrator.ts +1359 -0
- package/src/server/services/PipelineExecutor.ts +245 -108
- package/src/server/tools/document-understanding-tool.ts +63 -45
- package/src/server/types.ts +101 -16
- package/src/server/workflow/DocumentUnderstandingInstruction.ts +308 -0
- package/dist/client/345.277fbb2b97424db5.js +0 -10
- package/dist/client-v2/345.2fa9834b46dd4531.js +0 -10
package/dist/client/index.js
CHANGED
|
@@ -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("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("plugin-document-understanding",["react","antd","@nocobase/client","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["plugin-document-understanding"]=t(require("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["plugin-document-understanding"]=t(e.react,e.antd,e["@nocobase/client"],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},342:function(e){e.exports=n},694:function(e){e.exports=o},59:function(e){e.exports=t},155:function(t){t.exports=e}},l={};function f(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return a[e](n,n.exports,f),n.exports}f.m=a,f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.f={},f.e=function(e){return Promise.all(Object.keys(f.f).reduce(function(t,n){return f.f[n](e,t),t},[]))},f.u=function(e){return""+e+".277fbb2b97424db5.js"},f.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s={},f.l=function(e,t,n,r){if(s[e])return void s[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:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,f.nc&&o.setAttribute("nonce",f.nc),o.setAttribute("data-rspack","plugin-document-understanding:"+n),o.src=e),s[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=s[e];if(delete s[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)},f.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.g.importScripts&&(p=f.g.location+"");var s,p,d=f.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");f.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},f.f.j=function(e,t){var n=f.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=f.p+f.u(e),u=Error();f.l(o,function(t){if(f.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)f.o(u,n)&&(f.m[n]=u[n]);c&&c(f)}for(e&&e(t);a<o.length;a++)r=o[a],f.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(c=self.webpackChunkplugin_document_understanding=self.webpackChunkplugin_document_understanding||[]).forEach(u.bind(null,0)),c.push=u.bind(null,c.push.bind(c));var h={};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/")>=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/")}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/"}f.p=e}(),!function(){f.r(h),f.d(h,{PluginDocumentUnderstandingClient:function(){return l}});var e=f(155),t=f.n(e),n=f(342);function r(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 o(e,t,n){return(o=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&u(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 u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=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 o(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function o(){var e,t;if(!(this instanceof o))throw TypeError("Cannot call a class as a function");return e=o,t=arguments,e=i(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,a()?Reflect.construct(e,t||[],i(this).constructor):e.apply(this,t))}return o.prototype=Object.create(e&&e.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),e&&u(o,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.add("document-understanding",{title:this.t("Document Understanding"),icon:"FileSearchOutlined",Component:t().lazy(function(){return f.e("345").then(f.bind(f,824))}),aclSnippet:"pm.document-understanding"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(o,i){var u=e.apply(t,n);function c(e){r(u,o,i,c,a,"next",e)}function a(e){r(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)}}(o.prototype,n),o}(c(n.Plugin));h.default=l}(),h}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("plugin-document-understanding",["react","antd","@nocobase/plugin-workflow/client-v2","@nocobase/client","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["plugin-document-understanding"]=t(require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["plugin-document-understanding"]=t(e.react,e.antd,e["@nocobase/plugin-workflow/client-v2"],e["@nocobase/client"],e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i){return function(){"use strict";var u,c,a,l={650:function(e,t,n){n.d(t,{M:function(){return u},k:function(){return i}});var r=n(694),o=JSON.parse('{"UU":"plugin-document-understanding"}');function i(){var e=(0,r.useFlowEngine)();return function(t){return e.context.t(t,{ns:[o.UU,"client"]})}}function u(e){return(0,r.tExpr)(e,{ns:[o.UU,"client"]})}},375:function(e){e.exports=o},342:function(e){e.exports=r},694:function(e){e.exports=i},197:function(e){e.exports=n},59:function(e){e.exports=t},155:function(t){t.exports=e}},f={};function s(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return l[e](n,n.exports,s),n.exports}s.m=l,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+"."+({169:"6888909107c553c3",379:"e29f5ced467ce23d",867:"3ed3b814115181ca"})[e]+".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)},p={},s.l=function(e,t,n,r){if(p[e])return void p[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:"+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:"+n),o.src=e),p[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=p[e];if(delete p[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=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&&(d=s.g.location+"");var p,d,b=s.g.document;if(!d&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(d=b.currentScript.src),!d)){var g=b.getElementsByTagName("script");if(g.length)for(var v=g.length-1;v>-1&&(!d||!/^http(s?):/.test(d));)d=g[v--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");s.p=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),u={889:0},s.f.j=function(e,t){var n=s.o(u,e)?u[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=u[e]=[t,r]});t.push(n[2]=r);var o=s.p+s.u(e),i=Error();s.l(o,function(t){if(s.o(u,e)&&(0!==(n=u[e])&&(u[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},c=function(e,t){var n,r,o=t[0],i=t[1],c=t[2],a=0;if(o.some(function(e){return 0!==u[e]})){for(n in i)s.o(i,n)&&(s.m[n]=i[n]);c&&c(s)}for(e&&e(t);a<o.length;a++)r=o[a],s.o(u,r)&&u[r]&&u[r][0](),u[r]=0},(a=self.webpackChunkplugin_document_understanding=self.webpackChunkplugin_document_understanding||[]).forEach(c.bind(null,0)),a.push=c.bind(null,a.push.bind(a));var y={};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/")>=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/")}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/"}s.p=e}(),!function(){s.r(y),s.d(y,{PluginDocumentUnderstandingClient:function(){return x},default:function(){return k}});var e=s(155),t=s.n(e),n=s(342),r=s(375),o=s(197),i=s(650);function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var f=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function o(){var e,n,a;if(!(this instanceof o))throw TypeError("Cannot call a class as a function");return n=o,a=arguments,n=c(n),u(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,l()?Reflect.construct(n,a||[],c(this).constructor):n.apply(this,a)),"type","document-understanding"),u(e,"title",(0,i.M)("Document Understanding")),u(e,"group","extended"),u(e,"description",(0,i.M)("Parse, OCR, extract, analyze, transform, compare, or audit L/C & disbursement documents via Document Understanding.")),u(e,"icon",t().createElement(r.FileSearchOutlined,null)),u(e,"FieldsetLoader",function(){return Promise.all([s.e("379"),s.e("169")]).then(s.bind(s,328)).then(function(e){return{default:e.DocumentUnderstandingFieldset}})}),e}return o.prototype=Object.create(e&&e.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),e&&a(o,e),n=[{key:"createDefaultConfig",value:function(){return{mode:"business_action",businessId:"document-core",action:"extract",variant:"invoice",ignoreFail:!1}}},{key:"useVariables",value:function(e){return{value:e.key,label:e.title,children:[{value:"operationId",label:(0,i.M)("Operation ID")},{value:"state",label:(0,i.M)("State")},{value:"data",label:(0,i.M)("Structured Data")},{value:"markdown",label:(0,i.M)("Markdown Content")},{value:"text",label:(0,i.M)("Plain Text")},{value:"report",label:(0,i.M)("Report")},{value:"verdict",label:(0,i.M)("Verdict")},{value:"discrepancies",label:(0,i.M)("Discrepancies")},{value:"usage",label:(0,i.M)("Token & Cost Usage")}]}}}],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)}}(o.prototype,n),o}(o.Instruction);function p(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 d(e,t,n){return t=v(t),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}(e,_()?Reflect.construct(t,n||[],v(e).constructor):t.apply(e,n))}function b(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function g(e,t,n){return(g=_()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&m(o,n.prototype),o}).apply(null,arguments)}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t="function"==typeof Map?new Map:void 0;return(w=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 g(e,arguments,v(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),m(n,e)})(e)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}var O=function(e){function t(){return b(this,t),d(this,t,arguments)}return h(t,e),t}(f),x=function(e){var n;function r(){return b(this,r),d(this,r,arguments)}return h(r,e),n=[{key:"load",value:function(){var e;return(e=function(){var e,n;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(r){return this.pluginSettingsManager.add("document-understanding",{title:this.t("Document Understanding"),icon:"FileSearchOutlined",Component:t().lazy(function(){return Promise.all([s.e("379"),s.e("867")]).then(s.bind(s,742))}),aclSnippet:"pm.document-understanding"}),null==(n=this.app.pm.get("workflow")||this.app.pm.get("@nocobase/plugin-workflow"))||null==(e=n.registerInstruction)||e.call(n,"document-understanding",O),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){p(i,r,o,u,c,"next",e)}function c(e){p(i,r,o,u,c,"throw",e)}u(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)}}(r.prototype,n),r}(w(n.Plugin)),k=x}(),y}()});
|
|
@@ -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_understanding_client_v2=self.webpackChunkplugin_document_understanding_client_v2||[]).push([["169"],{328:function(e,n,t){t.d(n,{DocumentUnderstandingFieldset:function(){return f}});var a=t(155),r=t.n(a),l=t(59),i=t(694),o=t(197),c=t(585),u=t(832),m=t(650);function s(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=Array(n);t<n;t++)a[t]=e[t];return a}var p=[{value:"document-core",label:"document-core (v2.0.0)"},{value:"lc-checker",label:"lc-checker (v1.2.0 - UCP 600 / ISBP 821)"},{value:"example-review",label:"example-review (v1.0.0)"}],f=function(){var e,n=(0,m.k)(),t=(0,i.useFlowContext)(),f=l.Form.useFormInstance(),d=l.Form.useWatch(["config","mode"],f)||"business_action",g=l.Form.useWatch(["config","businessId"],f)||"document-core",b=l.Form.useWatch(["config","action"],f)||"extract",v=function(e){if(Array.isArray(e))return e}(e=(0,a.useState)([]))||function(e){var n,t,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var r=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(n=a.next()).done)&&(r.push(n.value),2!==r.length);l=!0);}catch(e){i=!0,t=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw t}}return r}}(e)||function(e){if(e){if("string"==typeof e)return s(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),h=v[0],E=v[1];(0,a.useEffect)(function(){if("pipeline"===d&&(null==t?void 0:t.api)){var e=!1;return t.api.request({url:"docUnderstanding:listPipelines"}).then(function(n){e||E((0,u.mT)(n,[]))}).catch(function(){}),function(){e=!0}}},[null==t?void 0:t.api,d]);var I=Array.from(new Set(c.VQ.filter(function(e){return e.businessId===g}).map(function(e){return e.action}))),F=c.VQ.filter(function(e){return e.businessId===g&&e.action===b&&e.discriminatorValue});return r().createElement("div",null,r().createElement(l.Form.Item,{name:["config","mode"],label:n("Execution Mode"),initialValue:"business_action"},r().createElement(l.Select,{options:[{value:"business_action",label:n("Canonical Business Action (du-rework)")},{value:"pipeline",label:n("Configured Pipeline")}]})),"pipeline"===d?r().createElement(l.Form.Item,{name:["config","pipelineId"],label:n("Pipeline"),rules:[{required:!0,message:n("Select a pipeline")}]},r().createElement(l.Select,{placeholder:n("Select pipeline"),options:h.map(function(e){return{value:e.id,label:e.name}})})):r().createElement(r().Fragment,null,r().createElement(l.Form.Item,{name:["config","businessId"],label:n("Business"),initialValue:"document-core"},r().createElement(l.Select,{options:p})),r().createElement(l.Form.Item,{name:["config","action"],label:n("Action"),initialValue:"extract"},r().createElement(l.Select,{options:I.map(function(e){return{value:e,label:e}})})),F.length>0&&r().createElement(l.Form.Item,{name:["config","variant"],label:n("Variant / Mode")},r().createElement(l.Select,{allowClear:!0,placeholder:n("Select variant"),options:F.map(function(e){return{value:e.discriminatorValue,label:"".concat(e.discriminatorValue," — ").concat(e.description)}})}))),r().createElement(l.Form.Item,{name:["config","files"],label:n("Document Files / Attachment Variable"),extra:n("Bind an attachment field, file URL, or comma-separated upload paths from upstream nodes")},r().createElement(o.WorkflowVariableInput,{placeholder:"uploads/invoice.pdf"})),r().createElement(l.Form.Item,{name:["config","pages"],label:n("Page Selection (DI-06)"),extra:n('Optional page ranges, e.g. "1-3, 5" (leave empty for all pages)')},r().createElement(o.WorkflowVariableInput,{placeholder:"1-3"})),r().createElement(l.Form.Item,{name:["config","inputJson"],label:n("Input Parameters (JSON)"),extra:n("Additional action parameters (e.g. referenceData, questions, targetLanguage, ruleSetVersion)")},r().createElement(o.WorkflowVariableJsonTextArea,{rows:4,placeholder:'{ "outputFormat": "json" }'})),r().createElement(l.Form.Item,{name:["config","ignoreFail"],valuePropName:"checked",initialValue:!1},r().createElement(l.Checkbox,null,n("Continue workflow even if document processing fails"))))}}}]);
|
|
@@ -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_understanding_client_v2=self.webpackChunkplugin_document_understanding_client_v2||[]).push([["379"],{832:function(e,t,i){function n(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function a(e,t){var i,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(i=null==(n=e.data)?void 0:n.data)?i:t:t}function r(e){return n(e,Error)?e.message:String(e)}function s(e){if(!e)return"-";var t=n(e,Date)?e:new Date(e);return Number.isNaN(t.getTime())?"-":t.toLocaleString()}i.d(t,{gJ:function(){return r},mT:function(){return a},r6:function(){return s}})},585:function(e,t,i){function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function a(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}i.d(t,{VQ:function(){return c},Xm:function(){return r},vZ:function(){return s}});var r=["PENDING_INGESTION","ACCEPTED","QUEUED","RUNNING","WAITING_CHILDREN","WAITING_INPUT","RETRY_PENDING","CANCEL_REQUESTED","SUCCEEDED","FAILED","CANCELLED","TIMED_OUT"];function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,i=e.trim();if(!i||"all"===i.toLowerCase())return[];var n=[],a=0,r=!0,s=!1,o=void 0;try{for(var c,d=i.split(",")[Symbol.iterator]();!(r=(c=d.next()).done);r=!0){var m=c.value.trim();if(m){var u=/^(\d+)(?:\s*-\s*(\d+))?$/.exec(m);if(!u)throw Error('Invalid page range segment "'.concat(m,'". Expected "1-5" or "1,3-5".'));var l=Number(u[1]),p=u[2]?Number(u[2]):l;if(!Number.isSafeInteger(l)||!Number.isSafeInteger(p)||l<1||p<l)throw Error('Invalid page range "'.concat(m,'": page numbers must be >= 1 and from <= to.'));if((a+=p-l+1)>t)throw Error("Selected page count (".concat(a,") exceeds maximum allowed (").concat(t,")."));n.push({from:l,to:p})}}}catch(e){s=!0,o=e}finally{try{r||null==d.return||d.return()}finally{if(s)throw o}}return n}function o(e,t,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return{type:"object",properties:function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(t){a(e,t,i[t])})}return e}(a({},e,{type:"string",enum:[t],default:t}),i),required:[e].concat(function(e){if(Array.isArray(e))return n(e)}(r)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e){if(e){if("string"==typeof e)return n(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return n(e,void 0)}}(r)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}}[{ruleId:"UCP600-ART14-A",standard:"UCP 600",title:"Standard for Examination of Documents",description:"Nominated/issuing bank must determine on the basis of the documents alone whether they appear on their face to constitute a complying presentation."},{ruleId:"UCP600-ART14-D",standard:"UCP 600",title:"Non-conflicting Data Across Documents",description:"Data in a document, when read in context with the credit, the document itself and international standard banking practice, need not be identical to, but must not conflict with, data in that document, any other stipulated document or the credit."},{ruleId:"UCP600-ART14-E",standard:"UCP 600",title:"Description of Goods in Non-Invoice Documents",description:"In documents other than the commercial invoice, the description of the goods, services or performance, if stated, may be in general terms not conflicting with their description in the credit."},{ruleId:"UCP600-ART14-I",standard:"UCP 600",title:"Document Dates vs Presentation Date",description:"A document may be dated prior to the issuance date of the credit, but must not be dated later than its date of presentation."},{ruleId:"UCP600-ART18-A",standard:"UCP 600",title:"Commercial Invoice Issuer & Beneficiary",description:"A commercial invoice must appear to have been issued by the beneficiary, made out in the name of the applicant, and in the same currency as the credit."},{ruleId:"UCP600-ART18-B",standard:"UCP 600",title:"Commercial Invoice Amount Within Credit Limit",description:"Commercial invoice amount must not exceed the amount permitted by the credit."},{ruleId:"UCP600-ART18-C",standard:"UCP 600",title:"Exact Goods Description in Commercial Invoice",description:"The description of the goods, services or performance in a commercial invoice must correspond with that appearing in the credit."},{ruleId:"UCP600-ART20-A-I",standard:"UCP 600",title:"Bill of Lading Carrier Identification & Signature",description:"A bill of lading must indicate the name of the carrier and be signed by the carrier, master, or named agent.",requiresVisualCheck:!0},{ruleId:"UCP600-ART20-A-II",standard:"UCP 600",title:"Bill of Lading Shipped On Board Notation & Date",description:"Bill of lading must indicate that the goods have been shipped on board a named vessel at the port of loading stated in the credit with an on-board date."},{ruleId:"UCP600-ART20-A-III",standard:"UCP 600",title:"Port of Loading and Discharge Match",description:"Bill of lading must indicate shipment from the port of loading to the port of discharge stated in the credit."},{ruleId:"UCP600-ART27",standard:"UCP 600",title:"Clean Transport Document",description:"A bank will only accept a clean transport document bearing no clause or notation expressly declaring a defective condition of the goods or packaging."},{ruleId:"UCP600-ART28-A",standard:"UCP 600",title:"Insurance Document Signature & Coverage",description:"Insurance document must appear to be issued and signed by an insurance company, underwriter or their agent/proxy, and cover at least 110% of CIF/CIP value when unspecified.",requiresVisualCheck:!0},{ruleId:"ISBP821-A35",standard:"ISBP 821",title:"Signatures, Stamps and Endorsements",description:"Required manual/facsimile signatures, stamps, or bill of lading endorsements must be visually verifiable when stipulated.",requiresVisualCheck:!0},{ruleId:"ISBP821-C3",standard:"ISBP 821",title:"Invoice Value & Trade Terms Consistency",description:"Incoterms and invoice line items/totals must match the credit terms without unpermitted charges."}].map(function(e){return e.ruleId});var c=[{endpointName:"du-ingest-parse",legacyEndpointName:"dugate-ingest-parse",pipelineName:"Ingest Parse",businessId:"document-core",businessVersion:"2.0.0",action:"ingest",discriminatorField:"mode",discriminatorValue:"parse",maxFiles:10,description:"Parse digital documents (PDF, DOCX, XLSX, PPTX, TXT, CSV, HTML) into clean Markdown/text.",inputSchema:o("mode","parse",{language:{type:"string",default:"vi"},pages:{type:"string",description:'Page ranges, e.g. "1-5" or "all"'},outputFormat:{type:"string",enum:["md","text","json"],default:"md"}})},{endpointName:"du-ingest-ocr",legacyEndpointName:"dugate-ingest-ocr",pipelineName:"Ingest Ocr",businessId:"document-core",businessVersion:"2.0.0",action:"ingest",discriminatorField:"mode",discriminatorValue:"ocr",maxFiles:10,description:"OCR scanned PDFs and images into Markdown and plain text.",inputSchema:o("mode","ocr",{language:{type:"string",default:"vi"},pages:{type:"string",description:'Page ranges, e.g. "1-5"'},outputFormat:{type:"string",enum:["md","text"],default:"md"}})},{endpointName:"du-ingest-digitize",legacyEndpointName:"dugate-ingest-digitize",pipelineName:"Ingest Digitize",businessId:"document-core",businessVersion:"2.0.0",action:"ingest",discriminatorField:"mode",discriminatorValue:"digitize",maxFiles:5,description:"Digitize handwritten forms, checkboxes, and structured form fields.",inputSchema:o("mode","digitize",{language:{type:"string",default:"vi"},outputFormat:{type:"string",enum:["md","json"],default:"json"}})},{endpointName:"du-ingest-split",legacyEndpointName:"dugate-ingest-split",pipelineName:"Ingest Split",businessId:"document-core",businessVersion:"2.0.0",action:"ingest",discriminatorField:"mode",discriminatorValue:"split",maxFiles:1,description:"Split a multi-page document by page ranges (up to 500 selected pages) into separate output artifacts.",inputSchema:o("mode","split",{pages:{type:"string",default:"1-2",description:'Comma-separated page ranges, e.g. "1-2,3-5"'}})},{endpointName:"du-extract-invoice",legacyEndpointName:"dugate-extract-invoice",pipelineName:"Extract Invoice",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"invoice",maxFiles:5,description:"Extract structured VAT/commercial invoice data (supplier, buyer, invoiceNumber, lineItems, totals).",inputSchema:o("type","invoice",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-contract",legacyEndpointName:"dugate-extract-contract",pipelineName:"Extract Contract",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"contract",maxFiles:5,description:"Extract parties, effectiveDate, value, obligations, and penaltyClauses from contracts.",inputSchema:o("type","contract",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-id-card",legacyEndpointName:"dugate-extract-id-card",pipelineName:"Extract Id Card",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"id-card",maxFiles:5,description:"Extract identity information (ID number, fullName, dateOfBirth, address, expiryDate) from CCCD/Passport.",inputSchema:o("type","id-card",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-receipt",legacyEndpointName:"dugate-extract-receipt",pipelineName:"Extract Receipt",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"receipt",maxFiles:5,description:"Extract merchant, receipt date, items, payment method, and total from receipts.",inputSchema:o("type","receipt",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-table",legacyEndpointName:"dugate-extract-table",pipelineName:"Extract Table",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"table",maxFiles:5,description:"Extract all tables from documents as structured JSON headers and rows.",inputSchema:o("type","table",{outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-extract-custom",legacyEndpointName:"dugate-extract-custom",pipelineName:"Extract Custom",businessId:"document-core",businessVersion:"2.0.0",action:"extract",discriminatorField:"type",discriminatorValue:"custom",maxFiles:5,description:"Extract custom entities matching a caller-supplied JSON Schema or field list.",inputSchema:o("type","custom",{fields:{type:"array",items:{type:"string"},description:"Field names when schema is omitted"},schema:{type:"object",description:"Target JSON Schema for structured output"},outputFormat:{type:"string",enum:["json"],default:"json"}})},{endpointName:"du-analyze-classify",legacyEndpointName:"dugate-analyze-classify",pipelineName:"Analyze Classify",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"classify",maxFiles:5,description:"Classify documents into categories with 0-1 confidence scores.",inputSchema:o("task","classify",{categories:{type:"array",items:{type:"string"}}})},{endpointName:"du-analyze-sentiment",legacyEndpointName:"dugate-analyze-sentiment",pipelineName:"Analyze Sentiment",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"sentiment",maxFiles:5,description:"Analyze sentiment polarity, confidence, and key phrases.",inputSchema:o("task","sentiment",{})},{endpointName:"du-analyze-compliance",legacyEndpointName:"dugate-analyze-compliance",pipelineName:"Analyze Compliance",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"compliance",maxFiles:5,description:"Check regulatory/policy compliance (PASS/FAIL/WARNING + violations).",inputSchema:o("task","compliance",{criteria:{type:"array",items:{type:"string"}}})},{endpointName:"du-analyze-fact-check",legacyEndpointName:"dugate-analyze-fact-check",pipelineName:"Analyze Fact Check",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"fact-check",maxFiles:5,description:"Cross-check document facts against authoritative referenceData.",inputSchema:o("task","fact-check",{referenceData:{type:"object",description:"Expected key-value facts to verify against"}})},{endpointName:"du-analyze-quality",legacyEndpointName:"dugate-analyze-quality",pipelineName:"Analyze Quality",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"quality",maxFiles:5,description:"Score document completeness and writing quality from 0 to 100.",inputSchema:o("task","quality",{criteria:{type:"array",items:{type:"string"}}})},{endpointName:"du-analyze-risk",legacyEndpointName:"dugate-analyze-risk",pipelineName:"Analyze Risk",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"risk",maxFiles:5,description:"Assess legal/financial contract risk level (LOW, MEDIUM, HIGH, CRITICAL) and risk factors.",inputSchema:o("task","risk",{focus:{type:"string"}})},{endpointName:"du-analyze-summarize-eval",legacyEndpointName:"dugate-analyze-summarize-eval",pipelineName:"Analyze Summarize Eval",businessId:"document-core",businessVersion:"2.0.0",action:"analyze",discriminatorField:"task",discriminatorValue:"summarize-eval",maxFiles:5,description:"Summarize document and evaluate author perspective, strengths, and gaps.",inputSchema:o("task","summarize-eval",{})},{endpointName:"du-transform-convert",legacyEndpointName:"dugate-transform-convert",pipelineName:"Transform Convert",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"convert",maxFiles:1,description:"Convert document content locally between Markdown, HTML, plain text, and JSON.",inputSchema:o("variant","convert",{outputFormat:{type:"string",enum:["md","html","text","json"],default:"md"}})},{endpointName:"du-transform-translate",legacyEndpointName:"dugate-transform-translate",pipelineName:"Transform Translate",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"translate",maxFiles:1,description:"Translate document into targetLanguage while preserving formatting.",inputSchema:o("variant","translate",{targetLanguage:{type:"string",default:"en"},tone:{type:"string",default:"professional"}})},{endpointName:"du-transform-rewrite",legacyEndpointName:"dugate-transform-rewrite",pipelineName:"Transform Rewrite",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"rewrite",maxFiles:1,description:"Rewrite document in academic, executive, simplified, or bullet_points style.",inputSchema:o("variant","rewrite",{style:{type:"string",enum:["academic","executive","simplified","bullet_points"],default:"executive"},tone:{type:"string"}})},{endpointName:"du-transform-redact",legacyEndpointName:"dugate-transform-redact",pipelineName:"Transform Redact",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"redact",maxFiles:1,description:"Mask PII (CCCD, PHONE_NUMBER, EMAIL, BANK_ACCOUNT, TAX_ID, or custom patterns) in text/documents.",inputSchema:o("variant","redact",{text:{type:"string"},redactPatterns:{type:"array",items:{type:"string"},default:["CCCD","PHONE_NUMBER","EMAIL"]},useAi:{type:"boolean",default:!1},outputFormat:{type:"string",enum:["text","md"],default:"text"}})},{endpointName:"du-transform-template",legacyEndpointName:"dugate-transform-template",pipelineName:"Transform Template",businessId:"document-core",businessVersion:"2.0.0",action:"transform",discriminatorField:"variant",discriminatorValue:"template",maxFiles:1,description:"Merge structured JSON variables into a {{placeholder}} document template.",inputSchema:o("variant","template",{templateText:{type:"string"},variables:{type:"object",description:"Key-value map merged into {{key}} placeholders"}})},{endpointName:"du-generate-summary",legacyEndpointName:"dugate-generate-summary",pipelineName:"Generate Summary",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"summary",maxFiles:5,description:"Generate a concise summary constrained by maxWords, format, and target audience.",inputSchema:o("task","summary",{format:{type:"string",enum:["paragraph","bullets","numbered","table","mind_map"],default:"bullets"},maxWords:{type:"integer",default:300},audience:{type:"string"}})},{endpointName:"du-generate-outline",legacyEndpointName:"dugate-generate-outline",pipelineName:"Generate Outline",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"outline",maxFiles:5,description:"Extract hierarchical H1/H2/H3 outline and section structure.",inputSchema:o("task","outline",{})},{endpointName:"du-generate-report",legacyEndpointName:"dugate-generate-report",pipelineName:"Generate Report",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"report",maxFiles:10,description:"Synthesize an executive analytical report across uploaded documents.",inputSchema:o("task","report",{focus:{type:"string"},language:{type:"string",default:"vi"}})},{endpointName:"du-generate-email",legacyEndpointName:"dugate-generate-email",pipelineName:"Generate Email",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"email",maxFiles:5,description:"Draft a professional email based on the uploaded documents.",inputSchema:o("task","email",{tone:{type:"string",default:"formal"},recipientRole:{type:"string"}})},{endpointName:"du-generate-minutes",legacyEndpointName:"dugate-generate-minutes",pipelineName:"Generate Minutes",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"minutes",maxFiles:5,description:"Generate structured meeting minutes with decisions, action items, and owners.",inputSchema:o("task","minutes",{format:{type:"string",enum:["md","json"],default:"json"}})},{endpointName:"du-generate-qa",legacyEndpointName:"dugate-generate-qa",pipelineName:"Generate Qa",businessId:"document-core",businessVersion:"2.0.0",action:"generate",discriminatorField:"task",discriminatorValue:"qa",maxFiles:5,description:"Answer questions grounded in the document with verbatim evidence quotes and confidence.",inputSchema:o("task","qa",{questions:{type:"array",items:{type:"string"}}})},{endpointName:"du-compare-diff",legacyEndpointName:"dugate-compare-diff",pipelineName:"Compare Diff",businessId:"document-core",businessVersion:"2.0.0",action:"compare",discriminatorField:"mode",discriminatorValue:"diff",maxFiles:2,description:"Compute deterministic line-by-line lexical diff between source and target documents.",inputSchema:o("mode","diff",{outputFormat:{type:"string",enum:["unified","json"],default:"json"}})},{endpointName:"du-compare-semantic",legacyEndpointName:"dugate-compare-semantic",pipelineName:"Compare Semantic",businessId:"document-core",businessVersion:"2.0.0",action:"compare",discriminatorField:"mode",discriminatorValue:"semantic",maxFiles:2,description:"Compare two documents semantically and assess legal significance (NEGLIGIBLE, MODERATE, HIGH).",inputSchema:o("mode","semantic",{focus:{type:"string"}})},{endpointName:"du-compare-version",legacyEndpointName:"dugate-compare-version",pipelineName:"Compare Version",businessId:"document-core",businessVersion:"2.0.0",action:"compare",discriminatorField:"mode",discriminatorValue:"version",maxFiles:2,description:"Generate a structured version changelog between two document revisions.",inputSchema:o("mode","version",{})},{endpointName:"du-workflow-disbursement",legacyEndpointName:"dugate-workflow-disbursement",pipelineName:"Workflow Disbursement",businessId:"document-core",businessVersion:"2.0.0",action:"disbursement",maxFiles:20,description:"Credit disbursement appraisal: parallel classify & extract, optional HITL approval (WAITING_INPUT), cross-check against referenceData, and memo generation.",inputSchema:{type:"object",properties:{inputVersion:{type:"string",default:"disbursement-input-v1"},referenceData:{type:"array",items:{type:"object",properties:{key:{type:"string"},expected:{}}}},maxConcurrency:{type:"integer",default:4,minimum:1,maximum:8},requireApproval:{type:"boolean",default:!1},failurePolicy:{type:"string",enum:["fail-closed","continue"],default:"fail-closed"}}}},{endpointName:"du-workflow-doc-compare",legacyEndpointName:"dugate-workflow-doc-compare",pipelineName:"Workflow Doc Compare",businessId:"document-core",businessVersion:"2.0.0",action:"doc-compare",maxFiles:2,description:"Long-document deep comparison: section chunking, structureClaims & referenceClaims verification, optional HITL review.",inputSchema:{type:"object",properties:{inputVersion:{type:"string",default:"doc-compare-input-v1"},chunkSizeChars:{type:"integer",default:8e3,minimum:200,maximum:2e5},requireHumanReview:{type:"boolean",default:!1},focus:{type:"string"}}}},{endpointName:"du-workflow-schema",pipelineName:"Workflow Schema",businessId:"document-core",businessVersion:"2.0.0",action:"schema-workflow",maxFiles:10,description:"Execute a provisioned dynamic pipeline/DAG workflow by pipelineName or pipelineId.",inputSchema:{type:"object",properties:{pipelineName:{type:"string"},pipelineId:{type:"integer"},parameters:{type:"object"}}}},{endpointName:"du-lc-checker",legacyEndpointName:"dugate-workflow-lc-checker",pipelineName:"Workflow Lc Checker",businessId:"lc-checker",businessVersion:"1.2.0",action:"lc-checker",maxFiles:50,description:"5-step Trade Finance L/C examination (OCR -> Screen -> Visual -> Adjudicate UCP 600 / ISBP 821 -> Vietnamese Report) with mandatory rule citations and humanSignOffRequired.",inputSchema:{type:"object",properties:{inputVersion:{type:"string",default:"lc-checker-input-v1"},ruleSetVersion:{type:"string",default:"ucp600-isbp821-v1"},maxConcurrency:{type:"integer",default:4,minimum:1,maximum:8},failurePolicy:{type:"string",enum:["fail-closed","continue"],default:"fail-closed"}}}},{endpointName:"du-example-review",pipelineName:"Example Review",businessId:"example-review",businessVersion:"1.0.0",action:"review",maxFiles:10,description:"Multi-document compliance review (1..10 PDF/DOCX/XLSX/JSON files) with fan-out item review and optional HITL approval.",inputSchema:{type:"object",properties:{reviewId:{type:"string"},requireApproval:{type:"boolean",default:!1},useAi:{type:"boolean",default:!0},criteria:{type:"array",items:{type:"string"}}}}}]}}]);
|
|
@@ -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_understanding_client_v2=self.webpackChunkplugin_document_understanding_client_v2||[]).push([["867"],{742:function(e,t,n){n.r(t),n.d(t,{PluginSettings:function(){return eh},default:function(){return eb}});var r=n(155),a=n.n(r),l=n(59),o=n(650),i=n(375),c=n(694),u=n(832);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){m(l,r,a,o,i,"next",e)}function i(e){m(l,r,a,o,i,"throw",e)}o(void 0)})}}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(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 n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var y=function(){var e=p(l.Form.useForm(),1)[0],t=(0,c.useFlowContext)().api,n=(0,o.k)(),s=p((0,r.useState)(!0),2),m=s[0],y=s[1],h=p((0,r.useState)(!1),2),b=h[0],g=h[1],E=p((0,r.useState)(!1),2),v=E[0],S=E[1],w=p((0,r.useState)(!1),2),I=w[0],k=w[1],O=p((0,r.useState)(),2),T=O[0],C=O[1],F=p((0,r.useState)([]),2),x=F[0],P=F[1],A=p((0,r.useState)(null),2),B=A[0],j=A[1],N=l.Form.useWatch("engineMode",e)||"builtin",R=l.Form.useWatch("llmService",e);if((0,r.useEffect)(function(){var n=!1;return d(function(){var r,a,l,o;return f(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,Promise.all([t.request({url:"docUnderstanding:getConfig"}),t.request({url:"docUnderstanding:listLlmServices"}).catch(function(){return null})])];case 1:if(a=(r=p.apply(void 0,[i.sent(),2]))[0],l=r[1],n)return[2];return e.setFieldsValue(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({engineMode:"builtin",publicGatewayEnabled:!0,maxFileSizeBytes:0xa00000,maxFilesPerRequest:20},(0,u.mT)(a,{}))),l&&P((0,u.mT)(l,[])),[3,4];case 2:return o=i.sent(),n||C((0,u.gJ)(o)),[3,4];case 3:return n||y(!1),[7];case 4:return[2]}})})(),function(){n=!0}},[t,e]),m)return a().createElement(l.Spin,{style:{marginTop:40}});var D=x.find(function(e){return e.llmService===R});return a().createElement(l.Form,{form:e,layout:"vertical",onFinish:function(e){return d(function(){var r;return f(this,function(a){switch(a.label){case 0:g(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,t.request({url:"docUnderstanding:updateConfig",method:"POST",data:e})];case 2:return a.sent(),l.message.success(n("Configuration saved successfully")),[3,5];case 3:return r=a.sent(),l.message.error("".concat(n("Failed to save config"),": ").concat((0,u.gJ)(r))),[3,5];case 4:return g(!1),[7];case 5:return[2]}})})()},style:{maxWidth:760}},T&&a().createElement(l.Alert,{message:T,type:"error",showIcon:!0,style:{marginBottom:16}}),a().createElement(l.Alert,{message:n("Document Understanding Service & Public API Gateway"),description:a().createElement("div",null,a().createElement("div",null,n("Provides built-in Document Understanding APIs (/api/du/v1/* and /api/v1/*) compatible with du-rework, with optional delegation to an external gateway.")),a().createElement(l.Space,{style:{marginTop:8},wrap:!0},a().createElement(l.Tag,{color:"blue"},"POST /api/du/v1/uploads"),a().createElement(l.Tag,{color:"blue"},"POST /api/du/v1/businesses/:id/actions/:action"),a().createElement(l.Tag,{color:"blue"},"GET /api/du/v1/operations/:id"),a().createElement(l.Tag,{color:"blue"},"GET /api/du/v1/artifacts/:id/download"))),type:"info",showIcon:!0,style:{marginBottom:16}}),a().createElement(l.Space,{style:{marginBottom:16},wrap:!0},a().createElement(l.Button,{icon:a().createElement(i.CheckCircleOutlined,null),onClick:function(){return d(function(){var e,r;return f(this,function(a){switch(a.label){case 0:S(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,t.request({url:"docUnderstanding:getHealth"})];case 2:return e=a.sent(),j((0,u.mT)(e,{})),l.message.success(n("Health check succeeded")),[3,5];case 3:return r=a.sent(),l.message.error("".concat(n("Health check failed"),": ").concat((0,u.gJ)(r))),[3,5];case 4:return S(!1),[7];case 5:return[2]}})})()},loading:v},n("Check Service Health")),a().createElement(l.Button,{icon:a().createElement(i.SyncOutlined,null),onClick:function(){return d(function(){var e,r,a,o,i;return f(this,function(c){switch(c.label){case 0:k(!0),c.label=1;case 1:return c.trys.push([1,3,4,5]),[4,t.request({url:"docUnderstanding:syncCatalog",method:"POST"})];case 2:return a=c.sent(),o=(0,u.mT)(a,{}),l.message.success("".concat(n("Catalog synchronized"),": ").concat(null!=(e=o.endpoints)?e:36," endpoints / ").concat(null!=(r=o.pipelines)?r:36," pipelines")),[3,5];case 3:return i=c.sent(),l.message.error((0,u.gJ)(i)),[3,5];case 4:return k(!1),[7];case 5:return[2]}})})()},loading:I},n("Sync du-rework Catalog (36 profiles)"))),B&&a().createElement(l.Card,{size:"small",style:{marginBottom:16},title:n("Runtime Health")},a().createElement("pre",{style:{margin:0,fontSize:12,overflow:"auto"}},JSON.stringify(B,null,2))),a().createElement(l.Card,{size:"small",title:n("Execution Engine & Gateway Policy"),style:{marginBottom:16}},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"engineMode",label:n("Execution Engine Mode"),initialValue:"builtin"},a().createElement(l.Select,{options:[{value:"builtin",label:n("Built-in NocoBase AI & Document Parser Engine")},{value:"hybrid",label:n("Hybrid (Built-in first, fallback to External Gateway)")},{value:"du_rework",label:n("External du-rework API Gateway")}]})),a().createElement(l.Form.Item,{name:"publicGatewayEnabled",label:n("Public API Gateway"),valuePropName:"checked",initialValue:!0},a().createElement(l.Switch,{checkedChildren:n("Enabled"),unCheckedChildren:n("Disabled")}))),"du_rework"!==N&&a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"llmService",label:n("Reasoning LLM Service (@nocobase/plugin-ai)"),help:n("Leave blank to auto-select the first enabled LLM service")},a().createElement(l.Select,{allowClear:!0,placeholder:n("Auto-select active LLM service"),options:x.map(function(e){return{value:e.llmService,label:"".concat(e.llmServiceTitle||e.llmService," (").concat(e.provider,")")}})})),a().createElement(l.Form.Item,{name:"llmModel",label:n("Reasoning Model")},D?a().createElement(l.Select,{allowClear:!0,placeholder:n("Auto-select default model"),options:D.enabledModels}):a().createElement(l.Input,{placeholder:"gpt-4o / gemini-2.5-pro"})),a().createElement(l.Form.Item,{name:"visionLlmService",label:n("Vision / OCR LLM Service (Optional)")},a().createElement(l.Select,{allowClear:!0,placeholder:n("Same as Reasoning LLM Service"),options:x.map(function(e){return{value:e.llmService,label:"".concat(e.llmServiceTitle||e.llmService," (").concat(e.provider,")")}})})),a().createElement(l.Form.Item,{name:"visionLlmModel",label:n("Vision / OCR Model (Optional)")},a().createElement(l.Input,{placeholder:"gemini-2.5-flash / gpt-4o"}))),a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"maxFilesPerRequest",label:n("Max Files per Operation (DI-06)"),initialValue:20},a().createElement(l.InputNumber,{style:{width:"100%"},min:1,max:50})),a().createElement(l.Form.Item,{name:"maxFileSizeBytes",label:n("Max File Size (bytes)"),initialValue:0xa00000},a().createElement(l.InputNumber,{style:{width:"100%"},min:102400,step:1048576})))),a().createElement(l.Card,{size:"small",title:n("External Gateway & Webhook Connection"),style:{marginBottom:16}},a().createElement(l.Form.Item,{name:"baseUrl",label:n("Base URL"),rules:[{required:!0,message:n("Base URL is required")}],help:n("Used when delegating to an external du-rework gateway or custom REST endpoints")},a().createElement(l.Input,{prefix:a().createElement(i.LinkOutlined,null),placeholder:"http://du-orchestrator:3000"})),a().createElement(l.Form.Item,{name:"authType",label:n("Authentication Type"),initialValue:"none"},a().createElement(l.Select,{options:[{value:"none",label:n("None")},{value:"api_key",label:n("API Key (x-api-key)")},{value:"bearer",label:n("Bearer Token")},{value:"custom_header",label:n("Custom Header")}]})),a().createElement(l.Form.Item,{noStyle:!0,dependencies:["authType"]},function(){var t=e.getFieldValue("authType");return t&&"none"!==t?a().createElement(a().Fragment,null,"custom_header"===t&&a().createElement(l.Form.Item,{name:"authHeaderName",label:n("Custom Header Name"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"x-api-key"})),a().createElement(l.Form.Item,{name:"authKey",label:"bearer"===t?n("Bearer Token"):n("API Key")},a().createElement(l.Input.Password,{placeholder:n("Leave blank to keep existing secret")}))):null}),a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"defaultTimeout",label:n("Request Timeout (ms)"),initialValue:3e4},a().createElement(l.InputNumber,{style:{width:"100%"},min:1e3,step:1e3})),a().createElement(l.Form.Item,{name:"defaultRetries",label:n("Default Retries"),initialValue:2},a().createElement(l.InputNumber,{style:{width:"100%"},min:0,max:10})),a().createElement(l.Form.Item,{name:"pollInterval",label:n("Poll Interval (ms)"),initialValue:5e3},a().createElement(l.InputNumber,{style:{width:"100%"},min:1e3,step:1e3})),a().createElement(l.Form.Item,{name:"pollTimeout",label:n("Poll Timeout (ms)"),initialValue:3e5},a().createElement(l.InputNumber,{style:{width:"100%"},min:5e3,step:5e3}))),a().createElement(l.Form.Item,{name:"webhookSecret",label:n("Webhook Secret"),help:n("Signs outbound x-du-signature callbacks and verifies incoming webhooks")},a().createElement(l.Input.Password,{placeholder:n("Optional: secret for HMAC-SHA256 webhook signature")}))),a().createElement(l.Form.Item,null,a().createElement(l.Button,{type:"primary",htmlType:"submit",icon:a().createElement(i.SaveOutlined,null),loading:b},n("Save Configuration"))))},h=n(585);function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function g(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function E(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){g(l,r,a,o,i,"next",e)}function i(e){g(l,r,a,o,i,"throw",e)}o(void 0)})}}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(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 S(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var w=l.Input.TextArea,I={PENDING_INGESTION:"default",ACCEPTED:"cyan",QUEUED:"blue",RUNNING:"processing",WAITING_CHILDREN:"processing",WAITING_INPUT:"warning",RETRY_PENDING:"orange",CANCEL_REQUESTED:"orange",SUCCEEDED:"success",FAILED:"error",CANCELLED:"default",TIMED_OUT:"error"},k=function(){var e,t,n,s=(0,c.useFlowContext)().api,m=(0,o.k)(),d=v((0,r.useState)([]),2),p=d[0],f=d[1],y=v((0,r.useState)(null),2),b=y[0],g=y[1],k=v((0,r.useState)(!1),2),O=k[0],T=k[1],C=v((0,r.useState)(),2),F=C[0],x=C[1],P=v((0,r.useState)(),2),A=P[0],B=P[1],j=v((0,r.useState)(!1),2),N=j[0],R=j[1],D=v((0,r.useState)(!1),2),U=D[0],z=D[1],M=v(l.Form.useForm(),1)[0],J=v((0,r.useState)([]),2),_=J[0],V=J[1],q=v((0,r.useState)(!1),2),L=q[0],H=q[1],G=v((0,r.useState)(null),2),W=G[0],K=G[1],$=v((0,r.useState)(!1),2),Q=$[0],Y=$[1],X=v((0,r.useState)(!1),2),Z=X[0],ee=X[1],et=v(l.Form.useForm(),1)[0],en=l.Form.useWatch("businessId",M)||"document-core",er=l.Form.useWatch("action",M)||"extract",ea=(0,r.useCallback)(function(){return E(function(){var e,t,n,r;return S(this,function(a){switch(a.label){case 0:T(!0),a.label=1;case 1:return a.trys.push([1,,3,4]),e={},F&&(e.state=F),A&&(e.businessId=A),[4,Promise.all([s.request({url:"docUnderstanding:listOperations",params:{filter:Object.keys(e).length>0?e:void 0}}),s.request({url:"docUnderstanding:getUsageSummary"}).catch(function(){return null})])];case 2:return n=(t=v.apply(void 0,[a.sent(),2]))[0],r=t[1],f((0,u.mT)(n,[])),r&&g((0,u.mT)(r,null)),[3,4];case 3:return T(!1),[7];case 4:return[2]}})})()},[s,F,A]);(0,r.useEffect)(function(){ea();var e=setInterval(ea,8e3);return function(){return clearInterval(e)}},[ea]);var el=function(e){return E(function(){var t,n;return S(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,s.request({url:"docUnderstanding:getOperation",params:{filterByTk:e}})];case 1:return t=r.sent(),K((0,u.mT)(t,null)),H(!0),[3,3];case 2:return n=r.sent(),l.message.error((0,u.gJ)(n)),[3,3];case 3:return[2]}})})()},eo=function(e){K(e),et.setFieldsValue({approved:!0,note:""}),Y(!0)},ei=Array.from(new Set(h.VQ.filter(function(e){return e.businessId===en}).map(function(e){return e.action}))),ec=h.VQ.filter(function(e){return e.businessId===en&&e.action===er&&e.discriminatorValue}),eu=[{title:m("Operation ID"),dataIndex:"id",width:150,render:function(e){return a().createElement("code",{style:{fontSize:11}},e.slice(0,12),"...")}},{title:m("Business / Action"),width:190,render:function(e,t){return a().createElement(l.Space,{size:4},a().createElement(l.Tag,{color:"geekblue"},t.businessId),a().createElement("span",null,t.action))}},{title:m("State"),dataIndex:"state",width:150,render:function(e){return a().createElement(l.Tag,{color:I[e]||"default"},e)}},{title:m("Progress"),width:130,render:function(e,t){var n,r;return a().createElement(l.Progress,{percent:null!=(n=null==(r=t.progress)?void 0:r.percent)?n:0,size:"small"})}},{title:m("Tokens / Cost"),width:150,render:function(e,t){return t.usage?a().createElement("span",{style:{fontSize:12}},t.usage.inputTokens+t.usage.outputTokens," tok ($",(t.usage.costMicrousd/1e6).toFixed(4),")"):"-"}},{title:m("Created"),dataIndex:"createdAt",width:165,render:function(e){return(0,u.r6)(e)}},{title:m("Action"),width:210,render:function(e,t){var n=["SUCCEEDED","FAILED","CANCELLED","TIMED_OUT"].includes(t.state);return a().createElement(l.Space,{size:4},a().createElement(l.Button,{size:"small",icon:a().createElement(i.EyeOutlined,null),onClick:function(){return el(t.id)},"aria-label":"".concat(m("View")," ").concat(t.id)},m("View")),"WAITING_INPUT"===t.state&&a().createElement(l.Button,{size:"small",type:"primary",icon:a().createElement(i.CheckOutlined,null),onClick:function(){return eo(t)},"aria-label":"".concat(m("Approve / Resume")," ").concat(t.id)},m("Resume")),!n&&a().createElement(l.Popconfirm,{title:m("Cancel this operation?"),onConfirm:function(){var e;return e=t.id,E(function(){var t;return S(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,s.request({url:"docUnderstanding:cancelOperation",method:"POST",params:{filterByTk:e}})];case 1:return n.sent(),l.message.success(m("Operation cancellation requested")),ea(),(null==W?void 0:W.id)===e&&el(e),[3,3];case 2:return t=n.sent(),l.message.error((0,u.gJ)(t)),[3,3];case 3:return[2]}})})()}},a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.StopOutlined,null),"aria-label":"".concat(m("Cancel")," ").concat(t.id)})))}}];return a().createElement("div",null,b&&a().createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:16}},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:m("Operations (30d)"),value:b.totalOperations})),a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:m("Input Tokens"),value:b.inputTokens})),a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:m("Output Tokens"),value:b.outputTokens})),a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:m("Estimated Cost (USD)"),value:(b.costMicrousd/1e6).toFixed(4),prefix:"$"}))),a().createElement(l.Space,{style:{marginBottom:16},wrap:!0},a().createElement(l.Button,{type:"primary",icon:a().createElement(i.PlayCircleOutlined,null),onClick:function(){M.resetFields(),V([]),R(!0)}},m("Run Business Action")),a().createElement(l.Select,{allowClear:!0,placeholder:m("Filter by state"),"aria-label":m("Filter by state"),value:F,onChange:x,style:{width:180},options:h.Xm.map(function(e){return{value:e,label:e}})}),a().createElement(l.Select,{allowClear:!0,placeholder:m("Filter by business"),"aria-label":m("Filter by business"),value:A,onChange:B,style:{width:180},options:[{value:"document-core",label:"document-core"},{value:"lc-checker",label:"lc-checker"},{value:"example-review",label:"example-review"}]}),a().createElement(l.Button,{icon:a().createElement(i.ReloadOutlined,null),onClick:ea},m("Refresh"))),a().createElement(l.Table,{rowKey:"id",columns:eu,dataSource:p,loading:O,size:"small",pagination:{pageSize:15}}),a().createElement(l.Modal,{title:m("Run Document Understanding Action"),open:N,onOk:function(){return E(function(){var e,t,n,r,a,o,i,c,d,p,f,y,b,g,E;return S(this,function(v){switch(v.label){case 0:z(!0),v.label=1;case 1:return v.trys.push([1,4,5,6]),[4,M.validateFields()];case 2:r=(null==(e=(n=v.sent()).inputJson)?void 0:e.trim())?JSON.parse(n.inputJson):{},(null==(a=h.VQ.find(function(e){return e.businessId===n.businessId&&e.action===n.action&&(!n.variant||e.discriminatorValue===n.variant)}))?void 0:a.discriminatorField)&&n.variant&&(r[a.discriminatorField]=n.variant),(null==(t=n.pages)?void 0:t.trim())&&((0,h.vZ)(n.pages),r.pages=n.pages.trim()),(o=new FormData).append("businessId",n.businessId),o.append("action",n.action),o.append("input",JSON.stringify(r)),i=!0,c=!1,d=void 0;try{for(p=_[Symbol.iterator]();!(i=(f=p.next()).done);i=!0)(y=f.value).originFileObj&&o.append("files",y.originFileObj,y.name)}catch(e){c=!0,d=e}finally{try{i||null==p.return||p.return()}finally{if(c)throw d}}return[4,s.request({url:"docUnderstanding:submitOperation",method:"POST",data:o})];case 3:return b=v.sent(),g=(0,u.mT)(b,{}),l.message.success("".concat(m("Operation submitted"),": ").concat(g.operationId||"")),R(!1),V([]),ea(),g.operationId&&el(g.operationId),[3,6];case 4:return E=v.sent(),l.message.error((0,u.gJ)(E)),[3,6];case 5:return z(!1),[7];case 6:return[2]}})})()},onCancel:function(){return R(!1)},confirmLoading:U,okText:m("Submit Operation"),cancelText:m("Cancel"),width:640,destroyOnClose:!0},a().createElement(l.Form,{form:M,layout:"vertical",initialValues:{businessId:"document-core",action:"extract",variant:"invoice",inputJson:"{}"}},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"businessId",label:m("Business"),rules:[{required:!0}]},a().createElement(l.Select,{options:[{value:"document-core",label:"document-core (v2.0.0)"},{value:"lc-checker",label:"lc-checker (v1.2.0)"},{value:"example-review",label:"example-review (v1.0.0)"}]})),a().createElement(l.Form.Item,{name:"action",label:m("Action"),rules:[{required:!0}]},a().createElement(l.Select,{options:ei.map(function(e){return{value:e,label:e}})}))),ec.length>0&&a().createElement(l.Form.Item,{name:"variant",label:m("Variant / Mode")},a().createElement(l.Select,{options:ec.map(function(e){return{value:e.discriminatorValue,label:"".concat(e.discriminatorValue," — ").concat(e.description)}})})),a().createElement(l.Form.Item,{label:m("Upload Input Documents")},a().createElement(l.Upload,{multiple:!0,beforeUpload:function(){return!1},fileList:_,onChange:function(e){return V(e.fileList)}},a().createElement(l.Button,{icon:a().createElement(i.UploadOutlined,null)},m("Select Files")))),a().createElement(l.Form.Item,{name:"pages",label:m("Page Selection (DI-06)"),help:m('Optional page ranges, e.g. "1-2, 5" (leave blank for all pages)')},a().createElement(l.Input,{placeholder:"1-2"})),a().createElement(l.Form.Item,{name:"inputJson",label:m("Input JSON")},a().createElement(w,{rows:4,style:{fontFamily:"monospace",fontSize:12}})))),a().createElement(l.Modal,{title:"".concat(m("Human-in-the-Loop Approval")," — ").concat((null==W?void 0:W.id.slice(0,12))||""),open:Q,onOk:function(){return E(function(){var e,t,n;return S(this,function(r){switch(r.label){case 0:if(!W)return[2];ee(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,et.validateFields()];case 2:return t=r.sent(),[4,s.request({url:"docUnderstanding:resumeOperation",method:"POST",params:{filterByTk:W.id},data:{waitId:null==(e=W.wait)?void 0:e.waitId,expectedStateVersion:W.stateVersion,input:t}})];case 3:return r.sent(),l.message.success(m("Operation resumed")),Y(!1),ea(),el(W.id),[3,6];case 4:return n=r.sent(),l.message.error((0,u.gJ)(n)),[3,6];case 5:return ee(!1),[7];case 6:return[2]}})})()},onCancel:function(){return Y(!1)},confirmLoading:Z,okText:m("Submit Decision"),cancelText:m("Cancel"),destroyOnClose:!0},(null==W||null==(e=W.wait)?void 0:e.prompt)&&a().createElement(l.Alert,{message:W.wait.prompt,type:"warning",showIcon:!0,style:{marginBottom:16}}),(null==W||null==(t=W.wait)?void 0:t.previewData)!==void 0&&a().createElement("pre",{style:{background:"#fafafa",padding:10,borderRadius:6,maxHeight:200,overflow:"auto",fontSize:11,marginBottom:16}},JSON.stringify(W.wait.previewData,null,2)),a().createElement(l.Form,{form:et,layout:"vertical",initialValues:{approved:!0}},a().createElement(l.Form.Item,{name:"approved",label:m("Approve & Proceed"),valuePropName:"checked"},a().createElement(l.Switch,{checkedChildren:m("Approve"),unCheckedChildren:m("Reject")})),a().createElement(l.Form.Item,{name:"note",label:m("Reviewer Note")},a().createElement(w,{rows:3,placeholder:m("Enter verification note...")})))),a().createElement(l.Drawer,{title:W?"".concat(m("Operation")," ").concat(W.id):m("Operation Details"),width:680,open:L,onClose:function(){return H(!1)}},W&&a().createElement("div",null,a().createElement(l.Space,{wrap:!0,style:{marginBottom:16}},a().createElement(l.Tag,{color:I[W.state]||"default"},W.state),a().createElement(l.Tag,{color:"geekblue"},W.businessId,"@",W.businessVersion," / ",W.action),a().createElement("span",null,"v",W.stateVersion),"WAITING_INPUT"===W.state&&a().createElement(l.Button,{size:"small",type:"primary",onClick:function(){return eo(W)}},m("Approve / Resume"))),(null==(n=W.outputPayload)?void 0:n.humanSignOffRequired)===!0&&a().createElement(l.Alert,{type:"warning",showIcon:!0,message:m("Human Sign-off Required (Trade Finance L/C Policy)"),description:m("Automated UCP 600 / ISBP 821 findings require an authorized specialist signature."),style:{marginBottom:16}}),W.error&&a().createElement(l.Alert,{type:"error",showIcon:!0,message:"".concat(W.error.code,": ").concat(W.error.title),description:W.error.detail,style:{marginBottom:16}}),W.usage&&a().createElement(a().Fragment,null,a().createElement("h4",null,m("Token & Cost Usage")),a().createElement("pre",{style:{background:"#f5f5f5",padding:10,borderRadius:6,fontSize:12}},JSON.stringify(W.usage,null,2))),W.documentInputCoverage&&a().createElement(a().Fragment,null,a().createElement("h4",null,m("Document Input Coverage (DI-06)")),a().createElement("pre",{style:{background:"#f5f5f5",padding:10,borderRadius:6,fontSize:11,maxHeight:160,overflow:"auto"}},JSON.stringify(W.documentInputCoverage,null,2))),a().createElement("h4",null,m("Output Payload")),a().createElement("pre",{style:{background:"#f0f5ff",padding:12,borderRadius:6,fontSize:12,maxHeight:360,overflow:"auto"}},W.outputPayload?JSON.stringify(W.outputPayload,null,2):m("(not yet available)")))))};function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function T(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function C(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){T(l,r,a,o,i,"next",e)}function i(e){T(l,r,a,o,i,"throw",e)}o(void 0)})}}function F(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return O(e,t)}}(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 x(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var P=function(){var e=(0,c.useFlowContext)().api,t=(0,o.k)(),n=F((0,r.useState)([]),2),s=n[0],m=n[1],d=F((0,r.useState)(!1),2),p=d[0],f=d[1],y=F((0,r.useState)(!1),2),h=y[0],b=y[1],g=F((0,r.useState)(!1),2),E=g[0],v=g[1],S=F((0,r.useState)(null),2),w=S[0],I=S[1],k=F(l.Form.useForm(),1)[0],O=(0,r.useCallback)(function(){return C(function(){var t;return x(this,function(n){switch(n.label){case 0:f(!0),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,e.request({url:"docUnderstanding:listApiKeys"})];case 2:return t=n.sent(),m((0,u.mT)(t,[])),[3,4];case 3:return f(!1),[7];case 4:return[2]}})})()},[e]);(0,r.useEffect)(function(){O()},[O]);var T=[{title:t("Name"),dataIndex:"name",width:180},{title:t("Key Prefix"),dataIndex:"keyPrefix",width:160,render:function(e){return a().createElement("code",null,e,"...")}},{title:t("Tenant"),dataIndex:"tenantId",width:120,render:function(e){return a().createElement(l.Tag,null,e)}},{title:t("Allowed Businesses"),dataIndex:"allowedBusinesses",width:220,render:function(e){return(e||["*"]).map(function(e){return a().createElement(l.Tag,{key:e},e)})}},{title:t("Status"),dataIndex:"status",width:100,render:function(e){return a().createElement(l.Tag,{color:"active"===e?"success":"error"},e)}},{title:t("Last Used"),dataIndex:"lastUsedAt",width:165,render:function(e){return(0,u.r6)(e)}},{title:t("Action"),width:110,render:function(n,r){return"active"===r.status?a().createElement(l.Popconfirm,{title:t("Revoke this API key?"),onConfirm:function(){var n;return n=r.id,C(function(){return x(this,function(r){switch(r.label){case 0:return[4,e.request({url:"docUnderstanding:revokeApiKey",method:"POST",params:{filterByTk:n}})];case 1:return r.sent(),l.message.success(t("API key revoked")),O(),[2]}})})()}},a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.StopOutlined,null),"aria-label":"".concat(t("Revoke")," ").concat(r.name)},t("Revoke"))):null}}];return a().createElement("div",null,a().createElement(l.Alert,{type:"info",showIcon:!0,icon:a().createElement(i.KeyOutlined,null),message:t("Gateway API Keys (x-api-key)"),description:t("External integrations pass x-api-key to call /api/du/v1/* or /api/v1/{uploads,businesses,operations,artifacts,usage}. Keys are stored as one-way SHA-256 hashes and isolated by Tenant ID."),style:{marginBottom:16}}),w&&a().createElement(l.Alert,{type:"success",showIcon:!0,closable:!0,onClose:function(){return I(null)},message:t("Copy your new x-api-key now — it will never be shown again"),description:a().createElement(l.Typography.Paragraph,{copyable:!0,style:{margin:"8px 0 0",fontFamily:"monospace"}},w.rawKey),style:{marginBottom:16}}),a().createElement(l.Space,{style:{marginBottom:16}},a().createElement(l.Button,{type:"primary",icon:a().createElement(i.PlusOutlined,null),onClick:function(){k.resetFields(),b(!0)}},t("Issue API Key"))),a().createElement(l.Table,{rowKey:"id",columns:T,dataSource:s,loading:p,size:"small"}),a().createElement(l.Modal,{title:t("Issue Gateway API Key"),open:h,onOk:function(){return C(function(){var n,r,a,o,i;return x(this,function(c){switch(c.label){case 0:v(!0),c.label=1;case 1:return c.trys.push([1,4,5,6]),[4,k.validateFields()];case 2:return a=c.sent(),[4,e.request({url:"docUnderstanding:issueApiKey",method:"POST",data:{name:a.name,tenantId:a.tenantId||"default",allowedBusinesses:(null==(n=a.allowedBusinesses)?void 0:n.length)?a.allowedBusinesses:["*"],allowedActions:(null==(r=a.allowedActions)?void 0:r.length)?a.allowedActions:["*"]}})];case 3:return o=c.sent(),I((0,u.mT)(o,null)),b(!1),O(),l.message.success(t("API key issued")),[3,6];case 4:return i=c.sent(),l.message.error((0,u.gJ)(i)),[3,6];case 5:return v(!1),[7];case 6:return[2]}})})()},onCancel:function(){return b(!1)},confirmLoading:E,okText:t("Issue Key"),cancelText:t("Cancel"),destroyOnClose:!0},a().createElement(l.Form,{form:k,layout:"vertical",initialValues:{tenantId:"default",allowedBusinesses:["*"]}},a().createElement(l.Form.Item,{name:"name",label:t("Key Name"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"ERP Invoice Integration"})),a().createElement(l.Form.Item,{name:"tenantId",label:t("Tenant ID"),help:t("Operations and artifacts are isolated per Tenant ID (cross-tenant lookups return 404)")},a().createElement(l.Input,{placeholder:"default"})),a().createElement(l.Form.Item,{name:"allowedBusinesses",label:t("Allowed Businesses")},a().createElement(l.Select,{mode:"multiple",options:[{value:"*",label:t("All Businesses (*)")},{value:"document-core",label:"document-core"},{value:"lc-checker",label:"lc-checker"},{value:"example-review",label:"example-review"}]})))))};function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function B(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function j(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){B(l,r,a,o,i,"next",e)}function i(e){B(l,r,a,o,i,"throw",e)}o(void 0)})}}function N(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||D(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 R(e){return function(e){if(Array.isArray(e))return A(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||D(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e,t){if(e){if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(e,t)}}function U(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var z=l.Input.TextArea,M=function(e){var t=e.value,n=e.onChange,c=(0,o.k)(),u=N((0,r.useState)([]),2),s=u[0],m=u[1],d=(0,r.useRef)(),p=JSON.stringify(null!=t?t:{});(0,r.useEffect)(function(){d.current!==p&&(d.current=p,m(Object.entries(JSON.parse(p)).map(function(e,t){var n=N(e,2),r=n[0],a=n[1];return{id:"".concat(r,"_").concat(t),key:r,value:String(null!=a?a:"")}})))},[p]);var f=function(e){m(e);var t=e.reduce(function(e,t){var n=t.key.trim();return n&&(e[n]=t.value),e},{});d.current=JSON.stringify(t),null==n||n(t)},y=function(e,t,n){var r,a,l=R(s);l[e]=(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},l[e]),a=a={key:t,value:n},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(a)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(a,e))}),r),f(l)},h=function(e){f(s.filter(function(t,n){return n!==e}))};return a().createElement("div",null,s.map(function(e,t){return a().createElement(l.Space,{key:e.id,style:{display:"flex",marginBottom:4}},a().createElement(l.Input,{placeholder:c("Header name"),"aria-label":c("Header name"),value:e.key,onChange:function(n){return y(t,n.target.value,e.value)},style:{width:180}}),a().createElement(l.Input,{placeholder:c("Value"),"aria-label":c("Value"),value:e.value,onChange:function(n){return y(t,e.key,n.target.value)},style:{width:220}}),a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.DeleteOutlined,null),onClick:function(){return h(t)},"aria-label":"".concat(c("Delete")," ").concat(e.key||c("Header name"))}))}),a().createElement(l.Button,{size:"small",type:"dashed",icon:a().createElement(i.PlusOutlined,null),onClick:function(){return m(R(s).concat([{id:"new_".concat(Date.now(),"_").concat(Math.random()),key:"",value:""}]))}},c("Add Header")))},J=function(e){var t=e.value,n=e.onChange,l=e.placeholder,i=(0,o.k)(),c=N((0,r.useState)(""),2),u=c[0],s=c[1],m=N((0,r.useState)(""),2),d=m[0],p=m[1];return(0,r.useEffect)(function(){if(!t)return void s("");try{s("string"==typeof t?JSON.stringify(JSON.parse(t),null,2):JSON.stringify(t,null,2))}catch(e){s("string"==typeof t?t:"")}},[t]),a().createElement("div",null,a().createElement(z,{rows:6,value:u,onChange:function(e){return s(e.target.value)},onBlur:function(){if(!u.trim()){p(""),null==n||n(null);return}try{var e=JSON.parse(u);p(""),null==n||n(e)}catch(e){p(i("Invalid JSON"))}},placeholder:l||"{}",status:d?"error":void 0,style:{fontFamily:"monospace",fontSize:12}}),d&&a().createElement("div",{role:"alert",style:{color:"#ff4d4f",fontSize:12}},d))},_=function(){var e=(0,c.useFlowContext)().api,t=(0,o.k)(),n=N((0,r.useState)([]),2),s=n[0],m=n[1],d=N((0,r.useState)(!1),2),p=d[0],f=d[1],y=N((0,r.useState)(!1),2),h=y[0],b=y[1],g=N(l.Form.useForm(),1)[0],E=N((0,r.useState)(null),2),v=E[0],S=E[1],w={sync:t("Synchronous"),polling:t("Polling"),webhook:t("Webhook")},I={multipart:t("Multipart Upload"),base64:t("Base64 in JSON")},k=(0,r.useCallback)(function(){return j(function(){var t;return U(this,function(n){switch(n.label){case 0:f(!0),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,e.request({url:"docUnderstanding:listEndpoints"})];case 2:return t=n.sent(),m((0,u.mT)(t,[])),[3,4];case 3:return f(!1),[7];case 4:return[2]}})})()},[e]);(0,r.useEffect)(function(){k()},[k]);var O=function(e){S(e.id),g.setFieldsValue(e),b(!0)},T=[{title:t("Name"),dataIndex:"name",width:170},{title:t("Protocol"),dataIndex:"protocolMode",width:130,render:function(e){return"builtin_du"===e?a().createElement(l.Tag,{color:"geekblue"},"du-rework (Built-in)"):"du_rework_v1"===e?a().createElement(l.Tag,{color:"blue"},"du-rework (Remote)"):a().createElement(l.Tag,null,t("Custom REST"))}},{title:t("Subpath"),dataIndex:"subpath",width:220},{title:t("Method"),dataIndex:"method",width:80,render:function(e){return a().createElement(l.Tag,null,e)}},{title:t("Execution"),dataIndex:"executionMode",width:130,render:function(e){return a().createElement(l.Tag,{color:{sync:"green",polling:"blue",webhook:"purple"}[e]},w[e]||e)}},{title:t("File"),dataIndex:"fileInputMode",width:130,render:function(e){return"none"===e?"-":I[e]||e}},{title:t("Enabled"),dataIndex:"enabled",width:70,render:function(e){return e?a().createElement(l.Tag,{color:"success"},t("Yes")):a().createElement(l.Tag,null,t("No"))}},{title:t("Action"),width:120,render:function(n,r){return a().createElement(l.Space,null,a().createElement(l.Button,{type:"link",size:"small",icon:a().createElement(i.EditOutlined,null),onClick:function(){return O(r)},"aria-label":"".concat(t("Edit")," ").concat(r.name)},t("Edit")),a().createElement(l.Popconfirm,{title:t("Delete this endpoint?"),okText:t("Delete"),onConfirm:function(){var n;return n=r.id,j(function(){return U(this,function(r){switch(r.label){case 0:return[4,e.request({url:"docUnderstanding:deleteEndpoint",method:"POST",params:{filterByTk:n}})];case 1:return r.sent(),l.message.success(t("Deleted")),k(),[2]}})})()}},a().createElement(l.Button,{type:"link",size:"small",danger:!0,icon:a().createElement(i.DeleteOutlined,null),"aria-label":"".concat(t("Delete")," ").concat(r.name)},t("Delete"))))}}];return a().createElement("div",null,a().createElement("div",{style:{marginBottom:16}},a().createElement(l.Button,{type:"primary",icon:a().createElement(i.PlusOutlined,null),onClick:function(){S(null),g.resetFields(),b(!0)}},t("Add Endpoint"))),a().createElement(l.Table,{rowKey:"id",columns:T,dataSource:s,loading:p,size:"small"}),a().createElement(l.Modal,{title:v?t("Edit Endpoint"):t("Add Endpoint"),open:h,onOk:function(){return j(function(){var n;return U(this,function(r){switch(r.label){case 0:return r.trys.push([0,6,,7]),[4,g.validateFields()];case 1:if((n=r.sent()).customHeaders=Object.entries(n.customHeaders||{}).reduce(function(e,t){var n=N(t,2),r=n[0],a=n[1],l=r.trim();return l&&(e[l]=a),e},{}),!v)return[3,3];return[4,e.request({url:"docUnderstanding:updateEndpoint",method:"POST",params:{filterByTk:v},data:n})];case 2:return r.sent(),[3,5];case 3:return[4,e.request({url:"docUnderstanding:createEndpoint",method:"POST",data:n})];case 4:r.sent(),r.label=5;case 5:return l.message.success(t("Saved")),b(!1),k(),[3,7];case 6:return r.sent(),[3,7];case 7:return[2]}})})()},onCancel:function(){return b(!1)},okText:t("Save"),cancelText:t("Cancel"),width:680,destroyOnClose:!0},a().createElement(l.Form,{form:g,layout:"vertical",preserve:!1},a().createElement(l.Tabs,{size:"small",items:[{key:"basic",label:t("Basic"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"name",label:t("Unique Name"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"ocr, classify, extract..."})),a().createElement(l.Form.Item,{name:"subpath",label:t("Subpath"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"/api/v1/ocr"})),a().createElement(l.Form.Item,{name:"description",label:t("Description")},a().createElement(z,{rows:2,placeholder:t("What this endpoint does")})),a().createElement(l.Space,{size:"large"},a().createElement(l.Form.Item,{name:"method",label:t("HTTP Method"),initialValue:"POST"},a().createElement(l.Select,{style:{width:120},options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"}]})),a().createElement(l.Form.Item,{name:"enabled",label:t("Enabled"),valuePropName:"checked",initialValue:!0},a().createElement(l.Switch,null))))},{key:"file",label:t("File Input"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"fileInputMode",label:t("File Input Mode"),initialValue:"none"},a().createElement(l.Select,{style:{width:200},options:[{value:"none",label:t("None")},{value:"multipart",label:t("Multipart Upload")},{value:"base64",label:t("Base64 in JSON")}]})),a().createElement(l.Form.Item,{noStyle:!0,dependencies:["fileInputMode"]},function(){return"none"!==g.getFieldValue("fileInputMode")?a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"fileFieldName",label:t("File Field Name"),initialValue:"file"},a().createElement(l.Input,{placeholder:"file",style:{width:200}})),a().createElement(l.Form.Item,{name:"maxFiles",label:t("Max Files"),initialValue:1},a().createElement(l.InputNumber,{min:1,max:20,style:{width:120}}))):null}))},{key:"gateway",label:t("Gateway / Discriminator"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"protocolMode",label:t("Protocol Mode"),initialValue:"legacy_rest"},a().createElement(l.Select,{style:{width:280},options:[{value:"builtin_du",label:t("Canonical du-rework (Built-in / Hybrid)")},{value:"du_rework_v1",label:t("Canonical du-rework (External Gateway)")},{value:"legacy_rest",label:t("Legacy / Generic HTTP REST")}]})),a().createElement(l.Space,{size:"middle"},a().createElement(l.Form.Item,{name:"businessId",label:t("Business ID")},a().createElement(l.Input,{placeholder:"document-core",style:{width:180}})),a().createElement(l.Form.Item,{name:"actionName",label:t("Action Name")},a().createElement(l.Input,{placeholder:"extract",style:{width:180}}))),a().createElement(l.Form.Item,{name:"discriminatorField",label:t("Discriminator Field"),help:t("Form field that selects the API sub-case (e.g. mode/type/task/action/process). Sent automatically.")},a().createElement(l.Input,{placeholder:"mode",style:{width:200}})),a().createElement(l.Form.Item,{name:"discriminatorValue",label:t("Discriminator Value"),help:t("Value sent in the discriminator field (e.g. parse, invoice, disbursement).")},a().createElement(l.Input,{placeholder:"parse",style:{width:200}})),a().createElement(l.Form.Item,{name:"syncQueryParam",label:t("Sync Query Param"),help:t("When set, the request appends ?<param>=true to ask for a synchronous response (e.g. sync).")},a().createElement(l.Input,{placeholder:"sync",style:{width:200}})),a().createElement(l.Form.Item,{name:"taskIdExtractPath",label:t("Task ID Extract Path"),help:t("JSON path of the async task id in the 202 response (e.g. name). Used when the response is 202 even in sync mode.")},a().createElement(l.Input,{placeholder:"name",style:{width:200}})),a().createElement(l.Form.Item,{name:"taskIdExtractRegex",label:t("Task ID Extract Regex"),help:t("Regex with one capture group to pull the task id from the extracted path value (e.g. operations/([^/]+)).")},a().createElement(l.Input,{placeholder:"operations/([^/]+)",style:{width:240}})))},{key:"async",label:t("Async Config"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"executionMode",label:t("Execution Mode"),initialValue:"sync"},a().createElement(l.Select,{style:{width:200},options:[{value:"sync",label:t("Synchronous")},{value:"polling",label:t("Polling")},{value:"webhook",label:t("Webhook")}]})),a().createElement(l.Form.Item,{noStyle:!0,dependencies:["executionMode"]},function(){var e=g.getFieldValue("executionMode");return"sync"===e?null:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"pollTaskIdField",label:t("Task ID Field"),help:t("Field in response containing the async task ID"),initialValue:"task_id"},a().createElement(l.Input,{placeholder:"task_id"})),"polling"===e&&a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"pollResultSubpath",label:t("Poll Result Subpath"),help:t("URL to poll for result. Use {taskId} as placeholder."),rules:[{required:!0,message:t("Required for polling mode")}]},a().createElement(l.Input,{placeholder:"/api/v1/tasks/{taskId}/result"})),a().createElement(l.Form.Item,{name:"pollResultField",label:t("Result Field"),help:t("Field in poll response containing the actual result")},a().createElement(l.Input,{placeholder:"result"})),a().createElement(l.Form.Item,{name:"pollStatusField",label:t("Status Field (optional)"),help:t("Field to check completion status. If empty, any non-null result = complete.")},a().createElement(l.Input,{placeholder:"status"})),a().createElement(l.Form.Item,{name:"pollCompletedValue",label:t("Completed Value"),help:t("Value of status field that means 'done'"),initialValue:"completed"},a().createElement(l.Input,{placeholder:"completed"})),a().createElement(l.Space,{size:"large"},a().createElement(l.Form.Item,{name:"pollInterval",label:t("Poll Interval (ms)"),help:t("Override default")},a().createElement(l.InputNumber,{min:1e3,step:1e3,placeholder:"5000",style:{width:150}})),a().createElement(l.Form.Item,{name:"pollTimeout",label:t("Poll Timeout (ms)"),help:t("Override default")},a().createElement(l.InputNumber,{min:5e3,step:5e3,placeholder:"300000",style:{width:150}})))))}))},{key:"schema",label:t("Schema"),children:a().createElement(a().Fragment,null,a().createElement(l.Form.Item,{name:"requestBodySchema",label:t("Request Body Schema (JSON Schema)")},a().createElement(J,{placeholder:'{ "type": "object", "properties": { ... } }'})),a().createElement(l.Form.Item,{name:"responseSchema",label:t("Response Schema (JSON Schema)")},a().createElement(J,{placeholder:'{ "type": "object", "properties": { ... } }'})))},{key:"headers",label:t("Custom Headers"),children:a().createElement(l.Form.Item,{name:"customHeaders",label:t("Additional Headers")},a().createElement(M,null))}]}))))};function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function q(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function L(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){q(l,r,a,o,i,"next",e)}function i(e){q(l,r,a,o,i,"throw",e)}o(void 0)})}}function H(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function G(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){H(e,t,n[t])})}return e}function W(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function K(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||Q(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 $(e){return function(e){if(Array.isArray(e))return V(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Q(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Q(e,t){if(e){if("string"==typeof e)return V(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return V(e,t)}}function Y(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var X=l.Input.TextArea,Z=l.Collapse.Panel,ee={pending:"default",running:"processing",polling:"processing",completed:"success",failed:"error",timeout:"error"},et=["completed","failed","timeout"],en=function(e){return!!e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"&&!Array.isArray(e)},er=function(e){return JSON.stringify(null!=e?e:{},null,2)},ea=function(e){return en(e)?Object.prototype.hasOwnProperty.call(e,"default")?e.default:"object"===e.type||e.properties?Object.entries(e.properties||{}).reduce(function(e,t){var n=K(t,2),r=n[0],a=ea(n[1]);return void 0!==a&&(e[r]=a),e},{}):"array"===e.type?[]:void 0:{}},el=function(e,t){return en(e)&&en(t)?Object.entries(e).reduce(function(e,t){var n=K(t,2),r=n[0],a=n[1];return W(G({},e),H({},r,el(a,e[r])))},G({},t)):void 0===t?e:t},eo=function(e){var t=e.value,n=e.onChange,l=e.placeholder,i=e.rows,c=(0,o.k)(),u=K((0,r.useState)(""),2),s=u[0],m=u[1],d=K((0,r.useState)(""),2),p=d[0],f=d[1];return(0,r.useEffect)(function(){if(!t)return void m("");try{m("string"==typeof t?JSON.stringify(JSON.parse(t),null,2):JSON.stringify(t,null,2))}catch(e){m("string"==typeof t?t:"")}},[t]),a().createElement("div",null,a().createElement(X,{rows:void 0===i?5:i,value:s,onChange:function(e){return m(e.target.value)},onBlur:function(){if(!s.trim()){f(""),null==n||n(null);return}try{var e=JSON.parse(s);f(""),null==n||n(e)}catch(e){f(c("Invalid JSON"))}},placeholder:l||"{}",status:p?"error":void 0,style:{fontFamily:"monospace",fontSize:12}}),p&&a().createElement("div",{role:"alert",style:{color:"#ff4d4f",fontSize:12}},p))},ei=function(e){var t=e.steps,n=e.endpoints,r=e.onChange,c=(0,o.k)(),u=function(e,n){var a,l=$(t),o=e+n;o<0||o>=l.length||(a=[l[o],l[e]],l[e]=a[0],l[o]=a[1],l.forEach(function(e,t){return e.stepOrder=t+1}),r(l))},s=function(e,n,a){var l=$(t);l[e]=W(G({},l[e]),H({},n,a)),r(l)},m=function(e){var n=t.filter(function(t,n){return n!==e});n.forEach(function(e,t){return e.stepOrder=t+1}),r(n)},d=function(){var e;r($(t).concat([(e=t.length+1,{_key:"new_".concat(Date.now(),"_").concat(Math.random()),stepOrder:e,name:"",endpointId:null,inputMapping:null,outputAlias:"",condition:null,onError:"fail",retryCount:0})]))};return 0===t.length?a().createElement("div",{style:{textAlign:"center",padding:"20px 0"}},a().createElement(l.Empty,{description:c("No steps yet"),imageStyle:{height:40}}),a().createElement(l.Button,{type:"dashed",icon:a().createElement(i.PlusOutlined,null),onClick:d,style:{marginTop:8}},c("Add First Step"))):a().createElement("div",null,a().createElement(l.Collapse,{size:"small",defaultActiveKey:t.map(function(e){return e._key})},t.map(function(e,r){var o=n.find(function(t){return t.id===e.endpointId}),d=a().createElement(l.Space,{size:4,onClick:function(e){return e.stopPropagation()}},a().createElement(l.Button,{size:"small",disabled:0===r,icon:a().createElement(i.ArrowUpOutlined,null),onClick:function(){return u(r,-1)},"aria-label":c("Move step up")}),a().createElement(l.Button,{size:"small",disabled:r===t.length-1,icon:a().createElement(i.ArrowDownOutlined,null),onClick:function(){return u(r,1)},"aria-label":c("Move step down")}),a().createElement(l.Popconfirm,{title:c("Remove step?"),okText:c("Delete"),onConfirm:function(){return m(r)}},a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.DeleteOutlined,null),"aria-label":c("Remove step?")}))),p=a().createElement(l.Space,null,a().createElement(l.Badge,{count:e.stepOrder,style:{backgroundColor:"#1677ff"}}),a().createElement("span",null,e.name||c("(unnamed)")),o&&a().createElement(l.Tag,null,o.name),"skip"===e.onError&&a().createElement(l.Tooltip,{title:c("Step can be skipped on error")},a().createElement(l.Tag,{color:"orange"},c("skip on error"))),e.condition&&a().createElement(l.Tooltip,{title:c("Has condition")},a().createElement(l.Tag,{color:"purple"},c("conditional")))),f="step-name-".concat(e._key),y="step-endpoint-".concat(e._key),h="step-alias-".concat(e._key);return a().createElement(Z,{key:e._key,header:p,extra:d},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement("div",null,a().createElement("label",{htmlFor:f,style:{fontWeight:500,display:"block",marginBottom:4}},c("Step Name")," *"),a().createElement(l.Input,{id:f,value:e.name,onChange:function(e){return s(r,"name",e.target.value)},placeholder:"OCR, Classify, Extract..."})),a().createElement("div",null,a().createElement("label",{htmlFor:y,style:{fontWeight:500,display:"block",marginBottom:4}},c("Endpoint")," *"),a().createElement(l.Select,{id:y,value:e.endpointId,onChange:function(e){return s(r,"endpointId",e)},placeholder:c("Select endpoint"),style:{width:"100%"},options:n.map(function(e){return{value:e.id,label:"".concat(e.name," (").concat(e.method," ").concat(e.subpath,")")}})})),a().createElement("div",null,a().createElement("label",{htmlFor:h,style:{fontWeight:500,display:"block",marginBottom:4,marginTop:12}},c("Output Alias")),a().createElement(l.Input,{id:h,value:e.outputAlias,onChange:function(e){return s(r,"outputAlias",e.target.value)},placeholder:"ocr_result"}),a().createElement("div",{style:{color:"#888",fontSize:11}},c("Other steps reference this as"),": $step[",e.outputAlias||e.stepOrder,"].response.field")),a().createElement("div",null,a().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4,marginTop:12}},c("On Error")),a().createElement(l.Space,null,a().createElement(l.Select,{value:e.onError,onChange:function(e){return s(r,"onError",e)},style:{width:120},"aria-label":c("On Error"),options:[{value:"fail",label:c("Fail")},{value:"skip",label:c("Skip")},{value:"retry",label:c("Retry")}]}),"retry"===e.onError&&a().createElement(l.InputNumber,{value:e.retryCount,onChange:function(e){return s(r,"retryCount",e||0)},min:1,max:10,addonBefore:"x",style:{width:100},"aria-label":c("Retry")})))),a().createElement("div",{style:{marginTop:12}},a().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4}},c("Input Mapping (JSON)"),a().createElement(l.Tooltip,{title:c("Map endpoint input fields. Use $input.field, $step[alias].response.field, $files, or literal values.")},a().createElement("span",{style:{fontWeight:"normal",color:"#888",marginLeft:6,cursor:"help"}},"?"))),a().createElement(eo,{value:e.inputMapping,onChange:function(e){return s(r,"inputMapping",e)},placeholder:'{ "text": "$step[ocr_result].response.text", "lang": "vi" }',rows:3})),a().createElement("div",{style:{marginTop:12}},a().createElement("label",{style:{fontWeight:500,display:"block",marginBottom:4}},c("Condition (optional JSON)"),a().createElement(l.Tooltip,{title:c("Only run this step if the condition matches.")},a().createElement("span",{style:{fontWeight:"normal",color:"#888",marginLeft:6,cursor:"help"}},"?"))),a().createElement(eo,{value:e.condition,onChange:function(e){return s(r,"condition",e)},placeholder:'{ "field": "$step[classify].response.type", "op": "eq", "value": "invoice" }',rows:2})))})),a().createElement(l.Button,{type:"dashed",icon:a().createElement(i.PlusOutlined,null),onClick:d,style:{marginTop:8,width:"100%"}},c("Add Step")))},ec=function(){var e=(0,c.useFlowContext)().api,t=(0,o.k)(),n=K((0,r.useState)([]),2),s=n[0],m=n[1],d=K((0,r.useState)([]),2),p=d[0],f=d[1],y=K((0,r.useState)(!1),2),h=y[0],b=y[1],g=K((0,r.useState)(!1),2),E=g[0],v=g[1],S=K(l.Form.useForm(),1)[0],w=K((0,r.useState)(null),2),I=w[0],k=w[1],O=K((0,r.useState)([]),2),T=O[0],C=O[1],F=K((0,r.useState)(!1),2),x=F[0],P=F[1],A=K((0,r.useState)(null),2),B=A[0],j=A[1],N=K((0,r.useState)("{}"),2),R=N[0],D=N[1],U=K((0,r.useState)(""),2),z=U[0],M=U[1],J=K((0,r.useState)(null),2),_=J[0],V=J[1],q=K((0,r.useState)(!1),2),H=q[0],Q=q[1],en=(0,r.useRef)(null),ec={pending:t("Pending"),running:t("Running"),polling:t("Polling"),completed:t("Completed"),failed:t("Failed"),timeout:t("Timeout")},eu=(0,r.useCallback)(function(){return L(function(){var t,n,r;return Y(this,function(a){switch(a.label){case 0:b(!0),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,Promise.all([e.request({url:"docUnderstanding:listPipelines"}),e.request({url:"docUnderstanding:listEndpoints"})])];case 2:return n=(t=K.apply(void 0,[a.sent(),2]))[0],r=t[1],m((0,u.mT)(n,[])),f((0,u.mT)(r,[])),[3,4];case 3:return b(!1),[7];case 4:return[2]}})})()},[e]);(0,r.useEffect)(function(){eu()},[eu]),(0,r.useEffect)(function(){return function(){en.current&&clearInterval(en.current)}},[]);var es=function(e){k(e.id),S.setFieldsValue({name:e.name,description:e.description,enabled:e.enabled,inputSchema:e.inputSchema,outputMapping:e.outputMapping}),C($(e.steps||[]).sort(function(e,t){return e.stepOrder-t.stepOrder}).map(function(e){var t;return{_key:"srv_".concat(e.id),id:e.id,stepOrder:e.stepOrder,name:e.name,endpointId:e.endpointId,inputMapping:null!=(t=e.inputMapping)?t:null,outputAlias:e.outputAlias||"",condition:e.condition,onError:e.onError||"fail",retryCount:e.retryCount||0}})),v(!0)},em=(0,r.useCallback)(function(){en.current&&(clearInterval(en.current),en.current=null)},[]),ed=(0,r.useCallback)(function(t){return L(function(){var n,r;return Y(this,function(a){switch(a.label){case 0:return[4,e.request({url:"docUnderstanding:getJobStatus",params:{filterByTk:t}})];case 1:return n=a.sent(),V(r=(0,u.mT)(n,null)),r&&et.includes(r.status)&&(em(),Q(!1)),[2,r]}})})()},[e,em]),ep=(0,r.useCallback)(function(e){em(),en.current=setInterval(function(){ed(e).catch(function(e){em(),Q(!1),l.message.error((0,u.gJ)(e)||t("Failed to refresh test job"))})},1500)},[ed,em,t]),ef=function(e){em(),j(e),V(null),Q(!1),M(""),D(er(ea(e.inputSchema))),P(!0)},ey=function(){em(),P(!1),j(null),V(null),Q(!1)},eh=[{title:t("Name"),dataIndex:"name",width:200},{title:t("Steps"),dataIndex:"steps",width:300,render:function(e){if(!e||0===e.length)return a().createElement(l.Tag,null,"0 ",t("steps"));var n=$(e).sort(function(e,t){return e.stepOrder-t.stepOrder});return a().createElement(l.Space,{size:2,wrap:!0},n.map(function(e,n){return a().createElement(a().Fragment,{key:e.id},n>0&&a().createElement("span",{style:{color:"#ccc"}},"→"),a().createElement(l.Tag,null,e.name||"".concat(t("Step")," ").concat(e.stepOrder)))}))}},{title:t("Enabled"),dataIndex:"enabled",width:80,render:function(e){return e?a().createElement(l.Tag,{color:"success"},t("Yes")):a().createElement(l.Tag,null,t("No"))}},{title:t("AI Tool"),width:100,render:function(e,n){var r;return n.enabled?a().createElement(l.Tooltip,{title:"".concat(t("Registered as"),": doc_understanding.").concat(null==(r=n.name)?void 0:r.toLowerCase().replace(/[^a-z0-9_]/g,"_"))},a().createElement(l.Tag,{color:"blue",icon:a().createElement(i.ThunderboltOutlined,null)},t("Active"))):a().createElement(l.Tag,null,t("Inactive"))}},{title:t("Action"),width:190,render:function(n,r){return a().createElement(l.Space,null,a().createElement(l.Button,{type:"link",size:"small",icon:a().createElement(i.PlayCircleOutlined,null),disabled:!r.enabled,onClick:function(){return ef(r)},"aria-label":"".concat(t("Test")," ").concat(r.name)},t("Test")),a().createElement(l.Button,{type:"link",size:"small",icon:a().createElement(i.EditOutlined,null),onClick:function(){return es(r)},"aria-label":"".concat(t("Edit")," ").concat(r.name)},t("Edit")),a().createElement(l.Popconfirm,{title:t("Delete this pipeline?"),okText:t("Delete"),onConfirm:function(){var n;return n=r.id,L(function(){return Y(this,function(r){switch(r.label){case 0:return[4,e.request({url:"docUnderstanding:deletePipeline",method:"POST",params:{filterByTk:n}})];case 1:return r.sent(),l.message.success(t("Deleted")),eu(),[2]}})})()}},a().createElement(l.Button,{type:"link",size:"small",danger:!0,icon:a().createElement(i.DeleteOutlined,null),"aria-label":"".concat(t("Delete")," ").concat(r.name)},t("Delete"))))}}];return a().createElement("div",null,a().createElement("div",{style:{marginBottom:16}},a().createElement(l.Button,{type:"primary",icon:a().createElement(i.PlusOutlined,null),onClick:function(){k(null),S.resetFields(),C([]),v(!0)}},t("Add Pipeline"))),a().createElement(l.Table,{rowKey:"id",columns:eh,dataSource:s,loading:h,size:"small"}),a().createElement(l.Modal,{title:I?t("Edit Pipeline"):t("New Pipeline"),open:E,onOk:function(){return L(function(){var n,r,a,o,i,c,u,s,m;return Y(this,function(d){switch(d.label){case 0:return d.trys.push([0,6,,7]),[4,S.validateFields()];case 1:n=d.sent(),r=!0,a=!1,o=void 0;try{for(i=T[Symbol.iterator]();!(r=(c=i.next()).done);r=!0){if(!(u=c.value).name)return l.message.error(t("All steps must have a name")),[2];if(!u.endpointId)return l.message.error("".concat(t("Step"),' "').concat(u.name||u.stepOrder,'" ').concat(t("must have an endpoint"))),[2]}}catch(e){a=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(a)throw o}}if(new Set(s=T.map(function(e){return e.outputAlias}).filter(Boolean)).size!==s.length)return l.message.error(t("Step output aliases must be unique")),[2];if(m=W(G({},n),{steps:T.map(function(e){return W(G({},e.id?{id:e.id}:{}),{stepOrder:e.stepOrder,name:e.name,endpointId:e.endpointId,inputMapping:e.inputMapping,outputAlias:e.outputAlias||void 0,condition:e.condition,onError:e.onError,retryCount:"retry"===e.onError?e.retryCount:0})})}),!I)return[3,3];return[4,e.request({url:"docUnderstanding:updatePipeline",method:"POST",params:{filterByTk:I},data:m})];case 2:return d.sent(),[3,5];case 3:return[4,e.request({url:"docUnderstanding:createPipeline",method:"POST",data:m})];case 4:d.sent(),d.label=5;case 5:return l.message.success(t("Saved")),v(!1),eu(),[3,7];case 6:return d.sent(),[3,7];case 7:return[2]}})})()},onCancel:function(){return v(!1)},okText:t("Save"),cancelText:t("Cancel"),width:800,destroyOnClose:!0},a().createElement(l.Form,{form:S,layout:"vertical",preserve:!1},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 16px"}},a().createElement(l.Form.Item,{name:"name",label:t("Pipeline Name"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"full_document_processing"})),a().createElement(l.Form.Item,{name:"enabled",label:t("Enabled"),valuePropName:"checked",initialValue:!0},a().createElement(l.Switch,null))),a().createElement(l.Form.Item,{name:"description",label:t("Description")},a().createElement(X,{rows:2,placeholder:t("What this pipeline does")})),a().createElement(l.Card,{title:t("Pipeline Steps"),size:"small",style:{marginBottom:16},extra:a().createElement(l.Tag,{color:"blue"},T.length," ",t("step(s)"))},a().createElement(ei,{steps:T,endpoints:p,onChange:C})),a().createElement(l.Collapse,{size:"small",ghost:!0},a().createElement(Z,{header:t("Advanced: Input Schema & Output Mapping"),key:"advanced"},a().createElement(l.Form.Item,{name:"inputSchema",label:t("Input Schema (JSON Schema)"),help:t("Defines what input this pipeline accepts. Used by AI tool schema.")},a().createElement(eo,{placeholder:'{ "type": "object", "properties": { "document_url": { "type": "string" } }, "required": ["document_url"] }'})),a().createElement(l.Form.Item,{name:"outputMapping",label:t("Output Mapping (JSON)"),help:t("Map final step results to pipeline output. If empty, all step results are returned.")},a().createElement(eo,{placeholder:'{ "text": "$step[ocr_result].response.text", "category": "$step[classify].response.category" }'})))))),a().createElement(l.Modal,{title:B?"".concat(t("Test Playground"),": ").concat(B.name):t("Test Playground"),open:x,onCancel:ey,width:860,destroyOnClose:!0,footer:[a().createElement(l.Button,{key:"close",onClick:ey},t("Close")),(null==_?void 0:_.id)&&a().createElement(l.Button,{key:"refresh",icon:a().createElement(i.ReloadOutlined,null),disabled:H,onClick:function(){return ed(_.id)}},t("Refresh")),a().createElement(l.Button,{key:"run",type:"primary",icon:a().createElement(i.PlayCircleOutlined,null),loading:H,onClick:function(){return L(function(){var n,r,a,o,i,c;return Y(this,function(s){switch(s.label){case 0:if(!B)return[2];try{r=R.trim()?JSON.parse(R):{},n=el(ea(B.inputSchema),r),M("")}catch(e){return M(t("Invalid JSON input")),[2]}em(),Q(!0),V(null),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,e.request({url:"docUnderstanding:executePipeline",method:"POST",data:{pipelineId:B.id,input:n}})];case 2:if(a=s.sent(),!(o=(0,u.mT)(a,{}).jobId))throw Error(t("Pipeline did not return a job ID"));return[4,ed(o)];case 3:return(i=s.sent())&&et.includes(i.status)||ep(o),l.message.success("".concat(t("Test job started"),": #").concat(o)),[3,5];case 4:return c=s.sent(),Q(!1),l.message.error((0,u.gJ)(c)||t("Failed to run pipeline test")),[3,5];case 5:return[2]}})})()}},t("Run test"))].filter(Boolean)},a().createElement("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:16}},a().createElement("div",null,a().createElement("label",{htmlFor:"playground-input",style:{fontWeight:500,marginBottom:6,display:"block"}},t("Input JSON")),a().createElement(X,{id:"playground-input",rows:16,value:R,onChange:function(e){D(e.target.value),z&&M("")},placeholder:'{ "document_url": "https://..." }',status:z?"error":void 0,style:{fontFamily:"monospace",fontSize:12}}),z&&a().createElement(l.Alert,{type:"error",showIcon:!0,message:z,style:{marginTop:8}}),a().createElement(l.Collapse,{size:"small",ghost:!0,style:{marginTop:12}},a().createElement(Z,{header:t("Input Schema"),key:"schema"},a().createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:6,fontSize:12,maxHeight:220,overflow:"auto"}},er(null==B?void 0:B.inputSchema))))),a().createElement("div",null,a().createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6}},a().createElement("span",{style:{fontWeight:500}},t("Result")),(null==_?void 0:_.status)&&a().createElement(l.Tag,{color:ee[_.status]||"default"},ec[_.status]||_.status)),_?a().createElement("div",null,a().createElement(l.Space,{style:{marginBottom:8},wrap:!0},a().createElement(l.Tag,null,t("Job")," #",_.id),_.currentStep&&a().createElement(l.Tag,null,t("Step")," ",_.currentStep)),_.error&&a().createElement(l.Alert,{type:"error",showIcon:!0,message:t("Pipeline error"),description:a().createElement("pre",{style:{margin:0,whiteSpace:"pre-wrap"}},_.error),style:{marginBottom:12}}),a().createElement("div",{style:{fontWeight:500,marginBottom:4}},t("Final Result")),a().createElement("pre",{style:{background:"#f0f5ff",padding:12,borderRadius:6,fontSize:12,maxHeight:220,overflow:"auto"}},void 0!==_.finalResult&&null!==_.finalResult?er(_.finalResult):t("(not yet available)")),a().createElement("div",{style:{fontWeight:500,margin:"12px 0 4px"}},t("Step Results")),a().createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:6,fontSize:12,maxHeight:260,overflow:"auto"}},_.stepResults?er(_.stepResults):"{}")):a().createElement(l.Empty,{description:t("Run a test to see job output"),imageStyle:{height:48}})))))};function eu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function es(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function em(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){es(l,r,a,o,i,"next",e)}function i(e){es(l,r,a,o,i,"throw",e)}o(void 0)})}}function ed(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eu(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 ep(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,r=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var ef={pending:"default",running:"processing",polling:"processing",waiting_input:"warning",completed:"success",failed:"error",cancelled:"default",timeout:"error"},ey=function(){var e=(0,c.useFlowContext)().api,t=(0,o.k)(),n=ed((0,r.useState)([]),2),s=n[0],m=n[1],d=ed((0,r.useState)([]),2),p=d[0],f=d[1],y=ed((0,r.useState)(!1),2),h=y[0],b=y[1],g=ed((0,r.useState)(!1),2),E=g[0],v=g[1],S=ed((0,r.useState)(null),2),w=S[0],I=S[1],k=ed((0,r.useState)(void 0),2),O=k[0],T=k[1],C=ed((0,r.useState)(void 0),2),F=C[0],x=C[1],P=ed((0,r.useState)(!1),2),A=P[0],B=P[1],j=ed((0,r.useState)(!1),2),N=j[0],R=j[1],D=ed(l.Form.useForm(),1)[0],U={pending:t("Pending"),running:t("Running"),polling:t("Polling"),waiting_input:t("Waiting Input"),completed:t("Completed"),failed:t("Failed"),cancelled:t("Cancelled"),timeout:t("Timeout")},z=(0,r.useCallback)(function(){return em(function(){var t,n;return ep(this,function(r){switch(r.label){case 0:b(!0),r.label=1;case 1:return r.trys.push([1,,3,4]),t={},O&&(t.status=O),F&&(t.pipelineId=F),[4,e.request({url:"docUnderstanding:listJobs",params:{filter:Object.keys(t).length>0?t:void 0}})];case 2:return n=r.sent(),m((0,u.mT)(n,[])),[3,4];case 3:return b(!1),[7];case 4:return[2]}})})()},[e,O,F]),M=(0,r.useCallback)(function(){return em(function(){var t;return ep(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e.request({url:"docUnderstanding:listPipelines"})];case 1:return t=n.sent(),f((0,u.mT)(t,[])),[3,3];case 2:return n.sent(),[3,3];case 3:return[2]}})})()},[e]);(0,r.useEffect)(function(){M()},[M]),(0,r.useEffect)(function(){z();var e=setInterval(z,1e4);return function(){return clearInterval(e)}},[z]);var J=new Map(p.map(function(e){return[e.id,e.name]})),_=function(t){return em(function(){var n;return ep(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.request({url:"docUnderstanding:getJobStatus",params:{filterByTk:t.id}})];case 1:return n=r.sent(),I((0,u.mT)(n,t)),[3,3];case 2:return r.sent(),I(t),[3,3];case 3:return v(!0),[2]}})})()},V=[{title:t("ID"),dataIndex:"id",width:60},{title:t("Pipeline"),dataIndex:"pipelineId",width:180,render:function(e){return J.get(e)||"#".concat(e)}},{title:t("Status"),dataIndex:"status",width:120,render:function(e){return a().createElement(l.Tag,{color:ef[e]||"default"},U[e]||e)}},{title:t("Current Step"),dataIndex:"currentStep",width:100,render:function(e,n){return"completed"===n.status?a().createElement(l.Tag,{color:"success"},t("Done")):"failed"===n.status||"cancelled"===n.status?a().createElement(l.Tag,{color:"error"},"".concat(t("Step")," ").concat(e)):a().createElement(l.Badge,{status:"processing",text:"".concat(t("Step")," ").concat(e)})}},{title:t("Started"),dataIndex:"startedAt",width:160,render:function(e){return(0,u.r6)(e)}},{title:t("Completed"),dataIndex:"completedAt",width:160,render:function(e){return(0,u.r6)(e)}},{title:t("Action"),width:190,render:function(n,r){var o=["completed","failed","cancelled","timeout"].includes(r.status);return a().createElement(l.Space,{size:4},a().createElement(l.Button,{size:"small",icon:a().createElement(i.EyeOutlined,null),onClick:function(){return _(r)},"aria-label":"".concat(t("View")," #").concat(r.id)},t("View")),"waiting_input"===r.status&&a().createElement(l.Button,{size:"small",type:"primary",icon:a().createElement(i.CheckOutlined,null),onClick:function(){I(r),D.setFieldsValue({approved:!0,note:""}),B(!0)},"aria-label":"".concat(t("Resume")," #").concat(r.id)},t("Resume")),!o&&a().createElement(l.Popconfirm,{title:t("Cancel this job?"),onConfirm:function(){var n;return n=r.id,em(function(){var r;return ep(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,e.request({url:"docUnderstanding:cancelJob",method:"POST",params:{filterByTk:n}})];case 1:return a.sent(),l.message.success(t("Job cancelled")),z(),[3,3];case 2:return r=a.sent(),l.message.error((0,u.gJ)(r)),[3,3];case 3:return[2]}})})()}},a().createElement(l.Button,{size:"small",danger:!0,icon:a().createElement(i.StopOutlined,null),"aria-label":"".concat(t("Cancel")," #").concat(r.id)})))}}];return a().createElement("div",null,a().createElement(l.Space,{style:{marginBottom:16},wrap:!0},a().createElement(l.Select,{allowClear:!0,placeholder:t("Filter by status"),"aria-label":t("Filter by status"),value:O,onChange:T,style:{width:170},options:Object.keys(ef).map(function(e){return{value:e,label:U[e]}})}),a().createElement(l.Select,{allowClear:!0,placeholder:t("Filter by pipeline"),"aria-label":t("Filter by pipeline"),value:F,onChange:x,style:{width:200},options:p.map(function(e){return{value:e.id,label:e.name}})}),a().createElement(l.Button,{icon:a().createElement(i.ReloadOutlined,null),onClick:z},t("Refresh"))),a().createElement(l.Table,{rowKey:"id",columns:V,dataSource:s,loading:h,size:"small",pagination:{pageSize:20}}),a().createElement(l.Modal,{title:"".concat(t("Approve / Resume")," #").concat((null==w?void 0:w.id)||""),open:A,onOk:function(){return em(function(){var n,r;return ep(this,function(a){switch(a.label){case 0:if(!w)return[2];R(!0),a.label=1;case 1:return a.trys.push([1,4,5,6]),[4,D.validateFields()];case 2:return n=a.sent(),[4,e.request({url:"docUnderstanding:resumeJob",method:"POST",params:{filterByTk:w.id},data:n})];case 3:return a.sent(),l.message.success(t("Job resumed")),B(!1),z(),_(w),[3,6];case 4:return r=a.sent(),l.message.error((0,u.gJ)(r)),[3,6];case 5:return R(!1),[7];case 6:return[2]}})})()},onCancel:function(){return B(!1)},confirmLoading:N,okText:t("Submit Decision"),cancelText:t("Cancel"),destroyOnClose:!0},a().createElement(l.Form,{form:D,layout:"vertical",initialValues:{approved:!0}},a().createElement(l.Form.Item,{name:"approved",label:t("Approve & Proceed"),valuePropName:"checked"},a().createElement(l.Switch,{checkedChildren:t("Approve"),unCheckedChildren:t("Reject")})),a().createElement(l.Form.Item,{name:"note",label:t("Reviewer Note")},a().createElement(l.Input.TextArea,{rows:3})))),a().createElement(l.Drawer,{title:w?"".concat(t("Job")," #").concat(w.id," — ").concat(J.get(w.pipelineId)||t("Unknown")):t("Job Details"),width:640,open:E,onClose:function(){return v(!1)}},w&&a().createElement("div",null,a().createElement("div",{style:{marginBottom:16}},a().createElement(l.Space,{wrap:!0},a().createElement(l.Tag,{color:ef[w.status]||"default"},U[w.status]||w.status),w.startedAt&&a().createElement("span",null,t("Started"),": ",(0,u.r6)(w.startedAt)),w.completedAt&&a().createElement("span",null,t("Completed"),": ",(0,u.r6)(w.completedAt)))),w.error&&a().createElement("div",{style:{background:"#fff2f0",border:"1px solid #ffccc7",borderRadius:6,padding:12,marginBottom:16}},a().createElement("strong",{style:{color:"#cf1322"}},t("Error"),":"),a().createElement("pre",{style:{margin:"4px 0 0",whiteSpace:"pre-wrap",color:"#cf1322"}},w.error)),w.usage&&a().createElement(a().Fragment,null,a().createElement("h4",null,t("Token & Cost Usage")),a().createElement("pre",{style:{background:"#f5f5f5",padding:10,borderRadius:6,fontSize:12}},JSON.stringify(w.usage,null,2))),a().createElement("h4",null,t("Input")),a().createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:6,fontSize:12,maxHeight:200,overflow:"auto"}},JSON.stringify(w.input,null,2)),a().createElement("h4",{style:{marginTop:16}},t("Step Results")),w.stepResults&&Object.keys(w.stepResults).length>0?Object.entries(w.stepResults).map(function(e){var t=ed(e,2),n=t[0],r=t[1];return a().createElement("div",{key:n,style:{marginBottom:8}},a().createElement(l.Tag,{color:"blue"},n),a().createElement("pre",{style:{background:"#f5f5f5",padding:8,borderRadius:4,fontSize:11,maxHeight:150,overflow:"auto",marginTop:4}},JSON.stringify(r,null,2)))}):a().createElement("div",{style:{color:"#999"}},t("No step results yet")),a().createElement("h4",{style:{marginTop:16}},t("Final Result")),a().createElement("pre",{style:{background:"#f0f5ff",padding:12,borderRadius:6,fontSize:12,maxHeight:300,overflow:"auto"}},w.finalResult?JSON.stringify(w.finalResult,null,2):t("(not yet available)")),w.externalTaskIds&&Object.keys(w.externalTaskIds).length>0&&a().createElement(a().Fragment,null,a().createElement("h4",{style:{marginTop:16}},t("External Task IDs")),a().createElement("pre",{style:{background:"#f5f5f5",padding:8,borderRadius:4,fontSize:11}},JSON.stringify(w.externalTaskIds,null,2))))))},eh=function(e){var t=e.embedded,n=void 0!==t&&t,r=(0,o.k)();return a().createElement("div",{style:{backgroundColor:"var(--nb-box-bg)",minHeight:n?void 0:"100vh"}},!n&&a().createElement("div",{style:{padding:"16px 24px",backgroundColor:"#fff",borderBottom:"1px solid #f0f0f0"}},a().createElement("h2",{style:{margin:0,fontSize:20,fontWeight:500}},r("Document Understanding - Pipeline Orchestrator"))),a().createElement("div",{style:{padding:n?0:"0 24px 24px"}},a().createElement(l.Tabs,{defaultActiveKey:"config",items:[{key:"config",label:r("Service Config"),children:a().createElement(y,null)},{key:"operations",label:r("Operations"),children:a().createElement(k,null)},{key:"api-keys",label:r("API Keys"),children:a().createElement(P,null)},{key:"endpoints",label:r("Endpoints"),children:a().createElement(_,null)},{key:"pipelines",label:r("Pipelines"),children:a().createElement(ec,null)},{key:"jobs",label:r("Jobs history"),children:a().createElement(ey,null)}]})))},eb=eh}}]);
|
package/dist/client-v2/index.js
CHANGED
|
@@ -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+".2fa9834b46dd4531.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)},p={},s.l=function(e,t,n,r){if(p[e])return void p[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),p[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=p[e];if(delete p[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=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&&(f=s.g.location+"");var p,f,d=s.g.document;if(!f&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(f=d.currentScript.src),!f)){var b=d.getElementsByTagName("script");if(b.length)for(var g=b.length-1;g>-1&&(!f||!/^http(s?):/.test(f));)f=b[g--].src}if(!f)throw Error("Automatic publicPath is not supported in this browser");s.p=f.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.".concat(this.options.name||"document-understanding")}),this.pluginSettingsManager.addPageTabItem({menuKey:"document-understanding",key:"index",title:this.t("Document Understanding"),componentLoader:function(){return s.e("345").then(s.bind(s,824))},aclSnippet:"pm.".concat(this.options.name||"document-understanding")}),[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("@nocobase/plugin-workflow/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("plugin-document-understanding/client-v2",["@nocobase/client-v2","react","antd","@nocobase/plugin-workflow/client-v2","@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("@nocobase/plugin-workflow/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["plugin-document-understanding/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/plugin-workflow/client-v2"],e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i){return function(){"use strict";var u,a,c,l={650:function(e,t,n){n.d(t,{M:function(){return u},k:function(){return i}});var r=n(694),o=JSON.parse('{"UU":"plugin-document-understanding"}');function i(){var e=(0,r.useFlowEngine)();return function(t){return e.context.t(t,{ns:[o.UU,"client"]})}}function u(e){return(0,r.tExpr)(e,{ns:[o.UU,"client"]})}},375:function(e){e.exports=o},485:function(t){t.exports=e},694:function(e){e.exports=i},197:function(e){e.exports=r},59:function(e){e.exports=n},155:function(e){e.exports=t}},s={};function f(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return l[e](n,n.exports,f),n.exports}f.m=l,f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.f={},f.e=function(e){return Promise.all(Object.keys(f.f).reduce(function(t,n){return f.f[n](e,t),t},[]))},f.u=function(e){return""+e+"."+({169:"53bf1be2ec192f0c",379:"e75c4829567cdb89",867:"66d7291e95f1de78"})[e]+".js"},f.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},p={},f.l=function(e,t,n,r){if(p[e])return void p[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),a=0;a<u.length;a++){var c=u[a];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="plugin-document-understanding/client-v2:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,f.nc&&o.setAttribute("nonce",f.nc),o.setAttribute("data-rspack","plugin-document-understanding/client-v2:"+n),o.src=e),p[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=p[e];if(delete p[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=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)},f.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.g.importScripts&&(d=f.g.location+"");var p,d,b=f.g.document;if(!d&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(d=b.currentScript.src),!d)){var v=b.getElementsByTagName("script");if(v.length)for(var g=v.length-1;g>-1&&(!d||!/^http(s?):/.test(d));)d=v[g--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");f.p=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),u={889:0},f.f.j=function(e,t){var n=f.o(u,e)?u[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=u[e]=[t,r]});t.push(n[2]=r);var o=f.p+f.u(e),i=Error();f.l(o,function(t){if(f.o(u,e)&&(0!==(n=u[e])&&(u[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},a=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==u[e]})){for(n in i)f.o(i,n)&&(f.m[n]=i[n]);a&&a(f)}for(e&&e(t);c<o.length;c++)r=o[c],f.o(u,r)&&u[r]&&u[r][0](),u[r]=0},(c=self.webpackChunkplugin_document_understanding_client_v2=self.webpackChunkplugin_document_understanding_client_v2||[]).forEach(a.bind(null,0)),c.push=a.bind(null,c.push.bind(c));var y={};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||"/",a=u.indexOf(i);e=a>=0?u.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-document-understanding/dist/client-v2/"}f.p=e}(),!function(){f.r(y),f.d(y,{default:function(){return m}});var e=f(485),t=f(155),n=f.n(t),r=f(375),o=f(197),i=f(650);function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return(a=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 l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var s=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function o(){var e,t,c;if(!(this instanceof o))throw TypeError("Cannot call a class as a function");return t=o,c=arguments,t=a(t),u(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,l()?Reflect.construct(t,c||[],a(this).constructor):t.apply(this,c)),"type","document-understanding"),u(e,"title",(0,i.M)("Document Understanding")),u(e,"group","extended"),u(e,"description",(0,i.M)("Parse, OCR, extract, analyze, transform, compare, or audit L/C & disbursement documents via Document Understanding.")),u(e,"icon",n().createElement(r.FileSearchOutlined,null)),u(e,"FieldsetLoader",function(){return Promise.all([f.e("379"),f.e("169")]).then(f.bind(f,328)).then(function(e){return{default:e.DocumentUnderstandingFieldset}})}),e}return o.prototype=Object.create(e&&e.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),e&&c(o,e),t=[{key:"createDefaultConfig",value:function(){return{mode:"business_action",businessId:"document-core",action:"extract",variant:"invoice",ignoreFail:!1}}},{key:"useVariables",value:function(e){return{value:e.key,label:e.title,children:[{value:"operationId",label:(0,i.M)("Operation ID")},{value:"state",label:(0,i.M)("State")},{value:"data",label:(0,i.M)("Structured Data")},{value:"markdown",label:(0,i.M)("Markdown Content")},{value:"text",label:(0,i.M)("Plain Text")},{value:"report",label:(0,i.M)("Report")},{value:"verdict",label:(0,i.M)("Verdict")},{value:"discrepancies",label:(0,i.M)("Discrepancies")},{value:"usage",label:(0,i.M)("Token & Cost Usage")}]}}}],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)}}(o.prototype,t),o}(o.Instruction);function p(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function d(e,t,n){return(d=h()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&v(o,n.prototype),o}).apply(null,arguments)}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e){var t="function"==typeof Map?new Map:void 0;return(g=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return d(e,arguments,b(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,e)})(e)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}var m=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=b(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,h()?Reflect.construct(e,t||[],b(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&v(n,e),t=[{key:"load",value:function(){var e;return(e=function(){var e,t;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),a=Object.defineProperty;return a(u,"next",{value:c(0)}),a(u,"throw",{value:c(1)}),a(u,"return",{value:c(2)}),"function"==typeof Symbol&&a(u,Symbol.iterator,{value:function(){return this}}),u;function c(a){return function(c){var l=[a,c];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(n){return this.pluginSettingsManager.addMenuItem({key:"document-understanding",title:this.t("Document Understanding"),icon:"FileSearchOutlined",aclSnippet:"pm.".concat(this.options.name||"document-understanding")}),this.pluginSettingsManager.addPageTabItem({menuKey:"document-understanding",key:"index",title:this.t("Document Understanding"),componentLoader:function(){return Promise.all([f.e("379"),f.e("867")]).then(f.bind(f,742))},aclSnippet:"pm.".concat(this.options.name||"document-understanding")}),null==(t=this.app.pm.get("workflow")||this.app.pm.get("@nocobase/plugin-workflow"))||null==(e=t.registerInstruction)||e.call(t,"document-understanding",s),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){p(i,r,o,u,a,"next",e)}function a(e){p(i,r,o,u,a,"throw",e)}u(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)}}(n.prototype,t),n}(g(e.Plugin))}(),y}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -9,14 +9,16 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
|
-
"@nocobase/client": "2.2.
|
|
13
|
-
"@nocobase/
|
|
14
|
-
"@nocobase/
|
|
15
|
-
"@nocobase/
|
|
16
|
-
"@nocobase/
|
|
17
|
-
"@nocobase/
|
|
18
|
-
"@nocobase/
|
|
12
|
+
"@nocobase/client": "2.2.52",
|
|
13
|
+
"@nocobase/plugin-workflow": "2.2.52",
|
|
14
|
+
"@nocobase/flow-engine": "2.2.52",
|
|
15
|
+
"@nocobase/client-v2": "2.2.52",
|
|
16
|
+
"@nocobase/actions": "2.2.52",
|
|
17
|
+
"@nocobase/utils": "2.2.52",
|
|
18
|
+
"@nocobase/database": "2.2.52",
|
|
19
|
+
"@nocobase/server": "2.2.52",
|
|
19
20
|
"antd": "5.24.2",
|
|
20
21
|
"@ant-design/icons": "5.6.1",
|
|
22
|
+
"@nocobase/ai": "2.2.52",
|
|
21
23
|
"axios": "1.21.1"
|
|
22
24
|
};
|