@nocobase/plugin-workflow 2.1.0-alpha.1 → 2.1.0-alpha.10
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/0e7da88f89e15485.js +10 -0
- package/dist/client/37560b46d530bcf9.js +10 -0
- package/dist/client/4464fed3a8411375.js +10 -0
- package/dist/client/973723cf75f1e4e9.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/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 +13 -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 +13 -0
- package/dist/client/nodes/update.d.ts +1 -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 +13 -0
- package/dist/client/triggers/index.d.ts +10 -0
- package/dist/client/triggers/schedule/index.d.ts +13 -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 +27 -5
- package/dist/locale/zh-TW.json +10 -3
- package/dist/node_modules/cron-parser/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 -2
- package/dist/server/Dispatcher.js +76 -62
- package/dist/server/Plugin.js +6 -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 +2 -0
- package/dist/server/actions/nodes.js +281 -2
- package/dist/server/instructions/ConditionInstruction.js +4 -1
- package/dist/server/instructions/OutputInstruction.d.ts +21 -0
- package/dist/server/instructions/OutputInstruction.js +54 -0
- package/dist/server/repositories/WorkflowRepository.js +2 -1
- package/dist/swagger/index.d.ts +814 -62
- package/dist/swagger/index.js +975 -205
- package/package.json +3 -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
|
@@ -39,6 +39,8 @@ __export(nodes_exports, {
|
|
|
39
39
|
create: () => create,
|
|
40
40
|
destroy: () => destroy,
|
|
41
41
|
destroyBranch: () => destroyBranch,
|
|
42
|
+
duplicate: () => duplicate,
|
|
43
|
+
move: () => move,
|
|
42
44
|
test: () => test,
|
|
43
45
|
update: () => update
|
|
44
46
|
});
|
|
@@ -49,10 +51,10 @@ var import__ = __toESM(require(".."));
|
|
|
49
51
|
async function create(context, next) {
|
|
50
52
|
const { db } = context;
|
|
51
53
|
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
52
|
-
const { whitelist, blacklist, updateAssociationValues, values
|
|
54
|
+
const { whitelist, blacklist, updateAssociationValues, values } = context.action.params;
|
|
53
55
|
const workflowPlugin = context.app.pm.get(import__.default);
|
|
54
56
|
context.body = await db.sequelize.transaction(async (transaction) => {
|
|
55
|
-
const workflow = workflowPlugin.enabledCache.get(Number.parseInt(
|
|
57
|
+
const workflow = workflowPlugin.enabledCache.get(Number.parseInt(context.action.sourceId, 10)) || await repository.getSourceModel(transaction);
|
|
56
58
|
if (!workflow.versionStats) {
|
|
57
59
|
workflow.versionStats = await workflow.getVersionStats({ transaction });
|
|
58
60
|
}
|
|
@@ -133,6 +135,117 @@ async function create(context, next) {
|
|
|
133
135
|
});
|
|
134
136
|
await next();
|
|
135
137
|
}
|
|
138
|
+
async function duplicate(context, next) {
|
|
139
|
+
const { db } = context;
|
|
140
|
+
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
141
|
+
const { whitelist, blacklist, filterByTk, values = {} } = context.action.params;
|
|
142
|
+
const workflowPlugin = context.app.pm.get(import__.default);
|
|
143
|
+
context.body = await db.sequelize.transaction(async (transaction) => {
|
|
144
|
+
const origin = filterByTk ? await repository.findOne({ filterByTk, transaction }) : null;
|
|
145
|
+
if (!origin) {
|
|
146
|
+
return context.throw(404, "Node not found");
|
|
147
|
+
}
|
|
148
|
+
const workflow = workflowPlugin.enabledCache.get(origin.workflowId) || await db.getRepository("workflows").findOne({
|
|
149
|
+
filterByTk: origin.workflowId,
|
|
150
|
+
transaction
|
|
151
|
+
});
|
|
152
|
+
if (!workflow) {
|
|
153
|
+
return context.throw(400, "Workflow not found");
|
|
154
|
+
}
|
|
155
|
+
if (!workflow.versionStats) {
|
|
156
|
+
workflow.versionStats = await workflow.getVersionStats({ transaction });
|
|
157
|
+
}
|
|
158
|
+
if (workflow.versionStats.executed > 0) {
|
|
159
|
+
context.throw(400, "Node could not be created in executed workflow");
|
|
160
|
+
}
|
|
161
|
+
const NODES_LIMIT = process.env.WORKFLOW_NODES_LIMIT ? parseInt(process.env.WORKFLOW_NODES_LIMIT, 10) : null;
|
|
162
|
+
if (NODES_LIMIT) {
|
|
163
|
+
const nodesCount = await workflow.countNodes({ transaction });
|
|
164
|
+
if (nodesCount >= NODES_LIMIT) {
|
|
165
|
+
context.throw(400, `The number of nodes in a workflow cannot exceed ${NODES_LIMIT}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
let nextConfig = values.config;
|
|
169
|
+
if (!nextConfig) {
|
|
170
|
+
const instruction = workflowPlugin.instructions.get(origin.type);
|
|
171
|
+
if (instruction && typeof instruction.duplicateConfig === "function") {
|
|
172
|
+
nextConfig = await instruction.duplicateConfig(origin, { origin: origin ?? void 0, transaction });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const instance = await repository.create({
|
|
176
|
+
values: {
|
|
177
|
+
config: nextConfig ?? origin.config,
|
|
178
|
+
upstreamId: values.upstreamId,
|
|
179
|
+
branchIndex: values.branchIndex,
|
|
180
|
+
type: origin.type,
|
|
181
|
+
title: origin.title,
|
|
182
|
+
workflowId: origin.workflowId
|
|
183
|
+
},
|
|
184
|
+
whitelist,
|
|
185
|
+
blacklist,
|
|
186
|
+
context,
|
|
187
|
+
transaction
|
|
188
|
+
});
|
|
189
|
+
if (!instance.upstreamId) {
|
|
190
|
+
const previousHead = await repository.findOne({
|
|
191
|
+
filter: {
|
|
192
|
+
id: {
|
|
193
|
+
$ne: instance.id
|
|
194
|
+
},
|
|
195
|
+
workflowId: origin.workflowId,
|
|
196
|
+
upstreamId: null
|
|
197
|
+
},
|
|
198
|
+
transaction
|
|
199
|
+
});
|
|
200
|
+
if (previousHead) {
|
|
201
|
+
await previousHead.setUpstream(instance, { transaction });
|
|
202
|
+
await instance.setDownstream(previousHead, { transaction });
|
|
203
|
+
instance.set("downstream", previousHead);
|
|
204
|
+
}
|
|
205
|
+
return instance;
|
|
206
|
+
}
|
|
207
|
+
const upstream = await instance.getUpstream({ transaction });
|
|
208
|
+
if (instance.branchIndex == null) {
|
|
209
|
+
const downstream = await upstream.getDownstream({ transaction });
|
|
210
|
+
if (downstream) {
|
|
211
|
+
await downstream.setUpstream(instance, { transaction });
|
|
212
|
+
await instance.setDownstream(downstream, { transaction });
|
|
213
|
+
instance.set("downstream", downstream);
|
|
214
|
+
}
|
|
215
|
+
await upstream.update(
|
|
216
|
+
{
|
|
217
|
+
downstreamId: instance.id
|
|
218
|
+
},
|
|
219
|
+
{ transaction }
|
|
220
|
+
);
|
|
221
|
+
upstream.set("downstream", instance);
|
|
222
|
+
} else {
|
|
223
|
+
const [downstream] = await upstream.getBranches({
|
|
224
|
+
where: {
|
|
225
|
+
id: {
|
|
226
|
+
[import_database.Op.ne]: instance.id
|
|
227
|
+
},
|
|
228
|
+
branchIndex: instance.branchIndex
|
|
229
|
+
},
|
|
230
|
+
transaction
|
|
231
|
+
});
|
|
232
|
+
if (downstream) {
|
|
233
|
+
await downstream.update(
|
|
234
|
+
{
|
|
235
|
+
upstreamId: instance.id,
|
|
236
|
+
branchIndex: null
|
|
237
|
+
},
|
|
238
|
+
{ transaction }
|
|
239
|
+
);
|
|
240
|
+
await instance.setDownstream(downstream, { transaction });
|
|
241
|
+
instance.set("downstream", downstream);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
instance.set("upstream", upstream);
|
|
245
|
+
return instance;
|
|
246
|
+
});
|
|
247
|
+
await next();
|
|
248
|
+
}
|
|
136
249
|
function searchBranchNodes(nodes, from) {
|
|
137
250
|
const branchHeads = nodes.filter((item) => item.upstreamId === from.id && item.branchIndex != null);
|
|
138
251
|
return branchHeads.reduce(
|
|
@@ -336,6 +449,170 @@ async function destroyBranch(context, next) {
|
|
|
336
449
|
context.body = deletedBranchHead;
|
|
337
450
|
await next();
|
|
338
451
|
}
|
|
452
|
+
async function move(context, next) {
|
|
453
|
+
const { db } = context;
|
|
454
|
+
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
455
|
+
const { filterByTk, values = {} } = context.action.params;
|
|
456
|
+
const rawUpstreamId = values.upstreamId;
|
|
457
|
+
const rawBranchIndex = values.branchIndex;
|
|
458
|
+
const upstreamId = rawUpstreamId == null || rawUpstreamId === "" ? null : rawUpstreamId;
|
|
459
|
+
let branchIndex = rawBranchIndex == null || rawBranchIndex === "" ? null : Number.parseInt(rawBranchIndex, 10);
|
|
460
|
+
if (rawBranchIndex != null && rawBranchIndex !== "" && Number.isNaN(branchIndex)) {
|
|
461
|
+
context.throw(400, "branchIndex must be a number");
|
|
462
|
+
}
|
|
463
|
+
if (upstreamId == null) {
|
|
464
|
+
branchIndex = null;
|
|
465
|
+
}
|
|
466
|
+
const fields = ["id", "key", "upstreamId", "downstreamId", "branchIndex", "workflowId"];
|
|
467
|
+
context.body = await db.sequelize.transaction(async (transaction) => {
|
|
468
|
+
const instance = await repository.findOne({
|
|
469
|
+
filterByTk,
|
|
470
|
+
fields,
|
|
471
|
+
appends: ["upstream", "downstream", "workflow.versionStats"],
|
|
472
|
+
transaction
|
|
473
|
+
});
|
|
474
|
+
if (!instance) {
|
|
475
|
+
context.throw(404, "Node not found");
|
|
476
|
+
}
|
|
477
|
+
if (instance.workflow.versionStats.executed > 0) {
|
|
478
|
+
context.throw(400, "Nodes in executed workflow could not be moved");
|
|
479
|
+
}
|
|
480
|
+
if (upstreamId != null && String(upstreamId) === String(instance.id)) {
|
|
481
|
+
context.throw(400, "Invalid upstream node");
|
|
482
|
+
}
|
|
483
|
+
const sameUpstream = (instance.upstreamId ?? null) == (upstreamId ?? null);
|
|
484
|
+
const sameBranchIndex = (instance.branchIndex ?? null) == (branchIndex ?? null);
|
|
485
|
+
if (sameUpstream && sameBranchIndex) {
|
|
486
|
+
context.throw(400, "Node does not need to be moved");
|
|
487
|
+
}
|
|
488
|
+
const { upstream: oldUpstream, downstream: oldDownstream } = instance.get();
|
|
489
|
+
if (oldUpstream && oldUpstream.downstreamId === instance.id) {
|
|
490
|
+
await oldUpstream.update(
|
|
491
|
+
{
|
|
492
|
+
downstreamId: oldDownstream ? oldDownstream.id : null
|
|
493
|
+
},
|
|
494
|
+
{ transaction }
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
if (oldDownstream && oldDownstream.upstreamId === instance.id) {
|
|
498
|
+
await oldDownstream.update(
|
|
499
|
+
{
|
|
500
|
+
upstreamId: oldUpstream ? oldUpstream.id : null,
|
|
501
|
+
branchIndex: instance.branchIndex ?? null
|
|
502
|
+
},
|
|
503
|
+
{ transaction }
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
let targetUpstream = null;
|
|
507
|
+
if (upstreamId != null) {
|
|
508
|
+
targetUpstream = await repository.findOne({
|
|
509
|
+
filterByTk: upstreamId,
|
|
510
|
+
fields,
|
|
511
|
+
transaction
|
|
512
|
+
});
|
|
513
|
+
if (!targetUpstream) {
|
|
514
|
+
context.throw(404, "Upstream node not found");
|
|
515
|
+
}
|
|
516
|
+
if (targetUpstream.workflowId !== instance.workflowId) {
|
|
517
|
+
context.throw(400, "Upstream node is not in the same workflow");
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
let newDownstream = null;
|
|
521
|
+
if (!targetUpstream) {
|
|
522
|
+
const previousHead = await repository.findOne({
|
|
523
|
+
filter: {
|
|
524
|
+
workflowId: instance.workflowId,
|
|
525
|
+
upstreamId: null,
|
|
526
|
+
id: {
|
|
527
|
+
[import_database.Op.ne]: instance.id
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
fields,
|
|
531
|
+
transaction
|
|
532
|
+
});
|
|
533
|
+
if (previousHead) {
|
|
534
|
+
await previousHead.update(
|
|
535
|
+
{
|
|
536
|
+
upstreamId: instance.id,
|
|
537
|
+
branchIndex: null
|
|
538
|
+
},
|
|
539
|
+
{ transaction }
|
|
540
|
+
);
|
|
541
|
+
newDownstream = previousHead;
|
|
542
|
+
}
|
|
543
|
+
await instance.update(
|
|
544
|
+
{
|
|
545
|
+
upstreamId: null,
|
|
546
|
+
branchIndex: null,
|
|
547
|
+
downstreamId: newDownstream ? newDownstream.id : null
|
|
548
|
+
},
|
|
549
|
+
{ transaction }
|
|
550
|
+
);
|
|
551
|
+
return instance;
|
|
552
|
+
}
|
|
553
|
+
if (branchIndex == null) {
|
|
554
|
+
if (targetUpstream.downstreamId) {
|
|
555
|
+
newDownstream = await repository.findOne({
|
|
556
|
+
filterByTk: targetUpstream.downstreamId,
|
|
557
|
+
fields,
|
|
558
|
+
transaction
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
if (newDownstream) {
|
|
562
|
+
await newDownstream.update(
|
|
563
|
+
{
|
|
564
|
+
upstreamId: instance.id,
|
|
565
|
+
branchIndex: null
|
|
566
|
+
},
|
|
567
|
+
{ transaction }
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
await targetUpstream.update(
|
|
571
|
+
{
|
|
572
|
+
downstreamId: instance.id
|
|
573
|
+
},
|
|
574
|
+
{ transaction }
|
|
575
|
+
);
|
|
576
|
+
await instance.update(
|
|
577
|
+
{
|
|
578
|
+
upstreamId: targetUpstream.id,
|
|
579
|
+
branchIndex: null,
|
|
580
|
+
downstreamId: newDownstream ? newDownstream.id : null
|
|
581
|
+
},
|
|
582
|
+
{ transaction }
|
|
583
|
+
);
|
|
584
|
+
return instance;
|
|
585
|
+
}
|
|
586
|
+
const branchHead = await repository.findOne({
|
|
587
|
+
filter: {
|
|
588
|
+
upstreamId: targetUpstream.id,
|
|
589
|
+
branchIndex
|
|
590
|
+
},
|
|
591
|
+
fields,
|
|
592
|
+
transaction
|
|
593
|
+
});
|
|
594
|
+
if (branchHead) {
|
|
595
|
+
await branchHead.update(
|
|
596
|
+
{
|
|
597
|
+
upstreamId: instance.id,
|
|
598
|
+
branchIndex: null
|
|
599
|
+
},
|
|
600
|
+
{ transaction }
|
|
601
|
+
);
|
|
602
|
+
newDownstream = branchHead;
|
|
603
|
+
}
|
|
604
|
+
await instance.update(
|
|
605
|
+
{
|
|
606
|
+
upstreamId: targetUpstream.id,
|
|
607
|
+
branchIndex,
|
|
608
|
+
downstreamId: newDownstream ? newDownstream.id : null
|
|
609
|
+
},
|
|
610
|
+
{ transaction }
|
|
611
|
+
);
|
|
612
|
+
return instance;
|
|
613
|
+
});
|
|
614
|
+
await next();
|
|
615
|
+
}
|
|
339
616
|
async function update(context, next) {
|
|
340
617
|
const { db } = context;
|
|
341
618
|
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
@@ -385,6 +662,8 @@ async function test(context, next) {
|
|
|
385
662
|
create,
|
|
386
663
|
destroy,
|
|
387
664
|
destroyBranch,
|
|
665
|
+
duplicate,
|
|
666
|
+
move,
|
|
388
667
|
test,
|
|
389
668
|
update
|
|
390
669
|
});
|
|
@@ -81,7 +81,10 @@ class ConditionInstruction extends import__.Instruction {
|
|
|
81
81
|
if (branchJob.status === import_constants.JOB_STATUS.RESOLVED) {
|
|
82
82
|
return job;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
if (branchJob.status === import_constants.JOB_STATUS.PENDING) {
|
|
85
|
+
return processor.exit(branchJob.status);
|
|
86
|
+
}
|
|
87
|
+
return branchJob;
|
|
85
88
|
}
|
|
86
89
|
async test({ engine, calculation, expression = "" }) {
|
|
87
90
|
const evaluator = import_evaluators.evaluators.get(engine);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Instruction } from '.';
|
|
10
|
+
import Processor from '../Processor';
|
|
11
|
+
import { FlowNodeModel } from '../types';
|
|
12
|
+
export default class ExecutionResultInstruction extends Instruction {
|
|
13
|
+
run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
|
|
14
|
+
result: any;
|
|
15
|
+
status: -1;
|
|
16
|
+
} | {
|
|
17
|
+
result: any;
|
|
18
|
+
status: 1;
|
|
19
|
+
}>;
|
|
20
|
+
resume(node: FlowNodeModel, job: any, processor: Processor): Promise<any>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var OutputInstruction_exports = {};
|
|
28
|
+
__export(OutputInstruction_exports, {
|
|
29
|
+
default: () => ExecutionResultInstruction
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(OutputInstruction_exports);
|
|
32
|
+
var import__ = require(".");
|
|
33
|
+
var import_constants = require("../constants");
|
|
34
|
+
class ExecutionResultInstruction extends import__.Instruction {
|
|
35
|
+
async run(node, prevJob, processor) {
|
|
36
|
+
const { value } = node.config;
|
|
37
|
+
const output = processor.getParsedValue(value, node.id);
|
|
38
|
+
try {
|
|
39
|
+
await processor.execution.update({ output }, { hooks: false, transaction: processor.mainTransaction });
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return {
|
|
42
|
+
result: e.message,
|
|
43
|
+
status: import_constants.JOB_STATUS.FAILED
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
result: output,
|
|
48
|
+
status: import_constants.JOB_STATUS.RESOLVED
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async resume(node, job, processor) {
|
|
52
|
+
return job;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -97,7 +97,8 @@ class WorkflowRepository extends import_database.Repository {
|
|
|
97
97
|
{ transaction }
|
|
98
98
|
);
|
|
99
99
|
if (typeof instruction.duplicateConfig === "function") {
|
|
100
|
-
await instruction.duplicateConfig(newNode, { origin: node, transaction });
|
|
100
|
+
const newConfig = await instruction.duplicateConfig(newNode, { origin: node, transaction });
|
|
101
|
+
await newNode.update({ config: newConfig }, { transaction });
|
|
101
102
|
}
|
|
102
103
|
oldToNew.set(node.id, newNode);
|
|
103
104
|
newToOld.set(newNode.id, node);
|