@nocobase/plugin-workflow 2.1.0-beta.9 → 2.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/214.7e602cfe7a8251b8.js +10 -0
- package/dist/client/618.19af7f84261c815d.js +10 -0
- package/dist/client/67.452743ce8ec30617.js +10 -0
- package/dist/client/964.ffbf5b47ed12bbdc.js +10 -0
- package/dist/client/Branch.d.ts +7 -3
- package/dist/client/BranchContext.d.ts +18 -0
- package/dist/client/components/TimeoutInput.d.ts +11 -0
- package/dist/client/constants.d.ts +13 -0
- package/dist/client/flows/triggerWorkflows.d.ts +14 -1
- 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 +5 -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 +63 -2
- 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/client/utils.d.ts +17 -0
- package/dist/common/collections/executions.d.ts +44 -1
- package/dist/common/collections/executions.js +63 -1
- package/dist/common/collections/flow_nodes.d.ts +1 -0
- package/dist/common/collections/flow_nodes.js +1 -0
- package/dist/common/collections/jobs.d.ts +1 -0
- package/dist/common/collections/jobs.js +8 -0
- package/dist/common/collections/userWorkflowTasks.d.ts +1 -0
- package/dist/common/collections/userWorkflowTasks.js +1 -0
- package/dist/common/collections/workflowCategories.d.ts +1 -0
- package/dist/common/collections/workflowCategories.js +1 -0
- package/dist/common/collections/workflowCategoryRelations.d.ts +1 -0
- package/dist/common/collections/workflowCategoryRelations.js +1 -0
- package/dist/common/collections/workflowStats.d.ts +1 -0
- package/dist/common/collections/workflowStats.js +1 -0
- package/dist/common/collections/workflowTasks.js +1 -0
- package/dist/common/collections/workflowVersionStats.d.ts +1 -0
- package/dist/common/collections/workflowVersionStats.js +1 -0
- package/dist/common/collections/workflows.d.ts +66 -11
- package/dist/common/collections/workflows.js +35 -2
- package/dist/common/constants.d.ts +5 -0
- package/dist/common/constants.js +7 -0
- package/dist/externalVersion.js +15 -13
- package/dist/locale/de-DE.json +4 -0
- package/dist/locale/en-US.json +7 -0
- package/dist/locale/es-ES.json +4 -0
- package/dist/locale/fr-FR.json +4 -0
- package/dist/locale/hu-HU.json +7 -3
- package/dist/locale/id-ID.json +4 -0
- package/dist/locale/it-IT.json +4 -0
- package/dist/locale/ja-JP.json +5 -1
- package/dist/locale/ko-KR.json +4 -0
- package/dist/locale/nl-NL.json +7 -3
- package/dist/locale/pt-BR.json +4 -0
- package/dist/locale/ru-RU.json +4 -0
- package/dist/locale/tr-TR.json +4 -0
- package/dist/locale/uk-UA.json +7 -3
- package/dist/locale/vi-VN.json +7 -3
- package/dist/locale/zh-CN.json +10 -0
- package/dist/locale/zh-TW.json +7 -3
- 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 +12 -6
- package/dist/server/Dispatcher.js +309 -190
- package/dist/server/ExecutionTimeoutManager.d.ts +46 -0
- package/dist/server/ExecutionTimeoutManager.js +320 -0
- package/dist/server/Plugin.d.ts +17 -3
- package/dist/server/Plugin.js +54 -12
- package/dist/server/Processor.d.ts +64 -12
- package/dist/server/Processor.js +286 -48
- package/dist/server/RunningExecutionRegistry.d.ts +18 -0
- package/dist/server/RunningExecutionRegistry.js +48 -0
- package/dist/server/actions/executions.d.ts +4 -3
- package/dist/server/actions/executions.js +42 -21
- package/dist/server/actions/jobs.d.ts +2 -1
- package/dist/server/actions/jobs.js +28 -1
- 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/constants.d.ts +2 -0
- package/dist/server/constants.js +3 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +2 -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 +15 -1
- 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 +24 -4
- package/dist/server/instructions/index.js +18 -0
- package/dist/server/migrations/20260423225800-fill-workflow-created-updated-by.d.ts +13 -0
- package/dist/server/migrations/20260423225800-fill-workflow-created-updated-by.js +57 -0
- package/dist/server/migrations/20260501120000-workflow-timeout.d.ts +13 -0
- package/dist/server/migrations/20260501120000-workflow-timeout.js +63 -0
- package/dist/server/timeout-errors.d.ts +13 -0
- package/dist/server/timeout-errors.js +47 -0
- package/dist/server/triggers/CollectionTrigger.d.ts +3 -0
- package/dist/server/triggers/CollectionTrigger.js +34 -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/types/Execution.d.ts +6 -0
- package/dist/server/types/Job.d.ts +3 -3
- package/dist/server/types/Workflow.d.ts +6 -1
- package/dist/server/utils.d.ts +27 -0
- package/dist/server/utils.js +142 -2
- package/dist/swagger/index.d.ts +66 -75
- package/dist/swagger/index.js +58 -67
- package/package.json +5 -4
- package/dist/client/0e458d99e9fc5e65.js +0 -10
- package/dist/client/27bd65abee87cafa.js +0 -10
- package/dist/client/478692c1637f2742.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;
|
|
@@ -15,7 +15,13 @@ export default class ExecutionModel extends Model {
|
|
|
15
15
|
title: string;
|
|
16
16
|
context: any;
|
|
17
17
|
status: number;
|
|
18
|
+
reason?: string | null;
|
|
18
19
|
dispatched: boolean;
|
|
20
|
+
parentExecutionId?: number | null;
|
|
21
|
+
stack?: Array<number | string>;
|
|
22
|
+
startedAt?: Date | null;
|
|
23
|
+
expiresAt?: Date | null;
|
|
24
|
+
output?: any;
|
|
19
25
|
createdAt: Date;
|
|
20
26
|
updatedAt: Date;
|
|
21
27
|
key: string;
|
|
@@ -11,12 +11,12 @@ import FlowNodeModel from './FlowNode';
|
|
|
11
11
|
export default class JobModel extends Model {
|
|
12
12
|
id: number;
|
|
13
13
|
status: number;
|
|
14
|
-
result
|
|
15
|
-
meta
|
|
14
|
+
result?: any;
|
|
15
|
+
meta?: any;
|
|
16
16
|
createdAt: Date;
|
|
17
17
|
updatedAt: Date;
|
|
18
18
|
upstreamId: number;
|
|
19
|
-
upstream
|
|
19
|
+
upstream?: JobModel;
|
|
20
20
|
nodeId: number;
|
|
21
21
|
node?: FlowNodeModel;
|
|
22
22
|
getNode: BelongsToGetAssociationMixin<FlowNodeModel>;
|
|
@@ -19,7 +19,12 @@ export default class WorkflowModel extends Model {
|
|
|
19
19
|
description?: string;
|
|
20
20
|
type: string;
|
|
21
21
|
config: any;
|
|
22
|
-
options:
|
|
22
|
+
options: {
|
|
23
|
+
timeout?: number;
|
|
24
|
+
stackLimit?: number;
|
|
25
|
+
deleteExecutionOnStatus?: number[];
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
23
28
|
sync: boolean;
|
|
24
29
|
createdAt: Date;
|
|
25
30
|
updatedAt: Date;
|
package/dist/server/utils.d.ts
CHANGED
|
@@ -6,4 +6,31 @@
|
|
|
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 { Transactionable } from '@nocobase/database';
|
|
10
|
+
import type { DataSourceManager } from '@nocobase/data-source-manager';
|
|
11
|
+
import type PluginWorkflowServer from './Plugin';
|
|
12
|
+
import { EXECUTION_REASON } from './constants';
|
|
13
|
+
import type { ExecutionModel, WorkflowModel } from './types';
|
|
14
|
+
import Processor from './Processor';
|
|
15
|
+
type AbortOptions = Transactionable & {
|
|
16
|
+
reason?: (typeof EXECUTION_REASON)[keyof typeof EXECUTION_REASON];
|
|
17
|
+
};
|
|
18
|
+
export declare function getExecutionLockKey(executionId: number | string): string;
|
|
19
|
+
export declare function isLockAcquireError(error: unknown): boolean;
|
|
20
|
+
export declare function validateCollectionField(collection: string, dataSourceManager: DataSourceManager): Record<string, string> | null;
|
|
21
|
+
export declare function getExecutionStatusName(status: number | null | undefined): string;
|
|
22
|
+
export declare function getWorkflowExecutionLogMeta(workflow: WorkflowModel, processor?: Processor): {
|
|
23
|
+
workflowId: number;
|
|
24
|
+
workflowKey: string;
|
|
25
|
+
workflowTitle: string;
|
|
26
|
+
executionId: number;
|
|
27
|
+
executionStatus: number;
|
|
28
|
+
executionStatusName: string;
|
|
29
|
+
lastNodeId: number;
|
|
30
|
+
lastNodeType: string;
|
|
31
|
+
lastJobId: number;
|
|
32
|
+
lastJobStatus: number;
|
|
33
|
+
};
|
|
34
|
+
export declare function abortExecution(plugin: PluginWorkflowServer, execution: ExecutionModel, options?: AbortOptions): Promise<boolean>;
|
|
9
35
|
export declare function toJSON(data: any): any;
|
|
36
|
+
export {};
|
package/dist/server/utils.js
CHANGED
|
@@ -26,10 +26,144 @@ 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
|
+
abortExecution: () => abortExecution,
|
|
30
|
+
getExecutionLockKey: () => getExecutionLockKey,
|
|
31
|
+
getExecutionStatusName: () => getExecutionStatusName,
|
|
32
|
+
getWorkflowExecutionLogMeta: () => getWorkflowExecutionLogMeta,
|
|
33
|
+
isLockAcquireError: () => isLockAcquireError,
|
|
34
|
+
toJSON: () => toJSON,
|
|
35
|
+
validateCollectionField: () => validateCollectionField
|
|
30
36
|
});
|
|
31
37
|
module.exports = __toCommonJS(utils_exports);
|
|
32
38
|
var import_database = require("@nocobase/database");
|
|
39
|
+
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
40
|
+
var import_constants = require("./constants");
|
|
41
|
+
function getExecutionLockKey(executionId) {
|
|
42
|
+
return `workflow:execution:${executionId}`;
|
|
43
|
+
}
|
|
44
|
+
function isLockAcquireError(error) {
|
|
45
|
+
return error instanceof Error && error.constructor.name === "LockAcquireError";
|
|
46
|
+
}
|
|
47
|
+
function afterTransactionCommit(transaction, callback) {
|
|
48
|
+
if (typeof transaction.afterCommit === "function") {
|
|
49
|
+
transaction.afterCommit(callback);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
callback();
|
|
53
|
+
}
|
|
54
|
+
function validateCollectionField(collection, dataSourceManager) {
|
|
55
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
56
|
+
if (!dataSourceName || !collectionName) {
|
|
57
|
+
return { collection: `"collection" must be in the format "dataSourceName:collectionName"` };
|
|
58
|
+
}
|
|
59
|
+
const dataSource = dataSourceManager.dataSources.get(dataSourceName);
|
|
60
|
+
if (!dataSource) {
|
|
61
|
+
return { collection: `Data source "${dataSourceName}" does not exist` };
|
|
62
|
+
}
|
|
63
|
+
if (!dataSource.collectionManager.getCollection(collectionName)) {
|
|
64
|
+
return { collection: `Collection "${collectionName}" does not exist in data source "${dataSourceName}"` };
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const EXECUTION_STATUS_NAMES = new Map(Object.entries(import_constants.EXECUTION_STATUS).map(([name, value]) => [value, name]));
|
|
69
|
+
function getExecutionStatusName(status) {
|
|
70
|
+
if (typeof status === "undefined") {
|
|
71
|
+
return "UNKNOWN";
|
|
72
|
+
}
|
|
73
|
+
return EXECUTION_STATUS_NAMES.get(status) ?? `${status}`;
|
|
74
|
+
}
|
|
75
|
+
function getWorkflowExecutionLogMeta(workflow, processor) {
|
|
76
|
+
var _a, _b, _c, _d;
|
|
77
|
+
const lastSavedJob = processor == null ? void 0 : processor.lastSavedJob;
|
|
78
|
+
const lastNode = (_a = processor == null ? void 0 : processor.nodesMap) == null ? void 0 : _a.get(lastSavedJob == null ? void 0 : lastSavedJob.nodeId);
|
|
79
|
+
return {
|
|
80
|
+
workflowId: workflow.id,
|
|
81
|
+
workflowKey: workflow.key,
|
|
82
|
+
workflowTitle: workflow.title,
|
|
83
|
+
executionId: ((_b = processor == null ? void 0 : processor.execution) == null ? void 0 : _b.id) ?? null,
|
|
84
|
+
executionStatus: ((_c = processor == null ? void 0 : processor.execution) == null ? void 0 : _c.status) ?? null,
|
|
85
|
+
executionStatusName: getExecutionStatusName((_d = processor == null ? void 0 : processor.execution) == null ? void 0 : _d.status),
|
|
86
|
+
lastNodeId: (lastNode == null ? void 0 : lastNode.id) ?? (lastSavedJob == null ? void 0 : lastSavedJob.nodeId) ?? null,
|
|
87
|
+
lastNodeType: (lastNode == null ? void 0 : lastNode.type) ?? null,
|
|
88
|
+
lastJobId: (lastSavedJob == null ? void 0 : lastSavedJob.id) ?? null,
|
|
89
|
+
lastJobStatus: (lastSavedJob == null ? void 0 : lastSavedJob.status) ?? null
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async function abortExecution(plugin, execution, options = {}) {
|
|
93
|
+
const logger = plugin.getLogger(execution.workflowId);
|
|
94
|
+
const transaction = options.transaction ?? void 0;
|
|
95
|
+
const ExecutionRepo = plugin.db.getRepository("executions");
|
|
96
|
+
const JobRepo = plugin.db.getRepository("jobs");
|
|
97
|
+
try {
|
|
98
|
+
const abortValues = {
|
|
99
|
+
status: import_constants.EXECUTION_STATUS.ABORTED,
|
|
100
|
+
...options.reason ? {
|
|
101
|
+
reason: options.reason
|
|
102
|
+
} : {}
|
|
103
|
+
};
|
|
104
|
+
if (transaction) {
|
|
105
|
+
const lockedExecution = await ExecutionRepo.findOne({
|
|
106
|
+
filterByTk: execution.id,
|
|
107
|
+
transaction,
|
|
108
|
+
lock: transaction.LOCK.UPDATE
|
|
109
|
+
});
|
|
110
|
+
if (!lockedExecution || lockedExecution.status !== import_constants.EXECUTION_STATUS.STARTED) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
await lockedExecution.update(abortValues, { transaction });
|
|
114
|
+
} else {
|
|
115
|
+
const [affected] = await ExecutionRepo.model.update(abortValues, {
|
|
116
|
+
where: {
|
|
117
|
+
id: execution.id,
|
|
118
|
+
status: import_constants.EXECUTION_STATUS.STARTED
|
|
119
|
+
},
|
|
120
|
+
individualHooks: true
|
|
121
|
+
});
|
|
122
|
+
if (!affected) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const updated = await JobRepo.update({
|
|
127
|
+
values: {
|
|
128
|
+
status: import_constants.JOB_STATUS.ABORTED
|
|
129
|
+
},
|
|
130
|
+
filter: {
|
|
131
|
+
executionId: execution.id,
|
|
132
|
+
status: import_constants.JOB_STATUS.PENDING
|
|
133
|
+
},
|
|
134
|
+
individualHooks: false,
|
|
135
|
+
transaction
|
|
136
|
+
});
|
|
137
|
+
const childExecutions = await plugin.db.getRepository("executions").find({
|
|
138
|
+
filter: {
|
|
139
|
+
parentExecutionId: execution.id,
|
|
140
|
+
status: import_constants.EXECUTION_STATUS.STARTED
|
|
141
|
+
},
|
|
142
|
+
transaction
|
|
143
|
+
});
|
|
144
|
+
for (const child of childExecutions) {
|
|
145
|
+
await abortExecution(plugin, child, { transaction, reason: import_constants.EXECUTION_REASON.PARENT_ABORTED });
|
|
146
|
+
}
|
|
147
|
+
const updateLocalState = () => {
|
|
148
|
+
execution.set("status", import_constants.EXECUTION_STATUS.ABORTED);
|
|
149
|
+
execution.set("reason", options.reason ?? null);
|
|
150
|
+
plugin.timeoutManager.clear(execution.id);
|
|
151
|
+
plugin.abortRunningExecution(execution.id, options.reason);
|
|
152
|
+
};
|
|
153
|
+
if (transaction) {
|
|
154
|
+
afterTransactionCommit(transaction, updateLocalState);
|
|
155
|
+
} else {
|
|
156
|
+
updateLocalState();
|
|
157
|
+
}
|
|
158
|
+
logger.info(`execution (${execution.id}) aborted`, {
|
|
159
|
+
workflowId: execution.workflowId,
|
|
160
|
+
pendingJobs: Array.isArray(updated) ? updated.length : updated
|
|
161
|
+
});
|
|
162
|
+
return true;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
33
167
|
function toJSON(data) {
|
|
34
168
|
if (Array.isArray(data)) {
|
|
35
169
|
return data.map(toJSON);
|
|
@@ -47,5 +181,11 @@ function toJSON(data) {
|
|
|
47
181
|
}
|
|
48
182
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
183
|
0 && (module.exports = {
|
|
50
|
-
|
|
184
|
+
abortExecution,
|
|
185
|
+
getExecutionLockKey,
|
|
186
|
+
getExecutionStatusName,
|
|
187
|
+
getWorkflowExecutionLogMeta,
|
|
188
|
+
isLockAcquireError,
|
|
189
|
+
toJSON,
|
|
190
|
+
validateCollectionField
|
|
51
191
|
});
|
package/dist/swagger/index.d.ts
CHANGED
|
@@ -329,24 +329,19 @@ declare const _default: {
|
|
|
329
329
|
'application/json': {
|
|
330
330
|
schema: {
|
|
331
331
|
type: string;
|
|
332
|
+
description: string;
|
|
332
333
|
properties: {
|
|
333
|
-
|
|
334
|
+
title: {
|
|
335
|
+
type: string;
|
|
336
|
+
description: string;
|
|
337
|
+
};
|
|
338
|
+
enabled: {
|
|
339
|
+
type: string;
|
|
340
|
+
description: string;
|
|
341
|
+
};
|
|
342
|
+
current: {
|
|
334
343
|
type: string;
|
|
335
344
|
description: string;
|
|
336
|
-
properties: {
|
|
337
|
-
title: {
|
|
338
|
-
type: string;
|
|
339
|
-
description: string;
|
|
340
|
-
};
|
|
341
|
-
enabled: {
|
|
342
|
-
type: string;
|
|
343
|
-
description: string;
|
|
344
|
-
};
|
|
345
|
-
current: {
|
|
346
|
-
type: string;
|
|
347
|
-
description: string;
|
|
348
|
-
};
|
|
349
|
-
};
|
|
350
345
|
};
|
|
351
346
|
};
|
|
352
347
|
};
|
|
@@ -417,13 +412,8 @@ declare const _default: {
|
|
|
417
412
|
'application/json': {
|
|
418
413
|
schema: {
|
|
419
414
|
type: string;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
values: {
|
|
423
|
-
type: string;
|
|
424
|
-
description: string;
|
|
425
|
-
};
|
|
426
|
-
};
|
|
415
|
+
description: string;
|
|
416
|
+
additionalProperties: boolean;
|
|
427
417
|
};
|
|
428
418
|
};
|
|
429
419
|
};
|
|
@@ -704,21 +694,16 @@ declare const _default: {
|
|
|
704
694
|
'application/json': {
|
|
705
695
|
schema: {
|
|
706
696
|
type: string;
|
|
697
|
+
description: string;
|
|
707
698
|
properties: {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
$ref: string;
|
|
717
|
-
};
|
|
718
|
-
config: {
|
|
719
|
-
$ref: string;
|
|
720
|
-
};
|
|
721
|
-
};
|
|
699
|
+
upstreamId: {
|
|
700
|
+
$ref: string;
|
|
701
|
+
};
|
|
702
|
+
branchIndex: {
|
|
703
|
+
$ref: string;
|
|
704
|
+
};
|
|
705
|
+
config: {
|
|
706
|
+
$ref: string;
|
|
722
707
|
};
|
|
723
708
|
};
|
|
724
709
|
};
|
|
@@ -764,22 +749,17 @@ declare const _default: {
|
|
|
764
749
|
'application/json': {
|
|
765
750
|
schema: {
|
|
766
751
|
type: string;
|
|
752
|
+
description: string;
|
|
767
753
|
properties: {
|
|
768
|
-
|
|
754
|
+
upstreamId: {
|
|
769
755
|
type: string;
|
|
756
|
+
nullable: boolean;
|
|
757
|
+
description: string;
|
|
758
|
+
};
|
|
759
|
+
branchIndex: {
|
|
760
|
+
type: string;
|
|
761
|
+
nullable: boolean;
|
|
770
762
|
description: string;
|
|
771
|
-
properties: {
|
|
772
|
-
upstreamId: {
|
|
773
|
-
type: string;
|
|
774
|
-
nullable: boolean;
|
|
775
|
-
description: string;
|
|
776
|
-
};
|
|
777
|
-
branchIndex: {
|
|
778
|
-
type: string;
|
|
779
|
-
nullable: boolean;
|
|
780
|
-
description: string;
|
|
781
|
-
};
|
|
782
|
-
};
|
|
783
763
|
};
|
|
784
764
|
};
|
|
785
765
|
};
|
|
@@ -820,17 +800,11 @@ declare const _default: {
|
|
|
820
800
|
type: string;
|
|
821
801
|
required: string[];
|
|
822
802
|
properties: {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
$ref: string;
|
|
829
|
-
};
|
|
830
|
-
config: {
|
|
831
|
-
$ref: string;
|
|
832
|
-
};
|
|
833
|
-
};
|
|
803
|
+
type: {
|
|
804
|
+
$ref: string;
|
|
805
|
+
};
|
|
806
|
+
config: {
|
|
807
|
+
$ref: string;
|
|
834
808
|
};
|
|
835
809
|
};
|
|
836
810
|
};
|
|
@@ -1116,24 +1090,19 @@ declare const _default: {
|
|
|
1116
1090
|
'application/json': {
|
|
1117
1091
|
schema: {
|
|
1118
1092
|
type: string;
|
|
1093
|
+
description: string;
|
|
1119
1094
|
properties: {
|
|
1120
|
-
|
|
1095
|
+
status: {
|
|
1096
|
+
type: string;
|
|
1097
|
+
description: string;
|
|
1098
|
+
};
|
|
1099
|
+
result: {
|
|
1100
|
+
type: string;
|
|
1101
|
+
description: string;
|
|
1102
|
+
};
|
|
1103
|
+
meta: {
|
|
1121
1104
|
type: string;
|
|
1122
1105
|
description: string;
|
|
1123
|
-
properties: {
|
|
1124
|
-
status: {
|
|
1125
|
-
type: string;
|
|
1126
|
-
description: string;
|
|
1127
|
-
};
|
|
1128
|
-
result: {
|
|
1129
|
-
type: string;
|
|
1130
|
-
description: string;
|
|
1131
|
-
};
|
|
1132
|
-
meta: {
|
|
1133
|
-
type: string;
|
|
1134
|
-
description: string;
|
|
1135
|
-
};
|
|
1136
|
-
};
|
|
1137
1106
|
};
|
|
1138
1107
|
};
|
|
1139
1108
|
};
|
|
@@ -1270,6 +1239,11 @@ declare const _default: {
|
|
|
1270
1239
|
description: string;
|
|
1271
1240
|
default: number;
|
|
1272
1241
|
};
|
|
1242
|
+
timeout: {
|
|
1243
|
+
type: string;
|
|
1244
|
+
description: string;
|
|
1245
|
+
default: number;
|
|
1246
|
+
};
|
|
1273
1247
|
};
|
|
1274
1248
|
};
|
|
1275
1249
|
categories: {
|
|
@@ -1417,6 +1391,23 @@ declare const _default: {
|
|
|
1417
1391
|
type: string;
|
|
1418
1392
|
description: string;
|
|
1419
1393
|
};
|
|
1394
|
+
parentExecutionId: {
|
|
1395
|
+
type: string;
|
|
1396
|
+
nullable: boolean;
|
|
1397
|
+
description: string;
|
|
1398
|
+
};
|
|
1399
|
+
startedAt: {
|
|
1400
|
+
type: string;
|
|
1401
|
+
format: string;
|
|
1402
|
+
nullable: boolean;
|
|
1403
|
+
description: string;
|
|
1404
|
+
};
|
|
1405
|
+
expiresAt: {
|
|
1406
|
+
type: string;
|
|
1407
|
+
format: string;
|
|
1408
|
+
nullable: boolean;
|
|
1409
|
+
description: string;
|
|
1410
|
+
};
|
|
1420
1411
|
jobs: {
|
|
1421
1412
|
type: string;
|
|
1422
1413
|
description: string;
|