@nocobase/plugin-workflow 0.7.0-alpha.82 → 0.7.1-alpha.4
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 +60 -38
- package/lib/triggers/index.d.ts +11 -4
- package/lib/triggers/index.js +53 -3
- package/lib/triggers/schedule.d.ts +38 -0
- package/lib/triggers/schedule.js +672 -0
- package/package.json +8 -7
- package/lib/server.d.ts +0 -10
- package/lib/server.js +0 -117
package/lib/server.js
DELETED
|
@@ -1,117 +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 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); } }
|
|
49
|
-
|
|
50
|
-
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); }); }; }
|
|
51
|
-
|
|
52
|
-
class _default extends _server().Plugin {
|
|
53
|
-
constructor(...args) {
|
|
54
|
-
super(...args);
|
|
55
|
-
this.triggers = new (_utils().Registry)();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getName() {
|
|
59
|
-
return this.getPackageName(__dirname);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
load(options = {}) {
|
|
63
|
-
var _this = this;
|
|
64
|
-
|
|
65
|
-
return _asyncToGenerator(function* () {
|
|
66
|
-
const db = _this.app.db;
|
|
67
|
-
db.registerModels({
|
|
68
|
-
WorkflowModel: _Workflow.default,
|
|
69
|
-
ExecutionModel: _Execution.default
|
|
70
|
-
});
|
|
71
|
-
yield db.import({
|
|
72
|
-
directory: _path().default.resolve(__dirname, 'collections')
|
|
73
|
-
});
|
|
74
|
-
(0, _actions.default)(_this);
|
|
75
|
-
(0, _triggers.default)(_this); // [Life Cycle]:
|
|
76
|
-
// * load all workflows in db
|
|
77
|
-
// * add all hooks for enabled workflows
|
|
78
|
-
// * add hooks for create/update[enabled]/delete workflow to add/remove specific hooks
|
|
79
|
-
|
|
80
|
-
_this.app.on('beforeStart', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
81
|
-
const collection = db.getCollection('workflows');
|
|
82
|
-
const workflows = yield collection.repository.find({
|
|
83
|
-
filter: {
|
|
84
|
-
enabled: true
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
workflows.forEach(workflow => {
|
|
88
|
-
_this.toggle(workflow);
|
|
89
|
-
});
|
|
90
|
-
db.on('workflows.afterCreate', model => _this.toggle(model));
|
|
91
|
-
db.on('workflows.afterUpdate', model => _this.toggle(model));
|
|
92
|
-
db.on('workflows.afterDestroy', model => _this.toggle(model, false));
|
|
93
|
-
})); // [Life Cycle]: initialize all necessary seed data
|
|
94
|
-
// this.app.on('db.init', async () => {});
|
|
95
|
-
|
|
96
|
-
})();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
toggle(workflow, enable) {
|
|
100
|
-
var _this2 = this;
|
|
101
|
-
|
|
102
|
-
return _asyncToGenerator(function* () {
|
|
103
|
-
const type = workflow.get('type');
|
|
104
|
-
|
|
105
|
-
const trigger = _this2.triggers.get(type);
|
|
106
|
-
|
|
107
|
-
if (typeof enable !== 'undefined' ? enable : workflow.get('enabled')) {
|
|
108
|
-
yield trigger.on(workflow);
|
|
109
|
-
} else {
|
|
110
|
-
yield trigger.off(workflow);
|
|
111
|
-
}
|
|
112
|
-
})();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
exports.default = _default;
|