@nocobase/plugin-workflow 2.0.0-beta.14 → 2.0.0-beta.16

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.
@@ -73,6 +73,10 @@ var jobs_default = {
73
73
  {
74
74
  type: "json",
75
75
  name: "result"
76
+ },
77
+ {
78
+ type: "json",
79
+ name: "meta"
76
80
  }
77
81
  ]
78
82
  };
@@ -11,8 +11,8 @@ module.exports = {
11
11
  "react": "18.2.0",
12
12
  "@formily/core": "2.3.7",
13
13
  "@formily/react": "2.3.7",
14
- "@nocobase/client": "2.0.0-beta.14",
15
- "@nocobase/utils": "2.0.0-beta.14",
14
+ "@nocobase/client": "2.0.0-beta.16",
15
+ "@nocobase/utils": "2.0.0-beta.16",
16
16
  "antd": "5.24.2",
17
17
  "@ant-design/icons": "5.6.1",
18
18
  "react-router-dom": "6.30.1",
@@ -20,18 +20,18 @@ module.exports = {
20
20
  "lodash": "4.17.21",
21
21
  "@dnd-kit/core": "6.1.0",
22
22
  "@formily/shared": "2.3.7",
23
- "@nocobase/flow-engine": "2.0.0-beta.14",
24
- "@nocobase/plugin-mobile": "2.0.0-beta.14",
23
+ "@nocobase/flow-engine": "2.0.0-beta.16",
24
+ "@nocobase/plugin-mobile": "2.0.0-beta.16",
25
25
  "sequelize": "6.35.2",
26
- "@nocobase/server": "2.0.0-beta.14",
27
- "@nocobase/database": "2.0.0-beta.14",
28
- "@nocobase/data-source-manager": "2.0.0-beta.14",
29
- "@nocobase/logger": "2.0.0-beta.14",
30
- "@nocobase/evaluators": "2.0.0-beta.14",
26
+ "@nocobase/server": "2.0.0-beta.16",
27
+ "@nocobase/database": "2.0.0-beta.16",
28
+ "@nocobase/data-source-manager": "2.0.0-beta.16",
29
+ "@nocobase/logger": "2.0.0-beta.16",
30
+ "@nocobase/evaluators": "2.0.0-beta.16",
31
31
  "@formily/antd-v5": "1.2.3",
32
32
  "@formily/reactive": "2.3.7",
33
- "@nocobase/actions": "2.0.0-beta.14",
33
+ "@nocobase/actions": "2.0.0-beta.16",
34
34
  "dayjs": "1.11.13",
35
- "@nocobase/plugin-workflow-test": "2.0.0-beta.14",
36
- "@nocobase/test": "2.0.0-beta.14"
35
+ "@nocobase/plugin-workflow-test": "2.0.0-beta.16",
36
+ "@nocobase/test": "2.0.0-beta.16"
37
37
  };
@@ -1 +1 @@
1
- {"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2026-01-23T00:08:53.450Z"}
1
+ {"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2026-01-27T13:17:14.598Z"}
@@ -1 +1 @@
1
- {"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2026-01-23T00:08:53.066Z"}
1
+ {"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2026-01-27T13:17:14.233Z"}
@@ -1 +1 @@
1
- {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2026-01-23T00:08:52.848Z"}
1
+ {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2026-01-27T13:17:14.025Z"}
@@ -390,7 +390,8 @@ class Dispatcher {
390
390
  logger.info(`execution (${execution.id}) ${job ? "resuming" : "starting"}...`);
391
391
  try {
392
392
  await (job ? processor.resume(job) : processor.start());
393
- logger.info(`execution (${execution.id}) finished with status: ${execution.status}`, { execution });
393
+ logger.info(`execution (${execution.id}) finished with status: ${execution.status}`);
394
+ logger.debug(`execution (${execution.id}) details:`, { execution });
394
395
  if (execution.status && ((_b = (_a = execution.workflow.options) == null ? void 0 : _a.deleteExecutionOnStatus) == null ? void 0 : _b.includes(execution.status))) {
395
396
  await execution.destroy({ transaction: processor.mainTransaction });
396
397
  }
@@ -338,6 +338,7 @@ class PluginWorkflowServer extends import_server.Plugin {
338
338
  "flow_nodes:update",
339
339
  "flow_nodes:destroy",
340
340
  "flow_nodes:destroyBranch",
341
+ "flow_nodes:move",
341
342
  "flow_nodes:test",
342
343
  "jobs:get",
343
344
  "workflowCategories:*"
@@ -63,6 +63,7 @@ function actions_default({ app }) {
63
63
  update: nodes.update,
64
64
  destroy: nodes.destroy,
65
65
  destroyBranch: nodes.destroyBranch,
66
+ move: nodes.move,
66
67
  test: nodes.test
67
68
  }),
68
69
  ...make("jobs", jobs),
@@ -10,5 +10,6 @@ import { Context } from '@nocobase/actions';
10
10
  export declare function create(context: Context, next: any): Promise<void>;
11
11
  export declare function destroy(context: Context, next: any): Promise<void>;
12
12
  export declare function destroyBranch(context: Context, next: any): Promise<void>;
13
+ export declare function move(context: Context, next: any): Promise<void>;
13
14
  export declare function update(context: Context, next: any): Promise<void>;
14
15
  export declare function test(context: Context, next: any): Promise<void>;
@@ -39,6 +39,7 @@ __export(nodes_exports, {
39
39
  create: () => create,
40
40
  destroy: () => destroy,
41
41
  destroyBranch: () => destroyBranch,
42
+ move: () => move,
42
43
  test: () => test,
43
44
  update: () => update
44
45
  });
@@ -49,10 +50,10 @@ var import__ = __toESM(require(".."));
49
50
  async function create(context, next) {
50
51
  const { db } = context;
51
52
  const repository = import_actions.utils.getRepositoryFromParams(context);
52
- const { whitelist, blacklist, updateAssociationValues, values, associatedIndex: workflowId } = context.action.params;
53
+ const { whitelist, blacklist, updateAssociationValues, values } = context.action.params;
53
54
  const workflowPlugin = context.app.pm.get(import__.default);
54
55
  context.body = await db.sequelize.transaction(async (transaction) => {
55
- const workflow = workflowPlugin.enabledCache.get(Number.parseInt(workflowId, 10)) || await repository.getSourceModel(transaction);
56
+ const workflow = workflowPlugin.enabledCache.get(Number.parseInt(context.action.sourceId, 10)) || await repository.getSourceModel(transaction);
56
57
  if (!workflow.versionStats) {
57
58
  workflow.versionStats = await workflow.getVersionStats({ transaction });
58
59
  }
@@ -336,6 +337,170 @@ async function destroyBranch(context, next) {
336
337
  context.body = deletedBranchHead;
337
338
  await next();
338
339
  }
340
+ async function move(context, next) {
341
+ const { db } = context;
342
+ const repository = import_actions.utils.getRepositoryFromParams(context);
343
+ const { filterByTk, values = {} } = context.action.params;
344
+ const rawUpstreamId = values.upstreamId;
345
+ const rawBranchIndex = values.branchIndex;
346
+ const upstreamId = rawUpstreamId == null || rawUpstreamId === "" ? null : rawUpstreamId;
347
+ let branchIndex = rawBranchIndex == null || rawBranchIndex === "" ? null : Number.parseInt(rawBranchIndex, 10);
348
+ if (rawBranchIndex != null && rawBranchIndex !== "" && Number.isNaN(branchIndex)) {
349
+ context.throw(400, "branchIndex must be a number");
350
+ }
351
+ if (upstreamId == null) {
352
+ branchIndex = null;
353
+ }
354
+ const fields = ["id", "upstreamId", "downstreamId", "branchIndex", "workflowId"];
355
+ context.body = await db.sequelize.transaction(async (transaction) => {
356
+ const instance = await repository.findOne({
357
+ filterByTk,
358
+ fields,
359
+ appends: ["upstream", "downstream", "workflow.versionStats"],
360
+ transaction
361
+ });
362
+ if (!instance) {
363
+ context.throw(404, "Node not found");
364
+ }
365
+ if (instance.workflow.versionStats.executed > 0) {
366
+ context.throw(400, "Nodes in executed workflow could not be moved");
367
+ }
368
+ if (upstreamId != null && String(upstreamId) === String(instance.id)) {
369
+ context.throw(400, "Invalid upstream node");
370
+ }
371
+ const sameUpstream = (instance.upstreamId ?? null) == (upstreamId ?? null);
372
+ const sameBranchIndex = (instance.branchIndex ?? null) == (branchIndex ?? null);
373
+ if (sameUpstream && sameBranchIndex) {
374
+ context.throw(400, "Node does not need to be moved");
375
+ }
376
+ const { upstream: oldUpstream, downstream: oldDownstream } = instance.get();
377
+ if (oldUpstream && oldUpstream.downstreamId === instance.id) {
378
+ await oldUpstream.update(
379
+ {
380
+ downstreamId: oldDownstream ? oldDownstream.id : null
381
+ },
382
+ { transaction }
383
+ );
384
+ }
385
+ if (oldDownstream && oldDownstream.upstreamId === instance.id) {
386
+ await oldDownstream.update(
387
+ {
388
+ upstreamId: oldUpstream ? oldUpstream.id : null,
389
+ branchIndex: instance.branchIndex ?? null
390
+ },
391
+ { transaction }
392
+ );
393
+ }
394
+ let targetUpstream = null;
395
+ if (upstreamId != null) {
396
+ targetUpstream = await repository.findOne({
397
+ filterByTk: upstreamId,
398
+ fields,
399
+ transaction
400
+ });
401
+ if (!targetUpstream) {
402
+ context.throw(404, "Upstream node not found");
403
+ }
404
+ if (targetUpstream.workflowId !== instance.workflowId) {
405
+ context.throw(400, "Upstream node is not in the same workflow");
406
+ }
407
+ }
408
+ let newDownstream = null;
409
+ if (!targetUpstream) {
410
+ const previousHead = await repository.findOne({
411
+ filter: {
412
+ workflowId: instance.workflowId,
413
+ upstreamId: null,
414
+ id: {
415
+ [import_database.Op.ne]: instance.id
416
+ }
417
+ },
418
+ fields,
419
+ transaction
420
+ });
421
+ if (previousHead) {
422
+ await previousHead.update(
423
+ {
424
+ upstreamId: instance.id,
425
+ branchIndex: null
426
+ },
427
+ { transaction }
428
+ );
429
+ newDownstream = previousHead;
430
+ }
431
+ await instance.update(
432
+ {
433
+ upstreamId: null,
434
+ branchIndex: null,
435
+ downstreamId: newDownstream ? newDownstream.id : null
436
+ },
437
+ { transaction }
438
+ );
439
+ return instance;
440
+ }
441
+ if (branchIndex == null) {
442
+ if (targetUpstream.downstreamId) {
443
+ newDownstream = await repository.findOne({
444
+ filterByTk: targetUpstream.downstreamId,
445
+ fields,
446
+ transaction
447
+ });
448
+ }
449
+ if (newDownstream) {
450
+ await newDownstream.update(
451
+ {
452
+ upstreamId: instance.id,
453
+ branchIndex: null
454
+ },
455
+ { transaction }
456
+ );
457
+ }
458
+ await targetUpstream.update(
459
+ {
460
+ downstreamId: instance.id
461
+ },
462
+ { transaction }
463
+ );
464
+ await instance.update(
465
+ {
466
+ upstreamId: targetUpstream.id,
467
+ branchIndex: null,
468
+ downstreamId: newDownstream ? newDownstream.id : null
469
+ },
470
+ { transaction }
471
+ );
472
+ return instance;
473
+ }
474
+ const branchHead = await repository.findOne({
475
+ filter: {
476
+ upstreamId: targetUpstream.id,
477
+ branchIndex
478
+ },
479
+ fields,
480
+ transaction
481
+ });
482
+ if (branchHead) {
483
+ await branchHead.update(
484
+ {
485
+ upstreamId: instance.id,
486
+ branchIndex: null
487
+ },
488
+ { transaction }
489
+ );
490
+ newDownstream = branchHead;
491
+ }
492
+ await instance.update(
493
+ {
494
+ upstreamId: targetUpstream.id,
495
+ branchIndex,
496
+ downstreamId: newDownstream ? newDownstream.id : null
497
+ },
498
+ { transaction }
499
+ );
500
+ return instance;
501
+ });
502
+ await next();
503
+ }
339
504
  async function update(context, next) {
340
505
  const { db } = context;
341
506
  const repository = import_actions.utils.getRepositoryFromParams(context);
@@ -385,6 +550,7 @@ async function test(context, next) {
385
550
  create,
386
551
  destroy,
387
552
  destroyBranch,
553
+ move,
388
554
  test,
389
555
  update
390
556
  });
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.14",
9
+ "version": "2.0.0-beta.16",
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": "e51bd3f094b93bd8bbb8fa3c6ff0f07fcca2e16d",
51
+ "gitHead": "d76e49352101a74331ffa3005cc5f024d7fca663",
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([["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}}))}}}]);