@nocobase/plugin-workflow 0.7.0-alpha.83 → 0.7.1-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/Plugin.d.ts +18 -0
- package/lib/Plugin.js +285 -0
- package/lib/Processor.d.ts +40 -0
- package/lib/Processor.js +440 -0
- package/lib/actions/workflows.d.ts +1 -2
- package/lib/actions/workflows.js +13 -87
- package/lib/calculators/index.d.ts +2 -2
- package/lib/calculators/index.js +4 -4
- package/lib/collections/executions.js +7 -15
- package/lib/collections/jobs.js +7 -26
- package/lib/collections/workflows.d.ts +1 -2
- package/lib/collections/workflows.js +67 -67
- package/lib/index.d.ts +4 -3
- package/lib/index.js +24 -10
- package/lib/instructions/calculation.d.ts +1 -1
- package/lib/instructions/calculation.js +4 -6
- package/lib/instructions/condition.d.ts +2 -2
- package/lib/instructions/condition.js +15 -19
- package/lib/instructions/create.d.ts +1 -1
- package/lib/instructions/create.js +8 -12
- package/lib/instructions/delay.d.ts +14 -0
- package/lib/instructions/delay.js +138 -0
- package/lib/instructions/destroy.d.ts +1 -1
- package/lib/instructions/destroy.js +8 -12
- package/lib/instructions/index.d.ts +11 -8
- package/lib/instructions/index.js +43 -13
- package/lib/instructions/parallel.d.ts +3 -3
- package/lib/instructions/parallel.js +15 -19
- package/lib/instructions/prompt.d.ts +2 -2
- package/lib/instructions/prompt.js +2 -2
- package/lib/instructions/query.d.ts +2 -1
- package/lib/instructions/query.js +9 -13
- package/lib/instructions/update.d.ts +2 -2
- package/lib/instructions/update.js +10 -14
- package/lib/models/Execution.d.ts +2 -33
- package/lib/models/Execution.js +2 -397
- package/lib/models/Workflow.d.ts +2 -2
- package/lib/models/Workflow.js +1 -81
- package/lib/triggers/collection.d.ts +2 -6
- package/lib/triggers/collection.js +62 -27
- package/lib/triggers/index.d.ts +11 -4
- package/lib/triggers/index.js +52 -5
- package/lib/triggers/schedule.d.ts +4 -7
- package/lib/triggers/schedule.js +205 -135
- package/package.json +8 -9
- package/lib/server.d.ts +0 -10
- package/lib/server.js +0 -124
package/lib/server.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
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 _server() {
|
|
19
|
-
const data = require("@nocobase/server");
|
|
20
|
-
|
|
21
|
-
_server = function _server() {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var _Workflow = _interopRequireDefault(require("./models/Workflow"));
|
|
29
|
-
|
|
30
|
-
var _Execution = _interopRequireDefault(require("./models/Execution"));
|
|
31
|
-
|
|
32
|
-
var _actions = _interopRequireDefault(require("./actions"));
|
|
33
|
-
|
|
34
|
-
var _triggers = _interopRequireDefault(require("./triggers"));
|
|
35
|
-
|
|
36
|
-
function _utils() {
|
|
37
|
-
const data = require("@nocobase/utils");
|
|
38
|
-
|
|
39
|
-
_utils = function _utils() {
|
|
40
|
-
return data;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return data;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
47
|
-
|
|
48
|
-
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; }
|
|
49
|
-
|
|
50
|
-
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; }
|
|
51
|
-
|
|
52
|
-
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; }
|
|
53
|
-
|
|
54
|
-
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); } }
|
|
55
|
-
|
|
56
|
-
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); }); }; }
|
|
57
|
-
|
|
58
|
-
class _default extends _server().Plugin {
|
|
59
|
-
constructor(...args) {
|
|
60
|
-
super(...args);
|
|
61
|
-
this.triggers = new (_utils().Registry)();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
getName() {
|
|
65
|
-
return this.getPackageName(__dirname);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
load(options = {}) {
|
|
69
|
-
var _this = this;
|
|
70
|
-
|
|
71
|
-
return _asyncToGenerator(function* () {
|
|
72
|
-
const db = _this.app.db;
|
|
73
|
-
db.registerModels({
|
|
74
|
-
WorkflowModel: _Workflow.default,
|
|
75
|
-
ExecutionModel: _Execution.default
|
|
76
|
-
});
|
|
77
|
-
yield db.import({
|
|
78
|
-
directory: _path().default.resolve(__dirname, 'collections')
|
|
79
|
-
});
|
|
80
|
-
(0, _actions.default)(_this);
|
|
81
|
-
(0, _triggers.default)(_this); // [Life Cycle]:
|
|
82
|
-
// * load all workflows in db
|
|
83
|
-
// * add all hooks for enabled workflows
|
|
84
|
-
// * add hooks for create/update[enabled]/delete workflow to add/remove specific hooks
|
|
85
|
-
|
|
86
|
-
_this.app.on('beforeStart', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
87
|
-
const collection = db.getCollection('workflows');
|
|
88
|
-
const workflows = yield collection.repository.find({
|
|
89
|
-
filter: {
|
|
90
|
-
enabled: true
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
workflows.forEach(workflow => {
|
|
94
|
-
_this.toggle(workflow);
|
|
95
|
-
});
|
|
96
|
-
db.on('workflows.afterSave', model => _this.toggle(model));
|
|
97
|
-
db.on('workflows.afterDestroy', model => _this.toggle(model, false));
|
|
98
|
-
})); // [Life Cycle]: initialize all necessary seed data
|
|
99
|
-
// this.app.on('db.init', async () => {});
|
|
100
|
-
|
|
101
|
-
})();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
toggle(workflow, enable) {
|
|
105
|
-
const type = workflow.get('type');
|
|
106
|
-
const trigger = this.triggers.get(type);
|
|
107
|
-
|
|
108
|
-
if (typeof enable !== 'undefined' ? enable : workflow.get('enabled')) {
|
|
109
|
-
// NOTE: remove previous listener if config updated
|
|
110
|
-
const prev = workflow.previous();
|
|
111
|
-
|
|
112
|
-
if (prev.config) {
|
|
113
|
-
trigger.off(_objectSpread(_objectSpread({}, workflow.get()), prev));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
trigger.on(workflow);
|
|
117
|
-
} else {
|
|
118
|
-
trigger.off(workflow);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
exports.default = _default;
|