@nocobase/plugin-workflow 0.7.7-alpha.1 → 0.8.0-alpha.5
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/lib/client/AddButton.d.ts +7 -0
- package/lib/client/AddButton.js +173 -0
- package/lib/client/Branch.d.ts +7 -0
- package/lib/client/Branch.js +61 -0
- package/lib/client/ExecutionCanvas.d.ts +2 -0
- package/lib/client/ExecutionCanvas.js +214 -0
- package/lib/client/ExecutionLink.d.ts +1 -0
- package/lib/client/ExecutionLink.js +66 -0
- package/lib/client/ExecutionPage.d.ts +1 -0
- package/lib/client/ExecutionPage.js +92 -0
- package/lib/client/FlowContext.d.ts +3 -0
- package/lib/client/FlowContext.js +29 -0
- package/lib/client/WorkflowCanvas.d.ts +0 -13
- package/lib/client/WorkflowCanvas.js +33 -142
- package/lib/client/WorkflowLink.js +1 -1
- package/lib/client/WorkflowPage.js +1 -1
- package/lib/client/WorkflowProvider.js +30 -10
- package/lib/client/WorkflowShortcut.d.ts +1 -0
- package/lib/client/WorkflowShortcut.js +36 -52
- package/lib/client/calculators.js +3 -3
- package/lib/client/constants.d.ts +30 -0
- package/lib/client/constants.js +95 -0
- package/lib/client/nodes/condition.js +6 -4
- package/lib/client/nodes/create.js +2 -2
- package/lib/client/nodes/index.d.ts +2 -1
- package/lib/client/nodes/index.js +168 -46
- package/lib/client/nodes/parallel.js +6 -4
- package/lib/client/nodes/query.js +2 -2
- package/lib/client/nodes/update.js +2 -2
- package/lib/client/schemas/executions.d.ts +22 -0
- package/lib/client/schemas/executions.js +75 -40
- package/lib/client/schemas/workflows.js +7 -5
- package/lib/client/style.js +44 -3
- package/lib/client/triggers/collection.js +2 -2
- package/lib/client/triggers/index.d.ts +3 -1
- package/lib/client/triggers/index.js +96 -13
- package/lib/client/triggers/schedule/index.js +2 -2
- package/lib/server/Plugin.d.ts +4 -5
- package/lib/server/Plugin.js +12 -16
- package/lib/server/actions/jobs.js +1 -1
- package/lib/server/actions/workflows.d.ts +1 -0
- package/lib/server/actions/workflows.js +37 -7
- package/lib/server/extensions/assignees/actions.js +1 -1
- package/package.json +9 -8
|
@@ -34,7 +34,8 @@ const collection = {
|
|
|
34
34
|
title
|
|
35
35
|
}]) => ({
|
|
36
36
|
value,
|
|
37
|
-
label: title
|
|
37
|
+
label: title,
|
|
38
|
+
color: 'gold'
|
|
38
39
|
})),
|
|
39
40
|
required: true
|
|
40
41
|
}
|
|
@@ -56,7 +57,8 @@ const collection = {
|
|
|
56
57
|
type: 'string',
|
|
57
58
|
enum: [{
|
|
58
59
|
label: '{{t("On")}}',
|
|
59
|
-
value: true
|
|
60
|
+
value: true,
|
|
61
|
+
color: '#52c41a'
|
|
60
62
|
}, {
|
|
61
63
|
label: '{{t("Off")}}',
|
|
62
64
|
value: false
|
|
@@ -68,7 +70,7 @@ const collection = {
|
|
|
68
70
|
}]
|
|
69
71
|
};
|
|
70
72
|
const workflowSchema = {
|
|
71
|
-
type: '
|
|
73
|
+
type: 'void',
|
|
72
74
|
properties: {
|
|
73
75
|
provider: {
|
|
74
76
|
type: 'void',
|
|
@@ -239,7 +241,7 @@ const workflowSchema = {
|
|
|
239
241
|
},
|
|
240
242
|
executions: {
|
|
241
243
|
type: 'void',
|
|
242
|
-
title: '{{t("Execution
|
|
244
|
+
title: '{{t("Execution history")}}',
|
|
243
245
|
'x-component': 'Action.Link',
|
|
244
246
|
'x-component-props': {
|
|
245
247
|
type: 'primary'
|
|
@@ -247,7 +249,7 @@ const workflowSchema = {
|
|
|
247
249
|
properties: {
|
|
248
250
|
drawer: {
|
|
249
251
|
type: 'void',
|
|
250
|
-
title: '{{t("Execution
|
|
252
|
+
title: '{{t("Execution history")}}',
|
|
251
253
|
'x-component': 'Action.Drawer',
|
|
252
254
|
properties: _executions.executionSchema
|
|
253
255
|
}
|
package/lib/client/style.js
CHANGED
|
@@ -30,7 +30,13 @@ const workflowPageClass = (0, _css().css)`
|
|
|
30
30
|
header{
|
|
31
31
|
display: flex;
|
|
32
32
|
align-items: center;
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
> *:not(:last-child) {
|
|
35
|
+
&:after{
|
|
36
|
+
content: ">";
|
|
37
|
+
margin: 0 .5em;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
aside{
|
|
@@ -53,8 +59,20 @@ exports.workflowPageClass = workflowPageClass;
|
|
|
53
59
|
const workflowVersionDropdownClass = (0, _css().css)`
|
|
54
60
|
.ant-dropdown-menu-item{
|
|
55
61
|
|
|
62
|
+
strong{
|
|
63
|
+
font-weight: normal;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&.enabled{
|
|
67
|
+
strong{
|
|
68
|
+
font-weight: bold;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
56
72
|
&.unexecuted{
|
|
57
|
-
|
|
73
|
+
strong{
|
|
74
|
+
font-style: italic;
|
|
75
|
+
}
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
.ant-dropdown-menu-title-content{
|
|
@@ -163,10 +181,14 @@ const nodeCardClass = (0, _css().css)`
|
|
|
163
181
|
padding: 1em;
|
|
164
182
|
box-shadow: 0 .25em .5em rgba(0, 0, 0, .1);
|
|
165
183
|
|
|
166
|
-
.workflow-node-remove-button
|
|
184
|
+
.workflow-node-remove-button,
|
|
185
|
+
.workflow-node-job-button{
|
|
167
186
|
position: absolute;
|
|
168
187
|
right: -.5em;
|
|
169
188
|
top: -.5em;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.workflow-node-remove-button{
|
|
170
192
|
color: #999;
|
|
171
193
|
opacity: 0;
|
|
172
194
|
transition: opacity .3s ease;
|
|
@@ -180,6 +202,23 @@ const nodeCardClass = (0, _css().css)`
|
|
|
180
202
|
}
|
|
181
203
|
}
|
|
182
204
|
|
|
205
|
+
.workflow-node-job-button{
|
|
206
|
+
display: flex;
|
|
207
|
+
top: 0;
|
|
208
|
+
right: 0;
|
|
209
|
+
width: 1.25rem;
|
|
210
|
+
height: 1.25rem;
|
|
211
|
+
min-width: 1.25rem;
|
|
212
|
+
justify-content: center;
|
|
213
|
+
align-items: center;
|
|
214
|
+
font-size: 0.8em;
|
|
215
|
+
color: #fff;
|
|
216
|
+
|
|
217
|
+
&[type="button"]{
|
|
218
|
+
border: none;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
183
222
|
&:hover{
|
|
184
223
|
.workflow-node-remove-button{
|
|
185
224
|
opacity: 1;
|
|
@@ -196,6 +235,8 @@ const nodeMetaClass = (0, _css().css)`
|
|
|
196
235
|
`;
|
|
197
236
|
exports.nodeMetaClass = nodeMetaClass;
|
|
198
237
|
const nodeTitleClass = (0, _css().css)`
|
|
238
|
+
display: flex;
|
|
239
|
+
align-items: center;
|
|
199
240
|
font-weight: normal;
|
|
200
241
|
|
|
201
242
|
.workflow-node-id{
|
|
@@ -45,7 +45,7 @@ function _client() {
|
|
|
45
45
|
return data;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var _FlowContext = require("../FlowContext");
|
|
49
49
|
|
|
50
50
|
var _collection = require("../schemas/collection");
|
|
51
51
|
|
|
@@ -203,7 +203,7 @@ var _default = {
|
|
|
203
203
|
options = props.options,
|
|
204
204
|
_onChange = props.onChange;
|
|
205
205
|
|
|
206
|
-
const _useFlowContext = (0,
|
|
206
|
+
const _useFlowContext = (0, _FlowContext.useFlowContext)(),
|
|
207
207
|
workflow = _useFlowContext.workflow;
|
|
208
208
|
|
|
209
209
|
const value = options === null || options === void 0 ? void 0 : (_options$path = options.path) === null || _options$path === void 0 ? void 0 : _options$path.replace(/^data\./, '');
|
|
@@ -23,4 +23,6 @@ export interface Trigger {
|
|
|
23
23
|
getter?(node: any): React.ReactElement;
|
|
24
24
|
}
|
|
25
25
|
export declare const triggers: Registry<Trigger>;
|
|
26
|
-
export declare const TriggerConfig: (
|
|
26
|
+
export declare const TriggerConfig: ({ workflow }: {
|
|
27
|
+
workflow: any;
|
|
28
|
+
}) => JSX.Element;
|
|
@@ -65,6 +65,16 @@ function _reactI18next() {
|
|
|
65
65
|
return data;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
function _icons() {
|
|
69
|
+
const data = require("@ant-design/icons");
|
|
70
|
+
|
|
71
|
+
_icons = function _icons() {
|
|
72
|
+
return data;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
|
|
68
78
|
function _client2() {
|
|
69
79
|
const data = require("@nocobase/client");
|
|
70
80
|
|
|
@@ -77,7 +87,7 @@ function _client2() {
|
|
|
77
87
|
|
|
78
88
|
var _style = require("../style");
|
|
79
89
|
|
|
80
|
-
var
|
|
90
|
+
var _FlowContext = require("../FlowContext");
|
|
81
91
|
|
|
82
92
|
var _collection = _interopRequireDefault(require("./collection"));
|
|
83
93
|
|
|
@@ -90,14 +100,16 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
90
100
|
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); }); }; }
|
|
91
101
|
|
|
92
102
|
function useUpdateConfigAction() {
|
|
103
|
+
var _useFlowContext;
|
|
104
|
+
|
|
93
105
|
const _useTranslation = (0, _reactI18next().useTranslation)(),
|
|
94
106
|
t = _useTranslation.t;
|
|
95
107
|
|
|
96
108
|
const form = (0, _react().useForm)();
|
|
97
109
|
const api = (0, _client2().useAPIClient)();
|
|
98
110
|
|
|
99
|
-
const _useFlowContext = (0,
|
|
100
|
-
workflow =
|
|
111
|
+
const _ref = (_useFlowContext = (0, _FlowContext.useFlowContext)()) !== null && _useFlowContext !== void 0 ? _useFlowContext : {},
|
|
112
|
+
workflow = _ref.workflow;
|
|
101
113
|
|
|
102
114
|
const ctx = (0, _client2().useActionContext)();
|
|
103
115
|
|
|
@@ -133,23 +145,92 @@ exports.triggers = triggers;
|
|
|
133
145
|
triggers.register(_collection.default.type, _collection.default);
|
|
134
146
|
triggers.register(_schedule.default.type, _schedule.default);
|
|
135
147
|
|
|
136
|
-
|
|
148
|
+
function TriggerExecution() {
|
|
149
|
+
const compile = (0, _client2().useCompile)();
|
|
150
|
+
|
|
151
|
+
const _useFlowContext2 = (0, _FlowContext.useFlowContext)(),
|
|
152
|
+
workflow = _useFlowContext2.workflow,
|
|
153
|
+
execution = _useFlowContext2.execution;
|
|
154
|
+
|
|
155
|
+
if (!execution) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const trigger = triggers.get(workflow.type);
|
|
160
|
+
return _react2().default.createElement(_client2().SchemaComponent, {
|
|
161
|
+
schema: {
|
|
162
|
+
type: 'void',
|
|
163
|
+
properties: {
|
|
164
|
+
trigger: {
|
|
165
|
+
type: 'void',
|
|
166
|
+
'x-component': 'Action',
|
|
167
|
+
'x-component-props': {
|
|
168
|
+
title: _react2().default.createElement(_icons().InfoOutlined, null),
|
|
169
|
+
shape: 'circle',
|
|
170
|
+
className: 'workflow-node-job-button',
|
|
171
|
+
type: 'primary'
|
|
172
|
+
},
|
|
173
|
+
properties: {
|
|
174
|
+
[execution.id]: {
|
|
175
|
+
type: 'void',
|
|
176
|
+
'x-decorator': 'Form',
|
|
177
|
+
'x-decorator-props': {
|
|
178
|
+
initialValue: execution
|
|
179
|
+
},
|
|
180
|
+
'x-component': 'Action.Modal',
|
|
181
|
+
title: _react2().default.createElement("div", {
|
|
182
|
+
className: (0, _css().cx)(_style.nodeTitleClass)
|
|
183
|
+
}, _react2().default.createElement(_antd().Tag, null, compile(trigger.title)), _react2().default.createElement("strong", null, workflow.title), _react2().default.createElement("span", {
|
|
184
|
+
className: "workflow-node-id"
|
|
185
|
+
}, "#", execution.id)),
|
|
186
|
+
properties: {
|
|
187
|
+
createdAt: {
|
|
188
|
+
type: 'string',
|
|
189
|
+
title: '{{t("Triggered at")}}',
|
|
190
|
+
'x-decorator': 'FormItem',
|
|
191
|
+
'x-component': 'DatePicker',
|
|
192
|
+
'x-component-props': {
|
|
193
|
+
showTime: true
|
|
194
|
+
},
|
|
195
|
+
'x-read-pretty': true
|
|
196
|
+
},
|
|
197
|
+
context: {
|
|
198
|
+
type: 'object',
|
|
199
|
+
title: '{{t("Trigger context")}}',
|
|
200
|
+
'x-decorator': 'FormItem',
|
|
201
|
+
'x-component': 'Input.JSON',
|
|
202
|
+
'x-component-props': {
|
|
203
|
+
className: (0, _css().css)`
|
|
204
|
+
padding: 1em;
|
|
205
|
+
background-color: #eee;
|
|
206
|
+
`
|
|
207
|
+
},
|
|
208
|
+
'x-read-pretty': true
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const TriggerConfig = ({
|
|
220
|
+
workflow
|
|
221
|
+
}) => {
|
|
137
222
|
const _useTranslation2 = (0, _reactI18next().useTranslation)(),
|
|
138
223
|
t = _useTranslation2.t;
|
|
139
224
|
|
|
140
225
|
const compile = (0, _client2().useCompile)();
|
|
141
226
|
|
|
142
|
-
|
|
143
|
-
data = _useResourceActionCon2.data;
|
|
144
|
-
|
|
145
|
-
if (!data) {
|
|
227
|
+
if (!workflow || !workflow.type) {
|
|
146
228
|
return null;
|
|
147
229
|
}
|
|
148
230
|
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
executed = _data$data.executed;
|
|
231
|
+
const type = workflow.type,
|
|
232
|
+
config = workflow.config,
|
|
233
|
+
executed = workflow.executed;
|
|
153
234
|
|
|
154
235
|
const _triggers$get = triggers.get(type),
|
|
155
236
|
title = _triggers$get.title,
|
|
@@ -161,11 +242,13 @@ const TriggerConfig = () => {
|
|
|
161
242
|
const titleText = `${t('Trigger')}: ${compile(title)}`;
|
|
162
243
|
return _react2().default.createElement("div", {
|
|
163
244
|
className: (0, _css().cx)(_style.nodeCardClass)
|
|
245
|
+
}, _react2().default.createElement("div", {
|
|
246
|
+
className: (0, _css().cx)(_style.nodeHeaderClass)
|
|
164
247
|
}, _react2().default.createElement("div", {
|
|
165
248
|
className: (0, _css().cx)(_style.nodeMetaClass)
|
|
166
249
|
}, _react2().default.createElement(_antd().Tag, {
|
|
167
250
|
color: "gold"
|
|
168
|
-
}, t('Trigger'))), _react2().default.createElement("h4", null, compile(title)), _react2().default.createElement(_client2().SchemaComponent, {
|
|
251
|
+
}, t('Trigger'))), _react2().default.createElement("h4", null, compile(title)), _react2().default.createElement(TriggerExecution, null)), _react2().default.createElement(_client2().SchemaComponent, {
|
|
169
252
|
schema: {
|
|
170
253
|
type: 'void',
|
|
171
254
|
title: detailText,
|
|
@@ -47,7 +47,7 @@ function _client() {
|
|
|
47
47
|
|
|
48
48
|
var _ScheduleConfig = require("./ScheduleConfig");
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _FlowContext = require("../../FlowContext");
|
|
51
51
|
|
|
52
52
|
var _calculators = require("../../calculators");
|
|
53
53
|
|
|
@@ -93,7 +93,7 @@ var _default = {
|
|
|
93
93
|
_useCollectionManager2 = _useCollectionManager.collections,
|
|
94
94
|
collections = _useCollectionManager2 === void 0 ? [] : _useCollectionManager2;
|
|
95
95
|
|
|
96
|
-
const _useFlowContext = (0,
|
|
96
|
+
const _useFlowContext = (0, _FlowContext.useFlowContext)(),
|
|
97
97
|
workflow = _useFlowContext.workflow;
|
|
98
98
|
|
|
99
99
|
const collection = (_collections$find = collections.find(item => item.name === workflow.config.collection)) !== null && _collections$find !== void 0 ? _collections$find : {
|
package/lib/server/Plugin.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { Plugin } from '@nocobase/server';
|
|
2
1
|
import { Transactionable } from '@nocobase/database';
|
|
2
|
+
import { Plugin } from '@nocobase/server';
|
|
3
3
|
import { Registry } from '@nocobase/utils';
|
|
4
|
-
import { Trigger } from './triggers';
|
|
5
4
|
import { Instruction } from './instructions';
|
|
6
|
-
import Processor from './Processor';
|
|
7
|
-
import WorkflowModel from './models/Workflow';
|
|
8
5
|
import ExecutionModel from './models/Execution';
|
|
6
|
+
import WorkflowModel from './models/Workflow';
|
|
7
|
+
import Processor from './Processor';
|
|
8
|
+
import { Trigger } from './triggers';
|
|
9
9
|
export default class WorkflowPlugin extends Plugin {
|
|
10
10
|
instructions: Registry<Instruction>;
|
|
11
11
|
triggers: Registry<Trigger>;
|
|
12
12
|
calculators: Registry<Function>;
|
|
13
13
|
extensions: typeof import("./extensions/assignees").default[];
|
|
14
14
|
onBeforeSave: (instance: WorkflowModel, options: any) => Promise<void>;
|
|
15
|
-
getName(): string;
|
|
16
15
|
load(): Promise<void>;
|
|
17
16
|
toggle(workflow: WorkflowModel, enable?: boolean): void;
|
|
18
17
|
trigger(workflow: WorkflowModel, context: Object, options?: Transactionable & {
|
package/lib/server/Plugin.js
CHANGED
|
@@ -15,20 +15,20 @@ function _path() {
|
|
|
15
15
|
return data;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function
|
|
19
|
-
const data = require("@nocobase/
|
|
18
|
+
function _database() {
|
|
19
|
+
const data = require("@nocobase/database");
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
_database = function _database() {
|
|
22
22
|
return data;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
return data;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function
|
|
29
|
-
const data = require("@nocobase/
|
|
28
|
+
function _server() {
|
|
29
|
+
const data = require("@nocobase/server");
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
_server = function _server() {
|
|
32
32
|
return data;
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -47,17 +47,17 @@ function _utils() {
|
|
|
47
47
|
|
|
48
48
|
var _actions = _interopRequireDefault(require("./actions"));
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _calculators = _interopRequireDefault(require("./calculators"));
|
|
51
51
|
|
|
52
|
-
var
|
|
52
|
+
var _constants = require("./constants");
|
|
53
53
|
|
|
54
|
-
var
|
|
54
|
+
var _extensions = _interopRequireDefault(require("./extensions"));
|
|
55
55
|
|
|
56
|
-
var
|
|
56
|
+
var _instructions = _interopRequireDefault(require("./instructions"));
|
|
57
57
|
|
|
58
|
-
var
|
|
58
|
+
var _Processor = _interopRequireDefault(require("./Processor"));
|
|
59
59
|
|
|
60
|
-
var
|
|
60
|
+
var _triggers = _interopRequireDefault(require("./triggers"));
|
|
61
61
|
|
|
62
62
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
63
63
|
|
|
@@ -136,10 +136,6 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
136
136
|
}();
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
getName() {
|
|
140
|
-
return this.getPackageName(__dirname);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
139
|
load() {
|
|
144
140
|
var _this2 = this;
|
|
145
141
|
|
|
@@ -31,7 +31,7 @@ function _submit() {
|
|
|
31
31
|
});
|
|
32
32
|
context.status = 202;
|
|
33
33
|
yield next();
|
|
34
|
-
const plugin = context.app.pm.get('
|
|
34
|
+
const plugin = context.app.pm.get('workflow');
|
|
35
35
|
const processor = plugin.createProcessor(instance.execution); // NOTE: resume the process and no `await` for quick returning
|
|
36
36
|
|
|
37
37
|
processor.resume(instance);
|
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.revision = revision;
|
|
7
|
+
exports.update = update;
|
|
7
8
|
|
|
8
9
|
function _actions() {
|
|
9
|
-
const data = require("@nocobase/actions");
|
|
10
|
+
const data = _interopRequireWildcard(require("@nocobase/actions"));
|
|
10
11
|
|
|
11
12
|
_actions = function _actions() {
|
|
12
13
|
return data;
|
|
@@ -15,6 +16,10 @@ function _actions() {
|
|
|
15
16
|
return data;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
|
+
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
|
|
18
23
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
24
|
|
|
20
25
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -27,20 +32,45 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
27
32
|
|
|
28
33
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
34
|
|
|
30
|
-
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); } }
|
|
31
|
-
|
|
32
|
-
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); }); }; }
|
|
33
|
-
|
|
34
35
|
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
36
|
|
|
36
37
|
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; }
|
|
37
38
|
|
|
38
39
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
39
40
|
|
|
41
|
+
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); } }
|
|
42
|
+
|
|
43
|
+
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); }); }; }
|
|
44
|
+
|
|
40
45
|
function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
41
46
|
|
|
42
47
|
function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(value) { var ret = this.s.return; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, throw: function _throw(value) { var thr = this.s.return; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
|
|
43
48
|
|
|
49
|
+
function update(_x, _x2) {
|
|
50
|
+
return _update.apply(this, arguments);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function _update() {
|
|
54
|
+
_update = _asyncToGenerator(function* (context, next) {
|
|
55
|
+
const repository = _actions().utils.getRepositoryFromParams(context);
|
|
56
|
+
|
|
57
|
+
const _context$action$param = context.action.params,
|
|
58
|
+
filterByTk = _context$action$param.filterByTk,
|
|
59
|
+
values = _context$action$param.values; // only enable/disable
|
|
60
|
+
|
|
61
|
+
if (Object.keys(values).sort().join() !== 'enabled,key') {
|
|
62
|
+
const workflow = yield repository.findById(filterByTk);
|
|
63
|
+
|
|
64
|
+
if (workflow.get('executed')) {
|
|
65
|
+
return context.throw(400, 'executed workflow can not be updated');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return _actions().default.update(context, next);
|
|
70
|
+
});
|
|
71
|
+
return _update.apply(this, arguments);
|
|
72
|
+
}
|
|
73
|
+
|
|
44
74
|
function typeOf(value) {
|
|
45
75
|
if (Array.isArray(value)) {
|
|
46
76
|
return 'array';
|
|
@@ -98,7 +128,7 @@ function migrateConfig(config, oldToNew) {
|
|
|
98
128
|
return migrate(config);
|
|
99
129
|
}
|
|
100
130
|
|
|
101
|
-
function revision(
|
|
131
|
+
function revision(_x3, _x4) {
|
|
102
132
|
return _revision.apply(this, arguments);
|
|
103
133
|
}
|
|
104
134
|
|
|
@@ -218,7 +248,7 @@ function _revision() {
|
|
|
218
248
|
return instance;
|
|
219
249
|
});
|
|
220
250
|
|
|
221
|
-
return function (
|
|
251
|
+
return function (_x5) {
|
|
222
252
|
return _ref.apply(this, arguments);
|
|
223
253
|
};
|
|
224
254
|
}());
|
|
@@ -67,7 +67,7 @@ function _submit() {
|
|
|
67
67
|
context.status = 202;
|
|
68
68
|
yield next();
|
|
69
69
|
instance.job.latestUserJob = instance;
|
|
70
|
-
const plugin = context.app.pm.get('
|
|
70
|
+
const plugin = context.app.pm.get('workflow');
|
|
71
71
|
const processor = plugin.createProcessor(instance.execution); // NOTE: resume the process and no `await` for quick returning
|
|
72
72
|
|
|
73
73
|
processor.resume(instance.job);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-alpha.5",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"licenses": [
|
|
@@ -10,17 +10,18 @@
|
|
|
10
10
|
}
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nocobase/actions": "0.
|
|
14
|
-
"@nocobase/client": "0.
|
|
15
|
-
"@nocobase/database": "0.
|
|
16
|
-
"@nocobase/server": "0.
|
|
17
|
-
"@nocobase/utils": "0.
|
|
13
|
+
"@nocobase/actions": "0.8.0-alpha.5",
|
|
14
|
+
"@nocobase/client": "0.8.0-alpha.5",
|
|
15
|
+
"@nocobase/database": "0.8.0-alpha.5",
|
|
16
|
+
"@nocobase/server": "0.8.0-alpha.5",
|
|
17
|
+
"@nocobase/utils": "0.8.0-alpha.5",
|
|
18
|
+
"classnames": "^2.3.1",
|
|
18
19
|
"cron-parser": "4.4.0",
|
|
19
20
|
"json-templates": "^4.2.0",
|
|
20
21
|
"react-js-cron": "^1.4.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@nocobase/test": "0.
|
|
24
|
+
"@nocobase/test": "0.8.0-alpha.5"
|
|
24
25
|
},
|
|
25
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "335f62b0098089cc43a0488ea5c76136a655f97e"
|
|
26
27
|
}
|