plugin-document-understanding 1.1.14 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +29 -29
  2. package/client-v2.d.ts +2 -2
  3. package/client-v2.js +1 -1
  4. package/dist/client/{345.e6e484fb1974c3d3.js → 345.277fbb2b97424db5.js} +1 -1
  5. package/dist/client/index.js +1 -1
  6. package/dist/client-v2/{345.a8f28526ac21e02a.js → 345.2fa9834b46dd4531.js} +1 -1
  7. package/dist/client-v2/index.js +1 -1
  8. package/dist/externalVersion.js +8 -7
  9. package/dist/locale/en-US.json +3 -1
  10. package/dist/locale/zh-CN.json +3 -1
  11. package/dist/node_modules/form-data/lib/form_data.js +2 -2
  12. package/dist/node_modules/form-data/node_modules/es-define-property/.eslintrc +13 -0
  13. package/dist/node_modules/form-data/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  14. package/dist/node_modules/form-data/node_modules/es-define-property/.nycrc +9 -0
  15. package/dist/node_modules/form-data/node_modules/es-define-property/index.d.ts +3 -0
  16. package/dist/node_modules/form-data/node_modules/es-define-property/index.js +14 -0
  17. package/dist/node_modules/form-data/node_modules/es-define-property/package.json +81 -0
  18. package/dist/node_modules/form-data/node_modules/es-define-property/test/index.js +56 -0
  19. package/dist/node_modules/form-data/node_modules/es-object-atoms/.eslintrc +16 -0
  20. package/dist/node_modules/form-data/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
  21. package/dist/node_modules/form-data/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
  22. package/dist/node_modules/form-data/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
  23. package/dist/node_modules/form-data/node_modules/es-object-atoms/ToObject.d.ts +7 -0
  24. package/dist/node_modules/form-data/node_modules/es-object-atoms/ToObject.js +10 -0
  25. package/dist/node_modules/form-data/node_modules/es-object-atoms/index.d.ts +3 -0
  26. package/dist/node_modules/form-data/node_modules/es-object-atoms/index.js +4 -0
  27. package/dist/node_modules/form-data/node_modules/es-object-atoms/isObject.d.ts +3 -0
  28. package/dist/node_modules/form-data/node_modules/es-object-atoms/isObject.js +6 -0
  29. package/dist/node_modules/form-data/node_modules/es-object-atoms/package.json +80 -0
  30. package/dist/node_modules/form-data/node_modules/es-object-atoms/test/index.js +38 -0
  31. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/.eslintrc +13 -0
  32. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/.nycrc +9 -0
  33. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/index.d.ts +10 -0
  34. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/index.js +35 -0
  35. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/.eslintrc +5 -0
  36. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/.github/FUNDING.yml +12 -0
  37. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/.nycrc +13 -0
  38. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/index.d.ts +3 -0
  39. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/index.js +8 -0
  40. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/node_modules/hasown/package.json +92 -0
  41. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/package.json +78 -0
  42. package/dist/node_modules/form-data/node_modules/es-set-tostringtag/test/index.js +85 -0
  43. package/dist/node_modules/form-data/node_modules/get-intrinsic/.eslintrc +42 -0
  44. package/dist/node_modules/form-data/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  45. package/dist/node_modules/form-data/node_modules/get-intrinsic/.nycrc +9 -0
  46. package/dist/node_modules/form-data/node_modules/get-intrinsic/index.js +378 -0
  47. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/.eslintrc +11 -0
  48. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  49. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/.nycrc +9 -0
  50. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/index.d.ts +3 -0
  51. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/index.js +14 -0
  52. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/package.json +111 -0
  53. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/shams.d.ts +3 -0
  54. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/shams.js +45 -0
  55. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/index.js +22 -0
  56. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/shams/core-js.js +29 -0
  57. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
  58. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/has-symbols/test/tests.js +58 -0
  59. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/.eslintrc +5 -0
  60. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/.github/FUNDING.yml +12 -0
  61. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/.nycrc +13 -0
  62. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/index.d.ts +3 -0
  63. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/index.js +8 -0
  64. package/dist/node_modules/form-data/node_modules/get-intrinsic/node_modules/hasown/package.json +92 -0
  65. package/dist/node_modules/form-data/node_modules/get-intrinsic/package.json +97 -0
  66. package/dist/node_modules/form-data/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
  67. package/dist/node_modules/form-data/node_modules/gopd/.eslintrc +16 -0
  68. package/dist/node_modules/form-data/node_modules/gopd/.github/FUNDING.yml +12 -0
  69. package/dist/node_modules/form-data/node_modules/gopd/gOPD.d.ts +1 -0
  70. package/dist/node_modules/form-data/node_modules/gopd/gOPD.js +4 -0
  71. package/dist/node_modules/form-data/node_modules/gopd/index.d.ts +5 -0
  72. package/dist/node_modules/form-data/node_modules/gopd/index.js +15 -0
  73. package/dist/node_modules/form-data/node_modules/gopd/package.json +77 -0
  74. package/dist/node_modules/form-data/node_modules/gopd/test/index.js +36 -0
  75. package/dist/node_modules/form-data/node_modules/has-tostringtag/.eslintrc +5 -0
  76. package/dist/node_modules/form-data/node_modules/has-tostringtag/.github/FUNDING.yml +12 -0
  77. package/dist/node_modules/form-data/node_modules/has-tostringtag/.nycrc +13 -0
  78. package/dist/node_modules/form-data/node_modules/has-tostringtag/index.d.ts +3 -0
  79. package/dist/node_modules/form-data/node_modules/has-tostringtag/index.js +8 -0
  80. package/dist/node_modules/form-data/node_modules/has-tostringtag/package.json +108 -0
  81. package/dist/node_modules/form-data/node_modules/has-tostringtag/shams.d.ts +3 -0
  82. package/dist/node_modules/form-data/node_modules/has-tostringtag/shams.js +8 -0
  83. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/index.js +21 -0
  84. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/shams/core-js.js +31 -0
  85. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js +30 -0
  86. package/dist/node_modules/form-data/node_modules/has-tostringtag/test/tests.js +15 -0
  87. package/dist/node_modules/form-data/node_modules/hasown/.github/FUNDING.yml +12 -0
  88. package/dist/node_modules/form-data/node_modules/hasown/.nycrc +13 -0
  89. package/dist/node_modules/form-data/node_modules/hasown/index.d.ts +3 -0
  90. package/dist/node_modules/form-data/node_modules/hasown/index.js +8 -0
  91. package/dist/node_modules/form-data/node_modules/hasown/package.json +91 -0
  92. package/dist/node_modules/form-data/package.json +1 -1
  93. package/dist/node_modules/mime-types/index.js +3 -3
  94. package/dist/node_modules/mime-types/package.json +1 -1
  95. package/dist/server/actions.js +45 -35
  96. package/package.json +57 -46
  97. package/src/client/index.tsx +15 -15
  98. package/src/client-v2/components/EndpointsTab.tsx +578 -578
  99. package/src/client-v2/components/JobsTab.tsx +294 -294
  100. package/src/client-v2/components/PipelinesTab.tsx +962 -962
  101. package/src/client-v2/components/PluginSettings.tsx +54 -50
  102. package/src/client-v2/components/ServiceConfigTab.tsx +139 -139
  103. package/src/client-v2/components/__tests__/PluginSettings.test.tsx +39 -0
  104. package/src/client-v2/index.tsx +1 -1
  105. package/src/client-v2/locale.ts +21 -21
  106. package/src/client-v2/models/index.ts +12 -12
  107. package/src/client-v2/plugin.tsx +31 -21
  108. package/src/client-v2/types.ts +32 -32
  109. package/src/index.ts +2 -2
  110. package/src/locale/en-US.json +3 -1
  111. package/src/locale/zh-CN.json +3 -1
  112. package/src/server/__tests__/actions.test.ts +121 -98
  113. package/src/server/__tests__/cluster-safety.test.ts +259 -259
  114. package/src/server/__tests__/document-understanding-service.test.ts +82 -82
  115. package/src/server/__tests__/dugate-integration.test.ts +221 -221
  116. package/src/server/__tests__/smoke.test.ts +78 -55
  117. package/src/server/__tests__/upload-security.test.ts +128 -0
  118. package/src/server/actions.ts +53 -51
  119. package/src/server/collections/config.ts +18 -18
  120. package/src/server/collections/endpoints.ts +33 -33
  121. package/src/server/collections/jobs.ts +42 -42
  122. package/src/server/collections/pipeline-steps.ts +27 -27
  123. package/src/server/collections/pipelines.ts +19 -19
  124. package/src/server/dugate-seed.ts +491 -491
  125. package/src/server/index.ts +1 -1
  126. package/src/server/plugin.ts +143 -143
  127. package/src/server/services/AsyncJobManager.ts +238 -238
  128. package/src/server/services/DocumentUnderstandingService.ts +332 -332
  129. package/src/server/services/ExternalApiClient.ts +178 -178
  130. package/src/server/services/PipelineExecutor.ts +593 -593
  131. package/src/server/tools/document-understanding-tool.ts +181 -181
  132. package/src/server/types.ts +90 -90
@@ -1,50 +1,54 @@
1
- import React from 'react';
2
- import { Tabs } from 'antd';
3
- import { useT } from '../locale';
4
- import { ServiceConfigTab } from './ServiceConfigTab';
5
- import { EndpointsTab } from './EndpointsTab';
6
- import { PipelinesTab } from './PipelinesTab';
7
- import { JobsTab } from './JobsTab';
8
-
9
- export const PluginSettings = () => {
10
- const t = useT();
11
-
12
- return (
13
- <div style={{ backgroundColor: 'var(--nb-box-bg)', minHeight: '100vh' }}>
14
- <div style={{ padding: '16px 24px', backgroundColor: '#fff', borderBottom: '1px solid #f0f0f0' }}>
15
- <h2 style={{ margin: 0, fontSize: 20, fontWeight: 500 }}>
16
- {t('Document Understanding - Pipeline Orchestrator')}
17
- </h2>
18
- </div>
19
- <div style={{ padding: '0 24px 24px' }}>
20
- <Tabs
21
- defaultActiveKey="config"
22
- items={[
23
- {
24
- key: 'config',
25
- label: t('Service Config'),
26
- children: <ServiceConfigTab />,
27
- },
28
- {
29
- key: 'endpoints',
30
- label: t('Endpoints'),
31
- children: <EndpointsTab />,
32
- },
33
- {
34
- key: 'pipelines',
35
- label: t('Pipelines'),
36
- children: <PipelinesTab />,
37
- },
38
- {
39
- key: 'jobs',
40
- label: t('Jobs history'),
41
- children: <JobsTab />,
42
- },
43
- ]}
44
- />
45
- </div>
46
- </div>
47
- );
48
- };
49
-
50
- export default PluginSettings;
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ import React from 'react';
4
+ import { Tabs } from 'antd';
5
+ import { useT } from '../locale';
6
+ import { ServiceConfigTab } from './ServiceConfigTab';
7
+ import { EndpointsTab } from './EndpointsTab';
8
+ import { PipelinesTab } from './PipelinesTab';
9
+ import { JobsTab } from './JobsTab';
10
+
11
+ export const PluginSettings = ({ embedded = false }: { embedded?: boolean }) => {
12
+ const t = useT();
13
+
14
+ return (
15
+ <div style={{ backgroundColor: 'var(--nb-box-bg)', minHeight: embedded ? undefined : '100vh' }}>
16
+ {!embedded && (
17
+ <div style={{ padding: '16px 24px', backgroundColor: '#fff', borderBottom: '1px solid #f0f0f0' }}>
18
+ <h2 style={{ margin: 0, fontSize: 20, fontWeight: 500 }}>
19
+ {t('Document Understanding - Pipeline Orchestrator')}
20
+ </h2>
21
+ </div>
22
+ )}
23
+ <div style={{ padding: embedded ? 0 : '0 24px 24px' }}>
24
+ <Tabs
25
+ defaultActiveKey="config"
26
+ items={[
27
+ {
28
+ key: 'config',
29
+ label: t('Service Config'),
30
+ children: <ServiceConfigTab />,
31
+ },
32
+ {
33
+ key: 'endpoints',
34
+ label: t('Endpoints'),
35
+ children: <EndpointsTab />,
36
+ },
37
+ {
38
+ key: 'pipelines',
39
+ label: t('Pipelines'),
40
+ children: <PipelinesTab />,
41
+ },
42
+ {
43
+ key: 'jobs',
44
+ label: t('Jobs history'),
45
+ children: <JobsTab />,
46
+ },
47
+ ]}
48
+ />
49
+ </div>
50
+ </div>
51
+ );
52
+ };
53
+
54
+ export default PluginSettings;
@@ -1,139 +1,139 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { Form, Input, Select, Button, message, InputNumber, Spin, Alert } from 'antd';
3
- import { SaveOutlined, LinkOutlined } from '@ant-design/icons';
4
- import { useFlowContext } from '@nocobase/flow-engine';
5
- import { useT } from '../locale';
6
- import { ClientServiceConfig, ServiceConfig, errorMessage, unwrapData } from '../types';
7
-
8
- export const ServiceConfigTab = () => {
9
- const [form] = Form.useForm<Partial<ServiceConfig>>();
10
- const ctx = useFlowContext();
11
- const api = ctx.api;
12
- const t = useT();
13
- const [loading, setLoading] = useState(true);
14
- const [saving, setSaving] = useState(false);
15
- const [loadError, setLoadError] = useState<string>();
16
-
17
- useEffect(() => {
18
- let cancelled = false;
19
- const load = async () => {
20
- try {
21
- const response = await api.request({ url: 'docUnderstanding:getConfig' });
22
- if (cancelled) return;
23
- form.setFieldsValue(unwrapData<Partial<ClientServiceConfig>>(response, {}));
24
- } catch (error) {
25
- if (!cancelled) setLoadError(errorMessage(error));
26
- } finally {
27
- if (!cancelled) setLoading(false);
28
- }
29
- };
30
- load();
31
- return () => {
32
- cancelled = true;
33
- };
34
- }, [api, form]);
35
-
36
- const onFinish = async (values: Partial<ServiceConfig>) => {
37
- setSaving(true);
38
- try {
39
- await api.request({
40
- url: 'docUnderstanding:updateConfig',
41
- method: 'POST',
42
- data: values,
43
- });
44
- message.success(t('Configuration saved successfully'));
45
- } catch (error) {
46
- message.error(`${t('Failed to save config')}: ${errorMessage(error)}`);
47
- } finally {
48
- setSaving(false);
49
- }
50
- };
51
-
52
- if (loading) return <Spin style={{ marginTop: 40 }} />;
53
-
54
- return (
55
- <Form form={form} layout="vertical" onFinish={onFinish} style={{ maxWidth: 600 }}>
56
- {loadError && <Alert message={loadError} type="error" showIcon style={{ marginBottom: 16 }} />}
57
-
58
- <Alert
59
- message={t('Service Connection')}
60
- description={t('Configure the connection to your external document processing service')}
61
- type="info"
62
- showIcon
63
- style={{ marginBottom: 24 }}
64
- />
65
-
66
- <Form.Item
67
- name="baseUrl"
68
- label={t('Base URL')}
69
- rules={[{ required: true, message: t('Base URL is required') }]}
70
- help={t('The root URL of your document processing API')}
71
- >
72
- <Input prefix={<LinkOutlined />} placeholder="http://my-ocr-service:8000" />
73
- </Form.Item>
74
-
75
- <Form.Item name="authType" label={t('Authentication Type')} initialValue="none">
76
- <Select
77
- options={[
78
- { value: 'none', label: t('None') },
79
- { value: 'api_key', label: t('API Key') },
80
- { value: 'bearer', label: t('Bearer Token') },
81
- { value: 'custom_header', label: t('Custom Header') },
82
- ]}
83
- />
84
- </Form.Item>
85
-
86
- <Form.Item noStyle dependencies={['authType']}>
87
- {() => {
88
- const type = form.getFieldValue('authType');
89
- if (type === 'none') return null;
90
- return (
91
- <>
92
- {type === 'custom_header' && (
93
- <Form.Item name="authHeaderName" label={t('Custom Header Name')} rules={[{ required: true }]}>
94
- <Input placeholder="X-Api-Key" />
95
- </Form.Item>
96
- )}
97
- <Form.Item
98
- name="authKey"
99
- label={type === 'bearer' ? t('Bearer Token') : t('API Key')}
100
- rules={[{ required: true }]}
101
- >
102
- <Input.Password placeholder={t('Enter key or token')} />
103
- </Form.Item>
104
- </>
105
- );
106
- }}
107
- </Form.Item>
108
-
109
- <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '0 16px' }}>
110
- <Form.Item name="defaultTimeout" label={t('Request Timeout (ms)')} initialValue={30000}>
111
- <InputNumber style={{ width: '100%' }} min={1000} step={1000} />
112
- </Form.Item>
113
- <Form.Item name="defaultRetries" label={t('Default Retries')} initialValue={2}>
114
- <InputNumber style={{ width: '100%' }} min={0} max={10} />
115
- </Form.Item>
116
- <Form.Item name="pollInterval" label={t('Poll Interval (ms)')} initialValue={5000}>
117
- <InputNumber style={{ width: '100%' }} min={1000} step={1000} />
118
- </Form.Item>
119
- <Form.Item name="pollTimeout" label={t('Poll Timeout (ms)')} initialValue={300000}>
120
- <InputNumber style={{ width: '100%' }} min={5000} step={5000} />
121
- </Form.Item>
122
- </div>
123
-
124
- <Form.Item
125
- name="webhookSecret"
126
- label={t('Webhook Secret')}
127
- help={t('Used to verify HMAC-SHA256 signatures on incoming webhook callbacks')}
128
- >
129
- <Input.Password placeholder={t('Optional: secret for webhook signature verification')} />
130
- </Form.Item>
131
-
132
- <Form.Item>
133
- <Button type="primary" htmlType="submit" icon={<SaveOutlined />} loading={saving}>
134
- {t('Save Configuration')}
135
- </Button>
136
- </Form.Item>
137
- </Form>
138
- );
139
- };
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Form, Input, Select, Button, message, InputNumber, Spin, Alert } from 'antd';
3
+ import { SaveOutlined, LinkOutlined } from '@ant-design/icons';
4
+ import { useFlowContext } from '@nocobase/flow-engine';
5
+ import { useT } from '../locale';
6
+ import { ClientServiceConfig, ServiceConfig, errorMessage, unwrapData } from '../types';
7
+
8
+ export const ServiceConfigTab = () => {
9
+ const [form] = Form.useForm<Partial<ServiceConfig>>();
10
+ const ctx = useFlowContext();
11
+ const api = ctx.api;
12
+ const t = useT();
13
+ const [loading, setLoading] = useState(true);
14
+ const [saving, setSaving] = useState(false);
15
+ const [loadError, setLoadError] = useState<string>();
16
+
17
+ useEffect(() => {
18
+ let cancelled = false;
19
+ const load = async () => {
20
+ try {
21
+ const response = await api.request({ url: 'docUnderstanding:getConfig' });
22
+ if (cancelled) return;
23
+ form.setFieldsValue(unwrapData<Partial<ClientServiceConfig>>(response, {}));
24
+ } catch (error) {
25
+ if (!cancelled) setLoadError(errorMessage(error));
26
+ } finally {
27
+ if (!cancelled) setLoading(false);
28
+ }
29
+ };
30
+ load();
31
+ return () => {
32
+ cancelled = true;
33
+ };
34
+ }, [api, form]);
35
+
36
+ const onFinish = async (values: Partial<ServiceConfig>) => {
37
+ setSaving(true);
38
+ try {
39
+ await api.request({
40
+ url: 'docUnderstanding:updateConfig',
41
+ method: 'POST',
42
+ data: values,
43
+ });
44
+ message.success(t('Configuration saved successfully'));
45
+ } catch (error) {
46
+ message.error(`${t('Failed to save config')}: ${errorMessage(error)}`);
47
+ } finally {
48
+ setSaving(false);
49
+ }
50
+ };
51
+
52
+ if (loading) return <Spin style={{ marginTop: 40 }} />;
53
+
54
+ return (
55
+ <Form form={form} layout="vertical" onFinish={onFinish} style={{ maxWidth: 600 }}>
56
+ {loadError && <Alert message={loadError} type="error" showIcon style={{ marginBottom: 16 }} />}
57
+
58
+ <Alert
59
+ message={t('Service Connection')}
60
+ description={t('Configure the connection to your external document processing service')}
61
+ type="info"
62
+ showIcon
63
+ style={{ marginBottom: 24 }}
64
+ />
65
+
66
+ <Form.Item
67
+ name="baseUrl"
68
+ label={t('Base URL')}
69
+ rules={[{ required: true, message: t('Base URL is required') }]}
70
+ help={t('The root URL of your document processing API')}
71
+ >
72
+ <Input prefix={<LinkOutlined />} placeholder="http://my-ocr-service:8000" />
73
+ </Form.Item>
74
+
75
+ <Form.Item name="authType" label={t('Authentication Type')} initialValue="none">
76
+ <Select
77
+ options={[
78
+ { value: 'none', label: t('None') },
79
+ { value: 'api_key', label: t('API Key') },
80
+ { value: 'bearer', label: t('Bearer Token') },
81
+ { value: 'custom_header', label: t('Custom Header') },
82
+ ]}
83
+ />
84
+ </Form.Item>
85
+
86
+ <Form.Item noStyle dependencies={['authType']}>
87
+ {() => {
88
+ const type = form.getFieldValue('authType');
89
+ if (type === 'none') return null;
90
+ return (
91
+ <>
92
+ {type === 'custom_header' && (
93
+ <Form.Item name="authHeaderName" label={t('Custom Header Name')} rules={[{ required: true }]}>
94
+ <Input placeholder="X-Api-Key" />
95
+ </Form.Item>
96
+ )}
97
+ <Form.Item
98
+ name="authKey"
99
+ label={type === 'bearer' ? t('Bearer Token') : t('API Key')}
100
+ rules={[{ required: true }]}
101
+ >
102
+ <Input.Password placeholder={t('Enter key or token')} />
103
+ </Form.Item>
104
+ </>
105
+ );
106
+ }}
107
+ </Form.Item>
108
+
109
+ <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '0 16px' }}>
110
+ <Form.Item name="defaultTimeout" label={t('Request Timeout (ms)')} initialValue={30000}>
111
+ <InputNumber style={{ width: '100%' }} min={1000} step={1000} />
112
+ </Form.Item>
113
+ <Form.Item name="defaultRetries" label={t('Default Retries')} initialValue={2}>
114
+ <InputNumber style={{ width: '100%' }} min={0} max={10} />
115
+ </Form.Item>
116
+ <Form.Item name="pollInterval" label={t('Poll Interval (ms)')} initialValue={5000}>
117
+ <InputNumber style={{ width: '100%' }} min={1000} step={1000} />
118
+ </Form.Item>
119
+ <Form.Item name="pollTimeout" label={t('Poll Timeout (ms)')} initialValue={300000}>
120
+ <InputNumber style={{ width: '100%' }} min={5000} step={5000} />
121
+ </Form.Item>
122
+ </div>
123
+
124
+ <Form.Item
125
+ name="webhookSecret"
126
+ label={t('Webhook Secret')}
127
+ help={t('Used to verify HMAC-SHA256 signatures on incoming webhook callbacks')}
128
+ >
129
+ <Input.Password placeholder={t('Optional: secret for webhook signature verification')} />
130
+ </Form.Item>
131
+
132
+ <Form.Item>
133
+ <Button type="primary" htmlType="submit" icon={<SaveOutlined />} loading={saving}>
134
+ {t('Save Configuration')}
135
+ </Button>
136
+ </Form.Item>
137
+ </Form>
138
+ );
139
+ };
@@ -0,0 +1,39 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ import React from 'react';
4
+ import { render, screen } from '@testing-library/react';
5
+ import { describe, expect, it, vi } from 'vitest';
6
+ import { PluginSettings } from '../PluginSettings';
7
+
8
+ vi.mock('../../locale', () => ({ useT: () => (key: string) => key }));
9
+ vi.mock('../ServiceConfigTab', () => ({ ServiceConfigTab: () => <div>Service configuration content</div> }));
10
+ vi.mock('../EndpointsTab', () => ({ EndpointsTab: () => <div>Endpoint content</div> }));
11
+ vi.mock('../PipelinesTab', () => ({ PipelinesTab: () => <div>Pipeline content</div> }));
12
+ vi.mock('../JobsTab', () => ({ JobsTab: () => <div>Job content</div> }));
13
+
14
+ describe('Document Understanding plugin settings layout', () => {
15
+ it('omits the standalone page heading and full-page height when embedded while keeping the settings tabs', () => {
16
+ const view = render(<PluginSettings embedded />);
17
+ const root = view.container.firstElementChild as HTMLElement;
18
+ const content = root.firstElementChild as HTMLElement;
19
+
20
+ expect(screen.queryByRole('heading', { name: 'Document Understanding - Pipeline Orchestrator' })).toBeNull();
21
+ expect(root.style.minHeight).toBe('');
22
+ expect(content.style.padding).toBe('0px');
23
+ expect(screen.getByRole('tab', { name: 'Service Config' })).toBeTruthy();
24
+ expect(screen.getByRole('tab', { name: 'Endpoints' })).toBeTruthy();
25
+ expect(screen.getByRole('tab', { name: 'Pipelines' })).toBeTruthy();
26
+ expect(screen.getByRole('tab', { name: 'Jobs history' })).toBeTruthy();
27
+ });
28
+
29
+ it('keeps the heading, full-page height, and padding in standalone settings', () => {
30
+ const view = render(<PluginSettings />);
31
+ const root = view.container.firstElementChild as HTMLElement;
32
+ const headingWrapper = root.firstElementChild as HTMLElement;
33
+ const content = headingWrapper.nextElementSibling as HTMLElement;
34
+
35
+ expect(screen.getByRole('heading', { name: 'Document Understanding - Pipeline Orchestrator' })).toBeTruthy();
36
+ expect(root.style.minHeight).toBe('100vh');
37
+ expect(content.style.padding).toBe('0px 24px 24px');
38
+ });
39
+ });
@@ -1 +1 @@
1
- export { default } from './plugin';
1
+ export { default } from './plugin';
@@ -1,21 +1,21 @@
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
- import { tExpr as _tExpr, useFlowEngine } from '@nocobase/flow-engine';
11
- // @ts-ignore
12
- import pkg from './../../package.json';
13
-
14
- export function useT() {
15
- const engine = useFlowEngine();
16
- return (str: string) => engine.context.t(str, { ns: [pkg.name, 'client'] });
17
- }
18
-
19
- export function tExpr(key: string) {
20
- return _tExpr(key, { ns: [pkg.name, 'client'] });
21
- }
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
+ import { tExpr as _tExpr, useFlowEngine } from '@nocobase/flow-engine';
11
+ // @ts-ignore
12
+ import pkg from './../../package.json';
13
+
14
+ export function useT() {
15
+ const engine = useFlowEngine();
16
+ return (str: string) => engine.context.t(str, { ns: [pkg.name, 'client'] });
17
+ }
18
+
19
+ export function tExpr(key: string) {
20
+ return _tExpr(key, { ns: [pkg.name, 'client'] });
21
+ }
@@ -1,12 +1,12 @@
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
- import { ModelConstructor } from '@nocobase/flow-engine';
11
-
12
- export default {} as Record<string, ModelConstructor>;
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
+ import { ModelConstructor } from '@nocobase/flow-engine';
11
+
12
+ export default {} as Record<string, ModelConstructor>;
@@ -1,21 +1,31 @@
1
- import { Application, Plugin } from '@nocobase/client-v2';
2
-
3
- export class PluginDocumentUnderstandingClient extends Plugin<Record<string, never>, Application> {
4
- async load() {
5
- this.pluginSettingsManager.addMenuItem({
6
- key: 'document-understanding',
7
- title: this.t('Document Understanding'),
8
- icon: 'FileSearchOutlined',
9
- aclSnippet: 'pm.document-understanding',
10
- });
11
-
12
- this.pluginSettingsManager.addPageTabItem({
13
- menuKey: 'document-understanding',
14
- key: 'index',
15
- title: this.t('Document Understanding'),
16
- componentLoader: () => import('./components/PluginSettings'),
17
- });
18
- }
19
- }
20
-
21
- export default PluginDocumentUnderstandingClient;
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
+ import { Application, Plugin } from '@nocobase/client-v2';
11
+
12
+ export class PluginDocumentUnderstandingClient extends Plugin<Record<string, never>, Application> {
13
+ async load() {
14
+ this.pluginSettingsManager.addMenuItem({
15
+ key: 'document-understanding',
16
+ title: this.t('Document Understanding'),
17
+ icon: 'FileSearchOutlined',
18
+ aclSnippet: `pm.${this.options.name || 'document-understanding'}`,
19
+ });
20
+
21
+ this.pluginSettingsManager.addPageTabItem({
22
+ menuKey: 'document-understanding',
23
+ key: 'index',
24
+ title: this.t('Document Understanding'),
25
+ componentLoader: () => import('./components/PluginSettings'),
26
+ aclSnippet: `pm.${this.options.name || 'document-understanding'}`,
27
+ });
28
+ }
29
+ }
30
+
31
+ export default PluginDocumentUnderstandingClient;
@@ -1,32 +1,32 @@
1
- export type {
2
- ServiceConfig,
3
- ClientServiceConfig,
4
- EndpointDef,
5
- PipelineStepDef,
6
- PipelineDef,
7
- JobState,
8
- } from '../server/types';
9
-
10
- export interface ApiEnvelope<T> {
11
- data?: {
12
- data?: T;
13
- meta?: { count?: number };
14
- };
15
- }
16
-
17
- export function unwrapData<T>(response: unknown, fallback: T): T {
18
- if (!response || typeof response !== 'object') return fallback;
19
- const outer = response as ApiEnvelope<T>;
20
- return outer.data?.data ?? fallback;
21
- }
22
-
23
- export function errorMessage(error: unknown): string {
24
- return error instanceof Error ? error.message : String(error);
25
- }
26
-
27
- /** Job timestamps are declared as `Date` server-side but arrive as ISO strings over the wire. */
28
- export function formatDateTime(value: string | Date | null | undefined): string {
29
- if (!value) return '-';
30
- const date = value instanceof Date ? value : new Date(value);
31
- return Number.isNaN(date.getTime()) ? '-' : date.toLocaleString();
32
- }
1
+ export type {
2
+ ServiceConfig,
3
+ ClientServiceConfig,
4
+ EndpointDef,
5
+ PipelineStepDef,
6
+ PipelineDef,
7
+ JobState,
8
+ } from '../server/types';
9
+
10
+ export interface ApiEnvelope<T> {
11
+ data?: {
12
+ data?: T;
13
+ meta?: { count?: number };
14
+ };
15
+ }
16
+
17
+ export function unwrapData<T>(response: unknown, fallback: T): T {
18
+ if (!response || typeof response !== 'object') return fallback;
19
+ const outer = response as ApiEnvelope<T>;
20
+ return outer.data?.data ?? fallback;
21
+ }
22
+
23
+ export function errorMessage(error: unknown): string {
24
+ return error instanceof Error ? error.message : String(error);
25
+ }
26
+
27
+ /** Job timestamps are declared as `Date` server-side but arrive as ISO strings over the wire. */
28
+ export function formatDateTime(value: string | Date | null | undefined): string {
29
+ if (!value) return '-';
30
+ const date = value instanceof Date ? value : new Date(value);
31
+ return Number.isNaN(date.getTime()) ? '-' : date.toLocaleString();
32
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './server';
2
- export { default } from './server';
1
+ export * from './server';
2
+ export { default } from './server';
@@ -178,5 +178,7 @@
178
178
  "Task ID Extract Path": "Task ID Extract Path",
179
179
  "Sync Query Param": "Sync Query Param",
180
180
  "Discriminator Field": "Discriminator Field",
181
- "Gateway / Discriminator": "Gateway / Discriminator"
181
+ "Gateway / Discriminator": "Gateway / Discriminator",
182
+ "Invalid document upload.": "Invalid document upload.",
183
+ "Invalid pipeline input.": "Invalid pipeline input."
182
184
  }
@@ -178,5 +178,7 @@
178
178
  "Discriminator Field": "判别字段",
179
179
  "Gateway / Discriminator": "网关 / 判别字段",
180
180
  "When set, the request appends ?<param>=true to ask for a synchronous response (e.g. sync).": "设置后请求会附加 ?<param>=true 以请求同步响应(如 sync)。",
181
- "Form field that selects the API sub-case (e.g. mode/type/task/action/process). Sent automatically.": "选择 API 子类型的表单字段(如 mode/type/task/action/process)。自动发送。"
181
+ "Form field that selects the API sub-case (e.g. mode/type/task/action/process). Sent automatically.": "选择 API 子类型的表单字段(如 mode/type/task/action/process)。自动发送。",
182
+ "Invalid document upload.": "无效的文档上传。",
183
+ "Invalid pipeline input.": "无效的流水线输入。"
182
184
  }