@nocobase/plugin-workflow 0.9.3-alpha.1 → 0.9.4-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.
Files changed (74) hide show
  1. package/lib/client/CanvasContent.d.ts +4 -0
  2. package/lib/client/CanvasContent.js +49 -0
  3. package/lib/client/ExecutionCanvas.js +110 -44
  4. package/lib/client/WorkflowCanvas.js +35 -18
  5. package/lib/client/components/CollectionFieldset.js +2 -2
  6. package/lib/client/components/NodeDescription.d.ts +2 -0
  7. package/lib/client/components/NodeDescription.js +59 -0
  8. package/lib/client/components/ValueBlock.d.ts +5 -0
  9. package/lib/client/components/ValueBlock.js +110 -0
  10. package/lib/client/index.d.ts +1 -0
  11. package/lib/client/index.js +12 -0
  12. package/lib/client/locale/es-ES.d.ts +130 -0
  13. package/lib/client/locale/es-ES.js +136 -0
  14. package/lib/client/locale/zh-CN.d.ts +35 -6
  15. package/lib/client/locale/zh-CN.js +35 -6
  16. package/lib/client/nodes/aggregate.d.ts +186 -0
  17. package/lib/client/nodes/aggregate.js +349 -0
  18. package/lib/client/nodes/calculation.d.ts +2 -1
  19. package/lib/client/nodes/calculation.js +28 -53
  20. package/lib/client/nodes/condition.d.ts +2 -6
  21. package/lib/client/nodes/condition.js +4 -3
  22. package/lib/client/nodes/create.d.ts +5 -3
  23. package/lib/client/nodes/create.js +16 -7
  24. package/lib/client/nodes/delay.d.ts +1 -0
  25. package/lib/client/nodes/delay.js +1 -0
  26. package/lib/client/nodes/destroy.d.ts +2 -2
  27. package/lib/client/nodes/destroy.js +1 -0
  28. package/lib/client/nodes/index.d.ts +5 -2
  29. package/lib/client/nodes/index.js +95 -97
  30. package/lib/client/nodes/loop.d.ts +29 -0
  31. package/lib/client/nodes/loop.js +165 -0
  32. package/lib/client/nodes/manual/AssigneesSelect.js +8 -6
  33. package/lib/client/nodes/manual/index.d.ts +6 -1
  34. package/lib/client/nodes/manual/index.js +6 -1
  35. package/lib/client/nodes/parallel.d.ts +1 -0
  36. package/lib/client/nodes/parallel.js +2 -1
  37. package/lib/client/nodes/query.d.ts +12 -3
  38. package/lib/client/nodes/query.js +24 -17
  39. package/lib/client/nodes/request.d.ts +1 -0
  40. package/lib/client/nodes/request.js +1 -0
  41. package/lib/client/nodes/update.d.ts +2 -2
  42. package/lib/client/nodes/update.js +1 -0
  43. package/lib/client/schemas/collection.d.ts +1 -2
  44. package/lib/client/schemas/collection.js +5 -6
  45. package/lib/client/style.d.ts +1 -0
  46. package/lib/client/style.js +40 -26
  47. package/lib/client/triggers/collection.d.ts +2 -11
  48. package/lib/client/triggers/collection.js +6 -7
  49. package/lib/client/triggers/index.d.ts +1 -1
  50. package/lib/client/triggers/index.js +5 -3
  51. package/lib/client/triggers/schedule/index.d.ts +3 -1
  52. package/lib/client/triggers/schedule/index.js +6 -4
  53. package/lib/client/variable.d.ts +27 -1
  54. package/lib/client/variable.js +65 -34
  55. package/lib/server/Plugin.js +2 -14
  56. package/lib/server/Processor.d.ts +3 -0
  57. package/lib/server/Processor.js +30 -3
  58. package/lib/server/actions/workflows.js +2 -2
  59. package/lib/server/collections/workflows.js +2 -1
  60. package/lib/server/instructions/aggregate.d.ts +9 -0
  61. package/lib/server/instructions/aggregate.js +57 -0
  62. package/lib/server/instructions/calculation.js +1 -1
  63. package/lib/server/instructions/condition.js +1 -1
  64. package/lib/server/instructions/create.js +1 -1
  65. package/lib/server/instructions/destroy.js +1 -1
  66. package/lib/server/instructions/index.d.ts +1 -0
  67. package/lib/server/instructions/index.js +1 -1
  68. package/lib/server/instructions/loop.d.ts +16 -0
  69. package/lib/server/instructions/loop.js +107 -0
  70. package/lib/server/instructions/parallel.js +17 -10
  71. package/lib/server/instructions/query.js +1 -4
  72. package/lib/server/instructions/request.js +1 -1
  73. package/lib/server/instructions/update.js +1 -1
  74. package/package.json +13 -13
@@ -8,11 +8,6 @@ interface Calculator {
8
8
  group: string;
9
9
  }
10
10
  export declare const calculators: Registry<Calculator>;
11
- export declare function Calculation({ calculator, operands, onChange }: {
12
- calculator: any;
13
- operands?: any[];
14
- onChange: any;
15
- }): JSX.Element;
16
11
  declare function CalculationConfig({ value, onChange }: {
17
12
  value: any;
18
13
  onChange: any;
@@ -21,6 +16,7 @@ declare const _default: {
21
16
  title: string;
22
17
  type: string;
23
18
  group: string;
19
+ description: string;
24
20
  fieldset: {
25
21
  rejectOnFalse: {
26
22
  type: string;
@@ -96,7 +92,7 @@ declare const _default: {
96
92
  rejectOnFalse: boolean;
97
93
  };
98
94
  }[];
99
- render(data: any): JSX.Element;
95
+ render: (data: any) => JSX.Element;
100
96
  scope: {
101
97
  renderEngineReference: (key: string) => JSX.Element;
102
98
  useWorkflowVariableOptions: typeof useWorkflowVariableOptions;
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Calculation = Calculation;
7
6
  exports.default = exports.calculators = void 0;
8
7
  function _icons() {
9
8
  const data = require("@ant-design/icons");
@@ -211,7 +210,8 @@ function Calculation({
211
210
  operands,
212
211
  calculator: v
213
212
  }),
214
- placeholder: (0, _locale.lang)('Calculator')
213
+ placeholder: (0, _locale.lang)('Calculator'),
214
+ dropdownMatchSelectWidth: false
215
215
  }, calculatorGroups.filter(group => Boolean(getGroupCalculators(group.value).length)).map(group => _react().default.createElement(_antd().Select.OptGroup, {
216
216
  key: group.value,
217
217
  label: compile(group.title)
@@ -380,6 +380,7 @@ var _default = {
380
380
  title: `{{t("Condition", { ns: "${_locale.NAMESPACE}" })}}`,
381
381
  type: 'condition',
382
382
  group: 'control',
383
+ description: `{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${_locale.NAMESPACE}" })}}`,
383
384
  fieldset: {
384
385
  rejectOnFalse: {
385
386
  type: 'boolean',
@@ -477,7 +478,7 @@ var _default = {
477
478
  rejectOnFalse: false
478
479
  }
479
480
  }],
480
- render(data) {
481
+ render: function Renderer(data) {
481
482
  const _useTranslation2 = (0, _reactI18next().useTranslation)(),
482
483
  t = _useTranslation2.t;
483
484
  const _useFlowContext = (0, _FlowContext.useFlowContext)(),
@@ -4,17 +4,17 @@ declare const _default: {
4
4
  title: string;
5
5
  type: string;
6
6
  group: string;
7
+ description: string;
7
8
  fieldset: {
8
9
  collection: {
9
10
  type: string;
10
11
  title: string;
11
12
  required: boolean;
12
- 'x-reactions': string[];
13
+ 'x-reactions': any[];
13
14
  'x-decorator': string;
14
15
  'x-component': string;
15
16
  'x-component-props': {
16
17
  dropdownMatchSelectWidth: boolean;
17
- placeholder: string;
18
18
  };
19
19
  };
20
20
  params: {
@@ -62,7 +62,9 @@ declare const _default: {
62
62
  CollectionFieldset: import("react").MemoExoticComponent<import("react").FunctionComponent<Pick<any, string | number | symbol>>>;
63
63
  FieldsSelect: import("react").MemoExoticComponent<import("react").FunctionComponent<Pick<any, string | number | symbol>>>;
64
64
  };
65
- getOptions(config: any, types: any): import("../variable").VariableOption[];
65
+ useVariables({ config }: {
66
+ config: any;
67
+ }, options: any): import("../variable").VariableOption[];
66
68
  useInitializers(node: any): SchemaInitializerItemOptions | null;
67
69
  initializers: {
68
70
  CollectionFieldInitializers: typeof CollectionFieldInitializers;
@@ -19,10 +19,16 @@ var _CollectionFieldInitializers = require("../components/CollectionFieldInitial
19
19
  var _variable = require("../variable");
20
20
  var _FieldsSelect = require("../components/FieldsSelect");
21
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
+ 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; }
23
+ 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; }
24
+ 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; }
25
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
26
+ 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); }
22
27
  var _default = {
23
28
  title: `{{t("Create record", { ns: "${_locale.NAMESPACE}" })}}`,
24
29
  type: 'create',
25
30
  group: 'collection',
31
+ description: `{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${_locale.NAMESPACE}" })}}`,
26
32
  fieldset: {
27
33
  collection: _collection.collection,
28
34
  // multiple: {
@@ -51,13 +57,16 @@ var _default = {
51
57
  CollectionFieldset: _CollectionFieldset.default,
52
58
  FieldsSelect: _FieldsSelect.FieldsSelect
53
59
  },
54
- getOptions(config, types) {
55
- var _config$params, _config$params$append;
56
- return (0, _variable.useCollectionFieldOptions)({
57
- collection: config.collection,
58
- types,
59
- depth: ((_config$params = config.params) === null || _config$params === void 0 ? void 0 : (_config$params$append = _config$params.appends) === null || _config$params$append === void 0 ? void 0 : _config$params$append.length) ? 1 : 0
60
- });
60
+ useVariables({
61
+ config
62
+ }, options) {
63
+ var _options$depth, _config$params, _config$params$append;
64
+ const result = (0, _variable.useCollectionFieldOptions)(_objectSpread(_objectSpread({
65
+ collection: config === null || config === void 0 ? void 0 : config.collection
66
+ }, options), {}, {
67
+ depth: ((_options$depth = options === null || options === void 0 ? void 0 : options.depth) !== null && _options$depth !== void 0 ? _options$depth : config === null || config === void 0 ? void 0 : (_config$params = config.params) === null || _config$params === void 0 ? void 0 : (_config$params$append = _config$params.appends) === null || _config$params$append === void 0 ? void 0 : _config$params$append.length) ? 1 : 0
68
+ }));
69
+ return (result === null || result === void 0 ? void 0 : result.length) ? result : null;
61
70
  },
62
71
  useInitializers(node) {
63
72
  var _node$title;
@@ -3,6 +3,7 @@ declare const _default: {
3
3
  title: string;
4
4
  type: string;
5
5
  group: string;
6
+ description: string;
6
7
  fieldset: {
7
8
  duration: {
8
9
  type: string;
@@ -12,6 +12,7 @@ var _default = {
12
12
  title: `{{t("Delay", { ns: "${_locale.NAMESPACE}" })}}`,
13
13
  type: 'delay',
14
14
  group: 'control',
15
+ description: `{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${_locale.NAMESPACE}" })}}`,
15
16
  fieldset: {
16
17
  duration: {
17
18
  type: 'number',
@@ -4,17 +4,17 @@ declare const _default: {
4
4
  title: string;
5
5
  type: string;
6
6
  group: string;
7
+ description: string;
7
8
  fieldset: {
8
9
  collection: {
9
10
  type: string;
10
11
  title: string;
11
12
  required: boolean;
12
- 'x-reactions': string[];
13
+ 'x-reactions': any[];
13
14
  'x-decorator': string;
14
15
  'x-component': string;
15
16
  'x-component-props': {
16
17
  dropdownMatchSelectWidth: boolean;
17
- placeholder: string;
18
18
  };
19
19
  };
20
20
  params: {
@@ -24,6 +24,7 @@ var _default = {
24
24
  title: '{{t("Delete record")}}',
25
25
  type: 'destroy',
26
26
  group: 'collection',
27
+ description: `{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${_locale.NAMESPACE}" })}}`,
27
28
  fieldset: {
28
29
  collection: _collection.collection,
29
30
  params: {
@@ -7,6 +7,7 @@ export interface Instruction {
7
7
  title: string;
8
8
  type: string;
9
9
  group: string;
10
+ description?: string;
10
11
  options?: {
11
12
  label: string;
12
13
  value: any;
@@ -22,9 +23,10 @@ export interface Instruction {
22
23
  components?: {
23
24
  [key: string]: any;
24
25
  };
25
- render?(props: any): React.ReactNode;
26
+ render?(props: any): JSX.Element;
26
27
  endding?: boolean;
27
- getOptions?(config: any, types?: any): VariableOptions;
28
+ useVariables?(node: any, options?: any): VariableOptions;
29
+ useScopeVariables?(node: any, options?: any): VariableOptions;
28
30
  useInitializers?(node: any): SchemaInitializerItemOptions | null;
29
31
  initializers?: {
30
32
  [key: string]: any;
@@ -34,6 +36,7 @@ export declare const instructions: Registry<Instruction>;
34
36
  export declare const NodeContext: React.Context<any>;
35
37
  export declare function useNodeContext(): any;
36
38
  export declare function useAvailableUpstreams(node: any): any[];
39
+ export declare function useUpstreamScopes(node: any): any[];
37
40
  export declare function Node({ data }: {
38
41
  data: any;
39
42
  }): JSX.Element;
@@ -11,6 +11,7 @@ exports.RemoveButton = RemoveButton;
11
11
  exports.instructions = void 0;
12
12
  exports.useAvailableUpstreams = useAvailableUpstreams;
13
13
  exports.useNodeContext = useNodeContext;
14
+ exports.useUpstreamScopes = useUpstreamScopes;
14
15
  function _react() {
15
16
  const data = _interopRequireWildcard(require("react"));
16
17
  _react = function _react() {
@@ -73,42 +74,50 @@ var _FlowContext = require("../FlowContext");
73
74
  var _calculation = _interopRequireDefault(require("./calculation"));
74
75
  var _condition = _interopRequireDefault(require("./condition"));
75
76
  var _parallel = _interopRequireDefault(require("./parallel"));
77
+ var _loop = _interopRequireDefault(require("./loop"));
76
78
  var _delay = _interopRequireDefault(require("./delay"));
77
79
  var _manual = _interopRequireDefault(require("./manual"));
78
80
  var _query = _interopRequireDefault(require("./query"));
79
81
  var _create = _interopRequireDefault(require("./create"));
80
82
  var _update = _interopRequireDefault(require("./update"));
81
83
  var _destroy = _interopRequireDefault(require("./destroy"));
84
+ var _aggregate = _interopRequireDefault(require("./aggregate"));
82
85
  var _constants = require("../constants");
83
86
  var _locale = require("../locale");
84
87
  var _request = _interopRequireDefault(require("./request"));
88
+ var _NodeDescription = require("../components/NodeDescription");
89
+ const _excluded = ["job"];
85
90
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
86
91
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
87
92
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
88
- 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; }
89
- 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; }
90
- 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; }
91
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
92
- 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); }
93
93
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
94
94
  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."); }
95
95
  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); }
96
96
  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; }
97
97
  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; } }
98
98
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
99
+ 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; }
100
+ 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; }
101
+ 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; }
102
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
103
+ 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); }
104
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
105
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
99
106
  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); } }
100
107
  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); }); }; }
101
108
  const instructions = new (_client().Registry)();
102
109
  exports.instructions = instructions;
110
+ instructions.register('calculation', _calculation.default);
103
111
  instructions.register('condition', _condition.default);
104
112
  instructions.register('parallel', _parallel.default);
105
- instructions.register('calculation', _calculation.default);
113
+ instructions.register('loop', _loop.default);
106
114
  instructions.register('delay', _delay.default);
107
115
  instructions.register('manual', _manual.default);
108
116
  instructions.register('query', _query.default);
109
117
  instructions.register('create', _create.default);
110
118
  instructions.register('update', _update.default);
111
119
  instructions.register('destroy', _destroy.default);
120
+ instructions.register('aggregate', _aggregate.default);
112
121
  instructions.register('request', _request.default);
113
122
  function useUpdateAction() {
114
123
  const form = (0, _react2().useForm)();
@@ -155,6 +164,18 @@ function useAvailableUpstreams(node) {
155
164
  }
156
165
  return stack;
157
166
  }
167
+ function useUpstreamScopes(node) {
168
+ const stack = [];
169
+ if (!node) {
170
+ return [];
171
+ }
172
+ for (let current = node; current; current = current.upstream) {
173
+ if (current.upstream && current.branchIndex != null) {
174
+ stack.push(current.upstream);
175
+ }
176
+ }
177
+ return stack;
178
+ }
158
179
  function Node({
159
180
  data
160
181
  }) {
@@ -255,106 +276,76 @@ function RemoveButton() {
255
276
  className: "workflow-node-remove-button"
256
277
  });
257
278
  }
279
+ function InnerJobButton(_ref2) {
280
+ let job = _ref2.job,
281
+ props = _objectWithoutProperties(_ref2, _excluded);
282
+ const _JobStatusOptionsMap$ = _constants.JobStatusOptionsMap[job.status],
283
+ icon = _JobStatusOptionsMap$.icon,
284
+ color = _JobStatusOptionsMap$.color;
285
+ return _react().default.createElement(_antd().Button, _objectSpread(_objectSpread({}, props), {}, {
286
+ shape: "circle",
287
+ className: _style.nodeJobButtonClass
288
+ }), _react().default.createElement(_antd().Tag, {
289
+ color: color
290
+ }, icon));
291
+ }
258
292
  function JobButton() {
259
293
  var _useNodeContext;
260
- const compile = (0, _client2().useCompile)();
261
294
  const _useFlowContext3 = (0, _FlowContext.useFlowContext)(),
262
- execution = _useFlowContext3.execution;
263
- const _ref2 = (_useNodeContext = useNodeContext()) !== null && _useNodeContext !== void 0 ? _useNodeContext : {},
264
- id = _ref2.id,
265
- type = _ref2.type,
266
- title = _ref2.title,
267
- job = _ref2.job;
295
+ execution = _useFlowContext3.execution,
296
+ setViewJob = _useFlowContext3.setViewJob;
297
+ const _ref3 = (_useNodeContext = useNodeContext()) !== null && _useNodeContext !== void 0 ? _useNodeContext : {},
298
+ jobs = _ref3.jobs;
268
299
  if (!execution) {
269
300
  return null;
270
301
  }
271
- if (!job) {
302
+ if (!jobs.length) {
272
303
  return _react().default.createElement("span", {
273
- className: (0, _css().cx)('workflow-node-job-button', (0, _css().css)`
304
+ className: (0, _css().cx)(_style.nodeJobButtonClass, (0, _css().css)`
274
305
  border: 2px solid #d9d9d9;
275
306
  border-radius: 50%;
276
307
  cursor: not-allowed;
277
308
  `)
278
309
  });
279
310
  }
280
- const instruction = instructions.get(type);
281
- const _JobStatusOptionsMap$ = _constants.JobStatusOptionsMap[job.status],
282
- value = _JobStatusOptionsMap$.value,
283
- icon = _JobStatusOptionsMap$.icon,
284
- color = _JobStatusOptionsMap$.color;
285
- return _react().default.createElement(_client2().SchemaComponent, {
286
- schema: {
287
- type: 'void',
288
- properties: {
289
- [`${job.id}-button`]: {
290
- type: 'void',
291
- 'x-component': 'Action',
292
- 'x-component-props': {
293
- title: _react().default.createElement(_antd().Tag, {
294
- color: color
295
- }, icon),
296
- shape: 'circle',
297
- className: ['workflow-node-job-button', (0, _css().css)`
298
- .ant-tag {
299
- padding: 0;
300
- width: 100%;
301
- line-height: 18px;
302
- margin-right: 0;
303
- border-radius: 50%;
311
+ function onOpenJob({
312
+ key
313
+ }) {
314
+ const job = jobs.find(item => item.id == key);
315
+ setViewJob(job);
316
+ }
317
+ return jobs.length > 1 ? _react().default.createElement(_antd().Dropdown, {
318
+ menu: {
319
+ items: jobs.map(job => {
320
+ const _JobStatusOptionsMap$2 = _constants.JobStatusOptionsMap[job.status],
321
+ icon = _JobStatusOptionsMap$2.icon,
322
+ color = _JobStatusOptionsMap$2.color;
323
+ return {
324
+ key: job.id,
325
+ label: _react().default.createElement("div", {
326
+ className: (0, _css().css)`
327
+ display: flex;
328
+ gap: 0.5em;
329
+
330
+ time {
331
+ color: #999;
332
+ font-size: 0.8em;
304
333
  }
305
- `]
306
- },
307
- properties: {
308
- [`${job.id}-modal`]: {
309
- type: 'void',
310
- 'x-decorator': 'Form',
311
- 'x-decorator-props': {
312
- initialValue: job
313
- },
314
- 'x-component': 'Action.Modal',
315
- title: _react().default.createElement("div", {
316
- className: (0, _css().cx)(_style.nodeTitleClass)
317
- }, _react().default.createElement(_antd().Tag, null, compile(instruction.title)), _react().default.createElement("strong", null, title), _react().default.createElement("span", {
318
- className: "workflow-node-id"
319
- }, "#", id)),
320
- properties: {
321
- status: {
322
- type: 'number',
323
- title: `{{t("Status", { ns: "${_locale.NAMESPACE}" })}}`,
324
- 'x-decorator': 'FormItem',
325
- 'x-component': 'Select',
326
- enum: _constants.JobStatusOptions,
327
- 'x-read-pretty': true
328
- },
329
- updatedAt: {
330
- type: 'string',
331
- title: `{{t("Executed at", { ns: "${_locale.NAMESPACE}" })}}`,
332
- 'x-decorator': 'FormItem',
333
- 'x-component': 'DatePicker',
334
- 'x-component-props': {
335
- showTime: true
336
- },
337
- 'x-read-pretty': true
338
- },
339
- result: {
340
- type: 'object',
341
- title: `{{t("Node result", { ns: "${_locale.NAMESPACE}" })}}`,
342
- 'x-decorator': 'FormItem',
343
- 'x-component': 'Input.JSON',
344
- 'x-component-props': {
345
- className: (0, _css().css)`
346
- padding: 1em;
347
- background-color: #eee;
348
- `
349
- },
350
- 'x-read-pretty': true
351
- }
352
- }
353
- }
354
- }
355
- }
356
- }
334
+ `
335
+ }, _react().default.createElement("span", {
336
+ className: _style.nodeJobButtonClass
337
+ }, _react().default.createElement(_antd().Tag, {
338
+ color: color
339
+ }, icon)), _react().default.createElement("time", null, (0, _client().str2moment)(job.updatedAt).format('YYYY-MM-DD HH:mm:ss')))
340
+ };
341
+ }),
342
+ onClick: onOpenJob
357
343
  }
344
+ }, _react().default.createElement(InnerJobButton, {
345
+ job: jobs[jobs.length - 1]
346
+ })) : _react().default.createElement(InnerJobButton, {
347
+ job: jobs[0],
348
+ onClick: () => setViewJob(jobs[0])
358
349
  });
359
350
  }
360
351
  function NodeDefaultView(props) {
@@ -363,9 +354,9 @@ function NodeDefaultView(props) {
363
354
  children = props.children;
364
355
  const compile = (0, _client2().useCompile)();
365
356
  const api = (0, _client2().useAPIClient)();
366
- const _ref3 = (_useFlowContext4 = (0, _FlowContext.useFlowContext)()) !== null && _useFlowContext4 !== void 0 ? _useFlowContext4 : {},
367
- workflow = _ref3.workflow,
368
- refresh = _ref3.refresh;
357
+ const _ref4 = (_useFlowContext4 = (0, _FlowContext.useFlowContext)()) !== null && _useFlowContext4 !== void 0 ? _useFlowContext4 : {},
358
+ workflow = _ref4.workflow,
359
+ refresh = _ref4.refresh;
369
360
  const instruction = instructions.get(data.type);
370
361
  const detailText = workflow.executed ? '{{t("View")}}' : '{{t("Configure")}}';
371
362
  const typeTitle = compile(instruction.title);
@@ -404,7 +395,7 @@ function NodeDefaultView(props) {
404
395
  return;
405
396
  }
406
397
  const whiteSet = new Set(['workflow-node-meta', 'workflow-node-config-button', 'ant-input-disabled']);
407
- for (let el = ev.target; el && el !== ev.currentTarget; el = el.parentNode) {
398
+ for (let el = ev.target; el && el !== ev.currentTarget && el !== document.documentElement; el = el.parentNode) {
408
399
  if (Array.from(el.classList).some(name => whiteSet.has(name))) {
409
400
  setEditingConfig(true);
410
401
  ev.stopPropagation();
@@ -453,7 +444,7 @@ function NodeDefaultView(props) {
453
444
  },
454
445
  [`${instruction.type}_${data.id}`]: {
455
446
  type: 'void',
456
- title: instruction.title,
447
+ title: data.title,
457
448
  'x-component': 'Action.Drawer',
458
449
  'x-decorator': 'Form',
459
450
  'x-decorator-props': {
@@ -483,6 +474,14 @@ function NodeDefaultView(props) {
483
474
  `
484
475
  }
485
476
  }
477
+ } : instruction.description ? {
478
+ description: {
479
+ type: 'void',
480
+ 'x-component': _NodeDescription.NodeDescription,
481
+ 'x-component-props': {
482
+ instruction
483
+ }
484
+ }
486
485
  } : {}), {}, {
487
486
  fieldset: {
488
487
  type: 'void',
@@ -499,7 +498,6 @@ function NodeDefaultView(props) {
499
498
  min-width: 6em;
500
499
  }
501
500
  }
502
-
503
501
  .ant-input-affix-wrapper {
504
502
  &:not(.full-width) {
505
503
  .ant-input {
@@ -0,0 +1,29 @@
1
+ import { useWorkflowVariableOptions, VariableOption } from '../variable';
2
+ declare const _default: {
3
+ title: string;
4
+ type: string;
5
+ group: string;
6
+ description: string;
7
+ fieldset: {
8
+ target: {
9
+ type: string;
10
+ title: string;
11
+ description: string;
12
+ 'x-decorator': string;
13
+ 'x-component': string;
14
+ 'x-component-props': {
15
+ scope: string;
16
+ useTypedConstant: string[];
17
+ };
18
+ required: boolean;
19
+ };
20
+ };
21
+ view: {};
22
+ render: (data: any) => JSX.Element;
23
+ scope: {
24
+ useWorkflowVariableOptions: typeof useWorkflowVariableOptions;
25
+ };
26
+ components: {};
27
+ useScopeVariables(node: any, options: any): VariableOption[];
28
+ };
29
+ export default _default;