@nocobase/plugin-workflow 0.10.0-alpha.5 → 0.11.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +2 -3
- package/client.js +1 -30
- package/lib/client/AddButton.js +1 -8
- package/lib/client/Branch.js +8 -8
- package/lib/client/CanvasContent.js +8 -8
- package/lib/client/ExecutionCanvas.js +20 -27
- package/lib/client/ExecutionPage.js +1 -8
- package/lib/client/WorkflowCanvas.js +3 -10
- package/lib/client/WorkflowPage.js +1 -8
- package/lib/client/WorkflowProvider.js +3 -42
- package/lib/client/components/CollectionFieldset.d.ts +1 -1
- package/lib/client/components/CollectionFieldset.js +8 -15
- package/lib/client/components/Duration.js +5 -5
- package/lib/client/components/DynamicExpression.d.ts +3 -3
- package/lib/client/components/DynamicExpression.js +14 -4
- package/lib/client/components/FieldsSelect.d.ts +1 -1
- package/lib/client/components/FieldsSelect.js +6 -6
- package/lib/client/components/NodeDescription.js +11 -11
- package/lib/client/components/RadioWithTooltip.js +13 -20
- package/lib/client/components/ValueBlock.js +14 -21
- package/lib/client/components/renderEngineReference.js +1 -8
- package/lib/client/index.d.ts +12 -4
- package/lib/client/index.js +78 -15
- package/lib/client/nodes/aggregate.d.ts +10 -4
- package/lib/client/nodes/aggregate.js +12 -9
- package/lib/client/nodes/calculation.d.ts +11 -16
- package/lib/client/nodes/calculation.js +72 -52
- package/lib/client/nodes/condition.d.ts +2 -6
- package/lib/client/nodes/condition.js +20 -24
- package/lib/client/nodes/create.d.ts +8 -5
- package/lib/client/nodes/create.js +34 -7
- package/lib/client/nodes/destroy.d.ts +1 -1
- package/lib/client/nodes/index.d.ts +4 -4
- package/lib/client/nodes/index.js +79 -86
- package/lib/client/nodes/loop.d.ts +3 -1
- package/lib/client/nodes/loop.js +48 -35
- package/lib/client/nodes/manual/ModeConfig.js +23 -30
- package/lib/client/nodes/manual/SchemaConfig.d.ts +3 -3
- package/lib/client/nodes/manual/SchemaConfig.js +18 -17
- package/lib/client/nodes/manual/WorkflowTodo.js +66 -72
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -5
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/forms/custom.js +11 -18
- package/lib/client/nodes/manual/index.d.ts +11 -5
- package/lib/client/nodes/manual/index.js +21 -10
- package/lib/client/nodes/parallel.js +20 -20
- package/lib/client/nodes/query.d.ts +7 -4
- package/lib/client/nodes/query.js +34 -7
- package/lib/client/nodes/request.d.ts +10 -6
- package/lib/client/nodes/request.js +37 -9
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +1 -1
- package/lib/client/schemas/collection.d.ts +1 -1
- package/lib/client/schemas/collection.js +3 -10
- package/lib/client/style.js +18 -18
- package/lib/client/triggers/collection.d.ts +4 -3
- package/lib/client/triggers/collection.js +21 -7
- package/lib/client/triggers/index.d.ts +2 -2
- package/lib/client/triggers/index.js +46 -52
- package/lib/client/triggers/schedule/DateFieldsSelect.js +1 -1
- package/lib/client/triggers/schedule/EndsByField.js +11 -11
- package/lib/client/triggers/schedule/OnField.js +11 -11
- package/lib/client/triggers/schedule/RepeatField.js +4 -4
- package/lib/client/triggers/schedule/ScheduleConfig.js +17 -24
- package/lib/client/triggers/schedule/index.d.ts +3 -4
- package/lib/client/triggers/schedule/index.js +21 -11
- package/lib/client/variable.d.ts +3 -4
- package/lib/client/variable.js +110 -45
- package/lib/server/Plugin.d.ts +2 -3
- package/lib/server/Plugin.js +8 -9
- package/lib/server/Processor.d.ts +2 -4
- package/lib/server/actions/nodes.js +7 -7
- package/lib/server/fields/expression-field.d.ts +1 -2
- package/lib/server/fields/expression-field.js +1 -8
- package/lib/server/functions/index.d.ts +2 -3
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +12 -0
- package/lib/server/instructions/aggregate.d.ts +1 -1
- package/lib/server/instructions/aggregate.js +5 -5
- package/lib/server/instructions/condition.d.ts +2 -1
- package/lib/server/instructions/create.d.ts +1 -1
- package/lib/server/instructions/delay.d.ts +3 -3
- package/lib/server/instructions/delay.js +66 -64
- package/lib/server/instructions/destroy.d.ts +1 -1
- package/lib/server/instructions/index.d.ts +5 -5
- package/lib/server/instructions/loop.d.ts +1 -2
- package/lib/server/instructions/manual/actions.js +1 -1
- package/lib/server/instructions/manual/forms/index.d.ts +1 -1
- package/lib/server/instructions/manual/index.d.ts +1 -1
- package/lib/server/instructions/parallel.d.ts +1 -2
- package/lib/server/instructions/query.d.ts +1 -1
- package/lib/server/instructions/request.d.ts +2 -2
- package/lib/server/instructions/request.js +1 -0
- package/lib/server/instructions/update.d.ts +1 -1
- package/lib/server/migrations/20230221071831-calculation-expression.js +1 -1
- package/lib/server/migrations/20230221121203-condition-calculation.js +1 -1
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +7 -7
- package/lib/server/migrations/20230411034722-manual-multi-form.js +1 -8
- package/lib/server/triggers/collection.d.ts +1 -1
- package/lib/server/triggers/collection.js +2 -2
- package/lib/server/triggers/index.d.ts +1 -1
- package/lib/server/triggers/schedule.d.ts +1 -1
- package/lib/server/triggers/schedule.js +18 -18
- package/lib/server/{models → types}/Execution.d.ts +2 -3
- package/lib/server/{models → types}/FlowNode.d.ts +1 -2
- package/lib/server/{models → types}/Job.d.ts +1 -2
- package/lib/server/{models → types}/Workflow.d.ts +1 -2
- package/lib/server/types/index.d.ts +4 -0
- package/lib/server/types/index.js +5 -0
- package/package.json +40 -20
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/src/client/AddButton.tsx +99 -0
- package/src/client/Branch.tsx +35 -0
- package/src/client/CanvasContent.tsx +23 -0
- package/src/client/ExecutionCanvas.tsx +168 -0
- package/src/client/ExecutionLink.tsx +16 -0
- package/src/client/ExecutionPage.tsx +44 -0
- package/src/client/ExecutionResourceProvider.tsx +21 -0
- package/src/client/FlowContext.ts +7 -0
- package/src/client/WorkflowCanvas.tsx +220 -0
- package/src/client/WorkflowLink.tsx +16 -0
- package/src/client/WorkflowPage.tsx +51 -0
- package/src/client/WorkflowProvider.tsx +84 -0
- package/src/client/components/CollectionBlockInitializer.tsx +71 -0
- package/src/client/components/CollectionFieldset.tsx +158 -0
- package/src/client/components/Duration.tsx +45 -0
- package/src/client/components/DynamicExpression.tsx +53 -0
- package/src/client/components/FieldsSelect.tsx +28 -0
- package/src/client/components/FilterDynamicComponent.tsx +15 -0
- package/src/client/components/NodeDescription.tsx +44 -0
- package/src/client/components/NullRender.tsx +3 -0
- package/src/client/components/OpenDrawer.tsx +24 -0
- package/src/client/components/RadioWithTooltip.tsx +38 -0
- package/src/client/components/ValueBlock.tsx +67 -0
- package/src/client/components/renderEngineReference.tsx +30 -0
- package/src/client/constants.tsx +91 -0
- package/src/client/index.tsx +51 -0
- package/src/client/interfaces/expression.tsx +25 -0
- package/src/client/locale/en-US.ts +136 -0
- package/src/client/locale/es-ES.ts +129 -0
- package/src/client/locale/index.ts +18 -0
- package/src/client/locale/ja-JP.ts +90 -0
- package/src/client/locale/pt-BR.ts +136 -0
- package/src/client/locale/ru-RU.ts +90 -0
- package/src/client/locale/tr-TR.ts +90 -0
- package/src/client/locale/zh-CN.ts +242 -0
- package/src/client/nodes/aggregate.tsx +327 -0
- package/src/client/nodes/calculation.tsx +217 -0
- package/src/client/nodes/condition.tsx +490 -0
- package/src/client/nodes/create.tsx +86 -0
- package/src/client/nodes/delay.tsx +37 -0
- package/src/client/nodes/destroy.tsx +34 -0
- package/src/client/nodes/index.tsx +489 -0
- package/src/client/nodes/loop.tsx +159 -0
- package/src/client/nodes/manual/AssigneesSelect.tsx +33 -0
- package/src/client/nodes/manual/DetailsBlockProvider.tsx +80 -0
- package/src/client/nodes/manual/FormBlockInitializer.tsx +68 -0
- package/src/client/nodes/manual/FormBlockProvider.tsx +75 -0
- package/src/client/nodes/manual/ModeConfig.tsx +84 -0
- package/src/client/nodes/manual/SchemaConfig.tsx +365 -0
- package/src/client/nodes/manual/WorkflowTodo.tsx +611 -0
- package/src/client/nodes/manual/WorkflowTodoBlockInitializer.tsx +28 -0
- package/src/client/nodes/manual/forms/create.tsx +88 -0
- package/src/client/nodes/manual/forms/custom.tsx +388 -0
- package/src/client/nodes/manual/forms/update.tsx +130 -0
- package/src/client/nodes/manual/index.tsx +162 -0
- package/src/client/nodes/manual/utils.ts +28 -0
- package/src/client/nodes/parallel.tsx +137 -0
- package/src/client/nodes/query.tsx +89 -0
- package/src/client/nodes/request.tsx +185 -0
- package/src/client/nodes/update.tsx +99 -0
- package/src/client/schemas/collection.ts +75 -0
- package/src/client/schemas/executions.tsx +169 -0
- package/src/client/schemas/workflows.ts +364 -0
- package/src/client/style.tsx +312 -0
- package/src/client/triggers/collection.tsx +186 -0
- package/src/client/triggers/index.tsx +307 -0
- package/src/client/triggers/schedule/DateFieldsSelect.tsx +28 -0
- package/src/client/triggers/schedule/EndsByField.tsx +40 -0
- package/src/client/triggers/schedule/OnField.tsx +50 -0
- package/src/client/triggers/schedule/RepeatField.tsx +116 -0
- package/src/client/triggers/schedule/ScheduleConfig.tsx +225 -0
- package/src/client/triggers/schedule/constants.ts +4 -0
- package/src/client/triggers/schedule/index.tsx +72 -0
- package/src/client/triggers/schedule/locale/Cron.zh-CN.ts +79 -0
- package/src/client/utils.ts +36 -0
- package/src/client/variable.tsx +296 -0
- package/src/index.ts +1 -0
- package/src/server/Plugin.ts +351 -0
- package/src/server/Processor.ts +354 -0
- package/src/server/__tests__/Plugin.test.ts +398 -0
- package/src/server/__tests__/Processor.test.ts +474 -0
- package/src/server/__tests__/actions/workflows.test.ts +419 -0
- package/src/server/__tests__/collections/categories.ts +23 -0
- package/src/server/__tests__/collections/comments.ts +24 -0
- package/src/server/__tests__/collections/posts.ts +42 -0
- package/src/server/__tests__/collections/replies.ts +9 -0
- package/src/server/__tests__/collections/tags.ts +15 -0
- package/src/server/__tests__/index.ts +89 -0
- package/src/server/__tests__/instructions/aggregate.test.ts +294 -0
- package/src/server/__tests__/instructions/calculation.test.ts +265 -0
- package/src/server/__tests__/instructions/condition.test.ts +335 -0
- package/src/server/__tests__/instructions/create.test.ts +129 -0
- package/src/server/__tests__/instructions/delay.test.ts +182 -0
- package/src/server/__tests__/instructions/destroy.test.ts +58 -0
- package/src/server/__tests__/instructions/loop.test.ts +331 -0
- package/src/server/__tests__/instructions/manual.test.ts +854 -0
- package/src/server/__tests__/instructions/parallel.test.ts +445 -0
- package/src/server/__tests__/instructions/query.test.ts +359 -0
- package/src/server/__tests__/instructions/request.test.ts +217 -0
- package/src/server/__tests__/instructions/update.test.ts +189 -0
- package/src/server/__tests__/triggers/collection.test.ts +298 -0
- package/src/server/__tests__/triggers/schedule.test.ts +369 -0
- package/src/server/actions/index.ts +25 -0
- package/src/server/actions/nodes.ts +214 -0
- package/src/server/actions/workflows.ts +178 -0
- package/src/server/collections/executions.ts +35 -0
- package/src/server/collections/flow_nodes.ts +54 -0
- package/src/server/collections/jobs.ts +31 -0
- package/src/server/collections/workflows.ts +88 -0
- package/src/server/constants.ts +26 -0
- package/src/server/fields/expression-field.ts +11 -0
- package/src/server/fields/index.ts +7 -0
- package/src/server/functions/index.ts +16 -0
- package/src/server/index.ts +6 -0
- package/src/server/instructions/aggregate.ts +42 -0
- package/src/server/instructions/calculation.ts +41 -0
- package/src/server/instructions/condition.ts +172 -0
- package/src/server/instructions/create.ts +37 -0
- package/src/server/instructions/delay.ts +105 -0
- package/src/server/instructions/destroy.ts +23 -0
- package/src/server/instructions/index.ts +63 -0
- package/src/server/instructions/loop.ts +99 -0
- package/src/server/instructions/manual/actions.ts +79 -0
- package/src/server/instructions/manual/collecions/jobs.ts +17 -0
- package/src/server/instructions/manual/collecions/users.ts +15 -0
- package/src/server/instructions/manual/collecions/users_jobs.ts +50 -0
- package/src/server/instructions/manual/forms/create.ts +22 -0
- package/src/server/instructions/manual/forms/index.ts +12 -0
- package/src/server/instructions/manual/forms/update.ts +22 -0
- package/src/server/instructions/manual/index.ts +184 -0
- package/src/server/instructions/parallel.ts +121 -0
- package/src/server/instructions/query.ts +31 -0
- package/src/server/instructions/request.ts +87 -0
- package/src/server/instructions/update.ts +24 -0
- package/src/server/migrations/20221129153547-calculation-variables.ts +64 -0
- package/src/server/migrations/20230221032941-change-request-body-type.ts +76 -0
- package/src/server/migrations/20230221071831-calculation-expression.ts +102 -0
- package/src/server/migrations/20230221121203-condition-calculation.ts +82 -0
- package/src/server/migrations/20230221162902-jsonb-to-json.ts +51 -0
- package/src/server/migrations/20230411034722-manual-multi-form.ts +282 -0
- package/src/server/migrations/20230612021134-manual-collection-block.ts +138 -0
- package/src/server/triggers/collection.ts +142 -0
- package/src/server/triggers/index.ts +22 -0
- package/src/server/triggers/schedule.ts +567 -0
- package/src/server/types/Execution.ts +26 -0
- package/src/server/types/FlowNode.ts +21 -0
- package/src/server/types/Job.ts +18 -0
- package/src/server/types/Workflow.ts +36 -0
- package/src/server/types/index.ts +4 -0
- /package/lib/server/{models → types}/Execution.js +0 -0
- /package/lib/server/{models → types}/FlowNode.js +0 -0
- /package/lib/server/{models → types}/Job.js +0 -0
- /package/lib/server/{models → types}/Workflow.js +0 -0
package/lib/client/variable.js
CHANGED
|
@@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BaseTypeSets = void 0;
|
|
7
|
-
exports.
|
|
7
|
+
exports.getCollectionFieldOptions = getCollectionFieldOptions;
|
|
8
8
|
exports.triggerOptions = exports.systemOptions = exports.scopeOptions = exports.nodesOptions = void 0;
|
|
9
|
-
exports.useCollectionFieldOptions = useCollectionFieldOptions;
|
|
10
9
|
exports.useWorkflowVariableOptions = useWorkflowVariableOptions;
|
|
11
10
|
function _client() {
|
|
12
11
|
const data = require("@nocobase/client");
|
|
@@ -19,6 +18,8 @@ var _FlowContext = require("./FlowContext");
|
|
|
19
18
|
var _locale = require("./locale");
|
|
20
19
|
var _nodes = require("./nodes");
|
|
21
20
|
var _triggers = require("./triggers");
|
|
21
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
22
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
22
23
|
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; }
|
|
23
24
|
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; }
|
|
24
25
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -34,15 +35,9 @@ const nodesOptions = {
|
|
|
34
35
|
upstreams.forEach(node => {
|
|
35
36
|
var _instruction$useVaria;
|
|
36
37
|
const instruction = _nodes.instructions.get(node.type);
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
result.push({
|
|
41
|
-
key: node.id.toString(),
|
|
42
|
-
value: node.id.toString(),
|
|
43
|
-
label: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
|
|
44
|
-
children: subOptions
|
|
45
|
-
});
|
|
38
|
+
const subOption = (_instruction$useVaria = instruction.useVariables) === null || _instruction$useVaria === void 0 ? void 0 : _instruction$useVaria.call(instruction, node, options);
|
|
39
|
+
if (subOption) {
|
|
40
|
+
result.push(subOption);
|
|
46
41
|
}
|
|
47
42
|
});
|
|
48
43
|
return result;
|
|
@@ -73,11 +68,11 @@ const scopeOptions = {
|
|
|
73
68
|
const instruction = _nodes.instructions.get(node.type);
|
|
74
69
|
const subOptions = (_instruction$useScope = instruction.useScopeVariables) === null || _instruction$useScope === void 0 ? void 0 : _instruction$useScope.call(instruction, node, options);
|
|
75
70
|
if (subOptions) {
|
|
76
|
-
var _node$
|
|
71
|
+
var _node$title;
|
|
77
72
|
result.push({
|
|
78
73
|
key: node.id.toString(),
|
|
79
74
|
value: node.id.toString(),
|
|
80
|
-
label: (_node$
|
|
75
|
+
label: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
|
|
81
76
|
children: subOptions
|
|
82
77
|
});
|
|
83
78
|
}
|
|
@@ -95,14 +90,14 @@ const systemOptions = {
|
|
|
95
90
|
return [...(!types || types.includes('date') ? [{
|
|
96
91
|
key: 'now',
|
|
97
92
|
value: 'now',
|
|
98
|
-
label:
|
|
93
|
+
label: (0, _locale.lang)('System time')
|
|
99
94
|
}] : [])];
|
|
100
95
|
}
|
|
101
96
|
};
|
|
102
97
|
exports.systemOptions = systemOptions;
|
|
103
98
|
const BaseTypeSets = {
|
|
104
99
|
boolean: new Set(['checkbox']),
|
|
105
|
-
number: new Set(['number', 'percent']),
|
|
100
|
+
number: new Set(['integer', 'number', 'percent']),
|
|
106
101
|
string: new Set(['input', 'password', 'email', 'phone', 'select', 'radioGroup', 'text', 'markdown', 'richText', 'expression', 'time']),
|
|
107
102
|
date: new Set(['date', 'createdAt', 'updatedAt'])
|
|
108
103
|
};
|
|
@@ -110,7 +105,7 @@ const BaseTypeSets = {
|
|
|
110
105
|
// { type: 'reference', options: { collection: 'attachments', multiple: false } }
|
|
111
106
|
// { type: 'reference', options: { collection: 'myExpressions', entity: false } }
|
|
112
107
|
exports.BaseTypeSets = BaseTypeSets;
|
|
113
|
-
function matchFieldType(field, type,
|
|
108
|
+
function matchFieldType(field, type, appends) {
|
|
114
109
|
const inputType = typeof type;
|
|
115
110
|
if (inputType === 'string') {
|
|
116
111
|
var _BaseTypeSets$type;
|
|
@@ -128,42 +123,67 @@ function matchFieldType(field, type, depth) {
|
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
125
|
if (inputType === 'function') {
|
|
131
|
-
return type(field,
|
|
126
|
+
return type(field, appends);
|
|
132
127
|
}
|
|
133
128
|
return false;
|
|
134
129
|
}
|
|
135
130
|
function isAssociationField(field) {
|
|
136
131
|
return ['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type);
|
|
137
132
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
133
|
+
function getNextAppends(field, appends) {
|
|
134
|
+
const fieldPrefix = `${field.name}.`;
|
|
135
|
+
return appends.filter(item => item.startsWith(fieldPrefix)).map(item => item.replace(fieldPrefix, ''));
|
|
136
|
+
}
|
|
137
|
+
function filterTypedFields({
|
|
138
|
+
fields,
|
|
139
|
+
types,
|
|
140
|
+
appends,
|
|
141
|
+
compile,
|
|
142
|
+
getCollectionFields
|
|
143
|
+
}) {
|
|
142
144
|
return fields.filter(field => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
const match = types !== null && types !== void 0 && types.length ? types.some(type => matchFieldType(field, type, appends)) : true;
|
|
146
|
+
if (isAssociationField(field)) {
|
|
147
|
+
const nextAppends = getNextAppends(field, appends);
|
|
148
|
+
const included = appends.includes(field.name);
|
|
149
|
+
if (match) {
|
|
150
|
+
return included;
|
|
151
|
+
} else {
|
|
152
|
+
return (nextAppends.length || included) && filterTypedFields({
|
|
153
|
+
fields: getNormalizedFields(field.target, {
|
|
154
|
+
compile,
|
|
155
|
+
getCollectionFields
|
|
156
|
+
}),
|
|
157
|
+
types,
|
|
158
|
+
// depth: depth - 1,
|
|
159
|
+
appends: nextAppends,
|
|
160
|
+
compile,
|
|
161
|
+
getCollectionFields
|
|
162
|
+
}).length;
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
return match;
|
|
145
166
|
}
|
|
146
|
-
return types.some(type => matchFieldType(field, type, depth));
|
|
147
167
|
});
|
|
148
168
|
}
|
|
149
169
|
function useWorkflowVariableOptions(options = {}) {
|
|
150
170
|
const compile = (0, _client().useCompile)();
|
|
151
171
|
const result = [scopeOptions, nodesOptions, triggerOptions, systemOptions].map(item => {
|
|
152
|
-
const opts =
|
|
172
|
+
const opts = item.useOptions(options).filter(Boolean);
|
|
153
173
|
return {
|
|
154
174
|
label: compile(item.label),
|
|
155
175
|
value: item.value,
|
|
156
176
|
key: item.value,
|
|
157
|
-
children:
|
|
177
|
+
children: opts,
|
|
158
178
|
disabled: opts && !opts.length
|
|
159
179
|
};
|
|
160
180
|
});
|
|
161
181
|
return result;
|
|
162
182
|
}
|
|
163
|
-
function
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
183
|
+
function getNormalizedFields(collectionName, {
|
|
184
|
+
compile,
|
|
185
|
+
getCollectionFields
|
|
186
|
+
}) {
|
|
167
187
|
const fields = getCollectionFields(collectionName);
|
|
168
188
|
const foreignKeyFields = [];
|
|
169
189
|
const otherFields = [];
|
|
@@ -182,7 +202,7 @@ function useNormalizedFields(collectionName) {
|
|
|
182
202
|
var _field$uiSchema, _field$uiSchema2;
|
|
183
203
|
otherFields.splice(i, 0, _objectSpread(_objectSpread(_objectSpread({}, field), foreignKeyField), {}, {
|
|
184
204
|
uiSchema: _objectSpread(_objectSpread({}, field.uiSchema), {}, {
|
|
185
|
-
title: (
|
|
205
|
+
title: (_field$uiSchema = field.uiSchema) !== null && _field$uiSchema !== void 0 && _field$uiSchema.title ? `${compile((_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title)} ID` : foreignKeyField.name
|
|
186
206
|
})
|
|
187
207
|
}));
|
|
188
208
|
} else {
|
|
@@ -193,7 +213,7 @@ function useNormalizedFields(collectionName) {
|
|
|
193
213
|
isForeignKey: true,
|
|
194
214
|
interface: field.interface,
|
|
195
215
|
uiSchema: _objectSpread(_objectSpread({}, field.uiSchema), {}, {
|
|
196
|
-
title: (
|
|
216
|
+
title: (_field$uiSchema3 = field.uiSchema) !== null && _field$uiSchema3 !== void 0 && _field$uiSchema3.title ? `${compile((_field$uiSchema4 = field.uiSchema) === null || _field$uiSchema4 === void 0 ? void 0 : _field$uiSchema4.title)} ID` : field.name
|
|
197
217
|
})
|
|
198
218
|
}));
|
|
199
219
|
}
|
|
@@ -204,35 +224,80 @@ function useNormalizedFields(collectionName) {
|
|
|
204
224
|
type: field.dataType,
|
|
205
225
|
interface: belongsToField.interface,
|
|
206
226
|
uiSchema: _objectSpread(_objectSpread({}, belongsToField.uiSchema), {}, {
|
|
207
|
-
title: (
|
|
227
|
+
title: (_belongsToField$uiSch = belongsToField.uiSchema) !== null && _belongsToField$uiSch !== void 0 && _belongsToField$uiSch.title ? `${compile((_belongsToField$uiSch2 = belongsToField.uiSchema) === null || _belongsToField$uiSch2 === void 0 ? void 0 : _belongsToField$uiSch2.title)} ID` : field.name
|
|
208
228
|
})
|
|
209
229
|
}));
|
|
210
230
|
}
|
|
211
231
|
}
|
|
212
232
|
return otherFields.filter(field => field.interface && !field.hidden);
|
|
213
233
|
}
|
|
214
|
-
function
|
|
234
|
+
function loadChildren(_x) {
|
|
235
|
+
return _loadChildren.apply(this, arguments);
|
|
236
|
+
}
|
|
237
|
+
function _loadChildren() {
|
|
238
|
+
_loadChildren = _asyncToGenerator(function* (option) {
|
|
239
|
+
const result = getCollectionFieldOptions({
|
|
240
|
+
collection: option.field.target,
|
|
241
|
+
types: option.types,
|
|
242
|
+
appends: getNextAppends(option.field, option.appends),
|
|
243
|
+
sourceKey: option.field.key,
|
|
244
|
+
compile: this.compile,
|
|
245
|
+
getCollectionFields: this.getCollectionFields
|
|
246
|
+
});
|
|
247
|
+
if (result.length) {
|
|
248
|
+
option.children = result;
|
|
249
|
+
} else {
|
|
250
|
+
var _option$types;
|
|
251
|
+
option.isLeaf = true;
|
|
252
|
+
option.loadChildren = null;
|
|
253
|
+
const matchingType = (_option$types = option.types) === null || _option$types === void 0 ? void 0 : _option$types.some(type => matchFieldType(option.field, type, 0));
|
|
254
|
+
if (!matchingType) {
|
|
255
|
+
option.disabled = true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return _loadChildren.apply(this, arguments);
|
|
260
|
+
}
|
|
261
|
+
function getCollectionFieldOptions(options) {
|
|
215
262
|
const fields = options.fields,
|
|
216
263
|
collection = options.collection,
|
|
217
264
|
types = options.types,
|
|
218
|
-
_options$
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
265
|
+
_options$appends = options.appends,
|
|
266
|
+
appends = _options$appends === void 0 ? [] : _options$appends,
|
|
267
|
+
compile = options.compile,
|
|
268
|
+
getCollectionFields = options.getCollectionFields;
|
|
269
|
+
const normalizedFields = getNormalizedFields(collection, {
|
|
270
|
+
compile,
|
|
271
|
+
getCollectionFields
|
|
272
|
+
});
|
|
222
273
|
const computedFields = fields !== null && fields !== void 0 ? fields : normalizedFields;
|
|
223
|
-
const
|
|
274
|
+
const boundLoadChildren = loadChildren.bind({
|
|
275
|
+
compile,
|
|
276
|
+
getCollectionFields
|
|
277
|
+
});
|
|
278
|
+
const result = filterTypedFields({
|
|
279
|
+
fields: computedFields,
|
|
280
|
+
types,
|
|
281
|
+
// depth,
|
|
282
|
+
appends,
|
|
283
|
+
compile,
|
|
284
|
+
getCollectionFields
|
|
285
|
+
}).map(field => {
|
|
224
286
|
var _field$uiSchema5;
|
|
225
287
|
const label = compile(((_field$uiSchema5 = field.uiSchema) === null || _field$uiSchema5 === void 0 ? void 0 : _field$uiSchema5.title) || field.name);
|
|
288
|
+
const nextAppends = getNextAppends(field, appends);
|
|
289
|
+
// TODO: no matching fields in next appends should consider isLeaf as true
|
|
290
|
+
const isLeaf = !isAssociationField(field) || !nextAppends.length && !appends.includes(field.name);
|
|
226
291
|
return {
|
|
227
292
|
label,
|
|
228
293
|
key: field.name,
|
|
229
294
|
value: field.name,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
295
|
+
isLeaf,
|
|
296
|
+
loadChildren: isLeaf ? null : boundLoadChildren,
|
|
297
|
+
field,
|
|
298
|
+
// depth,
|
|
299
|
+
appends,
|
|
300
|
+
types
|
|
236
301
|
};
|
|
237
302
|
});
|
|
238
303
|
return result;
|
package/lib/server/Plugin.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Plugin } from '@nocobase/server';
|
|
2
2
|
import { Registry } from '@nocobase/utils';
|
|
3
3
|
import { Instruction } from './instructions';
|
|
4
|
-
import ExecutionModel from './models/Execution';
|
|
5
|
-
import WorkflowModel from './models/Workflow';
|
|
6
4
|
import Processor from './Processor';
|
|
7
5
|
import { Trigger } from './triggers';
|
|
8
6
|
import { CustomFunction } from './functions';
|
|
9
7
|
import { Logger } from '@nocobase/logger';
|
|
10
|
-
|
|
8
|
+
import type { WorkflowModel, ExecutionModel } from './types';
|
|
9
|
+
type ID = number | string;
|
|
11
10
|
export default class WorkflowPlugin extends Plugin {
|
|
12
11
|
instructions: Registry<Instruction>;
|
|
13
12
|
triggers: Registry<Trigger>;
|
package/lib/server/Plugin.js
CHANGED
|
@@ -82,7 +82,7 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
82
82
|
this.instructions = new (_utils().Registry)();
|
|
83
83
|
this.triggers = new (_utils().Registry)();
|
|
84
84
|
this.functions = new (_utils().Registry)();
|
|
85
|
-
this.executing =
|
|
85
|
+
this.executing = false;
|
|
86
86
|
this.pending = [];
|
|
87
87
|
this.events = [];
|
|
88
88
|
this.loggerCache = void 0;
|
|
@@ -142,7 +142,7 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
142
142
|
context = _event[1],
|
|
143
143
|
options = _event[2];
|
|
144
144
|
let valid = true;
|
|
145
|
-
if ((_options$context = options.context)
|
|
145
|
+
if ((_options$context = options.context) !== null && _options$context !== void 0 && _options$context.executionId) {
|
|
146
146
|
// NOTE: no transaction here for read-uncommitted execution
|
|
147
147
|
const existed = yield workflow.countExecutions({
|
|
148
148
|
where: {
|
|
@@ -165,10 +165,6 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
165
165
|
}, {
|
|
166
166
|
transaction
|
|
167
167
|
});
|
|
168
|
-
const executed = yield workflow.countExecutions({
|
|
169
|
-
transaction
|
|
170
|
-
});
|
|
171
|
-
// NOTE: not to trigger afterUpdate hook here
|
|
172
168
|
yield workflow.increment('executed', {
|
|
173
169
|
transaction
|
|
174
170
|
});
|
|
@@ -329,6 +325,7 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
329
325
|
if (_this4.executing) {
|
|
330
326
|
return;
|
|
331
327
|
}
|
|
328
|
+
_this4.executing = true;
|
|
332
329
|
let next = null;
|
|
333
330
|
// resuming has high priority
|
|
334
331
|
if (_this4.pending.length) {
|
|
@@ -338,21 +335,23 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
338
335
|
filter: {
|
|
339
336
|
status: _constants.EXECUTION_STATUS.QUEUEING
|
|
340
337
|
},
|
|
338
|
+
appends: ['workflow'],
|
|
341
339
|
sort: 'createdAt'
|
|
342
340
|
});
|
|
343
|
-
if (execution) {
|
|
341
|
+
if (execution && execution.workflow.enabled) {
|
|
344
342
|
next = [execution];
|
|
345
343
|
}
|
|
346
344
|
}
|
|
347
345
|
if (next) {
|
|
348
346
|
_this4.process(...next);
|
|
347
|
+
} else {
|
|
348
|
+
_this4.executing = false;
|
|
349
349
|
}
|
|
350
350
|
})();
|
|
351
351
|
}
|
|
352
352
|
process(execution, job) {
|
|
353
353
|
var _this5 = this;
|
|
354
354
|
return _asyncToGenerator(function* () {
|
|
355
|
-
_this5.executing = execution;
|
|
356
355
|
if (execution.status === _constants.EXECUTION_STATUS.QUEUEING) {
|
|
357
356
|
yield execution.update({
|
|
358
357
|
status: _constants.EXECUTION_STATUS.STARTED
|
|
@@ -366,7 +365,7 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
366
365
|
} catch (err) {
|
|
367
366
|
_this5.getLogger(execution.workflowId).error(`execution (${execution.id}) error: ${err.message}`, err);
|
|
368
367
|
}
|
|
369
|
-
_this5.executing =
|
|
368
|
+
_this5.executing = false;
|
|
370
369
|
_this5.dispatch();
|
|
371
370
|
})();
|
|
372
371
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { Transaction, Transactionable } from '@nocobase/database';
|
|
1
2
|
import { Logger } from '@nocobase/logger';
|
|
2
|
-
import { Transaction, Transactionable } from 'sequelize';
|
|
3
3
|
import Plugin from '.';
|
|
4
|
-
import ExecutionModel from './
|
|
5
|
-
import FlowNodeModel from './models/FlowNode';
|
|
6
|
-
import JobModel from './models/Job';
|
|
4
|
+
import type { ExecutionModel, FlowNodeModel, JobModel } from './types';
|
|
7
5
|
export interface ProcessorOptions extends Transactionable {
|
|
8
6
|
plugin: Plugin;
|
|
9
7
|
}
|
|
@@ -6,16 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.create = create;
|
|
7
7
|
exports.destroy = destroy;
|
|
8
8
|
exports.update = update;
|
|
9
|
-
function
|
|
10
|
-
const data = require("
|
|
11
|
-
|
|
9
|
+
function _actions() {
|
|
10
|
+
const data = require("@nocobase/actions");
|
|
11
|
+
_actions = function _actions() {
|
|
12
12
|
return data;
|
|
13
13
|
};
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const data = require("@nocobase/
|
|
18
|
-
|
|
16
|
+
function _database() {
|
|
17
|
+
const data = require("@nocobase/database");
|
|
18
|
+
_database = function _database() {
|
|
19
19
|
return data;
|
|
20
20
|
};
|
|
21
21
|
return data;
|
|
@@ -102,7 +102,7 @@ function _create() {
|
|
|
102
102
|
const _yield$upstream$getBr = yield upstream.getBranches({
|
|
103
103
|
where: {
|
|
104
104
|
id: {
|
|
105
|
-
[
|
|
105
|
+
[_database().Op.ne]: instance.id
|
|
106
106
|
},
|
|
107
107
|
branchIndex: instance.branchIndex
|
|
108
108
|
},
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '
|
|
2
|
-
import { BaseFieldOptions, Field } from '@nocobase/database';
|
|
1
|
+
import { BaseFieldOptions, DataTypes, Field } from '@nocobase/database';
|
|
3
2
|
export interface ExpressionFieldOptions extends BaseFieldOptions {
|
|
4
3
|
type: 'expression';
|
|
5
4
|
}
|
|
@@ -4,13 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ExpressionField = void 0;
|
|
7
|
-
function _sequelize() {
|
|
8
|
-
const data = require("sequelize");
|
|
9
|
-
_sequelize = function _sequelize() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
7
|
function _database() {
|
|
15
8
|
const data = require("@nocobase/database");
|
|
16
9
|
_database = function _database() {
|
|
@@ -20,7 +13,7 @@ function _database() {
|
|
|
20
13
|
}
|
|
21
14
|
class ExpressionField extends _database().Field {
|
|
22
15
|
get dataType() {
|
|
23
|
-
return
|
|
16
|
+
return _database().DataTypes.TEXT;
|
|
24
17
|
}
|
|
25
18
|
}
|
|
26
19
|
exports.ExpressionField = ExpressionField;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Plugin from '..';
|
|
2
|
-
import ExecutionModel from '../
|
|
3
|
-
|
|
4
|
-
export declare type CustomFunction = (this: {
|
|
2
|
+
import type { ExecutionModel, FlowNodeModel } from '../types';
|
|
3
|
+
export type CustomFunction = (this: {
|
|
5
4
|
execution: ExecutionModel;
|
|
6
5
|
node?: FlowNodeModel;
|
|
7
6
|
}) => any;
|
package/lib/server/index.d.ts
CHANGED
package/lib/server/index.js
CHANGED
|
@@ -40,4 +40,16 @@ Object.keys(_constants).forEach(function (key) {
|
|
|
40
40
|
var _triggers = require("./triggers");
|
|
41
41
|
var _Processor = _interopRequireDefault(require("./Processor"));
|
|
42
42
|
var _Plugin = _interopRequireDefault(require("./Plugin"));
|
|
43
|
+
var _types = require("./types");
|
|
44
|
+
Object.keys(_types).forEach(function (key) {
|
|
45
|
+
if (key === "default" || key === "__esModule") return;
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
47
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
48
|
+
Object.defineProperty(exports, key, {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _types[key];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
43
55
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function
|
|
8
|
-
const data = require("
|
|
9
|
-
|
|
7
|
+
function _database() {
|
|
8
|
+
const data = require("@nocobase/database");
|
|
9
|
+
_database = function _database() {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
@@ -41,14 +41,14 @@ var _default = {
|
|
|
41
41
|
const database = node.constructor.database;
|
|
42
42
|
const repo = associated ? database.getRepository(`${association === null || association === void 0 ? void 0 : association.associatedCollection}.${association.name}`, processor.getParsedValue(association === null || association === void 0 ? void 0 : association.associatedKey)) : database.getRepository(collection);
|
|
43
43
|
if (!options.dataType && aggregator === 'avg') {
|
|
44
|
-
options.dataType =
|
|
44
|
+
options.dataType = _database().DataTypes.DOUBLE;
|
|
45
45
|
}
|
|
46
46
|
const result = yield repo.aggregate(_objectSpread(_objectSpread({}, options), {}, {
|
|
47
47
|
method: aggregators[aggregator],
|
|
48
48
|
transaction: processor.transaction
|
|
49
49
|
}));
|
|
50
50
|
return {
|
|
51
|
-
result: options.dataType ===
|
|
51
|
+
result: options.dataType === _database().DataTypes.DOUBLE ? Number(result) : result,
|
|
52
52
|
status: _constants.JOB_STATUS.RESOLVED
|
|
53
53
|
};
|
|
54
54
|
})();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Registry } from '@nocobase/utils';
|
|
2
2
|
import { Instruction } from '.';
|
|
3
|
-
|
|
3
|
+
type Comparer = (a: any, b: any) => boolean;
|
|
4
|
+
export declare const calculators: Registry<Comparer>;
|
|
4
5
|
declare const _default: Instruction;
|
|
5
6
|
export default _default;
|
|
@@ -6,9 +6,9 @@ export default class implements Instruction {
|
|
|
6
6
|
protected plugin: Plugin;
|
|
7
7
|
timers: Map<number, NodeJS.Timeout>;
|
|
8
8
|
constructor(plugin: Plugin);
|
|
9
|
-
load()
|
|
10
|
-
unload()
|
|
11
|
-
schedule(job: any
|
|
9
|
+
load: () => Promise<void>;
|
|
10
|
+
unload: () => void;
|
|
11
|
+
schedule(job: any): void;
|
|
12
12
|
trigger(job: any): Promise<void>;
|
|
13
13
|
run: (node: any, prevJob: any, processor: Processor) => Promise<any>;
|
|
14
14
|
resume: (node: any, prevJob: any, processor: Processor) => Promise<any>;
|