@nocobase/plugin-workflow 0.7.0-alpha.0

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 (153) hide show
  1. package/LICENSE +201 -0
  2. package/esm/actions/flow_nodes.d.ts +3 -0
  3. package/esm/actions/flow_nodes.js +139 -0
  4. package/esm/actions/flow_nodes.js.map +1 -0
  5. package/esm/actions/index.d.ts +1 -0
  6. package/esm/actions/index.js +8 -0
  7. package/esm/actions/index.js.map +1 -0
  8. package/esm/calculators/index.d.ts +38 -0
  9. package/esm/calculators/index.js +128 -0
  10. package/esm/calculators/index.js.map +1 -0
  11. package/esm/collections/executions.d.ts +3 -0
  12. package/esm/collections/executions.js +38 -0
  13. package/esm/collections/executions.js.map +1 -0
  14. package/esm/collections/flow_nodes.d.ts +3 -0
  15. package/esm/collections/flow_nodes.js +72 -0
  16. package/esm/collections/flow_nodes.js.map +1 -0
  17. package/esm/collections/jobs.d.ts +3 -0
  18. package/esm/collections/jobs.js +47 -0
  19. package/esm/collections/jobs.js.map +1 -0
  20. package/esm/collections/workflows.d.ts +3 -0
  21. package/esm/collections/workflows.js +63 -0
  22. package/esm/collections/workflows.js.map +1 -0
  23. package/esm/constants.d.ts +17 -0
  24. package/esm/constants.js +18 -0
  25. package/esm/constants.js.map +1 -0
  26. package/esm/index.d.ts +5 -0
  27. package/esm/index.js +6 -0
  28. package/esm/index.js.map +1 -0
  29. package/esm/instructions/calculation.d.ts +8 -0
  30. package/esm/instructions/calculation.js +55 -0
  31. package/esm/instructions/calculation.js.map +1 -0
  32. package/esm/instructions/condition.d.ts +5 -0
  33. package/esm/instructions/condition.js +99 -0
  34. package/esm/instructions/condition.js.map +1 -0
  35. package/esm/instructions/create.d.ts +8 -0
  36. package/esm/instructions/create.js +25 -0
  37. package/esm/instructions/create.js.map +1 -0
  38. package/esm/instructions/destroy.d.ts +8 -0
  39. package/esm/instructions/destroy.js +25 -0
  40. package/esm/instructions/destroy.js.map +1 -0
  41. package/esm/instructions/index.d.ts +15 -0
  42. package/esm/instructions/index.js +20 -0
  43. package/esm/instructions/index.js.map +1 -0
  44. package/esm/instructions/parallel.d.ts +13 -0
  45. package/esm/instructions/parallel.js +88 -0
  46. package/esm/instructions/parallel.js.map +1 -0
  47. package/esm/instructions/prompt.d.ts +7 -0
  48. package/esm/instructions/prompt.js +13 -0
  49. package/esm/instructions/prompt.js.map +1 -0
  50. package/esm/instructions/query.d.ts +8 -0
  51. package/esm/instructions/query.js +25 -0
  52. package/esm/instructions/query.js.map +1 -0
  53. package/esm/instructions/update.d.ts +8 -0
  54. package/esm/instructions/update.js +25 -0
  55. package/esm/instructions/update.js.map +1 -0
  56. package/esm/models/Execution.d.ts +50 -0
  57. package/esm/models/Execution.js +250 -0
  58. package/esm/models/Execution.js.map +1 -0
  59. package/esm/models/FlowNode.d.ts +17 -0
  60. package/esm/models/FlowNode.js +4 -0
  61. package/esm/models/FlowNode.js.map +1 -0
  62. package/esm/models/Job.d.ts +15 -0
  63. package/esm/models/Job.js +4 -0
  64. package/esm/models/Job.js.map +1 -0
  65. package/esm/models/Workflow.d.ts +27 -0
  66. package/esm/models/Workflow.js +72 -0
  67. package/esm/models/Workflow.js.map +1 -0
  68. package/esm/server.d.ts +5 -0
  69. package/esm/server.js +62 -0
  70. package/esm/server.js.map +1 -0
  71. package/esm/triggers/index.d.ts +9 -0
  72. package/esm/triggers/index.js +6 -0
  73. package/esm/triggers/index.js.map +1 -0
  74. package/esm/triggers/model.d.ts +12 -0
  75. package/esm/triggers/model.js +47 -0
  76. package/esm/triggers/model.js.map +1 -0
  77. package/lib/actions/flow_nodes.d.ts +3 -0
  78. package/lib/actions/flow_nodes.js +163 -0
  79. package/lib/actions/flow_nodes.js.map +1 -0
  80. package/lib/actions/index.d.ts +1 -0
  81. package/lib/actions/index.js +30 -0
  82. package/lib/actions/index.js.map +1 -0
  83. package/lib/calculators/index.d.ts +38 -0
  84. package/lib/calculators/index.js +132 -0
  85. package/lib/calculators/index.js.map +1 -0
  86. package/lib/collections/executions.d.ts +3 -0
  87. package/lib/collections/executions.js +40 -0
  88. package/lib/collections/executions.js.map +1 -0
  89. package/lib/collections/flow_nodes.d.ts +3 -0
  90. package/lib/collections/flow_nodes.js +74 -0
  91. package/lib/collections/flow_nodes.js.map +1 -0
  92. package/lib/collections/jobs.d.ts +3 -0
  93. package/lib/collections/jobs.js +49 -0
  94. package/lib/collections/jobs.js.map +1 -0
  95. package/lib/collections/workflows.d.ts +3 -0
  96. package/lib/collections/workflows.js +65 -0
  97. package/lib/collections/workflows.js.map +1 -0
  98. package/lib/constants.d.ts +17 -0
  99. package/lib/constants.js +21 -0
  100. package/lib/constants.js.map +1 -0
  101. package/lib/index.d.ts +5 -0
  102. package/lib/index.js +23 -0
  103. package/lib/index.js.map +1 -0
  104. package/lib/instructions/calculation.d.ts +8 -0
  105. package/lib/instructions/calculation.js +57 -0
  106. package/lib/instructions/calculation.js.map +1 -0
  107. package/lib/instructions/condition.d.ts +5 -0
  108. package/lib/instructions/condition.js +120 -0
  109. package/lib/instructions/condition.js.map +1 -0
  110. package/lib/instructions/create.d.ts +8 -0
  111. package/lib/instructions/create.js +27 -0
  112. package/lib/instructions/create.js.map +1 -0
  113. package/lib/instructions/destroy.d.ts +8 -0
  114. package/lib/instructions/destroy.js +27 -0
  115. package/lib/instructions/destroy.js.map +1 -0
  116. package/lib/instructions/index.d.ts +15 -0
  117. package/lib/instructions/index.js +26 -0
  118. package/lib/instructions/index.js.map +1 -0
  119. package/lib/instructions/parallel.d.ts +13 -0
  120. package/lib/instructions/parallel.js +91 -0
  121. package/lib/instructions/parallel.js.map +1 -0
  122. package/lib/instructions/prompt.d.ts +7 -0
  123. package/lib/instructions/prompt.js +15 -0
  124. package/lib/instructions/prompt.js.map +1 -0
  125. package/lib/instructions/query.d.ts +8 -0
  126. package/lib/instructions/query.js +27 -0
  127. package/lib/instructions/query.js.map +1 -0
  128. package/lib/instructions/update.d.ts +8 -0
  129. package/lib/instructions/update.js +27 -0
  130. package/lib/instructions/update.js.map +1 -0
  131. package/lib/models/Execution.d.ts +50 -0
  132. package/lib/models/Execution.js +256 -0
  133. package/lib/models/Execution.js.map +1 -0
  134. package/lib/models/FlowNode.d.ts +17 -0
  135. package/lib/models/FlowNode.js +7 -0
  136. package/lib/models/FlowNode.js.map +1 -0
  137. package/lib/models/Job.d.ts +15 -0
  138. package/lib/models/Job.js +7 -0
  139. package/lib/models/Job.js.map +1 -0
  140. package/lib/models/Workflow.d.ts +27 -0
  141. package/lib/models/Workflow.js +78 -0
  142. package/lib/models/Workflow.js.map +1 -0
  143. package/lib/server.d.ts +5 -0
  144. package/lib/server.js +68 -0
  145. package/lib/server.js.map +1 -0
  146. package/lib/triggers/index.d.ts +9 -0
  147. package/lib/triggers/index.js +12 -0
  148. package/lib/triggers/index.js.map +1 -0
  149. package/lib/triggers/model.d.ts +12 -0
  150. package/lib/triggers/model.js +49 -0
  151. package/lib/triggers/model.js.map +1 -0
  152. package/package.json +28 -0
  153. package/tsconfig.build.json +9 -0
@@ -0,0 +1,72 @@
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
@@ -0,0 +1 @@
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,EAAE,OAAO;YACb,KAAK,EAAE,IAAI;SACZ;QACD,4BAA4B;QAC5B;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,WAAW;SAClB;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,YAAY;SACrB;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,YAAY;YACpB,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,YAAY;SACzB;QACD,mFAAmF;QACnF,mFAAmF;QACnF,6CAA6C;QAC7C;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,cAAc;SACtB;QACD,eAAe;QACf,6CAA6C;QAC7C,iDAAiD;QACjD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,YAAY;SACrB;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,IAAI;YACX,+BAA+B;YAC/B,UAAU,EAAE;gBACV,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;gBAChC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;gBACjC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;gBACpC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE;aACtC;SACF;QACD;YACE,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,EAAE;SACjB;KACF;CACmB,CAAC","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"]}
@@ -0,0 +1,3 @@
1
+ import { CollectionOptions } from '@nocobase/database';
2
+ declare const _default: CollectionOptions;
3
+ export default _default;
@@ -0,0 +1,47 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,3 @@
1
+ import { CollectionOptions } from '@nocobase/database';
2
+ declare const _default: CollectionOptions;
3
+ export default _default;
@@ -0,0 +1,63 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,17 @@
1
+ export declare const EXECUTION_STATUS: {
2
+ STARTED: number;
3
+ RESOLVED: number;
4
+ REJECTED: number;
5
+ CANCELLED: number;
6
+ };
7
+ export declare const JOB_STATUS: {
8
+ PENDING: number;
9
+ RESOLVED: number;
10
+ REJECTED: number;
11
+ CANCELLED: number;
12
+ };
13
+ export declare const BRANCH_INDEX: {
14
+ DEFAULT: any;
15
+ ON_TRUE: number;
16
+ ON_FALSE: number;
17
+ };
@@ -0,0 +1,18 @@
1
+ export const EXECUTION_STATUS = {
2
+ STARTED: 0,
3
+ RESOLVED: 1,
4
+ REJECTED: -1,
5
+ CANCELLED: -2
6
+ };
7
+ export const JOB_STATUS = {
8
+ PENDING: 0,
9
+ RESOLVED: 1,
10
+ REJECTED: -1,
11
+ CANCELLED: -2
12
+ };
13
+ export const BRANCH_INDEX = {
14
+ DEFAULT: null,
15
+ ON_TRUE: 1,
16
+ ON_FALSE: 0
17
+ };
18
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC,CAAC;IACZ,SAAS,EAAE,CAAC,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC,CAAC;IACZ,SAAS,EAAE,CAAC,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;CACZ,CAAC","sourcesContent":["export const EXECUTION_STATUS = {\n STARTED: 0,\n RESOLVED: 1,\n REJECTED: -1,\n CANCELLED: -2\n};\n\nexport const JOB_STATUS = {\n PENDING: 0,\n RESOLVED: 1,\n REJECTED: -1,\n CANCELLED: -2\n};\n\nexport const BRANCH_INDEX = {\n DEFAULT: null,\n ON_TRUE: 1,\n ON_FALSE: 0\n};\n"]}
package/esm/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './constants';
2
+ export * from './calculators';
3
+ export * from './triggers';
4
+ export * from './instructions';
5
+ export { default } from './server';
package/esm/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from './constants';
2
+ export * from './calculators';
3
+ export * from './triggers';
4
+ export * from './instructions';
5
+ export { default } from './server';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export * from './constants';\nexport * from './calculators';\nexport * from './triggers';\nexport * from './instructions';\n\nexport { default } from './server';\n"]}
@@ -0,0 +1,8 @@
1
+ import FlowNodeModel from "../models/FlowNode";
2
+ declare const _default: {
3
+ run(this: FlowNodeModel, prevJob: any, execution: any): Promise<{
4
+ result: any;
5
+ status: number;
6
+ }>;
7
+ };
8
+ export default _default;
@@ -0,0 +1,55 @@
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 { JOB_STATUS } from "../constants";
11
+ import { calculate } from "../calculators";
12
+ // @calculation: {
13
+ // calculator: 'concat',
14
+ // operands: [
15
+ // {
16
+ // type: 'calculation',
17
+ // options: {
18
+ // calculator: 'add',
19
+ // operands: [{ value: 1 }, { value: 2 }]
20
+ // }
21
+ // },
22
+ // {
23
+ // type: 'constant',
24
+ // value: '{{$context.data.title}}'
25
+ // },
26
+ // {
27
+ // type: 'context',
28
+ // options: {
29
+ // path: 'data.title'
30
+ // }
31
+ // },
32
+ // {
33
+ // type: 'constant',
34
+ // value: 1
35
+ // }
36
+ // ]
37
+ // }
38
+ export default {
39
+ run(prevJob, execution) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const { calculation } = this.config || {};
42
+ const result = calculation
43
+ ? calculate({
44
+ type: '$calculation',
45
+ options: execution.getParsedValue(calculation)
46
+ }, prevJob, execution)
47
+ : null;
48
+ return {
49
+ result,
50
+ status: JOB_STATUS.RESOLVED
51
+ };
52
+ });
53
+ }
54
+ };
55
+ //# sourceMappingURL=calculation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculation.js","sourceRoot":"","sources":["../../src/instructions/calculation.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,kBAAkB;AAClB,0BAA0B;AAC1B,gBAAgB;AAChB,QAAQ;AACR,6BAA6B;AAC7B,mBAAmB;AACnB,6BAA6B;AAC7B,iDAAiD;AACjD,UAAU;AACV,SAAS;AACT,QAAQ;AACR,0BAA0B;AAC1B,yCAAyC;AACzC,SAAS;AACT,QAAQ;AACR,yBAAyB;AACzB,mBAAmB;AACnB,6BAA6B;AAC7B,UAAU;AACV,SAAS;AACT,QAAQ;AACR,0BAA0B;AAC1B,iBAAiB;AACjB,QAAQ;AACR,MAAM;AACN,IAAI;AAEJ,eAAe;IACP,GAAG,CAAsB,OAAO,EAAE,SAAS;;YAC/C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;YAE1C,MAAM,MAAM,GAAG,WAAW;gBACxB,CAAC,CAAC,SAAS,CAAC;oBACV,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,WAAW,CAAC;iBAC/C,EAAE,OAAO,EAAE,SAAS,CAAC;gBACtB,CAAC,CAAC,IAAI,CAAC;YAET,OAAO;gBACL,MAAM;gBACN,MAAM,EAAE,UAAU,CAAC,QAAQ;aAC5B,CAAC;QACJ,CAAC;KAAA;CACF,CAAA","sourcesContent":["import { JOB_STATUS } from \"../constants\";\nimport FlowNodeModel from \"../models/FlowNode\";\nimport { calculate } from \"../calculators\";\n\n// @calculation: {\n// calculator: 'concat',\n// operands: [\n// {\n// type: 'calculation',\n// options: {\n// calculator: 'add',\n// operands: [{ value: 1 }, { value: 2 }]\n// }\n// },\n// {\n// type: 'constant',\n// value: '{{$context.data.title}}'\n// },\n// {\n// type: 'context',\n// options: {\n// path: 'data.title'\n// }\n// },\n// {\n// type: 'constant',\n// value: 1\n// }\n// ]\n// }\n\nexport default {\n async run(this: FlowNodeModel, prevJob, execution) {\n const { calculation } = this.config || {};\n\n const result = calculation\n ? calculate({\n type: '$calculation',\n options: execution.getParsedValue(calculation)\n }, prevJob, execution)\n : null;\n\n return {\n result,\n status: JOB_STATUS.RESOLVED\n };\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ run(this: any, prevJob: any, execution: any): Promise<any>;
3
+ resume(this: any, branchJob: any, execution: any): Promise<any>;
4
+ };
5
+ export default _default;
@@ -0,0 +1,99 @@
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 calculators, { calculate } from "../calculators";
11
+ import { JOB_STATUS } from "../constants";
12
+ // @calculation: {
13
+ // not: false,
14
+ // group: {
15
+ // type: 'and',
16
+ // calculations: [
17
+ // {
18
+ // calculator: 'time.equal',
19
+ // operands: [{ value: '{{$context.time}}' }, { value: '{{$fn.now}}' }]
20
+ // },
21
+ // {
22
+ // calculator: 'value.equal',
23
+ // operands: [{ value: '{{$jobsMapByNodeId.213}}' }, { value: 1 }]
24
+ // },
25
+ // {
26
+ // group: {
27
+ // type: 'or',
28
+ // calculations: [
29
+ // {
30
+ // calculator: 'value.equal',
31
+ // operands: [{ value: '{{$jobsMapByNodeId.213}}' }, { value: 1 }]
32
+ // }
33
+ // ]
34
+ // }
35
+ // }
36
+ // ]
37
+ // }
38
+ // }
39
+ function logicCalculate(calculation, input, execution) {
40
+ if (!calculation) {
41
+ return true;
42
+ }
43
+ const { not, group } = calculation;
44
+ let result;
45
+ if (group) {
46
+ const method = group.type === 'and' ? 'every' : 'some';
47
+ result = group.calculations[method](item => logicCalculate(item, input, execution));
48
+ }
49
+ else {
50
+ const args = calculation.operands.map(operand => calculate(operand, input, execution));
51
+ const fn = calculators.get(calculation.calculator);
52
+ if (!fn) {
53
+ throw new Error(`no calculator function registered for "${calculation.calculator}"`);
54
+ }
55
+ result = fn(...args);
56
+ }
57
+ return not ? !result : result;
58
+ }
59
+ export default {
60
+ run(prevJob, execution) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ // TODO(optimize): loading of jobs could be reduced and turned into incrementally in execution
63
+ // const jobs = await execution.getJobs();
64
+ const { calculation, rejectOnFalse } = this.config || {};
65
+ const result = logicCalculate(calculation, prevJob, execution);
66
+ if (!result && rejectOnFalse) {
67
+ return {
68
+ status: JOB_STATUS.REJECTED,
69
+ result
70
+ };
71
+ }
72
+ const job = {
73
+ status: JOB_STATUS.RESOLVED,
74
+ result,
75
+ // TODO(optimize): try unify the building of job
76
+ nodeId: this.id,
77
+ upstreamId: prevJob && prevJob.id || null
78
+ };
79
+ const branchNode = execution.nodes
80
+ .find(item => item.upstream === this && Boolean(item.branchIndex) === result);
81
+ if (!branchNode) {
82
+ return job;
83
+ }
84
+ const savedJob = yield execution.saveJob(job);
85
+ return execution.run(branchNode, savedJob);
86
+ });
87
+ },
88
+ resume(branchJob, execution) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ if (branchJob.status === JOB_STATUS.RESOLVED) {
91
+ // return to continue this.downstream
92
+ return branchJob;
93
+ }
94
+ // pass control to upper scope by ending current scope
95
+ return execution.end(this, branchJob);
96
+ });
97
+ }
98
+ };
99
+ //# sourceMappingURL=condition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition.js","sourceRoot":"","sources":["../../src/instructions/condition.ts"],"names":[],"mappings":"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","sourcesContent":["import calculators, { calculate, Operand } from \"../calculators\";\nimport { JOB_STATUS } from \"../constants\";\n\ntype BaseCalculation = {\n not?: boolean;\n};\n\ntype SingleCalculation = BaseCalculation & {\n calculation: string;\n operands?: Operand[];\n};\n\ntype GroupCalculationOptions = {\n type: 'and' | 'or';\n calculations: Calculation[]\n};\n\ntype GroupCalculation = BaseCalculation & {\n group: GroupCalculationOptions\n};\n\n// TODO(type)\ntype Calculation = SingleCalculation | GroupCalculation;\n\n// @calculation: {\n// not: false,\n// group: {\n// type: 'and',\n// calculations: [\n// {\n// calculator: 'time.equal',\n// operands: [{ value: '{{$context.time}}' }, { value: '{{$fn.now}}' }]\n// },\n// {\n// calculator: 'value.equal',\n// operands: [{ value: '{{$jobsMapByNodeId.213}}' }, { value: 1 }]\n// },\n// {\n// group: {\n// type: 'or',\n// calculations: [\n// {\n// calculator: 'value.equal',\n// operands: [{ value: '{{$jobsMapByNodeId.213}}' }, { value: 1 }]\n// }\n// ]\n// }\n// }\n// ]\n// }\n// }\nfunction logicCalculate(calculation, input, execution) {\n if (!calculation) {\n return true;\n }\n\n const { not, group } = calculation;\n let result;\n if (group) {\n const method = group.type === 'and' ? 'every' : 'some';\n result = group.calculations[method](item => logicCalculate(item, input, execution));\n } else {\n const args = calculation.operands.map(operand => calculate(operand, input, execution));\n const fn = calculators.get(calculation.calculator);\n if (!fn) {\n throw new Error(`no calculator function registered for \"${calculation.calculator}\"`);\n }\n result = fn(...args);\n }\n\n return not ? !result : result;\n}\n\n\nexport default {\n async run(this, prevJob, execution) {\n // TODO(optimize): loading of jobs could be reduced and turned into incrementally in execution\n // const jobs = await execution.getJobs();\n const { calculation, rejectOnFalse } = this.config || {};\n const result = logicCalculate(calculation, prevJob, execution);\n\n if (!result && rejectOnFalse) {\n return {\n status: JOB_STATUS.REJECTED,\n result\n };\n }\n\n const job = {\n status: JOB_STATUS.RESOLVED,\n result,\n // TODO(optimize): try unify the building of job\n nodeId: this.id,\n upstreamId: prevJob && prevJob.id || null\n };\n\n const branchNode = execution.nodes\n .find(item => item.upstream === this && Boolean(item.branchIndex) === result);\n\n if (!branchNode) {\n return job;\n }\n\n const savedJob = await execution.saveJob(job);\n\n return execution.run(branchNode, savedJob);\n },\n\n async resume(this, branchJob, execution) {\n if (branchJob.status === JOB_STATUS.RESOLVED) {\n // return to continue this.downstream\n return branchJob;\n }\n\n // pass control to upper scope by ending current scope\n return execution.end(this, branchJob);\n }\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import FlowNodeModel from "../models/FlowNode";
2
+ declare const _default: {
3
+ run(this: FlowNodeModel, input: any, execution: any): Promise<{
4
+ result: import("@nocobase/database").Model<any, any>;
5
+ status: number;
6
+ }>;
7
+ };
8
+ export default _default;
@@ -0,0 +1,25 @@
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 { JOB_STATUS } from "../constants";
11
+ export default {
12
+ run(input, execution) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ const { collection, params = {} } = this.config;
15
+ const repo = this.constructor.database.getRepository(collection);
16
+ const options = execution.getParsedValue(params);
17
+ const result = yield repo.create(Object.assign(Object.assign({}, options), { transaction: execution.transaction }));
18
+ return {
19
+ result,
20
+ status: JOB_STATUS.RESOLVED
21
+ };
22
+ });
23
+ }
24
+ };
25
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/instructions/create.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,eAAe;IACP,GAAG,CAAsB,KAAK,EAAE,SAAS;;YAC7C,MAAM,EACJ,UAAU,EACV,MAAM,GAAG,EAAE,EACZ,GAAG,IAAI,CAAC,MAAM,CAAC;YAEhB,MAAM,IAAI,GAA0B,IAAI,CAAC,WAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YACzF,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACjD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,iCAC3B,OAAO,KACV,WAAW,EAAE,SAAS,CAAC,WAAW,IAClC,CAAC;YAEH,OAAO;gBACL,MAAM;gBACN,MAAM,EAAE,UAAU,CAAC,QAAQ;aAC5B,CAAC;QACJ,CAAC;KAAA;CACF,CAAA","sourcesContent":["import { JOB_STATUS } from \"../constants\";\nimport FlowNodeModel from \"../models/FlowNode\";\n\nexport default {\n async run(this: FlowNodeModel, input, execution) {\n const {\n collection,\n params = {}\n } = this.config;\n\n const repo = (<typeof FlowNodeModel>this.constructor).database.getRepository(collection);\n const options = execution.getParsedValue(params);\n const result = await repo.create({\n ...options,\n transaction: execution.transaction\n });\n\n return {\n result,\n status: JOB_STATUS.RESOLVED\n };\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import FlowNodeModel from "../models/FlowNode";
2
+ declare const _default: {
3
+ run(this: FlowNodeModel, input: any, execution: any): Promise<{
4
+ result: any;
5
+ status: number;
6
+ }>;
7
+ };
8
+ export default _default;
@@ -0,0 +1,25 @@
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 { JOB_STATUS } from "../constants";
11
+ export default {
12
+ run(input, execution) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ const { collection, params = {} } = this.config;
15
+ const repo = this.constructor.database.getRepository(collection);
16
+ const options = execution.getParsedValue(params);
17
+ const result = yield repo.destroy(Object.assign(Object.assign({}, options), { transaction: execution.transaction }));
18
+ return {
19
+ result,
20
+ status: JOB_STATUS.RESOLVED
21
+ };
22
+ });
23
+ }
24
+ };
25
+ //# sourceMappingURL=destroy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../src/instructions/destroy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,eAAe;IACP,GAAG,CAAsB,KAAK,EAAE,SAAS;;YAC7C,MAAM,EACJ,UAAU,EACV,MAAM,GAAG,EAAE,EACZ,GAAG,IAAI,CAAC,MAAM,CAAC;YAEhB,MAAM,IAAI,GAA0B,IAAI,CAAC,WAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YACzF,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACjD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,iCAC5B,OAAO,KACV,WAAW,EAAE,SAAS,CAAC,WAAW,IAClC,CAAC;YAEH,OAAO;gBACL,MAAM;gBACN,MAAM,EAAE,UAAU,CAAC,QAAQ;aAC5B,CAAC;QACJ,CAAC;KAAA;CACF,CAAA","sourcesContent":["import { JOB_STATUS } from \"../constants\";\nimport FlowNodeModel from \"../models/FlowNode\";\n\nexport default {\n async run(this: FlowNodeModel, input, execution) {\n const {\n collection,\n params = {}\n } = this.config;\n\n const repo = (<typeof FlowNodeModel>this.constructor).database.getRepository(collection);\n const options = execution.getParsedValue(params);\n const result = await repo.destroy({\n ...options,\n transaction: execution.transaction\n });\n\n return {\n result,\n status: JOB_STATUS.RESOLVED\n };\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { Registry } from '@nocobase/utils';
2
+ import ExecutionModel from '../models/Execution';
3
+ import FlowNodeModel from '../models/FlowNode';
4
+ export interface Job {
5
+ status: number;
6
+ result?: unknown;
7
+ [key: string]: unknown;
8
+ }
9
+ export declare type InstructionResult = Job | Promise<Job>;
10
+ export interface Instruction {
11
+ run(this: FlowNodeModel, input: any, execution: ExecutionModel): InstructionResult;
12
+ resume?(this: FlowNodeModel, input: any, execution: ExecutionModel): InstructionResult;
13
+ }
14
+ export declare const instructions: Registry<Instruction>;
15
+ export default instructions;
@@ -0,0 +1,20 @@
1
+ import { Registry } from '@nocobase/utils';
2
+ import prompt from './prompt';
3
+ import calculation from './calculation';
4
+ import condition from './condition';
5
+ import parallel from './parallel';
6
+ import query from './query';
7
+ import create from './create';
8
+ import update from './update';
9
+ import destroy from './destroy';
10
+ export const instructions = new Registry();
11
+ instructions.register('prompt', prompt);
12
+ instructions.register('calculation', calculation);
13
+ instructions.register('condition', condition);
14
+ instructions.register('parallel', parallel);
15
+ instructions.register('query', query);
16
+ instructions.register('create', create);
17
+ instructions.register('update', update);
18
+ instructions.register('destroy', destroy);
19
+ export default instructions;
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/instructions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAK3C,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,OAAO,MAAM,WAAW,CAAC;AA+BhC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,QAAQ,EAAe,CAAC;AAExD,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACxC,YAAY,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAClD,YAAY,CAAC,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAC9C,YAAY,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC5C,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACtC,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACxC,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACxC,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAE1C,eAAe,YAAY,CAAC","sourcesContent":["import { Registry } from '@nocobase/utils';\n\nimport ExecutionModel from '../models/Execution';\nimport FlowNodeModel from '../models/FlowNode';\n\nimport prompt from './prompt';\nimport calculation from './calculation';\nimport condition from './condition';\nimport parallel from './parallel';\nimport query from './query';\nimport create from './create';\nimport update from './update';\nimport destroy from './destroy';\n\nexport interface Job {\n status: number;\n result?: unknown;\n [key: string]: unknown;\n}\n\nexport type InstructionResult = Job | Promise<Job>;\n\n// what should a instruction do?\n// - base on input and context, do any calculations or system call (io), and produce a result or pending.\nexport interface Instruction {\n run(\n this: FlowNodeModel,\n // what should input to be?\n // - just use previously output result for convenience?\n input: any,\n // what should context to be?\n // - could be the workflow execution object (containing context data)\n execution: ExecutionModel\n ): InstructionResult;\n\n // for start node in main flow (or branch) to resume when manual sub branch triggered\n resume?(\n this: FlowNodeModel,\n input: any,\n execution: ExecutionModel\n ): InstructionResult\n}\n\nexport const instructions = new Registry<Instruction>();\n\ninstructions.register('prompt', prompt);\ninstructions.register('calculation', calculation);\ninstructions.register('condition', condition);\ninstructions.register('parallel', parallel);\ninstructions.register('query', query);\ninstructions.register('create', create);\ninstructions.register('update', update);\ninstructions.register('destroy', destroy);\n\nexport default instructions;\n"]}
@@ -0,0 +1,13 @@
1
+ import ExecutionModel from "../models/Execution";
2
+ import FlowNodeModel from "../models/FlowNode";
3
+ import JobModel from "../models/Job";
4
+ export declare const PARALLEL_MODE: {
5
+ readonly ALL: "all";
6
+ readonly ANY: "any";
7
+ readonly RACE: "race";
8
+ };
9
+ declare const _default: {
10
+ run(this: FlowNodeModel, prevJob: JobModel, execution: ExecutionModel): Promise<any>;
11
+ resume(this: any, branchJob: any, execution: ExecutionModel): Promise<any>;
12
+ };
13
+ export default _default;