@nocobase/plugin-workflow 2.1.0-alpha.10 → 2.1.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/93d3f3f8ced1c194.js +10 -0
- package/dist/client/c46a9a8d11a5be44.js +10 -0
- package/dist/client/cd221313681d6736.js +10 -0
- package/dist/client/e9463c8cd2a45481.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client/nodes/create.d.ts +10 -0
- package/dist/client/nodes/destroy.d.ts +10 -0
- package/dist/client/nodes/query.d.ts +10 -0
- package/dist/client/nodes/update.d.ts +10 -0
- package/dist/client/triggers/collection.d.ts +14 -1
- package/dist/client/triggers/index.d.ts +4 -0
- package/dist/client/triggers/schedule/constants.d.ts +4 -0
- package/dist/client/triggers/schedule/index.d.ts +15 -0
- package/dist/externalVersion.js +12 -12
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/joi/dist/joi-browser.min.js +1 -0
- package/dist/node_modules/joi/lib/annotate.js +175 -0
- package/dist/node_modules/joi/lib/base.js +1069 -0
- package/dist/node_modules/joi/lib/cache.js +143 -0
- package/dist/node_modules/joi/lib/common.js +216 -0
- package/dist/node_modules/joi/lib/compile.js +283 -0
- package/dist/node_modules/joi/lib/errors.js +271 -0
- package/dist/node_modules/joi/lib/extend.js +312 -0
- package/dist/node_modules/joi/lib/index.d.ts +2365 -0
- package/dist/node_modules/joi/lib/index.js +1 -0
- package/dist/node_modules/joi/lib/manifest.js +476 -0
- package/dist/node_modules/joi/lib/messages.js +178 -0
- package/dist/node_modules/joi/lib/modify.js +267 -0
- package/dist/node_modules/joi/lib/ref.js +414 -0
- package/dist/node_modules/joi/lib/schemas.js +302 -0
- package/dist/node_modules/joi/lib/state.js +166 -0
- package/dist/node_modules/joi/lib/template.js +463 -0
- package/dist/node_modules/joi/lib/trace.js +346 -0
- package/dist/node_modules/joi/lib/types/alternatives.js +364 -0
- package/dist/node_modules/joi/lib/types/any.js +174 -0
- package/dist/node_modules/joi/lib/types/array.js +809 -0
- package/dist/node_modules/joi/lib/types/binary.js +100 -0
- package/dist/node_modules/joi/lib/types/boolean.js +150 -0
- package/dist/node_modules/joi/lib/types/date.js +233 -0
- package/dist/node_modules/joi/lib/types/function.js +93 -0
- package/dist/node_modules/joi/lib/types/keys.js +1067 -0
- package/dist/node_modules/joi/lib/types/link.js +168 -0
- package/dist/node_modules/joi/lib/types/number.js +363 -0
- package/dist/node_modules/joi/lib/types/object.js +22 -0
- package/dist/node_modules/joi/lib/types/string.js +850 -0
- package/dist/node_modules/joi/lib/types/symbol.js +102 -0
- package/dist/node_modules/joi/lib/validator.js +750 -0
- package/dist/node_modules/joi/lib/values.js +263 -0
- package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.d.ts +60 -0
- package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.js +225 -0
- package/dist/node_modules/joi/node_modules/@hapi/topo/package.json +30 -0
- package/dist/node_modules/joi/package.json +1 -0
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/server/Plugin.d.ts +1 -0
- package/dist/server/Plugin.js +26 -0
- package/dist/server/actions/nodes.d.ts +5 -0
- package/dist/server/actions/nodes.js +34 -2
- package/dist/server/actions/workflows.d.ts +6 -0
- package/dist/server/actions/workflows.js +38 -0
- package/dist/server/instructions/CreateInstruction.d.ts +3 -0
- package/dist/server/instructions/CreateInstruction.js +21 -0
- package/dist/server/instructions/DestroyInstruction.d.ts +3 -0
- package/dist/server/instructions/DestroyInstruction.js +22 -0
- package/dist/server/instructions/EndInstruction.d.ts +2 -0
- package/dist/server/instructions/EndInstruction.js +4 -0
- package/dist/server/instructions/QueryInstruction.d.ts +3 -0
- package/dist/server/instructions/QueryInstruction.js +21 -0
- package/dist/server/instructions/UpdateInstruction.d.ts +3 -0
- package/dist/server/instructions/UpdateInstruction.js +22 -0
- package/dist/server/instructions/index.d.ts +4 -0
- package/dist/server/instructions/index.js +18 -0
- package/dist/server/triggers/CollectionTrigger.d.ts +3 -0
- package/dist/server/triggers/CollectionTrigger.js +23 -0
- package/dist/server/triggers/ScheduleTrigger/index.d.ts +3 -0
- package/dist/server/triggers/ScheduleTrigger/index.js +18 -3
- package/dist/server/triggers/index.d.ts +3 -0
- package/dist/server/triggers/index.js +18 -0
- package/dist/server/utils.d.ts +2 -0
- package/dist/server/utils.js +22 -2
- package/package.json +3 -2
- package/dist/client/0e7da88f89e15485.js +0 -10
- package/dist/client/37560b46d530bcf9.js +0 -10
- package/dist/client/4464fed3a8411375.js +0 -10
- package/dist/client/973723cf75f1e4e9.js +0 -10
|
@@ -36,6 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
var nodes_exports = {};
|
|
38
38
|
__export(nodes_exports, {
|
|
39
|
+
NodeValidationError: () => NodeValidationError,
|
|
39
40
|
create: () => create,
|
|
40
41
|
destroy: () => destroy,
|
|
41
42
|
destroyBranch: () => destroyBranch,
|
|
@@ -48,6 +49,30 @@ module.exports = __toCommonJS(nodes_exports);
|
|
|
48
49
|
var import_actions = require("@nocobase/actions");
|
|
49
50
|
var import_database = require("@nocobase/database");
|
|
50
51
|
var import__ = __toESM(require(".."));
|
|
52
|
+
class NodeValidationError extends Error {
|
|
53
|
+
status = 400;
|
|
54
|
+
errors;
|
|
55
|
+
constructor(errors) {
|
|
56
|
+
super("Node validation failed");
|
|
57
|
+
this.name = "NodeValidationError";
|
|
58
|
+
this.errors = errors;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function validateNode(context, plugin, { type, config }) {
|
|
62
|
+
if (!type) {
|
|
63
|
+
context.throw(400, "Node type is required");
|
|
64
|
+
}
|
|
65
|
+
const instruction = plugin.instructions.get(type);
|
|
66
|
+
if (!instruction) {
|
|
67
|
+
context.throw(400, `Node type "${type}" is not registered`);
|
|
68
|
+
}
|
|
69
|
+
if (config && typeof instruction.validateConfig === "function") {
|
|
70
|
+
const errors = instruction.validateConfig(config);
|
|
71
|
+
if (errors) {
|
|
72
|
+
throw new NodeValidationError(errors);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
51
76
|
async function create(context, next) {
|
|
52
77
|
const { db } = context;
|
|
53
78
|
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
@@ -61,6 +86,7 @@ async function create(context, next) {
|
|
|
61
86
|
if (workflow.versionStats.executed > 0) {
|
|
62
87
|
context.throw(400, "Node could not be created in executed workflow");
|
|
63
88
|
}
|
|
89
|
+
validateNode(context, workflowPlugin, values);
|
|
64
90
|
const NODES_LIMIT = process.env.WORKFLOW_NODES_LIMIT ? parseInt(process.env.WORKFLOW_NODES_LIMIT, 10) : null;
|
|
65
91
|
if (NODES_LIMIT) {
|
|
66
92
|
const nodesCount = await workflow.countNodes({ transaction });
|
|
@@ -617,15 +643,19 @@ async function update(context, next) {
|
|
|
617
643
|
const { db } = context;
|
|
618
644
|
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
619
645
|
const { filterByTk, values, whitelist, blacklist, filter, updateAssociationValues } = context.action.params;
|
|
646
|
+
const workflowPlugin = context.app.pm.get(import__.default);
|
|
620
647
|
context.body = await db.sequelize.transaction(async (transaction) => {
|
|
621
|
-
const
|
|
648
|
+
const instance = await repository.findOne({
|
|
622
649
|
filterByTk,
|
|
623
650
|
appends: ["workflow.versionStats.executed"],
|
|
624
651
|
transaction
|
|
625
652
|
});
|
|
626
|
-
if (workflow.versionStats.executed > 0) {
|
|
653
|
+
if (instance.workflow.versionStats.executed > 0) {
|
|
627
654
|
context.throw(400, "Nodes in executed workflow could not be reconfigured");
|
|
628
655
|
}
|
|
656
|
+
const type = values.type ?? instance.type;
|
|
657
|
+
const config = values.config ?? instance.config;
|
|
658
|
+
validateNode(context, workflowPlugin, { type, config });
|
|
629
659
|
return repository.update({
|
|
630
660
|
filterByTk,
|
|
631
661
|
values,
|
|
@@ -650,6 +680,7 @@ async function test(context, next) {
|
|
|
650
680
|
if (typeof instruction.test !== "function") {
|
|
651
681
|
context.throw(400, `test method of instruction "${type}" not implemented`);
|
|
652
682
|
}
|
|
683
|
+
validateNode(context, plugin, { type, config });
|
|
653
684
|
try {
|
|
654
685
|
context.body = await instruction.test(config);
|
|
655
686
|
} catch (error) {
|
|
@@ -659,6 +690,7 @@ async function test(context, next) {
|
|
|
659
690
|
}
|
|
660
691
|
// Annotate the CommonJS export names for ESM import in node:
|
|
661
692
|
0 && (module.exports = {
|
|
693
|
+
NodeValidationError,
|
|
662
694
|
create,
|
|
663
695
|
destroy,
|
|
664
696
|
destroyBranch,
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Context } from '@nocobase/actions';
|
|
10
|
+
export declare class WorkflowValidationError extends Error {
|
|
11
|
+
status: number;
|
|
12
|
+
errors: Record<string, string>;
|
|
13
|
+
constructor(errors: Record<string, string>);
|
|
14
|
+
}
|
|
15
|
+
export declare function create(context: Context, next: any): Promise<void>;
|
|
10
16
|
export declare function update(context: Context, next: any): Promise<void>;
|
|
11
17
|
export declare function destroy(context: Context, next: any): Promise<void>;
|
|
12
18
|
export declare function revision(context: Context, next: any): Promise<void>;
|
|
@@ -36,6 +36,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
var workflows_exports = {};
|
|
38
38
|
__export(workflows_exports, {
|
|
39
|
+
WorkflowValidationError: () => WorkflowValidationError,
|
|
40
|
+
create: () => create,
|
|
39
41
|
destroy: () => destroy,
|
|
40
42
|
execute: () => execute,
|
|
41
43
|
revision: () => revision,
|
|
@@ -46,7 +48,38 @@ module.exports = __toCommonJS(workflows_exports);
|
|
|
46
48
|
var import_actions = __toESM(require("@nocobase/actions"));
|
|
47
49
|
var import_database = require("@nocobase/database");
|
|
48
50
|
var import_Plugin = __toESM(require("../Plugin"));
|
|
51
|
+
class WorkflowValidationError extends Error {
|
|
52
|
+
status = 400;
|
|
53
|
+
errors;
|
|
54
|
+
constructor(errors) {
|
|
55
|
+
super("Workflow validation failed");
|
|
56
|
+
this.name = "WorkflowValidationError";
|
|
57
|
+
this.errors = errors;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function validateWorkflow(context, plugin, { type, config }) {
|
|
61
|
+
if (!type) {
|
|
62
|
+
context.throw(400, "Trigger type is required");
|
|
63
|
+
}
|
|
64
|
+
const trigger = plugin.triggers.get(type);
|
|
65
|
+
if (!trigger) {
|
|
66
|
+
context.throw(400, `Trigger type "${type}" is not registered`);
|
|
67
|
+
}
|
|
68
|
+
if (config && typeof trigger.validateConfig === "function") {
|
|
69
|
+
const errors = trigger.validateConfig(config);
|
|
70
|
+
if (errors) {
|
|
71
|
+
throw new WorkflowValidationError(errors);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function create(context, next) {
|
|
76
|
+
const plugin = context.app.pm.get(import_Plugin.default);
|
|
77
|
+
const { values } = context.action.params;
|
|
78
|
+
validateWorkflow(context, plugin, values);
|
|
79
|
+
return import_actions.default.create(context, next);
|
|
80
|
+
}
|
|
49
81
|
async function update(context, next) {
|
|
82
|
+
const plugin = context.app.pm.get(import_Plugin.default);
|
|
50
83
|
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
51
84
|
const { filterByTk, values } = context.action.params;
|
|
52
85
|
context.action.mergeParams({
|
|
@@ -60,6 +93,9 @@ async function update(context, next) {
|
|
|
60
93
|
if (workflow.versionStats.executed > 0) {
|
|
61
94
|
return context.throw(400, "config of executed workflow can not be updated");
|
|
62
95
|
}
|
|
96
|
+
const type = values.type ?? workflow.type;
|
|
97
|
+
const config = values.config ?? workflow.config;
|
|
98
|
+
validateWorkflow(context, plugin, { type, config });
|
|
63
99
|
}
|
|
64
100
|
return import_actions.default.update(context, next);
|
|
65
101
|
}
|
|
@@ -180,6 +216,8 @@ async function execute(context, next) {
|
|
|
180
216
|
}
|
|
181
217
|
// Annotate the CommonJS export names for ESM import in node:
|
|
182
218
|
0 && (module.exports = {
|
|
219
|
+
WorkflowValidationError,
|
|
220
|
+
create,
|
|
183
221
|
destroy,
|
|
184
222
|
execute,
|
|
185
223
|
revision,
|
|
@@ -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 CreateInstruction 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 CreateInstruction_exports = {};
|
|
28
38
|
__export(CreateInstruction_exports, {
|
|
@@ -30,11 +40,22 @@ __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
|
+
});
|
|
52
|
+
validateConfig(config) {
|
|
53
|
+
const errors = super.validateConfig(config);
|
|
54
|
+
if (errors) {
|
|
55
|
+
return errors;
|
|
56
|
+
}
|
|
57
|
+
return (0, import_utils.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
|
|
58
|
+
}
|
|
38
59
|
async run(node, input, processor) {
|
|
39
60
|
const { collection, params: { appends = [], ...params } = {} } = node.config;
|
|
40
61
|
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,22 @@ __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
|
+
});
|
|
52
|
+
validateConfig(config) {
|
|
53
|
+
const errors = super.validateConfig(config);
|
|
54
|
+
if (errors) {
|
|
55
|
+
return errors;
|
|
56
|
+
}
|
|
57
|
+
return (0, import_utils.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
|
|
58
|
+
}
|
|
37
59
|
async run(node, input, processor) {
|
|
38
60
|
const { collection, params = {} } = node.config;
|
|
39
61
|
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,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,12 +40,23 @@ __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
|
+
});
|
|
53
|
+
validateConfig(config) {
|
|
54
|
+
const errors = super.validateConfig(config);
|
|
55
|
+
if (errors) {
|
|
56
|
+
return errors;
|
|
57
|
+
}
|
|
58
|
+
return (0, import_utils.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
|
|
59
|
+
}
|
|
39
60
|
async run(node, input, processor) {
|
|
40
61
|
const { collection, multiple, params = {}, failOnEmpty = false } = node.config;
|
|
41
62
|
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 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,22 @@ __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
|
+
});
|
|
52
|
+
validateConfig(config) {
|
|
53
|
+
const errors = super.validateConfig(config);
|
|
54
|
+
if (errors) {
|
|
55
|
+
return errors;
|
|
56
|
+
}
|
|
57
|
+
return (0, import_utils.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
|
|
58
|
+
}
|
|
37
59
|
async run(node, input, processor) {
|
|
38
60
|
const { collection, params = {} } = node.config;
|
|
39
61
|
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,28 @@ 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(...Object.values(MODE_BITMAP)),
|
|
88
|
+
changed: import_joi.default.when("mode", {
|
|
89
|
+
is: (mode) => (mode & MODE_BITMAP.UPDATE) === MODE_BITMAP.UPDATE,
|
|
90
|
+
then: import_joi.default.array().items(import_joi.default.string()).optional(),
|
|
91
|
+
otherwise: import_joi.default.forbidden()
|
|
92
|
+
}),
|
|
93
|
+
condition: import_joi.default.object(),
|
|
94
|
+
appends: import_joi.default.when("mode", {
|
|
95
|
+
is: (mode) => mode !== MODE_BITMAP.DESTROY,
|
|
96
|
+
then: import_joi.default.array().items(import_joi.default.string()).optional(),
|
|
97
|
+
otherwise: import_joi.default.forbidden()
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
validateConfig(config) {
|
|
101
|
+
const errors = super.validateConfig(config);
|
|
102
|
+
if (errors) {
|
|
103
|
+
return errors;
|
|
104
|
+
}
|
|
105
|
+
return (0, import_utils2.validateCollectionField)(config.collection, this.workflow.app.dataSourceManager);
|
|
106
|
+
}
|
|
84
107
|
events = /* @__PURE__ */ new Map();
|
|
85
108
|
// async function, should return promise
|
|
86
109
|
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
|
|
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(
|
|
52
|
-
this.modes.set(
|
|
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;
|