@nocobase/plugin-workflow 2.0.0-beta.2 → 2.0.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/dist/client/0b6813dae26ccf21.js +10 -0
- package/dist/client/{80d4cd8911e03c27.js → 2076012783c998ad.js} +1 -1
- package/dist/client/59fcf22e646963ed.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/index.d.ts +3 -0
- package/dist/client/index.js +1 -1
- 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 +7 -0
- package/dist/client/nodes/index.d.ts +14 -0
- package/dist/client/nodes/output.d.ts +53 -0
- package/dist/client/nodes/query.d.ts +7 -0
- package/dist/client/style.d.ts +4 -0
- package/dist/common/collections/jobs.js +4 -0
- 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 +25 -4
- 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.js +2 -1
- 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/package.json +2 -2
- 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);
|
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.0.0-beta.
|
|
9
|
+
"version": "2.0.0-beta.21",
|
|
10
10
|
"license": "AGPL-3.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/workflow",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@nocobase/test": "2.x",
|
|
49
49
|
"@nocobase/utils": "2.x"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "3ea30685d9592934ec578c0b5e8def60a7fcc3c2",
|
|
52
52
|
"keywords": [
|
|
53
53
|
"Workflow"
|
|
54
54
|
]
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_workflow=self.webpackChunk_nocobase_plugin_workflow||[]).push([["771"],{144:function(e,t,n){n.d(t,{g:function(){return w}});var r=n(2721),o=n(8156),a=n.n(o);let l=(0,o.createContext)(null),i={didCatch:!1,error:null};class c extends o.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=i}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,n,r=arguments.length,o=Array(r),a=0;a<r;a++)o[a]=arguments[a];null==(t=(n=this.props).onReset)||t.call(n,{args:o,reason:"imperative-api"}),this.setState(i)}}componentDidCatch(e,t){var n,r;null==(n=(r=this.props).onError)||n.call(r,e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}(e.resetKeys,r)){var o,a;null==(o=(a=this.props).onReset)||o.call(a,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(i)}}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:i}=this.state,c=e;if(a){let e={error:i,resetErrorBoundary:this.resetErrorBoundary};if((0,o.isValidElement)(r))c=r;else if("function"==typeof t)c=t(e);else if(n)c=(0,o.createElement)(n,e);else throw i}return(0,o.createElement)(l.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},c)}}var s=n(3772),u=n(2415),d=n(8551),m=n(5329),f=n(4477),p=n(8562);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function b(){var e=v(["\n margin-top: 0 !important;\n "]);return b=function(){return e},e}function h(){var e=v(["\n margin-bottom: 1em;\n "]);return h=function(){return e},e}function E(){var e=v(["\n margin-top: 0 !important;\n "]);return E=function(){return e},e}function w(e){var t,n=e.entry,o=(0,m.Z)().styles,l=(0,p.RY)(),i=(t=a().useState(100),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return y(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),v=i[0],w=i[1];return a().createElement("div",{className:"workflow-canvas-wrapper"},a().createElement(c,{FallbackComponent:s.ErrorFallback,onError:console.error},a().createElement("div",{className:"workflow-canvas",style:{zoom:v/100}},a().createElement("div",{className:(0,s.cx)(o.branchBlockClass,(0,s.css)(b()))},a().createElement("div",{className:o.branchClass},l?a().createElement(r.Alert,{type:"warning",message:(0,d.KQ)("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:(0,s.css)(h())}):null,a().createElement(f.Gk,null),a().createElement("div",{className:(0,s.cx)(o.branchBlockClass,(0,s.css)(E()))},a().createElement(u.I0,{entry:n})),a().createElement("div",{className:o.terminalClass},(0,d.KQ)("End")))))),a().createElement("div",{className:"workflow-canvas-zoomer"},a().createElement(r.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:v,onChange:w})))}},2378:function(e,t,n){n.r(t),n.d(t,{ExecutionPage:function(){return N}});var r=n(3772),o=n(8156),a=n.n(o),l=n(6128),i=n(2721),c=n(7584),s=n(482),u=n(3238),d=n(4199),m=n(144),f=n(118),p=n(1682),y=n(8398),v=n(8551),b=n(5329),h=n(9315),E=n(467);function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,t)||O(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e){return function(e){if(Array.isArray(e))return w(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||O(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){if(e){if("string"==typeof e)return w(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return w(e,t)}}function C(e){var t,n,o=(0,y.G2)().viewJob,l=(0,r.useRequest)({resource:"jobs",action:"get",params:{filterByTk:o.id}}),c=l.data;if(l.loading)return a().createElement(i.Spin,null);var s=(0,E.get)(c,"data.result");return a().createElement(r.Input.JSON,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){g(e,t,n[t])})}return e}({},e),n=n={value:s,disabled:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}function j(){var e=(0,r.usePlugin)(d.default).instructions,t=(0,r.useCompile)(),n=(0,y.G2)(),o=n.viewJob,l=n.setViewJob,c=(0,b.Z)().styles,s=(null!=o?o:{}).node,u=void 0===s?{}:s,m=e.get(u.type);return a().createElement(r.ActionContextProvider,{value:{visible:!!o,setVisible:l}},a().createElement(r.SchemaComponent,{components:{JobResult:C},schema:{type:"void",properties:g({},"".concat(null==o?void 0:o.id,"-").concat(null==o?void 0:o.updatedAt,"-modal"),{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:a().createElement("div",{className:c.nodeTitleClass},a().createElement(i.Tag,null,t(null==m?void 0:m.title)),a().createElement("strong",null,u.title),a().createElement("span",{className:"workflow-node-id"},"#",u.id)),properties:{status:{type:"number",title:'{{t("Status", { ns: "'.concat(v.A7,'" })}}'),"x-decorator":"FormItem","x-component":"Select",enum:p.Vh,"x-read-pretty":!0},updatedAt:{type:"string",title:'{{t("Executed at", { ns: "'.concat(v.A7,'" })}}'),"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:'{{t("Node result", { ns: "'.concat(v.A7,'" })}}'),"x-decorator":"FormItem","x-component":"JobResult","x-component-props":{className:c.nodeJobResultClass,autoSize:{minRows:4,maxRows:32}}}}})}}))}function A(e){var t=(0,y.G2)().execution,n=(0,r.useAPIClient)(),u=(0,l.useNavigate)(),d=(0,b.Z)().styles,m=(0,r.useResourceActionContext)().refresh,v=x((0,o.useState)([]),2),E=v[0],w=v[1],g=x((0,o.useState)([]),2),k=g[0],O=g[1],C=x((0,o.useState)(null),2),j=C[0],A=C[1],P=x((0,o.useState)(null),2),N=P[0],I=P[1],D=x((0,o.useState)(null),2),R=D[0],T=D[1],B=(0,o.useCallback)(function(e){t&&e&&(j!==t.id&&n.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-id",pageSize:10,fields:["id","status","createdAt"]}).then(function(e){var n=e.data;A(t.id),w(n.data)}).catch(function(){}),(N!==t.id||R&&Date.now()-Number(R)>6e4&&k.length<10)&&n.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"id",pageSize:10,fields:["id","status","createdAt"]}).then(function(e){var n=e.data;I(t.id),T(Date.now()),O(n.data.reverse())}).catch(function(){}))},[t,j,N,R,k.length,n]),K=(0,o.useCallback)(function(e){var n=e.key;n!=t.id&&u((0,h.s_)(n))},[t.id,u]);return t?a().createElement(i.Space,null,a().createElement(i.Dropdown,{onOpenChange:B,menu:{onClick:K,defaultSelectedKeys:["".concat(t.id)],className:(0,r.cx)(d.dropdownClass,d.executionsDropdownRowClass),items:S(k).concat([t],S(E)).map(function(e){return{key:e.id,label:a().createElement(a().Fragment,null,a().createElement("span",{className:"id"},"#".concat(e.id)),a().createElement("time",null,(0,c.str2moment)(e.createdAt).format("YYYY-MM-DD HH:mm:ss"))),icon:a().createElement("span",null,a().createElement(f.Y,{statusMap:p.uy,status:e.status}))}})}},a().createElement(i.Space,null,a().createElement("strong",null,"#".concat(t.id)),a().createElement(s.DownOutlined,null))),a().createElement(i.Button,{type:"link",size:"small",icon:a().createElement(s.ReloadOutlined,null),onClick:m})):null}function P(){var e,t=(0,u.useTranslation)().t,n=(0,r.useCompile)(),d=(0,r.useResourceActionContext)(),f=d.data,b=d.loading,E=d.refresh,w=(0,r.useDocumentTitle)().setTitle,g=x((0,o.useState)(null),2),S=g[0],O=g[1],C=(0,r.useApp)(),P=(0,r.useAPIClient)();(0,o.useEffect)(function(){var e,t=(null!=(e=null==f?void 0:f.data)?e:{}).workflow;null==w||w("".concat((null==t?void 0:t.title)?"".concat(t.title," - "):"").concat((0,v.KQ)("Execution history")))},[null==f?void 0:f.data,w]);var N=(0,o.useCallback)(function(){i.Modal.confirm({title:(0,v.KQ)("Cancel the execution"),icon:a().createElement(s.ExclamationCircleFilled,null),content:(0,v.KQ)("Are you sure you want to cancel the execution?"),onOk:function(){P.resource("executions").cancel({filterByTk:null==f?void 0:f.data.id}).then(function(){i.message.success(t("Operation succeeded")),E()}).catch(function(e){console.error(e.data.error)})}})},[null==f?void 0:f.data]);if(!(null==f?void 0:f.data))return b?a().createElement(i.Spin,null):a().createElement(i.Result,{status:"404",title:"Not found"});var I=null!=(e=null==f?void 0:f.data)?e:{},D=I.jobs,R=I.workflow,T=void 0===R?{}:R,B=T.nodes,K=void 0===B?[]:B,M=(T.revisions,k(I.workflow,["nodes","revisions"])),Y=k(I,["jobs","workflow"]);(0,h.Yc)(K),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=new Map;e.forEach(function(e){e.jobs=[],n.set(e.id,e)}),t.forEach(function(e){var t=n.get(e.nodeId);t&&(t.jobs.push(e),e.node={id:t.id,key:t.key,title:t.title,type:t.type})}),e.forEach(function(e){e.jobs=e.jobs.sort(function(e,t){return e.id-t.id})})}(K,void 0===D?[]:D);var z=K.find(function(e){return!e.upstream}),F=p.uy[Y.status];return a().createElement(y.iT.Provider,{value:{workflow:M.type?M:null,nodes:K,execution:Y,viewJob:S,setViewJob:O}},a().createElement("div",{className:"workflow-toolbar"},a().createElement("header",null,a().createElement(i.Breadcrumb,{items:[{title:a().createElement(l.Link,{to:C.pluginSettingsManager.getRoutePath("workflow")},(0,v.KQ)("Workflow"))},{title:a().createElement(i.Tooltip,{title:"Key: ".concat(M.key)},a().createElement(l.Link,{to:(0,h.SI)(M.id)},M.title))},{title:a().createElement(A,null)}]})),a().createElement("aside",null,a().createElement(i.Tag,{color:F.color},n(F.label)),Y.status?null:a().createElement(i.Tooltip,{title:(0,v.KQ)("Cancel the execution")},a().createElement(i.Button,{type:"link",danger:!0,onClick:N,shape:"circle",size:"small",icon:a().createElement(s.StopOutlined,null)})),a().createElement("time",null,(0,c.str2moment)(Y.updatedAt).format("YYYY-MM-DD HH:mm:ss")))),a().createElement(m.g,{entry:z}),a().createElement(j,null))}var N=function(){var e,t,n,o=(0,l.useParams)(),i=(0,b.Z)().styles;return a().createElement("div",{className:(0,r.cx)(i.workflowPageClass)},a().createElement(r.SchemaComponent,{schema:{type:"void",properties:(e={},t="execution_".concat(o.id),n={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:o,appends:["jobs","workflow","workflow.nodes","workflow.versionStats","workflow.stats"],except:["jobs.result","workflow.options"]}}},"x-component":"ExecutionCanvas"},t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e)},components:{ExecutionCanvas:P}}))}}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_workflow=self.webpackChunk_nocobase_plugin_workflow||[]).push([["626"],{144:function(e,t,r){r.d(t,{g:function(){return g}});var n=r(2721),o=r(8156),a=r.n(o);let l=(0,o.createContext)(null),i={didCatch:!1,error:null};class c extends o.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=i}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,r,n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];null==(t=(r=this.props).onReset)||t.call(r,{args:o,reason:"imperative-api"}),this.setState(i)}}componentDidCatch(e,t){var r,n;null==(r=(n=this.props).onError)||r.call(n,e,t)}componentDidUpdate(e,t){let{didCatch:r}=this.state,{resetKeys:n}=this.props;if(r&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,n)){var o,a;null==(o=(a=this.props).onReset)||o.call(a,{next:n,prev:e.resetKeys,reason:"keys"}),this.setState(i)}}render(){let{children:e,fallbackRender:t,FallbackComponent:r,fallback:n}=this.props,{didCatch:a,error:i}=this.state,c=e;if(a){let e={error:i,resetErrorBoundary:this.resetErrorBoundary};if((0,o.isValidElement)(n))c=n;else if("function"==typeof t)c=t(e);else if(r)c=(0,o.createElement)(r,e);else throw i}return(0,o.createElement)(l.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},c)}}var s=r(3772),u=r(2415),d=r(8551),f=r(5329),p=r(4477),m=r(8562);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function b(){var e=v(["\n margin-top: 0 !important;\n "]);return b=function(){return e},e}function h(){var e=v(["\n margin-bottom: 1em;\n "]);return h=function(){return e},e}function w(){var e=v(["\n margin-top: 0 !important;\n "]);return w=function(){return e},e}function g(e){var t,r=e.entry,o=(0,f.Z)().styles,l=(0,m.RY)(),i=(t=a().useState(100),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw n}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return y(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),v=i[0],g=i[1];return a().createElement("div",{className:"workflow-canvas-wrapper"},a().createElement(c,{FallbackComponent:s.ErrorFallback,onError:console.error},a().createElement("div",{className:"workflow-canvas",style:{zoom:v/100}},a().createElement("div",{className:(0,s.cx)(o.branchBlockClass,(0,s.css)(b()))},a().createElement("div",{className:o.branchClass},l?a().createElement(n.Alert,{type:"warning",message:(0,d.KQ)("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:(0,s.css)(h())}):null,a().createElement(p.Gk,null),a().createElement("div",{className:(0,s.cx)(o.branchBlockClass,(0,s.css)(w()))},a().createElement(u.I0,{entry:r})),a().createElement("div",{className:o.terminalClass},(0,d.KQ)("End")))))),a().createElement("div",{className:"workflow-canvas-zoomer"},a().createElement(n.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:v,onChange:g})))}},6443:function(e,t,r){r.r(t),r.d(t,{WorkflowPage:function(){return q}});var n=r(3772),o=r(8156),a=r.n(o),l=r(6128),i=r(5329),c=r(3238),s=r(2721),u=r(482),d=r(3505),f=r(7584),p=r(144),m=r(4665),y=r(1113),v=r(8398),b=r(8551),h=r(1685),w=r(9315),g=r(8303),k=r(1600),E=r(4477),x=r(1682),C=r(7032),A=r(8562),O=r(2495),S=r(2743);function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function j(e,t,r,n,o,a,l){try{var i=e[a](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,o)}function T(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(e){j(a,n,o,l,i,"next",e)}function i(e){j(a,n,o,l,i,"throw",e)}l(void 0)})}}function R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function N(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function K(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return P(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return P(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t){var r,n,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var c=[a,i];if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function I(){var e,t,r=(e=["\n margin-bottom: 1em;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return I=function(){return r},r}function Q(e){var t,r=e.request,o=(e.filter,K(e,["request","filter"])),l=(0,v.G2)().workflow,i=N(R({},o),{request:N(R({},r),{params:N(R({},null==r?void 0:r.params),{filter:N(R({},null==r||null==(t=r.params)?void 0:t.filter),{key:l.key})})})});return a().createElement(n.ResourceActionProvider,i)}function D(e){var t=e.data,r=e.option,o=(0,n.useCompile)()(r.label);return a().createElement(c.Trans,{ns:b.A7,values:{statusText:o}},"Workflow executed, the result status is ",a().createElement(s.Tag,{color:r.color},"{{statusText}}"),a().createElement(l.Link,{to:"/admin/workflow/executions/".concat(t.id)},"View the execution"))}function V(){var e=(0,v.G2)().workflow,t=(0,d.useForm)(),r=(0,n.useResourceContext)().resource,o=(0,n.useActionContext)(),l=(0,n.useNavigateNoUpdate)(),i=s.App.useApp().message,c=(0,A.RY)();return{run:function(){return T(function(){var n,s,u,d;return F(this,function(f){switch(f.label){case 0:return s=(n=t.values).autoRevision,u=K(n,["autoRevision"]),[4,t.submit()];case 1:return f.sent(),[4,r.execute(R({filterByTk:e.id,values:u},!c&&s?{autoRevision:1}:{}))];case 2:var p,m,y,v;return d=f.sent().data.data,t.reset(),o.setFormValueChanged(!1),o.setVisible(!1),null==i||i.open((m=(p=d.execution).id,y=p.status,(v=x.uy[y])?{type:"info",content:a().createElement(D,{data:{id:m},option:v})}:null)),d.newVersionId&&l("/admin/workflow/workflows/".concat(d.newVersionId)),[2]}})})()}}}function z(e){var t=e.children,r=(0,d.useField)(),n=(0,v.G2)().workflow,o=(0,E.cC)(),l=o.validate(n.config),i="";switch(!0){case!l:i=(0,b.KQ)("The trigger is not configured correctly, please check the trigger configuration.");break;case!o.triggerFieldset:i=(0,b.KQ)("This type of trigger has not been supported to be executed manually.")}return r.setPattern(i?"disabled":"editable"),i?a().createElement(s.Tooltip,{title:i},t):t}function G(){var e,t=(0,v.G2)().workflow,r=(0,A.RY)(),o=(0,E.cC)();return a().createElement(v.zQ.Provider,{value:t},a().createElement(C.XA.Provider,{value:!0},a().createElement(n.SchemaComponent,{components:R({Alert:s.Alert,Fieldset:g.p,ActionDisabledProvider:z},o.components),scope:R({useCancelAction:n.useCancelAction,useExecuteConfirmAction:V},o.scope),schema:{name:"trigger-modal-".concat(t.type,"-").concat(t.id),type:"void","x-decorator":"ActionDisabledProvider","x-component":"Action","x-component-props":{openSize:"small"},title:"{{t('Execute manually', { ns: \"".concat(b.A7,'" })}}'),properties:{drawer:{type:"void","x-decorator":"FormV2","x-component":"Action.Modal",title:"{{t('Execute manually', { ns: \"".concat(b.A7,'" })}}'),properties:N(R(N(R({},Object.keys(null!=(e=o.triggerFieldset)?e:{}).length?{alert:{type:"void","x-component":"Alert","x-component-props":{message:"{{t('Trigger variables need to be filled for executing.', { ns: \"".concat(b.A7,'" })}}'),className:(0,n.css)(I())}}}:{description:{type:"void","x-component":"p","x-content":"{{t('This will perform all the actions configured in the workflow. Are you sure you want to continue?', { ns: \"".concat(b.A7,'" })}}')}}),{fieldset:{type:"void","x-decorator":"FormItem","x-component":"Fieldset",title:"{{t('Trigger variables', { ns: \"".concat(b.A7,'" })}}'),properties:o.triggerFieldset}}),r?{}:{autoRevision:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":"{{t('Automatically create a new version after execution', { ns: \"".concat(b.A7,'" })}}'),default:!0}}),{footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{type:"void",title:"{{t('Cancel')}}","x-component":"Action","x-component-props":{useAction:"{{useCancelAction}}"}},submit:{type:"void",title:"{{t('Confirm')}}","x-component":"Action","x-component-props":{type:"primary",useAction:"{{useExecuteConfirmAction}}"}}}}})}}}})))}function M(){var e=(0,v.G2)(),t=e.workflow,r=e.revisions,i=void 0===r?[]:r,d=B((0,o.useState)(!1),2),f=d[0],p=d[1],g=(0,l.useNavigate)(),E=(0,c.useTranslation)().t,C=s.App.useApp().modal,O=(0,n.useApp)(),S=(0,n.useResourceContext)().resource,P=(0,n.useResourceActionContext)().refresh,j=s.App.useApp().message,R=(0,A.U3)(),N=(0,o.useCallback)(T(function(){var e;return F(this,function(r){switch(r.label){case 0:return[4,S.revision({filterByTk:t.id,filter:{key:t.key}})];case 1:return e=r.sent().data.data,j.success(E("Operation succeeded")),g("/admin/workflow/workflows/".concat(e.id)),[2]}})}),[S,t.id,t.key,j,E,g]),K=(0,o.useCallback)(T(function(){var e;return F(this,function(r){return e=t.current?(0,b.KQ)("This is a main version, delete it will cause the whole workflow to be deleted (including all other revisions)."):(0,b.KQ)("Current version will be deleted (without affecting other versions)."),C.confirm({title:E("Are you sure you want to delete it?"),content:e,onOk:function(){return T(function(){var e,r,n,o;return F(this,function(a){switch(a.label){case 0:return[4,S.destroy({filterByTk:t.id})];case 1:if(a.sent(),j.success(E("Operation succeeded")),e=O.pluginSettingsManager.getRoutePath("workflow"),t.current)return[2,g(e)];return i.length&&g((0,w.SI)(null==(r=i.find(function(e){return e.current}))?void 0:r.id)),[4,S.list({filter:{key:t.key,current:!0},fields:["id"],pageSize:1})];case 2:if(200!==(n=a.sent()).status)return[2];if(!(o=B(n.data.data,1)[0]))return[2,g(e)];return[2,g((0,w.SI)(o.id))]}})})()}}),[2]})}),[t,C,E,S,j,g,O.pluginSettingsManager,i]),I=(0,o.useCallback)(function(e){switch(e.key){case"refresh":P();return;case"history":p(!0);return;case"revision":return N();case"delete":return K()}},[K,N,P]);return a().createElement(a().Fragment,null,a().createElement(s.Dropdown,{menu:{items:[{key:"key",label:"Key: ".concat(t.key),disabled:!0},{type:"divider"},{role:"button","aria-label":"refresh",key:"refresh",label:E("Refresh")},{role:"button","aria-label":"history",key:"history",label:(0,b.KQ)("Execution history"),disabled:!R},{role:"button","aria-label":"revision",key:"revision",label:(0,b.KQ)("Copy to new version")},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:E("Delete")}],onClick:I}},a().createElement(s.Button,{"aria-label":"more",type:"text",icon:a().createElement(u.EllipsisOutlined,null)})),a().createElement(n.ActionContextProvider,{value:{visible:f,setVisible:p}},a().createElement(n.SchemaComponent,{schema:h.V,components:{ExecutionResourceProvider:Q,ExecutionLink:y.a,ExecutionStatusColumn:m.rV},scope:{useRefreshActionProps:k.X,ExecutionStatusOptions:x.C6}})))}function _(){var e,t=(0,i.Z)().styles,r=(0,l.useNavigate)(),c=(0,v.G2)().workflow,d=(0,o.useCallback)(function(e){var t=e.key;t!=c.id&&r((0,w.SI)(t))},[c.id,r]),p=(0,n.useRequest)({resource:"workflows",action:"list",params:{filter:{key:c.key},fields:["id","createdAt","current","enabled","versionStats.executed"],sort:"-id"}},{refreshDeps:[c.id],manual:!0}),m=p.data,y=p.run,h=(0,o.useCallback)(function(e){e&&y()},[y]),g=null!=(e=null==m?void 0:m.data)?e:[];return a().createElement(s.Dropdown,{className:"workflow-versions",trigger:["click"],onOpenChange:h,menu:{onClick:d,defaultSelectedKeys:["".concat(c.id)],className:(0,n.cx)(t.dropdownClass,t.workflowVersionDropdownClass),items:g.sort(function(e,t){return t.id-e.id}).map(function(e,t){return{role:"button","aria-label":"version-".concat(t),key:"".concat(e.id),icon:e.current?a().createElement(u.RightOutlined,null):null,className:(0,n.cx)({executed:e.versionStats.executed>0,unexecuted:0==e.versionStats.executed,enabled:e.enabled}),label:a().createElement(a().Fragment,null,a().createElement("strong",null,"#".concat(e.id)),a().createElement("time",null,(0,f.dayjs)(e.createdAt).fromNow()))}})}},a().createElement(s.Button,{type:"text","aria-label":"version"},a().createElement("label",null,(0,b.KQ)("Version")),a().createElement("span",null,(null==c?void 0:c.id)?"#".concat(c.id):null),a().createElement(u.DownOutlined,null)))}function W(){var e,t,r,i,c=(0,l.useNavigate)(),u=(0,n.useApp)(),d=(0,n.useResourceActionContext)(),f=d.data,m=d.refresh,y=d.loading,h=(0,n.useResourceContext)().resource,g=(0,n.useDocumentTitle)().setTitle,k=B((0,o.useState)(null!=(r=null==f||null==(t=f.data)?void 0:t.enabled)&&r),2),E=k[0],x=k[1],C=B((0,o.useState)(!1),2),A=C[0],P=C[1],j=null!=(i=null==f?void 0:f.data)?i:{},R=j.nodes,N=void 0===R?[]:R,I=K(j,["nodes"]);(0,w.Yc)(N),(0,o.useEffect)(function(){var e,t=null!=(e=null==f?void 0:f.data)?e:{},r=t.title,n=t.enabled;null==g||g("".concat((0,b.KQ)("Workflow")).concat(r?": ".concat(r):"")),x(n)},[null==f?void 0:f.data,g]);var Q=(0,o.useCallback)((e=T(function(e){return F(this,function(t){switch(t.label){case 0:return P(!0),[4,h.update({filterByTk:I.id,values:{enabled:e}})];case 1:return t.sent(),P(!1),x(e),[2]}})}),function(t){return e.apply(this,arguments)}),[h,I.id]);if(!(null==f?void 0:f.data))return y?a().createElement(s.Spin,null):a().createElement(s.Result,{status:"404",title:"Not found",extra:a().createElement(s.Button,{onClick:function(){return c(-1)}},(0,b.KQ)("Go back"))});var D=N.find(function(e){return!e.upstream});return a().createElement(v.iT.Provider,{value:{workflow:I,nodes:N,refresh:m}},a().createElement("div",{className:"workflow-toolbar"},a().createElement("header",null,a().createElement(s.Breadcrumb,{items:[{title:a().createElement(l.Link,{to:u.pluginSettingsManager.getRoutePath("workflow")},(0,b.KQ)("Workflow"))},{title:a().createElement(s.Tooltip,{title:"Key: ".concat(I.key)},a().createElement("strong",null,I.title))}]}),I.sync?a().createElement(s.Tag,{color:"orange"},(0,b.KQ)("Synchronously")):a().createElement(s.Tag,{color:"cyan"},(0,b.KQ)("Asynchronously"))),a().createElement("aside",null,a().createElement(G,null),a().createElement(_,null),a().createElement(s.Switch,{checked:E,onChange:Q,checkedChildren:(0,b.KQ)("On"),unCheckedChildren:(0,b.KQ)("Off"),loading:A}),a().createElement(M,null))),a().createElement(O.E1,null,a().createElement(S.I,null,a().createElement(p.g,{entry:D}))))}var q=function(){var e,t,r,o=(0,l.useParams)(),c=(0,i.Z)().styles;return a().createElement("div",{className:(0,n.cx)(c.workflowPageClass)},a().createElement(n.SchemaComponent,{schema:{type:"void",properties:(e={},t="provider_".concat(o.id),r={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:o.id},appends:["nodes","stats.executed","versionStats.executed"]}}},"x-component":"WorkflowCanvas"},t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e)},components:{WorkflowCanvas:W}}))}}}]);
|