@nocobase/plugin-workflow 0.9.2-alpha.2 → 0.9.2-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/lib/client/AddButton.js +1 -3
  2. package/lib/client/Branch.d.ts +1 -1
  3. package/lib/client/ExecutionCanvas.js +1 -1
  4. package/lib/client/FlowContext.d.ts +1 -1
  5. package/lib/client/WorkflowProvider.js +0 -1
  6. package/lib/client/components/CollectionFieldset.d.ts +1 -1
  7. package/lib/client/components/CollectionFieldset.js +13 -13
  8. package/lib/client/components/Duration.js +3 -3
  9. package/lib/client/components/DynamicExpression.d.ts +1 -1
  10. package/lib/client/components/DynamicExpression.js +19 -19
  11. package/lib/client/components/RadioWithTooltip.js +4 -4
  12. package/lib/client/components/renderEngineReference.js +12 -11
  13. package/lib/client/interfaces/expression.d.ts +1 -1
  14. package/lib/client/interfaces/expression.js +2 -1
  15. package/lib/client/locale/en-US.d.ts +70 -70
  16. package/lib/client/locale/en-US.js +115 -115
  17. package/lib/client/locale/ja-JP.d.ts +57 -57
  18. package/lib/client/locale/ja-JP.js +85 -85
  19. package/lib/client/locale/pt-BR.d.ts +70 -70
  20. package/lib/client/locale/pt-BR.js +115 -115
  21. package/lib/client/locale/ru-RU.d.ts +57 -57
  22. package/lib/client/locale/ru-RU.js +85 -85
  23. package/lib/client/locale/tr-TR.d.ts +57 -57
  24. package/lib/client/locale/tr-TR.js +85 -85
  25. package/lib/client/locale/zh-CN.js +55 -55
  26. package/lib/client/nodes/calculation.d.ts +1 -1
  27. package/lib/client/nodes/calculation.js +29 -29
  28. package/lib/client/nodes/condition.d.ts +3 -3
  29. package/lib/client/nodes/condition.js +76 -72
  30. package/lib/client/nodes/delay.d.ts +1 -1
  31. package/lib/client/nodes/index.js +35 -37
  32. package/lib/client/nodes/manual/ModeConfig.js +5 -5
  33. package/lib/client/nodes/manual/SchemaConfig.js +2 -5
  34. package/lib/client/nodes/manual/WorkflowTodo.js +3 -3
  35. package/lib/client/nodes/manual/forms/customForm.js +1 -2
  36. package/lib/client/nodes/parallel.d.ts +1 -1
  37. package/lib/client/nodes/parallel.js +6 -6
  38. package/lib/client/nodes/request.d.ts +2 -0
  39. package/lib/client/nodes/request.js +7 -5
  40. package/lib/client/style.js +67 -63
  41. package/lib/client/triggers/index.d.ts +4 -4
  42. package/lib/client/triggers/index.js +5 -7
  43. package/lib/client/triggers/schedule/DateFieldsSelect.d.ts +1 -1
  44. package/lib/client/triggers/schedule/EndsByField.js +3 -3
  45. package/lib/client/triggers/schedule/OnField.js +3 -3
  46. package/lib/client/triggers/schedule/RepeatField.js +16 -16
  47. package/lib/client/triggers/schedule/ScheduleConfig.js +2 -2
  48. package/lib/client/utils.js +1 -1
  49. package/lib/client/variable.js +4 -4
  50. package/lib/server/Processor.d.ts +2 -2
  51. package/lib/server/Processor.js +8 -8
  52. package/lib/server/functions/index.d.ts +1 -1
  53. package/lib/server/functions/index.js +1 -2
  54. package/lib/server/instructions/calculation.d.ts +1 -1
  55. package/lib/server/instructions/calculation.js +7 -7
  56. package/lib/server/instructions/condition.d.ts +2 -2
  57. package/lib/server/instructions/condition.js +7 -8
  58. package/lib/server/instructions/create.d.ts +1 -1
  59. package/lib/server/instructions/destroy.d.ts +1 -1
  60. package/lib/server/instructions/manual/index.js +1 -2
  61. package/lib/server/instructions/parallel.d.ts +3 -3
  62. package/lib/server/instructions/query.d.ts +2 -2
  63. package/lib/server/instructions/request.js +0 -1
  64. package/lib/server/instructions/update.d.ts +2 -2
  65. package/lib/server/migrations/20230221071831-calculation-expression.js +11 -11
  66. package/lib/server/migrations/20230221121203-condition-calculation.js +6 -6
  67. package/lib/server/migrations/20230221162902-jsonb-to-json.js +3 -5
  68. package/lib/server/migrations/20230411034722-manual-multi-form.js +3 -2
  69. package/lib/server/triggers/collection.d.ts +2 -2
  70. package/lib/server/triggers/collection.js +2 -2
  71. package/lib/server/triggers/schedule.js +26 -20
  72. package/package.json +12 -12
@@ -61,9 +61,9 @@ function OnField({
61
61
  setDir = _useState2[1];
62
62
  return _react().default.createElement("fieldset", {
63
63
  className: (0, _css().css)`
64
- display: flex;
65
- gap: .5em;
66
- `
64
+ display: flex;
65
+ gap: 0.5em;
66
+ `
67
67
  }, _react().default.createElement(_DateFieldsSelect.DateFieldsSelect, {
68
68
  value: value.field,
69
69
  onChange: field => _onChange(_objectSpread(_objectSpread({}, value), {}, {
@@ -115,28 +115,28 @@ function RepeatField({
115
115
  const locale = languages[localStorage.getItem('NOCOBASE_LOCALE') || 'en-US'];
116
116
  return _react().default.createElement("fieldset", {
117
117
  className: (0, _css().css)`
118
- display: flex;
119
- flex-direction: ${typeValue === 'cron' ? 'column' : 'row'};
120
- align-items: flex-start;
121
- gap: .5em;
118
+ display: flex;
119
+ flex-direction: ${typeValue === 'cron' ? 'column' : 'row'};
120
+ align-items: flex-start;
121
+ gap: 0.5em;
122
122
 
123
- .react-js-cron{
124
- padding: .5em .5em 0 .5em;
125
- border: 1px dashed #ccc;
123
+ .react-js-cron {
124
+ padding: 0.5em 0.5em 0 0.5em;
125
+ border: 1px dashed #ccc;
126
126
 
127
- .react-js-cron-field{
128
- margin-bottom: .5em;
127
+ .react-js-cron-field {
128
+ margin-bottom: 0.5em;
129
129
 
130
- > span{
131
- margin: 0 .5em 0 0;
132
- }
130
+ > span {
131
+ margin: 0 0.5em 0 0;
132
+ }
133
133
 
134
- > .react-js-cron-select{
135
- margin: 0 .5em 0 0;
134
+ > .react-js-cron-select {
135
+ margin: 0 0.5em 0 0;
136
+ }
136
137
  }
137
138
  }
138
- }
139
- `
139
+ `
140
140
  }, _react().default.createElement(_antd().Select, {
141
141
  value: typeValue,
142
142
  onChange: onTypeChange
@@ -225,11 +225,11 @@ const ScheduleConfig = () => {
225
225
  'x-component': 'fieldset',
226
226
  'x-component-props': {
227
227
  className: (0, _css().css)`
228
- .ant-input-number{
228
+ .ant-input-number {
229
229
  width: 4em;
230
230
  }
231
231
 
232
- .ant-picker{
232
+ .ant-picker {
233
233
  width: auto;
234
234
  }
235
235
  `
@@ -19,7 +19,7 @@ function linkNodes(nodes) {
19
19
  _step;
20
20
  try {
21
21
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
22
- let node = _step.value;
22
+ const node = _step.value;
23
23
  if (node.upstreamId) {
24
24
  node.upstream = nodesMap.get(node.upstreamId);
25
25
  }
@@ -107,7 +107,7 @@ function filterTypedFields(fields, types, depth = 1) {
107
107
  return fields;
108
108
  }
109
109
  return fields.filter(field => {
110
- if (isAssociationField(field) && depth && filterTypedFields(useNormallizedFields(field.target), types, depth - 1).length) {
110
+ if (isAssociationField(field) && depth && filterTypedFields(useNormalizedFields(field.target), types, depth - 1).length) {
111
111
  return true;
112
112
  }
113
113
  return types.some(type => matchFieldType(field, type));
@@ -127,7 +127,7 @@ function useWorkflowVariableOptions(types) {
127
127
  });
128
128
  return options;
129
129
  }
130
- function useNormallizedFields(collectionName) {
130
+ function useNormalizedFields(collectionName) {
131
131
  const compile = (0, _client().useCompile)();
132
132
  const _useCollectionManager = (0, _client().useCollectionManager)(),
133
133
  getCollection = _useCollectionManager.getCollection;
@@ -151,7 +151,7 @@ function useNormallizedFields(collectionName) {
151
151
  const foreignKeyField = foreignKeyFields.find(f => f.name === field.foreignKey);
152
152
  if (foreignKeyField) {
153
153
  var _field$uiSchema, _field$uiSchema2;
154
- otherFields.splice(i, 0, _objectSpread(_objectSpread({}, foreignKeyField), {}, {
154
+ otherFields.splice(i, 0, _objectSpread(_objectSpread(_objectSpread({}, field), foreignKeyField), {}, {
155
155
  uiSchema: _objectSpread(_objectSpread({}, field.uiSchema), {}, {
156
156
  title: ((_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.title) ? `${compile((_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title)} ID` : foreignKeyField.name
157
157
  })
@@ -189,7 +189,7 @@ function useCollectionFieldOptions(options) {
189
189
  _options$depth = options.depth,
190
190
  depth = _options$depth === void 0 ? 1 : _options$depth;
191
191
  const compile = (0, _client().useCompile)();
192
- const normalizedFields = fields !== null && fields !== void 0 ? fields : useNormallizedFields(collection);
192
+ const normalizedFields = fields !== null && fields !== void 0 ? fields : useNormalizedFields(collection);
193
193
  const result = filterTypedFields(normalizedFields, types, depth).filter(field => !isAssociationField(field) || depth).map(field => {
194
194
  var _field$uiSchema5;
195
195
  const label = compile(((_field$uiSchema5 = field.uiSchema) === null || _field$uiSchema5 === void 0 ? void 0 : _field$uiSchema5.title) || field.name);
@@ -1,9 +1,9 @@
1
+ import { Logger } from '@nocobase/logger';
1
2
  import { Transaction, Transactionable } from 'sequelize';
2
3
  import Plugin from '.';
3
4
  import ExecutionModel from './models/Execution';
4
- import JobModel from './models/Job';
5
5
  import FlowNodeModel from './models/FlowNode';
6
- import { Logger } from '@nocobase/logger';
6
+ import JobModel from './models/Job';
7
7
  export interface ProcessorOptions extends Transactionable {
8
8
  plugin: Plugin;
9
9
  }
@@ -4,13 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- function _jsonTemplates() {
8
- const data = _interopRequireDefault(require("json-templates"));
9
- _jsonTemplates = function _jsonTemplates() {
10
- return data;
11
- };
12
- return data;
13
- }
14
7
  function _database() {
15
8
  const data = require("@nocobase/database");
16
9
  _database = function _database() {
@@ -25,6 +18,13 @@ function _evaluators() {
25
18
  };
26
19
  return data;
27
20
  }
21
+ function _jsonTemplates() {
22
+ const data = _interopRequireDefault(require("json-templates"));
23
+ _jsonTemplates = function _jsonTemplates() {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
28
  var _constants = require("./constants");
29
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
30
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -333,7 +333,7 @@ class Processor {
333
333
  _step;
334
334
  try {
335
335
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
336
- let _step$value = _slicedToArray(_step.value, 2),
336
+ const _step$value = _slicedToArray(_step.value, 2),
337
337
  name = _step$value[0],
338
338
  fn = _step$value[1];
339
339
  systemFns[name] = fn.bind(scope);
@@ -1,4 +1,4 @@
1
- import Plugin from "..";
1
+ import Plugin from '..';
2
2
  export default function ({ functions }: Plugin, more?: {
3
3
  [key: string]: Function;
4
4
  }): void;
@@ -23,5 +23,4 @@ function _default({
23
23
  fn = _Object$entries$_i[1];
24
24
  functions.register(name, fn);
25
25
  }
26
- }
27
- ;
26
+ }
@@ -1,3 +1,3 @@
1
- import { Instruction } from ".";
1
+ import { Instruction } from '.';
2
2
  declare const _default: Instruction;
3
3
  export default _default;
@@ -4,16 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- function _jsonTemplates() {
8
- const data = _interopRequireDefault(require("json-templates"));
9
- _jsonTemplates = function _jsonTemplates() {
7
+ function _evaluators() {
8
+ const data = require("@nocobase/evaluators");
9
+ _evaluators = function _evaluators() {
10
10
  return data;
11
11
  };
12
12
  return data;
13
13
  }
14
- function _evaluators() {
15
- const data = _interopRequireDefault(require("@nocobase/evaluators"));
16
- _evaluators = function _evaluators() {
14
+ function _jsonTemplates() {
15
+ const data = _interopRequireDefault(require("json-templates"));
16
+ _jsonTemplates = function _jsonTemplates() {
17
17
  return data;
18
18
  };
19
19
  return data;
@@ -41,7 +41,7 @@ var _default = {
41
41
  expression = parsed.expression;
42
42
  scope = (_parse2 = (0, _jsonTemplates().default)((_node$config$scope = node.config.scope) !== null && _node$config$scope !== void 0 ? _node$config$scope : '')(scope)) !== null && _parse2 !== void 0 ? _parse2 : {};
43
43
  }
44
- const evaluator = _evaluators().default.get(engine);
44
+ const evaluator = _evaluators().evaluators.get(engine);
45
45
  try {
46
46
  const result = evaluator && expression ? evaluator(expression, scope) : null;
47
47
  return {
@@ -1,5 +1,5 @@
1
- import { Registry } from "@nocobase/utils";
2
- import { Instruction } from ".";
1
+ import { Registry } from '@nocobase/utils';
2
+ import { Instruction } from '.';
3
3
  export declare const calculators: Registry<Function>;
4
4
  declare const _default: Instruction;
5
5
  export default _default;
@@ -4,22 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.calculators = void 0;
7
- function _utils() {
8
- const data = require("@nocobase/utils");
9
- _utils = function _utils() {
7
+ function _evaluators() {
8
+ const data = require("@nocobase/evaluators");
9
+ _evaluators = function _evaluators() {
10
10
  return data;
11
11
  };
12
12
  return data;
13
13
  }
14
- function _evaluators() {
15
- const data = _interopRequireDefault(require("@nocobase/evaluators"));
16
- _evaluators = function _evaluators() {
14
+ function _utils() {
15
+ const data = require("@nocobase/utils");
16
+ _utils = function _utils() {
17
17
  return data;
18
18
  };
19
19
  return data;
20
20
  }
21
21
  var _constants = require("../constants");
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
22
  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); } }
24
23
  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); }); }; }
25
24
  const calculators = new (_utils().Registry)();
@@ -106,7 +105,7 @@ var _default = {
106
105
  calculation = _ref.calculation,
107
106
  expression = _ref.expression,
108
107
  rejectOnFalse = _ref.rejectOnFalse;
109
- const evaluator = _evaluators().default.get(engine);
108
+ const evaluator = _evaluators().evaluators.get(engine);
110
109
  let result = true;
111
110
  try {
112
111
  result = evaluator ? evaluator(expression, processor.getScope()) : logicCalculate(processor.getParsedValue(calculation));
@@ -1,4 +1,4 @@
1
- import FlowNodeModel from "../models/FlowNode";
1
+ import FlowNodeModel from '../models/FlowNode';
2
2
  declare const _default: {
3
3
  run(node: FlowNodeModel, input: any, processor: any): Promise<{
4
4
  result: any;
@@ -1,4 +1,4 @@
1
- import FlowNodeModel from "../models/FlowNode";
1
+ import FlowNodeModel from '../models/FlowNode';
2
2
  declare const _default: {
3
3
  run(node: FlowNodeModel, input: any, processor: any): Promise<{
4
4
  result: any;
@@ -158,5 +158,4 @@ class _default {
158
158
  })();
159
159
  }
160
160
  }
161
- exports.default = _default;
162
- ;
161
+ exports.default = _default;
@@ -1,6 +1,6 @@
1
- import FlowNodeModel from "../models/FlowNode";
2
- import JobModel from "../models/Job";
3
- import Processor from "../Processor";
1
+ import FlowNodeModel from '../models/FlowNode';
2
+ import JobModel from '../models/Job';
3
+ import Processor from '../Processor';
4
4
  export declare const PARALLEL_MODE: {
5
5
  readonly ALL: "all";
6
6
  readonly ANY: "any";
@@ -1,5 +1,5 @@
1
- import FlowNodeModel from "../models/FlowNode";
2
- import Processor from "../Processor";
1
+ import FlowNodeModel from '../models/FlowNode';
2
+ import Processor from '../Processor';
3
3
  declare const _default: {
4
4
  run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
5
5
  result: any;
@@ -52,7 +52,6 @@ function _request() {
52
52
  });
53
53
  return _request.apply(this, arguments);
54
54
  }
55
- ;
56
55
  class _default {
57
56
  constructor(plugin) {
58
57
  this.plugin = void 0;
@@ -1,5 +1,5 @@
1
- import FlowNodeModel from "../models/FlowNode";
2
- import Processor from "../Processor";
1
+ import FlowNodeModel from '../models/FlowNode';
2
+ import Processor from '../Processor';
3
3
  declare const _default: {
4
4
  run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
5
5
  result: any;
@@ -26,19 +26,19 @@ function addQuote(v) {
26
26
  return `'${v}'`;
27
27
  }
28
28
  const calculatorsMap = {
29
- 'equal': '==',
29
+ equal: '==',
30
30
  '===': '==',
31
- 'notEqual': '!=',
31
+ notEqual: '!=',
32
32
  '!==': '!=',
33
- 'gt': '>',
34
- 'gte': '>=',
35
- 'lt': '<',
36
- 'lte': '<=',
37
- 'add': '+',
38
- 'minus': '-',
39
- 'multiple': '*',
40
- 'divide': '/',
41
- 'mod': '%',
33
+ gt: '>',
34
+ gte: '>=',
35
+ lt: '<',
36
+ lte: '<=',
37
+ add: '+',
38
+ minus: '-',
39
+ multiple: '*',
40
+ divide: '/',
41
+ mod: '%',
42
42
  includes(a, b) {
43
43
  return `SEARCH(${b}, ${a}) >= 0`;
44
44
  },
@@ -19,14 +19,14 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
19
19
  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); } }
20
20
  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); }); }; }
21
21
  const calculatorsMap = {
22
- 'equal': '==',
22
+ equal: '==',
23
23
  '===': '==',
24
- 'notEqual': '!=',
24
+ notEqual: '!=',
25
25
  '!==': '!=',
26
- 'gt': '>',
27
- 'gte': '>=',
28
- 'lt': '<',
29
- 'lte': '<=',
26
+ gt: '>',
27
+ gte: '>=',
28
+ lt: '<',
29
+ lte: '<=',
30
30
  includes(a, b) {
31
31
  return `SEARCH('${b}', '${a}') >= 0`;
32
32
  },
@@ -22,16 +22,14 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
22
22
  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); }); }; }
23
23
  class _default extends _server().Migration {
24
24
  up() {
25
- var _arguments = arguments,
26
- _this = this;
25
+ var _this = this;
27
26
  return _asyncToGenerator(function* () {
28
27
  const match = yield _this.app.version.satisfies('<0.9.0-alpha.3');
29
28
  if (!match) {
30
29
  return;
31
30
  }
32
- const _arguments$0$context = _arguments[0].context,
33
- sequelize = _arguments$0$context.sequelize,
34
- queryInterface = _arguments$0$context.queryInterface;
31
+ const sequelize = _this.sequelize;
32
+ const queryInterface = _this.queryInterface;
35
33
  const db = _this.app.db;
36
34
  yield sequelize.transaction( /*#__PURE__*/function () {
37
35
  var _ref = _asyncToGenerator(function* (transaction) {
@@ -185,7 +185,7 @@ function migrateUsedConfig(config, manualForms) {
185
185
  }
186
186
  return `{{$jobsMapByNodeId.${id}.${manualForms[id]}${path || ''}}}`;
187
187
  });
188
- } else if (valueType === 'object') {
188
+ } else if (valueType === 'object' && config[key]) {
189
189
  migrateUsedConfig(config[key], manualForms);
190
190
  }
191
191
  });
@@ -285,8 +285,9 @@ class _default extends _server().Migration {
285
285
  }
286
286
  });
287
287
  yield usedNodes.reduce((promise, node) => promise.then( /*#__PURE__*/_asyncToGenerator(function* () {
288
+ var _node$config2;
288
289
  yield node.update({
289
- config: migrateUsedConfig((0, _lodash().cloneDeep)(node.config), nodeForms)
290
+ config: migrateUsedConfig((0, _lodash().cloneDeep)((_node$config2 = node.config) !== null && _node$config2 !== void 0 ? _node$config2 : {}), nodeForms)
290
291
  }, {
291
292
  silent: true,
292
293
  transaction
@@ -1,5 +1,5 @@
1
- import { Trigger } from "..";
2
- import WorkflowModel from "../models/Workflow";
1
+ import { Trigger } from '..';
2
+ import WorkflowModel from '../models/Workflow';
3
3
  export interface CollectionChangeTriggerConfig {
4
4
  collection: string;
5
5
  mode: number;
@@ -112,7 +112,7 @@ class CollectionTrigger extends _.Trigger {
112
112
  _step;
113
113
  try {
114
114
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
115
- let _step$value = _slicedToArray(_step.value, 2),
115
+ const _step$value = _slicedToArray(_step.value, 2),
116
116
  key = _step$value[0],
117
117
  type = _step$value[1];
118
118
  const event = `${collection}.${type}`;
@@ -150,7 +150,7 @@ class CollectionTrigger extends _.Trigger {
150
150
  _step2;
151
151
  try {
152
152
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
153
- let _step2$value = _slicedToArray(_step2.value, 2),
153
+ const _step2$value = _slicedToArray(_step2.value, 2),
154
154
  key = _step2$value[0],
155
155
  type = _step2$value[1];
156
156
  const event = `${collection}.${type}`;
@@ -106,18 +106,20 @@ function getOnTimestampWithOffset(on, now) {
106
106
  case 'string':
107
107
  return parseDateWithoutMs(on);
108
108
  case 'object':
109
- const field = on.field,
110
- _on$offset = on.offset,
111
- offset = _on$offset === void 0 ? 0 : _on$offset,
112
- _on$unit = on.unit,
113
- unit = _on$unit === void 0 ? 1000 : _on$unit;
114
- if (!field) {
115
- return null;
109
+ {
110
+ const field = on.field,
111
+ _on$offset = on.offset,
112
+ offset = _on$offset === void 0 ? 0 : _on$offset,
113
+ _on$unit = on.unit,
114
+ unit = _on$unit === void 0 ? 1000 : _on$unit;
115
+ if (!field) {
116
+ return null;
117
+ }
118
+ const timestamp = now.getTime();
119
+ // onDate + offset > now
120
+ // onDate > now - offset
121
+ return timestamp - offset * unit;
116
122
  }
117
- const timestamp = now.getTime();
118
- // onDate + offset > now
119
- // onDate > now - offset
120
- return timestamp - offset * unit;
121
123
  default:
122
124
  return null;
123
125
  }
@@ -128,15 +130,19 @@ function getDataOptionTime(data, on, dir = 1) {
128
130
  }
129
131
  switch (typeof on) {
130
132
  case 'string':
131
- const time = parseDateWithoutMs(on);
132
- return time ? time : null;
133
+ {
134
+ const time = parseDateWithoutMs(on);
135
+ return time ? time : null;
136
+ }
133
137
  case 'object':
134
- const field = on.field,
135
- _on$offset2 = on.offset,
136
- offset = _on$offset2 === void 0 ? 0 : _on$offset2,
137
- _on$unit2 = on.unit,
138
- unit = _on$unit2 === void 0 ? 1000 : _on$unit2;
139
- return data.get(field) ? data.get(field).getTime() - offset * unit * dir : null;
138
+ {
139
+ const field = on.field,
140
+ _on$offset2 = on.offset,
141
+ offset = _on$offset2 === void 0 ? 0 : _on$offset2,
142
+ _on$unit2 = on.unit,
143
+ unit = _on$unit2 === void 0 ? 1000 : _on$unit2;
144
+ return data.get(field) ? data.get(field).getTime() - offset * unit * dir : null;
145
+ }
140
146
  default:
141
147
  return null;
142
148
  }
@@ -365,7 +371,7 @@ function matchNext(workflow, now, range = this.cacheCycle) {
365
371
  const interval = _cronParser().default.parseExpression(repeat, {
366
372
  currentDate
367
373
  });
368
- let next = interval.next();
374
+ const next = interval.next();
369
375
  // NOTE: cache all workflows will be matched in current cycle
370
376
  if (next.getTime() - timestamp <= range) {
371
377
  return true;
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-workflow",
3
- "version": "0.9.2-alpha.2",
3
+ "version": "0.9.2-alpha.4",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "dependencies": {
9
- "@nocobase/actions": "0.9.2-alpha.2",
10
- "@nocobase/client": "0.9.2-alpha.2",
11
- "@nocobase/database": "0.9.2-alpha.2",
12
- "@nocobase/evaluators": "0.9.2-alpha.2",
13
- "@nocobase/logger": "0.9.2-alpha.2",
14
- "@nocobase/resourcer": "0.9.2-alpha.2",
15
- "@nocobase/server": "0.9.2-alpha.2",
16
- "@nocobase/utils": "0.9.2-alpha.2",
9
+ "@nocobase/actions": "0.9.2-alpha.4",
10
+ "@nocobase/client": "0.9.2-alpha.4",
11
+ "@nocobase/database": "0.9.2-alpha.4",
12
+ "@nocobase/evaluators": "0.9.2-alpha.4",
13
+ "@nocobase/logger": "0.9.2-alpha.4",
14
+ "@nocobase/resourcer": "0.9.2-alpha.4",
15
+ "@nocobase/server": "0.9.2-alpha.4",
16
+ "@nocobase/utils": "0.9.2-alpha.4",
17
17
  "antd": "4.22.8",
18
18
  "axios": "^0.27.2",
19
19
  "classnames": "^2.3.1",
@@ -24,9 +24,9 @@
24
24
  "react-js-cron": "^3.1.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@nocobase/plugin-formula-field": "0.9.2-alpha.2",
28
- "@nocobase/test": "0.9.2-alpha.2",
27
+ "@nocobase/plugin-formula-field": "0.9.2-alpha.4",
28
+ "@nocobase/test": "0.9.2-alpha.4",
29
29
  "@types/ejs": "^3.1.1"
30
30
  },
31
- "gitHead": "1a0de6908b2b1854bdf434fcafa8909cb65bb8a3"
31
+ "gitHead": "96cb023f353a4fb099dea074c575be65ebab813f"
32
32
  }