@nocobase/plugin-workflow 1.8.0-beta.10 → 1.8.0-beta.13

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 (31) hide show
  1. package/dist/client/256475f279fb46d1.js +10 -0
  2. package/dist/client/48fc0fadf459229d.js +10 -0
  3. package/dist/client/6667e5f1fde96579.js +10 -0
  4. package/dist/client/69d4f948046f2ad2.js +10 -0
  5. package/dist/client/WorkflowTasks.d.ts +7 -0
  6. package/dist/client/index.js +1 -1
  7. package/dist/client/nodes/calculation.d.ts +1 -0
  8. package/dist/client/nodes/condition.d.ts +1 -0
  9. package/dist/client/schemas/executions.d.ts +1 -0
  10. package/dist/client/variable.d.ts +5 -2
  11. package/dist/common/collections/workflows.d.ts +14 -0
  12. package/dist/common/collections/workflows.js +1 -2
  13. package/dist/externalVersion.js +11 -10
  14. package/dist/node_modules/cron-parser/package.json +1 -1
  15. package/dist/node_modules/lru-cache/package.json +1 -1
  16. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  17. package/dist/server/Plugin.d.ts +1 -0
  18. package/dist/server/Plugin.js +27 -2
  19. package/dist/server/actions/nodes.js +1 -2
  20. package/dist/server/actions/workflows.js +9 -1
  21. package/dist/server/instructions/CalculationInstruction.d.ts +10 -0
  22. package/dist/server/instructions/CalculationInstruction.js +15 -0
  23. package/dist/server/instructions/ConditionInstruction.d.ts +11 -0
  24. package/dist/server/instructions/ConditionInstruction.js +15 -0
  25. package/dist/server/migrations/20250619213102-add-missed-stats.d.ts +14 -0
  26. package/dist/server/migrations/20250619213102-add-missed-stats.js +61 -0
  27. package/package.json +4 -3
  28. package/dist/client/3c67def1831d0b23.js +0 -10
  29. package/dist/client/8e2ad933533030aa.js +0 -10
  30. package/dist/client/e9d2f9ed69c18a56.js +0 -10
  31. package/dist/client/f9eeb46e5c6a9ffe.js +0 -10
@@ -78,4 +78,5 @@ export default class extends Instruction {
78
78
  label: any;
79
79
  };
80
80
  useInitializers(node: any): SchemaInitializerItemType;
81
+ testable: boolean;
81
82
  }
@@ -119,4 +119,5 @@ export default class extends Instruction {
119
119
  Component({ data }: {
120
120
  data: any;
121
121
  }): React.JSX.Element;
122
+ testable: boolean;
122
123
  }
@@ -152,6 +152,7 @@ export declare const executionSchema: {
152
152
  appends: string[];
153
153
  pageSize: number;
154
154
  sort: string[];
155
+ except: string[];
155
156
  filter: {};
156
157
  };
157
158
  };
@@ -7,6 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
+ import { CollectionManager } from '@nocobase/client';
10
11
  export type VariableOption = {
11
12
  key?: string;
12
13
  value?: string;
@@ -21,7 +22,9 @@ export type VariableDataType = 'boolean' | 'number' | 'string' | 'date' | {
21
22
  multiple?: boolean;
22
23
  entity?: boolean;
23
24
  };
24
- } | ((field: any) => boolean);
25
+ } | ((field: any, options: {
26
+ collectionManager?: CollectionManager;
27
+ }) => boolean);
25
28
  export type UseVariableOptions = {
26
29
  types?: VariableDataType[];
27
30
  fieldNames?: {
@@ -70,7 +73,7 @@ export declare const BaseTypeSets: {
70
73
  };
71
74
  export declare function useWorkflowVariableOptions(options?: UseVariableOptions): any[];
72
75
  export declare function getCollectionFieldOptions(options: any): VariableOption[];
73
- export declare function useGetCollectionFields(dataSourceName?: any): (collectionName: any) => import("@nocobase/client").CollectionFieldOptions[];
76
+ export declare function useGetDataSourceCollectionManager(dataSourceName?: any): CollectionManager;
74
77
  export declare function WorkflowVariableInput({ variableOptions, ...props }: {
75
78
  [x: string]: any;
76
79
  variableOptions: any;
@@ -223,6 +223,20 @@ declare const _default: {
223
223
  constraints?: undefined;
224
224
  through?: undefined;
225
225
  otherKey?: undefined;
226
+ } | {
227
+ type: string;
228
+ name: string;
229
+ target: string;
230
+ foreignKey: string;
231
+ sourceKey: string;
232
+ constraints: boolean;
233
+ interface?: undefined;
234
+ uiSchema?: undefined;
235
+ defaultValue?: undefined;
236
+ required?: undefined;
237
+ onDelete?: undefined;
238
+ through?: undefined;
239
+ otherKey?: undefined;
226
240
  } | {
227
241
  type: string;
228
242
  name: string;
@@ -170,8 +170,7 @@ var workflows_default = {
170
170
  target: "workflowStats",
171
171
  foreignKey: "key",
172
172
  sourceKey: "key",
173
- constraints: false,
174
- onDelete: "CASCADE"
173
+ constraints: false
175
174
  // interface: 'oho',
176
175
  // uiSchema: {
177
176
  // type: 'object',
@@ -11,8 +11,8 @@ module.exports = {
11
11
  "react": "18.2.0",
12
12
  "@formily/core": "2.3.0",
13
13
  "@formily/react": "2.3.0",
14
- "@nocobase/client": "1.8.0-beta.10",
15
- "@nocobase/utils": "1.8.0-beta.10",
14
+ "@nocobase/client": "1.8.0-beta.13",
15
+ "@nocobase/utils": "1.8.0-beta.13",
16
16
  "antd": "5.24.2",
17
17
  "@ant-design/icons": "5.6.1",
18
18
  "react-router-dom": "6.28.1",
@@ -20,16 +20,17 @@ module.exports = {
20
20
  "lodash": "4.17.21",
21
21
  "@dnd-kit/core": "6.1.0",
22
22
  "@formily/shared": "2.3.2",
23
+ "@nocobase/plugin-mobile": "1.8.0-beta.13",
23
24
  "sequelize": "6.35.2",
24
- "@nocobase/database": "1.8.0-beta.10",
25
- "@nocobase/server": "1.8.0-beta.10",
26
- "@nocobase/data-source-manager": "1.8.0-beta.10",
27
- "@nocobase/logger": "1.8.0-beta.10",
28
- "@nocobase/evaluators": "1.8.0-beta.10",
25
+ "@nocobase/database": "1.8.0-beta.13",
26
+ "@nocobase/server": "1.8.0-beta.13",
27
+ "@nocobase/data-source-manager": "1.8.0-beta.13",
28
+ "@nocobase/logger": "1.8.0-beta.13",
29
+ "@nocobase/evaluators": "1.8.0-beta.13",
29
30
  "@formily/antd-v5": "1.2.3",
30
31
  "@formily/reactive": "2.3.0",
31
- "@nocobase/actions": "1.8.0-beta.10",
32
+ "@nocobase/actions": "1.8.0-beta.13",
32
33
  "dayjs": "1.11.13",
33
- "@nocobase/plugin-workflow-test": "1.8.0-beta.10",
34
- "@nocobase/test": "1.8.0-beta.10"
34
+ "@nocobase/plugin-workflow-test": "1.8.0-beta.13",
35
+ "@nocobase/test": "1.8.0-beta.13"
35
36
  };
@@ -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":"2025-06-18T22:32:17.259Z"}
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":"2025-07-03T10:07:12.012Z"}
@@ -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":"2025-06-18T22:32:16.916Z"}
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":"2025-07-03T10:07:11.667Z"}
@@ -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":"2025-06-18T22:32:16.724Z"}
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":"2025-07-03T10:07:11.489Z"}
@@ -41,6 +41,7 @@ export default class PluginWorkflowServer extends Plugin {
41
41
  private loggerCache;
42
42
  private meter;
43
43
  private checker;
44
+ private onQueueExecution;
44
45
  private onBeforeSave;
45
46
  private onAfterCreate;
46
47
  private onAfterUpdate;
@@ -75,6 +75,20 @@ class PluginWorkflowServer extends import_server.Plugin {
75
75
  loggerCache;
76
76
  meter = null;
77
77
  checker = null;
78
+ onQueueExecution = async (event) => {
79
+ const ExecutionRepo = this.db.getRepository("executions");
80
+ const execution = await ExecutionRepo.findOne({
81
+ filterByTk: event.executionId
82
+ });
83
+ if (!execution || execution.status !== import_constants.EXECUTION_STATUS.QUEUEING) {
84
+ return;
85
+ }
86
+ this.getLogger(execution.workflowId).info(
87
+ `execution (${execution.id}) received from queue, adding to pending list`
88
+ );
89
+ this.pending.push([execution]);
90
+ this.dispatch();
91
+ };
78
92
  onBeforeSave = async (instance, { transaction, cycling }) => {
79
93
  if (cycling) {
80
94
  return;
@@ -176,6 +190,7 @@ class PluginWorkflowServer extends import_server.Plugin {
176
190
  this.ready = true;
177
191
  };
178
192
  onBeforeStop = async () => {
193
+ this.app.logger.info(`stopping workflow plugin before app (${this.app.name}) shutdown...`);
179
194
  for (const workflow of this.enabledCache.values()) {
180
195
  this.toggle(workflow, false, { silent: true });
181
196
  }
@@ -289,6 +304,10 @@ class PluginWorkflowServer extends import_server.Plugin {
289
304
  this.snowflake = new import_nodejs_snowflake.Snowflake({
290
305
  custom_epoch: pluginRecord == null ? void 0 : pluginRecord.createdAt.getTime()
291
306
  });
307
+ this.app.eventQueue.subscribe(`${this.name}.pendingExecution`, {
308
+ idle: () => !this.executing && !this.pending.length && !this.events.length,
309
+ process: this.onQueueExecution
310
+ });
292
311
  }
293
312
  /**
294
313
  * @internal
@@ -545,8 +564,14 @@ class PluginWorkflowServer extends import_server.Plugin {
545
564
  logger.info(`preparing execution for event`);
546
565
  try {
547
566
  const execution = await this.createExecution(...event);
548
- if ((execution == null ? void 0 : execution.status) === import_constants.EXECUTION_STATUS.QUEUEING && !this.executing && !this.pending.length) {
549
- this.pending.push([execution]);
567
+ if ((execution == null ? void 0 : execution.status) === import_constants.EXECUTION_STATUS.QUEUEING) {
568
+ if (!this.executing && !this.pending.length) {
569
+ logger.info(`local pending list is empty, adding execution (${execution.id}) to pending list`);
570
+ this.pending.push([execution]);
571
+ } else {
572
+ logger.info(`local pending list is not empty, sending execution (${execution.id}) to queue`);
573
+ this.app.eventQueue.publish(`${this.name}.pendingExecution`, { executionId: execution.id });
574
+ }
550
575
  }
551
576
  } catch (error) {
552
577
  logger.error(`failed to create execution:`, { error });
@@ -52,8 +52,7 @@ async function create(context, next) {
52
52
  context.body = await db.sequelize.transaction(async (transaction) => {
53
53
  const workflow = await repository.getSourceModel(transaction);
54
54
  workflow.versionStats = await workflow.getVersionStats({ transaction });
55
- const { executed } = workflow.versionStats;
56
- if (executed) {
55
+ if (workflow.versionStats.executed > 0) {
57
56
  context.throw(400, "Node could not be created in executed workflow");
58
57
  }
59
58
  const instance = await repository.create({
@@ -84,11 +84,19 @@ async function destroy(context, next) {
84
84
  transaction
85
85
  });
86
86
  revisions.forEach((item) => ids.add(item.id));
87
- context.body = await repository.destroy({
87
+ const deleted = await repository.destroy({
88
88
  filterByTk: Array.from(ids),
89
89
  individualHooks: true,
90
90
  transaction
91
91
  });
92
+ const StatsRepo = context.db.getRepository("workflowStats");
93
+ await StatsRepo.destroy({
94
+ filter: {
95
+ key: Array.from(keysSet)
96
+ },
97
+ transaction
98
+ });
99
+ context.body = deleted;
92
100
  });
93
101
  next();
94
102
  }
@@ -21,5 +21,15 @@ export declare class CalculationInstruction extends Instruction {
21
21
  result: any;
22
22
  status: -2;
23
23
  }>;
24
+ test({ engine, expression }: {
25
+ engine?: string;
26
+ expression?: string;
27
+ }): Promise<{
28
+ result: any;
29
+ status: 1;
30
+ } | {
31
+ result: any;
32
+ status: -2;
33
+ }>;
24
34
  }
25
35
  export default CalculationInstruction;
@@ -51,6 +51,21 @@ class CalculationInstruction extends import__.Instruction {
51
51
  };
52
52
  }
53
53
  }
54
+ async test({ engine = "math.js", expression = "" }) {
55
+ const evaluator = import_evaluators.evaluators.get(engine);
56
+ try {
57
+ const result = evaluator && expression ? evaluator(expression) : null;
58
+ return {
59
+ result,
60
+ status: import_constants.JOB_STATUS.RESOLVED
61
+ };
62
+ } catch (e) {
63
+ return {
64
+ result: e.toString(),
65
+ status: import_constants.JOB_STATUS.ERROR
66
+ };
67
+ }
68
+ }
54
69
  }
55
70
  var CalculationInstruction_default = CalculationInstruction;
56
71
  // Annotate the CommonJS export names for ESM import in node:
@@ -29,5 +29,16 @@ export declare class ConditionInstruction extends Instruction {
29
29
  result: boolean;
30
30
  }>;
31
31
  resume(node: FlowNodeModel, branchJob: JobModel, processor: Processor): Promise<any>;
32
+ test({ engine, calculation, expression }: {
33
+ engine: any;
34
+ calculation: any;
35
+ expression?: string;
36
+ }): Promise<{
37
+ result: any;
38
+ status: 1;
39
+ } | {
40
+ result: any;
41
+ status: -2;
42
+ }>;
32
43
  }
33
44
  export default ConditionInstruction;
@@ -84,6 +84,21 @@ class ConditionInstruction extends import__.Instruction {
84
84
  }
85
85
  return processor.exit(branchJob.status);
86
86
  }
87
+ async test({ engine, calculation, expression = "" }) {
88
+ const evaluator = import_evaluators.evaluators.get(engine);
89
+ try {
90
+ const result = evaluator ? evaluator(expression) : (0, import_logicCalculate.logicCalculate)(calculation);
91
+ return {
92
+ result,
93
+ status: import_constants.JOB_STATUS.RESOLVED
94
+ };
95
+ } catch (e) {
96
+ return {
97
+ result: e.toString(),
98
+ status: import_constants.JOB_STATUS.ERROR
99
+ };
100
+ }
101
+ }
87
102
  }
88
103
  var ConditionInstruction_default = ConditionInstruction;
89
104
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1,14 @@
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 { Migration } from '@nocobase/server';
10
+ export default class extends Migration {
11
+ appVersion: string;
12
+ on: string;
13
+ up(): Promise<void>;
14
+ }
@@ -0,0 +1,61 @@
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 add_missed_stats_exports = {};
28
+ __export(add_missed_stats_exports, {
29
+ default: () => add_missed_stats_default
30
+ });
31
+ module.exports = __toCommonJS(add_missed_stats_exports);
32
+ var import_server = require("@nocobase/server");
33
+ class add_missed_stats_default extends import_server.Migration {
34
+ appVersion = "<1.8.0";
35
+ on = "afterLoad";
36
+ async up() {
37
+ const { db } = this.context;
38
+ const WorkflowRepo = db.getRepository("workflows");
39
+ const ExecutionRepo = db.getRepository("executions");
40
+ await db.sequelize.transaction(async (transaction) => {
41
+ const workflows = await WorkflowRepo.find({
42
+ filter: {
43
+ current: true
44
+ },
45
+ appends: ["stats"],
46
+ transaction
47
+ });
48
+ for (const workflow of workflows) {
49
+ if (!workflow.stats) {
50
+ const executed = await ExecutionRepo.count({
51
+ filter: {
52
+ key: workflow.key
53
+ },
54
+ transaction
55
+ }) || workflow.allExecuted || 0;
56
+ await workflow.createStats({ executed }, { transaction });
57
+ }
58
+ }
59
+ });
60
+ }
61
+ }
package/package.json CHANGED
@@ -4,13 +4,13 @@
4
4
  "displayName.zh-CN": "工作流",
5
5
  "description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
6
6
  "description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
7
- "version": "1.8.0-beta.10",
7
+ "version": "1.8.0-beta.13",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow",
11
11
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow",
12
12
  "dependencies": {
13
- "@nocobase/plugin-workflow-test": "1.8.0-beta.10"
13
+ "@nocobase/plugin-workflow-test": "1.8.0-beta.13"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@ant-design/icons": "5.x",
@@ -40,13 +40,14 @@
40
40
  "@nocobase/logger": "1.x",
41
41
  "@nocobase/plugin-data-source-main": "1.x",
42
42
  "@nocobase/plugin-error-handler": "1.x",
43
+ "@nocobase/plugin-mobile": "1.x",
43
44
  "@nocobase/plugin-users": "1.x",
44
45
  "@nocobase/resourcer": "1.x",
45
46
  "@nocobase/server": "1.x",
46
47
  "@nocobase/test": "1.x",
47
48
  "@nocobase/utils": "1.x"
48
49
  },
49
- "gitHead": "09fe854edfc44f45422fa983093dd34694416c5a",
50
+ "gitHead": "9ccd306ff667a54317ba07a000fc5aa00685d5e6",
50
51
  "keywords": [
51
52
  "Workflow"
52
53
  ]
@@ -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([["383"],{8958:function(e,t,n){n.d(t,{a:function(){return a}});var o=n(8156),r=n.n(o),c=n(3238),i=n(6128),l=n(3772),u=n(7893),a=function(){var e=(0,c.useTranslation)().t,t=(0,l.useRecord)().id,n=(0,l.useActionContext)().setVisible;return r().createElement(i.Link,{to:(0,u.s_)(t),onClick:function(){return n(!1)}},e("View"))}},2266:function(e,t,n){n.d(t,{P:function(){return b},r:function(){return v}});var o=n(8156),r=n.n(o),c=n(2721),i=n(482),l=n(3238),u=n(3772),a=n(9144),s=n(573);function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}function d(){var e,t,n=(e=["\n display: flex;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return d=function(){return n},n}function m(e){var t,n=(0,u.useCompile)()(e.label),o=(null!=(t=a.uy[e.value])?t:{}).color;return r().createElement(c.Tag,{color:o,closable:e.closable,onClose:e.onClose},n)}function y(e){var t=(0,u.useCompile)();return r().createElement(r().Fragment,null,r().createElement(m,e),e.description?r().createElement("span",null,t(e.description)):null)}function b(e){var t,n,o=p({},function(e){if(null==e)throw TypeError("Cannot destructure "+e);return e}(e)),i=o.multiple?"multiple":null;return r().createElement(c.Select,(t=f({role:"button","data-testid":"select-".concat(i||"single")},o),n=n={mode:i,optionLabelProp:"label",tagRender:m},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t),a.C6.filter(function(e){return!!e.value&&e.value!==a.r9.ABORTED}).map(function(e){return r().createElement(c.Select.Option,f({key:e.value},e),r().createElement(y,e))}))}function v(e){var t=(0,l.useTranslation)().t,n=(0,u.useResourceActionContext)().refresh,a=(0,u.useResourceContext)().resource,p=(0,u.useRecord)(),f=(0,o.useCallback)(function(){c.Modal.confirm({title:(0,s.KQ)("Cancel the execution"),icon:r().createElement(i.ExclamationCircleFilled,null),content:(0,s.KQ)("Are you sure you want to cancel the execution?"),onOk:function(){a.cancel({filterByTk:p.id}).then(function(){c.message.success(t("Operation succeeded")),n()}).catch(function(e){console.error(e.data.error)})}})},[p]);return r().createElement("div",{className:(0,u.css)(d())},e.children,p.status?null:r().createElement(c.Tooltip,{title:(0,s.KQ)("Cancel the execution")},r().createElement(c.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r().createElement(i.StopOutlined,null)})))}},2659:function(e,t,n){n.d(t,{V:function(){return b}});var o,r=n(8156),c=n.n(r),i=n(6128),l=n(3238),u=n(2721),a=n(3772),s=n(1768),p=n(9144),f=n(573),d=n(7893);function m(e,t,n,o,r,c,i){try{var l=e[c](i),u=l.value}catch(e){n(e);return}l.done?t(u):Promise.resolve(u).then(o,r)}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var b={type:"void",name:"executionHistoryDrawer",title:'{{t("Execution history", { ns: "'.concat(f.A7,'" })}}'),"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:s.Z,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction:function(){var e=(0,l.useTranslation)().t,t=(0,a.useResourceActionContext)(),n=t.refresh,o=t.defaultRequest,r=(0,a.useResourceContext)().resource,c=(0,a.useActionContext)().setVisible;return{run:function(){var t;return(t=function(){var t;return function(e,t){var n,o,r,c,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return c={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,o&&(r=2&u[0]?o.return:u[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,u[1])).done)return r;switch(o=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,o=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){i.label=u[1];break}if(6===u[0]&&i.label<r[1]){i.label=r[1],r=u;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(u);break}r[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],o=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return[4,r.destroy({filter:null==(t=o.params)?void 0:t.filter})];case 1:return i.sent(),u.message.success(e("Operation succeeded")),n(),c(!1),[2]}})},function(){var e=this,n=arguments;return new Promise(function(o,r){var c=t.apply(e,n);function i(e){m(c,o,r,i,l,"next",e)}function l(e){m(c,o,r,i,l,"throw",e)}i(void 0)})})()}}},confirm:{title:'{{t("Clear all executions", { ns: "'.concat(f.A7,'" })}}'),content:'{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "'.concat(f.A7,'" })}}')}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Version", { ns: "'.concat(f.A7,'" })}}'),properties:{workflowId:(y(o={type:"number"},"x-component",function(e){var t=e.value,n=(0,a.useActionContext)().setVisible;return c().createElement(i.Link,{to:(0,d.SI)(t),onClick:function(){return n(!1)}},"#".concat(t))}),y(o,"x-read-pretty",!0),o)}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Status", { ns: "'.concat(f.A7,'" })}}'),properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"},"x-reactions":[{dependencies:["..status"],fulfill:{state:{visible:"{{ $deps[0] !== ".concat(p.r9.STARTED," }}")}}}]}}}}}}}}}}}},8327:function(e,t,n){n.d(t,{X:function(){return c}});var o=n(3772);function r(e,t,n,o,r,c,i){try{var l=e[c](i),u=l.value}catch(e){n(e);return}l.done?t(u):Promise.resolve(u).then(o,r)}function c(){var e=(0,o.useResourceActionContext)();return{onClick:function(){var t;return(t=function(){var t;return function(e,t){var n,o,r,c,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return c={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,o&&(r=2&u[0]?o.return:u[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,u[1])).done)return r;switch(o=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,o=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){i.label=u[1];break}if(6===u[0]&&i.label<r[1]){i.label=r[1],r=u;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(u);break}r[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],o=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){return null==e||null==(t=e.refresh)||t.call(e),[2]})},function(){var e=this,n=arguments;return new Promise(function(o,c){var i=t.apply(e,n);function l(e){r(i,o,c,l,u,"next",e)}function u(e){r(i,o,c,l,u,"throw",e)}l(void 0)})})()}}}}}]);
@@ -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([["638"],{679:function(e,t,o){o.r(t),o.d(t,{WorkflowPane:function(){return ea}});var r=o(8156),n=o.n(r),i=o(2721),c=o(8563),a=o(3505),l=o(3772),s=o(8958);function u(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){var r;r=o[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function p(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o.push.apply(o,r)}return o})(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}var m=function(e){var t,o=e.request,r=(e.filter,function(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)o=i[r],!(t.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}(e,["request","filter"])),i=(0,l.useRecord)(),c=p(u({},r),{request:p(u({},o),{params:p(u({},null==o?void 0:o.params),{filter:p(u({},null==o||null==(t=o.params)?void 0:t.filter),{key:i.key})})})});return n().createElement(l.ResourceActionProvider,c)},d=o(3238),f=o(6128),y=o(7893),b=function(){var e=(0,d.useTranslation)().t,t=(0,l.useRecord)().id,o=(0,l.useActionContext)().setVisible,r=(0,l.useGetAriaLabelOfAction)("Configure").getAriaLabel;return n().createElement(f.Link,{"aria-label":r(),to:(0,y.SI)(t),onClick:function(){return o(!1)}},e("Configure"))};function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,r=Array(t);o<t;o++)r[o]=e[o];return r}function x(e){var t,o,i,c=e.component,s=e.children,u=function(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)o=i[r],!(t.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}(e,["component","children"]),p=(t=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var o,r,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i=[],c=!0,a=!1;try{for(n=n.call(e);!(c=(o=n.next()).done)&&(i.push(o.value),i.length!==t);c=!0);}catch(e){a=!0,r=e}finally{try{c||null==n.return||n.return()}finally{if(a)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return v(e,2);var o=Object.prototype.toString.call(e).slice(8,-1);if("Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o)return Array.from(o);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return v(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.")}()),m=p[0],d=p[1],f=(0,a.useFieldSchema)();return n().createElement(l.ActionContextProvider,{value:{visible:m,setVisible:d,fieldSchema:f}},n().createElement(void 0===c?"div":c,(o=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){var r;r=o[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},u),i=i={onClick:function(){d(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o.push.apply(o,r)}return o})(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}),o),s),n().createElement(l.SchemaComponent,{schema:f,onlyRenderProperties:!0}))}var g=o(573),h=o(2659),O=o(67),A={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-decorator":"FormItem",title:'{{t("Trigger type", { ns: "'.concat(g.A7,'" })}}'),"x-component":"Select","x-component-props":{optionRender:"{{TriggerOptionRender}}",popupMatchSelectWidth:!0,listHeight:300},enum:"{{useTriggersOptions()}}",required:!0},sync:{type:"boolean",title:'{{ t("Execute mode", { ns: "'.concat(g.A7,'" }) }}'),description:'{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "'.concat(g.A7,'" }) }}'),"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:'{{ t("Asynchronously", { ns: "'.concat(g.A7,'" }) }}'),value:!1,tooltip:'{{ t("Will be executed in the background as a queued task.", { ns: "'.concat(g.A7,'" }) }}')},{label:'{{ t("Synchronously", { ns: "'.concat(g.A7,'" }) }}'),value:!0,tooltip:'{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "'.concat(g.A7,'" }) }}')}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},categories:{type:"array",title:'{{ t("Category", { ns: "'.concat(g.A7,'" }) }}'),"x-decorator":"FormItem","x-component":"CollectionField","x-collection-field":"workflows.categories"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:'{{ t("Auto delete history when execution is on end status", { ns: "'.concat(g.A7,'" }) }}'),"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}},stackLimit:{type:"number",title:'{{ t("Maximum number of cycling triggers", { ns: "'.concat(g.A7,'" }) }}'),description:'{{ t("The triggers of same workflow by some node (create, update and sub-flow etc.) more than this number will be ignored. Large number may cause performance issues. Please use with caution.", { ns: "'.concat(g.A7,'" }) }}'),"x-decorator":"FormItem",default:1,"x-component":"InputNumber","x-component-props":{min:1,precision:0,className:"auto-width"}}}}},w={name:"workflow",type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:O.Z,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CategoryTabs",properties:{main:{type:"void","x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useWorkflowFilterActionProps","x-component-props":{icon:"FilterOutlined",nonfilterable:["description","categories"]},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:'{{t("Sync", { ns: "'.concat(g.A7,'" })}}'),"x-decorator":"Tooltip","x-decorator-props":{title:'{{ t("Sync enabled status of all workflows from database", { ns: "'.concat(g.A7,'" }) }}')},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction:"{{ useSyncAction }}"},"x-reactions":["{{useWorkflowSyncReaction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:A.title,type:A.type,sync:A.sync,categories:A.categories,description:A.description,options:A.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"array","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Title") }}',properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},categories:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Category", { ns: "'.concat(g.A7,'" }) }}'),properties:{categories:{type:"array","x-component":"EnumerationField","x-component-props":{multiple:!0,fieldNames:{label:"title",value:"id",color:"color"}}}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Trigger type", { ns: "'.concat(g.A7,'" }) }}'),properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Execute mode", { ns: "'.concat(g.A7,'" }) }}'),properties:{sync:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Status", { ns: "'.concat(g.A7,'" }) }}'),properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},"stats.executed":{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Executed", { ns: "'.concat(g.A7,'" }) }}'),properties:{"stats.executed":{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(e){var t=(0,l.useCollectionRecordData)();return n().createElement("a",function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){var r;r=o[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({"aria-label":"executed-".concat(t.title)},e))}},"x-component":"InputNumber","x-read-pretty":!0,properties:{drawer:h.V}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:A.title,enabled:A.enabled,sync:A.sync,categories:A.categories,description:A.description,options:A.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:'{{t("Duplicate", { ns: "'.concat(g.A7,'" })}}'),"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:'{{t("Duplicate to new workflow", { ns: "'.concat(g.A7,'" })}}'),"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useRevisionAction }}"}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}}}},C=o(2266),S=o(7511),P=o(8327);function E(e){var t=e.data,o=t.label,r=t.color,c=t.options,a=(0,l.useCompile)();return n().createElement(i.Space,{direction:"vertical"},n().createElement(i.Tag,{color:r},a(o)),n().createElement(i.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"}},a(c.description)))}var j=o(482),k=o(2948),F=o(8875),D=o(467);function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,r=Array(t);o<t;o++)r[o]=e[o];return r}function R(e,t,o,r,n,i,c){try{var a=e[i](c),l=a.value}catch(e){o(e);return}a.done?t(l):Promise.resolve(l).then(r,n)}function I(e){return function(){var t=this,o=arguments;return new Promise(function(r,n){var i=e.apply(t,o);function c(e){R(i,r,n,c,a,"next",e)}function a(e){R(i,r,n,c,a,"throw",e)}c(void 0)})}}function V(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){var r;r=o[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function M(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o.push.apply(o,r)}return o})(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}function q(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var o,r,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i=[],c=!0,a=!1;try{for(n=n.call(e);!(c=(o=n.next()).done)&&(i.push(o.value),!t||i.length!==t);c=!0);}catch(e){a=!0,r=e}finally{try{c||null==n.return||n.return()}finally{if(a)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return T(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);if("Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o)return Array.from(o);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return T(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 L(e,t){var o,r,n,i,c={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var l=[i,a];if(o)throw TypeError("Generator is already executing.");for(;c;)try{if(o=1,r&&(n=2&l[0]?r.return:l[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,l[1])).done)return n;switch(r=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return c.label++,{value:l[1],done:!1};case 5:c.label++,r=l[1],l=[0];continue;case 7:l=c.ops.pop(),c.trys.pop();continue;default:if(!(n=(n=c.trys).length>0&&n[n.length-1])&&(6===l[0]||2===l[0])){c=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){c.label=l[1];break}if(6===l[0]&&c.label<n[1]){c.label=n[1],n=l;break}if(n&&c.label<n[2]){c.label=n[2],c.ops.push(l);break}n[2]&&c.ops.pop(),c.trys.pop();continue}l=t.call(e,c)}catch(e){l=[6,e],r=0}finally{o=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}function N(){var e,t,o=(e=["\n .ant-tabs-nav-list > :first-child {\n border: none;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return N=function(){return o},o}function W(e){var t=(0,k.useDraggable)({id:e.id,data:e.data}),o=t.attributes,r=t.listeners,i=t.setNodeRef;return n().createElement("div",V({ref:i},r,o),n().createElement("div",null,e.children))}function B(e){var t=(0,k.useDroppable)({id:e.id,data:e.data}),o=t.isOver,r=t.setNodeRef;return n().createElement("div",{ref:r,style:o?{color:"green"}:void 0},e.children)}var _=(0,a.observer)(function(e){var t=e.item;return n().createElement(B,{id:t.id.toString(),data:t},n().createElement("div",null,n().createElement(W,{id:t.id.toString(),data:t},n().createElement(z,{item:t}))))},{displayName:"TabTitle"}),z=function(e){var t=e.item,o=(0,d.useTranslation)().t,r=(0,l.useCompile)();return n().createElement(i.Space,null,n().createElement(i.Badge,{color:t.color}),o(r(t.title)))},K=(0,a.observer)(function(e){var t,o=q((0,r.useState)(null),2),i=o[0],c=o[1],a=(0,r.useContext)($).refresh,s=(0,l.useAPIClient)(),u=(t=I(function(e){var t,o;return L(this,function(r){switch(r.label){case 0:if(t=e.active,o=e.over,setTimeout(function(){c(null)}),!(o&&o.id!==t.id))return[3,2];return[4,s.resource("workflowCategories").move({sourceId:t.id,targetId:o.id})];case 1:r.sent(),a(),r.label=2;case 2:return[2]}})}),function(e){return t.apply(this,arguments)}),p=(0,k.useSensor)(k.MouseSensor,{activationConstraint:{distance:10}}),m=(0,k.useSensors)(p);return n().createElement(k.DndContext,{sensors:m,onDragEnd:u,onDragStart:function(e){var t;c(null==(t=e.active)?void 0:t.data.current)}},e.children,n().createElement(k.DragOverlay,null,i?n().createElement("span",{style:{whiteSpace:"nowrap"}},n().createElement(z,{item:i})):null))},{displayName:"DndProvider"}),$=(0,r.createContext)({});function G(e){var t=e.values,o=e.onEdit,c=e.onRemove,a=(0,l.useCompile)(),s=(0,r.useCallback)(function(e){switch(e.key){case"edit":o(t);break;case"delete":c(t.id)}},[o,c,t]);return n().createElement(i.Dropdown,{menu:{items:[{key:"edit",label:(0,g.KQ)("Edit category")},{key:"delete",label:(0,g.KQ)("Delete category")}],onClick:s}},n().createElement(j.MenuOutlined,{role:"button","aria-label":a(t.title),style:{padding:8,margin:"-8px"}}))}function U(){var e,t=(0,l.useResourceActionContext)(),o=t.run,s=t.setState,u=t.defaultRequest,p=q((0,r.useState)({tab:"all"}),2),m=p[0],d=p[1],f=q((0,r.useState)(m.tab),2),y=f[0],b=f[1],v=(0,l.useCompile)(),x=(0,l.useAPIClient)(),h=(0,a.useFieldSchema)(),O=i.App.useApp().modal,A=(0,l.useRequest)({resource:"workflowCategories",action:"list",params:{paginate:!1,sort:["sort"]}}),w=A.data,C=A.refresh,S=q((0,r.useState)(!1),2),P=S[0],E=S[1],j=(0,r.useMemo)(function(){return(0,c.createForm)()},[]),k=(0,r.useCallback)(function(e){E(!0);var t=(0,D.cloneDeep)(e);j.setValues(t)},[j]),T=(0,r.useCallback)(function(){E(!1),j.reset()},[j]),R=(0,r.useCallback)(function(e){O.confirm({title:v("{{t('Delete category')}}"),content:v("{{t('Are you sure you want to delete it?')}}"),onOk:I(function(){return L(this,function(t){switch(t.label){case 0:return[4,x.resource("workflowCategories").destroy({filter:{id:e}})];case 1:return t.sent(),e===+m.tab&&d({tab:"all"}),C(),o(),[2]}})})})},[m.tab]),W=(0,r.useMemo)(function(){if(!(null==w?void 0:w.data))return[];var e=w.data.sort(function(e,t){return e.sort-t.sort}).concat().map(function(e){return M(V({},e),{schema:h.properties.main})});return e.find(function(e){return"all"===e.id})||e.unshift({title:'{{t("All", { ns: "'.concat(g.A7,'" })}}'),id:"all",sort:0,closable:!1,schema:h.properties.main}),e.map(function(e){return{label:"all"!==e.id?n().createElement("div",{"data-no-dnd":"true"},n().createElement(_,{item:e})):v(e.title),key:String(e.id),closable:e.closable,closeIcon:n().createElement(G,{values:e,onEdit:k,onRemove:R}),children:n().createElement(i.Card,{variant:"borderless",style:{borderRadius:"0 0.5em 0.5em 0.5em"}},n().createElement(a.RecursionField,{name:y,schema:e.schema,onlyRenderProperties:!0}))}})},[null==w?void 0:w.data,y]),B=(0,r.useCallback)(function(e){if(d({tab:e}),b((0,F.uid)()),"all"!==e){var t,r={$and:[null==u||null==(t=u.params)?void 0:t.filter,{"categories.id":e}]};o({filter:r}),null==s||s({categories:[+e],params:[{filter:r}]})}else o(),null==s||s({categories:[],params:[]})},[null==u||null==(e=u.params)?void 0:e.filter,o,s]);return((0,r.useEffect)(function(){"all"!==m.tab&&B(m.tab)},[m.tab,B]),w)?n().createElement($.Provider,{value:{refresh:C}},n().createElement(K,null,n().createElement(i.Tabs,{addIcon:n().createElement(l.SchemaComponent,{components:{AddCategory:Z},schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category", { ns: "'.concat(g.A7,'" }) }}'),"x-component":"AddCategory","x-component-props":{type:"primary"}}}}}),onChange:B,defaultActiveKey:m.tab||"all",type:"editable-card",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},className:(0,l.css)(N()),items:W})),n().createElement(l.ActionContextProvider,{value:{visible:P,setVisible:T,openSize:"small"}},n().createElement(l.SchemaComponent,{scope:{useFormProviderProps:H,useCancelAction:l.useCancelAction,useEditSubmit:Q},schema:{name:"modal",type:"void","x-decorator":"FormV2","x-decorator-props":{form:j},title:'{{ t("Edit category", { ns: "'.concat(g.A7,'" }) }}'),"x-component":"Action.Modal","x-component-props":{delay:0},properties:{title:{type:"string",title:'{{t("Title")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditSubmit }}",style:{marginLeft:"8px"}}}}}}}}))):null}function Q(){var e=(0,a.useForm)(),t=(0,l.useActionContext)(),o=(0,l.useResourceActionContext)(),n=(0,r.useContext)($).refresh,i=(0,l.useAPIClient)();return{run:function(){return I(function(){var r;return L(this,function(c){switch(c.label){case 0:return[4,e.submit()];case 1:return c.sent(),[4,i.resource("workflowCategories").update({filterByTk:null==(r=e.values)?void 0:r.id,values:e.values})];case 2:return c.sent(),t.setVisible(!1),[4,e.reset()];case 3:return c.sent(),null==n||n(),null==o||o.refresh(),[2]}})})()}}}function H(){return{form:(0,a.useForm)()}}function X(){var e=(0,a.useForm)(),t=(0,l.useActionContext)().setVisible,o=(0,r.useContext)($).refresh,n=(0,l.useAPIClient)();return{run:function(){return I(function(){var r;return L(this,function(i){switch(i.label){case 0:return[4,e.submit()];case 1:return i.sent(),r=(0,D.cloneDeep)(e.values),[4,n.resource("workflowCategories").create({values:r})];case 2:return i.sent(),t(!1),e.reset(),o(),[2]}})})()}}}function Z(e){var t=q((0,r.useState)(!1),2),o=t[0],i=t[1],a=(0,d.useTranslation)().t,s=(0,r.useMemo)(function(){return(0,c.createForm)()},[]);return n().createElement(l.ActionContextProvider,{value:{visible:o,setVisible:i,openSize:"small"}},n().createElement("div",{onClick:function(){return i(!0)},title:a("Add category")},n().createElement(j.PlusOutlined,null)),n().createElement(l.SchemaComponent,{schema:{name:"modal",type:"void","x-decorator":"FormV2","x-decorator-props":{form:s},title:'{{ t("Add category") }}',"x-component":"Action.Modal","x-component-props":M(V({},e),{delay:0}),properties:{title:{type:"string",title:'{{t("Title")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateSubmit }}",style:{marginLeft:"8px"}}}}}}},scope:{useCancelAction:l.useCancelAction,useCreateSubmit:X}}))}function J(e){var t=e.value,o=e.multiple,r=e.fieldNames,c=void 0===r?l.defaultFieldNames:r,a=(0,l.useCompile)();return(o?null!=t?t:[]:t?[t]:[]).map(function(e){return n().createElement(i.Tag,{key:e[c.value],color:e[c.color]},a(e[c.label]))})}var Y=function(){var e,t,o=(0,l.useResourceContext)().collection,r=(0,l.useFilterFieldOptions)(o.fields),n=(0,l.useResourceActionContext)();return(0,l.useFilterFieldProps)({options:r,params:(null==(t=n.state)||null==(e=t.params)?void 0:e[0])||n.params,service:n})};function ee(e,t,o,r,n,i,c){try{var a=e[i](c),l=a.value}catch(e){o(e);return}a.done?t(l):Promise.resolve(l).then(r,n)}function et(e){return function(){var t=this,o=arguments;return new Promise(function(r,n){var i=e.apply(t,o);function c(e){ee(i,r,n,c,a,"next",e)}function a(e){ee(i,r,n,c,a,"throw",e)}c(void 0)})}}function eo(e,t){var o,r,n,i,c={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var l=[i,a];if(o)throw TypeError("Generator is already executing.");for(;c;)try{if(o=1,r&&(n=2&l[0]?r.return:l[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,l[1])).done)return n;switch(r=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return c.label++,{value:l[1],done:!1};case 5:c.label++,r=l[1],l=[0];continue;case 7:l=c.ops.pop(),c.trys.pop();continue;default:if(!(n=(n=c.trys).length>0&&n[n.length-1])&&(6===l[0]||2===l[0])){c=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){c.label=l[1];break}if(6===l[0]&&c.label<n[1]){c.label=n[1],n=l;break}if(n&&c.label<n[2]){c.label=n[2],c.ops.push(l);break}n[2]&&c.ops.pop(),c.trys.pop();continue}l=t.call(e,c)}catch(e){l=[6,e],r=0}finally{o=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}function er(e){var t=(0,a.useField)(),o=(0,l.useRecord)(),i=(0,l.usePlugin)(S.default);return(0,a.useFormEffects)(function(e){(0,c.onFieldChange)("type",function(e){var r=o.id||!e.value;if(e.value){var n=i.triggers.get(e.value);null!=n.sync?(r=!0,t.setValue(n.sync)):t.setInitialValue(!1)}t.setPattern(r?"disabled":"editable")})}),(0,r.useEffect)(function(){if(o.id){t.setPattern("disabled");var r,n=i.triggers.get(o.type);null!=n.sync?t.setValue(n.sync):t.setInitialValue(null!=(r=e.value)&&r)}},[o.id,t,i.triggers,o.type,e.value]),n().createElement(S.RadioWithTooltip,e)}function en(e){var t=(0,l.useApp)();e.visible=!!((0,l.usePlugin)("multi-app-share-collection")||"main"!==t.name)}function ei(){var e=i.App.useApp().message,t=(0,d.useTranslation)().t,o=(0,l.useResourceContext)().resource;return{run:function(){return et(function(){return eo(this,function(r){switch(r.label){case 0:return[4,o.sync()];case 1:return r.sent(),e.success(t("Operation succeeded")),[2]}})})()}}}function ec(){var e=i.App.useApp().message,t=(0,d.useTranslation)().t,o=(0,l.useResourceActionContext)().refresh,r=(0,l.useResourceContext)(),n=r.resource,c=r.targetKey,s=(0,l.useActionContext)().setVisible,u=(0,l.useRecord)()[c],p=(0,a.useForm)(),m=(0,a.useField)();return{run:function(){return et(function(){return eo(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,4,5]),[4,p.submit()];case 1:return r.sent(),m.data=m.data||{},m.data.loading=!0,[4,n.revision({filterByTk:u,values:p.values})];case 2:return r.sent(),e.success(t("Operation succeeded")),o(),s(!1),[3,5];case 3:return console.error(r.sent()),[3,5];case 4:return m.data&&(m.data.loading=!1),[7];case 5:return[2]}})})()}}}function ea(){var e,t,o=(0,r.useContext)(l.SchemaComponentContext),c=(0,l.usePlugin)(S.default).useTriggersOptions;return n().createElement(l.SchemaComponentContext.Provider,{value:(e=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){var r;r=o[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},o),t=t={designable:!1},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o.push.apply(o,r)}return o})(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e)},n().createElement(l.SchemaComponent,{schema:w,components:{CollectionProvider:l.CollectionProvider,WorkflowLink:b,ExecutionResourceProvider:m,ExecutionLink:s.a,OpenDrawer:x,ExecutionStatusSelect:C.P,SyncOptionSelect:er,ExecutionStatusColumn:C.r,Tooltip:i.Tooltip,CategoryTabs:U,EnumerationField:J},scope:{useTriggersOptions:c,useWorkflowSyncReaction:en,useSyncAction:ei,useWorkflowFilterActionProps:Y,useRefreshActionProps:P.X,useRevisionAction:ec,TriggerOptionRender:E,ExecutionStatusOptions:S.ExecutionStatusOptions}}))}}}]);