@nocobase/plugin-workflow 2.1.0-alpha.1 → 2.1.0-alpha.11
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/93d3f3f8ced1c194.js +10 -0
- package/dist/client/AddNodeContext.d.ts +1 -0
- package/dist/client/NodeClipboardContext.d.ts +11 -0
- package/dist/client/NodeDragContext.d.ts +11 -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/hooks/{useWorkflowFilterActionProps.d.ts → useResourceFilterActionProps.d.ts} +1 -1
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +1 -1
- package/dist/client/models/NodeDetailsGridModel.d.ts +13 -0
- package/dist/client/models/NodeDetailsModel.d.ts +34 -0
- package/dist/client/models/NodeValueModel.d.ts +15 -0
- package/dist/client/models/TaskCardCommonItemModel.d.ts +14 -0
- package/dist/client/models/index.d.ts +11 -0
- package/dist/client/nodeVariableUtils.d.ts +14 -0
- package/dist/client/nodes/calculation.d.ts +7 -0
- package/dist/client/nodes/create.d.ts +23 -0
- package/dist/client/nodes/destroy.d.ts +10 -0
- package/dist/client/nodes/index.d.ts +24 -0
- package/dist/client/nodes/output.d.ts +53 -0
- package/dist/client/nodes/query.d.ts +23 -0
- package/dist/client/nodes/update.d.ts +11 -0
- package/dist/client/schemas/executions.d.ts +41 -22
- package/dist/client/style.d.ts +4 -0
- package/dist/client/triggers/collection.d.ts +27 -1
- package/dist/client/triggers/index.d.ts +14 -0
- package/dist/client/triggers/schedule/constants.d.ts +4 -0
- package/dist/client/triggers/schedule/index.d.ts +28 -0
- package/dist/common/collections/executions.d.ts +22 -22
- package/dist/common/collections/executions.js +12 -0
- package/dist/common/collections/jobs.js +4 -0
- package/dist/common/collections/workflows.d.ts +22 -9
- package/dist/common/collections/workflows.js +9 -1
- package/dist/externalVersion.js +12 -12
- package/dist/locale/de-DE.json +10 -3
- package/dist/locale/en-US.json +22 -3
- package/dist/locale/es-ES.json +10 -3
- package/dist/locale/fr-FR.json +10 -3
- package/dist/locale/hu-HU.json +10 -2
- package/dist/locale/id-ID.json +10 -2
- package/dist/locale/it-IT.json +10 -3
- package/dist/locale/ja-JP.json +10 -5
- package/dist/locale/ko-KR.json +10 -3
- package/dist/locale/nl-NL.json +10 -3
- package/dist/locale/pt-BR.json +10 -3
- package/dist/locale/ru-RU.json +10 -3
- package/dist/locale/tr-TR.json +10 -3
- package/dist/locale/uk-UA.json +10 -3
- package/dist/locale/vi-VN.json +10 -2
- package/dist/locale/zh-CN.json +28 -5
- package/dist/locale/zh-TW.json +10 -3
- 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/Dispatcher.d.ts +3 -2
- package/dist/server/Dispatcher.js +76 -62
- package/dist/server/Plugin.d.ts +1 -0
- package/dist/server/Plugin.js +32 -1
- package/dist/server/Processor.d.ts +9 -0
- package/dist/server/Processor.js +6 -1
- package/dist/server/actions/index.js +2 -0
- package/dist/server/actions/nodes.d.ts +7 -0
- package/dist/server/actions/nodes.js +315 -4
- package/dist/server/actions/workflows.d.ts +6 -0
- package/dist/server/actions/workflows.js +38 -0
- package/dist/server/instructions/ConditionInstruction.js +4 -1
- 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/OutputInstruction.d.ts +21 -0
- package/dist/server/instructions/OutputInstruction.js +54 -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/repositories/WorkflowRepository.js +2 -1
- 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/dist/swagger/index.d.ts +814 -62
- package/dist/swagger/index.js +975 -205
- package/package.json +4 -3
- package/dist/client/27bd65abee87cafa.js +0 -10
- package/dist/client/80d4cd8911e03c27.js +0 -10
- package/dist/client/bfc2a351589613e1.js +0 -10
- package/dist/client/e078314a62391f36.js +0 -10
|
@@ -29,22 +29,22 @@ __export(Dispatcher_exports, {
|
|
|
29
29
|
default: () => Dispatcher
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(Dispatcher_exports);
|
|
32
|
-
var
|
|
32
|
+
var import_node_crypto = require("node:crypto");
|
|
33
33
|
var import_sequelize = require("sequelize");
|
|
34
34
|
var import_constants = require("./constants");
|
|
35
35
|
var import_Plugin = require("./Plugin");
|
|
36
36
|
class Dispatcher {
|
|
37
37
|
constructor(plugin) {
|
|
38
38
|
this.plugin = plugin;
|
|
39
|
-
this.prepare = this.prepare.bind(this);
|
|
40
39
|
}
|
|
41
40
|
ready = false;
|
|
42
41
|
executing = null;
|
|
42
|
+
preparing = null;
|
|
43
43
|
pending = [];
|
|
44
44
|
events = [];
|
|
45
45
|
eventsCount = 0;
|
|
46
46
|
get idle() {
|
|
47
|
-
return this.ready && !this.executing && !this.pending.length && !this.events.length;
|
|
47
|
+
return this.ready && !this.executing && !this.preparing && !this.pending.length && !this.events.length;
|
|
48
48
|
}
|
|
49
49
|
onQueueExecution = async (event) => {
|
|
50
50
|
const ExecutionRepo = this.plugin.db.getRepository("executions");
|
|
@@ -96,11 +96,55 @@ class Dispatcher {
|
|
|
96
96
|
this.eventsCount = this.events.length;
|
|
97
97
|
logger.info(`new event triggered, now events: ${this.events.length}`);
|
|
98
98
|
logger.debug(`event data:`, { context });
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
this.prepare();
|
|
100
|
+
}
|
|
101
|
+
prepare() {
|
|
102
|
+
if (this.preparing) {
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
103
|
-
|
|
105
|
+
this.preparing = (async () => {
|
|
106
|
+
try {
|
|
107
|
+
while (this.events.length) {
|
|
108
|
+
if (this.executing && this.plugin.db.options.dialect === "sqlite") {
|
|
109
|
+
await this.executing;
|
|
110
|
+
}
|
|
111
|
+
const event = this.events.shift();
|
|
112
|
+
this.eventsCount = this.events.length;
|
|
113
|
+
if (!event) continue;
|
|
114
|
+
const logger = this.plugin.getLogger(event[0].id);
|
|
115
|
+
logger.info(`preparing execution for event`);
|
|
116
|
+
try {
|
|
117
|
+
const execution = await this.createExecution(...event);
|
|
118
|
+
if (!(execution == null ? void 0 : execution.dispatched)) {
|
|
119
|
+
if (this.plugin.serving() && !this.executing && !this.pending.length) {
|
|
120
|
+
logger.info(`local pending list is empty, adding execution (${execution.id}) to pending list`);
|
|
121
|
+
this.pending.push({ execution });
|
|
122
|
+
} else {
|
|
123
|
+
logger.info(
|
|
124
|
+
`instance is not serving as worker or local pending list is not empty, sending execution (${execution.id}) to queue`
|
|
125
|
+
);
|
|
126
|
+
try {
|
|
127
|
+
await this.plugin.app.eventQueue.publish(this.plugin.channelPendingExecution, {
|
|
128
|
+
executionId: execution.id
|
|
129
|
+
});
|
|
130
|
+
} catch (qErr) {
|
|
131
|
+
logger.error(`publishing execution (${execution.id}) to queue failed:`, { error: qErr });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
logger.error(`failed to create execution:`, { error });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} finally {
|
|
140
|
+
this.preparing = null;
|
|
141
|
+
if (this.events.length) {
|
|
142
|
+
this.prepare();
|
|
143
|
+
} else {
|
|
144
|
+
this.dispatch();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
})();
|
|
104
148
|
}
|
|
105
149
|
async resume(job) {
|
|
106
150
|
let { execution } = job;
|
|
@@ -119,16 +163,26 @@ class Dispatcher {
|
|
|
119
163
|
}
|
|
120
164
|
async beforeStop() {
|
|
121
165
|
this.ready = false;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
166
|
+
this.plugin.getLogger("dispatcher").info("app is stopping, draining local queues...");
|
|
167
|
+
while (this.preparing || this.executing || this.events.length || this.pending.length) {
|
|
168
|
+
if (this.preparing) {
|
|
169
|
+
await this.preparing;
|
|
170
|
+
}
|
|
171
|
+
if (this.executing) {
|
|
172
|
+
await this.executing;
|
|
173
|
+
}
|
|
174
|
+
if (this.events.length && !this.preparing) {
|
|
175
|
+
this.prepare();
|
|
176
|
+
}
|
|
177
|
+
if (this.pending.length && !this.executing) {
|
|
178
|
+
this.dispatch();
|
|
179
|
+
}
|
|
180
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
127
181
|
}
|
|
182
|
+
this.plugin.getLogger("dispatcher").info("local queues drained");
|
|
128
183
|
}
|
|
129
184
|
dispatch() {
|
|
130
|
-
if (!this.ready) {
|
|
131
|
-
this.plugin.getLogger("dispatcher").warn(`app is not ready, new dispatching will be ignored`);
|
|
185
|
+
if (!this.ready && !this.pending.length && !this.events.length) {
|
|
132
186
|
return;
|
|
133
187
|
}
|
|
134
188
|
if (this.executing) {
|
|
@@ -136,7 +190,8 @@ class Dispatcher {
|
|
|
136
190
|
return;
|
|
137
191
|
}
|
|
138
192
|
if (this.events.length) {
|
|
139
|
-
|
|
193
|
+
this.prepare();
|
|
194
|
+
return;
|
|
140
195
|
}
|
|
141
196
|
this.executing = (async () => {
|
|
142
197
|
let next = null;
|
|
@@ -149,13 +204,15 @@ class Dispatcher {
|
|
|
149
204
|
this.plugin.getLogger(next[0].workflowId).info(`pending execution (${next[0].id}) ready to process`);
|
|
150
205
|
}
|
|
151
206
|
} else {
|
|
152
|
-
if (this.plugin.serving()) {
|
|
207
|
+
if (this.ready && this.plugin.serving()) {
|
|
153
208
|
execution = await this.acquireQueueingExecution();
|
|
154
209
|
if (execution) {
|
|
155
210
|
next = [execution];
|
|
156
211
|
}
|
|
157
212
|
} else {
|
|
158
|
-
this.plugin.getLogger("dispatcher").warn(
|
|
213
|
+
this.plugin.getLogger("dispatcher").warn(
|
|
214
|
+
`${import_Plugin.WORKER_JOB_WORKFLOW_PROCESS} is not serving on this instance or app not ready, new dispatching will be ignored`
|
|
215
|
+
);
|
|
159
216
|
}
|
|
160
217
|
}
|
|
161
218
|
if (next) {
|
|
@@ -233,7 +290,7 @@ class Dispatcher {
|
|
|
233
290
|
{
|
|
234
291
|
context,
|
|
235
292
|
key: workflow.key,
|
|
236
|
-
eventKey: options.eventKey ?? (0,
|
|
293
|
+
eventKey: options.eventKey ?? (0, import_node_crypto.randomUUID)(),
|
|
237
294
|
stack: options.stack,
|
|
238
295
|
dispatched: deferred ?? false,
|
|
239
296
|
status: deferred ? import_constants.EXECUTION_STATUS.STARTED : import_constants.EXECUTION_STATUS.QUEUEING,
|
|
@@ -268,50 +325,6 @@ class Dispatcher {
|
|
|
268
325
|
execution.workflow = workflow;
|
|
269
326
|
return execution;
|
|
270
327
|
}
|
|
271
|
-
prepare = async () => {
|
|
272
|
-
if (this.executing && this.plugin.db.options.dialect === "sqlite") {
|
|
273
|
-
await this.executing;
|
|
274
|
-
}
|
|
275
|
-
const event = this.events.shift();
|
|
276
|
-
this.eventsCount = this.events.length;
|
|
277
|
-
if (!event) {
|
|
278
|
-
this.plugin.getLogger("dispatcher").info(`events queue is empty, no need to prepare`);
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
const logger = this.plugin.getLogger(event[0].id);
|
|
282
|
-
logger.info(`preparing execution for event`);
|
|
283
|
-
try {
|
|
284
|
-
const execution = await this.createExecution(...event);
|
|
285
|
-
if (!(execution == null ? void 0 : execution.dispatched)) {
|
|
286
|
-
if (this.plugin.serving() && !this.executing && !this.pending.length) {
|
|
287
|
-
logger.info(`local pending list is empty, adding execution (${execution.id}) to pending list`);
|
|
288
|
-
this.pending.push({ execution });
|
|
289
|
-
} else {
|
|
290
|
-
logger.info(
|
|
291
|
-
`instance is not serving as worker or local pending list is not empty, sending execution (${execution.id}) to queue`
|
|
292
|
-
);
|
|
293
|
-
try {
|
|
294
|
-
await this.plugin.app.eventQueue.publish(this.plugin.channelPendingExecution, {
|
|
295
|
-
executionId: execution.id
|
|
296
|
-
});
|
|
297
|
-
} catch (qErr) {
|
|
298
|
-
logger.error(`publishing execution (${execution.id}) to queue failed:`, { error: qErr });
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
} catch (error) {
|
|
303
|
-
logger.error(`failed to create execution:`, { error });
|
|
304
|
-
}
|
|
305
|
-
if (this.events.length) {
|
|
306
|
-
await this.prepare();
|
|
307
|
-
} else {
|
|
308
|
-
this.plugin.getLogger("dispatcher").info("no more events need to be prepared, dispatching...");
|
|
309
|
-
if (this.executing) {
|
|
310
|
-
await this.executing;
|
|
311
|
-
}
|
|
312
|
-
this.dispatch();
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
328
|
async acquirePendingExecution(execution) {
|
|
316
329
|
const logger = this.plugin.getLogger(execution.workflowId);
|
|
317
330
|
const isolationLevel = this.plugin.db.options.dialect === "sqlite" ? [][0] : import_sequelize.Transaction.ISOLATION_LEVELS.REPEATABLE_READ;
|
|
@@ -390,7 +403,8 @@ class Dispatcher {
|
|
|
390
403
|
logger.info(`execution (${execution.id}) ${job ? "resuming" : "starting"}...`);
|
|
391
404
|
try {
|
|
392
405
|
await (job ? processor.resume(job) : processor.start());
|
|
393
|
-
logger.info(`execution (${execution.id}) finished with status: ${execution.status}
|
|
406
|
+
logger.info(`execution (${execution.id}) finished with status: ${execution.status}`);
|
|
407
|
+
logger.debug(`execution (${execution.id}) details:`, { execution });
|
|
394
408
|
if (execution.status && ((_b = (_a = execution.workflow.options) == null ? void 0 : _a.deleteExecutionOnStatus) == null ? void 0 : _b.includes(execution.status))) {
|
|
395
409
|
await execution.destroy({ transaction: processor.mainTransaction });
|
|
396
410
|
}
|
package/dist/server/Plugin.d.ts
CHANGED
package/dist/server/Plugin.js
CHANGED
|
@@ -49,12 +49,15 @@ var import_utils = require("@nocobase/utils");
|
|
|
49
49
|
var import_Dispatcher = __toESM(require("./Dispatcher"));
|
|
50
50
|
var import_Processor = __toESM(require("./Processor"));
|
|
51
51
|
var import_actions = __toESM(require("./actions"));
|
|
52
|
+
var import_nodes = require("./actions/nodes");
|
|
53
|
+
var import_workflows = require("./actions/workflows");
|
|
52
54
|
var import_functions = __toESM(require("./functions"));
|
|
53
55
|
var import_CollectionTrigger = __toESM(require("./triggers/CollectionTrigger"));
|
|
54
56
|
var import_ScheduleTrigger = __toESM(require("./triggers/ScheduleTrigger"));
|
|
55
57
|
var import_CalculationInstruction = __toESM(require("./instructions/CalculationInstruction"));
|
|
56
58
|
var import_ConditionInstruction = __toESM(require("./instructions/ConditionInstruction"));
|
|
57
59
|
var import_EndInstruction = __toESM(require("./instructions/EndInstruction"));
|
|
60
|
+
var import_OutputInstruction = __toESM(require("./instructions/OutputInstruction"));
|
|
58
61
|
var import_CreateInstruction = __toESM(require("./instructions/CreateInstruction"));
|
|
59
62
|
var import_DestroyInstruction = __toESM(require("./instructions/DestroyInstruction"));
|
|
60
63
|
var import_QueryInstruction = __toESM(require("./instructions/QueryInstruction"));
|
|
@@ -270,6 +273,7 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
270
273
|
this.registerInstruction("condition", import_ConditionInstruction.default);
|
|
271
274
|
this.registerInstruction("multi-conditions", import_MultiConditionsInstruction.default);
|
|
272
275
|
this.registerInstruction("end", import_EndInstruction.default);
|
|
276
|
+
this.registerInstruction("output", import_OutputInstruction.default);
|
|
273
277
|
this.registerInstruction("create", import_CreateInstruction.default);
|
|
274
278
|
this.registerInstruction("destroy", import_DestroyInstruction.default);
|
|
275
279
|
this.registerInstruction("query", import_QueryInstruction.default);
|
|
@@ -278,6 +282,29 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
278
282
|
this.registerInstruction(name, instruction);
|
|
279
283
|
}
|
|
280
284
|
}
|
|
285
|
+
registerErrorHandlers() {
|
|
286
|
+
const PluginErrorHandler = this.app.pm.get("error-handler");
|
|
287
|
+
if (PluginErrorHandler == null ? void 0 : PluginErrorHandler.errorHandler) {
|
|
288
|
+
PluginErrorHandler.errorHandler.register(
|
|
289
|
+
(err) => err instanceof import_nodes.NodeValidationError || err.name === "NodeValidationError",
|
|
290
|
+
(err, ctx) => {
|
|
291
|
+
ctx.status = err.status;
|
|
292
|
+
ctx.body = {
|
|
293
|
+
errors: Object.values(err.errors).map((message) => ({ message }))
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
);
|
|
297
|
+
PluginErrorHandler.errorHandler.register(
|
|
298
|
+
(err) => err instanceof import_workflows.WorkflowValidationError || err.name === "WorkflowValidationError",
|
|
299
|
+
(err, ctx) => {
|
|
300
|
+
ctx.status = err.status;
|
|
301
|
+
ctx.body = {
|
|
302
|
+
errors: Object.values(err.errors).map((message) => ({ message }))
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
281
308
|
async beforeLoad() {
|
|
282
309
|
this.db.registerRepositories({
|
|
283
310
|
WorkflowRepository: import_WorkflowRepository.default
|
|
@@ -287,7 +314,8 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
287
314
|
filter: { name: this.name }
|
|
288
315
|
});
|
|
289
316
|
this.snowflake = new import_nodejs_snowflake.Snowflake({
|
|
290
|
-
custom_epoch: pluginRecord == null ? void 0 : pluginRecord.createdAt.getTime()
|
|
317
|
+
custom_epoch: pluginRecord == null ? void 0 : pluginRecord.createdAt.getTime(),
|
|
318
|
+
instance_id: this.app.instanceId
|
|
291
319
|
});
|
|
292
320
|
}
|
|
293
321
|
/**
|
|
@@ -299,6 +327,7 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
299
327
|
this.initTriggers(options.triggers);
|
|
300
328
|
this.initInstructions(options.instructions);
|
|
301
329
|
(0, import_functions.default)(this, options.functions);
|
|
330
|
+
this.registerErrorHandlers();
|
|
302
331
|
this.functions.register("instanceId", () => this.app.instanceId);
|
|
303
332
|
this.functions.register("epoch", () => 1605024e3);
|
|
304
333
|
this.functions.register("genSnowflakeId", () => this.app.snowflakeIdGenerator.generate());
|
|
@@ -335,6 +364,8 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
335
364
|
"flow_nodes:update",
|
|
336
365
|
"flow_nodes:destroy",
|
|
337
366
|
"flow_nodes:destroyBranch",
|
|
367
|
+
"flow_nodes:duplicate",
|
|
368
|
+
"flow_nodes:move",
|
|
338
369
|
"flow_nodes:test",
|
|
339
370
|
"jobs:get",
|
|
340
371
|
"workflowCategories:*"
|
|
@@ -96,6 +96,15 @@ export default class Processor {
|
|
|
96
96
|
* @experimental
|
|
97
97
|
*/
|
|
98
98
|
getScope(sourceNodeId?: number | string, includeSelfScope?: boolean): {
|
|
99
|
+
ctx: {
|
|
100
|
+
$context: any;
|
|
101
|
+
$jobsMapByNodeKey: {
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
};
|
|
104
|
+
$system: {};
|
|
105
|
+
$scopes: {};
|
|
106
|
+
$env: {};
|
|
107
|
+
};
|
|
99
108
|
$context: any;
|
|
100
109
|
$jobsMapByNodeKey: {
|
|
101
110
|
[key: string]: any;
|
package/dist/server/Processor.js
CHANGED
|
@@ -439,13 +439,18 @@ class Processor {
|
|
|
439
439
|
$scopes[n.id] = $scopes[n.key] = instruction.getScope(n, this.jobResultsMapByNodeKey[n.key], this);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
|
|
442
|
+
const scopes = {
|
|
443
443
|
$context: this.execution.context,
|
|
444
444
|
$jobsMapByNodeKey: this.jobResultsMapByNodeKey,
|
|
445
445
|
$system: systemFns,
|
|
446
446
|
$scopes,
|
|
447
447
|
$env: this.options.plugin.app.environment.getVariables()
|
|
448
448
|
};
|
|
449
|
+
return {
|
|
450
|
+
...scopes,
|
|
451
|
+
ctx: scopes
|
|
452
|
+
// 2.0
|
|
453
|
+
};
|
|
449
454
|
}
|
|
450
455
|
/**
|
|
451
456
|
* @experimental
|
|
@@ -7,8 +7,15 @@
|
|
|
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 NodeValidationError extends Error {
|
|
11
|
+
status: number;
|
|
12
|
+
errors: Record<string, string>;
|
|
13
|
+
constructor(errors: Record<string, string>);
|
|
14
|
+
}
|
|
10
15
|
export declare function create(context: Context, next: any): Promise<void>;
|
|
16
|
+
export declare function duplicate(context: Context, next: any): Promise<void>;
|
|
11
17
|
export declare function destroy(context: Context, next: any): Promise<void>;
|
|
12
18
|
export declare function destroyBranch(context: Context, next: any): Promise<void>;
|
|
19
|
+
export declare function move(context: Context, next: any): Promise<void>;
|
|
13
20
|
export declare function update(context: Context, next: any): Promise<void>;
|
|
14
21
|
export declare function test(context: Context, next: any): Promise<void>;
|