@nocobase/plugin-workflow 2.0.0-beta.2 → 2.0.0-beta.20

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.
Files changed (47) hide show
  1. package/dist/client/{80d4cd8911e03c27.js → 2076012783c998ad.js} +1 -1
  2. package/dist/client/cc4188baa297ff50.js +10 -0
  3. package/dist/client/e37f5077c1cb2207.js +10 -0
  4. package/dist/client/index.d.ts +3 -0
  5. package/dist/client/index.js +1 -1
  6. package/dist/client/models/NodeDetailsModel.d.ts +34 -0
  7. package/dist/client/models/NodeValueModel.d.ts +15 -0
  8. package/dist/client/models/TaskCardCommonItemModel.d.ts +14 -0
  9. package/dist/client/models/index.d.ts +11 -0
  10. package/dist/client/nodes/calculation.d.ts +7 -0
  11. package/dist/client/nodes/create.d.ts +7 -0
  12. package/dist/client/nodes/index.d.ts +14 -0
  13. package/dist/client/nodes/output.d.ts +53 -0
  14. package/dist/client/nodes/query.d.ts +7 -0
  15. package/dist/common/collections/jobs.js +4 -0
  16. package/dist/externalVersion.js +12 -12
  17. package/dist/locale/de-DE.json +3 -4
  18. package/dist/locale/en-US.json +7 -4
  19. package/dist/locale/es-ES.json +3 -4
  20. package/dist/locale/fr-FR.json +3 -4
  21. package/dist/locale/it-IT.json +3 -4
  22. package/dist/locale/ja-JP.json +3 -6
  23. package/dist/locale/ko-KR.json +3 -4
  24. package/dist/locale/nl-NL.json +3 -4
  25. package/dist/locale/pt-BR.json +3 -4
  26. package/dist/locale/ru-RU.json +3 -4
  27. package/dist/locale/tr-TR.json +3 -4
  28. package/dist/locale/uk-UA.json +3 -4
  29. package/dist/locale/zh-CN.json +10 -5
  30. package/dist/locale/zh-TW.json +2 -3
  31. package/dist/node_modules/cron-parser/package.json +1 -1
  32. package/dist/node_modules/lru-cache/package.json +1 -1
  33. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  34. package/dist/server/Dispatcher.js +2 -1
  35. package/dist/server/Plugin.js +5 -1
  36. package/dist/server/Processor.d.ts +9 -0
  37. package/dist/server/Processor.js +6 -1
  38. package/dist/server/actions/index.js +1 -0
  39. package/dist/server/actions/nodes.d.ts +1 -0
  40. package/dist/server/actions/nodes.js +168 -2
  41. package/dist/server/instructions/ConditionInstruction.js +4 -1
  42. package/dist/server/instructions/OutputInstruction.d.ts +21 -0
  43. package/dist/server/instructions/OutputInstruction.js +54 -0
  44. package/dist/server/repositories/WorkflowRepository.js +2 -1
  45. package/package.json +2 -2
  46. package/dist/client/bfc2a351589613e1.js +0 -10
  47. package/dist/client/e078314a62391f36.js +0 -10
@@ -53,10 +53,11 @@
53
53
  "Choose a record or primary key of a record in the collection to trigger.": "选择数据表中的一行记录或者记录的主键来触发。",
54
54
  "Clear all executions": "清除所有执行记录",
55
55
  "Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?": "清空执行记录不会重置执行次数,且执行中的也不会被删除,确定要删除所有执行记录吗?",
56
+ "Collection \"{{collectionName}}\" not found.": "数据表“{{collectionName}}”未找到。",
56
57
  "Collection event": "数据表事件",
57
58
  "Collection operations": "数据表操作",
58
59
  "Completed": "已完成",
59
- "Concat": "连接",
60
+ "Concatenate": "连接",
60
61
  "Condition": "条件判断",
61
62
  "Condition expression": "条件表达式",
62
63
  "Condition label": "条件名称",
@@ -75,6 +76,7 @@
75
76
  "Current version will be deleted (without affecting other versions).": "当前版本将被删除(不影响其他版本)。",
76
77
  "Data operation nodes in workflow will run in a same transaction until any interruption. Any failure will cause data rollback, and will also rollback the history of the execution.": "工作流中的节点将在同一个事务中运行。任何失败都会导致数据回滚,同时也会回滚相应的执行历史。",
77
78
  "Date range": "日期范围",
79
+ "Data source \"{{dataSourceName}}\" not found.": "数据源“{{dataSourceName}}”未找到。",
78
80
  "Date variables": "日期变量",
79
81
  "Days": "天",
80
82
  "Delete a main version will cause all other revisions to be deleted too.": "删除主版本将导致其他版本一并被删除。",
@@ -120,7 +122,7 @@
120
122
  "Hours": "小时",
121
123
  "If checked, all nodes in-progress could continue to be processed in execution of disabled workflow. Otherwise, all nodes in-progress will be aborted automatically.": "如果选中,在途的节点在禁用或升级到新版本的工作流中将继续处理。否则将自动取消执行。",
122
124
  "If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.": "选中后,当查询结果有多条记录时,会返回数组作为结果,可以使用循环节点对它逐条操作;否则,仅返回一条数据。",
123
- "If the number of loop calls is too large, there will be performance issues.": "If the number of loop calls is too large, there will be performance issues.",
125
+ "Input workflow result": "请输入工作流执行结果",
124
126
  "Inside of \"No\" branch": "“否”分支内",
125
127
  "Inside of \"Yes\" branch": "“是”分支内",
126
128
  "Inside of \"{{branchName}}\" branch": "“{{branchName}}”分支内",
@@ -152,6 +154,7 @@
152
154
  "Node type": "节点类型",
153
155
  "Node with unknown type will cause error. Please delete it or check plugin which provide this type.": "未知类型的节点会导致错误,请删除或检查提供该类型的插件。",
154
156
  "Null": "Null",
157
+ "Not found": "未找到",
155
158
  "Off": "停用",
156
159
  "On": "启用",
157
160
  "On going": "进行中",
@@ -160,6 +163,8 @@
160
163
  "Operations": "操作",
161
164
  "Operator": "运算符",
162
165
  "Otherwise": "否则",
166
+ "Output": "流程输出",
167
+ "Output value": "结果值",
163
168
  "Pending": "待处理",
164
169
  "Please add at least one condition": "请添加至少一个条件",
165
170
  "Please select collection first": "请先选择数据表",
@@ -185,6 +190,7 @@
185
190
  "Select context": "选择上下文",
186
191
  "Select users": "选择用户",
187
192
  "Select workflow": "选择工作流",
193
+ "Set output data of this workflow. When this one is executed as a subflow, the output could be used as variables in downstream nodes of super workflow. You can also use this node in an AI employee workflow, to define what to output. If this node is added multiple times, the value of the last executed node prevails.": "设置工作流的输出数据。在作为子流程执行后可以被上级流程后续节点使用。你也可以在 AI 员工工作流中使用此节点,来定义输出内容。如果多次添加此节点,则以最后一个被执行的节点的值为准。",
188
194
  "Single record": "单条数据",
189
195
  "Some node meets error.": "某个节点出错。",
190
196
  "Started and executing, maybe waiting for an async callback (manual, delay etc.).": "已开始执行,可能在等待异步回调(人工、延时等)。",
@@ -253,12 +259,11 @@
253
259
  "Will be executed in the background as a queued task.": "将作为队列任务在后台执行。",
254
260
  "Workflow": "工作流",
255
261
  "Workflow executed, the result status is <1>{{statusText}}</1><2>View the execution</2>": "工作流已执行,结果状态为 <1>{{statusText}}</1><2>查看执行详情</2>",
256
- "Workflow is not exists": "工作流不存在",
262
+ "Workflow of execution is not existed": "执行计划对应的工作流不存在",
257
263
  "Workflow tasks": "流程待办",
258
264
  "Workflow todos": "流程待办",
259
265
  "Workflow will be triggered before deleting succeeded (only supports pre-action event in local mode).": "删除成功之前触发工作流(支持操作前事件)。",
260
266
  "Workflow will be triggered directly once the button clicked, without data saving. Only supports to be bound with \"Custom action event\".": "按钮点击后直接触发工作流,但不会保存数据。仅支持绑定“自定义操作事件”。",
261
267
  "Workflow with unknown type will cause error. Please delete it or check plugin which provide this type.": "未知类型的工作流会导致错误,请删除或检查提供该类型的插件。",
262
- "Yes": "是",
263
- "concat": "连接"
268
+ "Yes": "是"
264
269
  }
@@ -54,7 +54,7 @@
54
54
  "Collection event": "Collection event",
55
55
  "Collection operations": "Collection operations",
56
56
  "Completed": "Completed",
57
- "Concat": "Concat",
57
+ "Concatenate": "連接",
58
58
  "Condition": "Condition",
59
59
  "Condition expression": "Condition expression",
60
60
  "Condition label": "Condition label",
@@ -247,12 +247,11 @@
247
247
  "Will be executed in the background as a queued task.": "Will be executed in the background as a queued task.",
248
248
  "Workflow": "Workflow",
249
249
  "Workflow executed, the result status is <1>{{statusText}}</1><2>View the execution</2>": "Workflow executed, the result status is <1>{{statusText}}</1><2>View the execution</2>",
250
- "Workflow is not exists": "Workflow is not exists",
250
+ "Workflow of execution is not existed": "Workflow of execution is not existed",
251
251
  "Workflow tasks": "Workflow tasks",
252
252
  "Workflow todos": "Workflow todos",
253
253
  "Workflow will be triggered before deleting succeeded (only supports pre-action event in local mode).": "Workflow will be triggered before deleting succeeded (only supports pre-action event in local mode).",
254
254
  "Workflow will be triggered directly once the button clicked, without data saving. Only supports to be bound with \"Custom action event\".": "Workflow will be triggered directly once the button clicked, without data saving. Only supports to be bound with \"Custom action event\".",
255
255
  "Workflow with unknown type will cause error. Please delete it or check plugin which provide this type.": "Workflow with unknown type will cause error. Please delete it or check plugin which provide this type.",
256
256
  "Yes": "Yes",
257
- "concat": "concat"
258
257
  }
@@ -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-04T03:45:20.943Z"}
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-02-05T04:40:25.837Z"}
@@ -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-04T03:45:20.595Z"}
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-02-05T04:40:25.504Z"}
@@ -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-04T03:45:20.400Z"}
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-02-05T04:40:25.318Z"}
@@ -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
  }
@@ -55,6 +55,7 @@ var import_ScheduleTrigger = __toESM(require("./triggers/ScheduleTrigger"));
55
55
  var import_CalculationInstruction = __toESM(require("./instructions/CalculationInstruction"));
56
56
  var import_ConditionInstruction = __toESM(require("./instructions/ConditionInstruction"));
57
57
  var import_EndInstruction = __toESM(require("./instructions/EndInstruction"));
58
+ var import_OutputInstruction = __toESM(require("./instructions/OutputInstruction"));
58
59
  var import_CreateInstruction = __toESM(require("./instructions/CreateInstruction"));
59
60
  var import_DestroyInstruction = __toESM(require("./instructions/DestroyInstruction"));
60
61
  var import_QueryInstruction = __toESM(require("./instructions/QueryInstruction"));
@@ -270,6 +271,7 @@ class PluginWorkflowServer extends import_server.Plugin {
270
271
  this.registerInstruction("condition", import_ConditionInstruction.default);
271
272
  this.registerInstruction("multi-conditions", import_MultiConditionsInstruction.default);
272
273
  this.registerInstruction("end", import_EndInstruction.default);
274
+ this.registerInstruction("output", import_OutputInstruction.default);
273
275
  this.registerInstruction("create", import_CreateInstruction.default);
274
276
  this.registerInstruction("destroy", import_DestroyInstruction.default);
275
277
  this.registerInstruction("query", import_QueryInstruction.default);
@@ -287,7 +289,8 @@ class PluginWorkflowServer extends import_server.Plugin {
287
289
  filter: { name: this.name }
288
290
  });
289
291
  this.snowflake = new import_nodejs_snowflake.Snowflake({
290
- custom_epoch: pluginRecord == null ? void 0 : pluginRecord.createdAt.getTime()
292
+ custom_epoch: pluginRecord == null ? void 0 : pluginRecord.createdAt.getTime(),
293
+ instance_id: this.app.instanceId
291
294
  });
292
295
  }
293
296
  /**
@@ -335,6 +338,7 @@ class PluginWorkflowServer extends import_server.Plugin {
335
338
  "flow_nodes:update",
336
339
  "flow_nodes:destroy",
337
340
  "flow_nodes:destroyBranch",
341
+ "flow_nodes:move",
338
342
  "flow_nodes:test",
339
343
  "jobs:get",
340
344
  "workflowCategories:*"
@@ -96,6 +96,15 @@ export default class Processor {
96
96
  * @experimental
97
97
  */
98
98
  getScope(sourceNodeId?: number | string, includeSelfScope?: boolean): {
99
+ ctx: {
100
+ $context: any;
101
+ $jobsMapByNodeKey: {
102
+ [key: string]: any;
103
+ };
104
+ $system: {};
105
+ $scopes: {};
106
+ $env: {};
107
+ };
99
108
  $context: any;
100
109
  $jobsMapByNodeKey: {
101
110
  [key: string]: any;
@@ -439,13 +439,18 @@ class Processor {
439
439
  $scopes[n.id] = $scopes[n.key] = instruction.getScope(n, this.jobResultsMapByNodeKey[n.key], this);
440
440
  }
441
441
  }
442
- return {
442
+ const scopes = {
443
443
  $context: this.execution.context,
444
444
  $jobsMapByNodeKey: this.jobResultsMapByNodeKey,
445
445
  $system: systemFns,
446
446
  $scopes,
447
447
  $env: this.options.plugin.app.environment.getVariables()
448
448
  };
449
+ return {
450
+ ...scopes,
451
+ ctx: scopes
452
+ // 2.0
453
+ };
449
454
  }
450
455
  /**
451
456
  * @experimental
@@ -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
  });
@@ -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
- return processor.exit(branchJob.status);
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.2",
9
+ "version": "2.0.0-beta.20",
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": "b77a33ee933ae6e09d2d5dce017ca15d8552d57b",
51
+ "gitHead": "f4ab788fc6c17915157617026dfbba6f0d78eaac",
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}}))}}}]);