@nocobase/plugin-workflow 2.1.0-beta.44 → 2.1.0-beta.46
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/index.js +1 -1
- package/dist/externalVersion.js +12 -12
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/joi/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/server/Dispatcher.d.ts +3 -0
- package/dist/server/Dispatcher.js +123 -85
- package/dist/server/ExecutionTimeoutManager.d.ts +1 -0
- package/dist/server/ExecutionTimeoutManager.js +16 -8
- package/dist/server/Plugin.d.ts +4 -3
- package/dist/server/Plugin.js +5 -8
- package/dist/server/Processor.d.ts +0 -4
- package/dist/server/Processor.js +8 -22
- package/dist/server/instructions/OutputInstruction.js +1 -1
- package/dist/server/triggers/CollectionTrigger.js +6 -0
- package/dist/server/utils.js +34 -30
- package/package.json +2 -2
package/dist/server/utils.js
CHANGED
|
@@ -91,33 +91,38 @@ function getWorkflowExecutionLogMeta(workflow, processor) {
|
|
|
91
91
|
}
|
|
92
92
|
async function abortExecution(plugin, execution, options = {}) {
|
|
93
93
|
const logger = plugin.getLogger(execution.workflowId);
|
|
94
|
-
const
|
|
95
|
-
const transaction = options.transaction ?? await plugin.useDataSourceTransaction("main", null, true);
|
|
94
|
+
const transaction = options.transaction ?? void 0;
|
|
96
95
|
const ExecutionRepo = plugin.db.getRepository("executions");
|
|
97
96
|
const JobRepo = plugin.db.getRepository("jobs");
|
|
98
97
|
try {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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;
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
{
|
|
118
|
-
|
|
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;
|
|
119
124
|
}
|
|
120
|
-
|
|
125
|
+
}
|
|
121
126
|
const updated = await JobRepo.update({
|
|
122
127
|
values: {
|
|
123
128
|
status: import_constants.JOB_STATUS.ABORTED
|
|
@@ -139,24 +144,23 @@ async function abortExecution(plugin, execution, options = {}) {
|
|
|
139
144
|
for (const child of childExecutions) {
|
|
140
145
|
await abortExecution(plugin, child, { transaction, reason: import_constants.EXECUTION_REASON.PARENT_ABORTED });
|
|
141
146
|
}
|
|
142
|
-
|
|
147
|
+
const updateLocalState = () => {
|
|
143
148
|
execution.set("status", import_constants.EXECUTION_STATUS.ABORTED);
|
|
144
149
|
execution.set("reason", options.reason ?? null);
|
|
145
150
|
plugin.timeoutManager.clear(execution.id);
|
|
146
151
|
plugin.abortRunningExecution(execution.id, options.reason);
|
|
147
|
-
}
|
|
152
|
+
};
|
|
153
|
+
if (transaction) {
|
|
154
|
+
afterTransactionCommit(transaction, updateLocalState);
|
|
155
|
+
} else {
|
|
156
|
+
updateLocalState();
|
|
157
|
+
}
|
|
148
158
|
logger.info(`execution (${execution.id}) aborted`, {
|
|
149
159
|
workflowId: execution.workflowId,
|
|
150
160
|
pendingJobs: Array.isArray(updated) ? updated.length : updated
|
|
151
161
|
});
|
|
152
|
-
if (ownTransaction) {
|
|
153
|
-
await transaction.commit();
|
|
154
|
-
}
|
|
155
162
|
return true;
|
|
156
163
|
} catch (error) {
|
|
157
|
-
if (ownTransaction && !transaction.finished) {
|
|
158
|
-
await transaction.rollback();
|
|
159
|
-
}
|
|
160
164
|
throw error;
|
|
161
165
|
}
|
|
162
166
|
}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
|
|
7
7
|
"description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
|
|
8
8
|
"description.ru-RU": "Мощный инструмент BPM, обеспечивающий базовую поддержку автоматизации бизнес-процессов с возможностью неограниченного расширения триггеров и узлов.",
|
|
9
|
-
"version": "2.1.0-beta.
|
|
9
|
+
"version": "2.1.0-beta.46",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/workflow",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@nocobase/test": "2.x",
|
|
50
50
|
"@nocobase/utils": "2.x"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "91fd3ab238a5ff58735bbfca04a8cb05d233b0af",
|
|
53
53
|
"keywords": [
|
|
54
54
|
"Workflow"
|
|
55
55
|
]
|