@nocobase/plugin-workflow 0.9.0-alpha.2 → 0.9.1-alpha.2
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/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/lib/client/AddButton.d.ts +1 -1
- package/lib/client/AddButton.js +43 -27
- package/lib/client/Branch.d.ts +1 -1
- package/lib/client/ExecutionCanvas.js +5 -10
- package/lib/client/WorkflowCanvas.js +12 -42
- package/lib/client/WorkflowProvider.js +10 -1
- package/lib/client/components/CollectionBlockInitializer.d.ts +7 -0
- package/lib/client/components/CollectionBlockInitializer.js +81 -0
- package/lib/client/components/CollectionFieldInitializers.d.ts +2 -0
- package/lib/client/components/CollectionFieldInitializers.js +89 -0
- package/lib/client/components/CollectionFieldset.js +25 -33
- package/lib/client/components/FilterDynamicComponent.d.ts +6 -0
- package/lib/client/components/FilterDynamicComponent.js +43 -0
- package/lib/client/components/NullRender.d.ts +1 -0
- package/lib/client/components/NullRender.js +10 -0
- package/lib/client/components/RadioWithTooltip.d.ts +7 -0
- package/lib/client/components/RadioWithTooltip.js +94 -0
- package/lib/client/constants.d.ts +10 -8
- package/lib/client/constants.js +52 -14
- package/lib/client/index.d.ts +0 -1
- package/lib/client/index.js +1 -10
- package/lib/client/locale/en-US.d.ts +18 -18
- package/lib/client/locale/en-US.js +19 -19
- package/lib/client/locale/zh-CN.d.ts +47 -20
- package/lib/client/locale/zh-CN.js +48 -21
- package/lib/client/nodes/calculation.d.ts +39 -7
- package/lib/client/nodes/calculation.js +165 -19
- package/lib/client/nodes/condition.d.ts +67 -4
- package/lib/client/nodes/condition.js +283 -31
- package/lib/client/nodes/create.d.ts +10 -10
- package/lib/client/nodes/create.js +28 -42
- package/lib/client/nodes/delay.d.ts +4 -4
- package/lib/client/nodes/delay.js +10 -8
- package/lib/client/nodes/destroy.d.ts +4 -7
- package/lib/client/nodes/destroy.js +4 -5
- package/lib/client/nodes/index.d.ts +10 -2
- package/lib/client/nodes/index.js +217 -110
- package/lib/client/nodes/manual/AssigneesSelect.d.ts +6 -0
- package/lib/client/nodes/manual/AssigneesSelect.js +65 -0
- package/lib/client/nodes/manual/ModeConfig.d.ts +5 -0
- package/lib/client/nodes/manual/ModeConfig.js +160 -0
- package/lib/client/nodes/manual/SchemaConfig.d.ts +6 -0
- package/lib/client/nodes/manual/SchemaConfig.js +715 -0
- package/lib/client/nodes/manual/WorkflowTodo.d.ts +8 -0
- package/lib/client/nodes/manual/WorkflowTodo.js +691 -0
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +5 -0
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +75 -0
- package/lib/client/nodes/manual/index.d.ts +62 -0
- package/lib/client/nodes/manual/index.js +137 -0
- package/lib/client/nodes/parallel.d.ts +12 -7
- package/lib/client/nodes/parallel.js +32 -39
- package/lib/client/nodes/query.d.ts +11 -19
- package/lib/client/nodes/query.js +40 -47
- package/lib/client/nodes/request.d.ts +77 -42
- package/lib/client/nodes/request.js +123 -69
- package/lib/client/nodes/update.d.ts +33 -29
- package/lib/client/nodes/update.js +14 -7
- package/lib/client/schemas/collection.d.ts +0 -3
- package/lib/client/schemas/collection.js +2 -7
- package/lib/client/schemas/executions.js +1 -1
- package/lib/client/schemas/workflows.js +1 -1
- package/lib/client/style.js +51 -9
- package/lib/client/triggers/collection.d.ts +44 -15
- package/lib/client/triggers/collection.js +104 -82
- package/lib/client/triggers/index.d.ts +6 -3
- package/lib/client/triggers/index.js +167 -74
- package/lib/client/triggers/schedule/DateFieldsSelect.js +1 -3
- package/lib/client/triggers/schedule/ScheduleConfig.js +15 -17
- package/lib/client/triggers/schedule/index.d.ts +7 -6
- package/lib/client/triggers/schedule/index.js +39 -81
- package/lib/client/utils.d.ts +1 -0
- package/lib/client/utils.js +38 -0
- package/lib/client/variable.d.ts +21 -0
- package/lib/client/variable.js +147 -0
- package/lib/server/Plugin.d.ts +3 -3
- package/lib/server/Plugin.js +12 -21
- package/lib/server/Processor.d.ts +9 -2
- package/lib/server/Processor.js +33 -33
- package/lib/server/actions/index.js +2 -4
- package/lib/server/actions/workflows.d.ts +1 -0
- package/lib/server/actions/workflows.js +80 -23
- package/lib/server/collections/executions.js +5 -7
- package/lib/server/collections/flow_nodes.js +6 -18
- package/lib/server/collections/jobs.js +3 -1
- package/lib/server/collections/workflows.js +8 -4
- package/lib/server/constants.d.ts +9 -3
- package/lib/server/constants.js +11 -5
- package/lib/server/functions/index.d.ts +4 -0
- package/lib/server/functions/index.js +38 -0
- package/lib/server/index.d.ts +0 -1
- package/lib/server/index.js +0 -14
- package/lib/server/instructions/calculation.d.ts +2 -7
- package/lib/server/instructions/calculation.js +32 -37
- package/lib/server/instructions/condition.d.ts +4 -4
- package/lib/server/instructions/condition.js +126 -54
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/manual/actions.js +101 -0
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.d.ts +2 -0
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.js +2 -1
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.js +10 -10
- package/lib/server/instructions/manual/index.d.ts +25 -0
- package/lib/server/instructions/manual/index.js +200 -0
- package/lib/server/instructions/parallel.js +11 -7
- package/lib/server/instructions/request.d.ts +5 -4
- package/lib/server/instructions/request.js +60 -79
- package/lib/server/migrations/20230221032941-change-request-body-type.d.ts +5 -0
- package/lib/server/migrations/20230221032941-change-request-body-type.js +113 -0
- package/lib/server/migrations/20230221071831-calculation-expression.d.ts +4 -0
- package/lib/server/migrations/20230221071831-calculation-expression.js +143 -0
- package/lib/server/migrations/20230221121203-condition-calculation.d.ts +4 -0
- package/lib/server/migrations/20230221121203-condition-calculation.js +126 -0
- package/lib/server/migrations/20230221162902-jsonb-to-json.d.ts +4 -0
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +81 -0
- package/lib/server/triggers/schedule.js +11 -3
- package/package.json +10 -10
- package/lib/client/calculators.d.ts +0 -89
- package/lib/client/calculators.js +0 -668
- package/lib/client/components/CollectionFieldSelect.d.ts +0 -2
- package/lib/client/components/CollectionFieldSelect.js +0 -106
- package/lib/client/components/EjsTextArea.d.ts +0 -2
- package/lib/client/components/EjsTextArea.js +0 -232
- package/lib/server/actions/jobs.d.ts +0 -2
- package/lib/server/actions/jobs.js +0 -39
- package/lib/server/calculators/index.d.ts +0 -40
- package/lib/server/calculators/index.js +0 -187
- package/lib/server/extensions/assignees/actions.js +0 -75
- package/lib/server/extensions/assignees/index.d.ts +0 -2
- package/lib/server/extensions/assignees/index.js +0 -273
- package/lib/server/extensions/index.d.ts +0 -3
- package/lib/server/extensions/index.js +0 -13
- package/lib/server/instructions/prompt.d.ts +0 -19
- package/lib/server/instructions/prompt.js +0 -131
- /package/lib/server/{extensions/assignees → instructions/manual}/actions.d.ts +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.d.ts +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.js +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.d.ts +0 -0
|
@@ -54,27 +54,37 @@ declare const _default: {
|
|
|
54
54
|
Advanced: string;
|
|
55
55
|
End: string;
|
|
56
56
|
'Node result': string;
|
|
57
|
-
Constant: string;
|
|
58
|
-
Null: string;
|
|
59
|
-
Boolean: string;
|
|
60
|
-
String: string;
|
|
61
57
|
Calculator: string;
|
|
62
58
|
'Arithmetic calculation': string;
|
|
63
59
|
'String operation': string;
|
|
60
|
+
'System variables': string;
|
|
61
|
+
'Current time': string;
|
|
64
62
|
'Executed at': string;
|
|
65
63
|
Queueing: string;
|
|
66
64
|
'On going': string;
|
|
67
|
-
|
|
68
|
-
Failed: string;
|
|
65
|
+
Resolved: string;
|
|
69
66
|
Pending: string;
|
|
67
|
+
Failed: string;
|
|
68
|
+
Error: string;
|
|
69
|
+
Aborted: string;
|
|
70
70
|
Canceled: string;
|
|
71
|
+
Rejected: string;
|
|
72
|
+
'Continue the process': string;
|
|
73
|
+
'Terminate the process': string;
|
|
74
|
+
'Save temporarily': string;
|
|
75
|
+
Operations: string;
|
|
71
76
|
'This node contains branches, deleting will also be preformed to them, are you sure?': string;
|
|
72
77
|
Control: string;
|
|
73
78
|
'Collection operations': string;
|
|
79
|
+
Manual: string;
|
|
74
80
|
'Extended types': string;
|
|
75
81
|
'Node type': string;
|
|
76
82
|
Calculation: string;
|
|
77
|
-
'
|
|
83
|
+
'Calculation engine': string;
|
|
84
|
+
Basic: string;
|
|
85
|
+
'Calculation expression': string;
|
|
86
|
+
'Expression syntax error': string;
|
|
87
|
+
'Syntax references: ': string;
|
|
78
88
|
'Calculation result': string;
|
|
79
89
|
True: string;
|
|
80
90
|
False: string;
|
|
@@ -83,7 +93,7 @@ declare const _default: {
|
|
|
83
93
|
Mode: string;
|
|
84
94
|
'Continue when "Yes"': string;
|
|
85
95
|
'Branch into "Yes" and "No"': string;
|
|
86
|
-
|
|
96
|
+
'Condition expression': string;
|
|
87
97
|
'Parallel branch': string;
|
|
88
98
|
'Add branch': string;
|
|
89
99
|
'All succeeded': string;
|
|
@@ -98,6 +108,21 @@ declare const _default: {
|
|
|
98
108
|
'Select status': string;
|
|
99
109
|
'Succeed and continue': string;
|
|
100
110
|
'Fail and exit': string;
|
|
111
|
+
Assignee: string;
|
|
112
|
+
Assignees: string;
|
|
113
|
+
'User interface': string;
|
|
114
|
+
'Configure user interface': string;
|
|
115
|
+
'View user interface': string;
|
|
116
|
+
Separately: string;
|
|
117
|
+
'Each user has own task': string;
|
|
118
|
+
Collaboratively: string;
|
|
119
|
+
'Everyone shares one task': string;
|
|
120
|
+
Negotiation: string;
|
|
121
|
+
'All pass': string;
|
|
122
|
+
'Everyone should pass': string;
|
|
123
|
+
'Any pass': string;
|
|
124
|
+
'Anyone pass': string;
|
|
125
|
+
'Field name existed in form': string;
|
|
101
126
|
'Create record': string;
|
|
102
127
|
'Update record': string;
|
|
103
128
|
'Query record': string;
|
|
@@ -110,21 +135,23 @@ declare const _default: {
|
|
|
110
135
|
'Can not delete': string;
|
|
111
136
|
'The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.': string;
|
|
112
137
|
'HTTP request': string;
|
|
138
|
+
'HTTP method': string;
|
|
113
139
|
URL: string;
|
|
114
|
-
|
|
115
|
-
'Request headers': string;
|
|
116
|
-
'Name(e.g. Content-Type)': string;
|
|
117
|
-
'Value(e.g. Application/json)': string;
|
|
140
|
+
Headers: string;
|
|
118
141
|
'Add request header': string;
|
|
119
|
-
|
|
120
|
-
'
|
|
142
|
+
Parameters: string;
|
|
143
|
+
'Add parameter': string;
|
|
144
|
+
Body: string;
|
|
145
|
+
'Use variable': string;
|
|
146
|
+
Format: string;
|
|
147
|
+
Insert: string;
|
|
148
|
+
'Timeout config': string;
|
|
149
|
+
ms: string;
|
|
121
150
|
'Input request data': string;
|
|
122
|
-
'
|
|
123
|
-
'
|
|
124
|
-
'Copy variable output template statement': string;
|
|
125
|
-
'Default headers is Content-Type: application/json': string;
|
|
151
|
+
'Only support standard JSON data': string;
|
|
152
|
+
'"Content-Type" only support "application/json", and no need to specify': string;
|
|
126
153
|
'Ignore fail request and continue workflow': string;
|
|
127
|
-
'
|
|
128
|
-
|
|
154
|
+
'Workflow todos': string;
|
|
155
|
+
Task: string;
|
|
129
156
|
};
|
|
130
157
|
export default _default;
|
|
@@ -60,27 +60,37 @@ var _default = {
|
|
|
60
60
|
'Advanced': '高级模式',
|
|
61
61
|
'End': '结束',
|
|
62
62
|
'Node result': '节点数据',
|
|
63
|
-
'Constant': '常量',
|
|
64
|
-
'Null': '空值',
|
|
65
|
-
'Boolean': '逻辑值',
|
|
66
|
-
'String': '字符串',
|
|
67
63
|
'Calculator': '运算',
|
|
68
64
|
'Arithmetic calculation': '算术运算',
|
|
69
65
|
'String operation': '字符串',
|
|
66
|
+
'System variables': '系统变量',
|
|
67
|
+
'Current time': '当前时间',
|
|
70
68
|
'Executed at': '执行于',
|
|
71
69
|
'Queueing': '队列中',
|
|
72
70
|
'On going': '进行中',
|
|
73
|
-
'
|
|
71
|
+
'Resolved': '完成',
|
|
72
|
+
'Pending': '待处理',
|
|
74
73
|
'Failed': '失败',
|
|
75
|
-
'
|
|
74
|
+
'Error': '出错',
|
|
75
|
+
'Aborted': '已终止',
|
|
76
76
|
'Canceled': '已取消',
|
|
77
|
+
'Rejected': '已拒绝',
|
|
78
|
+
'Continue the process': '继续流程',
|
|
79
|
+
'Terminate the process': '终止流程',
|
|
80
|
+
'Save temporarily': '暂存',
|
|
81
|
+
'Operations': '操作',
|
|
77
82
|
'This node contains branches, deleting will also be preformed to them, are you sure?': '节点包含分支,将同时删除其所有分支下的子节点,确定继续?',
|
|
78
83
|
'Control': '流程控制',
|
|
79
84
|
'Collection operations': '数据表操作',
|
|
85
|
+
'Manual': '人工处理',
|
|
80
86
|
'Extended types': '扩展类型',
|
|
81
87
|
'Node type': '节点类型',
|
|
82
88
|
'Calculation': '运算',
|
|
83
|
-
'
|
|
89
|
+
'Calculation engine': '运算引擎',
|
|
90
|
+
'Basic': '基础',
|
|
91
|
+
'Calculation expression': '运算表达式',
|
|
92
|
+
'Expression syntax error': '表达式语法错误',
|
|
93
|
+
'Syntax references: ': '语法参考:',
|
|
84
94
|
'Calculation result': '运算结果',
|
|
85
95
|
'True': '真',
|
|
86
96
|
'False': '假',
|
|
@@ -89,7 +99,7 @@ var _default = {
|
|
|
89
99
|
'Mode': '模式',
|
|
90
100
|
'Continue when "Yes"': '“是”则继续',
|
|
91
101
|
'Branch into "Yes" and "No"': '“是”和“否”分别继续',
|
|
92
|
-
'
|
|
102
|
+
'Condition expression': '条件表达式',
|
|
93
103
|
'Parallel branch': '分支',
|
|
94
104
|
'Add branch': '增加分支',
|
|
95
105
|
'All succeeded': '全部成功',
|
|
@@ -104,6 +114,21 @@ var _default = {
|
|
|
104
114
|
'Select status': '选择状态',
|
|
105
115
|
'Succeed and continue': '通过并继续',
|
|
106
116
|
'Fail and exit': '失败并退出',
|
|
117
|
+
'Assignee': '负责人',
|
|
118
|
+
'Assignees': '负责人',
|
|
119
|
+
'User interface': '操作界面',
|
|
120
|
+
'Configure user interface': '配置界面',
|
|
121
|
+
'View user interface': '查看界面',
|
|
122
|
+
'Separately': '分别处理',
|
|
123
|
+
'Each user has own task': '每个人处理各自的任务',
|
|
124
|
+
'Collaboratively': '协作处理',
|
|
125
|
+
'Everyone shares one task': '所有人共享同一个任务',
|
|
126
|
+
'Negotiation': '协商机制',
|
|
127
|
+
'All pass': '全部通过',
|
|
128
|
+
'Everyone should pass': '每个人通过才通过',
|
|
129
|
+
'Any pass': '任意通过',
|
|
130
|
+
'Anyone pass': '任何一人通过即通过',
|
|
131
|
+
'Field name existed in form': '表单中已有对应标识的字段',
|
|
107
132
|
'Create record': '新增数据',
|
|
108
133
|
'Update record': '更新数据',
|
|
109
134
|
'Query record': '查询数据',
|
|
@@ -116,21 +141,23 @@ var _default = {
|
|
|
116
141
|
'Can not delete': '无法删除',
|
|
117
142
|
'The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.': '该节点的执行结果已被其他节点({{nodes}})引用,删除前请先移除引用。',
|
|
118
143
|
'HTTP request': 'HTTP 请求',
|
|
144
|
+
'HTTP method': 'HTTP 方法',
|
|
119
145
|
'URL': '地址',
|
|
120
|
-
'
|
|
121
|
-
'Request headers': '请求头',
|
|
122
|
-
'Name(e.g. Content-Type)': '名称(例如 Content-Type)',
|
|
123
|
-
'Value(e.g. Application/json)': '值(例如 Application/json)',
|
|
146
|
+
'Headers': '请求头',
|
|
124
147
|
'Add request header': '添加请求头',
|
|
125
|
-
'
|
|
126
|
-
'
|
|
148
|
+
'Parameters': '参数',
|
|
149
|
+
'Add parameter': '添加参数',
|
|
150
|
+
'Body': '请求体',
|
|
151
|
+
'Use variable': '使用变量',
|
|
152
|
+
'Format': '格式化',
|
|
153
|
+
'Insert': '插入',
|
|
154
|
+
'Timeout config': '超时设置',
|
|
155
|
+
'ms': '毫秒',
|
|
127
156
|
'Input request data': '输入请求数据',
|
|
128
|
-
'
|
|
129
|
-
'
|
|
130
|
-
'
|
|
131
|
-
'
|
|
132
|
-
'
|
|
133
|
-
'Syntax see': '语法参考',
|
|
134
|
-
'Show available variable tool': '显示可用变量工具'
|
|
157
|
+
'Only support standard JSON data': '仅支持标准 JSON 数据',
|
|
158
|
+
'"Content-Type" only support "application/json", and no need to specify': '"Content-Type" 请求头仅支持 "application/json",无需填写',
|
|
159
|
+
'Ignore fail request and continue workflow': '忽略失败的请求并继续工作流',
|
|
160
|
+
'Workflow todos': '工作流待办',
|
|
161
|
+
'Task': '任务'
|
|
135
162
|
};
|
|
136
163
|
exports.default = _default;
|
|
@@ -1,24 +1,56 @@
|
|
|
1
|
+
import { SchemaInitializerItemOptions } from '@nocobase/client';
|
|
2
|
+
import { useWorkflowVariableOptions } from '../variable';
|
|
3
|
+
import { RadioWithTooltip } from '../components/RadioWithTooltip';
|
|
1
4
|
declare const _default: {
|
|
2
5
|
title: string;
|
|
3
6
|
type: string;
|
|
4
7
|
group: string;
|
|
5
8
|
fieldset: {
|
|
6
|
-
|
|
9
|
+
engine: {
|
|
7
10
|
type: string;
|
|
8
11
|
title: string;
|
|
9
|
-
|
|
12
|
+
'x-decorator': string;
|
|
13
|
+
'x-component': string;
|
|
14
|
+
'x-component-props': {
|
|
15
|
+
options: any[];
|
|
16
|
+
};
|
|
10
17
|
required: boolean;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
expression: {
|
|
21
|
+
type: string;
|
|
22
|
+
title: string;
|
|
11
23
|
'x-decorator': string;
|
|
12
24
|
'x-component': string;
|
|
25
|
+
'x-component-props': {
|
|
26
|
+
scope: string;
|
|
27
|
+
};
|
|
28
|
+
"x-validator"(value: any, rules: any, { form }: {
|
|
29
|
+
form: any;
|
|
30
|
+
}): string;
|
|
31
|
+
'x-reactions': {
|
|
32
|
+
dependencies: string[];
|
|
33
|
+
fulfill: {
|
|
34
|
+
schema: {
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
required: boolean;
|
|
13
40
|
};
|
|
14
41
|
};
|
|
15
42
|
view: {};
|
|
43
|
+
scope: {
|
|
44
|
+
useWorkflowVariableOptions: typeof useWorkflowVariableOptions;
|
|
45
|
+
renderReference: (key: string) => JSX.Element;
|
|
46
|
+
};
|
|
16
47
|
components: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
48
|
+
CalculationResult({ dataSource }: {
|
|
49
|
+
dataSource: any;
|
|
50
|
+
}): string | JSX.Element;
|
|
51
|
+
RadioWithTooltip: typeof RadioWithTooltip;
|
|
21
52
|
};
|
|
22
|
-
|
|
53
|
+
getOptions(config: any, types: any): any[];
|
|
54
|
+
useInitializers(node: any): SchemaInitializerItemOptions;
|
|
23
55
|
};
|
|
24
56
|
export default _default;
|
|
@@ -25,12 +25,52 @@ function _css() {
|
|
|
25
25
|
return data;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
function _jsonTemplates() {
|
|
29
|
+
const data = _interopRequireDefault(require("json-templates"));
|
|
30
|
+
|
|
31
|
+
_jsonTemplates = function _jsonTemplates() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _client() {
|
|
39
|
+
const data = require("@nocobase/client");
|
|
40
|
+
|
|
41
|
+
_client = function _client() {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _client2() {
|
|
49
|
+
const data = require("@nocobase/evaluators/client");
|
|
50
|
+
|
|
51
|
+
_client2 = function _client2() {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var _FlowContext = require("../FlowContext");
|
|
29
59
|
|
|
30
60
|
var _locale = require("../locale");
|
|
31
61
|
|
|
62
|
+
var _variable = require("../variable");
|
|
63
|
+
|
|
64
|
+
var _RadioWithTooltip = require("../components/RadioWithTooltip");
|
|
65
|
+
|
|
66
|
+
const _excluded = ["node", "insert"];
|
|
67
|
+
|
|
32
68
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
69
|
|
|
70
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
71
|
+
|
|
72
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
73
|
+
|
|
34
74
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
35
75
|
|
|
36
76
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -42,36 +82,142 @@ var _default = {
|
|
|
42
82
|
type: 'calculation',
|
|
43
83
|
group: 'control',
|
|
44
84
|
fieldset: {
|
|
45
|
-
|
|
46
|
-
type: '
|
|
47
|
-
title: `{{t("
|
|
48
|
-
|
|
85
|
+
engine: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
title: `{{t("Calculation engine", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
88
|
+
'x-decorator': 'FormItem',
|
|
89
|
+
'x-component': 'RadioWithTooltip',
|
|
90
|
+
'x-component-props': {
|
|
91
|
+
options: Array.from(_client2().evaluators.getEntities()).reduce((result, [value, options]) => result.concat(_objectSpread({
|
|
92
|
+
value
|
|
93
|
+
}, options)), [])
|
|
94
|
+
},
|
|
49
95
|
required: true,
|
|
96
|
+
default: 'math.js'
|
|
97
|
+
},
|
|
98
|
+
expression: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
title: `{{t("Calculation expression", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
50
101
|
'x-decorator': 'FormItem',
|
|
51
|
-
'x-component': '
|
|
102
|
+
'x-component': 'Variable.TextArea',
|
|
103
|
+
'x-component-props': {
|
|
104
|
+
scope: '{{useWorkflowVariableOptions}}'
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
['x-validator'](value, rules, {
|
|
108
|
+
form
|
|
109
|
+
}) {
|
|
110
|
+
const values = form.values;
|
|
111
|
+
|
|
112
|
+
const _evaluators$get = _client2().evaluators.get(values.engine),
|
|
113
|
+
evaluate = _evaluators$get.evaluate;
|
|
114
|
+
|
|
115
|
+
const exp = value.trim().replace(/{{([^{}]+)}}/g, '1');
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
evaluate(exp);
|
|
119
|
+
return '';
|
|
120
|
+
} catch (e) {
|
|
121
|
+
return (0, _locale.lang)('Expression syntax error');
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
'x-reactions': {
|
|
126
|
+
dependencies: ['engine'],
|
|
127
|
+
fulfill: {
|
|
128
|
+
schema: {
|
|
129
|
+
description: '{{renderReference($deps[0])}}'
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
required: true
|
|
52
134
|
}
|
|
53
135
|
},
|
|
54
136
|
view: {},
|
|
137
|
+
scope: {
|
|
138
|
+
useWorkflowVariableOptions: _variable.useWorkflowVariableOptions,
|
|
139
|
+
renderReference: _client2().renderReference
|
|
140
|
+
},
|
|
55
141
|
components: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
onChange
|
|
142
|
+
CalculationResult({
|
|
143
|
+
dataSource
|
|
59
144
|
}) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
145
|
+
var _execution$jobs;
|
|
146
|
+
|
|
147
|
+
const _useFlowContext = (0, _FlowContext.useFlowContext)(),
|
|
148
|
+
execution = _useFlowContext.execution;
|
|
149
|
+
|
|
150
|
+
if (!execution) {
|
|
151
|
+
return (0, _locale.lang)('Calculation result');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const result = (0, _jsonTemplates().default)(dataSource)({
|
|
155
|
+
$jobsMapByNodeId: ((_execution$jobs = execution.jobs) !== null && _execution$jobs !== void 0 ? _execution$jobs : []).reduce((map, job) => Object.assign(map, {
|
|
156
|
+
[job.nodeId]: job.result
|
|
157
|
+
}), {})
|
|
158
|
+
});
|
|
159
|
+
return _react().default.createElement("pre", {
|
|
160
|
+
className: (0, _css().css)`
|
|
161
|
+
margin: 0;
|
|
162
|
+
`
|
|
163
|
+
}, JSON.stringify(result, null, 2));
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
RadioWithTooltip: _RadioWithTooltip.RadioWithTooltip
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
getOptions(config, types) {
|
|
170
|
+
if (types && !types.some(type => type in _variable.TypeSets || Object.values(_variable.TypeSets).some(set => set.has(type)))) {
|
|
171
|
+
return null;
|
|
63
172
|
}
|
|
64
173
|
|
|
174
|
+
return [// { key: '', value: '', label: lang('Calculation result') }
|
|
175
|
+
];
|
|
65
176
|
},
|
|
66
177
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
t = _useWorkflowTranslati.t;
|
|
178
|
+
useInitializers(node) {
|
|
179
|
+
var _node$title;
|
|
70
180
|
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
181
|
+
return {
|
|
182
|
+
type: 'item',
|
|
183
|
+
title: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
|
|
184
|
+
component: CalculationInitializer,
|
|
185
|
+
node
|
|
186
|
+
};
|
|
74
187
|
}
|
|
75
188
|
|
|
76
189
|
};
|
|
77
|
-
exports.default = _default;
|
|
190
|
+
exports.default = _default;
|
|
191
|
+
|
|
192
|
+
function CalculationInitializer(_ref) {
|
|
193
|
+
let node = _ref.node,
|
|
194
|
+
insert = _ref.insert,
|
|
195
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
196
|
+
|
|
197
|
+
return _react().default.createElement(_client().SchemaInitializer.Item, _objectSpread(_objectSpread({}, props), {}, {
|
|
198
|
+
onClick: () => {
|
|
199
|
+
var _node$title2;
|
|
200
|
+
|
|
201
|
+
insert({
|
|
202
|
+
type: 'void',
|
|
203
|
+
name: node.id,
|
|
204
|
+
title: node.title,
|
|
205
|
+
'x-component': 'CardItem',
|
|
206
|
+
'x-component-props': {
|
|
207
|
+
title: (_node$title2 = node.title) !== null && _node$title2 !== void 0 ? _node$title2 : `#${node.id}`
|
|
208
|
+
},
|
|
209
|
+
'x-designer': 'SimpleDesigner',
|
|
210
|
+
properties: {
|
|
211
|
+
result: {
|
|
212
|
+
type: 'void',
|
|
213
|
+
'x-component': 'CalculationResult',
|
|
214
|
+
'x-component-props': {
|
|
215
|
+
// NOTE: as same format as other reference for migration of revision
|
|
216
|
+
dataSource: `{{$jobsMapByNodeId.${node.id}}}`
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { Registry } from "@nocobase/utils/client";
|
|
3
|
+
import { useWorkflowVariableOptions } from "../variable";
|
|
4
|
+
import { RadioWithTooltip } from "../components/RadioWithTooltip";
|
|
5
|
+
interface Calculator {
|
|
6
|
+
name: string;
|
|
7
|
+
type: 'boolean' | 'number' | 'string' | 'date' | 'unknown' | 'null' | 'array';
|
|
8
|
+
group: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const calculators: Registry<Calculator>;
|
|
11
|
+
export declare function Calculation({ calculator, operands, onChange }: {
|
|
12
|
+
calculator: any;
|
|
13
|
+
operands?: any[];
|
|
14
|
+
onChange: any;
|
|
15
|
+
}): JSX.Element;
|
|
2
16
|
declare function CalculationConfig({ value, onChange }: {
|
|
3
17
|
value: any;
|
|
4
18
|
onChange: any;
|
|
@@ -8,9 +22,8 @@ declare const _default: {
|
|
|
8
22
|
type: string;
|
|
9
23
|
group: string;
|
|
10
24
|
fieldset: {
|
|
11
|
-
|
|
25
|
+
rejectOnFalse: {
|
|
12
26
|
type: string;
|
|
13
|
-
name: string;
|
|
14
27
|
title: string;
|
|
15
28
|
'x-decorator': string;
|
|
16
29
|
'x-component': string;
|
|
@@ -22,12 +35,57 @@ declare const _default: {
|
|
|
22
35
|
label: string;
|
|
23
36
|
}[];
|
|
24
37
|
};
|
|
25
|
-
|
|
38
|
+
engine: {
|
|
39
|
+
type: string;
|
|
40
|
+
title: string;
|
|
41
|
+
'x-decorator': string;
|
|
42
|
+
'x-component': string;
|
|
43
|
+
'x-component-props': {
|
|
44
|
+
options: [string, import("@nocobase/evaluators/client").Evaluator] | (string | {
|
|
45
|
+
label: string;
|
|
46
|
+
})[];
|
|
47
|
+
};
|
|
48
|
+
required: boolean;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
calculation: {
|
|
26
52
|
type: string;
|
|
27
|
-
name: string;
|
|
28
53
|
title: string;
|
|
29
54
|
'x-decorator': string;
|
|
30
55
|
'x-component': string;
|
|
56
|
+
'x-reactions': {
|
|
57
|
+
dependencies: string[];
|
|
58
|
+
fulfill: {
|
|
59
|
+
state: {
|
|
60
|
+
visible: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
required: boolean;
|
|
65
|
+
};
|
|
66
|
+
expression: {
|
|
67
|
+
type: string;
|
|
68
|
+
title: string;
|
|
69
|
+
'x-decorator': string;
|
|
70
|
+
'x-component': string;
|
|
71
|
+
'x-component-props': {
|
|
72
|
+
scope: string;
|
|
73
|
+
};
|
|
74
|
+
"x-validator"(value: any, rules: any, { form }: {
|
|
75
|
+
form: any;
|
|
76
|
+
}): string;
|
|
77
|
+
'x-reactions': {
|
|
78
|
+
dependencies: string[];
|
|
79
|
+
fulfill: {
|
|
80
|
+
state: {
|
|
81
|
+
visible: string;
|
|
82
|
+
};
|
|
83
|
+
schema: {
|
|
84
|
+
description: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
required: boolean;
|
|
31
89
|
};
|
|
32
90
|
};
|
|
33
91
|
view: {};
|
|
@@ -39,8 +97,13 @@ declare const _default: {
|
|
|
39
97
|
};
|
|
40
98
|
}[];
|
|
41
99
|
render(data: any): JSX.Element;
|
|
100
|
+
scope: {
|
|
101
|
+
renderReference: (key: string) => JSX.Element;
|
|
102
|
+
useWorkflowVariableOptions: typeof useWorkflowVariableOptions;
|
|
103
|
+
};
|
|
42
104
|
components: {
|
|
43
105
|
CalculationConfig: typeof CalculationConfig;
|
|
106
|
+
RadioWithTooltip: typeof RadioWithTooltip;
|
|
44
107
|
};
|
|
45
108
|
};
|
|
46
109
|
export default _default;
|