@nocobase/plugin-workflow 2.1.0-beta.2 → 2.1.0-beta.21
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/LICENSE +201 -661
- package/README.md +79 -10
- package/dist/client/214.7e602cfe7a8251b8.js +10 -0
- package/dist/client/261.7722d7400942730e.js +10 -0
- package/dist/client/67.f904ef4520868b8a.js +10 -0
- package/dist/client/964.6251d37b35710747.js +10 -0
- package/dist/client/hooks/{useWorkflowFilterActionProps.d.ts → useResourceFilterActionProps.d.ts} +1 -1
- 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/index.d.ts +3 -0
- package/dist/client/nodes/query.d.ts +18 -2
- package/dist/client/nodes/update.d.ts +10 -0
- package/dist/client/schemas/collection.d.ts +8 -2
- package/dist/client/schemas/executions.d.ts +41 -23
- 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/common/collections/executions.d.ts +22 -22
- package/dist/common/collections/executions.js +12 -0
- package/dist/common/collections/jobs.js +7 -0
- package/dist/common/collections/workflows.d.ts +22 -9
- package/dist/common/collections/workflows.js +9 -1
- package/dist/externalVersion.js +15 -13
- package/dist/locale/zh-CN.json +4 -1
- package/dist/node_modules/cron-parser/lib/parser.js +1 -1
- 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/dist/commonjs/diagnostics-channel.d.ts +5 -0
- package/dist/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +10 -0
- package/dist/node_modules/lru-cache/dist/commonjs/index.d.ts +1381 -0
- package/dist/node_modules/lru-cache/dist/commonjs/index.js +1692 -0
- package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -0
- package/dist/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +5 -0
- package/dist/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
- package/dist/node_modules/lru-cache/dist/esm/browser/index.d.ts +1381 -0
- package/dist/node_modules/lru-cache/dist/{mjs → esm/browser}/index.js +537 -179
- package/dist/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
- package/dist/node_modules/lru-cache/dist/esm/diagnostics-channel.d.ts +5 -0
- package/dist/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
- package/dist/node_modules/lru-cache/dist/esm/index.d.ts +1381 -0
- package/dist/node_modules/lru-cache/dist/{cjs → esm}/index.js +538 -184
- package/dist/node_modules/lru-cache/dist/esm/index.min.js +2 -0
- package/dist/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +5 -0
- package/dist/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +7 -0
- package/dist/node_modules/lru-cache/dist/esm/node/index.d.ts +1381 -0
- package/dist/node_modules/lru-cache/dist/esm/node/index.js +1688 -0
- package/dist/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/nodejs_snowflake.js +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/server/Dispatcher.d.ts +3 -2
- package/dist/server/Dispatcher.js +74 -61
- package/dist/server/Plugin.d.ts +1 -0
- package/dist/server/Plugin.js +28 -3
- package/dist/server/actions/nodes.d.ts +5 -0
- package/dist/server/actions/nodes.js +38 -5
- package/dist/server/actions/workflows.d.ts +6 -0
- package/dist/server/actions/workflows.js +38 -0
- package/dist/server/instructions/ConditionInstruction.d.ts +2 -0
- package/dist/server/instructions/ConditionInstruction.js +17 -0
- package/dist/server/instructions/CreateInstruction.d.ts +3 -0
- package/dist/server/instructions/CreateInstruction.js +25 -0
- package/dist/server/instructions/DestroyInstruction.d.ts +3 -0
- package/dist/server/instructions/DestroyInstruction.js +25 -0
- package/dist/server/instructions/EndInstruction.d.ts +2 -0
- package/dist/server/instructions/EndInstruction.js +4 -0
- package/dist/server/instructions/MultiConditionsInstruction.d.ts +2 -0
- package/dist/server/instructions/MultiConditionsInstruction.js +23 -0
- package/dist/server/instructions/OutputInstruction.d.ts +2 -0
- package/dist/server/instructions/OutputInstruction.js +14 -0
- package/dist/server/instructions/QueryInstruction.d.ts +3 -0
- package/dist/server/instructions/QueryInstruction.js +32 -7
- package/dist/server/instructions/UpdateInstruction.d.ts +3 -0
- package/dist/server/instructions/UpdateInstruction.js +27 -0
- package/dist/server/instructions/index.d.ts +15 -2
- package/dist/server/instructions/index.js +18 -0
- package/dist/server/triggers/CollectionTrigger.d.ts +3 -0
- package/dist/server/triggers/CollectionTrigger.js +28 -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 +17 -0
- package/dist/server/utils.js +51 -2
- package/dist/swagger/index.d.ts +830 -109
- package/dist/swagger/index.js +947 -208
- package/package.json +6 -5
- package/dist/client/27bd65abee87cafa.js +0 -10
- package/dist/client/478692c1637f2742.js +0 -10
- package/dist/client/c1347b9d21f864d9.js +0 -10
- package/dist/client/f39e94207f92e352.js +0 -10
- package/dist/node_modules/lru-cache/LICENSE +0 -15
- package/dist/node_modules/lru-cache/dist/cjs/index-cjs.d.ts +0 -7
- package/dist/node_modules/lru-cache/dist/cjs/index-cjs.js +0 -1
- package/dist/node_modules/lru-cache/dist/cjs/index.d.ts +0 -807
- package/dist/node_modules/lru-cache/dist/cjs/index.min.js +0 -2
- package/dist/node_modules/lru-cache/dist/mjs/index.d.ts +0 -807
- package/dist/node_modules/lru-cache/dist/mjs/index.min.js +0 -2
- /package/dist/node_modules/lru-cache/dist/{cjs → commonjs}/package.json +0 -0
- /package/dist/node_modules/lru-cache/dist/{mjs → esm}/package.json +0 -0
|
@@ -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;
|
package/dist/server/utils.d.ts
CHANGED
|
@@ -6,4 +6,21 @@
|
|
|
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 type { DataSourceManager } from '@nocobase/data-source-manager';
|
|
10
|
+
import type { WorkflowModel } from './types';
|
|
11
|
+
import Processor from './Processor';
|
|
12
|
+
export declare function validateCollectionField(collection: string, dataSourceManager: DataSourceManager): Record<string, string> | null;
|
|
13
|
+
export declare function getExecutionStatusName(status: number | null | undefined): string;
|
|
14
|
+
export declare function getWorkflowExecutionLogMeta(workflow: WorkflowModel, processor?: Processor): {
|
|
15
|
+
workflowId: number;
|
|
16
|
+
workflowKey: string;
|
|
17
|
+
workflowTitle: string;
|
|
18
|
+
executionId: number;
|
|
19
|
+
executionStatus: number;
|
|
20
|
+
executionStatusName: string;
|
|
21
|
+
lastNodeId: number;
|
|
22
|
+
lastNodeType: string;
|
|
23
|
+
lastJobId: number;
|
|
24
|
+
lastJobStatus: number;
|
|
25
|
+
};
|
|
9
26
|
export declare function toJSON(data: any): any;
|
package/dist/server/utils.js
CHANGED
|
@@ -26,10 +26,56 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
26
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
27
|
var utils_exports = {};
|
|
28
28
|
__export(utils_exports, {
|
|
29
|
-
|
|
29
|
+
getExecutionStatusName: () => getExecutionStatusName,
|
|
30
|
+
getWorkflowExecutionLogMeta: () => getWorkflowExecutionLogMeta,
|
|
31
|
+
toJSON: () => toJSON,
|
|
32
|
+
validateCollectionField: () => validateCollectionField
|
|
30
33
|
});
|
|
31
34
|
module.exports = __toCommonJS(utils_exports);
|
|
32
35
|
var import_database = require("@nocobase/database");
|
|
36
|
+
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
37
|
+
var import_constants = require("./constants");
|
|
38
|
+
function validateCollectionField(collection, dataSourceManager) {
|
|
39
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
40
|
+
if (collection.includes(":")) {
|
|
41
|
+
const parts = collection.split(":");
|
|
42
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
43
|
+
return { collection: `"collection" must be in the format "dataSourceName:collectionName"` };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const dataSource = dataSourceManager.dataSources.get(dataSourceName);
|
|
47
|
+
if (!dataSource) {
|
|
48
|
+
return { collection: `Data source "${dataSourceName}" does not exist` };
|
|
49
|
+
}
|
|
50
|
+
if (!dataSource.collectionManager.getCollection(collectionName)) {
|
|
51
|
+
return { collection: `Collection "${collectionName}" does not exist in data source "${dataSourceName}"` };
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const EXECUTION_STATUS_NAMES = new Map(Object.entries(import_constants.EXECUTION_STATUS).map(([name, value]) => [value, name]));
|
|
56
|
+
function getExecutionStatusName(status) {
|
|
57
|
+
if (typeof status === "undefined") {
|
|
58
|
+
return "UNKNOWN";
|
|
59
|
+
}
|
|
60
|
+
return EXECUTION_STATUS_NAMES.get(status) ?? `${status}`;
|
|
61
|
+
}
|
|
62
|
+
function getWorkflowExecutionLogMeta(workflow, processor) {
|
|
63
|
+
var _a, _b, _c, _d;
|
|
64
|
+
const lastSavedJob = processor == null ? void 0 : processor.lastSavedJob;
|
|
65
|
+
const lastNode = (_a = processor == null ? void 0 : processor.nodesMap) == null ? void 0 : _a.get(lastSavedJob == null ? void 0 : lastSavedJob.nodeId);
|
|
66
|
+
return {
|
|
67
|
+
workflowId: workflow.id,
|
|
68
|
+
workflowKey: workflow.key,
|
|
69
|
+
workflowTitle: workflow.title,
|
|
70
|
+
executionId: ((_b = processor == null ? void 0 : processor.execution) == null ? void 0 : _b.id) ?? null,
|
|
71
|
+
executionStatus: ((_c = processor == null ? void 0 : processor.execution) == null ? void 0 : _c.status) ?? null,
|
|
72
|
+
executionStatusName: getExecutionStatusName((_d = processor == null ? void 0 : processor.execution) == null ? void 0 : _d.status),
|
|
73
|
+
lastNodeId: (lastNode == null ? void 0 : lastNode.id) ?? (lastSavedJob == null ? void 0 : lastSavedJob.nodeId) ?? null,
|
|
74
|
+
lastNodeType: (lastNode == null ? void 0 : lastNode.type) ?? null,
|
|
75
|
+
lastJobId: (lastSavedJob == null ? void 0 : lastSavedJob.id) ?? null,
|
|
76
|
+
lastJobStatus: (lastSavedJob == null ? void 0 : lastSavedJob.status) ?? null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
33
79
|
function toJSON(data) {
|
|
34
80
|
if (Array.isArray(data)) {
|
|
35
81
|
return data.map(toJSON);
|
|
@@ -47,5 +93,8 @@ function toJSON(data) {
|
|
|
47
93
|
}
|
|
48
94
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
95
|
0 && (module.exports = {
|
|
50
|
-
|
|
96
|
+
getExecutionStatusName,
|
|
97
|
+
getWorkflowExecutionLogMeta,
|
|
98
|
+
toJSON,
|
|
99
|
+
validateCollectionField
|
|
51
100
|
});
|