@nocobase/plugin-workflow 0.9.0-alpha.2 → 0.9.1-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/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/lib/client/AddButton.d.ts +1 -1
- package/lib/client/AddButton.js +7 -2
- package/lib/client/Branch.d.ts +1 -1
- package/lib/client/ExecutionCanvas.js +5 -10
- package/lib/client/WorkflowCanvas.js +11 -40
- 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 +21 -25
- 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 +40 -6
- package/lib/client/nodes/calculation.js +171 -19
- package/lib/client/nodes/condition.d.ts +67 -0
- package/lib/client/nodes/condition.js +287 -27
- package/lib/client/nodes/create.d.ts +8 -6
- package/lib/client/nodes/create.js +27 -33
- package/lib/client/nodes/delay.d.ts +2 -0
- package/lib/client/nodes/delay.js +8 -4
- package/lib/client/nodes/destroy.d.ts +2 -2
- package/lib/client/nodes/destroy.js +2 -2
- package/lib/client/nodes/index.d.ts +10 -2
- package/lib/client/nodes/index.js +73 -27
- package/lib/client/nodes/manual/AssigneesSelect.d.ts +6 -0
- package/lib/client/nodes/manual/AssigneesSelect.js +64 -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 +64 -0
- package/lib/client/nodes/manual/index.js +146 -0
- package/lib/client/nodes/parallel.d.ts +11 -5
- package/lib/client/nodes/parallel.js +22 -34
- package/lib/client/nodes/query.d.ts +9 -14
- package/lib/client/nodes/query.js +38 -44
- package/lib/client/nodes/request.d.ts +75 -33
- package/lib/client/nodes/request.js +124 -63
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +2 -2
- package/lib/client/schemas/collection.js +1 -1
- package/lib/client/schemas/executions.js +1 -1
- package/lib/client/schemas/workflows.js +1 -1
- package/lib/client/style.js +0 -4
- package/lib/client/triggers/collection.d.ts +7 -3
- package/lib/client/triggers/collection.js +39 -48
- package/lib/client/triggers/index.d.ts +5 -2
- package/lib/client/triggers/index.js +34 -12
- package/lib/client/triggers/schedule/index.d.ts +7 -5
- package/lib/client/triggers/schedule/index.js +38 -79
- 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
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
|
|
8
|
-
function _path() {
|
|
9
|
-
const data = _interopRequireDefault(require("path"));
|
|
10
|
-
|
|
11
|
-
_path = function _path() {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function _utils() {
|
|
19
|
-
const data = require("@nocobase/utils");
|
|
20
|
-
|
|
21
|
-
_utils = function _utils() {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var _actions = require("./actions");
|
|
29
|
-
|
|
30
|
-
var _constants = require("../../constants");
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
|
-
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); } }
|
|
35
|
-
|
|
36
|
-
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); }); }; }
|
|
37
|
-
|
|
38
|
-
// NOTE: for single record mode (mode: 0/null)
|
|
39
|
-
function middleware(_x, _x2) {
|
|
40
|
-
return _middleware.apply(this, arguments);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function _middleware() {
|
|
44
|
-
_middleware = _asyncToGenerator(function* (context, next) {
|
|
45
|
-
const job = context.body,
|
|
46
|
-
state = context.state,
|
|
47
|
-
action = context.action;
|
|
48
|
-
const _job$node$config = job.node.config,
|
|
49
|
-
assignees = _job$node$config.assignees,
|
|
50
|
-
mode = _job$node$config.mode; // NOTE: skip to no user implementation
|
|
51
|
-
|
|
52
|
-
if (!assignees) {
|
|
53
|
-
return next();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!state.currentUser) {
|
|
57
|
-
return context.throw(401);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!assignees.includes(state.currentUser.id)) {
|
|
61
|
-
return context.throw(404);
|
|
62
|
-
} // NOTE: multiple record mode could not use jobs:submit action
|
|
63
|
-
// should use users_jobs:submit/:id instead
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (mode) {
|
|
67
|
-
return context.throw(400);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
yield next();
|
|
71
|
-
const data = {
|
|
72
|
-
userId: context.state.currentUser.id,
|
|
73
|
-
jobId: job.id,
|
|
74
|
-
nodeId: job.nodeId,
|
|
75
|
-
executionId: job.executionId,
|
|
76
|
-
workflowId: job.execution.workflowId,
|
|
77
|
-
status: job.status,
|
|
78
|
-
result: job.result
|
|
79
|
-
}; // NOTE: update users job after main job is done
|
|
80
|
-
|
|
81
|
-
const UserJobModel = context.db.getModel('users_jobs');
|
|
82
|
-
let userJob = yield UserJobModel.findOne({
|
|
83
|
-
where: {
|
|
84
|
-
userId: context.state.currentUser.id,
|
|
85
|
-
jobId: job.id
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
if (userJob) {
|
|
90
|
-
yield userJob.update(data);
|
|
91
|
-
} else {
|
|
92
|
-
userJob = yield UserJobModel.create(data);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
return _middleware.apply(this, arguments);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function run(_x3, _x4, _x5) {
|
|
99
|
-
return _run.apply(this, arguments);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function _run() {
|
|
103
|
-
_run = _asyncToGenerator(function* (node, prevJob, processor) {
|
|
104
|
-
var _prevJob$id;
|
|
105
|
-
|
|
106
|
-
const _node$config = node.config,
|
|
107
|
-
assignees = _node$config.assignees,
|
|
108
|
-
mode = _node$config.mode;
|
|
109
|
-
|
|
110
|
-
if (!assignees) {
|
|
111
|
-
const plugin = processor.options.plugin;
|
|
112
|
-
const origin = plugin.instructions.get('prompt');
|
|
113
|
-
return origin.constructor.prototype.run.call(this, node, prevJob, processor);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const job = yield processor.saveJob({
|
|
117
|
-
status: _constants.JOB_STATUS.PENDING,
|
|
118
|
-
result: mode ? [] : null,
|
|
119
|
-
nodeId: node.id,
|
|
120
|
-
upstreamId: (_prevJob$id = prevJob === null || prevJob === void 0 ? void 0 : prevJob.id) !== null && _prevJob$id !== void 0 ? _prevJob$id : null
|
|
121
|
-
}); // NOTE: batch create users jobs
|
|
122
|
-
|
|
123
|
-
const UserJobModel = processor.options.plugin.db.getModel('users_jobs');
|
|
124
|
-
yield UserJobModel.bulkCreate(assignees.map(userId => ({
|
|
125
|
-
userId,
|
|
126
|
-
jobId: job.id,
|
|
127
|
-
nodeId: node.id,
|
|
128
|
-
executionId: job.executionId,
|
|
129
|
-
workflowId: node.workflowId,
|
|
130
|
-
status: _constants.JOB_STATUS.PENDING
|
|
131
|
-
})), {
|
|
132
|
-
transaction: processor.transaction
|
|
133
|
-
});
|
|
134
|
-
return job;
|
|
135
|
-
});
|
|
136
|
-
return _run.apply(this, arguments);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const PROMPT_ASSIGNED_MODE = {
|
|
140
|
-
SINGLE: Symbol('single'),
|
|
141
|
-
ALL: Symbol('all'),
|
|
142
|
-
ANY: Symbol('any'),
|
|
143
|
-
ALL_PERCENTAGE: Symbol('all percentage'),
|
|
144
|
-
ANY_PERCENTAGE: Symbol('any percentage')
|
|
145
|
-
};
|
|
146
|
-
const Modes = {
|
|
147
|
-
[PROMPT_ASSIGNED_MODE.SINGLE]: {
|
|
148
|
-
getStatus(distribution, assignees) {
|
|
149
|
-
const done = distribution.find(item => item.status !== _constants.JOB_STATUS.PENDING && item.count > 0);
|
|
150
|
-
return done ? done.status : null;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
[PROMPT_ASSIGNED_MODE.ALL]: {
|
|
155
|
-
getStatus(distribution, assignees) {
|
|
156
|
-
const resolved = distribution.find(item => item.status === _constants.JOB_STATUS.RESOLVED);
|
|
157
|
-
|
|
158
|
-
if (resolved && resolved.count === assignees.length) {
|
|
159
|
-
return _constants.JOB_STATUS.RESOLVED;
|
|
160
|
-
} // NOTE: `rejected` or `canceled`
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const failed = distribution.find(item => item.status < _constants.JOB_STATUS.PENDING);
|
|
164
|
-
|
|
165
|
-
if (failed && failed.count) {
|
|
166
|
-
return failed.status;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
[PROMPT_ASSIGNED_MODE.ANY]: {
|
|
174
|
-
getStatus(distribution, assignees) {
|
|
175
|
-
const resolved = distribution.find(item => item.status === _constants.JOB_STATUS.RESOLVED);
|
|
176
|
-
|
|
177
|
-
if (resolved && resolved.count) {
|
|
178
|
-
return _constants.JOB_STATUS.RESOLVED;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const failedCount = distribution.reduce((count, item) => item.status < _constants.JOB_STATUS.PENDING ? count + item.count : count, 0); // NOTE: all failures are considered as rejected for now
|
|
182
|
-
|
|
183
|
-
if (failedCount === assignees.length) {
|
|
184
|
-
return _constants.JOB_STATUS.REJECTED;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
function getMode(mode) {
|
|
194
|
-
switch (true) {
|
|
195
|
-
case mode === 1:
|
|
196
|
-
return Modes[PROMPT_ASSIGNED_MODE.ALL];
|
|
197
|
-
|
|
198
|
-
case mode === -1:
|
|
199
|
-
return Modes[PROMPT_ASSIGNED_MODE.ANY];
|
|
200
|
-
|
|
201
|
-
case mode > 0:
|
|
202
|
-
return Modes[PROMPT_ASSIGNED_MODE.ALL_PERCENTAGE];
|
|
203
|
-
|
|
204
|
-
case mode < 0:
|
|
205
|
-
return Modes[PROMPT_ASSIGNED_MODE.ANY_PERCENTAGE];
|
|
206
|
-
|
|
207
|
-
default:
|
|
208
|
-
return Modes[PROMPT_ASSIGNED_MODE.SINGLE];
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function resume(_x6, _x7, _x8) {
|
|
213
|
-
return _resume.apply(this, arguments);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function _resume() {
|
|
217
|
-
_resume = _asyncToGenerator(function* (node, job, processor) {
|
|
218
|
-
var _job$latestUserJob$re, _job$latestUserJob, _getMode$getStatus;
|
|
219
|
-
|
|
220
|
-
// NOTE: check all users jobs related if all done then continue as parallel
|
|
221
|
-
const _node$config2 = node.config,
|
|
222
|
-
assignees = _node$config2.assignees,
|
|
223
|
-
mode = _node$config2.mode;
|
|
224
|
-
|
|
225
|
-
if (!assignees) {
|
|
226
|
-
const plugin = processor.options.plugin;
|
|
227
|
-
const origin = plugin.instructions.get('prompt');
|
|
228
|
-
return origin.constructor.prototype.resume.call(this, node, job, processor);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const UserJobModel = processor.options.plugin.db.getModel('users_jobs');
|
|
232
|
-
const distribution = yield UserJobModel.count({
|
|
233
|
-
where: {
|
|
234
|
-
jobId: job.id
|
|
235
|
-
},
|
|
236
|
-
group: ['status']
|
|
237
|
-
});
|
|
238
|
-
const submitted = distribution.reduce((count, item) => item.status !== _constants.JOB_STATUS.PENDING ? count + item.count : count, 0);
|
|
239
|
-
const result = mode ? (submitted || 0) / assignees.length : (_job$latestUserJob$re = (_job$latestUserJob = job.latestUserJob) === null || _job$latestUserJob === void 0 ? void 0 : _job$latestUserJob.result) !== null && _job$latestUserJob$re !== void 0 ? _job$latestUserJob$re : job.result;
|
|
240
|
-
job.set({
|
|
241
|
-
status: (_getMode$getStatus = getMode(mode).getStatus(distribution, assignees)) !== null && _getMode$getStatus !== void 0 ? _getMode$getStatus : _constants.JOB_STATUS.PENDING,
|
|
242
|
-
result
|
|
243
|
-
});
|
|
244
|
-
return job;
|
|
245
|
-
});
|
|
246
|
-
return _resume.apply(this, arguments);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function _default(_x9) {
|
|
250
|
-
return _ref.apply(this, arguments);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function _ref() {
|
|
254
|
-
_ref = _asyncToGenerator(function* (plugin) {
|
|
255
|
-
const instruction = plugin.instructions.get('prompt');
|
|
256
|
-
instruction.extend({
|
|
257
|
-
run,
|
|
258
|
-
resume
|
|
259
|
-
});
|
|
260
|
-
instruction.use(middleware); // TODO(bug): through table should be load first because primary
|
|
261
|
-
// await plugin.db.import({
|
|
262
|
-
// directory: path.join(__dirname, './collections')
|
|
263
|
-
// });
|
|
264
|
-
|
|
265
|
-
plugin.db.collection((0, _utils().requireModule)(_path().default.join(__dirname, './collections/users_jobs')));
|
|
266
|
-
plugin.db.extendCollection((0, _utils().requireModule)(_path().default.join(__dirname, './collections/users')));
|
|
267
|
-
plugin.db.extendCollection((0, _utils().requireModule)(_path().default.join(__dirname, './collections/jobs')));
|
|
268
|
-
plugin.app.actions({
|
|
269
|
-
'users_jobs:submit': _actions.submit
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
return _ref.apply(this, arguments);
|
|
273
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _assignees = _interopRequireDefault(require("./assignees"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
var _default = [_assignees.default];
|
|
13
|
-
exports.default = _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Context } from '@nocobase/actions';
|
|
2
|
-
import Plugin from '..';
|
|
3
|
-
import { Instruction } from '.';
|
|
4
|
-
export interface PromptConfig {
|
|
5
|
-
fields: [];
|
|
6
|
-
actions: any;
|
|
7
|
-
}
|
|
8
|
-
export default class implements Instruction {
|
|
9
|
-
protected plugin: Plugin;
|
|
10
|
-
middlewares: any[];
|
|
11
|
-
constructor(plugin: Plugin);
|
|
12
|
-
middleware: (context: Context, next: any) => Promise<void>;
|
|
13
|
-
use(middleware: any): void;
|
|
14
|
-
run(node: any, input: any, processor: any): {
|
|
15
|
-
status: number;
|
|
16
|
-
};
|
|
17
|
-
resume(node: any, job: any, processor: any): any;
|
|
18
|
-
extend(options: Instruction): void;
|
|
19
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
function _koaCompose() {
|
|
9
|
-
const data = _interopRequireDefault(require("koa-compose"));
|
|
10
|
-
|
|
11
|
-
_koaCompose = function _koaCompose() {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function _actions() {
|
|
19
|
-
const data = require("@nocobase/actions");
|
|
20
|
-
|
|
21
|
-
_actions = function _actions() {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var _constants = require("../constants");
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
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); } }
|
|
33
|
-
|
|
34
|
-
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); }); }; }
|
|
35
|
-
|
|
36
|
-
function loadJob(_x, _x2) {
|
|
37
|
-
return _loadJob.apply(this, arguments);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _loadJob() {
|
|
41
|
-
_loadJob = _asyncToGenerator(function* (context, next) {
|
|
42
|
-
const _context$action$param = context.action.params,
|
|
43
|
-
filterByTk = _context$action$param.filterByTk,
|
|
44
|
-
values = _context$action$param.values;
|
|
45
|
-
|
|
46
|
-
if (!context.body) {
|
|
47
|
-
const jobRepo = _actions().utils.getRepositoryFromParams(context);
|
|
48
|
-
|
|
49
|
-
const job = yield jobRepo.findOne({
|
|
50
|
-
filterByTk,
|
|
51
|
-
appends: ['node', 'execution'],
|
|
52
|
-
context
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
if (!filterByTk || !job) {
|
|
56
|
-
return context.throw(404);
|
|
57
|
-
} // cache
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
context.body = job;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const _context$body$node = context.body.node,
|
|
64
|
-
type = _context$body$node.type,
|
|
65
|
-
config = _context$body$node.config;
|
|
66
|
-
|
|
67
|
-
if (type === 'prompt' && config.actions && !config.actions[values.status]) {
|
|
68
|
-
return context.throw(400);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
yield next();
|
|
72
|
-
});
|
|
73
|
-
return _loadJob.apply(this, arguments);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
class _default {
|
|
77
|
-
constructor(plugin) {
|
|
78
|
-
var _this = this;
|
|
79
|
-
|
|
80
|
-
this.plugin = void 0;
|
|
81
|
-
this.middlewares = [];
|
|
82
|
-
|
|
83
|
-
this.middleware = /*#__PURE__*/function () {
|
|
84
|
-
var _ref = _asyncToGenerator(function* (context, next) {
|
|
85
|
-
const _context$action = context.action,
|
|
86
|
-
actionName = _context$action.actionName,
|
|
87
|
-
resourceName = _context$action.resourceName;
|
|
88
|
-
|
|
89
|
-
if (actionName === 'submit' && resourceName === 'jobs' // && this.middlewares.length
|
|
90
|
-
) {
|
|
91
|
-
return (0, _koaCompose().default)([loadJob, ..._this.middlewares])(context, next);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
yield next();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
return function (_x3, _x4) {
|
|
98
|
-
return _ref.apply(this, arguments);
|
|
99
|
-
};
|
|
100
|
-
}();
|
|
101
|
-
|
|
102
|
-
this.plugin = plugin;
|
|
103
|
-
plugin.app.resourcer.use(this.middleware);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
use(middleware) {
|
|
107
|
-
this.middlewares.push(middleware);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
run(node, input, processor) {
|
|
111
|
-
return {
|
|
112
|
-
status: _constants.JOB_STATUS.PENDING
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
resume(node, job, processor) {
|
|
117
|
-
if (!node.config.actions) {
|
|
118
|
-
job.set('status', _constants.JOB_STATUS.RESOLVED);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return job;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
extend(options) {
|
|
125
|
-
Object.assign(this, options);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
exports.default = _default;
|
|
131
|
-
;
|
|
File without changes
|
/package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.d.ts
RENAMED
|
File without changes
|
/package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.js
RENAMED
|
File without changes
|
|
File without changes
|