@nocobase/plugin-workflow 0.7.0-alpha.34 → 0.7.0-alpha.57

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 (132) hide show
  1. package/lib/actions/index.js +31 -32
  2. package/lib/actions/nodes.js +310 -182
  3. package/lib/actions/workflows.js +260 -157
  4. package/lib/calculators/index.js +142 -90
  5. package/lib/collections/executions.js +40 -43
  6. package/lib/collections/flow_nodes.js +60 -65
  7. package/lib/collections/jobs.js +45 -47
  8. package/lib/collections/workflows.js +78 -87
  9. package/lib/constants.js +22 -17
  10. package/lib/index.js +71 -22
  11. package/lib/instructions/calculation.js +34 -29
  12. package/lib/instructions/condition.js +94 -87
  13. package/lib/instructions/create.js +43 -26
  14. package/lib/instructions/destroy.js +42 -25
  15. package/lib/instructions/index.js +46 -25
  16. package/lib/instructions/parallel.js +99 -84
  17. package/lib/instructions/prompt.js +21 -13
  18. package/lib/instructions/query.js +47 -29
  19. package/lib/instructions/update.js +44 -25
  20. package/lib/models/Execution.js +401 -248
  21. package/lib/models/FlowNode.js +18 -5
  22. package/lib/models/Job.js +18 -5
  23. package/lib/models/Workflow.js +132 -88
  24. package/lib/server.js +93 -66
  25. package/lib/triggers/collection.js +113 -51
  26. package/lib/triggers/index.js +25 -11
  27. package/package.json +7 -12
  28. package/esm/actions/index.d.ts +0 -1
  29. package/esm/actions/index.js +0 -14
  30. package/esm/actions/index.js.map +0 -1
  31. package/esm/actions/nodes.d.ts +0 -4
  32. package/esm/actions/nodes.js +0 -187
  33. package/esm/actions/nodes.js.map +0 -1
  34. package/esm/actions/workflows.d.ts +0 -3
  35. package/esm/actions/workflows.js +0 -163
  36. package/esm/actions/workflows.js.map +0 -1
  37. package/esm/calculators/index.d.ts +0 -38
  38. package/esm/calculators/index.js +0 -128
  39. package/esm/calculators/index.js.map +0 -1
  40. package/esm/collections/executions.d.ts +0 -3
  41. package/esm/collections/executions.js +0 -43
  42. package/esm/collections/executions.js.map +0 -1
  43. package/esm/collections/flow_nodes.d.ts +0 -3
  44. package/esm/collections/flow_nodes.js +0 -65
  45. package/esm/collections/flow_nodes.js.map +0 -1
  46. package/esm/collections/jobs.d.ts +0 -3
  47. package/esm/collections/jobs.js +0 -47
  48. package/esm/collections/jobs.js.map +0 -1
  49. package/esm/collections/workflows.d.ts +0 -3
  50. package/esm/collections/workflows.js +0 -87
  51. package/esm/collections/workflows.js.map +0 -1
  52. package/esm/constants.d.ts +0 -17
  53. package/esm/constants.js +0 -18
  54. package/esm/constants.js.map +0 -1
  55. package/esm/index.d.ts +0 -5
  56. package/esm/index.js +0 -6
  57. package/esm/index.js.map +0 -1
  58. package/esm/instructions/calculation.d.ts +0 -8
  59. package/esm/instructions/calculation.js +0 -55
  60. package/esm/instructions/calculation.js.map +0 -1
  61. package/esm/instructions/condition.d.ts +0 -5
  62. package/esm/instructions/condition.js +0 -99
  63. package/esm/instructions/condition.js.map +0 -1
  64. package/esm/instructions/create.d.ts +0 -8
  65. package/esm/instructions/create.js +0 -26
  66. package/esm/instructions/create.js.map +0 -1
  67. package/esm/instructions/destroy.d.ts +0 -8
  68. package/esm/instructions/destroy.js +0 -25
  69. package/esm/instructions/destroy.js.map +0 -1
  70. package/esm/instructions/index.d.ts +0 -15
  71. package/esm/instructions/index.js +0 -20
  72. package/esm/instructions/index.js.map +0 -1
  73. package/esm/instructions/parallel.d.ts +0 -13
  74. package/esm/instructions/parallel.js +0 -88
  75. package/esm/instructions/parallel.js.map +0 -1
  76. package/esm/instructions/prompt.d.ts +0 -7
  77. package/esm/instructions/prompt.js +0 -13
  78. package/esm/instructions/prompt.js.map +0 -1
  79. package/esm/instructions/query.d.ts +0 -8
  80. package/esm/instructions/query.js +0 -29
  81. package/esm/instructions/query.js.map +0 -1
  82. package/esm/instructions/update.d.ts +0 -9
  83. package/esm/instructions/update.js +0 -25
  84. package/esm/instructions/update.js.map +0 -1
  85. package/esm/models/Execution.d.ts +0 -51
  86. package/esm/models/Execution.js +0 -256
  87. package/esm/models/Execution.js.map +0 -1
  88. package/esm/models/FlowNode.d.ts +0 -17
  89. package/esm/models/FlowNode.js +0 -4
  90. package/esm/models/FlowNode.js.map +0 -1
  91. package/esm/models/Job.d.ts +0 -15
  92. package/esm/models/Job.js +0 -4
  93. package/esm/models/Job.js.map +0 -1
  94. package/esm/models/Workflow.d.ts +0 -29
  95. package/esm/models/Workflow.js +0 -88
  96. package/esm/models/Workflow.js.map +0 -1
  97. package/esm/server.d.ts +0 -5
  98. package/esm/server.js +0 -62
  99. package/esm/server.js.map +0 -1
  100. package/esm/triggers/collection.d.ts +0 -12
  101. package/esm/triggers/collection.js +0 -61
  102. package/esm/triggers/collection.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/lib/actions/index.js.map +0 -1
  107. package/lib/actions/nodes.js.map +0 -1
  108. package/lib/actions/workflows.js.map +0 -1
  109. package/lib/calculators/index.js.map +0 -1
  110. package/lib/collections/executions.js.map +0 -1
  111. package/lib/collections/flow_nodes.js.map +0 -1
  112. package/lib/collections/jobs.js.map +0 -1
  113. package/lib/collections/workflows.js.map +0 -1
  114. package/lib/constants.js.map +0 -1
  115. package/lib/index.js.map +0 -1
  116. package/lib/instructions/calculation.js.map +0 -1
  117. package/lib/instructions/condition.js.map +0 -1
  118. package/lib/instructions/create.js.map +0 -1
  119. package/lib/instructions/destroy.js.map +0 -1
  120. package/lib/instructions/index.js.map +0 -1
  121. package/lib/instructions/parallel.js.map +0 -1
  122. package/lib/instructions/prompt.js.map +0 -1
  123. package/lib/instructions/query.js.map +0 -1
  124. package/lib/instructions/update.js.map +0 -1
  125. package/lib/models/Execution.js.map +0 -1
  126. package/lib/models/FlowNode.js.map +0 -1
  127. package/lib/models/Job.js.map +0 -1
  128. package/lib/models/Workflow.js.map +0 -1
  129. package/lib/server.js.map +0 -1
  130. package/lib/triggers/collection.js.map +0 -1
  131. package/lib/triggers/index.js.map +0 -1
  132. package/tsconfig.build.json +0 -9
@@ -1,3 +0,0 @@
1
- import { CollectionOptions } from '@nocobase/database';
2
- declare const _default: CollectionOptions;
3
- export default _default;
@@ -1,43 +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
- type: 'uuid',
20
- name: 'transaction',
21
- defaultValue: null
22
- },
23
- {
24
- interface: 'linkTo',
25
- type: 'hasMany',
26
- name: 'jobs',
27
- title: '流程记录'
28
- },
29
- {
30
- interface: 'json',
31
- type: 'jsonb',
32
- name: 'context',
33
- title: '上下文数据'
34
- },
35
- {
36
- interface: 'select',
37
- type: 'integer',
38
- name: 'status',
39
- title: '状态'
40
- }
41
- ]
42
- };
43
- //# 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,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,aAAa;YACnB,YAAY,EAAE,IAAI;SACnB;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 type: 'uuid',\n name: 'transaction',\n defaultValue: null\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,65 +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
- // Note: 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
- },
56
- {
57
- interface: 'json',
58
- type: 'jsonb',
59
- name: 'config',
60
- title: '配置',
61
- defaultValue: {}
62
- }
63
- ]
64
- };
65
- //# 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,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,qBAAqB;QACrB,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;SACZ;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 // Note: 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 },\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,87 +0,0 @@
1
- export default {
2
- name: 'workflows',
3
- model: 'WorkflowModel',
4
- title: '自动化',
5
- fields: [
6
- {
7
- name: 'key',
8
- type: 'uid'
9
- },
10
- {
11
- interface: 'string',
12
- type: 'string',
13
- name: 'title',
14
- title: '工作流名称',
15
- required: true
16
- },
17
- {
18
- interface: 'boolean',
19
- type: 'boolean',
20
- name: 'enabled',
21
- title: '启用',
22
- defaultValue: false
23
- },
24
- {
25
- interface: 'textarea',
26
- type: 'text',
27
- name: 'description',
28
- title: '描述'
29
- },
30
- {
31
- interface: 'select',
32
- type: 'string',
33
- title: '触发方式',
34
- name: 'type',
35
- required: true
36
- },
37
- {
38
- interface: 'json',
39
- type: 'jsonb',
40
- title: '触发配置',
41
- name: 'config',
42
- required: true,
43
- defaultValue: {}
44
- },
45
- {
46
- interface: 'boolean',
47
- type: 'boolean',
48
- title: '使用事务',
49
- name: 'useTransaction',
50
- defaultValue: true
51
- },
52
- {
53
- interface: 'linkTo',
54
- type: 'hasMany',
55
- name: 'nodes',
56
- target: 'flow_nodes',
57
- title: '流程节点'
58
- },
59
- {
60
- interface: 'linkTo',
61
- type: 'hasMany',
62
- name: 'executions',
63
- target: 'executions',
64
- title: '触发执行'
65
- },
66
- {
67
- type: 'boolean',
68
- name: 'executed',
69
- defaultValue: false
70
- },
71
- {
72
- type: 'boolean',
73
- name: 'current',
74
- defaultValue: false
75
- },
76
- {
77
- type: 'hasMany',
78
- name: 'revisions',
79
- target: 'workflows',
80
- foreignKey: 'key',
81
- sourceKey: 'key',
82
- // NOTE: no constraints needed here because tricky self-referencing
83
- constraints: false
84
- }
85
- ]
86
- };
87
- //# 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,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,KAAK;SACZ;QACD;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;YACX,YAAY,EAAE,KAAK;SACpB;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;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,UAAU;YAChB,YAAY,EAAE,KAAK;SACpB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,KAAK;SACpB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,mEAAmE;YACnE,WAAW,EAAE,KAAK;SACnB;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'workflows',\n model: 'WorkflowModel',\n title: '自动化',\n fields: [\n {\n name: 'key',\n type: 'uid'\n },\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 defaultValue: false\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 type: 'boolean',\n name: 'executed',\n defaultValue: false\n },\n {\n type: 'boolean',\n name: 'current',\n defaultValue: false\n },\n {\n type: 'hasMany',\n name: 'revisions',\n target: 'workflows',\n foreignKey: 'key',\n sourceKey: 'key',\n // NOTE: no constraints needed here because tricky self-referencing\n constraints: false\n }\n ]\n} as CollectionOptions;\n"]}
@@ -1,17 +0,0 @@
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
- };
package/esm/constants.js DELETED
@@ -1,18 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,5 +0,0 @@
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 DELETED
@@ -1,6 +0,0 @@
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
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
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"]}
@@ -1,8 +0,0 @@
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;
@@ -1,55 +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 { 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
@@ -1 +0,0 @@
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"]}
@@ -1,5 +0,0 @@
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;
@@ -1,99 +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 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
@@ -1 +0,0 @@
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"]}
@@ -1,8 +0,0 @@
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;
@@ -1,26 +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 { 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.tx }));
18
- return {
19
- // NOTE: get() for non-proxied instance (#380)
20
- result: result.get(),
21
- status: JOB_STATUS.RESOLVED
22
- };
23
- });
24
- }
25
- };
26
- //# sourceMappingURL=create.js.map
@@ -1 +0,0 @@
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,EAAE,IACzB,CAAC;YAEH,OAAO;gBACL,8CAA8C;gBAC9C,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE;gBACpB,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.tx\n });\n\n return {\n // NOTE: get() for non-proxied instance (#380)\n result: result.get(),\n status: JOB_STATUS.RESOLVED\n };\n }\n}\n"]}
@@ -1,8 +0,0 @@
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;
@@ -1,25 +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 { 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.tx }));
18
- return {
19
- result,
20
- status: JOB_STATUS.RESOLVED
21
- };
22
- });
23
- }
24
- };
25
- //# sourceMappingURL=destroy.js.map
@@ -1 +0,0 @@
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,EAAE,IACzB,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.tx\n });\n\n return {\n result,\n status: JOB_STATUS.RESOLVED\n };\n }\n}\n"]}