@nocobase/plugin-workflow 0.11.0-alpha.1 → 0.11.1-alpha.2

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 (133) hide show
  1. package/lib/client/AddButton.js +13 -4
  2. package/lib/client/Branch.js +4 -2
  3. package/lib/client/CanvasContent.js +6 -4
  4. package/lib/client/ExecutionCanvas.js +18 -7
  5. package/lib/client/ExecutionPage.js +4 -2
  6. package/lib/client/WorkflowCanvas.js +16 -6
  7. package/lib/client/WorkflowPage.js +4 -2
  8. package/lib/client/WorkflowProvider.js +2 -2
  9. package/lib/client/components/CollectionBlockInitializer.js +3 -3
  10. package/lib/client/components/CollectionFieldset.js +7 -1
  11. package/lib/client/components/FieldsSelect.js +4 -1
  12. package/lib/client/components/NodeDescription.js +36 -22
  13. package/lib/client/index.js +3 -3
  14. package/lib/client/locale/zh-CN.d.ts +5 -1
  15. package/lib/client/locale/zh-CN.js +6 -2
  16. package/lib/client/nodes/aggregate.d.ts +6 -1
  17. package/lib/client/nodes/aggregate.js +4 -3
  18. package/lib/client/nodes/calculation.d.ts +5 -3
  19. package/lib/client/nodes/calculation.js +6 -5
  20. package/lib/client/nodes/condition.d.ts +1 -7
  21. package/lib/client/nodes/condition.js +12 -23
  22. package/lib/client/nodes/create.d.ts +2 -4
  23. package/lib/client/nodes/create.js +1 -3
  24. package/lib/client/nodes/index.d.ts +1 -2
  25. package/lib/client/nodes/index.js +24 -24
  26. package/lib/client/nodes/loop.js +19 -28
  27. package/lib/client/nodes/manual/FormBlockInitializer.js +6 -5
  28. package/lib/client/nodes/manual/SchemaConfig.d.ts +1 -2
  29. package/lib/client/nodes/manual/SchemaConfig.js +175 -21
  30. package/lib/client/nodes/manual/WorkflowTodo.js +39 -46
  31. package/lib/client/nodes/manual/forms/create.js +8 -1
  32. package/lib/client/nodes/manual/forms/custom.js +11 -4
  33. package/lib/client/nodes/manual/forms/update.js +8 -1
  34. package/lib/client/nodes/manual/index.d.ts +6 -1
  35. package/lib/client/nodes/manual/index.js +5 -4
  36. package/lib/client/nodes/parallel.js +7 -4
  37. package/lib/client/nodes/query.d.ts +2 -5
  38. package/lib/client/nodes/query.js +1 -3
  39. package/lib/client/nodes/sql.d.ts +26 -0
  40. package/lib/client/{triggers/schedule/DateFieldsSelect.js → nodes/sql.js} +37 -46
  41. package/lib/client/schemas/collection.d.ts +2 -3
  42. package/lib/client/schemas/collection.js +8 -7
  43. package/lib/client/style.d.ts +18 -13
  44. package/lib/client/style.js +312 -289
  45. package/lib/client/triggers/collection.d.ts +9 -10
  46. package/lib/client/triggers/collection.js +4 -0
  47. package/lib/client/triggers/index.d.ts +2 -3
  48. package/lib/client/triggers/index.js +10 -5
  49. package/lib/client/triggers/schedule/OnField.js +35 -23
  50. package/lib/client/triggers/schedule/ScheduleConfig.js +7 -7
  51. package/lib/client/triggers/schedule/index.d.ts +0 -1
  52. package/lib/client/triggers/schedule/index.js +31 -19
  53. package/lib/client/variable.d.ts +29 -11
  54. package/lib/client/variable.js +39 -24
  55. package/lib/server/Plugin.d.ts +1 -3
  56. package/lib/server/Plugin.js +10 -6
  57. package/lib/server/Processor.d.ts +1 -1
  58. package/lib/server/Processor.js +2 -2
  59. package/lib/server/instructions/create.d.ts +1 -1
  60. package/lib/server/instructions/create.js +13 -13
  61. package/lib/server/instructions/index.js +1 -1
  62. package/lib/server/instructions/manual/actions.js +19 -7
  63. package/lib/server/instructions/manual/forms/create.js +7 -1
  64. package/lib/server/instructions/manual/forms/update.js +7 -1
  65. package/lib/server/instructions/query.js +8 -1
  66. package/lib/server/instructions/request.d.ts +1 -1
  67. package/lib/server/instructions/request.js +4 -2
  68. package/lib/server/instructions/sql.d.ts +12 -0
  69. package/lib/server/instructions/sql.js +34 -0
  70. package/lib/server/migrations/20230710115902-manual-action-values.d.ts +4 -0
  71. package/lib/server/migrations/20230710115902-manual-action-values.js +97 -0
  72. package/lib/server/triggers/collection.js +13 -11
  73. package/lib/server/utils.d.ts +2 -0
  74. package/lib/server/utils.js +21 -0
  75. package/package.json +12 -11
  76. package/src/client/AddButton.tsx +17 -5
  77. package/src/client/Branch.tsx +4 -2
  78. package/src/client/CanvasContent.tsx +6 -4
  79. package/src/client/ExecutionCanvas.tsx +11 -13
  80. package/src/client/ExecutionPage.tsx +3 -2
  81. package/src/client/WorkflowCanvas.tsx +14 -13
  82. package/src/client/WorkflowPage.tsx +3 -2
  83. package/src/client/WorkflowProvider.tsx +2 -2
  84. package/src/client/components/CollectionBlockInitializer.tsx +3 -3
  85. package/src/client/components/CollectionFieldset.tsx +5 -3
  86. package/src/client/components/FieldsSelect.tsx +5 -1
  87. package/src/client/components/NodeDescription.tsx +30 -23
  88. package/src/client/index.tsx +3 -3
  89. package/src/client/locale/zh-CN.ts +8 -2
  90. package/src/client/nodes/aggregate.tsx +4 -4
  91. package/src/client/nodes/calculation.tsx +4 -5
  92. package/src/client/nodes/condition.tsx +7 -34
  93. package/src/client/nodes/create.tsx +0 -1
  94. package/src/client/nodes/index.tsx +21 -25
  95. package/src/client/nodes/loop.tsx +16 -31
  96. package/src/client/nodes/manual/FormBlockInitializer.tsx +6 -5
  97. package/src/client/nodes/manual/SchemaConfig.tsx +162 -18
  98. package/src/client/nodes/manual/WorkflowTodo.tsx +43 -47
  99. package/src/client/nodes/manual/forms/create.tsx +5 -1
  100. package/src/client/nodes/manual/forms/custom.tsx +7 -3
  101. package/src/client/nodes/manual/forms/update.tsx +5 -1
  102. package/src/client/nodes/manual/index.tsx +5 -5
  103. package/src/client/nodes/parallel.tsx +6 -5
  104. package/src/client/nodes/query.tsx +0 -1
  105. package/src/client/nodes/sql.tsx +37 -0
  106. package/src/client/schemas/collection.ts +6 -6
  107. package/src/client/style.tsx +324 -289
  108. package/src/client/triggers/collection.tsx +4 -0
  109. package/src/client/triggers/index.tsx +14 -10
  110. package/src/client/triggers/schedule/OnField.tsx +29 -15
  111. package/src/client/triggers/schedule/ScheduleConfig.tsx +21 -19
  112. package/src/client/triggers/schedule/index.tsx +25 -19
  113. package/src/client/variable.tsx +48 -26
  114. package/src/server/Plugin.ts +13 -9
  115. package/src/server/Processor.ts +2 -2
  116. package/src/server/__tests__/collections/categories.ts +4 -0
  117. package/src/server/__tests__/instructions/manual.test.ts +391 -72
  118. package/src/server/__tests__/instructions/request.test.ts +30 -0
  119. package/src/server/__tests__/instructions/sql.test.ts +162 -0
  120. package/src/server/__tests__/triggers/collection.test.ts +35 -0
  121. package/src/server/instructions/create.ts +13 -11
  122. package/src/server/instructions/index.ts +1 -0
  123. package/src/server/instructions/manual/actions.ts +16 -4
  124. package/src/server/instructions/manual/forms/create.ts +2 -1
  125. package/src/server/instructions/manual/forms/update.ts +3 -2
  126. package/src/server/instructions/query.ts +12 -1
  127. package/src/server/instructions/request.ts +2 -1
  128. package/src/server/instructions/sql.ts +25 -0
  129. package/src/server/migrations/20230710115902-manual-action-values.ts +78 -0
  130. package/src/server/triggers/collection.ts +15 -11
  131. package/src/server/utils.ts +17 -0
  132. package/lib/client/triggers/schedule/DateFieldsSelect.d.ts +0 -2
  133. package/src/client/triggers/schedule/DateFieldsSelect.tsx +0 -28
@@ -1,7 +1,7 @@
1
1
  import { BlockInitializers, SchemaInitializerItemOptions, useCollectionManager, useCompile } from '@nocobase/client';
2
2
 
3
3
  import { CollectionBlockInitializer } from '../../components/CollectionBlockInitializer';
4
- import { getCollectionFieldOptions } from '../../variable';
4
+ import { defaultFieldNames, getCollectionFieldOptions } from '../../variable';
5
5
  import { NAMESPACE } from '../../locale';
6
6
  import { SchemaConfig, SchemaConfigButton } from './SchemaConfig';
7
7
  import { ModeConfig } from './ModeConfig';
@@ -85,7 +85,7 @@ export default {
85
85
  ModeConfig,
86
86
  AssigneesSelect,
87
87
  },
88
- useVariables({ id, title, config }, { types }) {
88
+ useVariables({ id, title, config }, { types, fieldNames = defaultFieldNames }) {
89
89
  const compile = useCompile();
90
90
  const { getCollectionFields } = useCollectionManager();
91
91
  const formKeys = Object.keys(config.forms ?? {});
@@ -119,9 +119,9 @@ export default {
119
119
 
120
120
  return options.length
121
121
  ? {
122
- value: `${id}`,
123
- label: title,
124
- children: options,
122
+ [fieldNames.value]: `${id}`,
123
+ [fieldNames.label]: title,
124
+ [fieldNames.children]: options,
125
125
  }
126
126
  : null;
127
127
  },
@@ -4,10 +4,10 @@ import { Button, Tooltip } from 'antd';
4
4
  import React, { useState } from 'react';
5
5
  import { NodeDefaultView } from '.';
6
6
  import { Branch } from '../Branch';
7
- import { RadioWithTooltip } from '../components/RadioWithTooltip';
8
7
  import { useFlowContext } from '../FlowContext';
9
- import { lang, NAMESPACE } from '../locale';
10
- import { branchBlockClass, nodeSubtreeClass } from '../style';
8
+ import { RadioWithTooltip } from '../components/RadioWithTooltip';
9
+ import { NAMESPACE, lang } from '../locale';
10
+ import useStyles from '../style';
11
11
 
12
12
  export default {
13
13
  title: `{{t("Parallel branch", { ns: "${NAMESPACE}" })}}`,
@@ -44,6 +44,7 @@ export default {
44
44
  },
45
45
  view: {},
46
46
  component: function Component({ data }) {
47
+ const { styles } = useStyles();
47
48
  const {
48
49
  id,
49
50
  config: { mode },
@@ -64,8 +65,8 @@ export default {
64
65
 
65
66
  return (
66
67
  <NodeDefaultView data={data}>
67
- <div className={cx(nodeSubtreeClass)}>
68
- <div className={cx(branchBlockClass)}>
68
+ <div className={cx(styles.nodeSubtreeClass)}>
69
+ <div className={cx(styles.branchBlockClass)}>
69
70
  {branches.map((branch) => (
70
71
  <Branch key={branch.id} from={data} entry={branch} branchIndex={branch.branchIndex} />
71
72
  ))}
@@ -41,7 +41,6 @@ export default {
41
41
  },
42
42
  components: {
43
43
  FilterDynamicComponent,
44
- FieldsSelect,
45
44
  },
46
45
  useVariables({ id, title, config }, options) {
47
46
  const compile = useCompile();
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+
3
+ import { Variable, css } from '@nocobase/client';
4
+
5
+ import { NAMESPACE } from '../locale';
6
+ import { useWorkflowVariableOptions } from '../variable';
7
+
8
+ export default {
9
+ title: `{{t("SQL action", { ns: "${NAMESPACE}" })}}`,
10
+ type: 'sql',
11
+ group: 'extended',
12
+ description: `{{t("Execute a SQL statement in database.", { ns: "${NAMESPACE}" })}}`,
13
+ fieldset: {
14
+ sql: {
15
+ type: 'string',
16
+ required: true,
17
+ title: 'SQL',
18
+ description: `{{t("Usage of SQL query result is not supported yet.", { ns: "${NAMESPACE}" })}}`,
19
+ 'x-decorator': 'FormItem',
20
+ 'x-component': 'SQLInput',
21
+ 'x-component-props': {
22
+ rows: 20,
23
+ className: css`
24
+ font-size: 80%;
25
+ font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
26
+ `,
27
+ },
28
+ },
29
+ },
30
+ scope: {},
31
+ components: {
32
+ SQLInput(props) {
33
+ const scope = useWorkflowVariableOptions();
34
+ return <Variable.RawTextArea scope={scope} {...props} />;
35
+ },
36
+ },
37
+ };
@@ -52,15 +52,15 @@ export const filter = {
52
52
  export const appends = {
53
53
  type: 'array',
54
54
  title: `{{t("Preload associations", { ns: "${NAMESPACE}" })}}`,
55
- description: `{{t("Please select the associated fields that need to be accessed in subsequent nodes", { ns: "${NAMESPACE}" })}}`,
55
+ description: `{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${NAMESPACE}" })}}`,
56
56
  'x-decorator': 'FormItem',
57
- 'x-component': 'FieldsSelect',
57
+ 'x-component': 'AppendsTreeSelect',
58
58
  'x-component-props': {
59
- mode: 'multiple',
60
- placeholder: '{{t("Select field")}}',
61
- filter(field) {
62
- return ['linkTo', 'belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type);
59
+ useCollection() {
60
+ const { values } = useForm();
61
+ return values?.collection;
63
62
  },
63
+ className: 'full-width',
64
64
  },
65
65
  'x-reactions': [
66
66
  {