@nocobase/plugin-workflow 0.7.0-alpha.4 → 0.7.0-alpha.56

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 (137) hide show
  1. package/lib/actions/index.js +31 -26
  2. package/{esm/actions/flow_nodes.d.ts → lib/actions/nodes.d.ts} +1 -0
  3. package/lib/actions/nodes.js +321 -0
  4. package/lib/actions/workflows.d.ts +3 -0
  5. package/lib/actions/workflows.js +271 -0
  6. package/lib/calculators/index.js +143 -91
  7. package/lib/collections/executions.js +40 -38
  8. package/lib/collections/flow_nodes.js +60 -72
  9. package/lib/collections/jobs.js +45 -47
  10. package/lib/collections/workflows.js +78 -63
  11. package/lib/constants.js +22 -17
  12. package/lib/index.js +71 -22
  13. package/lib/instructions/calculation.js +34 -29
  14. package/lib/instructions/condition.js +94 -87
  15. package/lib/instructions/create.d.ts +1 -1
  16. package/lib/instructions/create.js +43 -25
  17. package/lib/instructions/destroy.js +42 -25
  18. package/lib/instructions/index.js +46 -25
  19. package/lib/instructions/parallel.js +99 -84
  20. package/lib/instructions/prompt.js +21 -13
  21. package/lib/instructions/query.js +47 -25
  22. package/lib/instructions/update.d.ts +2 -1
  23. package/lib/instructions/update.js +44 -25
  24. package/lib/models/Execution.d.ts +3 -2
  25. package/lib/models/Execution.js +400 -241
  26. package/lib/models/FlowNode.js +18 -5
  27. package/lib/models/Job.js +18 -5
  28. package/lib/models/Workflow.d.ts +3 -1
  29. package/lib/models/Workflow.js +132 -72
  30. package/lib/server.js +93 -66
  31. package/{esm/triggers/model.d.ts → lib/triggers/collection.d.ts} +1 -1
  32. package/lib/triggers/collection.js +125 -0
  33. package/lib/triggers/index.js +25 -11
  34. package/package.json +7 -12
  35. package/esm/actions/flow_nodes.js +0 -139
  36. package/esm/actions/flow_nodes.js.map +0 -1
  37. package/esm/actions/index.d.ts +0 -1
  38. package/esm/actions/index.js +0 -8
  39. package/esm/actions/index.js.map +0 -1
  40. package/esm/calculators/index.d.ts +0 -38
  41. package/esm/calculators/index.js +0 -128
  42. package/esm/calculators/index.js.map +0 -1
  43. package/esm/collections/executions.d.ts +0 -3
  44. package/esm/collections/executions.js +0 -38
  45. package/esm/collections/executions.js.map +0 -1
  46. package/esm/collections/flow_nodes.d.ts +0 -3
  47. package/esm/collections/flow_nodes.js +0 -72
  48. package/esm/collections/flow_nodes.js.map +0 -1
  49. package/esm/collections/jobs.d.ts +0 -3
  50. package/esm/collections/jobs.js +0 -47
  51. package/esm/collections/jobs.js.map +0 -1
  52. package/esm/collections/workflows.d.ts +0 -3
  53. package/esm/collections/workflows.js +0 -63
  54. package/esm/collections/workflows.js.map +0 -1
  55. package/esm/constants.d.ts +0 -17
  56. package/esm/constants.js +0 -18
  57. package/esm/constants.js.map +0 -1
  58. package/esm/index.d.ts +0 -5
  59. package/esm/index.js +0 -6
  60. package/esm/index.js.map +0 -1
  61. package/esm/instructions/calculation.d.ts +0 -8
  62. package/esm/instructions/calculation.js +0 -55
  63. package/esm/instructions/calculation.js.map +0 -1
  64. package/esm/instructions/condition.d.ts +0 -5
  65. package/esm/instructions/condition.js +0 -99
  66. package/esm/instructions/condition.js.map +0 -1
  67. package/esm/instructions/create.d.ts +0 -8
  68. package/esm/instructions/create.js +0 -25
  69. package/esm/instructions/create.js.map +0 -1
  70. package/esm/instructions/destroy.d.ts +0 -8
  71. package/esm/instructions/destroy.js +0 -25
  72. package/esm/instructions/destroy.js.map +0 -1
  73. package/esm/instructions/index.d.ts +0 -15
  74. package/esm/instructions/index.js +0 -20
  75. package/esm/instructions/index.js.map +0 -1
  76. package/esm/instructions/parallel.d.ts +0 -13
  77. package/esm/instructions/parallel.js +0 -88
  78. package/esm/instructions/parallel.js.map +0 -1
  79. package/esm/instructions/prompt.d.ts +0 -7
  80. package/esm/instructions/prompt.js +0 -13
  81. package/esm/instructions/prompt.js.map +0 -1
  82. package/esm/instructions/query.d.ts +0 -8
  83. package/esm/instructions/query.js +0 -25
  84. package/esm/instructions/query.js.map +0 -1
  85. package/esm/instructions/update.d.ts +0 -8
  86. package/esm/instructions/update.js +0 -25
  87. package/esm/instructions/update.js.map +0 -1
  88. package/esm/models/Execution.d.ts +0 -50
  89. package/esm/models/Execution.js +0 -250
  90. package/esm/models/Execution.js.map +0 -1
  91. package/esm/models/FlowNode.d.ts +0 -17
  92. package/esm/models/FlowNode.js +0 -4
  93. package/esm/models/FlowNode.js.map +0 -1
  94. package/esm/models/Job.d.ts +0 -15
  95. package/esm/models/Job.js +0 -4
  96. package/esm/models/Job.js.map +0 -1
  97. package/esm/models/Workflow.d.ts +0 -27
  98. package/esm/models/Workflow.js +0 -72
  99. package/esm/models/Workflow.js.map +0 -1
  100. package/esm/server.d.ts +0 -5
  101. package/esm/server.js +0 -62
  102. package/esm/server.js.map +0 -1
  103. package/esm/triggers/index.d.ts +0 -9
  104. package/esm/triggers/index.js +0 -6
  105. package/esm/triggers/index.js.map +0 -1
  106. package/esm/triggers/model.js +0 -47
  107. package/esm/triggers/model.js.map +0 -1
  108. package/lib/actions/flow_nodes.d.ts +0 -3
  109. package/lib/actions/flow_nodes.js +0 -163
  110. package/lib/actions/flow_nodes.js.map +0 -1
  111. package/lib/actions/index.js.map +0 -1
  112. package/lib/calculators/index.js.map +0 -1
  113. package/lib/collections/executions.js.map +0 -1
  114. package/lib/collections/flow_nodes.js.map +0 -1
  115. package/lib/collections/jobs.js.map +0 -1
  116. package/lib/collections/workflows.js.map +0 -1
  117. package/lib/constants.js.map +0 -1
  118. package/lib/index.js.map +0 -1
  119. package/lib/instructions/calculation.js.map +0 -1
  120. package/lib/instructions/condition.js.map +0 -1
  121. package/lib/instructions/create.js.map +0 -1
  122. package/lib/instructions/destroy.js.map +0 -1
  123. package/lib/instructions/index.js.map +0 -1
  124. package/lib/instructions/parallel.js.map +0 -1
  125. package/lib/instructions/prompt.js.map +0 -1
  126. package/lib/instructions/query.js.map +0 -1
  127. package/lib/instructions/update.js.map +0 -1
  128. package/lib/models/Execution.js.map +0 -1
  129. package/lib/models/FlowNode.js.map +0 -1
  130. package/lib/models/Job.js.map +0 -1
  131. package/lib/models/Workflow.js.map +0 -1
  132. package/lib/server.js.map +0 -1
  133. package/lib/triggers/index.js.map +0 -1
  134. package/lib/triggers/model.d.ts +0 -12
  135. package/lib/triggers/model.js +0 -49
  136. package/lib/triggers/model.js.map +0 -1
  137. package/tsconfig.build.json +0 -9
@@ -1,139 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { Op } from 'sequelize';
11
- import actions, { utils } from '@nocobase/actions';
12
- export function create(context, next) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- return actions.create(context, () => __awaiter(this, void 0, void 0, function* () {
15
- const { body: instance, db } = context;
16
- const repository = utils.getRepositoryFromParams(context);
17
- if (!instance.upstreamId) {
18
- const previousHead = yield repository.findOne({
19
- filter: {
20
- id: {
21
- $ne: instance.id
22
- },
23
- upstreamId: null
24
- }
25
- });
26
- if (previousHead) {
27
- yield previousHead.setUpstream(instance);
28
- yield instance.setDownstream(previousHead);
29
- instance.set('downstream', previousHead);
30
- }
31
- return next();
32
- }
33
- const upstream = yield instance.getUpstream();
34
- if (instance.branchIndex == null) {
35
- const downstream = yield upstream.getDownstream();
36
- if (downstream) {
37
- yield downstream.setUpstream(instance);
38
- yield instance.setDownstream(downstream);
39
- instance.set('downstream', downstream);
40
- }
41
- yield upstream.update({
42
- downstreamId: instance.id
43
- });
44
- upstream.set('downstream', instance);
45
- }
46
- else {
47
- const [downstream] = yield upstream.getBranches({
48
- where: {
49
- id: {
50
- [Op.ne]: instance.id
51
- },
52
- branchIndex: instance.branchIndex
53
- }
54
- });
55
- if (downstream) {
56
- yield downstream.update({
57
- upstreamId: instance.id,
58
- branchIndex: null
59
- });
60
- yield instance.setDownstream(downstream);
61
- instance.set('downstream', downstream);
62
- }
63
- }
64
- instance.set('upstream', upstream);
65
- yield next();
66
- }));
67
- });
68
- }
69
- function searchBranchNodes(nodes, from) {
70
- const branchHeads = nodes
71
- .filter((item) => item.upstreamId === from.id && item.branchIndex != null);
72
- return branchHeads.reduce((flatten, head) => flatten.concat(searchBranchDownstreams(nodes, head)), []);
73
- }
74
- function searchBranchDownstreams(nodes, from) {
75
- let result = [];
76
- for (let search = from; search; search = search.downstream) {
77
- result = [...result, search, ...searchBranchNodes(nodes, search)];
78
- }
79
- return result;
80
- }
81
- export function destroy(context, next) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- const repository = utils.getRepositoryFromParams(context);
84
- const { db } = context;
85
- const { filterByTk } = context.action.params;
86
- context.body = yield db.sequelize.transaction((transaction) => __awaiter(this, void 0, void 0, function* () {
87
- const fields = ['id', 'upstreamId', 'downstreamId', 'branchIndex'];
88
- const instance = yield repository.findOne({
89
- filterByTk,
90
- fields: [...fields, 'workflowId'],
91
- appends: ['upstream', 'downstream'],
92
- transaction
93
- });
94
- const { upstream, downstream } = instance.get();
95
- if (upstream && upstream.downstreamId === instance.id) {
96
- yield upstream.update({
97
- downstreamId: instance.downstreamId
98
- }, { transaction });
99
- }
100
- if (downstream) {
101
- yield downstream.update({
102
- upstreamId: instance.upstreamId,
103
- branchIndex: instance.branchIndex
104
- }, { transaction });
105
- }
106
- const nodes = yield repository.find({
107
- filter: {
108
- workflowId: instance.workflowId
109
- },
110
- fields,
111
- transaction
112
- });
113
- const nodesMap = new Map();
114
- // make map
115
- nodes.forEach(item => {
116
- nodesMap.set(item.id, item);
117
- });
118
- // overwrite
119
- nodesMap.set(instance.id, instance);
120
- // make linked list
121
- nodes.forEach(item => {
122
- if (item.upstreamId) {
123
- item.upstream = nodesMap.get(item.upstreamId);
124
- }
125
- if (item.downstreamId) {
126
- item.downstream = nodesMap.get(item.downstreamId);
127
- }
128
- });
129
- const branchNodes = searchBranchNodes(nodes, instance);
130
- yield repository.destroy({
131
- filterByTk: [instance.id, ...branchNodes.map(item => item.id)],
132
- transaction
133
- });
134
- return instance;
135
- }));
136
- yield next();
137
- });
138
- }
139
- //# sourceMappingURL=flow_nodes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow_nodes.js","sourceRoot":"","sources":["../../src/actions/flow_nodes.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAC/B,OAAO,OAAO,EAAE,EAAW,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,UAAgB,MAAM,CAAC,OAAgB,EAAE,IAAI;;QACjD,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAS,EAAE;YACxC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC;YACvC,MAAM,UAAU,GAAG,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;YAE1D,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;gBACxB,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;oBAC5C,MAAM,EAAE;wBACN,EAAE,EAAE;4BACF,GAAG,EAAE,QAAQ,CAAC,EAAE;yBACjB;wBACD,UAAU,EAAE,IAAI;qBACjB;iBACF,CAAC,CAAC;gBACH,IAAI,YAAY,EAAE;oBAChB,MAAM,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;oBACzC,MAAM,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;oBAC3C,QAAQ,CAAC,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;iBAC1C;gBACD,OAAO,IAAI,E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AAI,CAAC,YAAY,EAAE;oBACrB,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBACnD;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAEvD,MAAM,UAAU,CAAC,OAAO,CAAC;gBACvB,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC9D,WAAW;aACZ,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAA,CAAC,CAAC;QAEH,MAAM,IAAI,EAAE,CAAC;IACf,CAAC;CAAA","sourcesContent":["import { Op } from 'sequelize';\nimport actions, { Context, utils } from '@nocobase/actions';\n\nexport async function create(context: Context, next) {\n return actions.create(context, async () => {\n const { body: instance, db } = context;\n const repository = utils.getRepositoryFromParams(context);\n\n if (!instance.upstreamId) {\n const previousHead = await repository.findOne({\n filter: {\n id: {\n $ne: instance.id\n },\n upstreamId: null\n }\n });\n if (previousHead) {\n await previousHead.setUpstream(instance);\n await instance.setDownstream(previousHead);\n instance.set('downstream', previousHead);\n }\n return next();\n }\n\n const upstream = await instance.getUpstream();\n\n if (instance.branchIndex == null) {\n const downstream = await upstream.getDownstream();\n\n if (downstream) {\n await downstream.setUpstream(instance);\n await instance.setDownstream(downstream);\n instance.set('downstream', downstream);\n }\n\n await upstream.update({\n downstreamId: instance.id\n });\n\n upstream.set('downstream', instance);\n } else {\n const [downstream] = await upstream.getBranches({\n where: {\n id: {\n [Op.ne]: instance.id\n },\n branchIndex: instance.branchIndex\n }\n });\n\n if (downstream) {\n await downstream.update({\n upstreamId: instance.id,\n branchIndex: null\n });\n await instance.setDownstream(downstream);\n instance.set('downstream', downstream);\n }\n }\n\n instance.set('upstream', upstream);\n\n await next();\n });\n}\n\nfunction searchBranchNodes(nodes, from): any[] {\n const branchHeads = nodes\n .filter((item: any) => item.upstreamId === from.id && item.branchIndex != null);\n return branchHeads.reduce((flatten: any[], head) => flatten.concat(searchBranchDownstreams(nodes, head)), []) as any[];\n}\n\nfunction searchBranchDownstreams(nodes, from) {\n let result = [];\n for (let search = from; search; search = search.downstream) {\n result = [...result, search, ...searchBranchNodes(nodes, search)];\n }\n return result;\n}\n\nexport async function destroy(context: Context, next) {\n const repository = utils.getRepositoryFromParams(context);\n const { db } = context;\n const { filterByTk } = context.action.params;\n\n context.body = await db.sequelize.transaction(async transaction => {\n const fields = ['id', 'upstreamId', 'downstreamId', 'branchIndex'];\n const instance = await repository.findOne({\n filterByTk,\n fields: [...fields, 'workflowId'],\n appends: ['upstream', 'downstream'],\n transaction\n });\n const { upstream, downstream } = instance.get();\n\n if (upstream && upstream.downstreamId === instance.id) {\n await upstream.update({\n downstreamId: instance.downstreamId\n }, { transaction });\n }\n\n if (downstream) {\n await downstream.update({\n upstreamId: instance.upstreamId,\n branchIndex: instance.branchIndex\n }, { transaction });\n }\n\n const nodes = await repository.find({\n filter: {\n workflowId: instance.workflowId\n },\n fields,\n transaction\n });\n const nodesMap = new Map();\n // make map\n nodes.forEach(item => {\n nodesMap.set(item.id, item);\n });\n // overwrite\n nodesMap.set(instance.id, instance);\n // make linked list\n nodes.forEach(item => {\n if (item.upstreamId) {\n item.upstream = nodesMap.get(item.upstreamId);\n }\n if (item.downstreamId) {\n item.downstream = nodesMap.get(item.downstreamId);\n }\n });\n\n const branchNodes = searchBranchNodes(nodes, instance);\n\n await repository.destroy({\n filterByTk: [instance.id, ...branchNodes.map(item => item.id)],\n transaction\n });\n\n return instance;\n });\n\n await next();\n}\n"]}
@@ -1 +0,0 @@
1
- export default function (app: any): void;
@@ -1,8 +0,0 @@
1
- import * as flow_nodes from './flow_nodes';
2
- function make(name, mod) {
3
- return Object.keys(mod).reduce((result, key) => (Object.assign(Object.assign({}, result), { [`${name}:${key}`]: mod[key] })), {});
4
- }
5
- export default function (app) {
6
- app.actions(Object.assign({}, make('flow_nodes', flow_nodes)));
7
- }
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,SAAS,IAAI,CAAC,IAAI,EAAE,GAAG;IACrB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,iCAC3C,MAAM,KACT,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,IAC5B,EAAE,EAAE,CAAC,CAAA;AACT,CAAC;AAED,MAAM,CAAC,OAAO,WAAU,GAAG;IACzB,GAAG,CAAC,OAAO,mBACN,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,EACjC,CAAC;AACL,CAAC","sourcesContent":["import * as flow_nodes from './flow_nodes';\n\nfunction make(name, mod) {\n return Object.keys(mod).reduce((result, key) => ({\n ...result,\n [`${name}:${key}`]: mod[key]\n }), {})\n}\n\nexport default function(app) {\n app.actions({\n ...make('flow_nodes', flow_nodes)\n });\n}\n"]}
@@ -1,38 +0,0 @@
1
- import { Registry } from "@nocobase/utils";
2
- import ExecutionModel from '../models/Execution';
3
- import JobModel from '../models/Job';
4
- export declare const calculators: Registry<Function>;
5
- export default calculators;
6
- export declare type OperandType = '$context' | '$input' | '$jobsMapByNodeId' | '$calculation';
7
- export declare type ObjectGetterOptions = {
8
- path?: string;
9
- };
10
- export declare type JobGetterOptions = ObjectGetterOptions & {
11
- nodeId: number;
12
- };
13
- export declare type CalculationOptions = {
14
- calculator: string;
15
- operands: Operand[];
16
- };
17
- export declare type ConstantOperand = {
18
- type?: 'constant';
19
- value: any;
20
- };
21
- export declare type ContextOperand = {
22
- type: '$context';
23
- options: ObjectGetterOptions;
24
- };
25
- export declare type InputOperand = {
26
- type: '$input';
27
- options: ObjectGetterOptions;
28
- };
29
- export declare type JobOperand = {
30
- type: '$jobsMapByNodeId';
31
- options: JobGetterOptions;
32
- };
33
- export declare type Calculation = {
34
- type: '$calculation';
35
- options: CalculationOptions;
36
- };
37
- export declare type Operand = ContextOperand | InputOperand | JobOperand | ConstantOperand | Calculation;
38
- export declare function calculate(operand: Operand, lastJob: JobModel, execution: ExecutionModel): any;
@@ -1,128 +0,0 @@
1
- import { get as getWithPath } from 'lodash';
2
- import { Registry } from "@nocobase/utils";
3
- export const calculators = new Registry();
4
- export default calculators;
5
- // @deprecated
6
- // HACK: if no path provided, return self
7
- // @see https://github.com/lodash/lodash/pull/1270
8
- // TODO(question): should add default value as lodash?
9
- function get(object, path) {
10
- return path == null || !path.length ? object : getWithPath(object, path);
11
- }
12
- // NOTE:
13
- // this method could only be used in executing nodes.
14
- // because type of 'job' need loaded jobs in runtime execution.
15
- // or the execution should be prepared first.
16
- export function calculate(operand, lastJob, execution) {
17
- switch (operand.type) {
18
- // @Deprecated
19
- // from execution context
20
- case '$context':
21
- return get(execution.context, operand.options.path);
22
- // @Deprecated
23
- // from last job (or input job)
24
- case '$input':
25
- return lastJob !== null && lastJob !== void 0 ? lastJob : get(lastJob.result, operand.options.path);
26
- // @Deprecated
27
- // from job in execution
28
- case '$jobsMapByNodeId':
29
- // assume jobs have been fetched from execution before
30
- const job = execution.jobsMapByNodeId[operand.options.nodeId];
31
- return job && get(job, operand.options.path);
32
- case '$calculation':
33
- const fn = calculators.get(operand.options.calculator);
34
- if (!fn) {
35
- throw new Error(`no calculator function registered for "${operand.options.calculator}"`);
36
- }
37
- return fn(...operand.options.operands.map(item => calculate(item, lastJob, execution)));
38
- // constant
39
- default:
40
- return operand.value;
41
- }
42
- }
43
- // built-in functions
44
- function equal(a, b) {
45
- return a === b;
46
- }
47
- function notEqual(a, b) {
48
- return a !== b;
49
- }
50
- function gt(a, b) {
51
- return a > b;
52
- }
53
- function gte(a, b) {
54
- return a >= b;
55
- }
56
- function lt(a, b) {
57
- return a < b;
58
- }
59
- function lte(a, b) {
60
- return a <= b;
61
- }
62
- calculators.register('equal', equal);
63
- calculators.register('notEqual', notEqual);
64
- calculators.register('gt', gt);
65
- calculators.register('gte', gte);
66
- calculators.register('lt', lt);
67
- calculators.register('lte', lte);
68
- calculators.register('===', equal);
69
- calculators.register('!==', notEqual);
70
- calculators.register('>', gt);
71
- calculators.register('>=', gte);
72
- calculators.register('<', lt);
73
- calculators.register('<=', lte);
74
- function add(...args) {
75
- return args.reduce((sum, a) => sum + a, 0);
76
- }
77
- function minus(a, b) {
78
- return a - b;
79
- }
80
- function multipe(...args) {
81
- return args.reduce((result, a) => result * a, 1);
82
- }
83
- function divide(a, b) {
84
- return a / b;
85
- }
86
- function mod(a, b) {
87
- return a % b;
88
- }
89
- calculators.register('add', add);
90
- calculators.register('minus', minus);
91
- calculators.register('multipe', multipe);
92
- calculators.register('divide', divide);
93
- calculators.register('mod', mod);
94
- calculators.register('+', add);
95
- calculators.register('-', minus);
96
- calculators.register('*', multipe);
97
- calculators.register('/', divide);
98
- calculators.register('%', mod);
99
- function includes(a, b) {
100
- return a.includes(b);
101
- }
102
- function notIncludes(a, b) {
103
- return !a.includes(b);
104
- }
105
- function startsWith(a, b) {
106
- return a.startsWith(b);
107
- }
108
- function notStartsWith(a, b) {
109
- return !a.startsWith(b);
110
- }
111
- function endsWith(a, b) {
112
- return a.endsWith(b);
113
- }
114
- function notEndsWith(a, b) {
115
- return !a.endsWith(b);
116
- }
117
- calculators.register('includes', includes);
118
- calculators.register('notIncludes', notIncludes);
119
- calculators.register('startsWith', startsWith);
120
- calculators.register('notStartsWith', notStartsWith);
121
- calculators.register('endsWith', endsWith);
122
- calculators.register('notEndsWith', notEndsWith);
123
- function before(a, b) {
124
- return a < b;
125
- }
126
- calculators.register('now', () => new Date());
127
- // TODO: add more common calculators
128
- //# sourceMappingURL=index.js.map
@@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AE,QAAQ,CAAC,CAAC;AAC3C,WAAW,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AACjD,WAAW,CAAC,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAC/C,WAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AACrD,WAAW,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC3C,WAAW,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAEjD,SAAS,MAAM,CAAC,CAAS,EAAE,CAAS;IAClC,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AAE9C,oCAAoC","sourcesContent":["import { get as getWithPath } from 'lodash';\nimport { Registry } from \"@nocobase/utils\";\n\nimport ExecutionModel from '../models/Execution';\nimport JobModel from '../models/Job';\n\nexport const calculators = new Registry<Function>();\n\nexport default calculators;\n\n\nexport type OperandType = '$context' | '$input' | '$jobsMapByNodeId' | '$calculation';\n\nexport type ObjectGetterOptions = {\n path?: string\n};\n\nexport type JobGetterOptions = ObjectGetterOptions & {\n nodeId: number\n};\n\nexport type CalculationOptions = {\n calculator: string,\n operands: Operand[]\n};\n\nexport type ConstantOperand = {\n type?: 'constant';\n value: any\n};\n\nexport type ContextOperand = {\n type: '$context';\n options: ObjectGetterOptions;\n};\n\nexport type InputOperand = {\n type: '$input';\n options: ObjectGetterOptions;\n};\n\nexport type JobOperand = {\n type: '$jobsMapByNodeId';\n options: JobGetterOptions;\n};\n\nexport type Calculation = {\n type: '$calculation';\n options: CalculationOptions\n};\n\n// TODO(type): union type here is wrong\nexport type Operand = ContextOperand | InputOperand | JobOperand | ConstantOperand | Calculation;\n\n// @deprecated\n// HACK: if no path provided, return self\n// @see https://github.com/lodash/lodash/pull/1270\n// TODO(question): should add default value as lodash?\nfunction get(object, path?: string | Array<string>) {\n return path == null || !path.length ? object : getWithPath(object, path);\n}\n\n// NOTE:\n// this method could only be used in executing nodes.\n// because type of 'job' need loaded jobs in runtime execution.\n// or the execution should be prepared first.\nexport function calculate(operand: Operand, lastJob: JobModel, execution: ExecutionModel) {\n switch (operand.type) {\n // @Deprecated\n // from execution context\n case '$context':\n return get(execution.context, operand.options.path);\n\n // @Deprecated\n // from last job (or input job)\n case '$input':\n return lastJob ?? get(lastJob.result, operand.options.path);\n\n // @Deprecated\n // from job in execution\n case '$jobsMapByNodeId':\n // assume jobs have been fetched from execution before\n const job = execution.jobsMapByNodeId[operand.options.nodeId];\n return job && get(job, operand.options.path);\n\n case '$calculation':\n const fn = calculators.get(operand.options.calculator);\n if (!fn) {\n throw new Error(`no calculator function registered for \"${operand.options.calculator}\"`);\n }\n return fn(...operand.options.operands.map(item => calculate(item, lastJob, execution)));\n\n // constant\n default:\n return operand.value;\n }\n}\n\n\n\n// built-in functions\n\nfunction equal(a, b) {\n return a === b;\n}\n\nfunction notEqual(a, b) {\n return a !== b;\n}\n\nfunction gt(a, b) {\n return a > b;\n}\n\nfunction gte(a, b) {\n return a >= b;\n}\n\nfunction lt(a, b) {\n return a < b;\n}\n\nfunction lte(a, b) {\n return a <= b;\n}\n\ncalculators.register('equal', equal);\ncalculators.register('notEqual', notEqual);\ncalculators.register('gt', gt);\ncalculators.register('gte', gte);\ncalculators.register('lt', lt);\ncalculators.register('lte', lte);\n\ncalculators.register('===', equal);\ncalculators.register('!==', notEqual);\ncalculators.register('>', gt);\ncalculators.register('>=', gte);\ncalculators.register('<', lt);\ncalculators.register('<=', lte);\n\n\n\nfunction add(...args) {\n return args.reduce((sum, a) => sum + a, 0);\n}\n\nfunction minus(a, b) {\n return a - b;\n}\n\nfunction multipe(...args) {\n return args.reduce((result, a) => result * a, 1);\n}\n\nfunction divide(a, b) {\n return a / b;\n}\n\nfunction mod(a, b) {\n return a % b;\n}\n\ncalculators.register('add', add);\ncalculators.register('minus', minus);\ncalculators.register('multipe', multipe);\ncalculators.register('divide', divide);\ncalculators.register('mod', mod);\n\ncalculators.register('+', add);\ncalculators.register('-', minus);\ncalculators.register('*', multipe);\ncalculators.register('/', divide);\ncalculators.register('%', mod);\n\nfunction includes(a, b) {\n return a.includes(b);\n}\n\nfunction notIncludes(a, b) {\n return !a.includes(b);\n}\n\nfunction startsWith(a: string, b: string) {\n return a.startsWith(b);\n}\n\nfunction notStartsWith(a: string, b: string) {\n return !a.startsWith(b);\n}\n\nfunction endsWith(a: string, b: string) {\n return a.endsWith(b);\n}\n\nfunction notEndsWith(a: string, b: string) {\n return !a.endsWith(b);\n}\n\ncalculators.register('includes', includes);\ncalculators.register('notIncludes', notIncludes);\ncalculators.register('startsWith', startsWith);\ncalculators.register('notStartsWith', notStartsWith);\ncalculators.register('endsWith', endsWith);\ncalculators.register('notEndsWith', notEndsWith);\n\nfunction before(a: string, b: string) {\n return a < b;\n}\n\ncalculators.register('now', () => new Date());\n\n// TODO: add more common calculators\n"]}
@@ -1,3 +0,0 @@
1
- import { CollectionOptions } from '@nocobase/database';
2
- declare const _default: CollectionOptions;
3
- export default _default;
@@ -1,38 +0,0 @@
1
- export default {
2
- name: 'executions',
3
- model: 'ExecutionModel',
4
- title: '执行流程',
5
- fields: [
6
- {
7
- interface: 'linkTo',
8
- type: 'belongsTo',
9
- name: 'workflow',
10
- title: '所属工作流'
11
- },
12
- {
13
- type: 'boolean',
14
- name: 'useTransaction',
15
- title: '使用事务',
16
- defaultValue: false
17
- },
18
- {
19
- interface: 'linkTo',
20
- type: 'hasMany',
21
- name: 'jobs',
22
- title: '流程记录'
23
- },
24
- {
25
- interface: 'json',
26
- type: 'jsonb',
27
- name: 'context',
28
- title: '上下文数据'
29
- },
30
- {
31
- interface: 'select',
32
- type: 'integer',
33
- name: 'status',
34
- title: '状态'
35
- }
36
- ]
37
- };
38
- //# sourceMappingURL=executions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executions.js","sourceRoot":"","sources":["../../src/collections/executions.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,gBAAgB;IACvB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE;QACN;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,OAAO;SACf;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,MAAM;YACb,YAAY,EAAE,KAAK;SACpB;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,OAAO;SACf;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,IAAI;SACZ;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'executions',\n model: 'ExecutionModel',\n title: '执行流程',\n fields: [\n {\n interface: 'linkTo',\n type: 'belongsTo',\n name: 'workflow',\n title: '所属工作流'\n },\n {\n type: 'boolean',\n name: 'useTransaction',\n title: '使用事务',\n defaultValue: false\n },\n {\n interface: 'linkTo',\n type: 'hasMany',\n name: 'jobs',\n title: '流程记录'\n },\n {\n interface: 'json',\n type: 'jsonb',\n name: 'context',\n title: '上下文数据'\n },\n {\n interface: 'select',\n type: 'integer',\n name: 'status',\n title: '状态'\n }\n ]\n} as CollectionOptions;\n"]}
@@ -1,3 +0,0 @@
1
- import { CollectionOptions } from '@nocobase/database';
2
- declare const _default: CollectionOptions;
3
- export default _default;
@@ -1,72 +0,0 @@
1
- export default {
2
- name: 'flow_nodes',
3
- // model: 'FlowNodeModel',
4
- title: 'Workflow Nodes',
5
- fields: [
6
- {
7
- interface: 'string',
8
- type: 'string',
9
- name: 'title',
10
- title: '名称'
11
- },
12
- // which workflow belongs to
13
- {
14
- interface: 'linkTo',
15
- name: 'workflow',
16
- type: 'belongsTo',
17
- },
18
- {
19
- interface: 'linkTo',
20
- name: 'upstream',
21
- type: 'belongsTo',
22
- target: 'flow_nodes'
23
- },
24
- {
25
- interface: 'linkTo',
26
- name: 'branches',
27
- type: 'hasMany',
28
- target: 'flow_nodes',
29
- sourceKey: 'id',
30
- foreignKey: 'upstreamId',
31
- },
32
- // only works when upstream node is branching type, such as condition and parallel.
33
- // put here because the design of flow-links model is not really necessary for now.
34
- // or it should be put into flow-links model.
35
- {
36
- interface: 'select',
37
- name: 'branchIndex',
38
- type: 'integer',
39
- title: 'branch index'
40
- },
41
- // for reasons:
42
- // 1. redirect type node to solve cycle flow.
43
- // 2. recognize as real next node after branches.
44
- {
45
- interface: 'linkTo',
46
- name: 'downstream',
47
- type: 'belongsTo',
48
- target: 'flow_nodes'
49
- },
50
- {
51
- interface: 'select',
52
- type: 'string',
53
- name: 'type',
54
- title: '类型',
55
- // TODO: data for test only now
56
- dataSource: [
57
- { label: '数据处理', value: 'data' },
58
- { label: '数据查询', value: 'query' },
59
- { label: '等待人工输入', value: 'prompt' },
60
- { label: '条件判断', value: 'condition' },
61
- ]
62
- },
63
- {
64
- interface: 'json',
65
- type: 'jsonb',
66
- name: 'config',
67
- title: '配置',
68
- defaultValue: {}
69
- }
70
- ]
71
- };
72
- //# sourceMappingURL=flow_nodes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow_nodes.js","sourceRoot":"","sources":["../../src/collections/flow_nodes.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,IAAI,EAAE,YAAY;IAClB,0BAA0B;IAC1B,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE;QACN;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,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","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'flow_nodes',\n // model: 'FlowNodeModel',\n title: 'Workflow Nodes',\n fields: [\n {\n interface: 'string',\n type: 'string',\n name: 'title',\n title: '名称'\n },\n // which workflow belongs to\n {\n interface: 'linkTo',\n name: 'workflow',\n type: 'belongsTo',\n },\n {\n interface: 'linkTo',\n name: 'upstream',\n type: 'belongsTo',\n target: 'flow_nodes'\n },\n {\n interface: 'linkTo',\n name: 'branches',\n type: 'hasMany',\n target: 'flow_nodes',\n sourceKey: 'id',\n foreignKey: 'upstreamId',\n },\n // only works when upstream node is branching type, such as condition and parallel.\n // put here because the design of flow-links model is not really necessary for now.\n // or it should be put into flow-links model.\n {\n interface: 'select',\n name: 'branchIndex',\n type: 'integer',\n title: 'branch index'\n },\n // for reasons:\n // 1. redirect type node to solve cycle flow.\n // 2. recognize as real next node after branches.\n {\n interface: 'linkTo',\n name: 'downstream',\n type: 'belongsTo',\n target: 'flow_nodes'\n },\n {\n interface: 'select',\n type: 'string',\n name: 'type',\n title: '类型',\n // TODO: data for test only now\n dataSource: [\n { label: '数据处理', value: 'data' },\n { label: '数据查询', value: 'query' },\n { label: '等待人工输入', value: 'prompt' },\n { label: '条件判断', value: 'condition' },\n ]\n },\n {\n interface: 'json',\n type: 'jsonb',\n name: 'config',\n title: '配置',\n defaultValue: {}\n }\n ]\n} as CollectionOptions;\n"]}
@@ -1,3 +0,0 @@
1
- import { CollectionOptions } from '@nocobase/database';
2
- declare const _default: CollectionOptions;
3
- export default _default;
@@ -1,47 +0,0 @@
1
- export default {
2
- name: 'jobs',
3
- title: '流程记录',
4
- fields: [
5
- {
6
- interface: 'linkTo',
7
- type: 'belongsTo',
8
- name: 'execution',
9
- title: '所属流程'
10
- },
11
- {
12
- interface: 'linkTo',
13
- type: 'belongsTo',
14
- name: 'node',
15
- target: 'flow_nodes',
16
- title: '所属节点'
17
- },
18
- {
19
- interface: 'linkTo',
20
- type: 'belongsTo',
21
- name: 'upstream',
22
- target: 'jobs',
23
- title: '上游记录'
24
- },
25
- // pending / resolved / rejected
26
- {
27
- interface: 'status',
28
- type: 'integer',
29
- name: 'status',
30
- title: '处理状态'
31
- },
32
- {
33
- interface: 'json',
34
- type: 'jsonb',
35
- name: 'result',
36
- title: '处理结果'
37
- },
38
- // TODO: possibly need node snapshot in case if node has been changed
39
- // {
40
- // interface: 'json',
41
- // type: 'jsonb',
42
- // name: 'nodeSnapshot',
43
- // title: 'node snapshot'
44
- // }
45
- ]
46
- };
47
- //# sourceMappingURL=jobs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/collections/jobs.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,MAAM;IACb,MAAM,EAAE;QACN;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,YAAY;YACpB,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,MAAM;SACd;QACD,gCAAgC;QAChC;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;SACd;QACD,qEAAqE;QACrE,IAAI;QACJ,uBAAuB;QACvB,mBAAmB;QACnB,0BAA0B;QAC1B,2BAA2B;QAC3B,IAAI;KACL;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'jobs',\n title: '流程记录',\n fields: [\n {\n interface: 'linkTo',\n type: 'belongsTo',\n name: 'execution',\n title: '所属流程'\n },\n {\n interface: 'linkTo',\n type: 'belongsTo',\n name: 'node',\n target: 'flow_nodes',\n title: '所属节点'\n },\n {\n interface: 'linkTo',\n type: 'belongsTo',\n name: 'upstream',\n target: 'jobs',\n title: '上游记录'\n },\n // pending / resolved / rejected\n {\n interface: 'status',\n type: 'integer',\n name: 'status',\n title: '处理状态'\n },\n {\n interface: 'json',\n type: 'jsonb',\n name: 'result',\n title: '处理结果'\n },\n // TODO: possibly need node snapshot in case if node has been changed\n // {\n // interface: 'json',\n // type: 'jsonb',\n // name: 'nodeSnapshot',\n // title: 'node snapshot'\n // }\n ]\n} as CollectionOptions;\n"]}
@@ -1,3 +0,0 @@
1
- import { CollectionOptions } from '@nocobase/database';
2
- declare const _default: CollectionOptions;
3
- export default _default;
@@ -1,63 +0,0 @@
1
- export default {
2
- name: 'workflows',
3
- model: 'WorkflowModel',
4
- title: '自动化',
5
- fields: [
6
- {
7
- interface: 'string',
8
- type: 'string',
9
- name: 'title',
10
- title: '自动化名称',
11
- required: true
12
- },
13
- {
14
- interface: 'boolean',
15
- type: 'boolean',
16
- name: 'enabled',
17
- title: '启用'
18
- },
19
- {
20
- interface: 'textarea',
21
- type: 'text',
22
- name: 'description',
23
- title: '描述'
24
- },
25
- {
26
- interface: 'select',
27
- type: 'string',
28
- title: '触发方式',
29
- name: 'type',
30
- required: true
31
- },
32
- {
33
- interface: 'json',
34
- type: 'jsonb',
35
- title: '触发配置',
36
- name: 'config',
37
- required: true,
38
- defaultValue: {}
39
- },
40
- {
41
- interface: 'boolean',
42
- type: 'boolean',
43
- title: '使用事务',
44
- name: 'useTransaction',
45
- defaultValue: true
46
- },
47
- {
48
- interface: 'linkTo',
49
- type: 'hasMany',
50
- name: 'nodes',
51
- target: 'flow_nodes',
52
- title: '流程节点'
53
- },
54
- {
55
- interface: 'linkTo',
56
- type: 'hasMany',
57
- name: 'executions',
58
- target: 'executions',
59
- title: '触发执行'
60
- }
61
- ]
62
- };
63
- //# sourceMappingURL=workflows.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../src/collections/workflows.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE;QACN;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,IAAI;SACf;QACD;YACE,SAAS,EAAE,SAAS;YACpB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,IAAI;SACZ;QACD;YACE,SAAS,EAAE,UAAU;YACrB,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,aAAa;YACnB,KAAK,EAAE,IAAI;SACZ;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;SACf;QACD;YACE,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,EAAE;SACjB;QACD;YACE,SAAS,EAAE,SAAS;YACpB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,gBAAgB;YACtB,YAAY,EAAE,IAAI;SACnB;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,YAAY;YACpB,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,YAAY;YACpB,KAAK,EAAE,MAAM;SACd;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'workflows',\n model: 'WorkflowModel',\n title: '自动化',\n fields: [\n {\n interface: 'string',\n type: 'string',\n name: 'title',\n title: '自动化名称',\n required: true\n },\n {\n interface: 'boolean',\n type: 'boolean',\n name: 'enabled',\n title: '启用'\n },\n {\n interface: 'textarea',\n type: 'text',\n name: 'description',\n title: '描述'\n },\n {\n interface: 'select',\n type: 'string',\n title: '触发方式',\n name: 'type',\n required: true\n },\n {\n interface: 'json',\n type: 'jsonb',\n title: '触发配置',\n name: 'config',\n required: true,\n defaultValue: {}\n },\n {\n interface: 'boolean',\n type: 'boolean',\n title: '使用事务',\n name: 'useTransaction',\n defaultValue: true\n },\n {\n interface: 'linkTo',\n type: 'hasMany',\n name: 'nodes',\n target: 'flow_nodes',\n title: '流程节点'\n },\n {\n interface: 'linkTo',\n type: 'hasMany',\n name: 'executions',\n target: 'executions',\n title: '触发执行'\n }\n ]\n} as CollectionOptions;\n"]}