@nocobase/plugin-workflow 2.1.0-alpha.2 → 2.1.0-alpha.20

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 (136) hide show
  1. package/LICENSE +201 -661
  2. package/README.md +79 -10
  3. package/dist/client/214.88c6cd534bd4fc1c.js +10 -0
  4. package/dist/client/261.404a35cf5ae2ceba.js +10 -0
  5. package/dist/client/67.f904ef4520868b8a.js +10 -0
  6. package/dist/client/964.6251d37b35710747.js +10 -0
  7. package/dist/client/hooks/{useWorkflowFilterActionProps.d.ts → useResourceFilterActionProps.d.ts} +1 -1
  8. package/dist/client/index.js +1 -1
  9. package/dist/client/nodes/create.d.ts +10 -0
  10. package/dist/client/nodes/destroy.d.ts +10 -0
  11. package/dist/client/nodes/index.d.ts +3 -0
  12. package/dist/client/nodes/query.d.ts +18 -2
  13. package/dist/client/nodes/update.d.ts +10 -0
  14. package/dist/client/schemas/collection.d.ts +8 -2
  15. package/dist/client/schemas/executions.d.ts +41 -22
  16. package/dist/client/triggers/collection.d.ts +14 -1
  17. package/dist/client/triggers/index.d.ts +4 -0
  18. package/dist/client/triggers/schedule/constants.d.ts +4 -0
  19. package/dist/client/triggers/schedule/index.d.ts +15 -0
  20. package/dist/common/collections/executions.d.ts +22 -22
  21. package/dist/common/collections/executions.js +12 -0
  22. package/dist/common/collections/jobs.js +7 -0
  23. package/dist/common/collections/workflows.d.ts +22 -9
  24. package/dist/common/collections/workflows.js +9 -1
  25. package/dist/externalVersion.js +15 -13
  26. package/dist/locale/zh-CN.json +4 -1
  27. package/dist/node_modules/cron-parser/package.json +1 -1
  28. package/dist/node_modules/joi/dist/joi-browser.min.js +1 -0
  29. package/dist/node_modules/joi/lib/annotate.js +175 -0
  30. package/dist/node_modules/joi/lib/base.js +1069 -0
  31. package/dist/node_modules/joi/lib/cache.js +143 -0
  32. package/dist/node_modules/joi/lib/common.js +216 -0
  33. package/dist/node_modules/joi/lib/compile.js +283 -0
  34. package/dist/node_modules/joi/lib/errors.js +271 -0
  35. package/dist/node_modules/joi/lib/extend.js +312 -0
  36. package/dist/node_modules/joi/lib/index.d.ts +2365 -0
  37. package/dist/node_modules/joi/lib/index.js +1 -0
  38. package/dist/node_modules/joi/lib/manifest.js +476 -0
  39. package/dist/node_modules/joi/lib/messages.js +178 -0
  40. package/dist/node_modules/joi/lib/modify.js +267 -0
  41. package/dist/node_modules/joi/lib/ref.js +414 -0
  42. package/dist/node_modules/joi/lib/schemas.js +302 -0
  43. package/dist/node_modules/joi/lib/state.js +166 -0
  44. package/dist/node_modules/joi/lib/template.js +463 -0
  45. package/dist/node_modules/joi/lib/trace.js +346 -0
  46. package/dist/node_modules/joi/lib/types/alternatives.js +364 -0
  47. package/dist/node_modules/joi/lib/types/any.js +174 -0
  48. package/dist/node_modules/joi/lib/types/array.js +809 -0
  49. package/dist/node_modules/joi/lib/types/binary.js +100 -0
  50. package/dist/node_modules/joi/lib/types/boolean.js +150 -0
  51. package/dist/node_modules/joi/lib/types/date.js +233 -0
  52. package/dist/node_modules/joi/lib/types/function.js +93 -0
  53. package/dist/node_modules/joi/lib/types/keys.js +1067 -0
  54. package/dist/node_modules/joi/lib/types/link.js +168 -0
  55. package/dist/node_modules/joi/lib/types/number.js +363 -0
  56. package/dist/node_modules/joi/lib/types/object.js +22 -0
  57. package/dist/node_modules/joi/lib/types/string.js +850 -0
  58. package/dist/node_modules/joi/lib/types/symbol.js +102 -0
  59. package/dist/node_modules/joi/lib/validator.js +750 -0
  60. package/dist/node_modules/joi/lib/values.js +263 -0
  61. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.d.ts +60 -0
  62. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.js +225 -0
  63. package/dist/node_modules/joi/node_modules/@hapi/topo/package.json +30 -0
  64. package/dist/node_modules/joi/package.json +1 -0
  65. package/dist/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts +5 -0
  66. package/dist/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +10 -0
  67. package/dist/node_modules/lru-cache/dist/commonjs/index.d.ts +1381 -0
  68. package/dist/node_modules/lru-cache/dist/commonjs/index.js +1692 -0
  69. package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -0
  70. package/dist/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +5 -0
  71. package/dist/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
  72. package/dist/node_modules/lru-cache/dist/esm/browser/index.d.ts +1381 -0
  73. package/dist/node_modules/lru-cache/dist/{mjs → esm/browser}/index.js +537 -179
  74. package/dist/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
  75. package/dist/node_modules/lru-cache/dist/esm/diagnostics-channel.d.ts +5 -0
  76. package/dist/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
  77. package/dist/node_modules/lru-cache/dist/esm/index.d.ts +1381 -0
  78. package/dist/node_modules/lru-cache/dist/{cjs → esm}/index.js +538 -184
  79. package/dist/node_modules/lru-cache/dist/esm/index.min.js +2 -0
  80. package/dist/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +5 -0
  81. package/dist/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +7 -0
  82. package/dist/node_modules/lru-cache/dist/esm/node/index.d.ts +1381 -0
  83. package/dist/node_modules/lru-cache/dist/esm/node/index.js +1688 -0
  84. package/dist/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
  85. package/dist/node_modules/lru-cache/package.json +1 -1
  86. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  87. package/dist/server/Dispatcher.d.ts +3 -2
  88. package/dist/server/Dispatcher.js +74 -61
  89. package/dist/server/Plugin.d.ts +1 -0
  90. package/dist/server/Plugin.js +28 -2
  91. package/dist/server/actions/nodes.d.ts +5 -0
  92. package/dist/server/actions/nodes.js +34 -2
  93. package/dist/server/actions/workflows.d.ts +6 -0
  94. package/dist/server/actions/workflows.js +38 -0
  95. package/dist/server/instructions/ConditionInstruction.d.ts +2 -0
  96. package/dist/server/instructions/ConditionInstruction.js +17 -0
  97. package/dist/server/instructions/CreateInstruction.d.ts +3 -0
  98. package/dist/server/instructions/CreateInstruction.js +25 -0
  99. package/dist/server/instructions/DestroyInstruction.d.ts +3 -0
  100. package/dist/server/instructions/DestroyInstruction.js +25 -0
  101. package/dist/server/instructions/EndInstruction.d.ts +2 -0
  102. package/dist/server/instructions/EndInstruction.js +4 -0
  103. package/dist/server/instructions/MultiConditionsInstruction.d.ts +2 -0
  104. package/dist/server/instructions/MultiConditionsInstruction.js +23 -0
  105. package/dist/server/instructions/OutputInstruction.d.ts +2 -0
  106. package/dist/server/instructions/OutputInstruction.js +14 -0
  107. package/dist/server/instructions/QueryInstruction.d.ts +3 -0
  108. package/dist/server/instructions/QueryInstruction.js +32 -7
  109. package/dist/server/instructions/UpdateInstruction.d.ts +3 -0
  110. package/dist/server/instructions/UpdateInstruction.js +27 -0
  111. package/dist/server/instructions/index.d.ts +4 -0
  112. package/dist/server/instructions/index.js +18 -0
  113. package/dist/server/triggers/CollectionTrigger.d.ts +3 -0
  114. package/dist/server/triggers/CollectionTrigger.js +28 -0
  115. package/dist/server/triggers/ScheduleTrigger/index.d.ts +3 -0
  116. package/dist/server/triggers/ScheduleTrigger/index.js +18 -3
  117. package/dist/server/triggers/index.d.ts +3 -0
  118. package/dist/server/triggers/index.js +18 -0
  119. package/dist/server/utils.d.ts +17 -0
  120. package/dist/server/utils.js +51 -2
  121. package/dist/swagger/index.d.ts +830 -109
  122. package/dist/swagger/index.js +947 -208
  123. package/package.json +6 -5
  124. package/dist/client/27bd65abee87cafa.js +0 -10
  125. package/dist/client/478692c1637f2742.js +0 -10
  126. package/dist/client/c1347b9d21f864d9.js +0 -10
  127. package/dist/client/f39e94207f92e352.js +0 -10
  128. package/dist/node_modules/lru-cache/LICENSE +0 -15
  129. package/dist/node_modules/lru-cache/dist/cjs/index-cjs.d.ts +0 -7
  130. package/dist/node_modules/lru-cache/dist/cjs/index-cjs.js +0 -1
  131. package/dist/node_modules/lru-cache/dist/cjs/index.d.ts +0 -807
  132. package/dist/node_modules/lru-cache/dist/cjs/index.min.js +0 -2
  133. package/dist/node_modules/lru-cache/dist/mjs/index.d.ts +0 -807
  134. package/dist/node_modules/lru-cache/dist/mjs/index.min.js +0 -2
  135. /package/dist/node_modules/lru-cache/dist/{cjs → commonjs}/package.json +0 -0
  136. /package/dist/node_modules/lru-cache/dist/{mjs → esm}/package.json +0 -0
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var CreateInstruction_exports = {};
28
38
  __export(CreateInstruction_exports, {
@@ -30,11 +40,26 @@ __export(CreateInstruction_exports, {
30
40
  default: () => CreateInstruction_default
31
41
  });
32
42
  module.exports = __toCommonJS(CreateInstruction_exports);
43
+ var import_joi = __toESM(require("joi"));
33
44
  var import_data_source_manager = require("@nocobase/data-source-manager");
34
45
  var import_constants = require("../constants");
35
46
  var import_utils = require("../utils");
36
47
  var import__ = require(".");
37
48
  class CreateInstruction extends import__.Instruction {
49
+ configSchema = import_joi.default.object({
50
+ collection: import_joi.default.string().required().messages({ "any.required": "Collection is not configured" }),
51
+ params: import_joi.default.object({
52
+ values: import_joi.default.object(),
53
+ appends: import_joi.default.array().items(import_joi.default.string())
54
+ })
55
+ });
56
+ validateConfig(config) {
57
+ const errors = super.validateConfig(config);
58
+ if (errors) {
59
+ return errors;
60
+ }
61
+ return (0, import_utils.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
62
+ }
38
63
  async run(node, input, processor) {
39
64
  const { collection, params: { appends = [], ...params } = {} } = node.config;
40
65
  const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
@@ -6,10 +6,13 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import { Instruction } from '.';
10
11
  import type Processor from '../Processor';
11
12
  import type { FlowNodeModel } from '../types';
12
13
  export declare class DestroyInstruction extends Instruction {
14
+ configSchema: Joi.ObjectSchema<any>;
15
+ validateConfig(config: Record<string, any>): Record<string, string>;
13
16
  run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
14
17
  result: any;
15
18
  status: 1;
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var DestroyInstruction_exports = {};
28
38
  __export(DestroyInstruction_exports, {
@@ -30,10 +40,25 @@ __export(DestroyInstruction_exports, {
30
40
  default: () => DestroyInstruction_default
31
41
  });
32
42
  module.exports = __toCommonJS(DestroyInstruction_exports);
43
+ var import_joi = __toESM(require("joi"));
33
44
  var import_data_source_manager = require("@nocobase/data-source-manager");
34
45
  var import__ = require(".");
35
46
  var import_constants = require("../constants");
47
+ var import_utils = require("../utils");
36
48
  class DestroyInstruction extends import__.Instruction {
49
+ configSchema = import_joi.default.object({
50
+ collection: import_joi.default.string().required().messages({ "any.required": "Collection is not configured" }),
51
+ params: import_joi.default.object({
52
+ filter: import_joi.default.object()
53
+ })
54
+ });
55
+ validateConfig(config) {
56
+ const errors = super.validateConfig(config);
57
+ if (errors) {
58
+ return errors;
59
+ }
60
+ return (0, import_utils.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
61
+ }
37
62
  async run(node, input, processor) {
38
63
  const { collection, params = {} } = node.config;
39
64
  const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
@@ -6,9 +6,11 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import Instruction from '.';
10
11
  import Processor from '../Processor';
11
12
  import { FlowNodeModel } from '../types';
12
13
  export default class extends Instruction {
14
+ configSchema: Joi.ObjectSchema<any>;
13
15
  run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<any>;
14
16
  }
@@ -39,9 +39,13 @@ __export(EndInstruction_exports, {
39
39
  default: () => EndInstruction_default
40
40
  });
41
41
  module.exports = __toCommonJS(EndInstruction_exports);
42
+ var import_joi = __toESM(require("joi"));
42
43
  var import__ = __toESM(require("."));
43
44
  var import_constants = require("../constants");
44
45
  class EndInstruction_default extends import__.default {
46
+ configSchema = import_joi.default.object({
47
+ endStatus: import_joi.default.number().valid(import_constants.JOB_STATUS.RESOLVED, import_constants.JOB_STATUS.FAILED)
48
+ });
45
49
  async run(node, prevJob, processor) {
46
50
  const { endStatus = import_constants.JOB_STATUS.RESOLVED } = node.config;
47
51
  processor.saveJob({
@@ -6,10 +6,12 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import { Instruction } from '.';
10
11
  import type Processor from '../Processor';
11
12
  import type { FlowNodeModel, JobModel } from '../types';
12
13
  export declare class MultiConditionsInstruction extends Instruction {
14
+ configSchema: Joi.ObjectSchema<any>;
13
15
  run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<JobModel>;
14
16
  resume(node: FlowNodeModel, branchJob: JobModel, processor: Processor): Promise<any>;
15
17
  private evaluateCondition;
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var MultiConditionsInstruction_exports = {};
28
38
  __export(MultiConditionsInstruction_exports, {
@@ -30,11 +40,24 @@ __export(MultiConditionsInstruction_exports, {
30
40
  default: () => MultiConditionsInstruction_default
31
41
  });
32
42
  module.exports = __toCommonJS(MultiConditionsInstruction_exports);
43
+ var import_joi = __toESM(require("joi"));
33
44
  var import_evaluators = require("@nocobase/evaluators");
34
45
  var import__ = require(".");
35
46
  var import_constants = require("../constants");
36
47
  var import_logicCalculate = require("../logicCalculate");
37
48
  class MultiConditionsInstruction extends import__.Instruction {
49
+ configSchema = import_joi.default.object({
50
+ conditions: import_joi.default.array().items(
51
+ import_joi.default.object({
52
+ uid: import_joi.default.string(),
53
+ title: import_joi.default.string(),
54
+ engine: import_joi.default.string(),
55
+ calculation: import_joi.default.any(),
56
+ expression: import_joi.default.string()
57
+ })
58
+ ),
59
+ continueOnNoMatch: import_joi.default.boolean()
60
+ });
38
61
  async run(node, prevJob, processor) {
39
62
  const { conditions = [], continueOnNoMatch = false } = node.config || {};
40
63
  const meta = { conditions: [] };
@@ -6,10 +6,12 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import { Instruction } from '.';
10
11
  import Processor from '../Processor';
11
12
  import { FlowNodeModel } from '../types';
12
13
  export default class ExecutionResultInstruction extends Instruction {
14
+ configSchema: Joi.ObjectSchema<any>;
13
15
  run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
14
16
  result: any;
15
17
  status: -1;
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,15 +25,27 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var OutputInstruction_exports = {};
28
38
  __export(OutputInstruction_exports, {
29
39
  default: () => ExecutionResultInstruction
30
40
  });
31
41
  module.exports = __toCommonJS(OutputInstruction_exports);
42
+ var import_joi = __toESM(require("joi"));
32
43
  var import__ = require(".");
33
44
  var import_constants = require("../constants");
34
45
  class ExecutionResultInstruction extends import__.Instruction {
46
+ configSchema = import_joi.default.object({
47
+ value: import_joi.default.any()
48
+ });
35
49
  async run(node, prevJob, processor) {
36
50
  const { value } = node.config;
37
51
  const output = processor.getParsedValue(value, node.id);
@@ -6,10 +6,13 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import type Processor from '../Processor';
10
11
  import type { FlowNodeModel } from '../types';
11
12
  import { Instruction } from '.';
12
13
  export declare class QueryInstruction extends Instruction {
14
+ configSchema: Joi.ObjectSchema<any>;
15
+ validateConfig(config: Record<string, any>): Record<string, string>;
13
16
  run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
14
17
  result: any;
15
18
  status: -1;
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var QueryInstruction_exports = {};
28
38
  __export(QueryInstruction_exports, {
@@ -30,22 +40,37 @@ __export(QueryInstruction_exports, {
30
40
  default: () => QueryInstruction_default
31
41
  });
32
42
  module.exports = __toCommonJS(QueryInstruction_exports);
43
+ var import_joi = __toESM(require("joi"));
33
44
  var import_actions = require("@nocobase/actions");
34
45
  var import_data_source_manager = require("@nocobase/data-source-manager");
35
46
  var import_constants = require("../constants");
36
47
  var import_utils = require("../utils");
37
48
  var import__ = require(".");
38
49
  class QueryInstruction extends import__.Instruction {
50
+ configSchema = import_joi.default.object({
51
+ collection: import_joi.default.string().required().messages({ "any.required": "Collection is not configured" }),
52
+ multiple: import_joi.default.boolean(),
53
+ params: import_joi.default.object({
54
+ filter: import_joi.default.object(),
55
+ appends: import_joi.default.array().items(import_joi.default.string()),
56
+ page: import_joi.default.alternatives(import_joi.default.number(), import_joi.default.string()),
57
+ pageSize: import_joi.default.alternatives(import_joi.default.number(), import_joi.default.string()),
58
+ sort: import_joi.default.array().items(import_joi.default.object({ field: import_joi.default.string(), direction: import_joi.default.string().allow("asc", "desc") }))
59
+ }),
60
+ failOnEmpty: import_joi.default.boolean()
61
+ });
62
+ validateConfig(config) {
63
+ const errors = super.validateConfig(config);
64
+ if (errors) {
65
+ return errors;
66
+ }
67
+ return (0, import_utils.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
68
+ }
39
69
  async run(node, input, processor) {
40
70
  const { collection, multiple, params = {}, failOnEmpty = false } = node.config;
41
71
  const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
42
72
  const { repository } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
43
- const {
44
- page = import_actions.DEFAULT_PAGE,
45
- pageSize = import_actions.DEFAULT_PER_PAGE,
46
- sort = [],
47
- ...options
48
- } = processor.getParsedValue(params, node.id);
73
+ const { page, pageSize, sort = [], ...options } = processor.getParsedValue(params, node.id);
49
74
  const appends = options.appends ? Array.from(
50
75
  options.appends.reduce((set, field) => {
51
76
  set.add(field.split(".")[0]);
@@ -55,7 +80,7 @@ class QueryInstruction extends import__.Instruction {
55
80
  ) : options.appends;
56
81
  const result = await (multiple ? repository.find : repository.findOne).call(repository, {
57
82
  ...options,
58
- ...import_actions.utils.pageArgsToLimitArgs(page, pageSize),
83
+ ...import_actions.utils.pageArgsToLimitArgs(page ?? import_actions.DEFAULT_PAGE, pageSize ?? import_actions.DEFAULT_PER_PAGE),
59
84
  sort: sort.filter((item) => item.field).map((item) => {
60
85
  var _a;
61
86
  return `${((_a = item.direction) == null ? void 0 : _a.toLowerCase()) === "desc" ? "-" : ""}${item.field}`;
@@ -6,10 +6,13 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import type Processor from '../Processor';
10
11
  import type { FlowNodeModel } from '../types';
11
12
  import { Instruction } from '.';
12
13
  export declare class UpdateInstruction extends Instruction {
14
+ configSchema: Joi.ObjectSchema<any>;
15
+ validateConfig(config: Record<string, any>): Record<string, string>;
13
16
  run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
14
17
  result: any;
15
18
  status: 1;
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var UpdateInstruction_exports = {};
28
38
  __export(UpdateInstruction_exports, {
@@ -30,10 +40,27 @@ __export(UpdateInstruction_exports, {
30
40
  default: () => UpdateInstruction_default
31
41
  });
32
42
  module.exports = __toCommonJS(UpdateInstruction_exports);
43
+ var import_joi = __toESM(require("joi"));
33
44
  var import_data_source_manager = require("@nocobase/data-source-manager");
34
45
  var import_constants = require("../constants");
46
+ var import_utils = require("../utils");
35
47
  var import__ = require(".");
36
48
  class UpdateInstruction extends import__.Instruction {
49
+ configSchema = import_joi.default.object({
50
+ collection: import_joi.default.string().required().messages({ "any.required": "Collection is not configured" }),
51
+ params: import_joi.default.object({
52
+ individualHooks: import_joi.default.boolean(),
53
+ filter: import_joi.default.object(),
54
+ values: import_joi.default.object()
55
+ })
56
+ });
57
+ validateConfig(config) {
58
+ const errors = super.validateConfig(config);
59
+ if (errors) {
60
+ return errors;
61
+ }
62
+ return (0, import_utils.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
63
+ }
37
64
  async run(node, input, processor) {
38
65
  const { collection, params = {} } = node.config;
39
66
  const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
@@ -6,6 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import { Transactionable } from '@nocobase/database';
10
11
  import type Plugin from '../Plugin';
11
12
  import type Processor from '../Processor';
@@ -24,11 +25,14 @@ export type InstructionInterface = {
24
25
  duplicateConfig?: (node: FlowNodeModel, options: Transactionable & {
25
26
  origin?: FlowNodeModel;
26
27
  }) => object | Promise<object>;
28
+ validateConfig?: (config: Record<string, any>) => Record<string, string> | null;
27
29
  test?: (config: Record<string, any>) => IJob | Promise<IJob>;
28
30
  };
29
31
  export declare abstract class Instruction implements InstructionInterface {
30
32
  workflow: Plugin;
33
+ configSchema?: Joi.ObjectSchema;
31
34
  constructor(workflow: Plugin);
35
+ validateConfig(config: Record<string, any>): Record<string, string> | null;
32
36
  abstract run(node: FlowNodeModel, input: any, processor: Processor): InstructionResult;
33
37
  }
34
38
  export default Instruction;
@@ -34,6 +34,24 @@ class Instruction {
34
34
  constructor(workflow) {
35
35
  this.workflow = workflow;
36
36
  }
37
+ configSchema;
38
+ validateConfig(config) {
39
+ if (!this.configSchema) {
40
+ return null;
41
+ }
42
+ const { error } = this.configSchema.validate(config, { abortEarly: false, allowUnknown: true });
43
+ if (!error) {
44
+ return null;
45
+ }
46
+ const errors = {};
47
+ for (const detail of error.details) {
48
+ const key = detail.path.join(".");
49
+ if (!errors[key]) {
50
+ errors[key] = detail.message;
51
+ }
52
+ }
53
+ return errors;
54
+ }
37
55
  }
38
56
  var instructions_default = Instruction;
39
57
  // Annotate the CommonJS export names for ESM import in node:
@@ -6,6 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import { Model } from '@nocobase/database';
10
11
  import Trigger from '.';
11
12
  import type { WorkflowModel } from '../types';
@@ -18,6 +19,8 @@ export interface CollectionChangeTriggerConfig {
18
19
  }
19
20
  export default class CollectionTrigger extends Trigger {
20
21
  readonly workflow: PluginWorkflowServer;
22
+ configSchema: Joi.ObjectSchema<any>;
23
+ validateConfig(config: Record<string, any>): Record<string, string>;
21
24
  events: Map<any, any>;
22
25
  constructor(workflow: PluginWorkflowServer);
23
26
  private static handler;
@@ -39,6 +39,7 @@ __export(CollectionTrigger_exports, {
39
39
  default: () => CollectionTrigger
40
40
  });
41
41
  module.exports = __toCommonJS(CollectionTrigger_exports);
42
+ var import_joi = __toESM(require("joi"));
42
43
  var import_lodash = require("lodash");
43
44
  var import_utils = require("@nocobase/utils");
44
45
  var import_database = require("@nocobase/database");
@@ -81,6 +82,33 @@ class CollectionTrigger extends import__.default {
81
82
  }
82
83
  });
83
84
  }
85
+ configSchema = import_joi.default.object({
86
+ collection: import_joi.default.string().required(),
87
+ mode: import_joi.default.number().valid(
88
+ MODE_BITMAP.CREATE,
89
+ MODE_BITMAP.UPDATE,
90
+ MODE_BITMAP.DESTROY,
91
+ MODE_BITMAP.CREATE | MODE_BITMAP.UPDATE
92
+ ),
93
+ changed: import_joi.default.when("mode", {
94
+ is: (mode) => (mode & MODE_BITMAP.UPDATE) === MODE_BITMAP.UPDATE,
95
+ then: import_joi.default.array().items(import_joi.default.string()).optional(),
96
+ otherwise: import_joi.default.forbidden()
97
+ }),
98
+ condition: import_joi.default.object(),
99
+ appends: import_joi.default.when("mode", {
100
+ is: (mode) => mode !== MODE_BITMAP.DESTROY,
101
+ then: import_joi.default.array().items(import_joi.default.string()).optional(),
102
+ otherwise: import_joi.default.forbidden()
103
+ })
104
+ });
105
+ validateConfig(config) {
106
+ const errors = super.validateConfig(config);
107
+ if (errors) {
108
+ return errors;
109
+ }
110
+ return (0, import_utils2.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
111
+ }
84
112
  events = /* @__PURE__ */ new Map();
85
113
  // async function, should return promise
86
114
  static async handler(workflowId, eventType, data, options) {
@@ -6,10 +6,13 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import Trigger from '..';
10
11
  import type Plugin from '../../Plugin';
11
12
  import { WorkflowModel } from '../../types';
12
13
  export default class ScheduleTrigger extends Trigger {
14
+ configSchema: Joi.ObjectSchema<any>;
15
+ validateConfig(config: Record<string, any>): Record<string, string>;
13
16
  sync: boolean;
14
17
  private modes;
15
18
  constructor(workflow: Plugin);
@@ -39,17 +39,32 @@ __export(ScheduleTrigger_exports, {
39
39
  default: () => ScheduleTrigger
40
40
  });
41
41
  module.exports = __toCommonJS(ScheduleTrigger_exports);
42
+ var import_joi = __toESM(require("joi"));
42
43
  var import__ = __toESM(require(".."));
44
+ var import_utils = require("../../utils");
43
45
  var import_DateFieldScheduleTrigger = __toESM(require("./DateFieldScheduleTrigger"));
44
46
  var import_StaticScheduleTrigger = __toESM(require("./StaticScheduleTrigger"));
45
- var import_utils = require("./utils");
47
+ var import_utils2 = require("./utils");
46
48
  class ScheduleTrigger extends import__.default {
49
+ configSchema = import_joi.default.object({
50
+ mode: import_joi.default.number().valid(import_utils2.SCHEDULE_MODE.STATIC, import_utils2.SCHEDULE_MODE.DATE_FIELD)
51
+ });
52
+ validateConfig(config) {
53
+ const errors = super.validateConfig(config);
54
+ if (errors) {
55
+ return errors;
56
+ }
57
+ if (config.mode === import_utils2.SCHEDULE_MODE.DATE_FIELD && config.collection) {
58
+ return (0, import_utils.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
59
+ }
60
+ return null;
61
+ }
47
62
  sync = false;
48
63
  modes = /* @__PURE__ */ new Map();
49
64
  constructor(workflow) {
50
65
  super(workflow);
51
- this.modes.set(import_utils.SCHEDULE_MODE.STATIC, new import_StaticScheduleTrigger.default(workflow));
52
- this.modes.set(import_utils.SCHEDULE_MODE.DATE_FIELD, new import_DateFieldScheduleTrigger.default(workflow));
66
+ this.modes.set(import_utils2.SCHEDULE_MODE.STATIC, new import_StaticScheduleTrigger.default(workflow));
67
+ this.modes.set(import_utils2.SCHEDULE_MODE.DATE_FIELD, new import_DateFieldScheduleTrigger.default(workflow));
53
68
  }
54
69
  getTrigger(mode) {
55
70
  return this.modes.get(mode);
@@ -6,12 +6,14 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import { Transactionable } from '@nocobase/database';
10
11
  import type Plugin from '../Plugin';
11
12
  import type { WorkflowModel } from '../types';
12
13
  import Processor from '../Processor';
13
14
  export declare abstract class Trigger {
14
15
  readonly workflow: Plugin;
16
+ configSchema?: Joi.ObjectSchema;
15
17
  constructor(workflow: Plugin);
16
18
  on(workflow: WorkflowModel): void;
17
19
  off(workflow: WorkflowModel): void;
@@ -19,6 +21,7 @@ export declare abstract class Trigger {
19
21
  duplicateConfig?(workflow: WorkflowModel, options: Transactionable & {
20
22
  origin?: WorkflowModel;
21
23
  }): object | Promise<object>;
24
+ validateConfig(config: Record<string, any>): Record<string, string> | null;
22
25
  validateContext?(values: any, workflow: WorkflowModel): null | void | {
23
26
  [key: string]: string;
24
27
  };
@@ -34,6 +34,7 @@ class Trigger {
34
34
  constructor(workflow) {
35
35
  this.workflow = workflow;
36
36
  }
37
+ configSchema;
37
38
  on(workflow) {
38
39
  }
39
40
  off(workflow) {
@@ -41,6 +42,23 @@ class Trigger {
41
42
  validateEvent(workflow, context, options) {
42
43
  return true;
43
44
  }
45
+ validateConfig(config) {
46
+ if (!this.configSchema) {
47
+ return null;
48
+ }
49
+ const { error } = this.configSchema.validate(config, { abortEarly: false, allowUnknown: true });
50
+ if (!error) {
51
+ return null;
52
+ }
53
+ const errors = {};
54
+ for (const detail of error.details) {
55
+ const key = detail.path.join(".");
56
+ if (!errors[key]) {
57
+ errors[key] = detail.message;
58
+ }
59
+ }
60
+ return errors;
61
+ }
44
62
  sync;
45
63
  }
46
64
  var triggers_default = Trigger;