@nocobase/plugin-workflow 0.7.0-alpha.34 → 0.7.0-alpha.57
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/actions/index.js +31 -32
- package/lib/actions/nodes.js +310 -182
- package/lib/actions/workflows.js +260 -157
- package/lib/calculators/index.js +142 -90
- package/lib/collections/executions.js +40 -43
- package/lib/collections/flow_nodes.js +60 -65
- package/lib/collections/jobs.js +45 -47
- package/lib/collections/workflows.js +78 -87
- package/lib/constants.js +22 -17
- package/lib/index.js +71 -22
- package/lib/instructions/calculation.js +34 -29
- package/lib/instructions/condition.js +94 -87
- package/lib/instructions/create.js +43 -26
- package/lib/instructions/destroy.js +42 -25
- package/lib/instructions/index.js +46 -25
- package/lib/instructions/parallel.js +99 -84
- package/lib/instructions/prompt.js +21 -13
- package/lib/instructions/query.js +47 -29
- package/lib/instructions/update.js +44 -25
- package/lib/models/Execution.js +401 -248
- package/lib/models/FlowNode.js +18 -5
- package/lib/models/Job.js +18 -5
- package/lib/models/Workflow.js +132 -88
- package/lib/server.js +93 -66
- package/lib/triggers/collection.js +113 -51
- package/lib/triggers/index.js +25 -11
- package/package.json +7 -12
- package/esm/actions/index.d.ts +0 -1
- package/esm/actions/index.js +0 -14
- package/esm/actions/index.js.map +0 -1
- package/esm/actions/nodes.d.ts +0 -4
- package/esm/actions/nodes.js +0 -187
- package/esm/actions/nodes.js.map +0 -1
- package/esm/actions/workflows.d.ts +0 -3
- package/esm/actions/workflows.js +0 -163
- package/esm/actions/workflows.js.map +0 -1
- package/esm/calculators/index.d.ts +0 -38
- package/esm/calculators/index.js +0 -128
- package/esm/calculators/index.js.map +0 -1
- package/esm/collections/executions.d.ts +0 -3
- package/esm/collections/executions.js +0 -43
- package/esm/collections/executions.js.map +0 -1
- package/esm/collections/flow_nodes.d.ts +0 -3
- package/esm/collections/flow_nodes.js +0 -65
- package/esm/collections/flow_nodes.js.map +0 -1
- package/esm/collections/jobs.d.ts +0 -3
- package/esm/collections/jobs.js +0 -47
- package/esm/collections/jobs.js.map +0 -1
- package/esm/collections/workflows.d.ts +0 -3
- package/esm/collections/workflows.js +0 -87
- package/esm/collections/workflows.js.map +0 -1
- package/esm/constants.d.ts +0 -17
- package/esm/constants.js +0 -18
- package/esm/constants.js.map +0 -1
- package/esm/index.d.ts +0 -5
- package/esm/index.js +0 -6
- package/esm/index.js.map +0 -1
- package/esm/instructions/calculation.d.ts +0 -8
- package/esm/instructions/calculation.js +0 -55
- package/esm/instructions/calculation.js.map +0 -1
- package/esm/instructions/condition.d.ts +0 -5
- package/esm/instructions/condition.js +0 -99
- package/esm/instructions/condition.js.map +0 -1
- package/esm/instructions/create.d.ts +0 -8
- package/esm/instructions/create.js +0 -26
- package/esm/instructions/create.js.map +0 -1
- package/esm/instructions/destroy.d.ts +0 -8
- package/esm/instructions/destroy.js +0 -25
- package/esm/instructions/destroy.js.map +0 -1
- package/esm/instructions/index.d.ts +0 -15
- package/esm/instructions/index.js +0 -20
- package/esm/instructions/index.js.map +0 -1
- package/esm/instructions/parallel.d.ts +0 -13
- package/esm/instructions/parallel.js +0 -88
- package/esm/instructions/parallel.js.map +0 -1
- package/esm/instructions/prompt.d.ts +0 -7
- package/esm/instructions/prompt.js +0 -13
- package/esm/instructions/prompt.js.map +0 -1
- package/esm/instructions/query.d.ts +0 -8
- package/esm/instructions/query.js +0 -29
- package/esm/instructions/query.js.map +0 -1
- package/esm/instructions/update.d.ts +0 -9
- package/esm/instructions/update.js +0 -25
- package/esm/instructions/update.js.map +0 -1
- package/esm/models/Execution.d.ts +0 -51
- package/esm/models/Execution.js +0 -256
- package/esm/models/Execution.js.map +0 -1
- package/esm/models/FlowNode.d.ts +0 -17
- package/esm/models/FlowNode.js +0 -4
- package/esm/models/FlowNode.js.map +0 -1
- package/esm/models/Job.d.ts +0 -15
- package/esm/models/Job.js +0 -4
- package/esm/models/Job.js.map +0 -1
- package/esm/models/Workflow.d.ts +0 -29
- package/esm/models/Workflow.js +0 -88
- package/esm/models/Workflow.js.map +0 -1
- package/esm/server.d.ts +0 -5
- package/esm/server.js +0 -62
- package/esm/server.js.map +0 -1
- package/esm/triggers/collection.d.ts +0 -12
- package/esm/triggers/collection.js +0 -61
- package/esm/triggers/collection.js.map +0 -1
- package/esm/triggers/index.d.ts +0 -9
- package/esm/triggers/index.js +0 -6
- package/esm/triggers/index.js.map +0 -1
- package/lib/actions/index.js.map +0 -1
- package/lib/actions/nodes.js.map +0 -1
- package/lib/actions/workflows.js.map +0 -1
- package/lib/calculators/index.js.map +0 -1
- package/lib/collections/executions.js.map +0 -1
- package/lib/collections/flow_nodes.js.map +0 -1
- package/lib/collections/jobs.js.map +0 -1
- package/lib/collections/workflows.js.map +0 -1
- package/lib/constants.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/instructions/calculation.js.map +0 -1
- package/lib/instructions/condition.js.map +0 -1
- package/lib/instructions/create.js.map +0 -1
- package/lib/instructions/destroy.js.map +0 -1
- package/lib/instructions/index.js.map +0 -1
- package/lib/instructions/parallel.js.map +0 -1
- package/lib/instructions/prompt.js.map +0 -1
- package/lib/instructions/query.js.map +0 -1
- package/lib/instructions/update.js.map +0 -1
- package/lib/models/Execution.js.map +0 -1
- package/lib/models/FlowNode.js.map +0 -1
- package/lib/models/Job.js.map +0 -1
- package/lib/models/Workflow.js.map +0 -1
- package/lib/server.js.map +0 -1
- package/lib/triggers/collection.js.map +0 -1
- package/lib/triggers/index.js.map +0 -1
- package/tsconfig.build.json +0 -9
|
@@ -1,27 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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); } }
|
|
17
|
+
|
|
18
|
+
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); }); }; }
|
|
19
|
+
|
|
20
|
+
var _default = {
|
|
21
|
+
run(input, execution) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
|
|
24
|
+
return _asyncToGenerator(function* () {
|
|
25
|
+
const _this$config = _this.config,
|
|
26
|
+
collection = _this$config.collection,
|
|
27
|
+
_this$config$params = _this$config.params,
|
|
28
|
+
params = _this$config$params === void 0 ? {} : _this$config$params;
|
|
29
|
+
|
|
30
|
+
const repo = _this.constructor.database.getRepository(collection);
|
|
31
|
+
|
|
32
|
+
const options = execution.getParsedValue(params);
|
|
33
|
+
const result = yield repo.destroy(_objectSpread(_objectSpread({}, options), {}, {
|
|
34
|
+
transaction: execution.tx
|
|
35
|
+
}));
|
|
36
|
+
return {
|
|
37
|
+
result,
|
|
38
|
+
status: _constants.JOB_STATUS.RESOLVED
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
}
|
|
42
|
+
|
|
10
43
|
};
|
|
11
|
-
|
|
12
|
-
const constants_1 = require("../constants");
|
|
13
|
-
exports.default = {
|
|
14
|
-
run(input, execution) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { collection, params = {} } = this.config;
|
|
17
|
-
const repo = this.constructor.database.getRepository(collection);
|
|
18
|
-
const options = execution.getParsedValue(params);
|
|
19
|
-
const result = yield repo.destroy(Object.assign(Object.assign({}, options), { transaction: execution.tx }));
|
|
20
|
-
return {
|
|
21
|
-
result,
|
|
22
|
-
status: constants_1.JOB_STATUS.RESOLVED
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=destroy.js.map
|
|
44
|
+
exports.default = _default;
|
|
@@ -1,26 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.instructions = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.instructions = exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _utils() {
|
|
9
|
+
const data = require("@nocobase/utils");
|
|
10
|
+
|
|
11
|
+
_utils = function _utils() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var _prompt = _interopRequireDefault(require("./prompt"));
|
|
19
|
+
|
|
20
|
+
var _calculation = _interopRequireDefault(require("./calculation"));
|
|
21
|
+
|
|
22
|
+
var _condition = _interopRequireDefault(require("./condition"));
|
|
23
|
+
|
|
24
|
+
var _parallel = _interopRequireDefault(require("./parallel"));
|
|
25
|
+
|
|
26
|
+
var _query = _interopRequireDefault(require("./query"));
|
|
27
|
+
|
|
28
|
+
var _create = _interopRequireDefault(require("./create"));
|
|
29
|
+
|
|
30
|
+
var _update = _interopRequireDefault(require("./update"));
|
|
31
|
+
|
|
32
|
+
var _destroy = _interopRequireDefault(require("./destroy"));
|
|
33
|
+
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
+
|
|
36
|
+
const instructions = new (_utils().Registry)();
|
|
37
|
+
exports.instructions = instructions;
|
|
38
|
+
instructions.register('prompt', _prompt.default);
|
|
39
|
+
instructions.register('calculation', _calculation.default);
|
|
40
|
+
instructions.register('condition', _condition.default);
|
|
41
|
+
instructions.register('parallel', _parallel.default);
|
|
42
|
+
instructions.register('query', _query.default);
|
|
43
|
+
instructions.register('create', _create.default);
|
|
44
|
+
instructions.register('update', _update.default);
|
|
45
|
+
instructions.register('destroy', _destroy.default);
|
|
46
|
+
var _default = instructions;
|
|
47
|
+
exports.default = _default;
|
|
@@ -1,91 +1,106 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.PARALLEL_MODE = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
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); } }
|
|
11
|
+
|
|
12
|
+
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); }); }; }
|
|
13
|
+
|
|
14
|
+
const PARALLEL_MODE = {
|
|
15
|
+
ALL: 'all',
|
|
16
|
+
ANY: 'any',
|
|
17
|
+
RACE: 'race'
|
|
18
18
|
};
|
|
19
|
+
exports.PARALLEL_MODE = PARALLEL_MODE;
|
|
19
20
|
const StatusGetters = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return constants_1.JOB_STATUS.PENDING;
|
|
28
|
-
},
|
|
29
|
-
[exports.PARALLEL_MODE.ANY](result) {
|
|
30
|
-
return result.some(j => j && j.status === constants_1.JOB_STATUS.RESOLVED)
|
|
31
|
-
? constants_1.JOB_STATUS.RESOLVED
|
|
32
|
-
: (result.some(j => j && j.status === constants_1.JOB_STATUS.PENDING)
|
|
33
|
-
? constants_1.JOB_STATUS.PENDING
|
|
34
|
-
: constants_1.JOB_STATUS.REJECTED);
|
|
35
|
-
},
|
|
36
|
-
[exports.PARALLEL_MODE.RACE](result) {
|
|
37
|
-
return result.some(j => j && j.status === constants_1.JOB_STATUS.RESOLVED)
|
|
38
|
-
? constants_1.JOB_STATUS.RESOLVED
|
|
39
|
-
: (result.some(j => j && j.status === constants_1.JOB_STATUS.REJECTED)
|
|
40
|
-
? constants_1.JOB_STATUS.REJECTED
|
|
41
|
-
: constants_1.JOB_STATUS.PENDING);
|
|
21
|
+
[PARALLEL_MODE.ALL](result) {
|
|
22
|
+
if (result.some(j => j && j.status === _constants.JOB_STATUS.REJECTED)) {
|
|
23
|
+
return _constants.JOB_STATUS.REJECTED;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (result.every(j => j && j.status === _constants.JOB_STATUS.RESOLVED)) {
|
|
27
|
+
return _constants.JOB_STATUS.RESOLVED;
|
|
42
28
|
}
|
|
29
|
+
|
|
30
|
+
return _constants.JOB_STATUS.PENDING;
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
[PARALLEL_MODE.ANY](result) {
|
|
34
|
+
return result.some(j => j && j.status === _constants.JOB_STATUS.RESOLVED) ? _constants.JOB_STATUS.RESOLVED : result.some(j => j && j.status === _constants.JOB_STATUS.PENDING) ? _constants.JOB_STATUS.PENDING : _constants.JOB_STATUS.REJECTED;
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
[PARALLEL_MODE.RACE](result) {
|
|
38
|
+
return result.some(j => j && j.status === _constants.JOB_STATUS.RESOLVED) ? _constants.JOB_STATUS.RESOLVED : result.some(j => j && j.status === _constants.JOB_STATUS.REJECTED) ? _constants.JOB_STATUS.REJECTED : _constants.JOB_STATUS.PENDING;
|
|
39
|
+
}
|
|
40
|
+
|
|
43
41
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
42
|
+
var _default = {
|
|
43
|
+
run(prevJob, execution) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
|
|
46
|
+
return _asyncToGenerator(function* () {
|
|
47
|
+
var _prevJob$id;
|
|
48
|
+
|
|
49
|
+
const branches = execution.nodes.filter(item => item.upstream === _this && item.branchIndex !== null).sort((a, b) => a.branchIndex - b.branchIndex);
|
|
50
|
+
const job = yield execution.saveJob({
|
|
51
|
+
status: _constants.JOB_STATUS.PENDING,
|
|
52
|
+
result: Array(branches.length).fill(null),
|
|
53
|
+
nodeId: _this.id,
|
|
54
|
+
upstreamId: (_prevJob$id = prevJob === null || prevJob === void 0 ? void 0 : prevJob.id) !== null && _prevJob$id !== void 0 ? _prevJob$id : null
|
|
55
|
+
}); // NOTE:
|
|
56
|
+
// use `reduce` but not `Promise.all` here to avoid racing manupulating db.
|
|
57
|
+
// for users, this is almost equivalent to `Promise.all`,
|
|
58
|
+
// because of the delay is not significant sensible.
|
|
59
|
+
// another better aspect of this is, it could handle sequenced branches in future.
|
|
60
|
+
|
|
61
|
+
yield branches.reduce((promise, branch) => promise.then(() => execution.run(branch, job)), Promise.resolve());
|
|
62
|
+
return execution.end(_this, job);
|
|
63
|
+
})();
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
resume(branchJob, execution) {
|
|
67
|
+
var _this2 = this;
|
|
68
|
+
|
|
69
|
+
return _asyncToGenerator(function* () {
|
|
70
|
+
const job = execution.findBranchParentJob(branchJob, _this2);
|
|
71
|
+
const result = job.result,
|
|
72
|
+
status = job.status; // if parallel has been done (resolved / rejected), do not care newly executed branch jobs.
|
|
73
|
+
|
|
74
|
+
if (status !== _constants.JOB_STATUS.PENDING) {
|
|
75
|
+
return null;
|
|
76
|
+
} // find the index of the node which start the branch
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const jobNode = execution.nodesMap.get(branchJob.nodeId);
|
|
80
|
+
|
|
81
|
+
const _execution$findBranch = execution.findBranchStartNode(jobNode),
|
|
82
|
+
branchIndex = _execution$findBranch.branchIndex;
|
|
83
|
+
|
|
84
|
+
const _ref = _this2.config || {},
|
|
85
|
+
_ref$mode = _ref.mode,
|
|
86
|
+
mode = _ref$mode === void 0 ? PARALLEL_MODE.ALL : _ref$mode;
|
|
87
|
+
|
|
88
|
+
const newResult = [...result.slice(0, branchIndex), branchJob.get(), ...result.slice(branchIndex + 1)];
|
|
89
|
+
job.set({
|
|
90
|
+
result: newResult,
|
|
91
|
+
status: StatusGetters[mode](newResult)
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
if (job.status === _constants.JOB_STATUS.PENDING) {
|
|
95
|
+
yield job.save({
|
|
96
|
+
transaction: execution.tx
|
|
64
97
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
// find the index of the node which start the branch
|
|
75
|
-
const jobNode = execution.nodesMap.get(branchJob.nodeId);
|
|
76
|
-
const { branchIndex } = execution.findBranchStartNode(jobNode);
|
|
77
|
-
const { mode = exports.PARALLEL_MODE.ALL } = this.config || {};
|
|
78
|
-
const newResult = [...result.slice(0, branchIndex), branchJob.get(), ...result.slice(branchIndex + 1)];
|
|
79
|
-
job.set({
|
|
80
|
-
result: newResult,
|
|
81
|
-
status: StatusGetters[mode](newResult)
|
|
82
|
-
});
|
|
83
|
-
if (job.status === constants_1.JOB_STATUS.PENDING) {
|
|
84
|
-
yield job.save({ transaction: execution.tx });
|
|
85
|
-
return execution.end(this, job);
|
|
86
|
-
}
|
|
87
|
-
return job;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
98
|
+
return execution.end(_this2, job);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return job;
|
|
102
|
+
})();
|
|
103
|
+
}
|
|
104
|
+
|
|
90
105
|
};
|
|
91
|
-
|
|
106
|
+
exports.default = _default;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
var _default = {
|
|
11
|
+
run(input, execution) {
|
|
12
|
+
return {
|
|
13
|
+
status: _constants.JOB_STATUS.PENDING
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
resume(job, execution) {
|
|
18
|
+
job.set('status', _constants.JOB_STATUS.RESOLVED);
|
|
19
|
+
return job;
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
};
|
|
15
|
-
|
|
23
|
+
exports.default = _default;
|
|
@@ -1,31 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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); } }
|
|
17
|
+
|
|
18
|
+
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); }); }; }
|
|
19
|
+
|
|
20
|
+
var _default = {
|
|
21
|
+
run(input, execution) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
|
|
24
|
+
return _asyncToGenerator(function* () {
|
|
25
|
+
const _this$config = _this.config,
|
|
26
|
+
collection = _this$config.collection,
|
|
27
|
+
multiple = _this$config.multiple,
|
|
28
|
+
_this$config$params = _this$config.params,
|
|
29
|
+
params = _this$config$params === void 0 ? {} : _this$config$params;
|
|
30
|
+
|
|
31
|
+
const repo = _this.constructor.database.getRepository(collection);
|
|
32
|
+
|
|
33
|
+
const options = execution.getParsedValue(params);
|
|
34
|
+
const result = yield (multiple ? repo.find : repo.findOne).call(repo, _objectSpread(_objectSpread({}, options), {}, {
|
|
35
|
+
// NOTE: `raw` to avoid getting undefined value from Proxied model instance (#380)
|
|
36
|
+
// e.g. Object.prototype.hasOwnProperty.call(result, 'id') // false
|
|
37
|
+
// so the properties can not be get by json-templates(object-path)
|
|
38
|
+
raw: true,
|
|
39
|
+
transaction: execution.tx
|
|
40
|
+
}));
|
|
41
|
+
return {
|
|
42
|
+
result,
|
|
43
|
+
status: _constants.JOB_STATUS.RESOLVED
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
}
|
|
47
|
+
|
|
10
48
|
};
|
|
11
|
-
|
|
12
|
-
const constants_1 = require("../constants");
|
|
13
|
-
exports.default = {
|
|
14
|
-
run(input, execution) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { collection, multiple, params = {} } = this.config;
|
|
17
|
-
const repo = this.constructor.database.getRepository(collection);
|
|
18
|
-
const options = execution.getParsedValue(params);
|
|
19
|
-
const result = yield (multiple ? repo.find : repo.findOne).call(repo, Object.assign(Object.assign({}, options), {
|
|
20
|
-
// NOTE: `raw` to avoid getting undefined value from Proxied model instance (#380)
|
|
21
|
-
// e.g. Object.prototype.hasOwnProperty.call(result, 'id') // false
|
|
22
|
-
// so the properties can not be get by json-templates(object-path)
|
|
23
|
-
raw: true, transaction: execution.tx }));
|
|
24
|
-
return {
|
|
25
|
-
result,
|
|
26
|
-
status: constants_1.JOB_STATUS.RESOLVED
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=query.js.map
|
|
49
|
+
exports.default = _default;
|
|
@@ -1,27 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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); } }
|
|
17
|
+
|
|
18
|
+
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); }); }; }
|
|
19
|
+
|
|
20
|
+
var _default = {
|
|
21
|
+
run(input, execution) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
|
|
24
|
+
return _asyncToGenerator(function* () {
|
|
25
|
+
const _this$config = _this.config,
|
|
26
|
+
collection = _this$config.collection,
|
|
27
|
+
_this$config$multiple = _this$config.multiple,
|
|
28
|
+
multiple = _this$config$multiple === void 0 ? false : _this$config$multiple,
|
|
29
|
+
_this$config$params = _this$config.params,
|
|
30
|
+
params = _this$config$params === void 0 ? {} : _this$config$params;
|
|
31
|
+
|
|
32
|
+
const repo = _this.constructor.database.getRepository(collection);
|
|
33
|
+
|
|
34
|
+
const options = execution.getParsedValue(params);
|
|
35
|
+
const result = yield repo.update(_objectSpread(_objectSpread({}, options), {}, {
|
|
36
|
+
transaction: execution.tx
|
|
37
|
+
}));
|
|
38
|
+
return {
|
|
39
|
+
result: multiple ? result : result[0] || null,
|
|
40
|
+
status: _constants.JOB_STATUS.RESOLVED
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
}
|
|
44
|
+
|
|
10
45
|
};
|
|
11
|
-
|
|
12
|
-
const constants_1 = require("../constants");
|
|
13
|
-
exports.default = {
|
|
14
|
-
run(input, execution) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { collection, multiple = false, params = {} } = this.config;
|
|
17
|
-
const repo = this.constructor.database.getRepository(collection);
|
|
18
|
-
const options = execution.getParsedValue(params);
|
|
19
|
-
const result = yield repo.update(Object.assign(Object.assign({}, options), { transaction: execution.tx }));
|
|
20
|
-
return {
|
|
21
|
-
result: multiple ? result : (result[0] || null),
|
|
22
|
-
status: constants_1.JOB_STATUS.RESOLVED
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=update.js.map
|
|
46
|
+
exports.default = _default;
|