@nocobase/plugin-workflow 0.10.1-alpha.1 → 0.11.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/client.d.ts +2 -3
- package/client.js +1 -30
- package/lib/client/AddButton.js +13 -11
- package/lib/client/Branch.js +10 -8
- package/lib/client/CanvasContent.js +12 -10
- package/lib/client/ExecutionCanvas.js +37 -33
- package/lib/client/ExecutionPage.js +4 -9
- package/lib/client/WorkflowCanvas.js +18 -15
- package/lib/client/WorkflowPage.js +4 -9
- package/lib/client/WorkflowProvider.js +1 -40
- package/lib/client/components/CollectionBlockInitializer.js +3 -3
- package/lib/client/components/CollectionFieldset.d.ts +1 -1
- package/lib/client/components/CollectionFieldset.js +15 -16
- package/lib/client/components/Duration.js +5 -5
- package/lib/client/components/DynamicExpression.d.ts +3 -3
- package/lib/client/components/FieldsSelect.d.ts +1 -1
- package/lib/client/components/FieldsSelect.js +10 -7
- package/lib/client/components/NodeDescription.js +45 -31
- package/lib/client/components/RadioWithTooltip.js +13 -20
- package/lib/client/components/ValueBlock.js +14 -21
- package/lib/client/components/renderEngineReference.js +1 -8
- package/lib/client/index.d.ts +12 -4
- package/lib/client/index.js +78 -15
- package/lib/client/locale/zh-CN.d.ts +5 -1
- package/lib/client/locale/zh-CN.js +6 -2
- package/lib/client/nodes/aggregate.d.ts +8 -3
- package/lib/client/nodes/aggregate.js +5 -4
- package/lib/client/nodes/calculation.d.ts +6 -4
- package/lib/client/nodes/calculation.js +22 -28
- package/lib/client/nodes/condition.d.ts +2 -10
- package/lib/client/nodes/condition.js +19 -37
- package/lib/client/nodes/create.d.ts +5 -6
- package/lib/client/nodes/create.js +1 -3
- package/lib/client/nodes/destroy.d.ts +1 -1
- package/lib/client/nodes/index.d.ts +2 -3
- package/lib/client/nodes/index.js +95 -102
- package/lib/client/nodes/loop.d.ts +1 -1
- package/lib/client/nodes/loop.js +46 -54
- package/lib/client/nodes/manual/FormBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/ModeConfig.js +23 -30
- package/lib/client/nodes/manual/SchemaConfig.d.ts +4 -5
- package/lib/client/nodes/manual/SchemaConfig.js +180 -25
- package/lib/client/nodes/manual/WorkflowTodo.js +95 -110
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -5
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/forms/create.js +8 -1
- package/lib/client/nodes/manual/forms/custom.js +22 -22
- package/lib/client/nodes/manual/forms/update.js +8 -1
- package/lib/client/nodes/manual/index.d.ts +6 -1
- package/lib/client/nodes/manual/index.js +5 -4
- package/lib/client/nodes/parallel.js +23 -20
- package/lib/client/nodes/query.d.ts +3 -5
- package/lib/client/nodes/query.js +1 -3
- package/lib/client/nodes/request.d.ts +2 -2
- package/lib/client/nodes/request.js +7 -7
- package/lib/client/nodes/sql.d.ts +26 -0
- package/lib/client/{triggers/schedule/DateFieldsSelect.js → nodes/sql.js} +37 -46
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +1 -1
- package/lib/client/schemas/collection.d.ts +3 -4
- package/lib/client/schemas/collection.js +11 -17
- package/lib/client/style.d.ts +18 -13
- package/lib/client/style.js +315 -292
- package/lib/client/triggers/collection.d.ts +13 -13
- package/lib/client/triggers/collection.js +5 -1
- package/lib/client/triggers/index.d.ts +3 -4
- package/lib/client/triggers/index.js +51 -53
- package/lib/client/triggers/schedule/EndsByField.js +11 -11
- package/lib/client/triggers/schedule/OnField.js +45 -33
- package/lib/client/triggers/schedule/RepeatField.js +4 -4
- package/lib/client/triggers/schedule/ScheduleConfig.js +24 -31
- package/lib/client/triggers/schedule/index.d.ts +1 -1
- package/lib/client/triggers/schedule/index.js +32 -20
- package/lib/client/variable.d.ts +31 -13
- package/lib/client/variable.js +44 -29
- package/lib/server/Plugin.d.ts +3 -6
- package/lib/server/Plugin.js +15 -12
- package/lib/server/Processor.d.ts +3 -5
- package/lib/server/Processor.js +2 -2
- package/lib/server/actions/nodes.js +7 -7
- package/lib/server/fields/expression-field.d.ts +1 -2
- package/lib/server/fields/expression-field.js +1 -8
- package/lib/server/functions/index.d.ts +2 -3
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +12 -0
- package/lib/server/instructions/aggregate.d.ts +1 -1
- package/lib/server/instructions/aggregate.js +5 -5
- package/lib/server/instructions/condition.d.ts +2 -1
- package/lib/server/instructions/create.d.ts +2 -2
- package/lib/server/instructions/create.js +13 -13
- package/lib/server/instructions/delay.d.ts +3 -3
- package/lib/server/instructions/delay.js +66 -64
- package/lib/server/instructions/destroy.d.ts +1 -1
- package/lib/server/instructions/index.d.ts +5 -5
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/loop.d.ts +1 -2
- package/lib/server/instructions/manual/actions.js +19 -7
- package/lib/server/instructions/manual/forms/create.js +7 -1
- package/lib/server/instructions/manual/forms/index.d.ts +1 -1
- package/lib/server/instructions/manual/forms/update.js +7 -1
- package/lib/server/instructions/manual/index.d.ts +1 -1
- package/lib/server/instructions/parallel.d.ts +1 -2
- package/lib/server/instructions/query.d.ts +1 -1
- package/lib/server/instructions/query.js +8 -1
- package/lib/server/instructions/request.d.ts +3 -3
- package/lib/server/instructions/request.js +5 -2
- package/lib/server/instructions/sql.d.ts +12 -0
- package/lib/server/instructions/sql.js +34 -0
- package/lib/server/instructions/update.d.ts +1 -1
- package/lib/server/migrations/20230221071831-calculation-expression.js +1 -1
- package/lib/server/migrations/20230221121203-condition-calculation.js +1 -1
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +7 -7
- package/lib/server/migrations/20230411034722-manual-multi-form.js +1 -8
- package/lib/server/migrations/20230710115902-manual-action-values.d.ts +4 -0
- package/lib/server/migrations/20230710115902-manual-action-values.js +97 -0
- package/lib/server/triggers/collection.d.ts +1 -1
- package/lib/server/triggers/collection.js +15 -13
- package/lib/server/triggers/index.d.ts +1 -1
- package/lib/server/triggers/schedule.d.ts +1 -1
- package/lib/server/triggers/schedule.js +18 -18
- package/lib/server/{models → types}/Execution.d.ts +2 -3
- package/lib/server/{models → types}/FlowNode.d.ts +1 -2
- package/lib/server/{models → types}/Job.d.ts +1 -2
- package/lib/server/{models → types}/Workflow.d.ts +1 -2
- package/lib/server/types/index.d.ts +4 -0
- package/lib/server/types/index.js +5 -0
- package/lib/server/utils.d.ts +2 -0
- package/lib/server/utils.js +21 -0
- package/package.json +39 -18
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/src/client/AddButton.tsx +111 -0
- package/src/client/Branch.tsx +37 -0
- package/src/client/CanvasContent.tsx +25 -0
- package/src/client/ExecutionCanvas.tsx +166 -0
- package/src/client/ExecutionLink.tsx +16 -0
- package/src/client/ExecutionPage.tsx +45 -0
- package/src/client/ExecutionResourceProvider.tsx +21 -0
- package/src/client/FlowContext.ts +7 -0
- package/src/client/WorkflowCanvas.tsx +221 -0
- package/src/client/WorkflowLink.tsx +16 -0
- package/src/client/WorkflowPage.tsx +52 -0
- package/src/client/WorkflowProvider.tsx +84 -0
- package/src/client/components/CollectionBlockInitializer.tsx +71 -0
- package/src/client/components/CollectionFieldset.tsx +160 -0
- package/src/client/components/Duration.tsx +45 -0
- package/src/client/components/DynamicExpression.tsx +53 -0
- package/src/client/components/FieldsSelect.tsx +32 -0
- package/src/client/components/FilterDynamicComponent.tsx +15 -0
- package/src/client/components/NodeDescription.tsx +51 -0
- package/src/client/components/NullRender.tsx +3 -0
- package/src/client/components/OpenDrawer.tsx +24 -0
- package/src/client/components/RadioWithTooltip.tsx +38 -0
- package/src/client/components/ValueBlock.tsx +67 -0
- package/src/client/components/renderEngineReference.tsx +30 -0
- package/src/client/constants.tsx +91 -0
- package/src/client/index.tsx +51 -0
- package/src/client/interfaces/expression.tsx +25 -0
- package/src/client/locale/en-US.ts +136 -0
- package/src/client/locale/es-ES.ts +129 -0
- package/src/client/locale/index.ts +18 -0
- package/src/client/locale/ja-JP.ts +90 -0
- package/src/client/locale/pt-BR.ts +136 -0
- package/src/client/locale/ru-RU.ts +90 -0
- package/src/client/locale/tr-TR.ts +90 -0
- package/src/client/locale/zh-CN.ts +248 -0
- package/src/client/nodes/aggregate.tsx +327 -0
- package/src/client/nodes/calculation.tsx +216 -0
- package/src/client/nodes/condition.tsx +463 -0
- package/src/client/nodes/create.tsx +85 -0
- package/src/client/nodes/delay.tsx +37 -0
- package/src/client/nodes/destroy.tsx +34 -0
- package/src/client/nodes/index.tsx +485 -0
- package/src/client/nodes/loop.tsx +144 -0
- package/src/client/nodes/manual/AssigneesSelect.tsx +33 -0
- package/src/client/nodes/manual/DetailsBlockProvider.tsx +80 -0
- package/src/client/nodes/manual/FormBlockInitializer.tsx +69 -0
- package/src/client/nodes/manual/FormBlockProvider.tsx +75 -0
- package/src/client/nodes/manual/ModeConfig.tsx +84 -0
- package/src/client/nodes/manual/SchemaConfig.tsx +509 -0
- package/src/client/nodes/manual/WorkflowTodo.tsx +607 -0
- package/src/client/nodes/manual/WorkflowTodoBlockInitializer.tsx +28 -0
- package/src/client/nodes/manual/forms/create.tsx +92 -0
- package/src/client/nodes/manual/forms/custom.tsx +392 -0
- package/src/client/nodes/manual/forms/update.tsx +134 -0
- package/src/client/nodes/manual/index.tsx +162 -0
- package/src/client/nodes/manual/utils.ts +28 -0
- package/src/client/nodes/parallel.tsx +138 -0
- package/src/client/nodes/query.tsx +88 -0
- package/src/client/nodes/request.tsx +185 -0
- package/src/client/nodes/sql.tsx +37 -0
- package/src/client/nodes/update.tsx +99 -0
- package/src/client/schemas/collection.ts +75 -0
- package/src/client/schemas/executions.tsx +169 -0
- package/src/client/schemas/workflows.ts +364 -0
- package/src/client/style.tsx +347 -0
- package/src/client/triggers/collection.tsx +190 -0
- package/src/client/triggers/index.tsx +311 -0
- package/src/client/triggers/schedule/EndsByField.tsx +40 -0
- package/src/client/triggers/schedule/OnField.tsx +64 -0
- package/src/client/triggers/schedule/RepeatField.tsx +116 -0
- package/src/client/triggers/schedule/ScheduleConfig.tsx +227 -0
- package/src/client/triggers/schedule/constants.ts +4 -0
- package/src/client/triggers/schedule/index.tsx +78 -0
- package/src/client/triggers/schedule/locale/Cron.zh-CN.ts +79 -0
- package/src/client/utils.ts +36 -0
- package/src/client/variable.tsx +318 -0
- package/src/index.ts +1 -0
- package/src/server/Plugin.ts +355 -0
- package/src/server/Processor.ts +354 -0
- package/src/server/__tests__/Plugin.test.ts +398 -0
- package/src/server/__tests__/Processor.test.ts +474 -0
- package/src/server/__tests__/actions/workflows.test.ts +419 -0
- package/src/server/__tests__/collections/categories.ts +27 -0
- package/src/server/__tests__/collections/comments.ts +24 -0
- package/src/server/__tests__/collections/posts.ts +42 -0
- package/src/server/__tests__/collections/replies.ts +9 -0
- package/src/server/__tests__/collections/tags.ts +15 -0
- package/src/server/__tests__/index.ts +89 -0
- package/src/server/__tests__/instructions/aggregate.test.ts +294 -0
- package/src/server/__tests__/instructions/calculation.test.ts +265 -0
- package/src/server/__tests__/instructions/condition.test.ts +335 -0
- package/src/server/__tests__/instructions/create.test.ts +129 -0
- package/src/server/__tests__/instructions/delay.test.ts +182 -0
- package/src/server/__tests__/instructions/destroy.test.ts +58 -0
- package/src/server/__tests__/instructions/loop.test.ts +331 -0
- package/src/server/__tests__/instructions/manual.test.ts +1173 -0
- package/src/server/__tests__/instructions/parallel.test.ts +445 -0
- package/src/server/__tests__/instructions/query.test.ts +359 -0
- package/src/server/__tests__/instructions/request.test.ts +247 -0
- package/src/server/__tests__/instructions/sql.test.ts +162 -0
- package/src/server/__tests__/instructions/update.test.ts +189 -0
- package/src/server/__tests__/triggers/collection.test.ts +333 -0
- package/src/server/__tests__/triggers/schedule.test.ts +369 -0
- package/src/server/actions/index.ts +25 -0
- package/src/server/actions/nodes.ts +214 -0
- package/src/server/actions/workflows.ts +178 -0
- package/src/server/collections/executions.ts +35 -0
- package/src/server/collections/flow_nodes.ts +54 -0
- package/src/server/collections/jobs.ts +31 -0
- package/src/server/collections/workflows.ts +88 -0
- package/src/server/constants.ts +26 -0
- package/src/server/fields/expression-field.ts +11 -0
- package/src/server/fields/index.ts +7 -0
- package/src/server/functions/index.ts +16 -0
- package/src/server/index.ts +6 -0
- package/src/server/instructions/aggregate.ts +42 -0
- package/src/server/instructions/calculation.ts +41 -0
- package/src/server/instructions/condition.ts +172 -0
- package/src/server/instructions/create.ts +39 -0
- package/src/server/instructions/delay.ts +105 -0
- package/src/server/instructions/destroy.ts +23 -0
- package/src/server/instructions/index.ts +64 -0
- package/src/server/instructions/loop.ts +99 -0
- package/src/server/instructions/manual/actions.ts +91 -0
- package/src/server/instructions/manual/collecions/jobs.ts +17 -0
- package/src/server/instructions/manual/collecions/users.ts +15 -0
- package/src/server/instructions/manual/collecions/users_jobs.ts +50 -0
- package/src/server/instructions/manual/forms/create.ts +23 -0
- package/src/server/instructions/manual/forms/index.ts +12 -0
- package/src/server/instructions/manual/forms/update.ts +23 -0
- package/src/server/instructions/manual/index.ts +184 -0
- package/src/server/instructions/parallel.ts +121 -0
- package/src/server/instructions/query.ts +42 -0
- package/src/server/instructions/request.ts +88 -0
- package/src/server/instructions/sql.ts +25 -0
- package/src/server/instructions/update.ts +24 -0
- package/src/server/migrations/20221129153547-calculation-variables.ts +64 -0
- package/src/server/migrations/20230221032941-change-request-body-type.ts +76 -0
- package/src/server/migrations/20230221071831-calculation-expression.ts +102 -0
- package/src/server/migrations/20230221121203-condition-calculation.ts +82 -0
- package/src/server/migrations/20230221162902-jsonb-to-json.ts +51 -0
- package/src/server/migrations/20230411034722-manual-multi-form.ts +282 -0
- package/src/server/migrations/20230612021134-manual-collection-block.ts +138 -0
- package/src/server/migrations/20230710115902-manual-action-values.ts +78 -0
- package/src/server/triggers/collection.ts +146 -0
- package/src/server/triggers/index.ts +22 -0
- package/src/server/triggers/schedule.ts +567 -0
- package/src/server/types/Execution.ts +26 -0
- package/src/server/types/FlowNode.ts +21 -0
- package/src/server/types/Job.ts +18 -0
- package/src/server/types/Workflow.ts +36 -0
- package/src/server/types/index.ts +4 -0
- package/src/server/utils.ts +17 -0
- package/lib/client/triggers/schedule/DateFieldsSelect.d.ts +0 -2
- /package/lib/server/{models → types}/Execution.js +0 -0
- /package/lib/server/{models → types}/FlowNode.js +0 -0
- /package/lib/server/{models → types}/Job.js +0 -0
- /package/lib/server/{models → types}/Workflow.js +0 -0
|
@@ -16,12 +16,17 @@ var _constants = require("./constants");
|
|
|
16
16
|
var _locale = require("../../locale");
|
|
17
17
|
var _CollectionBlockInitializer = require("../../components/CollectionBlockInitializer");
|
|
18
18
|
var _variable = require("../../variable");
|
|
19
|
-
var _FieldsSelect = require("../../components/FieldsSelect");
|
|
20
19
|
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; }
|
|
21
20
|
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; }
|
|
22
21
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
22
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
24
23
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
24
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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."); }
|
|
26
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
27
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
28
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
29
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
30
|
var _default = {
|
|
26
31
|
title: `{{t("Schedule event", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
27
32
|
type: 'schedule',
|
|
@@ -36,38 +41,45 @@ var _default = {
|
|
|
36
41
|
useCollectionDataSource: _client().useCollectionDataSource
|
|
37
42
|
},
|
|
38
43
|
components: {
|
|
39
|
-
ScheduleConfig: _ScheduleConfig.ScheduleConfig
|
|
40
|
-
FieldsSelect: _FieldsSelect.FieldsSelect
|
|
44
|
+
ScheduleConfig: _ScheduleConfig.ScheduleConfig
|
|
41
45
|
},
|
|
42
46
|
useVariables(config, opts) {
|
|
43
|
-
var _config$appends;
|
|
44
47
|
const compile = (0, _client().useCompile)();
|
|
45
48
|
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
46
49
|
getCollectionFields = _useCollectionManager.getCollectionFields;
|
|
50
|
+
const _opts$fieldNames = opts.fieldNames,
|
|
51
|
+
fieldNames = _opts$fieldNames === void 0 ? _variable.defaultFieldNames : _opts$fieldNames;
|
|
47
52
|
const options = [];
|
|
48
|
-
if (!(opts
|
|
53
|
+
if (!(opts !== null && opts !== void 0 && opts.types) || opts.types.includes('date')) {
|
|
49
54
|
options.push({
|
|
50
55
|
key: 'date',
|
|
51
56
|
value: 'date',
|
|
52
57
|
label: (0, _locale.lang)('Trigger time')
|
|
53
58
|
});
|
|
54
59
|
}
|
|
55
|
-
const depth =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}, opts), {}, {
|
|
59
|
-
collection: config.collection,
|
|
60
|
-
compile,
|
|
61
|
-
getCollectionFields
|
|
62
|
-
}));
|
|
60
|
+
// const depth = config.appends?.length
|
|
61
|
+
// ? config.appends.reduce((max, item) => Math.max(max, item.split('.').length), 1) + 1
|
|
62
|
+
// : 1;
|
|
63
63
|
if (config.mode === _constants.SCHEDULE_MODE.COLLECTION_FIELD) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
var _config$appends;
|
|
65
|
+
const _getCollectionFieldOp = (0, _variable.getCollectionFieldOptions)(_objectSpread(_objectSpread({}, opts), {}, {
|
|
66
|
+
fields: [{
|
|
67
|
+
collectionName: config.collection,
|
|
68
|
+
name: 'data',
|
|
69
|
+
type: 'hasOne',
|
|
70
|
+
target: config.collection,
|
|
71
|
+
uiSchema: {
|
|
72
|
+
title: (0, _locale.lang)('Trigger data')
|
|
73
|
+
}
|
|
74
|
+
}],
|
|
75
|
+
appends: ['data', ...(((_config$appends = config.appends) === null || _config$appends === void 0 ? void 0 : _config$appends.map(item => `data.${item}`)) || [])],
|
|
76
|
+
compile,
|
|
77
|
+
getCollectionFields
|
|
78
|
+
})),
|
|
79
|
+
_getCollectionFieldOp2 = _slicedToArray(_getCollectionFieldOp, 1),
|
|
80
|
+
fieldOption = _getCollectionFieldOp2[0];
|
|
81
|
+
if (fieldOption) {
|
|
82
|
+
options.push(fieldOption);
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
return options;
|
package/lib/client/variable.d.ts
CHANGED
|
@@ -1,34 +1,52 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type VariableOption = {
|
|
2
2
|
key?: string;
|
|
3
|
-
value
|
|
4
|
-
label
|
|
3
|
+
value?: string;
|
|
4
|
+
label?: string;
|
|
5
5
|
children?: VariableOptions;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
export type VariableOptions = VariableOption[] | null;
|
|
9
|
+
export type VariableDataType = string | {
|
|
10
|
+
type: string;
|
|
11
|
+
options?: {
|
|
12
|
+
entity?: boolean;
|
|
13
|
+
collection?: string;
|
|
14
|
+
};
|
|
15
|
+
} | ((field: any, appends?: string[]) => boolean);
|
|
16
|
+
export type OptionsOfUseVariableOptions = {
|
|
17
|
+
types?: VariableDataType[];
|
|
18
|
+
fieldNames?: {
|
|
19
|
+
label?: string;
|
|
20
|
+
value?: string;
|
|
21
|
+
children?: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare const defaultFieldNames: {
|
|
25
|
+
readonly label: "label";
|
|
26
|
+
readonly value: "value";
|
|
27
|
+
readonly children: "children";
|
|
6
28
|
};
|
|
7
|
-
export declare type VariableOptions = VariableOption[] | null;
|
|
8
29
|
export declare const nodesOptions: {
|
|
9
30
|
label: string;
|
|
10
31
|
value: string;
|
|
11
|
-
useOptions(options:
|
|
32
|
+
useOptions(options: OptionsOfUseVariableOptions): VariableOption[];
|
|
12
33
|
};
|
|
13
34
|
export declare const triggerOptions: {
|
|
14
35
|
label: string;
|
|
15
36
|
value: string;
|
|
16
|
-
useOptions(options:
|
|
37
|
+
useOptions(options: OptionsOfUseVariableOptions): any;
|
|
17
38
|
};
|
|
18
39
|
export declare const scopeOptions: {
|
|
19
40
|
label: string;
|
|
20
41
|
value: string;
|
|
21
|
-
useOptions(options:
|
|
42
|
+
useOptions(options: OptionsOfUseVariableOptions): VariableOption[];
|
|
22
43
|
};
|
|
23
44
|
export declare const systemOptions: {
|
|
24
45
|
label: string;
|
|
25
46
|
value: string;
|
|
26
|
-
useOptions({ types }: {
|
|
27
|
-
|
|
28
|
-
}): {
|
|
47
|
+
useOptions({ types, fieldNames }: OptionsOfUseVariableOptions): {
|
|
48
|
+
[x: string]: string;
|
|
29
49
|
key: string;
|
|
30
|
-
value: string;
|
|
31
|
-
label: string;
|
|
32
50
|
}[];
|
|
33
51
|
};
|
|
34
52
|
export declare const BaseTypeSets: {
|
|
@@ -37,7 +55,7 @@ export declare const BaseTypeSets: {
|
|
|
37
55
|
string: Set<string>;
|
|
38
56
|
date: Set<string>;
|
|
39
57
|
};
|
|
40
|
-
export declare function useWorkflowVariableOptions(options?:
|
|
58
|
+
export declare function useWorkflowVariableOptions(options?: OptionsOfUseVariableOptions): {
|
|
41
59
|
label: any;
|
|
42
60
|
value: any;
|
|
43
61
|
key: any;
|
package/lib/client/variable.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.BaseTypeSets = void 0;
|
|
6
|
+
exports.defaultFieldNames = exports.BaseTypeSets = void 0;
|
|
7
7
|
exports.getCollectionFieldOptions = getCollectionFieldOptions;
|
|
8
8
|
exports.triggerOptions = exports.systemOptions = exports.scopeOptions = exports.nodesOptions = void 0;
|
|
9
9
|
exports.useWorkflowVariableOptions = useWorkflowVariableOptions;
|
|
@@ -25,6 +25,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
25
25
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26
26
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
27
27
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
28
|
+
const defaultFieldNames = {
|
|
29
|
+
label: 'label',
|
|
30
|
+
value: 'value',
|
|
31
|
+
children: 'children'
|
|
32
|
+
};
|
|
33
|
+
exports.defaultFieldNames = defaultFieldNames;
|
|
28
34
|
const nodesOptions = {
|
|
29
35
|
label: `{{t("Node result", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
30
36
|
value: '$jobsMapByNodeId',
|
|
@@ -60,6 +66,8 @@ const scopeOptions = {
|
|
|
60
66
|
label: `{{t("Scope variables", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
61
67
|
value: '$scopes',
|
|
62
68
|
useOptions(options) {
|
|
69
|
+
const _options$fieldNames = options.fieldNames,
|
|
70
|
+
fieldNames = _options$fieldNames === void 0 ? defaultFieldNames : _options$fieldNames;
|
|
63
71
|
const current = (0, _nodes.useNodeContext)();
|
|
64
72
|
const scopes = (0, _nodes.useUpstreamScopes)(current);
|
|
65
73
|
const result = [];
|
|
@@ -71,9 +79,9 @@ const scopeOptions = {
|
|
|
71
79
|
var _node$title;
|
|
72
80
|
result.push({
|
|
73
81
|
key: node.id.toString(),
|
|
74
|
-
value: node.id.toString(),
|
|
75
|
-
label: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
|
|
76
|
-
children: subOptions
|
|
82
|
+
[fieldNames.value]: node.id.toString(),
|
|
83
|
+
[fieldNames.label]: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
|
|
84
|
+
[fieldNames.children]: subOptions
|
|
77
85
|
});
|
|
78
86
|
}
|
|
79
87
|
});
|
|
@@ -85,19 +93,20 @@ const systemOptions = {
|
|
|
85
93
|
label: `{{t("System variables", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
86
94
|
value: '$system',
|
|
87
95
|
useOptions({
|
|
88
|
-
types
|
|
96
|
+
types,
|
|
97
|
+
fieldNames = defaultFieldNames
|
|
89
98
|
}) {
|
|
90
99
|
return [...(!types || types.includes('date') ? [{
|
|
91
100
|
key: 'now',
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
[fieldNames.label]: (0, _locale.lang)('System time'),
|
|
102
|
+
[fieldNames.value]: 'now'
|
|
94
103
|
}] : [])];
|
|
95
104
|
}
|
|
96
105
|
};
|
|
97
106
|
exports.systemOptions = systemOptions;
|
|
98
107
|
const BaseTypeSets = {
|
|
99
108
|
boolean: new Set(['checkbox']),
|
|
100
|
-
number: new Set(['number', 'percent']),
|
|
109
|
+
number: new Set(['integer', 'number', 'percent']),
|
|
101
110
|
string: new Set(['input', 'password', 'email', 'phone', 'select', 'radioGroup', 'text', 'markdown', 'richText', 'expression', 'time']),
|
|
102
111
|
date: new Set(['date', 'createdAt', 'updatedAt'])
|
|
103
112
|
};
|
|
@@ -142,7 +151,7 @@ function filterTypedFields({
|
|
|
142
151
|
getCollectionFields
|
|
143
152
|
}) {
|
|
144
153
|
return fields.filter(field => {
|
|
145
|
-
const match =
|
|
154
|
+
const match = types !== null && types !== void 0 && types.length ? types.some(type => matchFieldType(field, type, appends)) : true;
|
|
146
155
|
if (isAssociationField(field)) {
|
|
147
156
|
const nextAppends = getNextAppends(field, appends);
|
|
148
157
|
const included = appends.includes(field.name);
|
|
@@ -167,15 +176,20 @@ function filterTypedFields({
|
|
|
167
176
|
});
|
|
168
177
|
}
|
|
169
178
|
function useWorkflowVariableOptions(options = {}) {
|
|
179
|
+
var _options$fieldNames2;
|
|
180
|
+
const fieldNames = Object.assign({}, defaultFieldNames, (_options$fieldNames2 = options.fieldNames) !== null && _options$fieldNames2 !== void 0 ? _options$fieldNames2 : {});
|
|
181
|
+
const opts = Object.assign(options, {
|
|
182
|
+
fieldNames
|
|
183
|
+
});
|
|
170
184
|
const compile = (0, _client().useCompile)();
|
|
171
185
|
const result = [scopeOptions, nodesOptions, triggerOptions, systemOptions].map(item => {
|
|
172
|
-
const
|
|
186
|
+
const children = item.useOptions(opts).filter(Boolean);
|
|
173
187
|
return {
|
|
174
|
-
label: compile(item.label),
|
|
175
|
-
value: item.value,
|
|
176
|
-
key: item.value,
|
|
177
|
-
children:
|
|
178
|
-
disabled:
|
|
188
|
+
[fieldNames.label]: compile(item.label),
|
|
189
|
+
[fieldNames.value]: item.value,
|
|
190
|
+
key: item[fieldNames.value],
|
|
191
|
+
[fieldNames.children]: children,
|
|
192
|
+
disabled: children && !children.length
|
|
179
193
|
};
|
|
180
194
|
});
|
|
181
195
|
return result;
|
|
@@ -202,7 +216,7 @@ function getNormalizedFields(collectionName, {
|
|
|
202
216
|
var _field$uiSchema, _field$uiSchema2;
|
|
203
217
|
otherFields.splice(i, 0, _objectSpread(_objectSpread(_objectSpread({}, field), foreignKeyField), {}, {
|
|
204
218
|
uiSchema: _objectSpread(_objectSpread({}, field.uiSchema), {}, {
|
|
205
|
-
title: (
|
|
219
|
+
title: (_field$uiSchema = field.uiSchema) !== null && _field$uiSchema !== void 0 && _field$uiSchema.title ? `${compile((_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title)} ID` : foreignKeyField.name
|
|
206
220
|
})
|
|
207
221
|
}));
|
|
208
222
|
} else {
|
|
@@ -213,7 +227,7 @@ function getNormalizedFields(collectionName, {
|
|
|
213
227
|
isForeignKey: true,
|
|
214
228
|
interface: field.interface,
|
|
215
229
|
uiSchema: _objectSpread(_objectSpread({}, field.uiSchema), {}, {
|
|
216
|
-
title: (
|
|
230
|
+
title: (_field$uiSchema3 = field.uiSchema) !== null && _field$uiSchema3 !== void 0 && _field$uiSchema3.title ? `${compile((_field$uiSchema4 = field.uiSchema) === null || _field$uiSchema4 === void 0 ? void 0 : _field$uiSchema4.title)} ID` : field.name
|
|
217
231
|
})
|
|
218
232
|
}));
|
|
219
233
|
}
|
|
@@ -224,7 +238,7 @@ function getNormalizedFields(collectionName, {
|
|
|
224
238
|
type: field.dataType,
|
|
225
239
|
interface: belongsToField.interface,
|
|
226
240
|
uiSchema: _objectSpread(_objectSpread({}, belongsToField.uiSchema), {}, {
|
|
227
|
-
title: (
|
|
241
|
+
title: (_belongsToField$uiSch = belongsToField.uiSchema) !== null && _belongsToField$uiSch !== void 0 && _belongsToField$uiSch.title ? `${compile((_belongsToField$uiSch2 = belongsToField.uiSchema) === null || _belongsToField$uiSch2 === void 0 ? void 0 : _belongsToField$uiSch2.title)} ID` : field.name
|
|
228
242
|
})
|
|
229
243
|
}));
|
|
230
244
|
}
|
|
@@ -236,20 +250,17 @@ function loadChildren(_x) {
|
|
|
236
250
|
}
|
|
237
251
|
function _loadChildren() {
|
|
238
252
|
_loadChildren = _asyncToGenerator(function* (option) {
|
|
239
|
-
const result = getCollectionFieldOptions({
|
|
253
|
+
const result = getCollectionFieldOptions(_objectSpread({
|
|
240
254
|
collection: option.field.target,
|
|
241
255
|
types: option.types,
|
|
242
|
-
appends: getNextAppends(option.field, option.appends)
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
getCollectionFields: this.getCollectionFields
|
|
246
|
-
});
|
|
256
|
+
appends: getNextAppends(option.field, option.appends)
|
|
257
|
+
}, this));
|
|
258
|
+
option.loadChildren = null;
|
|
247
259
|
if (result.length) {
|
|
248
260
|
option.children = result;
|
|
249
261
|
} else {
|
|
250
262
|
var _option$types;
|
|
251
263
|
option.isLeaf = true;
|
|
252
|
-
option.loadChildren = null;
|
|
253
264
|
const matchingType = (_option$types = option.types) === null || _option$types === void 0 ? void 0 : _option$types.some(type => matchFieldType(option.field, type, 0));
|
|
254
265
|
if (!matchingType) {
|
|
255
266
|
option.disabled = true;
|
|
@@ -265,7 +276,9 @@ function getCollectionFieldOptions(options) {
|
|
|
265
276
|
_options$appends = options.appends,
|
|
266
277
|
appends = _options$appends === void 0 ? [] : _options$appends,
|
|
267
278
|
compile = options.compile,
|
|
268
|
-
getCollectionFields = options.getCollectionFields
|
|
279
|
+
getCollectionFields = options.getCollectionFields,
|
|
280
|
+
_options$fieldNames3 = options.fieldNames,
|
|
281
|
+
fieldNames = _options$fieldNames3 === void 0 ? defaultFieldNames : _options$fieldNames3;
|
|
269
282
|
const normalizedFields = getNormalizedFields(collection, {
|
|
270
283
|
compile,
|
|
271
284
|
getCollectionFields
|
|
@@ -273,7 +286,8 @@ function getCollectionFieldOptions(options) {
|
|
|
273
286
|
const computedFields = fields !== null && fields !== void 0 ? fields : normalizedFields;
|
|
274
287
|
const boundLoadChildren = loadChildren.bind({
|
|
275
288
|
compile,
|
|
276
|
-
getCollectionFields
|
|
289
|
+
getCollectionFields,
|
|
290
|
+
fieldNames
|
|
277
291
|
});
|
|
278
292
|
const result = filterTypedFields({
|
|
279
293
|
fields: computedFields,
|
|
@@ -285,13 +299,14 @@ function getCollectionFieldOptions(options) {
|
|
|
285
299
|
}).map(field => {
|
|
286
300
|
var _field$uiSchema5;
|
|
287
301
|
const label = compile(((_field$uiSchema5 = field.uiSchema) === null || _field$uiSchema5 === void 0 ? void 0 : _field$uiSchema5.title) || field.name);
|
|
302
|
+
// console.log('===', label, field);
|
|
288
303
|
const nextAppends = getNextAppends(field, appends);
|
|
289
304
|
// TODO: no matching fields in next appends should consider isLeaf as true
|
|
290
305
|
const isLeaf = !isAssociationField(field) || !nextAppends.length && !appends.includes(field.name);
|
|
291
306
|
return {
|
|
292
|
-
label,
|
|
307
|
+
[fieldNames.label]: label,
|
|
293
308
|
key: field.name,
|
|
294
|
-
value: field.name,
|
|
309
|
+
[fieldNames.value]: field.name,
|
|
295
310
|
isLeaf,
|
|
296
311
|
loadChildren: isLeaf ? null : boundLoadChildren,
|
|
297
312
|
field,
|
package/lib/server/Plugin.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Plugin } from '@nocobase/server';
|
|
2
2
|
import { Registry } from '@nocobase/utils';
|
|
3
3
|
import { Instruction } from './instructions';
|
|
4
|
-
import ExecutionModel from './models/Execution';
|
|
5
|
-
import WorkflowModel from './models/Workflow';
|
|
6
4
|
import Processor from './Processor';
|
|
7
5
|
import { Trigger } from './triggers';
|
|
8
6
|
import { CustomFunction } from './functions';
|
|
9
7
|
import { Logger } from '@nocobase/logger';
|
|
10
|
-
|
|
8
|
+
import type { WorkflowModel, ExecutionModel } from './types';
|
|
9
|
+
type ID = number | string;
|
|
11
10
|
export default class WorkflowPlugin extends Plugin {
|
|
12
11
|
instructions: Registry<Instruction>;
|
|
13
12
|
triggers: Registry<Trigger>;
|
|
@@ -20,9 +19,7 @@ export default class WorkflowPlugin extends Plugin {
|
|
|
20
19
|
onBeforeSave: (instance: WorkflowModel, options: any) => Promise<void>;
|
|
21
20
|
load(): Promise<void>;
|
|
22
21
|
toggle(workflow: WorkflowModel, enable?: boolean): void;
|
|
23
|
-
trigger(workflow: WorkflowModel, context: {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
}, options?: {
|
|
22
|
+
trigger(workflow: WorkflowModel, context: object, options?: {
|
|
26
23
|
context?: any;
|
|
27
24
|
}): void;
|
|
28
25
|
private prepare;
|
package/lib/server/Plugin.js
CHANGED
|
@@ -82,7 +82,7 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
82
82
|
this.instructions = new (_utils().Registry)();
|
|
83
83
|
this.triggers = new (_utils().Registry)();
|
|
84
84
|
this.functions = new (_utils().Registry)();
|
|
85
|
-
this.executing =
|
|
85
|
+
this.executing = false;
|
|
86
86
|
this.pending = [];
|
|
87
87
|
this.events = [];
|
|
88
88
|
this.loggerCache = void 0;
|
|
@@ -133,7 +133,8 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
133
133
|
}();
|
|
134
134
|
this.prepare = /*#__PURE__*/_asyncToGenerator(function* () {
|
|
135
135
|
var _options$context;
|
|
136
|
-
const
|
|
136
|
+
const _this$events = _slicedToArray(_this.events, 1),
|
|
137
|
+
event = _this$events[0];
|
|
137
138
|
if (!event) {
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
@@ -142,7 +143,7 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
142
143
|
context = _event[1],
|
|
143
144
|
options = _event[2];
|
|
144
145
|
let valid = true;
|
|
145
|
-
if ((_options$context = options.context)
|
|
146
|
+
if ((_options$context = options.context) !== null && _options$context !== void 0 && _options$context.executionId) {
|
|
146
147
|
// NOTE: no transaction here for read-uncommitted execution
|
|
147
148
|
const existed = yield workflow.countExecutions({
|
|
148
149
|
where: {
|
|
@@ -165,10 +166,6 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
165
166
|
}, {
|
|
166
167
|
transaction
|
|
167
168
|
});
|
|
168
|
-
const executed = yield workflow.countExecutions({
|
|
169
|
-
transaction
|
|
170
|
-
});
|
|
171
|
-
// NOTE: not to trigger afterUpdate hook here
|
|
172
169
|
yield workflow.increment('executed', {
|
|
173
170
|
transaction
|
|
174
171
|
});
|
|
@@ -193,6 +190,7 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
193
190
|
_this.pending.push([execution]);
|
|
194
191
|
}
|
|
195
192
|
}
|
|
193
|
+
_this.events.shift();
|
|
196
194
|
if (_this.events.length) {
|
|
197
195
|
yield _this.prepare();
|
|
198
196
|
} else {
|
|
@@ -329,30 +327,37 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
329
327
|
if (_this4.executing) {
|
|
330
328
|
return;
|
|
331
329
|
}
|
|
330
|
+
_this4.executing = true;
|
|
332
331
|
let next = null;
|
|
333
332
|
// resuming has high priority
|
|
334
333
|
if (_this4.pending.length) {
|
|
335
334
|
next = _this4.pending.shift();
|
|
335
|
+
_this4.getLogger(next[0].workflowId).info(`pending execution (${next[0].id}) ready to process`);
|
|
336
336
|
} else {
|
|
337
337
|
const execution = yield _this4.db.getRepository('executions').findOne({
|
|
338
338
|
filter: {
|
|
339
339
|
status: _constants.EXECUTION_STATUS.QUEUEING
|
|
340
340
|
},
|
|
341
|
+
appends: ['workflow'],
|
|
341
342
|
sort: 'createdAt'
|
|
342
343
|
});
|
|
343
|
-
if (execution) {
|
|
344
|
+
if (execution && execution.workflow.enabled) {
|
|
345
|
+
_this4.getLogger(execution.workflowId).info(`execution (${execution.id}) fetched from db`);
|
|
344
346
|
next = [execution];
|
|
345
347
|
}
|
|
346
348
|
}
|
|
347
349
|
if (next) {
|
|
348
|
-
_this4.process(...next);
|
|
350
|
+
yield _this4.process(...next);
|
|
351
|
+
}
|
|
352
|
+
_this4.executing = false;
|
|
353
|
+
if (next) {
|
|
354
|
+
_this4.dispatch();
|
|
349
355
|
}
|
|
350
356
|
})();
|
|
351
357
|
}
|
|
352
358
|
process(execution, job) {
|
|
353
359
|
var _this5 = this;
|
|
354
360
|
return _asyncToGenerator(function* () {
|
|
355
|
-
_this5.executing = execution;
|
|
356
361
|
if (execution.status === _constants.EXECUTION_STATUS.QUEUEING) {
|
|
357
362
|
yield execution.update({
|
|
358
363
|
status: _constants.EXECUTION_STATUS.STARTED
|
|
@@ -366,8 +371,6 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
366
371
|
} catch (err) {
|
|
367
372
|
_this5.getLogger(execution.workflowId).error(`execution (${execution.id}) error: ${err.message}`, err);
|
|
368
373
|
}
|
|
369
|
-
_this5.executing = null;
|
|
370
|
-
_this5.dispatch();
|
|
371
374
|
})();
|
|
372
375
|
}
|
|
373
376
|
createProcessor(execution, options = {}) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { Transaction, Transactionable } from '@nocobase/database';
|
|
1
2
|
import { Logger } from '@nocobase/logger';
|
|
2
|
-
import { Transaction, Transactionable } from 'sequelize';
|
|
3
3
|
import Plugin from '.';
|
|
4
|
-
import ExecutionModel from './
|
|
5
|
-
import FlowNodeModel from './models/FlowNode';
|
|
6
|
-
import JobModel from './models/Job';
|
|
4
|
+
import type { ExecutionModel, FlowNodeModel, JobModel } from './types';
|
|
7
5
|
export interface ProcessorOptions extends Transactionable {
|
|
8
6
|
plugin: Plugin;
|
|
9
7
|
}
|
|
@@ -49,5 +47,5 @@ export default class Processor {
|
|
|
49
47
|
$system: {};
|
|
50
48
|
$scopes: {};
|
|
51
49
|
};
|
|
52
|
-
getParsedValue(value: any, node?: any): any;
|
|
50
|
+
getParsedValue(value: any, node?: any, additionalScope?: object): any;
|
|
53
51
|
}
|
package/lib/server/Processor.js
CHANGED
|
@@ -371,9 +371,9 @@ class Processor {
|
|
|
371
371
|
$scopes
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
|
-
getParsedValue(value, node) {
|
|
374
|
+
getParsedValue(value, node, additionalScope) {
|
|
375
375
|
const template = (0, _utils().parse)(value);
|
|
376
|
-
const scope = this.getScope(node);
|
|
376
|
+
const scope = Object.assign(this.getScope(node), additionalScope);
|
|
377
377
|
template.parameters.forEach(({
|
|
378
378
|
key
|
|
379
379
|
}) => {
|
|
@@ -6,16 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.create = create;
|
|
7
7
|
exports.destroy = destroy;
|
|
8
8
|
exports.update = update;
|
|
9
|
-
function
|
|
10
|
-
const data = require("
|
|
11
|
-
|
|
9
|
+
function _actions() {
|
|
10
|
+
const data = require("@nocobase/actions");
|
|
11
|
+
_actions = function _actions() {
|
|
12
12
|
return data;
|
|
13
13
|
};
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const data = require("@nocobase/
|
|
18
|
-
|
|
16
|
+
function _database() {
|
|
17
|
+
const data = require("@nocobase/database");
|
|
18
|
+
_database = function _database() {
|
|
19
19
|
return data;
|
|
20
20
|
};
|
|
21
21
|
return data;
|
|
@@ -102,7 +102,7 @@ function _create() {
|
|
|
102
102
|
const _yield$upstream$getBr = yield upstream.getBranches({
|
|
103
103
|
where: {
|
|
104
104
|
id: {
|
|
105
|
-
[
|
|
105
|
+
[_database().Op.ne]: instance.id
|
|
106
106
|
},
|
|
107
107
|
branchIndex: instance.branchIndex
|
|
108
108
|
},
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '
|
|
2
|
-
import { BaseFieldOptions, Field } from '@nocobase/database';
|
|
1
|
+
import { BaseFieldOptions, DataTypes, Field } from '@nocobase/database';
|
|
3
2
|
export interface ExpressionFieldOptions extends BaseFieldOptions {
|
|
4
3
|
type: 'expression';
|
|
5
4
|
}
|
|
@@ -4,13 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ExpressionField = void 0;
|
|
7
|
-
function _sequelize() {
|
|
8
|
-
const data = require("sequelize");
|
|
9
|
-
_sequelize = function _sequelize() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
7
|
function _database() {
|
|
15
8
|
const data = require("@nocobase/database");
|
|
16
9
|
_database = function _database() {
|
|
@@ -20,7 +13,7 @@ function _database() {
|
|
|
20
13
|
}
|
|
21
14
|
class ExpressionField extends _database().Field {
|
|
22
15
|
get dataType() {
|
|
23
|
-
return
|
|
16
|
+
return _database().DataTypes.TEXT;
|
|
24
17
|
}
|
|
25
18
|
}
|
|
26
19
|
exports.ExpressionField = ExpressionField;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Plugin from '..';
|
|
2
|
-
import ExecutionModel from '../
|
|
3
|
-
|
|
4
|
-
export declare type CustomFunction = (this: {
|
|
2
|
+
import type { ExecutionModel, FlowNodeModel } from '../types';
|
|
3
|
+
export type CustomFunction = (this: {
|
|
5
4
|
execution: ExecutionModel;
|
|
6
5
|
node?: FlowNodeModel;
|
|
7
6
|
}) => any;
|
package/lib/server/index.d.ts
CHANGED
package/lib/server/index.js
CHANGED
|
@@ -40,4 +40,16 @@ Object.keys(_constants).forEach(function (key) {
|
|
|
40
40
|
var _triggers = require("./triggers");
|
|
41
41
|
var _Processor = _interopRequireDefault(require("./Processor"));
|
|
42
42
|
var _Plugin = _interopRequireDefault(require("./Plugin"));
|
|
43
|
+
var _types = require("./types");
|
|
44
|
+
Object.keys(_types).forEach(function (key) {
|
|
45
|
+
if (key === "default" || key === "__esModule") return;
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
47
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
48
|
+
Object.defineProperty(exports, key, {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _types[key];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
43
55
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function
|
|
8
|
-
const data = require("
|
|
9
|
-
|
|
7
|
+
function _database() {
|
|
8
|
+
const data = require("@nocobase/database");
|
|
9
|
+
_database = function _database() {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
@@ -41,14 +41,14 @@ var _default = {
|
|
|
41
41
|
const database = node.constructor.database;
|
|
42
42
|
const repo = associated ? database.getRepository(`${association === null || association === void 0 ? void 0 : association.associatedCollection}.${association.name}`, processor.getParsedValue(association === null || association === void 0 ? void 0 : association.associatedKey)) : database.getRepository(collection);
|
|
43
43
|
if (!options.dataType && aggregator === 'avg') {
|
|
44
|
-
options.dataType =
|
|
44
|
+
options.dataType = _database().DataTypes.DOUBLE;
|
|
45
45
|
}
|
|
46
46
|
const result = yield repo.aggregate(_objectSpread(_objectSpread({}, options), {}, {
|
|
47
47
|
method: aggregators[aggregator],
|
|
48
48
|
transaction: processor.transaction
|
|
49
49
|
}));
|
|
50
50
|
return {
|
|
51
|
-
result: options.dataType ===
|
|
51
|
+
result: options.dataType === _database().DataTypes.DOUBLE ? Number(result) : result,
|
|
52
52
|
status: _constants.JOB_STATUS.RESOLVED
|
|
53
53
|
};
|
|
54
54
|
})();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Registry } from '@nocobase/utils';
|
|
2
2
|
import { Instruction } from '.';
|
|
3
|
-
|
|
3
|
+
type Comparer = (a: any, b: any) => boolean;
|
|
4
|
+
export declare const calculators: Registry<Comparer>;
|
|
4
5
|
declare const _default: Instruction;
|
|
5
6
|
export default _default;
|